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