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

@onflow/util-actor

Package Overview
Dependencies
Maintainers
11
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/util-actor - npm Package Compare versions

Comparing version 1.2.0-alpha.0 to 1.2.0-alpha.1

6

CHANGELOG.md
# @onflow/util-actor
## 1.2.0-alpha.1
### Patch Changes
- [#1631](https://github.com/onflow/fcl-js/pull/1631) [`35052784`](https://github.com/onflow/fcl-js/commit/3505278418e64045248c04fd21f0c09ddbb3132e) Thanks [@JeffreyDoyle](https://github.com/JeffreyDoyle)! - PKG [fcl-actor] -- Upgrade queue-microtask to latest
## 1.2.0-alpha.0

@@ -4,0 +10,0 @@

263

dist/actor.js

@@ -8,5 +8,5 @@ 'use strict';

var _createForOfIteratorHelper = require('@babel/runtime/helpers/createForOfIteratorHelper');
var _regeneratorRuntime = require('@babel/runtime/helpers/regeneratorRuntime');
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
var _typeof = require('@babel/runtime/helpers/typeof');
var _regeneratorRuntime = require('@babel/runtime/regenerator');
var queueMicrotask = require('queue-microtask');

@@ -19,5 +19,5 @@

var _createForOfIteratorHelper__default = /*#__PURE__*/_interopDefaultLegacy(_createForOfIteratorHelper);
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
var queueMicrotask__default = /*#__PURE__*/_interopDefaultLegacy(queueMicrotask);

@@ -30,18 +30,14 @@

deliver: function deliver(msg) {
return _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
return _regeneratorRuntime__default["default"].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();
}
return _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee() {
return _regeneratorRuntime__default["default"]().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();
}

@@ -72,3 +68,2 @@ }, _callee);

var DEFAULT_TIMEOUT = 5000;
var _send = function send(addr, tag, data) {

@@ -79,3 +74,2 @@ var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

var timeout = opts.timeout != null ? opts.timeout : DEFAULT_TIMEOUT;
if (expectReply && timeout) {

@@ -86,3 +80,2 @@ setTimeout(function () {

}
var payload = {

@@ -97,3 +90,2 @@ to: addr,

};
try {

@@ -110,74 +102,56 @@ root.FCL_REGISTRY[addr] && root.FCL_REGISTRY[addr].mailbox.deliver(payload);

};
var fromHandlers = function fromHandlers() {
var handlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return /*#__PURE__*/function () {
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(ctx) {
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee(ctx) {
var letter;
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!(typeof handlers[INIT] === "function")) {
_context.next = 3;
break;
}
return _regeneratorRuntime__default["default"]().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
if (!(typeof handlers[INIT] === "function")) {
_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;
}
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;
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();
}
}
_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) {

@@ -188,3 +162,2 @@ return _ref.apply(this, arguments);

};
var spawn = function spawn(fn) {

@@ -219,10 +192,7 @@ var addr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

opts.from = addr;
var _iterator = _createForOfIteratorHelper__default["default"](root.FCL_REGISTRY[addr].subs),
_step;
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var to = _step.value;
_send(to, tag, data, opts);

@@ -280,10 +250,7 @@ }

root.FCL_REGISTRY[addr].error = error;
var _iterator2 = _createForOfIteratorHelper__default["default"](root.FCL_REGISTRY[addr].subs),
_step2;
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var to = _step2.value;
_send(to, UPDATED);

@@ -299,17 +266,13 @@ }

if (_typeof__default["default"](fn) === "object") fn = fromHandlers(fn);
queueMicrotask__default["default"]( /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
return _regeneratorRuntime__default["default"].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();
}
queueMicrotask__default["default"]( /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee2() {
return _regeneratorRuntime__default["default"]().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();
}

@@ -319,3 +282,5 @@ }, _callee2);

return addr;
}; // Returns an unsubscribe function
};
// Returns an unsubscribe function
// A SUBSCRIBE handler will need to be created to handle the subscription event

