@xmachines/play-xstate 1.0.0-beta.8 → 1.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 (97) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +175 -336
  3. package/dist/define-player.d.ts +6 -56
  4. package/dist/define-player.d.ts.map +1 -1
  5. package/dist/define-player.js +7 -61
  6. package/dist/define-player.js.map +1 -1
  7. package/dist/define-player.typecheck.js +6 -0
  8. package/dist/define-player.typecheck.js.map +1 -1
  9. package/dist/errors.d.ts +170 -0
  10. package/dist/errors.d.ts.map +1 -0
  11. package/dist/errors.js +202 -0
  12. package/dist/errors.js.map +1 -0
  13. package/dist/guards/compose.d.ts +14 -3
  14. package/dist/guards/compose.d.ts.map +1 -1
  15. package/dist/guards/compose.js +29 -2
  16. package/dist/guards/compose.js.map +1 -1
  17. package/dist/guards/helpers.d.ts +16 -1
  18. package/dist/guards/helpers.d.ts.map +1 -1
  19. package/dist/guards/helpers.js +16 -35
  20. package/dist/guards/helpers.js.map +1 -1
  21. package/dist/guards/index.d.ts +2 -1
  22. package/dist/guards/index.d.ts.map +1 -1
  23. package/dist/guards/index.js +1 -1
  24. package/dist/guards/index.js.map +1 -1
  25. package/dist/guards/types.d.ts +1 -1
  26. package/dist/guards/types.d.ts.map +1 -1
  27. package/dist/index.d.ts +6 -10
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +3 -5
  30. package/dist/index.js.map +1 -1
  31. package/dist/player-actor.d.ts +134 -28
  32. package/dist/player-actor.d.ts.map +1 -1
  33. package/dist/player-actor.js +424 -159
  34. package/dist/player-actor.js.map +1 -1
  35. package/dist/player-actor.typecheck.js +9 -5
  36. package/dist/player-actor.typecheck.js.map +1 -1
  37. package/dist/routing/build-url.d.ts +27 -16
  38. package/dist/routing/build-url.d.ts.map +1 -1
  39. package/dist/routing/build-url.js +48 -25
  40. package/dist/routing/build-url.js.map +1 -1
  41. package/dist/routing/derive-current-route.d.ts +22 -0
  42. package/dist/routing/derive-current-route.d.ts.map +1 -0
  43. package/dist/routing/derive-current-route.js +122 -0
  44. package/dist/routing/derive-current-route.js.map +1 -0
  45. package/dist/routing/derive-initial-route.d.ts +43 -0
  46. package/dist/routing/derive-initial-route.d.ts.map +1 -0
  47. package/dist/routing/derive-initial-route.js +57 -0
  48. package/dist/routing/derive-initial-route.js.map +1 -0
  49. package/dist/routing/derive-route.d.ts +15 -1
  50. package/dist/routing/derive-route.d.ts.map +1 -1
  51. package/dist/routing/derive-route.js +25 -10
  52. package/dist/routing/derive-route.js.map +1 -1
  53. package/dist/routing/format-play-route-transitions.d.ts +29 -2
  54. package/dist/routing/format-play-route-transitions.d.ts.map +1 -1
  55. package/dist/routing/format-play-route-transitions.js +32 -8
  56. package/dist/routing/format-play-route-transitions.js.map +1 -1
  57. package/dist/routing/index.d.ts +3 -1
  58. package/dist/routing/index.d.ts.map +1 -1
  59. package/dist/routing/index.js +2 -0
  60. package/dist/routing/index.js.map +1 -1
  61. package/dist/routing/types.d.ts +11 -4
  62. package/dist/routing/types.d.ts.map +1 -1
  63. package/dist/types.d.ts +12 -6
  64. package/dist/types.d.ts.map +1 -1
  65. package/package.json +34 -11
  66. package/dist/catalog/index.d.ts +0 -13
  67. package/dist/catalog/index.d.ts.map +0 -1
  68. package/dist/catalog/index.js +0 -11
  69. package/dist/catalog/index.js.map +0 -1
  70. package/dist/catalog/types.d.ts +0 -27
  71. package/dist/catalog/types.d.ts.map +0 -1
  72. package/dist/catalog/types.js +0 -2
  73. package/dist/catalog/types.js.map +0 -1
  74. package/dist/catalog/validate-binding.d.ts +0 -22
  75. package/dist/catalog/validate-binding.d.ts.map +0 -1
  76. package/dist/catalog/validate-binding.js +0 -30
  77. package/dist/catalog/validate-binding.js.map +0 -1
  78. package/dist/catalog/validate-props.d.ts +0 -51
  79. package/dist/catalog/validate-props.d.ts.map +0 -1
  80. package/dist/catalog/validate-props.js +0 -155
  81. package/dist/catalog/validate-props.js.map +0 -1
  82. package/dist/catalog/validate-props.typecheck.d.ts +0 -2
  83. package/dist/catalog/validate-props.typecheck.d.ts.map +0 -1
  84. package/dist/catalog/validate-props.typecheck.js +0 -6
  85. package/dist/catalog/validate-props.typecheck.js.map +0 -1
  86. package/dist/signals/debounce.d.ts +0 -18
  87. package/dist/signals/debounce.d.ts.map +0 -1
  88. package/dist/signals/debounce.js +0 -35
  89. package/dist/signals/debounce.js.map +0 -1
  90. package/dist/signals/index.d.ts +0 -2
  91. package/dist/signals/index.d.ts.map +0 -1
  92. package/dist/signals/index.js +0 -2
  93. package/dist/signals/index.js.map +0 -1
  94. package/dist/signals/state-signal.d.ts +0 -33
  95. package/dist/signals/state-signal.d.ts.map +0 -1
  96. package/dist/signals/state-signal.js +0 -41
  97. package/dist/signals/state-signal.js.map +0 -1
@@ -1,29 +1,23 @@
1
1
  import type { AnyStateMachine } from "xstate";
2
2
  import type { PlayerConfig, PlayerFactory } from "./types.js";
3
3
  /**
4
- * Create a player factory from XState machine and catalog
4
+ * Create a player factory from an XState machine
5
5
  *
6
- * Factory pattern that accepts an XState v5 machine and optional UI catalog,
6
+ * Factory pattern that accepts an XState v5 machine,
7
7
  * returning a function that creates {@link PlayerActor} instances. This enables
8
8
  * creating multiple actor instances from a single configuration, useful for
9
9
  * testing, multi-instance scenarios, or server-side rendering.
10
10
  *
11
- * **Architectural Context:** Implements **Strict Separation (INV-02)** by accepting
12
- * the machine definition (pure business logic) separately from the catalog (UI vocabulary).
13
- * The machine references component names in `meta.view` without importing React/framework code.
14
- *
15
11
  * @typeParam TMachine - XState v5 state machine type
16
- * @typeParam TCatalog - Optional UI component catalog type
17
12
  *
18
13
  * @param config - Player configuration object
19
14
  * @param config.machine - XState v5 state machine
20
- * @param config.catalog - Optional UI component catalog (allows machines without UI)
21
15
  * @param config.options - Optional lifecycle hooks (onStart, onTransition, etc.)
22
16
  *
23
17
  * @returns Factory function that creates actor instances with optional input context
24
18
  *
25
19
  * @example
26
- * Basic player factory without catalog
20
+ * Basic player factory
27
21
  * ```typescript
28
22
  * import { setup } from "xstate";
29
23
  * import { definePlayer } from "@xmachines/play-xstate";
@@ -42,53 +36,9 @@ import type { PlayerConfig, PlayerFactory } from "./types.js";
42
36
  * ```
43
37
  *
44
38
  * @example
45
- * Player factory with catalog and parameter-aware routing
46
- * ```typescript
47
- * import { setup } from "xstate";
48
- * import { defineCatalog } from "@xmachines/play-catalog";
49
- * import { definePlayer } from "@xmachines/play-xstate";
50
- * import { z } from "zod";
51
- *
52
- * const catalog = defineCatalog({
53
- * HomePage: z.object({}),
54
- * ProfilePage: z.object({ userId: z.string() })
55
- * });
56
- *
57
- * const machine = setup({
58
- * types: {
59
- * context: {} as { userId: string },
60
- * events: {} as { type: 'play.route'; to: string; params?: Record<string, string> }
61
- * }
62
- * }).createMachine({
63
- * initial: 'home',
64
- * context: { userId: '' },
65
- * states: {
66
- * home: {
67
- * route: {},
68
- * meta: {
69
- * route: '/',
70
- * view: { component: 'HomePage' }
71
- * }
72
- * },
73
- * profile: {
74
- * route: {},
75
- * meta: {
76
- * route: '/profile/:userId',
77
- * view: { component: 'ProfilePage', userId: (ctx) => ctx.userId }
78
- * }
79
- * }
80
- * }
81
- * });
82
- *
83
- * const createPlayer = definePlayer({ machine, catalog });
84
- * const actor = createPlayer({ userId: 'user123' });
85
- * actor.start();
86
- * ```
87
- *
88
- * @example
89
39
  * Multiple actor instances from single factory
90
40
  * ```typescript
91
- * const createPlayer = definePlayer({ machine, catalog });
41
+ * const createPlayer = definePlayer({ machine });
92
42
  *
93
43
  * // Create actors for different users
94
44
  * const alice = createPlayer({ userId: 'alice' });
@@ -101,10 +51,10 @@ import type { PlayerConfig, PlayerFactory } from "./types.js";
101
51
  * console.log(alice.state.get() !== bob.state.get());
102
52
  * ```
103
53
  *
104
- * @see {@link https://gitlab.com/xmachin-es/rfc/-/blob/main/src/play-v1.md | RFC Play v1}
54
+ * @see [Play RFC](../../docs/rfc/play.md)
105
55
  * @see {@link PlayerActor} for the concrete actor implementation
106
56
  * @see {@link PlayerConfig} for configuration options
107
57
  * @see {@link PlayerFactory} for factory function signature
108
58
  */
