@xmachines/play-xstate 2.0.0 → 2.1.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 (56) hide show
  1. package/README.md +66 -65
  2. package/dist/define-player.d.ts +16 -16
  3. package/dist/define-player.js +16 -16
  4. package/dist/errors.d.ts +57 -50
  5. package/dist/errors.d.ts.map +1 -1
  6. package/dist/errors.js +63 -55
  7. package/dist/errors.js.map +1 -1
  8. package/dist/guards/compose.d.ts +53 -50
  9. package/dist/guards/compose.d.ts.map +1 -1
  10. package/dist/guards/compose.js +67 -63
  11. package/dist/guards/compose.js.map +1 -1
  12. package/dist/guards/helpers.d.ts +22 -22
  13. package/dist/guards/helpers.js +23 -23
  14. package/dist/guards/index.d.ts +9 -9
  15. package/dist/guards/index.js +9 -9
  16. package/dist/guards/types.d.ts +9 -8
  17. package/dist/guards/types.d.ts.map +1 -1
  18. package/dist/index.d.ts +6 -5
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +8 -7
  21. package/dist/index.js.map +1 -1
  22. package/dist/player-actor.d.ts +162 -146
  23. package/dist/player-actor.d.ts.map +1 -1
  24. package/dist/player-actor.js +269 -241
  25. package/dist/player-actor.js.map +1 -1
  26. package/dist/routing/build-url.d.ts +19 -16
  27. package/dist/routing/build-url.d.ts.map +1 -1
  28. package/dist/routing/build-url.js +62 -59
  29. package/dist/routing/build-url.js.map +1 -1
  30. package/dist/routing/derive-current-route.d.ts +42 -36
  31. package/dist/routing/derive-current-route.d.ts.map +1 -1
  32. package/dist/routing/derive-current-route.js +57 -49
  33. package/dist/routing/derive-current-route.js.map +1 -1
  34. package/dist/routing/derive-initial-route.d.ts +23 -20
  35. package/dist/routing/derive-initial-route.d.ts.map +1 -1
  36. package/dist/routing/derive-initial-route.js +27 -24
  37. package/dist/routing/derive-initial-route.js.map +1 -1
  38. package/dist/routing/derive-route.d.ts +38 -37
  39. package/dist/routing/derive-route.d.ts.map +1 -1
  40. package/dist/routing/derive-route.js +45 -42
  41. package/dist/routing/derive-route.js.map +1 -1
  42. package/dist/routing/format-play-route-transitions.d.ts +34 -28
  43. package/dist/routing/format-play-route-transitions.d.ts.map +1 -1
  44. package/dist/routing/format-play-route-transitions.js +32 -28
  45. package/dist/routing/format-play-route-transitions.js.map +1 -1
  46. package/dist/routing/index.d.ts +3 -3
  47. package/dist/routing/index.js +3 -3
  48. package/dist/routing/types.d.ts +12 -11
  49. package/dist/routing/types.d.ts.map +1 -1
  50. package/dist/types.d.ts +64 -60
  51. package/dist/types.d.ts.map +1 -1
  52. package/dist/view/derive-current-view.d.ts +42 -40
  53. package/dist/view/derive-current-view.d.ts.map +1 -1
  54. package/dist/view/derive-current-view.js +51 -47
  55. package/dist/view/derive-current-view.js.map +1 -1
  56. package/package.json +7 -6
