ywana-core8 0.0.989 → 0.0.991

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5351,6 +5351,20 @@ var Wizard = function Wizard(props) {
5351
5351
  * Task Context
5352
5352
  */
5353
5353
 
5354
+ function _catch$5(body, recover) {
5355
+ try {
5356
+ var result = body();
5357
+ } catch (e) {
5358
+ return recover(e);
5359
+ }
5360
+ if (result && result.then) {
5361
+ return result.then(void 0, recover);
5362
+ }
5363
+ return result;
5364
+ } /**
5365
+ * Task Provider
5366
+ */
5367
+
5354
5368
  function _settle(pact, state, value) {
5355
5369
  if (!pact.s) {
5356
5370
  if (value instanceof _Pact) {
@@ -5370,14 +5384,12 @@ function _settle(pact, state, value) {
5370
5384
  }
5371
5385
  pact.s = state;
5372
5386
  pact.v = value;
5373
- const observer = pact.o;
5387
+ var observer = pact.o;
5374
5388
  if (observer) {
5375
5389
  observer(pact);
5376
5390
  }
5377
5391
  }
5378
- } /**
5379
- * Task Provider
5380
- */
5392
+ }
5381
5393
  var _Pact = /*#__PURE__*/function () {
5382
5394
  function _Pact() {}
5383
5395
  _Pact.prototype.then = function (onFulfilled, onRejected) {
@@ -5446,17 +5458,6 @@ function _forTo(array, body, check) {
5446
5458
  _cycle();
5447
5459
  return pact;
5448
5460
  }
5449
- function _catch$5(body, recover) {
5450
- try {
5451
- var result = body();
5452
- } catch (e) {
5453
- return recover(e);
5454
- }
5455
- if (result && result.then) {
5456
- return result.then(void 0, recover);
5457
- }
5458
- return result;
5459
- }
5460
5461
  var TaskContext = React__default["default"].createContext({});
5461
5462
  var TaskContextProvider = function TaskContextProvider(props) {
5462
5463
  var removeTask = function removeTask(task) {
@@ -5517,34 +5518,41 @@ var TaskContextProvider = function TaskContextProvider(props) {
5517
5518
  return Promise.reject(e);
5518
5519
  }
5519
5520
  };
5521
+ var executeListeners = function executeListeners() {
5522
+ try {
5523
+ var taskIDs = Object.keys(listeners);
5524
+ var _temp = _forTo(taskIDs, function (i) {
5525
+ var taskID = taskIDs[i];
5526
+ return Promise.resolve(task(taskID)).then(function (tsk) {
5527
+ var listener = listeners[taskID];
5528
+ if (listener) listener(tsk, appContextRef.current);
5529
+ });
5530
+ });
5531
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
5532
+ } catch (e) {
5533
+ return Promise.reject(e);
5534
+ }
5535
+ };
5520
5536
  var host = props.host,
5521
5537
  _props$url = props.url,
5522
5538
  url = _props$url === void 0 ? "/tasks" : _props$url,
5523
5539
  _props$frequency = props.frequency,
5524
5540
  frequency = _props$frequency === void 0 ? 1000 : _props$frequency,
5525
- children = props.children,
5526
- ctx = props.ctx;
5541
+ children = props.children;
5527
5542
  var API = CollectionAPI$1(url, host, "");
5528
5543
  var _useState = React.useState({}),
5529
5544
  listeners = _useState[0],
5530
5545
  setListeners = _useState[1];
5531
- var appContext = React.useContext(ctx);
5546
+ var appContext = React.useContext(appContext);
5547
+ var appContextRef = React.useRef(appContext);
5548
+ React.useEffect(function () {
5549
+ appContextRef.current = appContext;
5550
+ }, [appContext]);
5532
5551
  React.useEffect(function () {
5533
5552
  if (Object.keys(listeners).length === 0) return;
5534
5553
  var _interval = setInterval(function () {
5535
- try {
5536
- var taskIDs = Object.keys(listeners);
5537
- var _temp = _forTo(taskIDs, function (i) {
5538
- var taskID = taskIDs[i];
5539
- return Promise.resolve(task(taskID)).then(function (tsk) {
5540
- var listener = listeners[taskID];
5541
- if (listener) listener(tsk, appContext);
5542
- });
5543
- });
5544
- return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
5545
- } catch (e) {
5546
- return Promise.reject(e);
5547
- }
5554
+ executeListeners();
5555
+ return Promise.resolve();
5548
5556
  }, frequency);
5549
5557
  return function () {
5550
5558
  return clearInterval(_interval);