xstate 4.35.2 → 5.0.0-alpha.1
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/README.md +25 -16
- package/actions/dist/xstate-actions.cjs.d.ts +1 -0
- package/actions/dist/xstate-actions.cjs.dev.js +30 -0
- package/actions/dist/xstate-actions.cjs.js +7 -0
- package/actions/dist/xstate-actions.cjs.prod.js +30 -0
- package/actions/dist/xstate-actions.esm.js +2 -0
- package/actions/dist/xstate-actions.umd.min.js +2 -0
- package/actions/dist/xstate-actions.umd.min.js.map +1 -0
- package/actions/dynamicAction.ts +34 -0
- package/actions/package.json +8 -0
- package/actors/dist/xstate-actors.cjs.d.ts +1 -0
- package/actors/dist/xstate-actors.cjs.dev.js +20 -0
- package/actors/dist/xstate-actors.cjs.js +7 -0
- package/actors/dist/xstate-actors.cjs.prod.js +20 -0
- package/actors/dist/xstate-actors.esm.js +2 -0
- package/actors/dist/xstate-actors.umd.min.js +2 -0
- package/actors/dist/xstate-actors.umd.min.js.map +1 -0
- package/actors/package.json +8 -0
- package/dev/dist/xstate-dev.cjs.d.ts +1 -0
- package/dev/dist/xstate-dev.cjs.dev.js +11 -0
- package/dev/dist/xstate-dev.cjs.js +7 -0
- package/{lib/devTools.js → dev/dist/xstate-dev.cjs.prod.js} +17 -10
- package/dev/dist/xstate-dev.esm.js +1 -0
- package/dev/dist/xstate-dev.umd.min.js +2 -0
- package/dev/dist/xstate-dev.umd.min.js.map +1 -0
- package/dev/package.json +8 -0
- package/dist/actions-7ea9280f.cjs.prod.js +4674 -0
- package/dist/actions-b08d0da8.cjs.dev.js +4718 -0
- package/dist/actions-b673cb13.esm.js +4660 -0
- package/dist/declarations/actions/dynamicAction.d.ts +5 -0
- package/dist/declarations/src/Machine.d.ts +4 -0
- package/dist/declarations/src/Mailbox.d.ts +12 -0
- package/{es → dist/declarations/src}/SimulatedClock.d.ts +16 -17
- package/dist/declarations/src/State.d.ts +97 -0
- package/dist/declarations/src/StateMachine.d.ts +120 -0
- package/dist/declarations/src/StateNode.d.ts +127 -0
- package/{es → dist/declarations/src}/actionTypes.d.ts +16 -20
- package/dist/declarations/src/actions/assign.d.ts +7 -0
- package/dist/declarations/src/actions/cancel.d.ts +10 -0
- package/dist/declarations/src/actions/choose.d.ts +3 -0
- package/dist/declarations/src/actions/invoke.d.ts +3 -0
- package/dist/declarations/src/actions/log.d.ts +11 -0
- package/dist/declarations/src/actions/pure.d.ts +3 -0
- package/dist/declarations/src/actions/raise.d.ts +9 -0
- package/dist/declarations/src/actions/send.d.ts +51 -0
- package/dist/declarations/src/actions/stop.d.ts +7 -0
- package/dist/declarations/src/actions.d.ts +43 -0
- package/dist/declarations/src/actors.d.ts +37 -0
- package/dist/declarations/src/constants.d.ts +5 -0
- package/{lib/devTools.d.ts → dist/declarations/src/dev/index.d.ts} +14 -14
- package/{es → dist/declarations/src}/environment.d.ts +1 -2
- package/dist/declarations/src/guards.d.ts +8 -0
- package/dist/declarations/src/index.d.ts +44 -0
- package/dist/declarations/src/interpreter.d.ts +108 -0
- package/{es → dist/declarations/src}/mapState.d.ts +3 -4
- package/dist/declarations/src/memo.d.ts +2 -0
- package/dist/declarations/src/registry.d.ts +8 -0
- package/{es → dist/declarations/src}/schema.d.ts +2 -3
- package/dist/declarations/src/spawn.d.ts +2 -0
- package/dist/declarations/src/stateUtils.d.ts +70 -0
- package/dist/declarations/src/symbolObservable.d.ts +1 -0
- package/{lib → dist/declarations/src}/typegenTypes.d.ts +132 -133
- package/dist/declarations/src/types.d.ts +1001 -0
- package/dist/declarations/src/utils.d.ts +54 -0
- package/{es/devTools.js → dist/index-20b364c4.esm.js} +18 -6
- package/dist/index-2a564d03.cjs.dev.js +64 -0
- package/dist/xstate.cjs.d.ts +1 -0
- package/dist/xstate.cjs.dev.js +993 -0
- package/dist/xstate.cjs.js +7 -0
- package/dist/xstate.cjs.prod.js +993 -0
- package/dist/xstate.esm.js +952 -0
- package/dist/xstate.umd.min.js +2 -0
- package/dist/xstate.umd.min.js.map +1 -0
- package/guards/dist/xstate-guards.cjs.d.ts +1 -0
- package/guards/dist/xstate-guards.cjs.dev.js +15 -0
- package/guards/dist/xstate-guards.cjs.js +7 -0
- package/guards/dist/xstate-guards.cjs.prod.js +15 -0
- package/guards/dist/xstate-guards.esm.js +2 -0
- package/guards/dist/xstate-guards.umd.min.js +2 -0
- package/guards/dist/xstate-guards.umd.min.js.map +1 -0
- package/guards/package.json +8 -0
- package/invoke/package.json +4 -0
- package/package.json +44 -30
- package/dist/xstate.interpreter.js +0 -15
- package/dist/xstate.js +0 -15
- package/dist/xstate.web.js +0 -15
- package/es/Actor.d.ts +0 -25
- package/es/Actor.js +0 -99
- package/es/Machine.d.ts +0 -12
- package/es/Machine.js +0 -21
- package/es/SimulatedClock.js +0 -81
- package/es/State.d.ts +0 -123
- package/es/State.js +0 -274
- package/es/StateNode.d.ts +0 -282
- package/es/StateNode.js +0 -1587
- package/es/_virtual/_tslib.js +0 -78
- package/es/actionTypes.js +0 -22
- package/es/actions.d.ts +0 -157
- package/es/actions.js +0 -630
- package/es/behaviors.d.ts +0 -37
- package/es/behaviors.js +0 -131
- package/es/constants.d.ts +0 -6
- package/es/constants.js +0 -6
- package/es/devTools.d.ts +0 -14
- package/es/each.d.ts +0 -4
- package/es/each.js +0 -13
- package/es/environment.js +0 -3
- package/es/index.d.ts +0 -22
- package/es/index.js +0 -25
- package/es/interpreter.d.ts +0 -217
- package/es/interpreter.js +0 -1488
- package/es/invoke.d.ts +0 -11
- package/es/invokeUtils.d.ts +0 -7
- package/es/invokeUtils.js +0 -40
- package/es/json.d.ts +0 -31
- package/es/json.js +0 -86
- package/es/mapState.js +0 -32
- package/es/match.d.ts +0 -9
- package/es/match.js +0 -34
- package/es/model.d.ts +0 -8
- package/es/model.js +0 -50
- package/es/model.types.d.ts +0 -56
- package/es/patterns.d.ts +0 -14
- package/es/patterns.js +0 -48
- package/es/registry.d.ts +0 -9
- package/es/registry.js +0 -19
- package/es/scheduler.d.ts +0 -17
- package/es/scheduler.js +0 -79
- package/es/schema.js +0 -6
- package/es/scxml.d.ts +0 -6
- package/es/serviceScope.d.ts +0 -4
- package/es/serviceScope.js +0 -16
- package/es/stateUtils.d.ts +0 -18
- package/es/stateUtils.js +0 -262
- package/es/typegenTypes.d.ts +0 -133
- package/es/types.d.ts +0 -1040
- package/es/types.js +0 -33
- package/es/utils.d.ts +0 -72
- package/es/utils.js +0 -622
- package/es/waitFor.d.ts +0 -34
- package/es/waitFor.js +0 -73
- package/lib/Actor.d.ts +0 -25
- package/lib/Actor.js +0 -108
- package/lib/Machine.d.ts +0 -12
- package/lib/Machine.js +0 -26
- package/lib/SimulatedClock.d.ts +0 -17
- package/lib/SimulatedClock.js +0 -85
- package/lib/State.d.ts +0 -123
- package/lib/State.js +0 -282
- package/lib/StateNode.d.ts +0 -282
- package/lib/StateNode.js +0 -1591
- package/lib/_virtual/_tslib.js +0 -85
- package/lib/actionTypes.d.ts +0 -20
- package/lib/actionTypes.js +0 -43
- package/lib/actions.d.ts +0 -157
- package/lib/actions.js +0 -662
- package/lib/behaviors.d.ts +0 -37
- package/lib/behaviors.js +0 -137
- package/lib/constants.d.ts +0 -6
- package/lib/constants.js +0 -13
- package/lib/each.d.ts +0 -4
- package/lib/each.js +0 -17
- package/lib/environment.d.ts +0 -2
- package/lib/environment.js +0 -7
- package/lib/index.d.ts +0 -22
- package/lib/index.js +0 -64
- package/lib/interpreter.d.ts +0 -217
- package/lib/interpreter.js +0 -1494
- package/lib/invoke.d.ts +0 -11
- package/lib/invoke.js +0 -20
- package/lib/invokeUtils.d.ts +0 -7
- package/lib/invokeUtils.js +0 -45
- package/lib/json.d.ts +0 -31
- package/lib/json.js +0 -94
- package/lib/mapState.d.ts +0 -4
- package/lib/mapState.js +0 -36
- package/lib/match.d.ts +0 -9
- package/lib/match.js +0 -38
- package/lib/model.d.ts +0 -8
- package/lib/model.js +0 -54
- package/lib/model.types.d.ts +0 -56
- package/lib/model.types.js +0 -2
- package/lib/patterns.d.ts +0 -14
- package/lib/patterns.js +0 -53
- package/lib/registry.d.ts +0 -9
- package/lib/registry.js +0 -23
- package/lib/scheduler.d.ts +0 -17
- package/lib/scheduler.js +0 -83
- package/lib/schema.d.ts +0 -3
- package/lib/schema.js +0 -11
- package/lib/scxml.d.ts +0 -6
- package/lib/scxml.js +0 -350
- package/lib/serviceScope.d.ts +0 -4
- package/lib/serviceScope.js +0 -21
- package/lib/stateUtils.d.ts +0 -18
- package/lib/stateUtils.js +0 -277
- package/lib/typegenTypes.js +0 -2
- package/lib/types.d.ts +0 -1040
- package/lib/types.js +0 -35
- package/lib/utils.d.ts +0 -72
- package/lib/utils.js +0 -669
- package/lib/waitFor.d.ts +0 -34
- package/lib/waitFor.js +0 -77
package/lib/waitFor.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _tslib = require('./_virtual/_tslib.js');
|
|
6
|
-
|
|
7
|
-
var defaultWaitForOptions = {
|
|
8
|
-
timeout: 10000 // 10 seconds
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Subscribes to an actor ref and waits for its emitted value to satisfy
|
|
13
|
-
* a predicate, and then resolves with that value.
|
|
14
|
-
* Will throw if the desired state is not reached after a timeout
|
|
15
|
-
* (defaults to 10 seconds).
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```js
|
|
19
|
-
* const state = await waitFor(someService, state => {
|
|
20
|
-
* return state.hasTag('loaded');
|
|
21
|
-
* });
|
|
22
|
-
*
|
|
23
|
-
* state.hasTag('loaded'); // true
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @param actorRef The actor ref to subscribe to
|
|
27
|
-
* @param predicate Determines if a value matches the condition to wait for
|
|
28
|
-
* @param options
|
|
29
|
-
* @returns A promise that eventually resolves to the emitted value
|
|
30
|
-
* that matches the condition
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
function waitFor(actorRef, predicate, options) {
|
|
34
|
-
var resolvedOptions = _tslib.__assign(_tslib.__assign({}, defaultWaitForOptions), options);
|
|
35
|
-
|
|
36
|
-
return new Promise(function (res, rej) {
|
|
37
|
-
var done = false;
|
|
38
|
-
|
|
39
|
-
if (process.env.NODE_ENV !== 'production' && resolvedOptions.timeout < 0) {
|
|
40
|
-
console.error('`timeout` passed to `waitFor` is negative and it will reject its internal promise immediately.');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
var handle = resolvedOptions.timeout === Infinity ? undefined : setTimeout(function () {
|
|
44
|
-
sub.unsubscribe();
|
|
45
|
-
rej(new Error("Timeout of ".concat(resolvedOptions.timeout, " ms exceeded")));
|
|
46
|
-
}, resolvedOptions.timeout);
|
|
47
|
-
|
|
48
|
-
var dispose = function () {
|
|
49
|
-
clearTimeout(handle);
|
|
50
|
-
done = true;
|
|
51
|
-
sub === null || sub === void 0 ? void 0 : sub.unsubscribe();
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
var sub = actorRef.subscribe({
|
|
55
|
-
next: function (emitted) {
|
|
56
|
-
if (predicate(emitted)) {
|
|
57
|
-
dispose();
|
|
58
|
-
res(emitted);
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
error: function (err) {
|
|
62
|
-
dispose();
|
|
63
|
-
rej(err);
|
|
64
|
-
},
|
|
65
|
-
complete: function () {
|
|
66
|
-
dispose();
|
|
67
|
-
rej(new Error("Actor terminated without satisfying predicate"));
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
if (done) {
|
|
72
|
-
sub.unsubscribe();
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
exports.waitFor = waitFor;
|