@@ -328,3 +293,2 @@ //

//
function subscriber(address, spawnFn, callback) {

@@ -334,50 +298,38 @@ spawnFn(address);

var self = spawn( /*#__PURE__*/function () {
var _ref3 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(ctx) {
var _ref3 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee3(ctx) {
var letter, error;
return _regeneratorRuntime__default["default"].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;
return _regeneratorRuntime__default["default"]().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;
case 16:
case "end":
return _context3.stop();
}
}
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) {

@@ -390,3 +342,5 @@ return _ref3.apply(this, arguments);

};
} // Returns a promise that returns a result
}
// Returns a promise that returns a result
// A SNAPSHOT handler will need to be created to handle the snapshot event

@@ -398,3 +352,2 @@ //

//
function snapshoter(address, spawnFn) {

@@ -401,0 +354,0 @@ spawnFn(address);

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
import _createForOfIteratorHelper from '@babel/runtime/helpers/createForOfIteratorHelper';
import _regeneratorRuntime from '@babel/runtime/helpers/regeneratorRuntime';
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
import _typeof from '@babel/runtime/helpers/typeof';
import _regeneratorRuntime from '@babel/runtime/regenerator';
import queueMicrotask from 'queue-microtask';

@@ -14,18 +14,14 @@

deliver: function deliver(msg) {
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
return _regeneratorRuntime.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();
}
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
return _regeneratorRuntime().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();
}

@@ -56,3 +52,2 @@ }, _callee);

var DEFAULT_TIMEOUT = 5000;
var _send = function send(addr, tag, data) {

@@ -63,3 +58,2 @@ var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

var timeout = opts.timeout != null ? opts.timeout : DEFAULT_TIMEOUT;
if (expectReply && timeout) {

@@ -70,3 +64,2 @@ setTimeout(function () {

}
var payload = {

@@ -81,3 +74,2 @@ to: addr,

};
try {

@@ -94,74 +86,56 @@ root.FCL_REGISTRY[addr] && root.FCL_REGISTRY[addr].mailbox.deliver(payload);

};
var fromHandlers = function fromHandlers() {
var handlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ctx) {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ctx) {
var letter;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!(typeof handlers[INIT] === "function")) {
_context.next = 3;
break;
}
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
if (!(typeof handlers[INIT] === "function")) {
_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;
}
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;
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();
}
}
_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) {

@@ -172,3 +146,2 @@ return _ref.apply(this, arguments);

};
var spawn = function spawn(fn) {

@@ -203,10 +176,7 @@ var addr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

opts.from = addr;
var _iterator = _createForOfIteratorHelper(root.FCL_REGISTRY[addr].subs),
_step;
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var to = _step.value;
_send(to, tag, data, opts);

@@ -264,10 +234,7 @@ }

root.FCL_REGISTRY[addr].error = error;
var _iterator2 = _createForOfIteratorHelper(root.FCL_REGISTRY[addr].subs),
_step2;
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var to = _step2.value;
_send(to, UPDATED);

@@ -283,17 +250,13 @@ }

if (_typeof(fn) === "object") fn = fromHandlers(fn);
queueMicrotask( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
return _regeneratorRuntime.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();
}
queueMicrotask( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
return _regeneratorRuntime().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();
}

@@ -303,3 +266,5 @@ }, _callee2);

return addr;
}; // Returns an unsubscribe function
};
// Returns an unsubscribe function
// A SUBSCRIBE handler will need to be created to handle the subscription event

@@ -312,3 +277,2 @@ //

