lit-ui-router-ssr 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # lit-ui-router-ssr
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/lit-ui-router-ssr.svg)](https://npmx.dev/package/lit-ui-router-ssr)
4
- [![GitHub Release](https://img.shields.io/github/v/release/simshanith/lit-ui-router?filter=lit-ui-router-ssr@*)](https://github.com/simshanith/lit-ui-router/releases/?q=lit-ui-router-ssr)
4
+ [![GitHub Release](https://img.shields.io/github/v/release/simshanith/lit-ui-router?filter=lit-ui-router-ssr@*)](https://lit-ui-router.dev/gh/releases/lit-ui-router-ssr/latest)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
6
  [![Website](https://img.shields.io/website?url=https%3A%2F%2Flit-ui-router.dev)](https://lit-ui-router.dev/packages/ssr)
7
7
  [![codecov](https://codecov.io/gh/simshanith/lit-ui-router/graph/badge.svg?component=lit-ui-router-ssr)](https://app.codecov.io/gh/simshanith/lit-ui-router?components%5B0%5D=lit-ui-router-ssr)
@@ -100,11 +100,12 @@ first page's slashed spelling does not resolve to the same shell.
100
100
  ## Settling the router on each path
101
101
 
102
102
  A server render reads the router only once its transition has landed, resolves included.
103
- `settle(router, path)` sets the url, syncs the router to it, and resolves with the transition that
104
- landed, so the synchronous render after it reads every resolve. A `redirectTo` chain settles on its
105
- final state, and a path the router already stands on resolves at once.
103
+ `settle(router, path)`, the `ui-router-server/ssr` step this package re-exports, sets the url, syncs
104
+ the router to it, and resolves with the transition that landed, so the synchronous render after it
105
+ reads every resolve. A `redirectTo` chain settles on its final state, and a path the router already
106
+ stands on resolves at once.
106
107
 
107
- A page fails to land in three ways, and each rejects rather than hangs:
108
+ A page fails to land in four ways, and each rejects rather than hangs:
108
109
 
109
110
  - **No rule matches.** A url no state claims, on a router with no `otherwise` rule, rejects with an
110
111
  `Error` naming it. An `otherwise` rule is itself a match and settles on its state.
@@ -112,6 +113,8 @@ A page fails to land in three ways, and each rejects rather than hangs:
112
113
  `Rejection`, the resolve's error in its `detail`. Core's `defaultErrorHandler` still logs it.
113
114
  - **Nothing lands in time.** `{ timeout }` bounds the wait, `10_000` ms by default; `0` waits without
114
115
  a limit.
116
+ - **The url keeps rewriting.** `{ maxRewrites }` bounds a chain of url rules that rewrite the url to
117
+ another url, `10` by default.
115
118
 
116
119
  `settle()` never calls `router.start()`, which runs once per router: it drives `urlService`
117
120
  directly, so a page loop calls it once per path on the same router, started or not.
@@ -1,4 +1,4 @@
1
1
  export { prerender } from "./prerender.js";
2
- export { settle } from "./settle.js";
2
+ export { settle } from "ui-router-server/ssr";
3
3
  export { UiViewRenderer } from "./ui-view-renderer.js";
4
4
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
1
  export const signatureAttribute = "data-lit-ui-router-ssr";
2
2
  export const signatureSelector = `script[type="application/json"][${signatureAttribute}]`;
3
- export const packageVersion = "0.4.0";
3
+ export const packageVersion = "0.5.0";
4
4
  //# sourceMappingURL=signature.js.map
package/dist/index.d.ts CHANGED
@@ -5,6 +5,6 @@
5
5
  * @module
6
6
  */
7
7
  export { type EmittedPage, type FileWriter, prerender, type PrerenderOptions, type PrerenderResult, type PrerenderTally, type RedirectLine, type RenderContext } from "./prerender.js";
8
- export { settle, type SettleOptions } from "./settle.js";
8
+ export { settle, type SettleOptions } from "ui-router-server/ssr";
9
9
  export { UiViewRenderer } from "./ui-view-renderer.js";
10
10
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { prerender } from "./prerender.js";
2
- export { settle } from "./settle.js";
2
+ export { settle } from "ui-router-server/ssr";
3
3
  export { UiViewRenderer } from "./ui-view-renderer.js";
4
4
  //# sourceMappingURL=index.js.map
package/dist/signature.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export const signatureAttribute = "data-lit-ui-router-ssr";
2
2
  export const signatureSelector = `script[type="application/json"][${signatureAttribute}]`;
3
- export const packageVersion = "0.4.0";
3
+ export const packageVersion = "0.5.0";
4
4
  //# sourceMappingURL=signature.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lit-ui-router-ssr",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Static prerendering for lit-ui-router: mount verdicts in, an emitted site out",
5
5
  "homepage": "https://lit-ui-router.dev/packages/ssr",
6
6
  "bugs": {
@@ -72,7 +72,7 @@
72
72
  "@uirouter/core": "^6.0.8",
73
73
  "lit": "^3.1.2",
74
74
  "lit-ui-router": "^1.16.1",
75
- "ui-router-server": "^0.2.0 || ^0.3.0 || ^0.4.0"
75
+ "ui-router-server": "^0.5.0"
76
76
  },
77
77
  "peerDependenciesMeta": {
78
78
  "@lit-labs/ssr-client": {
package/src/index.ts CHANGED
@@ -15,6 +15,6 @@ export {
15
15
  type RenderContext,
16
16
  } from './prerender.js';
17
17
 
18
- export { settle, type SettleOptions } from './settle.js';
18
+ export { settle, type SettleOptions } from 'ui-router-server/ssr';
19
19
 
20
20
  export { UiViewRenderer } from './ui-view-renderer.js';
@@ -1,48 +0,0 @@
1
- import { RejectType } from "@uirouter/core";
2
- const maxRewrites = 10;
3
- export const settle = (router, path, options = {}) => {
4
- const { timeout = 1e4 } = options;
5
- const { globals, stateService, transitionService, urlService } = router;
6
- return new Promise((resolve, reject) => {
7
- let timer;
8
- const done = () => {
9
- offSuccess();
10
- offError();
11
- clearTimeout(timer);
12
- };
13
- const land = (transition) => {
14
- done();
15
- resolve(transition);
16
- };
17
- const fail = (reason) => {
18
- done();
19
- reject(reason);
20
- };
21
- const offSuccess = transitionService.onSuccess({}, land);
22
- const offError = transitionService.onError({}, (transition) => {
23
- const rejection = transition.error();
24
- if (rejection.type === RejectType.SUPERSEDED) return;
25
- if (rejection.type === RejectType.IGNORED) {
26
- if (!globals.transition && globals.successfulTransitions.size() > 0) land(globals.successfulTransitions.peekTail());
27
- return;
28
- }
29
- fail(new Error(rejection.message, { cause: rejection }));
30
- });
31
- if (timeout > 0 && timeout !== Infinity) timer = setTimeout(() => fail(new Error(`settle: ${path} did not land within ${timeout}ms`)), timeout);
32
- urlService.url(path);
33
- for (let rewrites = 0; rewrites <= maxRewrites; rewrites++) {
34
- const best = urlService.match({
35
- path: urlService.path(),
36
- search: urlService.search(),
37
- hash: urlService.hash()
38
- });
39
- if (!best) return fail(new Error(`settle: no url rule matches ${urlService.url()} and the router declares no otherwise`));
40
- if (best.rule.type === "STATE" && globals.successfulTransitions.size() > 0 && stateService.href(best.rule.state, best.match) === stateService.href(globals.current, globals.params)) return land(globals.successfulTransitions.peekTail());
41
- const before = urlService.url();
42
- urlService.sync();
43
- if (urlService.url() === before) return;
44
- }
45
- fail(new Error(`settle: ${path} rewrote its url more than ${maxRewrites} times`));
46
- });
47
- };
48
- //# sourceMappingURL=settle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settle.js","mappings":"AACA,SAAS,kBAAkB;AAkB3B,MAAM,cAAc;AAwCpB,OAAO,MAAM,UACX,QACA,MACA,UAAyB,CAAC,MACF;CACxB,MAAM,EAAE,UAAU,QAAW;CAC7B,MAAM,EAAE,SAAS,cAAc,mBAAmB,eAAe;CAEjE,OAAO,IAAI,SAAqB,SAAS,WAAW;EAClD,IAAI;EAEJ,MAAM,aAAmB;GACvB,WAAW;GACX,SAAS;GACT,aAAa,KAAK;EACpB;EAEA,MAAM,QAAQ,eAAiC;GAC7C,KAAK;GACL,QAAQ,UAAU;EACpB;EAEA,MAAM,QAAQ,WAAwB;GACpC,KAAK;GACL,OAAO,MAAM;EACf;EAGA,MAAM,aAAa,kBAAkB,UAAU,CAAC,GAAG,IAAI;EAGvD,MAAM,WAAW,kBAAkB,QAAQ,CAAC,IAAI,eAAe;GAC7D,MAAM,YAAY,WAAW,MAAM;GAEnC,IAAI,UAAU,SAAS,WAAW,YAAY;GAE9C,IAAI,UAAU,SAAS,WAAW,SAAS;IAEzC,IAAI,CAAC,QAAQ,cAAc,QAAQ,sBAAsB,KAAK,IAAI,GAChE,KAAK,QAAQ,sBAAsB,SAAS,CAAC;IAE/C;GACF;GAEA,KAAK,IAAI,MAAM,UAAU,SAAS,EAAE,OAAO,UAAU,CAAC,CAAC;EACzD,CAAC;EAED,IAAI,UAAU,KAAK,YAAY,UAC7B,QAAQ,iBAEJ,KAAK,IAAI,MAAM,WAAW,KAAK,uBAAuB,QAAQ,GAAG,CAAC,GACpE,OACF;EAEF,WAAW,IAAI,IAAI;EAEnB,KAAK,IAAI,WAAW,GAAG,YAAY,aAAa,YAAY;GAC1D,MAAM,OAAO,WAAW,MAAM;IAC5B,MAAM,WAAW,KAAK;IACtB,QAAQ,WAAW,OAAO;IAC1B,MAAM,WAAW,KAAK;GACxB,CAAC;GAED,IAAI,CAAC,MACH,OAAO,KACL,IAAI,MACF,+BAA+B,WAAW,IAAI,EAAE,sCAClD,CACF;GAIF,IACE,KAAK,KAAK,SAAS,WACnB,QAAQ,sBAAsB,KAAK,IAAI,KACvC,aAAa,KACV,KAAK,KAAmB,OACzB,KAAK,KACP,MAAM,aAAa,KAAK,QAAQ,SAAS,QAAQ,MAAM,GAEvD,OAAO,KAAK,QAAQ,sBAAsB,SAAS,CAAC;GACtD,MAAM,SAAS,WAAW,IAAI;GAC9B,WAAW,KAAK;GAGhB,IAAI,WAAW,IAAI,MAAM,QAAQ;EACnC;EAEA,KACE,IAAI,MACF,WAAW,KAAK,6BAA6B,YAAY,OAC3D,CACF;CACF,CAAC;AACH","names":[],"ignoreList":[],"sources":["../../src/settle.ts"]}
package/dist/settle.d.ts DELETED
@@ -1,49 +0,0 @@
1
- import type { Transition, UIRouter } from "@uirouter/core";
2
- /** Options for {@link settle | `settle`}. */
3
- export interface SettleOptions {
4
- /**
5
- * How long to wait for the transition to land, in milliseconds, before
6
- * rejecting. Defaults to `10_000`; `0` or `Infinity` waits without a limit.
7
- */
8
- timeout?: number;
9
- }
10
- /**
11
- * Moves `router` to `path` and resolves once the transition the url starts
12
- * has landed, resolves included, so a synchronous render reads the router
13
- * after it.
14
- *
15
- * It never calls `router.start()`, which runs once per router: it sets the
16
- * url and syncs the router to it, whether or not the router is listening.
17
- * A page loop calls it once per path on the same router. A `redirectTo`
18
- * chain settles on its final state, and a path the router already stands on
19
- * resolves with the transition that brought it there.
20
- *
21
- * A failed transition still reaches `stateService.defaultErrorHandler`,
22
- * which logs it unless replaced.
23
- *
24
- * @param router - the server router, its location installed with `installServerLocation`
25
- * @param path - the url to settle on, relative to the mount, query included
26
- * @param options - how long to wait
27
- * @returns the transition that landed
28
- * @throws an `Error` when no url rule matches `path` and the router declares no `otherwise`
29
- * @throws an `Error` whose `cause` is the transition's `Rejection` when it fails, a failed resolve's error in that rejection's `detail`
30
- * @throws an `Error` when nothing lands within {@link SettleOptions.timeout | `timeout`}
31
- *
32
- * @example
33
- * ```ts
34
- * import { prerender, settle } from 'lit-ui-router-ssr';
35
- *
36
- * await prerender({
37
- * mounts,
38
- * router,
39
- * outDir: 'dist',
40
- * paths: ['/', '/sheet/7B'],
41
- * renderShell: async (verdict, { path }) => {
42
- * await settle(router, path);
43
- * return page();
44
- * },
45
- * });
46
- * ```
47
- */
48
- export declare const settle: (router: UIRouter, path: string, options?: SettleOptions) => Promise<Transition>;
49
- //# sourceMappingURL=settle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settle.d.ts","mappings":"AAEA,cAGE,YACA,gBACK;;AAGP,iBAAiB,cAAc;;;;;CAK7B;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,OAAO,cAAM,SACX,QAAQ,UACR,cACA,UAAS,kBACR,QAAQ","names":[],"ignoreList":[],"sources":["../src/settle.ts"]}
package/dist/settle.js DELETED
@@ -1,48 +0,0 @@
1
- import { RejectType } from "@uirouter/core";
2
- const maxRewrites = 10;
3
- export const settle = (router, path, options = {}) => {
4
- const { timeout = 1e4 } = options;
5
- const { globals, stateService, transitionService, urlService } = router;
6
- return new Promise((resolve, reject) => {
7
- let timer;
8
- const done = () => {
9
- offSuccess();
10
- offError();
11
- clearTimeout(timer);
12
- };
13
- const land = (transition) => {
14
- done();
15
- resolve(transition);
16
- };
17
- const fail = (reason) => {
18
- done();
19
- reject(reason);
20
- };
21
- const offSuccess = transitionService.onSuccess({}, land);
22
- const offError = transitionService.onError({}, (transition) => {
23
- const rejection = transition.error();
24
- if (rejection.type === RejectType.SUPERSEDED) return;
25
- if (rejection.type === RejectType.IGNORED) {
26
- if (!globals.transition && globals.successfulTransitions.size() > 0) land(globals.successfulTransitions.peekTail());
27
- return;
28
- }
29
- fail(new Error(rejection.message, { cause: rejection }));
30
- });
31
- if (timeout > 0 && timeout !== Infinity) timer = setTimeout(() => fail(new Error(`settle: ${path} did not land within ${timeout}ms`)), timeout);
32
- urlService.url(path);
33
- for (let rewrites = 0; rewrites <= maxRewrites; rewrites++) {
34
- const best = urlService.match({
35
- path: urlService.path(),
36
- search: urlService.search(),
37
- hash: urlService.hash()
38
- });
39
- if (!best) return fail(new Error(`settle: no url rule matches ${urlService.url()} and the router declares no otherwise`));
40
- if (best.rule.type === "STATE" && globals.successfulTransitions.size() > 0 && stateService.href(best.rule.state, best.match) === stateService.href(globals.current, globals.params)) return land(globals.successfulTransitions.peekTail());
41
- const before = urlService.url();
42
- urlService.sync();
43
- if (urlService.url() === before) return;
44
- }
45
- fail(new Error(`settle: ${path} rewrote its url more than ${maxRewrites} times`));
46
- });
47
- };
48
- //# sourceMappingURL=settle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settle.js","mappings":"AACA,SAAS,kBAAkB;AAkB3B,MAAM,cAAc;AAwCpB,OAAO,MAAM,UACX,QACA,MACA,UAAyB,CAAC,MACF;CACxB,MAAM,EAAE,UAAU,QAAW;CAC7B,MAAM,EAAE,SAAS,cAAc,mBAAmB,eAAe;CAEjE,OAAO,IAAI,SAAqB,SAAS,WAAW;EAClD,IAAI;EAEJ,MAAM,aAAmB;GACvB,WAAW;GACX,SAAS;GACT,aAAa,KAAK;EACpB;EAEA,MAAM,QAAQ,eAAiC;GAC7C,KAAK;GACL,QAAQ,UAAU;EACpB;EAEA,MAAM,QAAQ,WAAwB;GACpC,KAAK;GACL,OAAO,MAAM;EACf;EAGA,MAAM,aAAa,kBAAkB,UAAU,CAAC,GAAG,IAAI;EAGvD,MAAM,WAAW,kBAAkB,QAAQ,CAAC,IAAI,eAAe;GAC7D,MAAM,YAAY,WAAW,MAAM;GAEnC,IAAI,UAAU,SAAS,WAAW,YAAY;GAE9C,IAAI,UAAU,SAAS,WAAW,SAAS;IAEzC,IAAI,CAAC,QAAQ,cAAc,QAAQ,sBAAsB,KAAK,IAAI,GAChE,KAAK,QAAQ,sBAAsB,SAAS,CAAC;IAE/C;GACF;GAEA,KAAK,IAAI,MAAM,UAAU,SAAS,EAAE,OAAO,UAAU,CAAC,CAAC;EACzD,CAAC;EAED,IAAI,UAAU,KAAK,YAAY,UAC7B,QAAQ,iBAEJ,KAAK,IAAI,MAAM,WAAW,KAAK,uBAAuB,QAAQ,GAAG,CAAC,GACpE,OACF;EAEF,WAAW,IAAI,IAAI;EAEnB,KAAK,IAAI,WAAW,GAAG,YAAY,aAAa,YAAY;GAC1D,MAAM,OAAO,WAAW,MAAM;IAC5B,MAAM,WAAW,KAAK;IACtB,QAAQ,WAAW,OAAO;IAC1B,MAAM,WAAW,KAAK;GACxB,CAAC;GAED,IAAI,CAAC,MACH,OAAO,KACL,IAAI,MACF,+BAA+B,WAAW,IAAI,EAAE,sCAClD,CACF;GAIF,IACE,KAAK,KAAK,SAAS,WACnB,QAAQ,sBAAsB,KAAK,IAAI,KACvC,aAAa,KACV,KAAK,KAAmB,OACzB,KAAK,KACP,MAAM,aAAa,KAAK,QAAQ,SAAS,QAAQ,MAAM,GAEvD,OAAO,KAAK,QAAQ,sBAAsB,SAAS,CAAC;GACtD,MAAM,SAAS,WAAW,IAAI;GAC9B,WAAW,KAAK;GAGhB,IAAI,WAAW,IAAI,MAAM,QAAQ;EACnC;EAEA,KACE,IAAI,MACF,WAAW,KAAK,6BAA6B,YAAY,OAC3D,CACF;CACF,CAAC;AACH","names":[],"ignoreList":[],"sources":["../src/settle.ts"]}
package/src/settle.ts DELETED
@@ -1,154 +0,0 @@
1
- // Drives a server router's url sync to a landed transition, since `start()` and `urlService.sync()` drop the promise.
2
- import { RejectType } from '@uirouter/core';
3
- import type {
4
- RawParams,
5
- StateRule,
6
- Transition,
7
- UIRouter,
8
- } from '@uirouter/core';
9
-
10
- /** Options for {@link settle | `settle`}. */
11
- export interface SettleOptions {
12
- /**
13
- * How long to wait for the transition to land, in milliseconds, before
14
- * rejecting. Defaults to `10_000`; `0` or `Infinity` waits without a limit.
15
- */
16
- timeout?: number;
17
- }
18
-
19
- // Bounds a chain of url rules that rewrite the url to another url.
20
- const maxRewrites = 10;
21
-
22
- /**
23
- * Moves `router` to `path` and resolves once the transition the url starts
24
- * has landed, resolves included, so a synchronous render reads the router
25
- * after it.
26
- *
27
- * It never calls `router.start()`, which runs once per router: it sets the
28
- * url and syncs the router to it, whether or not the router is listening.
29
- * A page loop calls it once per path on the same router. A `redirectTo`
30
- * chain settles on its final state, and a path the router already stands on
31
- * resolves with the transition that brought it there.
32
- *
33
- * A failed transition still reaches `stateService.defaultErrorHandler`,
34
- * which logs it unless replaced.
35
- *
36
- * @param router - the server router, its location installed with `installServerLocation`
37
- * @param path - the url to settle on, relative to the mount, query included
38
- * @param options - how long to wait
39
- * @returns the transition that landed
40
- * @throws an `Error` when no url rule matches `path` and the router declares no `otherwise`
41
- * @throws an `Error` whose `cause` is the transition's `Rejection` when it fails, a failed resolve's error in that rejection's `detail`
42
- * @throws an `Error` when nothing lands within {@link SettleOptions.timeout | `timeout`}
43
- *
44
- * @example
45
- * ```ts
46
- * import { prerender, settle } from 'lit-ui-router-ssr';
47
- *
48
- * await prerender({
49
- * mounts,
50
- * router,
51
- * outDir: 'dist',
52
- * paths: ['/', '/sheet/7B'],
53
- * renderShell: async (verdict, { path }) => {
54
- * await settle(router, path);
55
- * return page();
56
- * },
57
- * });
58
- * ```
59
- */
60
- export const settle = (
61
- router: UIRouter,
62
- path: string,
63
- options: SettleOptions = {},
64
- ): Promise<Transition> => {
65
- const { timeout = 10_000 } = options;
66
- const { globals, stateService, transitionService, urlService } = router;
67
-
68
- return new Promise<Transition>((resolve, reject) => {
69
- let timer: ReturnType<typeof setTimeout> | undefined;
70
-
71
- const done = (): void => {
72
- offSuccess();
73
- offError();
74
- clearTimeout(timer);
75
- };
76
-
77
- const land = (transition: Transition): void => {
78
- done();
79
- resolve(transition);
80
- };
81
-
82
- const fail = (reason: Error): void => {
83
- done();
84
- reject(reason);
85
- };
86
-
87
- // SAFETY: hook registration returns its deregistration function, typed only as `Function`.
88
- const offSuccess = transitionService.onSuccess({}, land) as () => void;
89
-
90
- // SAFETY: hook registration returns its deregistration function, typed only as `Function`.
91
- const offError = transitionService.onError({}, (transition) => {
92
- const rejection = transition.error();
93
-
94
- if (rejection.type === RejectType.SUPERSEDED) return;
95
-
96
- if (rejection.type === RejectType.IGNORED) {
97
- // Ignored with nothing in flight: the router already stands where the url points.
98
- if (!globals.transition && globals.successfulTransitions.size() > 0)
99
- land(globals.successfulTransitions.peekTail());
100
-
101
- return;
102
- }
103
-
104
- fail(new Error(rejection.message, { cause: rejection }));
105
- }) as () => void;
106
-
107
- if (timeout > 0 && timeout !== Infinity)
108
- timer = setTimeout(
109
- () =>
110
- fail(new Error(`settle: ${path} did not land within ${timeout}ms`)),
111
- timeout,
112
- );
113
-
114
- urlService.url(path);
115
-
116
- for (let rewrites = 0; rewrites <= maxRewrites; rewrites++) {
117
- const best = urlService.match({
118
- path: urlService.path(),
119
- search: urlService.search(),
120
- hash: urlService.hash(),
121
- });
122
-
123
- if (!best)
124
- return fail(
125
- new Error(
126
- `settle: no url rule matches ${urlService.url()} and the router declares no otherwise`,
127
- ),
128
- );
129
-
130
- // Core's state rule starts nothing when the url's href is the current one.
131
- // SAFETY: a `STATE` rule is core's `StateRule`, and its match is the url's param values.
132
- if (
133
- best.rule.type === 'STATE' &&
134
- globals.successfulTransitions.size() > 0 &&
135
- stateService.href(
136
- (best.rule as StateRule).state,
137
- best.match as RawParams,
138
- ) === stateService.href(globals.current, globals.params)
139
- )
140
- return land(globals.successfulTransitions.peekTail());
141
- const before = urlService.url();
142
- urlService.sync();
143
-
144
- // A rule that rewrote the url to another url needs its own sync when the router is not listening.
145
- if (urlService.url() === before) return;
146
- }
147
-
148
- fail(
149
- new Error(
150
- `settle: ${path} rewrote its url more than ${maxRewrites} times`,
151
- ),
152
- );
153
- });
154
- };