@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
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import type { PlayRouteEvent } from "@xmachines/play-router";
|
|
2
|
-
import type { PlaySpec } from "@xmachines/play-actor";
|
|
3
|
-
import type { RouteMetadata } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* Event schema for the `play.route` navigation event, for use in an XState v6
|
|
6
|
-
* `schemas.events` map.
|
|
7
|
-
*
|
|
8
|
-
* XState v6 declares machine events as a map of event type to payload schema
|
|
9
|
-
* (payloads exclude the `type` field). Every Play machine handles `play.route`,
|
|
10
|
-
* so this constant is the single source of truth for its payload shape —
|
|
11
|
-
* declare it instead of re-deriving the payload shape per machine. The payload
|
|
12
|
-
* is authored explicitly (not `Omit<PlayRouteEvent, "type">`): `Omit` over
|
|
13
|
-
* PlayRouteEvent's index signature collapses the named props and would erase
|
|
14
|
-
* all payload checking.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* import { setup } from "xstate";
|
|
19
|
-
* import {
|
|
20
|
-
* emptyEventSchema,
|
|
21
|
-
* playMetaSchema,
|
|
22
|
-
* playRouteEventSchema,
|
|
23
|
-
* } from "@xmachines/play-xstate";
|
|
24
|
-
*
|
|
25
|
-
* const authSetup = setup({
|
|
26
|
-
* schemas: {
|
|
27
|
-
* events: {
|
|
28
|
-
* "play.route": playRouteEventSchema,
|
|
29
|
-
* "auth.logout": emptyEventSchema,
|
|
30
|
-
* },
|
|
31
|
-
* meta: playMetaSchema,
|
|
32
|
-
* },
|
|
33
|
-
* });
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @see {@link playMetaSchema} for the companion state-meta schema
|
|
37
|
-
*/
|
|
38
|
-
/**
|
|
39
|
-
* Adds `TExtra` as an optional-by-union extension of `TBase`.
|
|
40
|
-
*
|
|
41
|
-
* XState v6's `InferEvents` wraps every event payload in `Required<>` (to
|
|
42
|
-
* undo Zod-style optional inference), which would make `?`-marked fields
|
|
43
|
-
* mandatory on every send. Encoding optionality as a union sidesteps that:
|
|
44
|
-
* `Required<>` distributes over the members, each of which is already fully
|
|
45
|
-
* required. Use it for your own event payload schemas with optional fields.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```typescript
|
|
49
|
-
* type SavePayload = WithOptional<{ id: string }, { draft: boolean }>;
|
|
50
|
-
* // accepts { id } and { id, draft } — and survives InferEvents' Required<>
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
export type WithOptional<TBase, TExtra> = TBase | (TBase & TExtra);
|
|
54
|
-
/**
|
|
55
|
-
* The `play.route` event payload as machines receive it: `to` required;
|
|
56
|
-
* `params`/`query`/`match` encoded as optional-by-union so they stay omittable
|
|
57
|
-
* through XState v6's `Required<>` event inference.
|
|
58
|
-
*/
|
|
59
|
-
export type PlayRoutePayload = WithOptional<WithOptional<WithOptional<{
|
|
60
|
-
to: PlayRouteEvent["to"];
|
|
61
|
-
}, {
|
|
62
|
-
params: Record<string, string>;
|
|
63
|
-
}>, {
|
|
64
|
-
query: Record<string, string>;
|
|
65
|
-
}>, {
|
|
66
|
-
match: unknown;
|
|
67
|
-
}>;
|
|
68
|
-
export declare const playRouteEventSchema: import("xstate").TypeSchema<PlayRoutePayload>;
|
|
69
|
-
/**
|
|
70
|
-
* State meta schema for Play's routing/view metadata, for use as an XState v6
|
|
71
|
-
* `schemas.meta` declaration.
|
|
72
|
-
*
|
|
73
|
-
* XState v6 types state `meta` as `never` unless a meta schema is declared, so
|
|
74
|
-
* every machine that carries `meta.route` templates or `meta.view` specs needs
|
|
75
|
-
* this schema. `route` accepts both the string template form
|
|
76
|
-
* (`"/profile/:username"`) and the object form (`{ path, title }` — see
|
|
77
|
-
* {@link RouteMetadata}); `view` is a Play view {@link PlaySpec}.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* ```typescript
|
|
81
|
-
* import { createMachine } from "xstate";
|
|
82
|
-
* import { playMetaSchema } from "@xmachines/play-xstate";
|
|
83
|
-
*
|
|
84
|
-
* const machine = createMachine({
|
|
85
|
-
* schemas: { meta: playMetaSchema },
|
|
86
|
-
* initial: "home",
|
|
87
|
-
* states: {
|
|
88
|
-
* home: { id: "home", meta: { route: "/" } },
|
|
89
|
-
* },
|
|
90
|
-
* });
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* @see {@link playRouteEventSchema} for the companion `play.route` event schema
|
|
94
|
-
*/
|
|
95
|
-
export declare const playMetaSchema: import("xstate").TypeSchema<{
|
|
96
|
-
route?: RouteMetadata;
|
|
97
|
-
view?: PlaySpec;
|
|
98
|
-
}>;
|
|
99
|
-
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/routing/schemas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,YAAY,CAAC,KAAK,EAAE,MAAM,IAAI,KAAK,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;AAEnE;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAC1C,YAAY,CACX,YAAY,CAAC;IAAE,EAAE,EAAE,cAAc,CAAC,IAAI,CAAC,CAAA;CAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC,EAC9E;IAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CACjC,EACD;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,CAClB,CAAC;AAEF,eAAO,MAAM,oBAAoB,+CAA4B,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,cAAc;YAAmB,aAAa;WAAS,QAAQ;EAAK,CAAC"}
|
package/dist/routing/schemas.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { types } from "xstate";
|
|
2
|
-
export const playRouteEventSchema = types();
|
|
3
|
-
/**
|
|
4
|
-
* State meta schema for Play's routing/view metadata, for use as an XState v6
|
|
5
|
-
* `schemas.meta` declaration.
|
|
6
|
-
*
|
|
7
|
-
* XState v6 types state `meta` as `never` unless a meta schema is declared, so
|
|
8
|
-
* every machine that carries `meta.route` templates or `meta.view` specs needs
|
|
9
|
-
* this schema. `route` accepts both the string template form
|
|
10
|
-
* (`"/profile/:username"`) and the object form (`{ path, title }` — see
|
|
11
|
-
* {@link RouteMetadata}); `view` is a Play view {@link PlaySpec}.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import { createMachine } from "xstate";
|
|
16
|
-
* import { playMetaSchema } from "@xmachines/play-xstate";
|
|
17
|
-
*
|
|
18
|
-
* const machine = createMachine({
|
|
19
|
-
* schemas: { meta: playMetaSchema },
|
|
20
|
-
* initial: "home",
|
|
21
|
-
* states: {
|
|
22
|
-
* home: { id: "home", meta: { route: "/" } },
|
|
23
|
-
* },
|
|
24
|
-
* });
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @see {@link playRouteEventSchema} for the companion `play.route` event schema
|
|
28
|
-
*/
|
|
29
|
-
export const playMetaSchema = types();
|
|
30
|
-
//# sourceMappingURL=schemas.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/routing/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAqE/B,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAAoB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAA8C,CAAC"}
|
package/dist/schemas.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Event schema for a payload-less event, for use in an XState v6
|
|
3
|
-
* `schemas.events` map.
|
|
4
|
-
*
|
|
5
|
-
* Most Play machines carry events with no payload (`auth.logout`, `timer`,
|
|
6
|
-
* …) — declare them with this constant instead of re-spelling
|
|
7
|
-
* `types<Record<string, never>>()` per event.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* import { setup } from "xstate";
|
|
12
|
-
* import { emptyEventSchema, playRouteEventSchema } from "@xmachines/play-xstate";
|
|
13
|
-
*
|
|
14
|
-
* setup({
|
|
15
|
-
* schemas: {
|
|
16
|
-
* events: {
|
|
17
|
-
* "play.route": playRouteEventSchema,
|
|
18
|
-
* "auth.logout": emptyEventSchema,
|
|
19
|
-
* },
|
|
20
|
-
* },
|
|
21
|
-
* });
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @see {@link playRouteEventSchema} and {@link playMetaSchema} for the routing
|
|
25
|
-
* schema constants
|
|
26
|
-
*/
|
|
27
|
-
export declare const emptyEventSchema: import("xstate").TypeSchema<Record<string, never>>;
|
|
28
|
-
//# sourceMappingURL=schemas.d.ts.map
|
package/dist/schemas.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,gBAAgB,oDAAiC,CAAC"}
|
package/dist/schemas.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { types } from "xstate";
|
|
2
|
-
/**
|
|
3
|
-
* Event schema for a payload-less event, for use in an XState v6
|
|
4
|
-
* `schemas.events` map.
|
|
5
|
-
*
|
|
6
|
-
* Most Play machines carry events with no payload (`auth.logout`, `timer`,
|
|
7
|
-
* …) — declare them with this constant instead of re-spelling
|
|
8
|
-
* `types<Record<string, never>>()` per event.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* import { setup } from "xstate";
|
|
13
|
-
* import { emptyEventSchema, playRouteEventSchema } from "@xmachines/play-xstate";
|
|
14
|
-
*
|
|
15
|
-
* setup({
|
|
16
|
-
* schemas: {
|
|
17
|
-
* events: {
|
|
18
|
-
* "play.route": playRouteEventSchema,
|
|
19
|
-
* "auth.logout": emptyEventSchema,
|
|
20
|
-
* },
|
|
21
|
-
* },
|
|
22
|
-
* });
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @see {@link playRouteEventSchema} and {@link playMetaSchema} for the routing
|
|
26
|
-
* schema constants
|
|
27
|
-
*/
|
|
28
|
-
export const emptyEventSchema = types();
|
|
29
|
-
//# sourceMappingURL=schemas.js.map
|
package/dist/schemas.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAyB,CAAC"}
|