@xmachines/play-router 2.2.0 → 4.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/README.md +103 -109
- package/dist/base-route-map.d.ts +7 -1
- package/dist/base-route-map.d.ts.map +1 -1
- package/dist/base-route-map.js +25 -12
- package/dist/base-route-map.js.map +1 -1
- package/dist/build-tree.d.ts +16 -1
- package/dist/build-tree.d.ts.map +1 -1
- package/dist/build-tree.js +23 -6
- package/dist/build-tree.js.map +1 -1
- package/dist/create-route-map-from-tree.d.ts +12 -6
- package/dist/create-route-map-from-tree.d.ts.map +1 -1
- package/dist/create-route-map-from-tree.js +13 -5
- package/dist/create-route-map-from-tree.js.map +1 -1
- package/dist/errors.d.ts +2 -134
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +11 -151
- package/dist/errors.js.map +1 -1
- package/dist/find-route.d.ts.map +1 -1
- package/dist/find-route.js +14 -19
- package/dist/find-route.js.map +1 -1
- package/dist/index.d.ts +7 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -11
- package/dist/index.js.map +1 -1
- package/dist/provider-lifecycle.d.ts +28 -6
- package/dist/provider-lifecycle.d.ts.map +1 -1
- package/dist/provider-lifecycle.js +16 -2
- package/dist/provider-lifecycle.js.map +1 -1
- package/dist/router-bridge-base.d.ts +42 -23
- package/dist/router-bridge-base.d.ts.map +1 -1
- package/dist/router-bridge-base.js +257 -84
- package/dist/router-bridge-base.js.map +1 -1
- package/dist/router-sync.d.ts +1 -1
- package/dist/router-sync.d.ts.map +1 -1
- package/dist/router-sync.js +28 -13
- package/dist/router-sync.js.map +1 -1
- package/dist/types.d.ts +186 -87
- package/dist/types.d.ts.map +1 -1
- package/dist/{create-route-map.d.ts → xstate/create-route-map.d.ts} +6 -20
- package/dist/xstate/create-route-map.d.ts.map +1 -0
- package/dist/{create-route-map.js → xstate/create-route-map.js} +5 -3
- package/dist/xstate/create-route-map.js.map +1 -0
- package/dist/{extract-routes.d.ts → xstate/extract-routes.d.ts} +3 -2
- package/dist/xstate/extract-routes.d.ts.map +1 -0
- package/dist/{extract-routes.js → xstate/extract-routes.js} +8 -3
- package/dist/xstate/extract-routes.js.map +1 -0
- package/dist/xstate/index.d.ts +35 -0
- package/dist/xstate/index.d.ts.map +1 -0
- package/dist/xstate/index.js +33 -0
- package/dist/xstate/index.js.map +1 -0
- package/dist/{machine-to-graph.d.ts → xstate/machine-to-graph.d.ts} +1 -1
- package/dist/xstate/machine-to-graph.d.ts.map +1 -0
- package/dist/{machine-to-graph.js → xstate/machine-to-graph.js} +2 -2
- package/dist/xstate/machine-to-graph.js.map +1 -0
- package/dist/xstate/machine-types.d.ts +42 -0
- package/dist/xstate/machine-types.d.ts.map +1 -0
- package/dist/xstate/machine-types.js +2 -0
- package/dist/xstate/machine-types.js.map +1 -0
- package/dist/{query.d.ts → xstate/query.d.ts} +6 -4
- package/dist/xstate/query.d.ts.map +1 -0
- package/dist/{query.js → xstate/query.js} +3 -2
- package/dist/xstate/query.js.map +1 -0
- package/package.json +26 -20
- package/dist/base-path.d.ts +0 -209
- package/dist/base-path.d.ts.map +0 -1
- package/dist/base-path.js +0 -418
- package/dist/base-path.js.map +0 -1
- package/dist/create-route-map.d.ts.map +0 -1
- package/dist/create-route-map.js.map +0 -1
- package/dist/extract-routes.d.ts.map +0 -1
- package/dist/extract-routes.js.map +0 -1
- package/dist/framework-params.d.ts +0 -144
- package/dist/framework-params.d.ts.map +0 -1
- package/dist/framework-params.js +0 -291
- package/dist/framework-params.js.map +0 -1
- package/dist/machine-to-graph.d.ts.map +0 -1
- package/dist/machine-to-graph.js.map +0 -1
- package/dist/query.d.ts.map +0 -1
- package/dist/query.js.map +0 -1
- package/dist/url-pattern-utils.d.ts +0 -93
- package/dist/url-pattern-utils.d.ts.map +0 -1
- package/dist/url-pattern-utils.js +0 -233
- package/dist/url-pattern-utils.js.map +0 -1
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @see [Multi-router integration](../../docs/examples/multi-router-integration.md)
|
|
19
19
|
*/
|
|
20
|
-
import { type BasePathOptions } from "
|
|
21
|
-
import
|
|
20
|
+
import { type BasePathOptions } from "@xmachines/play-url";
|
|
21
|
+
import { DISPOSE } from "@xmachines/play";
|
|
22
|
+
import type { MountableRouterBridge, RoutableActor, RouterBridge } from "./types.js";
|
|
22
23
|
import type { RouteMap } from "./base-route-map.js";
|
|
23
24
|
/**
|
|
24
25
|
* The props that every `PlayRouterProvider` of a framework shares.
|
|
@@ -30,7 +31,7 @@ import type { RouteMap } from "./base-route-map.js";
|
|
|
30
31
|
* An adapter re-exports a two-parameter alias of this type, with `TRouter` bound to
|
|
31
32
|
* the type of its router instance and `TNode` bound to its own node type.
|
|
32
33
|
*/
|
|
33
|
-
export interface PlayRouterProviderBaseProps<TRouter, TActor extends
|
|
34
|
+
export interface PlayRouterProviderBaseProps<TRouter, TActor extends RoutableActor, TNode> {
|
|
34
35
|
/**
|
|
35
36
|
* The actor to keep in step with the router. It must be a stable reference: give
|
|
36
37
|
* the same actor instance on every render. An actor in the JSX, or a new actor on
|
|
@@ -90,13 +91,17 @@ export interface PlayRouterProviderBaseProps<TRouter, TActor extends PlayActor,
|
|
|
90
91
|
/**
|
|
91
92
|
* The constructor shape that a bridge class must satisfy for a provider factory: `(router, actor, routeMap, options?) → RouterBridge`.
|
|
92
93
|
*
|
|
94
|
+
* `TActor` carries the actor type of the caller through to the constructor, so the spec
|
|
95
|
+
* type of that actor reaches the bridge whole. A bridge that reads no spec binds nothing
|
|
96
|
+
* and receives the default.
|
|
97
|
+
*
|
|
93
98
|
* The return type is `RouterBridge`, the published contract of a bridge, so a
|
|
94
99
|
* consumer bridge of its own keeps compiling. Every bridge on `RouterBridgeBase` also
|
|
95
100
|
* satisfies `MountableRouterBridge`, and the provider finds that mount API at run
|
|
96
101
|
* time: a bridge without it ignores `basePath`, exactly as it did before the option
|
|
97
102
|
* existed.
|
|
98
103
|
*/
|
|
99
|
-
export type PlayRouterBridgeConstructor<TRouter> = new (router: TRouter, actor:
|
|
104
|
+
export type PlayRouterBridgeConstructor<TRouter, TActor extends RoutableActor = RoutableActor> = new (router: TRouter, actor: TActor, routeMap: RouteMap, options?: BasePathOptions) => RouterBridge;
|
|
100
105
|
/**
|
|
101
106
|
* Tells you whether a bridge can move its mount.
|
|
102
107
|
*
|
|
@@ -117,7 +122,7 @@ export declare function isMountableBridge(bridge: RouterBridge | null | undefine
|
|
|
117
122
|
*/
|
|
118
123
|
export declare function mountKey(basePath?: BasePathOptions["basePath"], basePathParams?: BasePathOptions["basePathParams"]): string;
|
|
119
124
|
/** What {@link openProviderBridge} needs to build and connect a bridge. */
|
|
120
|
-
export interface OpenProviderBridgeArgs<TRouter, TActor extends
|
|
125
|
+
export interface OpenProviderBridgeArgs<TRouter, TActor extends RoutableActor> extends BasePathOptions {
|
|
121
126
|
router: TRouter;
|
|
122
127
|
actor: TActor;
|
|
123
128
|
routeMap: RouteMap;
|
|
@@ -132,7 +137,7 @@ export interface OpenProviderBridgeArgs<TRouter, TActor extends PlayActor> exten
|
|
|
132
137
|
*
|
|
133
138
|
* @returns The bridge, and a `close` that disconnects it one time.
|
|
134
139
|
*/
|
|
135
|
-
export declare function openProviderBridge<TRouter, TActor extends
|
|
140
|
+
export declare function openProviderBridge<TRouter, TActor extends RoutableActor>(BridgeCtor: PlayRouterBridgeConstructor<TRouter, TActor>, { router, actor, routeMap, basePath, basePathParams }: OpenProviderBridgeArgs<TRouter, TActor>): {
|
|
136
141
|
bridge: RouterBridge;
|
|
137
142
|
close: () => void;
|
|
138
143
|
};
|
|
@@ -163,6 +168,23 @@ export interface RouterConnection {
|
|
|
163
168
|
(): void;
|
|
164
169
|
/** Stops the synchronization. */
|
|
165
170
|
disconnect(): void;
|
|
171
|
+
/**
|
|
172
|
+
* Stops the synchronization when the scope of a `using` declaration ends.
|
|
173
|
+
*
|
|
174
|
+
* This value IS the release of `connectRouter`, and all eight router adapters return
|
|
175
|
+
* it, so it carries the protocol of `@xmachines/play` like every other release of the
|
|
176
|
+
* ecosystem:
|
|
177
|
+
*
|
|
178
|
+
* ```ts
|
|
179
|
+
* {
|
|
180
|
+
* using connection = connectRouter({ actor, router, routeMap });
|
|
181
|
+
* // disconnect() runs at the end of the scope, and after an exception too
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* The release is {@link RouterConnection.disconnect}, which is idempotent.
|
|
186
|
+
*/
|
|
187
|
+
[DISPOSE](): void;
|
|
166
188
|
/** The resolved prefix of the mount, or `""` when the machine owns the whole router. */
|
|
167
189
|
readonly basePath: string;
|
|
168
190
|
/** The values of the `:param` segments of the mount. They travel in no event. */
|
|
@@ -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,
|
|
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;AAC9E,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,CAAC,OAAO,EAAE,MAAM,SAAS,aAAa,EAAE,KAAK;IACxF;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,uGAAuG;IACvG,MAAM,EAAE,OAAO,CAAC;IAChB;;;;;;;;;;;OAWG;IACH,QAAQ,EAAE,QAAQ,CAA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5F;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CAmC7C;AAmBD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,EACvC,QAAQ,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,EACtC,cAAc,CAAC,EAAE,eAAe,CAAC,gBAAgB,CAAC,GAChD,IAAI,CAEN;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAgB;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"}
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @see [Multi-router integration](../../docs/examples/multi-router-integration.md)
|
|
19
19
|
*/
|
|
20
|
-
import { normalizeBasePath } from "
|
|
20
|
+
import { normalizeBasePath } from "@xmachines/play-url";
|
|
21
|
+
import { asCleanup, DISPOSE } from "@xmachines/play";
|
|
21
22
|
/**
|
|
22
23
|
* Tells you whether a bridge can move its mount.
|
|
23
24
|
*
|
|
@@ -140,7 +141,20 @@ export function createRouterConnection(bridge) {
|
|
|
140
141
|
const disconnect = () => {
|
|
141
142
|
bridge.disconnect();
|
|
142
143
|
};
|
|
143
|
-
|
|
144
|
+
// `asCleanup` publishes the release under the dispose key, so a scope may own the
|
|
145
|
+
// connection. It is the ONE place that knows how for a release that is a FUNCTION: it
|
|
146
|
+
// writes `DISPOSE` and, where a polyfill of Explicit Resource Management installed the
|
|
147
|
+
// well-known symbol after this module evaluated, `Symbol.dispose` beside it, and it
|
|
148
|
+
// gives both keys a descriptor that a test double, a wrapper, and a later `asCleanup`
|
|
149
|
+
// can still redefine. A second copy of that rule here would be a second chance to
|
|
150
|
+
// disagree with it.
|
|
151
|
+
//
|
|
152
|
+
// An object LITERAL writes the key itself — `createRouter` and `createBrowserHistory`
|
|
153
|
+
// of play-dom-router each do. `asCleanup` takes a callable, and those two values are
|
|
154
|
+
// no callables, so the note of `packages/play/src/disposable.ts` covers them instead:
|
|
155
|
+
// a literal carries the key that existed when it was defined, so a polyfill belongs
|
|
156
|
+
// before the first import of `@xmachines/play`.
|
|
157
|
+
return Object.defineProperties(asCleanup(disconnect), {
|
|
144
158
|
disconnect: { value: disconnect, enumerable: true },
|
|
145
159
|
basePath: { get: () => bridge.basePath, enumerable: true },
|
|
146
160
|
basePathParams: { get: () => bridge.basePathParams, enumerable: true },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-lifecycle.js","sourceRoot":"","sources":["../src/provider-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,iBAAiB,EAAwB,MAAM,
|
|
1
|
+
{"version":3,"file":"provider-lifecycle.js","sourceRoot":"","sources":["../src/provider-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,iBAAiB,EAAwB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAgGrD;;;;;;;GAOG;AACH,MA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oBAAoB;IACpB,EAAE;IACF,sFAAsF;IACtF,qFAAqF;IACrF,sFAAsF;IACtF,oFAAoF;IACpF,gDAAgD;IAChD,OAAO,MAAM,CAAC,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"}
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
*
|
|
43
43
|
* @see [Play RFC](../../docs/rfc/play.md) - invariant INV-04
|
|
44
44
|
*/
|
|
45
|
+
import { type BasePathOptions } from "@xmachines/play-url";
|
|
45
46
|
import { Signal } from "@xmachines/play-signals";
|
|
46
47
|
import type { MountableRouterBridge, RoutableActor } from "./types.js";
|
|
47
|
-
import { type BasePathOptions } from "./base-path.js";
|
|
48
48
|
/**
|
|
49
49
|
* The narrow interface of the TC39 Signal watcher. `RouterBridgeBase` uses it to
|
|
50
50
|
* observe each change of `actor.currentRoute`.
|
|
@@ -441,8 +441,9 @@ export declare abstract class RouterBridgeBase implements MountableRouterBridge
|
|
|
441
441
|
* pattern, for a wildcard pattern, and for an unknown id, the method skips the push
|
|
442
442
|
* completely: a push of the raw value writes a stateId, a `:param` pattern, or a
|
|
443
443
|
* literal `*` into the browser URL. The method still writes the raw route to
|
|
444
|
-
*
|
|
445
|
-
*
|
|
444
|
+
* lastActorRoute, and it leaves lastSyncedPath as it stands, because that field
|
|
445
|
+
* records a LOCATION and no location changed. Therefore the dedup guard fires
|
|
446
|
+
* correctly on the next identical value of the signal.
|
|
446
447
|
*
|
|
447
448
|
* @param route - The raw value of the actor route.
|
|
448
449
|
* @param resolved - The concrete path of that route. The default resolves it here. A
|
|
@@ -470,16 +471,14 @@ export declare abstract class RouterBridgeBase implements MountableRouterBridge
|
|
|
470
471
|
/**
|
|
471
472
|
* Reads the path parameters of a URL, with the URLPattern API.
|
|
472
473
|
*
|
|
473
|
-
* The
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
* must therefore give a polyfill in an environment without the native URLPattern:
|
|
477
|
-
* Node.js < 24, and an older browser.
|
|
474
|
+
* The API is always present: `@xmachines/play-router` uses the native URLPattern of the
|
|
475
|
+
* runtime, and it falls back to `urlpattern-polyfill`, which it carries as an ordinary
|
|
476
|
+
* dependency. A consumer therefore loads nothing, whatever the runtime.
|
|
478
477
|
*
|
|
479
478
|
* @param pathname - The real URL path, for example '/profile/john'
|
|
480
479
|
* @param stateId - The stateId of the match, for the lookup of the route pattern
|
|
481
480
|
* @returns The path parameters of the read, or an empty object when nothing matches
|
|
482
|
-
* @throws {
|
|
481
|
+
* @throws {InvalidRoutePatternError} When URLPattern cannot compile the route pattern
|
|
483
482
|
*/
|
|
484
483
|
protected extractParams(pathname: string, stateId: string): Record<string, string>;
|
|
485
484
|
/**
|
|
@@ -493,6 +492,9 @@ export declare abstract class RouterBridgeBase implements MountableRouterBridge
|
|
|
493
492
|
* `/docs/*`, because no concrete value is available for a real URL
|
|
494
493
|
* - a string that is no path and no known stateId
|
|
495
494
|
*
|
|
495
|
+
* A LITERAL route of the map comes back with each escape resolved: `/tags/c\+\+` gives
|
|
496
|
+
* the path `/tags/c++`, which is the path that the route matches.
|
|
497
|
+
*
|
|
496
498
|
* A lookup of a stateId tries the form `"#stateId"` and the bare form `"stateId"`,
|
|
497
499
|
* through `lookupPathByStateId`. Therefore a route map of your own that holds one
|
|
498
500
|
* form only still resolves the path.
|
|
@@ -507,7 +509,7 @@ export declare abstract class RouterBridgeBase implements MountableRouterBridge
|
|
|
507
509
|
*/
|
|
508
510
|
protected resolveNavigationPath(route: string): string | null;
|
|
509
511
|
/**
|
|
510
|
-
* Tells you whether the actor already stands
|
|
512
|
+
* Tells you whether the actor already stands on the PATH of a location of the router.
|
|
511
513
|
*
|
|
512
514
|
* The `currentRoute` of the actor can be a stateId, for example `"#app.home"`, while a
|
|
513
515
|
* location of the router is a URL path, for example `"/home"`. Therefore the method
|
|
@@ -516,24 +518,41 @@ export declare abstract class RouterBridgeBase implements MountableRouterBridge
|
|
|
516
518
|
* `takeReturnUnderMount`, it reads a location that the HOST chose as a restore of the
|
|
517
519
|
* actor and writes over it.
|
|
518
520
|
*
|
|
519
|
-
* The actor is
|
|
521
|
+
* The actor is on the path in three cases: the stateId of the match IS the actor
|
|
520
522
|
* route, the path of the match IS the actor route, or the actor route is a stateId
|
|
521
523
|
* that resolves to the same registered path as the stateId of the match. Each lookup
|
|
522
524
|
* goes through {@link lookupPathByStateId}, which tries the form `"#stateId"` and also
|
|
523
525
|
* the bare form `"stateId"`. Therefore a route map with `"#about"` recognizes an actor
|
|
524
526
|
* route of `"about"`, and the opposite also works, and this is correct for a
|
|
525
|
-
* structural map of your own that holds one form.
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
|
|
536
|
-
|
|
527
|
+
* structural map of your own that holds one form.
|
|
528
|
+
*
|
|
529
|
+
* An actor route with a concrete path, which starts with `"/"`, goes to a direct
|
|
530
|
+
* comparison of the pathname against `machinePath`. That comparison runs BEFORE the
|
|
531
|
+
* map, because a location the map does not hold is still a location the actor can
|
|
532
|
+
* stand on.
|
|
533
|
+
*
|
|
534
|
+
* The QUERY is a question of its own, and {@link sameQuery} answers it. Each caller
|
|
535
|
+
* asks BOTH, and the two answers do different work. "The two sides are in step" needs
|
|
536
|
+
* the path AND the query, so a router that carries the only query is a deep link that
|
|
537
|
+
* the actor has to follow — for a stateId route as much as for a path route. The
|
|
538
|
+
* RESTORE needs the path, beside `carriesNoOwnSuffix`: an actor that stands here and
|
|
539
|
+
* carries no query and no fragment of its own has nothing to put in the address bar,
|
|
540
|
+
* and a push would only rewrite the location the user opened.
|
|
541
|
+
*
|
|
542
|
+
* A query that the ACTOR carries is a difference that this branch still reads as a
|
|
543
|
+
* restore, so an actor at `/?ref=nav` wins against a router at `/?other=1`. `main`
|
|
544
|
+
* answers the same way, and whether that is a deep link or a restore is a decision
|
|
545
|
+
* about the rule: issue #18 carries it, and a test pins the behaviour.
|
|
546
|
+
*
|
|
547
|
+
* Each lookup runs ONE time, and a caller that needs both answers calls this method
|
|
548
|
+
* one time too. `getPathByStateId` belongs to the route map: a map of a consumer can
|
|
549
|
+
* answer differently on a second call, and `RouteMap` pays a cache lookup for each of
|
|
550
|
+
* them.
|
|
551
|
+
*
|
|
552
|
+
* @param machinePath - The machine half of the location of the router, with no query.
|
|
553
|
+
* @param actorRoute - The raw value of the actor route. It CAN carry a query.
|
|
554
|
+
*/
|
|
555
|
+
private isActorAtPath;
|
|
537
556
|
/**
|
|
538
557
|
* Returns the path of the route map for a value of an actor route, and it tries both
|
|
539
558
|
* forms of a stateId.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-bridge-base.d.ts","sourceRoot":"","sources":["../src/router-bridge-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,MAAM,EAAe,MAAM,yBAAyB,CAAC;AAE9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AASvE
|
|
1
|
+
{"version":3,"file":"router-bridge-base.d.ts","sourceRoot":"","sources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