xstate 6.0.0-alpha.61 → 6.0.0-alpha.62
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/{createActor-0d08a5f3.development.esm.js → createActor-55f62c08.development.esm.js} +17 -6
- package/dist/{createActor-81470538.development.cjs.js → createActor-6d6bfee1.development.cjs.js} +17 -6
- package/dist/{createActor-3347cc32.cjs.js → createActor-8dfa9b5c.cjs.js} +14 -6
- package/dist/{createActor-f4b06bda.esm.js → createActor-f9b188f2.esm.js} +14 -6
- package/dist/declarations/src/StateMachine.d.ts +15 -7
- package/dist/declarations/src/createActor.d.ts +2 -4
- package/dist/declarations/src/createMachineFromConfig.d.ts +5 -0
- package/dist/declarations/src/setup.d.ts +1 -1
- package/dist/declarations/src/types.d.ts +3 -8
- package/dist/declarations/src/types.v6.d.ts +0 -5
- package/dist/{effectDescriptor-f4708cf3.cjs.js → effectDescriptor-0a7315fa.cjs.js} +1 -1
- package/dist/{effectDescriptor-dbd6ef85.esm.js → effectDescriptor-35129133.esm.js} +1 -1
- package/dist/{effectDescriptor-31a53206.development.esm.js → effectDescriptor-5048c471.development.esm.js} +1 -1
- package/dist/{effectDescriptor-a1ea3f94.development.cjs.js → effectDescriptor-a3ff2473.development.cjs.js} +1 -1
- package/dist/{index-2384b028.development.cjs.js → index-05e9e83b.development.cjs.js} +1 -1
- package/dist/{index-eee6a6a1.cjs.js → index-ad40a951.cjs.js} +1 -1
- package/dist/{index-ff1d8226.esm.js → index-e5f3a62b.esm.js} +1 -1
- package/dist/{index-1e523796.development.esm.js → index-eda79ddc.development.esm.js} +1 -1
- package/dist/xstate-actors.cjs.js +2 -2
- package/dist/xstate-actors.development.cjs.js +2 -2
- package/dist/xstate-actors.development.esm.js +2 -2
- package/dist/xstate-actors.esm.js +2 -2
- package/dist/xstate-actors.umd.min.js +1 -1
- package/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/xstate-durable.cjs.js +2 -2
- package/dist/xstate-durable.development.cjs.js +2 -2
- package/dist/xstate-durable.development.esm.js +2 -2
- package/dist/xstate-durable.esm.js +2 -2
- package/dist/xstate-durable.umd.min.js +1 -1
- package/dist/xstate-durable.umd.min.js.map +1 -1
- package/dist/xstate-graph.cjs.js +2 -2
- package/dist/xstate-graph.development.cjs.js +2 -2
- package/dist/xstate-graph.development.esm.js +2 -2
- package/dist/xstate-graph.esm.js +2 -2
- package/dist/xstate-graph.umd.min.js +1 -1
- package/dist/xstate-graph.umd.min.js.map +1 -1
- package/dist/xstate-validation.cjs.js +1 -1
- package/dist/xstate-validation.development.cjs.js +1 -1
- package/dist/xstate-validation.development.esm.js +1 -1
- package/dist/xstate-validation.esm.js +1 -1
- package/dist/xstate.cjs.js +23 -6
- package/dist/xstate.development.cjs.js +25 -7
- package/dist/xstate.development.esm.js +27 -9
- package/dist/xstate.esm.js +25 -8
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/{createActor-0d08a5f3.development.esm.js → createActor-55f62c08.development.esm.js}
RENAMED
|
@@ -2097,11 +2097,19 @@ function getCandidates(stateNode, event) {
|
|
|
2097
2097
|
function scheduleDelayedEvent(stateNode, timerId, resolveEvent, resolveScheduledDelay) {
|
|
2098
2098
|
const oldEntry = stateNode.entry;
|
|
2099
2099
|
stateNode.entry = (x, enq) => {
|
|
2100
|
+
const result = typeof oldEntry === 'function' ? oldEntry(x, enq) : undefined;
|
|
2101
|
+
// The entry context patch is applied by the caller after this wrapper returns.
|
|
2102
|
+
const context = result?.context !== undefined ? mergeContextPatch(x.context, result.context) : x.context;
|
|
2100
2103
|
enq.raise(resolveEvent(x), {
|
|
2101
2104
|
id: timerId,
|
|
2102
|
-
delay: resolveScheduledDelay(
|
|
2105
|
+
delay: resolveScheduledDelay({
|
|
2106
|
+
context,
|
|
2107
|
+
event: x.event,
|
|
2108
|
+
delays: x.delays,
|
|
2109
|
+
input: x.input
|
|
2110
|
+
})
|
|
2103
2111
|
});
|
|
2104
|
-
return
|
|
2112
|
+
return result;
|
|
2105
2113
|
};
|
|
2106
2114
|
const oldExit = stateNode.exit;
|
|
2107
2115
|
stateNode.exit = (_, enq) => {
|
|
@@ -5412,6 +5420,9 @@ class Actor {
|
|
|
5412
5420
|
this._deferred = void 0;
|
|
5413
5421
|
this._restored = false;
|
|
5414
5422
|
this._warnedUnhandledTypes = void 0;
|
|
5423
|
+
if (options && 'state' in options) {
|
|
5424
|
+
throw new Error('The "state" actor option was removed. Pass the persisted snapshot as "snapshot" instead: createActor(logic, { snapshot }).');
|
|
5425
|
+
}
|
|
5415
5426
|
const resolvedOptions = options ? {
|
|
5416
5427
|
...defaultOptions,
|
|
5417
5428
|
...options
|
|
@@ -5428,7 +5439,7 @@ class Actor {
|
|
|
5428
5439
|
this.system = parent ? parent.system : resolvedOptions._systemRef?.current ?? createRuntimeSystem(this, {
|
|
5429
5440
|
clock,
|
|
5430
5441
|
logger,
|
|
5431
|
-
snapshot: resolvedOptions.snapshot
|
|
5442
|
+
snapshot: resolvedOptions.snapshot,
|
|
5432
5443
|
createActorRef
|
|
5433
5444
|
});
|
|
5434
5445
|
if (!parent && resolvedOptions._systemRef && !resolvedOptions._systemRef.current) {
|
|
@@ -5461,7 +5472,7 @@ class Actor {
|
|
|
5461
5472
|
|
|
5462
5473
|
// prepare to collect initial microsteps during initialTransition
|
|
5463
5474
|
this._collectedMicrosteps = undefined;
|
|
5464
|
-
const persistedState = options?.snapshot
|
|
5475
|
+
const persistedState = options?.snapshot;
|
|
5465
5476
|
this._restored = persistedState !== undefined;
|
|
5466
5477
|
try {
|
|
5467
5478
|
if (persistedState) {
|
|
@@ -6223,7 +6234,7 @@ class Actor {
|
|
|
6223
6234
|
* {@link Actor.getSnapshot}. Persisted state represents the internal state of
|
|
6224
6235
|
* the actor, while snapshots represent the actor's last emitted value.
|
|
6225
6236
|
*
|
|
6226
|
-
* Can be restored with {@link ActorOptions.
|
|
6237
|
+
* Can be restored with {@link ActorOptions.snapshot}
|
|
6227
6238
|
* @see https://stately.ai/docs/persistence
|
|
6228
6239
|
*/
|
|
6229
6240
|
|
|
@@ -6271,7 +6282,7 @@ class Actor {
|
|
|
6271
6282
|
|
|
6272
6283
|
/**
|
|
6273
6284
|
* The options `createActor` (and framework hooks) require for `TLogic`:
|
|
6274
|
-
* `{ input }` or a persisted `{ snapshot }`
|
|
6285
|
+
* `{ input }` or a persisted `{ snapshot }` when
|
|
6275
6286
|
* the logic requires input, otherwise nothing.
|
|
6276
6287
|
*
|
|
6277
6288
|
* @public
|
package/dist/{createActor-81470538.development.cjs.js → createActor-6d6bfee1.development.cjs.js}
RENAMED
|
@@ -2099,11 +2099,19 @@ function getCandidates(stateNode, event) {
|
|
|
2099
2099
|
function scheduleDelayedEvent(stateNode, timerId, resolveEvent, resolveScheduledDelay) {
|
|
2100
2100
|
const oldEntry = stateNode.entry;
|
|
2101
2101
|
stateNode.entry = (x, enq) => {
|
|
2102
|
+
const result = typeof oldEntry === 'function' ? oldEntry(x, enq) : undefined;
|
|
2103
|
+
// The entry context patch is applied by the caller after this wrapper returns.
|
|
2104
|
+
const context = result?.context !== undefined ? mergeContextPatch(x.context, result.context) : x.context;
|
|
2102
2105
|
enq.raise(resolveEvent(x), {
|
|
2103
2106
|
id: timerId,
|
|
2104
|
-
delay: resolveScheduledDelay(
|
|
2107
|
+
delay: resolveScheduledDelay({
|
|
2108
|
+
context,
|
|
2109
|
+
event: x.event,
|
|
2110
|
+
delays: x.delays,
|
|
2111
|
+
input: x.input
|
|
2112
|
+
})
|
|
2105
2113
|
});
|
|
2106
|
-
return
|
|
2114
|
+
return result;
|
|
2107
2115
|
};
|
|
2108
2116
|
const oldExit = stateNode.exit;
|
|
2109
2117
|
stateNode.exit = (_, enq) => {
|
|
@@ -5414,6 +5422,9 @@ class Actor {
|
|
|
5414
5422
|
this._deferred = void 0;
|
|
5415
5423
|
this._restored = false;
|
|
5416
5424
|
this._warnedUnhandledTypes = void 0;
|
|
5425
|
+
if (options && 'state' in options) {
|
|
5426
|
+
throw new Error('The "state" actor option was removed. Pass the persisted snapshot as "snapshot" instead: createActor(logic, { snapshot }).');
|
|
5427
|
+
}
|
|
5417
5428
|
const resolvedOptions = options ? {
|
|
5418
5429
|
...defaultOptions,
|
|
5419
5430
|
...options
|
|
@@ -5430,7 +5441,7 @@ class Actor {
|
|
|
5430
5441
|
this.system = parent ? parent.system : resolvedOptions._systemRef?.current ?? createRuntimeSystem(this, {
|
|
5431
5442
|
clock,
|
|
5432
5443
|
logger,
|
|
5433
|
-
snapshot: resolvedOptions.snapshot
|
|
5444
|
+
snapshot: resolvedOptions.snapshot,
|
|
5434
5445
|
createActorRef
|
|
5435
5446
|
});
|
|
5436
5447
|
if (!parent && resolvedOptions._systemRef && !resolvedOptions._systemRef.current) {
|
|
@@ -5463,7 +5474,7 @@ class Actor {
|
|
|
5463
5474
|
|
|
5464
5475
|
// prepare to collect initial microsteps during initialTransition
|
|
5465
5476
|
this._collectedMicrosteps = undefined;
|
|
5466
|
-
const persistedState = options?.snapshot
|
|
5477
|
+
const persistedState = options?.snapshot;
|
|
5467
5478
|
this._restored = persistedState !== undefined;
|
|
5468
5479
|
try {
|
|
5469
5480
|
if (persistedState) {
|
|
@@ -6225,7 +6236,7 @@ class Actor {
|
|
|
6225
6236
|
* {@link Actor.getSnapshot}. Persisted state represents the internal state of
|
|
6226
6237
|
* the actor, while snapshots represent the actor's last emitted value.
|
|
6227
6238
|
*
|
|
6228
|
-
* Can be restored with {@link ActorOptions.
|
|
6239
|
+
* Can be restored with {@link ActorOptions.snapshot}
|
|
6229
6240
|
* @see https://stately.ai/docs/persistence
|
|
6230
6241
|
*/
|
|
6231
6242
|
|
|
@@ -6273,7 +6284,7 @@ class Actor {
|
|
|
6273
6284
|
|
|
6274
6285
|
/**
|
|
6275
6286
|
* The options `createActor` (and framework hooks) require for `TLogic`:
|
|
6276
|
-
* `{ input }` or a persisted `{ snapshot }`
|
|
6287
|
+
* `{ input }` or a persisted `{ snapshot }` when
|
|
6277
6288
|
* the logic requires input, otherwise nothing.
|
|
6278
6289
|
*
|
|
6279
6290
|
* @public
|
|
@@ -2089,11 +2089,19 @@ function getCandidates(stateNode, event) {
|
|
|
2089
2089
|
function scheduleDelayedEvent(stateNode, timerId, resolveEvent, resolveScheduledDelay) {
|
|
2090
2090
|
const oldEntry = stateNode.entry;
|
|
2091
2091
|
stateNode.entry = (x, enq) => {
|
|
2092
|
+
const result = typeof oldEntry === 'function' ? oldEntry(x, enq) : undefined;
|
|
2093
|
+
// The entry context patch is applied by the caller after this wrapper returns.
|
|
2094
|
+
const context = result?.context !== undefined ? mergeContextPatch(x.context, result.context) : x.context;
|
|
2092
2095
|
enq.raise(resolveEvent(x), {
|
|
2093
2096
|
id: timerId,
|
|
2094
|
-
delay: resolveScheduledDelay(
|
|
2097
|
+
delay: resolveScheduledDelay({
|
|
2098
|
+
context,
|
|
2099
|
+
event: x.event,
|
|
2100
|
+
delays: x.delays,
|
|
2101
|
+
input: x.input
|
|
2102
|
+
})
|
|
2095
2103
|
});
|
|
2096
|
-
return
|
|
2104
|
+
return result;
|
|
2097
2105
|
};
|
|
2098
2106
|
const oldExit = stateNode.exit;
|
|
2099
2107
|
stateNode.exit = (_, enq) => {
|
|
@@ -5303,7 +5311,7 @@ class Actor {
|
|
|
5303
5311
|
this.system = parent ? parent.system : resolvedOptions._systemRef?.current ?? createRuntimeSystem(this, {
|
|
5304
5312
|
clock,
|
|
5305
5313
|
logger,
|
|
5306
|
-
snapshot: resolvedOptions.snapshot
|
|
5314
|
+
snapshot: resolvedOptions.snapshot,
|
|
5307
5315
|
createActorRef
|
|
5308
5316
|
});
|
|
5309
5317
|
if (!parent && resolvedOptions._systemRef && !resolvedOptions._systemRef.current) {
|
|
@@ -5336,7 +5344,7 @@ class Actor {
|
|
|
5336
5344
|
|
|
5337
5345
|
// prepare to collect initial microsteps during initialTransition
|
|
5338
5346
|
this._collectedMicrosteps = undefined;
|
|
5339
|
-
const persistedState = options?.snapshot
|
|
5347
|
+
const persistedState = options?.snapshot;
|
|
5340
5348
|
this._restored = persistedState !== undefined;
|
|
5341
5349
|
try {
|
|
5342
5350
|
if (persistedState) {
|
|
@@ -6088,7 +6096,7 @@ class Actor {
|
|
|
6088
6096
|
* {@link Actor.getSnapshot}. Persisted state represents the internal state of
|
|
6089
6097
|
* the actor, while snapshots represent the actor's last emitted value.
|
|
6090
6098
|
*
|
|
6091
|
-
* Can be restored with {@link ActorOptions.
|
|
6099
|
+
* Can be restored with {@link ActorOptions.snapshot}
|
|
6092
6100
|
* @see https://stately.ai/docs/persistence
|
|
6093
6101
|
*/
|
|
6094
6102
|
|
|
@@ -6133,7 +6141,7 @@ class Actor {
|
|
|
6133
6141
|
|
|
6134
6142
|
/**
|
|
6135
6143
|
* The options `createActor` (and framework hooks) require for `TLogic`:
|
|
6136
|
-
* `{ input }` or a persisted `{ snapshot }`
|
|
6144
|
+
* `{ input }` or a persisted `{ snapshot }` when
|
|
6137
6145
|
* the logic requires input, otherwise nothing.
|
|
6138
6146
|
*
|
|
6139
6147
|
* @public
|
|
@@ -2087,11 +2087,19 @@ function getCandidates(stateNode, event) {
|
|
|
2087
2087
|
function scheduleDelayedEvent(stateNode, timerId, resolveEvent, resolveScheduledDelay) {
|
|
2088
2088
|
const oldEntry = stateNode.entry;
|
|
2089
2089
|
stateNode.entry = (x, enq) => {
|
|
2090
|
+
const result = typeof oldEntry === 'function' ? oldEntry(x, enq) : undefined;
|
|
2091
|
+
// The entry context patch is applied by the caller after this wrapper returns.
|
|
2092
|
+
const context = result?.context !== undefined ? mergeContextPatch(x.context, result.context) : x.context;
|
|
2090
2093
|
enq.raise(resolveEvent(x), {
|
|
2091
2094
|
id: timerId,
|
|
2092
|
-
delay: resolveScheduledDelay(
|
|
2095
|
+
delay: resolveScheduledDelay({
|
|
2096
|
+
context,
|
|
2097
|
+
event: x.event,
|
|
2098
|
+
delays: x.delays,
|
|
2099
|
+
input: x.input
|
|
2100
|
+
})
|
|
2093
2101
|
});
|
|
2094
|
-
return
|
|
2102
|
+
return result;
|
|
2095
2103
|
};
|
|
2096
2104
|
const oldExit = stateNode.exit;
|
|
2097
2105
|
stateNode.exit = (_, enq) => {
|
|
@@ -5301,7 +5309,7 @@ class Actor {
|
|
|
5301
5309
|
this.system = parent ? parent.system : resolvedOptions._systemRef?.current ?? createRuntimeSystem(this, {
|
|
5302
5310
|
clock,
|
|
5303
5311
|
logger,
|
|
5304
|
-
snapshot: resolvedOptions.snapshot
|
|
5312
|
+
snapshot: resolvedOptions.snapshot,
|
|
5305
5313
|
createActorRef
|
|
5306
5314
|
});
|
|
5307
5315
|
if (!parent && resolvedOptions._systemRef && !resolvedOptions._systemRef.current) {
|
|
@@ -5334,7 +5342,7 @@ class Actor {
|
|
|
5334
5342
|
|
|
5335
5343
|
// prepare to collect initial microsteps during initialTransition
|
|
5336
5344
|
this._collectedMicrosteps = undefined;
|
|
5337
|
-
const persistedState = options?.snapshot
|
|
5345
|
+
const persistedState = options?.snapshot;
|
|
5338
5346
|
this._restored = persistedState !== undefined;
|
|
5339
5347
|
try {
|
|
5340
5348
|
if (persistedState) {
|
|
@@ -6086,7 +6094,7 @@ class Actor {
|
|
|
6086
6094
|
* {@link Actor.getSnapshot}. Persisted state represents the internal state of
|
|
6087
6095
|
* the actor, while snapshots represent the actor's last emitted value.
|
|
6088
6096
|
*
|
|
6089
|
-
* Can be restored with {@link ActorOptions.
|
|
6097
|
+
* Can be restored with {@link ActorOptions.snapshot}
|
|
6090
6098
|
* @see https://stately.ai/docs/persistence
|
|
6091
6099
|
*/
|
|
6092
6100
|
|
|
@@ -6131,7 +6139,7 @@ class Actor {
|
|
|
6131
6139
|
|
|
6132
6140
|
/**
|
|
6133
6141
|
* The options `createActor` (and framework hooks) require for `TLogic`:
|
|
6134
|
-
* `{ input }` or a persisted `{ snapshot }`
|
|
6142
|
+
* `{ input }` or a persisted `{ snapshot }` when
|
|
6135
6143
|
* the logic requires input, otherwise nothing.
|
|
6136
6144
|
*
|
|
6137
6145
|
* @public
|
|
@@ -13,12 +13,17 @@ type CompatibleProvidedActorSource<TExpected extends AnyActorLogic, TActual exte
|
|
|
13
13
|
type ProvidedActors<TExpectedActorMap extends Sources['actors'], TProvidedActorMap extends Partial<Record<keyof TExpectedActorMap & string, AnyActorLogic>>> = {
|
|
14
14
|
[K in keyof TProvidedActorMap]: K extends keyof TExpectedActorMap ? TProvidedActorMap[K] extends AnyActorLogic ? CompatibleProvidedActorSource<TExpectedActorMap[K], TProvidedActorMap[K]> : never : never;
|
|
15
15
|
};
|
|
16
|
+
type ProvidedSourceMap<TDeclared, TProvided> = {
|
|
17
|
+
[K in keyof TDeclared]: K extends keyof TProvided ? {} extends Pick<TProvided, K> ? TDeclared[K] | Exclude<TProvided[K], undefined> : Exclude<TProvided[K], undefined> : TDeclared[K];
|
|
18
|
+
};
|
|
19
|
+
type ProvidedActionContracts<T> = {
|
|
20
|
+
[K in keyof T]: T[K] extends (...args: infer TArgs) => any ? (...args: TArgs) => void : never;
|
|
21
|
+
};
|
|
16
22
|
/** @public */
|
|
17
23
|
export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TInput, TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TConfig extends StateSchema, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TInternalEvent extends EventObject = never, TTransitionMeta extends MetaObject = TMeta> implements ActorLogic<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, TInput, AnyActorSystem, TEmitted> {
|
|
18
24
|
/** The raw config used to create the machine. */
|
|
19
25
|
config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any, any, any, any> & {
|
|
20
26
|
schemas?: AnyMachineSchemas;
|
|
21
|
-
internalEvents?: readonly string[];
|
|
22
27
|
};
|
|
23
28
|
validator?: ActorLogicValidator | undefined;
|
|
24
29
|
/**
|
|
@@ -49,7 +54,9 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
49
54
|
readonly _actorMap: TActorMap;
|
|
50
55
|
readonly _stateSchema: TConfig;
|
|
51
56
|
/** The machine's own version. */
|
|
52
|
-
version
|
|
57
|
+
version: TConfig extends {
|
|
58
|
+
version: infer TVersion extends string;
|
|
59
|
+
} ? TVersion : undefined;
|
|
53
60
|
schemas: AnyMachineSchemas | undefined;
|
|
54
61
|
/** Standard Schema for snapshots persisted by this machine version. */
|
|
55
62
|
readonly snapshotSchema: StandardSchemaV1<unknown, Snapshot<unknown> & PersistedMachineSnapshot & {
|
|
@@ -61,7 +68,9 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
61
68
|
/** Runtime options for machine execution. */
|
|
62
69
|
options: MachineOptions;
|
|
63
70
|
root: StateNode<TContext, TEvent, TMeta, TTransitionMeta>;
|
|
64
|
-
id:
|
|
71
|
+
id: TConfig extends {
|
|
72
|
+
id: infer TId extends string;
|
|
73
|
+
} ? TId : '(machine)';
|
|
65
74
|
states: StateNode<TContext, TEvent, TMeta, TTransitionMeta>['states'];
|
|
66
75
|
events: Array<EventDescriptor<TEvent>>;
|
|
67
76
|
internalEventDescriptors: ReadonlyArray<string>;
|
|
@@ -76,7 +85,6 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
76
85
|
/** The raw config used to create the machine. */
|
|
77
86
|
config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any, any, any, any> & {
|
|
78
87
|
schemas?: AnyMachineSchemas;
|
|
79
|
-
internalEvents?: readonly string[];
|
|
80
88
|
}, sources?: Sources, validator?: ActorLogicValidator | undefined);
|
|
81
89
|
/**
|
|
82
90
|
* Clones this state machine with the provided sources.
|
|
@@ -85,8 +93,8 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
85
93
|
* recursively merge with the existing options.
|
|
86
94
|
* @returns A new `StateMachine` instance with the provided sources.
|
|
87
95
|
*/
|
|
88
|
-
provide<const TProvidedActorMap extends Partial<Record<keyof TActorMap & string, AnyActorLogic>> = {}>(sources: {
|
|
89
|
-
actions?: Partial<TActionMap>;
|
|
96
|
+
provide<const TProvidedActorMap extends Partial<Record<keyof TActorMap & string, AnyActorLogic>> = {}, const TProvidedActionMap extends Partial<ProvidedActionContracts<TActionMap>> = {}>(sources: {
|
|
97
|
+
actions?: TProvidedActionMap & Partial<ProvidedActionContracts<TActionMap>> & Record<Exclude<keyof TProvidedActionMap, keyof TActionMap>, never>;
|
|
90
98
|
actors?: TProvidedActorMap & ProvidedActors<TActorMap, TProvidedActorMap>;
|
|
91
99
|
guards?: Partial<TGuardMap> & {
|
|
92
100
|
[K in keyof TGuardMap]?: GuardSourceMap<TContext, TEvent>[string];
|
|
@@ -94,7 +102,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
94
102
|
delays?: {
|
|
95
103
|
[K in keyof TDelayMap]?: DelaySourceMap<TContext, TEvent>[string];
|
|
96
104
|
};
|
|
97
|
-
}):
|
|
105
|
+
}): StateMachine<TContext, TEvent, TChildren, TStateValue, TTag, TInput, TOutput, TEmitted, TMeta, TConfig, ProvidedSourceMap<TActionMap, TProvidedActionMap>, ProvidedSourceMap<TActorMap, TProvidedActorMap>, TGuardMap, TDelayMap, TInternalEvent, TTransitionMeta>;
|
|
98
106
|
resolveState(config: {
|
|
99
107
|
value: StateValue;
|
|
100
108
|
context?: TContext;
|
|
@@ -202,7 +202,7 @@ export declare class Actor<TLogic extends AnyActorLogic> implements ActorInstanc
|
|
|
202
202
|
* {@link Actor.getSnapshot}. Persisted state represents the internal state of
|
|
203
203
|
* the actor, while snapshots represent the actor's last emitted value.
|
|
204
204
|
*
|
|
205
|
-
* Can be restored with {@link ActorOptions.
|
|
205
|
+
* Can be restored with {@link ActorOptions.snapshot}
|
|
206
206
|
* @see https://stately.ai/docs/persistence
|
|
207
207
|
*/
|
|
208
208
|
getPersistedSnapshot(options?: {
|
|
@@ -246,7 +246,7 @@ export declare class Actor<TLogic extends AnyActorLogic> implements ActorInstanc
|
|
|
246
246
|
export type RequiredActorOptionsKeys<TLogic extends AnyActorLogic> = undefined extends InputFrom<TLogic> ? never : 'input';
|
|
247
247
|
/**
|
|
248
248
|
* The options `createActor` (and framework hooks) require for `TLogic`:
|
|
249
|
-
* `{ input }` or a persisted `{ snapshot }`
|
|
249
|
+
* `{ input }` or a persisted `{ snapshot }` when
|
|
250
250
|
* the logic requires input, otherwise nothing.
|
|
251
251
|
*
|
|
252
252
|
* @public
|
|
@@ -257,8 +257,6 @@ export type RequiredActorOptionsFor<TLogic extends AnyActorLogic> = [
|
|
|
257
257
|
[K in RequiredActorOptionsKeys<TLogic>]: unknown;
|
|
258
258
|
} | {
|
|
259
259
|
snapshot: NonNullable<ActorOptions<TLogic>['snapshot']>;
|
|
260
|
-
} | {
|
|
261
|
-
state: NonNullable<ActorOptions<TLogic>['state']>;
|
|
262
260
|
};
|
|
263
261
|
/** Options accepted by {@link createActor}. */
|
|
264
262
|
type CreateActorOptionsArgs<TLogic extends AnyActorLogic> = [
|
|
@@ -123,6 +123,11 @@ export interface MachineJSON extends StateNodeJSON {
|
|
|
123
123
|
duration: number | string | ResolvableJSON;
|
|
124
124
|
}>;
|
|
125
125
|
schemas?: Record<string, unknown>;
|
|
126
|
+
/**
|
|
127
|
+
* Event types that only the machine itself (and its children) may send;
|
|
128
|
+
* external senders are rejected with reason `internalEvent`.
|
|
129
|
+
*/
|
|
130
|
+
internalEvents?: string[];
|
|
126
131
|
}
|
|
127
132
|
type EvaluatorSlot = 'context' | 'guard' | 'choice' | 'action' | 'actionParams' | 'transition' | 'input' | 'output' | 'delay' | 'transitionContext' | 'unknown';
|
|
128
133
|
type EvaluatorKind = 'expr' | 'code';
|
|
@@ -841,7 +841,7 @@ type PublicStateSchema<T extends StateSchema> = {
|
|
|
841
841
|
input: T extends {
|
|
842
842
|
input: infer TInput;
|
|
843
843
|
} ? TInput : undefined;
|
|
844
|
-
} & PublicStateField<T, 'id'> & PublicStateField<T, 'route'> & PublicStateField<T, 'type'> & PublicStateField<T, 'history'> & PublicStateField<T, 'target'> & PublicStateField<T, 'initial'> & PublicStateField<T, 'contextSchema'> & PublicStateField<T, 'outputSchema'> & PublicStateField<T, 'internalEvents'> & (T extends {
|
|
844
|
+
} & PublicStateField<T, 'id'> & PublicStateField<T, 'version'> & PublicStateField<T, 'route'> & PublicStateField<T, 'type'> & PublicStateField<T, 'history'> & PublicStateField<T, 'target'> & PublicStateField<T, 'initial'> & PublicStateField<T, 'contextSchema'> & PublicStateField<T, 'outputSchema'> & PublicStateField<T, 'internalEvents'> & (T extends {
|
|
845
845
|
invoke: infer TInvoke;
|
|
846
846
|
} ? {
|
|
847
847
|
invoke: PublicInvoke<TInvoke>;
|
|
@@ -275,11 +275,8 @@ export type NormalizeDescriptor<TDescriptor extends string> = TDescriptor extend
|
|
|
275
275
|
type EventTypeMatchesDescriptor<TEventType extends string, TDescriptor extends string> = TEventType extends NormalizeDescriptor<TDescriptor> ? true : false;
|
|
276
276
|
type IsInternalEventType<TEventType extends string, TDescriptors extends string> = string extends TDescriptors ? false : true extends (TDescriptors extends any ? EventTypeMatchesDescriptor<TEventType, TDescriptors> : never) ? true : false;
|
|
277
277
|
type ExcludeInternalEvents<TEvent extends EventObject, TDescriptors extends string> = TEvent extends any ? IsInternalEventType<TEvent['type'], TDescriptors> extends true ? never : TEvent : never;
|
|
278
|
-
type InternalEventDescriptorsFromConfig<TEvent extends EventObject, TConfig> = TConfig extends {
|
|
279
|
-
internalEvents?: readonly EventDescriptor<TEvent>[];
|
|
280
|
-
} ? TConfig['internalEvents'] extends readonly (infer TDesc)[] ? Extract<TDesc, string> : never : never;
|
|
281
278
|
type InternalEventTypes<TInternalEvent extends EventObject> = TInternalEvent extends any ? TInternalEvent['type'] : never;
|
|
282
|
-
type SendableEventFromMachine<TEvent extends EventObject, TInternalEvent extends EventObject
|
|
279
|
+
type SendableEventFromMachine<TEvent extends EventObject, TInternalEvent extends EventObject> = IsAny<TInternalEvent> extends true ? TEvent : ExcludeInternalEvents<TEvent, InternalEventTypes<TInternalEvent>>;
|
|
283
280
|
/** @public */
|
|
284
281
|
export type IsLiteralString<T extends string> = string extends T ? false : true;
|
|
285
282
|
type ActorsBySrc<TActor extends ProvidedActor> = {
|
|
@@ -796,8 +793,6 @@ export interface ActorOptions<TLogic extends AnyActorLogic> {
|
|
|
796
793
|
* @see https://stately.ai/docs/persistence
|
|
797
794
|
*/
|
|
798
795
|
snapshot?: Snapshot<unknown> & Partial<RestorablePersistedSnapshotFor<DoNotInfer<TLogic>>>;
|
|
799
|
-
/** @deprecated Use `snapshot` instead. */
|
|
800
|
-
state?: Snapshot<unknown>;
|
|
801
796
|
/** The source actor logic. */
|
|
802
797
|
src?: string | AnyActorLogic;
|
|
803
798
|
/**
|
|
@@ -1047,9 +1042,9 @@ export interface ActorInstance<TSnapshot extends Snapshot<unknown>, TEvent exten
|
|
|
1047
1042
|
*/
|
|
1048
1043
|
export type ActorSelf<TSnapshot extends Snapshot<unknown>, TEvent extends EventObject, TEmitted extends EventObject = EventObject, TSendEvent extends EventObject = TEvent> = ActorRuntime<TSnapshot, TEvent, TEmitted, TSendEvent> & ActorRef<TSnapshot, TEvent, TEmitted, TSendEvent>;
|
|
1049
1044
|
/** @public */
|
|
1050
|
-
export type ActorRefFrom<T> = T extends StateMachine<infer TContext, infer TEvent, infer TChildren, infer TStateValue, infer TTag, infer _TInput, infer TOutput, infer TEmitted, infer TMeta, infer
|
|
1045
|
+
export type ActorRefFrom<T> = T extends StateMachine<infer TContext, infer TEvent, infer TChildren, infer TStateValue, infer TTag, infer _TInput, infer TOutput, infer TEmitted, infer TMeta, infer _TConfig, infer _TActionMap, infer _TActorMap, infer _TGuardMap, infer _TDelayMap, infer TInternalEvent> ? ActorRef<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, any>, TEvent, TEmitted, SendableEventFromMachine<TEvent, TInternalEvent>> : T extends Promise<infer U> ? ActorRefFrom<AsyncActorLogic<U>> : T extends ActorLogic<infer TSnapshot, infer TEvent, infer _TInput, infer _TSystem, infer TEmitted> ? ActorRef<TSnapshot, TEvent, TEmitted, SendableEventFromLogic<T>> : never;
|
|
1051
1046
|
/** @public */
|
|
1052
|
-
export type SendableEventFromLogic<TLogic extends AnyActorLogic> = TLogic extends StateMachine<infer _TContext, infer TEvent, infer _TChildren, infer _TStateValue, infer _TTag, infer _TInput, infer _TOutput, infer _TEmitted, infer _TMeta, infer
|
|
1047
|
+
export type SendableEventFromLogic<TLogic extends AnyActorLogic> = TLogic extends StateMachine<infer _TContext, infer TEvent, infer _TChildren, infer _TStateValue, infer _TTag, infer _TInput, infer _TOutput, infer _TEmitted, infer _TMeta, infer _TConfig, infer _TActionMap, infer _TActorMap, infer _TGuardMap, infer _TDelayMap, infer TInternalEvent> ? SendableEventFromMachine<TEvent, TInternalEvent> : TLogic extends SendableEventCarrier<infer TSendableEvent> ? TSendableEvent : EventFromLogic<TLogic>;
|
|
1053
1048
|
type OpaqueMachineSnapshot<TSnapshot extends Snapshot<unknown>> = TSnapshot extends MachineSnapshot<infer TContext, infer TEvent, infer TChildren, infer TStateValue, infer TTag, infer TOutput, infer TMeta, infer _TStateSchema> ? MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, any> : TSnapshot;
|
|
1054
1049
|
/** @public */
|
|
1055
1050
|
export type ActorRefFromLogic<T extends AnyActorLogic> = ActorRef<OpaqueMachineSnapshot<SnapshotFrom<T>>, EventFromLogic<T>, EmittedFrom<T>, SendableEventFromLogic<T>>;
|
|
@@ -84,9 +84,6 @@ export type ValidateTopLevelFinalOutputs<TConfig, TContext extends MachineContex
|
|
|
84
84
|
} : {};
|
|
85
85
|
type NormalizeActorRef<TActorRef> = TActorRef extends ActorRef<infer TSnapshot, infer TEvent, infer TEmitted, infer TSendEvent> ? ActorRef<TSnapshot, TEvent, TEmitted, TSendEvent> : never;
|
|
86
86
|
type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
|
|
87
|
-
type InternalEventDescriptorFor<TEvent extends EventObject> = [TEvent] extends [
|
|
88
|
-
never
|
|
89
|
-
] ? string : EventDescriptor<TEvent>;
|
|
90
87
|
/**
|
|
91
88
|
* Runtime options for state machine execution.
|
|
92
89
|
*
|
|
@@ -139,8 +136,6 @@ export type Next_MachineConfig<TContextSchema extends StandardSchemaV1, TEventSc
|
|
|
139
136
|
* being accepted and silently ignored: nothing reads it in v6.
|
|
140
137
|
*/
|
|
141
138
|
types?: RemovedTypesKey;
|
|
142
|
-
/** @deprecated Declare private event schemas in `schemas.internalEvents`. */
|
|
143
|
-
internalEvents?: readonly InternalEventDescriptorFor<TEvent>[];
|
|
144
139
|
schemas?: MachineSchemas<TContextSchema, TEventSchemaMap, TInternalEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTransitionMetaSchema, TTagSchema, TChildrenSchemaMap>;
|
|
145
140
|
actions?: TActionMap;
|
|
146
141
|
guards?: TGuardMap & GuardSourceMap<TContext, TEvent>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var createActor = require('./createActor-
|
|
3
|
+
var createActor = require('./createActor-8dfa9b5c.cjs.js');
|
|
4
4
|
|
|
5
5
|
function attachMicrostepActorRefs(microsteps, actorScope, inputSnapshot) {
|
|
6
6
|
const result = microsteps.map(([snapshot, actions, transitions]) => [snapshot, actions, transitions ?? []]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { w as createInertActorScope, x as setInertActorScopeSnapshot, as as finalizeTransitionResult, A as attachSnapshotActorRef, O as createInitEvent, aw as hasAmbientInspector, z as beginSpawnAllocation, B as macrostep, P as createSpawnEffect, Q as initialMicrostep, a2 as isAtomicStateNode, ax as getProperAncestors, ay as isRemoteActorRef, az as getActorIdPrefix } from './createActor-
|
|
1
|
+
import { w as createInertActorScope, x as setInertActorScopeSnapshot, as as finalizeTransitionResult, A as attachSnapshotActorRef, O as createInitEvent, aw as hasAmbientInspector, z as beginSpawnAllocation, B as macrostep, P as createSpawnEffect, Q as initialMicrostep, a2 as isAtomicStateNode, ax as getProperAncestors, ay as isRemoteActorRef, az as getActorIdPrefix } from './createActor-f9b188f2.esm.js';
|
|
2
2
|
|
|
3
3
|
function attachMicrostepActorRefs(microsteps, actorScope, inputSnapshot) {
|
|
4
4
|
const result = microsteps.map(([snapshot, actions, transitions]) => [snapshot, actions, transitions ?? []]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { w as createInertActorScope, x as setInertActorScopeSnapshot, as as finalizeTransitionResult, A as attachSnapshotActorRef, O as createInitEvent, aw as hasAmbientInspector, z as beginSpawnAllocation, B as macrostep, P as createSpawnEffect, Q as initialMicrostep, a2 as isAtomicStateNode, ax as getProperAncestors, ay as isRemoteActorRef, az as getActorIdPrefix } from './createActor-
|
|
1
|
+
import { w as createInertActorScope, x as setInertActorScopeSnapshot, as as finalizeTransitionResult, A as attachSnapshotActorRef, O as createInitEvent, aw as hasAmbientInspector, z as beginSpawnAllocation, B as macrostep, P as createSpawnEffect, Q as initialMicrostep, a2 as isAtomicStateNode, ax as getProperAncestors, ay as isRemoteActorRef, az as getActorIdPrefix } from './createActor-55f62c08.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function attachMicrostepActorRefs(microsteps, actorScope, inputSnapshot) {
|
|
4
4
|
const result = microsteps.map(([snapshot, actions, transitions]) => [snapshot, actions, transitions ?? []]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var createActor = require('./createActor-
|
|
3
|
+
var createActor = require('./createActor-6d6bfee1.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
function attachMicrostepActorRefs(microsteps, actorScope, inputSnapshot) {
|
|
6
6
|
const result = microsteps.map(([snapshot, actions, transitions]) => [snapshot, actions, transitions ?? []]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as createInitEvent, y as createDeadLetterEffect, an as XSTATE_STOP, ao as createCustomEffect, ap as XSTATE_LOGIC_EFFECT_START, aq as XSTATE_LOGIC_EFFECT_RESOLVE, ar as XSTATE_LOGIC_EFFECT_REJECT, as as finalizeTransitionResult, at as createEmitEffect, au as createSendToEffect, av as XSTATE_INIT, a1 as parseDelayToMilliseconds, ak as runStep, a0 as createActor } from './createActor-
|
|
1
|
+
import { O as createInitEvent, y as createDeadLetterEffect, an as XSTATE_STOP, ao as createCustomEffect, ap as XSTATE_LOGIC_EFFECT_START, aq as XSTATE_LOGIC_EFFECT_RESOLVE, ar as XSTATE_LOGIC_EFFECT_REJECT, as as finalizeTransitionResult, at as createEmitEffect, au as createSendToEffect, av as XSTATE_INIT, a1 as parseDelayToMilliseconds, ak as runStep, a0 as createActor } from './createActor-f9b188f2.esm.js';
|
|
2
2
|
|
|
3
3
|
function assertValid(validator, request) {
|
|
4
4
|
const error = validator.check(request);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as createInitEvent, y as createDeadLetterEffect, an as XSTATE_STOP, ao as createCustomEffect, ap as XSTATE_LOGIC_EFFECT_START, aq as XSTATE_LOGIC_EFFECT_RESOLVE, ar as XSTATE_LOGIC_EFFECT_REJECT, as as finalizeTransitionResult, at as createEmitEffect, au as createSendToEffect, av as XSTATE_INIT, a1 as parseDelayToMilliseconds, ak as runStep, a0 as createActor } from './createActor-
|
|
1
|
+
import { O as createInitEvent, y as createDeadLetterEffect, an as XSTATE_STOP, ao as createCustomEffect, ap as XSTATE_LOGIC_EFFECT_START, aq as XSTATE_LOGIC_EFFECT_RESOLVE, ar as XSTATE_LOGIC_EFFECT_REJECT, as as finalizeTransitionResult, at as createEmitEffect, au as createSendToEffect, av as XSTATE_INIT, a1 as parseDelayToMilliseconds, ak as runStep, a0 as createActor } from './createActor-55f62c08.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function assertValid(validator, request) {
|
|
4
4
|
const error = validator.check(request);
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var createActor = require('./createActor-
|
|
6
|
-
var dist_xstateActors = require('./index-
|
|
5
|
+
var createActor = require('./createActor-8dfa9b5c.cjs.js');
|
|
6
|
+
var dist_xstateActors = require('./index-ad40a951.cjs.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var createActor = require('./createActor-
|
|
6
|
-
var dist_xstateActors = require('./index-
|
|
5
|
+
var createActor = require('./createActor-6d6bfee1.development.cjs.js');
|
|
6
|
+
var dist_xstateActors = require('./index-05e9e83b.development.cjs.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a5 as createListenerLogic, a6 as createSubscriptionLogic, a7 as listenerLogic, a8 as subscriptionLogic } from './createActor-
|
|
2
|
-
export { T as TimeoutError, c as createAsyncLogic, b as createCallbackLogic, d as createEmptyActor, e as createEventObservableLogic, f as createLogic, g as createObservableLogic } from './index-
|
|
1
|
+
export { a5 as createListenerLogic, a6 as createSubscriptionLogic, a7 as listenerLogic, a8 as subscriptionLogic } from './createActor-55f62c08.development.esm.js';
|
|
2
|
+
export { T as TimeoutError, c as createAsyncLogic, b as createCallbackLogic, d as createEmptyActor, e as createEventObservableLogic, f as createLogic, g as createObservableLogic } from './index-eda79ddc.development.esm.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a5 as createListenerLogic, a6 as createSubscriptionLogic, a7 as listenerLogic, a8 as subscriptionLogic } from './createActor-
|
|
2
|
-
export { T as TimeoutError, c as createAsyncLogic, b as createCallbackLogic, d as createEmptyActor, e as createEventObservableLogic, f as createLogic, g as createObservableLogic } from './index-
|
|
1
|
+
export { a5 as createListenerLogic, a6 as createSubscriptionLogic, a7 as listenerLogic, a8 as subscriptionLogic } from './createActor-f9b188f2.esm.js';
|
|
2
|
+
export { T as TimeoutError, c as createAsyncLogic, b as createCallbackLogic, d as createEmptyActor, e as createEventObservableLogic, f as createLogic, g as createObservableLogic } from './index-e5f3a62b.esm.js';
|