//
function subscriber(address, spawnFn, callback) {

@@ -318,50 +282,38 @@ spawnFn(address);

var self = spawn( /*#__PURE__*/function () {
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(ctx) {
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(ctx) {
var letter, error;
return _regeneratorRuntime.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;
return _regeneratorRuntime().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;
case 16:
case "end":
return _context3.stop();
}
}
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) {

@@ -374,3 +326,5 @@ return _ref3.apply(this, arguments);

};
} // Returns a promise that returns a result
}
// Returns a promise that returns a result
// A SNAPSHOT handler will need to be created to handle the snapshot event

@@ -382,3 +336,2 @@ //

//
function snapshoter(address, spawnFn) {

@@ -385,0 +338,0 @@ spawnFn(address);

@@ -7,3 +7,30 @@ (function (global, factory) {

function _typeof(obj) {
"@babel/helpers - typeof";
return _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;
}, _typeof(obj);
}
function _toPrimitive(input, hint) {
if (_typeof(input) !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (_typeof(res) !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return _typeof(key) === "symbol" ? key : String(key);
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {

@@ -19,3 +46,2 @@ Object.defineProperty(obj, key, {

}
return obj;

@@ -26,3 +52,2 @@ }

var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {

@@ -34,6 +59,4 @@ var symbols = Object.getOwnPropertySymbols(object);

}
return keys;
}
function _objectSpread2(target) {

@@ -48,3 +71,2 @@ for (var i = 1; i < arguments.length; i++) {

}
return target;

@@ -55,7 +77,3 @@ }

if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) {
arr2[i] = arr[i];
}
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;

@@ -75,3 +93,2 @@ }

var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {

@@ -81,5 +98,3 @@ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {

var i = 0;
var F = function F() {};
return {

@@ -102,9 +117,7 @@ s: 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;
didErr = false,
err;
return {

@@ -133,211 +146,95 @@ s: function s() {

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
function _regeneratorRuntime() {
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
_regeneratorRuntime = function _regeneratorRuntime() {
return exports;
};
var exports = {},
Op = Object.prototype,
hasOwn = Op.hasOwnProperty,
defineProperty = Object.defineProperty || function (obj, key, desc) {
obj[key] = desc.value;
},
$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 {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
define({}, "");
} catch (err) {
define = function define(obj, key, value) {
return obj[key] = value;
};
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
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 defineProperty(generator, "_invoke", {
value: makeInvokeMethod(innerFn, self, context)
}), generator;
}
}
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);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
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);
}
var regeneratorRuntime$1 = {exports: {}};
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);
}
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
})(_typeof);
(function (module) {
var _typeof$1 = _typeof.exports["default"];
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];
}
function tryCatch(fn, obj, arg) {
try {
define({}, "");
return {
type: "normal",
arg: fn.call(obj, arg)
};
} catch (err) {
define = function define(obj, key, value) {
return obj[key] = value;
return {
type: "throw",
arg: err
};
}
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;
}
exports.wrap = wrap;
var ContinueSentinel = {};
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
var IteratorPrototype = {};
define(IteratorPrototype, iteratorSymbol, function () {
return this;
});
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);
});
});
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(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);
}
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) {
var previousPromise;
defineProperty(this, "_invoke", {
value: function value(method, arg) {
function callInvokeWithMethodAndArg() {

@@ -348,220 +245,238 @@ return new PromiseImpl(function (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");
}
});
}
function makeInvokeMethod(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;
}
}
return ContinueSentinel;
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);
}
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;
}
};
}
function maybeInvokeDelegate(delegate, context) {
var methodName = context.method,
method = delegate.iterator[methodName];
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), 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.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 {
next: doneResult
};
}
function doneResult() {
return {
value: undefined,
done: !0
};
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
value: GeneratorFunctionPrototype,
configurable: !0
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
value: GeneratorFunction,
configurable: !0
}), 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 (val) {
var object = Object(val),
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 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);
}
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;
}
}
},
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;
}
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;
}
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;
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
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;
if (info.done) {
resolve(value);
} else {
Function("r", "regeneratorRuntime = r")(runtime);
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);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}

