Big News: Socket Selected for OpenAI's Cybersecurity Grant Program.Details
Socket
Book a DemoSign in
Socket

unplugin-vue-router

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unplugin-vue-router - npm Package Compare versions

Comparing version
0.10.7
to
0.10.8
+30
-13
dist/data-loaders/pinia-colada.cjs

@@ -42,3 +42,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }

const isSSR = router[_runtime.IS_SSR_KEY];
const key = keyText(options.key(to));
const key = serializeQueryKey(options.key, to);
if (!entries.has(loader)) {

@@ -89,8 +89,11 @@ const route = _vue.shallowRef.call(void 0, to);

const [trackedRoute, params, query, hash] = _runtime.trackRoute.call(void 0, route);
entry.tracked.set(keyText(options.key(trackedRoute)).join("|"), {
ready: false,
params,
query,
hash
});
entry.tracked.set(
joinKeys(serializeQueryKey(options.key, trackedRoute)),
{
ready: false,
params,
query,
hash
}
);
return loader(trackedRoute, {

@@ -100,3 +103,3 @@ signal: _optionalChain([route, 'access', _3 => _3.meta, 'access', _4 => _4[_runtime.ABORT_CONTROLLER_KEY], 'optionalAccess', _5 => _5.signal])

},
key: () => options.key(entry.route.value)
key: () => toValueWithParameters(options.key, entry.route.value)
// TODO: cleanup if gc

@@ -121,3 +124,3 @@ // onDestroy() {

if (entry.route.value !== to) {
const tracked = entry.tracked.get(key.join("|"));
const tracked = entry.tracked.get(joinKeys(key));
reload = !tracked || hasRouteChanged(to, tracked);

@@ -163,3 +166,3 @@ }

function commit(to) {
const key = keyText(options.key(to));
const key = serializeQueryKey(options.key, to);
if (this.pendingTo === to) {

@@ -175,3 +178,9 @@ if (process.env.NODE_ENV === "development") {

this.data.value = this.staged;
this.tracked.get(key.join("|")).ready = true;
if (process.env.NODE_ENV === "development" && !this.tracked.has(joinKeys(key))) {
console.warn(
`A query was defined with the same key as the loader "[${key.join(", ")}]" but with different "query" function.
See https://pinia-colada.esm.dev/#TODO`
);
}
this.tracked.get(joinKeys(key)).ready = true;
}

@@ -267,2 +276,3 @@ this.error.value = this.stagedError;

}
var joinKeys = (keys) => keys.join("|");
function hasRouteChanged(to, tracked) {

@@ -276,6 +286,13 @@ return !tracked.ready || !_runtime.isSubsetOf.call(void 0, tracked.params, to.params) || !_runtime.isSubsetOf.call(void 0, tracked.query, to.query) || tracked.hash.v != null && tracked.hash.v !== to.hash;

};
var keyText = (key) => {
var toValueWithParameters = (optionValue, arg) => {
return typeof optionValue === "function" ? (
// This should work in TS without a cast
optionValue(arg)
) : optionValue;
};
function serializeQueryKey(keyOption, to) {
const key = toValueWithParameters(keyOption, to);
const keys = Array.isArray(key) ? key : [key];
return keys.map(stringifyFlatObject);
};
}
function stringifyFlatObject(obj) {

@@ -282,0 +299,0 @@ return obj && typeof obj === "object" ? JSON.stringify(obj, Object.keys(obj).sort()) : String(obj);

@@ -30,3 +30,3 @@ import { RouteMap, RouteLocationNormalizedLoaded, LocationQuery } from 'vue-router';

*/
key: (to: RouteLocationNormalizedLoaded<Name>) => EntryKey;
key: EntryKey | ((to: RouteLocationNormalizedLoaded<Name>) => EntryKey);
/**

@@ -33,0 +33,0 @@ * Function that returns a promise with the data.

@@ -30,3 +30,3 @@ import { RouteMap, RouteLocationNormalizedLoaded, LocationQuery } from 'vue-router';

*/
key: (to: RouteLocationNormalizedLoaded<Name>) => EntryKey;
key: EntryKey | ((to: RouteLocationNormalizedLoaded<Name>) => EntryKey);
/**

@@ -33,0 +33,0 @@ * Function that returns a promise with the data.

@@ -42,3 +42,3 @@ import {

const isSSR = router[IS_SSR_KEY];
const key = keyText(options.key(to));
const key = serializeQueryKey(options.key, to);
if (!entries.has(loader)) {

@@ -89,8 +89,11 @@ const route = shallowRef(to);

const [trackedRoute, params, query, hash] = trackRoute(route);
entry.tracked.set(keyText(options.key(trackedRoute)).join("|"), {
ready: false,
params,
query,
hash
});
entry.tracked.set(
joinKeys(serializeQueryKey(options.key, trackedRoute)),
{
ready: false,
params,
query,
hash
}
);
return loader(trackedRoute, {

@@ -100,3 +103,3 @@ signal: route.meta[ABORT_CONTROLLER_KEY]?.signal

},
key: () => options.key(entry.route.value)
key: () => toValueWithParameters(options.key, entry.route.value)
// TODO: cleanup if gc

@@ -121,3 +124,3 @@ // onDestroy() {

if (entry.route.value !== to) {
const tracked = entry.tracked.get(key.join("|"));
const tracked = entry.tracked.get(joinKeys(key));
reload = !tracked || hasRouteChanged(to, tracked);

@@ -163,3 +166,3 @@ }

function commit(to) {
const key = keyText(options.key(to));
const key = serializeQueryKey(options.key, to);
if (this.pendingTo === to) {

@@ -175,3 +178,9 @@ if (process.env.NODE_ENV === "development") {

this.data.value = this.staged;
this.tracked.get(key.join("|")).ready = true;
if (process.env.NODE_ENV === "development" && !this.tracked.has(joinKeys(key))) {
console.warn(
`A query was defined with the same key as the loader "[${key.join(", ")}]" but with different "query" function.
See https://pinia-colada.esm.dev/#TODO`
);
}
this.tracked.get(joinKeys(key)).ready = true;
}

@@ -267,2 +276,3 @@ this.error.value = this.stagedError;

}
var joinKeys = (keys) => keys.join("|");
function hasRouteChanged(to, tracked) {

@@ -276,6 +286,13 @@ return !tracked.ready || !isSubsetOf(tracked.params, to.params) || !isSubsetOf(tracked.query, to.query) || tracked.hash.v != null && tracked.hash.v !== to.hash;

};
var keyText = (key) => {
var toValueWithParameters = (optionValue, arg) => {
return typeof optionValue === "function" ? (
// This should work in TS without a cast
optionValue(arg)
) : optionValue;
};
function serializeQueryKey(keyOption, to) {
const key = toValueWithParameters(keyOption, to);
const keys = Array.isArray(key) ? key : [key];
return keys.map(stringifyFlatObject);
};
}
function stringifyFlatObject(obj) {

@@ -282,0 +299,0 @@ return obj && typeof obj === "object" ? JSON.stringify(obj, Object.keys(obj).sort()) : String(obj);

@@ -89,3 +89,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/data-loaders/navigation-guard.ts

isSSR,
errors = [],
errors: globalErrors = [],
selectNavigationResult = (results) => results[0].value

@@ -102,3 +102,3 @@ }) {

}
if (process.env.NODE_ENV === "development") {
if (process.env.NODE_ENV === "development" && !isSSR) {
console.warn(

@@ -161,3 +161,3 @@ "[vue-router]: Data Loader is experimental and subject to breaking changes in the future."

loaders.map((loader) => {
const { server, lazy } = loader._.options;
const { server, lazy, errors } = loader._.options;
if (!server && isSSR) {

@@ -173,8 +173,8 @@ return;

// return the non-lazy loader to commit changes after all loaders are done
ret.catch(
(reason) => (
// Check if the error is an expected error to discard it
_optionalChain([loader, 'access', _7 => _7._, 'access', _8 => _8.options, 'access', _9 => _9.errors, 'optionalAccess', _10 => _10.some, 'call', _11 => _11((Err) => reason instanceof Err)]) || (Array.isArray(errors) ? errors.some((Err) => reason instanceof Err) : errors(reason)) ? void 0 : Promise.reject(reason)
)
)
ret.catch((reason) => {
if (errors && (Array.isArray(errors) ? errors.some((Err) => reason instanceof Err) : errors(reason))) {
return;
}
return (Array.isArray(globalErrors) ? globalErrors.some((Err) => reason instanceof Err) : globalErrors(reason)) ? void 0 : Promise.reject(reason);
})
);

@@ -197,3 +197,3 @@ })

if (failure) {
_optionalChain([to, 'access', _12 => _12.meta, 'access', _13 => _13[ABORT_CONTROLLER_KEY], 'optionalAccess', _14 => _14.abort, 'call', _15 => _15(failure)]);
_optionalChain([to, 'access', _7 => _7.meta, 'access', _8 => _8[ABORT_CONTROLLER_KEY], 'optionalAccess', _9 => _9.abort, 'call', _10 => _10(failure)]);
if (

@@ -228,3 +228,3 @@ // NOTE: using a smaller version to cutoff some bytes

const removeOnError = router.onError((error, to) => {
_optionalChain([to, 'access', _16 => _16.meta, 'access', _17 => _17[ABORT_CONTROLLER_KEY], 'optionalAccess', _18 => _18.abort, 'call', _19 => _19(error)]);
_optionalChain([to, 'access', _11 => _11.meta, 'access', _12 => _12[ABORT_CONTROLLER_KEY], 'optionalAccess', _13 => _13.abort, 'call', _14 => _14(error)]);
if (router[PENDING_LOCATION_KEY] === to) {

@@ -231,0 +231,0 @@ router[PENDING_LOCATION_KEY] = null;

@@ -321,5 +321,5 @@ import * as vue_router from 'vue-router';

* List of _expected_ errors that shouldn't abort the navigation (for non-lazy loaders). Provide a list of
* constructors that can be checked with `instanceof`.
* constructors that can be checked with `instanceof` or a custom function that returns `true` for expected errors.
*/
errors?: Array<new (...args: any) => any>;
errors?: Array<new (...args: any) => any> | ((reason?: unknown) => boolean);
}

@@ -326,0 +326,0 @@ /**

@@ -321,5 +321,5 @@ import * as vue_router from 'vue-router';

* List of _expected_ errors that shouldn't abort the navigation (for non-lazy loaders). Provide a list of
* constructors that can be checked with `instanceof`.
* constructors that can be checked with `instanceof` or a custom function that returns `true` for expected errors.
*/
errors?: Array<new (...args: any) => any>;
errors?: Array<new (...args: any) => any> | ((reason?: unknown) => boolean);
}

@@ -326,0 +326,0 @@ /**

@@ -89,3 +89,3 @@ // src/data-loaders/navigation-guard.ts

isSSR,
errors = [],
errors: globalErrors = [],
selectNavigationResult = (results) => results[0].value

@@ -102,3 +102,3 @@ }) {

}
if (process.env.NODE_ENV === "development") {
if (process.env.NODE_ENV === "development" && !isSSR) {
console.warn(

@@ -161,3 +161,3 @@ "[vue-router]: Data Loader is experimental and subject to breaking changes in the future."

loaders.map((loader) => {
const { server, lazy } = loader._.options;
const { server, lazy, errors } = loader._.options;
if (!server && isSSR) {

@@ -173,8 +173,8 @@ return;

// return the non-lazy loader to commit changes after all loaders are done
ret.catch(
(reason) => (
// Check if the error is an expected error to discard it
loader._.options.errors?.some((Err) => reason instanceof Err) || (Array.isArray(errors) ? errors.some((Err) => reason instanceof Err) : errors(reason)) ? void 0 : Promise.reject(reason)
)
)
ret.catch((reason) => {
if (errors && (Array.isArray(errors) ? errors.some((Err) => reason instanceof Err) : errors(reason))) {
return;
}
return (Array.isArray(globalErrors) ? globalErrors.some((Err) => reason instanceof Err) : globalErrors(reason)) ? void 0 : Promise.reject(reason);
})
);

@@ -181,0 +181,0 @@ })

{
"name": "unplugin-vue-router",
"version": "0.10.7",
"version": "0.10.8",
"type": "module",

@@ -152,3 +152,3 @@ "description": "File based typed routing for Vue Router",

"dependencies": {
"@babel/types": "^7.25.2",
"@babel/types": "^7.25.4",
"@rollup/pluginutils": "^5.1.0",

@@ -165,3 +165,3 @@ "@vue-macros/common": "^1.12.2",

"scule": "^1.3.0",
"unplugin": "^1.12.1",
"unplugin": "^1.12.2",
"yaml": "^2.5.0"

@@ -178,6 +178,6 @@ },

"devDependencies": {
"@pinia/colada": "^0.8.1",
"@shikijs/vitepress-twoslash": "1.12.1",
"@tanstack/vue-query": "^5.51.21",
"@types/node": "^20.14.15",
"@pinia/colada": "^0.8.2",
"@shikijs/vitepress-twoslash": "1.14.1",
"@tanstack/vue-query": "^5.52.0",
"@types/node": "^20.16.1",
"@vitest/coverage-v8": "^2.0.5",

@@ -190,5 +190,5 @@ "@vitest/ui": "^2.0.5",

"enquirer": "^2.4.1",
"execa": "^9.3.0",
"firebase": "^10.12.5",
"happy-dom": "^14.12.3",
"execa": "^9.3.1",
"firebase": "^10.13.0",
"happy-dom": "^15.0.0",
"lint-staged": "^15.2.9",

@@ -201,3 +201,3 @@ "minimist": "^1.2.8",

"rimraf": "^6.0.1",
"rollup": "^4.20.0",
"rollup": "^4.21.0",
"semver": "^7.6.3",

@@ -209,14 +209,14 @@ "ts-expect": "^1.3.0",

"unplugin-vue-markdown": "^0.26.2",
"vite": "^5.4.0",
"vite-plugin-vue-devtools": "^7.3.8",
"vitepress": "1.3.2",
"vite": "^5.4.2",
"vite-plugin-vue-devtools": "^7.3.9",
"vitepress": "1.3.4",
"vitest": "^2.0.5",
"vue": "^3.4.37",
"vue": "^3.4.38",
"vue-router": "^4.4.3",
"vue-router-mock": "^1.1.0",
"vue-tsc": "^2.0.29",
"vuefire": "^3.1.24",
"webpack": "^5.93.0",
"vuefire": "^3.2.0",
"webpack": "^5.94.0",
"yorkie": "^2.0.0",
"unplugin-vue-router": "0.10.7"
"unplugin-vue-router": "0.10.8"
},

@@ -223,0 +223,0 @@ "scripts": {