@real-router/vue 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -2
- package/dist/cjs/{createHttpStatusSink-XDu5aGhc.d.ts → createHttpStatusSink-BENH-5-J.d.ts} +1 -1
- package/dist/cjs/{createHttpStatusSink-XDu5aGhc.d.ts.map → createHttpStatusSink-BENH-5-J.d.ts.map} +1 -1
- package/dist/cjs/index.d.ts +66 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/ssr.d.ts +1 -1
- package/dist/cjs/ssr.js +1 -1
- package/dist/cjs/useRoute-Dba_kop6.js +2 -0
- package/dist/cjs/{useRoute-BT3SkdOc.js.map → useRoute-Dba_kop6.js.map} +1 -1
- package/dist/esm/{createHttpStatusSink-DduXvbGr.d.mts → createHttpStatusSink-BENH-5-J.d.mts} +1 -1
- package/dist/esm/{createHttpStatusSink-DduXvbGr.d.mts.map → createHttpStatusSink-BENH-5-J.d.mts.map} +1 -1
- package/dist/esm/index.d.mts +66 -0
- package/dist/esm/index.d.mts.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/ssr.d.mts +1 -1
- package/dist/esm/ssr.mjs +1 -1
- package/dist/esm/{useRoute-2ocUdDHc.mjs → useRoute-BBfRYSpV.mjs} +1 -1
- package/dist/esm/{useRoute-2ocUdDHc.mjs.map → useRoute-BBfRYSpV.mjs.map} +1 -1
- package/package.json +5 -5
- package/src/RouterProvider.ts +28 -1
- package/dist/cjs/useRoute-BT3SkdOc.js +0 -2
package/dist/esm/ssr.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createHttpStatusSink, t as HttpStatusSink } from "./createHttpStatusSink-
|
|
1
|
+
import { n as createHttpStatusSink, t as HttpStatusSink } from "./createHttpStatusSink-BENH-5-J.mjs";
|
|
2
2
|
import { PropType } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/ClientOnly.d.ts
|
package/dist/esm/ssr.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e,t}from"./useRoute-
|
|
1
|
+
import{n as e,t}from"./useRoute-BBfRYSpV.mjs";import{Suspense as n,defineComponent as r,h as i,inject as a,onMounted as o,provide as s,ref as c}from"vue";const l=r({name:`ClientOnly`,setup(e,{slots:t}){let n=c(!1);return o(()=>{n.value=!0}),()=>n.value?t.default?.():t.fallback?.()}}),u=r({name:`ServerOnly`,setup(e,{slots:t}){let n=c(!1);return o(()=>{n.value=!0}),()=>n.value?t.fallback?.():t.default?.()}}),d=new Promise(()=>{});function f(e){let{route:n}=t();return n.value.context.ssrDataDeferred?.[e]??d}const p=r({name:`Await`,props:{name:{type:String,required:!0}},async setup(e,{slots:t}){let n=await f(e.name);return()=>t.default?.({value:n})}}),m=r({name:`Streamed`,setup(e,{slots:t}){return()=>i(n,{},{default:()=>t.default?.(),fallback:()=>t.fallback?.()})}}),h=()=>null,g=r({name:`HttpStatusCode`,props:{code:{type:Number,required:!0}},setup(t){let n=a(e,null);return n&&(n.code=t.code),h}}),_=r({name:`HttpStatusProvider`,props:{sink:{type:Object,required:!0}},setup(t,{slots:n}){return s(e,t.sink),()=>n.default?.()}});function v(){return{code:void 0}}export{p as Await,l as ClientOnly,g as HttpStatusCode,_ as HttpStatusProvider,u as ServerOnly,m as Streamed,v as createHttpStatusSink,f as useDeferred};
|
|
2
2
|
//# sourceMappingURL=ssr.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{inject as e}from"vue";const t=Symbol(`RouterKey`),n=Symbol(`NavigatorKey`),r=Symbol(`RouteKey`),i=Symbol(`HttpStatusSink`),a=()=>{let t=e(r);if(!t)throw Error(`useRoute must be used within a RouterProvider`);if(!t.route.value)throw Error(`useRoute called with no active route. Did you forget to await router.start() before rendering, or is the router stopped/disposed?`);return t};export{t as a,r as i,i as n,n as r,a as t};
|
|
2
|
-
//# sourceMappingURL=useRoute-
|
|
2
|
+
//# sourceMappingURL=useRoute-BBfRYSpV.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRoute-
|
|
1
|
+
{"version":3,"file":"useRoute-BBfRYSpV.mjs","names":[],"sources":["../../src/context.ts","../../src/composables/useRoute.ts"],"sourcesContent":["import type { RouteContext as RouteContextType } from \"./types\";\nimport type { HttpStatusSink } from \"./utils/createHttpStatusSink\";\nimport type { Router, Navigator } from \"@real-router/core\";\nimport type { InjectionKey } from \"vue\";\n\nexport const RouterKey: InjectionKey<Router> = Symbol(\"RouterKey\");\n\nexport const NavigatorKey: InjectionKey<Navigator> = Symbol(\"NavigatorKey\");\n\nexport const RouteKey: InjectionKey<RouteContextType> = Symbol(\"RouteKey\");\n\nexport const HTTP_STATUS_KEY: InjectionKey<HttpStatusSink> =\n Symbol(\"HttpStatusSink\");\n","import { inject } from \"vue\";\n\nimport { RouteKey } from \"../context\";\n\nimport type { RouteContext } from \"../types\";\nimport type { Params, State } from \"@real-router/core\";\nimport type { Ref } from \"vue\";\n\n/**\n * Return shape for `useRoute()` — `RouteContext<P>` with `route` narrowed\n * to the non-nullable variant. The composable throws when `route.value`\n * would be `undefined`, so consumers can read `.value.params.x` without a\n * nullable guard. Extracted from inline duplication at two call sites.\n */\nexport type UseRouteReturn<P extends Params = Params> = Omit<\n RouteContext<P>,\n \"route\"\n> & { route: Readonly<Ref<State<P>>> };\n\nexport const useRoute = <P extends Params = Params>(): UseRouteReturn<P> => {\n const routeContext = inject(RouteKey);\n\n if (!routeContext) {\n throw new Error(\"useRoute must be used within a RouterProvider\");\n }\n\n if (!routeContext.route.value) {\n throw new Error(\n \"useRoute called with no active route. Did you forget to await router.start() before rendering, or is the router stopped/disposed?\",\n );\n }\n\n return routeContext as UseRouteReturn<P>;\n};\n"],"mappings":"6BAKA,MAAa,EAAkC,OAAO,WAAW,EAEpD,EAAwC,OAAO,cAAc,EAE7D,EAA2C,OAAO,UAAU,EAE5D,EACX,OAAO,gBAAgB,ECOZ,MAA+D,CAC1E,IAAM,EAAe,EAAO,CAAQ,EAEpC,GAAI,CAAC,EACH,MAAU,MAAM,+CAA+C,EAGjE,GAAI,CAAC,EAAa,MAAM,MACtB,MAAU,MACR,mIACF,EAGF,OAAO,CACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@real-router/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "Vue 3 integration for Real-Router",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -66,15 +66,15 @@
|
|
|
66
66
|
"license": "MIT",
|
|
67
67
|
"sideEffects": false,
|
|
68
68
|
"dependencies": {
|
|
69
|
+
"@real-router/core": "^0.55.0",
|
|
69
70
|
"@real-router/route-utils": "^0.2.2",
|
|
70
|
-
"@real-router/
|
|
71
|
-
"@real-router/sources": "^0.8.3"
|
|
71
|
+
"@real-router/sources": "^0.8.4"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@testing-library/jest-dom": "6.9.1",
|
|
75
|
-
"@vue/test-utils": "2.4.
|
|
75
|
+
"@vue/test-utils": "2.4.10",
|
|
76
76
|
"vue": "3.5.13",
|
|
77
|
-
"@real-router/browser-plugin": "^0.17.
|
|
77
|
+
"@real-router/browser-plugin": "^0.17.5"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
80
|
"vue": ">=3.3.0"
|
package/src/RouterProvider.ts
CHANGED
|
@@ -5,11 +5,12 @@ import { pushDirectiveRouter } from "./directives/vLink";
|
|
|
5
5
|
import {
|
|
6
6
|
createRouteAnnouncer,
|
|
7
7
|
createScrollRestoration,
|
|
8
|
+
createScrollSpy,
|
|
8
9
|
createViewTransitions,
|
|
9
10
|
} from "./dom-utils";
|
|
10
11
|
import { setupRouteProvision } from "./setupRouteProvision";
|
|
11
12
|
|
|
12
|
-
import type { ScrollRestorationOptions } from "./dom-utils";
|
|
13
|
+
import type { ScrollRestorationOptions, ScrollSpyOptions } from "./dom-utils";
|
|
13
14
|
import type { Router } from "@real-router/core";
|
|
14
15
|
import type { PropType } from "vue";
|
|
15
16
|
|
|
@@ -62,6 +63,9 @@ export const RouterProvider = defineComponent({
|
|
|
62
63
|
scrollRestoration: {
|
|
63
64
|
type: Object as PropType<ScrollRestorationOptions>,
|
|
64
65
|
},
|
|
66
|
+
scrollSpy: {
|
|
67
|
+
type: Object as PropType<ScrollSpyOptions>,
|
|
68
|
+
},
|
|
65
69
|
viewTransitions: {
|
|
66
70
|
type: Boolean,
|
|
67
71
|
default: false,
|
|
@@ -106,6 +110,29 @@ export const RouterProvider = defineComponent({
|
|
|
106
110
|
},
|
|
107
111
|
);
|
|
108
112
|
|
|
113
|
+
// Reactive scrollSpy: watch by primitives, omit scrollContainer getter
|
|
114
|
+
// identity for the same reason scrollRestoration does.
|
|
115
|
+
watchToggleableUtility(
|
|
116
|
+
() =>
|
|
117
|
+
[
|
|
118
|
+
props.router,
|
|
119
|
+
props.scrollSpy !== undefined && props.scrollSpy.selector !== "",
|
|
120
|
+
props.scrollSpy?.selector,
|
|
121
|
+
props.scrollSpy?.rootMargin,
|
|
122
|
+
] as const,
|
|
123
|
+
([router, enabled, selector, rootMargin]) => {
|
|
124
|
+
if (!enabled || !selector) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return createScrollSpy(router, {
|
|
129
|
+
selector,
|
|
130
|
+
rootMargin,
|
|
131
|
+
scrollContainer: props.scrollSpy?.scrollContainer,
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
|
|
109
136
|
// Reactive viewTransitions: toggling prop creates/destroys the utility.
|
|
110
137
|
watchToggleableUtility(
|
|
111
138
|
() => [props.router, props.viewTransitions] as const,
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
let e=require(`vue`);const t=Symbol(`RouterKey`),n=Symbol(`NavigatorKey`),r=Symbol(`RouteKey`),i=Symbol(`HttpStatusSink`),a=()=>{let t=(0,e.inject)(r);if(!t)throw Error(`useRoute must be used within a RouterProvider`);if(!t.route.value)throw Error(`useRoute called with no active route. Did you forget to await router.start() before rendering, or is the router stopped/disposed?`);return t};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
|
|
2
|
-
//# sourceMappingURL=useRoute-BT3SkdOc.js.map
|