xstate 5.0.0-beta.30 → 5.0.0-beta.31
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/actions/dist/xstate-actions.cjs.js +3 -3
- package/actions/dist/xstate-actions.development.cjs.js +3 -3
- package/actions/dist/xstate-actions.development.esm.js +3 -3
- package/actions/dist/xstate-actions.esm.js +3 -3
- package/actions/dist/xstate-actions.umd.min.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js.map +1 -1
- package/actors/dist/xstate-actors.cjs.js +8 -12
- package/actors/dist/xstate-actors.development.cjs.js +8 -12
- package/actors/dist/xstate-actors.development.esm.js +8 -12
- package/actors/dist/xstate-actors.esm.js +8 -12
- package/actors/dist/xstate-actors.umd.min.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/declarations/src/Machine.d.ts +2 -2
- package/dist/declarations/src/StateNode.d.ts +2 -2
- package/dist/declarations/src/actors/callback.d.ts +1 -1
- package/dist/declarations/src/spawn.d.ts +3 -0
- package/dist/declarations/src/types.d.ts +17 -42
- package/dist/declarations/src/utils.d.ts +4 -4
- package/dist/{interpreter-a2c1e529.cjs.js → interpreter-05e11c15.cjs.js} +2 -2
- package/dist/{interpreter-7f1dc557.development.cjs.js → interpreter-a2236840.development.cjs.js} +3 -3
- package/dist/{interpreter-b8f53c4b.esm.js → interpreter-d5fa7ce0.esm.js} +2 -2
- package/dist/{interpreter-945c4b96.development.esm.js → interpreter-e4d2487f.development.esm.js} +3 -3
- package/dist/{raise-0b7dde8b.esm.js → raise-6a68d0cc.esm.js} +49 -22
- package/dist/{raise-6e4f5cf7.development.esm.js → raise-6fbd4513.development.esm.js} +49 -22
- package/dist/{raise-e79b1f86.cjs.js → raise-90808d65.cjs.js} +49 -22
- package/dist/{raise-7cae872b.development.cjs.js → raise-b4bfe138.development.cjs.js} +49 -22
- package/dist/{send-19a256f0.development.cjs.js → send-4163d2af.development.cjs.js} +52 -20
- package/dist/{send-e7063201.cjs.js → send-72e85cc6.cjs.js} +52 -20
- package/dist/{send-a1d772da.development.esm.js → send-7baeedcb.development.esm.js} +52 -20
- package/dist/{send-f4fb3ba5.esm.js → send-e5f0f3f6.esm.js} +52 -20
- package/dist/xstate.cjs.js +4 -4
- package/dist/xstate.development.cjs.js +7 -4
- package/dist/xstate.development.esm.js +10 -7
- package/dist/xstate.esm.js +7 -7
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.js +2 -2
- package/guards/dist/xstate-guards.development.cjs.js +2 -2
- package/guards/dist/xstate-guards.development.esm.js +2 -2
- package/guards/dist/xstate-guards.esm.js +2 -2
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var interpreter = require('./interpreter-
|
|
3
|
+
var interpreter = require('./interpreter-05e11c15.cjs.js');
|
|
4
4
|
|
|
5
5
|
const cache = new WeakMap();
|
|
6
6
|
function memo(object, key, fn) {
|
|
@@ -16,13 +16,13 @@ function memo(object, key, fn) {
|
|
|
16
16
|
return memoizedData[key];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function
|
|
19
|
+
function resolveCancel(_, state, actionArgs, {
|
|
20
20
|
sendId
|
|
21
21
|
}) {
|
|
22
22
|
const resolvedSendId = typeof sendId === 'function' ? sendId(actionArgs) : sendId;
|
|
23
23
|
return [state, resolvedSendId];
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function executeCancel(actorContext, resolvedSendId) {
|
|
26
26
|
actorContext.self.cancel(resolvedSendId);
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
@@ -37,16 +37,17 @@ function cancel(sendId) {
|
|
|
37
37
|
}
|
|
38
38
|
cancel.type = 'xstate.cancel';
|
|
39
39
|
cancel.sendId = sendId;
|
|
40
|
-
cancel.resolve =
|
|
41
|
-
cancel.execute =
|
|
40
|
+
cancel.resolve = resolveCancel;
|
|
41
|
+
cancel.execute = executeCancel;
|
|
42
42
|
return cancel;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
function
|
|
45
|
+
function resolveInvoke(actorContext, state, actionArgs, {
|
|
46
46
|
id,
|
|
47
47
|
systemId,
|
|
48
48
|
src,
|
|
49
|
-
input
|
|
49
|
+
input,
|
|
50
|
+
syncSnapshot
|
|
50
51
|
}) {
|
|
51
52
|
const referenced = interpreter.resolveReferencedActor(state.machine.implementations.actors[src]);
|
|
52
53
|
let actorRef;
|
|
@@ -64,6 +65,21 @@ function resolve$2(actorContext, state, actionArgs, {
|
|
|
64
65
|
self: actorContext?.self
|
|
65
66
|
}) : configuredInput
|
|
66
67
|
});
|
|
68
|
+
if (syncSnapshot) {
|
|
69
|
+
actorRef.subscribe({
|
|
70
|
+
next: snapshot => {
|
|
71
|
+
if (snapshot.status === 'active') {
|
|
72
|
+
actorContext.self.send({
|
|
73
|
+
type: `xstate.snapshot.${id}`,
|
|
74
|
+
snapshot
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
error: () => {
|
|
79
|
+
/* TODO */
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
67
83
|
}
|
|
68
84
|
return [cloneState(state, {
|
|
69
85
|
children: {
|
|
@@ -75,7 +91,7 @@ function resolve$2(actorContext, state, actionArgs, {
|
|
|
75
91
|
actorRef
|
|
76
92
|
}];
|
|
77
93
|
}
|
|
78
|
-
function
|
|
94
|
+
function executeInvoke(actorContext, {
|
|
79
95
|
id,
|
|
80
96
|
actorRef
|
|
81
97
|
}) {
|
|
@@ -101,7 +117,8 @@ function invoke({
|
|
|
101
117
|
id,
|
|
102
118
|
systemId,
|
|
103
119
|
src,
|
|
104
|
-
input
|
|
120
|
+
input,
|
|
121
|
+
onSnapshot
|
|
105
122
|
}) {
|
|
106
123
|
function invoke(_) {
|
|
107
124
|
}
|
|
@@ -110,12 +127,13 @@ function invoke({
|
|
|
110
127
|
invoke.systemId = systemId;
|
|
111
128
|
invoke.src = src;
|
|
112
129
|
invoke.input = input;
|
|
113
|
-
invoke.
|
|
114
|
-
invoke.
|
|
130
|
+
invoke.syncSnapshot = !!onSnapshot;
|
|
131
|
+
invoke.resolve = resolveInvoke;
|
|
132
|
+
invoke.execute = executeInvoke;
|
|
115
133
|
return invoke;
|
|
116
134
|
}
|
|
117
135
|
|
|
118
|
-
function
|
|
136
|
+
function resolveStop(_, state, args, {
|
|
119
137
|
actorRef
|
|
120
138
|
}) {
|
|
121
139
|
const actorRefOrString = typeof actorRef === 'function' ? actorRef(args) : actorRef;
|
|
@@ -131,7 +149,7 @@ function resolve$1(_, state, args, {
|
|
|
131
149
|
children
|
|
132
150
|
}), resolvedActorRef];
|
|
133
151
|
}
|
|
134
|
-
function
|
|
152
|
+
function executeStop(actorContext, actorRef) {
|
|
135
153
|
if (!actorRef) {
|
|
136
154
|
return;
|
|
137
155
|
}
|
|
@@ -154,8 +172,8 @@ function stop(actorRef) {
|
|
|
154
172
|
}
|
|
155
173
|
stop.type = 'xstate.stop';
|
|
156
174
|
stop.actorRef = actorRef;
|
|
157
|
-
stop.resolve =
|
|
158
|
-
stop.execute =
|
|
175
|
+
stop.resolve = resolveStop;
|
|
176
|
+
stop.execute = executeStop;
|
|
159
177
|
return stop;
|
|
160
178
|
}
|
|
161
179
|
|
|
@@ -262,9 +280,18 @@ function evaluateGuard(guard, context, event, state) {
|
|
|
262
280
|
}
|
|
263
281
|
|
|
264
282
|
function getOutput(configuration, context, event, self) {
|
|
265
|
-
const
|
|
283
|
+
const {
|
|
284
|
+
machine
|
|
285
|
+
} = configuration[0];
|
|
286
|
+
const {
|
|
287
|
+
root
|
|
288
|
+
} = machine;
|
|
289
|
+
if (!root.output) {
|
|
290
|
+
return undefined;
|
|
291
|
+
}
|
|
266
292
|
const finalChildStateNode = configuration.find(stateNode => stateNode.type === 'final' && stateNode.parent === machine.root);
|
|
267
|
-
|
|
293
|
+
const doneStateEvent = interpreter.createDoneStateEvent(finalChildStateNode.id, finalChildStateNode.output ? interpreter.resolveOutput(finalChildStateNode.output, context, event, self) : undefined);
|
|
294
|
+
return interpreter.resolveOutput(root.output, context, doneStateEvent, self);
|
|
268
295
|
}
|
|
269
296
|
const isAtomicStateNode = stateNode => stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
270
297
|
function getChildren(stateNode) {
|
|
@@ -930,7 +957,7 @@ function enterStates(event, filteredTransitions, mutConfiguration, actions, inte
|
|
|
930
957
|
if (!parent.parent) {
|
|
931
958
|
continue;
|
|
932
959
|
}
|
|
933
|
-
internalQueue.push(interpreter.createDoneStateEvent(parent.id, stateNodeToEnter.output ? interpreter.
|
|
960
|
+
internalQueue.push(interpreter.createDoneStateEvent(parent.id, stateNodeToEnter.output ? interpreter.resolveOutput(stateNodeToEnter.output, currentState.context, event, actorContext.self) : undefined));
|
|
934
961
|
if (parent.parent) {
|
|
935
962
|
const grandparent = parent.parent;
|
|
936
963
|
if (grandparent.type === 'parallel') {
|
|
@@ -1380,7 +1407,7 @@ function getPersistedState(state) {
|
|
|
1380
1407
|
};
|
|
1381
1408
|
}
|
|
1382
1409
|
|
|
1383
|
-
function
|
|
1410
|
+
function resolveRaise(_, state, args, {
|
|
1384
1411
|
event: eventOrExpr,
|
|
1385
1412
|
id,
|
|
1386
1413
|
delay
|
|
@@ -1405,7 +1432,7 @@ function resolve(_, state, args, {
|
|
|
1405
1432
|
delay: resolvedDelay
|
|
1406
1433
|
}];
|
|
1407
1434
|
}
|
|
1408
|
-
function
|
|
1435
|
+
function executeRaise(actorContext, params) {
|
|
1409
1436
|
if (typeof params.delay === 'number') {
|
|
1410
1437
|
actorContext.self.delaySend(params);
|
|
1411
1438
|
return;
|
|
@@ -1424,8 +1451,8 @@ function raise(eventOrExpr, options) {
|
|
|
1424
1451
|
raise.event = eventOrExpr;
|
|
1425
1452
|
raise.id = options?.id;
|
|
1426
1453
|
raise.delay = options?.delay;
|
|
1427
|
-
raise.resolve =
|
|
1428
|
-
raise.execute =
|
|
1454
|
+
raise.resolve = resolveRaise;
|
|
1455
|
+
raise.execute = executeRaise;
|
|
1429
1456
|
return raise;
|
|
1430
1457
|
}
|
|
1431
1458
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var interpreter = require('./interpreter-
|
|
3
|
+
var interpreter = require('./interpreter-a2236840.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
const cache = new WeakMap();
|
|
6
6
|
function memo(object, key, fn) {
|
|
@@ -16,13 +16,13 @@ function memo(object, key, fn) {
|
|
|
16
16
|
return memoizedData[key];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function
|
|
19
|
+
function resolveCancel(_, state, actionArgs, {
|
|
20
20
|
sendId
|
|
21
21
|
}) {
|
|
22
22
|
const resolvedSendId = typeof sendId === 'function' ? sendId(actionArgs) : sendId;
|
|
23
23
|
return [state, resolvedSendId];
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function executeCancel(actorContext, resolvedSendId) {
|
|
26
26
|
actorContext.self.cancel(resolvedSendId);
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
@@ -40,16 +40,17 @@ function cancel(sendId) {
|
|
|
40
40
|
}
|
|
41
41
|
cancel.type = 'xstate.cancel';
|
|
42
42
|
cancel.sendId = sendId;
|
|
43
|
-
cancel.resolve =
|
|
44
|
-
cancel.execute =
|
|
43
|
+
cancel.resolve = resolveCancel;
|
|
44
|
+
cancel.execute = executeCancel;
|
|
45
45
|
return cancel;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function
|
|
48
|
+
function resolveInvoke(actorContext, state, actionArgs, {
|
|
49
49
|
id,
|
|
50
50
|
systemId,
|
|
51
51
|
src,
|
|
52
|
-
input
|
|
52
|
+
input,
|
|
53
|
+
syncSnapshot
|
|
53
54
|
}) {
|
|
54
55
|
const referenced = interpreter.resolveReferencedActor(state.machine.implementations.actors[src]);
|
|
55
56
|
let actorRef;
|
|
@@ -67,6 +68,21 @@ function resolve$2(actorContext, state, actionArgs, {
|
|
|
67
68
|
self: actorContext?.self
|
|
68
69
|
}) : configuredInput
|
|
69
70
|
});
|
|
71
|
+
if (syncSnapshot) {
|
|
72
|
+
actorRef.subscribe({
|
|
73
|
+
next: snapshot => {
|
|
74
|
+
if (snapshot.status === 'active') {
|
|
75
|
+
actorContext.self.send({
|
|
76
|
+
type: `xstate.snapshot.${id}`,
|
|
77
|
+
snapshot
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
error: () => {
|
|
82
|
+
/* TODO */
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
70
86
|
}
|
|
71
87
|
if (!actorRef) {
|
|
72
88
|
console.warn(`Actor type '${src}' not found in machine '${actorContext.id}'.`);
|
|
@@ -81,7 +97,7 @@ function resolve$2(actorContext, state, actionArgs, {
|
|
|
81
97
|
actorRef
|
|
82
98
|
}];
|
|
83
99
|
}
|
|
84
|
-
function
|
|
100
|
+
function executeInvoke(actorContext, {
|
|
85
101
|
id,
|
|
86
102
|
actorRef
|
|
87
103
|
}) {
|
|
@@ -107,7 +123,8 @@ function invoke({
|
|
|
107
123
|
id,
|
|
108
124
|
systemId,
|
|
109
125
|
src,
|
|
110
|
-
input
|
|
126
|
+
input,
|
|
127
|
+
onSnapshot
|
|
111
128
|
}) {
|
|
112
129
|
function invoke(_) {
|
|
113
130
|
{
|
|
@@ -119,12 +136,13 @@ function invoke({
|
|
|
119
136
|
invoke.systemId = systemId;
|
|
120
137
|
invoke.src = src;
|
|
121
138
|
invoke.input = input;
|
|
122
|
-
invoke.
|
|
123
|
-
invoke.
|
|
139
|
+
invoke.syncSnapshot = !!onSnapshot;
|
|
140
|
+
invoke.resolve = resolveInvoke;
|
|
141
|
+
invoke.execute = executeInvoke;
|
|
124
142
|
return invoke;
|
|
125
143
|
}
|
|
126
144
|
|
|
127
|
-
function
|
|
145
|
+
function resolveStop(_, state, args, {
|
|
128
146
|
actorRef
|
|
129
147
|
}) {
|
|
130
148
|
const actorRefOrString = typeof actorRef === 'function' ? actorRef(args) : actorRef;
|
|
@@ -140,7 +158,7 @@ function resolve$1(_, state, args, {
|
|
|
140
158
|
children
|
|
141
159
|
}), resolvedActorRef];
|
|
142
160
|
}
|
|
143
|
-
function
|
|
161
|
+
function executeStop(actorContext, actorRef) {
|
|
144
162
|
if (!actorRef) {
|
|
145
163
|
return;
|
|
146
164
|
}
|
|
@@ -166,8 +184,8 @@ function stop(actorRef) {
|
|
|
166
184
|
}
|
|
167
185
|
stop.type = 'xstate.stop';
|
|
168
186
|
stop.actorRef = actorRef;
|
|
169
|
-
stop.resolve =
|
|
170
|
-
stop.execute =
|
|
187
|
+
stop.resolve = resolveStop;
|
|
188
|
+
stop.execute = executeStop;
|
|
171
189
|
return stop;
|
|
172
190
|
}
|
|
173
191
|
|
|
@@ -282,9 +300,18 @@ function evaluateGuard(guard, context, event, state) {
|
|
|
282
300
|
}
|
|
283
301
|
|
|
284
302
|
function getOutput(configuration, context, event, self) {
|
|
285
|
-
const
|
|
303
|
+
const {
|
|
304
|
+
machine
|
|
305
|
+
} = configuration[0];
|
|
306
|
+
const {
|
|
307
|
+
root
|
|
308
|
+
} = machine;
|
|
309
|
+
if (!root.output) {
|
|
310
|
+
return undefined;
|
|
311
|
+
}
|
|
286
312
|
const finalChildStateNode = configuration.find(stateNode => stateNode.type === 'final' && stateNode.parent === machine.root);
|
|
287
|
-
|
|
313
|
+
const doneStateEvent = interpreter.createDoneStateEvent(finalChildStateNode.id, finalChildStateNode.output ? interpreter.resolveOutput(finalChildStateNode.output, context, event, self) : undefined);
|
|
314
|
+
return interpreter.resolveOutput(root.output, context, doneStateEvent, self);
|
|
288
315
|
}
|
|
289
316
|
const isAtomicStateNode = stateNode => stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
290
317
|
function getChildren(stateNode) {
|
|
@@ -961,7 +988,7 @@ function enterStates(event, filteredTransitions, mutConfiguration, actions, inte
|
|
|
961
988
|
if (!parent.parent) {
|
|
962
989
|
continue;
|
|
963
990
|
}
|
|
964
|
-
internalQueue.push(interpreter.createDoneStateEvent(parent.id, stateNodeToEnter.output ? interpreter.
|
|
991
|
+
internalQueue.push(interpreter.createDoneStateEvent(parent.id, stateNodeToEnter.output ? interpreter.resolveOutput(stateNodeToEnter.output, currentState.context, event, actorContext.self) : undefined));
|
|
965
992
|
if (parent.parent) {
|
|
966
993
|
const grandparent = parent.parent;
|
|
967
994
|
if (grandparent.type === 'parallel') {
|
|
@@ -1417,7 +1444,7 @@ function getPersistedState(state) {
|
|
|
1417
1444
|
};
|
|
1418
1445
|
}
|
|
1419
1446
|
|
|
1420
|
-
function
|
|
1447
|
+
function resolveRaise(_, state, args, {
|
|
1421
1448
|
event: eventOrExpr,
|
|
1422
1449
|
id,
|
|
1423
1450
|
delay
|
|
@@ -1442,7 +1469,7 @@ function resolve(_, state, args, {
|
|
|
1442
1469
|
delay: resolvedDelay
|
|
1443
1470
|
}];
|
|
1444
1471
|
}
|
|
1445
|
-
function
|
|
1472
|
+
function executeRaise(actorContext, params) {
|
|
1446
1473
|
if (typeof params.delay === 'number') {
|
|
1447
1474
|
actorContext.self.delaySend(params);
|
|
1448
1475
|
return;
|
|
@@ -1464,8 +1491,8 @@ function raise(eventOrExpr, options) {
|
|
|
1464
1491
|
raise.event = eventOrExpr;
|
|
1465
1492
|
raise.id = options?.id;
|
|
1466
1493
|
raise.delay = options?.delay;
|
|
1467
|
-
raise.resolve =
|
|
1468
|
-
raise.execute =
|
|
1494
|
+
raise.resolve = resolveRaise;
|
|
1495
|
+
raise.execute = executeRaise;
|
|
1469
1496
|
return raise;
|
|
1470
1497
|
}
|
|
1471
1498
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
4
|
-
var interpreter = require('./interpreter-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-b4bfe138.development.cjs.js');
|
|
4
|
+
var interpreter = require('./interpreter-a2236840.development.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorContext, {
|
|
7
7
|
machine,
|
|
@@ -19,7 +19,7 @@ function createSpawner(actorContext, {
|
|
|
19
19
|
const input = 'input' in options ? options.input : referenced.input;
|
|
20
20
|
|
|
21
21
|
// TODO: this should also receive `src`
|
|
22
|
-
const
|
|
22
|
+
const actorRef = interpreter.createActor(referenced.src, {
|
|
23
23
|
id: options.id,
|
|
24
24
|
parent: actorContext.self,
|
|
25
25
|
input: typeof input === 'function' ? input({
|
|
@@ -29,16 +29,48 @@ function createSpawner(actorContext, {
|
|
|
29
29
|
}) : input,
|
|
30
30
|
systemId
|
|
31
31
|
});
|
|
32
|
-
spawnedChildren[
|
|
33
|
-
|
|
32
|
+
spawnedChildren[actorRef.id] = actorRef;
|
|
33
|
+
if (options.syncSnapshot) {
|
|
34
|
+
actorRef.subscribe({
|
|
35
|
+
next: snapshot => {
|
|
36
|
+
if (snapshot.status === 'active') {
|
|
37
|
+
actorContext.self.send({
|
|
38
|
+
type: `xstate.snapshot.${actorRef.id}`,
|
|
39
|
+
snapshot
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
error: () => {
|
|
44
|
+
/* TODO */
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return actorRef;
|
|
34
49
|
} else {
|
|
35
50
|
// TODO: this should also receive `src`
|
|
36
|
-
|
|
51
|
+
const actorRef = interpreter.createActor(src, {
|
|
37
52
|
id: options.id,
|
|
38
53
|
parent: actorContext.self,
|
|
39
54
|
input: options.input,
|
|
40
55
|
systemId
|
|
41
56
|
});
|
|
57
|
+
if (options.syncSnapshot) {
|
|
58
|
+
actorRef.subscribe({
|
|
59
|
+
next: snapshot => {
|
|
60
|
+
if (snapshot.status === 'active') {
|
|
61
|
+
actorContext.self.send({
|
|
62
|
+
type: `xstate.snapshot.${actorRef.id}`,
|
|
63
|
+
snapshot,
|
|
64
|
+
id: actorRef.id
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
error: () => {
|
|
69
|
+
/* TODO */
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return actorRef;
|
|
42
74
|
}
|
|
43
75
|
};
|
|
44
76
|
return (src, options) => {
|
|
@@ -59,7 +91,7 @@ function createSpawner(actorContext, {
|
|
|
59
91
|
};
|
|
60
92
|
}
|
|
61
93
|
|
|
62
|
-
function
|
|
94
|
+
function resolveAssign(actorContext, state, actionArgs, {
|
|
63
95
|
assignment
|
|
64
96
|
}) {
|
|
65
97
|
if (!state.context) {
|
|
@@ -105,11 +137,11 @@ function assign(assignment) {
|
|
|
105
137
|
}
|
|
106
138
|
assign.type = 'xstate.assign';
|
|
107
139
|
assign.assignment = assignment;
|
|
108
|
-
assign.resolve =
|
|
140
|
+
assign.resolve = resolveAssign;
|
|
109
141
|
return assign;
|
|
110
142
|
}
|
|
111
143
|
|
|
112
|
-
function
|
|
144
|
+
function resolveChoose(_, state, actionArgs, {
|
|
113
145
|
branches
|
|
114
146
|
}) {
|
|
115
147
|
const matchedActions = branches.find(condition => {
|
|
@@ -125,11 +157,11 @@ function choose(branches) {
|
|
|
125
157
|
}
|
|
126
158
|
choose.type = 'xstate.choose';
|
|
127
159
|
choose.branches = branches;
|
|
128
|
-
choose.resolve =
|
|
160
|
+
choose.resolve = resolveChoose;
|
|
129
161
|
return choose;
|
|
130
162
|
}
|
|
131
163
|
|
|
132
|
-
function
|
|
164
|
+
function resolveLog(_, state, actionArgs, {
|
|
133
165
|
value,
|
|
134
166
|
label
|
|
135
167
|
}) {
|
|
@@ -138,7 +170,7 @@ function resolve$2(_, state, actionArgs, {
|
|
|
138
170
|
label
|
|
139
171
|
}];
|
|
140
172
|
}
|
|
141
|
-
function
|
|
173
|
+
function executeLog({
|
|
142
174
|
logger
|
|
143
175
|
}, {
|
|
144
176
|
value,
|
|
@@ -173,12 +205,12 @@ function log(value = ({
|
|
|
173
205
|
log.type = 'xstate.log';
|
|
174
206
|
log.value = value;
|
|
175
207
|
log.label = label;
|
|
176
|
-
log.resolve =
|
|
177
|
-
log.execute =
|
|
208
|
+
log.resolve = resolveLog;
|
|
209
|
+
log.execute = executeLog;
|
|
178
210
|
return log;
|
|
179
211
|
}
|
|
180
212
|
|
|
181
|
-
function
|
|
213
|
+
function resolvePure(_, state, args, {
|
|
182
214
|
get
|
|
183
215
|
}) {
|
|
184
216
|
return [state, undefined, interpreter.toArray(get({
|
|
@@ -194,7 +226,7 @@ function pure(getActions) {
|
|
|
194
226
|
}
|
|
195
227
|
pure.type = 'xstate.pure';
|
|
196
228
|
pure.get = getActions;
|
|
197
|
-
pure.resolve =
|
|
229
|
+
pure.resolve = resolvePure;
|
|
198
230
|
return pure;
|
|
199
231
|
}
|
|
200
232
|
|
|
@@ -233,7 +265,7 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
233
265
|
return SpecialTargets;
|
|
234
266
|
}({});
|
|
235
267
|
|
|
236
|
-
function
|
|
268
|
+
function resolveSendTo(actorContext, state, args, {
|
|
237
269
|
to,
|
|
238
270
|
event: eventOrExpr,
|
|
239
271
|
id,
|
|
@@ -278,7 +310,7 @@ function resolve(actorContext, state, args, {
|
|
|
278
310
|
delay: resolvedDelay
|
|
279
311
|
}];
|
|
280
312
|
}
|
|
281
|
-
function
|
|
313
|
+
function executeSendTo(actorContext, params) {
|
|
282
314
|
if (typeof params.delay === 'number') {
|
|
283
315
|
actorContext.self.delaySend(params);
|
|
284
316
|
return;
|
|
@@ -311,8 +343,8 @@ function sendTo(to, eventOrExpr, options) {
|
|
|
311
343
|
sendTo.event = eventOrExpr;
|
|
312
344
|
sendTo.id = options?.id;
|
|
313
345
|
sendTo.delay = options?.delay;
|
|
314
|
-
sendTo.resolve =
|
|
315
|
-
sendTo.execute =
|
|
346
|
+
sendTo.resolve = resolveSendTo;
|
|
347
|
+
sendTo.execute = executeSendTo;
|
|
316
348
|
return sendTo;
|
|
317
349
|
}
|
|
318
350
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
4
|
-
var interpreter = require('./interpreter-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-90808d65.cjs.js');
|
|
4
|
+
var interpreter = require('./interpreter-05e11c15.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorContext, {
|
|
7
7
|
machine,
|
|
@@ -19,7 +19,7 @@ function createSpawner(actorContext, {
|
|
|
19
19
|
const input = 'input' in options ? options.input : referenced.input;
|
|
20
20
|
|
|
21
21
|
// TODO: this should also receive `src`
|
|
22
|
-
const
|
|
22
|
+
const actorRef = interpreter.createActor(referenced.src, {
|
|
23
23
|
id: options.id,
|
|
24
24
|
parent: actorContext.self,
|
|
25
25
|
input: typeof input === 'function' ? input({
|
|
@@ -29,16 +29,48 @@ function createSpawner(actorContext, {
|
|
|
29
29
|
}) : input,
|
|
30
30
|
systemId
|
|
31
31
|
});
|
|
32
|
-
spawnedChildren[
|
|
33
|
-
|
|
32
|
+
spawnedChildren[actorRef.id] = actorRef;
|
|
33
|
+
if (options.syncSnapshot) {
|
|
34
|
+
actorRef.subscribe({
|
|
35
|
+
next: snapshot => {
|
|
36
|
+
if (snapshot.status === 'active') {
|
|
37
|
+
actorContext.self.send({
|
|
38
|
+
type: `xstate.snapshot.${actorRef.id}`,
|
|
39
|
+
snapshot
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
error: () => {
|
|
44
|
+
/* TODO */
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return actorRef;
|
|
34
49
|
} else {
|
|
35
50
|
// TODO: this should also receive `src`
|
|
36
|
-
|
|
51
|
+
const actorRef = interpreter.createActor(src, {
|
|
37
52
|
id: options.id,
|
|
38
53
|
parent: actorContext.self,
|
|
39
54
|
input: options.input,
|
|
40
55
|
systemId
|
|
41
56
|
});
|
|
57
|
+
if (options.syncSnapshot) {
|
|
58
|
+
actorRef.subscribe({
|
|
59
|
+
next: snapshot => {
|
|
60
|
+
if (snapshot.status === 'active') {
|
|
61
|
+
actorContext.self.send({
|
|
62
|
+
type: `xstate.snapshot.${actorRef.id}`,
|
|
63
|
+
snapshot,
|
|
64
|
+
id: actorRef.id
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
error: () => {
|
|
69
|
+
/* TODO */
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return actorRef;
|
|
42
74
|
}
|
|
43
75
|
};
|
|
44
76
|
return (src, options) => {
|
|
@@ -59,7 +91,7 @@ function createSpawner(actorContext, {
|
|
|
59
91
|
};
|
|
60
92
|
}
|
|
61
93
|
|
|
62
|
-
function
|
|
94
|
+
function resolveAssign(actorContext, state, actionArgs, {
|
|
63
95
|
assignment
|
|
64
96
|
}) {
|
|
65
97
|
if (!state.context) {
|
|
@@ -102,11 +134,11 @@ function assign(assignment) {
|
|
|
102
134
|
}
|
|
103
135
|
assign.type = 'xstate.assign';
|
|
104
136
|
assign.assignment = assignment;
|
|
105
|
-
assign.resolve =
|
|
137
|
+
assign.resolve = resolveAssign;
|
|
106
138
|
return assign;
|
|
107
139
|
}
|
|
108
140
|
|
|
109
|
-
function
|
|
141
|
+
function resolveChoose(_, state, actionArgs, {
|
|
110
142
|
branches
|
|
111
143
|
}) {
|
|
112
144
|
const matchedActions = branches.find(condition => {
|
|
@@ -119,11 +151,11 @@ function choose(branches) {
|
|
|
119
151
|
}
|
|
120
152
|
choose.type = 'xstate.choose';
|
|
121
153
|
choose.branches = branches;
|
|
122
|
-
choose.resolve =
|
|
154
|
+
choose.resolve = resolveChoose;
|
|
123
155
|
return choose;
|
|
124
156
|
}
|
|
125
157
|
|
|
126
|
-
function
|
|
158
|
+
function resolveLog(_, state, actionArgs, {
|
|
127
159
|
value,
|
|
128
160
|
label
|
|
129
161
|
}) {
|
|
@@ -132,7 +164,7 @@ function resolve$2(_, state, actionArgs, {
|
|
|
132
164
|
label
|
|
133
165
|
}];
|
|
134
166
|
}
|
|
135
|
-
function
|
|
167
|
+
function executeLog({
|
|
136
168
|
logger
|
|
137
169
|
}, {
|
|
138
170
|
value,
|
|
@@ -164,12 +196,12 @@ function log(value = ({
|
|
|
164
196
|
log.type = 'xstate.log';
|
|
165
197
|
log.value = value;
|
|
166
198
|
log.label = label;
|
|
167
|
-
log.resolve =
|
|
168
|
-
log.execute =
|
|
199
|
+
log.resolve = resolveLog;
|
|
200
|
+
log.execute = executeLog;
|
|
169
201
|
return log;
|
|
170
202
|
}
|
|
171
203
|
|
|
172
|
-
function
|
|
204
|
+
function resolvePure(_, state, args, {
|
|
173
205
|
get
|
|
174
206
|
}) {
|
|
175
207
|
return [state, undefined, interpreter.toArray(get({
|
|
@@ -182,7 +214,7 @@ function pure(getActions) {
|
|
|
182
214
|
}
|
|
183
215
|
pure.type = 'xstate.pure';
|
|
184
216
|
pure.get = getActions;
|
|
185
|
-
pure.resolve =
|
|
217
|
+
pure.resolve = resolvePure;
|
|
186
218
|
return pure;
|
|
187
219
|
}
|
|
188
220
|
|
|
@@ -221,7 +253,7 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
221
253
|
return SpecialTargets;
|
|
222
254
|
}({});
|
|
223
255
|
|
|
224
|
-
function
|
|
256
|
+
function resolveSendTo(actorContext, state, args, {
|
|
225
257
|
to,
|
|
226
258
|
event: eventOrExpr,
|
|
227
259
|
id,
|
|
@@ -266,7 +298,7 @@ function resolve(actorContext, state, args, {
|
|
|
266
298
|
delay: resolvedDelay
|
|
267
299
|
}];
|
|
268
300
|
}
|
|
269
|
-
function
|
|
301
|
+
function executeSendTo(actorContext, params) {
|
|
270
302
|
if (typeof params.delay === 'number') {
|
|
271
303
|
actorContext.self.delaySend(params);
|
|
272
304
|
return;
|
|
@@ -296,8 +328,8 @@ function sendTo(to, eventOrExpr, options) {
|
|
|
296
328
|
sendTo.event = eventOrExpr;
|
|
297
329
|
sendTo.id = options?.id;
|
|
298
330
|
sendTo.delay = options?.delay;
|
|
299
|
-
sendTo.resolve =
|
|
300
|
-
sendTo.execute =
|
|
331
|
+
sendTo.resolve = resolveSendTo;
|
|
332
|
+
sendTo.execute = executeSendTo;
|
|
301
333
|
return sendTo;
|
|
302
334
|
}
|
|
303
335
|
|