@xmachines/play-xstate 3.0.0 → 5.0.0

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 (80) hide show
  1. package/README.md +190 -68
  2. package/dist/capabilities.d.ts +93 -0
  3. package/dist/capabilities.d.ts.map +1 -0
  4. package/dist/capabilities.js +4 -0
  5. package/dist/capabilities.js.map +1 -0
  6. package/dist/define-player.d.ts +7 -1
  7. package/dist/define-player.d.ts.map +1 -1
  8. package/dist/define-player.js +9 -60
  9. package/dist/define-player.js.map +1 -1
  10. package/dist/errors.d.ts +64 -23
  11. package/dist/errors.d.ts.map +1 -1
  12. package/dist/errors.js +93 -31
  13. package/dist/errors.js.map +1 -1
  14. package/dist/index.d.ts +4 -6
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +11 -6
  17. package/dist/index.js.map +1 -1
  18. package/dist/player-actor.d.ts +73 -137
  19. package/dist/player-actor.d.ts.map +1 -1
  20. package/dist/player-actor.js +108 -254
  21. package/dist/player-actor.js.map +1 -1
  22. package/dist/routing/build-url.d.ts +8 -1
  23. package/dist/routing/build-url.d.ts.map +1 -1
  24. package/dist/routing/build-url.js +34 -54
  25. package/dist/routing/build-url.js.map +1 -1
  26. package/dist/routing/derive-current-route.d.ts +12 -38
  27. package/dist/routing/derive-current-route.d.ts.map +1 -1
  28. package/dist/routing/derive-current-route.js +24 -82
  29. package/dist/routing/derive-current-route.js.map +1 -1
  30. package/dist/routing/derive-initial-route.d.ts +2 -1
  31. package/dist/routing/derive-initial-route.d.ts.map +1 -1
  32. package/dist/routing/derive-initial-route.js +13 -2
  33. package/dist/routing/derive-initial-route.js.map +1 -1
  34. package/dist/routing/derive-route.d.ts +81 -2
  35. package/dist/routing/derive-route.d.ts.map +1 -1
  36. package/dist/routing/derive-route.js +97 -3
  37. package/dist/routing/derive-route.js.map +1 -1
  38. package/dist/routing/format-play-route-transitions.d.ts +8 -2
  39. package/dist/routing/format-play-route-transitions.d.ts.map +1 -1
  40. package/dist/routing/format-play-route-transitions.js +175 -43
  41. package/dist/routing/format-play-route-transitions.js.map +1 -1
  42. package/dist/routing/index.d.ts +1 -1
  43. package/dist/routing/index.d.ts.map +1 -1
  44. package/dist/routing/types.d.ts +9 -5
  45. package/dist/routing/types.d.ts.map +1 -1
  46. package/dist/state-meta.d.ts +52 -0
  47. package/dist/state-meta.d.ts.map +1 -0
  48. package/dist/state-meta.js +77 -0
  49. package/dist/state-meta.js.map +1 -0
  50. package/dist/types.d.ts +20 -5
  51. package/dist/types.d.ts.map +1 -1
  52. package/dist/view/derive-current-view.d.ts +7 -6
  53. package/dist/view/derive-current-view.d.ts.map +1 -1
  54. package/dist/view/derive-current-view.js +7 -6
  55. package/dist/view/derive-current-view.js.map +1 -1
  56. package/dist/with-routing.d.ts +45 -0
  57. package/dist/with-routing.d.ts.map +1 -0
  58. package/dist/with-routing.js +140 -0
  59. package/dist/with-routing.js.map +1 -0
  60. package/dist/with-view.d.ts +57 -0
  61. package/dist/with-view.d.ts.map +1 -0
  62. package/dist/with-view.js +158 -0
  63. package/dist/with-view.js.map +1 -0
  64. package/package.json +40 -18
  65. package/dist/guards/compose.d.ts +0 -158
  66. package/dist/guards/compose.d.ts.map +0 -1
  67. package/dist/guards/compose.js +0 -188
  68. package/dist/guards/compose.js.map +0 -1
  69. package/dist/guards/helpers.d.ts +0 -62
  70. package/dist/guards/helpers.d.ts.map +0 -1
  71. package/dist/guards/helpers.js +0 -85
  72. package/dist/guards/helpers.js.map +0 -1
  73. package/dist/guards/index.d.ts +0 -20
  74. package/dist/guards/index.d.ts.map +0 -1
  75. package/dist/guards/index.js +0 -18
  76. package/dist/guards/index.js.map +0 -1
  77. package/dist/guards/types.d.ts +0 -22
  78. package/dist/guards/types.d.ts.map +0 -1
  79. package/dist/guards/types.js +0 -2
  80. package/dist/guards/types.js.map +0 -1
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { PlayError } from "@xmachines/play";
1
+ import { PlayError } from "@xmachines/play/errors";
2
2
  /**
3
3
  * `buildRouteUrl()` throws this error when the context of the actor does not hold a
4
4
  * necessary route parameter.
@@ -14,7 +14,7 @@ import { PlayError } from "@xmachines/play";
14
14
  *
15
15
  * @example
16
16
  * ```typescript
17
- * import { buildRouteUrl } from "@xmachines/play-xstate";
17
+ * import { buildRouteUrl } from "@xmachines/play-xstate/routing";
18
18
  * import { MissingRouteParamError } from "@xmachines/play-xstate/errors";
19
19
  *
20
20
  * try {
@@ -36,21 +36,42 @@ export declare class MissingRouteParamError extends PlayError {
36
36
  constructor(param: string, template: string);
37
37
  }
38
38
  /**
39
- * @deprecated Nothing throws this error now. `buildRouteUrl` reads an absent `query`
40
- * field as `query: {}`. The generated `play.route` transitions assign `query` on
41
- * every navigation, and the loss that this error guarded against therefore cannot
42
- * happen through the route derivation. A machine that handles `play.route` itself
43
- * and wants the query must assign `event.query` to its context itself. This class
44
- * stays in the exports, so that an `instanceof` handler that exists now still
45
- * compiles. Remove such a handler when you have the time.
46
- *
47
- * `buildRouteUrl()` threw this error before, when the context had a `params` field,
48
- * which means a context that knows the routing, but no `query` field.
49
- *
50
- * **Error code:** `PLAY_XSTATE_MISSING_QUERY_CONTEXT`
39
+ * `buildRouteUrl()` throws this error when a route parameter carries a value that no path
40
+ * can hold, so the template matches the built URL back never.
41
+ *
42
+ * A dot segment is that value. A URL parser resolves `.` and `..` BEFORE it decodes the
43
+ * percent escapes, and it counts `%2e` as the dot, so every encoding of them resolves
44
+ * away: `/files/..` becomes `/`. The actor would hold the route `/files/..` while the
45
+ * address bar shows `/`, and the two stay out of step for the rest of the session.
46
+ *
47
+ * Give the param a value that names a segment. Machine state that can carry a path from a
48
+ * user belongs behind a check of its own, in the same way that a base path checks the
49
+ * values of its `:param` segments.
50
+ *
51
+ * **Error code:** `PLAY_XSTATE_ROUTE_PARAM_INVALID`
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * import { buildRouteUrl } from "@xmachines/play-xstate/routing";
56
+ * import { InvalidRouteParamError } from "@xmachines/play-xstate/errors";
57
+ *
58
+ * try {
59
+ * buildRouteUrl("/files/:name", { params: { name: ".." }, query: {} });
60
+ * } catch (err) {
61
+ * if (err instanceof InvalidRouteParamError) {
62
+ * console.error(`"${err.value}" cannot stand in "${err.param}"`);
63
+ * }
64
+ * }
65
+ * ```
51
66
  */
