xstate 6.0.0-alpha.45 → 6.0.0-alpha.46
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-756e1335.cjs.js} +3 -3
- package/dist/{StateMachine-d2fcf2e8.esm.js → StateMachine-9509c0bd.esm.js} +3 -3
- package/dist/{StateMachine-4bf86161.development.esm.js → StateMachine-a5ede014.development.esm.js} +3 -3
- package/dist/{StateMachine-5b915fb1.development.cjs.js → StateMachine-fa133051.development.cjs.js} +3 -3
- package/dist/{createActor-48401456.cjs.js → createActor-0816a84b.cjs.js} +54 -19
- package/dist/{createActor-641ab5f7.esm.js → createActor-9523f716.esm.js} +54 -20
- package/dist/{createActor-60ee6b5b.development.esm.js → createActor-f5277b31.development.esm.js} +51 -20
- package/dist/{createActor-5c9fa117.development.cjs.js → createActor-f6e6146f.development.cjs.js} +51 -19
- package/dist/declarations/src/setup.d.ts +1 -1
- package/dist/declarations/src/types.d.ts +23 -13
- package/dist/{effectDescriptor-adb27412.cjs.js → effectDescriptor-3a016bbe.cjs.js} +1 -1
- package/dist/{effectDescriptor-dffb91a8.esm.js → effectDescriptor-87826c41.esm.js} +1 -1
- package/dist/{effectDescriptor-0cba79a1.development.cjs.js → effectDescriptor-8a5d62e0.development.cjs.js} +1 -1
- package/dist/{effectDescriptor-fed26db6.development.esm.js → effectDescriptor-9a14147f.development.esm.js} +1 -1
- package/dist/{index-662114ff.development.cjs.js → index-1e1e1cba.development.cjs.js} +1 -1
- package/dist/{index-158e7c37.development.esm.js → index-3907b7aa.development.esm.js} +1 -1
- package/dist/{index-fce4ea5c.cjs.js → index-7b9c4f77.cjs.js} +1 -1
- package/dist/{index-8f19f242.esm.js → index-c7431a16.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.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.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 +4 -4
- package/dist/xstate.development.cjs.js +4 -4
- package/dist/xstate.development.esm.js +6 -6
- package/dist/xstate.esm.js +6 -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-0816a84b.cjs.js');
|
|
4
|
+
var dist_xstateActors = require('./index-7b9c4f77.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.
|
|
@@ -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-9523f716.esm.js';
|
|
2
|
+
import { g as assertValid } from './index-c7431a16.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.
|
package/dist/{StateMachine-4bf86161.development.esm.js → StateMachine-a5ede014.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-f5277b31.development.esm.js';
|
|
2
|
+
import { g as assertValid } from './index-3907b7aa.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.
|
package/dist/{StateMachine-5b915fb1.development.cjs.js → StateMachine-fa133051.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-f6e6146f.development.cjs.js');
|
|
4
|
+
var dist_xstateActors = require('./index-1e1e1cba.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.
|
|
@@ -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.
|
|
@@ -3699,6 +3730,9 @@ function getPersistedSnapshot(snapshot, options) {
|
|
|
3699
3730
|
const embedChildren = options?.embedChildren !== false;
|
|
3700
3731
|
for (const id in children) {
|
|
3701
3732
|
const child = children[id];
|
|
3733
|
+
if (typeof child.src !== 'string' && (!options || !('__unsafeAllowInlineActors' in options))) {
|
|
3734
|
+
throw new Error('An inline child actor cannot be persisted.');
|
|
3735
|
+
}
|
|
3702
3736
|
// Children are referenced by their logical address. Embedding the child
|
|
3703
3737
|
// state is the co-locating runtime's whole-tree checkpoint capability;
|
|
3704
3738
|
// remote handles never embed — their state lives with another runtime.
|
|
@@ -5747,6 +5781,7 @@ exports.pathToStateValue = pathToStateValue;
|
|
|
5747
5781
|
exports.reserveChildId = reserveChildId;
|
|
5748
5782
|
exports.resolveActionsWithContext = resolveActionsWithContext;
|
|
5749
5783
|
exports.resolveReferencedActor = resolveReferencedActor;
|
|
5784
|
+
exports.resolveRegisteredActorSource = resolveRegisteredActorSource;
|
|
5750
5785
|
exports.resolveStateValue = resolveStateValue;
|
|
5751
5786
|
exports.runStep = runStep;
|
|
5752
5787
|
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.
|
|
@@ -3697,6 +3728,9 @@ function getPersistedSnapshot(snapshot, options) {
|
|
|
3697
3728
|
const embedChildren = options?.embedChildren !== false;
|
|
3698
3729
|
for (const id in children) {
|
|
3699
3730
|
const child = children[id];
|
|
3731
|
+
if (typeof child.src !== 'string' && (!options || !('__unsafeAllowInlineActors' in options))) {
|
|
3732
|
+
throw new Error('An inline child actor cannot be persisted.');
|
|
3733
|
+
}
|
|
3700
3734
|
// Children are referenced by their logical address. Embedding the child
|
|
3701
3735
|
// state is the co-locating runtime's whole-tree checkpoint capability;
|
|
3702
3736
|
// remote handles never embed — their state lives with another runtime.
|
|
@@ -5662,4 +5696,4 @@ function createActor(logic, options) {
|
|
|
5662
5696
|
return new Actor(logic, options);
|
|
5663
5697
|
}
|
|
5664
5698
|
|
|
5665
|
-
export {
|
|
5699
|
+
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 };
|
package/dist/{createActor-60ee6b5b.development.esm.js → createActor-f5277b31.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.
|
|
@@ -5704,4 +5735,4 @@ function createActor(logic, options) {
|
|
|
5704
5735
|
return new Actor(logic, options);
|
|
5705
5736
|
}
|
|
5706
5737
|
|
|
5707
|
-
export {
|
|
5738
|
+
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 };
|
package/dist/{createActor-5c9fa117.development.cjs.js → createActor-f6e6146f.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.
|
|
@@ -5789,6 +5820,7 @@ exports.pathToStateValue = pathToStateValue;
|
|
|
5789
5820
|
exports.reserveChildId = reserveChildId;
|
|
5790
5821
|
exports.resolveActionsWithContext = resolveActionsWithContext;
|
|
5791
5822
|
exports.resolveReferencedActor = resolveReferencedActor;
|
|
5823
|
+
exports.resolveRegisteredActorSource = resolveRegisteredActorSource;
|
|
5792
5824
|
exports.resolveStateValue = resolveStateValue;
|
|
5793
5825
|
exports.runStep = runStep;
|
|
5794
5826
|
exports.setInertActorScopeSnapshot = setInertActorScopeSnapshot;
|
|
@@ -424,7 +424,7 @@ type StateTransitionFunction<TStateSchemas extends Record<string, SetupStateSche
|
|
|
424
424
|
guards: TGuardMap;
|
|
425
425
|
delays: TDelayMap;
|
|
426
426
|
input: TInput;
|
|
427
|
-
} & OutputArg<TExpressionEvent>, enq: EnqueueObject<TEvent, TEmitted, TSystemRegistry>) => StateTransitionResult<TStateSchemas, TContext, TContextShape, TMeta, TExpressionEvent, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry, false> | void;
|
|
427
|
+
} & OutputArg<TExpressionEvent>, enq: EnqueueObject<TEvent, TEmitted, TSystemRegistry, TActorMap>) => StateTransitionResult<TStateSchemas, TContext, TContextShape, TMeta, TExpressionEvent, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry, false> | void;
|
|
428
428
|
type StateTransitionResult<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TMeta extends MetaObject, TExpressionEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TSystemRegistry extends SystemRegistry, TAllowContextMapper extends boolean> = {
|
|
429
429
|
target?: never;
|
|
430
430
|
context?: StateTransitionContext<TAllowContextMapper, TContext, TContextShape, TContextShape, TContext, TExpressionEvent, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
@@ -209,7 +209,7 @@ export type TransitionConfigTarget = string | undefined;
|
|
|
209
209
|
export type TransitionConfigOrTarget<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays']> = SingleOrArray<TransitionConfigTarget | TransitionConfig<TContext, TExpressionEvent, TEvent, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap> | TransitionConfigFunction<TContext, TExpressionEvent, TEvent, TEmitted, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta>>;
|
|
210
210
|
export type TransitionConfigFunction<TContext extends MachineContext, TCurrentEvent extends EventObject, TEvent extends EventObject, TEmitted extends EventObject, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TMeta extends MetaObject, TInput = undefined, _TCtx extends MachineContext = [TContext] extends [never] ? any : TContext> = (args: TransitionFunctionArgs<_TCtx, TCurrentEvent, TEvent, TActionMap, TActorMap, TGuardMap, TDelayMap> & {
|
|
211
211
|
input: TInput;
|
|
212
|
-
}, enq: EnqueueObject<TEvent, TEmitted>) => {
|
|
212
|
+
}, enq: EnqueueObject<TEvent, TEmitted, SystemRegistry, TActorMap>) => {
|
|
213
213
|
target?: string | string[];
|
|
214
214
|
context?: TransitionContextPatch<_TCtx>;
|
|
215
215
|
reenter?: boolean;
|
|
@@ -1210,24 +1210,34 @@ export interface SubscribeToMappers<TSnapshot extends Snapshot<unknown>, TOutput
|
|
|
1210
1210
|
done?: (output: TOutput) => TMappedEvent;
|
|
1211
1211
|
error?: (error: unknown) => TMappedEvent;
|
|
1212
1212
|
}
|
|
1213
|
-
|
|
1213
|
+
type EnqueueSpawnOptions<TLogic extends AnyActorLogic, TSystemRegistry extends SystemRegistry> = {
|
|
1214
|
+
input?: InputFrom<TLogic>;
|
|
1215
|
+
id?: string;
|
|
1216
|
+
syncSnapshot?: boolean;
|
|
1217
|
+
registryKey?: RegistryKeyForLogic<TLogic, TSystemRegistry>;
|
|
1218
|
+
};
|
|
1219
|
+
type EnqueueSpawnArgs<TLogic extends AnyActorLogic, TSystemRegistry extends SystemRegistry> = ConditionalRequired<[
|
|
1220
|
+
options?: EnqueueSpawnOptions<TLogic, TSystemRegistry> & {
|
|
1221
|
+
[K in RequiredLogicInput<TLogic>]: unknown;
|
|
1222
|
+
}
|
|
1223
|
+
], IsNotNever<RequiredLogicInput<TLogic>>>;
|
|
1224
|
+
type EnqueueSpawner<TActorMap extends Sources['actors'], TSystemRegistry extends SystemRegistry> = {
|
|
1225
|
+
<TSource extends keyof TActorMap & string>(src: TSource, ...[options]: EnqueueSpawnArgs<TActorMap[TSource], TSystemRegistry>): ActorFromLogic<TActorMap[TSource]>;
|
|
1226
|
+
<TLogic extends AnyActorLogic>(logic: TLogic, ...[options]: EnqueueSpawnArgs<TLogic, TSystemRegistry>): ActorFromLogic<TLogic>;
|
|
1227
|
+
};
|
|
1228
|
+
export type EnqueueObject<TEvent extends EventObject, TEmittedEvent extends EventObject, TSystemRegistry extends SystemRegistry = SystemRegistry, TActorMap extends Sources['actors'] = Sources['actors']> = {
|
|
1214
1229
|
cancel: (id: string) => void;
|
|
1215
1230
|
raise: (ev: TEvent, options?: {
|
|
1216
1231
|
id?: string;
|
|
1217
1232
|
delay?: number;
|
|
1218
1233
|
}) => void;
|
|
1219
1234
|
/**
|
|
1220
|
-
* Spawns a child actor from
|
|
1221
|
-
* child gets a deterministic src-keyed id (`worker:0`,
|
|
1222
|
-
* allocated from the parent snapshot's own counters, so ids
|
|
1223
|
-
* identically and persist with the parent.
|
|
1235
|
+
* Spawns a child actor from a registered source key or logic. Without an
|
|
1236
|
+
* explicit `id`, the child gets a deterministic src-keyed id (`worker:0`,
|
|
1237
|
+
* `worker:1`, …) allocated from the parent snapshot's own counters, so ids
|
|
1238
|
+
* replay identically and persist with the parent.
|
|
1224
1239
|
*/
|
|
1225
|
-
spawn: <
|
|
1226
|
-
input?: InputFrom<T>;
|
|
1227
|
-
id?: string;
|
|
1228
|
-
syncSnapshot?: boolean;
|
|
1229
|
-
registryKey?: RegistryKeyForLogic<T, TSystemRegistry>;
|
|
1230
|
-
}) => ActorFromLogic<T>;
|
|
1240
|
+
spawn: EnqueueSpawner<TActorMap, TSystemRegistry>;
|
|
1231
1241
|
emit: (emittedEvent: TEmittedEvent) => void;
|
|
1232
1242
|
<T extends (...args: any[]) => any>(fn: T, ...args: Parameters<T>): void;
|
|
1233
1243
|
log: (...args: any[]) => void;
|
|
@@ -1270,7 +1280,7 @@ export type Action<TContext extends MachineContext, TEvent extends EventObject,
|
|
|
1270
1280
|
delays: TDelayMap;
|
|
1271
1281
|
system?: AnyActorSystem;
|
|
1272
1282
|
params: TParams;
|
|
1273
|
-
}, enqueue: EnqueueObject<TEvent, TEmittedEvent>) => {
|
|
1283
|
+
}, enqueue: EnqueueObject<TEvent, TEmittedEvent, SystemRegistry, TActorMap>) => {
|
|
1274
1284
|
context?: Partial<_TCtx>;
|
|
1275
1285
|
children?: Record<string, AnyActor | undefined>;
|
|
1276
1286
|
} | void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aa as createInertActorScope, ab as setInertActorScopeSnapshot, f as finalizeTransitionResult, ac as attachSnapshotActorRef, K as createInitEvent, az as hasAmbientInspector, a as beginSpawnAllocation, ad as macrostep, ao as createSpawnEffect, ap as initialMicrostep, j as isAtomicStateNode, aA as getProperAncestors, aB as isRemoteActorRef, aC as getActorIdPrefix } from './createActor-9523f716.esm.js';
|
|
2
2
|
|
|
3
3
|
function attachMicrostepActorRefs(microsteps, actorScope, inputSnapshot) {
|
|
4
4
|
if (!microsteps.length) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var createActor = require('./createActor-
|
|
3
|
+
var createActor = require('./createActor-f6e6146f.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
function attachMicrostepActorRefs(microsteps, actorScope, inputSnapshot) {
|
|
6
6
|
if (!microsteps.length) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aa as createInertActorScope, ab as setInertActorScopeSnapshot, f as finalizeTransitionResult, ac as attachSnapshotActorRef, K as createInitEvent, az as hasAmbientInspector, a as beginSpawnAllocation, ad as macrostep, ao as createSpawnEffect, ap as initialMicrostep, j as isAtomicStateNode, aA as getProperAncestors, aB as isRemoteActorRef, aC as getActorIdPrefix } from './createActor-f5277b31.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function attachMicrostepActorRefs(microsteps, actorScope, inputSnapshot) {
|
|
4
4
|
if (!microsteps.length) {
|