sibujs 4.13.0 → 4.14.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 +1 -1
- package/dist/browser.cjs +15 -2
- package/dist/browser.js +9 -7
- package/dist/build.cjs +880 -281
- package/dist/build.d.cts +68 -3
- package/dist/build.d.ts +68 -3
- package/dist/build.js +88 -30
- package/dist/cdn.dev.global.js +12 -12
- package/dist/cdn.full.dev.global.js +13 -13
- package/dist/cdn.full.global.js +12 -12
- package/dist/cdn.global.js +12 -12
- package/dist/{chunk-7K7W4AA5.js → chunk-2TTRW2TE.js} +6 -6
- package/dist/{chunk-J6FW5TV6.js → chunk-3HEX6QJQ.js} +5 -3
- package/dist/chunk-3HZOSMPX.js +90 -0
- package/dist/{chunk-GNSRXK34.js → chunk-4FJSAUKB.js} +11 -3
- package/dist/{chunk-IV74C2YX.js → chunk-4TQDTWWN.js} +6 -5
- package/dist/{chunk-L3QHS4O4.js → chunk-7ILEHTVX.js} +1 -1
- package/dist/{chunk-CK5F2IR5.js → chunk-A454RAEK.js} +4 -4
- package/dist/{chunk-BRRRVLHQ.js → chunk-AE32RGWX.js} +10 -6
- package/dist/{chunk-EXXSN3BW.js → chunk-B3HOT4TK.js} +1 -1
- package/dist/{chunk-F4W7WYXY.js → chunk-BKZ5N6NK.js} +8 -6
- package/dist/{chunk-MNEITZ27.js → chunk-BNXRWZZV.js} +49 -8
- package/dist/chunk-BOYKGGVD.js +2015 -0
- package/dist/{chunk-G6366I2A.js → chunk-CCKUNHVU.js} +2 -2
- package/dist/{chunk-346BYZL2.js → chunk-CJ7KS3DF.js} +16 -10
- package/dist/chunk-CNPT6NKV.js +1859 -0
- package/dist/{chunk-ENFRHCMK.js → chunk-F67F77IA.js} +2 -2
- package/dist/{chunk-TUCPL2HB.js → chunk-GIJ33UJZ.js} +1 -1
- package/dist/chunk-GVAMIU6K.js +195 -0
- package/dist/{chunk-HDKDBC6V.js → chunk-HQIAL7F2.js} +8 -6
- package/dist/{chunk-ZE5LF44R.js → chunk-JTFQ7IL4.js} +8 -8
- package/dist/{chunk-AM6DZLBM.js → chunk-LJMX4SQ7.js} +2 -2
- package/dist/{chunk-HVVRXRGO.js → chunk-MIRKTVH4.js} +7 -14
- package/dist/{chunk-YJ57VR6Y.js → chunk-N7A6FKWW.js} +5 -3
- package/dist/chunk-NT3ZYB5S.js +167 -0
- package/dist/{chunk-Z3EZX6DZ.js → chunk-QS6GMWDD.js} +151 -86
- package/dist/chunk-R5U7XKVJ.js +16 -0
- package/dist/{chunk-3C56VNCK.js → chunk-RVR5NPFL.js} +3 -3
- package/dist/{chunk-F2UWOZ6J.js → chunk-RVWJGWCL.js} +2 -2
- package/dist/{chunk-NYNYSPK7.js → chunk-S37PZD6I.js} +30 -45
- package/dist/{chunk-QV5WEOFD.js → chunk-SVULV7O4.js} +119 -26
- package/dist/{chunk-C2FAO6VQ.js → chunk-TLS4NVIB.js} +5 -5
- package/dist/{chunk-M25RIH6Y.js → chunk-UUIKJJIK.js} +10 -8
- package/dist/chunk-UYTYNCMZ.js +199 -0
- package/dist/chunk-VM2U5LEL.js +2596 -0
- package/dist/{chunk-24L5RDPS.js → chunk-Y4LUM2XS.js} +8 -6
- package/dist/data.cjs +265 -35
- package/dist/data.d.cts +31 -1
- package/dist/data.d.ts +31 -1
- package/dist/data.js +16 -10
- package/dist/devtools.cjs +15 -2
- package/dist/devtools.js +9 -7
- package/dist/{dispose-GEIG2KOF.js → dispose-EIHHHDC7.js} +3 -1
- package/dist/ecosystem.cjs +62 -23
- package/dist/ecosystem.js +14 -12
- package/dist/extras.cjs +3520 -270
- package/dist/extras.d.cts +3 -3
- package/dist/extras.d.ts +3 -3
- package/dist/extras.js +39 -29
- package/dist/index.cjs +442 -253
- package/dist/index.d.cts +93 -283
- package/dist/index.d.ts +93 -283
- package/dist/index.js +26 -16
- package/dist/motion.cjs +12 -1
- package/dist/motion.js +6 -4
- package/dist/patterns.cjs +15 -2
- package/dist/patterns.js +10 -8
- package/dist/performance.cjs +36 -2
- package/dist/performance.d.cts +2 -2
- package/dist/performance.d.ts +2 -2
- package/dist/performance.js +14 -10
- package/dist/plugins.cjs +5225 -1807
- package/dist/plugins.d.cts +8 -834
- package/dist/plugins.d.ts +8 -834
- package/dist/plugins.js +64 -2329
- package/dist/prerenderServer-MXJEVWA3.js +350 -0
- package/dist/renderRoute-DP20XwMS.d.cts +86 -0
- package/dist/renderRoute-fxgsm2Ir.d.ts +86 -0
- package/dist/routeHead-CE9SV-cH.d.cts +995 -0
- package/dist/routeHead-DzVxPviY.d.ts +995 -0
- package/dist/{routeMiddleware-B1sp4P7a.d.ts → routeMiddleware-BySbueoE.d.ts} +0 -25
- package/dist/{routeMiddleware-CedQTsLK.d.cts → routeMiddleware-CijZD5eW.d.cts} +0 -25
- package/dist/ssr-JpGpHnpC.d.cts +841 -0
- package/dist/ssr-JpGpHnpC.d.ts +841 -0
- package/dist/{ssr-VBM6J5SJ.js → ssr-NECEU4X4.js} +15 -6
- package/dist/ssr-dom.cjs +1862 -0
- package/dist/ssr-dom.d.cts +341 -0
- package/dist/ssr-dom.d.ts +341 -0
- package/dist/ssr-dom.js +19 -0
- package/dist/ssr.cjs +7630 -2064
- package/dist/ssr.d.cts +63 -5
- package/dist/ssr.d.ts +63 -5
- package/dist/ssr.js +136 -14
- package/dist/testing.cjs +6543 -87
- package/dist/testing.d.cts +80 -1
- package/dist/testing.d.ts +80 -1
- package/dist/testing.js +117 -4
- package/dist/ui.cjs +36 -2
- package/dist/ui.js +17 -14
- package/dist/widgets.cjs +14 -1
- package/dist/widgets.js +11 -9
- package/package.json +9 -2
- package/dist/chunk-2F4PSJ5Z.js +0 -765
- package/dist/chunk-7XHATCIH.js +0 -121
- package/dist/chunk-B36ADEIR.js +0 -21
- package/dist/ssr-Db0Sgdu3.d.cts +0 -245
- package/dist/ssr-Db0Sgdu3.d.ts +0 -245
package/dist/plugins.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { L as LazyModule, M as Migration, a as MigrationStorageError, P as PackageExportTarget, S as SemVer, V as VERSION, b as bundlerMetadata, c as checkCompatibility, d as compareSemVer, e as createBootSequence, f as createBundle, g as createMigrationRunner, h as createModuleRegistry, i as createSSRCache, j as createTestHarness, k as deferNonCritical, l as env, m as healthCheck, n as lazyModule, p as packageInfo, o as parseSemVer, q as preloadCritical, r as prerenderRoutes, s as satisfies } from './startup-BLfSeL15.cjs';
|
|
2
2
|
import { A as Accessor } from './signal-EotCj4hS.cjs';
|
|
3
3
|
export { P as PluginContext, a as PluginInstallCancelledError, b as PluginRegistry, S as SibuPlugin, c as createPlugin, d as createPluginRegistry, i as inject, e as isPluginInstallCancelledError, p as plugin, r as resetPlugins, s as setDefaultPluginRegistry, t as triggerPluginError, f as triggerPluginMount, g as triggerPluginUnmount } from './plugin-DVgSnTfK.cjs';
|
|
4
|
-
|
|
5
|
-
import { T as TrustedHTML } from './ssr-
|
|
4
|
+
export { A as AsyncComponent, b as AsyncRoute, C as Component, c as ComponentRoute, G as Guard, d as GuardResult, J as JsonLd, K as KeepAliveRoute, L as LazyComponent, e as LazyRoute, N as NavigationFailure, f as NavigationFailureReason, g as NavigationGuard, h as NavigationNext, i as NavigationQuery, j as NavigationResult, k as NavigationTarget, O as Outlet, P as Params, Q as QueryValues, l as RedirectRoute, m as ResolvedHeadTag, n as ResolvedRouteHead, o as Route, p as RouteBase, q as RouteContext, a as RouteDef, r as RouteHead, s as RouteHeadAlternate, t as RouteHeadOpenGraph, u as RouteHeadTwitter, v as RouteHeadValue, w as RouteMeta, x as RouteTransitionOptions, y as RouterHeadOptions, z as RouterLink, R as RouterOptions, B as RouterPlugin, S as ScrollBehavior, D as ScrollPosition, E as SibuRouter, F as Suspense, _ as __getNavigationEpoch, H as __removeRouterPagehideHandler, I as addRoute, M as afterEach, T as back, U as beforeEach, V as beforeResolve, W as buildURL, X as createMemoryRouter, Y as createRouter, Z as destroyRouter, $ as forward, a0 as getRouteInfo, a1 as getRouteTransition, a2 as go, a3 as hasRoute, a4 as jsonLdScript, a5 as lazy, a6 as navigate, a7 as preloadRoute, a8 as push, a9 as removeRoute, aa as replace, ab as resolveRouteHead, ac as route, ad as routeHeadToHTML, ae as router, af as routerPlugin, ag as routerReady, ah as routerState, ai as serializeJsonLd, aj as setRouteTransition, ak as setRoutes } from './routeHead-CE9SV-cH.cjs';
|
|
5
|
+
import { T as TrustedHTML } from './ssr-JpGpHnpC.cjs';
|
|
6
|
+
import './types-CJFViL6Q.cjs';
|
|
6
7
|
|
|
7
8
|
type Translations = Record<string, string>;
|
|
8
9
|
/**
|
|
@@ -14,7 +15,7 @@ type Translations = Record<string, string>;
|
|
|
14
15
|
* either `userName` or the locale changes.
|
|
15
16
|
*/
|
|
16
17
|
type TranslationParams = Record<string, string | number | (() => string | number)>;
|
|
17
|
-
type Params
|
|
18
|
+
type Params = TranslationParams;
|
|
18
19
|
/**
|
|
19
20
|
* Set the active locale.
|
|
20
21
|
*
|
|
@@ -91,7 +92,7 @@ declare function registerTranslations(locale: string, messages: Translations): v
|
|
|
91
92
|
* Parameter getters are resolved on every call, so `t("hi", { name: userName })`
|
|
92
93
|
* inside a binding tracks `userName` too.
|
|
93
94
|
*/
|
|
94
|
-
declare function t(key: string, params?: Params
|
|
95
|
+
declare function t(key: string, params?: Params): string;
|
|
95
96
|
/**
|
|
96
97
|
* A LIVE translation: returns a getter that re-reads the message every time a
|
|
97
98
|
* binding calls it. Pass it anywhere the tag factories accept a reactive value
|
|
@@ -121,7 +122,7 @@ declare function t(key: string, params?: Params$1): string;
|
|
|
121
122
|
* setLocale("es"); // text and attributes update in place — no re-render
|
|
122
123
|
* ```
|
|
123
124
|
*/
|
|
124
|
-
declare function translated(key: string, params?: Params
|
|
125
|
+
declare function translated(key: string, params?: Params): Accessor<string>;
|
|
125
126
|
/**
|
|
126
127
|
* Trans component — renders a translated string reactively inside a `<span>`.
|
|
127
128
|
* Automatically updates when the client locale changes, when messages for the
|
|
@@ -144,7 +145,7 @@ declare function translated(key: string, params?: Params$1): Accessor<string>;
|
|
|
144
145
|
* // When the locale or userName changes, the text updates automatically
|
|
145
146
|
* ```
|
|
146
147
|
*/
|
|
147
|
-
declare function Trans(key: string, params?: Params
|
|
148
|
+
declare function Trans(key: string, params?: Params): HTMLElement;
|
|
148
149
|
/**
|
|
149
150
|
* Check if a translation key exists for the current locale — the request's
|
|
150
151
|
* locale during SSR, the client locale otherwise.
|
|
@@ -166,833 +167,6 @@ declare function hasTranslation(key: string): boolean;
|
|
|
166
167
|
*/
|
|
167
168
|
declare function getAvailableLocales(): string[];
|
|
168
169
|
|
|
169
|
-
/**
|
|
170
|
-
* A route component. An alias of the public `Component` (props-less, any
|
|
171
|
-
* `Element` root), kept under this name so existing imports of the router's
|
|
172
|
-
* `Component` continue to work.
|
|
173
|
-
*/
|
|
174
|
-
type Component = Component$1<void, Element>;
|
|
175
|
-
type AsyncComponent = () => Promise<Element>;
|
|
176
|
-
type LazyComponent = () => Promise<{
|
|
177
|
-
default: Component;
|
|
178
|
-
}>;
|
|
179
|
-
type Params = Record<string, string>;
|
|
180
|
-
/** Every value of every query key, in URL order: `?tag=a&tag=b` is `{ tag: ["a", "b"] }`. */
|
|
181
|
-
type QueryValues = Readonly<Record<string, readonly string[]>>;
|
|
182
|
-
/**
|
|
183
|
-
* The query of a navigation object. An array value repeats its key once per
|
|
184
|
-
* value, in order: `{ tag: ["a", "b"] }` is `?tag=a&tag=b`.
|
|
185
|
-
*/
|
|
186
|
-
type NavigationQuery = Readonly<Record<string, string | readonly string[]>>;
|
|
187
|
-
interface RouteContext {
|
|
188
|
-
readonly path: string;
|
|
189
|
-
readonly params: Params;
|
|
190
|
-
/**
|
|
191
|
-
* The decoded query (`+` is a space, `%XX` is decoded). A repeated key keeps
|
|
192
|
-
* its last value here: `?tag=a&tag=b` is `{ tag: "b" }`. Read
|
|
193
|
-
* {@link RouteContext.queryAll} for every value.
|
|
194
|
-
*/
|
|
195
|
-
readonly query: Params;
|
|
196
|
-
/**
|
|
197
|
-
* Every value of every query key, in URL order, with the same decoding as
|
|
198
|
-
* `query`: `?tag=a&tag=b` is `{ tag: ["a", "b"] }`. Two locations are the
|
|
199
|
-
* same route — for duplicate detection and `RouterLink` exact-active — when
|
|
200
|
-
* these match, key order aside.
|
|
201
|
-
*/
|
|
202
|
-
readonly queryAll: QueryValues;
|
|
203
|
-
readonly hash: string;
|
|
204
|
-
readonly meta: RouteMeta;
|
|
205
|
-
readonly matched: RouteDef[];
|
|
206
|
-
}
|
|
207
|
-
type GuardResult = boolean | string | Promise<boolean | string>;
|
|
208
|
-
type Guard = (to: RouteContext, from?: RouteContext) => GuardResult;
|
|
209
|
-
type NavigationGuard = (to: RouteContext, from: RouteContext, next: NavigationNext) => void;
|
|
210
|
-
type NavigationNext = (result?: boolean | string | Error) => void;
|
|
211
|
-
type RouteMeta = Record<string, unknown>;
|
|
212
|
-
interface RouteBase {
|
|
213
|
-
readonly path: string;
|
|
214
|
-
readonly name?: string;
|
|
215
|
-
readonly meta?: RouteMeta;
|
|
216
|
-
/**
|
|
217
|
-
* The document head while this route is committed: `title`, `description`,
|
|
218
|
-
* `canonical`, Open Graph (`og`) and extra `meta` entries. Values may be
|
|
219
|
-
* getters `(route) => string`, evaluated reactively. Nested records merge,
|
|
220
|
-
* the deepest winning; `createRouter({ head })` provides the defaults.
|
|
221
|
-
*
|
|
222
|
-
* The router manages the head only once some route (or the router) declares
|
|
223
|
-
* one, so an app without `head` is never touched.
|
|
224
|
-
*/
|
|
225
|
-
readonly head?: RouteHead;
|
|
226
|
-
readonly children?: RouteDef[];
|
|
227
|
-
readonly beforeEnter?: Guard | Guard[];
|
|
228
|
-
readonly alias?: string | string[];
|
|
229
|
-
/**
|
|
230
|
-
* Identity of the mounted instance of this route's component.
|
|
231
|
-
*
|
|
232
|
-
* When a navigation stays on this route but the key changes, the outlet
|
|
233
|
-
* disposes the old instance (running its `onUnmount` / `onCleanup`
|
|
234
|
-
* callbacks and releasing its bindings) and mounts a fresh one — so a page
|
|
235
|
-
* that reads `route().params.id` once at setup always sees the right id.
|
|
236
|
-
*
|
|
237
|
-
* **Default:** the path params this record declares in its *own* path (and
|
|
238
|
-
* aliases). `/records/1` → `/records/2` remounts; `?tab=a` → `?tab=b` or a
|
|
239
|
-
* hash change does not. A parent layout is not remounted when only a child's
|
|
240
|
-
* param changes — the child's `Outlet()` remounts the child instead. A
|
|
241
|
-
* record with no params of its own is never remounted by a param change, and
|
|
242
|
-
* a `*` tail (`pathMatch`) is not part of the default: a catch-all keeps its
|
|
243
|
-
* instance and reads `pathMatch` reactively (`key: (r) => r.params.pathMatch`
|
|
244
|
-
* remounts per path).
|
|
245
|
-
*
|
|
246
|
-
* **Override:** return any string derived from the route. Return a constant
|
|
247
|
-
* to keep one long-lived instance across param changes (the instance must
|
|
248
|
-
* then read params reactively, e.g. `routerState().params()` or
|
|
249
|
-
* `() => route().params.id`). Include query values to also remount on a
|
|
250
|
-
* query change.
|
|
251
|
-
*
|
|
252
|
-
* Called untracked with the committed route. Ignored by `KeepAliveRoute()`,
|
|
253
|
-
* which already keeps one instance per full location.
|
|
254
|
-
*
|
|
255
|
-
* @example
|
|
256
|
-
* ```ts
|
|
257
|
-
* // Keep one instance for every record; the page reads params reactively.
|
|
258
|
-
* { path: "/records/:id", component: RecordPage, key: () => "record" }
|
|
259
|
-
* // Also remount when ?tab changes.
|
|
260
|
-
* { path: "/records/:id", component: RecordPage, key: (r) => `${r.params.id}|${r.query.tab ?? ""}` }
|
|
261
|
-
* ```
|
|
262
|
-
*/
|
|
263
|
-
readonly key?: (route: RouteContext) => string;
|
|
264
|
-
}
|
|
265
|
-
interface ComponentRoute extends RouteBase {
|
|
266
|
-
readonly component: Component;
|
|
267
|
-
}
|
|
268
|
-
interface AsyncRoute extends RouteBase {
|
|
269
|
-
readonly component: AsyncComponent | LazyComponent;
|
|
270
|
-
}
|
|
271
|
-
interface RedirectRoute extends RouteBase {
|
|
272
|
-
readonly redirect: string | ((to: RouteContext) => string);
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* A route whose component is loaded on first visit via a dynamic
|
|
276
|
-
* `import()`. This is the ergonomic shorthand for
|
|
277
|
-
* `{ component: lazy(() => import("./Page")) }`.
|
|
278
|
-
*
|
|
279
|
-
* The loader must return a module with a `default` Component export.
|
|
280
|
-
*/
|
|
281
|
-
interface LazyRoute extends RouteBase {
|
|
282
|
-
readonly lazy: () => Promise<{
|
|
283
|
-
default: Component;
|
|
284
|
-
}>;
|
|
285
|
-
}
|
|
286
|
-
type RouteDef = ComponentRoute | AsyncRoute | RedirectRoute | LazyRoute;
|
|
287
|
-
interface RouterOptions {
|
|
288
|
-
readonly mode?: "history" | "hash";
|
|
289
|
-
readonly base?: string;
|
|
290
|
-
readonly linkActiveClass?: string;
|
|
291
|
-
readonly linkExactActiveClass?: string;
|
|
292
|
-
readonly fallback?: boolean;
|
|
293
|
-
/**
|
|
294
|
-
* Scroll position to restore after a navigation commits.
|
|
295
|
-
*
|
|
296
|
-
* A **browser-only, post-navigation side effect**:
|
|
297
|
-
*
|
|
298
|
-
* - In a runtime without the required scrolling primitives
|
|
299
|
-
* (`requestAnimationFrame` and `window.scrollTo`) the hook is **not invoked
|
|
300
|
-
* at all** — it is browser code, and its result would be discarded anyway.
|
|
301
|
-
* - It runs *after* the route and history have committed. An exception it
|
|
302
|
-
* throws is reported to the console but never retroactively fails an
|
|
303
|
-
* already-committed navigation: `NavigationResult.success` stays `true` and
|
|
304
|
-
* `currentRoute` stays authoritative.
|
|
305
|
-
* - Returning a falsy value means "do not scroll" and is not an error.
|
|
306
|
-
*/
|
|
307
|
-
readonly scrollBehavior?: ScrollBehavior;
|
|
308
|
-
readonly guardTimeout?: number;
|
|
309
|
-
readonly cacheSize?: number;
|
|
310
|
-
readonly errorRetryDelay?: number;
|
|
311
|
-
readonly preloadStrategy?: "none" | "hover" | "visible";
|
|
312
|
-
/**
|
|
313
|
-
* Enable KeepAlive caching for route components.
|
|
314
|
-
* - `true` — cache all routes
|
|
315
|
-
* - string[] — cache only named routes matching these names
|
|
316
|
-
* - number — cache all routes with this max cache size
|
|
317
|
-
*/
|
|
318
|
-
readonly keepAlive?: boolean | string[] | number;
|
|
319
|
-
/**
|
|
320
|
-
* Head defaults for every route, plus `titleTemplate`. Declaring it (or a
|
|
321
|
-
* `head` on any route) makes the router own `document.title` and the
|
|
322
|
-
* description / canonical / Open Graph tags; see {@link RouteBase.head}.
|
|
323
|
-
*/
|
|
324
|
-
readonly head?: RouterHeadOptions;
|
|
325
|
-
}
|
|
326
|
-
type ScrollBehavior = (to: RouteContext, from: RouteContext, savedPosition: ScrollPosition | null) => ScrollPosition | null;
|
|
327
|
-
interface ScrollPosition {
|
|
328
|
-
readonly x: number;
|
|
329
|
-
readonly y: number;
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Why a navigation failed, at a finer grain than `type`.
|
|
333
|
-
*
|
|
334
|
-
* `type: "aborted"` alone cannot tell a caller whether the user was denied
|
|
335
|
-
* access, whether they simply clicked a newer link, or whether the app tore the
|
|
336
|
-
* router down — three situations that call for very different handling (show a
|
|
337
|
-
* message / stay silent / stay silent). `reason` disambiguates them without
|
|
338
|
-
* changing the existing `type` values, so code branching on `type` keeps
|
|
339
|
-
* working unchanged.
|
|
340
|
-
*
|
|
341
|
-
* - `guard` — a navigation guard returned `false`.
|
|
342
|
-
* - `superseded` — a newer navigation started before this one could commit.
|
|
343
|
-
* Expected during rapid navigation; normally not surfaced to users.
|
|
344
|
-
* - `router-destroyed` — the router was destroyed while this navigation was in
|
|
345
|
-
* flight.
|
|
346
|
-
* - `redirect-loop` — redirect resolution exceeded the maximum hop count.
|
|
347
|
-
* - `unsafe-target` — the target or a redirect used a blocked URI scheme, or was
|
|
348
|
-
* an absolute/protocol-relative URL (open-redirect protection).
|
|
349
|
-
* - `duplicate` — the target is identical to the current route.
|
|
350
|
-
* - `error` — an unexpected error escaped the navigation pipeline.
|
|
351
|
-
*/
|
|
352
|
-
type NavigationFailureReason = "guard" | "superseded" | "router-destroyed" | "redirect-loop" | "unsafe-target" | "duplicate" | "error";
|
|
353
|
-
interface NavigationFailure {
|
|
354
|
-
readonly type: "aborted" | "cancelled" | "duplicated" | "timeout";
|
|
355
|
-
/**
|
|
356
|
-
* Finer-grained cause. Additive — existing checks on `type` are unaffected.
|
|
357
|
-
*/
|
|
358
|
-
readonly reason?: NavigationFailureReason;
|
|
359
|
-
readonly from: RouteContext;
|
|
360
|
-
readonly to: RouteContext;
|
|
361
|
-
readonly error?: Error;
|
|
362
|
-
}
|
|
363
|
-
type NavigationResult = {
|
|
364
|
-
success: true;
|
|
365
|
-
route: RouteContext;
|
|
366
|
-
} | {
|
|
367
|
-
success: false;
|
|
368
|
-
type: NavigationFailure["type"];
|
|
369
|
-
/** Mirrors `failure.reason`; see {@link NavigationFailureReason}. */
|
|
370
|
-
reason?: NavigationFailureReason;
|
|
371
|
-
failure: NavigationFailure;
|
|
372
|
-
};
|
|
373
|
-
type NavigationTarget = string | {
|
|
374
|
-
path?: string;
|
|
375
|
-
name?: string;
|
|
376
|
-
params?: Params;
|
|
377
|
-
query?: NavigationQuery;
|
|
378
|
-
hash?: string;
|
|
379
|
-
};
|
|
380
|
-
/**
|
|
381
|
-
* Component loader with caching and error recovery
|
|
382
|
-
*/
|
|
383
|
-
/**
|
|
384
|
-
* How the router will produce an instance of a route's component.
|
|
385
|
-
*
|
|
386
|
-
* Deliberately never holds an `Element`: an instance produced by one invocation
|
|
387
|
-
* must never become a reusable factory. (LOAD-002)
|
|
388
|
-
*
|
|
389
|
-
* The two kinds are structural, not provisional:
|
|
390
|
-
*
|
|
391
|
-
* - `factory` — invoke once per instance, only when an instance is needed.
|
|
392
|
-
* Everything unbranded lands here: synchronous, `async`, and
|
|
393
|
-
* Promise-returning component factories alike.
|
|
394
|
-
* - `deferred` — an **explicitly branded** `lazy()` module loader. This is the
|
|
395
|
-
* only kind preload may execute. (LOAD-004)
|
|
396
|
-
*/
|
|
397
|
-
type RoutePlan = {
|
|
398
|
-
kind: "factory";
|
|
399
|
-
component: Component;
|
|
400
|
-
} | {
|
|
401
|
-
kind: "deferred";
|
|
402
|
-
load: AsyncComponent | LazyComponent;
|
|
403
|
-
};
|
|
404
|
-
declare class SibuRouter {
|
|
405
|
-
private options;
|
|
406
|
-
private matcher;
|
|
407
|
-
private guards;
|
|
408
|
-
private loader;
|
|
409
|
-
private navigator;
|
|
410
|
-
private currentRouteGetter;
|
|
411
|
-
private currentRouteSetter;
|
|
412
|
-
private isReadyGetter;
|
|
413
|
-
private isReadySetter;
|
|
414
|
-
private cleanup;
|
|
415
|
-
private destroyed;
|
|
416
|
-
private navEpoch;
|
|
417
|
-
private headController;
|
|
418
|
-
private readonly readyPromise;
|
|
419
|
-
private resolveReady;
|
|
420
|
-
private loadedPromise;
|
|
421
|
-
constructor(routes: RouteDef[], options?: RouterOptions);
|
|
422
|
-
private initialize;
|
|
423
|
-
/** Load the component of every record the current route matched, without instantiating any. */
|
|
424
|
-
private preloadMatched;
|
|
425
|
-
/** Settles after the initial navigation and its component loads; see `routerReady()`. */
|
|
426
|
-
whenReady(): Promise<void>;
|
|
427
|
-
private createInitialRoute;
|
|
428
|
-
private handleLocationChange;
|
|
429
|
-
private getCurrentPath;
|
|
430
|
-
private createRouteContext;
|
|
431
|
-
navigate(to: NavigationTarget, options?: {
|
|
432
|
-
replace?: boolean;
|
|
433
|
-
state?: unknown;
|
|
434
|
-
skipHistory?: boolean;
|
|
435
|
-
initialResolution?: boolean;
|
|
436
|
-
}): Promise<NavigationResult>;
|
|
437
|
-
private static readonly MAX_REDIRECT_DEPTH;
|
|
438
|
-
private performNavigation;
|
|
439
|
-
private updateHead;
|
|
440
|
-
private resolvePath;
|
|
441
|
-
private isSameRoute;
|
|
442
|
-
private updateHistory;
|
|
443
|
-
/**
|
|
444
|
-
* Apply the configured `scrollBehavior`, if the runtime can actually scroll.
|
|
445
|
-
*
|
|
446
|
-
* This runs *after* the route has been committed, so an exception here does
|
|
447
|
-
* not merely skip scrolling — it propagates out of `navigateInternal` and the
|
|
448
|
-
* navigation is reported as `success: false` while the route state says it
|
|
449
|
-
* succeeded. In a DOM-less runtime the bare `requestAnimationFrame` did
|
|
450
|
-
* exactly that: a legal `scrollBehavior` option made every navigation report
|
|
451
|
-
* failure under SSR and in memory-router-style tests. (MEM-001)
|
|
452
|
-
*
|
|
453
|
-
* Policy A, consistent with the history write in `updateHistory()` (NODE-001):
|
|
454
|
-
* the route still commits, and only the browser-only side effect is skipped.
|
|
455
|
-
*
|
|
456
|
-
* Both primitives are probed, not just `window` — `requestAnimationFrame` and
|
|
457
|
-
* `scrollTo` can be missing independently (jsdom without a rAF polyfill, a
|
|
458
|
-
* partial DOM shim). `requestAnimationFrame` is invoked as a method on the
|
|
459
|
-
* global object rather than through a detached reference, since browsers
|
|
460
|
-
* reject a bare call with "Illegal invocation".
|
|
461
|
-
*/
|
|
462
|
-
private handleScrollBehavior;
|
|
463
|
-
/**
|
|
464
|
-
* Resolve how this route's component will be produced, without instantiating
|
|
465
|
-
* anything. Pair with {@link instantiateComponent} at the commit boundary.
|
|
466
|
-
*/
|
|
467
|
-
loadPlan(route: RouteDef, routePath: string): Promise<RoutePlan>;
|
|
468
|
-
/**
|
|
469
|
-
* Create exactly one real instance from an already-resolved plan. With a
|
|
470
|
-
* `scope`, the factory runs in it (see `RouteScope`).
|
|
471
|
-
*/
|
|
472
|
-
instantiateComponent(plan: RoutePlan, route: RouteDef, routePath: string, scope?: RouteScope): Promise<Element>;
|
|
473
|
-
/** Resolve a route's module/factory without creating any component instance. */
|
|
474
|
-
preloadPlan(route: RouteDef, routePath: string): Promise<void>;
|
|
475
|
-
beforeEach(guard: NavigationGuard): () => void;
|
|
476
|
-
beforeResolve(guard: NavigationGuard): () => void;
|
|
477
|
-
afterEach(hook: (to: RouteContext, from: RouteContext) => void): () => void;
|
|
478
|
-
push(to: NavigationTarget): Promise<NavigationResult>;
|
|
479
|
-
replace(to: NavigationTarget): Promise<NavigationResult>;
|
|
480
|
-
go(delta: number): void;
|
|
481
|
-
back(): void;
|
|
482
|
-
forward(): void;
|
|
483
|
-
get currentRoute(): RouteContext;
|
|
484
|
-
get isReady(): boolean;
|
|
485
|
-
/** @internal Navigation generation — see `navEpoch`. Not a public API. */
|
|
486
|
-
get navigationEpoch(): number;
|
|
487
|
-
get isNavigating(): boolean;
|
|
488
|
-
destroy(): void;
|
|
489
|
-
clearCache(): void;
|
|
490
|
-
clearErrorCache(): void;
|
|
491
|
-
updateRoutes(routes: RouteDef[]): void;
|
|
492
|
-
/**
|
|
493
|
-
* Add a route dynamically at runtime.
|
|
494
|
-
*/
|
|
495
|
-
addRoute(route: RouteDef, parentPath?: string): void;
|
|
496
|
-
/**
|
|
497
|
-
* Remove a route by path.
|
|
498
|
-
*/
|
|
499
|
-
removeRoute(path: string): void;
|
|
500
|
-
/**
|
|
501
|
-
* Get the reactive route getter for tracking.
|
|
502
|
-
*/
|
|
503
|
-
get routeGetter(): () => RouteContext;
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* Create the global router and make it the one `route()`, `navigate()` and
|
|
507
|
-
* `RouterLink` talk to. Any previously created router is destroyed first.
|
|
508
|
-
*
|
|
509
|
-
* @param routesOrOptions Either the route table, or the options object when
|
|
510
|
-
* routes are supplied later via {@link setRoutes}.
|
|
511
|
-
* @param options Router options when the first argument is the route table.
|
|
512
|
-
* @returns The created router instance.
|
|
513
|
-
*/
|
|
514
|
-
declare function createRouter(routesOrOptions: RouteDef[] | RouterOptions, options?: RouterOptions): SibuRouter;
|
|
515
|
-
/**
|
|
516
|
-
* Set routes on the global router (replaces existing routes).
|
|
517
|
-
*/
|
|
518
|
-
declare function setRoutes(routes: RouteDef[]): void;
|
|
519
|
-
/**
|
|
520
|
-
* The route one mounted route instance was committed with.
|
|
521
|
-
*
|
|
522
|
-
* A navigation commits the router's route first; the outlet swaps the
|
|
523
|
-
* component afterwards — a microtask later for a synchronous page, a whole
|
|
524
|
-
* chunk download later for a lazy one. If route instances read the
|
|
525
|
-
* router-global route, the outgoing page re-runs its effects against the
|
|
526
|
-
* INCOMING route's params in that window, and its teardown sees them too.
|
|
527
|
-
*
|
|
528
|
-
* So each instance reads its own scope instead. Outlets create one per
|
|
529
|
-
* instance, run the component factory in it (an owner scope, see
|
|
530
|
-
* reactivity/track-core.ts, so every computation the page creates — now or
|
|
531
|
-
* later, through its directives — inherits it), and then:
|
|
532
|
-
*
|
|
533
|
-
* - an instance the outlet KEEPS across a navigation (same record and instance
|
|
534
|
-
* key: a query/hash-only change, or a layout whose child changed) is handed
|
|
535
|
-
* the new route — it follows the navigation, as before;
|
|
536
|
-
* - an instance being REPLACED is never updated: it keeps observing its own
|
|
537
|
-
* route until it is disposed, and its teardown runs in its scope;
|
|
538
|
-
* - a KeepAlive view keeps its route while cached and gets the new route when
|
|
539
|
-
* it is shown again.
|
|
540
|
-
*
|
|
541
|
-
* Once the instance is disposed the scope is released: a computation that
|
|
542
|
-
* outlived it (an app-lifetime derived that happened to be created while the
|
|
543
|
-
* page rendered) is not the page's, and falls back to the router-global route.
|
|
544
|
-
*/
|
|
545
|
-
declare class RouteScope {
|
|
546
|
-
private readonly get;
|
|
547
|
-
private readonly set;
|
|
548
|
-
private released;
|
|
549
|
-
constructor(route: RouteContext);
|
|
550
|
-
/** The instance's route, or `null` once released. Reactive. */
|
|
551
|
-
read(): RouteContext | null;
|
|
552
|
-
/** Hand a kept instance the route of the navigation that kept it. */
|
|
553
|
-
update(route: RouteContext): void;
|
|
554
|
-
/**
|
|
555
|
-
* Called when the instance is disposed. The switch to "no scope" is
|
|
556
|
-
* published a microtask later, once the whole dispose has finished: a
|
|
557
|
-
* teardown the instance registered after this one (an `onMount` effect, say)
|
|
558
|
-
* may still be alive at this point, and must not re-run against the
|
|
559
|
-
* router-global route on its way out.
|
|
560
|
-
*/
|
|
561
|
-
release(): void;
|
|
562
|
-
}
|
|
563
|
-
/**
|
|
564
|
-
* Read the current route as a plain snapshot.
|
|
565
|
-
*
|
|
566
|
-
* Reading it once in a route component's setup is safe: when a navigation
|
|
567
|
-
* changes that route's own params, the outlet mounts a fresh instance (see
|
|
568
|
-
* `RouteBase.key`). Inside a getter — `() => route().params.id` — the read is
|
|
569
|
-
* reactive, which is what a long-lived layout or a constant-`key` route needs.
|
|
570
|
-
*
|
|
571
|
-
* Inside a route instance (anything its component creates, and any effect,
|
|
572
|
-
* derived or binding created from there) this is the route THAT INSTANCE was
|
|
573
|
-
* committed with. An instance the outlet keeps across a navigation follows it;
|
|
574
|
-
* an instance being replaced keeps its own route until it is disposed, so its
|
|
575
|
-
* effects and teardown never observe the next page's params. Everywhere else
|
|
576
|
-
* it is the router's current route.
|
|
577
|
-
*
|
|
578
|
-
* @returns The active {@link RouteContext} (path, params, query, hash).
|
|
579
|
-
* @throws If no router has been created yet.
|
|
580
|
-
*/
|
|
581
|
-
declare function route(): RouteContext;
|
|
582
|
-
/**
|
|
583
|
-
* Handle onto the global router's navigation surface.
|
|
584
|
-
*
|
|
585
|
-
* @returns An object exposing the current route plus `push`, `replace`, `go`,
|
|
586
|
-
* `back`, `forward` and the three guard registrars.
|
|
587
|
-
* @throws If no router has been created yet.
|
|
588
|
-
*/
|
|
589
|
-
declare function router(): {
|
|
590
|
-
currentRoute: RouteContext;
|
|
591
|
-
isReady: boolean;
|
|
592
|
-
isNavigating: boolean;
|
|
593
|
-
push: (to: NavigationTarget) => Promise<NavigationResult> | undefined;
|
|
594
|
-
replace: (to: NavigationTarget) => Promise<NavigationResult> | undefined;
|
|
595
|
-
go: (delta: number) => void | undefined;
|
|
596
|
-
back: () => void | undefined;
|
|
597
|
-
forward: () => void | undefined;
|
|
598
|
-
beforeEach: (guard: NavigationGuard) => (() => void) | undefined;
|
|
599
|
-
beforeResolve: (guard: NavigationGuard) => (() => void) | undefined;
|
|
600
|
-
afterEach: (hook: (to: RouteContext, from: RouteContext) => void) => (() => void) | undefined;
|
|
601
|
-
};
|
|
602
|
-
/**
|
|
603
|
-
* Resolves once the router has resolved the page's initial location AND loaded
|
|
604
|
-
* the components that location matched (lazy route chunks included).
|
|
605
|
-
*
|
|
606
|
-
* Await it before `hydrate()` on a pre-rendered page: the client tree is then
|
|
607
|
-
* built with every route component already loaded, so the outlet renders in
|
|
608
|
-
* the same task and the swap from pre-rendered markup shows no empty frame.
|
|
609
|
-
* Also resolves if the initial navigation fails or the router is destroyed.
|
|
610
|
-
*
|
|
611
|
-
* @returns A promise that never rejects.
|
|
612
|
-
* @throws If no router has been created yet.
|
|
613
|
-
*
|
|
614
|
-
* @example
|
|
615
|
-
* ```ts
|
|
616
|
-
* createRouter(routes, { mode: "history" });
|
|
617
|
-
* await routerReady();
|
|
618
|
-
* hydrate(App, document.getElementById("app")!);
|
|
619
|
-
* ```
|
|
620
|
-
*/
|
|
621
|
-
declare function routerReady(): Promise<void>;
|
|
622
|
-
/**
|
|
623
|
-
* Navigate to a target, running every registered guard.
|
|
624
|
-
*
|
|
625
|
-
* @param to Path string or location descriptor.
|
|
626
|
-
* @param options `replace` swaps the current history entry instead of pushing;
|
|
627
|
-
* `state` is stored on the history entry.
|
|
628
|
-
* @returns A promise for the {@link NavigationResult} — resolved even when a
|
|
629
|
-
* guard cancels, so the outcome must be inspected rather than assumed.
|
|
630
|
-
* @throws If no router has been created yet.
|
|
631
|
-
*/
|
|
632
|
-
declare function navigate(to: NavigationTarget, options?: {
|
|
633
|
-
replace?: boolean;
|
|
634
|
-
state?: unknown;
|
|
635
|
-
}): Promise<NavigationResult>;
|
|
636
|
-
/**
|
|
637
|
-
* Navigate by pushing a new history entry.
|
|
638
|
-
*
|
|
639
|
-
* @param to Path string or location descriptor.
|
|
640
|
-
* @returns A promise for the {@link NavigationResult}.
|
|
641
|
-
*/
|
|
642
|
-
declare function push(to: NavigationTarget): Promise<NavigationResult>;
|
|
643
|
-
/**
|
|
644
|
-
* Navigate by replacing the current history entry.
|
|
645
|
-
*
|
|
646
|
-
* @param to Path string or location descriptor.
|
|
647
|
-
* @returns A promise for the {@link NavigationResult}.
|
|
648
|
-
*/
|
|
649
|
-
declare function replace(to: NavigationTarget): Promise<NavigationResult>;
|
|
650
|
-
/**
|
|
651
|
-
* Move through history by a relative offset, as `history.go` does.
|
|
652
|
-
*
|
|
653
|
-
* @param delta Number of entries to move; negative goes back.
|
|
654
|
-
* @returns Nothing — history moves asynchronously, so nothing is awaited here.
|
|
655
|
-
*/
|
|
656
|
-
declare function go(delta: number): void;
|
|
657
|
-
/** Go back one history entry. Equivalent to `go(-1)`. */
|
|
658
|
-
declare function back(): void;
|
|
659
|
-
/** Go forward one history entry. Equivalent to `go(1)`. */
|
|
660
|
-
declare function forward(): void;
|
|
661
|
-
/**
|
|
662
|
-
* Register a guard that runs before every navigation is confirmed.
|
|
663
|
-
*
|
|
664
|
-
* @param guard Called with the target and current routes; return `false` to
|
|
665
|
-
* cancel, or a target to redirect.
|
|
666
|
-
* @returns An unregister function.
|
|
667
|
-
*/
|
|
668
|
-
declare function beforeEach(guard: NavigationGuard): () => void;
|
|
669
|
-
/**
|
|
670
|
-
* Register a guard that runs after `beforeEach` and after async components have
|
|
671
|
-
* resolved, but before the route commits.
|
|
672
|
-
*
|
|
673
|
-
* @param guard Called with the target and current routes.
|
|
674
|
-
* @returns An unregister function.
|
|
675
|
-
*/
|
|
676
|
-
declare function beforeResolve(guard: NavigationGuard): () => void;
|
|
677
|
-
/**
|
|
678
|
-
* Register a hook that runs after every confirmed navigation. It cannot cancel
|
|
679
|
-
* or redirect — by the time it runs the route has already committed.
|
|
680
|
-
*
|
|
681
|
-
* @param hook Called with the new and previous routes.
|
|
682
|
-
* @returns An unregister function.
|
|
683
|
-
*/
|
|
684
|
-
declare function afterEach(hook: (to: RouteContext, from: RouteContext) => void): () => void;
|
|
685
|
-
/**
|
|
686
|
-
* The route outlet: renders whichever component matches the current route, and
|
|
687
|
-
* swaps it when the top-level matched record or its instance key changes. By
|
|
688
|
-
* default the key is that record's own path params, so `/records/1` →
|
|
689
|
-
* `/records/2` mounts a fresh instance while a query- or hash-only change keeps
|
|
690
|
-
* the current one (see `RouteBase.key`).
|
|
691
|
-
*
|
|
692
|
-
* @returns A Comment anchor that manages the matched component. Like every
|
|
693
|
-
* factory here it hands back a live node the caller can insert directly.
|
|
694
|
-
*
|
|
695
|
-
* TRAP — a navigation REBUILDS the outlet's subtree, so focus and selection
|
|
696
|
-
* inside the outgoing route are discarded. The runtime restores focus when the
|
|
697
|
-
* incoming route contains an element with the same `id`, `name` or
|
|
698
|
-
* `data-focus-key`, and warns in dev when it cannot.
|
|
699
|
-
*/
|
|
700
|
-
declare function Route(): Node;
|
|
701
|
-
/**
|
|
702
|
-
* A route outlet that caches rendered components using KeepAlive.
|
|
703
|
-
* Routes are preserved in the DOM cache so signals, form state, and scroll
|
|
704
|
-
* position survive navigation.
|
|
705
|
-
*
|
|
706
|
-
* Uses the `keepAlive` option from RouterOptions if set, or accepts
|
|
707
|
-
* explicit options.
|
|
708
|
-
*
|
|
709
|
-
* ## Cache identity
|
|
710
|
-
*
|
|
711
|
-
* A cached view is keyed by the **full location** — path + query + hash — so
|
|
712
|
-
* `/search?q=a`, `/search?q=b`, and `/docs#one` are three distinct cached views.
|
|
713
|
-
* Keying on `route.path` alone would serve one query's cached DOM and state for
|
|
714
|
-
* another.
|
|
715
|
-
*
|
|
716
|
-
* ## Reuse and disposal
|
|
717
|
-
*
|
|
718
|
-
* | Event | Effect on a cached view |
|
|
719
|
-
* |---|---|
|
|
720
|
-
* | navigated away from | detached, kept in cache, **not** disposed |
|
|
721
|
-
* | navigated back to | the same node is re-attached — no remount |
|
|
722
|
-
* | evicted past `max` (LRU) | disposed and dropped |
|
|
723
|
-
* | excluded by `include` | never cached; disposed on navigation away |
|
|
724
|
-
* | outlet disposed | whole cache disposed and cleared |
|
|
725
|
-
*
|
|
726
|
-
* ## Cache identity is not async ownership
|
|
727
|
-
*
|
|
728
|
-
* The cache key answers *"which cached view is this?"*. It never answers *"may
|
|
729
|
-
* this async completion still commit?"* — that is what the update generation is
|
|
730
|
-
* for, because `same route value !== same navigation generation`. See
|
|
731
|
-
* `docs/architecture/router.md`.
|
|
732
|
-
*
|
|
733
|
-
* @param options Optional: override the router-level keepAlive setting
|
|
734
|
-
*
|
|
735
|
-
* @example
|
|
736
|
-
* ```ts
|
|
737
|
-
* // Cache all routes (max 10)
|
|
738
|
-
* createRouter(routes, { keepAlive: 10 });
|
|
739
|
-
* mount(() => div([nav, KeepAliveRoute()]), root);
|
|
740
|
-
*
|
|
741
|
-
* // Or cache specific routes by name
|
|
742
|
-
* createRouter(routes, { keepAlive: ["dashboard", "settings"] });
|
|
743
|
-
* mount(() => div([nav, KeepAliveRoute()]), root);
|
|
744
|
-
*
|
|
745
|
-
* // Or override per-outlet
|
|
746
|
-
* KeepAliveRoute({ max: 5, include: ["dashboard"] })
|
|
747
|
-
* ```
|
|
748
|
-
*/
|
|
749
|
-
declare function KeepAliveRoute(options?: {
|
|
750
|
-
max?: number;
|
|
751
|
-
include?: string[];
|
|
752
|
-
}): Node;
|
|
753
|
-
declare function RouterLink(props: {
|
|
754
|
-
to: NavigationTarget;
|
|
755
|
-
replace?: boolean;
|
|
756
|
-
activeClass?: string;
|
|
757
|
-
exactActiveClass?: string;
|
|
758
|
-
/** @deprecated Pass children positionally: `RouterLink(props, children)`. */
|
|
759
|
-
nodes?: NodeChildren;
|
|
760
|
-
target?: string;
|
|
761
|
-
rel?: string;
|
|
762
|
-
[key: string]: unknown;
|
|
763
|
-
}, children?: NodeChildren): HTMLAnchorElement;
|
|
764
|
-
/**
|
|
765
|
-
* Async boundary for code-split / deferred content.
|
|
766
|
-
*
|
|
767
|
-
* **Ownership contract.** The boundary owns every node it creates or installs.
|
|
768
|
-
* A node that leaves the boundary — replaced by resolved content, or dropped on
|
|
769
|
-
* teardown — is lifecycle-disposed exactly once. Native detachment alone is not
|
|
770
|
-
* cleanup: a detached subtree keeps its effects, listeners and registered
|
|
771
|
-
* disposers alive, firing against DOM nobody can see. (SUS-001)
|
|
772
|
-
*
|
|
773
|
-
* **Async completion grants no commit permission.** A resolution that arrives
|
|
774
|
-
* after the boundary was torn down, or after a newer generation superseded it,
|
|
775
|
-
* may never insert into the DOM. Because the promise typically resolves with an
|
|
776
|
-
* *already constructed* Element — whose effects and listeners were created
|
|
777
|
-
* before the boundary discovered it lost ownership — the stale result is
|
|
778
|
-
* disposed rather than merely dropped. (SUS-002)
|
|
779
|
-
*
|
|
780
|
-
* The boundary is **single-shot**: `props.nodes()` is invoked exactly once, so
|
|
781
|
-
* only one async generation is reachable in practice. The generation token is
|
|
782
|
-
* kept anyway because teardown must be able to invalidate the in-flight one, and
|
|
783
|
-
* because ownership is the correct primitive to express that with.
|
|
784
|
-
*/
|
|
785
|
-
declare function Suspense(props: {
|
|
786
|
-
/** Shown while `nodes` is pending. An element, or a function returning one. */
|
|
787
|
-
fallback?: (() => HTMLElement) | HTMLElement;
|
|
788
|
-
/**
|
|
789
|
-
* The content. May be an element, or any thenable resolving to one —
|
|
790
|
-
* `PromiseLike`, not `Promise`, because a promise from another realm or a
|
|
791
|
-
* custom thenable is awaited just the same. The previous type admitted only
|
|
792
|
-
* `Promise`, so the very values the runtime was fixed to handle still had to
|
|
793
|
-
* be cast at the call site.
|
|
794
|
-
*/
|
|
795
|
-
nodes: () => HTMLElement | PromiseLike<HTMLElement>;
|
|
796
|
-
}): Node;
|
|
797
|
-
/**
|
|
798
|
-
* Creates a lazy-loaded component.
|
|
799
|
-
* Marks the function with a symbol so the router can detect it reliably
|
|
800
|
-
* (no AsyncFunction heuristic needed).
|
|
801
|
-
*/
|
|
802
|
-
declare function lazy(importFn: () => Promise<{
|
|
803
|
-
default: Component;
|
|
804
|
-
}>): LazyComponent;
|
|
805
|
-
/**
|
|
806
|
-
* Preloads a route component
|
|
807
|
-
*/
|
|
808
|
-
declare function preloadRoute(to: NavigationTarget): Promise<void>;
|
|
809
|
-
/**
|
|
810
|
-
* Validates if a route exists
|
|
811
|
-
*/
|
|
812
|
-
/**
|
|
813
|
-
* Current navigation generation for the active router, or `-1` when no router
|
|
814
|
-
* exists (including after `destroyRouter()`).
|
|
815
|
-
*
|
|
816
|
-
* @internal Not part of the public API. Exists so asynchronous work that can
|
|
817
|
-
* acquire DOM ownership — notably `hydrateRouter()`'s bootstrap — can prove it
|
|
818
|
-
* has not been superseded. Capture before the async gap, re-check immediately
|
|
819
|
-
* before committing. A URL comparison cannot serve this purpose: an A→B→A
|
|
820
|
-
* navigation returns to the same URL under a *newer* generation, and stale work
|
|
821
|
-
* must stay superseded.
|
|
822
|
-
*/
|
|
823
|
-
declare function __getNavigationEpoch(): number;
|
|
824
|
-
/**
|
|
825
|
-
* Whether a named route is registered.
|
|
826
|
-
*
|
|
827
|
-
* @param name The route's `name`.
|
|
828
|
-
* @returns `true` when a route with that name exists; `false` when it does not,
|
|
829
|
-
* and also when no router has been created yet.
|
|
830
|
-
*/
|
|
831
|
-
declare function hasRoute(name: string): boolean;
|
|
832
|
-
/**
|
|
833
|
-
* Gets route information by name
|
|
834
|
-
*/
|
|
835
|
-
declare function getRouteInfo(name: string): RouteDef | null;
|
|
836
|
-
/**
|
|
837
|
-
* Builds a URL for a route
|
|
838
|
-
*/
|
|
839
|
-
declare function buildURL(to: NavigationTarget): string;
|
|
840
|
-
declare function destroyRouter(): void;
|
|
841
|
-
/**
|
|
842
|
-
* Remove the module-level `pagehide` listener. Intended for HMR and tests —
|
|
843
|
-
* normal apps never need to call this (the listener is page-lifetime).
|
|
844
|
-
*
|
|
845
|
-
* @internal
|
|
846
|
-
*/
|
|
847
|
-
declare function __removeRouterPagehideHandler(): void;
|
|
848
|
-
/**
|
|
849
|
-
* Outlet renders the child route component within a layout.
|
|
850
|
-
* Use inside a parent route's component to render matched children.
|
|
851
|
-
*
|
|
852
|
-
* The child is remounted when the matched child record changes or when its
|
|
853
|
-
* instance key does — by default the params declared below the top-level
|
|
854
|
-
* record, so a child-only param change remounts the child and leaves the
|
|
855
|
-
* layout in place (see `RouteBase.key`).
|
|
856
|
-
*/
|
|
857
|
-
declare function Outlet(): Node;
|
|
858
|
-
/**
|
|
859
|
-
* Add a route at runtime.
|
|
860
|
-
*/
|
|
861
|
-
declare function addRoute(route: RouteDef, parentPath?: string): void;
|
|
862
|
-
/**
|
|
863
|
-
* Remove a route at runtime.
|
|
864
|
-
*/
|
|
865
|
-
declare function removeRoute(path: string): void;
|
|
866
|
-
/**
|
|
867
|
-
* routerState provides centralized reactive access to router state.
|
|
868
|
-
*/
|
|
869
|
-
declare function routerState(): {
|
|
870
|
-
currentPath: () => string;
|
|
871
|
-
params: () => Params;
|
|
872
|
-
query: () => Params;
|
|
873
|
-
queryAll: () => QueryValues;
|
|
874
|
-
hash: () => string;
|
|
875
|
-
meta: () => RouteMeta;
|
|
876
|
-
isNavigating: () => boolean;
|
|
877
|
-
isReady: () => boolean;
|
|
878
|
-
};
|
|
879
|
-
interface RouterPlugin {
|
|
880
|
-
name: string;
|
|
881
|
-
onNavigate?: (to: RouteContext, from: RouteContext) => void;
|
|
882
|
-
onError?: (error: Error, to: RouteContext) => void;
|
|
883
|
-
onReady?: () => void;
|
|
884
|
-
}
|
|
885
|
-
/**
|
|
886
|
-
* Register a router plugin (analytics, breadcrumbs, permissions, etc.).
|
|
887
|
-
*/
|
|
888
|
-
declare function routerPlugin(plugin: RouterPlugin): () => void;
|
|
889
|
-
interface RouteTransitionOptions {
|
|
890
|
-
enterClass?: string;
|
|
891
|
-
leaveClass?: string;
|
|
892
|
-
duration?: number;
|
|
893
|
-
}
|
|
894
|
-
/**
|
|
895
|
-
* Configure route transition animations.
|
|
896
|
-
*/
|
|
897
|
-
declare function setRouteTransition(options: RouteTransitionOptions): void;
|
|
898
|
-
/**
|
|
899
|
-
* Get current route transition options.
|
|
900
|
-
*/
|
|
901
|
-
declare function getRouteTransition(): RouteTransitionOptions | null;
|
|
902
|
-
/**
|
|
903
|
-
* createMemoryRouter creates a router that doesn't interact with browser history.
|
|
904
|
-
* Useful for testing and SSR.
|
|
905
|
-
*/
|
|
906
|
-
declare function createMemoryRouter(routes: RouteDef[], _initialPath?: string): {
|
|
907
|
-
router: SibuRouter;
|
|
908
|
-
currentPath: () => string;
|
|
909
|
-
push: (path: string) => Promise<NavigationResult>;
|
|
910
|
-
};
|
|
911
|
-
|
|
912
|
-
/**
|
|
913
|
-
* One head value: a string, nothing, or a getter evaluated reactively against
|
|
914
|
-
* the committed route — so route params (`(r) => \`Order ${r.params.id}\``) and
|
|
915
|
-
* translated strings (`() => t("pricing.title")`) both work and stay current.
|
|
916
|
-
* `null` explicitly clears a value a parent route or the defaults set.
|
|
917
|
-
*/
|
|
918
|
-
type RouteHeadValue = string | null | undefined | ((route: RouteContext) => string | null | undefined);
|
|
919
|
-
/** Open Graph tags a route can set. */
|
|
920
|
-
interface RouteHeadOpenGraph {
|
|
921
|
-
/** `og:title`. Defaults to the route's title (without `titleTemplate`). */
|
|
922
|
-
title?: RouteHeadValue;
|
|
923
|
-
/** `og:description`. Defaults to the route's description. */
|
|
924
|
-
description?: RouteHeadValue;
|
|
925
|
-
/** `og:image` — use an ABSOLUTE URL; link-preview bots do not resolve relative ones. */
|
|
926
|
-
image?: RouteHeadValue;
|
|
927
|
-
/** `og:url`. Defaults to the canonical URL. */
|
|
928
|
-
url?: RouteHeadValue;
|
|
929
|
-
/** `og:type`, e.g. `"website"` or `"article"`. */
|
|
930
|
-
type?: RouteHeadValue;
|
|
931
|
-
/** `og:site_name`. */
|
|
932
|
-
siteName?: RouteHeadValue;
|
|
933
|
-
}
|
|
934
|
-
/**
|
|
935
|
-
* The `head` of a route record (and of `createRouter({ head })`, as defaults).
|
|
936
|
-
*
|
|
937
|
-
* Nested records merge field by field, the deepest record winning; the router
|
|
938
|
-
* defaults sit underneath every route.
|
|
939
|
-
*/
|
|
940
|
-
interface RouteHead {
|
|
941
|
-
/** `document.title`. */
|
|
942
|
-
title?: RouteHeadValue;
|
|
943
|
-
/** `<meta name="description">`. */
|
|
944
|
-
description?: RouteHeadValue;
|
|
945
|
-
/** `<link rel="canonical">` — use an absolute URL. */
|
|
946
|
-
canonical?: RouteHeadValue;
|
|
947
|
-
/** Open Graph tags. */
|
|
948
|
-
og?: RouteHeadOpenGraph;
|
|
949
|
-
/**
|
|
950
|
-
* Any other `<meta>` entries (`{ name: "robots", content: "noindex" }`,
|
|
951
|
-
* `{ name: "twitter:card", content: "summary_large_image" }`). Identified by
|
|
952
|
-
* their `name` or `property`; an entry with neither is ignored.
|
|
953
|
-
*/
|
|
954
|
-
meta?: Record<string, RouteHeadValue>[];
|
|
955
|
-
}
|
|
956
|
-
/** Router-level head options: defaults for every route, plus the title template. */
|
|
957
|
-
interface RouterHeadOptions extends RouteHead {
|
|
958
|
-
/**
|
|
959
|
-
* Wraps every route title: `"%s · Studio"` or `(title) => \`${title} · Studio\``.
|
|
960
|
-
* Not applied to the default title itself.
|
|
961
|
-
*/
|
|
962
|
-
titleTemplate?: string | ((title: string) => string);
|
|
963
|
-
}
|
|
964
|
-
/** One resolved `<head>` element, keyed by what it describes. */
|
|
965
|
-
interface ResolvedHeadTag {
|
|
966
|
-
/** Identity used to replace / remove the tag across navigations. */
|
|
967
|
-
key: string;
|
|
968
|
-
tag: "meta" | "link";
|
|
969
|
-
attrs: Record<string, string>;
|
|
970
|
-
}
|
|
971
|
-
/** The head a route resolves to. */
|
|
972
|
-
interface ResolvedRouteHead {
|
|
973
|
-
title: string | null;
|
|
974
|
-
tags: ResolvedHeadTag[];
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
* Resolve the head a committed route renders: the router defaults, then every
|
|
978
|
-
* matched record from the root down. Getters are invoked here, so calling this
|
|
979
|
-
* inside an effect subscribes to whatever they read.
|
|
980
|
-
*
|
|
981
|
-
* @param route The committed route.
|
|
982
|
-
* @param defaults `createRouter({ head })`, if any.
|
|
983
|
-
* @returns The title and the tags, after the shared head policy.
|
|
984
|
-
*/
|
|
985
|
-
declare function resolveRouteHead(route: RouteContext, defaults?: RouterHeadOptions): ResolvedRouteHead;
|
|
986
|
-
/**
|
|
987
|
-
* Serialize a resolved head to HTML, for SSR or a static page. Each tag carries
|
|
988
|
-
* the `data-sibu-head` marker so the client router adopts it on start-up
|
|
989
|
-
* instead of duplicating it.
|
|
990
|
-
*
|
|
991
|
-
* @param head The result of {@link resolveRouteHead}.
|
|
992
|
-
* @returns `<title>` plus one element per tag.
|
|
993
|
-
*/
|
|
994
|
-
declare function routeHeadToHTML(head: ResolvedRouteHead): string;
|
|
995
|
-
|
|
996
170
|
/**
|
|
997
171
|
* Serializable route state that can be transferred from server to client.
|
|
998
172
|
*/
|
|
@@ -1103,4 +277,4 @@ declare function createSSRRouter(routes: SSRRouteDef[]): {
|
|
|
1103
277
|
}) => string;
|
|
1104
278
|
};
|
|
1105
279
|
|
|
1106
|
-
export { type
|
|
280
|
+
export { type SSRRouteDef, type SSRRouteState, Trans, type TranslationParams, createSSRRouter, deserializeRouteState, getAvailableLocales, getLocale, hasTranslation, hydrateRouter, registerTranslations, renderRouteToDocument, renderRouteToString, resolveServerRoute, serializeRouteState, setLocale, t, translated };
|