xstate 5.0.0-beta.50 → 5.0.0-beta.51

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.
Files changed (39) hide show
  1. package/actions/dist/xstate-actions.cjs.js +11 -10
  2. package/actions/dist/xstate-actions.cjs.mjs +1 -0
  3. package/actions/dist/xstate-actions.development.cjs.js +11 -10
  4. package/actions/dist/xstate-actions.development.cjs.mjs +1 -0
  5. package/actions/dist/xstate-actions.development.esm.js +2 -2
  6. package/actions/dist/xstate-actions.esm.js +2 -2
  7. package/actions/dist/xstate-actions.umd.min.js +1 -1
  8. package/actions/dist/xstate-actions.umd.min.js.map +1 -1
  9. package/actors/dist/xstate-actors.cjs.js +1 -1
  10. package/actors/dist/xstate-actors.development.cjs.js +1 -1
  11. package/actors/dist/xstate-actors.development.esm.js +1 -1
  12. package/actors/dist/xstate-actors.esm.js +1 -1
  13. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  14. package/dist/declarations/src/actions/enqueueActions.d.ts +32 -0
  15. package/dist/declarations/src/actions/pure.d.ts +7 -10
  16. package/dist/declarations/src/actions.d.ts +3 -2
  17. package/dist/declarations/src/utils.d.ts +1 -20
  18. package/dist/{send-2b001f05.development.esm.js → pure-296f8ebd.development.esm.js} +113 -71
  19. package/dist/{send-df1c8ef2.development.cjs.js → pure-a0f16134.development.cjs.js} +113 -70
  20. package/dist/{send-88351a33.esm.js → pure-aefddc19.esm.js} +107 -65
  21. package/dist/{send-7f3db830.cjs.js → pure-c5f1b46c.cjs.js} +107 -64
  22. package/dist/{raise-32ec7226.esm.js → raise-4742bf04.esm.js} +7 -12
  23. package/dist/{raise-dc9c2c58.development.cjs.js → raise-528386de.development.cjs.js} +6 -11
  24. package/dist/{raise-6c05c91b.development.esm.js → raise-acaa3884.development.esm.js} +7 -12
  25. package/dist/{raise-8176cd35.cjs.js → raise-d5633a02.cjs.js} +6 -11
  26. package/dist/xstate.cjs.js +13 -12
  27. package/dist/xstate.cjs.mjs +1 -0
  28. package/dist/xstate.development.cjs.js +13 -12
  29. package/dist/xstate.development.cjs.mjs +1 -0
  30. package/dist/xstate.development.esm.js +4 -4
  31. package/dist/xstate.esm.js +4 -4
  32. package/dist/xstate.umd.min.js +1 -1
  33. package/dist/xstate.umd.min.js.map +1 -1
  34. package/guards/dist/xstate-guards.cjs.js +1 -1
  35. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  36. package/guards/dist/xstate-guards.development.esm.js +1 -1
  37. package/guards/dist/xstate-guards.esm.js +1 -1
  38. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  39. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, e as evaluateGuard, t as toArray, U as XSTATE_ERROR, V as createErrorActorEvent } from './raise-6c05c91b.development.esm.js';
1
+ import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, e as evaluateGuard, t as toArray, U as XSTATE_ERROR, V as createErrorActorEvent, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-acaa3884.development.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -122,75 +122,6 @@ function choose(branches) {
122
122
  return choose;
123
123
  }
124
124
 
