Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unplugin-vue-router

Package Overview
Dependencies
Maintainers
1
Versions
67
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.0 to 0.10.1

dist/chunk-2UFBHZEE.js

20

dist/data-loaders/basic.js

@@ -0,1 +1,5 @@

import {
toLazyValue
} from "./chunk-4MKZ4JDN.js";
// src/data-loaders/defineLoader.ts

@@ -29,3 +33,3 @@ import {

};
function load(to, router, parent) {
function load(to, router, from, parent) {
const entries = router[LOADER_ENTRIES_KEY];

@@ -39,2 +43,3 @@ const isSSR = router[IS_SSR_KEY];

error: shallowRef(),
to,
options,

@@ -83,3 +88,3 @@ children: /* @__PURE__ */ new Set(),

const currentLoad = Promise.resolve(
loader(to, { signal: to.meta[ABORT_CONTROLLER_KEY].signal })
loader(to, { signal: to.meta[ABORT_CONTROLLER_KEY]?.signal })
).then((d) => {

@@ -97,3 +102,3 @@ if (entry.pendingLoad === currentLoad) {

entry.stagedError = e;
if (!options.lazy || isSSR) {
if (!toLazyValue(options.lazy, to, from) || isSSR) {
throw e;

@@ -133,2 +138,3 @@ }

this.pendingTo = null;
this.to = to;
for (const childEntry of this.children) {

@@ -140,3 +146,4 @@ childEntry.commit(to);

const useDataLoader = () => {
const [parentEntry, _router, _route] = getCurrentContext();
const currentContext = getCurrentContext();
const [parentEntry, _router, _route] = currentContext;
const router = _router || useRouter();

@@ -151,3 +158,5 @@ const route = _route || useRoute();

) {
router[APP_KEY].runWithContext(() => load(route, router, parentEntry));
router[APP_KEY].runWithContext(
() => load(route, router, void 0, parentEntry)
);
}

@@ -175,2 +184,3 @@ entry = entries.get(loader);

}).catch((e) => parentEntry ? Promise.reject(e) : null);
setCurrentContext(currentContext);
return Object.assign(promise, useDataLoaderResult);

@@ -177,0 +187,0 @@ };

@@ -0,1 +1,5 @@

import {
toLazyValue
} from "./chunk-4MKZ4JDN.js";
// src/data-loaders/defineColadaLoader.ts

@@ -35,3 +39,3 @@ import {

let isInitial = true;
function load(to, router, parent, reload) {
function load(to, router, from, parent, reload) {
const entries = router[LOADER_ENTRIES_KEY];

@@ -47,2 +51,3 @@ const isSSR = router[IS_SSR_KEY];

error: shallowRef(),
to,
options,

@@ -69,2 +74,11 @@ children: /* @__PURE__ */ new Set(),

}
const currentContext = getCurrentContext();
if (process.env.NODE_ENV === "development") {
if (parent !== currentContext[0]) {
console.warn(
`\u274C\u{1F476} "${key}" has a different parent than the current context. This shouldn't be happening. Please report a bug with a reproduction to https://github.com/posva/unplugin-vue-router/`
);
}
}
setCurrentContext([entry, router, to]);
if (!entry.ext) {

@@ -84,3 +98,3 @@ entry.ext = useQuery({

return loader(trackedRoute, {
signal: route.meta[ABORT_CONTROLLER_KEY].signal
signal: route.meta[ABORT_CONTROLLER_KEY]?.signal
});

@@ -105,11 +119,2 @@ },

isLoading.value = true;
const currentContext = getCurrentContext();
if (process.env.NODE_ENV === "development") {
if (parent !== currentContext[0]) {
console.warn(
`\u274C\u{1F476} "${key}" has a different parent than the current context. This shouldn't be happening. Please report a bug with a reproduction to https://github.com/posva/unplugin-vue-router/`
);
}
}
setCurrentContext([entry, router, to]);
entry.staged = STAGED_NO_VALUE;

@@ -122,3 +127,3 @@ entry.stagedError = error.value;

entry.stagedError = newError;
if (!options.lazy || isSSR) {
if (!toLazyValue(options.lazy, to, from) || isSSR) {
throw newError;

@@ -168,2 +173,3 @@ }

this.stagedError = this.error.value;
this.to = to;
this.pendingTo = null;

@@ -177,3 +183,4 @@ for (const childEntry of this.children) {

const useDataLoader = () => {
const [parentEntry, _router, _route] = getCurrentContext();
const currentEntry = getCurrentContext();
const [parentEntry, _router, _route] = currentEntry;
const router = _router || useRouter();

@@ -189,3 +196,6 @@ const route = _route || useRoute();

router[APP_KEY].runWithContext(
() => load(route, router, parentEntry, true)
() => (
// in this case we always need to run the functions for nested loaders consistency
load(route, router, void 0, parentEntry, true)
)
);

@@ -195,8 +205,6 @@ }

if (parentEntry) {
if (parentEntry === entry) {
console.warn(
`\u{1F476}\u274C "${options.key}" has itself as parent. This shouldn't be happening. Please report a bug with a reproduction to https://github.com/posva/unplugin-vue-router/`
);
if (parentEntry !== entry) {
parentEntry.children.add(entry);
} else {
}
parentEntry.children.add(entry);
}

@@ -224,7 +232,7 @@ const { data, error, isLoading, ext } = entry;

reload: (to = router.currentRoute.value) => router[APP_KEY].runWithContext(
() => load(to, router, void 0, true)
() => load(to, router, void 0, void 0, true)
).then(() => entry.commit(to)),
// pinia colada
refetch: (to = router.currentRoute.value) => router[APP_KEY].runWithContext(
() => load(to, router, void 0, true)
() => load(to, router, void 0, void 0, true)
).then(() => entry.commit(to)),

@@ -231,0 +239,0 @@ refresh: (to = router.currentRoute.value) => router[APP_KEY].runWithContext(() => load(to, router)).then(

import * as esbuild from 'esbuild';
import { O as Options } from './types-B3fGzmzY.js';
import { O as Options } from './types-CEBdfPkN.js';
import 'vue-router';

@@ -4,0 +4,0 @@

import {
src_default
} from "./chunk-JAQZ7GSU.js";
} from "./chunk-2UFBHZEE.js";
import "./chunk-HWA3WM2K.js";

@@ -5,0 +5,0 @@ import "./chunk-6F4PWJZI.js";

import * as unplugin from 'unplugin';
import { R as ResolvedOptions, S as ServerContext, O as Options } from './types-B3fGzmzY.js';
export { D as DEFAULT_OPTIONS, E as EditableTreeNode, T as TreeNode, b as TreeNodeValueParam, d as TreeNodeValueStatic, c as createTreeNodeValue, g as getFileBasedRouteName, a as getPascalCaseRouteName } from './types-B3fGzmzY.js';
import { R as ResolvedOptions, S as ServerContext, O as Options } from './types-CEBdfPkN.js';
export { D as DEFAULT_OPTIONS, E as EditableTreeNode, T as TreeNode, b as TreeNodeValueParam, d as TreeNodeValueStatic, c as createTreeNodeValue, g as getFileBasedRouteName, a as getPascalCaseRouteName } from './types-CEBdfPkN.js';
import 'vue-router';

@@ -5,0 +5,0 @@

@@ -7,3 +7,3 @@ import {

src_default
} from "./chunk-JAQZ7GSU.js";
} from "./chunk-2UFBHZEE.js";
import {

@@ -10,0 +10,0 @@ DEFAULT_OPTIONS,

@@ -1,2 +0,2 @@

export { D as DEFAULT_OPTIONS, O as Options, R as ResolvedOptions, i as RoutesFolder, e as RoutesFolderOption, f as RoutesFolderOptionResolved, S as ServerContext, _ as _OverridableOption, h as _RoutesFolder, m as mergeAllExtensions, j as resolveOptions, r as resolveOverridableOption } from './types-B3fGzmzY.js';
export { D as DEFAULT_OPTIONS, O as Options, R as ResolvedOptions, i as RoutesFolder, e as RoutesFolderOption, f as RoutesFolderOptionResolved, S as ServerContext, _ as _OverridableOption, h as _RoutesFolder, m as mergeAllExtensions, j as resolveOptions, r as resolveOverridableOption } from './types-CEBdfPkN.js';
import 'vue-router';
import * as rollup from 'rollup';
import { O as Options } from './types-B3fGzmzY.js';
import { O as Options } from './types-CEBdfPkN.js';
import 'vue-router';

@@ -4,0 +4,0 @@

import {
src_default
} from "./chunk-JAQZ7GSU.js";
} from "./chunk-2UFBHZEE.js";
import "./chunk-HWA3WM2K.js";

@@ -5,0 +5,0 @@ import "./chunk-6F4PWJZI.js";

@@ -127,2 +127,7 @@ import * as vue_router from 'vue-router';

selectNavigationResult?: (results: NavigationResult[]) => _Awaitable<Exclude<NavigationGuardReturn, Function | Promise<unknown>>>;
/**
* 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` or a custom function that returns `true` for expected errors.
*/
errors?: Array<new (...args: any) => any> | ((reason?: unknown) => boolean);
}

@@ -186,4 +191,11 @@

declare function getCurrentContext(): readonly [entry: DataLoaderEntryBase<boolean, unknown>, router: Router, route: vue_router.RouteLocationNormalizedLoadedGeneric] | readonly [];
declare function setCurrentContext(context: typeof currentContext | readonly []): void;
/**
* Sets the current context for data loaders. This allows for nested loaders to be aware of their parent context.
* INTERNAL ONLY.
*
* @param context - the context to set
* @internal
*/
declare function setCurrentContext(context?: typeof currentContext | readonly []): void;
/**
* Restore the current context after a promise is resolved.

@@ -200,4 +212,4 @@ * @param promise - promise to wrap

<T extends {}, U>(target: T, source: U): T & U;
<T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
<T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
<T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V;
<T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
(target: object, ...sources: any[]): any;

@@ -217,3 +229,3 @@ };

readonly fullPath: string;
readonly redirectedFrom: vue_router.RouteLocationGeneric | undefined;
readonly redirectedFrom: vue_router.RouteLocation | undefined;
readonly path: string;

@@ -246,2 +258,6 @@ readonly meta: vue_router.RouteMeta;

/**
* Location the data was loaded for or `null` if the data is not loaded.
*/
to: RouteLocationNormalizedLoaded$1 | null;
/**
* Whether there is an ongoing request.

@@ -291,3 +307,3 @@ */

*/
lazy?: isLazy;
lazy?: isLazy | ((to: RouteLocationNormalizedLoaded$1, from?: RouteLocationNormalizedLoaded$1) => boolean);
/**

@@ -301,3 +317,5 @@ * Whether this loader should be awaited on the server side or not. Combined with the `lazy` option, this gives full

/**
* When the data should be committed to the entry. This only applies to non-lazy loaders.
* When the data should be committed to the entry. In the case of lazy loaders, the loader will try to commit the data
* after all non-lazy loaders have finished loading, but it might not be able to if the lazy loader hasn't been
* resolved yet.
*

@@ -308,2 +326,7 @@ * @see {@link DefineDataLoaderCommit}

commit?: DefineDataLoaderCommit;
/**
* 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`.
*/
errors?: Array<new (...args: any) => any>;
}

@@ -320,3 +343,3 @@ /**

*/
signal: AbortSignal;
signal: AbortSignal | undefined;
}

@@ -364,7 +387,8 @@ /**

*
* @param route - route location to load the data for
* @param to - route location to load the data for
* @param router - router instance
* @param from - route location we are coming from
* @param parent - parent data loader entry
*/
load: (route: RouteLocationNormalizedLoaded$1, router: Router, parent?: DataLoaderEntryBase) => Promise<void>;
load: (to: RouteLocationNormalizedLoaded$1, router: Router, from?: RouteLocationNormalizedLoaded$1, parent?: DataLoaderEntryBase) => Promise<void>;
/**

@@ -371,0 +395,0 @@ * Resolved options for the loader.

@@ -80,2 +80,5 @@ // src/data-loaders/navigation-guard.ts

// src/data-loaders/createDataLoader.ts
var toLazyValue = (lazy, to, from) => typeof lazy === "function" ? lazy(to, from) : lazy;
// src/data-loaders/navigation-guard.ts

@@ -87,2 +90,3 @@ function setupLoaderGuard({

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

@@ -145,3 +149,3 @@ }) {

});
const removeDataLoaderGuard = router.beforeResolve((to) => {
const removeDataLoaderGuard = router.beforeResolve((to, from) => {
const loaders = Array.from(to.meta[LOADER_SET_KEY]);

@@ -157,8 +161,13 @@ setCurrentContext([]);

() => app.runWithContext(
() => loader._.load(to, router)
() => loader._.load(to, router, from)
)
);
return !isSSR && lazy ? void 0 : (
return !isSSR && toLazyValue(lazy, to, from) ? void 0 : (
// return the non-lazy loader to commit changes after all loaders are done
ret
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)
)
)
);

@@ -179,3 +188,3 @@ })

});
const removeAfterEach = router.afterEach((to, _from, failure) => {
const removeAfterEach = router.afterEach((to, from, failure) => {
if (failure) {

@@ -201,3 +210,3 @@ to.meta[ABORT_CONTROLLER_KEY]?.abort(failure);

const entry = loader._.getEntry(router);
if (entry && (!lazy || !entry.isLoading.value)) {
if (entry && (!toLazyValue(lazy, to, from) || !entry.isLoading.value)) {
entry.commit(to);

@@ -204,0 +213,0 @@ }

@@ -1,2 +0,2 @@

export { E as EditableTreeNode, O as Options, T as TreeNode, b as TreeNodeValueParam, d as TreeNodeValueStatic } from './types-B3fGzmzY.js';
export { E as EditableTreeNode, O as Options, T as TreeNode, b as TreeNodeValueParam, d as TreeNodeValueStatic } from './types-CEBdfPkN.js';
import 'vue-router';
import * as vite from 'vite';
import { O as Options } from './types-B3fGzmzY.js';
import { O as Options } from './types-CEBdfPkN.js';
import 'vue-router';

@@ -4,0 +4,0 @@

import {
src_default
} from "./chunk-JAQZ7GSU.js";
} from "./chunk-2UFBHZEE.js";
import "./chunk-HWA3WM2K.js";

@@ -5,0 +5,0 @@ import "./chunk-6F4PWJZI.js";

import * as webpack from 'webpack';
import { O as Options } from './types-B3fGzmzY.js';
import { O as Options } from './types-CEBdfPkN.js';
import 'vue-router';

@@ -4,0 +4,0 @@

import {
src_default
} from "./chunk-JAQZ7GSU.js";
} from "./chunk-2UFBHZEE.js";
import "./chunk-HWA3WM2K.js";

@@ -5,0 +5,0 @@ import "./chunk-6F4PWJZI.js";

{
"name": "unplugin-vue-router",
"version": "0.10.0",
"version": "0.10.1",
"type": "module",

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

"dependencies": {
"@babel/types": "^7.24.7",
"@babel/types": "^7.24.9",
"@rollup/pluginutils": "^5.1.0",

@@ -164,3 +164,3 @@ "@vue-macros/common": "^1.10.4",

"scule": "^1.3.0",
"unplugin": "^1.10.1",
"unplugin": "^1.11.0",
"yaml": "^2.4.5"

@@ -178,7 +178,7 @@ },

"@pinia/colada": "^0.6.0",
"@shikijs/vitepress-twoslash": "1.6.5",
"@tanstack/vue-query": "^5.45.0",
"@types/node": "^20.14.2",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/ui": "^1.6.0",
"@shikijs/vitepress-twoslash": "1.11.0",
"@tanstack/vue-query": "^5.51.9",
"@types/node": "^20.14.11",
"@vitest/coverage-v8": "^2.0.3",
"@vitest/ui": "^2.0.3",
"@volar/vue-language-core": "^1.6.5",

@@ -189,30 +189,31 @@ "@vue/test-utils": "^2.4.6",

"enquirer": "^2.4.1",
"execa": "^9.2.0",
"firebase": "^10.12.2",
"happy-dom": "^14.12.0",
"execa": "^9.3.0",
"firebase": "^10.12.4",
"happy-dom": "^14.12.3",
"lint-staged": "^15.2.7",
"minimist": "^1.2.8",
"nodemon": "^3.1.3",
"nodemon": "^3.1.4",
"p-series": "^3.0.0",
"pinia": "^2.1.7",
"prettier": "^3.3.2",
"rimraf": "^5.0.7",
"rollup": "^4.18.0",
"semver": "^7.6.2",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"rollup": "^4.19.0",
"semver": "^7.6.3",
"ts-expect": "^1.3.0",
"tsup": "^8.1.0",
"typescript": "^5.4.5",
"unplugin-auto-import": "^0.17.6",
"tsup": "^8.2.1",
"typescript": "^5.5.3",
"unplugin-auto-import": "^0.18.0",
"unplugin-vue-markdown": "^0.26.2",
"vite": "^5.3.1",
"vitepress": "1.2.3",
"vitest": "^1.6.0",
"vue": "^3.4.29",
"vite": "^5.3.4",
"vite-plugin-vue-devtools": "^7.3.6",
"vitepress": "1.3.1",
"vitest": "^2.0.3",
"vue": "^3.4.33",
"vue-router": "^4.4.0",
"vue-router-mock": "^1.1.0",
"vue-tsc": "^2.0.21",
"vuefire": "^3.1.23",
"webpack": "^5.92.0",
"vue-tsc": "^2.0.26",
"vuefire": "^3.1.24",
"webpack": "^5.93.0",
"yorkie": "^2.0.0",
"unplugin-vue-router": "0.10.0"
"unplugin-vue-router": "0.10.1"
},

@@ -219,0 +220,0 @@ "scripts": {

# unplugin-vue-router
[![NPM version](https://img.shields.io/npm/v/unplugin-vue-router?color=black&label=)](https://www.npmjs.com/package/unplugin-vue-router) [![ci status](https://github.com/posva/unplugin-vue-router/actions/workflows/ci.yml/badge.svg)](https://github.com/posva/unplugin-vue-router/actions/workflows/ci.yml)
[![NPM version](https://img.shields.io/npm/v/unplugin-vue-router?color=black&label=)](https://www.npmjs.com/package/unplugin-vue-router) [![ci status](https://github.com/posva/unplugin-vue-router/actions/workflows/ci.yml/badge.svg)](https://github.com/posva/unplugin-vue-router/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/posva/unplugin-vue-router/graph/badge.svg?token=28IvHS7TAx)](https://codecov.io/gh/posva/unplugin-vue-router)

@@ -5,0 +5,0 @@ > Automatic file based Routing in Vue with TS support ✨

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc