@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.
- package/LICENSE +21 -0
- package/README.md +175 -336
- package/dist/define-player.d.ts +6 -56
- package/dist/define-player.d.ts.map +1 -1
- package/dist/define-player.js +7 -61
- package/dist/define-player.js.map +1 -1
- package/dist/define-player.typecheck.js +6 -0
- package/dist/define-player.typecheck.js.map +1 -1
- package/dist/errors.d.ts +170 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +202 -0
- package/dist/errors.js.map +1 -0
- package/dist/guards/compose.d.ts +14 -3
- package/dist/guards/compose.d.ts.map +1 -1
- package/dist/guards/compose.js +29 -2
- package/dist/guards/compose.js.map +1 -1
- package/dist/guards/helpers.d.ts +16 -1
- package/dist/guards/helpers.d.ts.map +1 -1
- package/dist/guards/helpers.js +16 -35
- package/dist/guards/helpers.js.map +1 -1
- package/dist/guards/index.d.ts +2 -1
- package/dist/guards/index.d.ts.map +1 -1
- package/dist/guards/index.js +1 -1
- package/dist/guards/index.js.map +1 -1
- package/dist/guards/types.d.ts +1 -1
- package/dist/guards/types.d.ts.map +1 -1
- package/dist/index.d.ts +6 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/player-actor.d.ts +134 -28
- package/dist/player-actor.d.ts.map +1 -1
- package/dist/player-actor.js +424 -159
- package/dist/player-actor.js.map +1 -1
- package/dist/player-actor.typecheck.js +9 -5
- package/dist/player-actor.typecheck.js.map +1 -1
- package/dist/routing/build-url.d.ts +27 -16
- package/dist/routing/build-url.d.ts.map +1 -1
- package/dist/routing/build-url.js +48 -25
- package/dist/routing/build-url.js.map +1 -1
- package/dist/routing/derive-current-route.d.ts +22 -0
- package/dist/routing/derive-current-route.d.ts.map +1 -0
- package/dist/routing/derive-current-route.js +122 -0
- package/dist/routing/derive-current-route.js.map +1 -0
- package/dist/routing/derive-initial-route.d.ts +43 -0
- package/dist/routing/derive-initial-route.d.ts.map +1 -0
- package/dist/routing/derive-initial-route.js +57 -0
- package/dist/routing/derive-initial-route.js.map +1 -0
- package/dist/routing/derive-route.d.ts +15 -1
- package/dist/routing/derive-route.d.ts.map +1 -1
- package/dist/routing/derive-route.js +25 -10
- package/dist/routing/derive-route.js.map +1 -1
- package/dist/routing/format-play-route-transitions.d.ts +29 -2
- package/dist/routing/format-play-route-transitions.d.ts.map +1 -1
- package/dist/routing/format-play-route-transitions.js +32 -8
- package/dist/routing/format-play-route-transitions.js.map +1 -1
- package/dist/routing/index.d.ts +3 -1
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +2 -0
- package/dist/routing/index.js.map +1 -1
- package/dist/routing/types.d.ts +11 -4
- package/dist/routing/types.d.ts.map +1 -1
- package/dist/types.d.ts +12 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +34 -11
- package/dist/catalog/index.d.ts +0 -13
- package/dist/catalog/index.d.ts.map +0 -1
- package/dist/catalog/index.js +0 -11
- package/dist/catalog/index.js.map +0 -1
- package/dist/catalog/types.d.ts +0 -27
- package/dist/catalog/types.d.ts.map +0 -1
- package/dist/catalog/types.js +0 -2
- package/dist/catalog/types.js.map +0 -1
- package/dist/catalog/validate-binding.d.ts +0 -22
- package/dist/catalog/validate-binding.d.ts.map +0 -1
- package/dist/catalog/validate-binding.js +0 -30
- package/dist/catalog/validate-binding.js.map +0 -1
- package/dist/catalog/validate-props.d.ts +0 -51
- package/dist/catalog/validate-props.d.ts.map +0 -1
- package/dist/catalog/validate-props.js +0 -155
- package/dist/catalog/validate-props.js.map +0 -1
- package/dist/catalog/validate-props.typecheck.d.ts +0 -2
- package/dist/catalog/validate-props.typecheck.d.ts.map +0 -1
- package/dist/catalog/validate-props.typecheck.js +0 -6
- package/dist/catalog/validate-props.typecheck.js.map +0 -1
- package/dist/signals/debounce.d.ts +0 -18
- package/dist/signals/debounce.d.ts.map +0 -1
- package/dist/signals/debounce.js +0 -35
- package/dist/signals/debounce.js.map +0 -1
- package/dist/signals/index.d.ts +0 -2
- package/dist/signals/index.d.ts.map +0 -1
- package/dist/signals/index.js +0 -2
- package/dist/signals/index.js.map +0 -1
- package/dist/signals/state-signal.d.ts +0 -33
- package/dist/signals/state-signal.d.ts.map +0 -1
- package/dist/signals/state-signal.js +0 -41
- package/dist/signals/state-signal.js.map +0 -1
package/dist/player-actor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"player-actor.js","sourceRoot":"","sources":["../src/player-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,WAAW,
|
|
1
|
+
{"version":3,"file":"player-actor.js","sourceRoot":"","sources":["../src/player-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,WAAW,GAaX,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,aAAa,EAA+C,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE5E,MAAM,iBAAiB,GAAG,CAAC,QAAiB,EAAkC,EAAE;IAC/E,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IACd,CAAC;IAED,IAAI,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO,OAAQ,QAAgC,CAAC,MAAM,KAAK,QAAQ,CAAC;AACrE,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,CAAC,QAAiB,EAAW,EAAE;IAC3D,OAAO,CACN,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAA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AAW,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACM,oBAAoB;QAC5B,OAAO,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,CAAC;IAChD,CAAC;IAED;;;;;;;OAOG;IACK,oBAAoB,CAAC,QAA4B;QACxD,IAAI,CAAC;YACJ,MAAM,IAAI,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;YAEzC,uEAAuE;YACvE,uEAAuE;YACvE,wEAAwE;YACxE,yEAAyE;YACzE,uEAAuE;YACvE,wCAAwC;YACxC,IAAI,sBAAsB,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,EAAE,CAAC;gBACxD,OAAO;YACR,CAAC;YAED,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;YAC5B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;gBAChC,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBACtE,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACvC,CAAC;YACD,mDAAmD;QACpD,CAAC;IACF,CAAC;IAED;;;;OAIG;IACH,OAAO;QACN,IAAI,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;CACD"}
|
|
@@ -13,11 +13,15 @@ const machine = setup({
|
|
|
13
13
|
idle: {},
|
|
14
14
|
},
|
|
15
15
|
});
|
|
16
|
-
const createPlayer = definePlayer({ machine
|
|
16
|
+
const createPlayer = definePlayer({ machine });
|
|
17
17
|
const actor = createPlayer({ value: 1 });
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const restoredActor = createPlayer({ value: 1 }, { snapshot: actor.getSnapshot() });
|
|
19
|
+
// Verify actor instances are created successfully
|
|
20
|
+
void actor;
|
|
21
|
+
void restoredActor;
|
|
22
|
+
// CONS-16: [key: string]: unknown index signature removed.
|
|
23
|
+
// Accessing unknown properties on PlayerActor is now a type error (correct behavior).
|
|
24
|
+
// @ts-expect-error — unknown fields no longer accessible via index signature
|
|
20
25
|
const unknownField = actor["custom-extension-field"];
|
|
21
|
-
|
|
22
|
-
void extensionNotAny;
|
|
26
|
+
void unknownField;
|
|
23
27
|
//# sourceMappingURL=player-actor.typecheck.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"player-actor.typecheck.js","sourceRoot":"","sources":["../src/player-actor.typecheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"player-actor.typecheck.js","sourceRoot":"","sources":["../src/player-actor.typecheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,OAAO,GAAG,KAAK,CAAC;IACrB,KAAK,EAAE;QACN,OAAO,EAAE,EAAuB;QAChC,KAAK,EAAE,EAAuB;QAC9B,MAAM,EAAE,EAAsB;KAC9B;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,MAAM;IACf,MAAM,EAAE;QACP,IAAI,EAAE,EAAE;KACR;CACD,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AAC/C,MAAM,KAAK,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;AACzC,MAAM,aAAa,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAEpF,kDAAkD;AAClD,KAAK,KAAK,CAAC;AACX,KAAK,aAAa,CAAC;AAEnB,2DAA2D;AAC3D,sFAAsF;AACtF,6EAA6E;AAC7E,MAAM,YAAY,GAAG,KAAK,CAAC,wBAAwB,CAAC,CAAC;AACrD,KAAK,YAAY,CAAC"}
|
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
import type { RouteContext } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
* Build full URL from route template and context
|
|
3
|
+
* Build a full URL from a route template and the actor's context.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* - "Parameters: String template syntax — /user/:id"
|
|
8
|
-
* - "Inheritance: relative paths inherit parent route"
|
|
5
|
+
* Substitutes `:param` and `:param?` placeholders from `context.params`,
|
|
6
|
+
* then appends query params and hash fragments.
|
|
9
7
|
*
|
|
10
|
-
*
|
|
8
|
+
* All parameter values must be in `context.params`. Flat context fields are not
|
|
9
|
+
* inspected — this is intentional so misspelled placeholders produce a compile-time
|
|
10
|
+
* error rather than silently resolving to `undefined`.
|
|
11
|
+
*
|
|
12
|
+
* @param routeTemplate - Route path template, e.g. `"/profile/:userId"` or
|
|
13
|
+
* `"/settings/:section?"`.
|
|
14
|
+
* @param context - Actor context object. Route parameters must be in `context.params`;
|
|
15
|
+
* flat context fields are not inspected. **Must include a `query` field** (use `query: {}`
|
|
16
|
+
* when no query parameters are needed). Omitting `query` when `params` is present throws
|
|
17
|
+
* `MissingQueryContextError` to prevent silent query-string loss.
|
|
18
|
+
* @returns The fully resolved URL string.
|
|
19
|
+
*
|
|
20
|
+
* @throws {MissingRouteParamError} When a **required** `:param` placeholder has no
|
|
21
|
+
* matching value in context. Optional parameters (`:param?`) are silently omitted
|
|
22
|
+
* when missing. Import the class from `@xmachines/play-xstate/errors`.
|
|
23
|
+
* @throws {MissingQueryContextError} When the context has a `params` field but no
|
|
24
|
+
* `query` field. This indicates a routing-aware machine context that was not set up
|
|
25
|
+
* to receive query parameters, which would silently drop query params from
|
|
26
|
+
* `play.route` events. Import the class from `@xmachines/play-xstate/errors`.
|
|
11
27
|
*
|
|
12
28
|
* @example
|
|
13
29
|
* ```typescript
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* query: { tab: 'profile' },
|
|
17
|
-
* hash: 'section-1'
|
|
18
|
-
* });
|
|
19
|
-
* // Result: '/user/123?tab=profile#section-1'
|
|
20
|
-
* ```
|
|
30
|
+
* buildRouteUrl("/user/:id", { params: { id: "123" }, query: { tab: "profile" }, hash: "top" });
|
|
31
|
+
* // → "/user/123?tab=profile#top"
|
|
21
32
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
33
|
+
* buildRouteUrl("/settings/:section?", { params: {}, query: {} });
|
|
34
|
+
* // → "/settings" (optional param omitted, no query string)
|
|
35
|
+
* ```
|
|
25
36
|
*/
|
|
26
37
|
export declare const buildRouteUrl: (routeTemplate: string, context?: RouteContext) => string;
|
|
27
38
|
//# sourceMappingURL=build-url.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-url.d.ts","sourceRoot":"","sources":["../../src/routing/build-url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"build-url.d.ts","sourceRoot":"","sources":["../../src/routing/build-url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,aAAa,GACzB,eAAe,MAAM,EACrB,UAAS,YAA4B,KACnC,MAsCF,CAAC"}
|
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
import { isAbsoluteRoute } from "./derive-route.js";
|
|
2
|
+
import { MissingRouteParamError, MissingQueryContextError } from "../errors.js";
|
|
2
3
|
/**
|
|
3
|
-
* Build full URL from route template and context
|
|
4
|
+
* Build a full URL from a route template and the actor's context.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* - "Parameters: String template syntax — /user/:id"
|
|
8
|
-
* - "Inheritance: relative paths inherit parent route"
|
|
6
|
+
* Substitutes `:param` and `:param?` placeholders from `context.params`,
|
|
7
|
+
* then appends query params and hash fragments.
|
|
9
8
|
*
|
|
10
|
-
*
|
|
9
|
+
* All parameter values must be in `context.params`. Flat context fields are not
|
|
10
|
+
* inspected — this is intentional so misspelled placeholders produce a compile-time
|
|
11
|
+
* error rather than silently resolving to `undefined`.
|
|
12
|
+
*
|
|
13
|
+
* @param routeTemplate - Route path template, e.g. `"/profile/:userId"` or
|
|
14
|
+
* `"/settings/:section?"`.
|
|
15
|
+
* @param context - Actor context object. Route parameters must be in `context.params`;
|
|
16
|
+
* flat context fields are not inspected. **Must include a `query` field** (use `query: {}`
|
|
17
|
+
* when no query parameters are needed). Omitting `query` when `params` is present throws
|
|
18
|
+
* `MissingQueryContextError` to prevent silent query-string loss.
|
|
19
|
+
* @returns The fully resolved URL string.
|
|
20
|
+
*
|
|
21
|
+
* @throws {MissingRouteParamError} When a **required** `:param` placeholder has no
|
|
22
|
+
* matching value in context. Optional parameters (`:param?`) are silently omitted
|
|
23
|
+
* when missing. Import the class from `@xmachines/play-xstate/errors`.
|
|
24
|
+
* @throws {MissingQueryContextError} When the context has a `params` field but no
|
|
25
|
+
* `query` field. This indicates a routing-aware machine context that was not set up
|
|
26
|
+
* to receive query parameters, which would silently drop query params from
|
|
27
|
+
* `play.route` events. Import the class from `@xmachines/play-xstate/errors`.
|
|
11
28
|
*
|
|
12
29
|
* @example
|
|
13
30
|
* ```typescript
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* query: { tab: 'profile' },
|
|
17
|
-
* hash: 'section-1'
|
|
18
|
-
* });
|
|
19
|
-
* // Result: '/user/123?tab=profile#section-1'
|
|
20
|
-
* ```
|
|
31
|
+
* buildRouteUrl("/user/:id", { params: { id: "123" }, query: { tab: "profile" }, hash: "top" });
|
|
32
|
+
* // → "/user/123?tab=profile#top"
|
|
21
33
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
34
|
+
* buildRouteUrl("/settings/:section?", { params: {}, query: {} });
|
|
35
|
+
* // → "/settings" (optional param omitted, no query string)
|
|
36
|
+
* ```
|
|
25
37
|
*/
|
|
26
|
-
export const buildRouteUrl = (routeTemplate, context = {}) => {
|
|
38
|
+
export const buildRouteUrl = (routeTemplate, context = { query: {} }) => {
|
|
39
|
+
// Guard: when the context has a `params` field (indicating a routing-aware machine
|
|
40
|
+
// context set up via formatPlayRouteTransitions or manually), it must also declare
|
|
41
|
+
// a `query` field. Without `query`, any query parameters from play.route events are
|
|
42
|
+
// silently dropped. Using "query" in context distinguishes an absent field from
|
|
43
|
+
// query: undefined.
|
|
44
|
+
if ("params" in context && !("query" in context)) {
|
|
45
|
+
throw new MissingQueryContextError();
|
|
46
|
+
}
|
|
27
47
|
// Handle relative vs absolute paths
|
|
28
48
|
const basePath = context.basePath || "";
|
|
29
49
|
const isAbsolute = isAbsoluteRoute(routeTemplate);
|
|
@@ -56,19 +76,18 @@ export const buildRouteUrl = (routeTemplate, context = {}) => {
|
|
|
56
76
|
* - Required parameters without values log warnings
|
|
57
77
|
*
|
|
58
78
|
* Parameter lookup:
|
|
59
|
-
* -
|
|
60
|
-
* - Falls back to context[param] (flat context)
|
|
79
|
+
* - Reads from context.params[param] exclusively. Flat context fields are not inspected.
|
|
61
80
|
*
|
|
62
81
|
* @param template - URL template with :param or :param? syntax
|
|
63
|
-
* @param context - Context with parameter values (may have
|
|
82
|
+
* @param context - Context with parameter values (may have params field)
|
|
64
83
|
* @returns URL with parameters substituted and double slashes cleaned
|
|
84
|
+
* @throws {MissingRouteParamError} When a required route parameter is missing
|
|
65
85
|
*/
|
|
66
86
|
const substituteParams = (template, context) => {
|
|
67
87
|
// Replace parameters, handling optional syntax
|
|
68
88
|
let hasOptionalRemoval = false;
|
|
69
89
|
const result = template.replace(/:(\w+)(\?)?/g, (_match, param, optional) => {
|
|
70
|
-
|
|
71
|
-
const value = context.routeParams?.[param] ?? context[param];
|
|
90
|
+
const value = context.params?.[param]; // nosemgrep: gitlab.eslint.detect-object-injection
|
|
72
91
|
// Parameter has a non-empty value - substitute it
|
|
73
92
|
// For optional params, treat empty string as "no value"
|
|
74
93
|
if (value !== undefined && value !== null && value !== "") {
|
|
@@ -79,9 +98,7 @@ const substituteParams = (template, context) => {
|
|
|
79
98
|
hasOptionalRemoval = true;
|
|
80
99
|
return ""; // Will leave // in path, cleaned up below
|
|
81
100
|
}
|
|
82
|
-
|
|
83
|
-
console.warn(`Route parameter '${param}' not found in context. Template: ${template}`);
|
|
84
|
-
return "";
|
|
101
|
+
throw new MissingRouteParamError(param, template);
|
|
85
102
|
});
|
|
86
103
|
// Clean up double slashes
|
|
87
104
|
let cleaned = result.replace(/\/+/g, "/");
|
|
@@ -90,6 +107,12 @@ const substituteParams = (template, context) => {
|
|
|
90
107
|
if (hasOptionalRemoval && cleaned.endsWith("/")) {
|
|
91
108
|
cleaned = cleaned.slice(0, -1);
|
|
92
109
|
}
|
|
110
|
+
// Never return an empty path: a root-level template of only optional params
|
|
111
|
+
// (e.g. "/:section?") collapses to "" after the trailing-slash trim, which
|
|
112
|
+
// would produce invalid URLs like "" or "?tab=x". Normalize to "/".
|
|
113
|
+
if (cleaned === "") {
|
|
114
|
+
cleaned = "/";
|
|
115
|
+
}
|
|
93
116
|
return cleaned;
|
|
94
117
|
};
|
|
95
118
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-url.js","sourceRoot":"","sources":["../../src/routing/build-url.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"build-url.js","sourceRoot":"","sources":["../../src/routing/build-url.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC5B,aAAqB,EACrB,UAAwB,EAAE,KAAK,EAAE,EAAE,EAAE,EAC5B,EAAE;IACX,mFAAmF;IACnF,mFAAmF;IACnF,oFAAoF;IACpF,gFAAgF;IAChF,oBAAoB;IACpB,IAAI,QAAQ,IAAI,OAAO,IAAI,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,wBAAwB,EAAE,CAAC;IACtC,CAAC;IAED,oCAAoC;IACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;IACxC,MAAM,UAAU,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;IAElD,iBAAiB;IACjB,IAAI,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IAE1E,qCAAqC;IACrC,GAAG,GAAG,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAErC,mCAAmC;IACnC,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxD,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CACtD,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,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,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,0BAA0B;IAC1B,IAAI,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE1C,+DAA+D;IAC/D,2EAA2E;IAC3E,IAAI,kBAAkB,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACjD,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,4EAA4E;IAC5E,2EAA2E;IAC3E,oEAAoE;IACpE,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QACpB,OAAO,GAAG,GAAG,CAAC;IACf,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,QAAgB,EAAU,EAAE;IAC5D,kCAAkC;IAClC,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAE/C,qCAAqC;IACrC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAEvD,yBAAyB;IACzB,OAAO,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,IAAI,kBAAkB,EAAE,CAAC,CAAC,CAAC,IAAI,kBAAkB,EAAE,CAAC;AAC9F,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AnyMachineSnapshot } from "xstate";
|
|
2
|
+
/**
|
|
3
|
+
* Derive the actor's current URL from state metadata and context.
|
|
4
|
+
*
|
|
5
|
+
* Resolves the route template from the current state's `meta.route` and substitutes
|
|
6
|
+
* any `:param` placeholders from `context.params` (preferred) or flat `context`.
|
|
7
|
+
*
|
|
8
|
+
* Returns `null` — rather than throwing — when:
|
|
9
|
+
* - The snapshot has no route metadata (non-routable state)
|
|
10
|
+
* - A required route parameter is absent from context (`MissingRouteParamError`)
|
|
11
|
+
*
|
|
12
|
+
* The `null` return on missing params is intentional: it keeps the computed signal
|
|
13
|
+
* stable during transient states (e.g. mid-transition before context is fully updated,
|
|
14
|
+
* or after logout when `context.username` is `null` but the router bridge has not yet
|
|
15
|
+
* synced to the new state). The router bridge and URL bar are updated on the next
|
|
16
|
+
* stable snapshot once context is complete.
|
|
17
|
+
*
|
|
18
|
+
* @param snapshot - Current XState machine snapshot.
|
|
19
|
+
* @returns Resolved URL string, or `null` if the route cannot be resolved.
|
|
20
|
+
*/
|
|
21
|
+
export declare const deriveCurrentRoute: (snapshot: AnyMachineSnapshot) => string | null;
|
|
22
|
+
//# sourceMappingURL=derive-current-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-current-route.d.ts","sourceRoot":"","sources":["../../src/routing/derive-current-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAmEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,kBAAkB,KAAG,MAAM,GAAG,IA4C1E,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { MissingRouteParamError } from "../errors.js";
|
|
2
|
+
import { deriveRoute } from "./derive-route.js";
|
|
3
|
+
import { buildRouteUrl } from "./build-url.js";
|
|
4
|
+
/**
|
|
5
|
+
* Collect the `meta` of the active state nodes along a SINGLE root-to-leaf branch,
|
|
6
|
+
* keyed by state id and ordered ancestors-first — the shape {@link deriveRoute} folds.
|
|
7
|
+
*
|
|
8
|
+
* `snapshot.getMeta()` returns a FLAT record of every active state's meta. For a
|
|
9
|
+
* non-parallel machine that record is already a single ancestor chain, but for a
|
|
10
|
+
* PARALLEL machine it interleaves entries from every active region, so folding it
|
|
11
|
+
* blindly would concatenate a relative route from one region onto an absolute route
|
|
12
|
+
* from a sibling region (a URL belonging to neither region's tree). The flat record
|
|
13
|
+
* also cannot be re-ordered back into a hierarchy: when states declare an explicit
|
|
14
|
+
* `id` (e.g. a child `id: "dashboard-overview"` under `id: "dashboard"`), the meta
|
|
15
|
+
* keys are those ids and carry no ancestry information.
|
|
16
|
+
*
|
|
17
|
+
* We therefore walk `snapshot.value` (which encodes the true active-state hierarchy
|
|
18
|
+
* by state key) against the machine's node tree, following the FIRST active child at
|
|
19
|
+
* each level. This yields one deterministic branch — matching the historical
|
|
20
|
+
* first-found behaviour for parallel machines — and works regardless of explicit ids
|
|
21
|
+
* because each node carries its own `id` and `meta`.
|
|
22
|
+
*
|
|
23
|
+
* Falls back to `null` when the snapshot does not expose a navigable machine/value
|
|
24
|
+
* (defensive — real XState snapshots always do); callers then use `getMeta()` as before.
|
|
25
|
+
*/
|
|
26
|
+
const firstActiveBranchMeta = (snapshot) => {
|
|
27
|
+
const root = snapshot.machine?.root;
|
|
28
|
+
if (!root)
|
|
29
|
+
return null;
|
|
30
|
+
const ordered = {};
|
|
31
|
+
let node = root;
|
|
32
|
+
let value = snapshot.value;
|
|
33
|
+
while (node) {
|
|
34
|
+
if (node.meta && typeof node.meta === "object") {
|
|
35
|
+
ordered[node.id] = node.meta; // nosemgrep: gitlab.eslint.detect-object-injection
|
|
36
|
+
}
|
|
37
|
+
// Determine the active child key at this level. A string value is an atomic
|
|
38
|
+
// active leaf name; an object value is a compound (one key) or parallel (many
|
|
39
|
+
// keys) node — take the first key for a single deterministic branch.
|
|
40
|
+
let key;
|
|
41
|
+
if (typeof value === "string") {
|
|
42
|
+
key = value;
|
|
43
|
+
}
|
|
44
|
+
else if (value && typeof value === "object") {
|
|
45
|
+
key = Object.keys(value)[0];
|
|
46
|
+
}
|
|
47
|
+
if (key === undefined)
|
|
48
|
+
break;
|
|
49
|
+
const child = node.states?.[key]; // nosemgrep: gitlab.eslint.detect-object-injection
|
|
50
|
+
if (!child)
|
|
51
|
+
break;
|
|
52
|
+
value =
|
|
53
|
+
typeof value === "object" && value !== null
|
|
54
|
+
? value[key] // nosemgrep: gitlab.eslint.detect-object-injection
|
|
55
|
+
: {};
|
|
56
|
+
node = child;
|
|
57
|
+
}
|
|
58
|
+
return ordered;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Derive the actor's current URL from state metadata and context.
|
|
62
|
+
*
|
|
63
|
+
* Resolves the route template from the current state's `meta.route` and substitutes
|
|
64
|
+
* any `:param` placeholders from `context.params` (preferred) or flat `context`.
|
|
65
|
+
*
|
|
66
|
+
* Returns `null` — rather than throwing — when:
|
|
67
|
+
* - The snapshot has no route metadata (non-routable state)
|
|
68
|
+
* - A required route parameter is absent from context (`MissingRouteParamError`)
|
|
69
|
+
*
|
|
70
|
+
* The `null` return on missing params is intentional: it keeps the computed signal
|
|
71
|
+
* stable during transient states (e.g. mid-transition before context is fully updated,
|
|
72
|
+
* or after logout when `context.username` is `null` but the router bridge has not yet
|
|
73
|
+
* synced to the new state). The router bridge and URL bar are updated on the next
|
|
74
|
+
* stable snapshot once context is complete.
|
|
75
|
+
*
|
|
76
|
+
* @param snapshot - Current XState machine snapshot.
|
|
77
|
+
* @returns Resolved URL string, or `null` if the route cannot be resolved.
|
|
78
|
+
*/
|
|
79
|
+
export const deriveCurrentRoute = (snapshot) => {
|
|
80
|
+
if (!snapshot || typeof snapshot.getMeta !== "function") {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
// Prefer the single active branch (correct for parallel machines and explicit
|
|
84
|
+
// ids); fall back to the flat getMeta() record if the snapshot lacks a navigable
|
|
85
|
+
// machine tree.
|
|
86
|
+
const meta = firstActiveBranchMeta(snapshot) ?? snapshot.getMeta();
|
|
87
|
+
if (!meta || typeof meta !== "object") {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const routeTemplate = deriveRoute(meta);
|
|
91
|
+
if (!routeTemplate) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
return buildRouteUrl(routeTemplate, (snapshot.context ?? {}));
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
// MissingRouteParamError: transient and self-resolving — a required `:param` is absent
|
|
99
|
+
// from context during a mid-transition state (e.g. actor in profile state before the
|
|
100
|
+
// first play.route event populates context.params, or after logout before the bridge
|
|
101
|
+
// redirects). Returning null is correct:
|
|
102
|
+
// - Router bridges handle null by skipping navigation (syncRouterFromActor line 242)
|
|
103
|
+
// - The signal recomputes automatically on the next snapshot when params are populated
|
|
104
|
+
// - Throwing would propagate into signal watchers as an unhandled exception for a
|
|
105
|
+
// state that resolves itself — worse than a one-tick null.
|
|
106
|
+
// Do NOT convert this to a throw. See MissingQueryContextError for the structural-error
|
|
107
|
+
// case where throwing is appropriate (non-self-resolving programmer error).
|
|
108
|
+
if (error instanceof MissingRouteParamError) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
// MissingQueryContextError: structural programmer error — the machine context
|
|
112
|
+
// declares `params` but no `query` field. This cannot self-resolve on the next
|
|
113
|
+
// snapshot; re-throw so it surfaces immediately. Frameworks with error boundaries
|
|
114
|
+
// (React, Svelte, SvelteKit) will catch it; signal watchers will see it as an
|
|
115
|
+
// unhandled exception. Fix: add `query: Record<string, string>` to the machine's
|
|
116
|
+
// context type and initializer.
|
|
117
|
+
//
|
|
118
|
+
// All other unexpected errors also re-throw unchanged.
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=derive-current-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-current-route.js","sourceRoot":"","sources":["../../src/routing/derive-current-route.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C;;;;;;;;;;;;;;;;;;;;;GAqBG;A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;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAA4B,EAAiB,EAAE;IACjF,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,8EAA8E;IAC9E,iFAAiF;IACjF,gBAAgB;IAChB,MAAM,IAAI,GAAG,qBAAqB,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;IACnE,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,aAAa,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,CAAC,aAAa,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,CAAC;QACJ,OAAO,aAAa,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAiB,CAAC,CAAC;IAC/E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,uFAAuF;QACvF,qFAAqF;QACrF,qFAAqF;QACrF,yCAAyC;QACzC,uFAAuF;QACvF,yFAAyF;QACzF,oFAAoF;QACpF,+DAA+D;QAC/D,wFAAwF;QACxF,4EAA4E;QAC5E,IAAI,KAAK,YAAY,sBAAsB,EAAE,CAAC;YAC7C,OAAO,IAAI,CAAC;QACb,CAAC;QACD,8EAA8E;QAC9E,+EAA+E;QAC/E,kFAAkF;QAClF,8EAA8E;QAC9E,iFAAiF;QACjF,gCAAgC;QAChC,EAAE;QACF,uDAAuD;QACvD,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type AnyStateMachine } from "xstate";
|
|
2
|
+
/**
|
|
3
|
+
* Derive the machine's initial route directly from the machine definition.
|
|
4
|
+
*
|
|
5
|
+
* Uses XState's pure `initialTransition` helper to compute the machine's initial
|
|
6
|
+
* snapshot — resolving the full initial state chain (including nested compound
|
|
7
|
+
* states) and the real initial context for the given `input` — without creating
|
|
8
|
+
* an actor and without executing entry actions.
|
|
9
|
+
*
|
|
10
|
+
* Route resolution follows the same rules as {@link deriveCurrentRoute} for live
|
|
11
|
+
* snapshots: the deepest routed state wins, relative `meta.route` segments resolve
|
|
12
|
+
* against routed ancestors, and `:param` placeholders substitute from the initial
|
|
13
|
+
* `context.params`.
|
|
14
|
+
*
|
|
15
|
+
* Router bridges compare the resulting value against the browser URL to distinguish
|
|
16
|
+
* a deep-link (non-initial URL → router wins) from a restore (initial URL + actor at
|
|
17
|
+
* a different restored route → actor wins). Because the derivation never consults a
|
|
18
|
+
* restored snapshot, it always yields the machine's **default** initial route.
|
|
19
|
+
*
|
|
20
|
+
* @param machine - XState v5 state machine definition.
|
|
21
|
+
* @param input - Actor input, applied to the machine's context factory exactly as
|
|
22
|
+
* `createActor(machine, { input })` would.
|
|
23
|
+
* @returns Resolved initial URL string, or `null` if the initial state has no
|
|
24
|
+
* `meta.route`, a required `:param` is absent from the initial context, or the
|
|
25
|
+
* machine's context/initial-transition logic throws for the given input (mirroring
|
|
26
|
+
* `createActor`'s error-status snapshot, which has no derivable route either).
|
|
27
|
+
*
|
|
28
|
+
* @throws {MissingQueryContextError} When the initial context declares `params` but
|
|
29
|
+
* no `query` field — a structural programmer error that must surface immediately.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const machine = setup({}).createMachine({
|
|
34
|
+
* context: ({ input }) => ({ params: { username: input.username }, query: {} }),
|
|
35
|
+
* initial: "profile",
|
|
36
|
+
* states: { profile: { meta: { route: "/profile/:username" } } },
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* deriveInitialRoute(machine, { username: "alice" }); // "/profile/alice"
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare const deriveInitialRoute: (machine: AnyStateMachine, input?: unknown) => string | null;
|
|
43
|
+
//# sourceMappingURL=derive-initial-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-initial-route.d.ts","sourceRoot":"","sources":["../../src/routing/derive-initial-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AAI1F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,eAAe,EAAE,QAAQ,OAAO,KAAG,MAAM,GAAG,IAavF,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { initialTransition } from "xstate";
|
|
2
|
+
import { deriveCurrentRoute } from "./derive-current-route.js";
|
|
3
|
+
/**
|
|
4
|
+
* Derive the machine's initial route directly from the machine definition.
|
|
5
|
+
*
|
|
6
|
+
* Uses XState's pure `initialTransition` helper to compute the machine's initial
|
|
7
|
+
* snapshot — resolving the full initial state chain (including nested compound
|
|
8
|
+
* states) and the real initial context for the given `input` — without creating
|
|
9
|
+
* an actor and without executing entry actions.
|
|
10
|
+
*
|
|
11
|
+
* Route resolution follows the same rules as {@link deriveCurrentRoute} for live
|
|
12
|
+
* snapshots: the deepest routed state wins, relative `meta.route` segments resolve
|
|
13
|
+
* against routed ancestors, and `:param` placeholders substitute from the initial
|
|
14
|
+
* `context.params`.
|
|
15
|
+
*
|
|
16
|
+
* Router bridges compare the resulting value against the browser URL to distinguish
|
|
17
|
+
* a deep-link (non-initial URL → router wins) from a restore (initial URL + actor at
|
|
18
|
+
* a different restored route → actor wins). Because the derivation never consults a
|
|
19
|
+
* restored snapshot, it always yields the machine's **default** initial route.
|
|
20
|
+
*
|
|
21
|
+
* @param machine - XState v5 state machine definition.
|
|
22
|
+
* @param input - Actor input, applied to the machine's context factory exactly as
|
|
23
|
+
* `createActor(machine, { input })` would.
|
|
24
|
+
* @returns Resolved initial URL string, or `null` if the initial state has no
|
|
25
|
+
* `meta.route`, a required `:param` is absent from the initial context, or the
|
|
26
|
+
* machine's context/initial-transition logic throws for the given input (mirroring
|
|
27
|
+
* `createActor`'s error-status snapshot, which has no derivable route either).
|
|
28
|
+
*
|
|
29
|
+
* @throws {MissingQueryContextError} When the initial context declares `params` but
|
|
30
|
+
* no `query` field — a structural programmer error that must surface immediately.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const machine = setup({}).createMachine({
|
|
35
|
+
* context: ({ input }) => ({ params: { username: input.username }, query: {} }),
|
|
36
|
+
* initial: "profile",
|
|
37
|
+
* states: { profile: { meta: { route: "/profile/:username" } } },
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* deriveInitialRoute(machine, { username: "alice" }); // "/profile/alice"
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export const deriveInitialRoute = (machine, input) => {
|
|
44
|
+
let initialSnapshot;
|
|
45
|
+
try {
|
|
46
|
+
[initialSnapshot] = initialTransition(machine, input);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Context factory or initial-transition logic threw for this input (e.g. a
|
|
50
|
+
// factory reading a required `input` field when none was provided). This is
|
|
51
|
+
// the pure-helper equivalent of createActor's error-status snapshot, which
|
|
52
|
+
// has no route metadata either — report "no derivable initial route".
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return deriveCurrentRoute(initialSnapshot);
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=derive-initial-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-initial-route.js","sourceRoot":"","sources":["../../src/routing/derive-initial-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiD,MAAM,QAAQ,CAAC;AAE1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAwB,EAAE,KAAe,EAAiB,EAAE;IAC9F,IAAI,eAAmC,CAAC;IACxC,IAAI,CAAC;QACJ,CAAC,eAAe,CAAC,GAAG,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;IAAC,MAAM,CAAC;QACR,2EAA2E;QAC3E,4EAA4E;QAC5E,2EAA2E;QAC3E,sEAAsE;QACtE,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,kBAAkB,CAAC,eAAe,CAAC,CAAC;AAC5C,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RouteMetadata } from "./types.js";
|
|
1
2
|
/**
|
|
2
3
|
* Derive route from XState state metadata
|
|
3
4
|
*
|
|
@@ -72,7 +73,7 @@
|
|
|
72
73
|
* console.log(route); // "/dashboard"
|
|
73
74
|
* ```
|
|
74
75
|
*
|
|
75
|
-
* @see
|
|
76
|
+
* @see [Play RFC](../../../docs/rfc/play.md)
|
|
76
77
|
* @see {@link buildRouteUrl} for URL construction with parameter substitution
|
|
77
78
|
* @see {@link isAbsoluteRoute} for checking path absoluteness
|
|
78
79
|
*
|
|
@@ -86,6 +87,19 @@
|
|
|
86
87
|
* not correspond to distinct URLs.
|
|
87
88
|
*/
|
|
88
89
|
export declare const deriveRoute: (stateMeta: Record<string, unknown>) => string | null;
|
|
90
|
+
/**
|
|
91
|
+
* Normalize route metadata to string path
|
|
92
|
+
*
|
|
93
|
+
* Handles both string and object formats for route definitions, ensuring consistent
|
|
94
|
+
* string output for URL construction.
|
|
95
|
+
*
|
|
96
|
+
* @param route - Route metadata (string or object with path property)
|
|
97
|
+
* @param source - `PlayError.scope` to report when the metadata is invalid
|
|
98
|
+
* (defaults to `"deriveRoute"`)
|
|
99
|
+
* @returns Normalized route path string
|
|
100
|
+
* @throws {InvalidRouteMetadataError} If route format is invalid
|
|
101
|
+
*/
|
|
102
|
+
export declare const normalizeRoute: (route: RouteMetadata, source?: string) => string;
|
|
89
103
|
/**
|
|
90
104
|
* Check if route path is absolute
|
|
91
105
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive-route.d.ts","sourceRoot":"","sources":["../../src/routing/derive-route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"derive-route.d.ts","sourceRoot":"","sources":["../../src/routing/derive-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,YAAY,CAAC;AAG7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFG;AACH,eAAO,MAAM,WAAW,GAAI,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MAAM,GAAG,IAqBzE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,aAAa,EAAE,eAAsB,KAAG,MAW7E,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,OAE9C,CAAC"}
|