52
- export declare class MissingQueryContextError extends PlayError {
53
- constructor();
67
+ export declare class InvalidRouteParamError extends PlayError {
68
+ /** The name of the route parameter that carries the value, for example `"name"`. */
69
+ readonly param: string;
70
+ /** The value that no path can hold, for example `".."`. */
71
+ readonly value: string;
72
+ /** The route template that declares the parameter, for example `"/files/:name"`. */
73
+ readonly template: string;
74
+ constructor(param: string, value: string, template: string);
54
75
  }
55
76
  /**
56
77
  * `formatPlayRouteTransitions()` throws this error when a state node declares a
@@ -112,15 +133,35 @@ export declare class InvalidRouteMetadataError extends PlayError {
112
133
  constructor(route: unknown, source?: string);
113
134
  }
114
135
  /**
115
- * `composeGuards()` and `composeGuardsOr()` throw this error for an empty array of
116
- * guards. A composition of zero guards has no meaning.
136
+ * `formatPlayRouteTransitions()` throws this error for a `meta.route` object whose
137
+ * `handler` field holds a value that the routing layer does not know.
138
+ *
139
+ * The field decides WHERE the generated `play.route` transition sits, and each value
140
+ * produces a different reachability. `"local"` in particular makes a state reachable
141
+ * only while its parent is active. A typo such as `"locale"` would therefore fall back
142
+ * to a placement that the author did not ask for, and the route would behave correctly
143
+ * in the test that the author wrote and wrongly everywhere else. The error refuses the
144
+ * value instead.
145
+ *
146
+ * **Error code:** `PLAY_XSTATE_INVALID_ROUTE_HANDLER`
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * import { InvalidRouteHandlerError } from "@xmachines/play-xstate/errors";
117
151
  *
118
- * **Error code:** `PLAY_XSTATE_EMPTY_GUARD_ARRAY`
152
+ * try {
153
+ * formatPlayRouteTransitions(config);
154
+ * } catch (error) {
155
+ * if (error instanceof InvalidRouteHandlerError) {
156
+ * console.error(error.handler); // the value that the config declared
157
+ * }
158
+ * }
159
+ * ```
119
160
  */
120
- export declare class EmptyGuardArrayError extends PlayError {
121
- /** The combinator of the call with the empty array: `"and"` or `"or"`. */
122
- readonly combinator: "and" | "or";
123
- constructor(combinator: "and" | "or");
161
+ export declare class InvalidRouteHandlerError extends PlayError {
162
+ /** The value that the config declared, as a string, for the debug work. */
163
+ readonly handler: string;
164
+ constructor(handler: unknown, source?: string);
124
165
  }
125
166
  /**
126
167
  * `PlayerActor.send()` throws this error when the event argument is not a plain
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAsB5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,4FAA4F;IAC5F,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAU3C;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,wBAAyB,SAAQ,SAAS;;CAWtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IACjD,sGAAsG;IACtG,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAW3C;AAED;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;;CASjD;AAED;;;;;GAKG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACvD,gEAAgE;IAChE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,KAAK,EAA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;;;;;GA8BG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IACjD,sGAAsG;IACtG,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAW3C;AAED;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;;CASjD;AAqBD;;;;;GAKG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACvD,gEAAgE;IAChE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,KAAK,EAAE,OAAO,EAAE,MAAM,SAAgB;CAUlD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,wBAAyB,SAAQ,SAAS;IACtD,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,OAAO,EAAE,MAAM,SAA+B;CAUnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;IAC/C,qDAAqD;IACrD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;gBAEb,MAAM,EAAE,OAAO;CAS3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,uBAAwB,SAAQ,SAAS;gBACzC,KAAK,EAAE,OAAO;CAS1B"}
package/dist/errors.js CHANGED
@@ -1,4 +1,4 @@
1
- import { PlayError } from "@xmachines/play";
1
+ import { PlayError } from "@xmachines/play/errors";
2
2
  /**
3
3
  * Converts a value from a throw into a string, and it trusts that value not:
4
4
  * `String()` itself throws for an object with a null prototype, and also for a value
@@ -35,7 +35,7 @@ const safeString = (value) => {
35
35
  *
36
36
  * @example
37
37
  * ```typescript
38
- * import { buildRouteUrl } from "@xmachines/play-xstate";
38
+ * import { buildRouteUrl } from "@xmachines/play-xstate/routing";
39
39
  * import { MissingRouteParamError } from "@xmachines/play-xstate/errors";
40
40
  *
41
41
  * try {
@@ -62,25 +62,47 @@ export class MissingRouteParamError extends PlayError {
62
62
  }
63
63
  }
64
64
  /**
65
- * @deprecated Nothing throws this error now. `buildRouteUrl` reads an absent `query`
66
- * field as `query: {}`. The generated `play.route` transitions assign `query` on
67
- * every navigation, and the loss that this error guarded against therefore cannot
68
- * happen through the route derivation. A machine that handles `play.route` itself
69
- * and wants the query must assign `event.query` to its context itself. This class
70
- * stays in the exports, so that an `instanceof` handler that exists now still
71
- * compiles. Remove such a handler when you have the time.
72
- *
73
- * `buildRouteUrl()` threw this error before, when the context had a `params` field,
74
- * which means a context that knows the routing, but no `query` field.
75
- *
76
- * **Error code:** `PLAY_XSTATE_MISSING_QUERY_CONTEXT`
65
+ * `buildRouteUrl()` throws this error when a route parameter carries a value that no path
66
+ * can hold, so the template matches the built URL back never.
67
+ *
68
+ * A dot segment is that value. A URL parser resolves `.` and `..` BEFORE it decodes the
69
+ * percent escapes, and it counts `%2e` as the dot, so every encoding of them resolves
70
+ * away: `/files/..` becomes `/`. The actor would hold the route `/files/..` while the
71
+ * address bar shows `/`, and the two stay out of step for the rest of the session.
72
+ *
73
+ * Give the param a value that names a segment. Machine state that can carry a path from a
74
+ * user belongs behind a check of its own, in the same way that a base path checks the
75
+ * values of its `:param` segments.
76
+ *
77
+ * **Error code:** `PLAY_XSTATE_ROUTE_PARAM_INVALID`
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * import { buildRouteUrl } from "@xmachines/play-xstate/routing";
82
+ * import { InvalidRouteParamError } from "@xmachines/play-xstate/errors";
83
+ *
84
+ * try {
85
+ * buildRouteUrl("/files/:name", { params: { name: ".." }, query: {} });
86
+ * } catch (err) {
87
+ * if (err instanceof InvalidRouteParamError) {
88
+ * console.error(`"${err.value}" cannot stand in "${err.param}"`);
89
+ * }
90
+ * }
91
+ * ```
77
92
  */
78
- export class MissingQueryContextError extends PlayError {
79
- constructor() {
80
- super("buildRouteUrl", "PLAY_XSTATE_MISSING_QUERY_CONTEXT", "buildRouteUrl() received a context without a 'query' field. " +
81
- "Declare 'query: Record<string, string>' in the machine context type and " +
82
- "initialise it to {} so query parameters from play.route events are not silently dropped.");
83
- this.name = "MissingQueryContextError";
93
+ export class InvalidRouteParamError extends PlayError {
94
+ /** The name of the route parameter that carries the value, for example `"name"`. */
95
+ param;
96
+ /** The value that no path can hold, for example `".."`. */
97
+ value;
98
+ /** The route template that declares the parameter, for example `"/files/:name"`. */
99
+ template;
100
+ constructor(param, value, template) {
101
+ super("buildRouteUrl", "PLAY_XSTATE_ROUTE_PARAM_INVALID", `Route parameter '${param}' of template '${template}' carries the value '${value}', which resolves away in a URL.`);
102
+ this.name = "InvalidRouteParamError";
103
+ this.param = param;
104
+ this.value = value;
105
+ this.template = template;
84
106
  }
85
107
  }
86
108
  /**
@@ -140,6 +162,25 @@ export class InvalidMachineError extends PlayError {
140
162
  this.name = "InvalidMachineError";
141
163
  }
142
164
  }
165
+ /**
166
+ * Describes an unknown value for the message of an error, and throws nothing itself.
167
+ *
168
+ * `JSON.stringify` alone is not enough for a value that arrives from the config of a
169
+ * user. It returns the VALUE `undefined` for a function, for a symbol, and for
170
+ * `undefined`, which puts the text "undefined" in a field that is declared `string`.
171
+ * It also THROWS a `TypeError` for a circular object, and an error constructor that
172
+ * throws hides the error that it was built to report.
173
+ *
174
+ * The fallback names the type instead, for example `[function]`.
175
+ */
176
+ function describeValue(value) {
177
+ try {
178
+ return JSON.stringify(value) ?? `[${typeof value}]`;
179
+ }
180
+ catch {
181
+ return `[${typeof value}]`;
182
+ }
183
+ }
143
184
  /**
144
185
  * `normalizeRoute()` throws this error when the `meta.route` value of a state is not
145
186
  * a string and not an object with a `path` property.
@@ -150,25 +191,46 @@ export class InvalidRouteMetadataError extends PlayError {
150
191
  /** The invalid route value, as a string, for the debug work. */
151
192
  detail;
152
193
  constructor(route, source = "deriveRoute") {
153
- const detail = JSON.stringify(route);
194
+ const detail = describeValue(route);
154
195
  super(source, "PLAY_XSTATE_INVALID_ROUTE_METADATA", `Invalid route metadata: ${detail}. Expected string or { path: string }`);
155
196
  this.name = "InvalidRouteMetadataError";
156
197
  this.detail = detail;
157
198
  }
158
199
  }
159
200
  /**
160
- * `composeGuards()` and `composeGuardsOr()` throw this error for an empty array of
161
- * guards. A composition of zero guards has no meaning.
201
+ * `formatPlayRouteTransitions()` throws this error for a `meta.route` object whose
202
+ * `handler` field holds a value that the routing layer does not know.
203
+ *
204
+ * The field decides WHERE the generated `play.route` transition sits, and each value
205
+ * produces a different reachability. `"local"` in particular makes a state reachable
206
+ * only while its parent is active. A typo such as `"locale"` would therefore fall back
207
+ * to a placement that the author did not ask for, and the route would behave correctly
208
+ * in the test that the author wrote and wrongly everywhere else. The error refuses the
209
+ * value instead.
162
210
  *
163
- * **Error code:** `PLAY_XSTATE_EMPTY_GUARD_ARRAY`
211
+ * **Error code:** `PLAY_XSTATE_INVALID_ROUTE_HANDLER`
212
+ *
213
+ * @example
214
+ * ```typescript
215
+ * import { InvalidRouteHandlerError } from "@xmachines/play-xstate/errors";
216
+ *
217
+ * try {
218
+ * formatPlayRouteTransitions(config);
219
+ * } catch (error) {
220
+ * if (error instanceof InvalidRouteHandlerError) {
221
+ * console.error(error.handler); // the value that the config declared
222
+ * }
223
+ * }
224
+ * ```
164
225
  */
165
- export class EmptyGuardArrayError extends PlayError {
166
- /** The combinator of the call with the empty array: `"and"` or `"or"`. */
167
- combinator;
168
- constructor(combinator) {
169
- super(combinator === "and" ? "composeGuards" : "composeGuardsOr", "PLAY_XSTATE_EMPTY_GUARD_ARRAY", `${combinator === "and" ? "composeGuards" : "composeGuardsOr"} requires at least one guard`);
170
- this.name = "EmptyGuardArrayError";
171
- this.combinator = combinator;
226
+ export class InvalidRouteHandlerError extends PlayError {
227
+ /** The value that the config declared, as a string, for the debug work. */
228
+ handler;
229
+ constructor(handler, source = "formatPlayRouteTransitions") {
230
+ const detail = describeValue(handler);
231
+ super(source, "PLAY_XSTATE_INVALID_ROUTE_HANDLER", `Invalid route handler: ${detail}. Expected "root", "local", or "both"`);
232
+ this.name = "InvalidRouteHandlerError";
233
+ this.handler = detail;
172
234
  }
173
235
  }
174
236
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,CAAC,KAAc,EAAU,EAAE;IAC7C,IAAI,CAAC;QACJ,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACR,IAAI,CAAC;YACJ,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC;QAAC,MAAM,CAAC;YACR,6DAA6D;YAC7D,OAAO,yBAAyB,CAAC;QAClC,CAAC;IACF,CAAC;AACF,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IACpD,+EAA+E;IACtE,KAAK,CAAS;IAEvB,4FAA4F;IACnF,QAAQ,CAAS;IAE1B,YAAY,KAAa,EAAE,QAAgB;QAC1C,KAAK,CACJ,eAAe,EACf,iCAAiC,EACjC,oBAAoB,KAAK,8BAA8B,QAAQ,iCAAiC,CAChG,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;CACD;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,wBAAyB,SAAQ,SAAS;IACtD;QACC,KAAK,CACJ,eAAe,EACf,mCAAmC,EACnC,8DAA8D;YAC7D,0EAA0E;YAC1E,0FAA0F,CAC3F,CAAC;QACF,I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AM,GAAG,4BAA4B;QAClE,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;QACtC,KAAK,CACJ,MAAM,EACN,mCAAmC,EACnC,0BAA0B,MAAM,uCAAuC,CACvE,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACvB,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC/C,qDAAqD;IAC5C,MAAM,CAAU;IAEzB,YAAY,MAAe;QAC1B,KAAK,CACJ,aAAa,EACb,2BAA2B,EAC3B,iDAAiD,CACjD,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,uBAAwB,SAAQ,SAAS;IACrD,YAAY,KAAc;QACzB,KAAK,CACJ,aAAa,EACb,8BAA8B,EAC9B,8CAA8C,UAAU,CAAC,KAAK,CAAC,GAAG,EAClE,EAAE,KAAK,EAAE,KAAK,EAAE,CAChB,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACvC,CAAC;CACD"}
package/dist/index.d.ts CHANGED
@@ -2,21 +2,19 @@
2
2
  * @xmachines/play-xstate - the XState v5 adapter of the Play Architecture
3
3
  *
4
4
  * This package gives you the definePlayer() API. That function binds an XState state
5
- * machine to the actor base, with the signal lifecycle and the DevTools
5
+ * machine to the actor base, with the atom lifecycle and the DevTools
6
6
  * integration.
7
7
  *
8
8
  * The Play RFC gives this package as the adapter of the logic layer. It converts a
9
- * declarative machine definition into a live actor with a signal-driven
9
+ * declarative machine definition into a live actor with an atom-driven
10
10
  * reactivity.
11
11
  *
12
12
  * @packageDocumentation
13
13
  */
14
14
  export { definePlayer } from "./define-player.js";
15
15
  export { PlayerActor } from "./player-actor.js";
16
+ export { compose } from "./capabilities.js";
17
+ export type { Capability, PlayerConstructor } from "./capabilities.js";
16
18
  export type { PlayerConfig, PlayerOptions, PlayerFactory, PlayerFactoryResumeOptions, } from "./types.js";
17
- export { composeGuards, composeGuardsOr, negateGuard, hasContext, eventMatches, contextFieldMatches, } from "./guards/index.js";
18
- export type { Guard, GuardArray, ComposedGuard } from "./guards/index.js";
19
- export { deriveRoute, isAbsoluteRoute, buildRouteUrl, formatPlayRouteTransitions, } from "./routing/index.js";
20
- export type { RouteMachineConfig, RouteStateNode, RouteContext, RouteObject, RouteMetadata, } from "./routing/index.js";
21
19
  export { DISPOSE } from "@xmachines/play";
22
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,0BAA0B,GAC1B,MAAM,YAAY,CAAC;AAGpB,OAAO,EACN,aAAa,EACb,eAAe,EACf,WAAW,EACX,UAAU,EACV,YAAY,EACZ,mBAAmB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAG1E,OAAO,EACN,WAAW,EACX,eAAe,EACf,aAAa,EACb,0BAA0B,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACX,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,WAAW,EACX,aAAa,GACb,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,YAAY,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,0BAA0B,GAC1B,MAAM,YAAY,CAAC;AAWpB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -2,21 +2,26 @@
2
2
  * @xmachines/play-xstate - the XState v5 adapter of the Play Architecture
3
3
  *
4
4
  * This package gives you the definePlayer() API. That function binds an XState state
5
- * machine to the actor base, with the signal lifecycle and the DevTools
5
+ * machine to the actor base, with the atom lifecycle and the DevTools
6
6
  * integration.
7
7
  *
8
8
  * The Play RFC gives this package as the adapter of the logic layer. It converts a
9
- * declarative machine definition into a live actor with a signal-driven
9
+ * declarative machine definition into a live actor with an atom-driven
10
10
  * reactivity.
11
11
  *
12
12
  * @packageDocumentation
13
13
  */
14
14
  export { definePlayer } from "./define-player.js";
15
15
  export { PlayerActor } from "./player-actor.js";
16
- // The guard utilities
17
- export { composeGuards, composeGuardsOr, negateGuard, hasContext, eventMatches, contextFieldMatches, } from "./guards/index.js";
18
- // The routing utilities
19
- export { deriveRoute, isAbsoluteRoute, buildRouteUrl, formatPlayRouteTransitions, } from "./routing/index.js";
16
+ // The composition of the capabilities. Each capability itself lives behind its own entry
17
+ // point — `@xmachines/play-xstate/routing` and `@xmachines/play-xstate/view` — so this
18
+ // module imports neither, and an application loads only what it composes.
19
+ export { compose } from "./capabilities.js";
20
+ // The routing utilities live behind `@xmachines/play-xstate/routing`, with the mixin
21
+ // that needs them: `deriveRoute`, `isAbsoluteRoute`, `buildRouteUrl`,
22
+ // `formatPlayRouteTransitions`, and the route types. Each one names
23
+ // `@xmachines/play-router` in its `.d.ts`, and that package is an OPTIONAL peer. This
24
+ // entry therefore names no capability package, exactly as the view half does.
20
25
  // The release protocol of @xmachines/play. This package's own published `.d.ts` names
21
26
  // exactly these, so a consumer reads them from here and needs no second manifest
22
27
  // entry. It names `asCleanup` nowhere: a consumer of this package RECEIVES a
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQhD,sBAAsB;AACtB,OAAO,EACN,aAAa,EACb,eAAe,EACf,WAAW,EACX,UAAU,EACV,YAAY,EACZ,mBAAmB,GACnB,MAAM,mBAAmB,CAAC;AAG3B,wBAAwB;AACxB,OAAO,EACN,WAAW,EACX,eAAe,EACf,aAAa,EACb,0BAA0B,GAC1B,MAAM,oBAAoB,CAAC;AAQ5B,sFAAsF;AACtF,iFAAiF;AACjF,6EAA6E;AAC7E,4DAA4D;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,yFAAyF;AACzF,uFAAuF;AACvF,0EAA0E;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAS5C,qFAAqF;AACrF,sEAAsE;AACtE,oEAAoE;AACpE,sFAAsF;AACtF,8EAA8E;AAC9E,sFAAsF;AACtF,iFAAiF;AACjF,6EAA6E;AAC7E,4DAA4D;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}