@@ -1 +1 @@
1
- {"version":3,"file":"player-actor.js","sourceRoot":"","sources":["../src/player-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,GAYL,MAAM,QAAQ,CAAC;AAChB,OAAO,EACN,aAAa,EACb,kBAAkB,EAClB,kBAAkB,GAIlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE9F,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE;;;;;;GAMG;AACH,MAAM,WAAW,GAAG,CAAC,KAAc,EAAkB,EAAE;IACtD,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,IAAI,CAAC;IACxC,MAAM,OAAO,GAAI,KAA0D,CAAC,OAAO,CAAC;IACpF,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,OAAO,MAAM,CAAC,SAAS,CAAC,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1
  import type { RouteContext } from "./types.js";
2
2
  /**
3
- * Build a full URL from a route template and the actor's context.
3
+ * Builds a complete URL from a route template and the context of the actor.
4
4
  *
5
- * Substitutes `:param` and `:param?` placeholders from `context.params`,
6
- * then appends query params and hash fragments.
5
+ * The function replaces each `:param` placeholder and each `:param?` placeholder
6
+ * with a value of `context.params`. It then appends the query params and the hash
7
+ * fragment.
7
8
  *
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`.
9
+ * Every parameter value must be in `context.params`. The function reads no flat
10
+ * context field, and this is deliberate: a placeholder with a spelling error
11
+ * therefore gives a compile-time error, and it does not resolve to `undefined` in
12
+ * silence.
11
13
  *
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. A missing `query` field builds a
16
- * query-less URL, exactly like `query: {}`.
17
- * @returns The fully resolved URL string.
14
+ * @param routeTemplate - The template of the route path, for example
15
+ * `"/profile/:userId"` or `"/settings/:section?"`.
16
+ * @param context - The context object of the actor. Each route parameter must be in
17
+ * `context.params`, because the function reads no flat context field. An absent
18
+ * `query` field builds a URL without a query, exactly like `query: {}`.
19
+ * @returns The complete URL string.
18
20
  *
19
- * @throws {MissingRouteParamError} When a **required** `:param` placeholder has no
20
- * matching value in context. Optional parameters (`:param?`) are silently omitted
21
- * when missing. Import the class from `@xmachines/play-xstate/errors`.
21
+ * @throws {MissingRouteParamError} When a **necessary** `:param` placeholder has no
22
+ * value in the context. The function omits an optional parameter (`:param?`) in
23
+ * silence when its value is absent. Import the class from
24
+ * `@xmachines/play-xstate/errors`.
22
25
  *
23
26
  * @example
24
27
  * ```typescript
@@ -26,7 +29,7 @@ import type { RouteContext } from "./types.js";
26
29
  * // → "/user/123?tab=profile#top"
27
30
  *
28
31
  * buildRouteUrl("/settings/:section?", { params: {}, query: {} });
29
- * // → "/settings" (optional param omitted, no query string)
32
+ * // → "/settings" (the optional param is absent, and there is no query string)
30
33
  * ```
31
34
  */
32
35
  export declare const buildRouteUrl: (routeTemplate: string, context?: RouteContext) => string;
@@ -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;AAI/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,aAAa,GACzB,eAAe,MAAM,EACrB,UAAS,YAA4B,KACnC,MAwCF,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,aAAa,GACzB,eAAe,MAAM,EACrB,UAAS,YAA4B,KACnC,MAwCF,CAAC"}
@@ -1,25 +1,28 @@
1
1
  import { isAbsoluteRoute } from "./derive-route.js";
2
2
  import { MissingRouteParamError } from "../errors.js";
3
3
  /**
4
- * Build a full URL from a route template and the actor's context.
4
+ * Builds a complete URL from a route template and the context of the actor.
5
5
  *
6
- * Substitutes `:param` and `:param?` placeholders from `context.params`,
7
- * then appends query params and hash fragments.
6
+ * The function replaces each `:param` placeholder and each `:param?` placeholder
7
+ * with a value of `context.params`. It then appends the query params and the hash
8
+ * fragment.
8
9
  *
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`.
10
+ * Every parameter value must be in `context.params`. The function reads no flat
11
+ * context field, and this is deliberate: a placeholder with a spelling error
12
+ * therefore gives a compile-time error, and it does not resolve to `undefined` in
13
+ * silence.
12
14
  *
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. A missing `query` field builds a
17
- * query-less URL, exactly like `query: {}`.
18
- * @returns The fully resolved URL string.
15
+ * @param routeTemplate - The template of the route path, for example
16
+ * `"/profile/:userId"` or `"/settings/:section?"`.
17
+ * @param context - The context object of the actor. Each route parameter must be in
18
+ * `context.params`, because the function reads no flat context field. An absent
19
+ * `query` field builds a URL without a query, exactly like `query: {}`.
20
+ * @returns The complete URL string.
19
21
  *
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`.
22
+ * @throws {MissingRouteParamError} When a **necessary** `:param` placeholder has no
23
+ * value in the context. The function omits an optional parameter (`:param?`) in
24
+ * silence when its value is absent. Import the class from
25
+ * `@xmachines/play-xstate/errors`.
23
26
  *
24
27
  * @example
25
28
  * ```typescript
@@ -27,26 +30,26 @@ import { MissingRouteParamError } from "../errors.js";
27
30
  * // → "/user/123?tab=profile#top"
28
31
  *
29
32
  * buildRouteUrl("/settings/:section?", { params: {}, query: {} });
30
- * // → "/settings" (optional param omitted, no query string)
33
+ * // → "/settings" (the optional param is absent, and there is no query string)
31
34
  * ```
32
35
  */
33
36
  export const buildRouteUrl = (routeTemplate, context = { query: {} }) => {
34
- // A context without a `query` field builds a query-less URL, the same way a
35
- // missing context does. The generated play.route transitions assign `query`
36
- // on every navigation regardless of the initial context shape, so there is
37
- // no query-loss here for a throw to prevent machines that handle
38
- // play.route by hand and want query forwarding must assign event.query to
39
- // context themselves.
40
- // Handle relative vs absolute paths
37
+ // A context without a `query` field builds a URL without a query, in the same way
38
+ // as an absent context. The generated play.route transitions assign `query` on
39
+ // every navigation, and the shape of the initial context has no effect on that.
40
+ // Therefore no query goes away here, and a throw prevents nothing. A machine that
41
+ // handles play.route itself and wants the query must assign event.query to its
42
+ // context itself.
43
+ // Handle a relative path and an absolute path
41
44
  const basePath = context.basePath || "";
42
45
  const isAbsolute = isAbsoluteRoute(routeTemplate);
43
- // Build base URL
46
+ // Build the base URL
44
47
  let url = isAbsolute ? routeTemplate : joinPaths(basePath, routeTemplate);
45
- // Replace :param with context values
48
+ // Replace each :param with a context value
46
49
  url = substituteParams(url, context);
47
- // Append query params from context. The ubiquitous empty `query: {}` gets
48
- // the key check so the per-recompute URLSearchParams allocation is only
49
- // paid when there is something to serialize.
50
+ // Append the query params of the context. The frequent empty `query: {}` passes the
51
+ // key check first. Therefore each recomputation allocates a URLSearchParams object
52
+ // only when it has something to write.
50
53
  if (context.query && typeof context.query === "object") {
51
54
  const queryEntries = Object.entries(context.query);
52
55
  if (queryEntries.length > 0) {
@@ -57,75 +60,75 @@ export const buildRouteUrl = (routeTemplate, context = { query: {} }) => {
57
60
  }
58
61
  }
59
62
  }
60
- // Append hash from context
63
+ // Append the hash of the context
61
64
  if (context.hash && typeof context.hash === "string") {
62
65
  url += `#${context.hash}`;
63
66
  }
64
67
  return url;
65
68
  };
66
69
  /**
67
- * Substitute `:param` placeholders with `encodeURIComponent`-escaped context
68
- * values.
70
+ * Replaces each `:param` placeholder with a context value, and it escapes that
71
+ * value with `encodeURIComponent`.
69
72
  *
70
- * Supports optional parameters with :param? syntax.
71
- * - Optional parameters without values are removed entirely (including the /)
72
- * - Required parameters without values log warnings
73
+ * The function supports an optional parameter, in the form :param?.
74
+ * - It removes an optional parameter without a value completely, and it also removes the /
75
+ * - It writes a warning for a necessary parameter without a value
73
76
  *
74
- * Parameter lookup:
75
- * - Reads from context.params[param] exclusively. Flat context fields are not inspected.
77
+ * The lookup of a parameter:
78
+ * - The function reads context.params[param] only. It reads no flat context field.
76
79
  *
77
- * @param template - URL template with :param or :param? syntax
78
- * @param context - Context with parameter values (may have params field)
79
- * @returns URL with parameters substituted and double slashes cleaned
80
- * @throws {MissingRouteParamError} When a required route parameter is missing
80
+ * @param template - The URL template, with the :param or :param? syntax
81
+ * @param context - The context with the parameter values. It can have a params field
82
+ * @returns The URL with the parameters in place, and without a double slash
83
+ * @throws {MissingRouteParamError} When a necessary route parameter is absent
81
84
  */
82
85
  const substituteParams = (template, context) => {
83
- // Replace parameters, handling optional syntax
86
+ // Replace each parameter, and handle the optional syntax
84
87
  let hasOptionalRemoval = false;
85
88
  const result = template.replace(/:(\w+)(\?)?/g, (_match, param, optional) => {
86
89
  const value = context.params?.[param]; // nosemgrep: gitlab.eslint.detect-object-injection
87
- // Parameter has a non-empty value - substitute it
88
- // For optional params, treat empty string as "no value"
90
+ // The parameter has a value that is not empty: put it in place.
91
+ // For an optional param, an empty string means "no value".
89
92
  if (value !== undefined && value !== null && value !== "") {
90
93
  return encodeURIComponent(String(value));
91
94
  }
92
- // Optional parameter without value (or empty string) - remove the segment
95
+ // An optional parameter without a value, or with an empty string: remove the segment
93
96
  if (optional === "?") {
94
97
  hasOptionalRemoval = true;
95
- return ""; // Will leave // in path, cleaned up below
98
+ return ""; // This leaves // in the path. The code below removes it
96
99
  }
97
100
  throw new MissingRouteParamError(param, template);
98
101
  });
99
- // Clean up double slashes
102
+ // Remove each double slash
100
103
  let cleaned = result.replace(/\/+/g, "/");
101
- // Only remove trailing slash if we removed optional parameters
102
- // (preserves trailing slash for required params, which indicates an error)
104
+ // Remove a trailing slash only after the code removed an optional parameter.
105
+ // A trailing slash of a necessary param stays, because it shows an error.
103
106
  if (hasOptionalRemoval && cleaned.endsWith("/")) {
104
107
  cleaned = cleaned.slice(0, -1);
105
108
  }
106
- // Never return an empty path: a root-level template of only optional params
107
- // (e.g. "/:section?") collapses to "" after the trailing-slash trim, which
108
- // would produce invalid URLs like "" or "?tab=x". Normalize to "/".
109
+ // Return an empty path never: a template of the root level with optional params
110
+ // only, for example "/:section?", becomes "" after the trim of the trailing slash.
111
+ // That value makes an invalid URL, such as "" or "?tab=x". Normalize it to "/".
109
112
  if (cleaned === "") {
110
113
  cleaned = "/";
111
114
  }
112
115
  return cleaned;
113
116
  };
114
117
  /**
115
- * Join base path and relative path
118
+ * Joins a base path and a relative path
116
119
  *
117
- * Ensures single slash between paths
120
+ * The function puts one slash between the two paths
118
121
  *
119
- * @param base - Base path
120
- * @param relative - Relative path
121
- * @returns Joined path
122
+ * @param base - The base path
123
+ * @param relative - The relative path
124
+ * @returns The joined path
122
125
  */
123
126
  const joinPaths = (base, relative) => {
124
- // Remove trailing slash from base
127
+ // Remove the trailing slash of the base
125
128
  const normalizedBase = base.replace(/\/$/, "");
126
- // Remove leading slash from relative
129
+ // Remove the first slash of the relative path
127
130
  const normalizedRelative = relative.replace(/^\//, "");
128
- // Join with single slash
131
+ // Join the two paths with one slash
129
132
  return normalizedBase ? `${normalizedBase}/${normalizedRelative}` : `/${normalizedRelative}`;
130
133
  };
131
134
  //# sourceMappingURL=build-url.js.map
@@ -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;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC5B,aAAqB,EACrB,UAAwB,EAAE,KAAK,EAAE,EAAE,EAAE,EAC5B,EAAE;IACX,4EAA4E;IAC5E,4EAA4E;IAC5E,2EAA2E;IAC3E,mEAAmE;IACnE,0EAA0E;IAC1E,sBAAsB;IAEtB,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,CA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AAM,EAAE,GAAG,CAAC,CAAC;IAE1C,6EAA6E;IAC7E,0EAA0E;IAC1E,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,gFAAgF;IAChF,mFAAmF;IACnF,gFAAgF;IAChF,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,wCAAwC;IACxC,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAE/C,8CAA8C;IAC9C,MAAM,kBAAkB,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAEvD,oCAAoC;IACpC,OAAO,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,IAAI,kBAAkB,EAAE,CAAC,CAAC,CAAC,IAAI,kBAAkB,EAAE,CAAC;AAC9F,CAAC,CAAC"}
@@ -1,54 +1,60 @@
1
1
  import type { AnyMachineSnapshot } from "xstate";
2
2
  /**
3
- * Collect the `meta` of the active state nodes along a SINGLE root-to-leaf branch,
4
- * keyed by state id and ordered ancestors-first the shape {@link deriveRoute} folds.
3
+ * Collects the `meta` object of the active state nodes of a SINGLE branch, from the
4
+ * root to a leaf. The key of each entry is the state id, and the order is the
5
+ * ancestors first. {@link deriveRoute} folds this shape.
5
6
  *
6
- * `snapshot.getMeta()` returns a FLAT record of every active state's meta. For a
7
- * non-parallel machine that record is already a single ancestor chain, but for a
8
- * PARALLEL machine it interleaves entries from every active region, so folding it
9
- * blindly would concatenate a relative route from one region onto an absolute route
10
- * from a sibling region (a URL belonging to neither region's tree). The flat record
11
- * also cannot be re-ordered back into a hierarchy: when states declare an explicit
12
- * `id` (e.g. a child `id: "dashboard-overview"` under `id: "dashboard"`), the meta
13
- * keys are those ids and carry no ancestry information.
7
+ * `snapshot.getMeta()` returns a FLAT record of the meta object of every active
8
+ * state. For a machine that is not parallel, that record is one chain of ancestors
9
+ * already. For a PARALLEL machine, it mixes the entries of every active region. A
10
+ * blind fold therefore joins a relative route of one region to an absolute route of
11
+ * a sibling region, and the URL belongs to the tree of neither region. The flat
12
+ * record also cannot go back into a hierarchy: when a state declares an explicit
13
+ * `id`, for example a child with `id: "dashboard-overview"` under `id: "dashboard"`,
14
+ * the meta keys are those ids, and they carry no information about the ancestry.
14
15
  *
15
- * We therefore walk `snapshot.value` (which encodes the true active-state hierarchy
16
- * by state key) against the machine's node tree, following the FIRST active child at
17
- * each level. This yields one deterministic branch — matching the historical
18
- * first-found behaviour for parallel machines and works regardless of explicit ids
19
- * because each node carries its own `id` and `meta`.
16
+ * Therefore this function walks `snapshot.value`, which holds the real hierarchy of
17
+ * the active states by the state key, against the node tree of the machine. It
18
+ * follows the FIRST active child at each level. This gives one deterministic branch,
19
+ * which matches the historical behavior of "the first that it finds" for a parallel
20
+ * machine. It also works with an explicit id, because each node carries its own `id`
21
+ * and its own `meta`.
20
22
  *
21
- * Falls back to `null` when the snapshot does not expose a navigable machine/value
22
- * (defensive real XState snapshots always do); callers then use `getMeta()` as before.
23
+ * The function returns `null` when the snapshot exposes no machine and no value to
24
+ * walk. This is a defensive measure, because a real XState snapshot always exposes
25
+ * them. The caller then uses `getMeta()`, as before.
23
26
  */
24
27
  export declare const firstActiveBranchMeta: (snapshot: AnyMachineSnapshot) => Record<string, unknown> | null;
25
28
  /**
26
- * Resolve the meta record route and view derivation fold: the single active
27
- * branch {@link firstActiveBranchMeta} walks (correct for parallel machines
28
- * and explicit ids), or the flat `getMeta()` record when the snapshot lacks a
29
- * navigable machine tree. Shared by `deriveCurrentRoute` and
30
- * `deriveCurrentView` so the two sides cannot drift apart on branch selection
31
- * or on tolerating degenerate snapshots.
29
+ * Resolves the meta record that the route derivation and the view derivation fold:
30
+ * the single active branch that {@link firstActiveBranchMeta} walks, which is
31
+ * correct for a parallel machine and for an explicit id, or the flat `getMeta()`
32
+ * record when the snapshot has no machine tree to walk. `deriveCurrentRoute` and
33
+ * `deriveCurrentView` share this function. Therefore the two sides cannot move apart
34
+ * on the selection of the branch, and they cannot move apart on their tolerance of a
35
+ * degenerate snapshot.
32
36
  */
33
37
  export declare const activeStateMeta: (snapshot: AnyMachineSnapshot) => Record<string, unknown> | null;
34
38
  /**
35
- * Derive the actor's current URL from state metadata and context.
39
+ * Derives the current URL of the actor from the state metadata and the context.
36
40
  *
37
- * Resolves the route template from the current state's `meta.route` and substitutes
38
- * any `:param` placeholders from `context.params` (preferred) or flat `context`.
41
+ * The function resolves the route template from the `meta.route` field of the
42
+ * current state. It then replaces each `:param` placeholder with a value of
43
+ * `context.params`, which it prefers, or of the flat `context` object.
39
44
  *
40
- * Returns `null` rather than throwing when:
41
- * - The snapshot has no route metadata (non-routable state)
42
- * - A required route parameter is absent from context (`MissingRouteParamError`)
45
+ * The function returns `null`, and it throws no error, in two cases:
46
+ * - The snapshot has no route metadata, which means a state without a route
47
+ * - The context does not hold a necessary route parameter (`MissingRouteParamError`)
43
48
  *
44
- * The `null` return on missing params is intentional: it keeps the computed signal
45
- * stable during transient states (e.g. mid-transition before context is fully updated,
46
- * or after logout when `context.username` is `null` but the router bridge has not yet
47
- * synced to the new state). The router bridge and URL bar are updated on the next
48
- * stable snapshot once context is complete.
49
+ * The `null` value for an absent param is deliberate: the computed signal therefore
50
+ * stays stable during a temporary state. Such a state appears during a transition,
51
+ * before the context is complete, and also after a logout, when `context.username`
52
+ * is `null` and the router bridge did not reach the new state yet. The router bridge
53
+ * and the URL bar receive the new value on the next stable snapshot, when the
54
+ * context is complete.
49
55
  *
50
- * @param snapshot - Current XState machine snapshot.
51
- * @returns Resolved URL string, or `null` if the route cannot be resolved.
56
+ * @param snapshot - The current snapshot of the XState machine.
57
+ * @returns The resolved URL string, or `null` when the function cannot resolve the route.
52
58
  */
53
59
  export declare const deriveCurrentRoute: (snapshot: AnyMachineSnapshot) => string | null;
54
60
  //# sourceMappingURL=derive-current-route.d.ts.map
@@ -1 +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;AAOjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,qBAAqB,GACjC,UAAU,kBAAkB,KAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAoC5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,kBAAkB,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAMxF,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,kBAAkB,KAAG,MAAM,GAAG,IA6B1E,CAAC"}
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;AAOjD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,qBAAqB,GACjC,UAAU,kBAAkB,KAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAqC5B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,kBAAkB,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAMxF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,kBAAkB,KAAG,MAAM,GAAG,IA8B1E,CAAC"}
@@ -2,26 +2,29 @@ import { MissingRouteParamError } from "../errors.js";
2
2
  import { deriveRoute } from "./derive-route.js";
3
3
  import { buildRouteUrl } from "./build-url.js";
4
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.
5
+ * Collects the `meta` object of the active state nodes of a SINGLE branch, from the
6
+ * root to a leaf. The key of each entry is the state id, and the order is the
7
+ * ancestors first. {@link deriveRoute} folds this shape.
7
8
  *
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.
9
+ * `snapshot.getMeta()` returns a FLAT record of the meta object of every active
10
+ * state. For a machine that is not parallel, that record is one chain of ancestors
11
+ * already. For a PARALLEL machine, it mixes the entries of every active region. A
12
+ * blind fold therefore joins a relative route of one region to an absolute route of
13
+ * a sibling region, and the URL belongs to the tree of neither region. The flat
14
+ * record also cannot go back into a hierarchy: when a state declares an explicit
15
+ * `id`, for example a child with `id: "dashboard-overview"` under `id: "dashboard"`,
16
+ * the meta keys are those ids, and they carry no information about the ancestry.
16
17
  *
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`.
18
+ * Therefore this function walks `snapshot.value`, which holds the real hierarchy of
19
+ * the active states by the state key, against the node tree of the machine. It
20
+ * follows the FIRST active child at each level. This gives one deterministic branch,
21
+ * which matches the historical behavior of "the first that it finds" for a parallel
22
+ * machine. It also works with an explicit id, because each node carries its own `id`
23
+ * and its own `meta`.
22
24
  *
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
+ * The function returns `null` when the snapshot exposes no machine and no value to
26
+ * walk. This is a defensive measure, because a real XState snapshot always exposes
27
+ * them. The caller then uses `getMeta()`, as before.
25
28
  */
26
29
  export const firstActiveBranchMeta = (snapshot) => {
27
30
  const root = snapshot.machine?.root;
@@ -34,9 +37,10 @@ export const firstActiveBranchMeta = (snapshot) => {
34
37
  if (node.meta && typeof node.meta === "object") {
35
38
  ordered[node.id] = node.meta; // nosemgrep: gitlab.eslint.detect-object-injection
36
39
  }
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
+ // Find the key of the active child at this level. A string value is the name of an
41
+ // atomic active leaf. An object value is a compound node, with one key, or a
42
+ // parallel node, with many keys: take the first key, for one deterministic
43
+ // branch.
40
44
  let key;
41
45
  if (typeof value === "string") {
42
46
  key = value;
@@ -58,12 +62,13 @@ export const firstActiveBranchMeta = (snapshot) => {
58
62
  return ordered;
59
63
  };
60
64
  /**
61
- * Resolve the meta record route and view derivation fold: the single active
62
- * branch {@link firstActiveBranchMeta} walks (correct for parallel machines
63
- * and explicit ids), or the flat `getMeta()` record when the snapshot lacks a
64
- * navigable machine tree. Shared by `deriveCurrentRoute` and
65
- * `deriveCurrentView` so the two sides cannot drift apart on branch selection
66
- * or on tolerating degenerate snapshots.
65
+ * Resolves the meta record that the route derivation and the view derivation fold:
66
+ * the single active branch that {@link firstActiveBranchMeta} walks, which is
67
+ * correct for a parallel machine and for an explicit id, or the flat `getMeta()`
68
+ * record when the snapshot has no machine tree to walk. `deriveCurrentRoute` and
69
+ * `deriveCurrentView` share this function. Therefore the two sides cannot move apart
70
+ * on the selection of the branch, and they cannot move apart on their tolerance of a
71
+ * degenerate snapshot.
67
72
  */
68
73
  export const activeStateMeta = (snapshot) => {
69
74
  if (!snapshot || typeof snapshot.getMeta !== "function") {
@@ -73,23 +78,25 @@ export const activeStateMeta = (snapshot) => {
73
78
  return meta && typeof meta === "object" ? meta : null;
74
79
  };
75
80
  /**
76
- * Derive the actor's current URL from state metadata and context.
81
+ * Derives the current URL of the actor from the state metadata and the context.
77
82
  *
78
- * Resolves the route template from the current state's `meta.route` and substitutes
79
- * any `:param` placeholders from `context.params` (preferred) or flat `context`.
83
+ * The function resolves the route template from the `meta.route` field of the
84
+ * current state. It then replaces each `:param` placeholder with a value of
85
+ * `context.params`, which it prefers, or of the flat `context` object.
80
86
  *
81
- * Returns `null` rather than throwing when:
82
- * - The snapshot has no route metadata (non-routable state)
83
- * - A required route parameter is absent from context (`MissingRouteParamError`)
87
+ * The function returns `null`, and it throws no error, in two cases:
88
+ * - The snapshot has no route metadata, which means a state without a route
89
+ * - The context does not hold a necessary route parameter (`MissingRouteParamError`)
84
90
  *
85
- * The `null` return on missing params is intentional: it keeps the computed signal
86
- * stable during transient states (e.g. mid-transition before context is fully updated,
87
- * or after logout when `context.username` is `null` but the router bridge has not yet
88
- * synced to the new state). The router bridge and URL bar are updated on the next
89
- * stable snapshot once context is complete.
91
+ * The `null` value for an absent param is deliberate: the computed signal therefore
92
+ * stays stable during a temporary state. Such a state appears during a transition,
93
+ * before the context is complete, and also after a logout, when `context.username`
94
+ * is `null` and the router bridge did not reach the new state yet. The router bridge
95
+ * and the URL bar receive the new value on the next stable snapshot, when the
96
+ * context is complete.
90
97
  *
91
- * @param snapshot - Current XState machine snapshot.
92
- * @returns Resolved URL string, or `null` if the route cannot be resolved.
98
+ * @param snapshot - The current snapshot of the XState machine.
99
+ * @returns The resolved URL string, or `null` when the function cannot resolve the route.
93
100
  */
94
101
  export const deriveCurrentRoute = (snapshot) => {
95
102
  const meta = activeStateMeta(snapshot);
@@ -104,19 +111,20 @@ export const deriveCurrentRoute = (snapshot) => {
104
111
  return buildRouteUrl(routeTemplate, (snapshot.context ?? {}));
105
112
  }
106
113
  catch (error) {
107
- // MissingRouteParamError: transient and self-resolving a required `:param` is absent
108
- // from context during a mid-transition state (e.g. actor in profile state before the
109
- // first play.route event populates context.params, or after logout before the bridge
110
- // redirects). Returning null is correct:
111
- // - Router bridges handle null by skipping navigation (syncRouterFromActor line 242)
112
- // - The signal recomputes automatically on the next snapshot when params are populated
113
- // - Throwing would propagate into signal watchers as an unhandled exception for a
114
- // state that resolves itself worse than a one-tick null.
115
- // Do NOT convert this to a throw.
114
+ // MissingRouteParamError: the condition is temporary, and it resolves itself. A
115
+ // necessary `:param` is absent from the context during a state of a transition, for
116
+ // example an actor in the profile state before the first play.route event fills
117
+ // context.params, and also after a logout, before the bridge redirects. A `null`
118
+ // value is correct here:
119
+ // - a router bridge reads null and skips the navigation (syncRouterFromActor, line 242)
120
+ // - the signal computes its value again on the next snapshot, when the params arrive
121
+ // - a throw goes to each signal watcher as an unhandled exception, for a state
122
+ // that resolves itself. That is worse than a null value for one tick.
123
+ // Do NOT convert this into a throw.
116
124
  if (error instanceof MissingRouteParamError) {
117
125
  return null;
118
126
  }
119
- // Unexpected errors re-throw unchanged.
127
+ // Each unexpected error goes to the caller without a change.
120
128
  throw error;
121
129
  }
122
130
  };