109
- export declare const definePlayer: <TMachine extends AnyStateMachine, TCatalog = Record<string, unknown>>(config: PlayerConfig<TMachine, TCatalog>) => PlayerFactory<TMachine>;
59
+ export declare const definePlayer: <TMachine extends AnyStateMachine>(config: PlayerConfig<TMachine>) => PlayerFactory<TMachine>;
110
60
  //# sourceMappingURL=define-player.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"define-player.d.ts","sourceRoot":"","sources":["../src/define-player.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAa,MAAM,QAAQ,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyGG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,SAAS,eAAe,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChG,QAAQ,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,KACtC,aAAa,CAAC,QAAQ,CAQxB,CAAC"}
1
+ {"version":3,"file":"define-player.d.ts","sourceRoot":"","sources":["../src/define-player.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAa,MAAM,QAAQ,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAA8B,MAAM,YAAY,CAAC;AAG1F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,SAAS,eAAe,EAC5D,QAAQ,YAAY,CAAC,QAAQ,CAAC,KAC5B,aAAa,CAAC,QAAQ,CAKxB,CAAC"}
@@ -1,28 +1,22 @@
1
1
  import { PlayerActor } from "./player-actor.js";
2
2
  /**
3
- * Create a player factory from XState machine and catalog
3
+ * Create a player factory from an XState machine
4
4
  *
5
- * Factory pattern that accepts an XState v5 machine and optional UI catalog,
5
+ * Factory pattern that accepts an XState v5 machine,
6
6
  * returning a function that creates {@link PlayerActor} instances. This enables
7
7
  * creating multiple actor instances from a single configuration, useful for
8
8
  * testing, multi-instance scenarios, or server-side rendering.
9
9
  *
10
- * **Architectural Context:** Implements **Strict Separation (INV-02)** by accepting
11
- * the machine definition (pure business logic) separately from the catalog (UI vocabulary).
12
- * The machine references component names in `meta.view` without importing React/framework code.
13
- *
14
10
  * @typeParam TMachine - XState v5 state machine type
15
- * @typeParam TCatalog - Optional UI component catalog type
16
11
  *
17
12
  * @param config - Player configuration object
18
13
  * @param config.machine - XState v5 state machine
19
- * @param config.catalog - Optional UI component catalog (allows machines without UI)
20
14
  * @param config.options - Optional lifecycle hooks (onStart, onTransition, etc.)
21
15
  *
22
16
  * @returns Factory function that creates actor instances with optional input context
23
17
  *
24
18
  * @example
25
- * Basic player factory without catalog
19
+ * Basic player factory
26
20
  * ```typescript
27
21
  * import { setup } from "xstate";
28
22
  * import { definePlayer } from "@xmachines/play-xstate";
@@ -41,53 +35,9 @@ import { PlayerActor } from "./player-actor.js";
41
35
  * ```
42
36
  *
43
37
  * @example
44
- * Player factory with catalog and parameter-aware routing
45
- * ```typescript
46
- * import { setup } from "xstate";
47
- * import { defineCatalog } from "@xmachines/play-catalog";
48
- * import { definePlayer } from "@xmachines/play-xstate";
49
- * import { z } from "zod";
50
- *
51
- * const catalog = defineCatalog({
52
- * HomePage: z.object({}),
53
- * ProfilePage: z.object({ userId: z.string() })
54
- * });
55
- *
56
- * const machine = setup({
57
- * types: {
58
- * context: {} as { userId: string },
59
- * events: {} as { type: 'play.route'; to: string; params?: Record<string, string> }
60
- * }
61
- * }).createMachine({
62
- * initial: 'home',
63
- * context: { userId: '' },
64
- * states: {
65
- * home: {
66
- * route: {},
67
- * meta: {
68
- * route: '/',
69
- * view: { component: 'HomePage' }
70
- * }
71
- * },
72
- * profile: {
73
- * route: {},
74
- * meta: {
75
- * route: '/profile/:userId',
76
- * view: { component: 'ProfilePage', userId: (ctx) => ctx.userId }
77
- * }
78
- * }
79
- * }
80
- * });
81
- *
82
- * const createPlayer = definePlayer({ machine, catalog });
83
- * const actor = createPlayer({ userId: 'user123' });
84
- * actor.start();
85
- * ```
86
- *
87
- * @example
88
38
  * Multiple actor instances from single factory
89
39
  * ```typescript
90
- * const createPlayer = definePlayer({ machine, catalog });
40
+ * const createPlayer = definePlayer({ machine });
91
41
  *
92
42
  * // Create actors for different users
93
43
  * const alice = createPlayer({ userId: 'alice' });
@@ -100,17 +50,13 @@ import { PlayerActor } from "./player-actor.js";
100
50
  * console.log(alice.state.get() !== bob.state.get());
101
51
  * ```
102
52
  *
103
- * @see {@link https://gitlab.com/xmachin-es/rfc/-/blob/main/src/play-v1.md | RFC Play v1}
53
+ * @see [Play RFC](../../docs/rfc/play.md)
104
54
  * @see {@link PlayerActor} for the concrete actor implementation
105
55
  * @see {@link PlayerConfig} for configuration options
106
56
  * @see {@link PlayerFactory} for factory function signature
107
57
  */
108
58
  export const definePlayer = (config) => {
109
- const { machine, catalog, options } = config;
110
- // Return factory function
111
- // Per CONTEXT.md: "Factory function for creating multiple actor instances"
112
- return (input) => {
113
- return new PlayerActor(machine, catalog ?? {}, options ?? {}, input);
114
- };
59
+ const { machine, options } = config;
60
+ return (input, restore) => new PlayerActor(machine, options ?? {}, input, restore?.snapshot);
115
61
  };
116
62
  //# sourceMappingURL=define-player.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"define-player.js","sourceRoot":"","sources":["../src/define-player.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC3B,MAAwC,EACd,EAAE;IAC5B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAE7C,0BAA0B;IAC1B,2EAA2E;IAC3E,OAAO,CAAC,KAA2B,EAAE,EAAE;QACtC,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,OAAO,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC,CAAC;AACH,CAAC,CAAC"}
1
+ {"version":3,"file":"define-player.js","sourceRoot":"","sources":["../src/define-player.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC3B,MAA8B,EACJ,EAAE;IAC5B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAEpC,OAAO,CAAC,KAA2B,EAAE,OAA8C,EAAE,EAAE,CACtF,IAAI,WAAW,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AACpE,CAAC,CAAC"}
@@ -35,8 +35,14 @@ const createPlayer = definePlayer({
35
35
  },
36
36
  });
37
37
  const actor = createPlayer({ count: 1 });
38
+ const snapshot = actor.getSnapshot();
39
+ const restoredActor = createPlayer({ count: 1 }, { snapshot });
38
40
  const returnNotAny = false;
41
+ const restoredReturnNotAny = false;
39
42
  void returnNotAny;
43
+ void restoredReturnNotAny;
40
44
  // @ts-expect-error factory input must match machine input shape
41
45
  createPlayer("invalid");
46
+ // @ts-expect-error snapshot must be nested under the `snapshot` key
47
+ createPlayer({ count: 1 }, { persisted: snapshot });
42
48
  //# sourceMappingURL=define-player.typecheck.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"define-player.typecheck.js","sourceRoot":"","sources":["../src/define-player.typecheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKlD,MAAM,OAAO,GAAG,KAAK,CAAC;IACrB,KAAK,EAAE;QACN,OAAO,EAAE,EAAuB;QAChC,KAAK,EAAE,EAAuB;QAC9B,MAAM,EAAE,EAAqB;KAC7B;CACD,CAAC,CAAC,aAAa,CAAC;IAChB,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IAChD,OAAO,EAAE,QAAQ;IACjB,MAAM,EAAE;QACP,MAAM,EAAE;YACP,EAAE,EAAE;gBACH,GAAG,EAAE;oBACJ,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;wBACxB,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC;oBACpB,CAAC;iBACD;aACD;SACD;KACD;CACD,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,YAAY,CAAC;IACjC,OAAO;IACP,OAAO,EAAE;QACR,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE;YAK7C,MAAM,WAAW,GAA4B,KAAK,CAAC;YACnD,MAAM,UAAU,GAA2B,KAAK,CAAC;YACjD,MAAM,UAAU,GAA2B,KAAK,CAAC;YAEjD,KAAK,WAAW,CAAC;YACjB,KAAK,UAAU,CAAC;YAChB,KAAK,UAAU,CAAC;QACjB,CAAC;KACD;CACD,CAAC,CAAC;AAEH,MAAM,KAAK,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;AAGzC,MAAM,YAAY,GAA6B,KAAK,CAAC;AACrD,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AK,CAAC,WAAW,EAAE,CAAC;AACrC,MAAM,aAAa,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;AAI/D,MAAM,YAAY,GAA6B,KAAK,CAAC;AACrD,MAAM,oBAAoB,GAAqC,KAAK,CAAC;AACrE,KAAK,YAAY,CAAC;AAClB,KAAK,oBAAoB,CAAC;AAE1B,gEAAgE;AAChE,YAAY,CAAC,SAAS,CAAC,CAAC;AAExB,oEAAoE;AACpE,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC"}
@@ -0,0 +1,170 @@
1
+ import { PlayError } from "@xmachines/play";
2
+ /**
3
+ * Thrown by `buildRouteUrl()` when a required route parameter is absent from the
4
+ * actor's context.
5
+ *
6
+ * Use the `param` and `template` fields to identify the missing parameter without
7
+ * parsing the `.message` string.
8
+ *
9
+ * **Error code:** `PLAY_XSTATE_ROUTE_PARAM_MISSING`
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { MissingRouteParamError } from "@xmachines/play-xstate/errors";
14
+ *
15
+ * // The route template "/profile/:userId" requires "userId" in context.
16
+ * // If userId is absent, MissingRouteParamError is thrown when the
17
+ * // actor.currentRoute signal is read.
18
+ *
19
+ * try {
20
+ * actor.currentRoute.get();
21
+ * } catch (err) {
22
+ * if (err instanceof MissingRouteParamError) {
23
+ * console.error(
24
+ * `Missing "${err.param}" for template "${err.template}"`
25
+ * );
26
+ * }
27
+ * }
28
+ * ```
29
+ */
30
+ export declare class MissingRouteParamError extends PlayError {
31
+ /** The name of the route parameter that was missing (e.g. `"userId"`). */
32
+ readonly param: string;
33
+ /** The route template that required the missing parameter (e.g. `"/profile/:userId"`). */
34
+ readonly template: string;
35
+ constructor(param: string, template: string);
36
+ }
37
+ /**
38
+ * Thrown by `buildRouteUrl()` when the context has a `params` field (indicating a
39
+ * routing-aware machine context) but no `query` field.
40
+ *
41
+ * The `params` field signals the context was set up for routing (either manually or via
42
+ * `formatPlayRouteTransitions`). A routing-aware context without `query` will silently
43
+ * drop any query parameters carried by `play.route` events, producing incorrect URLs.
44
+ *
45
+ * **Fix:** Ensure the machine context type includes `query: Record<string, string>`
46
+ * and that the context initializer sets `query: {}` (or a populated value).
47
+ * If using `formatPlayRouteTransitions`, the field is assigned automatically on each
48
+ * `play.route` event — but the machine's initial context must still declare it.
49
+ *
50
+ * **Error code:** `PLAY_XSTATE_MISSING_QUERY_CONTEXT`
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * import { MissingQueryContextError } from "@xmachines/play-xstate/errors";
55
+ *
56
+ * try {
57
+ * // params present but no query field — throws
58
+ * buildRouteUrl("/profile/:userId", { params: { userId: "42" } });
59
+ * } catch (err) {
60
+ * if (err instanceof MissingQueryContextError) {
61
+ * console.error("Machine context missing query field");
62
+ * }
63
+ * }
64
+ *
65
+ * // Correct — both params and query declared
66
+ * buildRouteUrl("/profile/:userId", { params: { userId: "42" }, query: {} });
67
+ * ```
68
+ */
69
+ export declare class MissingQueryContextError extends PlayError {
70
+ constructor();
71
+ }
72
+ /**
73
+ * Thrown by `formatPlayRouteTransitions()` when a state node declares `meta.route`
74
+ * but omits an explicit `id`.
75
+ *
76
+ * Without `id`, the function cannot generate a `play.route` guard that targets the
77
+ * state — the guard compares `event.to` against `#<id>`, so a missing `id` means
78
+ * the state is silently unreachable via routing. This error surfaces the
79
+ * misconfiguration at machine-definition time rather than silently skipping the state.
80
+ *
81
+ * **Error code:** `PLAY_XSTATE_MISSING_STATE_ID`
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * // Bad — meta.route without id:
86
+ * states: {
87
+ * profile: {
88
+ * meta: { route: "/profile/:username" },
89
+ * // ← missing id: "profile"
90
+ * }
91
+ * }
92
+ *
93
+ * // Good:
94
+ * states: {
95
+ * profile: {
96
+ * id: "profile",
97
+ * meta: { route: "/profile/:username" },
98
+ * }
99
+ * }
100
+ * ```
101
+ */
102
+ export declare class MissingStateIdError extends PlayError {
103
+ /** The state key (position in the states tree) that is missing an explicit `id`. */
104
+ readonly stateKey: string;
105
+ /** The route template declared on the state (e.g. `"/profile/:username"`). */
106
+ readonly route: string;
107
+ constructor(stateKey: string, route: string);
108
+ }
109
+ /**
110
+ * Thrown by the `PlayerActor` constructor when the `machine` argument is not a
111
+ * valid XState machine object (null, undefined, or a non-object).
112
+ *
113
+ * **Error code:** `PLAY_XSTATE_INVALID_MACHINE`
114
+ */
115
+ export declare class InvalidMachineError extends PlayError {
116
+ constructor();
117
+ }
118
+ /**
119
+ * Thrown by `normalizeRoute()` when a state's `meta.route` value is neither a
120
+ * string nor an object with a `path` property.
121
+ *
122
+ * **Error code:** `PLAY_XSTATE_INVALID_ROUTE_METADATA`
123
+ */
124
+ export declare class InvalidRouteMetadataError extends PlayError {
125
+ /** The serialised form of the invalid route value for debugging. */
126
+ readonly detail: string;
127
+ constructor(route: unknown, source?: string);
128
+ }
129
+ /**
130
+ * Thrown by `composeGuards()` or `composeGuardsOr()` when called with an empty
131
+ * guards array. A composition of zero guards has no meaningful semantics.
132
+ *
133
+ * **Error code:** `PLAY_XSTATE_EMPTY_GUARD_ARRAY`
134
+ */
135
+ export declare class EmptyGuardArrayError extends PlayError {
136
+ /** The combinator that was called with an empty array (`"and"` or `"or"`). */
137
+ readonly combinator: "and" | "or";
138
+ constructor(combinator: "and" | "or");
139
+ }
140
+ /**
141
+ * Thrown by `PlayerActor.send()` when the event argument is not a plain object.
142
+ *
143
+ * `PlayEvent` requires `{ type: string, ...fields }`. Passing `null`, `undefined`,
144
+ * a string, or any other non-object value is a programmer error.
145
+ *
146
+ * The offending value is attached as the `detail` readonly class field for debugging.
147
+ * TypeScript consumers can access `err.detail` directly without any unsafe cast.
148
+ *
149
+ * **Error code:** `PLAY_XSTATE_INVALID_EVENT`
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * import { InvalidEventError } from "@xmachines/play-xstate/errors";
154
+ *
155
+ * try {
156
+ * actor.send(null as any);
157
+ * } catch (err) {
158
+ * if (err instanceof InvalidEventError) {
159
+ * // err.detail is typed as `unknown` — no cast needed
160
+ * console.error("Invalid event passed to actor.send():", err.detail);
161
+ * }
162
+ * }
163
+ * ```
164
+ */
165
+ export declare class InvalidEventError extends PlayError {
166
+ /** The offending value passed to `send()`. */
167
+ readonly detail: unknown;
168
+ constructor(detail: unknown);
169
+ }
170
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,0FAA0F;IAC1F,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAU3C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,wBAAyB,SAAQ,SAAS;;CAWtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IACjD,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAW3C;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;;CASjD;AAED;;;;;GAKG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACvD,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,KAAK,EAAE,OAAO,EAAE,MAAM,SAAgB;CAUlD;AAED;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;IAClD,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,KAAK,GAAG,IAAI,CAAC;gBAEtB,UAAU,EAAE,KAAK,GAAG,IAAI;CASpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;IAC/C,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;gBAEb,MAAM,EAAE,OAAO;CAS3B"}
package/dist/errors.js ADDED
@@ -0,0 +1,202 @@
1
+ import { PlayError } from "@xmachines/play";
2
+ /**
3
+ * Thrown by `buildRouteUrl()` when a required route parameter is absent from the
4
+ * actor's context.
5
+ *
6
+ * Use the `param` and `template` fields to identify the missing parameter without
7
+ * parsing the `.message` string.
8
+ *
9
+ * **Error code:** `PLAY_XSTATE_ROUTE_PARAM_MISSING`
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { MissingRouteParamError } from "@xmachines/play-xstate/errors";
14
+ *
15
+ * // The route template "/profile/:userId" requires "userId" in context.
16
+ * // If userId is absent, MissingRouteParamError is thrown when the
17
+ * // actor.currentRoute signal is read.
18
+ *
19
+ * try {
20
+ * actor.currentRoute.get();
21
+ * } catch (err) {
22
+ * if (err instanceof MissingRouteParamError) {
23
+ * console.error(
24
+ * `Missing "${err.param}" for template "${err.template}"`
25
+ * );
26
+ * }
27
+ * }
28
+ * ```
29
+ */
30
+ export class MissingRouteParamError extends PlayError {
31
+ /** The name of the route parameter that was missing (e.g. `"userId"`). */
32
+ param;
33
+ /** The route template that required the missing parameter (e.g. `"/profile/:userId"`). */
34
+ template;
35
+ constructor(param, template) {
36
+ super("buildRouteUrl", "PLAY_XSTATE_ROUTE_PARAM_MISSING", `Route parameter '${param}' is required by template '${template}' but was not found in context.`);
37
+ this.name = "MissingRouteParamError";
38
+ this.param = param;
39
+ this.template = template;
40
+ }
41
+ }
42
+ /**
43
+ * Thrown by `buildRouteUrl()` when the context has a `params` field (indicating a
44
+ * routing-aware machine context) but no `query` field.
45
+ *
46
+ * The `params` field signals the context was set up for routing (either manually or via
47
+ * `formatPlayRouteTransitions`). A routing-aware context without `query` will silently
48
+ * drop any query parameters carried by `play.route` events, producing incorrect URLs.
49
+ *
50
+ * **Fix:** Ensure the machine context type includes `query: Record<string, string>`
51
+ * and that the context initializer sets `query: {}` (or a populated value).
52
+ * If using `formatPlayRouteTransitions`, the field is assigned automatically on each
53
+ * `play.route` event — but the machine's initial context must still declare it.
54
+ *
55
+ * **Error code:** `PLAY_XSTATE_MISSING_QUERY_CONTEXT`
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * import { MissingQueryContextError } from "@xmachines/play-xstate/errors";
60
+ *
61
+ * try {
62
+ * // params present but no query field — throws
63
+ * buildRouteUrl("/profile/:userId", { params: { userId: "42" } });
64
+ * } catch (err) {
65
+ * if (err instanceof MissingQueryContextError) {
66
+ * console.error("Machine context missing query field");
67
+ * }
68
+ * }
69
+ *
70
+ * // Correct — both params and query declared
71
+ * buildRouteUrl("/profile/:userId", { params: { userId: "42" }, query: {} });
72
+ * ```
73
+ */
74
+ export class MissingQueryContextError extends PlayError {
75
+ constructor() {
76
+ super("buildRouteUrl", "PLAY_XSTATE_MISSING_QUERY_CONTEXT", "buildRouteUrl() received a context without a 'query' field. " +
77
+ "Declare 'query: Record<string, string>' in the machine context type and " +
78
+ "initialise it to {} so query parameters from play.route events are not silently dropped.");
79
+ this.name = "MissingQueryContextError";
80
+ }
81
+ }
82
+ /**
83
+ * Thrown by `formatPlayRouteTransitions()` when a state node declares `meta.route`
84
+ * but omits an explicit `id`.
85
+ *
86
+ * Without `id`, the function cannot generate a `play.route` guard that targets the
87
+ * state — the guard compares `event.to` against `#<id>`, so a missing `id` means
88
+ * the state is silently unreachable via routing. This error surfaces the
89
+ * misconfiguration at machine-definition time rather than silently skipping the state.
90
+ *
91
+ * **Error code:** `PLAY_XSTATE_MISSING_STATE_ID`
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * // Bad — meta.route without id:
96
+ * states: {
97
+ * profile: {
98
+ * meta: { route: "/profile/:username" },
99
+ * // ← missing id: "profile"
100
+ * }
101
+ * }
102
+ *
103
+ * // Good:
104
+ * states: {
105
+ * profile: {
106
+ * id: "profile",
107
+ * meta: { route: "/profile/:username" },
108
+ * }
109
+ * }
110
+ * ```
111
+ */
112
+ export class MissingStateIdError extends PlayError {
113
+ /** The state key (position in the states tree) that is missing an explicit `id`. */
114
+ stateKey;
115
+ /** The route template declared on the state (e.g. `"/profile/:username"`). */
116
+ route;
117
+ constructor(stateKey, route) {
118
+ super("formatPlayRouteTransitions", "PLAY_XSTATE_MISSING_STATE_ID", `State "${stateKey}" declares meta.route "${route}" but has no explicit id. ` +
119
+ `Add id: "${stateKey}" to the state config so play.route events can target it.`);
120
+ this.name = "MissingStateIdError";
121
+ this.stateKey = stateKey;
122
+ this.route = route;
123
+ }
124
+ }
125
+ /**
126
+ * Thrown by the `PlayerActor` constructor when the `machine` argument is not a
127
+ * valid XState machine object (null, undefined, or a non-object).
128
+ *
129
+ * **Error code:** `PLAY_XSTATE_INVALID_MACHINE`
130
+ */
131
+ export class InvalidMachineError extends PlayError {
132
+ constructor() {
133
+ super("PlayerActor", "PLAY_XSTATE_INVALID_MACHINE", "PlayerActor requires a valid XState machine");
134
+ this.name = "InvalidMachineError";
135
+ }
136
+ }
137
+ /**
138
+ * Thrown by `normalizeRoute()` when a state's `meta.route` value is neither a
139
+ * string nor an object with a `path` property.
140
+ *
141
+ * **Error code:** `PLAY_XSTATE_INVALID_ROUTE_METADATA`
142
+ */
143
+ export class InvalidRouteMetadataError extends PlayError {
144
+ /** The serialised form of the invalid route value for debugging. */
145
+ detail;
146
+ constructor(route, source = "deriveRoute") {
147
+ const detail = JSON.stringify(route);
148
+ super(source, "PLAY_XSTATE_INVALID_ROUTE_METADATA", `Invalid route metadata: ${detail}. Expected string or { path: string }`);
149
+ this.name = "InvalidRouteMetadataError";
150
+ this.detail = detail;
151
+ }
152
+ }
153
+ /**
154
+ * Thrown by `composeGuards()` or `composeGuardsOr()` when called with an empty
155
+ * guards array. A composition of zero guards has no meaningful semantics.
156
+ *
157
+ * **Error code:** `PLAY_XSTATE_EMPTY_GUARD_ARRAY`
158
+ */
159
+ export class EmptyGuardArrayError extends PlayError {
160
+ /** The combinator that was called with an empty array (`"and"` or `"or"`). */
161
+ combinator;
162
+ constructor(combinator) {
163
+ super(combinator === "and" ? "composeGuards" : "composeGuardsOr", "PLAY_XSTATE_EMPTY_GUARD_ARRAY", `${combinator === "and" ? "composeGuards" : "composeGuardsOr"} requires at least one guard`);
164
+ this.name = "EmptyGuardArrayError";
165
+ this.combinator = combinator;
166
+ }
167
+ }
168
+ /**
169
+ * Thrown by `PlayerActor.send()` when the event argument is not a plain object.
170
+ *
171
+ * `PlayEvent` requires `{ type: string, ...fields }`. Passing `null`, `undefined`,
172
+ * a string, or any other non-object value is a programmer error.
173
+ *
174
+ * The offending value is attached as the `detail` readonly class field for debugging.
175
+ * TypeScript consumers can access `err.detail` directly without any unsafe cast.
176
+ *
177
+ * **Error code:** `PLAY_XSTATE_INVALID_EVENT`
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * import { InvalidEventError } from "@xmachines/play-xstate/errors";
182
+ *
183
+ * try {
184
+ * actor.send(null as any);
185
+ * } catch (err) {
186
+ * if (err instanceof InvalidEventError) {
187
+ * // err.detail is typed as `unknown` — no cast needed
188
+ * console.error("Invalid event passed to actor.send():", err.detail);
189
+ * }
190
+ * }
191
+ * ```
192
+ */
193
+ export class InvalidEventError extends PlayError {
194
+ /** The offending value passed to `send()`. */
195
+ detail;
196
+ constructor(detail) {
197
+ super("PlayerActor", "PLAY_XSTATE_INVALID_EVENT", "PlayerActor.send() received a non-object event.");
198
+ this.name = "InvalidEventError";
199
+ this.detail = detail;
200
+ }
201
+ }
202
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+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AChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;CACD"}
@@ -1,4 +1,15 @@
1
+ import type { GuardPredicate } from "xstate";
1
2
  import type { Guard, GuardArray } from "./types.js";
3
+ import type { MachineContext, EventObject, ParameterizedObject } from "xstate";
4
+ /**
5
+ * Narrowest public return type for guard composition helpers.
6
+ *
7
+ * `GuardPredicate<MachineContext, EventObject, unknown, ParameterizedObject>` is the
8
+ * widest-compatible concrete XState guard type that does not use `any`.
9
+ *
10
+ * @public
11
+ */
12
+ export type ComposedGuard = GuardPredicate<MachineContext, EventObject, unknown, ParameterizedObject>;
2
13
  /**
3
14
  * Compose guards with AND logic using XState's and() helper
4
15
  *
@@ -54,7 +65,7 @@ import type { Guard, GuardArray } from "./types.js";
54
65
  * @see {@link composeGuardsOr} for OR composition
55
66
  * @see {@link negateGuard} for NOT logic
56
67
  */
57
- export declare const composeGuards: <TContext = any, TEvent = any>(guards: GuardArray<TContext, TEvent>) => any;
68
+ export declare const composeGuards: <TContext = any, TEvent = any>(guards: GuardArray<TContext, TEvent>) => ComposedGuard;
58
69
  /**
59
70
  * Compose guards with OR logic using XState's or() helper
60
71
  *
@@ -95,7 +106,7 @@ export declare const composeGuards: <TContext = any, TEvent = any>(guards: Guard
95
106
  * @see {@link composeGuards} for AND composition
96
107
  * @see {@link negateGuard} for NOT logic
97
108
  */
98
- export declare const composeGuardsOr: <TContext = any, TEvent = any>(guards: GuardArray<TContext, TEvent>) => any;
109
+ export declare const composeGuardsOr: <TContext = any, TEvent = any>(guards: GuardArray<TContext, TEvent>) => ComposedGuard;
99
110
  /**
100
111
  * Negate a guard using XState's not() helper
101
112
  *
@@ -132,5 +143,5 @@ export declare const composeGuardsOr: <TContext = any, TEvent = any>(guards: Gua
132
143
  * @see {@link composeGuards} for AND composition
133
144
  * @see {@link composeGuardsOr} for OR composition
134
145
  */
135
- export declare const negateGuard: <TContext = any, TEvent = any>(guard: Guard<TContext, TEvent> | string) => any;
146
+ export declare const negateGuard: <TContext = any, TEvent = any>(guard: Guard<TContext, TEvent> | string) => ComposedGuard;
136
147
  //# sourceMappingURL=compose.d.ts.map