@xmachines/play-router 1.0.0-beta.56 → 1.0.0-beta.58
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/README.md +5 -5
- package/dist/machine-to-graph.js +1 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +12 -27
- package/dist/query.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -11,8 +11,8 @@ Part of the [xmachines-js monorepo](../../README.md).
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
pnpm add xstate@^5.31.0
|
|
15
|
+
pnpm add @xmachines/play-router
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
**Peer dependencies:**
|
|
@@ -33,7 +33,7 @@ import "urlpattern-polyfill";
|
|
|
33
33
|
Install the polyfill:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
|
|
36
|
+
pnpm add urlpattern-polyfill
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
`urlpattern-polyfill` is declared as an optional peer dependency. Package managers will not install it automatically — consumers must install and load it when their runtime lacks native URLPattern support.
|
|
@@ -323,10 +323,10 @@ Always use `node.fullPath` (never `node.path`) for browser URL matching and rout
|
|
|
323
323
|
|
|
324
324
|
```bash
|
|
325
325
|
# Run tests for this package
|
|
326
|
-
|
|
326
|
+
pnpm --filter @xmachines/play-router test
|
|
327
327
|
|
|
328
328
|
# Watch mode
|
|
329
|
-
|
|
329
|
+
pnpm --filter @xmachines/play-router run test:watch
|
|
330
330
|
```
|
|
331
331
|
|
|
332
332
|
A router bridge contract test suite for adapter authors lives in
|
package/dist/machine-to-graph.js
CHANGED
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAa,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAa,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAqBzF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,SAAS,EAAE,SAAS,MAAM,KAAG,SAAS,EAyB9E,CAAC;AAgBF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS,KAAG,SAAS,EAW5D,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,SAAS,EAAE,MAAM,MAAM,KAAG,OAE3D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,4BAA4B,GACxC,OAAO,KAAK,CAAC,eAAe,EAAE,eAAe,CAAC,EAC9C,SAAS,MAAM,KACb,MAAM,EAER,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,gBAAgB,GAC5B,OAAO,KAAK,CAAC,eAAe,EAAE,eAAe,CAAC,EAC9C,aAAa,MAAM,EACnB,WAAW,MAAM,KACf,OAKF,CAAC"}
|
package/dist/query.js
CHANGED
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
import { getSuccessors, hasPath } from "@statelyai/graph";
|
|
2
|
-
/**
|
|
3
|
-
* Matches the error message @statelyai/graph throws when a queried state ID has
|
|
4
|
-
* no corresponding node in the graph.
|
|
5
|
-
*/
|
|
6
|
-
const MISSING_NODE_MESSAGE = /not found|does not exist/i;
|
|
7
|
-
/**
|
|
8
|
-
* Run a @statelyai/graph query, converting its "node not found" error into a
|
|
9
|
-
* fallback value.
|
|
10
|
-
*
|
|
11
|
-
* A state ID with no graph node (e.g. a non-routable or removed state) is a
|
|
12
|
-
* normal "nothing reachable" outcome for the query helpers in this module, not
|
|
13
|
-
* an exceptional condition. All other errors propagate unchanged.
|
|
14
|
-
*/
|
|
15
|
-
const swallowMissingNode = (query, fallback) => {
|
|
16
|
-
try {
|
|
17
|
-
return query();
|
|
18
|
-
}
|
|
19
|
-
catch (err) {
|
|
20
|
-
if (err instanceof Error && MISSING_NODE_MESSAGE.test(err.message)) {
|
|
21
|
-
return fallback;
|
|
22
|
-
}
|
|
23
|
-
throw err;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
1
|
+
import { getSuccessors, hasNode, hasPath } from "@statelyai/graph";
|
|
26
2
|
/**
|
|
27
3
|
* Get the routable successor nodes of a state — states directly reachable via
|
|
28
4
|
* transition edges that have a defined `meta.route`.
|
|
@@ -31,7 +7,13 @@ const swallowMissingNode = (query, fallback) => {
|
|
|
31
7
|
* `getTransitionReachableRoutes`; returns full nodes so callers can project
|
|
32
8
|
* whichever field they need (stateId vs raw route string).
|
|
33
9
|
*/
|
|
34
|
-
const getRoutableSuccessors = (graph, stateId) =>
|
|
10
|
+
const getRoutableSuccessors = (graph, stateId) =>
|
|
11
|
+
// A state ID with no graph node (e.g. a non-routable or removed state) is a
|
|
12
|
+
// normal "nothing reachable" outcome, checked explicitly rather than by
|
|
13
|
+
// pattern-matching thrown error messages.
|
|
14
|
+
hasNode(graph, stateId)
|
|
15
|
+
? getSuccessors(graph, stateId).filter((n) => n.data.route !== undefined)
|
|
16
|
+
: [];
|
|
35
17
|
/**
|
|
36
18
|
* Get all routes navigable from given state
|
|
37
19
|
*
|
|
@@ -174,6 +156,9 @@ export const getTransitionReachableRoutes = (graph, stateId) => {
|
|
|
174
156
|
* ```
|
|
175
157
|
*/
|
|
176
158
|
export const isRouteReachable = (graph, fromStateId, toStateId) => {
|
|
177
|
-
|
|
159
|
+
// Missing endpoints are a normal "not reachable" outcome.
|
|
160
|
+
return hasNode(graph, fromStateId) && hasNode(graph, toStateId)
|
|
161
|
+
? hasPath(graph, fromStateId, toStateId)
|
|
162
|
+
: false;
|
|
178
163
|
};
|
|
179
164
|
//# sourceMappingURL=query.js.map
|
package/dist/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGnE;;;;;;;GAOG;AACH,MAAM,qBAAqB,GAAG,CAC7B,KAA8C,EAC9C,OAAe,EACgB,EAAE;AACjC,4EAA4E;AAC5E,wEAAwE;AACxE,0CAA0C;AAC1C,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC;IACtB,CAAC,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC;IACzE,CAAC,CAAC,EAAE,CAAC;AAEP;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAe,EAAE,OAAe,EAAe,EAAE;IACnF,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IAErB,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,0CAA0C;IAE9E,wEAAwE;IACxE,yEAAyE;IACzE,6EAA6E;IAC7E,yEAAyE;IACzE,sEAAs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AAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAe,EAAE,IAAY,EAAW,EAAE;IACrE,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC3C,KAA8C,EAC9C,OAAe,EACJ,EAAE;IACb,OAAO,qBAAqB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAM,CAAC,CAAC;AACxE,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC/B,KAA8C,EAC9C,WAAmB,EACnB,SAAiB,EACP,EAAE;IACZ,0DAA0D;IAC1D,OAAO,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC;QAC9D,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC;QACxC,CAAC,CAAC,KAAK,CAAC;AACV,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmachines/play-router",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.58",
|
|
4
4
|
"description": "Route tree extraction from XState v5 state machines. Part of @xmachines/play Universal Player Architecture.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"routing",
|
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
"prepublishOnly": "npm run build"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@statelyai/graph": "^
|
|
50
|
-
"@xmachines/play": "1.0.0-beta.
|
|
51
|
-
"@xmachines/play-actor": "1.0.0-beta.
|
|
52
|
-
"@xmachines/play-signals": "1.0.0-beta.
|
|
49
|
+
"@statelyai/graph": "^2.1.0",
|
|
50
|
+
"@xmachines/play": "1.0.0-beta.58",
|
|
51
|
+
"@xmachines/play-actor": "1.0.0-beta.58",
|
|
52
|
+
"@xmachines/play-signals": "1.0.0-beta.58",
|
|
53
53
|
"quick-lru": "^7.3.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@testing-library/jest-dom": "^6.9.1",
|
|
57
57
|
"@types/node": "^25.6.0",
|
|
58
58
|
"@vitest/browser-playwright": "^4.1.5",
|
|
59
|
-
"@xmachines/shared": "1.0.0-beta.
|
|
59
|
+
"@xmachines/shared": "1.0.0-beta.58",
|
|
60
60
|
"oxfmt": "^0.47.0",
|
|
61
61
|
"oxlint": "^1.62.0",
|
|
62
62
|
"typescript": "^5.9.3 || ^6.0.3",
|