125
- function resolveLog(_, state, actionArgs, actionParams, {
126
- value,
127
- label
128
- }) {
129
- return [state, {
130
- value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
131
- label
132
- }];
133
- }
134
- function executeLog({
135
- logger
136
- }, {
137
- value,
138
- label
139
- }) {
140
- if (label) {
141
- logger(label, value);
142
- } else {
143
- logger(value);
144
- }
145
- }
146
- /**
147
- *
148
- * @param expr The expression function to evaluate which will be logged.
149
- * Takes in 2 arguments:
150
- * - `ctx` - the current state context
151
- * - `event` - the event that caused this action to be executed.
152
- * @param label The label to give to the logged expression.
153
- */
154
- function log(value = ({
155
- context,
156
- event
157
- }) => ({
158
- context,
159
- event
160
- }), label) {
161
- function log(args, params) {
162
- {
163
- throw new Error(`This isn't supposed to be called`);
164
- }
165
- }
166
- log.type = 'xstate.log';
167
- log.value = value;
168
- log.label = label;
169
- log.resolve = resolveLog;
170
- log.execute = executeLog;
171
- return log;
172
- }
173
-
174
- function resolvePure(_, state, args, _actionParams, {
175
- get
176
- }) {
177
- return [state, undefined, toArray(get({
178
- context: args.context,
179
- event: args.event
180
- }))];
181
- }
182
- function pure(getActions) {
183
- function pure(args, params) {
184
- {
185
- throw new Error(`This isn't supposed to be called`);
186
- }
187
- }
188
- pure.type = 'xstate.pure';
189
- pure.get = getActions;
190
- pure.resolve = resolvePure;
191
- return pure;
192
- }
193
-
194
125
  /**
195
126
  *
196
127
  * @remarks
@@ -394,4 +325,115 @@ function escalate(errorData, options) {
394
325
  }, options);
395
326
  }
396
327
 
397
- export { SpecialTargets as S, assign as a, sendTo as b, choose as c, escalate as e, forwardTo as f, log as l, pure as p, sendParent as s };
328
+ function resolveEnqueueActions(_, state, args, _actionParams, {
329
+ collect
330
+ }) {
331
+ const actions = [];
332
+ const enqueue = function enqueue(action) {
333
+ actions.push(action);
334
+ };
335
+ enqueue.assign = (...args) => {
336
+ actions.push(assign(...args));
337
+ };
338
+ enqueue.cancel = (...args) => {
339
+ actions.push(cancel(...args));
340
+ };
341
+ enqueue.raise = (...args) => {
342
+ actions.push(raise(...args));
343
+ };
344
+ enqueue.sendTo = (...args) => {
345
+ actions.push(sendTo(...args));
346
+ };
347
+ enqueue.spawnChild = (...args) => {
348
+ actions.push(spawnChild(...args));
349
+ };
350
+ enqueue.stopChild = (...args) => {
351
+ actions.push(stopChild(...args));
352
+ };
353
+ collect({
354
+ context: args.context,
355
+ event: args.event,
356
+ enqueue,
357
+ check: guard => evaluateGuard(guard, state.context, args.event, state)
358
+ });
359
+ return [state, undefined, actions];
360
+ }
361
+ function enqueueActions(collect) {
362
+ function enqueueActions(args, params) {
363
+ {
364
+ throw new Error(`This isn't supposed to be called`);
365
+ }
366
+ }
367
+ enqueueActions.type = 'xstate.enqueueActions';
368
+ enqueueActions.collect = collect;
369
+ enqueueActions.resolve = resolveEnqueueActions;
370
+ return enqueueActions;
371
+ }
372
+
373
+ function resolveLog(_, state, actionArgs, actionParams, {
374
+ value,
375
+ label
376
+ }) {
377
+ return [state, {
378
+ value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
379
+ label
380
+ }];
381
+ }
382
+ function executeLog({
383
+ logger
384
+ }, {
385
+ value,
386
+ label
387
+ }) {
388
+ if (label) {
389
+ logger(label, value);
390
+ } else {
391
+ logger(value);
392
+ }
393
+ }
394
+ /**
395
+ *
396
+ * @param expr The expression function to evaluate which will be logged.
397
+ * Takes in 2 arguments:
398
+ * - `ctx` - the current state context
399
+ * - `event` - the event that caused this action to be executed.
400
+ * @param label The label to give to the logged expression.
401
+ */
402
+ function log(value = ({
403
+ context,
404
+ event
405
+ }) => ({
406
+ context,
407
+ event
408
+ }), label) {
409
+ function log(args, params) {
410
+ {
411
+ throw new Error(`This isn't supposed to be called`);
412
+ }
413
+ }
414
+ log.type = 'xstate.log';
415
+ log.value = value;
416
+ log.label = label;
417
+ log.resolve = resolveLog;
418
+ log.execute = executeLog;
419
+ return log;
420
+ }
421
+
422
+ /**
423
+ *
424
+ * @deprecated Use `enqueueActions(...)` instead
425
+ */
426
+ function pure(getActions) {
427
+ return enqueueActions(({
428
+ context,
429
+ event,
430
+ enqueue
431
+ }) => {
432
+ toArray(getActions({
433
+ context,
434
+ event
435
+ })).forEach(enqueue);
436
+ });
437
+ }
438
+
439
+ export { SpecialTargets as S, assign as a, escalate as b, choose as c, sendTo as d, enqueueActions as e, forwardTo as f, log as l, pure as p, sendParent as s };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-dc9c2c58.development.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-528386de.development.cjs.js');
4
4
 
