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/es/waitFor.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { __assign } from './_virtual/_tslib.js';
|
|
2
|
-
|
|
3
|
-
var defaultWaitForOptions = {
|
|
4
|
-
timeout: 10000 // 10 seconds
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Subscribes to an actor ref and waits for its emitted value to satisfy
|
|
9
|
-
* a predicate, and then resolves with that value.
|
|
10
|
-
* Will throw if the desired state is not reached after a timeout
|
|
11
|
-
* (defaults to 10 seconds).
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```js
|
|
15
|
-
* const state = await waitFor(someService, state => {
|
|
16
|
-
* return state.hasTag('loaded');
|
|
17
|
-
* });
|
|
18
|
-
*
|
|
19
|
-
* state.hasTag('loaded'); // true
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* @param actorRef The actor ref to subscribe to
|
|
23
|
-
* @param predicate Determines if a value matches the condition to wait for
|
|
24
|
-
* @param options
|
|
25
|
-
* @returns A promise that eventually resolves to the emitted value
|
|
26
|
-
* that matches the condition
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
function waitFor(actorRef, predicate, options) {
|
|
30
|
-
var resolvedOptions = __assign(__assign({}, defaultWaitForOptions), options);
|
|
31
|
-
|
|
32
|
-
return new Promise(function (res, rej) {
|
|
33
|
-
var done = false;
|
|
34
|
-
|
|
35
|
-
if (process.env.NODE_ENV !== 'production' && resolvedOptions.timeout < 0) {
|
|
36
|
-
console.error('`timeout` passed to `waitFor` is negative and it will reject its internal promise immediately.');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
var handle = resolvedOptions.timeout === Infinity ? undefined : setTimeout(function () {
|
|
40
|
-
sub.unsubscribe();
|
|
41
|
-
rej(new Error("Timeout of ".concat(resolvedOptions.timeout, " ms exceeded")));
|
|
42
|
-
}, resolvedOptions.timeout);
|
|
43
|
-
|
|
44
|
-
var dispose = function () {
|
|
45
|
-
clearTimeout(handle);
|
|
46
|
-
done = true;
|
|
47
|
-
sub === null || sub === void 0 ? void 0 : sub.unsubscribe();
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
var sub = actorRef.subscribe({
|
|
51
|
-
next: function (emitted) {
|
|
52
|
-
if (predicate(emitted)) {
|
|
53
|
-
dispose();
|
|
54
|
-
res(emitted);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
error: function (err) {
|
|
58
|
-
dispose();
|
|
59
|
-
rej(err);
|
|
60
|
-
},
|
|
61
|
-
complete: function () {
|
|
62
|
-
dispose();
|
|
63
|
-
rej(new Error("Actor terminated without satisfying predicate"));
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
if (done) {
|
|
68
|
-
sub.unsubscribe();
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export { waitFor };
|
package/lib/Actor.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { EventObject, Subscribable, InvokeDefinition, AnyEventObject, StateMachine, Spawnable, SCXML, ActorRef, BaseActorRef } from './types';
|
|
2
|
-
export interface Actor<TContext = any, TEvent extends EventObject = AnyEventObject> extends Subscribable<TContext> {
|
|
3
|
-
id: string;
|
|
4
|
-
send: (event: TEvent) => any;
|
|
5
|
-
stop?: () => any | undefined;
|
|
6
|
-
toJSON: () => {
|
|
7
|
-
id: string;
|
|
8
|
-
};
|
|
9
|
-
meta?: InvokeDefinition<TContext, TEvent>;
|
|
10
|
-
state?: any;
|
|
11
|
-
deferred?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare function createNullActor(id: string): ActorRef<any>;
|
|
14
|
-
/**
|
|
15
|
-
* Creates a deferred actor that is able to be invoked given the provided
|
|
16
|
-
* invocation information in its `.meta` value.
|
|
17
|
-
*
|
|
18
|
-
* @param invokeDefinition The meta information needed to invoke the actor.
|
|
19
|
-
*/
|
|
20
|
-
export declare function createInvocableActor<TC, TE extends EventObject>(invokeDefinition: InvokeDefinition<TC, TE>, machine: StateMachine<TC, any, TE, any>, context: TC, _event: SCXML.Event<TE>): ActorRef<any>;
|
|
21
|
-
export declare function createDeferredActor(entity: Spawnable, id: string, data?: any): ActorRef<any, undefined>;
|
|
22
|
-
export declare function isActor(item: any): item is ActorRef<any>;
|
|
23
|
-
export declare function isSpawnedActor(item: any): item is ActorRef<any>;
|
|
24
|
-
export declare function toActorRef<TEvent extends EventObject, TEmitted = any, TActorRefLike extends BaseActorRef<TEvent> = BaseActorRef<TEvent>>(actorRefLike: TActorRefLike): ActorRef<TEvent, TEmitted> & Omit<TActorRefLike, keyof ActorRef<any, any>>;
|
|
25
|
-
//# sourceMappingURL=Actor.d.ts.map
|
package/lib/Actor.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _tslib = require('./_virtual/_tslib.js');
|
|
6
|
-
var utils = require('./utils.js');
|
|
7
|
-
var serviceScope = require('./serviceScope.js');
|
|
8
|
-
|
|
9
|
-
function createNullActor(id) {
|
|
10
|
-
var _a;
|
|
11
|
-
|
|
12
|
-
return _a = {
|
|
13
|
-
id: id,
|
|
14
|
-
send: function () {
|
|
15
|
-
return void 0;
|
|
16
|
-
},
|
|
17
|
-
subscribe: function () {
|
|
18
|
-
return {
|
|
19
|
-
unsubscribe: function () {
|
|
20
|
-
return void 0;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
},
|
|
24
|
-
getSnapshot: function () {
|
|
25
|
-
return undefined;
|
|
26
|
-
},
|
|
27
|
-
toJSON: function () {
|
|
28
|
-
return {
|
|
29
|
-
id: id
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}, _a[utils.symbolObservable] = function () {
|
|
33
|
-
return this;
|
|
34
|
-
}, _a;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Creates a deferred actor that is able to be invoked given the provided
|
|
38
|
-
* invocation information in its `.meta` value.
|
|
39
|
-
*
|
|
40
|
-
* @param invokeDefinition The meta information needed to invoke the actor.
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
function createInvocableActor(invokeDefinition, machine, context, _event) {
|
|
44
|
-
var _a;
|
|
45
|
-
|
|
46
|
-
var invokeSrc = utils.toInvokeSource(invokeDefinition.src);
|
|
47
|
-
var serviceCreator = (_a = machine === null || machine === void 0 ? void 0 : machine.options.services) === null || _a === void 0 ? void 0 : _a[invokeSrc.type];
|
|
48
|
-
var resolvedData = invokeDefinition.data ? utils.mapContext(invokeDefinition.data, context, _event) : undefined;
|
|
49
|
-
var tempActor = serviceCreator ? createDeferredActor(serviceCreator, invokeDefinition.id, resolvedData) : createNullActor(invokeDefinition.id); // @ts-ignore
|
|
50
|
-
|
|
51
|
-
tempActor.meta = invokeDefinition;
|
|
52
|
-
return tempActor;
|
|
53
|
-
}
|
|
54
|
-
function createDeferredActor(entity, id, data) {
|
|
55
|
-
var tempActor = createNullActor(id); // @ts-ignore
|
|
56
|
-
|
|
57
|
-
tempActor.deferred = true;
|
|
58
|
-
|
|
59
|
-
if (utils.isMachine(entity)) {
|
|
60
|
-
// "mute" the existing service scope so potential spawned actors within the `.initialState` stay deferred here
|
|
61
|
-
var initialState_1 = tempActor.state = serviceScope.provide(undefined, function () {
|
|
62
|
-
return (data ? entity.withContext(data) : entity).initialState;
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
tempActor.getSnapshot = function () {
|
|
66
|
-
return initialState_1;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return tempActor;
|
|
71
|
-
}
|
|
72
|
-
function isActor(item) {
|
|
73
|
-
try {
|
|
74
|
-
return typeof item.send === 'function';
|
|
75
|
-
} catch (e) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function isSpawnedActor(item) {
|
|
80
|
-
return isActor(item) && 'id' in item;
|
|
81
|
-
} // TODO: refactor the return type, this could be written in a better way but it's best to avoid unneccessary breaking changes now
|
|
82
|
-
|
|
83
|
-
function toActorRef(actorRefLike) {
|
|
84
|
-
var _a;
|
|
85
|
-
|
|
86
|
-
return _tslib.__assign((_a = {
|
|
87
|
-
subscribe: function () {
|
|
88
|
-
return {
|
|
89
|
-
unsubscribe: function () {
|
|
90
|
-
return void 0;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
},
|
|
94
|
-
id: 'anonymous',
|
|
95
|
-
getSnapshot: function () {
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
}, _a[utils.symbolObservable] = function () {
|
|
99
|
-
return this;
|
|
100
|
-
}, _a), actorRefLike);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
exports.createDeferredActor = createDeferredActor;
|
|
104
|
-
exports.createInvocableActor = createInvocableActor;
|
|
105
|
-
exports.createNullActor = createNullActor;
|
|
106
|
-
exports.isActor = isActor;
|
|
107
|
-
exports.isSpawnedActor = isSpawnedActor;
|
|
108
|
-
exports.toActorRef = toActorRef;
|
package/lib/Machine.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AnyEventObject, BaseActionObject, DefaultContext, EventObject, MachineConfig, InternalMachineOptions, StateMachine, StateSchema, Typestate, ServiceMap } from './types';
|
|
2
|
-
import { TypegenConstraint, TypegenDisabled, ResolveTypegenMeta } from './typegenTypes';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated Use `createMachine(...)` instead.
|
|
5
|
-
*/
|
|
6
|
-
export declare function Machine<TContext = any, TEvent extends EventObject = AnyEventObject>(config: MachineConfig<TContext, any, TEvent>, options?: InternalMachineOptions<TContext, TEvent, ResolveTypegenMeta<TypegenDisabled, TEvent, BaseActionObject, ServiceMap>>, initialContext?: TContext): StateMachine<TContext, any, TEvent, any, BaseActionObject, ServiceMap, ResolveTypegenMeta<TypegenDisabled, TEvent, BaseActionObject, ServiceMap>>;
|
|
7
|
-
export declare function Machine<TContext = DefaultContext, TStateSchema extends StateSchema = any, TEvent extends EventObject = AnyEventObject>(config: MachineConfig<TContext, TStateSchema, TEvent>, options?: InternalMachineOptions<TContext, TEvent, ResolveTypegenMeta<TypegenDisabled, TEvent, BaseActionObject, ServiceMap>>, initialContext?: TContext): StateMachine<TContext, TStateSchema, TEvent, any, BaseActionObject, ServiceMap, ResolveTypegenMeta<TypegenDisabled, TEvent, BaseActionObject, ServiceMap>>;
|
|
8
|
-
export declare function createMachine<TContext, TEvent extends EventObject = AnyEventObject, TTypestate extends Typestate<TContext> = {
|
|
9
|
-
value: any;
|
|
10
|
-
context: TContext;
|
|
11
|
-
}, TServiceMap extends ServiceMap = ServiceMap, TTypesMeta extends TypegenConstraint = TypegenDisabled>(config: MachineConfig<TContext, any, TEvent, BaseActionObject, TServiceMap, TTypesMeta>, options?: InternalMachineOptions<TContext, TEvent, ResolveTypegenMeta<TTypesMeta, TEvent, BaseActionObject, TServiceMap>>): StateMachine<TContext, any, TEvent, TTypestate, BaseActionObject, TServiceMap, ResolveTypegenMeta<TTypesMeta, TEvent, BaseActionObject, TServiceMap>>;
|
|
12
|
-
//# sourceMappingURL=Machine.d.ts.map
|
package/lib/Machine.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var StateNode = require('./StateNode.js');
|
|
6
|
-
var environment = require('./environment.js');
|
|
7
|
-
|
|
8
|
-
var warned = false;
|
|
9
|
-
function Machine(config, options, initialContext) {
|
|
10
|
-
if (initialContext === void 0) {
|
|
11
|
-
initialContext = config.context;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return new StateNode.StateNode(config, options, initialContext);
|
|
15
|
-
}
|
|
16
|
-
function createMachine(config, options) {
|
|
17
|
-
if (!environment.IS_PRODUCTION && !('predictableActionArguments' in config) && !warned) {
|
|
18
|
-
warned = true;
|
|
19
|
-
console.warn('It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return new StateNode.StateNode(config, options);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
exports.Machine = Machine;
|
|
26
|
-
exports.createMachine = createMachine;
|
package/lib/SimulatedClock.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Clock } from './interpreter';
|
|
2
|
-
export interface SimulatedClock extends Clock {
|
|
3
|
-
start(speed: number): void;
|
|
4
|
-
increment(ms: number): void;
|
|
5
|
-
set(ms: number): void;
|
|
6
|
-
}
|
|
7
|
-
export declare class SimulatedClock implements SimulatedClock {
|
|
8
|
-
private timeouts;
|
|
9
|
-
private _now;
|
|
10
|
-
private _id;
|
|
11
|
-
now(): number;
|
|
12
|
-
private getId;
|
|
13
|
-
setTimeout(fn: (...args: any[]) => void, timeout: number): number;
|
|
14
|
-
clearTimeout(id: number): void;
|
|
15
|
-
private flushTimeouts;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=SimulatedClock.d.ts.map
|
package/lib/SimulatedClock.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _tslib = require('./_virtual/_tslib.js');
|
|
6
|
-
|
|
7
|
-
var SimulatedClock =
|
|
8
|
-
/*#__PURE__*/
|
|
9
|
-
|
|
10
|
-
/** @class */
|
|
11
|
-
function () {
|
|
12
|
-
function SimulatedClock() {
|
|
13
|
-
this.timeouts = new Map();
|
|
14
|
-
this._now = 0;
|
|
15
|
-
this._id = 0;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
SimulatedClock.prototype.now = function () {
|
|
19
|
-
return this._now;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
SimulatedClock.prototype.getId = function () {
|
|
23
|
-
return this._id++;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
SimulatedClock.prototype.setTimeout = function (fn, timeout) {
|
|
27
|
-
var id = this.getId();
|
|
28
|
-
this.timeouts.set(id, {
|
|
29
|
-
start: this.now(),
|
|
30
|
-
timeout: timeout,
|
|
31
|
-
fn: fn
|
|
32
|
-
});
|
|
33
|
-
return id;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
SimulatedClock.prototype.clearTimeout = function (id) {
|
|
37
|
-
this.timeouts.delete(id);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
SimulatedClock.prototype.set = function (time) {
|
|
41
|
-
if (this._now > time) {
|
|
42
|
-
throw new Error('Unable to travel back in time');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
this._now = time;
|
|
46
|
-
this.flushTimeouts();
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
SimulatedClock.prototype.flushTimeouts = function () {
|
|
50
|
-
var _this = this;
|
|
51
|
-
|
|
52
|
-
_tslib.__spreadArray([], _tslib.__read(this.timeouts), false).sort(function (_a, _b) {
|
|
53
|
-
var _c = _tslib.__read(_a, 2);
|
|
54
|
-
_c[0];
|
|
55
|
-
var timeoutA = _c[1];
|
|
56
|
-
|
|
57
|
-
var _d = _tslib.__read(_b, 2);
|
|
58
|
-
_d[0];
|
|
59
|
-
var timeoutB = _d[1];
|
|
60
|
-
|
|
61
|
-
var endA = timeoutA.start + timeoutA.timeout;
|
|
62
|
-
var endB = timeoutB.start + timeoutB.timeout;
|
|
63
|
-
return endB > endA ? -1 : 1;
|
|
64
|
-
}).forEach(function (_a) {
|
|
65
|
-
var _b = _tslib.__read(_a, 2),
|
|
66
|
-
id = _b[0],
|
|
67
|
-
timeout = _b[1];
|
|
68
|
-
|
|
69
|
-
if (_this.now() - timeout.start >= timeout.timeout) {
|
|
70
|
-
_this.timeouts.delete(id);
|
|
71
|
-
|
|
72
|
-
timeout.fn.call(null);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
SimulatedClock.prototype.increment = function (ms) {
|
|
78
|
-
this._now += ms;
|
|
79
|
-
this.flushTimeouts();
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
return SimulatedClock;
|
|
83
|
-
}();
|
|
84
|
-
|
|
85
|
-
exports.SimulatedClock = SimulatedClock;
|
package/lib/State.d.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { StateValue, ActivityMap, EventObject, HistoryValue, ActionObject, StateConfig, SCXML, StateSchema, TransitionDefinition, Typestate, ActorRef, StateMachine, SimpleEventsOf } from './types';
|
|
2
|
-
import { StateNode } from './StateNode';
|
|
3
|
-
import { TypegenDisabled, TypegenEnabled } from './typegenTypes';
|
|
4
|
-
import { BaseActionObject, Prop } from './types';
|
|
5
|
-
export declare function stateValuesEqual(a: StateValue | undefined, b: StateValue | undefined): boolean;
|
|
6
|
-
export declare function isStateConfig<TContext, TEvent extends EventObject>(state: any): state is StateConfig<TContext, TEvent>;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated Use `isStateConfig(object)` or `state instanceof State` instead.
|
|
9
|
-
*/
|
|
10
|
-
export declare const isState: typeof isStateConfig;
|
|
11
|
-
export declare function bindActionToState<TC, TE extends EventObject>(action: ActionObject<TC, TE>, state: State<TC, TE, any, any, any>): ActionObject<TC, TE>;
|
|
12
|
-
export declare class State<TContext, TEvent extends EventObject = EventObject, TStateSchema extends StateSchema<TContext> = any, TTypestate extends Typestate<TContext> = {
|
|
13
|
-
value: any;
|
|
14
|
-
context: TContext;
|
|
15
|
-
}, TResolvedTypesMeta = TypegenDisabled> {
|
|
16
|
-
value: StateValue;
|
|
17
|
-
context: TContext;
|
|
18
|
-
historyValue?: HistoryValue | undefined;
|
|
19
|
-
history?: State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>;
|
|
20
|
-
actions: Array<ActionObject<TContext, TEvent>>;
|
|
21
|
-
activities: ActivityMap;
|
|
22
|
-
meta: any;
|
|
23
|
-
events: TEvent[];
|
|
24
|
-
event: TEvent;
|
|
25
|
-
_event: SCXML.Event<TEvent>;
|
|
26
|
-
_sessionid: string | null;
|
|
27
|
-
/**
|
|
28
|
-
* Indicates whether the state has changed from the previous state. A state is considered "changed" if:
|
|
29
|
-
*
|
|
30
|
-
* - Its value is not equal to its previous value, or:
|
|
31
|
-
* - It has any new actions (side-effects) to execute.
|
|
32
|
-
*
|
|
33
|
-
* An initial state (with no history) will return `undefined`.
|
|
34
|
-
*/
|
|
35
|
-
changed: boolean | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* Indicates whether the state is a final state.
|
|
38
|
-
*/
|
|
39
|
-
done: boolean | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* The enabled state nodes representative of the state value.
|
|
42
|
-
*/
|
|
43
|
-
configuration: Array<StateNode<TContext, any, TEvent, any, any>>;
|
|
44
|
-
/**
|
|
45
|
-
* The next events that will cause a transition from the current state.
|
|
46
|
-
*/
|
|
47
|
-
nextEvents: Array<TEvent['type']>;
|
|
48
|
-
/**
|
|
49
|
-
* The transition definitions that resulted in this state.
|
|
50
|
-
*/
|
|
51
|
-
transitions: Array<TransitionDefinition<TContext, TEvent>>;
|
|
52
|
-
/**
|
|
53
|
-
* An object mapping actor IDs to spawned actors/invoked services.
|
|
54
|
-
*/
|
|
55
|
-
children: Record<string, ActorRef<any>>;
|
|
56
|
-
tags: Set<string>;
|
|
57
|
-
machine: StateMachine<TContext, any, TEvent, TTypestate, BaseActionObject, any, TResolvedTypesMeta> | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Creates a new State instance for the given `stateValue` and `context`.
|
|
60
|
-
* @param stateValue
|
|
61
|
-
* @param context
|
|
62
|
-
*/
|
|
63
|
-
static from<TC, TE extends EventObject = EventObject>(stateValue: State<TC, TE, any, any, any> | StateValue, context?: TC | undefined): State<TC, TE, any, any, any>;
|
|
64
|
-
/**
|
|
65
|
-
* Creates a new State instance for the given `config`.
|
|
66
|
-
* @param config The state config
|
|
67
|
-
*/
|
|
68
|
-
static create<TC, TE extends EventObject = EventObject>(config: StateConfig<TC, TE>): State<TC, TE, any, any, any>;
|
|
69
|
-
/**
|
|
70
|
-
* Creates a new `State` instance for the given `stateValue` and `context` with no actions (side-effects).
|
|
71
|
-
* @param stateValue
|
|
72
|
-
* @param context
|
|
73
|
-
*/
|
|
74
|
-
static inert<TC, TE extends EventObject = EventObject>(stateValue: State<TC, TE, any, any, any> | StateValue, context: TC): State<TC, TE>;
|
|
75
|
-
/**
|
|
76
|
-
* Creates a new State instance.
|
|
77
|
-
* @param value The state value
|
|
78
|
-
* @param context The extended state
|
|
79
|
-
* @param historyValue The tree representing historical values of the state nodes
|
|
80
|
-
* @param history The previous state
|
|
81
|
-
* @param actions An array of action objects to execute as side-effects
|
|
82
|
-
* @param activities A mapping of activities and whether they are started (`true`) or stopped (`false`).
|
|
83
|
-
* @param meta
|
|
84
|
-
* @param events Internal event queue. Should be empty with run-to-completion semantics.
|
|
85
|
-
* @param configuration
|
|
86
|
-
*/
|
|
87
|
-
constructor(config: StateConfig<TContext, TEvent>);
|
|
88
|
-
/**
|
|
89
|
-
* Returns an array of all the string leaf state node paths.
|
|
90
|
-
* @param stateValue
|
|
91
|
-
* @param delimiter The character(s) that separate each subpath in the string state node path.
|
|
92
|
-
*/
|
|
93
|
-
toStrings(stateValue?: StateValue, delimiter?: string): string[];
|
|
94
|
-
toJSON(): Omit<this, "machine" | "configuration" | "transitions" | "tags" | "toStrings" | "toJSON" | "matches" | "hasTag" | "can"> & {
|
|
95
|
-
tags: string[];
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Whether the current state value is a subset of the given parent state value.
|
|
99
|
-
* @param parentStateValue
|
|
100
|
-
*/
|
|
101
|
-
matches<TSV extends TResolvedTypesMeta extends TypegenEnabled ? Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'matchesStates'> : never>(parentStateValue: TSV): boolean;
|
|
102
|
-
matches<TSV extends TResolvedTypesMeta extends TypegenDisabled ? TTypestate['value'] : never>(parentStateValue: TSV): this is State<(TTypestate extends any ? {
|
|
103
|
-
value: TSV;
|
|
104
|
-
context: any;
|
|
105
|
-
} extends TTypestate ? TTypestate : never : never)['context'], TEvent, TStateSchema, TTypestate, TResolvedTypesMeta> & {
|
|
106
|
-
value: TSV;
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Whether the current state configuration has a state node with the specified `tag`.
|
|
110
|
-
* @param tag
|
|
111
|
-
*/
|
|
112
|
-
hasTag(tag: TResolvedTypesMeta extends TypegenEnabled ? Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'tags'> : string): boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Determines whether sending the `event` will cause a non-forbidden transition
|
|
115
|
-
* to be selected, even if the transitions have no actions nor
|
|
116
|
-
* change the state value.
|
|
117
|
-
*
|
|
118
|
-
* @param event The event to test
|
|
119
|
-
* @returns Whether the event will cause a transition
|
|
120
|
-
*/
|
|
121
|
-
can(event: TEvent | SimpleEventsOf<TEvent>['type']): boolean;
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=State.d.ts.map
|