xstate 6.0.0-alpha.45 → 6.0.0-alpha.47
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/{StateMachine-2eecedfe.cjs.js → StateMachine-7046f677.cjs.js} +8 -4
- package/dist/{StateMachine-5b915fb1.development.cjs.js → StateMachine-70c06bdd.development.cjs.js} +8 -4
- package/dist/{StateMachine-d2fcf2e8.esm.js → StateMachine-74929087.esm.js} +8 -4
- package/dist/{StateMachine-4bf86161.development.esm.js → StateMachine-ee10f67e.development.esm.js} +8 -4
- package/dist/{createActor-5c9fa117.development.cjs.js → createActor-6736cbbe.development.cjs.js} +57 -22
- package/dist/{createActor-641ab5f7.esm.js → createActor-915ea40c.esm.js} +60 -23
- package/dist/{createActor-48401456.cjs.js → createActor-bfe8b6bd.cjs.js} +60 -22
- package/dist/{createActor-60ee6b5b.development.esm.js → createActor-ff132afa.development.esm.js} +57 -23
- package/dist/declarations/src/StateMachine.d.ts +7 -3
- package/dist/declarations/src/durable/index.d.ts +9 -2
- package/dist/declarations/src/setup.d.ts +37 -8
- package/dist/declarations/src/types.d.ts +27 -17
- package/dist/declarations/src/types.v6.d.ts +27 -5
- package/dist/{effectDescriptor-adb27412.cjs.js → effectDescriptor-3c699328.development.cjs.js} +4 -1
- package/dist/{effectDescriptor-dffb91a8.esm.js → effectDescriptor-8be60443.esm.js} +4 -1
- package/dist/{effectDescriptor-0cba79a1.development.cjs.js → effectDescriptor-a7e2d4d1.cjs.js} +4 -1
- package/dist/{effectDescriptor-fed26db6.development.esm.js → effectDescriptor-fbe67d5a.development.esm.js} +4 -1
- package/dist/{index-662114ff.development.cjs.js → index-0f498ef2.development.cjs.js} +1 -1
- package/dist/{index-158e7c37.development.esm.js → index-70d56425.development.esm.js} +1 -1
- package/dist/{index-8f19f242.esm.js → index-b051c924.esm.js} +1 -1
- package/dist/{index-fce4ea5c.cjs.js → index-b3fe59bc.cjs.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.map +1 -1
- package/dist/xstate-durable.cjs.js +9 -6
- package/dist/xstate-durable.development.cjs.js +9 -6
- package/dist/xstate-durable.development.esm.js +9 -6
- package/dist/xstate-durable.esm.js +9 -6
- 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 +3 -3
- package/dist/xstate-graph.development.cjs.js +3 -3
- package/dist/xstate-graph.development.esm.js +3 -3
- package/dist/xstate-graph.esm.js +3 -3
- 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 -4
- package/dist/xstate.development.cjs.js +23 -4
- package/dist/xstate.development.esm.js +25 -6
- package/dist/xstate.esm.js +25 -6
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var createActor = require('./createActor-
|
|
4
|
-
var dist_xstateActors = require('./index-
|
|
3
|
+
var createActor = require('./createActor-bfe8b6bd.cjs.js');
|
|
4
|
+
var dist_xstateActors = require('./index-b3fe59bc.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorScope, actors, spawnedChildren) {
|
|
7
7
|
return (src, options) => {
|
|
8
|
-
const referencedSrc =
|
|
8
|
+
const referencedSrc = createActor.resolveRegisteredActorSource(actors, src);
|
|
9
9
|
// Generated ids come from the same transaction allocator as `enq.spawn`,
|
|
10
10
|
// so context-factory allocations persist with the snapshot and never
|
|
11
11
|
// collide with later spawns.
|
|
@@ -1020,7 +1020,11 @@ class StateMachine {
|
|
|
1020
1020
|
restoreSnapshot(snapshot, actorScope) {
|
|
1021
1021
|
const usesInertScope = !actorScope;
|
|
1022
1022
|
const resolvedActorScope = actorScope ?? createActor.createInertActorScope(this);
|
|
1023
|
-
const
|
|
1023
|
+
const snapshotMachine = snapshot.machine;
|
|
1024
|
+
// A live machine snapshot carries its producing machine so helpers such as
|
|
1025
|
+
// `matches()` can resolve state nodes. That runtime association is not the
|
|
1026
|
+
// persisted `{ id, version }` identity written by getPersistedSnapshot().
|
|
1027
|
+
const persistedMachine = snapshotMachine && typeof snapshotMachine === 'object' && typeof snapshotMachine.transition === 'function' && 'root' in snapshotMachine ? undefined : snapshotMachine;
|
|
1024
1028
|
const legacyPersistedVersion = snapshot.version;
|
|
1025
1029
|
const persistedVersion = typeof persistedMachine?.version === 'string' ? persistedMachine.version : legacyPersistedVersion;
|
|
1026
1030
|
if (legacyPersistedVersion !== undefined && persistedMachine?.version !== undefined && persistedMachine.version !== legacyPersistedVersion) {
|
package/dist/{StateMachine-5b915fb1.development.cjs.js → StateMachine-70c06bdd.development.cjs.js}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var createActor = require('./createActor-
|
|
4
|
-
var dist_xstateActors = require('./index-
|
|
3
|
+
var createActor = require('./createActor-6736cbbe.development.cjs.js');
|
|
4
|
+
var dist_xstateActors = require('./index-0f498ef2.development.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorScope, actors, spawnedChildren) {
|
|
7
7
|
return (src, options) => {
|
|
8
|
-
const referencedSrc =
|
|
8
|
+
const referencedSrc = createActor.resolveRegisteredActorSource(actors, src);
|
|
9
9
|
// Generated ids come from the same transaction allocator as `enq.spawn`,
|
|
10
10
|
// so context-factory allocations persist with the snapshot and never
|
|
11
11
|
// collide with later spawns.
|
|
@@ -1049,7 +1049,11 @@ class StateMachine {
|
|
|
1049
1049
|
restoreSnapshot(snapshot, actorScope) {
|
|
1050
1050
|
const usesInertScope = !actorScope;
|
|
1051
1051
|
const resolvedActorScope = actorScope ?? createActor.createInertActorScope(this);
|
|
1052
|
-
const
|
|
1052
|
+
const snapshotMachine = snapshot.machine;
|
|
1053
|
+
// A live machine snapshot carries its producing machine so helpers such as
|
|
1054
|
+
// `matches()` can resolve state nodes. That runtime association is not the
|
|
1055
|
+
// persisted `{ id, version }` identity written by getPersistedSnapshot().
|
|
1056
|
+
const persistedMachine = snapshotMachine && typeof snapshotMachine === 'object' && typeof snapshotMachine.transition === 'function' && 'root' in snapshotMachine ? undefined : snapshotMachine;
|
|
1053
1057
|
const legacyPersistedVersion = snapshot.version;
|
|
1054
1058
|
const persistedVersion = typeof persistedMachine?.version === 'string' ? persistedMachine.version : legacyPersistedVersion;
|
|
1055
1059
|
if (legacyPersistedVersion !== undefined && persistedMachine?.version !== undefined && persistedMachine.version !== legacyPersistedVersion) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Q as
|
|
2
|
-
import { g as assertValid } from './index-
|
|
1
|
+
import { Q as resolveRegisteredActorSource, R as allocateChildId, S as assertChildIdFree, T as reserveChildId, U as STATE_DELIMITER, V as mapValues, t as toArray, W as createInvokeId, Y as getDelayedTransitions, Z as getEventDescriptorKey, _ as getCandidates, $ as evaluateCandidate, a0 as formatTransition, a1 as NULL_EVENT, a2 as toTransitionConfigArray, a3 as createInvokeTimeoutEventId, a4 as matchesActorSession, a5 as formatRouteTransitions, a6 as resolveStateValue, a7 as getAllStateNodes, x as getStateNodes, a8 as createMachineSnapshot, a9 as isInFinalState, aa as createInertActorScope, ab as setInertActorScopeSnapshot, a as beginSpawnAllocation, ac as attachSnapshotActorRef, ad as macrostep, ae as isInertActorScope, af as setSnapshotActorRef, ag as cloneMachineSnapshot, ah as transitionNode, g as XSTATE_TIMER, m as matchesEventDescriptor, ai as getTransitionResult, aj as hasEffect, ak as createErrorPlatformEvent, al as withActorSelf, r as resolveActionsWithContext, am as takeSpawnAllocationCounters, an as mergeActorIdCounters, K as createInitEvent, ao as createSpawnEffect, ap as initialMicrostep, aq as toStatePath, ar as isStateId, as as getStateNodeByPath, at as getPersistedSnapshot, au as createRemoteActorRef, av as resolveReferencedActor, aw as createInvokeTimeoutEvent, ax as parseGeneratedActorId, ay as ACTOR_REF_TYPE, k as createActor } from './createActor-915ea40c.esm.js';
|
|
2
|
+
import { g as assertValid } from './index-b051c924.esm.js';
|
|
3
3
|
|
|
4
4
|
function createSpawner(actorScope, actors, spawnedChildren) {
|
|
5
5
|
return (src, options) => {
|
|
6
|
-
const referencedSrc =
|
|
6
|
+
const referencedSrc = resolveRegisteredActorSource(actors, src);
|
|
7
7
|
// Generated ids come from the same transaction allocator as `enq.spawn`,
|
|
8
8
|
// so context-factory allocations persist with the snapshot and never
|
|
9
9
|
// collide with later spawns.
|
|
@@ -1018,7 +1018,11 @@ class StateMachine {
|
|
|
1018
1018
|
restoreSnapshot(snapshot, actorScope) {
|
|
1019
1019
|
const usesInertScope = !actorScope;
|
|
1020
1020
|
const resolvedActorScope = actorScope ?? createInertActorScope(this);
|
|
1021
|
-
const
|
|
1021
|
+
const snapshotMachine = snapshot.machine;
|
|
1022
|
+
// A live machine snapshot carries its producing machine so helpers such as
|
|
1023
|
+
// `matches()` can resolve state nodes. That runtime association is not the
|
|
1024
|
+
// persisted `{ id, version }` identity written by getPersistedSnapshot().
|
|
1025
|
+
const persistedMachine = snapshotMachine && typeof snapshotMachine === 'object' && typeof snapshotMachine.transition === 'function' && 'root' in snapshotMachine ? undefined : snapshotMachine;
|
|
1022
1026
|
const legacyPersistedVersion = snapshot.version;
|
|
1023
1027
|
const persistedVersion = typeof persistedMachine?.version === 'string' ? persistedMachine.version : legacyPersistedVersion;
|
|
1024
1028
|
if (legacyPersistedVersion !== undefined && persistedMachine?.version !== undefined && persistedMachine.version !== legacyPersistedVersion) {
|
package/dist/{StateMachine-4bf86161.development.esm.js → StateMachine-ee10f67e.development.esm.js}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Q as
|
|
2
|
-
import { g as assertValid } from './index-
|
|
1
|
+
import { Q as resolveRegisteredActorSource, R as allocateChildId, S as assertChildIdFree, T as reserveChildId, U as STATE_DELIMITER, V as mapValues, t as toArray, W as createInvokeId, Y as getDelayedTransitions, Z as getEventDescriptorKey, _ as getCandidates, $ as evaluateCandidate, a0 as formatTransition, a1 as NULL_EVENT, a2 as toTransitionConfigArray, a3 as createInvokeTimeoutEventId, a4 as matchesActorSession, a5 as formatRouteTransitions, a6 as resolveStateValue, a7 as getAllStateNodes, x as getStateNodes, a8 as createMachineSnapshot, a9 as isInFinalState, aa as createInertActorScope, ab as setInertActorScopeSnapshot, a as beginSpawnAllocation, ac as attachSnapshotActorRef, ad as macrostep, ae as isInertActorScope, af as setSnapshotActorRef, ag as cloneMachineSnapshot, ah as transitionNode, g as XSTATE_TIMER, m as matchesEventDescriptor, ai as getTransitionResult, aj as hasEffect, ak as createErrorPlatformEvent, al as withActorSelf, r as resolveActionsWithContext, am as takeSpawnAllocationCounters, an as mergeActorIdCounters, K as createInitEvent, ao as createSpawnEffect, ap as initialMicrostep, aq as toStatePath, ar as isStateId, as as getStateNodeByPath, at as getPersistedSnapshot, au as createRemoteActorRef, av as resolveReferencedActor, aw as createInvokeTimeoutEvent, ax as parseGeneratedActorId, ay as ACTOR_REF_TYPE, k as createActor } from './createActor-ff132afa.development.esm.js';
|
|
2
|
+
import { g as assertValid } from './index-70d56425.development.esm.js';
|
|
3
3
|
|
|
4
4
|
function createSpawner(actorScope, actors, spawnedChildren) {
|
|
5
5
|
return (src, options) => {
|
|
6
|
-
const referencedSrc =
|
|
6
|
+
const referencedSrc = resolveRegisteredActorSource(actors, src);
|
|
7
7
|
// Generated ids come from the same transaction allocator as `enq.spawn`,
|
|
8
8
|
// so context-factory allocations persist with the snapshot and never
|
|
9
9
|
// collide with later spawns.
|
|
@@ -1047,7 +1047,11 @@ class StateMachine {
|
|
|
1047
1047
|
restoreSnapshot(snapshot, actorScope) {
|
|
1048
1048
|
const usesInertScope = !actorScope;
|
|
1049
1049
|
const resolvedActorScope = actorScope ?? createInertActorScope(this);
|
|
1050
|
-
const
|
|
1050
|
+
const snapshotMachine = snapshot.machine;
|
|
1051
|
+
// A live machine snapshot carries its producing machine so helpers such as
|
|
1052
|
+
// `matches()` can resolve state nodes. That runtime association is not the
|
|
1053
|
+
// persisted `{ id, version }` identity written by getPersistedSnapshot().
|
|
1054
|
+
const persistedMachine = snapshotMachine && typeof snapshotMachine === 'object' && typeof snapshotMachine.transition === 'function' && 'root' in snapshotMachine ? undefined : snapshotMachine;
|
|
1051
1055
|
const legacyPersistedVersion = snapshot.version;
|
|
1052
1056
|
const persistedVersion = typeof persistedMachine?.version === 'string' ? persistedMachine.version : legacyPersistedVersion;
|
|
1053
1057
|
if (legacyPersistedVersion !== undefined && persistedMachine?.version !== undefined && persistedMachine.version !== legacyPersistedVersion) {
|
package/dist/{createActor-5c9fa117.development.cjs.js → createActor-6736cbbe.development.cjs.js}
RENAMED
|
@@ -220,6 +220,27 @@ const builtInActions = {
|
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
222
|
|
|
223
|
+
const sourceKeyCaches = new WeakMap();
|
|
224
|
+
|
|
225
|
+
/** @internal */
|
|
226
|
+
function resolveRegisteredActorSource(actors, logic) {
|
|
227
|
+
let cache = sourceKeyCaches.get(actors);
|
|
228
|
+
if (!cache) {
|
|
229
|
+
cache = new Map();
|
|
230
|
+
for (const key of Object.keys(actors)) {
|
|
231
|
+
const registeredLogic = actors[key];
|
|
232
|
+
// Several source keys may intentionally share one implementation. The
|
|
233
|
+
// first key is its canonical persistence identity when spawning by the
|
|
234
|
+
// raw logic value, which cannot retain which alias was used to access it.
|
|
235
|
+
if (!cache.has(registeredLogic)) {
|
|
236
|
+
cache.set(registeredLogic, key);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
sourceKeyCaches.set(actors, cache);
|
|
240
|
+
}
|
|
241
|
+
return cache.get(logic);
|
|
242
|
+
}
|
|
243
|
+
|
|
223
244
|
const subscriptions = /* #__PURE__ */new WeakMap();
|
|
224
245
|
|
|
225
246
|
/**
|
|
@@ -667,21 +688,31 @@ function beginSpawnAllocation(actorScope) {
|
|
|
667
688
|
function getWorkingSnapshotOf(actorScope) {
|
|
668
689
|
return actorScope.self._snapshot;
|
|
669
690
|
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
for (const key of Object.keys(registeredActors)) {
|
|
680
|
-
cache.set(registeredActors[key], key);
|
|
691
|
+
function getRegisteredActors(actorScope) {
|
|
692
|
+
return actorScope.self.logic?.sources?.actors;
|
|
693
|
+
}
|
|
694
|
+
function resolveTransitionSpawnSource(actorScope, source) {
|
|
695
|
+
const registeredActors = getRegisteredActors(actorScope);
|
|
696
|
+
if (typeof source === 'string') {
|
|
697
|
+
const logic = registeredActors?.[source];
|
|
698
|
+
if (!logic) {
|
|
699
|
+
throw new Error(`Actor source '${source}' is not provided`);
|
|
681
700
|
}
|
|
682
|
-
|
|
701
|
+
return {
|
|
702
|
+
logic,
|
|
703
|
+
src: source
|
|
704
|
+
};
|
|
683
705
|
}
|
|
684
|
-
|
|
706
|
+
if (!registeredActors) {
|
|
707
|
+
return {
|
|
708
|
+
logic: source,
|
|
709
|
+
src: undefined
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
return {
|
|
713
|
+
logic: source,
|
|
714
|
+
src: resolveRegisteredActorSource(registeredActors, source)
|
|
715
|
+
};
|
|
685
716
|
}
|
|
686
717
|
|
|
687
718
|
/**
|
|
@@ -829,17 +860,17 @@ function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubsc
|
|
|
829
860
|
internalEvents.push(raisedEvent);
|
|
830
861
|
}
|
|
831
862
|
},
|
|
832
|
-
spawn: (
|
|
863
|
+
spawn: (source, options) => {
|
|
864
|
+
const {
|
|
865
|
+
logic,
|
|
866
|
+
src
|
|
867
|
+
} = resolveTransitionSpawnSource(actorScope, source);
|
|
833
868
|
if (!createActors) {
|
|
834
869
|
// TODO: replace this speculative placeholder with a typed inert actor ref.
|
|
835
870
|
return {
|
|
836
|
-
id: options?.id ?? options?.registryKey ?? logic.id
|
|
871
|
+
id: options?.id ?? options?.registryKey ?? src ?? logic.id
|
|
837
872
|
};
|
|
838
873
|
}
|
|
839
|
-
// Recover the registered source key for setup-provided logic so the
|
|
840
|
-
// spawned child persists (and gets a deterministic id prefix) by key
|
|
841
|
-
// instead of by inline logic reference.
|
|
842
|
-
const src = getRegisteredSrcKey(actorScope, logic);
|
|
843
874
|
// Generated ids allocate from the parent snapshot's own counters
|
|
844
875
|
// through the transition's allocation transaction; explicit
|
|
845
876
|
// generated-shaped ids reserve their numbering the same way.
|
|
@@ -877,12 +908,15 @@ function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubsc
|
|
|
877
908
|
},
|
|
878
909
|
stop: actor => {
|
|
879
910
|
if (actor) {
|
|
880
|
-
|
|
911
|
+
// enq.stop accepts the consumer ActorRef contract; refs handed to
|
|
912
|
+
// machine code are always full actor instances at runtime.
|
|
913
|
+
const actorInstance = actor;
|
|
914
|
+
const action = pushBuiltInAction(actions, builtInActions['@xstate.stop'], actorScope, actorInstance);
|
|
881
915
|
action.childUpdate = {
|
|
882
916
|
type: 'remove',
|
|
883
|
-
actor
|
|
917
|
+
actor: actorInstance
|
|
884
918
|
};
|
|
885
|
-
recordStoppedChild(actorScope,
|
|
919
|
+
recordStoppedChild(actorScope, actorInstance);
|
|
886
920
|
}
|
|
887
921
|
}
|
|
888
922
|
};
|
|
@@ -5789,6 +5823,7 @@ exports.pathToStateValue = pathToStateValue;
|
|
|
5789
5823
|
exports.reserveChildId = reserveChildId;
|
|
5790
5824
|
exports.resolveActionsWithContext = resolveActionsWithContext;
|
|
5791
5825
|
exports.resolveReferencedActor = resolveReferencedActor;
|
|
5826
|
+
exports.resolveRegisteredActorSource = resolveRegisteredActorSource;
|
|
5792
5827
|
exports.resolveStateValue = resolveStateValue;
|
|
5793
5828
|
exports.runStep = runStep;
|
|
5794
5829
|
exports.setInertActorScopeSnapshot = setInertActorScopeSnapshot;
|
|
@@ -217,6 +217,27 @@ const builtInActions = {
|
|
|
217
217
|
}
|
|
218
218
|
};
|
|
219
219
|
|
|
220
|
+
const sourceKeyCaches = new WeakMap();
|
|
221
|
+
|
|
222
|
+
/** @internal */
|
|
223
|
+
function resolveRegisteredActorSource(actors, logic) {
|
|
224
|
+
let cache = sourceKeyCaches.get(actors);
|
|
225
|
+
if (!cache) {
|
|
226
|
+
cache = new Map();
|
|
227
|
+
for (const key of Object.keys(actors)) {
|
|
228
|
+
const registeredLogic = actors[key];
|
|
229
|
+
// Several source keys may intentionally share one implementation. The
|
|
230
|
+
// first key is its canonical persistence identity when spawning by the
|
|
231
|
+
// raw logic value, which cannot retain which alias was used to access it.
|
|
232
|
+
if (!cache.has(registeredLogic)) {
|
|
233
|
+
cache.set(registeredLogic, key);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
sourceKeyCaches.set(actors, cache);
|
|
237
|
+
}
|
|
238
|
+
return cache.get(logic);
|
|
239
|
+
}
|
|
240
|
+
|
|
220
241
|
const subscriptions = /* #__PURE__ */new WeakMap();
|
|
221
242
|
|
|
222
243
|
/**
|
|
@@ -664,21 +685,31 @@ function beginSpawnAllocation(actorScope) {
|
|
|
664
685
|
function getWorkingSnapshotOf(actorScope) {
|
|
665
686
|
return actorScope.self._snapshot;
|
|
666
687
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
for (const key of Object.keys(registeredActors)) {
|
|
677
|
-
cache.set(registeredActors[key], key);
|
|
688
|
+
function getRegisteredActors(actorScope) {
|
|
689
|
+
return actorScope.self.logic?.sources?.actors;
|
|
690
|
+
}
|
|
691
|
+
function resolveTransitionSpawnSource(actorScope, source) {
|
|
692
|
+
const registeredActors = getRegisteredActors(actorScope);
|
|
693
|
+
if (typeof source === 'string') {
|
|
694
|
+
const logic = registeredActors?.[source];
|
|
695
|
+
if (!logic) {
|
|
696
|
+
throw new Error(`Actor source '${source}' is not provided`);
|
|
678
697
|
}
|
|
679
|
-
|
|
698
|
+
return {
|
|
699
|
+
logic,
|
|
700
|
+
src: source
|
|
701
|
+
};
|
|
680
702
|
}
|
|
681
|
-
|
|
703
|
+
if (!registeredActors) {
|
|
704
|
+
return {
|
|
705
|
+
logic: source,
|
|
706
|
+
src: undefined
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
return {
|
|
710
|
+
logic: source,
|
|
711
|
+
src: resolveRegisteredActorSource(registeredActors, source)
|
|
712
|
+
};
|
|
682
713
|
}
|
|
683
714
|
|
|
684
715
|
/**
|
|
@@ -819,17 +850,17 @@ function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubsc
|
|
|
819
850
|
internalEvents.push(raisedEvent);
|
|
820
851
|
}
|
|
821
852
|
},
|
|
822
|
-
spawn: (
|
|
853
|
+
spawn: (source, options) => {
|
|
854
|
+
const {
|
|
855
|
+
logic,
|
|
856
|
+
src
|
|
857
|
+
} = resolveTransitionSpawnSource(actorScope, source);
|
|
823
858
|
if (!createActors) {
|
|
824
859
|
// TODO: replace this speculative placeholder with a typed inert actor ref.
|
|
825
860
|
return {
|
|
826
|
-
id: options?.id ?? options?.registryKey ?? logic.id
|
|
861
|
+
id: options?.id ?? options?.registryKey ?? src ?? logic.id
|
|
827
862
|
};
|
|
828
863
|
}
|
|
829
|
-
// Recover the registered source key for setup-provided logic so the
|
|
830
|
-
// spawned child persists (and gets a deterministic id prefix) by key
|
|
831
|
-
// instead of by inline logic reference.
|
|
832
|
-
const src = getRegisteredSrcKey(actorScope, logic);
|
|
833
864
|
// Generated ids allocate from the parent snapshot's own counters
|
|
834
865
|
// through the transition's allocation transaction; explicit
|
|
835
866
|
// generated-shaped ids reserve their numbering the same way.
|
|
@@ -867,12 +898,15 @@ function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubsc
|
|
|
867
898
|
},
|
|
868
899
|
stop: actor => {
|
|
869
900
|
if (actor) {
|
|
870
|
-
|
|
901
|
+
// enq.stop accepts the consumer ActorRef contract; refs handed to
|
|
902
|
+
// machine code are always full actor instances at runtime.
|
|
903
|
+
const actorInstance = actor;
|
|
904
|
+
const action = pushBuiltInAction(actions, builtInActions['@xstate.stop'], actorScope, actorInstance);
|
|
871
905
|
action.childUpdate = {
|
|
872
906
|
type: 'remove',
|
|
873
|
-
actor
|
|
907
|
+
actor: actorInstance
|
|
874
908
|
};
|
|
875
|
-
recordStoppedChild(actorScope,
|
|
909
|
+
recordStoppedChild(actorScope, actorInstance);
|
|
876
910
|
}
|
|
877
911
|
}
|
|
878
912
|
};
|
|
@@ -3697,6 +3731,9 @@ function getPersistedSnapshot(snapshot, options) {
|
|
|
3697
3731
|
const embedChildren = options?.embedChildren !== false;
|
|
3698
3732
|
for (const id in children) {
|
|
3699
3733
|
const child = children[id];
|
|
3734
|
+
if (typeof child.src !== 'string' && (!options || !('__unsafeAllowInlineActors' in options))) {
|
|
3735
|
+
throw new Error('An inline child actor cannot be persisted.');
|
|
3736
|
+
}
|
|
3700
3737
|
// Children are referenced by their logical address. Embedding the child
|
|
3701
3738
|
// state is the co-locating runtime's whole-tree checkpoint capability;
|
|
3702
3739
|
// remote handles never embed — their state lives with another runtime.
|
|
@@ -5662,4 +5699,4 @@ function createActor(logic, options) {
|
|
|
5662
5699
|
return new Actor(logic, options);
|
|
5663
5700
|
}
|
|
5664
5701
|
|
|
5665
|
-
export {
|
|
5702
|
+
export { evaluateCandidate as $, Actor as A, checkStateIn as B, pathToStateValue as C, toObserver as D, executeEffects as E, isBuiltInExecutableAction as F, deliverEvent as G, runStep as H, stopActor as I, terminateActor as J, createInitEvent as K, createCustomEffect as L, XSTATE_LOGIC_EFFECT_START as M, XSTATE_LOGIC_EFFECT_RESOLVE as N, XSTATE_LOGIC_EFFECT_REJECT as O, createEmitEffect as P, resolveRegisteredActorSource as Q, allocateChildId as R, assertChildIdFree as S, reserveChildId as T, STATE_DELIMITER as U, mapValues as V, createInvokeId as W, XSTATE_INIT as X, getDelayedTransitions as Y, getEventDescriptorKey as Z, getCandidates as _, beginSpawnAllocation as a, formatTransition as a0, NULL_EVENT as a1, toTransitionConfigArray as a2, createInvokeTimeoutEventId as a3, matchesActorSession as a4, formatRouteTransitions as a5, resolveStateValue as a6, getAllStateNodes as a7, createMachineSnapshot as a8, isInFinalState as a9, getProperAncestors as aA, isRemoteActorRef as aB, getActorIdPrefix as aC, getAllOwnEvents as aD, matchesEvent as aE, encodeAddressSegment as aF, getRootActorId as aG, RUNTIME_OPERATIONS as aH, withSystemInspector as aI, getSnapshotActorRef as aJ, withExecutionIdentity as aK, createInertActorScope as aa, setInertActorScopeSnapshot as ab, attachSnapshotActorRef as ac, macrostep as ad, isInertActorScope as ae, setSnapshotActorRef as af, cloneMachineSnapshot as ag, transitionNode as ah, getTransitionResult as ai, hasEffect as aj, createErrorPlatformEvent as ak, withActorSelf as al, takeSpawnAllocationCounters as am, mergeActorIdCounters as an, createSpawnEffect as ao, initialMicrostep as ap, toStatePath as aq, isStateId as ar, getStateNodeByPath as as, getPersistedSnapshot as at, createRemoteActorRef as au, resolveReferencedActor as av, createInvokeTimeoutEvent as aw, parseGeneratedActorId as ax, ACTOR_REF_TYPE as ay, hasAmbientInspector as az, builtInActions as b, createTransitionEnqueue as c, deriveDeferredStarts as d, XSTATE_STOP as e, finalizeTransitionResult as f, XSTATE_TIMER as g, createSendToEffect as h, isLazyActorScope as i, isAtomicStateNode as j, createActor as k, createListenerLogic as l, matchesEventDescriptor as m, createSubscriptionLogic as n, listenerLogic as o, parseDelayToMilliseconds as p, getInitialSnapshot as q, resolveActionsWithContext as r, subscriptionLogic as s, toArray as t, getNextSnapshot as u, isMachineSnapshot as v, withActorScope as w, getStateNodes as x, getAllOwnEventDescriptors as y, matchesState as z };
|
|
@@ -219,6 +219,27 @@ const builtInActions = {
|
|
|
219
219
|
}
|
|
220
220
|
};
|
|
221
221
|
|
|
222
|
+
const sourceKeyCaches = new WeakMap();
|
|
223
|
+
|
|
224
|
+
/** @internal */
|
|
225
|
+
function resolveRegisteredActorSource(actors, logic) {
|
|
226
|
+
let cache = sourceKeyCaches.get(actors);
|
|
227
|
+
if (!cache) {
|
|
228
|
+
cache = new Map();
|
|
229
|
+
for (const key of Object.keys(actors)) {
|
|
230
|
+
const registeredLogic = actors[key];
|
|
231
|
+
// Several source keys may intentionally share one implementation. The
|
|
232
|
+
// first key is its canonical persistence identity when spawning by the
|
|
233
|
+
// raw logic value, which cannot retain which alias was used to access it.
|
|
234
|
+
if (!cache.has(registeredLogic)) {
|
|
235
|
+
cache.set(registeredLogic, key);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
sourceKeyCaches.set(actors, cache);
|
|
239
|
+
}
|
|
240
|
+
return cache.get(logic);
|
|
241
|
+
}
|
|
242
|
+
|
|
222
243
|
const subscriptions = /* #__PURE__ */new WeakMap();
|
|
223
244
|
|
|
224
245
|
/**
|
|
@@ -666,21 +687,31 @@ function beginSpawnAllocation(actorScope) {
|
|
|
666
687
|
function getWorkingSnapshotOf(actorScope) {
|
|
667
688
|
return actorScope.self._snapshot;
|
|
668
689
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
for (const key of Object.keys(registeredActors)) {
|
|
679
|
-
cache.set(registeredActors[key], key);
|
|
690
|
+
function getRegisteredActors(actorScope) {
|
|
691
|
+
return actorScope.self.logic?.sources?.actors;
|
|
692
|
+
}
|
|
693
|
+
function resolveTransitionSpawnSource(actorScope, source) {
|
|
694
|
+
const registeredActors = getRegisteredActors(actorScope);
|
|
695
|
+
if (typeof source === 'string') {
|
|
696
|
+
const logic = registeredActors?.[source];
|
|
697
|
+
if (!logic) {
|
|
698
|
+
throw new Error(`Actor source '${source}' is not provided`);
|
|
680
699
|
}
|
|
681
|
-
|
|
700
|
+
return {
|
|
701
|
+
logic,
|
|
702
|
+
src: source
|
|
703
|
+
};
|
|
682
704
|
}
|
|
683
|
-
|
|
705
|
+
if (!registeredActors) {
|
|
706
|
+
return {
|
|
707
|
+
logic: source,
|
|
708
|
+
src: undefined
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
return {
|
|
712
|
+
logic: source,
|
|
713
|
+
src: resolveRegisteredActorSource(registeredActors, source)
|
|
714
|
+
};
|
|
684
715
|
}
|
|
685
716
|
|
|
686
717
|
/**
|
|
@@ -821,17 +852,17 @@ function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubsc
|
|
|
821
852
|
internalEvents.push(raisedEvent);
|
|
822
853
|
}
|
|
823
854
|
},
|
|
824
|
-
spawn: (
|
|
855
|
+
spawn: (source, options) => {
|
|
856
|
+
const {
|
|
857
|
+
logic,
|
|
858
|
+
src
|
|
859
|
+
} = resolveTransitionSpawnSource(actorScope, source);
|
|
825
860
|
if (!createActors) {
|
|
826
861
|
// TODO: replace this speculative placeholder with a typed inert actor ref.
|
|
827
862
|
return {
|
|
828
|
-
id: options?.id ?? options?.registryKey ?? logic.id
|
|
863
|
+
id: options?.id ?? options?.registryKey ?? src ?? logic.id
|
|
829
864
|
};
|
|
830
865
|
}
|
|
831
|
-
// Recover the registered source key for setup-provided logic so the
|
|
832
|
-
// spawned child persists (and gets a deterministic id prefix) by key
|
|
833
|
-
// instead of by inline logic reference.
|
|
834
|
-
const src = getRegisteredSrcKey(actorScope, logic);
|
|
835
866
|
// Generated ids allocate from the parent snapshot's own counters
|
|
836
867
|
// through the transition's allocation transaction; explicit
|
|
837
868
|
// generated-shaped ids reserve their numbering the same way.
|
|
@@ -869,12 +900,15 @@ function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubsc
|
|
|
869
900
|
},
|
|
870
901
|
stop: actor => {
|
|
871
902
|
if (actor) {
|
|
872
|
-
|
|
903
|
+
// enq.stop accepts the consumer ActorRef contract; refs handed to
|
|
904
|
+
// machine code are always full actor instances at runtime.
|
|
905
|
+
const actorInstance = actor;
|
|
906
|
+
const action = pushBuiltInAction(actions, builtInActions['@xstate.stop'], actorScope, actorInstance);
|
|
873
907
|
action.childUpdate = {
|
|
874
908
|
type: 'remove',
|
|
875
|
-
actor
|
|
909
|
+
actor: actorInstance
|
|
876
910
|
};
|
|
877
|
-
recordStoppedChild(actorScope,
|
|
911
|
+
recordStoppedChild(actorScope, actorInstance);
|
|
878
912
|
}
|
|
879
913
|
}
|
|
880
914
|
};
|
|
@@ -3699,6 +3733,9 @@ function getPersistedSnapshot(snapshot, options) {
|
|
|
3699
3733
|
const embedChildren = options?.embedChildren !== false;
|
|
3700
3734
|
for (const id in children) {
|
|
3701
3735
|
const child = children[id];
|
|
3736
|
+
if (typeof child.src !== 'string' && (!options || !('__unsafeAllowInlineActors' in options))) {
|
|
3737
|
+
throw new Error('An inline child actor cannot be persisted.');
|
|
3738
|
+
}
|
|
3702
3739
|
// Children are referenced by their logical address. Embedding the child
|
|
3703
3740
|
// state is the co-locating runtime's whole-tree checkpoint capability;
|
|
3704
3741
|
// remote handles never embed — their state lives with another runtime.
|
|
@@ -5747,6 +5784,7 @@ exports.pathToStateValue = pathToStateValue;
|
|
|
5747
5784
|
exports.reserveChildId = reserveChildId;
|
|
5748
5785
|
exports.resolveActionsWithContext = resolveActionsWithContext;
|
|
5749
5786
|
exports.resolveReferencedActor = resolveReferencedActor;
|
|
5787
|
+
exports.resolveRegisteredActorSource = resolveRegisteredActorSource;
|
|
5750
5788
|
exports.resolveStateValue = resolveStateValue;
|
|
5751
5789
|
exports.runStep = runStep;
|
|
5752
5790
|
exports.setInertActorScopeSnapshot = setInertActorScopeSnapshot;
|
package/dist/{createActor-60ee6b5b.development.esm.js → createActor-ff132afa.development.esm.js}
RENAMED
|
@@ -218,6 +218,27 @@ const builtInActions = {
|
|
|
218
218
|
}
|
|
219
219
|
};
|
|
220
220
|
|
|
221
|
+
const sourceKeyCaches = new WeakMap();
|
|
222
|
+
|
|
223
|
+
/** @internal */
|
|
224
|
+
function resolveRegisteredActorSource(actors, logic) {
|
|
225
|
+
let cache = sourceKeyCaches.get(actors);
|
|
226
|
+
if (!cache) {
|
|
227
|
+
cache = new Map();
|
|
228
|
+
for (const key of Object.keys(actors)) {
|
|
229
|
+
const registeredLogic = actors[key];
|
|
230
|
+
// Several source keys may intentionally share one implementation. The
|
|
231
|
+
// first key is its canonical persistence identity when spawning by the
|
|
232
|
+
// raw logic value, which cannot retain which alias was used to access it.
|
|
233
|
+
if (!cache.has(registeredLogic)) {
|
|
234
|
+
cache.set(registeredLogic, key);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
sourceKeyCaches.set(actors, cache);
|
|
238
|
+
}
|
|
239
|
+
return cache.get(logic);
|
|
240
|
+
}
|
|
241
|
+
|
|
221
242
|
const subscriptions = /* #__PURE__ */new WeakMap();
|
|
222
243
|
|
|
223
244
|
/**
|
|
@@ -665,21 +686,31 @@ function beginSpawnAllocation(actorScope) {
|
|
|
665
686
|
function getWorkingSnapshotOf(actorScope) {
|
|
666
687
|
return actorScope.self._snapshot;
|
|
667
688
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
for (const key of Object.keys(registeredActors)) {
|
|
678
|
-
cache.set(registeredActors[key], key);
|
|
689
|
+
function getRegisteredActors(actorScope) {
|
|
690
|
+
return actorScope.self.logic?.sources?.actors;
|
|
691
|
+
}
|
|
692
|
+
function resolveTransitionSpawnSource(actorScope, source) {
|
|
693
|
+
const registeredActors = getRegisteredActors(actorScope);
|
|
694
|
+
if (typeof source === 'string') {
|
|
695
|
+
const logic = registeredActors?.[source];
|
|
696
|
+
if (!logic) {
|
|
697
|
+
throw new Error(`Actor source '${source}' is not provided`);
|
|
679
698
|
}
|
|
680
|
-
|
|
699
|
+
return {
|
|
700
|
+
logic,
|
|
701
|
+
src: source
|
|
702
|
+
};
|
|
681
703
|
}
|
|
682
|
-
|
|
704
|
+
if (!registeredActors) {
|
|
705
|
+
return {
|
|
706
|
+
logic: source,
|
|
707
|
+
src: undefined
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
return {
|
|
711
|
+
logic: source,
|
|
712
|
+
src: resolveRegisteredActorSource(registeredActors, source)
|
|
713
|
+
};
|
|
683
714
|
}
|
|
684
715
|
|
|
685
716
|
/**
|
|
@@ -827,17 +858,17 @@ function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubsc
|
|
|
827
858
|
internalEvents.push(raisedEvent);
|
|
828
859
|
}
|
|
829
860
|
},
|
|
830
|
-
spawn: (
|
|
861
|
+
spawn: (source, options) => {
|
|
862
|
+
const {
|
|
863
|
+
logic,
|
|
864
|
+
src
|
|
865
|
+
} = resolveTransitionSpawnSource(actorScope, source);
|
|
831
866
|
if (!createActors) {
|
|
832
867
|
// TODO: replace this speculative placeholder with a typed inert actor ref.
|
|
833
868
|
return {
|
|
834
|
-
id: options?.id ?? options?.registryKey ?? logic.id
|
|
869
|
+
id: options?.id ?? options?.registryKey ?? src ?? logic.id
|
|
835
870
|
};
|
|
836
871
|
}
|
|
837
|
-
// Recover the registered source key for setup-provided logic so the
|
|
838
|
-
// spawned child persists (and gets a deterministic id prefix) by key
|
|
839
|
-
// instead of by inline logic reference.
|
|
840
|
-
const src = getRegisteredSrcKey(actorScope, logic);
|
|
841
872
|
// Generated ids allocate from the parent snapshot's own counters
|
|
842
873
|
// through the transition's allocation transaction; explicit
|
|
843
874
|
// generated-shaped ids reserve their numbering the same way.
|
|
@@ -875,12 +906,15 @@ function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubsc
|
|
|
875
906
|
},
|
|
876
907
|
stop: actor => {
|
|
877
908
|
if (actor) {
|
|
878
|
-
|
|
909
|
+
// enq.stop accepts the consumer ActorRef contract; refs handed to
|
|
910
|
+
// machine code are always full actor instances at runtime.
|
|
911
|
+
const actorInstance = actor;
|
|
912
|
+
const action = pushBuiltInAction(actions, builtInActions['@xstate.stop'], actorScope, actorInstance);
|
|
879
913
|
action.childUpdate = {
|
|
880
914
|
type: 'remove',
|
|
881
|
-
actor
|
|
915
|
+
actor: actorInstance
|
|
882
916
|
};
|
|
883
|
-
recordStoppedChild(actorScope,
|
|
917
|
+
recordStoppedChild(actorScope, actorInstance);
|
|
884
918
|
}
|
|
885
919
|
}
|
|
886
920
|
};
|
|
@@ -5704,4 +5738,4 @@ function createActor(logic, options) {
|
|
|
5704
5738
|
return new Actor(logic, options);
|
|
5705
5739
|
}
|
|
5706
5740
|
|
|
5707
|
-
export {
|
|
5741
|
+
export { evaluateCandidate as $, Actor as A, checkStateIn as B, pathToStateValue as C, toObserver as D, executeEffects as E, isBuiltInExecutableAction as F, deliverEvent as G, runStep as H, stopActor as I, terminateActor as J, createInitEvent as K, createCustomEffect as L, XSTATE_LOGIC_EFFECT_START as M, XSTATE_LOGIC_EFFECT_RESOLVE as N, XSTATE_LOGIC_EFFECT_REJECT as O, createEmitEffect as P, resolveRegisteredActorSource as Q, allocateChildId as R, assertChildIdFree as S, reserveChildId as T, STATE_DELIMITER as U, mapValues as V, createInvokeId as W, XSTATE_INIT as X, getDelayedTransitions as Y, getEventDescriptorKey as Z, getCandidates as _, beginSpawnAllocation as a, formatTransition as a0, NULL_EVENT as a1, toTransitionConfigArray as a2, createInvokeTimeoutEventId as a3, matchesActorSession as a4, formatRouteTransitions as a5, resolveStateValue as a6, getAllStateNodes as a7, createMachineSnapshot as a8, isInFinalState as a9, getProperAncestors as aA, isRemoteActorRef as aB, getActorIdPrefix as aC, getAllOwnEvents as aD, matchesEvent as aE, encodeAddressSegment as aF, getRootActorId as aG, RUNTIME_OPERATIONS as aH, withSystemInspector as aI, getSnapshotActorRef as aJ, withExecutionIdentity as aK, createInertActorScope as aa, setInertActorScopeSnapshot as ab, attachSnapshotActorRef as ac, macrostep as ad, isInertActorScope as ae, setSnapshotActorRef as af, cloneMachineSnapshot as ag, transitionNode as ah, getTransitionResult as ai, hasEffect as aj, createErrorPlatformEvent as ak, withActorSelf as al, takeSpawnAllocationCounters as am, mergeActorIdCounters as an, createSpawnEffect as ao, initialMicrostep as ap, toStatePath as aq, isStateId as ar, getStateNodeByPath as as, getPersistedSnapshot as at, createRemoteActorRef as au, resolveReferencedActor as av, createInvokeTimeoutEvent as aw, parseGeneratedActorId as ax, ACTOR_REF_TYPE as ay, hasAmbientInspector as az, builtInActions as b, createTransitionEnqueue as c, deriveDeferredStarts as d, XSTATE_STOP as e, finalizeTransitionResult as f, XSTATE_TIMER as g, createSendToEffect as h, isLazyActorScope as i, isAtomicStateNode as j, createActor as k, createListenerLogic as l, matchesEventDescriptor as m, createSubscriptionLogic as n, listenerLogic as o, parseDelayToMilliseconds as p, getInitialSnapshot as q, resolveActionsWithContext as r, subscriptionLogic as s, toArray as t, getNextSnapshot as u, isMachineSnapshot as v, withActorScope as w, getStateNodes as x, getAllOwnEventDescriptors as y, matchesState as z };
|