@bquery/bquery 1.5.0 → 1.7.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 +193 -23
- package/dist/a11y/announce.d.ts +43 -0
- package/dist/a11y/announce.d.ts.map +1 -0
- package/dist/a11y/audit.d.ts +42 -0
- package/dist/a11y/audit.d.ts.map +1 -0
- package/dist/a11y/index.d.ts +53 -0
- package/dist/a11y/index.d.ts.map +1 -0
- package/dist/a11y/media-preferences.d.ts +77 -0
- package/dist/a11y/media-preferences.d.ts.map +1 -0
- package/dist/a11y/roving-tab-index.d.ts +38 -0
- package/dist/a11y/roving-tab-index.d.ts.map +1 -0
- package/dist/a11y/skip-link.d.ts +37 -0
- package/dist/a11y/skip-link.d.ts.map +1 -0
- package/dist/a11y/trap-focus.d.ts +49 -0
- package/dist/a11y/trap-focus.d.ts.map +1 -0
- package/dist/a11y/types.d.ts +152 -0
- package/dist/a11y/types.d.ts.map +1 -0
- package/dist/a11y-C5QOVvRn.js +421 -0
- package/dist/a11y-C5QOVvRn.js.map +1 -0
- package/dist/a11y.es.mjs +14 -0
- package/dist/component/component.d.ts +13 -5
- package/dist/component/component.d.ts.map +1 -1
- package/dist/component/html.d.ts +40 -3
- package/dist/component/html.d.ts.map +1 -1
- package/dist/component/index.d.ts +3 -2
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/library.d.ts.map +1 -1
- package/dist/component/scope.d.ts +138 -0
- package/dist/component/scope.d.ts.map +1 -0
- package/dist/component/types.d.ts +184 -17
- package/dist/component/types.d.ts.map +1 -1
- package/dist/component-CuuTijA6.js +684 -0
- package/dist/component-CuuTijA6.js.map +1 -0
- package/dist/component.es.mjs +10 -6
- package/dist/{config-DRmZZno3.js → config-BW35FKuA.js} +4 -4
- package/dist/config-BW35FKuA.js.map +1 -0
- package/dist/constraints-3lV9yyBw.js +100 -0
- package/dist/constraints-3lV9yyBw.js.map +1 -0
- package/dist/core/collection.d.ts +48 -0
- package/dist/core/collection.d.ts.map +1 -1
- package/dist/core/element.d.ts +92 -0
- package/dist/core/element.d.ts.map +1 -1
- package/dist/core/env.d.ts +18 -0
- package/dist/core/env.d.ts.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/shared.d.ts +8 -0
- package/dist/core/shared.d.ts.map +1 -1
- package/dist/core/utils/index.d.ts +52 -41
- package/dist/core/utils/index.d.ts.map +1 -1
- package/dist/core-Cjl7GUu8.js +717 -0
- package/dist/core-Cjl7GUu8.js.map +1 -0
- package/dist/{core-DPdbItcq.js → core-DnlyjbF2.js} +1 -1
- package/dist/{core-DPdbItcq.js.map → core-DnlyjbF2.js.map} +1 -1
- package/dist/core.es.mjs +45 -44
- package/dist/custom-directives-7wAShnnd.js +9 -0
- package/dist/custom-directives-7wAShnnd.js.map +1 -0
- package/dist/devtools/devtools.d.ts +212 -0
- package/dist/devtools/devtools.d.ts.map +1 -0
- package/dist/devtools/index.d.ts +20 -0
- package/dist/devtools/index.d.ts.map +1 -0
- package/dist/devtools/types.d.ts +69 -0
- package/dist/devtools/types.d.ts.map +1 -0
- package/dist/devtools-D2fQLhDN.js +122 -0
- package/dist/devtools-D2fQLhDN.js.map +1 -0
- package/dist/devtools.es.mjs +19 -0
- package/dist/dnd/draggable.d.ts +51 -0
- package/dist/dnd/draggable.d.ts.map +1 -0
- package/dist/dnd/droppable.d.ts +38 -0
- package/dist/dnd/droppable.d.ts.map +1 -0
- package/dist/dnd/index.d.ts +47 -0
- package/dist/dnd/index.d.ts.map +1 -0
- package/dist/dnd/sortable.d.ts +43 -0
- package/dist/dnd/sortable.d.ts.map +1 -0
- package/dist/dnd/types.d.ts +250 -0
- package/dist/dnd/types.d.ts.map +1 -0
- package/dist/dnd-B8EgyzaI.js +244 -0
- package/dist/dnd-B8EgyzaI.js.map +1 -0
- package/dist/dnd.es.mjs +6 -0
- package/dist/env-NeVmr4Gf.js +19 -0
- package/dist/env-NeVmr4Gf.js.map +1 -0
- package/dist/forms/create-form.d.ts +49 -0
- package/dist/forms/create-form.d.ts.map +1 -0
- package/dist/forms/index.d.ts +39 -0
- package/dist/forms/index.d.ts.map +1 -0
- package/dist/forms/types.d.ts +139 -0
- package/dist/forms/types.d.ts.map +1 -0
- package/dist/forms/validators.d.ts +179 -0
- package/dist/forms/validators.d.ts.map +1 -0
- package/dist/forms-C3yovgH9.js +141 -0
- package/dist/forms-C3yovgH9.js.map +1 -0
- package/dist/forms.es.mjs +14 -0
- package/dist/full.d.ts +37 -9
- package/dist/full.d.ts.map +1 -1
- package/dist/full.es.mjs +186 -91
- package/dist/full.iife.js +47 -31
- package/dist/full.iife.js.map +1 -1
- package/dist/full.umd.js +47 -31
- package/dist/full.umd.js.map +1 -1
- package/dist/i18n/formatting.d.ts +40 -0
- package/dist/i18n/formatting.d.ts.map +1 -0
- package/dist/i18n/i18n.d.ts +48 -0
- package/dist/i18n/i18n.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +57 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/translate.d.ts +83 -0
- package/dist/i18n/translate.d.ts.map +1 -0
- package/dist/i18n/types.d.ts +156 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n-BnnhTFOS.js +89 -0
- package/dist/i18n-BnnhTFOS.js.map +1 -0
- package/dist/i18n.es.mjs +6 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.mjs +233 -138
- package/dist/media/battery.d.ts +35 -0
- package/dist/media/battery.d.ts.map +1 -0
- package/dist/media/breakpoints.d.ts +51 -0
- package/dist/media/breakpoints.d.ts.map +1 -0
- package/dist/media/clipboard.d.ts +30 -0
- package/dist/media/clipboard.d.ts.map +1 -0
- package/dist/media/device-sensors.d.ts +54 -0
- package/dist/media/device-sensors.d.ts.map +1 -0
- package/dist/media/geolocation.d.ts +38 -0
- package/dist/media/geolocation.d.ts.map +1 -0
- package/dist/media/index.d.ts +42 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/media-query.d.ts +36 -0
- package/dist/media/media-query.d.ts.map +1 -0
- package/dist/media/network.d.ts +35 -0
- package/dist/media/network.d.ts.map +1 -0
- package/dist/media/types.d.ts +173 -0
- package/dist/media/types.d.ts.map +1 -0
- package/dist/media/viewport.d.ts +32 -0
- package/dist/media/viewport.d.ts.map +1 -0
- package/dist/media-Di2Ta22s.js +340 -0
- package/dist/media-Di2Ta22s.js.map +1 -0
- package/dist/media.es.mjs +12 -0
- package/dist/motion/index.d.ts +7 -3
- package/dist/motion/index.d.ts.map +1 -1
- package/dist/motion/morph.d.ts +27 -0
- package/dist/motion/morph.d.ts.map +1 -0
- package/dist/motion/parallax.d.ts +30 -0
- package/dist/motion/parallax.d.ts.map +1 -0
- package/dist/motion/reduced-motion.d.ts +36 -3
- package/dist/motion/reduced-motion.d.ts.map +1 -1
- package/dist/motion/types.d.ts +58 -0
- package/dist/motion/types.d.ts.map +1 -1
- package/dist/motion/typewriter.d.ts +31 -0
- package/dist/motion/typewriter.d.ts.map +1 -0
- package/dist/motion-qPj_TYGv.js +530 -0
- package/dist/motion-qPj_TYGv.js.map +1 -0
- package/dist/motion.es.mjs +27 -23
- package/dist/mount-SM07RUa6.js +403 -0
- package/dist/mount-SM07RUa6.js.map +1 -0
- package/dist/{object-qGpWr6-J.js → object-BCk-1c8T.js} +5 -4
- package/dist/{object-qGpWr6-J.js.map → object-BCk-1c8T.js.map} +1 -1
- package/dist/{platform-B7JhGBc7.js → platform-CPbCprb6.js} +3 -3
- package/dist/platform-CPbCprb6.js.map +1 -0
- package/dist/platform.es.mjs +2 -2
- package/dist/plugin/index.d.ts +22 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/registry.d.ts +108 -0
- package/dist/plugin/registry.d.ts.map +1 -0
- package/dist/plugin/types.d.ts +110 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/plugin-cPoOHFLY.js +64 -0
- package/dist/plugin-cPoOHFLY.js.map +1 -0
- package/dist/plugin.es.mjs +9 -0
- package/dist/reactive/computed.d.ts +7 -0
- package/dist/reactive/computed.d.ts.map +1 -1
- package/dist/reactive-Cfv0RK6x.js +233 -0
- package/dist/reactive-Cfv0RK6x.js.map +1 -0
- package/dist/reactive.es.mjs +18 -17
- package/dist/registry-CWf368tT.js +26 -0
- package/dist/registry-CWf368tT.js.map +1 -0
- package/dist/router/bq-link.d.ts +112 -0
- package/dist/router/bq-link.d.ts.map +1 -0
- package/dist/router/constraints.d.ts +9 -0
- package/dist/router/constraints.d.ts.map +1 -0
- package/dist/router/index.d.ts +14 -6
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/match.d.ts +0 -1
- package/dist/router/match.d.ts.map +1 -1
- package/dist/router/path-pattern.d.ts +14 -0
- package/dist/router/path-pattern.d.ts.map +1 -0
- package/dist/router/query.d.ts.map +1 -1
- package/dist/router/router.d.ts +3 -1
- package/dist/router/router.d.ts.map +1 -1
- package/dist/router/types.d.ts +48 -4
- package/dist/router/types.d.ts.map +1 -1
- package/dist/router/use-route.d.ts +50 -0
- package/dist/router/use-route.d.ts.map +1 -0
- package/dist/router/utils.d.ts +3 -0
- package/dist/router/utils.d.ts.map +1 -1
- package/dist/router-BrthaP_z.js +473 -0
- package/dist/router-BrthaP_z.js.map +1 -0
- package/dist/router.es.mjs +13 -10
- package/dist/{sanitize-jyJ2ryE2.js → sanitize-B1V4JswB.js} +95 -83
- package/dist/sanitize-B1V4JswB.js.map +1 -0
- package/dist/security/index.d.ts +2 -0
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/sanitize.d.ts +4 -1
- package/dist/security/sanitize.d.ts.map +1 -1
- package/dist/security/trusted-html.d.ts +53 -0
- package/dist/security/trusted-html.d.ts.map +1 -0
- package/dist/security.es.mjs +10 -9
- package/dist/ssr/hydrate.d.ts +65 -0
- package/dist/ssr/hydrate.d.ts.map +1 -0
- package/dist/ssr/index.d.ts +59 -0
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/ssr/render.d.ts +62 -0
- package/dist/ssr/render.d.ts.map +1 -0
- package/dist/ssr/serialize.d.ts +118 -0
- package/dist/ssr/serialize.d.ts.map +1 -0
- package/dist/ssr/types.d.ts +70 -0
- package/dist/ssr/types.d.ts.map +1 -0
- package/dist/ssr-B2qd_WBB.js +248 -0
- package/dist/ssr-B2qd_WBB.js.map +1 -0
- package/dist/ssr.es.mjs +9 -0
- package/dist/store/create-store.d.ts.map +1 -1
- package/dist/store/define-store.d.ts +1 -1
- package/dist/store/define-store.d.ts.map +1 -1
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/mapping.d.ts +1 -1
- package/dist/store/mapping.d.ts.map +1 -1
- package/dist/store/persisted.d.ts +38 -4
- package/dist/store/persisted.d.ts.map +1 -1
- package/dist/store/types.d.ts +140 -3
- package/dist/store/types.d.ts.map +1 -1
- package/dist/store/utils.d.ts +2 -2
- package/dist/store/utils.d.ts.map +1 -1
- package/dist/store/watch.d.ts +1 -1
- package/dist/store/watch.d.ts.map +1 -1
- package/dist/store-DWpyH6p5.js +338 -0
- package/dist/store-DWpyH6p5.js.map +1 -0
- package/dist/store.es.mjs +11 -10
- package/dist/storybook/index.d.ts +37 -0
- package/dist/storybook/index.d.ts.map +1 -0
- package/dist/storybook.es.mjs +151 -0
- package/dist/storybook.es.mjs.map +1 -0
- package/dist/testing/index.d.ts +23 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/testing.d.ts +156 -0
- package/dist/testing/testing.d.ts.map +1 -0
- package/dist/testing/types.d.ts +134 -0
- package/dist/testing/types.d.ts.map +1 -0
- package/dist/testing-CsqjNUyy.js +224 -0
- package/dist/testing-CsqjNUyy.js.map +1 -0
- package/dist/testing.es.mjs +9 -0
- package/dist/type-guards-Do9DWgNp.js +44 -0
- package/dist/type-guards-Do9DWgNp.js.map +1 -0
- package/dist/untrack-DJVQQ2WM.js +33 -0
- package/dist/untrack-DJVQQ2WM.js.map +1 -0
- package/dist/view/custom-directives.d.ts +20 -0
- package/dist/view/custom-directives.d.ts.map +1 -0
- package/dist/view/evaluate.d.ts.map +1 -1
- package/dist/view/process.d.ts.map +1 -1
- package/dist/view.es.mjs +11 -10
- package/package.json +52 -11
- package/src/a11y/announce.ts +131 -0
- package/src/a11y/audit.ts +314 -0
- package/src/a11y/index.ts +68 -0
- package/src/a11y/media-preferences.ts +255 -0
- package/src/a11y/roving-tab-index.ts +164 -0
- package/src/a11y/skip-link.ts +255 -0
- package/src/a11y/trap-focus.ts +184 -0
- package/src/a11y/types.ts +183 -0
- package/src/component/component.ts +345 -65
- package/src/component/html.ts +153 -53
- package/src/component/index.ts +12 -2
- package/src/component/library.ts +66 -28
- package/src/component/scope.ts +212 -0
- package/src/component/types.ts +238 -19
- package/src/core/collection.ts +707 -628
- package/src/core/element.ts +981 -774
- package/src/core/env.ts +60 -0
- package/src/core/index.ts +49 -48
- package/src/core/shared.ts +62 -13
- package/src/core/utils/index.ts +148 -83
- package/src/devtools/devtools.ts +410 -0
- package/src/devtools/index.ts +48 -0
- package/src/devtools/types.ts +104 -0
- package/src/dnd/draggable.ts +296 -0
- package/src/dnd/droppable.ts +228 -0
- package/src/dnd/index.ts +62 -0
- package/src/dnd/sortable.ts +307 -0
- package/src/dnd/types.ts +293 -0
- package/src/forms/create-form.ts +278 -0
- package/src/forms/index.ts +65 -0
- package/src/forms/types.ts +154 -0
- package/src/forms/validators.ts +265 -0
- package/src/full.ts +260 -3
- package/src/i18n/formatting.ts +67 -0
- package/src/i18n/i18n.ts +200 -0
- package/src/i18n/index.ts +67 -0
- package/src/i18n/translate.ts +182 -0
- package/src/i18n/types.ts +171 -0
- package/src/index.ts +108 -36
- package/src/media/battery.ts +116 -0
- package/src/media/breakpoints.ts +131 -0
- package/src/media/clipboard.ts +80 -0
- package/src/media/device-sensors.ts +158 -0
- package/src/media/geolocation.ts +119 -0
- package/src/media/index.ts +76 -0
- package/src/media/media-query.ts +92 -0
- package/src/media/network.ts +115 -0
- package/src/media/types.ts +177 -0
- package/src/media/viewport.ts +84 -0
- package/src/motion/index.ts +57 -48
- package/src/motion/morph.ts +151 -0
- package/src/motion/parallax.ts +120 -0
- package/src/motion/reduced-motion.ts +66 -17
- package/src/motion/transition.ts +97 -97
- package/src/motion/types.ts +63 -0
- package/src/motion/typewriter.ts +164 -0
- package/src/platform/announcer.ts +208 -208
- package/src/platform/config.ts +163 -163
- package/src/platform/cookies.ts +165 -165
- package/src/platform/index.ts +39 -39
- package/src/platform/meta.ts +168 -168
- package/src/plugin/index.ts +37 -0
- package/src/plugin/registry.ts +269 -0
- package/src/plugin/types.ts +137 -0
- package/src/reactive/async-data.ts +486 -486
- package/src/reactive/computed.ts +130 -92
- package/src/reactive/index.ts +37 -37
- package/src/reactive/signal.ts +29 -29
- package/src/router/bq-link.ts +279 -0
- package/src/router/constraints.ts +201 -0
- package/src/router/index.ts +49 -41
- package/src/router/match.ts +312 -106
- package/src/router/path-pattern.ts +52 -0
- package/src/router/query.ts +38 -35
- package/src/router/router.ts +402 -211
- package/src/router/types.ts +139 -93
- package/src/router/use-route.ts +68 -0
- package/src/router/utils.ts +157 -116
- package/src/security/constants.ts +211 -211
- package/src/security/index.ts +12 -10
- package/src/security/sanitize.ts +6 -2
- package/src/security/trusted-html.ts +71 -0
- package/src/ssr/hydrate.ts +82 -0
- package/src/ssr/index.ts +70 -0
- package/src/ssr/render.ts +508 -0
- package/src/ssr/serialize.ts +296 -0
- package/src/ssr/types.ts +81 -0
- package/src/store/create-store.ts +467 -329
- package/src/store/define-store.ts +2 -1
- package/src/store/index.ts +27 -22
- package/src/store/mapping.ts +2 -1
- package/src/store/persisted.ts +249 -61
- package/src/store/types.ts +247 -94
- package/src/store/utils.ts +135 -141
- package/src/store/watch.ts +2 -1
- package/src/storybook/index.ts +480 -0
- package/src/testing/index.ts +42 -0
- package/src/testing/testing.ts +593 -0
- package/src/testing/types.ts +170 -0
- package/src/view/custom-directives.ts +30 -0
- package/src/view/evaluate.ts +292 -290
- package/src/view/process.ts +108 -92
- package/dist/component-CY5MVoYN.js +0 -531
- package/dist/component-CY5MVoYN.js.map +0 -1
- package/dist/config-DRmZZno3.js.map +0 -1
- package/dist/core-CK2Mfpf4.js +0 -648
- package/dist/core-CK2Mfpf4.js.map +0 -1
- package/dist/motion-C5DRdPnO.js +0 -415
- package/dist/motion-C5DRdPnO.js.map +0 -1
- package/dist/platform-B7JhGBc7.js.map +0 -1
- package/dist/reactive-BDya-ia8.js +0 -253
- package/dist/reactive-BDya-ia8.js.map +0 -1
- package/dist/router-CijiICxt.js +0 -188
- package/dist/router-CijiICxt.js.map +0 -1
- package/dist/sanitize-jyJ2ryE2.js.map +0 -1
- package/dist/store-CPK9E62U.js +0 -262
- package/dist/store-CPK9E62U.js.map +0 -1
- package/dist/view-Cdi0g-qo.js +0 -396
- package/dist/view-Cdi0g-qo.js.map +0 -1
package/dist/router/types.d.ts
CHANGED
|
@@ -29,18 +29,55 @@ export type Route = {
|
|
|
29
29
|
/**
|
|
30
30
|
* Route definition for configuration.
|
|
31
31
|
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
32
|
+
type BaseRouteDefinition = {
|
|
33
|
+
/**
|
|
34
|
+
* Path pattern (e.g., '/user/:id', '/posts/*').
|
|
35
|
+
* Supports regex constraints on params: `/user/:id(\\d+)`.
|
|
36
|
+
* Constraint backreferences are not supported.
|
|
37
|
+
*/
|
|
34
38
|
path: string;
|
|
35
|
-
/** Component loader (sync or async) */
|
|
36
|
-
component: () => unknown | Promise<unknown>;
|
|
37
39
|
/** Optional route name for programmatic navigation */
|
|
38
40
|
name?: string;
|
|
39
41
|
/** Optional metadata */
|
|
40
42
|
meta?: Record<string, unknown>;
|
|
41
43
|
/** Nested child routes */
|
|
42
44
|
children?: RouteDefinition[];
|
|
45
|
+
/**
|
|
46
|
+
* Per-route navigation guard. Called before entering this route.
|
|
47
|
+
* Return `false` to cancel navigation.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* {
|
|
52
|
+
* path: '/admin',
|
|
53
|
+
* component: () => import('./Admin'),
|
|
54
|
+
* beforeEnter: (to, from) => isAuthenticated() || false,
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
beforeEnter?: NavigationGuard;
|
|
59
|
+
};
|
|
60
|
+
type ComponentRouteDefinition = BaseRouteDefinition & {
|
|
61
|
+
/** Component loader (sync or async) */
|
|
62
|
+
component: () => unknown | Promise<unknown>;
|
|
63
|
+
redirectTo?: never;
|
|
64
|
+
};
|
|
65
|
+
type RedirectRouteDefinition = BaseRouteDefinition & {
|
|
66
|
+
/**
|
|
67
|
+
* Redirect target path. When the route is matched, the router
|
|
68
|
+
* automatically navigates to this path instead.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* { path: '/old-page', redirectTo: '/new-page' }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
redirectTo: string;
|
|
76
|
+
component?: never;
|
|
77
|
+
children?: never;
|
|
78
|
+
beforeEnter?: never;
|
|
43
79
|
};
|
|
80
|
+
export type RouteDefinition = ComponentRouteDefinition | RedirectRouteDefinition;
|
|
44
81
|
/**
|
|
45
82
|
* Router configuration options.
|
|
46
83
|
*/
|
|
@@ -51,6 +88,12 @@ export type RouterOptions = {
|
|
|
51
88
|
base?: string;
|
|
52
89
|
/** Use hash-based routing instead of history (default: false) */
|
|
53
90
|
hash?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Restore scroll position on back/forward navigation (default: false).
|
|
93
|
+
* When enabled, the router saves scroll positions for each history entry
|
|
94
|
+
* and restores them on popstate events.
|
|
95
|
+
*/
|
|
96
|
+
scrollRestoration?: boolean;
|
|
54
97
|
};
|
|
55
98
|
/**
|
|
56
99
|
* Navigation guard function type.
|
|
@@ -85,4 +128,5 @@ export type Router = {
|
|
|
85
128
|
/** Destroy the router and cleanup listeners */
|
|
86
129
|
destroy: () => void;
|
|
87
130
|
};
|
|
131
|
+
export {};
|
|
88
132
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/router/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IACzC,mCAAmC;IACnC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAChC,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/router/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactive route composable.
|
|
3
|
+
* @module bquery/router
|
|
4
|
+
*/
|
|
5
|
+
import { type ReadonlySignal } from '../reactive/index';
|
|
6
|
+
import type { Route, RouteDefinition } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Return type for {@link useRoute}.
|
|
9
|
+
* Provides reactive access to individual route properties.
|
|
10
|
+
*/
|
|
11
|
+
export type UseRouteReturn = {
|
|
12
|
+
/** Full reactive route object */
|
|
13
|
+
route: ReadonlySignal<Route>;
|
|
14
|
+
/** Reactive current path */
|
|
15
|
+
path: ReadonlySignal<string>;
|
|
16
|
+
/** Reactive route params */
|
|
17
|
+
params: ReadonlySignal<Record<string, string>>;
|
|
18
|
+
/** Reactive query params */
|
|
19
|
+
query: ReadonlySignal<Record<string, string | string[]>>;
|
|
20
|
+
/** Reactive hash fragment (without #) */
|
|
21
|
+
hash: ReadonlySignal<string>;
|
|
22
|
+
/** Reactive matched route definition */
|
|
23
|
+
matched: ReadonlySignal<RouteDefinition | null>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Returns reactive access to the current route, params, query, and hash.
|
|
27
|
+
*
|
|
28
|
+
* Each property is a readonly computed signal that updates automatically
|
|
29
|
+
* when the route changes. This is useful for fine-grained reactivity
|
|
30
|
+
* where you only need to subscribe to specific route parts.
|
|
31
|
+
*
|
|
32
|
+
* @returns An object with reactive route properties
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { useRoute } from '@bquery/bquery/router';
|
|
37
|
+
* import { effect } from '@bquery/bquery/reactive';
|
|
38
|
+
*
|
|
39
|
+
* const { path, params, query, hash } = useRoute();
|
|
40
|
+
*
|
|
41
|
+
* effect(() => {
|
|
42
|
+
* console.log('Path:', path.value);
|
|
43
|
+
* console.log('Params:', params.value);
|
|
44
|
+
* console.log('Query:', query.value);
|
|
45
|
+
* console.log('Hash:', hash.value);
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare const useRoute: () => UseRouteReturn;
|
|
50
|
+
//# sourceMappingURL=use-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-route.d.ts","sourceRoot":"","sources":["../../src/router/use-route.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAMtD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,iCAAiC;IACjC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;IAC7B,4BAA4B;IAC5B,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAC7B,4BAA4B;IAC5B,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/C,4BAA4B;IAC5B,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;IACzD,yCAAyC;IACzC,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAC7B,wCAAwC;IACxC,OAAO,EAAE,cAAc,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;CACjD,CAAC;AAWF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,QAAQ,QAAO,cAE3B,CAAC"}
|
package/dist/router/utils.d.ts
CHANGED
|
@@ -16,6 +16,9 @@ export declare const flattenRoutes: (routes: RouteDefinition[], parentPath?: str
|
|
|
16
16
|
* @param name - The route name
|
|
17
17
|
* @param params - Route params to interpolate
|
|
18
18
|
* @returns The resolved path
|
|
19
|
+
* @throws {Error} If no router is initialized, the route name is unknown,
|
|
20
|
+
* a required path param is missing from `params`, a param value does not satisfy
|
|
21
|
+
* its route regex constraint, or a route param constraint has invalid syntax
|
|
19
22
|
*
|
|
20
23
|
* @example
|
|
21
24
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/router/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/router/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIlE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAM/C;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,eAAe,EAAE,EAAE,mBAAe,KAAG,eAAe,EAiBzF,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,SAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,KAAG,MAqD3E,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,EAAE,eAAa,KAAG,OAGtD,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,eAAa,KAAG,cAAc,CAAC,OAAO,CAKlF,CAAC"}
|
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
import { i as G } from "./object-BCk-1c8T.js";
|
|
2
|
+
import { n as nt, r as st } from "./core-DnlyjbF2.js";
|
|
3
|
+
import { r as L } from "./untrack-DJVQQ2WM.js";
|
|
4
|
+
import { n as Y, t as at } from "./constraints-3lV9yyBw.js";
|
|
5
|
+
var Z = null, k = nt({
|
|
6
|
+
path: "",
|
|
7
|
+
params: {},
|
|
8
|
+
query: {},
|
|
9
|
+
matched: null,
|
|
10
|
+
hash: ""
|
|
11
|
+
}), ot = L(() => k.value), T = () => Z, B = (t) => {
|
|
12
|
+
Z = t;
|
|
13
|
+
}, Q = async (t, e = {}) => {
|
|
14
|
+
const r = T();
|
|
15
|
+
if (!r) throw new Error("bQuery router: No router initialized. Call createRouter() first.");
|
|
16
|
+
await r[e.replace ? "replace" : "push"](t);
|
|
17
|
+
}, At = () => {
|
|
18
|
+
const t = T();
|
|
19
|
+
t ? t.back() : history.back();
|
|
20
|
+
}, Ct = () => {
|
|
21
|
+
const t = T();
|
|
22
|
+
t ? t.forward() : history.forward();
|
|
23
|
+
}, it = "active", ct = (t) => t.split(/\s+/).map((e) => e.trim()).filter((e) => e.length > 0), lt = typeof HTMLElement < "u" ? HTMLElement : class {
|
|
24
|
+
}, ut = class extends lt {
|
|
25
|
+
constructor(...t) {
|
|
26
|
+
super(...t), this._cleanup = null, this._trackedActiveClasses = /* @__PURE__ */ new Map(), this._handleClick = (e) => {
|
|
27
|
+
e instanceof MouseEvent && (e.defaultPrevented || e.button === 0 && (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || (e.preventDefault(), this._navigate())));
|
|
28
|
+
}, this._handleKeydown = (e) => {
|
|
29
|
+
e instanceof KeyboardEvent && e.key === "Enter" && (e.preventDefault(), this._navigate());
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
static get observedAttributes() {
|
|
33
|
+
return [
|
|
34
|
+
"to",
|
|
35
|
+
"replace",
|
|
36
|
+
"exact",
|
|
37
|
+
"active-class"
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
get to() {
|
|
41
|
+
const t = this.getAttribute("to");
|
|
42
|
+
return t == null || t.trim() === "" ? "/" : t;
|
|
43
|
+
}
|
|
44
|
+
set to(t) {
|
|
45
|
+
this.setAttribute("to", t);
|
|
46
|
+
}
|
|
47
|
+
get replace() {
|
|
48
|
+
return this.hasAttribute("replace");
|
|
49
|
+
}
|
|
50
|
+
set replace(t) {
|
|
51
|
+
t ? this.setAttribute("replace", "") : this.removeAttribute("replace");
|
|
52
|
+
}
|
|
53
|
+
get exact() {
|
|
54
|
+
return this.hasAttribute("exact");
|
|
55
|
+
}
|
|
56
|
+
set exact(t) {
|
|
57
|
+
t ? this.setAttribute("exact", "") : this.removeAttribute("exact");
|
|
58
|
+
}
|
|
59
|
+
get activeClass() {
|
|
60
|
+
return this.getAttribute("active-class") ?? it;
|
|
61
|
+
}
|
|
62
|
+
set activeClass(t) {
|
|
63
|
+
this.setAttribute("active-class", t);
|
|
64
|
+
}
|
|
65
|
+
connectedCallback() {
|
|
66
|
+
this.getAttribute("role") || this.setAttribute("role", "link"), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.addEventListener("click", this._handleClick), this.addEventListener("keydown", this._handleKeydown), this._setupActiveTracking();
|
|
67
|
+
}
|
|
68
|
+
disconnectedCallback() {
|
|
69
|
+
this.removeEventListener("click", this._handleClick), this.removeEventListener("keydown", this._handleKeydown), this._cleanup && (this._cleanup(), this._cleanup = null), this._clearTrackedActiveClasses();
|
|
70
|
+
}
|
|
71
|
+
attributeChangedCallback(t, e, r) {
|
|
72
|
+
(t === "to" || t === "exact" || t === "active-class") && this.isConnected && this._setupActiveTracking();
|
|
73
|
+
}
|
|
74
|
+
_setupActiveTracking() {
|
|
75
|
+
this._cleanup && (this._cleanup(), this._cleanup = null), this._clearTrackedActiveClasses();
|
|
76
|
+
const t = this.to, e = this.exact, r = ct(this.activeClass);
|
|
77
|
+
this._trackedActiveClasses = new Map(r.map((n) => [n, this.classList.contains(n)])), this._cleanup = st(() => {
|
|
78
|
+
const n = k.value.path, s = e ? n === t : t === "/" ? n === "/" : n === t || n.startsWith(t.endsWith("/") ? t : t + "/");
|
|
79
|
+
for (const a of r) {
|
|
80
|
+
const o = this._trackedActiveClasses.get(a) ?? !1;
|
|
81
|
+
this.classList.toggle(a, s || o);
|
|
82
|
+
}
|
|
83
|
+
s ? this.setAttribute("aria-current", "page") : this.removeAttribute("aria-current");
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
_clearTrackedActiveClasses() {
|
|
87
|
+
for (const [t, e] of this._trackedActiveClasses) this.classList.toggle(t, e);
|
|
88
|
+
this._trackedActiveClasses.clear();
|
|
89
|
+
}
|
|
90
|
+
_navigate() {
|
|
91
|
+
const t = this.to;
|
|
92
|
+
t && T() && Q(t, { replace: this.replace }).catch((e) => {
|
|
93
|
+
console.error("bq-link: Navigation failed:", e);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}, $t = () => {
|
|
97
|
+
typeof HTMLElement < "u" && typeof customElements < "u" && !customElements.get("bq-link") && customElements.define("bq-link", ut);
|
|
98
|
+
}, kt = (t, e = {}) => (r) => {
|
|
99
|
+
r.preventDefault(), Q(t, e).catch((n) => {
|
|
100
|
+
console.error("Navigation failed:", n);
|
|
101
|
+
});
|
|
102
|
+
}, Rt = (t) => {
|
|
103
|
+
const e = t ?? (typeof document < "u" ? document.body : null);
|
|
104
|
+
if (!e) return () => {
|
|
105
|
+
};
|
|
106
|
+
const r = (n) => {
|
|
107
|
+
if (!(n instanceof MouseEvent) || n.defaultPrevented || n.button !== 0 || n.ctrlKey || n.metaKey || n.shiftKey || n.altKey || typeof Element > "u" || !(n.target instanceof Element)) return;
|
|
108
|
+
const s = n.target.closest("a");
|
|
109
|
+
if (!s || !(s instanceof (s.ownerDocument.defaultView?.HTMLAnchorElement ?? HTMLAnchorElement)) || s.target || s.hasAttribute("download") || typeof window > "u" || s.origin !== window.location.origin) return;
|
|
110
|
+
const a = T();
|
|
111
|
+
if (!a) {
|
|
112
|
+
n.preventDefault(), Q(s.pathname + s.search + s.hash).catch((l) => {
|
|
113
|
+
console.error("Navigation failed:", l);
|
|
114
|
+
});
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const o = a.base, p = a.hash;
|
|
118
|
+
let u;
|
|
119
|
+
if (p && s.hash && s.hash.startsWith("#/")) u = s.hash.slice(1);
|
|
120
|
+
else {
|
|
121
|
+
let l = s.pathname;
|
|
122
|
+
o && o !== "/" && l.startsWith(o) && (l = l.slice(o.length) || "/"), u = l + s.search + s.hash;
|
|
123
|
+
}
|
|
124
|
+
n.preventDefault(), Q(u).catch((l) => {
|
|
125
|
+
console.error("Navigation failed:", l);
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
return e.addEventListener("click", r), () => e.removeEventListener("click", r);
|
|
129
|
+
}, ht = (t) => {
|
|
130
|
+
const e = {};
|
|
131
|
+
return new URLSearchParams(t).forEach((r, n) => {
|
|
132
|
+
if (G(n)) return;
|
|
133
|
+
const s = e[n];
|
|
134
|
+
s === void 0 ? e[n] = r : Array.isArray(s) ? s.push(r) : e[n] = [s, r];
|
|
135
|
+
}), e;
|
|
136
|
+
}, N = (t) => t !== void 0 && (t >= "a" && t <= "z" || t >= "A" && t <= "Z" || t === "_"), I = (t) => N(t) || t !== void 0 && t >= "0" && t <= "9", J = (t, e) => {
|
|
137
|
+
let r = 1, n = "", s = e + 1, a = !1;
|
|
138
|
+
for (; s < t.length; ) {
|
|
139
|
+
const o = t[s];
|
|
140
|
+
if (o === "\\" && s + 1 < t.length) {
|
|
141
|
+
n += o + t[s + 1], s += 2;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (o === "[" && !a) a = !0;
|
|
145
|
+
else if (o === "]" && a) a = !1;
|
|
146
|
+
else if (!a && o === "(") r++;
|
|
147
|
+
else if (!a && o === ")" && (r--, r === 0))
|
|
148
|
+
return {
|
|
149
|
+
constraint: n,
|
|
150
|
+
endIndex: s + 1
|
|
151
|
+
};
|
|
152
|
+
n += o, s++;
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}, ft = (t, e) => {
|
|
156
|
+
const r = J(t, e);
|
|
157
|
+
if (!r) throw new Error(`bQuery router: Invalid route param constraint syntax in path "${t}" at index ${e}.`);
|
|
158
|
+
return r;
|
|
159
|
+
}, V = /* @__PURE__ */ new Set(), tt = (t, e) => {
|
|
160
|
+
if (t[e] !== ":" || !N(t[e + 1])) return null;
|
|
161
|
+
let r = e + 2;
|
|
162
|
+
for (; r < t.length && I(t[r]); ) r++;
|
|
163
|
+
let n = r, s;
|
|
164
|
+
if (t[r] === "(") {
|
|
165
|
+
const a = ft(t, r);
|
|
166
|
+
s = a.constraint, n = a.endIndex;
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
name: t.slice(e + 1, r),
|
|
170
|
+
constraint: s,
|
|
171
|
+
nextIndex: n
|
|
172
|
+
};
|
|
173
|
+
}, dt = (t) => {
|
|
174
|
+
if (!V.has(t)) {
|
|
175
|
+
for (let e = 0; e < t.length; ) {
|
|
176
|
+
if (t[e] === ":" && N(t[e + 1])) {
|
|
177
|
+
const r = tt(t, e);
|
|
178
|
+
r?.constraint && at(r.constraint), e = r?.nextIndex ?? e + 1;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
e++;
|
|
182
|
+
}
|
|
183
|
+
V.add(t);
|
|
184
|
+
}
|
|
185
|
+
}, vt = (t, e) => {
|
|
186
|
+
const r = t.indexOf("/", e);
|
|
187
|
+
return r === -1 ? t.length : r;
|
|
188
|
+
}, F = (t, e) => {
|
|
189
|
+
let r = e;
|
|
190
|
+
for (; r < t.length && !(t[r] === "*" || t[r] === ":" && N(t[r + 1])); )
|
|
191
|
+
r++;
|
|
192
|
+
return t.slice(e, r);
|
|
193
|
+
}, X = (t, e, r, n) => {
|
|
194
|
+
const s = [];
|
|
195
|
+
let a = e;
|
|
196
|
+
for (; a <= r; ) {
|
|
197
|
+
const o = t.indexOf(n, a);
|
|
198
|
+
if (o === -1 || o > r) break;
|
|
199
|
+
s.push(o), a = o + 1;
|
|
200
|
+
}
|
|
201
|
+
return s.reverse();
|
|
202
|
+
}, pt = (t, e) => {
|
|
203
|
+
const r = /* @__PURE__ */ new Map(), n = (s, a) => {
|
|
204
|
+
const o = `${s}:${a}`;
|
|
205
|
+
if (r.has(o)) return r.get(o) ?? null;
|
|
206
|
+
if (s === t.length) {
|
|
207
|
+
const h = a === e.length ? {} : null;
|
|
208
|
+
return r.set(o, h), h;
|
|
209
|
+
}
|
|
210
|
+
const p = t[s];
|
|
211
|
+
if (p === "*") {
|
|
212
|
+
if (s === t.length - 1) {
|
|
213
|
+
const d = {};
|
|
214
|
+
return r.set(o, d), d;
|
|
215
|
+
}
|
|
216
|
+
const h = F(t, s + 1), w = h.length > 0 ? X(e, a, e.length, h) : null, A = (w ? (d) => {
|
|
217
|
+
for (const y of w) {
|
|
218
|
+
const v = d(y);
|
|
219
|
+
if (v) return v;
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
} : (d) => {
|
|
223
|
+
for (let y = e.length; y >= a; y--) {
|
|
224
|
+
const v = d(y);
|
|
225
|
+
if (v) return v;
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
})((d) => {
|
|
229
|
+
const y = n(s + 1, d);
|
|
230
|
+
return y ? (r.set(o, y), y) : null;
|
|
231
|
+
});
|
|
232
|
+
return A || (r.set(o, null), null);
|
|
233
|
+
}
|
|
234
|
+
const u = tt(t, s);
|
|
235
|
+
if (u) {
|
|
236
|
+
const h = u.constraint ? Y(u.constraint) : void 0, w = u.constraint ? e.length : vt(e, a), A = F(t, u.nextIndex), d = A.length > 0 ? X(e, a, w, A) : null, y = (d ? (v) => {
|
|
237
|
+
for (const g of d) {
|
|
238
|
+
if (g <= a) continue;
|
|
239
|
+
const b = v(g);
|
|
240
|
+
if (b) return b;
|
|
241
|
+
}
|
|
242
|
+
return null;
|
|
243
|
+
} : (v) => {
|
|
244
|
+
for (let g = w; g > a; g--) {
|
|
245
|
+
const b = v(g);
|
|
246
|
+
if (b) return b;
|
|
247
|
+
}
|
|
248
|
+
return null;
|
|
249
|
+
})((v) => {
|
|
250
|
+
const g = e.slice(a, v);
|
|
251
|
+
if (h && !h.test(g))
|
|
252
|
+
return null;
|
|
253
|
+
const b = n(u.nextIndex, v);
|
|
254
|
+
if (b) {
|
|
255
|
+
const q = {
|
|
256
|
+
[u.name]: g,
|
|
257
|
+
...b
|
|
258
|
+
};
|
|
259
|
+
return r.set(o, q), q;
|
|
260
|
+
}
|
|
261
|
+
return null;
|
|
262
|
+
});
|
|
263
|
+
return y || (r.set(o, null), null);
|
|
264
|
+
}
|
|
265
|
+
if (a >= e.length || p !== e[a])
|
|
266
|
+
return r.set(o, null), null;
|
|
267
|
+
const l = n(s + 1, a + 1);
|
|
268
|
+
return r.set(o, l), l;
|
|
269
|
+
};
|
|
270
|
+
return n(0, 0);
|
|
271
|
+
}, yt = (t, e) => {
|
|
272
|
+
for (const r of e) {
|
|
273
|
+
dt(r.path);
|
|
274
|
+
const n = pt(r.path, t);
|
|
275
|
+
if (n) return {
|
|
276
|
+
matched: r,
|
|
277
|
+
params: n
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
return null;
|
|
281
|
+
}, O = (t, e, r, n) => {
|
|
282
|
+
const s = yt(t, n);
|
|
283
|
+
return {
|
|
284
|
+
path: t,
|
|
285
|
+
params: s?.params ?? {},
|
|
286
|
+
query: ht(e),
|
|
287
|
+
matched: s?.matched ?? null,
|
|
288
|
+
hash: r.replace(/^#/, "")
|
|
289
|
+
};
|
|
290
|
+
}, et = (t, e = "") => {
|
|
291
|
+
const r = [];
|
|
292
|
+
for (const n of t) {
|
|
293
|
+
const s = n.path === "*" ? "*" : `${e}${n.path}`.replace(/\/+/g, "/");
|
|
294
|
+
r.push({
|
|
295
|
+
...n,
|
|
296
|
+
path: s
|
|
297
|
+
}), n.children && r.push(...et(n.children, s));
|
|
298
|
+
}
|
|
299
|
+
return r;
|
|
300
|
+
}, Lt = (t, e = {}) => {
|
|
301
|
+
const r = T();
|
|
302
|
+
if (!r) throw new Error("bQuery router: No router initialized.");
|
|
303
|
+
const n = r.routes.find((a) => a.name === t);
|
|
304
|
+
if (!n) throw new Error(`bQuery router: Route "${t}" not found.`);
|
|
305
|
+
let s = "";
|
|
306
|
+
for (let a = 0; a < n.path.length; ) {
|
|
307
|
+
if (n.path[a] === ":" && N(n.path[a + 1])) {
|
|
308
|
+
let o = a + 2;
|
|
309
|
+
for (; o < n.path.length && I(n.path[o]); ) o++;
|
|
310
|
+
let p = o, u = null;
|
|
311
|
+
if (n.path[o] === "(") {
|
|
312
|
+
const w = J(n.path, o);
|
|
313
|
+
if (!w) throw new Error(`bQuery router: Invalid constraint syntax in path "${n.path}" for route "${t}".`);
|
|
314
|
+
u = w.constraint, p = w.endIndex;
|
|
315
|
+
}
|
|
316
|
+
const l = n.path.slice(a + 1, o), h = e[l];
|
|
317
|
+
if (h === void 0) throw new Error(`bQuery router: Missing required param "${l}" for route "${t}".`);
|
|
318
|
+
if (u && !Y(u).test(h)) throw new Error(`bQuery router: Param "${l}" with value "${h}" does not satisfy the route constraint "${u}" for route "${t}".`);
|
|
319
|
+
s += encodeURIComponent(h), a = p;
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
s += n.path[a], a++;
|
|
323
|
+
}
|
|
324
|
+
return s;
|
|
325
|
+
}, Kt = (t, e = !1) => {
|
|
326
|
+
const r = k.value.path;
|
|
327
|
+
return e ? r === t : r.startsWith(t);
|
|
328
|
+
}, xt = (t, e = !1) => L(() => {
|
|
329
|
+
const r = k.value.path;
|
|
330
|
+
return e ? r === t : r.startsWith(t);
|
|
331
|
+
}), mt = 100, wt = (t) => {
|
|
332
|
+
const e = {};
|
|
333
|
+
for (const [r, n] of Object.entries(t))
|
|
334
|
+
G(r) || (e[r] = n);
|
|
335
|
+
return e;
|
|
336
|
+
}, Tt = (t) => {
|
|
337
|
+
const e = T();
|
|
338
|
+
e && e.destroy();
|
|
339
|
+
const { routes: r, base: n = "", hash: s = !1, scrollRestoration: a = !1 } = t, o = [], p = [], u = et(r), l = /* @__PURE__ */ new Map();
|
|
340
|
+
let h = "0", w = 0, A = null;
|
|
341
|
+
if (a && typeof history < "u" && "scrollRestoration" in history) {
|
|
342
|
+
A = history.scrollRestoration, history.scrollRestoration !== "manual" && (history.scrollRestoration = "manual");
|
|
343
|
+
const i = history.state && typeof history.state == "object" ? history.state : {};
|
|
344
|
+
if (typeof i.__bqScrollKey != "string") {
|
|
345
|
+
const c = s ? window.location.hash || "#/" : `${window.location.pathname}${window.location.search}${window.location.hash}`;
|
|
346
|
+
history.replaceState({
|
|
347
|
+
...i,
|
|
348
|
+
__bqScrollKey: h
|
|
349
|
+
}, "", c);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const d = () => history.state && history.state.__bqScrollKey || h, y = () => `${Date.now()}-${w++}`, v = (i = d()) => {
|
|
353
|
+
if (a)
|
|
354
|
+
for (l.has(i) && l.delete(i), l.set(i, {
|
|
355
|
+
x: window.scrollX,
|
|
356
|
+
y: window.scrollY
|
|
357
|
+
}); l.size > mt; ) {
|
|
358
|
+
const c = l.keys().next().value;
|
|
359
|
+
if (c === void 0) break;
|
|
360
|
+
l.delete(c);
|
|
361
|
+
}
|
|
362
|
+
}, g = (i = d()) => {
|
|
363
|
+
if (!a) return;
|
|
364
|
+
const c = l.get(i);
|
|
365
|
+
c ? window.scrollTo(c.x, c.y) : window.scrollTo(0, 0);
|
|
366
|
+
}, b = () => {
|
|
367
|
+
const i = history.state && typeof history.state == "object" ? { ...history.state } : {};
|
|
368
|
+
return a && (i.__bqScrollKey = h), i;
|
|
369
|
+
}, q = () => {
|
|
370
|
+
if (s) {
|
|
371
|
+
const [c, _ = ""] = (window.location.hash.slice(1) || "/").split("#"), [P, f = ""] = c.split("?");
|
|
372
|
+
return {
|
|
373
|
+
pathname: P,
|
|
374
|
+
search: f ? `?${f}` : "",
|
|
375
|
+
hash: _ ? `#${_}` : ""
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
let i = window.location.pathname;
|
|
379
|
+
return n && (i === n || i.startsWith(n + "/")) && (i = i.slice(n.length) || "/"), {
|
|
380
|
+
pathname: i,
|
|
381
|
+
search: window.location.search,
|
|
382
|
+
hash: window.location.hash
|
|
383
|
+
};
|
|
384
|
+
}, D = () => {
|
|
385
|
+
const { pathname: i, search: c, hash: _ } = q();
|
|
386
|
+
k.value = O(i, c, _, u);
|
|
387
|
+
}, H = async (i, c, _ = /* @__PURE__ */ new Set()) => {
|
|
388
|
+
const { pathname: P, search: f, hash: R } = q(), S = O(P, f, R, u), m = new URL(i, window.location.origin), C = `${m.pathname}${m.search}${m.hash}`;
|
|
389
|
+
if (_.has(C)) throw new Error(`bQuery router: redirect loop detected for path "${C}"`);
|
|
390
|
+
_.add(C);
|
|
391
|
+
const E = O(m.pathname, m.search, m.hash, u);
|
|
392
|
+
if (E.matched?.redirectTo) {
|
|
393
|
+
await H(E.matched.redirectTo, c, _);
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
if (E.matched?.beforeEnter && await E.matched.beforeEnter(E, S) === !1)
|
|
397
|
+
return;
|
|
398
|
+
for (const W of o) if (await W(E, S) === !1) return;
|
|
399
|
+
v();
|
|
400
|
+
const K = a ? d() : void 0, $ = c === "replaceState" && K ? K : y(), x = s ? `#${i}` : `${n}${i}`, z = a && history.state && typeof history.state == "object" ? wt(history.state) : {}, rt = a ? {
|
|
401
|
+
...z,
|
|
402
|
+
__bqScrollKey: $
|
|
403
|
+
} : {};
|
|
404
|
+
history[c](rt, "", x), h = $, D(), a && c === "pushState" && window.scrollTo(0, 0);
|
|
405
|
+
for (const W of p) W(k.value, S);
|
|
406
|
+
}, U = async (i) => {
|
|
407
|
+
const { pathname: c, search: _, hash: P } = q(), f = k.value, R = O(c, _, P, u);
|
|
408
|
+
if (R.matched?.redirectTo) {
|
|
409
|
+
await H(R.matched.redirectTo, "replaceState");
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if (R.matched?.beforeEnter && await R.matched.beforeEnter(R, f) === !1) {
|
|
413
|
+
const S = new URLSearchParams(Object.entries(f.query).flatMap(([K, $]) => Array.isArray($) ? $.map((x) => [K, x]) : [[K, $]])).toString(), m = S ? `?${S}` : "", C = f.hash ? `#${f.hash}` : "", E = s ? `#${f.path}${m}${C}` : `${n}${f.path}${m}${C}`;
|
|
414
|
+
history.replaceState(b(), "", E);
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
for (const S of o) if (await S(R, f) === !1) {
|
|
418
|
+
const m = new URLSearchParams(Object.entries(f.query).flatMap(([$, x]) => Array.isArray(x) ? x.map((z) => [$, z]) : [[$, x]])).toString(), C = m ? `?${m}` : "", E = f.hash ? `#${f.hash}` : "", K = s ? `#${f.path}${C}${E}` : `${n}${f.path}${C}${E}`;
|
|
419
|
+
history.replaceState(b(), "", K);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
v(h), h = i.state?.__bqScrollKey ?? d(), D(), g(h);
|
|
423
|
+
for (const S of p) S(k.value, f);
|
|
424
|
+
};
|
|
425
|
+
window.addEventListener("popstate", U), D();
|
|
426
|
+
const j = {
|
|
427
|
+
push: (i) => H(i, "pushState"),
|
|
428
|
+
replace: (i) => H(i, "replaceState"),
|
|
429
|
+
back: () => history.back(),
|
|
430
|
+
forward: () => history.forward(),
|
|
431
|
+
go: (i) => history.go(i),
|
|
432
|
+
beforeEach: (i) => (o.push(i), () => {
|
|
433
|
+
const c = o.indexOf(i);
|
|
434
|
+
c > -1 && o.splice(c, 1);
|
|
435
|
+
}),
|
|
436
|
+
afterEach: (i) => (p.push(i), () => {
|
|
437
|
+
const c = p.indexOf(i);
|
|
438
|
+
c > -1 && p.splice(c, 1);
|
|
439
|
+
}),
|
|
440
|
+
currentRoute: ot,
|
|
441
|
+
routes: u,
|
|
442
|
+
base: n,
|
|
443
|
+
hash: s,
|
|
444
|
+
destroy: () => {
|
|
445
|
+
window.removeEventListener("popstate", U), o.length = 0, p.length = 0, l.clear(), A !== null && typeof history < "u" && "scrollRestoration" in history && (history.scrollRestoration = A), B(null);
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
return B(j), j;
|
|
449
|
+
}, M = L(() => k.value), gt = {
|
|
450
|
+
route: M,
|
|
451
|
+
path: L(() => M.value.path),
|
|
452
|
+
params: L(() => M.value.params),
|
|
453
|
+
query: L(() => M.value.query),
|
|
454
|
+
hash: L(() => M.value.hash),
|
|
455
|
+
matched: L(() => M.value.matched)
|
|
456
|
+
}, qt = () => gt;
|
|
457
|
+
export {
|
|
458
|
+
Lt as a,
|
|
459
|
+
ut as c,
|
|
460
|
+
Ct as d,
|
|
461
|
+
Q as f,
|
|
462
|
+
xt as i,
|
|
463
|
+
$t as l,
|
|
464
|
+
Tt as n,
|
|
465
|
+
Rt as o,
|
|
466
|
+
ot as p,
|
|
467
|
+
Kt as r,
|
|
468
|
+
kt as s,
|
|
469
|
+
qt as t,
|
|
470
|
+
At as u
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
//# sourceMappingURL=router-BrthaP_z.js.map
|