@xmachines/play-xstate 2.0.0-alpha.1 → 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.
- package/README.md +114 -114
- package/dist/define-player.d.ts +16 -16
- package/dist/define-player.js +16 -16
- package/dist/errors.d.ts +84 -101
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +108 -108
- package/dist/errors.js.map +1 -1
- package/dist/guards/compose.d.ts +70 -77
- package/dist/guards/compose.d.ts.map +1 -1
- package/dist/guards/compose.js +90 -113
- package/dist/guards/compose.js.map +1 -1
- package/dist/guards/helpers.d.ts +22 -18
- package/dist/guards/helpers.d.ts.map +1 -1
- package/dist/guards/helpers.js +23 -19
- package/dist/guards/helpers.js.map +1 -1
- package/dist/guards/index.d.ts +10 -3
- package/dist/guards/index.d.ts.map +1 -1
- package/dist/guards/index.js +10 -3
- package/dist/guards/index.js.map +1 -1
- package/dist/guards/types.d.ts +9 -9
- package/dist/guards/types.d.ts.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -10
- package/dist/index.js.map +1 -1
- package/dist/player-actor.d.ts +197 -113
- package/dist/player-actor.d.ts.map +1 -1
- package/dist/player-actor.js +413 -401
- package/dist/player-actor.js.map +1 -1
- package/dist/routing/build-url.d.ts +19 -21
- package/dist/routing/build-url.d.ts.map +1 -1
- package/dist/routing/build-url.js +70 -71
- package/dist/routing/build-url.js.map +1 -1
- package/dist/routing/derive-current-route.d.ts +51 -13
- package/dist/routing/derive-current-route.d.ts.map +1 -1
- package/dist/routing/derive-current-route.js +69 -60
- package/dist/routing/derive-current-route.js.map +1 -1
- package/dist/routing/derive-initial-route.d.ts +23 -23
- package/dist/routing/derive-initial-route.js +27 -27
- package/dist/routing/derive-initial-route.js.map +1 -1
- package/dist/routing/derive-route.d.ts +38 -37
- package/dist/routing/derive-route.d.ts.map +1 -1
- package/dist/routing/derive-route.js +45 -42
- package/dist/routing/derive-route.js.map +1 -1
- package/dist/routing/format-play-route-transitions.d.ts +34 -71
- package/dist/routing/format-play-route-transitions.d.ts.map +1 -1
- package/dist/routing/format-play-route-transitions.js +74 -130
- package/dist/routing/format-play-route-transitions.js.map +1 -1
- package/dist/routing/index.d.ts +4 -8
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +4 -6
- package/dist/routing/index.js.map +1 -1
- package/dist/routing/types.d.ts +12 -11
- package/dist/routing/types.d.ts.map +1 -1
- package/dist/types.d.ts +97 -20
- package/dist/types.d.ts.map +1 -1
- package/dist/view/derive-current-view.d.ts +51 -0
- package/dist/view/derive-current-view.d.ts.map +1 -0
- package/dist/view/derive-current-view.js +119 -0
- package/dist/view/derive-current-view.js.map +1 -0
- package/package.json +22 -21
- package/dist/define-player.typecheck.d.ts +0 -2
- package/dist/define-player.typecheck.d.ts.map +0 -1
- package/dist/define-player.typecheck.js +0 -48
- package/dist/define-player.typecheck.js.map +0 -1
- package/dist/guards/compose.typecheck.d.ts +0 -2
- package/dist/guards/compose.typecheck.d.ts.map +0 -1
- package/dist/guards/compose.typecheck.js +0 -22
- package/dist/guards/compose.typecheck.js.map +0 -1
- package/dist/player-actor.typecheck.d.ts +0 -2
- package/dist/player-actor.typecheck.d.ts.map +0 -1
- package/dist/player-actor.typecheck.js +0 -30
- package/dist/player-actor.typecheck.js.map +0 -1
- package/dist/routing/create-routed-machine.d.ts +0 -71
- package/dist/routing/create-routed-machine.d.ts.map +0 -1
- package/dist/routing/create-routed-machine.js +0 -71
- package/dist/routing/create-routed-machine.js.map +0 -1
- package/dist/routing/play-route-event.typecheck.d.ts +0 -2
- package/dist/routing/play-route-event.typecheck.d.ts.map +0 -1
- package/dist/routing/play-route-event.typecheck.js +0 -43
- package/dist/routing/play-route-event.typecheck.js.map +0 -1
- package/dist/routing/schemas.d.ts +0 -99
- package/dist/routing/schemas.d.ts.map +0 -1
- package/dist/routing/schemas.js +0 -30
- package/dist/routing/schemas.js.map +0 -1
- package/dist/schemas.d.ts +0 -28
- package/dist/schemas.d.ts.map +0 -1
- package/dist/schemas.js +0 -29
- package/dist/schemas.js.map +0 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { composePlayState, toAtomState } from "@xmachines/play-actor";
|
|
2
|
+
import { activeStateMeta } from "../routing/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* The migration warning of the `contextProps` field, which 1.x removed. The code
|
|
5
|
+
* writes it one time for each spec. A meta.view object from a person passes around
|
|
6
|
+
* `typedSpec`, and a spec with the field therefore compiles without an error. But
|
|
7
|
+
* the meaning of the field inverted: it was an allowlist, or an empty filter that
|
|
8
|
+
* projected nothing, and the whole context is the value now. The key is the static
|
|
9
|
+
* meta.view object. Therefore the warning appears one time, and not for each
|
|
10
|
+
* snapshot.
|
|
11
|
+
*/
|
|
12
|
+
const warnedContextProps = new WeakSet();
|
|
13
|
+
const warnRemovedContextProps = (viewMeta) => {
|
|
14
|
+
if (warnedContextProps.has(viewMeta))
|
|
15
|
+
return;
|
|
16
|
+
warnedContextProps.add(viewMeta);
|
|
17
|
+
console.warn("[play-xstate] meta.view.contextProps has been removed: the whole machine context " +
|
|
18
|
+
"is always projected under /context. Delete the field — it no longer filters anything.");
|
|
19
|
+
};
|
|
20
|
+
const resolveViewMeta = (meta) => {
|
|
21
|
+
// Walk from the last entry to the first: snapshot.getMeta() puts the keys of the
|
|
22
|
+
// ancestors first. A scan from the end therefore lets the meta.view of the deepest
|
|
23
|
+
// active state win, and an ancestor hides it not.
|
|
24
|
+
const entries = Object.entries(meta);
|
|
25
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
26
|
+
// The array index has the bound of the loop. No user controls this property access.
|
|
27
|
+
const [key, stateMeta] = entries[i]; // nosemgrep: gitlab.eslint.detect-object-injection
|
|
28
|
+
const maybeView = stateMeta && typeof stateMeta === "object"
|
|
29
|
+
? stateMeta.view
|
|
30
|
+
: undefined;
|
|
31
|
+
if (maybeView &&
|
|
32
|
+
typeof maybeView === "object" &&
|
|
33
|
+
"root" in maybeView &&
|
|
34
|
+
"elements" in maybeView) {
|
|
35
|
+
return { key, view: maybeView };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Derives the current view of the actor from the state metadata.
|
|
42
|
+
*
|
|
43
|
+
* The function always returns a **fresh** `PlaySpec` object. The `Object.is`
|
|
44
|
+
* equality test of `Signal.State` therefore stops no real change of the view.
|
|
45
|
+
* `PlayerActor.validateAndCacheView` decides if the actor emits that fresh object:
|
|
46
|
+
* it compares the object with the last spec of an emission, it reuses the reference
|
|
47
|
+
* of the composed `state` field when the value of the projection did not change, and
|
|
48
|
+
* it emits nothing when the view on the screen is the same. A provider below the
|
|
49
|
+
* actor therefore mounts the UI again not on every event.
|
|
50
|
+
*
|
|
51
|
+
* ### The context projection
|
|
52
|
+
*
|
|
53
|
+
* The function projects the context of the machine into the `state` field of the
|
|
54
|
+
* derived spec, under the read-only `/context` subtree:
|
|
55
|
+
* `state: { ...meta.view.state, context: slice }`. The spec of the emission is
|
|
56
|
+
* therefore **consistent with itself**, and its `state` field describes the contents
|
|
57
|
+
* of the store correctly. `repeat.statePath: "/context/tasks"`,
|
|
58
|
+
* `visible: { $state: "/context/…" }`, and a `{ $state: "/context/…" }` prop all
|
|
59
|
+
* resolve through the ordinary state grammar. A tool such as `validateSpec` also
|
|
60
|
+
* passes on a derived view, with no special case. Validate the derived view, and not
|
|
61
|
+
* the raw `meta.view`.
|
|
62
|
+
*
|
|
63
|
+
* The store always holds the complete context. The function changes the authored
|
|
64
|
+
* `meta.view` object never.
|
|
65
|
+
*
|
|
66
|
+
* ### The viewKey
|
|
67
|
+
*
|
|
68
|
+
* The derived spec carries a `viewKey` field. Its value is the key of the meta
|
|
69
|
+
* record, which is the id of the state node, of the entry that this derivation
|
|
70
|
+
* selected. A provider uses it as the key of its store lifecycle: a new key seeds
|
|
71
|
+
* the store again, and the same key refreshes `/context` in place. The value comes
|
|
72
|
+
* from the selected entry, and not from "the id of the active state", because for a
|
|
73
|
+
* parallel machine the branch of the walk and the flat `getMeta()` fallback can
|
|
74
|
+
* select a view of a different region than the leaf of the branch.
|
|
75
|
+
*
|
|
76
|
+
* @param snapshot - The current snapshot of the XState machine.
|
|
77
|
+
* @returns The derived `PlaySpec`, or `null` when the current state has no view metadata.
|
|
78
|
+
*/
|
|
79
|
+
export const deriveCurrentView = (snapshot) => {
|
|
80
|
+
// Follow the SAME single active branch as the route derivation. Therefore the view
|
|
81
|
+
// on the screen of a parallel machine belongs to the region of the URL, when that
|
|
82
|
+
// region declares a view.
|
|
83
|
+
const meta = activeStateMeta(snapshot);
|
|
84
|
+
if (!meta) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
// A parallel machine can hold its routes and its views in DIFFERENT regions: one
|
|
88
|
+
// region owns the navigation, and another region owns the shell. When the branch of
|
|
89
|
+
// the walk declares no view, scan the flat record of every active region, where the
|
|
90
|
+
// deepest entry wins, before the conclusion that no view is present.
|
|
91
|
+
let resolved = resolveViewMeta(meta);
|
|
92
|
+
if (!resolved) {
|
|
93
|
+
const flatMeta = snapshot.getMeta();
|
|
94
|
+
if (flatMeta && typeof flatMeta === "object") {
|
|
95
|
+
resolved = resolveViewMeta(flatMeta);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!resolved) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const { key: viewKey, view: viewMeta } = resolved;
|
|
102
|
+
if ("contextProps" in viewMeta) {
|
|
103
|
+
warnRemovedContextProps(viewMeta);
|
|
104
|
+
}
|
|
105
|
+
// Project the complete context under /context. composePlayState skips the
|
|
106
|
+
// projection, the authored state wins, and the code writes a warning in development,
|
|
107
|
+
// when spec.state declares a top-level "context" key already.
|
|
108
|
+
const slice = snapshot.context !== null && typeof snapshot.context === "object"
|
|
109
|
+
? snapshot.context
|
|
110
|
+
: undefined;
|
|
111
|
+
const authoredState = viewMeta.state !== undefined ? toAtomState(viewMeta.state) : undefined;
|
|
112
|
+
const state = composePlayState(authoredState, slice);
|
|
113
|
+
return {
|
|
114
|
+
...viewMeta,
|
|
115
|
+
viewKey,
|
|
116
|
+
...(state !== undefined && { state }),
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=derive-current-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-current-view.js","sourceRoot":"","sources":["../../src/view/derive-current-view.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAiB,MAAM,uBAAuB,CAAC;AAErF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAStD;;;;;;;;GAQG;AACH,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAAU,CAAC;AACjD,MAAM,uBAAuB,GAAG,CAAC,QAAgB,EAAQ,EAAE;IAC1D,IAAI,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,OAAO;IAC7C,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjC,OAAO,CAAC,IAAI,CACX,mFAAmF;QAClF,uFAAuF,CACxF,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,IAA6B,EAA2B,EAAE;IAClF,iFAAiF;IACjF,mFAAmF;IACnF,kDAAkD;IAClD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,oFAAoF;QACpF,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,CAAsB,CAAC,CAAC,mDAAmD;QAC7G,MAAM,SAAS,GACd,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ;YACzC,CAAC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,KAAK,GACV,QAAQ,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ;QAChE,CAAC,CAAE,QAAQ,CAAC,OAAmC;QAC/C,CAAC,CAAC,SAAS,CAAC;IACd,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7F,MAAM,KAAK,GAAG,gBAAgB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAErD,OAAO;QACN,GAAG,QAAQ;QACX,OAAO;QACP,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,CAAC;KACrC,CAAC;AACH,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmachines/play-xstate",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "XState v5 adapter for Play Architecture",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"actor-model",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"author": "",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "git+
|
|
16
|
+
"url": "git+https://gitlab.com/xmachin-es/xmachines-js.git",
|
|
17
17
|
"directory": "packages/play-xstate"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
@@ -22,53 +22,54 @@
|
|
|
22
22
|
"LICENSE"
|
|
23
23
|
],
|
|
24
24
|
"type": "module",
|
|
25
|
+
"sideEffects": false,
|
|
25
26
|
"main": "./dist/index.js",
|
|
26
27
|
"types": "./dist/index.d.ts",
|
|
27
28
|
"exports": {
|
|
28
29
|
".": {
|
|
29
|
-
"source": "./src/index.ts",
|
|
30
30
|
"types": "./dist/index.d.ts",
|
|
31
|
-
"
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
32
|
},
|
|
33
33
|
"./errors": {
|
|
34
|
-
"source": "./src/errors.ts",
|
|
35
34
|
"types": "./dist/errors.d.ts",
|
|
36
|
-
"
|
|
37
|
-
}
|
|
35
|
+
"default": "./dist/errors.js"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
|
-
"build": "tsc --build",
|
|
43
|
+
"build": "vite build && tsc --build",
|
|
44
44
|
"clean": "rm -rf dist *.tsbuildinfo coverage node_modules/.svelte2tsx-* node_modules/.vite*",
|
|
45
45
|
"lint": "oxlint .",
|
|
46
46
|
"format": "oxfmt .",
|
|
47
47
|
"test": "vitest",
|
|
48
|
-
"
|
|
48
|
+
"test:coverage": "vitest run --coverage"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@xmachines/play": "2.
|
|
52
|
-
"@xmachines/play-actor": "2.
|
|
53
|
-
"@xmachines/play-signals": "2.
|
|
51
|
+
"@xmachines/play": "2.1.0",
|
|
52
|
+
"@xmachines/play-actor": "2.1.0",
|
|
53
|
+
"@xmachines/play-signals": "2.1.0",
|
|
54
54
|
"dequal": "^2.0.3"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@testing-library/jest-dom": "^6.9.1",
|
|
58
|
-
"@types/node": "^26.
|
|
59
|
-
"@xmachines/
|
|
60
|
-
"@xmachines/
|
|
61
|
-
"oxfmt": "^0.
|
|
62
|
-
"oxlint": "^1.
|
|
58
|
+
"@types/node": "^26.2.0",
|
|
59
|
+
"@xmachines/json-render-core": "^0.20.0-xm.2",
|
|
60
|
+
"@xmachines/play-router": "2.1.0",
|
|
61
|
+
"oxfmt": "^0.64.0",
|
|
62
|
+
"oxlint": "^1.79.0",
|
|
63
63
|
"typescript": "^5.9.3 || ^6.0.3",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
64
|
+
"vite": "^8.0.10",
|
|
65
|
+
"vitest": "^4.1.11",
|
|
66
|
+
"xstate": "^5.31.0"
|
|
66
67
|
},
|
|
67
68
|
"peerDependencies": {
|
|
68
|
-
"xstate": "^
|
|
69
|
+
"xstate": "^5.31.0"
|
|
69
70
|
},
|
|
70
71
|
"engines": {
|
|
71
72
|
"node": ">=22.0.0"
|
|
72
73
|
},
|
|
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 ^
|
|
74
|
+
"_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."
|
|
74
75
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-player.typecheck.d.ts","sourceRoot":"","sources":["../src/define-player.typecheck.ts"],"names":[],"mappings":""}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { setup, types } from "xstate";
|
|
2
|
-
import { emptyEventSchema } from "./schemas.js";
|
|
3
|
-
import { definePlayer } from "./define-player.js";
|
|
4
|
-
const machine = setup({
|
|
5
|
-
schemas: {
|
|
6
|
-
context: types(),
|
|
7
|
-
input: types(),
|
|
8
|
-
events: {
|
|
9
|
-
inc: emptyEventSchema,
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
}).createMachine({
|
|
13
|
-
context: ({ input }) => ({ count: input.count }),
|
|
14
|
-
initial: "active",
|
|
15
|
-
states: {
|
|
16
|
-
active: {
|
|
17
|
-
on: {
|
|
18
|
-
// XState v6: transitions are functions returning a context patch.
|
|
19
|
-
inc: ({ context }) => ({ context: { count: context.count + 1 } }),
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
const createPlayer = definePlayer({
|
|
25
|
-
machine,
|
|
26
|
-
options: {
|
|
27
|
-
onTransition: (actor, prevState, nextState) => {
|
|
28
|
-
const actorNotAny = false;
|
|
29
|
-
const prevNotAny = false;
|
|
30
|
-
const nextNotAny = false;
|
|
31
|
-
void actorNotAny;
|
|
32
|
-
void prevNotAny;
|
|
33
|
-
void nextNotAny;
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
const actor = createPlayer({ count: 1 });
|
|
38
|
-
const snapshot = actor.getSnapshot();
|
|
39
|
-
const restoredActor = createPlayer({ count: 1 }, { snapshot });
|
|
40
|
-
const returnNotAny = false;
|
|
41
|
-
const restoredReturnNotAny = false;
|
|
42
|
-
void returnNotAny;
|
|
43
|
-
void restoredReturnNotAny;
|
|
44
|
-
// @ts-expect-error factory input must match machine input shape
|
|
45
|
-
createPlayer("invalid");
|
|
46
|
-
// @ts-expect-error snapshot must be nested under the `snapshot` key
|
|
47
|
-
createPlayer({ count: 1 }, { persisted: snapshot });
|
|
48
|
-
//# sourceMappingURL=define-player.typecheck.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-player.typecheck.js","sourceRoot":"","sources":["../src/define-player.typecheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKlD,MAAM,OAAO,GAAG,KAAK,CAAC;IACrB,OAAO,EAAE;QACR,OAAO,EAAE,KAAK,EAAqB;QACnC,KAAK,EAAE,KAAK,EAAqB;QACjC,MAAM,EAAE;YACP,GAAG,EAAE,gBAAgB;SACrB;KACD;CACD,CAAC,CAAC,aAAa,CAAC;IAChB,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAA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ceRoot":"","sources":["../../src/guards/compose.typecheck.ts"],"names":[],"mappings":""}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type-level contract for guard composition: declared Guard<TContext> values
|
|
3
|
-
* and inline predicates must compose without casts, exactly as the JSDoc
|
|
4
|
-
* examples show.
|
|
5
|
-
*/
|
|
6
|
-
import { composeGuards, composeGuardsOr, negateGuard } from "./compose.js";
|
|
7
|
-
const isAdult = ({ context }) => context.age >= 18;
|
|
8
|
-
// Declared typed guards compose without casts.
|
|
9
|
-
const both = composeGuards([isAdult, ({ context }) => context.verified]);
|
|
10
|
-
// The documented inline-predicate example compiles as written (no annotations).
|
|
11
|
-
const isEligible = composeGuards([
|
|
12
|
-
({ context }) => context.age >= 18,
|
|
13
|
-
({ context }) => context.verified,
|
|
14
|
-
]);
|
|
15
|
-
// OR and NOT accept typed guards too.
|
|
16
|
-
const either = composeGuardsOr([isAdult, "isVerified"]);
|
|
17
|
-
const notAdult = negateGuard(isAdult);
|
|
18
|
-
void both;
|
|
19
|
-
void isEligible;
|
|
20
|
-
void either;
|
|
21
|
-
void notAdult;
|
|
22
|
-
//# sourceMappingURL=compose.typecheck.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compose.typecheck.js","sourceRoot":"","sources":["../../src/guards/compose.typecheck.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAK3E,MAAM,OAAO,GAAe,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC;AAE/D,+CAA+C;AAC/C,MAAM,IAAI,GAAG,aAAa,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,EAAoB,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAE3F,gFAAgF;AAChF,MAAM,UAAU,GAAG,aAAa,CAAC;IAChC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE;IAClC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ;CACjC,CAAC,CAAC;AAEH,sCAAsC;AACtC,MAAM,MAAM,GAAG,eAAe,CAAC,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;AACxD,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;AAEtC,KAAK,IAAI,CAAC;AACV,KAAK,UAAU,CAAC;AAChB,KAAK,MAAM,CAAC;AACZ,KAAK,QAAQ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"player-actor.typecheck.d.ts","sourceRoot":"","sources":["../src/player-actor.typecheck.ts"],"names":[],"mappings":""}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { setup, types } from "xstate";
|
|
2
|
-
import { emptyEventSchema } from "./schemas.js";
|
|
3
|
-
import { definePlayer } from "./define-player.js";
|
|
4
|
-
const machine = setup({
|
|
5
|
-
schemas: {
|
|
6
|
-
context: types(),
|
|
7
|
-
input: types(),
|
|
8
|
-
events: {
|
|
9
|
-
noop: emptyEventSchema,
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
}).createMachine({
|
|
13
|
-
context: ({ input }) => ({ value: input.value }),
|
|
14
|
-
initial: "idle",
|
|
15
|
-
states: {
|
|
16
|
-
idle: {},
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
const createPlayer = definePlayer({ machine });
|
|
20
|
-
const actor = createPlayer({ value: 1 });
|
|
21
|
-
const restoredActor = createPlayer({ value: 1 }, { snapshot: actor.getSnapshot() });
|
|
22
|
-
// Verify actor instances are created successfully
|
|
23
|
-
void actor;
|
|
24
|
-
void restoredActor;
|
|
25
|
-
// CONS-16: [key: string]: unknown index signature removed.
|
|
26
|
-
// Accessing unknown properties on PlayerActor is now a type error (correct behavior).
|
|
27
|
-
// @ts-expect-error — unknown fields no longer accessible via index signature
|
|
28
|
-
const unknownField = actor["custom-extension-field"];
|
|
29
|
-
void unknownField;
|
|
30
|
-
//# sourceMappingURL=player-actor.typecheck.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"player-actor.typecheck.js","sourceRoot":"","sources":["../src/player-actor.typecheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,OAAO,GAAG,KAAK,CAAC;IACrB,OAAO,EAAE;QACR,OAAO,EAAE,KAAK,EAAqB;QACnC,KAAK,EAAE,KAAK,EAAqB;QACjC,MAAM,EAAE;YACP,IAAI,EAAE,gBAAgB;SACtB;KACD;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,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structural constraint for `setup(...)` return values: anything exposing a
|
|
3
|
-
* `createMachine` function. Kept structural (rather than importing XState's
|
|
4
|
-
* `SetupReturn`) so the wrapper stays agnostic to that type's many generics.
|
|
5
|
-
*/
|
|
6
|
-
export type SetupLike = {
|
|
7
|
-
createMachine: (...args: never[]) => unknown;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Returns a `createMachine` that routes: identical signature to the setup's
|
|
11
|
-
* own `createMachine`, with {@link formatPlayRouteTransitions} applied to the
|
|
12
|
-
* config at runtime.
|
|
13
|
-
*
|
|
14
|
-
* ### Why this exists
|
|
15
|
-
*
|
|
16
|
-
* `formatPlayRouteTransitions(config)` accepts a loosely-typed config. A config
|
|
17
|
-
* authored as a standalone value loses inline transition-function parameter
|
|
18
|
-
* inference entirely (implicit-any under strict mode), and even the inline
|
|
19
|
-
* `setup().createMachine(formatPlayRouteTransitions({ ... }))` form depends on
|
|
20
|
-
* TypeScript threading contextual typing through two generic calls.
|
|
21
|
-
*
|
|
22
|
-
* This wrapper removes the question: it is typed as the setup's own
|
|
23
|
-
* `createMachine`, so the config is contextually typed exactly as if passed to
|
|
24
|
-
* `setup().createMachine(...)` directly — transition-function args infer from
|
|
25
|
-
* the setup's schemas, sibling targets are validated, and the returned machine
|
|
26
|
-
* keeps its full literal state-value typing.
|
|
27
|
-
*
|
|
28
|
-
* Typing is *identical to native* — including its current gaps: as of xstate
|
|
29
|
-
* 6.0.0-alpha.20, `event` and `context` reads in transition args are fully
|
|
30
|
-
* typed, while returned context patches are property-typed but still carry a
|
|
31
|
-
* loose index signature in the alpha itself. Expect that to tighten upstream
|
|
32
|
-
* without changes here.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```typescript
|
|
36
|
-
* import { setup, types } from "xstate";
|
|
37
|
-
* import { createRoutedMachine, playMetaSchema, playRouteEventSchema } from "@xmachines/play-xstate";
|
|
38
|
-
*
|
|
39
|
-
* const authSetup = setup({
|
|
40
|
-
* schemas: {
|
|
41
|
-
* context: types<{ isAuthenticated: boolean }>(),
|
|
42
|
-
* events: { "play.route": playRouteEventSchema },
|
|
43
|
-
* meta: playMetaSchema,
|
|
44
|
-
* },
|
|
45
|
-
* });
|
|
46
|
-
*
|
|
47
|
-
* const machine = createRoutedMachine(authSetup)({
|
|
48
|
-
* initial: "home",
|
|
49
|
-
* context: { isAuthenticated: false },
|
|
50
|
-
* states: {
|
|
51
|
-
* home: { id: "home", meta: { route: "/" } },
|
|
52
|
-
* login: { id: "login", meta: { route: "/login" } },
|
|
53
|
-
* },
|
|
54
|
-
* });
|
|
55
|
-
* // ({ context }) params in transitions infer from the setup schemas —
|
|
56
|
-
* // no explicit annotations needed.
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* Note: routes are injected at runtime, so the machine's static type does not
|
|
60
|
-
* gain an `xstate.route` event for them — `play.route` (declared in the
|
|
61
|
-
* setup's event schemas) remains the typed public API; native `xstate.route`
|
|
62
|
-
* interop is runtime-only.
|
|
63
|
-
*
|
|
64
|
-
* @param s - A `setup(...)` return value (anything with `createMachine`).
|
|
65
|
-
* @returns A function with the same signature as `s.createMachine` that
|
|
66
|
-
* applies {@link formatPlayRouteTransitions} before creating the machine.
|
|
67
|
-
*
|
|
68
|
-
* @see {@link formatPlayRouteTransitions} for the routing transform itself
|
|
69
|
-
*/
|
|
70
|
-
export declare const createRoutedMachine: <TSetup extends SetupLike>(s: TSetup) => TSetup["createMachine"];
|
|
71
|
-
//# sourceMappingURL=create-routed-machine.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-routed-machine.d.ts","sourceRoot":"","sources":["../../src/routing/create-routed-machine.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG;IAGvB,aAAa,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC;CAC7C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,SAAS,SAAS,EAAE,GAAG,MAAM,KAAG,MAAM,CAAC,eAAe,CASjE,CAAC"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { formatPlayRouteTransitions, } from "./format-play-route-transitions.js";
|
|
2
|
-
/**
|
|
3
|
-
* Returns a `createMachine` that routes: identical signature to the setup's
|
|
4
|
-
* own `createMachine`, with {@link formatPlayRouteTransitions} applied to the
|
|
5
|
-
* config at runtime.
|
|
6
|
-
*
|
|
7
|
-
* ### Why this exists
|
|
8
|
-
*
|
|
9
|
-
* `formatPlayRouteTransitions(config)` accepts a loosely-typed config. A config
|
|
10
|
-
* authored as a standalone value loses inline transition-function parameter
|
|
11
|
-
* inference entirely (implicit-any under strict mode), and even the inline
|
|
12
|
-
* `setup().createMachine(formatPlayRouteTransitions({ ... }))` form depends on
|
|
13
|
-
* TypeScript threading contextual typing through two generic calls.
|
|
14
|
-
*
|
|
15
|
-
* This wrapper removes the question: it is typed as the setup's own
|
|
16
|
-
* `createMachine`, so the config is contextually typed exactly as if passed to
|
|
17
|
-
* `setup().createMachine(...)` directly — transition-function args infer from
|
|
18
|
-
* the setup's schemas, sibling targets are validated, and the returned machine
|
|
19
|
-
* keeps its full literal state-value typing.
|
|
20
|
-
*
|
|
21
|
-
* Typing is *identical to native* — including its current gaps: as of xstate
|
|
22
|
-
* 6.0.0-alpha.20, `event` and `context` reads in transition args are fully
|
|
23
|
-
* typed, while returned context patches are property-typed but still carry a
|
|
24
|
-
* loose index signature in the alpha itself. Expect that to tighten upstream
|
|
25
|
-
* without changes here.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* import { setup, types } from "xstate";
|
|
30
|
-
* import { createRoutedMachine, playMetaSchema, playRouteEventSchema } from "@xmachines/play-xstate";
|
|
31
|
-
*
|
|
32
|
-
* const authSetup = setup({
|
|
33
|
-
* schemas: {
|
|
34
|
-
* context: types<{ isAuthenticated: boolean }>(),
|
|
35
|
-
* events: { "play.route": playRouteEventSchema },
|
|
36
|
-
* meta: playMetaSchema,
|
|
37
|
-
* },
|
|
38
|
-
* });
|
|
39
|
-
*
|
|
40
|
-
* const machine = createRoutedMachine(authSetup)({
|
|
41
|
-
* initial: "home",
|
|
42
|
-
* context: { isAuthenticated: false },
|
|
43
|
-
* states: {
|
|
44
|
-
* home: { id: "home", meta: { route: "/" } },
|
|
45
|
-
* login: { id: "login", meta: { route: "/login" } },
|
|
46
|
-
* },
|
|
47
|
-
* });
|
|
48
|
-
* // ({ context }) params in transitions infer from the setup schemas —
|
|
49
|
-
* // no explicit annotations needed.
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* Note: routes are injected at runtime, so the machine's static type does not
|
|
53
|
-
* gain an `xstate.route` event for them — `play.route` (declared in the
|
|
54
|
-
* setup's event schemas) remains the typed public API; native `xstate.route`
|
|
55
|
-
* interop is runtime-only.
|
|
56
|
-
*
|
|
57
|
-
* @param s - A `setup(...)` return value (anything with `createMachine`).
|
|
58
|
-
* @returns A function with the same signature as `s.createMachine` that
|
|
59
|
-
* applies {@link formatPlayRouteTransitions} before creating the machine.
|
|
60
|
-
*
|
|
61
|
-
* @see {@link formatPlayRouteTransitions} for the routing transform itself
|
|
62
|
-
*/
|
|
63
|
-
export const createRoutedMachine = (s) =>
|
|
64
|
-
// The runtime transform only ADDS behavior (native route configs + the
|
|
65
|
-
// play.route forwarder) and preserves the config's own shape, so exposing
|
|
66
|
-
// the setup's exact createMachine signature keeps native config typing.
|
|
67
|
-
((config) =>
|
|
68
|
-
// One internal widening cast: the `never[]` constraint that keeps
|
|
69
|
-
// SetupLike any-free also makes the parameter uncallable directly.
|
|
70
|
-
s.createMachine(formatPlayRouteTransitions(config)));
|
|
71
|
-
//# sourceMappingURL=create-routed-machine.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-routed-machine.js","sourceRoot":"","sources":["../../src/routing/create-routed-machine.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,0BAA0B,GAE1B,MAAM,oCAAoC,CAAC;AAa5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAA2B,CAAS,EAA2B,EAAE;AACnG,uEAAuE;AACvE,0EAA0E;AAC1E,wEAAwE;AACxE,CAAC,CAAC,MAA0B,EAAE,EAAE;AAC/B,kEAAkE;AAClE,mEAAmE;AAClE,CAAC,CAAC,aAA8C,CAChD,0BAA0B,CAAC,MAAM,CAAC,CAClC,CAA4B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"play-route-event.typecheck.d.ts","sourceRoot":"","sources":["../../src/routing/play-route-event.typecheck.ts"],"names":[],"mappings":""}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type-level contract for the play.route event payload as machines receive it
|
|
3
|
-
* through playRouteEventSchema. Pins the requirements the hand-written v5
|
|
4
|
-
* union enforced: `to` is required and string-typed; params/query/match are
|
|
5
|
-
* omittable; values constructed as PlayRouteEvent (router bridges) remain
|
|
6
|
-
* assignable.
|
|
7
|
-
*/
|
|
8
|
-
import { setup } from "xstate";
|
|
9
|
-
import { playRouteEventSchema } from "./schemas.js";
|
|
10
|
-
const s = setup({
|
|
11
|
-
schemas: {
|
|
12
|
-
events: { "play.route": playRouteEventSchema },
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
const m = s.createMachine({ initial: "a", states: { a: {} } });
|
|
16
|
-
// Minimal send: optional payload fields are omittable.
|
|
17
|
-
const minimal = { type: "play.route", to: "#home" };
|
|
18
|
-
// Full send: every documented field accepted.
|
|
19
|
-
const full = {
|
|
20
|
-
type: "play.route",
|
|
21
|
-
to: "#profile",
|
|
22
|
-
params: { username: "alice" },
|
|
23
|
-
query: { tab: "posts" },
|
|
24
|
-
match: {},
|
|
25
|
-
};
|
|
26
|
-
// @ts-expect-error `to` is required — a routeless play.route must not compile
|
|
27
|
-
const missingTo = { type: "play.route" };
|
|
28
|
-
// @ts-expect-error `to` must be a string
|
|
29
|
-
const badTo = { type: "play.route", to: 123 };
|
|
30
|
-
const badParams = {
|
|
31
|
-
type: "play.route",
|
|
32
|
-
to: "#p",
|
|
33
|
-
// @ts-expect-error `params` values must be strings
|
|
34
|
-
params: { n: 42 },
|
|
35
|
-
};
|
|
36
|
-
const fromBridge = bridgeEvent;
|
|
37
|
-
void fromBridge;
|
|
38
|
-
void minimal;
|
|
39
|
-
void full;
|
|
40
|
-
void missingTo;
|
|
41
|
-
void badTo;
|
|
42
|
-
void badParams;
|
|
43
|
-
//# sourceMappingURL=play-route-event.typecheck.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"play-route-event.typecheck.js","sourceRoot":"","sources":["../../src/routing/play-route-event.typecheck.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,EAAuB,MAAM,QAAQ,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,CAAC,GAAG,KAAK,CAAC;IACf,OAAO,EAAE;QACR,MAAM,EAAE,EAAE,YAAY,EAAE,oBAAoB,EAAE;KAC9C;CACD,CAAC,CAAC;AACH,MAAM,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAG/D,uDAAuD;AACvD,MAAM,OAAO,GAAyB,EAAE,IAAI,EAAE,YAAY,EAAE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