xstate 5.0.0-beta.36 → 5.0.0-beta.38
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 +4 -3
- package/actions/dist/xstate-actions.cjs.mjs +1 -0
- package/actions/dist/xstate-actions.development.cjs.js +4 -3
- package/actions/dist/xstate-actions.development.cjs.mjs +1 -0
- 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 +1 -1
- package/actors/dist/xstate-actors.development.cjs.js +1 -1
- package/actors/dist/xstate-actors.development.esm.js +1 -1
- package/actors/dist/xstate-actors.esm.js +1 -1
- 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/State.d.ts +2 -2
- package/dist/declarations/src/StateMachine.d.ts +4 -4
- package/dist/declarations/src/actions/assign.d.ts +4 -4
- package/dist/declarations/src/actions/cancel.d.ts +4 -4
- package/dist/declarations/src/actions/choose.d.ts +3 -3
- package/dist/declarations/src/actions/log.d.ts +4 -4
- package/dist/declarations/src/actions/pure.d.ts +4 -4
- package/dist/declarations/src/actions/raise.d.ts +3 -3
- package/dist/declarations/src/actions/send.d.ts +7 -7
- package/dist/declarations/src/actions/spawn.d.ts +34 -0
- package/dist/declarations/src/actions/stop.d.ts +4 -4
- package/dist/declarations/src/actions.d.ts +1 -0
- package/dist/declarations/src/actors/callback.d.ts +2 -2
- package/dist/declarations/src/actors/observable.d.ts +2 -3
- package/dist/declarations/src/actors/promise.d.ts +0 -1
- package/dist/declarations/src/actors/transition.d.ts +1 -1
- package/dist/declarations/src/guards.d.ts +9 -10
- package/dist/declarations/src/interpreter.d.ts +2 -2
- package/dist/declarations/src/spawn.d.ts +1 -2
- package/dist/declarations/src/stateUtils.d.ts +0 -5
- package/dist/declarations/src/typegenTypes.d.ts +2 -0
- package/dist/declarations/src/types.d.ts +47 -58
- package/dist/declarations/src/utils.d.ts +6 -6
- package/dist/declarations/src/waitFor.d.ts +1 -1
- package/dist/{interpreter-5c4e6634.development.esm.js → interpreter-4005eb36.development.esm.js} +14 -24
- package/dist/{interpreter-69605bf0.cjs.js → interpreter-b6f22ee2.cjs.js} +14 -24
- package/dist/{interpreter-de5217bc.esm.js → interpreter-c80ce92e.esm.js} +14 -24
- package/dist/{interpreter-d3567419.development.cjs.js → interpreter-ed3f81f7.development.cjs.js} +14 -24
- package/dist/{raise-5b7ad3b7.development.esm.js → raise-42073973.development.esm.js} +138 -118
- package/dist/{raise-c51b81a3.cjs.js → raise-7faa9b3b.cjs.js} +139 -118
- package/dist/{raise-106ea558.development.cjs.js → raise-b69a3d16.development.cjs.js} +138 -117
- package/dist/{raise-ffe1014a.esm.js → raise-c989c7fb.esm.js} +139 -119
- package/dist/{send-778692de.cjs.js → send-34160163.cjs.js} +31 -27
- package/dist/{send-0a7aa74e.esm.js → send-4b616da9.esm.js} +31 -27
- package/dist/{send-25e70bd4.development.cjs.js → send-58725522.development.cjs.js} +31 -27
- package/dist/{send-e93554d6.development.esm.js → send-bff8c910.development.esm.js} +31 -27
- package/dist/xstate.cjs.js +11 -16
- package/dist/xstate.cjs.mjs +1 -0
- package/dist/xstate.development.cjs.js +11 -16
- package/dist/xstate.development.cjs.mjs +1 -0
- package/dist/xstate.development.esm.js +13 -19
- package/dist/xstate.esm.js +13 -19
- 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 +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -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-7faa9b3b.cjs.js');
|
|
4
|
+
var interpreter = require('./interpreter-b6f22ee2.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorContext, {
|
|
7
7
|
machine,
|
|
@@ -12,7 +12,7 @@ function createSpawner(actorContext, {
|
|
|
12
12
|
systemId
|
|
13
13
|
} = options;
|
|
14
14
|
if (typeof src === 'string') {
|
|
15
|
-
const referenced = interpreter.resolveReferencedActor(machine
|
|
15
|
+
const referenced = interpreter.resolveReferencedActor(machine, src);
|
|
16
16
|
if (!referenced) {
|
|
17
17
|
throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
|
|
18
18
|
}
|
|
@@ -41,9 +41,7 @@ function createSpawner(actorContext, {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
error: () => {
|
|
45
|
-
/* TODO */
|
|
46
|
-
}
|
|
44
|
+
error: () => {}
|
|
47
45
|
});
|
|
48
46
|
}
|
|
49
47
|
return actorRef;
|
|
@@ -67,9 +65,7 @@ function createSpawner(actorContext, {
|
|
|
67
65
|
});
|
|
68
66
|
}
|
|
69
67
|
},
|
|
70
|
-
error: () => {
|
|
71
|
-
/* TODO */
|
|
72
|
-
}
|
|
68
|
+
error: () => {}
|
|
73
69
|
});
|
|
74
70
|
}
|
|
75
71
|
return actorRef;
|
|
@@ -93,7 +89,7 @@ function createSpawner(actorContext, {
|
|
|
93
89
|
};
|
|
94
90
|
}
|
|
95
91
|
|
|
96
|
-
function resolveAssign(actorContext, state, actionArgs, {
|
|
92
|
+
function resolveAssign(actorContext, state, actionArgs, actionParams, {
|
|
97
93
|
assignment
|
|
98
94
|
}) {
|
|
99
95
|
if (!state.context) {
|
|
@@ -103,18 +99,17 @@ function resolveAssign(actorContext, state, actionArgs, {
|
|
|
103
99
|
const assignArgs = {
|
|
104
100
|
context: state.context,
|
|
105
101
|
event: actionArgs.event,
|
|
106
|
-
action: actionArgs.action,
|
|
107
102
|
spawn: createSpawner(actorContext, state, actionArgs.event, spawnedChildren),
|
|
108
103
|
self: actorContext?.self,
|
|
109
104
|
system: actorContext?.system
|
|
110
105
|
};
|
|
111
106
|
let partialUpdate = {};
|
|
112
107
|
if (typeof assignment === 'function') {
|
|
113
|
-
partialUpdate = assignment(assignArgs);
|
|
108
|
+
partialUpdate = assignment(assignArgs, actionParams);
|
|
114
109
|
} else {
|
|
115
110
|
for (const key of Object.keys(assignment)) {
|
|
116
111
|
const propAssignment = assignment[key];
|
|
117
|
-
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs) : propAssignment;
|
|
112
|
+
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
|
|
118
113
|
}
|
|
119
114
|
}
|
|
120
115
|
const updatedContext = Object.assign({}, state.context, partialUpdate);
|
|
@@ -132,7 +127,7 @@ function resolveAssign(actorContext, state, actionArgs, {
|
|
|
132
127
|
* @param assignment An object that represents the partial context to update.
|
|
133
128
|
*/
|
|
134
129
|
function assign(assignment) {
|
|
135
|
-
function assign(
|
|
130
|
+
function assign(args, params) {
|
|
136
131
|
}
|
|
137
132
|
assign.type = 'xstate.assign';
|
|
138
133
|
assign.assignment = assignment;
|
|
@@ -140,7 +135,7 @@ function assign(assignment) {
|
|
|
140
135
|
return assign;
|
|
141
136
|
}
|
|
142
137
|
|
|
143
|
-
function resolveChoose(_, state, actionArgs, {
|
|
138
|
+
function resolveChoose(_, state, actionArgs, _actionParams, {
|
|
144
139
|
branches
|
|
145
140
|
}) {
|
|
146
141
|
const matchedActions = branches.find(condition => {
|
|
@@ -149,7 +144,7 @@ function resolveChoose(_, state, actionArgs, {
|
|
|
149
144
|
return [state, undefined, interpreter.toArray(matchedActions)];
|
|
150
145
|
}
|
|
151
146
|
function choose(branches) {
|
|
152
|
-
function choose(
|
|
147
|
+
function choose(args, params) {
|
|
153
148
|
}
|
|
154
149
|
choose.type = 'xstate.choose';
|
|
155
150
|
choose.branches = branches;
|
|
@@ -157,12 +152,12 @@ function choose(branches) {
|
|
|
157
152
|
return choose;
|
|
158
153
|
}
|
|
159
154
|
|
|
160
|
-
function resolveLog(_, state, actionArgs, {
|
|
155
|
+
function resolveLog(_, state, actionArgs, actionParams, {
|
|
161
156
|
value,
|
|
162
157
|
label
|
|
163
158
|
}) {
|
|
164
159
|
return [state, {
|
|
165
|
-
value: typeof value === 'function' ? value(actionArgs) : value,
|
|
160
|
+
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
166
161
|
label
|
|
167
162
|
}];
|
|
168
163
|
}
|
|
@@ -193,7 +188,7 @@ function log(value = ({
|
|
|
193
188
|
context,
|
|
194
189
|
event
|
|
195
190
|
}), label) {
|
|
196
|
-
function log(
|
|
191
|
+
function log(args, params) {
|
|
197
192
|
}
|
|
198
193
|
log.type = 'xstate.log';
|
|
199
194
|
log.value = value;
|
|
@@ -203,7 +198,7 @@ function log(value = ({
|
|
|
203
198
|
return log;
|
|
204
199
|
}
|
|
205
200
|
|
|
206
|
-
function resolvePure(_, state, args, {
|
|
201
|
+
function resolvePure(_, state, args, _actionParams, {
|
|
207
202
|
get
|
|
208
203
|
}) {
|
|
209
204
|
return [state, undefined, interpreter.toArray(get({
|
|
@@ -212,7 +207,7 @@ function resolvePure(_, state, args, {
|
|
|
212
207
|
}))];
|
|
213
208
|
}
|
|
214
209
|
function pure(getActions) {
|
|
215
|
-
function pure(
|
|
210
|
+
function pure(args, params) {
|
|
216
211
|
}
|
|
217
212
|
pure.type = 'xstate.pure';
|
|
218
213
|
pure.get = getActions;
|
|
@@ -221,6 +216,9 @@ function pure(getActions) {
|
|
|
221
216
|
}
|
|
222
217
|
|
|
223
218
|
/**
|
|
219
|
+
*
|
|
220
|
+
* @remarks
|
|
221
|
+
*
|
|
224
222
|
* `T | unknown` reduces to `unknown` and that can be problematic when it comes to contextual typing.
|
|
225
223
|
* It especially is a problem when the union has a function member, like here:
|
|
226
224
|
*
|
|
@@ -241,7 +239,10 @@ function pure(getActions) {
|
|
|
241
239
|
/**
|
|
242
240
|
* The string or object representing the state value relative to the parent state node.
|
|
243
241
|
*
|
|
242
|
+
* @remarks
|
|
243
|
+
*
|
|
244
244
|
* - For a child atomic state node, this is a string, e.g., `"pending"`.
|
|
245
|
+
*
|
|
245
246
|
* - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
|
|
246
247
|
*/
|
|
247
248
|
|
|
@@ -255,7 +256,7 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
255
256
|
return SpecialTargets;
|
|
256
257
|
}({});
|
|
257
258
|
|
|
258
|
-
function resolveSendTo(actorContext, state, args, {
|
|
259
|
+
function resolveSendTo(actorContext, state, args, actionParams, {
|
|
259
260
|
to,
|
|
260
261
|
event: eventOrExpr,
|
|
261
262
|
id,
|
|
@@ -265,15 +266,15 @@ function resolveSendTo(actorContext, state, args, {
|
|
|
265
266
|
if (typeof eventOrExpr === 'string') {
|
|
266
267
|
throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
|
|
267
268
|
}
|
|
268
|
-
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr;
|
|
269
|
+
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
269
270
|
let resolvedDelay;
|
|
270
271
|
if (typeof delay === 'string') {
|
|
271
272
|
const configDelay = delaysMap && delaysMap[delay];
|
|
272
|
-
resolvedDelay = typeof configDelay === 'function' ? configDelay(args) : configDelay;
|
|
273
|
+
resolvedDelay = typeof configDelay === 'function' ? configDelay(args, actionParams) : configDelay;
|
|
273
274
|
} else {
|
|
274
|
-
resolvedDelay = typeof delay === 'function' ? delay(args) : delay;
|
|
275
|
+
resolvedDelay = typeof delay === 'function' ? delay(args, actionParams) : delay;
|
|
275
276
|
}
|
|
276
|
-
const resolvedTarget = typeof to === 'function' ? to(args) : to;
|
|
277
|
+
const resolvedTarget = typeof to === 'function' ? to(args, actionParams) : to;
|
|
277
278
|
let targetActorRef;
|
|
278
279
|
if (typeof resolvedTarget === 'string') {
|
|
279
280
|
if (resolvedTarget === SpecialTargets.Parent) {
|
|
@@ -310,6 +311,9 @@ function executeSendTo(actorContext, params) {
|
|
|
310
311
|
actorContext.self.delaySend(params);
|
|
311
312
|
return;
|
|
312
313
|
}
|
|
314
|
+
|
|
315
|
+
// this forms an outgoing events queue
|
|
316
|
+
// thanks to that the recipient actors are able to read the *updated* snapshot value of the sender
|
|
313
317
|
actorContext.defer(() => {
|
|
314
318
|
const {
|
|
315
319
|
to,
|
|
@@ -328,7 +332,7 @@ function executeSendTo(actorContext, params) {
|
|
|
328
332
|
* - `delay` - The number of milliseconds to delay the sending of the event.
|
|
329
333
|
*/
|
|
330
334
|
function sendTo(to, eventOrExpr, options) {
|
|
331
|
-
function sendTo(
|
|
335
|
+
function sendTo(args, params) {
|
|
332
336
|
}
|
|
333
337
|
sendTo.type = 'xstate.sendTo';
|
|
334
338
|
sendTo.to = to;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as cloneState, e as evaluateGuard } from './raise-
|
|
2
|
-
import { f as ActorStatus, j as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, x as XSTATE_ERROR } from './interpreter-
|
|
1
|
+
import { j as cloneState, e as evaluateGuard } from './raise-c989c7fb.esm.js';
|
|
2
|
+
import { f as ActorStatus, j as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, x as XSTATE_ERROR } from './interpreter-c80ce92e.esm.js';
|
|
3
3
|
|
|
4
4
|
function createSpawner(actorContext, {
|
|
5
5
|
machine,
|
|
@@ -10,7 +10,7 @@ function createSpawner(actorContext, {
|
|
|
10
10
|
systemId
|
|
11
11
|
} = options;
|
|
12
12
|
if (typeof src === 'string') {
|
|
13
|
-
const referenced = resolveReferencedActor(machine
|
|
13
|
+
const referenced = resolveReferencedActor(machine, src);
|
|
14
14
|
if (!referenced) {
|
|
15
15
|
throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
|
|
16
16
|
}
|
|
@@ -39,9 +39,7 @@ function createSpawner(actorContext, {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
|
-
error: () => {
|
|
43
|
-
/* TODO */
|
|
44
|
-
}
|
|
42
|
+
error: () => {}
|
|
45
43
|
});
|
|
46
44
|
}
|
|
47
45
|
return actorRef;
|
|
@@ -65,9 +63,7 @@ function createSpawner(actorContext, {
|
|
|
65
63
|
});
|
|
66
64
|
}
|
|
67
65
|
},
|
|
68
|
-
error: () => {
|
|
69
|
-
/* TODO */
|
|
70
|
-
}
|
|
66
|
+
error: () => {}
|
|
71
67
|
});
|
|
72
68
|
}
|
|
73
69
|
return actorRef;
|
|
@@ -91,7 +87,7 @@ function createSpawner(actorContext, {
|
|
|
91
87
|
};
|
|
92
88
|
}
|
|
93
89
|
|
|
94
|
-
function resolveAssign(actorContext, state, actionArgs, {
|
|
90
|
+
function resolveAssign(actorContext, state, actionArgs, actionParams, {
|
|
95
91
|
assignment
|
|
96
92
|
}) {
|
|
97
93
|
if (!state.context) {
|
|
@@ -101,18 +97,17 @@ function resolveAssign(actorContext, state, actionArgs, {
|
|
|
101
97
|
const assignArgs = {
|
|
102
98
|
context: state.context,
|
|
103
99
|
event: actionArgs.event,
|
|
104
|
-
action: actionArgs.action,
|
|
105
100
|
spawn: createSpawner(actorContext, state, actionArgs.event, spawnedChildren),
|
|
106
101
|
self: actorContext?.self,
|
|
107
102
|
system: actorContext?.system
|
|
108
103
|
};
|
|
109
104
|
let partialUpdate = {};
|
|
110
105
|
if (typeof assignment === 'function') {
|
|
111
|
-
partialUpdate = assignment(assignArgs);
|
|
106
|
+
partialUpdate = assignment(assignArgs, actionParams);
|
|
112
107
|
} else {
|
|
113
108
|
for (const key of Object.keys(assignment)) {
|
|
114
109
|
const propAssignment = assignment[key];
|
|
115
|
-
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs) : propAssignment;
|
|
110
|
+
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
|
|
116
111
|
}
|
|
117
112
|
}
|
|
118
113
|
const updatedContext = Object.assign({}, state.context, partialUpdate);
|
|
@@ -130,7 +125,7 @@ function resolveAssign(actorContext, state, actionArgs, {
|
|
|
130
125
|
* @param assignment An object that represents the partial context to update.
|
|
131
126
|
*/
|
|
132
127
|
function assign(assignment) {
|
|
133
|
-
function assign(
|
|
128
|
+
function assign(args, params) {
|
|
134
129
|
}
|
|
135
130
|
assign.type = 'xstate.assign';
|
|
136
131
|
assign.assignment = assignment;
|
|
@@ -138,7 +133,7 @@ function assign(assignment) {
|
|
|
138
133
|
return assign;
|
|
139
134
|
}
|
|
140
135
|
|
|
141
|
-
function resolveChoose(_, state, actionArgs, {
|
|
136
|
+
function resolveChoose(_, state, actionArgs, _actionParams, {
|
|
142
137
|
branches
|
|
143
138
|
}) {
|
|
144
139
|
const matchedActions = branches.find(condition => {
|
|
@@ -147,7 +142,7 @@ function resolveChoose(_, state, actionArgs, {
|
|
|
147
142
|
return [state, undefined, toArray(matchedActions)];
|
|
148
143
|
}
|
|
149
144
|
function choose(branches) {
|
|
150
|
-
function choose(
|
|
145
|
+
function choose(args, params) {
|
|
151
146
|
}
|
|
152
147
|
choose.type = 'xstate.choose';
|
|
153
148
|
choose.branches = branches;
|
|
@@ -155,12 +150,12 @@ function choose(branches) {
|
|
|
155
150
|
return choose;
|
|
156
151
|
}
|
|
157
152
|
|
|
158
|
-
function resolveLog(_, state, actionArgs, {
|
|
153
|
+
function resolveLog(_, state, actionArgs, actionParams, {
|
|
159
154
|
value,
|
|
160
155
|
label
|
|
161
156
|
}) {
|
|
162
157
|
return [state, {
|
|
163
|
-
value: typeof value === 'function' ? value(actionArgs) : value,
|
|
158
|
+
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
164
159
|
label
|
|
165
160
|
}];
|
|
166
161
|
}
|
|
@@ -191,7 +186,7 @@ function log(value = ({
|
|
|
191
186
|
context,
|
|
192
187
|
event
|
|
193
188
|
}), label) {
|
|
194
|
-
function log(
|
|
189
|
+
function log(args, params) {
|
|
195
190
|
}
|
|
196
191
|
log.type = 'xstate.log';
|
|
197
192
|
log.value = value;
|
|
@@ -201,7 +196,7 @@ function log(value = ({
|
|
|
201
196
|
return log;
|
|
202
197
|
}
|
|
203
198
|
|
|
204
|
-
function resolvePure(_, state, args, {
|
|
199
|
+
function resolvePure(_, state, args, _actionParams, {
|
|
205
200
|
get
|
|
206
201
|
}) {
|
|
207
202
|
return [state, undefined, toArray(get({
|
|
@@ -210,7 +205,7 @@ function resolvePure(_, state, args, {
|
|
|
210
205
|
}))];
|
|
211
206
|
}
|
|
212
207
|
function pure(getActions) {
|
|
213
|
-
function pure(
|
|
208
|
+
function pure(args, params) {
|
|
214
209
|
}
|
|
215
210
|
pure.type = 'xstate.pure';
|
|
216
211
|
pure.get = getActions;
|
|
@@ -219,6 +214,9 @@ function pure(getActions) {
|
|
|
219
214
|
}
|
|
220
215
|
|
|
221
216
|
/**
|
|
217
|
+
*
|
|
218
|
+
* @remarks
|
|
219
|
+
*
|
|
222
220
|
* `T | unknown` reduces to `unknown` and that can be problematic when it comes to contextual typing.
|
|
223
221
|
* It especially is a problem when the union has a function member, like here:
|
|
224
222
|
*
|
|
@@ -239,7 +237,10 @@ function pure(getActions) {
|
|
|
239
237
|
/**
|
|
240
238
|
* The string or object representing the state value relative to the parent state node.
|
|
241
239
|
*
|
|
240
|
+
* @remarks
|
|
241
|
+
*
|
|
242
242
|
* - For a child atomic state node, this is a string, e.g., `"pending"`.
|
|
243
|
+
*
|
|
243
244
|
* - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
|
|
244
245
|
*/
|
|
245
246
|
|
|
@@ -253,7 +254,7 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
253
254
|
return SpecialTargets;
|
|
254
255
|
}({});
|
|
255
256
|
|
|
256
|
-
function resolveSendTo(actorContext, state, args, {
|
|
257
|
+
function resolveSendTo(actorContext, state, args, actionParams, {
|
|
257
258
|
to,
|
|
258
259
|
event: eventOrExpr,
|
|
259
260
|
id,
|
|
@@ -263,15 +264,15 @@ function resolveSendTo(actorContext, state, args, {
|
|
|
263
264
|
if (typeof eventOrExpr === 'string') {
|
|
264
265
|
throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
|
|
265
266
|
}
|
|
266
|
-
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr;
|
|
267
|
+
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
267
268
|
let resolvedDelay;
|
|
268
269
|
if (typeof delay === 'string') {
|
|
269
270
|
const configDelay = delaysMap && delaysMap[delay];
|
|
270
|
-
resolvedDelay = typeof configDelay === 'function' ? configDelay(args) : configDelay;
|
|
271
|
+
resolvedDelay = typeof configDelay === 'function' ? configDelay(args, actionParams) : configDelay;
|
|
271
272
|
} else {
|
|
272
|
-
resolvedDelay = typeof delay === 'function' ? delay(args) : delay;
|
|
273
|
+
resolvedDelay = typeof delay === 'function' ? delay(args, actionParams) : delay;
|
|
273
274
|
}
|
|
274
|
-
const resolvedTarget = typeof to === 'function' ? to(args) : to;
|
|
275
|
+
const resolvedTarget = typeof to === 'function' ? to(args, actionParams) : to;
|
|
275
276
|
let targetActorRef;
|
|
276
277
|
if (typeof resolvedTarget === 'string') {
|
|
277
278
|
if (resolvedTarget === SpecialTargets.Parent) {
|
|
@@ -308,6 +309,9 @@ function executeSendTo(actorContext, params) {
|
|
|
308
309
|
actorContext.self.delaySend(params);
|
|
309
310
|
return;
|
|
310
311
|
}
|
|
312
|
+
|
|
313
|
+
// this forms an outgoing events queue
|
|
314
|
+
// thanks to that the recipient actors are able to read the *updated* snapshot value of the sender
|
|
311
315
|
actorContext.defer(() => {
|
|
312
316
|
const {
|
|
313
317
|
to,
|
|
@@ -326,7 +330,7 @@ function executeSendTo(actorContext, params) {
|
|
|
326
330
|
* - `delay` - The number of milliseconds to delay the sending of the event.
|
|
327
331
|
*/
|
|
328
332
|
function sendTo(to, eventOrExpr, options) {
|
|
329
|
-
function sendTo(
|
|
333
|
+
function sendTo(args, params) {
|
|
330
334
|
}
|
|
331
335
|
sendTo.type = 'xstate.sendTo';
|
|
332
336
|
sendTo.to = to;
|
|
@@ -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-b69a3d16.development.cjs.js');
|
|
4
|
+
var interpreter = require('./interpreter-ed3f81f7.development.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorContext, {
|
|
7
7
|
machine,
|
|
@@ -12,7 +12,7 @@ function createSpawner(actorContext, {
|
|
|
12
12
|
systemId
|
|
13
13
|
} = options;
|
|
14
14
|
if (typeof src === 'string') {
|
|
15
|
-
const referenced = interpreter.resolveReferencedActor(machine
|
|
15
|
+
const referenced = interpreter.resolveReferencedActor(machine, src);
|
|
16
16
|
if (!referenced) {
|
|
17
17
|
throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
|
|
18
18
|
}
|
|
@@ -41,9 +41,7 @@ function createSpawner(actorContext, {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
error: () => {
|
|
45
|
-
/* TODO */
|
|
46
|
-
}
|
|
44
|
+
error: () => {}
|
|
47
45
|
});
|
|
48
46
|
}
|
|
49
47
|
return actorRef;
|
|
@@ -67,9 +65,7 @@ function createSpawner(actorContext, {
|
|
|
67
65
|
});
|
|
68
66
|
}
|
|
69
67
|
},
|
|
70
|
-
error: () => {
|
|
71
|
-
/* TODO */
|
|
72
|
-
}
|
|
68
|
+
error: () => {}
|
|
73
69
|
});
|
|
74
70
|
}
|
|
75
71
|
return actorRef;
|
|
@@ -93,7 +89,7 @@ function createSpawner(actorContext, {
|
|
|
93
89
|
};
|
|
94
90
|
}
|
|
95
91
|
|
|
96
|
-
function resolveAssign(actorContext, state, actionArgs, {
|
|
92
|
+
function resolveAssign(actorContext, state, actionArgs, actionParams, {
|
|
97
93
|
assignment
|
|
98
94
|
}) {
|
|
99
95
|
if (!state.context) {
|
|
@@ -103,18 +99,17 @@ function resolveAssign(actorContext, state, actionArgs, {
|
|
|
103
99
|
const assignArgs = {
|
|
104
100
|
context: state.context,
|
|
105
101
|
event: actionArgs.event,
|
|
106
|
-
action: actionArgs.action,
|
|
107
102
|
spawn: createSpawner(actorContext, state, actionArgs.event, spawnedChildren),
|
|
108
103
|
self: actorContext?.self,
|
|
109
104
|
system: actorContext?.system
|
|
110
105
|
};
|
|
111
106
|
let partialUpdate = {};
|
|
112
107
|
if (typeof assignment === 'function') {
|
|
113
|
-
partialUpdate = assignment(assignArgs);
|
|
108
|
+
partialUpdate = assignment(assignArgs, actionParams);
|
|
114
109
|
} else {
|
|
115
110
|
for (const key of Object.keys(assignment)) {
|
|
116
111
|
const propAssignment = assignment[key];
|
|
117
|
-
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs) : propAssignment;
|
|
112
|
+
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
|
|
118
113
|
}
|
|
119
114
|
}
|
|
120
115
|
const updatedContext = Object.assign({}, state.context, partialUpdate);
|
|
@@ -132,7 +127,7 @@ function resolveAssign(actorContext, state, actionArgs, {
|
|
|
132
127
|
* @param assignment An object that represents the partial context to update.
|
|
133
128
|
*/
|
|
134
129
|
function assign(assignment) {
|
|
135
|
-
function assign(
|
|
130
|
+
function assign(args, params) {
|
|
136
131
|
{
|
|
137
132
|
throw new Error(`This isn't supposed to be called`);
|
|
138
133
|
}
|
|
@@ -143,7 +138,7 @@ function assign(assignment) {
|
|
|
143
138
|
return assign;
|
|
144
139
|
}
|
|
145
140
|
|
|
146
|
-
function resolveChoose(_, state, actionArgs, {
|
|
141
|
+
function resolveChoose(_, state, actionArgs, _actionParams, {
|
|
147
142
|
branches
|
|
148
143
|
}) {
|
|
149
144
|
const matchedActions = branches.find(condition => {
|
|
@@ -152,7 +147,7 @@ function resolveChoose(_, state, actionArgs, {
|
|
|
152
147
|
return [state, undefined, interpreter.toArray(matchedActions)];
|
|
153
148
|
}
|
|
154
149
|
function choose(branches) {
|
|
155
|
-
function choose(
|
|
150
|
+
function choose(args, params) {
|
|
156
151
|
{
|
|
157
152
|
throw new Error(`This isn't supposed to be called`);
|
|
158
153
|
}
|
|
@@ -163,12 +158,12 @@ function choose(branches) {
|
|
|
163
158
|
return choose;
|
|
164
159
|
}
|
|
165
160
|
|
|
166
|
-
function resolveLog(_, state, actionArgs, {
|
|
161
|
+
function resolveLog(_, state, actionArgs, actionParams, {
|
|
167
162
|
value,
|
|
168
163
|
label
|
|
169
164
|
}) {
|
|
170
165
|
return [state, {
|
|
171
|
-
value: typeof value === 'function' ? value(actionArgs) : value,
|
|
166
|
+
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
172
167
|
label
|
|
173
168
|
}];
|
|
174
169
|
}
|
|
@@ -199,7 +194,7 @@ function log(value = ({
|
|
|
199
194
|
context,
|
|
200
195
|
event
|
|
201
196
|
}), label) {
|
|
202
|
-
function log(
|
|
197
|
+
function log(args, params) {
|
|
203
198
|
{
|
|
204
199
|
throw new Error(`This isn't supposed to be called`);
|
|
205
200
|
}
|
|
@@ -212,7 +207,7 @@ function log(value = ({
|
|
|
212
207
|
return log;
|
|
213
208
|
}
|
|
214
209
|
|
|
215
|
-
function resolvePure(_, state, args, {
|
|
210
|
+
function resolvePure(_, state, args, _actionParams, {
|
|
216
211
|
get
|
|
217
212
|
}) {
|
|
218
213
|
return [state, undefined, interpreter.toArray(get({
|
|
@@ -221,7 +216,7 @@ function resolvePure(_, state, args, {
|
|
|
221
216
|
}))];
|
|
222
217
|
}
|
|
223
218
|
function pure(getActions) {
|
|
224
|
-
function pure(
|
|
219
|
+
function pure(args, params) {
|
|
225
220
|
{
|
|
226
221
|
throw new Error(`This isn't supposed to be called`);
|
|
227
222
|
}
|
|
@@ -233,6 +228,9 @@ function pure(getActions) {
|
|
|
233
228
|
}
|
|
234
229
|
|
|
235
230
|
/**
|
|
231
|
+
*
|
|
232
|
+
* @remarks
|
|
233
|
+
*
|
|
236
234
|
* `T | unknown` reduces to `unknown` and that can be problematic when it comes to contextual typing.
|
|
237
235
|
* It especially is a problem when the union has a function member, like here:
|
|
238
236
|
*
|
|
@@ -253,7 +251,10 @@ function pure(getActions) {
|
|
|
253
251
|
/**
|
|
254
252
|
* The string or object representing the state value relative to the parent state node.
|
|
255
253
|
*
|
|
254
|
+
* @remarks
|
|
255
|
+
*
|
|
256
256
|
* - For a child atomic state node, this is a string, e.g., `"pending"`.
|
|
257
|
+
*
|
|
257
258
|
* - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
|
|
258
259
|
*/
|
|
259
260
|
|
|
@@ -267,7 +268,7 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
267
268
|
return SpecialTargets;
|
|
268
269
|
}({});
|
|
269
270
|
|
|
270
|
-
function resolveSendTo(actorContext, state, args, {
|
|
271
|
+
function resolveSendTo(actorContext, state, args, actionParams, {
|
|
271
272
|
to,
|
|
272
273
|
event: eventOrExpr,
|
|
273
274
|
id,
|
|
@@ -277,15 +278,15 @@ function resolveSendTo(actorContext, state, args, {
|
|
|
277
278
|
if (typeof eventOrExpr === 'string') {
|
|
278
279
|
throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
|
|
279
280
|
}
|
|
280
|
-
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr;
|
|
281
|
+
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
281
282
|
let resolvedDelay;
|
|
282
283
|
if (typeof delay === 'string') {
|
|
283
284
|
const configDelay = delaysMap && delaysMap[delay];
|
|
284
|
-
resolvedDelay = typeof configDelay === 'function' ? configDelay(args) : configDelay;
|
|
285
|
+
resolvedDelay = typeof configDelay === 'function' ? configDelay(args, actionParams) : configDelay;
|
|
285
286
|
} else {
|
|
286
|
-
resolvedDelay = typeof delay === 'function' ? delay(args) : delay;
|
|
287
|
+
resolvedDelay = typeof delay === 'function' ? delay(args, actionParams) : delay;
|
|
287
288
|
}
|
|
288
|
-
const resolvedTarget = typeof to === 'function' ? to(args) : to;
|
|
289
|
+
const resolvedTarget = typeof to === 'function' ? to(args, actionParams) : to;
|
|
289
290
|
let targetActorRef;
|
|
290
291
|
if (typeof resolvedTarget === 'string') {
|
|
291
292
|
if (resolvedTarget === SpecialTargets.Parent) {
|
|
@@ -322,6 +323,9 @@ function executeSendTo(actorContext, params) {
|
|
|
322
323
|
actorContext.self.delaySend(params);
|
|
323
324
|
return;
|
|
324
325
|
}
|
|
326
|
+
|
|
327
|
+
// this forms an outgoing events queue
|
|
328
|
+
// thanks to that the recipient actors are able to read the *updated* snapshot value of the sender
|
|
325
329
|
actorContext.defer(() => {
|
|
326
330
|
const {
|
|
327
331
|
to,
|
|
@@ -340,7 +344,7 @@ function executeSendTo(actorContext, params) {
|
|
|
340
344
|
* - `delay` - The number of milliseconds to delay the sending of the event.
|
|
341
345
|
*/
|
|
342
346
|
function sendTo(to, eventOrExpr, options) {
|
|
343
|
-
function sendTo(
|
|
347
|
+
function sendTo(args, params) {
|
|
344
348
|
{
|
|
345
349
|
throw new Error(`This isn't supposed to be called`);
|
|
346
350
|
}
|