5
5
  function createSpawner(actorScope, {
6
6
  machine,
@@ -124,75 +124,6 @@ function choose(branches) {
124
124
  return choose;
125
125
  }
126
126
 
127
- function resolveLog(_, state, actionArgs, actionParams, {
128
- value,
129
- label
130
- }) {
131
- return [state, {
132
- value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
133
- label
134
- }];
135
- }
136
- function executeLog({
137
- logger
138
- }, {
139
- value,
140
- label
141
- }) {
142
- if (label) {
143
- logger(label, value);
144
- } else {
145
- logger(value);
146
- }
147
- }
148
- /**
149
- *
150
- * @param expr The expression function to evaluate which will be logged.
151
- * Takes in 2 arguments:
152
- * - `ctx` - the current state context
153
- * - `event` - the event that caused this action to be executed.
154
- * @param label The label to give to the logged expression.
155
- */
156
- function log(value = ({
157
- context,
158
- event
159
- }) => ({
160
- context,
161
- event
162
- }), label) {
163
- function log(args, params) {
164
- {
165
- throw new Error(`This isn't supposed to be called`);
166
- }
167
- }
168
- log.type = 'xstate.log';
169
- log.value = value;
170
- log.label = label;
171
- log.resolve = resolveLog;
172
- log.execute = executeLog;
173
- return log;
174
- }
175
-
176
- function resolvePure(_, state, args, _actionParams, {
177
- get
178
- }) {
179
- return [state, undefined, guards_dist_xstateGuards.toArray(get({
180
- context: args.context,
181
- event: args.event
182
- }))];
183
- }
184
- function pure(getActions) {
185
- function pure(args, params) {
186
- {
187
- throw new Error(`This isn't supposed to be called`);
188
- }
189
- }
190
- pure.type = 'xstate.pure';
191
- pure.get = getActions;
192
- pure.resolve = resolvePure;
193
- return pure;
194
- }
195
-
196
127
  /**
197
128
  *
198
129
  * @remarks
@@ -396,9 +327,121 @@ function escalate(errorData, options) {
396
327
  }, options);
397
328
  }
398
329
 
330
+ function resolveEnqueueActions(_, state, args, _actionParams, {
331
+ collect
332
+ }) {
333
+ const actions = [];
334
+ const enqueue = function enqueue(action) {
335
+ actions.push(action);
336
+ };
337
+ enqueue.assign = (...args) => {
338
+ actions.push(assign(...args));
339
+ };
340
+ enqueue.cancel = (...args) => {
341
+ actions.push(guards_dist_xstateGuards.cancel(...args));
342
+ };
343
+ enqueue.raise = (...args) => {
344
+ actions.push(guards_dist_xstateGuards.raise(...args));
345
+ };
346
+ enqueue.sendTo = (...args) => {
347
+ actions.push(sendTo(...args));
348
+ };
349
+ enqueue.spawnChild = (...args) => {
350
+ actions.push(guards_dist_xstateGuards.spawnChild(...args));
351
+ };
352
+ enqueue.stopChild = (...args) => {
353
+ actions.push(guards_dist_xstateGuards.stopChild(...args));
354
+ };
355
+ collect({
356
+ context: args.context,
357
+ event: args.event,
358
+ enqueue,
359
+ check: guard => guards_dist_xstateGuards.evaluateGuard(guard, state.context, args.event, state)
360
+ });
361
+ return [state, undefined, actions];
362
+ }
363
+ function enqueueActions(collect) {
364
+ function enqueueActions(args, params) {
365
+ {
366
+ throw new Error(`This isn't supposed to be called`);
367
+ }
368
+ }
369
+ enqueueActions.type = 'xstate.enqueueActions';
370
+ enqueueActions.collect = collect;
371
+ enqueueActions.resolve = resolveEnqueueActions;
372
+ return enqueueActions;
373
+ }
374
+
375
+ function resolveLog(_, state, actionArgs, actionParams, {
376
+ value,
377
+ label
378
+ }) {
379
+ return [state, {
380
+ value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
381
+ label
382
+ }];
383
+ }
384
+ function executeLog({
385
+ logger
386
+ }, {
387
+ value,
388
+ label
389
+ }) {
390
+ if (label) {
391
+ logger(label, value);
392
+ } else {
393
+ logger(value);
394
+ }
395
+ }
396
+ /**
397
+ *
398
+ * @param expr The expression function to evaluate which will be logged.
399
+ * Takes in 2 arguments:
400
+ * - `ctx` - the current state context
401
+ * - `event` - the event that caused this action to be executed.
402
+ * @param label The label to give to the logged expression.
403
+ */
404
+ function log(value = ({
405
+ context,
406
+ event
407
+ }) => ({
408
+ context,
409
+ event
410
+ }), label) {
411
+ function log(args, params) {
412
+ {
413
+ throw new Error(`This isn't supposed to be called`);
414
+ }
415
+ }
416
+ log.type = 'xstate.log';
417
+ log.value = value;
418
+ log.label = label;
419
+ log.resolve = resolveLog;
420
+ log.execute = executeLog;
421
+ return log;
422
+ }
423
+
424
+ /**
425
+ *
426
+ * @deprecated Use `enqueueActions(...)` instead
427
+ */
428
+ function pure(getActions) {
429
+ return enqueueActions(({
430
+ context,
431
+ event,
432
+ enqueue
433
+ }) => {
434
+ guards_dist_xstateGuards.toArray(getActions({
435
+ context,
436
+ event
437
+ })).forEach(enqueue);
438
+ });
439
+ }
440
+
399
441
  exports.SpecialTargets = SpecialTargets;
400
442
  exports.assign = assign;
401
443
  exports.choose = choose;
444
+ exports.enqueueActions = enqueueActions;
402
445
  exports.escalate = escalate;
403
446
  exports.forwardTo = forwardTo;
404
447
  exports.log = log;
@@ -1,4 +1,4 @@
1
- import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, e as evaluateGuard, t as toArray, U as XSTATE_ERROR, V as createErrorActorEvent } from './raise-32ec7226.esm.js';
1
+ import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, e as evaluateGuard, t as toArray, U as XSTATE_ERROR, V as createErrorActorEvent, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-4742bf04.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -116,69 +116,6 @@ function choose(branches) {
116
116
  return choose;
117
117
  }
118
118
 
119
- function resolveLog(_, state, actionArgs, actionParams, {
120
- value,
121
- label
122
- }) {
123
- return [state, {
124
- value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
125
- label
126
- }];
127
- }
128
- function executeLog({
129
- logger
130
- }, {
131
- value,
132
- label
133
- }) {
134
- if (label) {
135
- logger(label, value);
136
- } else {
137
- logger(value);
138
- }
139
- }
140
- /**
141
- *
142
- * @param expr The expression function to evaluate which will be logged.
143
- * Takes in 2 arguments:
144
- * - `ctx` - the current state context
145
- * - `event` - the event that caused this action to be executed.
146
- * @param label The label to give to the logged expression.
147
- */
148
- function log(value = ({
149
- context,
150
- event
151
- }) => ({
152
- context,
153
- event
154
- }), label) {
155
- function log(args, params) {
156
- }
157
- log.type = 'xstate.log';
158
- log.value = value;
159
- log.label = label;
160
- log.resolve = resolveLog;
161
- log.execute = executeLog;
162
- return log;
163
- }
164
-
165
- function resolvePure(_, state, args, _actionParams, {
166
- get
167
- }) {
168
- return [state, undefined, toArray(get({
169
- context: args.context,
170
- event: args.event
171
- }))];
172
- }
173
- function pure(getActions) {
174
- function pure(args, params) {
175
- }
176
- pure.type = 'xstate.pure';
177
- pure.get = getActions;
178
- pure.resolve = resolvePure;
179
- return pure;
180
- }
181
-
182
119
  /**
183
120
  *
184
121
  * @remarks
@@ -369,4 +306,109 @@ function escalate(errorData, options) {
369
306
  }, options);
370
307
  }
371
308
 
372
- export { SpecialTargets as S, assign as a, sendTo as b, choose as c, escalate as e, forwardTo as f, log as l, pure as p, sendParent as s };
309
+ function resolveEnqueueActions(_, state, args, _actionParams, {
310
+ collect
311
+ }) {
312
+ const actions = [];
313
+ const enqueue = function enqueue(action) {
314
+ actions.push(action);
315
+ };
316
+ enqueue.assign = (...args) => {
317
+ actions.push(assign(...args));
318
+ };
319
+ enqueue.cancel = (...args) => {
320
+ actions.push(cancel(...args));
321
+ };
322
+ enqueue.raise = (...args) => {
323
+ actions.push(raise(...args));
324
+ };
325
+ enqueue.sendTo = (...args) => {
326
+ actions.push(sendTo(...args));
327
+ };
328
+ enqueue.spawnChild = (...args) => {
329
+ actions.push(spawnChild(...args));
330
+ };
331
+ enqueue.stopChild = (...args) => {
332
+ actions.push(stopChild(...args));
333
+ };
334
+ collect({
335
+ context: args.context,
336
+ event: args.event,
337
+ enqueue,
338
+ check: guard => evaluateGuard(guard, state.context, args.event, state)
339
+ });
340
+ return [state, undefined, actions];
341
+ }
342
+ function enqueueActions(collect) {
343
+ function enqueueActions(args, params) {
344
+ }
345
+ enqueueActions.type = 'xstate.enqueueActions';
346
+ enqueueActions.collect = collect;
347
+ enqueueActions.resolve = resolveEnqueueActions;
348
+ return enqueueActions;
349
+ }
350
+
351
+ function resolveLog(_, state, actionArgs, actionParams, {
352
+ value,
353
+ label
354
+ }) {
355
+ return [state, {
356
+ value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
357
+ label
358
+ }];
359
+ }
360
+ function executeLog({
361
+ logger
362
+ }, {
363
+ value,
364
+ label
365
+ }) {
366
+ if (label) {
367
+ logger(label, value);
368
+ } else {
369
+ logger(value);
370
+ }
371
+ }
372
+ /**
373
+ *
374
+ * @param expr The expression function to evaluate which will be logged.
375
+ * Takes in 2 arguments:
376
+ * - `ctx` - the current state context
377
+ * - `event` - the event that caused this action to be executed.
378
+ * @param label The label to give to the logged expression.
379
+ */
380
+ function log(value = ({
381
+ context,
382
+ event
383
+ }) => ({
384
+ context,
385
+ event
386
+ }), label) {
387
+ function log(args, params) {
388
+ }
389
+ log.type = 'xstate.log';
390
+ log.value = value;
391
+ log.label = label;
392
+ log.resolve = resolveLog;
393
+ log.execute = executeLog;
394
+ return log;
395
+ }
396
+
397
+ /**
398
+ *
399
+ * @deprecated Use `enqueueActions(...)` instead
400
+ */
401
+ function pure(getActions) {
402
+ return enqueueActions(({
403
+ context,
404
+ event,
405
+ enqueue
406
+ }) => {
407
+ toArray(getActions({
408
+ context,
409
+ event
410
+ })).forEach(enqueue);
411
+ });
412
+ }
413
+
414
+ export { SpecialTargets as S, assign as a, escalate as b, choose as c, sendTo as d, enqueueActions as e, forwardTo as f, log as l, pure as p, sendParent as s };