@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InvalidRouteMetadataError } from "../errors.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,16 +87,28 @@
|
|
|
86
87
|
* not correspond to distinct URLs.
|
|
87
88
|
*/
|
|
88
89
|
export const deriveRoute = (stateMeta) => {
|
|
89
|
-
//
|
|
90
|
-
|
|
90
|
+
// snapshot.getMeta() orders keys ancestors-first. Fold routed entries top-down
|
|
91
|
+
// so the deepest active state's meta.route wins over an ancestor's, while a
|
|
92
|
+
// RELATIVE route resolves against its nearest routed ancestors — mirroring
|
|
93
|
+
// play-router's tree resolution (child fullPath = parent fullPath + "/" + path).
|
|
94
|
+
let resolved = null;
|
|
95
|
+
for (const meta of Object.values(stateMeta)) {
|
|
91
96
|
if (typeof meta !== "object" || meta === null)
|
|
92
97
|
continue;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
if (!("route" in meta) || !meta.route)
|
|
99
|
+
continue;
|
|
100
|
+
const route = normalizeRoute(meta.route);
|
|
101
|
+
if (typeof route !== "string" || route === "")
|
|
102
|
+
continue;
|
|
103
|
+
if (isAbsoluteRoute(route)) {
|
|
104
|
+
resolved = route;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
const base = resolved === null || resolved === "/" ? "" : resolved;
|
|
108
|
+
resolved = `${base}/${route}`;
|
|
96
109
|
}
|
|
97
110
|
}
|
|
98
|
-
return
|
|
111
|
+
return resolved;
|
|
99
112
|
};
|
|
100
113
|
/**
|
|
101
114
|
* Normalize route metadata to string path
|
|
@@ -104,10 +117,12 @@ export const deriveRoute = (stateMeta) => {
|
|
|
104
117
|
* string output for URL construction.
|
|
105
118
|
*
|
|
106
119
|
* @param route - Route metadata (string or object with path property)
|
|
120
|
+
* @param source - `PlayError.scope` to report when the metadata is invalid
|
|
121
|
+
* (defaults to `"deriveRoute"`)
|
|
107
122
|
* @returns Normalized route path string
|
|
108
|
-
* @throws {
|
|
123
|
+
* @throws {InvalidRouteMetadataError} If route format is invalid
|
|
109
124
|
*/
|
|
110
|
-
const normalizeRoute = (route) => {
|
|
125
|
+
export const normalizeRoute = (route, source = "deriveRoute") => {
|
|
111
126
|
if (typeof route === "string") {
|
|
112
127
|
return route;
|
|
113
128
|
}
|
|
@@ -115,7 +130,7 @@ const normalizeRoute = (route) => {
|
|
|
115
130
|
if (route && typeof route === "object" && "path" in route) {
|
|
116
131
|
return route.path;
|
|
117
132
|
}
|
|
118
|
-
throw new
|
|
133
|
+
throw new InvalidRouteMetadataError(route, source);
|
|
119
134
|
};
|
|
120
135
|
/**
|
|
121
136
|
* Check if route path is absolute
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive-route.js","sourceRoot":"","sources":["../../src/routing/derive-route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"derive-route.js","sourceRoot":"","sources":["../../src/routing/derive-route.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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KAAK,EAAE,CAAC;QAC3D,OAAQ,KAAqB,CAAC,IAAI,CAAC;IACpC,CAAC;IAED,MAAM,IAAI,yBAAyB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAW,EAAE;IACxD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC,CAAC"}
|
|
@@ -1,11 +1,38 @@
|
|
|
1
|
+
import type { RouteMetadata } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal structural shape of a single XState state node as read by
|
|
4
|
+
* `formatPlayRouteTransitions` when crawling the machine config.
|
|
5
|
+
*
|
|
6
|
+
* Only the fields the function actually inspects are typed here; all other
|
|
7
|
+
* state-node fields (e.g. `on`, `entry`, `after`) pass through unmodified via
|
|
8
|
+
* the index signature.
|
|
9
|
+
*/
|
|
1
10
|
export type RouteStateNode = {
|
|
11
|
+
/** Optional explicit state ID (e.g. `"home"`, `"settings"`). Used as the `#id` target in `play.route` events. */
|
|
2
12
|
id?: string;
|
|
13
|
+
/** State metadata — `meta.route` marks the state as routable. */
|
|
3
14
|
meta?: {
|
|
4
|
-
|
|
15
|
+
/**
|
|
16
|
+
* URL path template — string form (e.g. `"/profile/:username"`) or object
|
|
17
|
+
* form (`{ path, title }`), matching {@link RouteMetadata}.
|
|
18
|
+
*/
|
|
19
|
+
route?: RouteMetadata;
|
|
5
20
|
};
|
|
21
|
+
/** Nested child states, recursively crawled for additional route declarations. */
|
|
6
22
|
states?: Record<string, RouteStateNode>;
|
|
7
23
|
[key: string]: unknown;
|
|
8
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Minimal structural constraint for machine configs accepted by
|
|
27
|
+
* `formatPlayRouteTransitions`.
|
|
28
|
+
*
|
|
29
|
+
* This is intentionally loose so the function accepts both the bare `createMachine`
|
|
30
|
+
* config object and the stricter `setup().createMachine` config without requiring
|
|
31
|
+
* any type casts at the call site. The generic `T extends RouteMachineConfig`
|
|
32
|
+
* parameter on `formatPlayRouteTransitions` preserves the original concrete type
|
|
33
|
+
* through the transform, so the return value remains directly usable by
|
|
34
|
+
* `setup().createMachine()`.
|
|
35
|
+
*/
|
|
9
36
|
export type RouteMachineConfig = {
|
|
10
37
|
context?: unknown;
|
|
11
38
|
states?: Record<string, unknown> | undefined;
|
|
@@ -36,7 +63,7 @@ export type RouteMachineConfig = {
|
|
|
36
63
|
* This automatically generates play.route handlers at the root level that:
|
|
37
64
|
* - Match event.to against state IDs (e.g., event.to === "#home")
|
|
38
65
|
* - Target the appropriate state
|
|
39
|
-
* - Assign
|
|
66
|
+
* - Assign params and query from the event to context
|
|
40
67
|
*
|
|
41
68
|
* @param machineConfig - XState machine config (before createMachine). Must extend `RouteMachineConfig`.
|
|
42
69
|
* @returns The same machine config with auto-generated `play.route` handlers merged in, preserving the original type `T`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-play-route-transitions.d.ts","sourceRoot":"","sources":["../../src/routing/format-play-route-transitions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"format-play-route-transitions.d.ts","sourceRoot":"","sources":["../../src/routing/format-play-route-transitions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,iHAAiH;IACjH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,iEAAiE;IACjE,IAAI,CAAC,EAAE;QACN;;;WAGG;QACH,KAAK,CAAC,EAAE,aAAa,CAAC;KACtB,CAAC;IACF,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB,CAAC;AAaF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC7C,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACzC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,kBAAkB,EAAE,aAAa,EAAE,CAAC,GAAG,CAAC,CA0E5F"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { assign } from "xstate";
|
|
2
|
+
import { MissingStateIdError } from "../errors.js";
|
|
3
|
+
import { normalizeRoute } from "./derive-route.js";
|
|
2
4
|
/**
|
|
3
5
|
* Formats play.route transitions from declarative route configs
|
|
4
6
|
*
|
|
@@ -23,7 +25,7 @@ import { assign } from "xstate";
|
|
|
23
25
|
* This automatically generates play.route handlers at the root level that:
|
|
24
26
|
* - Match event.to against state IDs (e.g., event.to === "#home")
|
|
25
27
|
* - Target the appropriate state
|
|
26
|
-
* - Assign
|
|
28
|
+
* - Assign params and query from the event to context
|
|
27
29
|
*
|
|
28
30
|
* @param machineConfig - XState machine config (before createMachine). Must extend `RouteMachineConfig`.
|
|
29
31
|
* @returns The same machine config with auto-generated `play.route` handlers merged in, preserving the original type `T`.
|
|
@@ -33,21 +35,33 @@ export function formatPlayRouteTransitions(machineConfig) {
|
|
|
33
35
|
const collectRoutes = (states, parentPath = "") => {
|
|
34
36
|
Object.entries(states).forEach(([key, stateConfig]) => {
|
|
35
37
|
const node = stateConfig;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
// Build the full key-based path from the root for the transition target
|
|
39
|
+
// (XState targets use the state key hierarchy, not explicit IDs)
|
|
40
|
+
const statePath = parentPath ? `${parentPath}.${key}` : key;
|
|
41
|
+
// Validates the metadata (malformed object routes throw
|
|
42
|
+
// InvalidRouteMetadataError) and normalizes to the path string. Both
|
|
43
|
+
// the string form ("") and the object form ({ path: "" }) of an empty
|
|
44
|
+
// path mark the state non-routable.
|
|
45
|
+
const routePath = node.meta?.route === undefined
|
|
46
|
+
? ""
|
|
47
|
+
: normalizeRoute(node.meta.route, "formatPlayRouteTransitions");
|
|
48
|
+
if (routePath && !node.id) {
|
|
49
|
+
throw new MissingStateIdError(key, routePath);
|
|
50
|
+
}
|
|
51
|
+
if (routePath && node.id) {
|
|
38
52
|
const transition = {
|
|
39
|
-
target: `.${
|
|
53
|
+
target: `.${statePath}`,
|
|
40
54
|
guard: ({ event }) => event.to === `#${node.id}`,
|
|
41
55
|
reenter: true,
|
|
42
56
|
actions: assign({
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
params: ({ event }) => event.params || {},
|
|
58
|
+
query: ({ event }) => event.query || {},
|
|
45
59
|
}),
|
|
46
60
|
};
|
|
47
61
|
routeTransitions.push(transition);
|
|
48
62
|
}
|
|
49
63
|
if (node.states) {
|
|
50
|
-
collectRoutes(node.states,
|
|
64
|
+
collectRoutes(node.states, statePath);
|
|
51
65
|
}
|
|
52
66
|
});
|
|
53
67
|
};
|
|
@@ -57,9 +71,19 @@ export function formatPlayRouteTransitions(machineConfig) {
|
|
|
57
71
|
}
|
|
58
72
|
if (routeTransitions.length > 0) {
|
|
59
73
|
const existingOn = machineConfig.on || {};
|
|
74
|
+
// Preserve user-defined play.route transitions (e.g. a hand-written 404
|
|
75
|
+
// fallback) by appending them AFTER the generated ones: XState evaluates
|
|
76
|
+
// candidate transitions in order, so generated guards win when they match
|
|
77
|
+
// and the user's transitions act as fallbacks otherwise.
|
|
78
|
+
const userRouteTransitions = existingOn["play.route"];
|
|
79
|
+
const normalizedUserTransitions = userRouteTransitions === undefined
|
|
80
|
+
? []
|
|
81
|
+
: Array.isArray(userRouteTransitions)
|
|
82
|
+
? userRouteTransitions
|
|
83
|
+
: [userRouteTransitions];
|
|
60
84
|
const updatedOn = {
|
|
61
85
|
...existingOn,
|
|
62
|
-
"play.route": routeTransitions,
|
|
86
|
+
"play.route": [...routeTransitions, ...normalizedUserTransitions],
|
|
63
87
|
};
|
|
64
88
|
return {
|
|
65
89
|
...machineConfig,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-play-route-transitions.js","sourceRoot":"","sources":["../../src/routing/format-play-route-transitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"format-play-route-transitions.js","sourceRoot":"","sources":["../../src/routing/format-play-route-transitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAwDnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,0BAA0B,CAA+B,aAAgB;IACxF,MAAM,gBAAgB,GAAsB,EAAE,CAAC;IAE/C,MAAM,aAAa,GAAG,CAAC,MAA+B,EAAE,UAAU,GAAG,EAAE,EAAE,EAAE;QAC1E,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,EAAE;YACrD,MAAM,IAAI,GAAG,WAA6B,CAAC;YAC3C,wEAAwE;YACxE,iEAAiE;YACjE,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;YAC5D,wDAAwD;YACxD,qEAAqE;YACrE,sEAAsE;YACtE,oCAAoC;YACpC,MAAM,SAAS,GACd,IAAI,CAAC,IAAI,EAAE,KAAK,KAAK,SAAS;gBAC7B,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;QACzE,0EAA0E;QAC1E,yDAAyD;QACzD,MAAM,oBAAoB,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;QACtD,MAAM,yBAAyB,GAC9B,oBAAoB,KAAK,SAAS;YACjC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC;gBACpC,CAAC,CAAC,oBAAoB;gBACtB,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC;QAE5B,MAAM,SAAS,GAAG;YACjB,GAAG,UAAU;YACb,YAAY,EAAE,CAAC,GAAG,gBAAgB,EAAE,GAAG,yBAAyB,CAAC;SACjE,CAAC;QAEF,OAAO;YACN,GAAG,aAAa;YAChB,EAAE,EAAE,SAAS;SACR,CAAC;IACR,CAAC;IAED,OAAO,aAAa,CAAC;AACtB,CAAC"}
|
package/dist/routing/index.d.ts
CHANGED
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
export { deriveRoute, isAbsoluteRoute } from "./derive-route.js";
|
|
10
|
+
export { deriveCurrentRoute } from "./derive-current-route.js";
|
|
11
|
+
export { deriveInitialRoute } from "./derive-initial-route.js";
|
|
10
12
|
export { buildRouteUrl } from "./build-url.js";
|
|
11
13
|
export { formatPlayRouteTransitions } from "./format-play-route-transitions.js";
|
|
12
14
|
export type { RouteMachineConfig, RouteStateNode } from "./format-play-route-transitions.js";
|
|
13
|
-
export type { RouteContext } from "./types.js";
|
|
15
|
+
export type { RouteContext, RouteObject, RouteMetadata } from "./types.js";
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC7F,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC7F,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/routing/index.js
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
export { deriveRoute, isAbsoluteRoute } from "./derive-route.js";
|
|
10
|
+
export { deriveCurrentRoute } from "./derive-current-route.js";
|
|
11
|
+
export { deriveInitialRoute } from "./derive-initial-route.js";
|
|
10
12
|
export { buildRouteUrl } from "./build-url.js";
|
|
11
13
|
export { formatPlayRouteTransitions } from "./format-play-route-transitions.js";
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC"}
|
package/dist/routing/types.d.ts
CHANGED
|
@@ -4,17 +4,24 @@ export interface RouteObject {
|
|
|
4
4
|
}
|
|
5
5
|
export type RouteMetadata = string | RouteObject;
|
|
6
6
|
/**
|
|
7
|
-
* Route build context from machine context
|
|
7
|
+
* Route build context from machine context.
|
|
8
|
+
*
|
|
9
|
+
* All URL parameter substitution must go through `params` — flat context fields are not
|
|
10
|
+
* inspected. This is intentional: the index signature was removed to enable compile-time
|
|
11
|
+
* validation of context shapes and IDE autocomplete on context fields.
|
|
12
|
+
*
|
|
13
|
+
* Machines using `formatPlayRouteTransitions` have `params` and `query` assigned
|
|
14
|
+
* automatically from each `play.route` event. Machines that call `buildRouteUrl` directly
|
|
15
|
+
* must populate `params` explicitly.
|
|
8
16
|
*/
|
|
9
17
|
export interface RouteContext {
|
|
10
18
|
/** Base path for relative routes */
|
|
11
19
|
basePath?: string;
|
|
12
|
-
/**
|
|
13
|
-
|
|
20
|
+
/** Path-only route parameters to substitute (e.g., `:userId` from `/profile/:userId`) */
|
|
21
|
+
params?: Record<string, unknown>;
|
|
14
22
|
/** Query parameters */
|
|
15
23
|
query?: Record<string, unknown>;
|
|
16
24
|
/** Hash fragment */
|
|
17
25
|
hash?: string;
|
|
18
|
-
[key: string]: unknown;
|
|
19
26
|
}
|
|
20
27
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/routing/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,WAAW,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/routing/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,WAAW,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,YAAY;IAC5B,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,uBAAuB;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,oBAAoB;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd"}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,14 +2,10 @@ import type { AnyStateMachine, InputFrom, SnapshotFrom } from "xstate";
|
|
|
2
2
|
import type { PlayerActor as PlayerActorClass } from "./player-actor.js";
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for definePlayer()
|
|
5
|
-
*
|
|
6
|
-
* Per CONTEXT.md: Single config object with machine, catalog, options
|
|
7
5
|
*/
|
|
8
|
-
export interface PlayerConfig<TMachine extends AnyStateMachine
|
|
6
|
+
export interface PlayerConfig<TMachine extends AnyStateMachine> {
|
|
9
7
|
/** XState v5 state machine */
|
|
10
8
|
machine: TMachine;
|
|
11
|
-
/** UI component catalog (optional - allows machines without UI) */
|
|
12
|
-
catalog?: TCatalog;
|
|
13
9
|
/** Lifecycle hooks and configuration */
|
|
14
10
|
options?: PlayerOptions<TMachine>;
|
|
15
11
|
}
|
|
@@ -30,10 +26,20 @@ export interface PlayerOptions<TMachine extends AnyStateMachine> {
|
|
|
30
26
|
/** Called on actor errors */
|
|
31
27
|
onError?: (actor: PlayerActorClass<TMachine>, error: Error) => void;
|
|
32
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Optional restore arguments for the player factory.
|
|
31
|
+
*
|
|
32
|
+
* Mirrors XState's createActor options bag while preserving the existing
|
|
33
|
+
* `createPlayer(input?)` calling convention for fresh actors.
|
|
34
|
+
*/
|
|
35
|
+
export interface PlayerFactoryResumeOptions<TMachine extends AnyStateMachine> {
|
|
36
|
+
/** Persisted XState snapshot used to restore actor state. */
|
|
37
|
+
snapshot?: SnapshotFrom<TMachine>;
|
|
38
|
+
}
|
|
33
39
|
/**
|
|
34
40
|
* Factory function returned by definePlayer()
|
|
35
41
|
*
|
|
36
42
|
* Per CONTEXT.md: Factory supports creating multiple actor instances
|
|
37
43
|
*/
|
|
38
|
-
export type PlayerFactory<TMachine extends AnyStateMachine> = (input?: InputFrom<TMachine>) => PlayerActorClass<TMachine>;
|
|
44
|
+
export type PlayerFactory<TMachine extends AnyStateMachine> = (input?: InputFrom<TMachine>, options?: PlayerFactoryResumeOptions<TMachine>) => PlayerActorClass<TMachine>;
|
|
39
45
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,IAAI,gBAAgB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QAAQ,SAAS,eAAe;IAC3E,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,QAAQ,SAAS,eAAe,IAAI,CAC7D,KAAK,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,EAC3B,OAAO,CAAC,EAAE,0BAA0B,CAAC,QAAQ,CAAC,KAC1C,gBAAgB,CAAC,QAAQ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmachines/play-xstate",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "XState v5 adapter for Play Architecture",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"actor-model",
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"author": "",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+ssh://git@gitlab.com/xmachin-es/xmachines-js.git",
|
|
17
|
+
"directory": "packages/play-xstate"
|
|
18
|
+
},
|
|
14
19
|
"files": [
|
|
15
20
|
"dist",
|
|
16
21
|
"README.md",
|
|
@@ -21,8 +26,14 @@
|
|
|
21
26
|
"types": "./dist/index.d.ts",
|
|
22
27
|
"exports": {
|
|
23
28
|
".": {
|
|
29
|
+
"source": "./src/index.ts",
|
|
24
30
|
"types": "./dist/index.d.ts",
|
|
25
31
|
"import": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./errors": {
|
|
34
|
+
"source": "./src/errors.ts",
|
|
35
|
+
"types": "./dist/errors.d.ts",
|
|
36
|
+
"import": "./dist/errors.js"
|
|
26
37
|
}
|
|
27
38
|
},
|
|
28
39
|
"publishConfig": {
|
|
@@ -30,22 +41,34 @@
|
|
|
30
41
|
},
|
|
31
42
|
"scripts": {
|
|
32
43
|
"build": "tsc --build",
|
|
33
|
-
"clean": "rm -rf dist *.tsbuildinfo node_modules/.
|
|
34
|
-
"
|
|
44
|
+
"clean": "rm -rf dist *.tsbuildinfo coverage node_modules/.svelte2tsx-* node_modules/.vite*",
|
|
45
|
+
"lint": "oxlint .",
|
|
46
|
+
"format": "oxfmt .",
|
|
35
47
|
"test": "vitest",
|
|
36
48
|
"prepublishOnly": "npm run build"
|
|
37
49
|
},
|
|
38
50
|
"dependencies": {
|
|
39
|
-
"@xmachines/play": "1.0.0
|
|
40
|
-
"@xmachines/play-actor": "1.0.0
|
|
41
|
-
"@xmachines/play-
|
|
42
|
-
"
|
|
43
|
-
"zod": "^4.3.6"
|
|
51
|
+
"@xmachines/play": "1.0.0",
|
|
52
|
+
"@xmachines/play-actor": "1.0.0",
|
|
53
|
+
"@xmachines/play-signals": "1.0.0",
|
|
54
|
+
"dequal": "^2.0.3"
|
|
44
55
|
},
|
|
45
56
|
"devDependencies": {
|
|
46
|
-
"@
|
|
57
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
58
|
+
"@types/node": "^26.1.1",
|
|
59
|
+
"@xmachines/play-router": "1.0.0",
|
|
60
|
+
"@xmachines/shared": "1.0.0",
|
|
61
|
+
"oxfmt": "^0.58.0",
|
|
62
|
+
"oxlint": "^1.73.0",
|
|
63
|
+
"typescript": "^5.9.3 || ^6.0.3",
|
|
64
|
+
"vitest": "^4.1.10",
|
|
65
|
+
"xstate": "^5.31.0"
|
|
47
66
|
},
|
|
48
67
|
"peerDependencies": {
|
|
49
|
-
"xstate": "^5.
|
|
50
|
-
}
|
|
68
|
+
"xstate": "^5.31.0"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=22.0.0"
|
|
72
|
+
},
|
|
73
|
+
"_devDependencies_note": "xstate appears in both peerDependencies and devDependencies intentionally. devDependencies provides workspace resolution for local builds, tests, and typechecking. peerDependencies declares the consumer version constraint. Both are pinned to ^5.30.0 to prevent drift."
|
|
51
74
|
}
|
package/dist/catalog/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Catalog binding and validation utilities
|
|
3
|
-
*
|
|
4
|
-
* Provides functions for validating component references and props
|
|
5
|
-
* using Zod schemas from the catalog.
|
|
6
|
-
*
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
export { validateComponentBinding } from "./validate-binding.js";
|
|
10
|
-
export { validateViewProps, mergeViewProps, createMemoSignature } from "./validate-props.js";
|
|
11
|
-
export type { ValidationResult, ViewMergeContext } from "./validate-props.js";
|
|
12
|
-
export type { Catalog, CatalogEntry } from "./types.js";
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/catalog/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC7F,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/catalog/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Catalog binding and validation utilities
|
|
3
|
-
*
|
|
4
|
-
* Provides functions for validating component references and props
|
|
5
|
-
* using Zod schemas from the catalog.
|
|
6
|
-
*
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
export { validateComponentBinding } from "./validate-binding.js";
|
|
10
|
-
export { validateViewProps, mergeViewProps, createMemoSignature } from "./validate-props.js";
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/catalog/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/catalog/types.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { z } from "zod";
|
|
2
|
-
import type { Catalog as BaseCatalog } from "@xmachines/play-catalog";
|
|
3
|
-
/**
|
|
4
|
-
* UI component catalog entry with schema and component reference
|
|
5
|
-
*
|
|
6
|
-
* Per CONTEXT.md: String keys reference components, Zod schemas validate props
|
|
7
|
-
*/
|
|
8
|
-
export interface CatalogEntry {
|
|
9
|
-
/** Zod schema for component props */
|
|
10
|
-
schema: z.ZodType<unknown>;
|
|
11
|
-
/** React component (or other framework component) */
|
|
12
|
-
component: unknown;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Component catalog mapping
|
|
16
|
-
*
|
|
17
|
-
* Re-export from @xmachines/play-catalog for consistent API.
|
|
18
|
-
*
|
|
19
|
-
* Supports two formats:
|
|
20
|
-
* - Direct Zod schemas: `Record<string, z.ZodType>` via defineCatalog()
|
|
21
|
-
* - CatalogEntry objects: `Record<string, CatalogEntry>` with { schema, component }
|
|
22
|
-
*
|
|
23
|
-
* PlayerActor accepts either format - if entry has 'schema' property, uses CatalogEntry pattern,
|
|
24
|
-
* otherwise treats as direct Zod schema.
|
|
25
|
-
*/
|
|
26
|
-
export type Catalog = BaseCatalog | Record<string, CatalogEntry>;
|
|
27
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/catalog/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtE;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,qCAAqC;IACrC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3B,qDAAqD;IACrD,SAAS,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC"}
|
package/dist/catalog/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/catalog/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Catalog } from "./types.js";
|
|
2
|
-
import type { ViewMetadata } from "@xmachines/play-actor";
|
|
3
|
-
/**
|
|
4
|
-
* Validate component binding against catalog
|
|
5
|
-
*
|
|
6
|
-
* Per CONTEXT.md:
|
|
7
|
-
* - "Component references: String keys"
|
|
8
|
-
* - "Mismatch detection: Both compile-time (TypeScript) and runtime validation"
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* const view = { component: 'Dashboard', userId: '123' };
|
|
13
|
-
* validateComponentBinding(view, catalog);
|
|
14
|
-
* // Throws if 'Dashboard' not in catalog
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @param view - View metadata from meta.view
|
|
18
|
-
* @param catalog - Component catalog
|
|
19
|
-
* @throws Error if component not found in catalog
|
|
20
|
-
*/
|
|
21
|
-
export declare const validateComponentBinding: (view: ViewMetadata, catalog: Catalog) => void;
|
|
22
|
-
//# sourceMappingURL=validate-binding.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-binding.d.ts","sourceRoot":"","sources":["../../src/catalog/validate-binding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,wBAAwB,GAAI,MAAM,YAAY,EAAE,SAAS,OAAO,KAAG,IAc/E,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validate component binding against catalog
|
|
3
|
-
*
|
|
4
|
-
* Per CONTEXT.md:
|
|
5
|
-
* - "Component references: String keys"
|
|
6
|
-
* - "Mismatch detection: Both compile-time (TypeScript) and runtime validation"
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const view = { component: 'Dashboard', userId: '123' };
|
|
11
|
-
* validateComponentBinding(view, catalog);
|
|
12
|
-
* // Throws if 'Dashboard' not in catalog
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* @param view - View metadata from meta.view
|
|
16
|
-
* @param catalog - Component catalog
|
|
17
|
-
* @throws Error if component not found in catalog
|
|
18
|
-
*/
|
|
19
|
-
export const validateComponentBinding = (view, catalog) => {
|
|
20
|
-
if (!view || !view.component) {
|
|
21
|
-
throw new Error("Invalid view metadata: missing 'component' property");
|
|
22
|
-
}
|
|
23
|
-
const { component } = view;
|
|
24
|
-
// Runtime validation
|
|
25
|
-
if (!(component in catalog)) {
|
|
26
|
-
const available = Object.keys(catalog).join(", ");
|
|
27
|
-
throw new Error(`Component "${component}" not found in catalog. Available components: ${available || "(none)"}`);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=validate-binding.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-binding.js","sourceRoot":"","sources":["../../src/catalog/validate-binding.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,IAAkB,EAAE,OAAgB,EAAQ,EAAE;IACtF,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAE3B,qBAAqB;IACrB,IAAI,CAAC,CAAC,SAAS,IAAI,OAAO,CAAC,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClD,MAAM,IAAI,KAAK,CACd,cAAc,SAAS,iDAAiD,SAAS,IAAI,QAAQ,EAAE,CAC/F,CAAC;IACH,CAAC;AACF,CAAC,CAAC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { z } from "zod";
|
|
2
|
-
import type { Catalog } from "./types.js";
|
|
3
|
-
import type { ViewMetadata } from "@xmachines/play-actor";
|
|
4
|
-
export type ViewMergeContext = {
|
|
5
|
-
routeParams?: Record<string, unknown>;
|
|
6
|
-
queryParams?: Record<string, unknown>;
|
|
7
|
-
[key: string]: unknown;
|
|
8
|
-
};
|
|
9
|
-
export type ValidationResult = {
|
|
10
|
-
success: true;
|
|
11
|
-
data: Record<string, unknown>;
|
|
12
|
-
} | {
|
|
13
|
-
success: false;
|
|
14
|
-
error: z.ZodError | Error;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Validate view props against Zod schema
|
|
18
|
-
*
|
|
19
|
-
* Per CONTEXT.md:
|
|
20
|
-
* - "Prop validation: At state entry"
|
|
21
|
-
* - "currentView derivation: Merge meta.view with relevant context data"
|
|
22
|
-
*
|
|
23
|
-
* Per RESEARCH.md Pattern 4: Use safeParse() for validation
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* const props = { userId: '123', stats: { logins: 5 } };
|
|
28
|
-
* const result = validateViewProps('Dashboard', props, catalog);
|
|
29
|
-
* if (!result.success) {
|
|
30
|
-
* console.error(result.error);
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* @param componentName - Component name from catalog
|
|
35
|
-
* @param props - Props to validate
|
|
36
|
-
* @param catalog - Component catalog with schemas
|
|
37
|
-
* @returns Zod parse result
|
|
38
|
-
*/
|
|
39
|
-
export declare const validateViewProps: (componentName: string, props: unknown, catalog: Catalog) => ValidationResult;
|
|
40
|
-
/**
|
|
41
|
-
* Merge view metadata with context for props
|
|
42
|
-
*
|
|
43
|
-
* Per CONTEXT.md: "Merge meta.view with relevant context data for component props"
|
|
44
|
-
*
|
|
45
|
-
* @param view - View metadata from meta.view
|
|
46
|
-
* @param context - Machine context
|
|
47
|
-
* @returns Merged props object
|
|
48
|
-
*/
|
|
49
|
-
export declare const mergeViewProps: (view: ViewMetadata, context: ViewMergeContext | null | undefined) => Record<string, unknown>;
|
|
50
|
-
export declare const createMemoSignature: (value: unknown) => string;
|
|
51
|
-
//# sourceMappingURL=validate-props.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-props.d.ts","sourceRoot":"","sources":["../../src/catalog/validate-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,MAAM,gBAAgB,GAAG;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACzB;IACA,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7B,GACD;IACA,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC;CACzB,CAAC;AAEL;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,iBAAiB,GAC7B,eAAe,MAAM,EACrB,OAAO,OAAO,EACd,SAAS,OAAO,KACd,gBA2BF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAC1B,MAAM,YAAY,EAClB,SAAS,gBAAgB,GAAG,IAAI,GAAG,SAAS,KAC1C,MAAM,CAAC,MAAM,EAAE,OAAO,CAkDxB,CAAC;AAiEF,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,KAAG,MAEpD,CAAC"}
|