@gez/router-vue
Advanced tools
+22
-32
@@ -1,39 +0,29 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| Object.defineProperty(exports, "RouterLink", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _link.RouterLink; | ||
| } | ||
| Object.defineProperty(exports, 'RouterLink', { | ||
| enumerable: true, | ||
| get: () => _link.RouterLink | ||
| }); | ||
| Object.defineProperty(exports, "RouterView", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _view.RouterView; | ||
| } | ||
| Object.defineProperty(exports, 'RouterView', { | ||
| enumerable: true, | ||
| get: () => _view.RouterView | ||
| }); | ||
| Object.defineProperty(exports, "RouterVuePlugin", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _plugin.RouterVuePlugin; | ||
| } | ||
| Object.defineProperty(exports, 'RouterVuePlugin', { | ||
| enumerable: true, | ||
| get: () => _plugin.RouterVuePlugin | ||
| }); | ||
| Object.defineProperty(exports, "useRoute", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _use.useRoute; | ||
| } | ||
| Object.defineProperty(exports, 'useRoute', { | ||
| enumerable: true, | ||
| get: () => _use.useRoute | ||
| }); | ||
| Object.defineProperty(exports, "useRouter", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _use.useRouter; | ||
| } | ||
| Object.defineProperty(exports, 'useRouter', { | ||
| enumerable: true, | ||
| get: () => _use.useRouter | ||
| }); | ||
| var _plugin = require("./plugin.cjs"); | ||
| var _use = require("./use.cjs"); | ||
| var _link = require("./link.cjs"); | ||
| var _view = require("./view.cjs"); | ||
| var _plugin = require('./plugin.cjs'); | ||
| var _use = require('./use.cjs'); | ||
| var _link = require('./link.cjs'); | ||
| var _view = require('./view.cjs'); |
+4
-4
@@ -1,4 +0,4 @@ | ||
| export { RouterVuePlugin } from "./plugin.mjs"; | ||
| export { useRoute, useRouter } from "./use.mjs"; | ||
| export { RouterLink } from "./link.mjs"; | ||
| export { RouterView } from "./view.mjs"; | ||
| export { RouterVuePlugin } from './plugin.mjs'; | ||
| export { useRoute, useRouter } from './use.mjs'; | ||
| export { RouterLink } from './link.mjs'; | ||
| export { RouterView } from './view.mjs'; |
+122
-113
@@ -1,10 +0,10 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| exports.RouterLink = void 0; | ||
| var _router = require("@gez/router"); | ||
| var _vue = require("vue"); | ||
| var _use = require("./use.cjs"); | ||
| var _router = require('@gez/router'); | ||
| var _vue = require('vue'); | ||
| var _use = require('./use.cjs'); | ||
| var __defProp = Object.defineProperty; | ||
@@ -16,118 +16,127 @@ var __defProps = Object.defineProperties; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) : obj[key] = value; | ||
| var __defNormalProp = (obj, key, value) => | ||
| key in obj | ||
| ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) | ||
| : (obj[key] = value); | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
| const RouterLink = exports.RouterLink = (0, _vue.defineComponent)({ | ||
| functional: true, | ||
| props: { | ||
| to: { | ||
| type: [String, Object], | ||
| required: true | ||
| const RouterLink = (exports.RouterLink = (0, _vue.defineComponent)({ | ||
| functional: true, | ||
| props: { | ||
| to: { | ||
| type: [String, Object], | ||
| required: true | ||
| }, | ||
| tag: { | ||
| type: String, | ||
| default: 'a' | ||
| }, | ||
| replace: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| exact: { | ||
| type: String, | ||
| default: 'include' | ||
| }, | ||
| // append: { | ||
| // type: Boolean as PropType<boolean>, | ||
| // default: false | ||
| // }, | ||
| activeClass: { | ||
| type: String, | ||
| default: 'router-link-active' | ||
| }, | ||
| event: { | ||
| type: String, | ||
| default: 'click' | ||
| } | ||
| }, | ||
| tag: { | ||
| type: String, | ||
| default: "a" | ||
| }, | ||
| replace: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| exact: { | ||
| type: String, | ||
| default: "include" | ||
| }, | ||
| // append: { | ||
| // type: Boolean as PropType<boolean>, | ||
| // default: false | ||
| // }, | ||
| activeClass: { | ||
| type: String, | ||
| default: "router-link-active" | ||
| }, | ||
| event: { | ||
| type: String, | ||
| default: "click" | ||
| } | ||
| }, | ||
| render(h, ctx) { | ||
| const { | ||
| to, | ||
| tag, | ||
| replace, | ||
| exact, | ||
| activeClass, | ||
| event | ||
| } = ctx.props; | ||
| const router = (0, _use.useRouter)(); | ||
| const current = (0, _use.useRoute)(); | ||
| const resolveRoute = router.resolve(to); | ||
| let compare; | ||
| switch (exact) { | ||
| case "route": | ||
| compare = _router.isSameRoute; | ||
| break; | ||
| case "exact": | ||
| compare = _router.isEqualRoute; | ||
| break; | ||
| case "include": | ||
| default: | ||
| compare = (current2, route) => { | ||
| return current2.fullPath.startsWith(route.fullPath); | ||
| render(h, ctx) { | ||
| const { to, tag, replace, exact, activeClass, event } = ctx.props; | ||
| const router = (0, _use.useRouter)(); | ||
| const current = (0, _use.useRoute)(); | ||
| const resolveRoute = router.resolve(to); | ||
| let compare; | ||
| switch (exact) { | ||
| case 'route': | ||
| compare = _router.isSameRoute; | ||
| break; | ||
| case 'exact': | ||
| compare = _router.isEqualRoute; | ||
| break; | ||
| case 'include': | ||
| default: | ||
| compare = (current2, route) => { | ||
| return current2.fullPath.startsWith(route.fullPath); | ||
| }; | ||
| break; | ||
| } | ||
| const active = compare(current, resolveRoute); | ||
| const handler = (e) => { | ||
| if (guardEvent(e)) { | ||
| router[replace ? 'replace' : 'push'](to); | ||
| } | ||
| }; | ||
| break; | ||
| const on = {}; | ||
| const eventTypeList = getEventTypeList(event); | ||
| eventTypeList.forEach((eventName) => { | ||
| on[eventName.toLocaleLowerCase()] = handler; | ||
| }); | ||
| const className = | ||
| (ctx.data.class instanceof Array | ||
| ? ctx.data.class | ||
| : [ctx.data.class]) || []; | ||
| return h( | ||
| tag, | ||
| __spreadProps(__spreadValues({}, ctx.data), { | ||
| class: [ | ||
| ...className, | ||
| 'router-link', | ||
| { | ||
| [activeClass]: active | ||
| } | ||
| ], | ||
| attrs: __spreadProps(__spreadValues({}, ctx.data.attrs || {}), { | ||
| href: resolveRoute.fullPath | ||
| }), | ||
| on | ||
| }), | ||
| ctx.children | ||
| ); | ||
| } | ||
| const active = compare(current, resolveRoute); | ||
| const handler = e => { | ||
| if (guardEvent(e)) { | ||
| router[replace ? "replace" : "push"](to); | ||
| } | ||
| }; | ||
| const on = {}; | ||
| const eventTypeList = getEventTypeList(event); | ||
| eventTypeList.forEach(eventName => { | ||
| on[eventName.toLocaleLowerCase()] = handler; | ||
| }); | ||
| const className = (ctx.data.class instanceof Array ? ctx.data.class : [ctx.data.class]) || []; | ||
| return h(tag, __spreadProps(__spreadValues({}, ctx.data), { | ||
| class: [...className, "router-link", { | ||
| [activeClass]: active | ||
| }], | ||
| attrs: __spreadProps(__spreadValues({}, ctx.data.attrs || {}), { | ||
| href: resolveRoute.fullPath | ||
| }), | ||
| on | ||
| }), ctx.children); | ||
| } | ||
| }); | ||
| })); | ||
| function getEventTypeList(eventType) { | ||
| if (eventType instanceof Array) { | ||
| if (eventType.length > 0) { | ||
| return eventType; | ||
| if (eventType instanceof Array) { | ||
| if (eventType.length > 0) { | ||
| return eventType; | ||
| } | ||
| return ['click']; | ||
| } | ||
| return ["click"]; | ||
| } | ||
| return [eventType || "click"]; | ||
| return [eventType || 'click']; | ||
| } | ||
| function guardEvent(e) { | ||
| var _a; | ||
| if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return; | ||
| if (e.defaultPrevented) return; | ||
| if (e.button !== void 0 && e.button !== 0) return; | ||
| if ((_a = e.currentTarget) == null ? void 0 : _a.getAttribute) { | ||
| const target = e.currentTarget.getAttribute("target"); | ||
| if (/\b_blank\b/i.test(target)) return; | ||
| } | ||
| if (e.preventDefault) e.preventDefault(); | ||
| return true; | ||
| } | ||
| var _a; | ||
| if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return; | ||
| if (e.defaultPrevented) return; | ||
| if (e.button !== void 0 && e.button !== 0) return; | ||
| if ((_a = e.currentTarget) == null ? void 0 : _a.getAttribute) { | ||
| const target = e.currentTarget.getAttribute('target'); | ||
| if (/\b_blank\b/i.test(target)) return; | ||
| } | ||
| if (e.preventDefault) e.preventDefault(); | ||
| return true; | ||
| } |
+73
-59
@@ -1,3 +0,3 @@ | ||
| import { type RouterRawLocation } from '@gez/router'; | ||
| import { type PropType } from 'vue'; | ||
| import type { RouterRawLocation } from '@gez/router'; | ||
| import type { PropType } from 'vue'; | ||
| export interface RouterLinkProps { | ||
@@ -45,58 +45,72 @@ /** | ||
| } | ||
| export declare const RouterLink: import("vue/types").DefineComponent<{ | ||
| to: { | ||
| type: PropType<RouterRawLocation>; | ||
| required: true; | ||
| }; | ||
| tag: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| replace: { | ||
| type: PropType<boolean>; | ||
| default: boolean; | ||
| }; | ||
| exact: { | ||
| type: PropType<"include" | "route" | "exact">; | ||
| default: string; | ||
| }; | ||
| activeClass: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| event: { | ||
| type: PropType<string | string[]>; | ||
| default: string; | ||
| }; | ||
| }, {}, {}, import("vue/types").ComponentComputedOptions, import("vue/types").ComponentMethodOptions, import("vue/types").ComponentOptionsMixin, import("vue/types").ComponentOptionsMixin, {}, string, Readonly<import("vue/types").ExtractPropTypes<{ | ||
| to: { | ||
| type: PropType<RouterRawLocation>; | ||
| required: true; | ||
| }; | ||
| tag: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| replace: { | ||
| type: PropType<boolean>; | ||
| default: boolean; | ||
| }; | ||
| exact: { | ||
| type: PropType<"include" | "route" | "exact">; | ||
| default: string; | ||
| }; | ||
| activeClass: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| event: { | ||
| type: PropType<string | string[]>; | ||
| default: string; | ||
| }; | ||
| }>>, { | ||
| exact: "include" | "route" | "exact"; | ||
| tag: string; | ||
| replace: boolean; | ||
| activeClass: string; | ||
| event: string | string[]; | ||
| }>; | ||
| export declare const RouterLink: import('vue/types').DefineComponent< | ||
| { | ||
| to: { | ||
| type: PropType<RouterRawLocation>; | ||
| required: true; | ||
| }; | ||
| tag: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| replace: { | ||
| type: PropType<boolean>; | ||
| default: boolean; | ||
| }; | ||
| exact: { | ||
| type: PropType<'include' | 'route' | 'exact'>; | ||
| default: string; | ||
| }; | ||
| activeClass: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| event: { | ||
| type: PropType<string | string[]>; | ||
| default: string; | ||
| }; | ||
| }, | ||
| {}, | ||
| {}, | ||
| import('vue/types').ComponentComputedOptions, | ||
| import('vue/types').ComponentMethodOptions, | ||
| import('vue/types').ComponentOptionsMixin, | ||
| import('vue/types').ComponentOptionsMixin, | ||
| {}, | ||
| string, | ||
| Readonly< | ||
| import('vue/types').ExtractPropTypes<{ | ||
| to: { | ||
| type: PropType<RouterRawLocation>; | ||
| required: true; | ||
| }; | ||
| tag: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| replace: { | ||
| type: PropType<boolean>; | ||
| default: boolean; | ||
| }; | ||
| exact: { | ||
| type: PropType<'include' | 'route' | 'exact'>; | ||
| default: string; | ||
| }; | ||
| activeClass: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| event: { | ||
| type: PropType<string | string[]>; | ||
| default: string; | ||
| }; | ||
| }> | ||
| >, | ||
| { | ||
| exact: 'include' | 'route' | 'exact'; | ||
| tag: string; | ||
| replace: boolean; | ||
| activeClass: string; | ||
| event: string | string[]; | ||
| } | ||
| >; |
+116
-110
@@ -7,124 +7,130 @@ var __defProp = Object.defineProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __defNormalProp = (obj, key, value) => | ||
| key in obj | ||
| ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) | ||
| : (obj[key] = value); | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
| import { | ||
| isEqualRoute, | ||
| isSameRoute | ||
| } from "@gez/router"; | ||
| import { defineComponent } from "vue"; | ||
| import { useRoute, useRouter } from "./use.mjs"; | ||
| import { isEqualRoute, isSameRoute } from '@gez/router'; | ||
| import { defineComponent } from 'vue'; | ||
| import { useRoute, useRouter } from './use.mjs'; | ||
| export const RouterLink = defineComponent({ | ||
| functional: true, | ||
| props: { | ||
| to: { | ||
| type: [String, Object], | ||
| required: true | ||
| functional: true, | ||
| props: { | ||
| to: { | ||
| type: [String, Object], | ||
| required: true | ||
| }, | ||
| tag: { | ||
| type: String, | ||
| default: 'a' | ||
| }, | ||
| replace: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| exact: { | ||
| type: String, | ||
| default: 'include' | ||
| }, | ||
| // append: { | ||
| // type: Boolean as PropType<boolean>, | ||
| // default: false | ||
| // }, | ||
| activeClass: { | ||
| type: String, | ||
| default: 'router-link-active' | ||
| }, | ||
| event: { | ||
| type: String, | ||
| default: 'click' | ||
| } | ||
| }, | ||
| tag: { | ||
| type: String, | ||
| default: "a" | ||
| }, | ||
| replace: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| exact: { | ||
| type: String, | ||
| default: "include" | ||
| }, | ||
| // append: { | ||
| // type: Boolean as PropType<boolean>, | ||
| // default: false | ||
| // }, | ||
| activeClass: { | ||
| type: String, | ||
| default: "router-link-active" | ||
| }, | ||
| event: { | ||
| type: String, | ||
| default: "click" | ||
| } | ||
| }, | ||
| render(h, ctx) { | ||
| const { to, tag, replace, exact, activeClass, event } = ctx.props; | ||
| const router = useRouter(); | ||
| const current = useRoute(); | ||
| const resolveRoute = router.resolve(to); | ||
| let compare; | ||
| switch (exact) { | ||
| case "route": | ||
| compare = isSameRoute; | ||
| break; | ||
| case "exact": | ||
| compare = isEqualRoute; | ||
| break; | ||
| case "include": | ||
| default: | ||
| compare = (current2, route) => { | ||
| return current2.fullPath.startsWith(route.fullPath); | ||
| render(h, ctx) { | ||
| const { to, tag, replace, exact, activeClass, event } = ctx.props; | ||
| const router = useRouter(); | ||
| const current = useRoute(); | ||
| const resolveRoute = router.resolve(to); | ||
| let compare; | ||
| switch (exact) { | ||
| case 'route': | ||
| compare = isSameRoute; | ||
| break; | ||
| case 'exact': | ||
| compare = isEqualRoute; | ||
| break; | ||
| case 'include': | ||
| default: | ||
| compare = (current2, route) => { | ||
| return current2.fullPath.startsWith(route.fullPath); | ||
| }; | ||
| break; | ||
| } | ||
| const active = compare(current, resolveRoute); | ||
| const handler = (e) => { | ||
| if (guardEvent(e)) { | ||
| router[replace ? 'replace' : 'push'](to); | ||
| } | ||
| }; | ||
| break; | ||
| const on = {}; | ||
| const eventTypeList = getEventTypeList(event); | ||
| eventTypeList.forEach((eventName) => { | ||
| on[eventName.toLocaleLowerCase()] = handler; | ||
| }); | ||
| const className = | ||
| (ctx.data.class instanceof Array | ||
| ? ctx.data.class | ||
| : [ctx.data.class]) || []; | ||
| return h( | ||
| tag, | ||
| __spreadProps(__spreadValues({}, ctx.data), { | ||
| class: [ | ||
| ...className, | ||
| 'router-link', | ||
| { | ||
| [activeClass]: active | ||
| } | ||
| ], | ||
| attrs: __spreadProps(__spreadValues({}, ctx.data.attrs || {}), { | ||
| href: resolveRoute.fullPath | ||
| }), | ||
| on | ||
| }), | ||
| ctx.children | ||
| ); | ||
| } | ||
| const active = compare(current, resolveRoute); | ||
| const handler = (e) => { | ||
| if (guardEvent(e)) { | ||
| router[replace ? "replace" : "push"](to); | ||
| } | ||
| }; | ||
| const on = {}; | ||
| const eventTypeList = getEventTypeList(event); | ||
| eventTypeList.forEach((eventName) => { | ||
| on[eventName.toLocaleLowerCase()] = handler; | ||
| }); | ||
| const className = (ctx.data.class instanceof Array ? ctx.data.class : [ctx.data.class]) || []; | ||
| return h( | ||
| tag, | ||
| __spreadProps(__spreadValues({}, ctx.data), { | ||
| class: [ | ||
| ...className, | ||
| "router-link", | ||
| { | ||
| [activeClass]: active | ||
| } | ||
| ], | ||
| attrs: __spreadProps(__spreadValues({}, ctx.data.attrs || {}), { | ||
| href: resolveRoute.fullPath | ||
| }), | ||
| on | ||
| }), | ||
| ctx.children | ||
| ); | ||
| } | ||
| }); | ||
| function getEventTypeList(eventType) { | ||
| if (eventType instanceof Array) { | ||
| if (eventType.length > 0) { | ||
| return eventType; | ||
| if (eventType instanceof Array) { | ||
| if (eventType.length > 0) { | ||
| return eventType; | ||
| } | ||
| return ['click']; | ||
| } | ||
| return ["click"]; | ||
| } | ||
| return [eventType || "click"]; | ||
| return [eventType || 'click']; | ||
| } | ||
| function guardEvent(e) { | ||
| var _a; | ||
| if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return; | ||
| if (e.defaultPrevented) return; | ||
| if (e.button !== void 0 && e.button !== 0) return; | ||
| if ((_a = e.currentTarget) == null ? void 0 : _a.getAttribute) { | ||
| const target = e.currentTarget.getAttribute("target"); | ||
| if (/\b_blank\b/i.test(target)) return; | ||
| } | ||
| if (e.preventDefault) e.preventDefault(); | ||
| return true; | ||
| var _a; | ||
| if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return; | ||
| if (e.defaultPrevented) return; | ||
| if (e.button !== void 0 && e.button !== 0) return; | ||
| if ((_a = e.currentTarget) == null ? void 0 : _a.getAttribute) { | ||
| const target = e.currentTarget.getAttribute('target'); | ||
| if (/\b_blank\b/i.test(target)) return; | ||
| } | ||
| if (e.preventDefault) e.preventDefault(); | ||
| return true; | ||
| } |
+63
-58
@@ -1,65 +0,70 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| exports.RouterVuePlugin = void 0; | ||
| var _link = require("./link.cjs"); | ||
| var _view = require("./view.cjs"); | ||
| var _link = require('./link.cjs'); | ||
| var _view = require('./view.cjs'); | ||
| var __defProp = Object.defineProperty; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) : obj[key] = value; | ||
| var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
| var __defNormalProp = (obj, key, value) => | ||
| key in obj | ||
| ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) | ||
| : (obj[key] = value); | ||
| var __publicField = (obj, key, value) => | ||
| __defNormalProp(obj, typeof key !== 'symbol' ? key + '' : key, value); | ||
| class RouterVuePlugin { | ||
| static install(Vue) { | ||
| if (this.installed && this._Vue === Vue) return; | ||
| this.installed = true; | ||
| this._Vue = Vue; | ||
| const eventMap = /* @__PURE__ */new WeakMap(); | ||
| Vue.mixin({ | ||
| beforeCreate() { | ||
| if (this.$options.router) { | ||
| this._routerRoot = this; | ||
| this._routerRoot._router = this.$options.router; | ||
| Vue.util.defineReactive(this, "_route", { | ||
| value: this._router.route, | ||
| count: 0 | ||
| }); | ||
| const _event = () => { | ||
| this._route.count++; | ||
| }; | ||
| eventMap.set(this, _event); | ||
| this.$options.router.afterEach(_event); | ||
| } else { | ||
| this.$parent && (this._routerRoot = this.$parent._routerRoot); | ||
| } | ||
| }, | ||
| beforeDestroy() { | ||
| const _event = eventMap.get(this); | ||
| if (_event) { | ||
| this.$router.unBindAfterEach(_event); | ||
| } | ||
| } | ||
| }); | ||
| Vue.component("router-view", _view.RouterView); | ||
| Vue.component("router-link", _link.RouterLink); | ||
| Object.defineProperty(Vue.prototype, "$router", { | ||
| get() { | ||
| return this._routerRoot._router; | ||
| } | ||
| }); | ||
| Object.defineProperty(Vue.prototype, "$route", { | ||
| get() { | ||
| this._routerRoot._route.count; | ||
| return this._routerRoot._route.value; | ||
| } | ||
| }); | ||
| } | ||
| static install(Vue) { | ||
| if (this.installed && this._Vue === Vue) return; | ||
| this.installed = true; | ||
| this._Vue = Vue; | ||
| const eventMap = /* @__PURE__ */ new WeakMap(); | ||
| Vue.mixin({ | ||
| beforeCreate() { | ||
| if (this.$options.router) { | ||
| this._routerRoot = this; | ||
| this._routerRoot._router = this.$options.router; | ||
| Vue.util.defineReactive(this, '_route', { | ||
| value: this._router.route, | ||
| count: 0 | ||
| }); | ||
| const _event = () => { | ||
| this._route.count++; | ||
| }; | ||
| eventMap.set(this, _event); | ||
| this.$options.router.afterEach(_event); | ||
| } else { | ||
| this.$parent && | ||
| (this._routerRoot = this.$parent._routerRoot); | ||
| } | ||
| }, | ||
| beforeDestroy() { | ||
| const _event = eventMap.get(this); | ||
| if (_event) { | ||
| this.$router.unBindAfterEach(_event); | ||
| } | ||
| } | ||
| }); | ||
| Vue.component('router-view', _view.RouterView); | ||
| Vue.component('router-link', _link.RouterLink); | ||
| Object.defineProperty(Vue.prototype, '$router', { | ||
| get() { | ||
| return this._routerRoot._router; | ||
| } | ||
| }); | ||
| Object.defineProperty(Vue.prototype, '$route', { | ||
| get() { | ||
| this._routerRoot._route.count; | ||
| return this._routerRoot._route.value; | ||
| } | ||
| }); | ||
| } | ||
| } | ||
| exports.RouterVuePlugin = RouterVuePlugin; | ||
| __publicField(RouterVuePlugin, "installed"); | ||
| __publicField(RouterVuePlugin, "_Vue"); | ||
| __publicField(RouterVuePlugin, 'installed'); | ||
| __publicField(RouterVuePlugin, '_Vue'); |
+1
-2
| import type { Route, RouterInstance } from '@gez/router'; | ||
| import { type VueConstructor } from 'vue'; | ||
| import type { VueConstructor } from 'vue'; | ||
| interface VueWithRouter extends Vue { | ||
@@ -34,2 +34,1 @@ _routerRoot: VueWithRouter; | ||
| } | ||
| export {}; |
+60
-50
| var __defProp = Object.defineProperty; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
| import { RouterLink } from "./link.mjs"; | ||
| import { RouterView } from "./view.mjs"; | ||
| var __defNormalProp = (obj, key, value) => | ||
| key in obj | ||
| ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) | ||
| : (obj[key] = value); | ||
| var __publicField = (obj, key, value) => | ||
| __defNormalProp(obj, typeof key !== 'symbol' ? key + '' : key, value); | ||
| import { RouterLink } from './link.mjs'; | ||
| import { RouterView } from './view.mjs'; | ||
| export class RouterVuePlugin { | ||
| static install(Vue) { | ||
| if (this.installed && this._Vue === Vue) return; | ||
| this.installed = true; | ||
| this._Vue = Vue; | ||
| const eventMap = /* @__PURE__ */ new WeakMap(); | ||
| Vue.mixin({ | ||
| beforeCreate() { | ||
| if (this.$options.router) { | ||
| this._routerRoot = this; | ||
| this._routerRoot._router = this.$options.router; | ||
| Vue.util.defineReactive(this, "_route", { | ||
| value: this._router.route, | ||
| count: 0 | ||
| }); | ||
| const _event = () => { | ||
| this._route.count++; | ||
| }; | ||
| eventMap.set(this, _event); | ||
| this.$options.router.afterEach(_event); | ||
| } else { | ||
| this.$parent && (this._routerRoot = this.$parent._routerRoot); | ||
| } | ||
| }, | ||
| beforeDestroy() { | ||
| const _event = eventMap.get(this); | ||
| if (_event) { | ||
| this.$router.unBindAfterEach(_event); | ||
| } | ||
| } | ||
| }); | ||
| Vue.component("router-view", RouterView); | ||
| Vue.component("router-link", RouterLink); | ||
| Object.defineProperty(Vue.prototype, "$router", { | ||
| get() { | ||
| return this._routerRoot._router; | ||
| } | ||
| }); | ||
| Object.defineProperty(Vue.prototype, "$route", { | ||
| get() { | ||
| this._routerRoot._route.count; | ||
| return this._routerRoot._route.value; | ||
| } | ||
| }); | ||
| } | ||
| static install(Vue) { | ||
| if (this.installed && this._Vue === Vue) return; | ||
| this.installed = true; | ||
| this._Vue = Vue; | ||
| const eventMap = /* @__PURE__ */ new WeakMap(); | ||
| Vue.mixin({ | ||
| beforeCreate() { | ||
| if (this.$options.router) { | ||
| this._routerRoot = this; | ||
| this._routerRoot._router = this.$options.router; | ||
| Vue.util.defineReactive(this, '_route', { | ||
| value: this._router.route, | ||
| count: 0 | ||
| }); | ||
| const _event = () => { | ||
| this._route.count++; | ||
| }; | ||
| eventMap.set(this, _event); | ||
| this.$options.router.afterEach(_event); | ||
| } else { | ||
| this.$parent && | ||
| (this._routerRoot = this.$parent._routerRoot); | ||
| } | ||
| }, | ||
| beforeDestroy() { | ||
| const _event = eventMap.get(this); | ||
| if (_event) { | ||
| this.$router.unBindAfterEach(_event); | ||
| } | ||
| } | ||
| }); | ||
| Vue.component('router-view', RouterView); | ||
| Vue.component('router-link', RouterLink); | ||
| Object.defineProperty(Vue.prototype, '$router', { | ||
| get() { | ||
| return this._routerRoot._router; | ||
| } | ||
| }); | ||
| Object.defineProperty(Vue.prototype, '$route', { | ||
| get() { | ||
| this._routerRoot._route.count; | ||
| return this._routerRoot._route.value; | ||
| } | ||
| }); | ||
| } | ||
| } | ||
| __publicField(RouterVuePlugin, "installed"); | ||
| __publicField(RouterVuePlugin, "_Vue"); | ||
| __publicField(RouterVuePlugin, 'installed'); | ||
| __publicField(RouterVuePlugin, '_Vue'); |
+20
-18
@@ -1,5 +0,5 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
@@ -9,21 +9,23 @@ exports.throwNoCurrentInstance = throwNoCurrentInstance; | ||
| exports.useRouter = useRouter; | ||
| var _vue = require("vue"); | ||
| var _vue = require('vue'); | ||
| function throwNoCurrentInstance(method) { | ||
| if (!(0, _vue.getCurrentInstance)()) { | ||
| throw new Error(`[router-vue]: Missing current instance. ${method}() must be called inside <script setup> or setup().`); | ||
| } | ||
| if (!(0, _vue.getCurrentInstance)()) { | ||
| throw new Error( | ||
| `[router-vue]: Missing current instance. ${method}() must be called inside <script setup> or setup().` | ||
| ); | ||
| } | ||
| } | ||
| function useRouter() { | ||
| if (process.env.NODE_ENV !== "production") { | ||
| throwNoCurrentInstance("useRouter"); | ||
| } | ||
| const vueInstance = (0, _vue.getCurrentInstance)(); | ||
| return vueInstance.proxy.$root.$router; | ||
| if (process.env.NODE_ENV !== 'production') { | ||
| throwNoCurrentInstance('useRouter'); | ||
| } | ||
| const vueInstance = (0, _vue.getCurrentInstance)(); | ||
| return vueInstance.proxy.$root.$router; | ||
| } | ||
| function useRoute() { | ||
| if (process.env.NODE_ENV !== "production") { | ||
| throwNoCurrentInstance("useRoute"); | ||
| } | ||
| const vueInstance = (0, _vue.getCurrentInstance)(); | ||
| return vueInstance.proxy.$root.$route; | ||
| } | ||
| if (process.env.NODE_ENV !== 'production') { | ||
| throwNoCurrentInstance('useRoute'); | ||
| } | ||
| const vueInstance = (0, _vue.getCurrentInstance)(); | ||
| return vueInstance.proxy.$root.$route; | ||
| } |
+16
-16
@@ -1,22 +0,22 @@ | ||
| import { getCurrentInstance } from "vue"; | ||
| import { getCurrentInstance } from 'vue'; | ||
| export function throwNoCurrentInstance(method) { | ||
| if (!getCurrentInstance()) { | ||
| throw new Error( | ||
| `[router-vue]: Missing current instance. ${method}() must be called inside <script setup> or setup().` | ||
| ); | ||
| } | ||
| if (!getCurrentInstance()) { | ||
| throw new Error( | ||
| `[router-vue]: Missing current instance. ${method}() must be called inside <script setup> or setup().` | ||
| ); | ||
| } | ||
| } | ||
| export function useRouter() { | ||
| if (process.env.NODE_ENV !== "production") { | ||
| throwNoCurrentInstance("useRouter"); | ||
| } | ||
| const vueInstance = getCurrentInstance(); | ||
| return vueInstance.proxy.$root.$router; | ||
| if (process.env.NODE_ENV !== 'production') { | ||
| throwNoCurrentInstance('useRouter'); | ||
| } | ||
| const vueInstance = getCurrentInstance(); | ||
| return vueInstance.proxy.$root.$router; | ||
| } | ||
| export function useRoute() { | ||
| if (process.env.NODE_ENV !== "production") { | ||
| throwNoCurrentInstance("useRoute"); | ||
| } | ||
| const vueInstance = getCurrentInstance(); | ||
| return vueInstance.proxy.$root.$route; | ||
| if (process.env.NODE_ENV !== 'production') { | ||
| throwNoCurrentInstance('useRoute'); | ||
| } | ||
| const vueInstance = getCurrentInstance(); | ||
| return vueInstance.proxy.$root.$route; | ||
| } |
+22
-32
@@ -1,39 +0,29 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| Object.defineProperty(exports, "RouterLink", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _link.RouterLink; | ||
| } | ||
| Object.defineProperty(exports, 'RouterLink', { | ||
| enumerable: true, | ||
| get: () => _link.RouterLink | ||
| }); | ||
| Object.defineProperty(exports, "RouterView", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _view.RouterView; | ||
| } | ||
| Object.defineProperty(exports, 'RouterView', { | ||
| enumerable: true, | ||
| get: () => _view.RouterView | ||
| }); | ||
| Object.defineProperty(exports, "RouterVuePlugin", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _plugin.RouterVuePlugin; | ||
| } | ||
| Object.defineProperty(exports, 'RouterVuePlugin', { | ||
| enumerable: true, | ||
| get: () => _plugin.RouterVuePlugin | ||
| }); | ||
| Object.defineProperty(exports, "useRoute", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _use.useRoute; | ||
| } | ||
| Object.defineProperty(exports, 'useRoute', { | ||
| enumerable: true, | ||
| get: () => _use.useRoute | ||
| }); | ||
| Object.defineProperty(exports, "useRouter", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _use.useRouter; | ||
| } | ||
| Object.defineProperty(exports, 'useRouter', { | ||
| enumerable: true, | ||
| get: () => _use.useRouter | ||
| }); | ||
| var _plugin = require("./plugin.cjs"); | ||
| var _use = require("./use.cjs"); | ||
| var _link = require("./link.cjs"); | ||
| var _view = require("./view.cjs"); | ||
| var _plugin = require('./plugin.cjs'); | ||
| var _use = require('./use.cjs'); | ||
| var _link = require('./link.cjs'); | ||
| var _view = require('./view.cjs'); |
+4
-4
@@ -1,4 +0,4 @@ | ||
| export { RouterVuePlugin } from "./plugin.mjs"; | ||
| export { useRoute, useRouter } from "./use.mjs"; | ||
| export { RouterLink } from "./link.mjs"; | ||
| export { RouterView } from "./view.mjs"; | ||
| export { RouterVuePlugin } from './plugin.mjs'; | ||
| export { useRoute, useRouter } from './use.mjs'; | ||
| export { RouterLink } from './link.mjs'; | ||
| export { RouterView } from './view.mjs'; |
+122
-113
@@ -1,10 +0,10 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| exports.RouterLink = void 0; | ||
| var _router = require("@gez/router"); | ||
| var _vue = require("vue"); | ||
| var _use = require("./use.cjs"); | ||
| var _router = require('@gez/router'); | ||
| var _vue = require('vue'); | ||
| var _use = require('./use.cjs'); | ||
| var __defProp = Object.defineProperty; | ||
@@ -16,118 +16,127 @@ var __defProps = Object.defineProperties; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) : obj[key] = value; | ||
| var __defNormalProp = (obj, key, value) => | ||
| key in obj | ||
| ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) | ||
| : (obj[key] = value); | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
| const RouterLink = exports.RouterLink = (0, _vue.defineComponent)({ | ||
| functional: true, | ||
| props: { | ||
| to: { | ||
| type: [String, Object], | ||
| required: true | ||
| const RouterLink = (exports.RouterLink = (0, _vue.defineComponent)({ | ||
| functional: true, | ||
| props: { | ||
| to: { | ||
| type: [String, Object], | ||
| required: true | ||
| }, | ||
| tag: { | ||
| type: String, | ||
| default: 'a' | ||
| }, | ||
| replace: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| exact: { | ||
| type: String, | ||
| default: 'include' | ||
| }, | ||
| // append: { | ||
| // type: Boolean as PropType<boolean>, | ||
| // default: false | ||
| // }, | ||
| activeClass: { | ||
| type: String, | ||
| default: 'router-link-active' | ||
| }, | ||
| event: { | ||
| type: String, | ||
| default: 'click' | ||
| } | ||
| }, | ||
| tag: { | ||
| type: String, | ||
| default: "a" | ||
| }, | ||
| replace: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| exact: { | ||
| type: String, | ||
| default: "include" | ||
| }, | ||
| // append: { | ||
| // type: Boolean as PropType<boolean>, | ||
| // default: false | ||
| // }, | ||
| activeClass: { | ||
| type: String, | ||
| default: "router-link-active" | ||
| }, | ||
| event: { | ||
| type: String, | ||
| default: "click" | ||
| } | ||
| }, | ||
| render(h, ctx) { | ||
| const { | ||
| to, | ||
| tag, | ||
| replace, | ||
| exact, | ||
| activeClass, | ||
| event | ||
| } = ctx.props; | ||
| const router = (0, _use.useRouter)(); | ||
| const current = (0, _use.useRoute)(); | ||
| const resolveRoute = router.resolve(to); | ||
| let compare; | ||
| switch (exact) { | ||
| case "route": | ||
| compare = _router.isSameRoute; | ||
| break; | ||
| case "exact": | ||
| compare = _router.isEqualRoute; | ||
| break; | ||
| case "include": | ||
| default: | ||
| compare = (current2, route) => { | ||
| return current2.fullPath.startsWith(route.fullPath); | ||
| render(h, ctx) { | ||
| const { to, tag, replace, exact, activeClass, event } = ctx.props; | ||
| const router = (0, _use.useRouter)(); | ||
| const current = (0, _use.useRoute)(); | ||
| const resolveRoute = router.resolve(to); | ||
| let compare; | ||
| switch (exact) { | ||
| case 'route': | ||
| compare = _router.isSameRoute; | ||
| break; | ||
| case 'exact': | ||
| compare = _router.isEqualRoute; | ||
| break; | ||
| case 'include': | ||
| default: | ||
| compare = (current2, route) => { | ||
| return current2.fullPath.startsWith(route.fullPath); | ||
| }; | ||
| break; | ||
| } | ||
| const active = compare(current, resolveRoute); | ||
| const handler = (e) => { | ||
| if (guardEvent(e)) { | ||
| router[replace ? 'replace' : 'push'](to); | ||
| } | ||
| }; | ||
| break; | ||
| const on = {}; | ||
| const eventTypeList = getEventTypeList(event); | ||
| eventTypeList.forEach((eventName) => { | ||
| on[eventName.toLocaleLowerCase()] = handler; | ||
| }); | ||
| const className = | ||
| (ctx.data.class instanceof Array | ||
| ? ctx.data.class | ||
| : [ctx.data.class]) || []; | ||
| return h( | ||
| tag, | ||
| __spreadProps(__spreadValues({}, ctx.data), { | ||
| class: [ | ||
| ...className, | ||
| 'router-link', | ||
| { | ||
| [activeClass]: active | ||
| } | ||
| ], | ||
| attrs: __spreadProps(__spreadValues({}, ctx.data.attrs || {}), { | ||
| href: resolveRoute.fullPath | ||
| }), | ||
| on | ||
| }), | ||
| ctx.children | ||
| ); | ||
| } | ||
| const active = compare(current, resolveRoute); | ||
| const handler = e => { | ||
| if (guardEvent(e)) { | ||
| router[replace ? "replace" : "push"](to); | ||
| } | ||
| }; | ||
| const on = {}; | ||
| const eventTypeList = getEventTypeList(event); | ||
| eventTypeList.forEach(eventName => { | ||
| on[eventName.toLocaleLowerCase()] = handler; | ||
| }); | ||
| const className = (ctx.data.class instanceof Array ? ctx.data.class : [ctx.data.class]) || []; | ||
| return h(tag, __spreadProps(__spreadValues({}, ctx.data), { | ||
| class: [...className, "router-link", { | ||
| [activeClass]: active | ||
| }], | ||
| attrs: __spreadProps(__spreadValues({}, ctx.data.attrs || {}), { | ||
| href: resolveRoute.fullPath | ||
| }), | ||
| on | ||
| }), ctx.children); | ||
| } | ||
| }); | ||
| })); | ||
| function getEventTypeList(eventType) { | ||
| if (eventType instanceof Array) { | ||
| if (eventType.length > 0) { | ||
| return eventType; | ||
| if (eventType instanceof Array) { | ||
| if (eventType.length > 0) { | ||
| return eventType; | ||
| } | ||
| return ['click']; | ||
| } | ||
| return ["click"]; | ||
| } | ||
| return [eventType || "click"]; | ||
| return [eventType || 'click']; | ||
| } | ||
| function guardEvent(e) { | ||
| var _a; | ||
| if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return; | ||
| if (e.defaultPrevented) return; | ||
| if (e.button !== void 0 && e.button !== 0) return; | ||
| if ((_a = e.currentTarget) == null ? void 0 : _a.getAttribute) { | ||
| const target = e.currentTarget.getAttribute("target"); | ||
| if (/\b_blank\b/i.test(target)) return; | ||
| } | ||
| if (e.preventDefault) e.preventDefault(); | ||
| return true; | ||
| } | ||
| var _a; | ||
| if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return; | ||
| if (e.defaultPrevented) return; | ||
| if (e.button !== void 0 && e.button !== 0) return; | ||
| if ((_a = e.currentTarget) == null ? void 0 : _a.getAttribute) { | ||
| const target = e.currentTarget.getAttribute('target'); | ||
| if (/\b_blank\b/i.test(target)) return; | ||
| } | ||
| if (e.preventDefault) e.preventDefault(); | ||
| return true; | ||
| } |
+73
-59
@@ -1,3 +0,3 @@ | ||
| import { type RouterRawLocation } from '@gez/router'; | ||
| import { type PropType } from 'vue'; | ||
| import type { RouterRawLocation } from '@gez/router'; | ||
| import type { PropType } from 'vue'; | ||
| export interface RouterLinkProps { | ||
@@ -45,58 +45,72 @@ /** | ||
| } | ||
| export declare const RouterLink: import("vue/types").DefineComponent<{ | ||
| to: { | ||
| type: PropType<RouterRawLocation>; | ||
| required: true; | ||
| }; | ||
| tag: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| replace: { | ||
| type: PropType<boolean>; | ||
| default: boolean; | ||
| }; | ||
| exact: { | ||
| type: PropType<"include" | "route" | "exact">; | ||
| default: string; | ||
| }; | ||
| activeClass: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| event: { | ||
| type: PropType<string | string[]>; | ||
| default: string; | ||
| }; | ||
| }, {}, {}, import("vue/types").ComponentComputedOptions, import("vue/types").ComponentMethodOptions, import("vue/types").ComponentOptionsMixin, import("vue/types").ComponentOptionsMixin, {}, string, Readonly<import("vue/types").ExtractPropTypes<{ | ||
| to: { | ||
| type: PropType<RouterRawLocation>; | ||
| required: true; | ||
| }; | ||
| tag: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| replace: { | ||
| type: PropType<boolean>; | ||
| default: boolean; | ||
| }; | ||
| exact: { | ||
| type: PropType<"include" | "route" | "exact">; | ||
| default: string; | ||
| }; | ||
| activeClass: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| event: { | ||
| type: PropType<string | string[]>; | ||
| default: string; | ||
| }; | ||
| }>>, { | ||
| exact: "include" | "route" | "exact"; | ||
| tag: string; | ||
| replace: boolean; | ||
| activeClass: string; | ||
| event: string | string[]; | ||
| }>; | ||
| export declare const RouterLink: import('vue/types').DefineComponent< | ||
| { | ||
| to: { | ||
| type: PropType<RouterRawLocation>; | ||
| required: true; | ||
| }; | ||
| tag: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| replace: { | ||
| type: PropType<boolean>; | ||
| default: boolean; | ||
| }; | ||
| exact: { | ||
| type: PropType<'include' | 'route' | 'exact'>; | ||
| default: string; | ||
| }; | ||
| activeClass: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| event: { | ||
| type: PropType<string | string[]>; | ||
| default: string; | ||
| }; | ||
| }, | ||
| {}, | ||
| {}, | ||
| import('vue/types').ComponentComputedOptions, | ||
| import('vue/types').ComponentMethodOptions, | ||
| import('vue/types').ComponentOptionsMixin, | ||
| import('vue/types').ComponentOptionsMixin, | ||
| {}, | ||
| string, | ||
| Readonly< | ||
| import('vue/types').ExtractPropTypes<{ | ||
| to: { | ||
| type: PropType<RouterRawLocation>; | ||
| required: true; | ||
| }; | ||
| tag: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| replace: { | ||
| type: PropType<boolean>; | ||
| default: boolean; | ||
| }; | ||
| exact: { | ||
| type: PropType<'include' | 'route' | 'exact'>; | ||
| default: string; | ||
| }; | ||
| activeClass: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| event: { | ||
| type: PropType<string | string[]>; | ||
| default: string; | ||
| }; | ||
| }> | ||
| >, | ||
| { | ||
| exact: 'include' | 'route' | 'exact'; | ||
| tag: string; | ||
| replace: boolean; | ||
| activeClass: string; | ||
| event: string | string[]; | ||
| } | ||
| >; |
+116
-110
@@ -7,124 +7,130 @@ var __defProp = Object.defineProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __defNormalProp = (obj, key, value) => | ||
| key in obj | ||
| ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) | ||
| : (obj[key] = value); | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
| import { | ||
| isEqualRoute, | ||
| isSameRoute | ||
| } from "@gez/router"; | ||
| import { defineComponent } from "vue"; | ||
| import { useRoute, useRouter } from "./use.mjs"; | ||
| import { isEqualRoute, isSameRoute } from '@gez/router'; | ||
| import { defineComponent } from 'vue'; | ||
| import { useRoute, useRouter } from './use.mjs'; | ||
| export const RouterLink = defineComponent({ | ||
| functional: true, | ||
| props: { | ||
| to: { | ||
| type: [String, Object], | ||
| required: true | ||
| functional: true, | ||
| props: { | ||
| to: { | ||
| type: [String, Object], | ||
| required: true | ||
| }, | ||
| tag: { | ||
| type: String, | ||
| default: 'a' | ||
| }, | ||
| replace: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| exact: { | ||
| type: String, | ||
| default: 'include' | ||
| }, | ||
| // append: { | ||
| // type: Boolean as PropType<boolean>, | ||
| // default: false | ||
| // }, | ||
| activeClass: { | ||
| type: String, | ||
| default: 'router-link-active' | ||
| }, | ||
| event: { | ||
| type: String, | ||
| default: 'click' | ||
| } | ||
| }, | ||
| tag: { | ||
| type: String, | ||
| default: "a" | ||
| }, | ||
| replace: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| exact: { | ||
| type: String, | ||
| default: "include" | ||
| }, | ||
| // append: { | ||
| // type: Boolean as PropType<boolean>, | ||
| // default: false | ||
| // }, | ||
| activeClass: { | ||
| type: String, | ||
| default: "router-link-active" | ||
| }, | ||
| event: { | ||
| type: String, | ||
| default: "click" | ||
| } | ||
| }, | ||
| render(h, ctx) { | ||
| const { to, tag, replace, exact, activeClass, event } = ctx.props; | ||
| const router = useRouter(); | ||
| const current = useRoute(); | ||
| const resolveRoute = router.resolve(to); | ||
| let compare; | ||
| switch (exact) { | ||
| case "route": | ||
| compare = isSameRoute; | ||
| break; | ||
| case "exact": | ||
| compare = isEqualRoute; | ||
| break; | ||
| case "include": | ||
| default: | ||
| compare = (current2, route) => { | ||
| return current2.fullPath.startsWith(route.fullPath); | ||
| render(h, ctx) { | ||
| const { to, tag, replace, exact, activeClass, event } = ctx.props; | ||
| const router = useRouter(); | ||
| const current = useRoute(); | ||
| const resolveRoute = router.resolve(to); | ||
| let compare; | ||
| switch (exact) { | ||
| case 'route': | ||
| compare = isSameRoute; | ||
| break; | ||
| case 'exact': | ||
| compare = isEqualRoute; | ||
| break; | ||
| case 'include': | ||
| default: | ||
| compare = (current2, route) => { | ||
| return current2.fullPath.startsWith(route.fullPath); | ||
| }; | ||
| break; | ||
| } | ||
| const active = compare(current, resolveRoute); | ||
| const handler = (e) => { | ||
| if (guardEvent(e)) { | ||
| router[replace ? 'replace' : 'push'](to); | ||
| } | ||
| }; | ||
| break; | ||
| const on = {}; | ||
| const eventTypeList = getEventTypeList(event); | ||
| eventTypeList.forEach((eventName) => { | ||
| on[eventName.toLocaleLowerCase()] = handler; | ||
| }); | ||
| const className = | ||
| (ctx.data.class instanceof Array | ||
| ? ctx.data.class | ||
| : [ctx.data.class]) || []; | ||
| return h( | ||
| tag, | ||
| __spreadProps(__spreadValues({}, ctx.data), { | ||
| class: [ | ||
| ...className, | ||
| 'router-link', | ||
| { | ||
| [activeClass]: active | ||
| } | ||
| ], | ||
| attrs: __spreadProps(__spreadValues({}, ctx.data.attrs || {}), { | ||
| href: resolveRoute.fullPath | ||
| }), | ||
| on | ||
| }), | ||
| ctx.children | ||
| ); | ||
| } | ||
| const active = compare(current, resolveRoute); | ||
| const handler = (e) => { | ||
| if (guardEvent(e)) { | ||
| router[replace ? "replace" : "push"](to); | ||
| } | ||
| }; | ||
| const on = {}; | ||
| const eventTypeList = getEventTypeList(event); | ||
| eventTypeList.forEach((eventName) => { | ||
| on[eventName.toLocaleLowerCase()] = handler; | ||
| }); | ||
| const className = (ctx.data.class instanceof Array ? ctx.data.class : [ctx.data.class]) || []; | ||
| return h( | ||
| tag, | ||
| __spreadProps(__spreadValues({}, ctx.data), { | ||
| class: [ | ||
| ...className, | ||
| "router-link", | ||
| { | ||
| [activeClass]: active | ||
| } | ||
| ], | ||
| attrs: __spreadProps(__spreadValues({}, ctx.data.attrs || {}), { | ||
| href: resolveRoute.fullPath | ||
| }), | ||
| on | ||
| }), | ||
| ctx.children | ||
| ); | ||
| } | ||
| }); | ||
| function getEventTypeList(eventType) { | ||
| if (eventType instanceof Array) { | ||
| if (eventType.length > 0) { | ||
| return eventType; | ||
| if (eventType instanceof Array) { | ||
| if (eventType.length > 0) { | ||
| return eventType; | ||
| } | ||
| return ['click']; | ||
| } | ||
| return ["click"]; | ||
| } | ||
| return [eventType || "click"]; | ||
| return [eventType || 'click']; | ||
| } | ||
| function guardEvent(e) { | ||
| var _a; | ||
| if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return; | ||
| if (e.defaultPrevented) return; | ||
| if (e.button !== void 0 && e.button !== 0) return; | ||
| if ((_a = e.currentTarget) == null ? void 0 : _a.getAttribute) { | ||
| const target = e.currentTarget.getAttribute("target"); | ||
| if (/\b_blank\b/i.test(target)) return; | ||
| } | ||
| if (e.preventDefault) e.preventDefault(); | ||
| return true; | ||
| var _a; | ||
| if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return; | ||
| if (e.defaultPrevented) return; | ||
| if (e.button !== void 0 && e.button !== 0) return; | ||
| if ((_a = e.currentTarget) == null ? void 0 : _a.getAttribute) { | ||
| const target = e.currentTarget.getAttribute('target'); | ||
| if (/\b_blank\b/i.test(target)) return; | ||
| } | ||
| if (e.preventDefault) e.preventDefault(); | ||
| return true; | ||
| } |
+63
-58
@@ -1,65 +0,70 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| exports.RouterVuePlugin = void 0; | ||
| var _link = require("./link.cjs"); | ||
| var _view = require("./view.cjs"); | ||
| var _link = require('./link.cjs'); | ||
| var _view = require('./view.cjs'); | ||
| var __defProp = Object.defineProperty; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) : obj[key] = value; | ||
| var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
| var __defNormalProp = (obj, key, value) => | ||
| key in obj | ||
| ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) | ||
| : (obj[key] = value); | ||
| var __publicField = (obj, key, value) => | ||
| __defNormalProp(obj, typeof key !== 'symbol' ? key + '' : key, value); | ||
| class RouterVuePlugin { | ||
| static install(Vue) { | ||
| if (this.installed && this._Vue === Vue) return; | ||
| this.installed = true; | ||
| this._Vue = Vue; | ||
| const eventMap = /* @__PURE__ */new WeakMap(); | ||
| Vue.mixin({ | ||
| beforeCreate() { | ||
| if (this.$options.router) { | ||
| this._routerRoot = this; | ||
| this._routerRoot._router = this.$options.router; | ||
| Vue.util.defineReactive(this, "_route", { | ||
| value: this._router.route, | ||
| count: 0 | ||
| }); | ||
| const _event = () => { | ||
| this._route.count++; | ||
| }; | ||
| eventMap.set(this, _event); | ||
| this.$options.router.afterEach(_event); | ||
| } else { | ||
| this.$parent && (this._routerRoot = this.$parent._routerRoot); | ||
| } | ||
| }, | ||
| beforeDestroy() { | ||
| const _event = eventMap.get(this); | ||
| if (_event) { | ||
| this.$router.unBindAfterEach(_event); | ||
| } | ||
| } | ||
| }); | ||
| Vue.component("router-view", _view.RouterView); | ||
| Vue.component("router-link", _link.RouterLink); | ||
| Object.defineProperty(Vue.prototype, "$router", { | ||
| get() { | ||
| return this._routerRoot._router; | ||
| } | ||
| }); | ||
| Object.defineProperty(Vue.prototype, "$route", { | ||
| get() { | ||
| this._routerRoot._route.count; | ||
| return this._routerRoot._route.value; | ||
| } | ||
| }); | ||
| } | ||
| static install(Vue) { | ||
| if (this.installed && this._Vue === Vue) return; | ||
| this.installed = true; | ||
| this._Vue = Vue; | ||
| const eventMap = /* @__PURE__ */ new WeakMap(); | ||
| Vue.mixin({ | ||
| beforeCreate() { | ||
| if (this.$options.router) { | ||
| this._routerRoot = this; | ||
| this._routerRoot._router = this.$options.router; | ||
| Vue.util.defineReactive(this, '_route', { | ||
| value: this._router.route, | ||
| count: 0 | ||
| }); | ||
| const _event = () => { | ||
| this._route.count++; | ||
| }; | ||
| eventMap.set(this, _event); | ||
| this.$options.router.afterEach(_event); | ||
| } else { | ||
| this.$parent && | ||
| (this._routerRoot = this.$parent._routerRoot); | ||
| } | ||
| }, | ||
| beforeDestroy() { | ||
| const _event = eventMap.get(this); | ||
| if (_event) { | ||
| this.$router.unBindAfterEach(_event); | ||
| } | ||
| } | ||
| }); | ||
| Vue.component('router-view', _view.RouterView); | ||
| Vue.component('router-link', _link.RouterLink); | ||
| Object.defineProperty(Vue.prototype, '$router', { | ||
| get() { | ||
| return this._routerRoot._router; | ||
| } | ||
| }); | ||
| Object.defineProperty(Vue.prototype, '$route', { | ||
| get() { | ||
| this._routerRoot._route.count; | ||
| return this._routerRoot._route.value; | ||
| } | ||
| }); | ||
| } | ||
| } | ||
| exports.RouterVuePlugin = RouterVuePlugin; | ||
| __publicField(RouterVuePlugin, "installed"); | ||
| __publicField(RouterVuePlugin, "_Vue"); | ||
| __publicField(RouterVuePlugin, 'installed'); | ||
| __publicField(RouterVuePlugin, '_Vue'); |
| import type { Route, RouterInstance } from '@gez/router'; | ||
| import { type VueConstructor } from 'vue'; | ||
| import type { VueConstructor } from 'vue'; | ||
| interface VueWithRouter extends Vue { | ||
@@ -34,2 +34,1 @@ _routerRoot: VueWithRouter; | ||
| } | ||
| export {}; |
+60
-50
| var __defProp = Object.defineProperty; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
| import { RouterLink } from "./link.mjs"; | ||
| import { RouterView } from "./view.mjs"; | ||
| var __defNormalProp = (obj, key, value) => | ||
| key in obj | ||
| ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) | ||
| : (obj[key] = value); | ||
| var __publicField = (obj, key, value) => | ||
| __defNormalProp(obj, typeof key !== 'symbol' ? key + '' : key, value); | ||
| import { RouterLink } from './link.mjs'; | ||
| import { RouterView } from './view.mjs'; | ||
| export class RouterVuePlugin { | ||
| static install(Vue) { | ||
| if (this.installed && this._Vue === Vue) return; | ||
| this.installed = true; | ||
| this._Vue = Vue; | ||
| const eventMap = /* @__PURE__ */ new WeakMap(); | ||
| Vue.mixin({ | ||
| beforeCreate() { | ||
| if (this.$options.router) { | ||
| this._routerRoot = this; | ||
| this._routerRoot._router = this.$options.router; | ||
| Vue.util.defineReactive(this, "_route", { | ||
| value: this._router.route, | ||
| count: 0 | ||
| }); | ||
| const _event = () => { | ||
| this._route.count++; | ||
| }; | ||
| eventMap.set(this, _event); | ||
| this.$options.router.afterEach(_event); | ||
| } else { | ||
| this.$parent && (this._routerRoot = this.$parent._routerRoot); | ||
| } | ||
| }, | ||
| beforeDestroy() { | ||
| const _event = eventMap.get(this); | ||
| if (_event) { | ||
| this.$router.unBindAfterEach(_event); | ||
| } | ||
| } | ||
| }); | ||
| Vue.component("router-view", RouterView); | ||
| Vue.component("router-link", RouterLink); | ||
| Object.defineProperty(Vue.prototype, "$router", { | ||
| get() { | ||
| return this._routerRoot._router; | ||
| } | ||
| }); | ||
| Object.defineProperty(Vue.prototype, "$route", { | ||
| get() { | ||
| this._routerRoot._route.count; | ||
| return this._routerRoot._route.value; | ||
| } | ||
| }); | ||
| } | ||
| static install(Vue) { | ||
| if (this.installed && this._Vue === Vue) return; | ||
| this.installed = true; | ||
| this._Vue = Vue; | ||
| const eventMap = /* @__PURE__ */ new WeakMap(); | ||
| Vue.mixin({ | ||
| beforeCreate() { | ||
| if (this.$options.router) { | ||
| this._routerRoot = this; | ||
| this._routerRoot._router = this.$options.router; | ||
| Vue.util.defineReactive(this, '_route', { | ||
| value: this._router.route, | ||
| count: 0 | ||
| }); | ||
| const _event = () => { | ||
| this._route.count++; | ||
| }; | ||
| eventMap.set(this, _event); | ||
| this.$options.router.afterEach(_event); | ||
| } else { | ||
| this.$parent && | ||
| (this._routerRoot = this.$parent._routerRoot); | ||
| } | ||
| }, | ||
| beforeDestroy() { | ||
| const _event = eventMap.get(this); | ||
| if (_event) { | ||
| this.$router.unBindAfterEach(_event); | ||
| } | ||
| } | ||
| }); | ||
| Vue.component('router-view', RouterView); | ||
| Vue.component('router-link', RouterLink); | ||
| Object.defineProperty(Vue.prototype, '$router', { | ||
| get() { | ||
| return this._routerRoot._router; | ||
| } | ||
| }); | ||
| Object.defineProperty(Vue.prototype, '$route', { | ||
| get() { | ||
| this._routerRoot._route.count; | ||
| return this._routerRoot._route.value; | ||
| } | ||
| }); | ||
| } | ||
| } | ||
| __publicField(RouterVuePlugin, "installed"); | ||
| __publicField(RouterVuePlugin, "_Vue"); | ||
| __publicField(RouterVuePlugin, 'installed'); | ||
| __publicField(RouterVuePlugin, '_Vue'); |
+20
-18
@@ -1,5 +0,5 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
@@ -9,21 +9,23 @@ exports.throwNoCurrentInstance = throwNoCurrentInstance; | ||
| exports.useRouter = useRouter; | ||
| var _vue = require("vue"); | ||
| var _vue = require('vue'); | ||
| function throwNoCurrentInstance(method) { | ||
| if (!(0, _vue.getCurrentInstance)()) { | ||
| throw new Error(`[router-vue]: Missing current instance. ${method}() must be called inside <script setup> or setup().`); | ||
| } | ||
| if (!(0, _vue.getCurrentInstance)()) { | ||
| throw new Error( | ||
| `[router-vue]: Missing current instance. ${method}() must be called inside <script setup> or setup().` | ||
| ); | ||
| } | ||
| } | ||
| function useRouter() { | ||
| if (process.env.NODE_ENV !== "production") { | ||
| throwNoCurrentInstance("useRouter"); | ||
| } | ||
| const vueInstance = (0, _vue.getCurrentInstance)(); | ||
| return vueInstance.proxy.$root.$router; | ||
| if (process.env.NODE_ENV !== 'production') { | ||
| throwNoCurrentInstance('useRouter'); | ||
| } | ||
| const vueInstance = (0, _vue.getCurrentInstance)(); | ||
| return vueInstance.proxy.$root.$router; | ||
| } | ||
| function useRoute() { | ||
| if (process.env.NODE_ENV !== "production") { | ||
| throwNoCurrentInstance("useRoute"); | ||
| } | ||
| const vueInstance = (0, _vue.getCurrentInstance)(); | ||
| return vueInstance.proxy.$root.$route; | ||
| } | ||
| if (process.env.NODE_ENV !== 'production') { | ||
| throwNoCurrentInstance('useRoute'); | ||
| } | ||
| const vueInstance = (0, _vue.getCurrentInstance)(); | ||
| return vueInstance.proxy.$root.$route; | ||
| } |
+16
-16
@@ -1,22 +0,22 @@ | ||
| import { getCurrentInstance } from "vue"; | ||
| import { getCurrentInstance } from 'vue'; | ||
| export function throwNoCurrentInstance(method) { | ||
| if (!getCurrentInstance()) { | ||
| throw new Error( | ||
| `[router-vue]: Missing current instance. ${method}() must be called inside <script setup> or setup().` | ||
| ); | ||
| } | ||
| if (!getCurrentInstance()) { | ||
| throw new Error( | ||
| `[router-vue]: Missing current instance. ${method}() must be called inside <script setup> or setup().` | ||
| ); | ||
| } | ||
| } | ||
| export function useRouter() { | ||
| if (process.env.NODE_ENV !== "production") { | ||
| throwNoCurrentInstance("useRouter"); | ||
| } | ||
| const vueInstance = getCurrentInstance(); | ||
| return vueInstance.proxy.$root.$router; | ||
| if (process.env.NODE_ENV !== 'production') { | ||
| throwNoCurrentInstance('useRouter'); | ||
| } | ||
| const vueInstance = getCurrentInstance(); | ||
| return vueInstance.proxy.$root.$router; | ||
| } | ||
| export function useRoute() { | ||
| if (process.env.NODE_ENV !== "production") { | ||
| throwNoCurrentInstance("useRoute"); | ||
| } | ||
| const vueInstance = getCurrentInstance(); | ||
| return vueInstance.proxy.$root.$route; | ||
| if (process.env.NODE_ENV !== 'production') { | ||
| throwNoCurrentInstance('useRoute'); | ||
| } | ||
| const vueInstance = getCurrentInstance(); | ||
| return vueInstance.proxy.$root.$route; | ||
| } |
+29
-30
@@ -1,34 +0,33 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| exports.RouterView = void 0; | ||
| var _vue = require("vue"); | ||
| const RouterView = exports.RouterView = (0, _vue.defineComponent)({ | ||
| functional: true, | ||
| render(h, ctx) { | ||
| var _a; | ||
| ctx.data.dataView = true; | ||
| let { | ||
| parent | ||
| } = ctx; | ||
| const { | ||
| data | ||
| } = ctx; | ||
| const route = parent.$route; | ||
| let depth = 0; | ||
| while (parent && parent._routerRoot !== parent) { | ||
| const vnodeData = ((_a = parent == null ? void 0 : parent.$vnode) == null ? void 0 : _a.data) || {}; | ||
| if (vnodeData.dataView) { | ||
| depth++; | ||
| } | ||
| parent.$parent && (parent = parent.$parent); | ||
| var _vue = require('vue'); | ||
| const RouterView = (exports.RouterView = (0, _vue.defineComponent)({ | ||
| functional: true, | ||
| render(h, ctx) { | ||
| var _a; | ||
| ctx.data.dataView = true; | ||
| let { parent } = ctx; | ||
| const { data } = ctx; | ||
| const route = parent.$route; | ||
| let depth = 0; | ||
| while (parent && parent._routerRoot !== parent) { | ||
| const vnodeData = | ||
| ((_a = parent == null ? void 0 : parent.$vnode) == null | ||
| ? void 0 | ||
| : _a.data) || {}; | ||
| if (vnodeData.dataView) { | ||
| depth++; | ||
| } | ||
| parent.$parent && (parent = parent.$parent); | ||
| } | ||
| const matchRoute = route.matched[depth]; | ||
| if (!matchRoute) { | ||
| return h(); | ||
| } | ||
| return h(matchRoute.component || matchRoute.asyncComponent, data); | ||
| } | ||
| const matchRoute = route.matched[depth]; | ||
| if (!matchRoute) { | ||
| return h(); | ||
| } | ||
| return h(matchRoute.component || matchRoute.asyncComponent, data); | ||
| } | ||
| }); | ||
| })); |
+23
-7
@@ -6,8 +6,24 @@ declare module 'vue/types' { | ||
| } | ||
| export declare const RouterView: import("vue/types").DefineComponent<Readonly<{ | ||
| [x: string]: any; | ||
| }>, {}, {}, import("vue/types").ComponentComputedOptions, import("vue/types").ComponentMethodOptions, import("vue/types").ComponentOptionsMixin, import("vue/types").ComponentOptionsMixin, {}, string, Readonly<import("vue/types").ExtractPropTypes<Readonly<{ | ||
| [x: string]: any; | ||
| }>>>, { | ||
| readonly [x: string]: any; | ||
| }>; | ||
| export declare const RouterView: import('vue/types').DefineComponent< | ||
| Readonly<{ | ||
| [x: string]: any; | ||
| }>, | ||
| {}, | ||
| {}, | ||
| import('vue/types').ComponentComputedOptions, | ||
| import('vue/types').ComponentMethodOptions, | ||
| import('vue/types').ComponentOptionsMixin, | ||
| import('vue/types').ComponentOptionsMixin, | ||
| {}, | ||
| string, | ||
| Readonly< | ||
| import('vue/types').ExtractPropTypes< | ||
| Readonly<{ | ||
| [x: string]: any; | ||
| }> | ||
| > | ||
| >, | ||
| { | ||
| readonly [x: string]: any; | ||
| } | ||
| >; |
+24
-21
@@ -1,24 +0,27 @@ | ||
| import { defineComponent } from "vue"; | ||
| import { defineComponent } from 'vue'; | ||
| export const RouterView = defineComponent({ | ||
| functional: true, | ||
| render(h, ctx) { | ||
| var _a; | ||
| ctx.data.dataView = true; | ||
| let { parent } = ctx; | ||
| const { data } = ctx; | ||
| const route = parent.$route; | ||
| let depth = 0; | ||
| while (parent && parent._routerRoot !== parent) { | ||
| const vnodeData = ((_a = parent == null ? void 0 : parent.$vnode) == null ? void 0 : _a.data) || {}; | ||
| if (vnodeData.dataView) { | ||
| depth++; | ||
| } | ||
| parent.$parent && (parent = parent.$parent); | ||
| functional: true, | ||
| render(h, ctx) { | ||
| var _a; | ||
| ctx.data.dataView = true; | ||
| let { parent } = ctx; | ||
| const { data } = ctx; | ||
| const route = parent.$route; | ||
| let depth = 0; | ||
| while (parent && parent._routerRoot !== parent) { | ||
| const vnodeData = | ||
| ((_a = parent == null ? void 0 : parent.$vnode) == null | ||
| ? void 0 | ||
| : _a.data) || {}; | ||
| if (vnodeData.dataView) { | ||
| depth++; | ||
| } | ||
| parent.$parent && (parent = parent.$parent); | ||
| } | ||
| const matchRoute = route.matched[depth]; | ||
| if (!matchRoute) { | ||
| return h(); | ||
| } | ||
| return h(matchRoute.component || matchRoute.asyncComponent, data); | ||
| } | ||
| const matchRoute = route.matched[depth]; | ||
| if (!matchRoute) { | ||
| return h(); | ||
| } | ||
| return h(matchRoute.component || matchRoute.asyncComponent, data); | ||
| } | ||
| }); |
+22
-32
@@ -1,39 +0,29 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| Object.defineProperty(exports, "RouterLink", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _link.RouterLink; | ||
| } | ||
| Object.defineProperty(exports, 'RouterLink', { | ||
| enumerable: true, | ||
| get: () => _link.RouterLink | ||
| }); | ||
| Object.defineProperty(exports, "RouterView", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _view.RouterView; | ||
| } | ||
| Object.defineProperty(exports, 'RouterView', { | ||
| enumerable: true, | ||
| get: () => _view.RouterView | ||
| }); | ||
| Object.defineProperty(exports, "RouterVuePlugin", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _plugin.RouterVuePlugin; | ||
| } | ||
| Object.defineProperty(exports, 'RouterVuePlugin', { | ||
| enumerable: true, | ||
| get: () => _plugin.RouterVuePlugin | ||
| }); | ||
| Object.defineProperty(exports, "useRoute", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _use.useRoute; | ||
| } | ||
| Object.defineProperty(exports, 'useRoute', { | ||
| enumerable: true, | ||
| get: () => _use.useRoute | ||
| }); | ||
| Object.defineProperty(exports, "useRouter", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _use.useRouter; | ||
| } | ||
| Object.defineProperty(exports, 'useRouter', { | ||
| enumerable: true, | ||
| get: () => _use.useRouter | ||
| }); | ||
| var _plugin = require("./plugin.cjs"); | ||
| var _use = require("./use.cjs"); | ||
| var _link = require("./link.cjs"); | ||
| var _view = require("./view.cjs"); | ||
| var _plugin = require('./plugin.cjs'); | ||
| var _use = require('./use.cjs'); | ||
| var _link = require('./link.cjs'); | ||
| var _view = require('./view.cjs'); |
+4
-4
@@ -1,4 +0,4 @@ | ||
| export { RouterVuePlugin } from "./plugin.mjs"; | ||
| export { useRouter, useRoute } from "./use.mjs"; | ||
| export { RouterLink } from "./link.mjs"; | ||
| export { RouterView } from "./view.mjs"; | ||
| export { RouterVuePlugin } from './plugin.mjs'; | ||
| export { useRouter, useRoute } from './use.mjs'; | ||
| export { RouterLink } from './link.mjs'; | ||
| export { RouterView } from './view.mjs'; |
+111
-106
@@ -1,10 +0,10 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| exports.RouterLink = void 0; | ||
| var _router = require("@gez/router"); | ||
| var _vue = require("vue"); | ||
| var _use = require("./use.cjs"); | ||
| var _router = require('@gez/router'); | ||
| var _vue = require('vue'); | ||
| var _use = require('./use.cjs'); | ||
| var __defProp = Object.defineProperty; | ||
@@ -14,110 +14,115 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) : obj[key] = value; | ||
| var __defNormalProp = (obj, key, value) => | ||
| key in obj | ||
| ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) | ||
| : (obj[key] = value); | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| const RouterLink = exports.RouterLink = (0, _vue.defineComponent)({ | ||
| props: { | ||
| to: { | ||
| type: [String, Object], | ||
| required: true | ||
| const RouterLink = (exports.RouterLink = (0, _vue.defineComponent)({ | ||
| props: { | ||
| to: { | ||
| type: [String, Object], | ||
| required: true | ||
| }, | ||
| tag: { | ||
| type: String, | ||
| default: 'a' | ||
| }, | ||
| replace: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| exact: { | ||
| type: String, | ||
| default: 'include' | ||
| }, | ||
| // append: { | ||
| // type: Boolean as PropType<boolean>, | ||
| // default: false | ||
| // }, | ||
| activeClass: { | ||
| type: String, | ||
| default: 'router-link-active' | ||
| }, | ||
| event: { | ||
| type: String, | ||
| default: 'click' | ||
| } | ||
| }, | ||
| tag: { | ||
| type: String, | ||
| default: "a" | ||
| }, | ||
| replace: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| exact: { | ||
| type: String, | ||
| default: "include" | ||
| }, | ||
| // append: { | ||
| // type: Boolean as PropType<boolean>, | ||
| // default: false | ||
| // }, | ||
| activeClass: { | ||
| type: String, | ||
| default: "router-link-active" | ||
| }, | ||
| event: { | ||
| type: String, | ||
| default: "click" | ||
| } | ||
| }, | ||
| render(props) { | ||
| const { | ||
| to, | ||
| tag, | ||
| replace, | ||
| exact, | ||
| activeClass, | ||
| event | ||
| } = props; | ||
| const router = (0, _use.useRouter)(); | ||
| const current = (0, _use.useRoute)(); | ||
| const resolveRoute = router.resolve(to); | ||
| let compare; | ||
| switch (exact) { | ||
| case "route": | ||
| compare = _router.isSameRoute; | ||
| break; | ||
| case "exact": | ||
| compare = _router.isEqualRoute; | ||
| break; | ||
| case "include": | ||
| default: | ||
| compare = (current2, route) => { | ||
| return current2.fullPath.startsWith(route.fullPath); | ||
| render(props) { | ||
| const { to, tag, replace, exact, activeClass, event } = props; | ||
| const router = (0, _use.useRouter)(); | ||
| const current = (0, _use.useRoute)(); | ||
| const resolveRoute = router.resolve(to); | ||
| let compare; | ||
| switch (exact) { | ||
| case 'route': | ||
| compare = _router.isSameRoute; | ||
| break; | ||
| case 'exact': | ||
| compare = _router.isEqualRoute; | ||
| break; | ||
| case 'include': | ||
| default: | ||
| compare = (current2, route) => { | ||
| return current2.fullPath.startsWith(route.fullPath); | ||
| }; | ||
| break; | ||
| } | ||
| const active = compare(current, resolveRoute); | ||
| const handler = (e) => { | ||
| if (guardEvent(e)) { | ||
| router[replace ? 'replace' : 'push'](to); | ||
| } | ||
| }; | ||
| break; | ||
| const on = {}; | ||
| const eventTypeList = getEventTypeList(event); | ||
| eventTypeList.forEach((eventName) => { | ||
| on[`on${eventName.toLocaleLowerCase()}`] = handler; | ||
| }); | ||
| return (0, _vue.h)( | ||
| tag, | ||
| __spreadValues( | ||
| { | ||
| class: ['router-link', active ? [activeClass] : ''], | ||
| href: resolveRoute.fullPath | ||
| }, | ||
| on | ||
| ), | ||
| this.$slots | ||
| ); | ||
| } | ||
| const active = compare(current, resolveRoute); | ||
| const handler = e => { | ||
| if (guardEvent(e)) { | ||
| router[replace ? "replace" : "push"](to); | ||
| } | ||
| }; | ||
| const on = {}; | ||
| const eventTypeList = getEventTypeList(event); | ||
| eventTypeList.forEach(eventName => { | ||
| on[`on${eventName.toLocaleLowerCase()}`] = handler; | ||
| }); | ||
| return (0, _vue.h)(tag, __spreadValues({ | ||
| class: ["router-link", active ? [activeClass] : ""], | ||
| href: resolveRoute.fullPath | ||
| }, on), this.$slots); | ||
| } | ||
| }); | ||
| })); | ||
| function getEventTypeList(eventType) { | ||
| if (eventType instanceof Array) { | ||
| if (eventType.length > 0) { | ||
| return eventType; | ||
| if (eventType instanceof Array) { | ||
| if (eventType.length > 0) { | ||
| return eventType; | ||
| } | ||
| return ['click']; | ||
| } | ||
| return ["click"]; | ||
| } | ||
| return [eventType || "click"]; | ||
| return [eventType || 'click']; | ||
| } | ||
| function guardEvent(e) { | ||
| var _a; | ||
| if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return; | ||
| if (e.defaultPrevented) return; | ||
| if (e.button !== void 0 && e.button !== 0) return; | ||
| if ((_a = e.currentTarget) == null ? void 0 : _a.getAttribute) { | ||
| const target = e.currentTarget.getAttribute("target"); | ||
| if (/\b_blank\b/i.test(target)) return; | ||
| } | ||
| if (e.preventDefault) e.preventDefault(); | ||
| return true; | ||
| } | ||
| var _a; | ||
| if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return; | ||
| if (e.defaultPrevented) return; | ||
| if (e.button !== void 0 && e.button !== 0) return; | ||
| if ((_a = e.currentTarget) == null ? void 0 : _a.getAttribute) { | ||
| const target = e.currentTarget.getAttribute('target'); | ||
| if (/\b_blank\b/i.test(target)) return; | ||
| } | ||
| if (e.preventDefault) e.preventDefault(); | ||
| return true; | ||
| } |
+75
-59
@@ -1,3 +0,3 @@ | ||
| import { type RouterRawLocation } from '@gez/router'; | ||
| import { type PropType } from 'vue'; | ||
| import type { RouterRawLocation } from '@gez/router'; | ||
| import type { PropType } from 'vue'; | ||
| export interface RouterLinkProps { | ||
@@ -45,58 +45,74 @@ /** | ||
| } | ||
| export declare const RouterLink: import("vue").DefineComponent<{ | ||
| to: { | ||
| type: PropType<RouterRawLocation>; | ||
| required: true; | ||
| }; | ||
| tag: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| replace: { | ||
| type: PropType<boolean>; | ||
| default: boolean; | ||
| }; | ||
| exact: { | ||
| type: PropType<"include" | "route" | "exact">; | ||
| default: string; | ||
| }; | ||
| activeClass: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| event: { | ||
| type: PropType<string | string[]>; | ||
| default: string; | ||
| }; | ||
| }, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{ | ||
| to: { | ||
| type: PropType<RouterRawLocation>; | ||
| required: true; | ||
| }; | ||
| tag: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| replace: { | ||
| type: PropType<boolean>; | ||
| default: boolean; | ||
| }; | ||
| exact: { | ||
| type: PropType<"include" | "route" | "exact">; | ||
| default: string; | ||
| }; | ||
| activeClass: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| event: { | ||
| type: PropType<string | string[]>; | ||
| default: string; | ||
| }; | ||
| }>>, { | ||
| exact: "include" | "route" | "exact"; | ||
| tag: string; | ||
| replace: boolean; | ||
| activeClass: string; | ||
| event: string | string[]; | ||
| }, {}>; | ||
| export declare const RouterLink: import('vue').DefineComponent< | ||
| { | ||
| to: { | ||
| type: PropType<RouterRawLocation>; | ||
| required: true; | ||
| }; | ||
| tag: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| replace: { | ||
| type: PropType<boolean>; | ||
| default: boolean; | ||
| }; | ||
| exact: { | ||
| type: PropType<'include' | 'route' | 'exact'>; | ||
| default: string; | ||
| }; | ||
| activeClass: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| event: { | ||
| type: PropType<string | string[]>; | ||
| default: string; | ||
| }; | ||
| }, | ||
| unknown, | ||
| unknown, | ||
| {}, | ||
| {}, | ||
| import('vue').ComponentOptionsMixin, | ||
| import('vue').ComponentOptionsMixin, | ||
| {}, | ||
| string, | ||
| import('vue').PublicProps, | ||
| Readonly< | ||
| import('vue').ExtractPropTypes<{ | ||
| to: { | ||
| type: PropType<RouterRawLocation>; | ||
| required: true; | ||
| }; | ||
| tag: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| replace: { | ||
| type: PropType<boolean>; | ||
| default: boolean; | ||
| }; | ||
| exact: { | ||
| type: PropType<'include' | 'route' | 'exact'>; | ||
| default: string; | ||
| }; | ||
| activeClass: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| event: { | ||
| type: PropType<string | string[]>; | ||
| default: string; | ||
| }; | ||
| }> | ||
| >, | ||
| { | ||
| exact: 'include' | 'route' | 'exact'; | ||
| tag: string; | ||
| replace: boolean; | ||
| activeClass: string; | ||
| event: string | string[]; | ||
| }, | ||
| {} | ||
| >; |
+105
-99
@@ -5,112 +5,118 @@ var __defProp = Object.defineProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __defNormalProp = (obj, key, value) => | ||
| key in obj | ||
| ? __defProp(obj, key, { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value | ||
| }) | ||
| : (obj[key] = value); | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| import { | ||
| isEqualRoute, | ||
| isSameRoute | ||
| } from "@gez/router"; | ||
| import { defineComponent, h } from "vue"; | ||
| import { useRoute, useRouter } from "./use.mjs"; | ||
| import { isEqualRoute, isSameRoute } from '@gez/router'; | ||
| import { defineComponent, h } from 'vue'; | ||
| import { useRoute, useRouter } from './use.mjs'; | ||
| export const RouterLink = defineComponent({ | ||
| props: { | ||
| to: { | ||
| type: [String, Object], | ||
| required: true | ||
| props: { | ||
| to: { | ||
| type: [String, Object], | ||
| required: true | ||
| }, | ||
| tag: { | ||
| type: String, | ||
| default: 'a' | ||
| }, | ||
| replace: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| exact: { | ||
| type: String, | ||
| default: 'include' | ||
| }, | ||
| // append: { | ||
| // type: Boolean as PropType<boolean>, | ||
| // default: false | ||
| // }, | ||
| activeClass: { | ||
| type: String, | ||
| default: 'router-link-active' | ||
| }, | ||
| event: { | ||
| type: String, | ||
| default: 'click' | ||
| } | ||
| }, | ||
| tag: { | ||
| type: String, | ||
| default: "a" | ||
| }, | ||
| replace: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| exact: { | ||
| type: String, | ||
| default: "include" | ||
| }, | ||
| // append: { | ||
| // type: Boolean as PropType<boolean>, | ||
| // default: false | ||
| // }, | ||
| activeClass: { | ||
| type: String, | ||
| default: "router-link-active" | ||
| }, | ||
| event: { | ||
| type: String, | ||
| default: "click" | ||
| } | ||
| }, | ||
| render(props) { | ||
| const { to, tag, replace, exact, activeClass, event } = props; | ||
| const router = useRouter(); | ||
| const current = useRoute(); | ||
| const resolveRoute = router.resolve(to); | ||
| let compare; | ||
| switch (exact) { | ||
| case "route": | ||
| compare = isSameRoute; | ||
| break; | ||
| case "exact": | ||
| compare = isEqualRoute; | ||
| break; | ||
| case "include": | ||
| default: | ||
| compare = (current2, route) => { | ||
| return current2.fullPath.startsWith(route.fullPath); | ||
| render(props) { | ||
| const { to, tag, replace, exact, activeClass, event } = props; | ||
| const router = useRouter(); | ||
| const current = useRoute(); | ||
| const resolveRoute = router.resolve(to); | ||
| let compare; | ||
| switch (exact) { | ||
| case 'route': | ||
| compare = isSameRoute; | ||
| break; | ||
| case 'exact': | ||
| compare = isEqualRoute; | ||
| break; | ||
| case 'include': | ||
| default: | ||
| compare = (current2, route) => { | ||
| return current2.fullPath.startsWith(route.fullPath); | ||
| }; | ||
| break; | ||
| } | ||
| const active = compare(current, resolveRoute); | ||
| const handler = (e) => { | ||
| if (guardEvent(e)) { | ||
| router[replace ? 'replace' : 'push'](to); | ||
| } | ||
| }; | ||
| break; | ||
| const on = {}; | ||
| const eventTypeList = getEventTypeList(event); | ||
| eventTypeList.forEach((eventName) => { | ||
| on[`on${eventName.toLocaleLowerCase()}`] = handler; | ||
| }); | ||
| return h( | ||
| tag, | ||
| __spreadValues( | ||
| { | ||
| class: ['router-link', active ? [activeClass] : ''], | ||
| href: resolveRoute.fullPath | ||
| }, | ||
| on | ||
| ), | ||
| this.$slots | ||
| ); | ||
| } | ||
| const active = compare(current, resolveRoute); | ||
| const handler = (e) => { | ||
| if (guardEvent(e)) { | ||
| router[replace ? "replace" : "push"](to); | ||
| } | ||
| }; | ||
| const on = {}; | ||
| const eventTypeList = getEventTypeList(event); | ||
| eventTypeList.forEach((eventName) => { | ||
| on[`on${eventName.toLocaleLowerCase()}`] = handler; | ||
| }); | ||
| return h( | ||
| tag, | ||
| __spreadValues({ | ||
| class: ["router-link", active ? [activeClass] : ""], | ||
| href: resolveRoute.fullPath | ||
| }, on), | ||
| this.$slots | ||
| ); | ||
| } | ||
| }); | ||
| function getEventTypeList(eventType) { | ||
| if (eventType instanceof Array) { | ||
| if (eventType.length > 0) { | ||
| return eventType; | ||
| if (eventType instanceof Array) { | ||
| if (eventType.length > 0) { | ||
| return eventType; | ||
| } | ||
| return ['click']; | ||
| } | ||
| return ["click"]; | ||
| } | ||
| return [eventType || "click"]; | ||
| return [eventType || 'click']; | ||
| } | ||
| function guardEvent(e) { | ||
| var _a; | ||
| if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return; | ||
| if (e.defaultPrevented) return; | ||
| if (e.button !== void 0 && e.button !== 0) return; | ||
| if ((_a = e.currentTarget) == null ? void 0 : _a.getAttribute) { | ||
| const target = e.currentTarget.getAttribute("target"); | ||
| if (/\b_blank\b/i.test(target)) return; | ||
| } | ||
| if (e.preventDefault) e.preventDefault(); | ||
| return true; | ||
| var _a; | ||
| if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return; | ||
| if (e.defaultPrevented) return; | ||
| if (e.button !== void 0 && e.button !== 0) return; | ||
| if ((_a = e.currentTarget) == null ? void 0 : _a.getAttribute) { | ||
| const target = e.currentTarget.getAttribute('target'); | ||
| if (/\b_blank\b/i.test(target)) return; | ||
| } | ||
| if (e.preventDefault) e.preventDefault(); | ||
| return true; | ||
| } |
+21
-18
@@ -1,22 +0,25 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| exports.RouterVuePlugin = RouterVuePlugin; | ||
| var _vue = require("vue"); | ||
| var _link = require("./link.cjs"); | ||
| var _symbols = require("./symbols.cjs"); | ||
| var _view = require("./view.cjs"); | ||
| var _vue = require('vue'); | ||
| var _link = require('./link.cjs'); | ||
| var _symbols = require('./symbols.cjs'); | ||
| var _view = require('./view.cjs'); | ||
| function RouterVuePlugin(router) { | ||
| return function install(app) { | ||
| const route = (0, _vue.shallowReactive)(router.route); | ||
| router.route = route; | ||
| app.config.globalProperties.$router = router; | ||
| app.config.globalProperties.$route = router.route; | ||
| app.provide(_symbols.routerKey, (0, _vue.unref)(router)); | ||
| app.provide(_symbols.routerViewLocationKey, (0, _vue.unref)(router.route)); | ||
| app.component("router-view", _view.RouterView); | ||
| app.component("router-link", _link.RouterLink); | ||
| }; | ||
| } | ||
| return function install(app) { | ||
| const route = (0, _vue.shallowReactive)(router.route); | ||
| router.route = route; | ||
| app.config.globalProperties.$router = router; | ||
| app.config.globalProperties.$route = router.route; | ||
| app.provide(_symbols.routerKey, (0, _vue.unref)(router)); | ||
| app.provide( | ||
| _symbols.routerViewLocationKey, | ||
| (0, _vue.unref)(router.route) | ||
| ); | ||
| app.component('router-view', _view.RouterView); | ||
| app.component('router-link', _link.RouterLink); | ||
| }; | ||
| } |
| import type { Route, RouterInstance } from '@gez/router'; | ||
| import { type App, type ShallowReactive } from 'vue'; | ||
| import type { App, ShallowReactive } from 'vue'; | ||
| declare module '@vue/runtime-core' { | ||
@@ -8,5 +8,6 @@ interface ComponentCustomProperties { | ||
| } | ||
| interface GlobalComponents { | ||
| } | ||
| interface GlobalComponents {} | ||
| } | ||
| export declare function RouterVuePlugin(router: RouterInstance): (app: App) => void; | ||
| export declare function RouterVuePlugin( | ||
| router: RouterInstance | ||
| ): (app: App) => void; |
+14
-14
@@ -1,16 +0,16 @@ | ||
| import { shallowReactive, unref } from "vue"; | ||
| import { RouterLink } from "./link.mjs"; | ||
| import { routerKey, routerViewLocationKey } from "./symbols.mjs"; | ||
| import { RouterView } from "./view.mjs"; | ||
| import { shallowReactive, unref } from 'vue'; | ||
| import { RouterLink } from './link.mjs'; | ||
| import { routerKey, routerViewLocationKey } from './symbols.mjs'; | ||
| import { RouterView } from './view.mjs'; | ||
| export function RouterVuePlugin(router) { | ||
| return function install(app) { | ||
| const route = shallowReactive(router.route); | ||
| router.route = route; | ||
| app.config.globalProperties.$router = router; | ||
| app.config.globalProperties.$route = router.route; | ||
| app.provide(routerKey, unref(router)); | ||
| app.provide(routerViewLocationKey, unref(router.route)); | ||
| app.component("router-view", RouterView); | ||
| app.component("router-link", RouterLink); | ||
| }; | ||
| return function install(app) { | ||
| const route = shallowReactive(router.route); | ||
| router.route = route; | ||
| app.config.globalProperties.$router = router; | ||
| app.config.globalProperties.$route = router.route; | ||
| app.provide(routerKey, unref(router)); | ||
| app.provide(routerViewLocationKey, unref(router.route)); | ||
| app.component('router-view', RouterView); | ||
| app.component('router-link', RouterLink); | ||
| }; | ||
| } |
+12
-7
@@ -1,9 +0,14 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| exports.routerViewLocationKey = exports.routerViewDepthKey = exports.routerKey = void 0; | ||
| const routerKey = exports.routerKey = Symbol("routerViewLocation"); | ||
| const routerViewLocationKey = exports.routerViewLocationKey = Symbol("routerViewLocation"); | ||
| const routerViewDepthKey = exports.routerViewDepthKey = Symbol("routerViewDepth"); | ||
| exports.routerViewLocationKey = | ||
| exports.routerViewDepthKey = | ||
| exports.routerKey = | ||
| void 0; | ||
| const routerKey = (exports.routerKey = Symbol('routerViewLocation')); | ||
| const routerViewLocationKey = (exports.routerViewLocationKey = | ||
| Symbol('routerViewLocation')); | ||
| const routerViewDepthKey = (exports.routerViewDepthKey = | ||
| Symbol('routerViewDepth')); |
@@ -1,3 +0,3 @@ | ||
| export const routerKey = Symbol("routerViewLocation"); | ||
| export const routerViewLocationKey = Symbol("routerViewLocation"); | ||
| export const routerViewDepthKey = Symbol("routerViewDepth"); | ||
| export const routerKey = Symbol('routerViewLocation'); | ||
| export const routerViewLocationKey = Symbol('routerViewLocation'); | ||
| export const routerViewDepthKey = Symbol('routerViewDepth'); |
+13
-11
@@ -1,5 +0,5 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
@@ -9,14 +9,16 @@ exports.throwNoCurrentInstance = throwNoCurrentInstance; | ||
| exports.useRouter = useRouter; | ||
| var _vue = require("vue"); | ||
| var _symbols = require("./symbols.cjs"); | ||
| var _vue = require('vue'); | ||
| var _symbols = require('./symbols.cjs'); | ||
| function throwNoCurrentInstance(method) { | ||
| if (!(0, _vue.getCurrentInstance)()) { | ||
| throw new Error(`[router-vue]: Missing current instance. ${method}() must be called inside <script setup> or setup().`); | ||
| } | ||
| if (!(0, _vue.getCurrentInstance)()) { | ||
| throw new Error( | ||
| `[router-vue]: Missing current instance. ${method}() must be called inside <script setup> or setup().` | ||
| ); | ||
| } | ||
| } | ||
| function useRouter() { | ||
| return (0, _vue.inject)(_symbols.routerKey); | ||
| return (0, _vue.inject)(_symbols.routerKey); | ||
| } | ||
| function useRoute() { | ||
| return (0, _vue.inject)(_symbols.routerViewLocationKey); | ||
| } | ||
| return (0, _vue.inject)(_symbols.routerViewLocationKey); | ||
| } |
+9
-9
@@ -1,15 +0,15 @@ | ||
| import { getCurrentInstance, inject } from "vue"; | ||
| import { routerKey, routerViewLocationKey } from "./symbols.mjs"; | ||
| import { getCurrentInstance, inject } from 'vue'; | ||
| import { routerKey, routerViewLocationKey } from './symbols.mjs'; | ||
| export function throwNoCurrentInstance(method) { | ||
| if (!getCurrentInstance()) { | ||
| throw new Error( | ||
| `[router-vue]: Missing current instance. ${method}() must be called inside <script setup> or setup().` | ||
| ); | ||
| } | ||
| if (!getCurrentInstance()) { | ||
| throw new Error( | ||
| `[router-vue]: Missing current instance. ${method}() must be called inside <script setup> or setup().` | ||
| ); | ||
| } | ||
| } | ||
| export function useRouter() { | ||
| return inject(routerKey); | ||
| return inject(routerKey); | ||
| } | ||
| export function useRoute() { | ||
| return inject(routerViewLocationKey); | ||
| return inject(routerViewLocationKey); | ||
| } |
+75
-63
@@ -1,69 +0,81 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| exports.RouterView = void 0; | ||
| var _vue = require("vue"); | ||
| var _symbols = require("./symbols.cjs"); | ||
| const RouterView = exports.RouterView = (0, _vue.defineComponent)({ | ||
| name: "RouterView", | ||
| inheritAttrs: true, | ||
| props: { | ||
| name: { | ||
| type: String, | ||
| default: "default" | ||
| var _vue = require('vue'); | ||
| var _symbols = require('./symbols.cjs'); | ||
| const RouterView = (exports.RouterView = (0, _vue.defineComponent)({ | ||
| name: 'RouterView', | ||
| inheritAttrs: true, | ||
| props: { | ||
| name: { | ||
| type: String, | ||
| default: 'default' | ||
| }, | ||
| route: Object | ||
| }, | ||
| route: Object | ||
| }, | ||
| // Better compat for @vue/compat users | ||
| // https://github.com/vuejs/router/issues/1315 | ||
| compatConfig: { | ||
| MODE: 3 | ||
| }, | ||
| setup: (props, { | ||
| attrs, | ||
| slots | ||
| }) => { | ||
| const instance = (0, _vue.getCurrentInstance)(); | ||
| if (!instance) { | ||
| console.error("no current instance"); | ||
| return; | ||
| // Better compat for @vue/compat users | ||
| // https://github.com/vuejs/router/issues/1315 | ||
| compatConfig: { | ||
| MODE: 3 | ||
| }, | ||
| setup: (props, { attrs, slots }) => { | ||
| const instance = (0, _vue.getCurrentInstance)(); | ||
| if (!instance) { | ||
| console.error('no current instance'); | ||
| return; | ||
| } | ||
| const injectedRoute = (0, _vue.inject)(_symbols.routerViewLocationKey); | ||
| const routeToDisplay = (0, _vue.computed)( | ||
| () => props.route || injectedRoute | ||
| ); | ||
| const injectedDepth = (0, _vue.inject)( | ||
| _symbols.routerViewDepthKey, | ||
| (0, _vue.computed)(() => 0) | ||
| ); | ||
| const depth = (0, _vue.computed)(() => { | ||
| let initialDepth = injectedDepth.value; | ||
| const { matched } = routeToDisplay.value; | ||
| let matchedRoute; | ||
| while ( | ||
| (matchedRoute = matched[initialDepth]) && | ||
| !(matchedRoute == null ? void 0 : matchedRoute.component) | ||
| ) { | ||
| initialDepth++; | ||
| } | ||
| return initialDepth; | ||
| }); | ||
| (0, _vue.provide)( | ||
| _symbols.routerViewLocationKey, | ||
| (0, _vue.shallowReactive)(routeToDisplay.value) | ||
| ); | ||
| (0, _vue.provide)( | ||
| _symbols.routerViewDepthKey, | ||
| (0, _vue.computed)(() => depth.value + 1) | ||
| ); | ||
| return () => { | ||
| const matchRoute = routeToDisplay.value.matched[depth.value]; | ||
| if (!matchRoute) { | ||
| return null; | ||
| } | ||
| const component = (0, _vue.h)( | ||
| matchRoute.component, | ||
| Object.assign({}, props, attrs) | ||
| ); | ||
| return ( | ||
| // pass the vnode to the slot as a prop. | ||
| // h and <component :is="..."> both accept vnodes | ||
| normalizeSlot(slots.default, { | ||
| Component: component | ||
| }) || component | ||
| ); | ||
| }; | ||
| } | ||
| const injectedRoute = (0, _vue.inject)(_symbols.routerViewLocationKey); | ||
| const routeToDisplay = (0, _vue.computed)(() => props.route || injectedRoute); | ||
| const injectedDepth = (0, _vue.inject)(_symbols.routerViewDepthKey, (0, _vue.computed)(() => 0)); | ||
| const depth = (0, _vue.computed)(() => { | ||
| let initialDepth = injectedDepth.value; | ||
| const { | ||
| matched | ||
| } = routeToDisplay.value; | ||
| let matchedRoute; | ||
| while ((matchedRoute = matched[initialDepth]) && !(matchedRoute == null ? void 0 : matchedRoute.component)) { | ||
| initialDepth++; | ||
| } | ||
| return initialDepth; | ||
| }); | ||
| (0, _vue.provide)(_symbols.routerViewLocationKey, (0, _vue.shallowReactive)(routeToDisplay.value)); | ||
| (0, _vue.provide)(_symbols.routerViewDepthKey, (0, _vue.computed)(() => depth.value + 1)); | ||
| return () => { | ||
| const matchRoute = routeToDisplay.value.matched[depth.value]; | ||
| if (!matchRoute) { | ||
| return null; | ||
| } | ||
| const component = (0, _vue.h)(matchRoute.component, Object.assign({}, props, attrs)); | ||
| return ( | ||
| // pass the vnode to the slot as a prop. | ||
| // h and <component :is="..."> both accept vnodes | ||
| normalizeSlot(slots.default, { | ||
| Component: component | ||
| }) || component | ||
| ); | ||
| }; | ||
| } | ||
| }); | ||
| })); | ||
| function normalizeSlot(slot, data) { | ||
| if (!slot) return null; | ||
| const slotContent = slot(data); | ||
| return slotContent.length === 1 ? slotContent[0] : slotContent; | ||
| } | ||
| if (!slot) return null; | ||
| const slotContent = slot(data); | ||
| return slotContent.length === 1 ? slotContent[0] : slotContent; | ||
| } |
+49
-21
@@ -1,21 +0,49 @@ | ||
| import { type Route } from '@gez/router'; | ||
| import { type PropType } from 'vue'; | ||
| export declare const RouterView: import("vue").DefineComponent<{ | ||
| name: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| route: PropType<Route>; | ||
| }, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { | ||
| [key: string]: any; | ||
| }> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { | ||
| [key: string]: any; | ||
| }>[] | null) | undefined, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{ | ||
| name: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| route: PropType<Route>; | ||
| }>>, { | ||
| name: string; | ||
| }, {}>; | ||
| import type { Route } from '@gez/router'; | ||
| import type { PropType } from 'vue'; | ||
| export declare const RouterView: import('vue').DefineComponent< | ||
| { | ||
| name: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| route: PropType<Route>; | ||
| }, | ||
| | (() => | ||
| | import('vue').VNode< | ||
| import('vue').RendererNode, | ||
| import('vue').RendererElement, | ||
| { | ||
| [key: string]: any; | ||
| } | ||
| > | ||
| | import('vue').VNode< | ||
| import('vue').RendererNode, | ||
| import('vue').RendererElement, | ||
| { | ||
| [key: string]: any; | ||
| } | ||
| >[] | ||
| | null) | ||
| | undefined, | ||
| unknown, | ||
| {}, | ||
| {}, | ||
| import('vue').ComponentOptionsMixin, | ||
| import('vue').ComponentOptionsMixin, | ||
| {}, | ||
| string, | ||
| import('vue').PublicProps, | ||
| Readonly< | ||
| import('vue').ExtractPropTypes<{ | ||
| name: { | ||
| type: PropType<string>; | ||
| default: string; | ||
| }; | ||
| route: PropType<Route>; | ||
| }> | ||
| >, | ||
| { | ||
| name: string; | ||
| }, | ||
| {} | ||
| >; |
+68
-68
| import { | ||
| computed, | ||
| defineComponent, | ||
| getCurrentInstance, | ||
| h, | ||
| inject, | ||
| provide, | ||
| shallowReactive | ||
| } from "vue"; | ||
| import { routerViewDepthKey, routerViewLocationKey } from "./symbols.mjs"; | ||
| computed, | ||
| defineComponent, | ||
| getCurrentInstance, | ||
| h, | ||
| inject, | ||
| provide, | ||
| shallowReactive | ||
| } from 'vue'; | ||
| import { routerViewDepthKey, routerViewLocationKey } from './symbols.mjs'; | ||
| export const RouterView = defineComponent({ | ||
| name: "RouterView", | ||
| inheritAttrs: true, | ||
| props: { | ||
| name: { | ||
| type: String, | ||
| default: "default" | ||
| name: 'RouterView', | ||
| inheritAttrs: true, | ||
| props: { | ||
| name: { | ||
| type: String, | ||
| default: 'default' | ||
| }, | ||
| route: Object | ||
| }, | ||
| route: Object | ||
| }, | ||
| // Better compat for @vue/compat users | ||
| // https://github.com/vuejs/router/issues/1315 | ||
| compatConfig: { MODE: 3 }, | ||
| setup: (props, { attrs, slots }) => { | ||
| const instance = getCurrentInstance(); | ||
| if (!instance) { | ||
| console.error("no current instance"); | ||
| return; | ||
| // Better compat for @vue/compat users | ||
| // https://github.com/vuejs/router/issues/1315 | ||
| compatConfig: { MODE: 3 }, | ||
| setup: (props, { attrs, slots }) => { | ||
| const instance = getCurrentInstance(); | ||
| if (!instance) { | ||
| console.error('no current instance'); | ||
| return; | ||
| } | ||
| const injectedRoute = inject(routerViewLocationKey); | ||
| const routeToDisplay = computed(() => props.route || injectedRoute); | ||
| const injectedDepth = inject( | ||
| routerViewDepthKey, | ||
| computed(() => 0) | ||
| ); | ||
| const depth = computed(() => { | ||
| let initialDepth = injectedDepth.value; | ||
| const { matched } = routeToDisplay.value; | ||
| let matchedRoute; | ||
| while ( | ||
| (matchedRoute = matched[initialDepth]) && | ||
| !(matchedRoute == null ? void 0 : matchedRoute.component) | ||
| ) { | ||
| initialDepth++; | ||
| } | ||
| return initialDepth; | ||
| }); | ||
| provide(routerViewLocationKey, shallowReactive(routeToDisplay.value)); | ||
| provide( | ||
| routerViewDepthKey, | ||
| computed(() => depth.value + 1) | ||
| ); | ||
| return () => { | ||
| const matchRoute = routeToDisplay.value.matched[depth.value]; | ||
| if (!matchRoute) { | ||
| return null; | ||
| } | ||
| const component = h( | ||
| matchRoute.component, | ||
| Object.assign({}, props, attrs) | ||
| ); | ||
| return ( | ||
| // pass the vnode to the slot as a prop. | ||
| // h and <component :is="..."> both accept vnodes | ||
| normalizeSlot(slots.default, { Component: component }) || | ||
| component | ||
| ); | ||
| }; | ||
| } | ||
| const injectedRoute = inject( | ||
| routerViewLocationKey | ||
| ); | ||
| const routeToDisplay = computed( | ||
| () => props.route || injectedRoute | ||
| ); | ||
| const injectedDepth = inject( | ||
| routerViewDepthKey, | ||
| computed(() => 0) | ||
| ); | ||
| const depth = computed(() => { | ||
| let initialDepth = injectedDepth.value; | ||
| const { matched } = routeToDisplay.value; | ||
| let matchedRoute; | ||
| while ((matchedRoute = matched[initialDepth]) && !(matchedRoute == null ? void 0 : matchedRoute.component)) { | ||
| initialDepth++; | ||
| } | ||
| return initialDepth; | ||
| }); | ||
| provide(routerViewLocationKey, shallowReactive(routeToDisplay.value)); | ||
| provide( | ||
| routerViewDepthKey, | ||
| computed(() => depth.value + 1) | ||
| ); | ||
| return () => { | ||
| const matchRoute = routeToDisplay.value.matched[depth.value]; | ||
| if (!matchRoute) { | ||
| return null; | ||
| } | ||
| const component = h( | ||
| matchRoute.component, | ||
| Object.assign({}, props, attrs) | ||
| ); | ||
| return ( | ||
| // pass the vnode to the slot as a prop. | ||
| // h and <component :is="..."> both accept vnodes | ||
| normalizeSlot(slots.default, { Component: component }) || component | ||
| ); | ||
| }; | ||
| } | ||
| }); | ||
| function normalizeSlot(slot, data) { | ||
| if (!slot) return null; | ||
| const slotContent = slot(data); | ||
| return slotContent.length === 1 ? slotContent[0] : slotContent; | ||
| if (!slot) return null; | ||
| const slotContent = slot(data); | ||
| return slotContent.length === 1 ? slotContent[0] : slotContent; | ||
| } |
+29
-30
@@ -1,34 +0,33 @@ | ||
| "use strict"; | ||
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| exports.RouterView = void 0; | ||
| var _vue = require("vue"); | ||
| const RouterView = exports.RouterView = (0, _vue.defineComponent)({ | ||
| functional: true, | ||
| render(h, ctx) { | ||
| var _a; | ||
| ctx.data.dataView = true; | ||
| let { | ||
| parent | ||
| } = ctx; | ||
| const { | ||
| data | ||
| } = ctx; | ||
| const route = parent.$route; | ||
| let depth = 0; | ||
| while (parent && parent._routerRoot !== parent) { | ||
| const vnodeData = ((_a = parent == null ? void 0 : parent.$vnode) == null ? void 0 : _a.data) || {}; | ||
| if (vnodeData.dataView) { | ||
| depth++; | ||
| } | ||
| parent.$parent && (parent = parent.$parent); | ||
| var _vue = require('vue'); | ||
| const RouterView = (exports.RouterView = (0, _vue.defineComponent)({ | ||
| functional: true, | ||
| render(h, ctx) { | ||
| var _a; | ||
| ctx.data.dataView = true; | ||
| let { parent } = ctx; | ||
| const { data } = ctx; | ||
| const route = parent.$route; | ||
| let depth = 0; | ||
| while (parent && parent._routerRoot !== parent) { | ||
| const vnodeData = | ||
| ((_a = parent == null ? void 0 : parent.$vnode) == null | ||
| ? void 0 | ||
| : _a.data) || {}; | ||
| if (vnodeData.dataView) { | ||
| depth++; | ||
| } | ||
| parent.$parent && (parent = parent.$parent); | ||
| } | ||
| const matchRoute = route.matched[depth]; | ||
| if (!matchRoute) { | ||
| return h(); | ||
| } | ||
| return h(matchRoute.component || matchRoute.asyncComponent, data); | ||
| } | ||
| const matchRoute = route.matched[depth]; | ||
| if (!matchRoute) { | ||
| return h(); | ||
| } | ||
| return h(matchRoute.component || matchRoute.asyncComponent, data); | ||
| } | ||
| }); | ||
| })); |
+23
-7
@@ -6,8 +6,24 @@ declare module 'vue/types' { | ||
| } | ||
| export declare const RouterView: import("vue/types").DefineComponent<Readonly<{ | ||
| [x: string]: any; | ||
| }>, {}, {}, import("vue/types").ComponentComputedOptions, import("vue/types").ComponentMethodOptions, import("vue/types").ComponentOptionsMixin, import("vue/types").ComponentOptionsMixin, {}, string, Readonly<import("vue/types").ExtractPropTypes<Readonly<{ | ||
| [x: string]: any; | ||
| }>>>, { | ||
| readonly [x: string]: any; | ||
| }>; | ||
| export declare const RouterView: import('vue/types').DefineComponent< | ||
| Readonly<{ | ||
| [x: string]: any; | ||
| }>, | ||
| {}, | ||
| {}, | ||
| import('vue/types').ComponentComputedOptions, | ||
| import('vue/types').ComponentMethodOptions, | ||
| import('vue/types').ComponentOptionsMixin, | ||
| import('vue/types').ComponentOptionsMixin, | ||
| {}, | ||
| string, | ||
| Readonly< | ||
| import('vue/types').ExtractPropTypes< | ||
| Readonly<{ | ||
| [x: string]: any; | ||
| }> | ||
| > | ||
| >, | ||
| { | ||
| readonly [x: string]: any; | ||
| } | ||
| >; |
+24
-21
@@ -1,24 +0,27 @@ | ||
| import { defineComponent } from "vue"; | ||
| import { defineComponent } from 'vue'; | ||
| export const RouterView = defineComponent({ | ||
| functional: true, | ||
| render(h, ctx) { | ||
| var _a; | ||
| ctx.data.dataView = true; | ||
| let { parent } = ctx; | ||
| const { data } = ctx; | ||
| const route = parent.$route; | ||
| let depth = 0; | ||
| while (parent && parent._routerRoot !== parent) { | ||
| const vnodeData = ((_a = parent == null ? void 0 : parent.$vnode) == null ? void 0 : _a.data) || {}; | ||
| if (vnodeData.dataView) { | ||
| depth++; | ||
| } | ||
| parent.$parent && (parent = parent.$parent); | ||
| functional: true, | ||
| render(h, ctx) { | ||
| var _a; | ||
| ctx.data.dataView = true; | ||
| let { parent } = ctx; | ||
| const { data } = ctx; | ||
| const route = parent.$route; | ||
| let depth = 0; | ||
| while (parent && parent._routerRoot !== parent) { | ||
| const vnodeData = | ||
| ((_a = parent == null ? void 0 : parent.$vnode) == null | ||
| ? void 0 | ||
| : _a.data) || {}; | ||
| if (vnodeData.dataView) { | ||
| depth++; | ||
| } | ||
| parent.$parent && (parent = parent.$parent); | ||
| } | ||
| const matchRoute = route.matched[depth]; | ||
| if (!matchRoute) { | ||
| return h(); | ||
| } | ||
| return h(matchRoute.component || matchRoute.asyncComponent, data); | ||
| } | ||
| const matchRoute = route.matched[depth]; | ||
| if (!matchRoute) { | ||
| return h(); | ||
| } | ||
| return h(matchRoute.component || matchRoute.asyncComponent, data); | ||
| } | ||
| }); |
+3
-3
@@ -23,3 +23,3 @@ { | ||
| "@gez/lint": "0.0.9", | ||
| "@gez/router": "0.0.75-alpha.1", | ||
| "@gez/router": "0.0.75-alpha.2", | ||
| "@types/node": "20.12.12", | ||
@@ -34,3 +34,3 @@ "@vitest/coverage-v8": "1.6.0", | ||
| }, | ||
| "version": "0.0.75-alpha.1", | ||
| "version": "0.0.75-alpha.2", | ||
| "type": "module", | ||
@@ -61,3 +61,3 @@ "private": false, | ||
| ], | ||
| "gitHead": "3ae7053018c8a99d74f1d22961b28f6db54df3b4" | ||
| "gitHead": "33732d6fd2ec1ec5ff3c15403c035fe936c04fda" | ||
| } |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
72111
13.8%2230
9.31%0
-100%