@esmx/router-vue 3.0.0-rc.62 → 3.0.0-rc.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img src="https://www.esmnext.com/logo.svg?t=2025" width="120" alt="Esmx Logo" />
2
+ <img src="https://esmx.dev/logo.svg?t=2025" width="120" alt="Esmx Logo" />
3
3
  <h1>@esmx/router-vue</h1>
4
4
 
5
5
  <div>
@@ -9,7 +9,7 @@
9
9
  <a href="https://github.com/esmnext/esmx/actions/workflows/build.yml">
10
10
  <img src="https://github.com/esmnext/esmx/actions/workflows/build.yml/badge.svg" alt="Build" />
11
11
  </a>
12
- <a href="https://www.esmnext.com/coverage/">
12
+ <a href="https://esmx.dev/coverage/">
13
13
  <img src="https://img.shields.io/badge/coverage-live%20report-brightgreen" alt="Coverage Report" />
14
14
  </a>
15
15
  <a href="https://nodejs.org/">
package/README.zh-CN.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img src="https://www.esmnext.com/logo.svg?t=2025" width="120" alt="Esmx Logo" />
2
+ <img src="https://esmx.dev/logo.svg?t=2025" width="120" alt="Esmx Logo" />
3
3
  <h1>@esmx/router-vue</h1>
4
4
 
5
5
  <div>
@@ -9,7 +9,7 @@
9
9
  <a href="https://github.com/esmnext/esmx/actions/workflows/build.yml">
10
10
  <img src="https://github.com/esmnext/esmx/actions/workflows/build.yml/badge.svg" alt="Build" />
11
11
  </a>
12
- <a href="https://www.esmnext.com/coverage/">
12
+ <a href="https://esmx.dev/coverage/">
13
13
  <img src="https://img.shields.io/badge/coverage-live%20report-brightgreen" alt="Coverage Report" />
14
14
  </a>
15
15
  <a href="https://nodejs.org/">
package/dist/index.d.ts CHANGED
@@ -2,5 +2,5 @@ export type * from './vue2';
2
2
  export type * from './vue3';
3
3
  export { useRouter, useRoute, useProvideRouter, useLink, getRoute, getRouter } from './use';
4
4
  export { RouterLink } from './router-link';
5
- export { RouterView } from './router-view';
5
+ export { RouterView, RouterViewDepth } from './router-view';
6
6
  export { RouterPlugin } from './plugin';
package/dist/index.mjs CHANGED
@@ -7,5 +7,5 @@ export {
7
7
  getRouter
8
8
  } from "./use.mjs";
9
9
  export { RouterLink } from "./router-link.mjs";
10
- export { RouterView } from "./router-view.mjs";
10
+ export { RouterView, RouterViewDepth } from "./router-view.mjs";
11
11
  export { RouterPlugin } from "./plugin.mjs";
