Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onflow/config

Package Overview
Dependencies
Maintainers
16
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/config - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3-alpha.0

9

CHANGELOG.md
# @onflow/config
## 1.0.3-alpha.0
### Patch Changes
- [#1227](https://github.com/onflow/fcl-js/pull/1227) [`352f1460`](https://github.com/onflow/fcl-js/commit/352f1460a2f34d228a74fa4bbc6fcf6e68a968b6) Thanks [@jribbink](https://github.com/jribbink)! - Switch to fcl-bundle instead of microbundle for build scripts
- Updated dependencies [[`352f1460`](https://github.com/onflow/fcl-js/commit/352f1460a2f34d228a74fa4bbc6fcf6e68a968b6)]:
- @onflow/util-actor@1.1.1-alpha.0
## 1.0.2

@@ -4,0 +13,0 @@

261

dist/config.js

@@ -1,58 +0,23 @@

var utilActor = require('@onflow/util-actor');
'use strict';
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
Object.defineProperty(exports, '__esModule', { value: true });
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
var _toArray = require('@babel/runtime/helpers/toArray');
var _typeof = require('@babel/runtime/helpers/typeof');
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
var _regeneratorRuntime = require('@babel/runtime/regenerator');
var utilActor = require('@onflow/util-actor');
return target;
};
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
return _extends.apply(this, arguments);
}
var _toArray__default = /*#__PURE__*/_interopDefaultLegacy(_toArray);
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
var _iteratorSymbol = /*#__PURE__*/typeof Symbol !== "undefined" ? Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator")) : "@@iterator";
var _asyncIteratorSymbol = /*#__PURE__*/typeof Symbol !== "undefined" ? Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator")) : "@@asyncIterator";
function _catch(body, recover) {
try {
var result = body();
} catch (e) {
return recover(e);
}
if (result && result.then) {
return result.then(void 0, recover);
}
return result;
}
var _HANDLERS;
var first = function first(wants, fallback) {
if (wants === void 0) {
wants = [];
}
try {
if (!wants.length) return Promise.resolve(fallback);
var _wants = wants,
head = _wants[0],
rest = _wants.slice(1);
return Promise.resolve(get(head)).then(function (ret) {
return ret == null ? first(rest, fallback) : ret;
});
} catch (e) {
return Promise.reject(e);
}
};
var NAME = "config";

@@ -72,3 +37,3 @@ var PUT = "PUT_CONFIG";

var HANDLERS = (_HANDLERS = {}, _HANDLERS[PUT] = function (ctx, _letter, _ref) {
var HANDLERS = (_HANDLERS = {}, _defineProperty__default["default"](_HANDLERS, PUT, function (ctx, _letter, _ref) {
var key = _ref.key,

@@ -78,4 +43,4 @@ value = _ref.value;

ctx.put(key, value);
ctx.broadcast(UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[GET] = function (ctx, letter, _ref2) {
ctx.broadcast(UPDATED, _objectSpread__default["default"]({}, ctx.all()));
}), _defineProperty__default["default"](_HANDLERS, GET, function (ctx, letter, _ref2) {
var key = _ref2.key,

@@ -85,5 +50,5 @@ fallback = _ref2.fallback;

letter.reply(ctx.get(key, fallback));
}, _HANDLERS[GET_ALL] = function (ctx, letter) {
letter.reply(_extends({}, ctx.all()));
}, _HANDLERS[UPDATE] = function (ctx, letter, _ref3) {
}), _defineProperty__default["default"](_HANDLERS, GET_ALL, function (ctx, letter) {
letter.reply(_objectSpread__default["default"]({}, ctx.all()));
}), _defineProperty__default["default"](_HANDLERS, UPDATE, function (ctx, letter, _ref3) {
var key = _ref3.key,

@@ -93,9 +58,9 @@ fn = _ref3.fn;

ctx.update(key, fn || identity);
ctx.broadcast(UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[DELETE] = function (ctx, letter, _ref4) {
ctx.broadcast(UPDATED, _objectSpread__default["default"]({}, ctx.all()));
}), _defineProperty__default["default"](_HANDLERS, DELETE, function (ctx, letter, _ref4) {
var key = _ref4.key;
if (key == null) throw new Error("Missing 'key' for config/delete");
ctx["delete"](key);
ctx.broadcast(UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[CLEAR] = function (ctx, letter) {
ctx.broadcast(UPDATED, _objectSpread__default["default"]({}, ctx.all()));
}), _defineProperty__default["default"](_HANDLERS, CLEAR, function (ctx, letter) {
var keys = Object.keys(ctx.all());

@@ -108,13 +73,13 @@

ctx.broadcast(UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[WHERE] = function (ctx, letter, _ref5) {
ctx.broadcast(UPDATED, _objectSpread__default["default"]({}, ctx.all()));
}), _defineProperty__default["default"](_HANDLERS, WHERE, function (ctx, letter, _ref5) {
var pattern = _ref5.pattern;
if (pattern == null) throw new Error("Missing 'pattern' for config/where");
letter.reply(ctx.where(pattern));
}, _HANDLERS[utilActor.SUBSCRIBE] = function (ctx, letter) {
}), _defineProperty__default["default"](_HANDLERS, utilActor.SUBSCRIBE, function (ctx, letter) {
ctx.subscribe(letter.from);
ctx.send(letter.from, UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[utilActor.UNSUBSCRIBE] = function (ctx, letter) {
ctx.send(letter.from, UPDATED, _objectSpread__default["default"]({}, ctx.all()));
}), _defineProperty__default["default"](_HANDLERS, utilActor.UNSUBSCRIBE, function (ctx, letter) {
ctx.unsubscribe(letter.from);
}, _HANDLERS);
}), _HANDLERS);
utilActor.spawn(HANDLERS, NAME);

@@ -140,2 +105,58 @@

function first() {
return _first.apply(this, arguments);
}
function _first() {
_first = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
var wants,
fallback,
_wants,
head,
rest,
ret,
_args2 = arguments;
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
wants = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : [];
fallback = _args2.length > 1 ? _args2[1] : undefined;
if (wants.length) {
_context2.next = 4;
break;
}
return _context2.abrupt("return", fallback);
case 4:
_wants = _toArray__default["default"](wants), head = _wants[0], rest = _wants.slice(1);
_context2.next = 7;
return get(head);
case 7:
ret = _context2.sent;
if (!(ret == null)) {
_context2.next = 10;
break;
}
return _context2.abrupt("return", first(rest, fallback));
case 10:
return _context2.abrupt("return", ret);
case 11:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return _first.apply(this, arguments);
}
function all() {

@@ -148,7 +169,4 @@ return utilActor.send(NAME, GET_ALL, null, {

function update(key, fn) {
if (fn === void 0) {
fn = identity;
}
function update(key) {
var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;
utilActor.send(NAME, UPDATE, {

@@ -188,3 +206,3 @@ key: key,

function config(values) {
if (values != null && typeof values === "object") {
if (values != null && _typeof__default["default"](values) === "object") {
Object.keys(values).map(function (d) {

@@ -222,40 +240,67 @@ return put(d, values[d]);

function overload(opts, callback) {
if (opts === void 0) {
opts = {};
}
function overload() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
return new Promise( /*#__PURE__*/function () {
var _ref6 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(resolve, reject) {
var oldConfig, result;
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return all();
if (callback === void 0) {
callback = noop;
}
case 2:
oldConfig = _context.sent;
_context.prev = 3;
config(opts);
_context.t0 = callback;
_context.next = 8;
return all();
return new Promise(function (resolve, reject) {
try {
return Promise.resolve(all()).then(function (oldConfig) {
var _temp = _catch(function () {
config(opts);
var _callback = callback;
return Promise.resolve(all()).then(function (_all) {
return Promise.resolve(_callback(_all)).then(function (result) {
return Promise.resolve(clearConfig()).then(function () {
return Promise.resolve(config(oldConfig)).then(function () {
resolve(result);
});
});
});
});
}, function (error) {
return Promise.resolve(clearConfig()).then(function () {
return Promise.resolve(config(oldConfig)).then(function () {
reject(error);
});
});
});
case 8:
_context.t1 = _context.sent;
_context.next = 11;
return (0, _context.t0)(_context.t1);
if (_temp && _temp.then) return _temp.then(function () {});
});
} catch (e) {
return Promise.reject(e);
}
});
case 11:
result = _context.sent;
_context.next = 14;
return clearConfig();
case 14:
_context.next = 16;
return config(oldConfig);
case 16:
resolve(result);
_context.next = 26;
break;
case 19:
_context.prev = 19;
_context.t2 = _context["catch"](3);
_context.next = 23;
return clearConfig();
case 23:
_context.next = 25;
return config(oldConfig);
case 25:
reject(_context.t2);
case 26:
case "end":
return _context.stop();
}
}
}, _callee, null, [[3, 19]]);
}));
return function (_x, _x2) {
return _ref6.apply(this, arguments);
};
}());
}

@@ -262,0 +307,0 @@

@@ -0,58 +1,10 @@

import _toArray from '@babel/runtime/helpers/toArray';
import _typeof from '@babel/runtime/helpers/typeof';
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
import _regeneratorRuntime from '@babel/runtime/regenerator';
import { SUBSCRIBE, UNSUBSCRIBE, spawn, send, subscriber } from '@onflow/util-actor';
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
var _iteratorSymbol = /*#__PURE__*/typeof Symbol !== "undefined" ? Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator")) : "@@iterator";
var _asyncIteratorSymbol = /*#__PURE__*/typeof Symbol !== "undefined" ? Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator")) : "@@asyncIterator";
function _catch(body, recover) {
try {
var result = body();
} catch (e) {
return recover(e);
}
if (result && result.then) {
return result.then(void 0, recover);
}
return result;
}
var _HANDLERS;
var first = function first(wants, fallback) {
if (wants === void 0) {
wants = [];
}
try {
if (!wants.length) return Promise.resolve(fallback);
var _wants = wants,
head = _wants[0],
rest = _wants.slice(1);
return Promise.resolve(get(head)).then(function (ret) {
return ret == null ? first(rest, fallback) : ret;
});
} catch (e) {
return Promise.reject(e);
}
};
var NAME = "config";

@@ -72,3 +24,3 @@ var PUT = "PUT_CONFIG";

var HANDLERS = (_HANDLERS = {}, _HANDLERS[PUT] = function (ctx, _letter, _ref) {
var HANDLERS = (_HANDLERS = {}, _defineProperty(_HANDLERS, PUT, function (ctx, _letter, _ref) {
var key = _ref.key,

@@ -78,4 +30,4 @@ value = _ref.value;

ctx.put(key, value);
ctx.broadcast(UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[GET] = function (ctx, letter, _ref2) {
ctx.broadcast(UPDATED, _objectSpread({}, ctx.all()));
}), _defineProperty(_HANDLERS, GET, function (ctx, letter, _ref2) {
var key = _ref2.key,

@@ -85,5 +37,5 @@ fallback = _ref2.fallback;

letter.reply(ctx.get(key, fallback));
}, _HANDLERS[GET_ALL] = function (ctx, letter) {
letter.reply(_extends({}, ctx.all()));
}, _HANDLERS[UPDATE] = function (ctx, letter, _ref3) {
}), _defineProperty(_HANDLERS, GET_ALL, function (ctx, letter) {
letter.reply(_objectSpread({}, ctx.all()));
}), _defineProperty(_HANDLERS, UPDATE, function (ctx, letter, _ref3) {
var key = _ref3.key,

@@ -93,9 +45,9 @@ fn = _ref3.fn;

ctx.update(key, fn || identity);
ctx.broadcast(UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[DELETE] = function (ctx, letter, _ref4) {
ctx.broadcast(UPDATED, _objectSpread({}, ctx.all()));
}), _defineProperty(_HANDLERS, DELETE, function (ctx, letter, _ref4) {
var key = _ref4.key;
if (key == null) throw new Error("Missing 'key' for config/delete");
ctx["delete"](key);
ctx.broadcast(UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[CLEAR] = function (ctx, letter) {
ctx.broadcast(UPDATED, _objectSpread({}, ctx.all()));
}), _defineProperty(_HANDLERS, CLEAR, function (ctx, letter) {
var keys = Object.keys(ctx.all());

@@ -108,13 +60,13 @@

ctx.broadcast(UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[WHERE] = function (ctx, letter, _ref5) {
ctx.broadcast(UPDATED, _objectSpread({}, ctx.all()));
}), _defineProperty(_HANDLERS, WHERE, function (ctx, letter, _ref5) {
var pattern = _ref5.pattern;
if (pattern == null) throw new Error("Missing 'pattern' for config/where");
letter.reply(ctx.where(pattern));
}, _HANDLERS[SUBSCRIBE] = function (ctx, letter) {
}), _defineProperty(_HANDLERS, SUBSCRIBE, function (ctx, letter) {
ctx.subscribe(letter.from);
ctx.send(letter.from, UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[UNSUBSCRIBE] = function (ctx, letter) {
ctx.send(letter.from, UPDATED, _objectSpread({}, ctx.all()));
}), _defineProperty(_HANDLERS, UNSUBSCRIBE, function (ctx, letter) {
ctx.unsubscribe(letter.from);
}, _HANDLERS);
}), _HANDLERS);
spawn(HANDLERS, NAME);

@@ -140,2 +92,58 @@

function first() {
return _first.apply(this, arguments);
}
function _first() {
_first = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
var wants,
fallback,
_wants,
head,
rest,
ret,
_args2 = arguments;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
wants = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : [];
fallback = _args2.length > 1 ? _args2[1] : undefined;
if (wants.length) {
_context2.next = 4;
break;
}
return _context2.abrupt("return", fallback);
case 4:
_wants = _toArray(wants), head = _wants[0], rest = _wants.slice(1);
_context2.next = 7;
return get(head);
case 7:
ret = _context2.sent;
if (!(ret == null)) {
_context2.next = 10;
break;
}
return _context2.abrupt("return", first(rest, fallback));
case 10:
return _context2.abrupt("return", ret);
case 11:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return _first.apply(this, arguments);
}
function all() {

@@ -148,7 +156,4 @@ return send(NAME, GET_ALL, null, {

function update(key, fn) {
if (fn === void 0) {
fn = identity;
}
function update(key) {
var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;
send(NAME, UPDATE, {

@@ -188,3 +193,3 @@ key: key,

function config(values) {
if (values != null && typeof values === "object") {
if (values != null && _typeof(values) === "object") {
Object.keys(values).map(function (d) {

@@ -222,40 +227,67 @@ return put(d, values[d]);

function overload(opts, callback) {
if (opts === void 0) {
opts = {};
}
function overload() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
return new Promise( /*#__PURE__*/function () {
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve, reject) {
var oldConfig, result;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return all();
if (callback === void 0) {
callback = noop;
}
case 2:
oldConfig = _context.sent;
_context.prev = 3;
config(opts);
_context.t0 = callback;
_context.next = 8;
return all();
return new Promise(function (resolve, reject) {
try {
return Promise.resolve(all()).then(function (oldConfig) {
var _temp = _catch(function () {
config(opts);
var _callback = callback;
return Promise.resolve(all()).then(function (_all) {
return Promise.resolve(_callback(_all)).then(function (result) {
return Promise.resolve(clearConfig()).then(function () {
return Promise.resolve(config(oldConfig)).then(function () {
resolve(result);
});
});
});
});
}, function (error) {
return Promise.resolve(clearConfig()).then(function () {
return Promise.resolve(config(oldConfig)).then(function () {
reject(error);
});
});
});
case 8:
_context.t1 = _context.sent;
_context.next = 11;
return (0, _context.t0)(_context.t1);
if (_temp && _temp.then) return _temp.then(function () {});
});
} catch (e) {
return Promise.reject(e);
}
});
case 11:
result = _context.sent;
_context.next = 14;
return clearConfig();
case 14:
_context.next = 16;
return config(oldConfig);
case 16:
resolve(result);
_context.next = 26;
break;
case 19:
_context.prev = 19;
_context.t2 = _context["catch"](3);
_context.next = 23;
return clearConfig();
case 23:
_context.next = 25;
return config(oldConfig);
case 25:
reject(_context.t2);
case 26:
case "end":
return _context.stop();
}
}
}, _callee, null, [[3, 19]]);
}));
return function (_x, _x2) {
return _ref6.apply(this, arguments);
};
}());
}

@@ -262,0 +294,0 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@onflow/util-actor')) :
typeof define === 'function' && define.amd ? define(['exports', '@onflow/util-actor'], factory) :
(global = global || self, factory(global.config = {}, global.utilActor));
}(this, (function (exports, utilActor) {
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.onflowConfig = {}));
})(this, (function (exports) { 'use strict';
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) {
arr2[i] = arr[i];
}
return arr2;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _toArray(arr) {
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
}
function _typeof$1(obj) {
"@babel/helpers - typeof";
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, _typeof$1(obj);
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
}
return target;
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
return _extends.apply(this, arguments);
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
var _iteratorSymbol = /*#__PURE__*/typeof Symbol !== "undefined" ? Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator")) : "@@iterator";
var _asyncIteratorSymbol = /*#__PURE__*/typeof Symbol !== "undefined" ? Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator")) : "@@asyncIterator";
function _catch(body, recover) {
try {
var result = body();
} catch (e) {
return recover(e);
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
if (result && result.then) {
return result.then(void 0, recover);
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return result;
return target;
}
var _HANDLERS;
var regeneratorRuntime$1 = {exports: {}};
var first = function first(wants, fallback) {
if (wants === void 0) {
wants = [];
var _typeof = {exports: {}};
(function (module) {
function _typeof(obj) {
"@babel/helpers - typeof";
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
}
try {
if (!wants.length) return Promise.resolve(fallback);
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
})(_typeof);
var _wants = wants,
head = _wants[0],
rest = _wants.slice(1);
(function (module) {
var _typeof$1 = _typeof.exports["default"];
return Promise.resolve(get(head)).then(function (ret) {
return ret == null ? first(rest, fallback) : ret;
function _regeneratorRuntime() {
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
return exports;
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
var exports = {},
Op = Object.prototype,
hasOwn = Op.hasOwnProperty,
$Symbol = "function" == typeof Symbol ? Symbol : {},
iteratorSymbol = $Symbol.iterator || "@@iterator",
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
function define(obj, key, value) {
return Object.defineProperty(obj, key, {
value: value,
enumerable: !0,
configurable: !0,
writable: !0
}), obj[key];
}
try {
define({}, "");
} catch (err) {
define = function define(obj, key, value) {
return obj[key] = value;
};
}
function wrap(innerFn, outerFn, self, tryLocsList) {
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
generator = Object.create(protoGenerator.prototype),
context = new Context(tryLocsList || []);
return generator._invoke = function (innerFn, self, context) {
var state = "suspendedStart";
return function (method, arg) {
if ("executing" === state) throw new Error("Generator is already running");
if ("completed" === state) {
if ("throw" === method) throw arg;
return doneResult();
}
for (context.method = method, context.arg = arg;;) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
if ("suspendedStart" === state) throw state = "completed", context.arg;
context.dispatchException(context.arg);
} else "return" === context.method && context.abrupt("return", context.arg);
state = "executing";
var record = tryCatch(innerFn, self, context);
if ("normal" === record.type) {
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
return {
value: record.arg,
done: context.done
};
}
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
}
};
}(innerFn, self, context), generator;
}
function tryCatch(fn, obj, arg) {
try {
return {
type: "normal",
arg: fn.call(obj, arg)
};
} catch (err) {
return {
type: "throw",
arg: err
};
}
}
exports.wrap = wrap;
var ContinueSentinel = {};
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
var IteratorPrototype = {};
define(IteratorPrototype, iteratorSymbol, function () {
return this;
});
} catch (e) {
return Promise.reject(e);
var getProto = Object.getPrototypeOf,
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function (method) {
define(prototype, method, function (arg) {
return this._invoke(method, arg);
});
});
}
function AsyncIterator(generator, PromiseImpl) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if ("throw" !== record.type) {
var result = record.arg,
value = result.value;
return value && "object" == _typeof$1(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
invoke("next", value, resolve, reject);
}, function (err) {
invoke("throw", err, resolve, reject);
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
result.value = unwrapped, resolve(result);
}, function (error) {
return invoke("throw", error, resolve, reject);
});
}
reject(record.arg);
}
var previousPromise;
this._invoke = function (method, arg) {
function callInvokeWithMethodAndArg() {
return new PromiseImpl(function (resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
};
}
function maybeInvokeDelegate(delegate, context) {
var method = delegate.iterator[context.method];
if (undefined === method) {
if (context.delegate = null, "throw" === context.method) {
if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
}
return ContinueSentinel;
}
var record = tryCatch(method, delegate.iterator, context.arg);
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
var info = record.arg;
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
}
function pushTryEntry(locs) {
var entry = {
tryLoc: locs[0]
};
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal", delete record.arg, entry.completion = record;
}
function Context(tryLocsList) {
this.tryEntries = [{
tryLoc: "root"
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
}
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) return iteratorMethod.call(iterable);
if ("function" == typeof iterable.next) return iterable;
if (!isNaN(iterable.length)) {
var i = -1,
next = function next() {
for (; ++i < iterable.length;) {
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
}
return next.value = undefined, next.done = !0, next;
};
return next.next = next;
}
}
return {
next: doneResult
};
}
function doneResult() {
return {
value: undefined,
done: !0
};
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
var ctor = "function" == typeof genFun && genFun.constructor;
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
}, exports.mark = function (genFun) {
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
}, exports.awrap = function (arg) {
return {
__await: arg
};
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
return this;
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
void 0 === PromiseImpl && (PromiseImpl = Promise);
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
return result.done ? result.value : iter.next();
});
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
return this;
}), define(Gp, "toString", function () {
return "[object Generator]";
}), exports.keys = function (object) {
var keys = [];
for (var key in object) {
keys.push(key);
}
return keys.reverse(), function next() {
for (; keys.length;) {
var key = keys.pop();
if (key in object) return next.value = key, next.done = !1, next;
}
return next.done = !0, next;
};
}, exports.values = values, Context.prototype = {
constructor: Context,
reset: function reset(skipTempReset) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
}
},
stop: function stop() {
this.done = !0;
var rootRecord = this.tryEntries[0].completion;
if ("throw" === rootRecord.type) throw rootRecord.arg;
return this.rval;
},
dispatchException: function dispatchException(exception) {
if (this.done) throw exception;
var context = this;
function handle(loc, caught) {
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i],
record = entry.completion;
if ("root" === entry.tryLoc) return handle("end");
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc"),
hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
} else if (hasCatch) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
} else {
if (!hasFinally) throw new Error("try statement without catch or finally");
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
}
}
}
},
abrupt: function abrupt(type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
var record = finallyEntry ? finallyEntry.completion : {};
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
},
complete: function complete(record, afterLoc) {
if ("throw" === record.type) throw record.arg;
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
},
finish: function finish(finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
}
},
"catch": function _catch(tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if ("throw" === record.type) {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
throw new Error("illegal catch attempt");
},
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
return this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
}
}, exports;
}
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
})(regeneratorRuntime$1);
var runtime = regeneratorRuntime$1.exports();
var regenerator = runtime; // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
try {
regeneratorRuntime = runtime;
} catch (accidentalStrictMode) {
if ((typeof globalThis === "undefined" ? "undefined" : _typeof$1(globalThis)) === "object") {
globalThis.regeneratorRuntime = runtime;
} else {
Function("r", "regeneratorRuntime = r")(runtime);
}
}
function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function F() {};
return {
s: F,
n: function n() {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function e(_e) {
throw _e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
return {
s: function s() {
it = it.call(o);
},
n: function n() {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function e(_e2) {
didErr = true;
err = _e2;
},
f: function f() {
try {
if (!normalCompletion && it["return"] != null) it["return"]();
} finally {
if (didErr) throw err;
}
}
};
}
var promise;
var queueMicrotask_1 = typeof queueMicrotask === 'function' ? queueMicrotask // reuse resolved promise, and allocate it lazily
: function (cb) {
return (promise || (promise = Promise.resolve())).then(cb)["catch"](function (err) {
return setTimeout(function () {
throw err;
}, 0);
});
};
var mailbox = function mailbox() {
var queue = [];
var next;
return {
deliver: function deliver(msg) {
return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
return regenerator.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
queue.push(msg);
if (next) {
next(queue.shift());
next = undefined;
}
case 2:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
},
receive: function receive() {
return new Promise(function innerReceive(resolve) {
var msg = queue.shift();
if (msg) return resolve(msg);
next = resolve;
});
}
};
};
var INIT = "INIT";
var SUBSCRIBE = "SUBSCRIBE";
var UNSUBSCRIBE = "UNSUBSCRIBE";
var UPDATED$1 = "UPDATED";
var EXIT = "EXIT";
var TERMINATE = "TERMINATE";
var root = (typeof self === "undefined" ? "undefined" : _typeof$1(self)) === "object" && self.self === self && self || (typeof global === "undefined" ? "undefined" : _typeof$1(global)) === "object" && global.global === global && global || (typeof window === "undefined" ? "undefined" : _typeof$1(window)) === "object" && window.window === window && window;
root.FCL_REGISTRY = root.FCL_REGISTRY == null ? {} : root.FCL_REGISTRY;
var pid = 0;
var DEFAULT_TIMEOUT = 5000;
var _send = function send(addr, tag, data) {
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
return new Promise(function (reply, reject) {
var expectReply = opts.expectReply || false;
var timeout = opts.timeout != null ? opts.timeout : DEFAULT_TIMEOUT;
if (expectReply && timeout) {
setTimeout(function () {
return reject(new Error("Timeout: ".concat(timeout, "ms passed without a response.")));
}, timeout);
}
var payload = {
to: addr,
from: opts.from,
tag: tag,
data: data,
timeout: timeout,
reply: reply,
reject: reject
};
try {
root.FCL_REGISTRY[addr] && root.FCL_REGISTRY[addr].mailbox.deliver(payload);
if (!expectReply) reply(true);
} catch (error) {
console.error("FCL.Actor -- Could Not Deliver Message", payload, root.FCL_REGISTRY[addr], error);
}
});
};
var kill = function kill(addr) {
delete root.FCL_REGISTRY[addr];
};
var fromHandlers = function fromHandlers() {
var handlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(ctx) {
var letter;
return regenerator.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!(typeof handlers[INIT] === "function")) {
_context.next = 3;
break;
}
_context.next = 3;
return handlers[INIT](ctx);
case 3:
_context.next = 6;
return ctx.receive();
case 6:
letter = _context.sent;
_context.prev = 7;
if (!(letter.tag === EXIT)) {
_context.next = 13;
break;
}
if (!(typeof handlers[TERMINATE] === "function")) {
_context.next = 12;
break;
}
_context.next = 12;
return handlers[TERMINATE](ctx, letter, letter.data || {});
case 12:
return _context.abrupt("break", 25);
case 13:
_context.next = 15;
return handlers[letter.tag](ctx, letter, letter.data || {});
case 15:
_context.next = 20;
break;
case 17:
_context.prev = 17;
_context.t0 = _context["catch"](7);
console.error("".concat(ctx.self(), " Error"), letter, _context.t0);
case 20:
_context.prev = 20;
return _context.abrupt("continue", 3);
case 23:
_context.next = 3;
break;
case 25:
case "end":
return _context.stop();
}
}
}, _callee, null, [[7, 17, 20, 23]]);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
}();
};
var spawn = function spawn(fn) {
var addr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
if (addr == null) addr = ++pid;
if (root.FCL_REGISTRY[addr] != null) return addr;
root.FCL_REGISTRY[addr] = {
addr: addr,
mailbox: mailbox(),
subs: new Set(),
kvs: {},
error: null
};
var ctx = {
self: function self() {
return addr;
},
receive: function receive() {
return root.FCL_REGISTRY[addr].mailbox.receive();
},
send: function send(to, tag, data) {
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
opts.from = addr;
return _send(to, tag, data, opts);
},
sendSelf: function sendSelf(tag, data, opts) {
if (root.FCL_REGISTRY[addr]) _send(addr, tag, data, opts);
},
broadcast: function broadcast(tag, data) {
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
opts.from = addr;
var _iterator = _createForOfIteratorHelper(root.FCL_REGISTRY[addr].subs),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var to = _step.value;
_send(to, tag, data, opts);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
},
subscribe: function subscribe(sub) {
return sub != null && root.FCL_REGISTRY[addr].subs.add(sub);
},
unsubscribe: function unsubscribe(sub) {
return sub != null && root.FCL_REGISTRY[addr].subs["delete"](sub);
},
subscriberCount: function subscriberCount() {
return root.FCL_REGISTRY[addr].subs.size;
},
hasSubs: function hasSubs() {
return !!root.FCL_REGISTRY[addr].subs.size;
},
put: function put(key, value) {
if (key != null) root.FCL_REGISTRY[addr].kvs[key] = value;
},
get: function get(key, fallback) {
var value = root.FCL_REGISTRY[addr].kvs[key];
return value == null ? fallback : value;
},
"delete": function _delete(key) {
delete root.FCL_REGISTRY[addr].kvs[key];
},
update: function update(key, fn) {
if (key != null) root.FCL_REGISTRY[addr].kvs[key] = fn(root.FCL_REGISTRY[addr].kvs[key]);
},
keys: function keys() {
return Object.keys(root.FCL_REGISTRY[addr].kvs);
},
all: function all() {
return root.FCL_REGISTRY[addr].kvs;
},
where: function where(pattern) {
return Object.keys(root.FCL_REGISTRY[addr].kvs).reduce(function (acc, key) {
return pattern.test(key) ? _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, key, root.FCL_REGISTRY[addr].kvs[key])) : acc;
}, {});
},
merge: function merge() {
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
Object.keys(data).forEach(function (key) {
return root.FCL_REGISTRY[addr].kvs[key] = data[key];
});
},
fatalError: function fatalError(error) {
root.FCL_REGISTRY[addr].error = error;
var _iterator2 = _createForOfIteratorHelper(root.FCL_REGISTRY[addr].subs),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var to = _step2.value;
_send(to, UPDATED$1);
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
}
};
if (_typeof$1(fn) === "object") fn = fromHandlers(fn);
queueMicrotask_1( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
return regenerator.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return fn(ctx);
case 2:
kill(addr);
case 3:
case "end":
return _context2.stop();
}
}
}, _callee2);
})));
return addr;
}; // Returns an unsubscribe function
// A SUBSCRIBE handler will need to be created to handle the subscription event
//
// [SUBSCRIBE]: (ctx, letter) => {
// ctx.subscribe(letter.from)
// ctx.send(letter.from, UPDATED, ctx.all())
// }
//
function subscriber(address, spawnFn, callback) {
spawnFn(address);
var EXIT = "@EXIT";
var self = spawn( /*#__PURE__*/function () {
var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(ctx) {
var letter, error;
return regenerator.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
ctx.send(address, SUBSCRIBE);
case 1:
_context3.next = 4;
return ctx.receive();
case 4:
letter = _context3.sent;
error = root.FCL_REGISTRY[address].error;
if (!(letter.tag === EXIT)) {
_context3.next = 9;
break;
}
ctx.send(address, UNSUBSCRIBE);
return _context3.abrupt("return");
case 9:
if (!error) {
_context3.next = 13;
break;
}
callback(null, error);
ctx.send(address, UNSUBSCRIBE);
return _context3.abrupt("return");
case 13:
callback(letter.data, null);
_context3.next = 1;
break;
case 16:
case "end":
return _context3.stop();
}
}
}, _callee3);
}));
return function (_x2) {
return _ref3.apply(this, arguments);
};
}());
return function () {
return _send(self, EXIT);
};
} // Returns a promise that returns a result
var _HANDLERS;
var NAME = "config";

@@ -75,3 +951,3 @@ var PUT = "PUT_CONFIG";

var HANDLERS = (_HANDLERS = {}, _HANDLERS[PUT] = function (ctx, _letter, _ref) {
var HANDLERS = (_HANDLERS = {}, _defineProperty(_HANDLERS, PUT, function (ctx, _letter, _ref) {
var key = _ref.key,

@@ -81,4 +957,4 @@ value = _ref.value;

ctx.put(key, value);
ctx.broadcast(UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[GET] = function (ctx, letter, _ref2) {
ctx.broadcast(UPDATED, _objectSpread2({}, ctx.all()));
}), _defineProperty(_HANDLERS, GET, function (ctx, letter, _ref2) {
var key = _ref2.key,

@@ -88,5 +964,5 @@ fallback = _ref2.fallback;

letter.reply(ctx.get(key, fallback));
}, _HANDLERS[GET_ALL] = function (ctx, letter) {
letter.reply(_extends({}, ctx.all()));
}, _HANDLERS[UPDATE] = function (ctx, letter, _ref3) {
}), _defineProperty(_HANDLERS, GET_ALL, function (ctx, letter) {
letter.reply(_objectSpread2({}, ctx.all()));
}), _defineProperty(_HANDLERS, UPDATE, function (ctx, letter, _ref3) {
var key = _ref3.key,

@@ -96,9 +972,9 @@ fn = _ref3.fn;

ctx.update(key, fn || identity);
ctx.broadcast(UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[DELETE] = function (ctx, letter, _ref4) {
ctx.broadcast(UPDATED, _objectSpread2({}, ctx.all()));
}), _defineProperty(_HANDLERS, DELETE, function (ctx, letter, _ref4) {
var key = _ref4.key;
if (key == null) throw new Error("Missing 'key' for config/delete");
ctx["delete"](key);
ctx.broadcast(UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[CLEAR] = function (ctx, letter) {
ctx.broadcast(UPDATED, _objectSpread2({}, ctx.all()));
}), _defineProperty(_HANDLERS, CLEAR, function (ctx, letter) {
var keys = Object.keys(ctx.all());

@@ -111,17 +987,17 @@

ctx.broadcast(UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[WHERE] = function (ctx, letter, _ref5) {
ctx.broadcast(UPDATED, _objectSpread2({}, ctx.all()));
}), _defineProperty(_HANDLERS, WHERE, function (ctx, letter, _ref5) {
var pattern = _ref5.pattern;
if (pattern == null) throw new Error("Missing 'pattern' for config/where");
letter.reply(ctx.where(pattern));
}, _HANDLERS[utilActor.SUBSCRIBE] = function (ctx, letter) {
}), _defineProperty(_HANDLERS, SUBSCRIBE, function (ctx, letter) {
ctx.subscribe(letter.from);
ctx.send(letter.from, UPDATED, _extends({}, ctx.all()));
}, _HANDLERS[utilActor.UNSUBSCRIBE] = function (ctx, letter) {
ctx.send(letter.from, UPDATED, _objectSpread2({}, ctx.all()));
}), _defineProperty(_HANDLERS, UNSUBSCRIBE, function (ctx, letter) {
ctx.unsubscribe(letter.from);
}, _HANDLERS);
utilActor.spawn(HANDLERS, NAME);
}), _HANDLERS);
spawn(HANDLERS, NAME);
function put(key, value) {
utilActor.send(NAME, PUT, {
_send(NAME, PUT, {
key: key,

@@ -134,3 +1010,3 @@ value: value

function get(key, fallback) {
return utilActor.send(NAME, GET, {
return _send(NAME, GET, {
key: key,

@@ -144,4 +1020,60 @@ fallback: fallback

function first() {
return _first.apply(this, arguments);
}
function _first() {
_first = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
var wants,
fallback,
_wants,
head,
rest,
ret,
_args2 = arguments;
return regenerator.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
wants = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : [];
fallback = _args2.length > 1 ? _args2[1] : undefined;
if (wants.length) {
_context2.next = 4;
break;
}
return _context2.abrupt("return", fallback);
case 4:
_wants = _toArray(wants), head = _wants[0], rest = _wants.slice(1);
_context2.next = 7;
return get(head);
case 7:
ret = _context2.sent;
if (!(ret == null)) {
_context2.next = 10;
break;
}
return _context2.abrupt("return", first(rest, fallback));
case 10:
return _context2.abrupt("return", ret);
case 11:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return _first.apply(this, arguments);
}
function all() {
return utilActor.send(NAME, GET_ALL, null, {
return _send(NAME, GET_ALL, null, {
expectReply: true,

@@ -152,8 +1084,5 @@ timeout: 10

function update(key, fn) {
if (fn === void 0) {
fn = identity;
}
utilActor.send(NAME, UPDATE, {
function update(key) {
var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;
_send(NAME, UPDATE, {
key: key,

@@ -166,3 +1095,3 @@ fn: fn

function _delete(key) {
utilActor.send(NAME, DELETE, {
_send(NAME, DELETE, {
key: key

@@ -174,3 +1103,3 @@ });

function where(pattern) {
return utilActor.send(NAME, WHERE, {
return _send(NAME, WHERE, {
pattern: pattern

@@ -184,4 +1113,4 @@ }, {

function subscribe(callback) {
return utilActor.subscriber(NAME, function () {
return utilActor.spawn(HANDLERS, NAME);
return subscriber(NAME, function () {
return spawn(HANDLERS, NAME);
}, callback);

@@ -191,7 +1120,7 @@ }

function clearConfig() {
return utilActor.send(NAME, CLEAR);
return _send(NAME, CLEAR);
}
function config(values) {
if (values != null && typeof values === "object") {
if (values != null && _typeof$1(values) === "object") {
Object.keys(values).map(function (d) {

@@ -229,40 +1158,67 @@ return put(d, values[d]);

function overload(opts, callback) {
if (opts === void 0) {
opts = {};
}
function overload() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
return new Promise( /*#__PURE__*/function () {
var _ref6 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(resolve, reject) {
var oldConfig, result;
return regenerator.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return all();
if (callback === void 0) {
callback = noop;
}
case 2:
oldConfig = _context.sent;
_context.prev = 3;
config(opts);
_context.t0 = callback;
_context.next = 8;
return all();
return new Promise(function (resolve, reject) {
try {
return Promise.resolve(all()).then(function (oldConfig) {
var _temp = _catch(function () {
config(opts);
var _callback = callback;
return Promise.resolve(all()).then(function (_all) {
return Promise.resolve(_callback(_all)).then(function (result) {
return Promise.resolve(clearConfig()).then(function () {
return Promise.resolve(config(oldConfig)).then(function () {
resolve(result);
});
});
});
});
}, function (error) {
return Promise.resolve(clearConfig()).then(function () {
return Promise.resolve(config(oldConfig)).then(function () {
reject(error);
});
});
});
case 8:
_context.t1 = _context.sent;
_context.next = 11;
return (0, _context.t0)(_context.t1);
if (_temp && _temp.then) return _temp.then(function () {});
});
} catch (e) {
return Promise.reject(e);
}
});
case 11:
result = _context.sent;
_context.next = 14;
return clearConfig();
case 14:
_context.next = 16;
return config(oldConfig);
case 16:
resolve(result);
_context.next = 26;
break;
case 19:
_context.prev = 19;
_context.t2 = _context["catch"](3);
_context.next = 23;
return clearConfig();
case 23:
_context.next = 25;
return config(oldConfig);
case 25:
reject(_context.t2);
case 26:
case "end":
return _context.stop();
}
}
}, _callee, null, [[3, 19]]);
}));
return function (_x, _x2) {
return _ref6.apply(this, arguments);
};
}());
}

@@ -273,3 +1229,5 @@

})));
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=config.umd.js.map
{
"name": "@onflow/config",
"version": "1.0.2",
"version": "1.0.3-alpha.0",
"description": "Config for FCL-JS",

@@ -21,5 +21,5 @@ "license": "Apache-2.0",

"devDependencies": {
"@onflow/fcl-bundle": "^1.0.1-alpha.0",
"jest": "25.3.0",
"jest-esm-transformer": "1.0.0",
"microbundle": "0.12.0-next.8"
"jest-esm-transformer": "1.0.0"
},

@@ -33,9 +33,10 @@ "source": "src/config.js",

"test": "jest",
"build": "microbundle --no-compress",
"build": "fcl-bundle",
"test:watch": "jest --watch",
"start": "microbundle watch --no-compress"
"start": "fcl-bundle --watch"
},
"dependencies": {
"@onflow/util-actor": "^1.1.0"
"@babel/runtime": "^7.18.6",
"@onflow/util-actor": "^1.1.1-alpha.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc