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