@esmx/router-vue 3.0.0-rc.78 → 3.0.0-rc.80
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/dist/index.d.ts +4 -4
- package/dist/index.mjs +10 -10
- package/dist/index.test.mjs +1 -3
- package/dist/plugin.test.mjs +2 -9
- package/dist/use.test.mjs +7 -2
- package/dist/util.mjs +3 -0
- package/dist/util.test.mjs +35 -2
- package/dist/vue2.d.ts +2 -0
- package/package.json +5 -5
- package/src/index.test.ts +1 -3
- package/src/index.ts +12 -15
- package/src/plugin.test.ts +2 -9
- package/src/router-link.ts +1 -1
- package/src/use.test.ts +8 -3
- package/src/util.test.ts +42 -2
- package/src/util.ts +11 -1
- package/src/vue2.ts +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export type * from './vue3';
|
|
3
|
-
export { useRouter, useRoute, useProvideRouter, useLink, useRouterViewDepth, getRouterViewDepth, getRoute, getRouter } from './use';
|
|
1
|
+
export { RouterPlugin } from './plugin';
|
|
4
2
|
export { RouterLink } from './router-link';
|
|
5
3
|
export { RouterView } from './router-view';
|
|
6
|
-
export {
|
|
4
|
+
export { getRoute, getRouter, getRouterViewDepth, useLink, useProvideRouter, useRoute, useRouter, useRouterViewDepth } from './use';
|
|
5
|
+
export type * from './vue2';
|
|
6
|
+
export type * from './vue3';
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
export { RouterPlugin } from "./plugin.mjs";
|
|
2
|
+
export { RouterLink } from "./router-link.mjs";
|
|
3
|
+
export { RouterView } from "./router-view.mjs";
|
|
1
4
|
export {
|
|
2
|
-
useRouter,
|
|
3
|
-
useRoute,
|
|
4
|
-
useProvideRouter,
|
|
5
|
-
useLink,
|
|
6
|
-
useRouterViewDepth,
|
|
7
|
-
getRouterViewDepth,
|
|
8
5
|
getRoute,
|
|
9
|
-
getRouter
|
|
6
|
+
getRouter,
|
|
7
|
+
getRouterViewDepth,
|
|
8
|
+
useLink,
|
|
9
|
+
useProvideRouter,
|
|
10
|
+
useRoute,
|
|
11
|
+
useRouter,
|
|
12
|
+
useRouterViewDepth
|
|
10
13
|
} from "./use.mjs";
|
|
11
|
-
export { RouterLink } from "./router-link.mjs";
|
|
12
|
-
export { RouterView } from "./router-view.mjs";
|
|
13
|
-
export { RouterPlugin } from "./plugin.mjs";
|
package/dist/index.test.mjs
CHANGED
|
@@ -81,9 +81,7 @@ describe("index.ts - Package Entry Point", () => {
|
|
|
81
81
|
];
|
|
82
82
|
expectedExports.forEach((exportName) => {
|
|
83
83
|
expect(RouterVueModule).toHaveProperty(exportName);
|
|
84
|
-
expect(
|
|
85
|
-
RouterVueModule[exportName]
|
|
86
|
-
).toBeDefined();
|
|
84
|
+
expect(Object.hasOwn(RouterVueModule, exportName)).toBe(true);
|
|
87
85
|
});
|
|
88
86
|
});
|
|
89
87
|
it("should not export unexpected items", () => {
|
package/dist/plugin.test.mjs
CHANGED
|
@@ -354,15 +354,8 @@ describe("plugin.ts - RouterPlugin", () => {
|
|
|
354
354
|
expect(routeDescriptor).toBeDefined();
|
|
355
355
|
expect(typeof (routerDescriptor == null ? void 0 : routerDescriptor.get)).toBe("function");
|
|
356
356
|
expect(typeof (routeDescriptor == null ? void 0 : routeDescriptor.get)).toBe("function");
|
|
357
|
-
expect(
|
|
358
|
-
|
|
359
|
-
globalProperties,
|
|
360
|
-
"$router"
|
|
361
|
-
)
|
|
362
|
-
).toBe(true);
|
|
363
|
-
expect(
|
|
364
|
-
Object.prototype.hasOwnProperty.call(globalProperties, "$route")
|
|
365
|
-
).toBe(true);
|
|
357
|
+
expect(Object.hasOwn(globalProperties, "$router")).toBe(true);
|
|
358
|
+
expect(Object.hasOwn(globalProperties, "$route")).toBe(true);
|
|
366
359
|
});
|
|
367
360
|
it("should provide correct component types", () => {
|
|
368
361
|
app = createApp({
|
package/dist/use.test.mjs
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { Router, RouterMode } from "@esmx/router";
|
|
2
2
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
createApp,
|
|
5
|
+
defineComponent,
|
|
6
|
+
getCurrentInstance,
|
|
7
|
+
h,
|
|
8
|
+
nextTick
|
|
9
|
+
} from "vue";
|
|
5
10
|
import { RouterView } from "./router-view.mjs";
|
|
6
11
|
import {
|
|
7
12
|
getRouterViewDepth,
|
package/dist/util.mjs
CHANGED
|
@@ -28,5 +28,8 @@ export function resolveComponent(component) {
|
|
|
28
28
|
if (isESModule(component)) {
|
|
29
29
|
return component.default || component;
|
|
30
30
|
}
|
|
31
|
+
if (component && typeof component === "object" && !Array.isArray(component) && "default" in component && Object.keys(component).length === 1) {
|
|
32
|
+
return component.default;
|
|
33
|
+
}
|
|
31
34
|
return component;
|
|
32
35
|
}
|
package/dist/util.test.mjs
CHANGED
|
@@ -2,8 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
-
import { computed, nextTick, ref } from "vue";
|
|
6
|
-
import { version } from "vue";
|
|
5
|
+
import { computed, nextTick, ref, version } from "vue";
|
|
7
6
|
import {
|
|
8
7
|
createDependentProxy,
|
|
9
8
|
createSymbolProperty,
|
|
@@ -268,6 +267,40 @@ describe("util.ts - Utility Functions", () => {
|
|
|
268
267
|
const classInstance = new ClassComponent();
|
|
269
268
|
expect(resolveComponent(classInstance)).toBe(classInstance);
|
|
270
269
|
});
|
|
270
|
+
it("should return default when object has only default key", () => {
|
|
271
|
+
const component = { default: "DefaultComponent" };
|
|
272
|
+
expect(resolveComponent(component)).toBe("DefaultComponent");
|
|
273
|
+
});
|
|
274
|
+
it("should return object when it has multiple keys including default", () => {
|
|
275
|
+
const component = {
|
|
276
|
+
default: "DefaultComponent",
|
|
277
|
+
other: "otherValue"
|
|
278
|
+
};
|
|
279
|
+
expect(resolveComponent(component)).toBe(component);
|
|
280
|
+
});
|
|
281
|
+
it("should return object when it has multiple keys without default", () => {
|
|
282
|
+
const component = {
|
|
283
|
+
prop1: "value1",
|
|
284
|
+
prop2: "value2"
|
|
285
|
+
};
|
|
286
|
+
expect(resolveComponent(component)).toBe(component);
|
|
287
|
+
});
|
|
288
|
+
it("should return object when it has single key that is not default", () => {
|
|
289
|
+
const component = { custom: "CustomComponent" };
|
|
290
|
+
expect(resolveComponent(component)).toBe(component);
|
|
291
|
+
});
|
|
292
|
+
it("should return array as is", () => {
|
|
293
|
+
const component = ["item1", "item2"];
|
|
294
|
+
expect(resolveComponent(component)).toBe(component);
|
|
295
|
+
});
|
|
296
|
+
it("should return object with single default key that is null", () => {
|
|
297
|
+
const component = { default: null };
|
|
298
|
+
expect(resolveComponent(component)).toBe(null);
|
|
299
|
+
});
|
|
300
|
+
it("should return object with single default key that is undefined", () => {
|
|
301
|
+
const component = { default: void 0 };
|
|
302
|
+
expect(resolveComponent(component)).toBe(void 0);
|
|
303
|
+
});
|
|
271
304
|
});
|
|
272
305
|
});
|
|
273
306
|
describe("createDependentProxy", () => {
|
package/dist/vue2.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Route, Router } from '@esmx/router';
|
|
2
|
+
import type Vue from 'vue2';
|
|
2
3
|
declare module 'vue/types/vue' {
|
|
3
4
|
interface Vue {
|
|
4
5
|
readonly $router: Router;
|
|
@@ -11,3 +12,4 @@ declare module 'vue2/types/vue' {
|
|
|
11
12
|
readonly $route: Route;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
15
|
+
export type { Vue };
|
package/package.json
CHANGED
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"vue": "^3.5.0 || ^2.7.0"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@esmx/router": "3.0.0-rc.
|
|
53
|
+
"@esmx/router": "3.0.0-rc.80"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@biomejs/biome": "
|
|
57
|
-
"@types/node": "^24.
|
|
56
|
+
"@biomejs/biome": "2.3.7",
|
|
57
|
+
"@types/node": "^24.0.0",
|
|
58
58
|
"@vitest/coverage-v8": "3.2.4",
|
|
59
59
|
"typescript": "5.9.3",
|
|
60
60
|
"unbuild": "3.6.1",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"vue": "3.5.23",
|
|
63
63
|
"vue2": "npm:vue@2.7.16"
|
|
64
64
|
},
|
|
65
|
-
"version": "3.0.0-rc.
|
|
65
|
+
"version": "3.0.0-rc.80",
|
|
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": "
|
|
84
|
+
"gitHead": "3fca699d5b4daa50c2c53f4adea0e8a71e14765b"
|
|
85
85
|
}
|
package/src/index.test.ts
CHANGED
|
@@ -97,9 +97,7 @@ describe('index.ts - Package Entry Point', () => {
|
|
|
97
97
|
|
|
98
98
|
expectedExports.forEach((exportName) => {
|
|
99
99
|
expect(RouterVueModule).toHaveProperty(exportName);
|
|
100
|
-
expect(
|
|
101
|
-
RouterVueModule[exportName as keyof typeof RouterVueModule]
|
|
102
|
-
).toBeDefined();
|
|
100
|
+
expect(Object.hasOwn(RouterVueModule, exportName)).toBe(true);
|
|
103
101
|
});
|
|
104
102
|
});
|
|
105
103
|
|
package/src/index.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
|
|
1
|
+
export { RouterPlugin } from './plugin';
|
|
2
|
+
export { RouterLink } from './router-link';
|
|
3
|
+
export { RouterView } from './router-view';
|
|
4
4
|
export {
|
|
5
|
-
useRouter,
|
|
6
|
-
useRoute,
|
|
7
|
-
useProvideRouter,
|
|
8
|
-
useLink,
|
|
9
|
-
useRouterViewDepth,
|
|
10
|
-
getRouterViewDepth,
|
|
11
5
|
getRoute,
|
|
12
|
-
getRouter
|
|
6
|
+
getRouter,
|
|
7
|
+
getRouterViewDepth,
|
|
8
|
+
useLink,
|
|
9
|
+
useProvideRouter,
|
|
10
|
+
useRoute,
|
|
11
|
+
useRouter,
|
|
12
|
+
useRouterViewDepth
|
|
13
13
|
} from './use';
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
export { RouterView } from './router-view';
|
|
17
|
-
|
|
18
|
-
export { RouterPlugin } from './plugin';
|
|
14
|
+
export type * from './vue2';
|
|
15
|
+
export type * from './vue3';
|
package/src/plugin.test.ts
CHANGED
|
@@ -446,15 +446,8 @@ describe('plugin.ts - RouterPlugin', () => {
|
|
|
446
446
|
expect(typeof routeDescriptor?.get).toBe('function');
|
|
447
447
|
|
|
448
448
|
// Verify properties exist in global properties
|
|
449
|
-
expect(
|
|
450
|
-
|
|
451
|
-
globalProperties,
|
|
452
|
-
'$router'
|
|
453
|
-
)
|
|
454
|
-
).toBe(true);
|
|
455
|
-
expect(
|
|
456
|
-
Object.prototype.hasOwnProperty.call(globalProperties, '$route')
|
|
457
|
-
).toBe(true);
|
|
449
|
+
expect(Object.hasOwn(globalProperties, '$router')).toBe(true);
|
|
450
|
+
expect(Object.hasOwn(globalProperties, '$route')).toBe(true);
|
|
458
451
|
});
|
|
459
452
|
|
|
460
453
|
it('should provide correct component types', () => {
|
package/src/router-link.ts
CHANGED
package/src/use.test.ts
CHANGED
|
@@ -2,9 +2,14 @@ import { type Route, Router, RouterMode } from '@esmx/router';
|
|
|
2
2
|
/**
|
|
3
3
|
* @vitest-environment happy-dom
|
|
4
4
|
*/
|
|
5
|
-
import { afterEach, beforeEach, describe, expect, it
|
|
6
|
-
import {
|
|
7
|
-
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
6
|
+
import {
|
|
7
|
+
createApp,
|
|
8
|
+
defineComponent,
|
|
9
|
+
getCurrentInstance,
|
|
10
|
+
h,
|
|
11
|
+
nextTick
|
|
12
|
+
} from 'vue';
|
|
8
13
|
import { RouterView } from './router-view';
|
|
9
14
|
import {
|
|
10
15
|
getRouterViewDepth,
|
package/src/util.test.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* @vitest-environment happy-dom
|
|
3
3
|
*/
|
|
4
4
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
-
import { computed, nextTick, ref } from 'vue';
|
|
6
|
-
import { version } from 'vue';
|
|
5
|
+
import { computed, nextTick, ref, version } from 'vue';
|
|
7
6
|
import {
|
|
8
7
|
createDependentProxy,
|
|
9
8
|
createSymbolProperty,
|
|
@@ -334,6 +333,47 @@ describe('util.ts - Utility Functions', () => {
|
|
|
334
333
|
const classInstance = new ClassComponent();
|
|
335
334
|
expect(resolveComponent(classInstance)).toBe(classInstance);
|
|
336
335
|
});
|
|
336
|
+
|
|
337
|
+
it('should return default when object has only default key', () => {
|
|
338
|
+
const component = { default: 'DefaultComponent' };
|
|
339
|
+
expect(resolveComponent(component)).toBe('DefaultComponent');
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
it('should return object when it has multiple keys including default', () => {
|
|
343
|
+
const component = {
|
|
344
|
+
default: 'DefaultComponent',
|
|
345
|
+
other: 'otherValue'
|
|
346
|
+
};
|
|
347
|
+
expect(resolveComponent(component)).toBe(component);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('should return object when it has multiple keys without default', () => {
|
|
351
|
+
const component = {
|
|
352
|
+
prop1: 'value1',
|
|
353
|
+
prop2: 'value2'
|
|
354
|
+
};
|
|
355
|
+
expect(resolveComponent(component)).toBe(component);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it('should return object when it has single key that is not default', () => {
|
|
359
|
+
const component = { custom: 'CustomComponent' };
|
|
360
|
+
expect(resolveComponent(component)).toBe(component);
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
it('should return array as is', () => {
|
|
364
|
+
const component = ['item1', 'item2'];
|
|
365
|
+
expect(resolveComponent(component)).toBe(component);
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
it('should return object with single default key that is null', () => {
|
|
369
|
+
const component = { default: null };
|
|
370
|
+
expect(resolveComponent(component)).toBe(null);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it('should return object with single default key that is undefined', () => {
|
|
374
|
+
const component = { default: undefined };
|
|
375
|
+
expect(resolveComponent(component)).toBe(undefined);
|
|
376
|
+
});
|
|
337
377
|
});
|
|
338
378
|
});
|
|
339
379
|
|
package/src/util.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { version } from 'vue';
|
|
2
1
|
import type { Ref } from 'vue';
|
|
2
|
+
import { version } from 'vue';
|
|
3
3
|
|
|
4
4
|
export const isVue3 = version.startsWith('3.');
|
|
5
5
|
|
|
@@ -41,5 +41,15 @@ export function resolveComponent(component: unknown): unknown {
|
|
|
41
41
|
return component.default || component;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
if (
|
|
45
|
+
component &&
|
|
46
|
+
typeof component === 'object' &&
|
|
47
|
+
!Array.isArray(component) &&
|
|
48
|
+
'default' in component &&
|
|
49
|
+
Object.keys(component).length === 1
|
|
50
|
+
) {
|
|
51
|
+
return component.default;
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
return component;
|
|
45
55
|
}
|
package/src/vue2.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Route, Router } from '@esmx/router';
|
|
2
2
|
import type Vue from 'vue2';
|
|
3
3
|
|
|
4
|
-
// @ts-
|
|
4
|
+
// @ts-expect-error
|
|
5
5
|
declare module 'vue/types/vue' {
|
|
6
6
|
interface Vue {
|
|
7
7
|
readonly $router: Router;
|
|
@@ -14,3 +14,5 @@ declare module 'vue2/types/vue' {
|
|
|
14
14
|
readonly $route: Route;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
export type { Vue };
|