@@ -66,6 +66,7 @@ describe("index.ts - Package Entry Point", () => {
66
66
  // Components
67
67
  "RouterLink",
68
68
  "RouterView",
69
+ "RouterViewDepth",
69
70
  // Plugin
70
71
  "RouterPlugin"
71
72
  ];
@@ -87,6 +88,7 @@ describe("index.ts - Package Entry Point", () => {
87
88
  "getRoute",
88
89
  "RouterLink",
89
90
  "RouterView",
91
+ "RouterViewDepth",
90
92
  "RouterPlugin"
91
93
  ];
92
94
  const unexpectedExports = actualExports.filter(
@@ -1,3 +1,4 @@
1
+ export declare const RouterViewDepth: unique symbol;
1
2
  /**
2
3
  * RouterView component for rendering matched route components.
3
4
  * Acts as a placeholder where route components are rendered based on the current route.
@@ -1,13 +1,13 @@
1
1
  import { defineComponent, h, inject, provide } from "vue";
2
2
  import { useRoute } from "./use.mjs";
3
3
  import { resolveComponent } from "./util.mjs";
4
- const RouterViewDepthKey = Symbol("RouterViewDepth");
4
+ export const RouterViewDepth = Symbol("RouterViewDepth");
5
5
  export const RouterView = defineComponent({
6
6
  name: "RouterView",
7
7
  setup() {
8
8
  const route = useRoute();
9
- const depth = inject(RouterViewDepthKey, 0);
10
- provide(RouterViewDepthKey, depth + 1);
9
+ const depth = inject(RouterViewDepth, 0);
10
+ provide(RouterViewDepth, depth + 1);
11
11
  return () => {
12
12
  const matchedRoute = route.matched[depth];
13
13
  const component = matchedRoute ? resolveComponent(matchedRoute.component) : null;
@@ -170,11 +170,11 @@ describe("router-view.ts - RouterView Component", () => {
170
170
  describe("Depth Tracking", () => {
171
171
  it("should inject depth 0 by default", async () => {
172
172
  let injectedDepth;
173
- const RouterViewDepthKey = Symbol("RouterViewDepth");
173
+ const RouterViewDepth = Symbol("RouterViewDepth");
174
174
  const TestRouterView = defineComponent({
175
175
  name: "TestRouterView",
176
176
  setup() {
177
- injectedDepth = inject(RouterViewDepthKey, -1);
177
+ injectedDepth = inject(RouterViewDepth, -1);
178
178
  return () => h(RouterView);
179
179
  }
180
180
  });
@@ -193,19 +193,19 @@ describe("router-view.ts - RouterView Component", () => {
193
193
  it("should provide correct depth in nested RouterViews", async () => {
194
194
  let parentDepth;
195
195
  let childDepth;
196
- const RouterViewDepthKey = Symbol("RouterViewDepth");
196
+ const RouterViewDepth = Symbol("RouterViewDepth");
197
197
  const ParentTestComponent = defineComponent({
198
198
  name: "ParentTestComponent",
199
199
  setup() {
200
- parentDepth = inject(RouterViewDepthKey, -1);
201
- provide(RouterViewDepthKey, 0);
200
+ parentDepth = inject(RouterViewDepth, -1);
201
+ provide(RouterViewDepth, 0);
202
202
  return () => h("div", [h("span", "Parent"), h(ChildTestComponent)]);
203
203
  }
204
204
  });
205
205
  const ChildTestComponent = defineComponent({
206
206
  name: "ChildTestComponent",
207
207
  setup() {
208
- childDepth = inject(RouterViewDepthKey, -1);
208
+ childDepth = inject(RouterViewDepth, -1);
209
209
  return () => h("div", "Child");
210
210
  }
211
211
  });
@@ -272,12 +272,12 @@ describe("router-view.ts - RouterView Component", () => {
272
272
  });
273
273
  describe("Edge Cases and Error Handling", () => {
274
274
  it("should render null when no route matches at current depth", async () => {
275
- const RouterViewDepthKey = Symbol("RouterViewDepth");
275
+ const RouterViewDepth = Symbol("RouterViewDepth");
276
276
  const DeepRouterView = defineComponent({
277
277
  name: "DeepRouterView",
278
278
  setup() {
279
- const currentDepth = inject(RouterViewDepthKey, 0);
280
- provide(RouterViewDepthKey, currentDepth + 1);
279
+ const currentDepth = inject(RouterViewDepth, 0);
280
+ provide(RouterViewDepth, currentDepth + 1);
281
281
  return () => h(RouterView);
282
282
  }
283
283
  });
package/dist/use.mjs CHANGED
@@ -62,7 +62,7 @@ export function useRoute() {
62
62
  }
63
63
  export function useProvideRouter(router) {
64
64
  const proxy = getCurrentProxy("useProvideRouter");
65
- const dep = ref(false);
65
+ const dep = ref(0);
66
66
  const proxiedRouter = createDependentProxy(router, dep);
67
67
  const proxiedRoute = createDependentProxy(router.route, dep);
68
68
  const context = {
@@ -74,7 +74,7 @@ export function useProvideRouter(router) {
74
74
  const unwatch = router.afterEach((to) => {
75
75
  if (router.route === to) {
76
76
  to.syncTo(proxiedRoute);
77
- dep.value = !dep.value;
77
+ dep.value++;
78
78
  }
79
79
  });
80
80
  onBeforeUnmount(unwatch);
package/dist/util.d.ts CHANGED
@@ -4,6 +4,6 @@ export declare function createSymbolProperty<T>(symbol: symbol): {
4
4
  readonly set: (instance: any, value: T) => void;
5
5
  readonly get: (instance: any) => T | undefined;
6
6
  };
7
- export declare function createDependentProxy<T extends object>(obj: T, dep: Ref<boolean>): T;
7
+ export declare function createDependentProxy<T extends object>(obj: T, dep: Ref<any>): T;
8
8
  export declare function isESModule(obj: unknown): obj is Record<string | symbol, any>;
9
9
  export declare function resolveComponent(component: unknown): unknown;
package/package.json CHANGED
@@ -50,7 +50,7 @@
50
50
  "vue": "^3.5.0 || ^2.7.0"
51
51
  },
52
52
  "dependencies": {
53
- "@esmx/router": "3.0.0-rc.62"
53
+ "@esmx/router": "3.0.0-rc.64"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@biomejs/biome": "1.9.4",
@@ -62,7 +62,7 @@
62
62
  "vue": "3.5.13",
63
63
  "vue2": "npm:vue@2.7.16"
64
64
  },
65
- "version": "3.0.0-rc.62",
65
+ "version": "3.0.0-rc.64",
66
66
  "type": "module",
67
67
  "private": false,
68
68
  "exports": {
@@ -81,5 +81,5 @@
81
81
  "template",
82
82
  "public"
83
83
  ],
84
- "gitHead": "e5a1e811403bf1db4437dff88c3ea8bc6b576f64"
84
+ "gitHead": "8c103750d1e623fa4fa23b6ed9149f39e4a9bd58"
85
85
  }
package/src/index.test.ts CHANGED
@@ -79,6 +79,7 @@ describe('index.ts - Package Entry Point', () => {
79
79
  // Components
80
80
  'RouterLink',
81
81
  'RouterView',
82
+ 'RouterViewDepth',
82
83
  // Plugin
83
84
  'RouterPlugin'
84
85
  ];
@@ -102,6 +103,7 @@ describe('index.ts - Package Entry Point', () => {
102
103
  'getRoute',
103
104
  'RouterLink',
104
105
  'RouterView',
106
+ 'RouterViewDepth',
105
107
  'RouterPlugin'
106
108
  ];
107
109
 
package/src/index.ts CHANGED
@@ -11,6 +11,6 @@ export {
11
11
  } from './use';
12
12
 
13
13
  export { RouterLink } from './router-link';
14
- export { RouterView } from './router-view';
14
+ export { RouterView, RouterViewDepth } from './router-view';
15
15
 
16
16
  export { RouterPlugin } from './plugin';
@@ -231,13 +231,13 @@ describe('router-view.ts - RouterView Component', () => {
231
231
  let injectedDepth: number | undefined;
232
232
 
233
233
  // Use the same symbol key that RouterView uses internally
234
- const RouterViewDepthKey = Symbol('RouterViewDepth');
234
+ const RouterViewDepth = Symbol('RouterViewDepth');
235
235
 
236
236
  // Create a custom RouterView component that can capture the injected depth
237
237
  const TestRouterView = defineComponent({
238
238
  name: 'TestRouterView',
239
239
  setup() {
240
- injectedDepth = inject(RouterViewDepthKey, -1);
240
+ injectedDepth = inject(RouterViewDepth, -1);
241
241
  return () => h(RouterView);
242
242
  }
243
243
  });
@@ -263,13 +263,13 @@ describe('router-view.ts - RouterView Component', () => {
263
263
  let parentDepth: number | undefined;
264
264
  let childDepth: number | undefined;
265
265
 
266
- const RouterViewDepthKey = Symbol('RouterViewDepth');
266
+ const RouterViewDepth = Symbol('RouterViewDepth');
267
267
 
268
268
  const ParentTestComponent = defineComponent({
269
269
  name: 'ParentTestComponent',
270
270
  setup() {
271
- parentDepth = inject(RouterViewDepthKey, -1);
272
- provide(RouterViewDepthKey, 0); // Simulate parent RouterView
271
+ parentDepth = inject(RouterViewDepth, -1);
272
+ provide(RouterViewDepth, 0); // Simulate parent RouterView
273
273
  return () =>
274
274
  h('div', [h('span', 'Parent'), h(ChildTestComponent)]);
275
275
  }
@@ -278,7 +278,7 @@ describe('router-view.ts - RouterView Component', () => {
278
278
  const ChildTestComponent = defineComponent({
279
279
  name: 'ChildTestComponent',
280
280
  setup() {
281
- childDepth = inject(RouterViewDepthKey, -1);
281
+ childDepth = inject(RouterViewDepth, -1);
282
282
  return () => h('div', 'Child');
283
283
  }
284
284
  });
@@ -362,14 +362,14 @@ describe('router-view.ts - RouterView Component', () => {
362
362
 
363
363
  describe('Edge Cases and Error Handling', () => {
364
364
  it('should render null when no route matches at current depth', async () => {
365
- const RouterViewDepthKey = Symbol('RouterViewDepth');
365
+ const RouterViewDepth = Symbol('RouterViewDepth');
366
366
 
367
367
  const DeepRouterView = defineComponent({
368
368
  name: 'DeepRouterView',
369
369
  setup() {
370
370
  // Inject depth 0 from parent RouterView and provide depth 1
371
- const currentDepth = inject(RouterViewDepthKey, 0);
372
- provide(RouterViewDepthKey, currentDepth + 1);
371
+ const currentDepth = inject(RouterViewDepth, 0);
372
+ provide(RouterViewDepth, currentDepth + 1);
373
373
  return () => h(RouterView);
374
374
  }
375
375
  });
@@ -2,7 +2,7 @@ import { defineComponent, h, inject, provide } from 'vue';
2
2
  import { useRoute } from './use';
3
3
  import { resolveComponent } from './util';
4
4
 
5
- const RouterViewDepthKey = Symbol('RouterViewDepth');
5
+ export const RouterViewDepth = Symbol('RouterViewDepth');
6
6
 
7
7
  /**
8
8
  * RouterView component for rendering matched route components.
@@ -39,11 +39,11 @@ export const RouterView = defineComponent({
39
39
 
40
40
  // Get current RouterView depth from parent RouterView (if any)
41
41
  // This enables proper nested routing by tracking how deep we are in the component tree
42
- const depth = inject(RouterViewDepthKey, 0);
42
+ const depth = inject(RouterViewDepth, 0);
43
43
 
44
44
  // Provide depth + 1 to child RouterView components
45
45
  // This ensures each nested RouterView renders the correct route component
46
- provide(RouterViewDepthKey, depth + 1);
46
+ provide(RouterViewDepth, depth + 1);
47
47
 
48
48
  return () => {
49
49
  // Get the matched route configuration at current depth
package/src/use.ts CHANGED
@@ -259,7 +259,7 @@ export function useRoute(): Route {
259
259
  export function useProvideRouter(router: Router): void {
260
260
  const proxy = getCurrentProxy('useProvideRouter');
261
261
 
262
- const dep = ref(false);
262
+ const dep = ref(0);
263
263
 
264
264
  const proxiedRouter = createDependentProxy(router, dep);
265
265
  const proxiedRoute = createDependentProxy(router.route, dep);
@@ -275,7 +275,7 @@ export function useProvideRouter(router: Router): void {
275
275
  const unwatch = router.afterEach((to: Route) => {
276
276
  if (router.route === to) {
277
277
  to.syncTo(proxiedRoute);
278
- dep.value = !dep.value;
278
+ dep.value++;
279
279
  }
280
280
  });
281
281
 
package/src/util.ts CHANGED
@@ -16,7 +16,7 @@ export function createSymbolProperty<T>(symbol: symbol) {
16
16
 
17
17
  export function createDependentProxy<T extends object>(
18
18
  obj: T,
19
- dep: Ref<boolean>
19
+ dep: Ref<any>
20
20
  ): T {
21
21
  return new Proxy(obj, {
22
22
  get(target, prop, receiver) {