ywana-core8 0.0.830 → 0.0.831

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
@@ -5002,6 +5002,124 @@ var CollectionAPI$1 = function CollectionAPI(url, host) {
5002
5002
  * Task Context
5003
5003
  */
5004
5004
 
5005
+ function _settle(pact, state, value) {
5006
+ if (!pact.s) {
5007
+ if (value instanceof _Pact) {
5008
+ if (value.s) {
5009
+ if (state & 1) {
5010
+ state = value.s;
5011
+ }
5012
+
5013
+ value = value.v;
5014
+ } else {
5015
+ value.o = _settle.bind(null, pact, state);
5016
+ return;
5017
+ }
5018
+ }
5019
+
5020
+ if (value && value.then) {
5021
+ value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
5022
+ return;
5023
+ }
5024
+
5025
+ pact.s = state;
5026
+ pact.v = value;
5027
+ const observer = pact.o;
5028
+
5029
+ if (observer) {
5030
+ observer(pact);
5031
+ }
5032
+ }
5033
+ }
5034
+ /**
5035
+ * Task Provider
5036
+ */
5037
+
5038
+
5039
+ var _Pact = /*#__PURE__*/function () {
5040
+ function _Pact() {}
5041
+
5042
+ _Pact.prototype.then = function (onFulfilled, onRejected) {
5043
+ var result = new _Pact();
5044
+ var state = this.s;
5045
+
5046
+ if (state) {
5047
+ var callback = state & 1 ? onFulfilled : onRejected;
5048
+
5049
+ if (callback) {
5050
+ try {
5051
+ _settle(result, 1, callback(this.v));
5052
+ } catch (e) {
5053
+ _settle(result, 2, e);
5054
+ }
5055
+
5056
+ return result;
5057
+ } else {
5058
+ return this;
5059
+ }
5060
+ }
5061
+
5062
+ this.o = function (_this) {
5063
+ try {
5064
+ var value = _this.v;
5065
+
5066
+ if (_this.s & 1) {
5067
+ _settle(result, 1, onFulfilled ? onFulfilled(value) : value);
5068
+ } else if (onRejected) {
5069
+ _settle(result, 1, onRejected(value));
5070
+ } else {
5071
+ _settle(result, 2, value);
5072
+ }
5073
+ } catch (e) {
5074
+ _settle(result, 2, e);
5075
+ }
5076
+ };
5077
+
5078
+ return result;
5079
+ };
5080
+
5081
+ return _Pact;
5082
+ }();
5083
+
5084
+ function _isSettledPact(thenable) {
5085
+ return thenable instanceof _Pact && thenable.s & 1;
5086
+ }
5087
+
5088
+ function _forTo(array, body, check) {
5089
+ var i = -1,
5090
+ pact,
5091
+ reject;
5092
+
5093
+ function _cycle(result) {
5094
+ try {
5095
+ while (++i < array.length && (!check || !check())) {
5096
+ result = body(i);
5097
+
5098
+ if (result && result.then) {
5099
+ if (_isSettledPact(result)) {
5100
+ result = result.v;
5101
+ } else {
5102
+ result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
5103
+ return;
5104
+ }
5105
+ }
5106
+ }
5107
+
5108
+ if (pact) {
5109
+ _settle(pact, 1, result);
5110
+ } else {
5111
+ pact = result;
5112
+ }
5113
+ } catch (e) {
5114
+ _settle(pact || (pact = new _Pact()), 2, e);
5115
+ }
5116
+ }
5117
+
5118
+ _cycle();
5119
+
5120
+ return pact;
5121
+ }
5122
+
5005
5123
  function _catch$5(body, recover) {
5006
5124
  try {
5007
5125
  var result = body();
@@ -5015,10 +5133,6 @@ function _catch$5(body, recover) {
5015
5133
 
5016
5134
  return result;
5017
5135
  }
5018
- /**
5019
- * Task Provider
5020
- */
5021
-
5022
5136
 
5023
5137
  var TaskContext = React__default["default"].createContext({});
5024
5138
  var TaskContextProvider = function TaskContextProvider(props) {
@@ -5108,20 +5222,20 @@ var TaskContextProvider = function TaskContextProvider(props) {
5108
5222
  React.useEffect(function () {
5109
5223
  var interval = setInterval(function () {
5110
5224
  try {
5111
- return Promise.resolve(API.all({
5112
- state: TASK_STATES.RUNNING
5113
- })).then(function (tasks) {
5114
- Object.keys(_listeners).forEach(function (taskID) {
5115
- var task = tasks.find(function (task) {
5116
- return task.id === taskID;
5117
- });
5225
+ var taskIDs = Object.keys(_listeners);
5226
+ if (taskIDs.length === 0) return Promise.resolve();
5118
5227
 
5228
+ var _temp2 = _forTo(taskIDs, function (i) {
5229
+ var taskID = taskIDs[i];
5230
+ return Promise.resolve(context.task(taskID)).then(function (task) {
5119
5231
  if (task) {
5120
5232
  var listener = _listeners[taskID];
5121
5233
  if (listener) listener(task);
5122
5234
  }
5123
5235
  });
5124
5236
  });
5237
+
5238
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
5125
5239
  } catch (e) {
5126
5240
  return Promise.reject(e);
5127
5241
  }
@@ -5143,17 +5257,6 @@ var TaskContextProvider = function TaskContextProvider(props) {
5143
5257
  value: value
5144
5258
  }, children);
5145
5259
  };
5146
- /**
5147
- * Task States
5148
- */
5149
-
5150
- var TASK_STATES = {
5151
- "CREATED": "CREATED",
5152
- "RUNNING": "RUNNING",
5153
- "COMPLETED": "COMPPLETED",
5154
- "FAULTED": "FAULTED",
5155
- "CANCELED": "CANCELED"
5156
- };
5157
5260
  /**
5158
5261
  * TaskProgress
5159
5262
  */