@xmachines/play-router 4.0.0 → 5.0.1
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 +25 -14
- package/dist/base-route-map.d.ts +17 -12
- package/dist/base-route-map.d.ts.map +1 -1
- package/dist/base-route-map.js +101 -25
- package/dist/base-route-map.js.map +1 -1
- package/dist/create-route-map-from-tree.d.ts +1 -1
- package/dist/create-route-map-from-tree.js +1 -1
- package/dist/errors.js +3 -3
- package/dist/errors.js.map +1 -1
- package/dist/find-route.d.ts +13 -1
- package/dist/find-route.d.ts.map +1 -1
- package/dist/find-route.js +22 -10
- package/dist/find-route.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/provider-lifecycle.d.ts +13 -5
- package/dist/provider-lifecycle.d.ts.map +1 -1
- package/dist/provider-lifecycle.js +9 -4
- package/dist/provider-lifecycle.js.map +1 -1
- package/dist/router-bridge-base.d.ts +36 -20
- package/dist/router-bridge-base.d.ts.map +1 -1
- package/dist/router-bridge-base.js +79 -72
- package/dist/router-bridge-base.js.map +1 -1
- package/dist/router-sync.d.ts +2 -26
- package/dist/router-sync.d.ts.map +1 -1
- package/dist/router-sync.js +8 -41
- package/dist/router-sync.js.map +1 -1
- package/dist/types.d.ts +31 -26
- package/dist/types.d.ts.map +1 -1
- package/dist/xstate/create-route-map.d.ts +2 -2
- package/dist/xstate/create-route-map.d.ts.map +1 -1
- package/dist/xstate/create-route-map.js +6 -3
- package/dist/xstate/create-route-map.js.map +1 -1
- package/dist/xstate/extract-routes.d.ts +2 -1
- package/dist/xstate/extract-routes.d.ts.map +1 -1
- package/dist/xstate/extract-routes.js +5 -5
- package/dist/xstate/extract-routes.js.map +1 -1
- package/package.json +15 -12
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @see [Multi-router integration](../../docs/examples/multi-router-integration.md)
|
|
19
19
|
*/
|
|
20
|
-
import { type BasePathOptions } from "@xmachines/play-url";
|
|
20
|
+
import { type BasePathOptions, type CompileOptions } from "@xmachines/play-url";
|
|
21
|
+
import type { RouterBridgeOptions } from "./router-bridge-base.js";
|
|
21
22
|
import { DISPOSE } from "@xmachines/play";
|
|
22
23
|
import type { MountableRouterBridge, RoutableActor, RouterBridge } from "./types.js";
|
|
23
24
|
import type { RouteMap } from "./base-route-map.js";
|
|
@@ -31,7 +32,7 @@ import type { RouteMap } from "./base-route-map.js";
|
|
|
31
32
|
* An adapter re-exports a two-parameter alias of this type, with `TRouter` bound to
|
|
32
33
|
* the type of its router instance and `TNode` bound to its own node type.
|
|
33
34
|
*/
|
|
34
|
-
export interface PlayRouterProviderBaseProps<TRouter, TActor extends RoutableActor, TNode> {
|
|
35
|
+
export interface PlayRouterProviderBaseProps<TRouter, TActor extends RoutableActor, TNode> extends CompileOptions {
|
|
35
36
|
/**
|
|
36
37
|
* The actor to keep in step with the router. It must be a stable reference: give
|
|
37
38
|
* the same actor instance on every render. An actor in the JSX, or a new actor on
|
|
@@ -95,13 +96,20 @@ export interface PlayRouterProviderBaseProps<TRouter, TActor extends RoutableAct
|
|
|
95
96
|
* type of that actor reaches the bridge whole. A bridge that reads no spec binds nothing
|
|
96
97
|
* and receives the default.
|
|
97
98
|
*
|
|
99
|
+
* The options are {@link RouterBridgeOptions}, because that is what
|
|
100
|
+
* {@link openProviderBridge} hands to the constructor: the base path AND the caches of a
|
|
101
|
+
* parse and a compilation. A `BasePathOptions` here named half of the value that travels,
|
|
102
|
+
* so a bridge author read the type and learned of no cache. A bridge that declares the
|
|
103
|
+
* narrower `BasePathOptions` still satisfies this type, and it reads the fields that it
|
|
104
|
+
* knows.
|
|
105
|
+
*
|
|
98
106
|
* The return type is `RouterBridge`, the published contract of a bridge, so a
|
|
99
107
|
* consumer bridge of its own keeps compiling. Every bridge on `RouterBridgeBase` also
|
|
100
108
|
* satisfies `MountableRouterBridge`, and the provider finds that mount API at run
|
|
101
109
|
* time: a bridge without it ignores `basePath`, exactly as it did before the option
|
|
102
110
|
* existed.
|
|
103
111
|
*/
|
|
104
|
-
export type PlayRouterBridgeConstructor<TRouter, TActor extends RoutableActor = RoutableActor> = new (router: TRouter, actor: TActor, routeMap: RouteMap, options?:
|
|
112
|
+
export type PlayRouterBridgeConstructor<TRouter, TActor extends RoutableActor = RoutableActor> = new (router: TRouter, actor: TActor, routeMap: RouteMap, options?: RouterBridgeOptions) => RouterBridge;
|
|
105
113
|
/**
|
|
106
114
|
* Tells you whether a bridge can move its mount.
|
|
107
115
|
*
|
|
@@ -122,7 +130,7 @@ export declare function isMountableBridge(bridge: RouterBridge | null | undefine
|
|
|
122
130
|
*/
|
|
123
131
|
export declare function mountKey(basePath?: BasePathOptions["basePath"], basePathParams?: BasePathOptions["basePathParams"]): string;
|
|
124
132
|
/** What {@link openProviderBridge} needs to build and connect a bridge. */
|
|
125
|
-
export interface OpenProviderBridgeArgs<TRouter, TActor extends RoutableActor> extends
|
|
133
|
+
export interface OpenProviderBridgeArgs<TRouter, TActor extends RoutableActor> extends RouterBridgeOptions {
|
|
126
134
|
router: TRouter;
|
|
127
135
|
actor: TActor;
|
|
128
136
|
routeMap: RouteMap;
|
|
@@ -137,7 +145,7 @@ export interface OpenProviderBridgeArgs<TRouter, TActor extends RoutableActor> e
|
|
|
137
145
|
*
|
|
138
146
|
* @returns The bridge, and a `close` that disconnects it one time.
|
|
139
147
|
*/
|
|
140
|
-
export declare function openProviderBridge<TRouter, TActor extends RoutableActor>(BridgeCtor: PlayRouterBridgeConstructor<TRouter, TActor>, { router, actor, routeMap,
|
|
148
|
+
export declare function openProviderBridge<TRouter, TActor extends RoutableActor>(BridgeCtor: PlayRouterBridgeConstructor<TRouter, TActor>, { router, actor, routeMap, ...options }: OpenProviderBridgeArgs<TRouter, TActor>): {
|
|
141
149
|
bridge: RouterBridge;
|
|
142
150
|
close: () => void;
|
|
143
151
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-lifecycle.d.ts","sourceRoot":"","sources":["../src/provider-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"provider-lifecycle.d.ts","sourceRoot":"","sources":["../src/provider-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAqB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAa,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;;;;GASG;AACH,MAAM,WAAW,2BAA2B,CAC3C,OAAO,EACP,MAAM,SAAS,aAAa,EAC5B,KAAK,CACJ,SAAQ,cAAc;IACvB;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,uGAAuG;IACvG,MAAM,EAAE,OAAO,CAAC;IAChB;;;;;;;;;;;OAWG;IACH,QAAQ,EAAE,QAAQ,CAAC;IACnB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACjD,+EAA+E;IAC/E,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,KAAK,CAAC;CACpD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,2BAA2B,CACtC,OAAO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;IAChC,uFAAuF;IACvF,IAAI,IAAI,CAAC;IACT,iCAAiC;IACjC,UAAU,IAAI,IAAI,CAAC;IACnB;;;;;;;;;;;;;;;OAeG;IACH,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;IAClB,wFAAwF;IACxF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1D,4DAA4D;IAC5D,WAAW,CACV,QAAQ,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,EACtC,cAAc,CAAC,EAAE,eAAe,CAAC,gBAAgB,CAAC,GAChD,IAAI,CAAC;CACR;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,qBAAqB,GAAG,gBAAgB,CA8BtF"}
|
|
@@ -74,8 +74,13 @@ export function mountKey(basePath, basePathParams) {
|
|
|
74
74
|
*
|
|
75
75
|
* @returns The bridge, and a `close` that disconnects it one time.
|
|
76
76
|
*/
|
|
77
|
-
export function openProviderBridge(BridgeCtor, { router, actor, routeMap,
|
|
78
|
-
|
|
77
|
+
export function openProviderBridge(BridgeCtor, { router, actor, routeMap, ...options }) {
|
|
78
|
+
// The REST travels whole, rather than two named fields. A bridge takes a base path and
|
|
79
|
+
// the caches of a parse and a compilation, and a provider is the place a server builds
|
|
80
|
+
// one for each request — the case the caches exist for. A destructure of the two
|
|
81
|
+
// base-path fields dropped every cache in silence, so a provider of React, Solid, Vue
|
|
82
|
+
// or TanStack isolated nothing. A rest also carries whatever a later release adds.
|
|
83
|
+
const bridge = new BridgeCtor(router, actor, routeMap, options);
|
|
79
84
|
// A bridge on the three-argument signature drops the options object, and
|
|
80
85
|
// `PlayRouterBridgeConstructor` accepts one: it asks for the published `RouterBridge`,
|
|
81
86
|
// so a consumer bridge that never heard of `basePath` still compiles. Such a bridge
|
|
@@ -93,8 +98,8 @@ export function openProviderBridge(BridgeCtor, { router, actor, routeMap, basePa
|
|
|
93
98
|
// second refusal here would replace its error with an identical one from another
|
|
94
99
|
// stack. For a bridge with no mount the normalization can still throw, and a prefix
|
|
95
100
|
// that it refuses is a prefix all the same — the warning is the answer, not the throw.
|
|
96
|
-
if (!isMountableBridge(bridge) && hasPrefix(basePath)) {
|
|
97
|
-
console.warn(`[@xmachines/play-router] The provider received basePath "${basePath}", and ${BridgeCtor.name || "the bridge"} takes no mount: it has no setBasePath(), so the prefix is ignored and the bridge claims the whole router. Extend RouterBridgeBase, or drop the basePath prop.`);
|
|
101
|
+
if (!isMountableBridge(bridge) && hasPrefix(options.basePath)) {
|
|
102
|
+
console.warn(`[@xmachines/play-router] The provider received basePath "${options.basePath}", and ${BridgeCtor.name || "the bridge"} takes no mount: it has no setBasePath(), so the prefix is ignored and the bridge claims the whole router. Extend RouterBridgeBase, or drop the basePath prop.`);
|
|
98
103
|
}
|
|
99
104
|
void bridge.connect();
|
|
100
105
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-lifecycle.js","sourceRoot":"","sources":["../src/provider-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"provider-lifecycle.js","sourceRoot":"","sources":["../src/provider-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,iBAAiB,EAA6C,MAAM,qBAAqB,CAAC;AAEnG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AA2GrD;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAChC,MAAuC;IAEvC,oFAAoF;IACpF,uFAAuF;IACvF,sCAAsC;IACtC,OAAO,MAAM,IAAI,IAAI,IAAI,OAAQ,MAAgC,CAAC,WAAW,KAAK,UAAU,CAAC;AAC9F,CAAC;AAED;;;;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AAC,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAqB,EAAE;QACzE,UAAU,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE;QACnD,QAAQ,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE;QAC1D,cAAc,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE;QACtE,WAAW,EAAE;YACZ,KAAK,EAAE,CACN,QAAsC,EACtC,cAAkD,EACjD,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,cAAc,CAAC;YACjD,UAAU,EAAE,IAAI;SAChB;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The class holds the logic that each router bridge shares, and that is 90% of the
|
|
5
5
|
* code of every bridge:
|
|
6
|
-
* - The
|
|
6
|
+
* - The atom watcher of the direction from the actor to the router
|
|
7
7
|
* - `lastSyncedPath`, for the echo suppression in the direction from the actor to the router
|
|
8
8
|
* - The `isProcessingNavigation` flag, which stops a loop of a guard redirect in `syncActorFromRouter` only
|
|
9
9
|
* - `syncRouterFromActor` and `syncActorFromRouter`, with the read of each URL parameter
|
|
@@ -42,24 +42,33 @@
|
|
|
42
42
|
*
|
|
43
43
|
* @see [Play RFC](../../docs/rfc/play.md) - invariant INV-04
|
|
44
44
|
*/
|
|
45
|
-
import { type BasePathOptions } from "@xmachines/play-url";
|
|
46
|
-
import {
|
|
45
|
+
import { type CompileOptions, type BasePathOptions } from "@xmachines/play-url";
|
|
46
|
+
import type { ReadonlyAtom } from "@xmachines/play-atom";
|
|
47
47
|
import type { MountableRouterBridge, RoutableActor } from "./types.js";
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* What a bridge takes beside the actor and the route map.
|
|
50
|
+
*
|
|
51
|
+
* It is {@link BasePathOptions} with the caches of {@link CompileOptions} added: the parse
|
|
52
|
+
* cache AND the compiled cache. A base path and a cache are two different questions, and
|
|
53
|
+
* this type joins them at the ONE place that asks both: the constructor of a bridge.
|
|
54
|
+
*/
|
|
55
|
+
export interface RouterBridgeOptions extends BasePathOptions, CompileOptions {
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The narrow interface of the atom watcher. `RouterBridgeBase` uses it to
|
|
50
59
|
* observe each change of `actor.currentRoute`.
|
|
51
60
|
*
|
|
52
|
-
* The interface hides the
|
|
61
|
+
* The interface hides the whole subscription surface of the atom. It exposes the
|
|
53
62
|
* two operations that `RouterBridgeBase` needs:
|
|
54
|
-
* - `watch(
|
|
63
|
+
* - `watch(atom)` — it starts the watch of one atom
|
|
55
64
|
* - `unwatch()` — it stops the watch and frees the resources
|
|
56
65
|
*
|
|
57
66
|
* A framework adapter subclass touches this handle never. `RouterBridgeBase` makes
|
|
58
67
|
* it and manages it internally.
|
|
59
68
|
*/
|
|
60
69
|
export interface RouteWatcherHandle {
|
|
61
|
-
/** Arms the watcher on the given
|
|
62
|
-
watch(
|
|
70
|
+
/** Arms the watcher on the given atom. */
|
|
71
|
+
watch(atom: ReadonlyAtom<string | null>): void;
|
|
63
72
|
/** Stops the observation and frees the watcher. */
|
|
64
73
|
unwatch(): void;
|
|
65
74
|
}
|
|
@@ -91,19 +100,19 @@ export declare abstract class RouterBridgeBase implements MountableRouterBridge
|
|
|
91
100
|
/**
|
|
92
101
|
* The raw value of `actor.currentRoute` that this bridge accounted for already.
|
|
93
102
|
*
|
|
94
|
-
* The field answers ONE question: "did the bridge see this value of the
|
|
103
|
+
* The field answers ONE question: "did the bridge see this value of the atom
|
|
95
104
|
* before?". It is therefore a string, and not a location — a route that resolves to
|
|
96
105
|
* no URL, such as an unknown stateId or a parameterized pattern, still stops a
|
|
97
106
|
* second attempt at the same value.
|
|
98
107
|
*
|
|
99
108
|
* The constructor and `connect()` seed it, so that the first fire of the watcher of
|
|
100
|
-
* the
|
|
109
|
+
* the atom pushes nothing for a route that moved nowhere.
|
|
101
110
|
*/
|
|
102
111
|
protected lastActorRoute: string | null;
|
|
103
112
|
/**
|
|
104
113
|
* The flag guards `syncActorFromRouter` against a re-entrant call from a guard
|
|
105
114
|
* redirect of the actor itself. Such a call has this sequence: the bridge sends to
|
|
106
|
-
* the actor, the
|
|
115
|
+
* the actor, the atom fires, the bridge pushes to the router, and a second
|
|
107
116
|
* `syncActorFromRouter` call starts before the first one returns.
|
|
108
117
|
*
|
|
109
118
|
* The flag is NOT the echo suppression of the direction from the actor to the
|
|
@@ -175,6 +184,13 @@ export declare abstract class RouterBridgeBase implements MountableRouterBridge
|
|
|
175
184
|
* the echo suppression therefore keeps comparing like with like.
|
|
176
185
|
*/
|
|
177
186
|
private mount;
|
|
187
|
+
/**
|
|
188
|
+
* The caches that every parse and every compilation of this bridge reads.
|
|
189
|
+
*
|
|
190
|
+
* `resolveNavigationPath` and `isActorAtPath` parse a CONCRETE location, and an
|
|
191
|
+
* application writes one for each value that it puts in a param.
|
|
192
|
+
*/
|
|
193
|
+
protected readonly compileOptions: CompileOptions;
|
|
178
194
|
/**
|
|
179
195
|
* @param actor - A `RoutableActor`, with `currentRoute`, `initialRoute`, and `send`.
|
|
180
196
|
* @param routeMap - The route map of both directions, for the resolution between a
|
|
@@ -187,7 +203,7 @@ export declare abstract class RouterBridgeBase implements MountableRouterBridge
|
|
|
187
203
|
constructor(actor: RoutableActor, routeMap: {
|
|
188
204
|
getStateIdByPath(path: string): string | null | undefined;
|
|
189
205
|
getPathByStateId(id: string): string | null | undefined;
|
|
190
|
-
}, options?:
|
|
206
|
+
}, options?: RouterBridgeOptions);
|
|
191
207
|
/**
|
|
192
208
|
* The resolved URL prefix that the machine of this bridge is mounted under, or `""`
|
|
193
209
|
* when the machine owns the complete router.
|
|
@@ -297,7 +313,7 @@ export declare abstract class RouterBridgeBase implements MountableRouterBridge
|
|
|
297
313
|
/**
|
|
298
314
|
* Connects the router bridge to the Actor.
|
|
299
315
|
*
|
|
300
|
-
* The method installs the
|
|
316
|
+
* The method installs the atom watcher of the direction from the actor to the
|
|
301
317
|
* router. It then starts the watch of the router changes, which each framework does
|
|
302
318
|
* in its own way.
|
|
303
319
|
*
|
|
@@ -341,12 +357,12 @@ export declare abstract class RouterBridgeBase implements MountableRouterBridge
|
|
|
341
357
|
/**
|
|
342
358
|
* Disconnects the router bridge from the Actor.
|
|
343
359
|
*
|
|
344
|
-
* The method stops the watch of the
|
|
360
|
+
* The method stops the watch of the atom, and it removes the router listener of the
|
|
345
361
|
* framework.
|
|
346
362
|
*/
|
|
347
363
|
disconnect(): void;
|
|
348
364
|
/**
|
|
349
|
-
* Writes the location of the router when the route
|
|
365
|
+
* Writes the location of the router when the route atom of the actor changes.
|
|
350
366
|
*
|
|
351
367
|
* The method resolves the actor route to a concrete URL path, then it calls
|
|
352
368
|
* navigateRouter() for the navigation of the framework. When it cannot resolve the
|
|
@@ -443,7 +459,7 @@ export declare abstract class RouterBridgeBase implements MountableRouterBridge
|
|
|
443
459
|
* literal `*` into the browser URL. The method still writes the raw route to
|
|
444
460
|
* lastActorRoute, and it leaves lastSyncedPath as it stands, because that field
|
|
445
461
|
* records a LOCATION and no location changed. Therefore the dedup guard fires
|
|
446
|
-
* correctly on the next identical value of the
|
|
462
|
+
* correctly on the next identical value of the atom.
|
|
447
463
|
*
|
|
448
464
|
* @param route - The raw value of the actor route.
|
|
449
465
|
* @param resolved - The concrete path of that route. The default resolves it here. A
|
|
@@ -584,10 +600,10 @@ export declare abstract class RouterBridgeBase implements MountableRouterBridge
|
|
|
584
600
|
* callback reports the pathname and the search SEPARATELY, and `sanitizePathname`
|
|
585
601
|
* removes the query. A comparison of the pathname alone therefore misses for every
|
|
586
602
|
* route with a query, and the push of this bridge comes back as a `play.route` event
|
|
587
|
-
* of its own navigation. That echo is not only wasted work:
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
603
|
+
* of its own navigation. That echo is not only wasted work: the bridge sends a
|
|
604
|
+
* `play.route` for a location that the actor stands on already, so every entry action
|
|
605
|
+
* of that state runs a second time, and a guard that refuses the repeat moves the
|
|
606
|
+
* actor to a state that no user asked for.
|
|
591
607
|
*
|
|
592
608
|
* The query is compared as a MAP, and not as a string: a framework can re-serialize
|
|
593
609
|
* a search string in another order, and `URLSearchParams` also accepts the form with
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-bridge-base.d.ts","sourceRoot":"","sources":["../src/router-bridge-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"router-bridge-base.d.ts","sourceRoot":"","sources":["../src/router-bridge-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAIN,KAAK,cAAc,EAMnB,KAAK,eAAe,EAEpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAQvE;;;;;;GAMG;AACH,MAAM,WAAW,mBAAoB,SAAQ,eAAe,EAAE,cAAc;CAAG;AAE/E;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,kBAAkB;IAClC,0CAA0C;IAC1C,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAC/C,mDAAmD;IACnD,OAAO,IAAI,IAAI,CAAC;CAChB;AA4BD,8BAAsB,gBAAiB,YAAW,qBAAqB;IA8HrE,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa;IACvC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE;QAC5B,gBAAgB,CAAC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