@@ -573,18 +488,14 @@ var mailbox = function mailbox() {

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();
}
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
return _regeneratorRuntime().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();
}

@@ -604,4 +515,8 @@ }, _callee);

var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
var promise;
var queueMicrotask_1 = typeof queueMicrotask === 'function' ? queueMicrotask // reuse resolved promise, and allocate it lazily
var queueMicrotask_1 = typeof queueMicrotask === 'function' ? queueMicrotask.bind(typeof window !== 'undefined' ? window : commonjsGlobal)
// reuse resolved promise, and allocate it lazily
: function (cb) {

@@ -622,7 +537,6 @@ return (promise || (promise = Promise.resolve())).then(cb)["catch"](function (err) {

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;
var root = (typeof self === "undefined" ? "undefined" : _typeof(self)) === "object" && self.self === self && self || (typeof global === "undefined" ? "undefined" : _typeof(global)) === "object" && global.global === global && global || (typeof window === "undefined" ? "undefined" : _typeof(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) {

@@ -633,3 +547,2 @@ var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

var timeout = opts.timeout != null ? opts.timeout : DEFAULT_TIMEOUT;
if (expectReply && timeout) {

@@ -640,3 +553,2 @@ setTimeout(function () {

}
var payload = {

@@ -651,3 +563,2 @@ to: addr,

};
try {

@@ -664,74 +575,56 @@ root.FCL_REGISTRY[addr] && root.FCL_REGISTRY[addr].mailbox.deliver(payload);

};
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 _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().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;
}
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
if (!(typeof handlers[INIT] === "function")) {
_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;
}
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;
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();
}
}
_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) {

@@ -742,3 +635,2 @@ return _ref.apply(this, arguments);

};
var spawn = function spawn(fn) {

@@ -773,10 +665,7 @@ var addr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

opts.from = addr;
var _iterator = _createForOfIteratorHelper(root.FCL_REGISTRY[addr].subs),
_step;
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var to = _step.value;
_send(to, tag, data, opts);

@@ -834,10 +723,7 @@ }

root.FCL_REGISTRY[addr].error = error;
var _iterator2 = _createForOfIteratorHelper(root.FCL_REGISTRY[addr].subs),
_step2;
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var to = _step2.value;
_send(to, UPDATED);

@@ -852,18 +738,14 @@ }

};
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();
}
if (_typeof(fn) === "object") fn = fromHandlers(fn);
queueMicrotask_1( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
return _regeneratorRuntime().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();
}

@@ -873,3 +755,5 @@ }, _callee2);

return addr;
}; // Returns an unsubscribe function
};
// Returns an unsubscribe function
// A SUBSCRIBE handler will need to be created to handle the subscription event

@@ -882,3 +766,2 @@ //

//
function subscriber(address, spawnFn, callback) {

@@ -888,50 +771,38 @@ spawnFn(address);

var self = spawn( /*#__PURE__*/function () {
var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(ctx) {
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().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;
return _regeneratorRuntime().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;
case 16:
case "end":
return _context3.stop();
}
}
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) {

@@ -944,3 +815,5 @@ return _ref3.apply(this, arguments);

};
} // Returns a promise that returns a result
}
// Returns a promise that returns a result
// A SNAPSHOT handler will need to be created to handle the snapshot event

@@ -952,3 +825,2 @@ //

//
function snapshoter(address, spawnFn) {

@@ -955,0 +827,0 @@ spawnFn(address);

{
"name": "@onflow/util-actor",
"version": "1.2.0-alpha.0",
"version": "1.2.0-alpha.1",
"description": "A mechanism for forcing order/transitions of scoped async state",

@@ -27,3 +27,3 @@ "license": "Apache-2.0",

"@babel/runtime": "^7.18.6",
"queue-microtask": "1.1.2"
"queue-microtask": "1.2.3"
},

@@ -30,0 +30,0 @@ "source": "src/index.js",

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