前端初始化
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019-present Eduardo San Martin Morote
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
# vue-router [](https://npmx.dev/package/vue-router) [](https://github.com/vuejs/router/actions/workflows/test.yml) [](https://codecov.io/gh/vuejs/router)
|
||||
|
||||
> To see what versions are currently supported, please refer to the [Security Policy](./packages/router/SECURITY.md).
|
||||
|
||||
<h2 align="center">Supporting Vue Router</h2>
|
||||
|
||||
Vue Router is part of the Vue Ecosystem and is an MIT-licensed open source project with its ongoing development made possible entirely by the support of Sponsors. If you would like to become a sponsor, please consider:
|
||||
|
||||
- [Become a Sponsor on GitHub](https://github.com/sponsors/posva)
|
||||
- [One-time donation via PayPal](https://paypal.me/posva)
|
||||
|
||||
<!--sponsors start-->
|
||||
|
||||
<h4 align="center">Gold Sponsors</h4>
|
||||
<p align="center">
|
||||
<a href="https://www.coderabbit.ai/?utm_source=vuerouter&utm_medium=sponsor" target="_blank" rel="noopener noreferrer">
|
||||
<picture>
|
||||
<source srcset="https://posva-sponsors.pages.dev/logos/coderabbitai-dark.svg" media="(prefers-color-scheme: dark)" height="72px" alt="CodeRabbit" />
|
||||
<img src="https://posva-sponsors.pages.dev/logos/coderabbitai-light.svg" height="72px" alt="CodeRabbit" />
|
||||
</picture>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<h4 align="center">Silver Sponsors</h4>
|
||||
<p align="center">
|
||||
<a href="https://www.vuemastery.com/" target="_blank" rel="noopener noreferrer">
|
||||
<picture>
|
||||
<source srcset="https://posva-sponsors.pages.dev/logos/vuemastery-dark.png" media="(prefers-color-scheme: dark)" height="42px" alt="VueMastery" />
|
||||
<img src="https://posva-sponsors.pages.dev/logos/vuemastery-light.svg" height="42px" alt="VueMastery" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="https://www.controla.ai/?utm_source=posva" target="_blank" rel="noopener noreferrer">
|
||||
<picture>
|
||||
<source srcset="https://posva-sponsors.pages.dev/logos/controla-dark.png" media="(prefers-color-scheme: dark)" height="42px" alt="Controla" />
|
||||
<img src="https://posva-sponsors.pages.dev/logos/controla-light.png" height="42px" alt="Controla" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="https://jobs.sendcloud.com" target="_blank" rel="noopener noreferrer">
|
||||
<picture>
|
||||
<source srcset="https://posva-sponsors.pages.dev/logos/sendcloud-dark.svg" media="(prefers-color-scheme: dark)" height="42px" alt="SendCloud" />
|
||||
<img src="https://posva-sponsors.pages.dev/logos/sendcloud-light.svg" height="42px" alt="SendCloud" />
|
||||
</picture>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<h4 align="center">Bronze Sponsors</h4>
|
||||
<p align="center">
|
||||
<a href="https://www.rtvision.com/" target="_blank" rel="noopener noreferrer">
|
||||
<picture>
|
||||
<source srcset="https://avatars.githubusercontent.com/u/8292810" media="(prefers-color-scheme: dark)" height="26px" alt="RTVision" />
|
||||
<img src="https://avatars.githubusercontent.com/u/8292810" height="26px" alt="RTVision" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="https://storyblok.com" target="_blank" rel="noopener noreferrer">
|
||||
<picture>
|
||||
<source srcset="https://posva-sponsors.pages.dev/logos/storyblok.png" media="(prefers-color-scheme: dark)" height="26px" alt="Storyblok" />
|
||||
<img src="https://posva-sponsors.pages.dev/logos/storyblok.png" height="26px" alt="Storyblok" />
|
||||
</picture>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<!--sponsors end-->
|
||||
|
||||
---
|
||||
|
||||
Get started with the [documentation](https://router.vuejs.org).
|
||||
|
||||
## Quickstart
|
||||
|
||||
- In-browser [playground](https://play.vuejs.org/#eNqlVG1v2jAQ/iu3dBJUg5iyTZqyFLWrqnXTXqpu2pdlH0JiIG1iW7ZDqVD++8523ii0XyoEOHfP3T13z8Vbr4gz5t8qL/CyQnCpYQuJpLGm50JABQvJCxisSzqIWAuQvNRUtl6fOEMHMbGNLxbCd/ERazMP8XscMQC/VHTowt1zwUumh4MjDBsceyOvDkd+oaaFyDF+ZoDh6mR2RfOcm2KvQoKP1izsHx6UlpwtZxellJRpxxlErFdBSGofbLfw2jr8RZnn1+iEqrJpiMsTsnjdJLyxLL9l7A40P408EnmzzxzPcMULGpLO/2REPEdLG3ZunvbiQtLUDI02u7n+ZPQeSI2r3SFpB4PzcrP09QFFv9OCy4erTGn8G9VGl7ev9LhVs9XTNGhLN6I2hlrZRnbT0A6utbQrQDcWmnCmalEknO5wGW5NeytHMzjEfXg8MhAbrQL460a0derCgAywOY6UGAofdOQrG9UHWj120V0PDv4PfytcTRxtv2mzjyqRmdCgqC4F5DFbosRaobxGE+fEIz48WtzprMmEazvdU3BnZi+r06Y6WMipNi5igRcAZ1jKTj6qHVghAGsxtm4xjDnyVloLFRBSMnG39HGApEOcvScpKtWz+FQV47nk9wrPt5i5liLyzhBEUrrWnOdqHIvsqfR7wLMP/ok/7Sr1fXv1TDl8sytsWytcvkW2fNS02YEsp/Kn0Bku507zMd4z91+tTcuStuSTFU3uDthv1ca1cS0pMljTXsM6lkuKl4BxX/76QTd4bp0FT8sc0c84b6jieWk4OtinkqVIu4ezbL9YDTO2/K0uN5oy1TRliNppWLwV9uKZ1ju6b/13vSkq/ZBT5SfKXDR4Y43AXEcubs5lSmUAU7EBJJulcDSZTD4aV4HpMjaec615EcDJRGysXcRpimRbC1aJGKaFGcTwBr82cR2d0wW+qX3katqv3KXvCCRJ0iMQwAQ/0zqDV/0H+yxf5Q==)
|
||||
- Add it to an existing Vue Project:
|
||||
|
||||
```bash
|
||||
npm install vue-router@5
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
See [Contributing Guide](https://github.com/vuejs/router/blob/main/.github/contributing.md).
|
||||
|
||||
## Special Thanks
|
||||
|
||||
<a href="https://www.browserstack.com">
|
||||
<img src="https://github.com/vuejs/vue-router/raw/dev/assets/browserstack-logo-600x315.png" height="80" title="BrowserStack Logo" alt="BrowserStack Logo" />
|
||||
</a>
|
||||
|
||||
Special thanks to [BrowserStack](https://www.browserstack.com) for letting the maintainers use their service to debug browser specific issues.
|
||||
+1056
File diff suppressed because it is too large
Load Diff
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { $n as defineParamParserRaw, An as MatchMiss, Bn as EXPERIMENTAL_RouterOptions, Cn as ParamParserTypeOf, Dn as PathParamNamesForFilePath, En as ParamParsers_Native, Fn as EXPERIMENTAL_RouteRecordRaw, Gn as createFixedResolver, Hn as EXPERIMENTAL_Router_Base, In as EXPERIMENTAL_RouteRecord_Base, Jn as ExtractParamParserType, Kn as MatcherPatternQuery, Ln as EXPERIMENTAL_RouteRecord_Group, Mn as EXPERIMENTAL_RouteRecordNormalized, Nn as EXPERIMENTAL_RouteRecordNormalized_Group, On as _mergeRouteRecord, Pn as EXPERIMENTAL_RouteRecordNormalized_Matchable, Qn as defineParamParser, Rn as EXPERIMENTAL_RouteRecord_Matchable, Sn as ParamParserType, Tn as ParamParsers, Un as experimental_createRouter, Vn as EXPERIMENTAL_RouterOptions_Base, Wn as normalizeRouteRecord, Xn as PARAM_PARSER_INT, Yn as normalizeParamParser, Zn as PARAM_PARSER_BOOL, _ as getCurrentContext, _n as defineBasicLoader, a as DefineLoaderFn, ar as MatcherPatternPath, b as withLoaderContext, bn as DefinePageQueryParamOptions, c as UseDataLoaderResult, cn as NavigationResult, cr as MatcherPatternPathStatic, d as DataLoaderPluginOptions, dn as DefineDataLoaderOptions, f as NavigationResult$1, fn as DefineDataLoaderOptions_DefinedData, fr as ParamParser, gn as UseDataLoaderBasic_LaxData, h as useIsDataLoading, hn as UseDataLoaderBasic_DefinedData, i as DefineDataLoaderOptionsBase_LaxData, ir as MatcherPatternHash, jn as miss, kn as definePage, l as toLazyValue, ln as DataLoaderBasicEntry, lr as MatcherQueryParams, m as reroute, mn as UseDataLoaderBasic, n as DataLoaderEntryBase, nr as MatcherParamsFormatted, o as UseDataLoader, or as MatcherPatternPathDynamic, p as SetupLoaderGuardOptions, pn as DefineDataLoaderOptions_LaxData, qn as MatcherPatternQueryParam, r as DefineDataLoaderOptionsBase_DefinedData, rr as MatcherPattern, s as UseDataLoaderInternals, sr as MatcherPatternPathDynamic_ParamOptions, t as DataLoaderContextBase, tr as EmptyParams, u as DataLoaderPlugin, un as DataLoaderContext, ur as MatcherQueryParamsValue, v as setCurrentContext, vn as ErrorDefault, wn as ParamParserType_Native, xn as DefinePageQueryParamOptionsAny, y as trackRoute, yn as DefinePage, zn as EXPERIMENTAL_Router } from "../index-BN0B0y8a.js";
|
||||
export { type DataLoaderBasicEntry, type DataLoaderContext, type DataLoaderContextBase, type DataLoaderEntryBase, DataLoaderPlugin, type DataLoaderPluginOptions, type DefineDataLoaderOptions, type DefineDataLoaderOptionsBase_DefinedData, type DefineDataLoaderOptionsBase_LaxData, type DefineDataLoaderOptions_DefinedData, type DefineDataLoaderOptions_LaxData, type DefineLoaderFn, type DefinePage, type DefinePageQueryParamOptions, type EXPERIMENTAL_RouteRecordNormalized, type EXPERIMENTAL_RouteRecordNormalized_Group, type EXPERIMENTAL_RouteRecordNormalized_Matchable, type EXPERIMENTAL_RouteRecordRaw, type EXPERIMENTAL_RouteRecord_Base, type EXPERIMENTAL_RouteRecord_Group, type EXPERIMENTAL_RouteRecord_Matchable, type EXPERIMENTAL_Router, type EXPERIMENTAL_RouterOptions, type EXPERIMENTAL_RouterOptions_Base, type EXPERIMENTAL_Router_Base, type EmptyParams, type ErrorDefault, type MatcherParamsFormatted, type MatcherPattern, type MatcherPatternHash, type MatcherPatternPath, MatcherPatternPathDynamic, type MatcherPatternPathDynamic_ParamOptions, MatcherPatternPathStatic, type MatcherPatternQuery, MatcherPatternQueryParam, type MatcherQueryParams, type MatcherQueryParamsValue, NavigationResult, PARAM_PARSER_BOOL, PARAM_PARSER_INT, type ParamParser, type ParamParserType, type ParamParserTypeOf, type ParamParserType_Native, type SetupLoaderGuardOptions, type UseDataLoader, type UseDataLoaderBasic, type UseDataLoaderBasic_DefinedData, type UseDataLoaderBasic_LaxData, type UseDataLoaderInternals, type UseDataLoaderResult, type DefinePageQueryParamOptionsAny as _DefinePageQueryParamOptionsAny, type ExtractParamParserType as _ExtractParamParserType, MatchMiss as _MatchMiss, NavigationResult$1 as _NavigationResult, type ParamParsers as _ParamParsers, type ParamParsers_Native as _ParamParsers_Native, type PathParamNamesForFilePath as _PathParamNamesForFilePath, _mergeRouteRecord, normalizeParamParser as _normalizeParamParser, createFixedResolver, defineBasicLoader, definePage, defineParamParser, defineParamParserRaw, experimental_createRouter, getCurrentContext, miss, normalizeRouteRecord, reroute, setCurrentContext, toLazyValue, trackRoute, useIsDataLoading, withLoaderContext };
|
||||
+1108
File diff suppressed because it is too large
Load Diff
+151
@@ -0,0 +1,151 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { It as RouteMap, a as DefineLoaderFn, c as UseDataLoaderResult, f as NavigationResult, g as _PromiseMerged, i as DefineDataLoaderOptionsBase_LaxData, mr as LocationQuery, n as DataLoaderEntryBase, o as UseDataLoader, pt as RouteLocationNormalizedLoaded, r as DefineDataLoaderOptionsBase_DefinedData, t as DataLoaderContextBase, vn as ErrorDefault } from "../index-BN0B0y8a.js";
|
||||
import { ShallowRef } from "vue";
|
||||
import { EntryKey, UseQueryOptions, UseQueryReturn } from "@pinia/colada";
|
||||
//#region src/experimental/data-loaders/defineColadaLoader.d.ts
|
||||
/**
|
||||
* Creates a Pinia Colada data loader with `data` is always defined.
|
||||
*
|
||||
* @param name - name of the route to have typed routes
|
||||
* @param options - options to configure the data loader
|
||||
*/
|
||||
declare function defineColadaLoader<Name extends keyof RouteMap, Data>(name: Name, options: DefineDataColadaLoaderOptions_DefinedData<Name, Data>): UseDataLoaderColada_DefinedData<Data>;
|
||||
/**
|
||||
* Creates a Pinia Colada data loader with `data` is possibly `undefined`.
|
||||
*
|
||||
* @param name - name of the route to have typed routes
|
||||
* @param options - options to configure the data loader
|
||||
*/
|
||||
declare function defineColadaLoader<Name extends keyof RouteMap, Data>(name: Name, options: DefineDataColadaLoaderOptions_LaxData<Name, Data>): UseDataLoaderColada_LaxData<Data>;
|
||||
/**
|
||||
* Creates a Pinia Colada data loader with `data` is always defined.
|
||||
* @param options - options to configure the data loader
|
||||
*/
|
||||
declare function defineColadaLoader<Data>(options: DefineDataColadaLoaderOptions_DefinedData<keyof RouteMap, Data>): UseDataLoaderColada_DefinedData<Data>;
|
||||
/**
|
||||
* Creates a Pinia Colada data loader with `data` is possibly `undefined`.
|
||||
* @param options - options to configure the data loader
|
||||
*/
|
||||
declare function defineColadaLoader<Data>(options: DefineDataColadaLoaderOptions_LaxData<keyof RouteMap, Data>): UseDataLoaderColada_LaxData<Data>;
|
||||
/**
|
||||
* Base type with docs for the options of `defineColadaLoader`.
|
||||
* @internal
|
||||
*/
|
||||
interface _DefineDataColadaLoaderOptions_Common<Name extends keyof RouteMap, Data> extends Omit<UseQueryOptions<Data, ErrorDefault, Data>, 'query' | 'key'> {
|
||||
/**
|
||||
* Key associated with the data and passed to pinia colada
|
||||
* @param to - Route to load the data
|
||||
*/
|
||||
key: EntryKey | ((to: RouteLocationNormalizedLoaded<Name>) => EntryKey);
|
||||
/**
|
||||
* Function that returns a promise with the data.
|
||||
*/
|
||||
query: DefineLoaderFn<Data, DataColadaLoaderContext, RouteLocationNormalizedLoaded<Name>>;
|
||||
}
|
||||
/**
|
||||
* Options for `defineColadaLoader` when the data is possibly `undefined`.
|
||||
*/
|
||||
interface DefineDataColadaLoaderOptions_LaxData<Name extends keyof RouteMap, Data> extends _DefineDataColadaLoaderOptions_Common<Name, Data>, DefineDataLoaderOptionsBase_LaxData {}
|
||||
/**
|
||||
* Options for `defineColadaLoader` when the data is always defined.
|
||||
*/
|
||||
interface DefineDataColadaLoaderOptions_DefinedData<Name extends keyof RouteMap, Data> extends _DefineDataColadaLoaderOptions_Common<Name, Data>, DefineDataLoaderOptionsBase_DefinedData {}
|
||||
/**
|
||||
* @deprecated Use {@link `DefineDataColadaLoaderOptions_LaxData`} instead.
|
||||
*/
|
||||
type DefineDataColadaLoaderOptions<Name extends keyof RouteMap, Data> = DefineDataColadaLoaderOptions_LaxData<Name, Data>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface DataColadaLoaderContext extends DataLoaderContextBase {}
|
||||
interface UseDataLoaderColadaResult<TData, TError = ErrorDefault, TDataInitial extends TData | undefined = TData | undefined> extends UseDataLoaderResult<TData | TDataInitial, ErrorDefault>, Pick<UseQueryReturn<TData, TError, TDataInitial>, 'isPending' | 'status' | 'asyncStatus' | 'state'> {
|
||||
/**
|
||||
* Equivalent to `useQuery().refetch()`. Refetches the data no matter if its stale or not.
|
||||
* @see reload - It also calls `refetch()` but returns an empty promise
|
||||
*/
|
||||
refetch: (to?: RouteLocationNormalizedLoaded) => ReturnType<UseQueryReturn<TData, TError, TDataInitial>['refetch']>;
|
||||
/**
|
||||
* Equivalent to `useQuery().refresh()`. Refetches the data **only** if it's stale.
|
||||
*/
|
||||
refresh: (to?: RouteLocationNormalizedLoaded) => ReturnType<UseQueryReturn<TData, TError, TDataInitial>['refetch']>;
|
||||
}
|
||||
/**
|
||||
* Data Loader composable returned by `defineColadaLoader()`.
|
||||
*/
|
||||
interface UseDataLoaderColada_LaxData<Data> extends UseDataLoader<Data | undefined, ErrorDefault> {
|
||||
/**
|
||||
* Data Loader composable returned by `defineColadaLoader()`.
|
||||
*
|
||||
* @example
|
||||
* Returns the Data loader data, isLoading, error etc. Meant to be used in `setup()` or `<script setup>` **without `await`**:
|
||||
* ```vue
|
||||
* <script setup>
|
||||
* const { data, isLoading, error } = useUserData()
|
||||
* </script>
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* It also returns a promise of the data when used in nested loaders. Note this `data` is **not a ref**. This is not meant to be used in `setup()` or `<script setup>`.
|
||||
* ```ts
|
||||
* export const useUserConnections = defineLoader(async () => {
|
||||
* const user = await useUserData()
|
||||
* return fetchUserConnections(user.id)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
(): _PromiseMerged<Exclude<Data, NavigationResult | undefined>, UseDataLoaderColadaResult<Exclude<Data, NavigationResult> | undefined>>;
|
||||
}
|
||||
/**
|
||||
* Data Loader composable returned by `defineColadaLoader()`.
|
||||
*/
|
||||
interface UseDataLoaderColada_DefinedData<TData> extends UseDataLoader<TData, ErrorDefault> {
|
||||
/**
|
||||
* Data Loader composable returned by `defineColadaLoader()`.
|
||||
*
|
||||
* @example
|
||||
* Returns the Data loader data, isLoading, error etc. Meant to be used in `setup()` or `<script setup>` **without `await`**:
|
||||
* ```vue
|
||||
* <script setup>
|
||||
* const { data, isLoading, error } = useUserData()
|
||||
* </script>
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* It also returns a promise of the data when used in nested loaders. Note this `data` is **not a ref**. This is not meant to be used in `setup()` or `<script setup>`.
|
||||
* ```ts
|
||||
* export const useUserConnections = defineLoader(async () => {
|
||||
* const user = await useUserData()
|
||||
* return fetchUserConnections(user.id)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
(): _PromiseMerged<Exclude<TData, NavigationResult | undefined>, UseDataLoaderColadaResult<Exclude<TData, NavigationResult>, ErrorDefault, Exclude<TData, NavigationResult>>>;
|
||||
}
|
||||
interface DataLoaderColadaEntry<TData, TError = unknown, TDataInitial extends TData | undefined = TData | undefined> extends DataLoaderEntryBase<TData, TError, TDataInitial> {
|
||||
/**
|
||||
* Reactive route passed to pinia colada so it automatically refetch
|
||||
*/
|
||||
route: ShallowRef<RouteLocationNormalizedLoaded>;
|
||||
/**
|
||||
* Tracked routes to know when the data should be refreshed. Key is the key of the query.
|
||||
*/
|
||||
tracked: Map<string, TrackedRoute>;
|
||||
/**
|
||||
* Extended options for pinia colada
|
||||
*/
|
||||
ext: UseQueryReturn<TData, TError, TDataInitial> | null;
|
||||
}
|
||||
interface TrackedRoute {
|
||||
ready: boolean;
|
||||
params: Partial<LocationQuery>;
|
||||
query: Partial<LocationQuery>;
|
||||
hash: {
|
||||
v: string | null;
|
||||
};
|
||||
}
|
||||
//#endregion
|
||||
export { type DataColadaLoaderContext, type DataLoaderColadaEntry, type DefineDataColadaLoaderOptions, type DefineDataColadaLoaderOptions_DefinedData, type DefineDataColadaLoaderOptions_LaxData, type UseDataLoaderColadaResult, type UseDataLoaderColada_DefinedData, type UseDataLoaderColada_LaxData, type _DefineDataColadaLoaderOptions_Common, defineColadaLoader };
|
||||
+232
@@ -0,0 +1,232 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { c as diagnostics, n as useRouter, t as useRoute } from "../useApi-CROJJdhE.js";
|
||||
import { a as assign, b as toLazyValue, c as setCurrentContext, d as ABORT_CONTROLLER_KEY, f as APP_KEY, g as LOADER_ENTRIES_KEY, h as IS_USE_DATA_LOADER_KEY, l as trackRoute, m as IS_SSR_KEY, n as NavigationResult, o as getCurrentContext, p as DATA_LOADERS_EFFECT_SCOPE_KEY, s as isSubsetOf, v as PENDING_LOCATION_KEY, y as STAGED_NO_VALUE } from "../navigation-guard-FVgy-neA.js";
|
||||
import { shallowRef, watch } from "vue";
|
||||
import { defineQuery, useQuery, useQueryCache } from "@pinia/colada";
|
||||
//#region src/experimental/data-loaders/defineColadaLoader.ts
|
||||
function defineColadaLoader(nameOrOptions, _options) {
|
||||
_options = _options || nameOrOptions;
|
||||
const loader = _options.query;
|
||||
const options = {
|
||||
...DEFAULT_DEFINE_LOADER_OPTIONS,
|
||||
..._options,
|
||||
commit: _options?.commit || "after-load"
|
||||
};
|
||||
let isInitial = true;
|
||||
const useDefinedQuery = defineQuery(() => {
|
||||
const router = useRouter();
|
||||
const entry = router[LOADER_ENTRIES_KEY].get(loader);
|
||||
return useQuery({
|
||||
...options,
|
||||
query: () => {
|
||||
const route = entry.route.value;
|
||||
const [trackedRoute, params, query, hash] = trackRoute(route);
|
||||
entry.tracked.set(joinKeys(serializeQueryKey(options.key, trackedRoute)), {
|
||||
ready: false,
|
||||
params,
|
||||
query,
|
||||
hash
|
||||
});
|
||||
return router[APP_KEY].runWithContext(() => loader(trackedRoute, { signal: route.meta[ABORT_CONTROLLER_KEY]?.signal }));
|
||||
},
|
||||
key: () => toValueWithParameters(options.key, entry.route.value)
|
||||
});
|
||||
});
|
||||
function load(to, router, from, parent, reload) {
|
||||
const entries = router[LOADER_ENTRIES_KEY];
|
||||
const isSSR = router[IS_SSR_KEY];
|
||||
const key = serializeQueryKey(options.key, to);
|
||||
if (!entries.has(loader)) {
|
||||
const route = shallowRef(to);
|
||||
entries.set(loader, {
|
||||
data: shallowRef(),
|
||||
isLoading: shallowRef(false),
|
||||
error: shallowRef(null),
|
||||
to,
|
||||
options,
|
||||
children: /* @__PURE__ */ new Set(),
|
||||
resetPending() {
|
||||
this.pendingTo = null;
|
||||
this.pendingLoad = null;
|
||||
this.isLoading.value = false;
|
||||
},
|
||||
staged: STAGED_NO_VALUE,
|
||||
stagedError: null,
|
||||
commit,
|
||||
tracked: /* @__PURE__ */ new Map(),
|
||||
ext: null,
|
||||
route,
|
||||
pendingTo: null,
|
||||
pendingLoad: null
|
||||
});
|
||||
}
|
||||
const entry = entries.get(loader);
|
||||
if (entry.pendingTo === to && entry.pendingLoad) return entry.pendingLoad;
|
||||
const currentContext = getCurrentContext();
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
if (parent !== currentContext[0]) diagnostics.VUE_ROUTER_R1001({ key: `[${key.join(",")}]` });
|
||||
}
|
||||
setCurrentContext([
|
||||
entry,
|
||||
router,
|
||||
to
|
||||
]);
|
||||
if (!entry.ext) {
|
||||
entry.ext = useDefinedQuery();
|
||||
useQueryCache().get(toValueWithParameters(options.key, to))?.deps.delete(router[DATA_LOADERS_EFFECT_SCOPE_KEY]);
|
||||
reload = false;
|
||||
}
|
||||
const { isLoading, data, error, ext } = entry;
|
||||
if (isInitial) {
|
||||
isInitial = false;
|
||||
if (ext.data.value !== void 0) {
|
||||
data.value = ext.data.value;
|
||||
setCurrentContext(currentContext);
|
||||
return entry.pendingLoad = Promise.resolve();
|
||||
}
|
||||
}
|
||||
if (entry.route.value !== to) {
|
||||
const tracked = entry.tracked.get(joinKeys(key));
|
||||
reload = !tracked || hasRouteChanged(to, tracked);
|
||||
}
|
||||
entry.route.value = entry.pendingTo = to;
|
||||
isLoading.value = true;
|
||||
entry.staged = STAGED_NO_VALUE;
|
||||
entry.stagedError = error.value;
|
||||
const currentLoad = ext[reload ? "refetch" : "refresh"]().then(() => {
|
||||
if (entry.pendingLoad === currentLoad) {
|
||||
const newError = ext.error.value;
|
||||
if (newError) {
|
||||
if (newError instanceof NavigationResult) {
|
||||
entry.pendingTo = null;
|
||||
throw newError;
|
||||
}
|
||||
entry.stagedError = newError;
|
||||
if (!toLazyValue(options.lazy, to, from) || isSSR) throw newError;
|
||||
} else {
|
||||
const newData = ext.data.value;
|
||||
if (newData instanceof NavigationResult) {
|
||||
if (process.env.NODE_ENV !== "production") diagnostics.VUE_ROUTER_R1002();
|
||||
entry.pendingTo = null;
|
||||
throw newData;
|
||||
} else {
|
||||
entry.staged = newData;
|
||||
entry.stagedError = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}).finally(() => {
|
||||
setCurrentContext(currentContext);
|
||||
if (entry.pendingLoad === currentLoad) {
|
||||
isLoading.value = false;
|
||||
if (options.commit === "immediate" || !router[PENDING_LOCATION_KEY]) entry.commit(to);
|
||||
}
|
||||
});
|
||||
setCurrentContext(currentContext);
|
||||
entry.pendingLoad = currentLoad;
|
||||
return currentLoad;
|
||||
}
|
||||
function commit(to) {
|
||||
const key = serializeQueryKey(options.key, to);
|
||||
if (this.pendingTo === to) {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
if (this.staged === STAGED_NO_VALUE && this.stagedError === null) diagnostics.VUE_ROUTER_R1003({ key: String(key) });
|
||||
}
|
||||
if (this.staged !== STAGED_NO_VALUE) {
|
||||
this.data.value = this.staged;
|
||||
if (process.env.NODE_ENV !== "production" && !this.tracked.has(joinKeys(key))) {
|
||||
diagnostics.VUE_ROUTER_R1006({ key: key.join(", ") });
|
||||
return;
|
||||
}
|
||||
this.tracked.get(joinKeys(key)).ready = true;
|
||||
}
|
||||
this.error.value = this.stagedError;
|
||||
this.staged = STAGED_NO_VALUE;
|
||||
this.stagedError = this.error.value;
|
||||
this.to = to;
|
||||
this.pendingTo = null;
|
||||
for (const childEntry of this.children) childEntry.commit(to);
|
||||
}
|
||||
}
|
||||
const useDataLoader = () => {
|
||||
const currentContext = getCurrentContext();
|
||||
const [parentEntry, _router, _route] = currentContext;
|
||||
const router = _router || useRouter();
|
||||
const route = _route || useRoute();
|
||||
const app = router[APP_KEY];
|
||||
const entries = router[LOADER_ENTRIES_KEY];
|
||||
let entry = entries.get(loader);
|
||||
if (!entry || parentEntry && entry.pendingTo !== route || !entry.pendingLoad) app.runWithContext(() => load(route, router, void 0, parentEntry, true));
|
||||
entry = entries.get(loader);
|
||||
if (parentEntry) {
|
||||
if (parentEntry !== entry) parentEntry.children.add(entry);
|
||||
}
|
||||
const { data, error, isLoading } = entry;
|
||||
const ext = useDefinedQuery();
|
||||
useQueryCache().get(toValueWithParameters(options.key, route))?.deps.delete(router[DATA_LOADERS_EFFECT_SCOPE_KEY]);
|
||||
watch(ext.data, (newData) => {
|
||||
if (!router[PENDING_LOCATION_KEY]) data.value = newData;
|
||||
});
|
||||
watch(ext.isLoading, (isFetching) => {
|
||||
if (!router[PENDING_LOCATION_KEY]) isLoading.value = isFetching;
|
||||
});
|
||||
watch(ext.error, (newError) => {
|
||||
if (!router[PENDING_LOCATION_KEY]) error.value = newError;
|
||||
});
|
||||
const useDataLoaderResult = {
|
||||
data,
|
||||
error,
|
||||
isLoading,
|
||||
reload: (to = router.currentRoute.value) => app.runWithContext(() => load(to, router, void 0, void 0, true)).then(() => entry.commit(to)),
|
||||
refetch: (to = router.currentRoute.value) => app.runWithContext(() => load(to, router, void 0, void 0, true)).then(() => (entry.commit(to), entry.ext.state.value)),
|
||||
refresh: (to = router.currentRoute.value) => app.runWithContext(() => load(to, router)).then(() => (entry.commit(to), entry.ext.state.value)),
|
||||
status: ext.status,
|
||||
asyncStatus: ext.asyncStatus,
|
||||
state: ext.state,
|
||||
isPending: ext.isPending
|
||||
};
|
||||
const promise = entry.pendingLoad.then(() => entry.staged === STAGED_NO_VALUE ? ext.data.value : entry.staged).catch((e) => parentEntry ? Promise.reject(e) : null).finally(() => setCurrentContext(currentContext));
|
||||
setCurrentContext(currentContext);
|
||||
return assign(promise, useDataLoaderResult);
|
||||
};
|
||||
useDataLoader[IS_USE_DATA_LOADER_KEY] = true;
|
||||
useDataLoader._ = {
|
||||
load,
|
||||
options,
|
||||
getEntry(router) {
|
||||
return router[LOADER_ENTRIES_KEY].get(loader);
|
||||
}
|
||||
};
|
||||
return useDataLoader;
|
||||
}
|
||||
const joinKeys = (keys) => keys.join("|");
|
||||
function hasRouteChanged(to, tracked) {
|
||||
return !tracked.ready || !isSubsetOf(tracked.params, to.params) || !isSubsetOf(tracked.query, to.query) || tracked.hash.v != null && tracked.hash.v !== to.hash;
|
||||
}
|
||||
const DEFAULT_DEFINE_LOADER_OPTIONS = {
|
||||
lazy: false,
|
||||
server: true,
|
||||
commit: "after-load"
|
||||
};
|
||||
const toValueWithParameters = (optionValue, arg) => {
|
||||
return typeof optionValue === "function" ? optionValue(arg) : optionValue;
|
||||
};
|
||||
/**
|
||||
* Transform the key to a string array so it can be used as a key in caches.
|
||||
*
|
||||
* @param key - key to transform
|
||||
* @param to - route to use
|
||||
*/
|
||||
function serializeQueryKey(keyOption, to) {
|
||||
const key = toValueWithParameters(keyOption, to);
|
||||
return (Array.isArray(key) ? key : [key]).map(stringifyFlatObject);
|
||||
}
|
||||
function stringifyFlatObject(obj) {
|
||||
return obj && typeof obj === "object" ? JSON.stringify(obj, Object.keys(obj).sort()) : String(obj);
|
||||
}
|
||||
//#endregion
|
||||
export { defineColadaLoader };
|
||||
+3292
File diff suppressed because one or more lines are too long
+316
@@ -0,0 +1,316 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { c as diagnostics, d as isNavigationFailure } from "./useApi-CROJJdhE.js";
|
||||
import { effectScope, inject, shallowRef } from "vue";
|
||||
//#region src/experimental/data-loaders/createDataLoader.ts
|
||||
const toLazyValue = (lazy, to, from) => typeof lazy === "function" ? lazy(to, from) : lazy;
|
||||
//#endregion
|
||||
//#region src/experimental/data-loaders/symbols.ts
|
||||
/**
|
||||
* Retrieves the internal version of loaders.
|
||||
* @internal
|
||||
*/
|
||||
const LOADER_SET_KEY = Symbol("loaders");
|
||||
/**
|
||||
* Retrieves the internal version of loader entries.
|
||||
* @internal
|
||||
*/
|
||||
const LOADER_ENTRIES_KEY = Symbol("loaderEntries");
|
||||
/**
|
||||
* Added to the loaders returned by `defineLoader()` to identify them.
|
||||
* Allows to extract exported useData() from a component.
|
||||
* @internal
|
||||
*/
|
||||
const IS_USE_DATA_LOADER_KEY = Symbol();
|
||||
/**
|
||||
* Symbol used to save the pending location on the router.
|
||||
* @internal
|
||||
*/
|
||||
const PENDING_LOCATION_KEY = Symbol();
|
||||
/**
|
||||
* Symbol used to know there is no value staged for the loader and that commit should be skipped.
|
||||
* @internal
|
||||
*/
|
||||
const STAGED_NO_VALUE = Symbol();
|
||||
/**
|
||||
* Gives access to the current app and it's `runWithContext` method.
|
||||
* @internal
|
||||
*/
|
||||
const APP_KEY = Symbol();
|
||||
/**
|
||||
* Gives access to an AbortController that aborts when the navigation is canceled.
|
||||
* @internal
|
||||
*/
|
||||
const ABORT_CONTROLLER_KEY = Symbol();
|
||||
/**
|
||||
* Symbol used to save the initial data on the router.
|
||||
* @internal
|
||||
*/
|
||||
const IS_SSR_KEY = Symbol();
|
||||
/**
|
||||
* Symbol used to get the effect scope used for data loaders.
|
||||
* @internal
|
||||
*/
|
||||
const DATA_LOADERS_EFFECT_SCOPE_KEY = Symbol();
|
||||
//#endregion
|
||||
//#region src/experimental/data-loaders/utils.ts
|
||||
/**
|
||||
* Check if a value is a `DataLoader`.
|
||||
*
|
||||
* @param loader - the object to check
|
||||
*/
|
||||
function isDataLoader(loader) {
|
||||
return loader && loader[IS_USE_DATA_LOADER_KEY];
|
||||
}
|
||||
/**
|
||||
* @internal: data loaders authoring only. Use `getCurrentContext` instead.
|
||||
*/
|
||||
let currentContext;
|
||||
function getCurrentContext() {
|
||||
return currentContext || [];
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
function setCurrentContext(context) {
|
||||
currentContext = context ? context.length ? context : null : null;
|
||||
}
|
||||
/**
|
||||
* Restore the current context after a promise is resolved.
|
||||
* @param promise - promise to wrap
|
||||
*/
|
||||
function withLoaderContext(promise) {
|
||||
const context = currentContext;
|
||||
return promise.finally(() => currentContext = context);
|
||||
}
|
||||
const assign = Object.assign;
|
||||
/**
|
||||
* Track the reads of a route and its properties
|
||||
* @internal
|
||||
* @param route - route to track
|
||||
*/
|
||||
function trackRoute(route) {
|
||||
const [params, paramReads] = trackObjectReads(route.params);
|
||||
const [query, queryReads] = trackObjectReads(route.query);
|
||||
let hash = { v: null };
|
||||
return [
|
||||
{
|
||||
...route,
|
||||
get hash() {
|
||||
return hash.v = route.hash;
|
||||
},
|
||||
params,
|
||||
query
|
||||
},
|
||||
paramReads,
|
||||
queryReads,
|
||||
hash
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Track the reads of an object (that doesn't change) and add the read properties to an object
|
||||
* @internal
|
||||
* @param obj - object to track
|
||||
*/
|
||||
function trackObjectReads(obj) {
|
||||
const reads = {};
|
||||
return [new Proxy(obj, { get(target, p, receiver) {
|
||||
const value = Reflect.get(target, p, receiver);
|
||||
reads[p] = value;
|
||||
return value;
|
||||
} }), reads];
|
||||
}
|
||||
/**
|
||||
* Returns `true` if `inner` is a subset of `outer`. Used to check if a tr
|
||||
*
|
||||
* @internal
|
||||
* @param outer - the bigger params
|
||||
* @param inner - the smaller params
|
||||
*/
|
||||
function isSubsetOf(inner, outer) {
|
||||
for (const key in inner) {
|
||||
const innerValue = inner[key];
|
||||
const outerValue = outer[key];
|
||||
if (typeof innerValue === "string") {
|
||||
if (innerValue !== outerValue) return false;
|
||||
} else if (!innerValue || !outerValue) {
|
||||
if (innerValue !== outerValue) return false;
|
||||
} else if (!Array.isArray(outerValue) || outerValue.length !== innerValue.length || innerValue.some((value, i) => value !== outerValue[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/experimental/data-loaders/navigation-guard.ts
|
||||
/**
|
||||
* Key to inject the global loading state for loaders used in `useIsDataLoading`.
|
||||
* @internal
|
||||
*/
|
||||
const IS_DATA_LOADING_KEY = Symbol();
|
||||
/**
|
||||
* TODO: export functions that allow preloading outside of a navigation guard
|
||||
*/
|
||||
/**
|
||||
* Setups the different Navigation Guards to collect the data loaders from the route records and then to execute them.
|
||||
* @internal used by the `DataLoaderPlugin`
|
||||
* @see {@link DataLoaderPlugin}
|
||||
*
|
||||
* @param router - the router instance
|
||||
* @returns
|
||||
*/
|
||||
function setupLoaderGuard({ router, app, effect: scope, isSSR, errors: globalErrors = [] }) {
|
||||
if (router[LOADER_ENTRIES_KEY] != null) {
|
||||
if (process.env.NODE_ENV !== "production") diagnostics.VUE_ROUTER_R1007();
|
||||
return () => {};
|
||||
}
|
||||
if (process.env.NODE_ENV === "development" && !isSSR) diagnostics.VUE_ROUTER_R1008();
|
||||
router[LOADER_ENTRIES_KEY] = /* @__PURE__ */ new WeakMap();
|
||||
router[APP_KEY] = app;
|
||||
router[DATA_LOADERS_EFFECT_SCOPE_KEY] = scope;
|
||||
router[IS_SSR_KEY] = !!isSSR;
|
||||
const isDataLoading = scope.run(() => shallowRef(false));
|
||||
app.provide(IS_DATA_LOADING_KEY, isDataLoading);
|
||||
const removeLoaderGuard = router.beforeEach((to) => {
|
||||
if (router[PENDING_LOCATION_KEY]) router[PENDING_LOCATION_KEY].meta[ABORT_CONTROLLER_KEY]?.abort();
|
||||
router[PENDING_LOCATION_KEY] = to;
|
||||
to.meta[LOADER_SET_KEY] = /* @__PURE__ */ new Set();
|
||||
to.meta[ABORT_CONTROLLER_KEY] = new AbortController();
|
||||
for (const record of to.matched) record.meta[LOADER_SET_KEY] ??= new Set(record.meta.loaders || []);
|
||||
});
|
||||
const removeDataLoaderGuard = router.beforeResolve((to, from) => {
|
||||
for (const record of to.matched) {
|
||||
for (const loader of record.meta[LOADER_SET_KEY]) to.meta[LOADER_SET_KEY].add(loader);
|
||||
for (const componentName in record.mods) {
|
||||
const viewModule = record.mods[componentName];
|
||||
for (const exportName in viewModule) {
|
||||
const exportValue = viewModule[exportName];
|
||||
if (isDataLoader(exportValue)) to.meta[LOADER_SET_KEY].add(exportValue);
|
||||
}
|
||||
const component = record.components?.[componentName];
|
||||
if (component && Array.isArray(component.__loaders)) {
|
||||
for (const loader of component.__loaders) if (isDataLoader(loader)) to.meta[LOADER_SET_KEY].add(loader);
|
||||
}
|
||||
}
|
||||
}
|
||||
const loaders = Array.from(to.meta[LOADER_SET_KEY]);
|
||||
const { signal } = to.meta[ABORT_CONTROLLER_KEY];
|
||||
setCurrentContext([]);
|
||||
isDataLoading.value = true;
|
||||
return Promise.all(loaders.map((loader) => {
|
||||
const { server, lazy, errors } = loader._.options;
|
||||
if (!server && isSSR) return;
|
||||
const ret = scope.run(() => app.runWithContext(() => loader._.load(to, router, from)));
|
||||
return !isSSR && toLazyValue(lazy, to, from) ? void 0 : ret.catch((reason) => {
|
||||
if (errors === true) {
|
||||
if (Array.isArray(globalErrors) ? globalErrors.some((Err) => reason instanceof Err) : globalErrors(reason)) return;
|
||||
} else if (errors && (Array.isArray(errors) ? errors.some((Err) => reason instanceof Err) : errors(reason))) return;
|
||||
throw reason;
|
||||
});
|
||||
})).then((results) => {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
for (const result of results) if (result instanceof NavigationResult) {
|
||||
diagnostics.VUE_ROUTER_R1009();
|
||||
throw result;
|
||||
}
|
||||
}
|
||||
}).catch((error) => error instanceof NavigationResult ? error.value : signal.aborted && error === signal.reason ? false : Promise.reject(error)).finally(() => {
|
||||
setCurrentContext([]);
|
||||
isDataLoading.value = false;
|
||||
});
|
||||
});
|
||||
const removeAfterEach = router.afterEach((to, from, failure) => {
|
||||
if (failure) {
|
||||
to.meta[ABORT_CONTROLLER_KEY]?.abort(failure);
|
||||
if (isNavigationFailure(failure, 16)) for (const loader of to.meta[LOADER_SET_KEY]) loader._.getEntry(router).resetPending();
|
||||
} else for (const loader of to.meta[LOADER_SET_KEY]) {
|
||||
const { commit, lazy } = loader._.options;
|
||||
if (commit === "after-load") {
|
||||
const entry = loader._.getEntry(router);
|
||||
if (entry && (!toLazyValue(lazy, to, from) || !entry.isLoading.value)) entry.commit(to);
|
||||
}
|
||||
}
|
||||
if (router[PENDING_LOCATION_KEY] === to) router[PENDING_LOCATION_KEY] = null;
|
||||
});
|
||||
const removeOnError = router.onError((error, to) => {
|
||||
to.meta[ABORT_CONTROLLER_KEY]?.abort(error);
|
||||
if (router[PENDING_LOCATION_KEY] === to) router[PENDING_LOCATION_KEY] = null;
|
||||
});
|
||||
return () => {
|
||||
delete router[LOADER_ENTRIES_KEY];
|
||||
delete router[APP_KEY];
|
||||
removeLoaderGuard();
|
||||
removeDataLoaderGuard();
|
||||
removeAfterEach();
|
||||
removeOnError();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Allows data loaders to change navigation. Called by {@link reroute}.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
var NavigationResult = class {
|
||||
value;
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Changes the navigation from within a data loader. Accepts the same values as a navigation
|
||||
* guard return: a route location to redirect to, or `false` to cancel the navigation.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* export const useUserData = defineBasicLoader(async (to) => {
|
||||
* const user = await fetchUser(to.params.id)
|
||||
* if (!user) {
|
||||
* reroute('/404')
|
||||
* }
|
||||
* return user
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
function reroute(to) {
|
||||
throw new NavigationResult(to);
|
||||
}
|
||||
/**
|
||||
* Data Loader plugin to add data loading support to Vue Router.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const router = createRouter({
|
||||
* routes,
|
||||
* history: createWebHistory(),
|
||||
* })
|
||||
*
|
||||
* const app = createApp({})
|
||||
* app.use(DataLoaderPlugin, { router })
|
||||
* app.use(router)
|
||||
* ```
|
||||
*/
|
||||
function DataLoaderPlugin(app, options) {
|
||||
const effect = effectScope(true);
|
||||
const removeGuards = setupLoaderGuard(assign({
|
||||
app,
|
||||
effect
|
||||
}, options));
|
||||
app.onUnmount(() => {
|
||||
effect.stop();
|
||||
removeGuards();
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Return a ref that reflects the global loading state of all loaders within a navigation.
|
||||
* This state doesn't update if `refresh()` is manually called.
|
||||
*/
|
||||
function useIsDataLoading() {
|
||||
return inject(IS_DATA_LOADING_KEY);
|
||||
}
|
||||
//#endregion
|
||||
export { LOADER_SET_KEY as _, assign as a, toLazyValue as b, setCurrentContext as c, ABORT_CONTROLLER_KEY as d, APP_KEY as f, LOADER_ENTRIES_KEY as g, IS_USE_DATA_LOADER_KEY as h, useIsDataLoading as i, trackRoute as l, IS_SSR_KEY as m, NavigationResult as n, getCurrentContext as o, DATA_LOADERS_EFFECT_SCOPE_KEY as p, reroute as r, isSubsetOf as s, DataLoaderPlugin as t, withLoaderContext as u, PENDING_LOCATION_KEY as v, STAGED_NO_VALUE as y };
|
||||
+581
@@ -0,0 +1,581 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
let scule = require("scule");
|
||||
let nostics = require("nostics");
|
||||
let pathe = require("pathe");
|
||||
let local_pkg = require("local-pkg");
|
||||
//#region src/unplugin/utils/index.ts
|
||||
const ts = String.raw;
|
||||
/**
|
||||
* Pads a single-line string with spaces.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param spaces The number of spaces to pad with.
|
||||
* @param str The string to pad, none if omitted.
|
||||
* @returns The padded string.
|
||||
*/
|
||||
function pad(spaces, str = "") {
|
||||
return " ".repeat(spaces) + str;
|
||||
}
|
||||
/**
|
||||
* Formats an array of union items as a multiline union type.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param items The items to format.
|
||||
* @param spaces The number of spaces to indent each line.
|
||||
* @returns The formatted multiline union type.
|
||||
*/
|
||||
function formatMultilineUnion(items, spaces) {
|
||||
return (items.length ? items : ["never"]).map((s) => `| ${s}`).join(`\n${pad(spaces)}`);
|
||||
}
|
||||
/**
|
||||
* Converts a string value to a string literal, escaping as necessary.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param str the string to convert to a string type
|
||||
* @returns The string wrapped in single quotes and escaped.
|
||||
* @example
|
||||
* toStringLiteral('hello') // returns "'hello'"
|
||||
* toStringLiteral("it's fine") // returns "'it\'s fine'"
|
||||
*/
|
||||
function toStringLiteral(str) {
|
||||
return `'${str.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/unplugin/core/utils.ts
|
||||
function logTree(tree, log) {
|
||||
log(printTree(tree));
|
||||
}
|
||||
const MAX_LEVEL = 1e3;
|
||||
function printTree(tree, level = 0, parentPre = "", treeStr = "") {
|
||||
if (typeof tree !== "object" || level >= MAX_LEVEL) return "";
|
||||
if (tree instanceof Map) {
|
||||
const total = tree.size;
|
||||
let index = 0;
|
||||
for (const [_key, child] of tree) {
|
||||
const hasNext = index++ < total - 1;
|
||||
const { children } = child;
|
||||
treeStr += `${`${parentPre}${hasNext ? "├" : "└"}${"─" + (children.size > 0 ? "┬" : "")} `}${child}\n`;
|
||||
if (children) treeStr += printTree(children, level + 1, `${parentPre}${hasNext ? "│" : " "} `);
|
||||
}
|
||||
} else {
|
||||
const children = tree.children;
|
||||
treeStr = `${tree}\n`;
|
||||
if (children) treeStr += printTree(children, level + 1);
|
||||
}
|
||||
return treeStr;
|
||||
}
|
||||
/**
|
||||
* Type safe alternative to Array.isArray
|
||||
* https://github.com/microsoft/TypeScript/pull/48228
|
||||
*/
|
||||
const isArray = Array.isArray;
|
||||
function trimExtension(path, extensions) {
|
||||
for (const extension of extensions) {
|
||||
const lastDot = path.endsWith(extension) ? -extension.length : 0;
|
||||
if (lastDot < 0) return path.slice(0, lastDot);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
function throttle(fn, wait, initialWait) {
|
||||
let pendingExecutionTimeout = null;
|
||||
let pendingExecution = false;
|
||||
let executionTimeout = null;
|
||||
return () => {
|
||||
if (pendingExecutionTimeout == null) {
|
||||
pendingExecutionTimeout = setTimeout(() => {
|
||||
pendingExecutionTimeout = null;
|
||||
if (pendingExecution) {
|
||||
pendingExecution = false;
|
||||
fn();
|
||||
}
|
||||
}, wait);
|
||||
executionTimeout = setTimeout(() => {
|
||||
executionTimeout = null;
|
||||
fn();
|
||||
}, initialWait);
|
||||
} else if (executionTimeout == null) pendingExecution = true;
|
||||
};
|
||||
}
|
||||
const LEADING_SLASH_RE = /^\//;
|
||||
const TRAILING_SLASH_RE = /\/$/;
|
||||
const ESCAPED_TRAILING_SLASH_RE = /\\\/$/;
|
||||
function joinPath(...paths) {
|
||||
let result = "";
|
||||
for (const path of paths) result = result.replace(TRAILING_SLASH_RE, "") + (path && "/" + path.replace(LEADING_SLASH_RE, ""));
|
||||
return result || "/";
|
||||
}
|
||||
function paramToName({ paramName, modifier, isSplat }) {
|
||||
return `${isSplat ? "$" : ""}${paramName.charAt(0).toUpperCase() + paramName.slice(1)}${modifier}`;
|
||||
}
|
||||
/**
|
||||
* Creates a name based of the node path segments.
|
||||
*
|
||||
* @param node - the node to get the path from
|
||||
* @param parent - the parent node
|
||||
* @returns a route name
|
||||
*/
|
||||
function getPascalCaseRouteName(node) {
|
||||
if (node.parent?.isRoot() && node.value.pathSegment === "") return "Root";
|
||||
let name = node.value.subSegments.map((segment) => {
|
||||
if (typeof segment === "string") return (0, scule.pascalCase)(segment);
|
||||
return paramToName(segment);
|
||||
}).join("");
|
||||
if (node.value.components.size && node.children.has("index")) name += "Parent";
|
||||
const parent = node.parent;
|
||||
return (parent && !parent.isRoot() ? getPascalCaseRouteName(parent).replace(/Parent$/, "") : "") + name;
|
||||
}
|
||||
/**
|
||||
* Joins the path segments of a node into a name that corresponds to the filepath represented by the node.
|
||||
*
|
||||
* @param node - the node to get the path from
|
||||
* @returns a route name
|
||||
*/
|
||||
function getFileBasedRouteName(node) {
|
||||
if (!node.parent) return "";
|
||||
return getFileBasedRouteName(node.parent) + "/" + (node.value.rawSegment === "index" ? "" : node.value.rawSegment);
|
||||
}
|
||||
function mergeRouteRecordOverride(a, b) {
|
||||
const merged = {};
|
||||
const keys = [.../* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)])];
|
||||
for (const key of keys) if (key === "alias") merged[key] = [].concat(a.alias || [], b.alias || []);
|
||||
else if (key === "meta") merged[key] = mergeDeep(a[key] || {}, b[key] || {});
|
||||
else if (key === "params") merged[key] = {
|
||||
path: {
|
||||
...a[key]?.path,
|
||||
...b[key]?.path
|
||||
},
|
||||
query: {
|
||||
...a[key]?.query,
|
||||
...b[key]?.query
|
||||
}
|
||||
};
|
||||
else merged[key] = b[key] ?? a[key];
|
||||
return merged;
|
||||
}
|
||||
function isObject(obj) {
|
||||
return obj && typeof obj === "object";
|
||||
}
|
||||
function mergeDeep(...objects) {
|
||||
return objects.reduce((prev, obj) => {
|
||||
Object.keys(obj).forEach((key) => {
|
||||
const pVal = prev[key];
|
||||
const oVal = obj[key];
|
||||
if (Array.isArray(pVal) && Array.isArray(oVal)) prev[key] = pVal.concat(...oVal);
|
||||
else if (isObject(pVal) && isObject(oVal)) prev[key] = mergeDeep(pVal, oVal);
|
||||
else prev[key] = oVal;
|
||||
});
|
||||
return prev;
|
||||
}, {});
|
||||
}
|
||||
/**
|
||||
* Returns a route path to be used by the router with any defined prefix from an absolute path to a file. Since it
|
||||
* returns a route path, it will remove the extension from the file.
|
||||
*
|
||||
* @param options - RoutesFolderOption to apply
|
||||
* @param filePath - absolute path to file
|
||||
* @returns a route path to be used by the router with any defined prefix
|
||||
*/
|
||||
function asRoutePath({ src, path = "", extensions }, filePath) {
|
||||
return trimExtension(typeof path === "string" ? path + filePath.slice(src.length + 1) : path(filePath), extensions);
|
||||
}
|
||||
function appendExtensionListToPattern(filePatterns, extensions) {
|
||||
const extensionPattern = extensions.length === 1 ? extensions[0] : `.{${extensions.map((extension) => extension.replace(".", "")).join(",")}}`;
|
||||
return Array.isArray(filePatterns) ? filePatterns.map((filePattern) => `${filePattern}${extensionPattern}`) : `${filePatterns}${extensionPattern}`;
|
||||
}
|
||||
var ImportsMap = class {
|
||||
map = /* @__PURE__ */ new Map();
|
||||
constructor() {}
|
||||
add(path, importEntry) {
|
||||
if (!this.map.has(path)) this.map.set(path, /* @__PURE__ */ new Map());
|
||||
const imports = this.map.get(path);
|
||||
if (typeof importEntry === "string") imports.set(importEntry, importEntry);
|
||||
else imports.set(importEntry.as || importEntry.name, importEntry.name);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Check if the given path has the given import name.
|
||||
*
|
||||
* @param path - the path to check
|
||||
* @param name - the import name to check
|
||||
*/
|
||||
has(path, name) {
|
||||
return this.map.has(path) && this.map.get(path).has(name);
|
||||
}
|
||||
/**
|
||||
* Add a default import. Alias for `add(path, { name: 'default', as })`.
|
||||
*
|
||||
* @param path - the path to import from
|
||||
* @param as - the name to import as
|
||||
*/
|
||||
addDefault(path, as) {
|
||||
return this.add(path, {
|
||||
name: "default",
|
||||
as
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get the list of imports for the given path.
|
||||
*
|
||||
* @param path - the path to get the import list for
|
||||
* @returns the list of imports for the given path
|
||||
*/
|
||||
getImportList(path) {
|
||||
if (!this.map.has(path)) return [];
|
||||
return Array.from(this.map.get(path)).map(([as, name]) => ({
|
||||
as: as || name,
|
||||
name
|
||||
}));
|
||||
}
|
||||
toString() {
|
||||
let importStatements = "";
|
||||
for (const [path, imports] of this.map) {
|
||||
if (!imports.size) continue;
|
||||
const fromImportPath = toStringLiteral(path);
|
||||
if (imports.size === 1) {
|
||||
const [[importName, maybeDefault]] = [...imports.entries()];
|
||||
if (maybeDefault === "default") {
|
||||
importStatements += `import ${importName} from ${fromImportPath}\n`;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
importStatements += `import { ${Array.from(imports).map(([as, name]) => as === name ? name : `${name} as ${as}`).join(", ")} } from ${fromImportPath}\n`;
|
||||
}
|
||||
return importStatements;
|
||||
}
|
||||
get size() {
|
||||
return this.map.size;
|
||||
}
|
||||
};
|
||||
//#endregion
|
||||
//#region src/unplugin/diagnostics.ts
|
||||
/**
|
||||
* Build-time diagnostics catalog for the Vue Router unplugin (file-based
|
||||
* routing). These run in Node during the build, so they are not `__DEV__`
|
||||
* guarded and are reported on every build.
|
||||
*
|
||||
* `why` keeps the original warning text (so existing substring assertions keep
|
||||
* matching); the `VUE_ROUTER_B####` code identifies the source, so messages do not
|
||||
* repeat a `[vue-router]` prefix. Codes are permanent: never rename or reuse.
|
||||
*/
|
||||
const diagnostics = /*#__PURE__*/ (0, nostics.defineDiagnostics)({
|
||||
reporters: [/*#__PURE__*/ (0, nostics.createConsoleReporter)()],
|
||||
codes: {
|
||||
VUE_ROUTER_B0001: {
|
||||
why: (p) => `In file "${p.filename}": Failed to process definePage: ${p.message}`,
|
||||
fix: "Fix the syntax error in the definePage() macro of this file."
|
||||
},
|
||||
VUE_ROUTER_B0002: {
|
||||
why: (p) => `In file "${p.filename}": ${p.message}`,
|
||||
fix: "Avoid referencing <script setup> bindings inside definePage(); pass static values instead."
|
||||
},
|
||||
VUE_ROUTER_B0003: {
|
||||
why: (p) => `In file "${p.filename}": Failed to extract definePage info: ${p.message}`,
|
||||
fix: "Fix the syntax error in the definePage() macro of this file."
|
||||
},
|
||||
VUE_ROUTER_B0004: {
|
||||
why: (p) => `route name must be a string literal or false. Found in file "${p.filename}".`,
|
||||
fix: "Use a string literal or `false` for the route `name`."
|
||||
},
|
||||
VUE_ROUTER_B0005: {
|
||||
why: (p) => `route path must be a string literal. Found in file "${p.filename}".`,
|
||||
fix: "Use a string literal for the route `path`."
|
||||
},
|
||||
VUE_ROUTER_B0006: {
|
||||
why: (p) => `Unrecognized default value in definePage() for query param "${p.paramName}". Typeof value: "${p.type}". This is a bug or a missing type of value, open an issue on https://github.com/vuejs/router and provide the definePage() code.`,
|
||||
fix: "Report a reproduction at https://github.com/vuejs/router with the definePage() code."
|
||||
},
|
||||
VUE_ROUTER_B0007: {
|
||||
why: (p) => `route alias must be a string literal or an array of string literals. Found in file "${p.filename}".`,
|
||||
fix: "Use a string literal or an array of string literals for the route `alias`."
|
||||
},
|
||||
VUE_ROUTER_B0008: {
|
||||
why: (p) => `route alias array must only contain string literals. Found "${p.found}" in file "${p.filename}".`,
|
||||
fix: "Only use string literals inside the route `alias` array."
|
||||
},
|
||||
VUE_ROUTER_B0009: {
|
||||
why: (p) => `Invalid extension "${p.ext}". Extensions must start with a dot.`,
|
||||
fix: "Prefix the extension with a dot, e.g. \".vue\"."
|
||||
},
|
||||
VUE_ROUTER_B0010: {
|
||||
why: (p) => `Segment "${p.segment}" is missing the closing ")". It will be treated as a static segment.`,
|
||||
fix: "Add the closing \")\" to the dynamic segment."
|
||||
},
|
||||
VUE_ROUTER_B0011: {
|
||||
why: (p) => `Invalid parameter in path "${p.segment}": parameter name cannot be empty. Using default name "pathMatch" for ':()'.`,
|
||||
fix: "Give the parameter a name, e.g. \":id\"."
|
||||
},
|
||||
VUE_ROUTER_B0012: {
|
||||
why: (p) => `Invalid JSON5 format of <${p.type}> content in ${p.filePath}\n${p.message}`,
|
||||
fix: "Fix the JSON5 syntax in the route custom block."
|
||||
},
|
||||
VUE_ROUTER_B0013: {
|
||||
why: (p) => `Invalid JSON format of <${p.type}> content in ${p.filePath}\n${p.message}`,
|
||||
fix: "Fix the JSON syntax in the route custom block."
|
||||
},
|
||||
VUE_ROUTER_B0014: {
|
||||
why: (p) => `Invalid YAML format of <${p.type}> content in ${p.filePath}\n${p.message}`,
|
||||
fix: "Fix the YAML syntax in the route custom block."
|
||||
},
|
||||
VUE_ROUTER_B0015: {
|
||||
why: (p) => `Language "${p.lang}" for <${p.type}> is not supported. Supported languages are: json5, json, yaml, yml. Found in ${p.filePath}.`,
|
||||
fix: "Use one of the supported languages: json5, json, yaml, yml."
|
||||
},
|
||||
VUE_ROUTER_B0016: {
|
||||
why: (p) => `Error decoding "${p.text}". Using original value`,
|
||||
fix: "Ensure the value is correctly percent-encoded."
|
||||
},
|
||||
VUE_ROUTER_B0017: {
|
||||
why: (p) => `A parameter without a name was found in the route "${p.fullPath}" in segment "${p.path}".`,
|
||||
fix: "Report a reproduction at https://github.com/vuejs/router."
|
||||
},
|
||||
VUE_ROUTER_B0018: {
|
||||
why: (p) => `Cannot statically determine if "parser" is raw in "${p.filename}" because it is re-exported from "${p.source}". The generated route param types may be incorrect. Define the parser inline in this file with \`defineParamParser\`/\`defineParamParserRaw\` instead of re-exporting it.`,
|
||||
fix: "Define the parser inline with `defineParamParser`/`defineParamParserRaw` instead of re-exporting it."
|
||||
},
|
||||
VUE_ROUTER_B0019: {
|
||||
why: (p) => `Parameter parser "${p.parser}" not found for route "${p.fullPath}".`,
|
||||
fix: "Define the param parser or use one of the native parsers."
|
||||
}
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
//#region src/unplugin/options.ts
|
||||
/**
|
||||
* Resolves an overridable option by calling the function with the existing
|
||||
* value if it's a function, otherwise returning the passed `value`. If `value`
|
||||
* is undefined, it returns the `defaultValue` instead.
|
||||
*
|
||||
* @param defaultValue default value for the option
|
||||
* @param value and overridable option
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
function resolveOverridableOption(defaultValue, value) {
|
||||
return typeof value === "function" ? value(defaultValue) : value ?? defaultValue;
|
||||
}
|
||||
/**
|
||||
* Default options for experimental param parsers.
|
||||
*/
|
||||
const DEFAULT_PARAM_PARSERS_OPTIONS = {
|
||||
dir: ["src/params"],
|
||||
include: ["*.ts"],
|
||||
exclude: ["*.test.{ts,js}", "*.spec.{ts,js}"]
|
||||
};
|
||||
/**
|
||||
* Default plugin options.
|
||||
*/
|
||||
const DEFAULT_OPTIONS = {
|
||||
extensions: [".vue"],
|
||||
exclude: [],
|
||||
routesFolder: "src/pages",
|
||||
filePatterns: ["**/*"],
|
||||
routeBlockLang: "json5",
|
||||
getRouteName: getFileBasedRouteName,
|
||||
importMode: "async",
|
||||
root: process.cwd(),
|
||||
dts: (0, local_pkg.isPackageExists)("typescript"),
|
||||
logs: false,
|
||||
_inspect: false,
|
||||
pathParser: { dotNesting: true },
|
||||
watch: !process.env.CI,
|
||||
experimental: {}
|
||||
};
|
||||
function normalizeRoutesFolderOption(routesFolder) {
|
||||
return (isArray(routesFolder) ? routesFolder : [routesFolder]).map((routeOption) => normalizeRouteOption(typeof routeOption === "string" ? { src: routeOption } : routeOption));
|
||||
}
|
||||
function normalizeRouteOption(routeOption) {
|
||||
return {
|
||||
...routeOption,
|
||||
filePatterns: routeOption.filePatterns ? typeof routeOption.filePatterns === "function" ? routeOption.filePatterns : isArray(routeOption.filePatterns) ? routeOption.filePatterns : [routeOption.filePatterns] : void 0,
|
||||
exclude: routeOption.exclude ? typeof routeOption.exclude === "function" ? routeOption.exclude : isArray(routeOption.exclude) ? routeOption.exclude : [routeOption.exclude] : void 0
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Normalize user options with defaults and resolved paths.
|
||||
*
|
||||
* @param options - user provided options
|
||||
* @returns normalized options
|
||||
*/
|
||||
function resolveOptions(options) {
|
||||
const root = options.root || DEFAULT_OPTIONS.root;
|
||||
const routesFolder = normalizeRoutesFolderOption(options.routesFolder || DEFAULT_OPTIONS.routesFolder).map((routeOption) => ({
|
||||
...routeOption,
|
||||
src: (0, pathe.resolve)(root, routeOption.src)
|
||||
}));
|
||||
const paramParsers = options.experimental?.paramParsers ? options.experimental.paramParsers === true ? DEFAULT_PARAM_PARSERS_OPTIONS : {
|
||||
...DEFAULT_PARAM_PARSERS_OPTIONS,
|
||||
...options.experimental.paramParsers
|
||||
} : void 0;
|
||||
const paramParsersDir = (paramParsers?.dir ? isArray(paramParsers.dir) ? paramParsers.dir : [paramParsers.dir] : []).map((dir) => (0, pathe.resolve)(root, dir));
|
||||
const paramParsersInclude = paramParsers?.include ? isArray(paramParsers.include) ? paramParsers.include : [paramParsers.include] : DEFAULT_PARAM_PARSERS_OPTIONS.include;
|
||||
const paramParsersExclude = paramParsers?.exclude ? isArray(paramParsers.exclude) ? paramParsers.exclude : [paramParsers.exclude] : DEFAULT_PARAM_PARSERS_OPTIONS.exclude;
|
||||
const autoExportsDataLoaders = options.experimental?.autoExportsDataLoaders ? (isArray(options.experimental.autoExportsDataLoaders) ? options.experimental.autoExportsDataLoaders : [options.experimental.autoExportsDataLoaders]).map((path) => (0, pathe.resolve)(root, path)) : void 0;
|
||||
const experimental = {
|
||||
...options.experimental,
|
||||
autoExportsDataLoaders,
|
||||
paramParsers: paramParsers && {
|
||||
...paramParsers,
|
||||
dir: paramParsersDir,
|
||||
include: paramParsersInclude,
|
||||
exclude: paramParsersExclude
|
||||
}
|
||||
};
|
||||
if (options.extensions) options.extensions = options.extensions.map((ext) => {
|
||||
if (!ext.startsWith(".")) {
|
||||
diagnostics.VUE_ROUTER_B0009({ ext });
|
||||
return "." + ext;
|
||||
}
|
||||
return ext;
|
||||
}).sort((a, b) => b.length - a.length);
|
||||
const filePatterns = options.filePatterns ? isArray(options.filePatterns) ? options.filePatterns : [options.filePatterns] : DEFAULT_OPTIONS.filePatterns;
|
||||
const exclude = options.exclude ? isArray(options.exclude) ? options.exclude : [options.exclude] : DEFAULT_OPTIONS.exclude;
|
||||
return {
|
||||
...DEFAULT_OPTIONS,
|
||||
...options,
|
||||
experimental,
|
||||
routesFolder,
|
||||
filePatterns,
|
||||
exclude
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Merge all the possible extensions as an array of unique values
|
||||
* @param options - user provided options
|
||||
* @internal
|
||||
*/
|
||||
function mergeAllExtensions(options) {
|
||||
const allExtensions = new Set(options.extensions);
|
||||
for (const routeOption of options.routesFolder) if (routeOption.extensions) {
|
||||
const extensions = resolveOverridableOption(options.extensions, routeOption.extensions);
|
||||
for (const ext of extensions) allExtensions.add(ext);
|
||||
}
|
||||
return Array.from(allExtensions.values());
|
||||
}
|
||||
//#endregion
|
||||
Object.defineProperty(exports, "DEFAULT_OPTIONS", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return DEFAULT_OPTIONS;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "DEFAULT_PARAM_PARSERS_OPTIONS", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return DEFAULT_PARAM_PARSERS_OPTIONS;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "ESCAPED_TRAILING_SLASH_RE", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return ESCAPED_TRAILING_SLASH_RE;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "ImportsMap", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return ImportsMap;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "appendExtensionListToPattern", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return appendExtensionListToPattern;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "asRoutePath", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return asRoutePath;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "diagnostics", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return diagnostics;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "formatMultilineUnion", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return formatMultilineUnion;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "getFileBasedRouteName", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getFileBasedRouteName;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "getPascalCaseRouteName", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getPascalCaseRouteName;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "joinPath", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return joinPath;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "logTree", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return logTree;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "mergeAllExtensions", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return mergeAllExtensions;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "mergeRouteRecordOverride", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return mergeRouteRecordOverride;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "pad", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return pad;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "resolveOptions", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return resolveOptions;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "resolveOverridableOption", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return resolveOverridableOption;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "throttle", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return throttle;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "toStringLiteral", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return toStringLiteral;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "ts", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return ts;
|
||||
}
|
||||
});
|
||||
+462
@@ -0,0 +1,462 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { pascalCase } from "scule";
|
||||
import { createConsoleReporter, defineDiagnostics } from "nostics";
|
||||
import { resolve } from "pathe";
|
||||
import { isPackageExists } from "local-pkg";
|
||||
//#region src/unplugin/utils/index.ts
|
||||
const ts = String.raw;
|
||||
/**
|
||||
* Pads a single-line string with spaces.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param spaces The number of spaces to pad with.
|
||||
* @param str The string to pad, none if omitted.
|
||||
* @returns The padded string.
|
||||
*/
|
||||
function pad(spaces, str = "") {
|
||||
return " ".repeat(spaces) + str;
|
||||
}
|
||||
/**
|
||||
* Formats an array of union items as a multiline union type.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param items The items to format.
|
||||
* @param spaces The number of spaces to indent each line.
|
||||
* @returns The formatted multiline union type.
|
||||
*/
|
||||
function formatMultilineUnion(items, spaces) {
|
||||
return (items.length ? items : ["never"]).map((s) => `| ${s}`).join(`\n${pad(spaces)}`);
|
||||
}
|
||||
/**
|
||||
* Converts a string value to a string literal, escaping as necessary.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param str the string to convert to a string type
|
||||
* @returns The string wrapped in single quotes and escaped.
|
||||
* @example
|
||||
* toStringLiteral('hello') // returns "'hello'"
|
||||
* toStringLiteral("it's fine") // returns "'it\'s fine'"
|
||||
*/
|
||||
function toStringLiteral(str) {
|
||||
return `'${str.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/unplugin/core/utils.ts
|
||||
function logTree(tree, log) {
|
||||
log(printTree(tree));
|
||||
}
|
||||
const MAX_LEVEL = 1e3;
|
||||
function printTree(tree, level = 0, parentPre = "", treeStr = "") {
|
||||
if (typeof tree !== "object" || level >= MAX_LEVEL) return "";
|
||||
if (tree instanceof Map) {
|
||||
const total = tree.size;
|
||||
let index = 0;
|
||||
for (const [_key, child] of tree) {
|
||||
const hasNext = index++ < total - 1;
|
||||
const { children } = child;
|
||||
treeStr += `${`${parentPre}${hasNext ? "├" : "└"}${"─" + (children.size > 0 ? "┬" : "")} `}${child}\n`;
|
||||
if (children) treeStr += printTree(children, level + 1, `${parentPre}${hasNext ? "│" : " "} `);
|
||||
}
|
||||
} else {
|
||||
const children = tree.children;
|
||||
treeStr = `${tree}\n`;
|
||||
if (children) treeStr += printTree(children, level + 1);
|
||||
}
|
||||
return treeStr;
|
||||
}
|
||||
/**
|
||||
* Type safe alternative to Array.isArray
|
||||
* https://github.com/microsoft/TypeScript/pull/48228
|
||||
*/
|
||||
const isArray = Array.isArray;
|
||||
function trimExtension(path, extensions) {
|
||||
for (const extension of extensions) {
|
||||
const lastDot = path.endsWith(extension) ? -extension.length : 0;
|
||||
if (lastDot < 0) return path.slice(0, lastDot);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
function throttle(fn, wait, initialWait) {
|
||||
let pendingExecutionTimeout = null;
|
||||
let pendingExecution = false;
|
||||
let executionTimeout = null;
|
||||
return () => {
|
||||
if (pendingExecutionTimeout == null) {
|
||||
pendingExecutionTimeout = setTimeout(() => {
|
||||
pendingExecutionTimeout = null;
|
||||
if (pendingExecution) {
|
||||
pendingExecution = false;
|
||||
fn();
|
||||
}
|
||||
}, wait);
|
||||
executionTimeout = setTimeout(() => {
|
||||
executionTimeout = null;
|
||||
fn();
|
||||
}, initialWait);
|
||||
} else if (executionTimeout == null) pendingExecution = true;
|
||||
};
|
||||
}
|
||||
const LEADING_SLASH_RE = /^\//;
|
||||
const TRAILING_SLASH_RE = /\/$/;
|
||||
const ESCAPED_TRAILING_SLASH_RE = /\\\/$/;
|
||||
function joinPath(...paths) {
|
||||
let result = "";
|
||||
for (const path of paths) result = result.replace(TRAILING_SLASH_RE, "") + (path && "/" + path.replace(LEADING_SLASH_RE, ""));
|
||||
return result || "/";
|
||||
}
|
||||
function paramToName({ paramName, modifier, isSplat }) {
|
||||
return `${isSplat ? "$" : ""}${paramName.charAt(0).toUpperCase() + paramName.slice(1)}${modifier}`;
|
||||
}
|
||||
/**
|
||||
* Creates a name based of the node path segments.
|
||||
*
|
||||
* @param node - the node to get the path from
|
||||
* @param parent - the parent node
|
||||
* @returns a route name
|
||||
*/
|
||||
function getPascalCaseRouteName(node) {
|
||||
if (node.parent?.isRoot() && node.value.pathSegment === "") return "Root";
|
||||
let name = node.value.subSegments.map((segment) => {
|
||||
if (typeof segment === "string") return pascalCase(segment);
|
||||
return paramToName(segment);
|
||||
}).join("");
|
||||
if (node.value.components.size && node.children.has("index")) name += "Parent";
|
||||
const parent = node.parent;
|
||||
return (parent && !parent.isRoot() ? getPascalCaseRouteName(parent).replace(/Parent$/, "") : "") + name;
|
||||
}
|
||||
/**
|
||||
* Joins the path segments of a node into a name that corresponds to the filepath represented by the node.
|
||||
*
|
||||
* @param node - the node to get the path from
|
||||
* @returns a route name
|
||||
*/
|
||||
function getFileBasedRouteName(node) {
|
||||
if (!node.parent) return "";
|
||||
return getFileBasedRouteName(node.parent) + "/" + (node.value.rawSegment === "index" ? "" : node.value.rawSegment);
|
||||
}
|
||||
function mergeRouteRecordOverride(a, b) {
|
||||
const merged = {};
|
||||
const keys = [.../* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)])];
|
||||
for (const key of keys) if (key === "alias") merged[key] = [].concat(a.alias || [], b.alias || []);
|
||||
else if (key === "meta") merged[key] = mergeDeep(a[key] || {}, b[key] || {});
|
||||
else if (key === "params") merged[key] = {
|
||||
path: {
|
||||
...a[key]?.path,
|
||||
...b[key]?.path
|
||||
},
|
||||
query: {
|
||||
...a[key]?.query,
|
||||
...b[key]?.query
|
||||
}
|
||||
};
|
||||
else merged[key] = b[key] ?? a[key];
|
||||
return merged;
|
||||
}
|
||||
function isObject(obj) {
|
||||
return obj && typeof obj === "object";
|
||||
}
|
||||
function mergeDeep(...objects) {
|
||||
return objects.reduce((prev, obj) => {
|
||||
Object.keys(obj).forEach((key) => {
|
||||
const pVal = prev[key];
|
||||
const oVal = obj[key];
|
||||
if (Array.isArray(pVal) && Array.isArray(oVal)) prev[key] = pVal.concat(...oVal);
|
||||
else if (isObject(pVal) && isObject(oVal)) prev[key] = mergeDeep(pVal, oVal);
|
||||
else prev[key] = oVal;
|
||||
});
|
||||
return prev;
|
||||
}, {});
|
||||
}
|
||||
/**
|
||||
* Returns a route path to be used by the router with any defined prefix from an absolute path to a file. Since it
|
||||
* returns a route path, it will remove the extension from the file.
|
||||
*
|
||||
* @param options - RoutesFolderOption to apply
|
||||
* @param filePath - absolute path to file
|
||||
* @returns a route path to be used by the router with any defined prefix
|
||||
*/
|
||||
function asRoutePath({ src, path = "", extensions }, filePath) {
|
||||
return trimExtension(typeof path === "string" ? path + filePath.slice(src.length + 1) : path(filePath), extensions);
|
||||
}
|
||||
function appendExtensionListToPattern(filePatterns, extensions) {
|
||||
const extensionPattern = extensions.length === 1 ? extensions[0] : `.{${extensions.map((extension) => extension.replace(".", "")).join(",")}}`;
|
||||
return Array.isArray(filePatterns) ? filePatterns.map((filePattern) => `${filePattern}${extensionPattern}`) : `${filePatterns}${extensionPattern}`;
|
||||
}
|
||||
var ImportsMap = class {
|
||||
map = /* @__PURE__ */ new Map();
|
||||
constructor() {}
|
||||
add(path, importEntry) {
|
||||
if (!this.map.has(path)) this.map.set(path, /* @__PURE__ */ new Map());
|
||||
const imports = this.map.get(path);
|
||||
if (typeof importEntry === "string") imports.set(importEntry, importEntry);
|
||||
else imports.set(importEntry.as || importEntry.name, importEntry.name);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Check if the given path has the given import name.
|
||||
*
|
||||
* @param path - the path to check
|
||||
* @param name - the import name to check
|
||||
*/
|
||||
has(path, name) {
|
||||
return this.map.has(path) && this.map.get(path).has(name);
|
||||
}
|
||||
/**
|
||||
* Add a default import. Alias for `add(path, { name: 'default', as })`.
|
||||
*
|
||||
* @param path - the path to import from
|
||||
* @param as - the name to import as
|
||||
*/
|
||||
addDefault(path, as) {
|
||||
return this.add(path, {
|
||||
name: "default",
|
||||
as
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get the list of imports for the given path.
|
||||
*
|
||||
* @param path - the path to get the import list for
|
||||
* @returns the list of imports for the given path
|
||||
*/
|
||||
getImportList(path) {
|
||||
if (!this.map.has(path)) return [];
|
||||
return Array.from(this.map.get(path)).map(([as, name]) => ({
|
||||
as: as || name,
|
||||
name
|
||||
}));
|
||||
}
|
||||
toString() {
|
||||
let importStatements = "";
|
||||
for (const [path, imports] of this.map) {
|
||||
if (!imports.size) continue;
|
||||
const fromImportPath = toStringLiteral(path);
|
||||
if (imports.size === 1) {
|
||||
const [[importName, maybeDefault]] = [...imports.entries()];
|
||||
if (maybeDefault === "default") {
|
||||
importStatements += `import ${importName} from ${fromImportPath}\n`;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
importStatements += `import { ${Array.from(imports).map(([as, name]) => as === name ? name : `${name} as ${as}`).join(", ")} } from ${fromImportPath}\n`;
|
||||
}
|
||||
return importStatements;
|
||||
}
|
||||
get size() {
|
||||
return this.map.size;
|
||||
}
|
||||
};
|
||||
//#endregion
|
||||
//#region src/unplugin/diagnostics.ts
|
||||
/**
|
||||
* Build-time diagnostics catalog for the Vue Router unplugin (file-based
|
||||
* routing). These run in Node during the build, so they are not `__DEV__`
|
||||
* guarded and are reported on every build.
|
||||
*
|
||||
* `why` keeps the original warning text (so existing substring assertions keep
|
||||
* matching); the `VUE_ROUTER_B####` code identifies the source, so messages do not
|
||||
* repeat a `[vue-router]` prefix. Codes are permanent: never rename or reuse.
|
||||
*/
|
||||
const diagnostics = /*#__PURE__*/ defineDiagnostics({
|
||||
reporters: [/*#__PURE__*/ createConsoleReporter()],
|
||||
codes: {
|
||||
VUE_ROUTER_B0001: {
|
||||
why: (p) => `In file "${p.filename}": Failed to process definePage: ${p.message}`,
|
||||
fix: "Fix the syntax error in the definePage() macro of this file."
|
||||
},
|
||||
VUE_ROUTER_B0002: {
|
||||
why: (p) => `In file "${p.filename}": ${p.message}`,
|
||||
fix: "Avoid referencing <script setup> bindings inside definePage(); pass static values instead."
|
||||
},
|
||||
VUE_ROUTER_B0003: {
|
||||
why: (p) => `In file "${p.filename}": Failed to extract definePage info: ${p.message}`,
|
||||
fix: "Fix the syntax error in the definePage() macro of this file."
|
||||
},
|
||||
VUE_ROUTER_B0004: {
|
||||
why: (p) => `route name must be a string literal or false. Found in file "${p.filename}".`,
|
||||
fix: "Use a string literal or `false` for the route `name`."
|
||||
},
|
||||
VUE_ROUTER_B0005: {
|
||||
why: (p) => `route path must be a string literal. Found in file "${p.filename}".`,
|
||||
fix: "Use a string literal for the route `path`."
|
||||
},
|
||||
VUE_ROUTER_B0006: {
|
||||
why: (p) => `Unrecognized default value in definePage() for query param "${p.paramName}". Typeof value: "${p.type}". This is a bug or a missing type of value, open an issue on https://github.com/vuejs/router and provide the definePage() code.`,
|
||||
fix: "Report a reproduction at https://github.com/vuejs/router with the definePage() code."
|
||||
},
|
||||
VUE_ROUTER_B0007: {
|
||||
why: (p) => `route alias must be a string literal or an array of string literals. Found in file "${p.filename}".`,
|
||||
fix: "Use a string literal or an array of string literals for the route `alias`."
|
||||
},
|
||||
VUE_ROUTER_B0008: {
|
||||
why: (p) => `route alias array must only contain string literals. Found "${p.found}" in file "${p.filename}".`,
|
||||
fix: "Only use string literals inside the route `alias` array."
|
||||
},
|
||||
VUE_ROUTER_B0009: {
|
||||
why: (p) => `Invalid extension "${p.ext}". Extensions must start with a dot.`,
|
||||
fix: "Prefix the extension with a dot, e.g. \".vue\"."
|
||||
},
|
||||
VUE_ROUTER_B0010: {
|
||||
why: (p) => `Segment "${p.segment}" is missing the closing ")". It will be treated as a static segment.`,
|
||||
fix: "Add the closing \")\" to the dynamic segment."
|
||||
},
|
||||
VUE_ROUTER_B0011: {
|
||||
why: (p) => `Invalid parameter in path "${p.segment}": parameter name cannot be empty. Using default name "pathMatch" for ':()'.`,
|
||||
fix: "Give the parameter a name, e.g. \":id\"."
|
||||
},
|
||||
VUE_ROUTER_B0012: {
|
||||
why: (p) => `Invalid JSON5 format of <${p.type}> content in ${p.filePath}\n${p.message}`,
|
||||
fix: "Fix the JSON5 syntax in the route custom block."
|
||||
},
|
||||
VUE_ROUTER_B0013: {
|
||||
why: (p) => `Invalid JSON format of <${p.type}> content in ${p.filePath}\n${p.message}`,
|
||||
fix: "Fix the JSON syntax in the route custom block."
|
||||
},
|
||||
VUE_ROUTER_B0014: {
|
||||
why: (p) => `Invalid YAML format of <${p.type}> content in ${p.filePath}\n${p.message}`,
|
||||
fix: "Fix the YAML syntax in the route custom block."
|
||||
},
|
||||
VUE_ROUTER_B0015: {
|
||||
why: (p) => `Language "${p.lang}" for <${p.type}> is not supported. Supported languages are: json5, json, yaml, yml. Found in ${p.filePath}.`,
|
||||
fix: "Use one of the supported languages: json5, json, yaml, yml."
|
||||
},
|
||||
VUE_ROUTER_B0016: {
|
||||
why: (p) => `Error decoding "${p.text}". Using original value`,
|
||||
fix: "Ensure the value is correctly percent-encoded."
|
||||
},
|
||||
VUE_ROUTER_B0017: {
|
||||
why: (p) => `A parameter without a name was found in the route "${p.fullPath}" in segment "${p.path}".`,
|
||||
fix: "Report a reproduction at https://github.com/vuejs/router."
|
||||
},
|
||||
VUE_ROUTER_B0018: {
|
||||
why: (p) => `Cannot statically determine if "parser" is raw in "${p.filename}" because it is re-exported from "${p.source}". The generated route param types may be incorrect. Define the parser inline in this file with \`defineParamParser\`/\`defineParamParserRaw\` instead of re-exporting it.`,
|
||||
fix: "Define the parser inline with `defineParamParser`/`defineParamParserRaw` instead of re-exporting it."
|
||||
},
|
||||
VUE_ROUTER_B0019: {
|
||||
why: (p) => `Parameter parser "${p.parser}" not found for route "${p.fullPath}".`,
|
||||
fix: "Define the param parser or use one of the native parsers."
|
||||
}
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
//#region src/unplugin/options.ts
|
||||
/**
|
||||
* Resolves an overridable option by calling the function with the existing
|
||||
* value if it's a function, otherwise returning the passed `value`. If `value`
|
||||
* is undefined, it returns the `defaultValue` instead.
|
||||
*
|
||||
* @param defaultValue default value for the option
|
||||
* @param value and overridable option
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
function resolveOverridableOption(defaultValue, value) {
|
||||
return typeof value === "function" ? value(defaultValue) : value ?? defaultValue;
|
||||
}
|
||||
/**
|
||||
* Default options for experimental param parsers.
|
||||
*/
|
||||
const DEFAULT_PARAM_PARSERS_OPTIONS = {
|
||||
dir: ["src/params"],
|
||||
include: ["*.ts"],
|
||||
exclude: ["*.test.{ts,js}", "*.spec.{ts,js}"]
|
||||
};
|
||||
/**
|
||||
* Default plugin options.
|
||||
*/
|
||||
const DEFAULT_OPTIONS = {
|
||||
extensions: [".vue"],
|
||||
exclude: [],
|
||||
routesFolder: "src/pages",
|
||||
filePatterns: ["**/*"],
|
||||
routeBlockLang: "json5",
|
||||
getRouteName: getFileBasedRouteName,
|
||||
importMode: "async",
|
||||
root: process.cwd(),
|
||||
dts: isPackageExists("typescript"),
|
||||
logs: false,
|
||||
_inspect: false,
|
||||
pathParser: { dotNesting: true },
|
||||
watch: !process.env.CI,
|
||||
experimental: {}
|
||||
};
|
||||
function normalizeRoutesFolderOption(routesFolder) {
|
||||
return (isArray(routesFolder) ? routesFolder : [routesFolder]).map((routeOption) => normalizeRouteOption(typeof routeOption === "string" ? { src: routeOption } : routeOption));
|
||||
}
|
||||
function normalizeRouteOption(routeOption) {
|
||||
return {
|
||||
...routeOption,
|
||||
filePatterns: routeOption.filePatterns ? typeof routeOption.filePatterns === "function" ? routeOption.filePatterns : isArray(routeOption.filePatterns) ? routeOption.filePatterns : [routeOption.filePatterns] : void 0,
|
||||
exclude: routeOption.exclude ? typeof routeOption.exclude === "function" ? routeOption.exclude : isArray(routeOption.exclude) ? routeOption.exclude : [routeOption.exclude] : void 0
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Normalize user options with defaults and resolved paths.
|
||||
*
|
||||
* @param options - user provided options
|
||||
* @returns normalized options
|
||||
*/
|
||||
function resolveOptions(options) {
|
||||
const root = options.root || DEFAULT_OPTIONS.root;
|
||||
const routesFolder = normalizeRoutesFolderOption(options.routesFolder || DEFAULT_OPTIONS.routesFolder).map((routeOption) => ({
|
||||
...routeOption,
|
||||
src: resolve(root, routeOption.src)
|
||||
}));
|
||||
const paramParsers = options.experimental?.paramParsers ? options.experimental.paramParsers === true ? DEFAULT_PARAM_PARSERS_OPTIONS : {
|
||||
...DEFAULT_PARAM_PARSERS_OPTIONS,
|
||||
...options.experimental.paramParsers
|
||||
} : void 0;
|
||||
const paramParsersDir = (paramParsers?.dir ? isArray(paramParsers.dir) ? paramParsers.dir : [paramParsers.dir] : []).map((dir) => resolve(root, dir));
|
||||
const paramParsersInclude = paramParsers?.include ? isArray(paramParsers.include) ? paramParsers.include : [paramParsers.include] : DEFAULT_PARAM_PARSERS_OPTIONS.include;
|
||||
const paramParsersExclude = paramParsers?.exclude ? isArray(paramParsers.exclude) ? paramParsers.exclude : [paramParsers.exclude] : DEFAULT_PARAM_PARSERS_OPTIONS.exclude;
|
||||
const autoExportsDataLoaders = options.experimental?.autoExportsDataLoaders ? (isArray(options.experimental.autoExportsDataLoaders) ? options.experimental.autoExportsDataLoaders : [options.experimental.autoExportsDataLoaders]).map((path) => resolve(root, path)) : void 0;
|
||||
const experimental = {
|
||||
...options.experimental,
|
||||
autoExportsDataLoaders,
|
||||
paramParsers: paramParsers && {
|
||||
...paramParsers,
|
||||
dir: paramParsersDir,
|
||||
include: paramParsersInclude,
|
||||
exclude: paramParsersExclude
|
||||
}
|
||||
};
|
||||
if (options.extensions) options.extensions = options.extensions.map((ext) => {
|
||||
if (!ext.startsWith(".")) {
|
||||
diagnostics.VUE_ROUTER_B0009({ ext });
|
||||
return "." + ext;
|
||||
}
|
||||
return ext;
|
||||
}).sort((a, b) => b.length - a.length);
|
||||
const filePatterns = options.filePatterns ? isArray(options.filePatterns) ? options.filePatterns : [options.filePatterns] : DEFAULT_OPTIONS.filePatterns;
|
||||
const exclude = options.exclude ? isArray(options.exclude) ? options.exclude : [options.exclude] : DEFAULT_OPTIONS.exclude;
|
||||
return {
|
||||
...DEFAULT_OPTIONS,
|
||||
...options,
|
||||
experimental,
|
||||
routesFolder,
|
||||
filePatterns,
|
||||
exclude
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Merge all the possible extensions as an array of unique values
|
||||
* @param options - user provided options
|
||||
* @internal
|
||||
*/
|
||||
function mergeAllExtensions(options) {
|
||||
const allExtensions = new Set(options.extensions);
|
||||
for (const routeOption of options.routesFolder) if (routeOption.extensions) {
|
||||
const extensions = resolveOverridableOption(options.extensions, routeOption.extensions);
|
||||
for (const ext of extensions) allExtensions.add(ext);
|
||||
}
|
||||
return Array.from(allExtensions.values());
|
||||
}
|
||||
//#endregion
|
||||
export { formatMultilineUnion as _, resolveOverridableOption as a, ts as b, ImportsMap as c, getFileBasedRouteName as d, getPascalCaseRouteName as f, throttle as g, mergeRouteRecordOverride as h, resolveOptions as i, appendExtensionListToPattern as l, logTree as m, DEFAULT_PARAM_PARSERS_OPTIONS as n, diagnostics as o, joinPath as p, mergeAllExtensions as r, ESCAPED_TRAILING_SLASH_RE as s, DEFAULT_OPTIONS as t, asRoutePath as u, pad as v, toStringLiteral as y };
|
||||
+2913
File diff suppressed because it is too large
Load Diff
+2913
File diff suppressed because it is too large
Load Diff
+2733
File diff suppressed because it is too large
Load Diff
+2794
File diff suppressed because it is too large
Load Diff
+13
@@ -0,0 +1,13 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
Object.defineProperties(exports, {
|
||||
__esModule: { value: true },
|
||||
[Symbol.toStringTag]: { value: "Module" }
|
||||
});
|
||||
//#region src/unplugin/esbuild.ts
|
||||
var esbuild_default = require("../unplugin-Of3wIaKI.cjs").unplugin_default.esbuild;
|
||||
//#endregion
|
||||
exports.default = esbuild_default;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-P-0BPDru.cjs";
|
||||
//#region src/unplugin/esbuild.d.ts
|
||||
declare const _default: (options?: Options | undefined) => import("unplugin").EsbuildPlugin;
|
||||
export = _default;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-P-0BPDru.mjs";
|
||||
//#region src/unplugin/esbuild.d.ts
|
||||
declare const _default: (options?: Options | undefined) => import("unplugin").EsbuildPlugin;
|
||||
//#endregion
|
||||
export { _default as default };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { n as unplugin_default } from "../unplugin-D63tPTIf.mjs";
|
||||
//#region src/unplugin/esbuild.ts
|
||||
var esbuild_default = unplugin_default.esbuild;
|
||||
//#endregion
|
||||
export { esbuild_default as default };
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
Object.defineProperties(exports, {
|
||||
__esModule: { value: true },
|
||||
[Symbol.toStringTag]: { value: "Module" }
|
||||
});
|
||||
const require_unplugin = require("../unplugin-Of3wIaKI.cjs");
|
||||
const require_options = require("../options-B2eSXqPk.cjs");
|
||||
exports.AutoExportLoaders = require_unplugin.AutoExportLoaders;
|
||||
exports.DEFAULT_OPTIONS = require_options.DEFAULT_OPTIONS;
|
||||
exports.EditableTreeNode = require_unplugin.EditableTreeNode;
|
||||
exports.VueRouterAutoImports = require_unplugin.VueRouterAutoImports;
|
||||
exports.createRoutesContext = require_unplugin.createRoutesContext;
|
||||
exports.createTreeNodeValue = require_unplugin.createTreeNodeValue;
|
||||
exports.default = require_unplugin.unplugin_default;
|
||||
exports.getFileBasedRouteName = require_options.getFileBasedRouteName;
|
||||
exports.getPascalCaseRouteName = require_options.getPascalCaseRouteName;
|
||||
exports.resolveOptions = require_options.resolveOptions;
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { C as createTreeNodeValue, S as TreeNodeValueStatic, _ as getPascalCaseRouteName, a as ResolvedOptions, b as TreeNodeValueGroup, c as RoutesFolderOptionResolved, g as getFileBasedRouteName, h as EditableTreeNode, i as ParamParsersOptions, l as ServerContext, o as RoutesFolder, p as resolveOptions, r as Options, s as RoutesFolderOption, t as DEFAULT_OPTIONS, v as TreeNode, x as TreeNodeValueParam, y as TreeNodeValue } from "../options-P-0BPDru.cjs";
|
||||
import { Plugin } from "vite";
|
||||
import { StringFilter } from "unplugin";
|
||||
//#region src/unplugin/core/context.d.ts
|
||||
declare function createRoutesContext(options: ResolvedOptions): {
|
||||
scanPages: (startWatchers?: boolean) => Promise<void>;
|
||||
writeConfigFiles: () => void;
|
||||
setServerContext: (_server: ServerContext) => void;
|
||||
stopWatcher: () => void;
|
||||
generateRoutes: () => string;
|
||||
generateResolver: () => string;
|
||||
definePageTransform(code: string, id: string): import("unplugin").Thenable<import("unplugin").TransformResult>;
|
||||
};
|
||||
//#endregion
|
||||
//#region src/experimental/data-loaders/auto-exports.d.ts
|
||||
/**
|
||||
* {@link AutoExportLoaders} options.
|
||||
*/
|
||||
interface AutoExportLoadersOptions {
|
||||
/**
|
||||
* Filter page components to apply the auto-export. Passed to `transform.filter.id`.
|
||||
*/
|
||||
transformFilter: StringFilter;
|
||||
/**
|
||||
* Globs to match the paths of the loaders.
|
||||
*/
|
||||
loadersPathsGlobs: string | string[];
|
||||
/**
|
||||
* Root of the project. All paths are resolved relatively to this one.
|
||||
* @default `process.cwd()`
|
||||
*/
|
||||
root?: string;
|
||||
}
|
||||
/**
|
||||
* Vite Plugin to automatically export loaders from page components.
|
||||
*
|
||||
* @param options Options
|
||||
* @experimental - This API is experimental and can be changed in the future. It's used internally by `experimental.autoExportsDataLoaders`
|
||||
*/
|
||||
declare function AutoExportLoaders({ transformFilter, loadersPathsGlobs, root }: AutoExportLoadersOptions): Plugin;
|
||||
//#endregion
|
||||
//#region src/unplugin/index.d.ts
|
||||
declare const _default: import("unplugin").UnpluginInstance<Options | undefined, boolean>;
|
||||
/**
|
||||
* Adds useful auto imports to the AutoImport config:
|
||||
* @example
|
||||
* ```js
|
||||
* import { VueRouterAutoImports } from 'vue-router/unplugin'
|
||||
*
|
||||
* AutoImport({
|
||||
* imports: [VueRouterAutoImports],
|
||||
* }),
|
||||
* ```
|
||||
*/
|
||||
declare const VueRouterAutoImports: Record<string, Array<string | [importName: string, alias: string]>>;
|
||||
//#endregion
|
||||
export { AutoExportLoaders, type AutoExportLoadersOptions, DEFAULT_OPTIONS, EditableTreeNode, type Options, type ParamParsersOptions, type ResolvedOptions, type RoutesFolder, type RoutesFolderOption, type RoutesFolderOptionResolved, type TreeNode, type TreeNodeValue, type TreeNodeValueGroup, type TreeNodeValueParam, type TreeNodeValueStatic, VueRouterAutoImports, createRoutesContext, createTreeNodeValue, _default as default, getFileBasedRouteName, getPascalCaseRouteName, resolveOptions };
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { C as createTreeNodeValue, S as TreeNodeValueStatic, _ as getPascalCaseRouteName, a as ResolvedOptions, b as TreeNodeValueGroup, c as RoutesFolderOptionResolved, g as getFileBasedRouteName, h as EditableTreeNode, i as ParamParsersOptions, l as ServerContext, o as RoutesFolder, p as resolveOptions, r as Options, s as RoutesFolderOption, t as DEFAULT_OPTIONS, v as TreeNode, x as TreeNodeValueParam, y as TreeNodeValue } from "../options-P-0BPDru.mjs";
|
||||
import { StringFilter } from "unplugin";
|
||||
import { Plugin } from "vite";
|
||||
//#region src/unplugin/core/context.d.ts
|
||||
declare function createRoutesContext(options: ResolvedOptions): {
|
||||
scanPages: (startWatchers?: boolean) => Promise<void>;
|
||||
writeConfigFiles: () => void;
|
||||
setServerContext: (_server: ServerContext) => void;
|
||||
stopWatcher: () => void;
|
||||
generateRoutes: () => string;
|
||||
generateResolver: () => string;
|
||||
definePageTransform(code: string, id: string): import("unplugin").Thenable<import("unplugin").TransformResult>;
|
||||
};
|
||||
//#endregion
|
||||
//#region src/experimental/data-loaders/auto-exports.d.ts
|
||||
/**
|
||||
* {@link AutoExportLoaders} options.
|
||||
*/
|
||||
interface AutoExportLoadersOptions {
|
||||
/**
|
||||
* Filter page components to apply the auto-export. Passed to `transform.filter.id`.
|
||||
*/
|
||||
transformFilter: StringFilter;
|
||||
/**
|
||||
* Globs to match the paths of the loaders.
|
||||
*/
|
||||
loadersPathsGlobs: string | string[];
|
||||
/**
|
||||
* Root of the project. All paths are resolved relatively to this one.
|
||||
* @default `process.cwd()`
|
||||
*/
|
||||
root?: string;
|
||||
}
|
||||
/**
|
||||
* Vite Plugin to automatically export loaders from page components.
|
||||
*
|
||||
* @param options Options
|
||||
* @experimental - This API is experimental and can be changed in the future. It's used internally by `experimental.autoExportsDataLoaders`
|
||||
*/
|
||||
declare function AutoExportLoaders({ transformFilter, loadersPathsGlobs, root }: AutoExportLoadersOptions): Plugin;
|
||||
//#endregion
|
||||
//#region src/unplugin/index.d.ts
|
||||
declare const _default: import("unplugin").UnpluginInstance<Options | undefined, boolean>;
|
||||
/**
|
||||
* Adds useful auto imports to the AutoImport config:
|
||||
* @example
|
||||
* ```js
|
||||
* import { VueRouterAutoImports } from 'vue-router/unplugin'
|
||||
*
|
||||
* AutoImport({
|
||||
* imports: [VueRouterAutoImports],
|
||||
* }),
|
||||
* ```
|
||||
*/
|
||||
declare const VueRouterAutoImports: Record<string, Array<string | [importName: string, alias: string]>>;
|
||||
//#endregion
|
||||
export { AutoExportLoaders, type AutoExportLoadersOptions, DEFAULT_OPTIONS, EditableTreeNode, type Options, type ParamParsersOptions, type ResolvedOptions, type RoutesFolder, type RoutesFolderOption, type RoutesFolderOptionResolved, type TreeNode, type TreeNodeValue, type TreeNodeValueGroup, type TreeNodeValueParam, type TreeNodeValueStatic, VueRouterAutoImports, createRoutesContext, createTreeNodeValue, _default as default, getFileBasedRouteName, getPascalCaseRouteName, resolveOptions };
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { d as getFileBasedRouteName, f as getPascalCaseRouteName, i as resolveOptions, t as DEFAULT_OPTIONS } from "../options-D3sDTRr-.mjs";
|
||||
import { a as EditableTreeNode, i as createRoutesContext, n as unplugin_default, o as createTreeNodeValue, r as AutoExportLoaders, t as VueRouterAutoImports } from "../unplugin-D63tPTIf.mjs";
|
||||
export { AutoExportLoaders, DEFAULT_OPTIONS, EditableTreeNode, VueRouterAutoImports, createRoutesContext, createTreeNodeValue, unplugin_default as default, getFileBasedRouteName, getPascalCaseRouteName, resolveOptions };
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const require_options = require("../options-B2eSXqPk.cjs");
|
||||
exports.DEFAULT_OPTIONS = require_options.DEFAULT_OPTIONS;
|
||||
exports.DEFAULT_PARAM_PARSERS_OPTIONS = require_options.DEFAULT_PARAM_PARSERS_OPTIONS;
|
||||
exports.mergeAllExtensions = require_options.mergeAllExtensions;
|
||||
exports.resolveOptions = require_options.resolveOptions;
|
||||
exports.resolveOverridableOption = require_options.resolveOverridableOption;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { a as ResolvedOptions, c as RoutesFolderOptionResolved, d as _RoutesFolder, f as mergeAllExtensions, i as ParamParsersOptions, l as ServerContext, m as resolveOverridableOption, n as DEFAULT_PARAM_PARSERS_OPTIONS, o as RoutesFolder, p as resolveOptions, r as Options, s as RoutesFolderOption, t as DEFAULT_OPTIONS, u as _OverridableOption } from "../options-P-0BPDru.cjs";
|
||||
export { DEFAULT_OPTIONS, DEFAULT_PARAM_PARSERS_OPTIONS, Options, ParamParsersOptions, ResolvedOptions, RoutesFolder, RoutesFolderOption, RoutesFolderOptionResolved, ServerContext, _OverridableOption, _RoutesFolder, mergeAllExtensions, resolveOptions, resolveOverridableOption };
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { a as ResolvedOptions, c as RoutesFolderOptionResolved, d as _RoutesFolder, f as mergeAllExtensions, i as ParamParsersOptions, l as ServerContext, m as resolveOverridableOption, n as DEFAULT_PARAM_PARSERS_OPTIONS, o as RoutesFolder, p as resolveOptions, r as Options, s as RoutesFolderOption, t as DEFAULT_OPTIONS, u as _OverridableOption } from "../options-P-0BPDru.mjs";
|
||||
export { DEFAULT_OPTIONS, DEFAULT_PARAM_PARSERS_OPTIONS, Options, ParamParsersOptions, ResolvedOptions, RoutesFolder, RoutesFolderOption, RoutesFolderOptionResolved, ServerContext, _OverridableOption, _RoutesFolder, mergeAllExtensions, resolveOptions, resolveOverridableOption };
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { a as resolveOverridableOption, i as resolveOptions, n as DEFAULT_PARAM_PARSERS_OPTIONS, r as mergeAllExtensions, t as DEFAULT_OPTIONS } from "../options-D3sDTRr-.mjs";
|
||||
export { DEFAULT_OPTIONS, DEFAULT_PARAM_PARSERS_OPTIONS, mergeAllExtensions, resolveOptions, resolveOverridableOption };
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
Object.defineProperties(exports, {
|
||||
__esModule: { value: true },
|
||||
[Symbol.toStringTag]: { value: "Module" }
|
||||
});
|
||||
//#region src/unplugin/rolldown.ts
|
||||
var rolldown_default = require("../unplugin-Of3wIaKI.cjs").unplugin_default.rolldown;
|
||||
//#endregion
|
||||
exports.default = rolldown_default;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-P-0BPDru.cjs";
|
||||
//#region src/unplugin/rolldown.d.ts
|
||||
declare const _default: (options?: Options | undefined) => import("unplugin").RolldownPlugin<any> | import("unplugin").RolldownPlugin<any>[];
|
||||
export = _default;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-P-0BPDru.mjs";
|
||||
//#region src/unplugin/rolldown.d.ts
|
||||
declare const _default: (options?: Options | undefined) => import("unplugin").RolldownPlugin<any> | import("unplugin").RolldownPlugin<any>[];
|
||||
//#endregion
|
||||
export { _default as default };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { n as unplugin_default } from "../unplugin-D63tPTIf.mjs";
|
||||
//#region src/unplugin/rolldown.ts
|
||||
var rolldown_default = unplugin_default.rolldown;
|
||||
//#endregion
|
||||
export { rolldown_default as default };
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
Object.defineProperties(exports, {
|
||||
__esModule: { value: true },
|
||||
[Symbol.toStringTag]: { value: "Module" }
|
||||
});
|
||||
//#region src/unplugin/rollup.ts
|
||||
var rollup_default = require("../unplugin-Of3wIaKI.cjs").unplugin_default.rollup;
|
||||
//#endregion
|
||||
exports.default = rollup_default;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-P-0BPDru.cjs";
|
||||
//#region src/unplugin/rollup.d.ts
|
||||
declare const _default: (options?: Options | undefined) => import("rollup").Plugin<any> | import("rollup").Plugin<any>[];
|
||||
export = _default;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-P-0BPDru.mjs";
|
||||
//#region src/unplugin/rollup.d.ts
|
||||
declare const _default: (options?: Options | undefined) => import("rollup").Plugin<any> | import("rollup").Plugin<any>[];
|
||||
//#endregion
|
||||
export { _default as default };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { n as unplugin_default } from "../unplugin-D63tPTIf.mjs";
|
||||
//#region src/unplugin/rollup.ts
|
||||
var rollup_default = unplugin_default.rollup;
|
||||
//#endregion
|
||||
export { rollup_default as default };
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { S as TreeNodeValueStatic, b as TreeNodeValueGroup, h as EditableTreeNode, r as Options, v as TreeNode, x as TreeNodeValueParam, y as TreeNodeValue } from "../options-P-0BPDru.cjs";
|
||||
export type { EditableTreeNode, Options, TreeNode, TreeNodeValue, TreeNodeValueGroup, TreeNodeValueParam, TreeNodeValueStatic };
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { S as TreeNodeValueStatic, b as TreeNodeValueGroup, h as EditableTreeNode, r as Options, v as TreeNode, x as TreeNodeValueParam, y as TreeNodeValue } from "../options-P-0BPDru.mjs";
|
||||
export type { EditableTreeNode, Options, TreeNode, TreeNodeValue, TreeNodeValueGroup, TreeNodeValueParam, TreeNodeValueStatic };
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
export {};
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
Object.defineProperties(exports, {
|
||||
__esModule: { value: true },
|
||||
[Symbol.toStringTag]: { value: "Module" }
|
||||
});
|
||||
//#region src/unplugin/vite.ts
|
||||
var vite_default = require("../unplugin-Of3wIaKI.cjs").unplugin_default.vite;
|
||||
//#endregion
|
||||
exports.default = vite_default;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-P-0BPDru.cjs";
|
||||
//#region src/unplugin/vite.d.ts
|
||||
declare const _default: (options?: Options | undefined) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
|
||||
export = _default;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-P-0BPDru.mjs";
|
||||
//#region src/unplugin/vite.d.ts
|
||||
declare const _default: (options?: Options | undefined) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
|
||||
//#endregion
|
||||
export { _default as default };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { n as unplugin_default } from "../unplugin-D63tPTIf.mjs";
|
||||
//#region src/unplugin/vite.ts
|
||||
var vite_default = unplugin_default.vite;
|
||||
//#endregion
|
||||
export { vite_default as default };
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
Object.defineProperties(exports, {
|
||||
__esModule: { value: true },
|
||||
[Symbol.toStringTag]: { value: "Module" }
|
||||
});
|
||||
//#region src/unplugin/webpack.ts
|
||||
var webpack_default = require("../unplugin-Of3wIaKI.cjs").unplugin_default.webpack;
|
||||
//#endregion
|
||||
exports.default = webpack_default;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-P-0BPDru.cjs";
|
||||
//#region src/unplugin/webpack.d.ts
|
||||
declare const _default: (options?: Options | undefined) => WebpackPluginInstance;
|
||||
export = _default;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-P-0BPDru.mjs";
|
||||
//#region src/unplugin/webpack.d.ts
|
||||
declare const _default: (options?: Options | undefined) => WebpackPluginInstance;
|
||||
//#endregion
|
||||
export { _default as default };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { n as unplugin_default } from "../unplugin-D63tPTIf.mjs";
|
||||
//#region src/unplugin/webpack.ts
|
||||
var webpack_default = unplugin_default.webpack;
|
||||
//#endregion
|
||||
export { webpack_default as default };
|
||||
+436
@@ -0,0 +1,436 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { createConsoleReporter, defineDiagnostics } from "nostics";
|
||||
import { inject } from "vue";
|
||||
//#region src/utils/index.ts
|
||||
/**
|
||||
* Identity function that returns the value as is.
|
||||
*
|
||||
* @param v - the value to return
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const identityFn = (v) => v;
|
||||
/**
|
||||
* Allows differentiating lazy components from functional components and vue-class-component
|
||||
* @internal
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
function isRouteComponent(component) {
|
||||
return typeof component === "object" || "displayName" in component || "props" in component || "__vccOpts" in component;
|
||||
}
|
||||
function isESModule(obj) {
|
||||
return obj.__esModule || obj[Symbol.toStringTag] === "Module" || obj.default && isRouteComponent(obj.default);
|
||||
}
|
||||
const assign = Object.assign;
|
||||
function applyToParams(fn, params) {
|
||||
const newParams = {};
|
||||
for (const key in params) {
|
||||
const value = params[key];
|
||||
newParams[key] = isArray(value) ? value.map(fn) : fn(value);
|
||||
}
|
||||
return newParams;
|
||||
}
|
||||
const noop = () => {};
|
||||
/**
|
||||
* Typesafe alternative to Array.isArray
|
||||
* https://github.com/microsoft/TypeScript/pull/48228
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const isArray = Array.isArray;
|
||||
function mergeOptions(defaults, partialOptions) {
|
||||
const options = {};
|
||||
for (const key in defaults) options[key] = key in partialOptions ? partialOptions[key] : defaults[key];
|
||||
return options;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/errors.ts
|
||||
const NavigationFailureSymbol = Symbol(process.env.NODE_ENV !== "production" ? "navigation failure" : "");
|
||||
/**
|
||||
* Enumeration with all possible types for navigation failures. Can be passed to
|
||||
* {@link isNavigationFailure} to check for specific failures.
|
||||
*/
|
||||
let NavigationFailureType = /* @__PURE__ */ function(NavigationFailureType) {
|
||||
/**
|
||||
* An aborted navigation is a navigation that failed because a navigation
|
||||
* guard returned `false` or called `next(false)`
|
||||
*/
|
||||
NavigationFailureType[NavigationFailureType["aborted"] = 4] = "aborted";
|
||||
/**
|
||||
* A cancelled navigation is a navigation that failed because a more recent
|
||||
* navigation finished started (not necessarily finished).
|
||||
*/
|
||||
NavigationFailureType[NavigationFailureType["cancelled"] = 8] = "cancelled";
|
||||
/**
|
||||
* A duplicated navigation is a navigation that failed because it was
|
||||
* initiated while already being at the exact same location.
|
||||
*/
|
||||
NavigationFailureType[NavigationFailureType["duplicated"] = 16] = "duplicated";
|
||||
return NavigationFailureType;
|
||||
}({});
|
||||
const ErrorTypeMessages = {
|
||||
[1]({ location, currentLocation }) {
|
||||
return `No match for\n ${JSON.stringify(location)}${currentLocation ? "\nwhile being at\n" + JSON.stringify(currentLocation) : ""}`;
|
||||
},
|
||||
[2]({ from, to }) {
|
||||
return `Redirected from "${from.fullPath}" to "${stringifyRoute(to)}" via a navigation guard.`;
|
||||
},
|
||||
[4]({ from, to }) {
|
||||
return `Navigation aborted from "${from.fullPath}" to "${to.fullPath}" via a navigation guard.`;
|
||||
},
|
||||
[8]({ from, to }) {
|
||||
return `Navigation cancelled from "${from.fullPath}" to "${to.fullPath}" with a new navigation.`;
|
||||
},
|
||||
[16]({ from, to: _to }) {
|
||||
return `Avoided redundant navigation to current location: "${from.fullPath}".`;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Creates a typed NavigationFailure object.
|
||||
* @internal
|
||||
* @param type - NavigationFailureType
|
||||
* @param params - { from, to }
|
||||
*/
|
||||
function createRouterError(type, params) {
|
||||
if (process.env.NODE_ENV !== "production" || false) return assign(new Error(ErrorTypeMessages[type](params)), {
|
||||
type,
|
||||
[NavigationFailureSymbol]: true
|
||||
}, params);
|
||||
else return assign(/* @__PURE__ */ new Error(), {
|
||||
type,
|
||||
[NavigationFailureSymbol]: true
|
||||
}, params);
|
||||
}
|
||||
function isNavigationFailure(error, type) {
|
||||
return error instanceof Error && NavigationFailureSymbol in error && (type == null || !!(error.type & type));
|
||||
}
|
||||
const propertiesToLog = [
|
||||
"params",
|
||||
"query",
|
||||
"hash"
|
||||
];
|
||||
/**
|
||||
* Stringifies a raw location for display in dev warnings.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
function stringifyRoute(to) {
|
||||
if (!to || typeof to === "string") return to;
|
||||
if (to.path != null) return to.path;
|
||||
const location = {};
|
||||
for (const key of propertiesToLog) if (key in to) location[key] = to[key];
|
||||
return JSON.stringify(location, null, 2);
|
||||
}
|
||||
//#endregion
|
||||
//#region src/diagnostics.ts
|
||||
/**
|
||||
* Runtime diagnostics catalog for Vue Router.
|
||||
*
|
||||
* Every entry has a stable `VUE_ROUTER_R####` code, a `why` that states the problem
|
||||
* (the diagnosis only, never the remedy) and a `fix` that states the remedy
|
||||
* (only, never the diagnosis). They are complementary: the reporter prints
|
||||
* both, so neither repeats the other. The diagnosis substrings asserted by the
|
||||
* warning tests stay in `why`. All call sites stay behind the existing `__DEV__` (or
|
||||
* `process.env.NODE_ENV !== 'production'`) guards and remain bare expression
|
||||
* statements so they tree-shake out of production builds.
|
||||
*
|
||||
* Codes are permanent: never rename or reuse one.
|
||||
* - `VUE_ROUTER_R0###` core runtime warnings
|
||||
* - `VUE_ROUTER_R1###` experimental data-loaders
|
||||
*/
|
||||
const diagnostics = /*#__PURE__*/ defineDiagnostics({
|
||||
reporters: [/*#__PURE__*/ createConsoleReporter()],
|
||||
codes: {
|
||||
VUE_ROUTER_R0001: {
|
||||
why: (p) => `Parent route "${p.name}" not found when adding child route`,
|
||||
fix: "Add the parent route before its children, or check the parent name for typos.",
|
||||
docs: "https://router.vuejs.org/guide/advanced/dynamic-routing.html#Adding-nested-routes"
|
||||
},
|
||||
VUE_ROUTER_R0002: {
|
||||
why: (p) => `Cannot remove non-existent route "${p.name}"`,
|
||||
fix: "Check the route name; it may already have been removed or was never added.",
|
||||
docs: "https://router.vuejs.org/guide/advanced/dynamic-routing.html#Removing-routes"
|
||||
},
|
||||
VUE_ROUTER_R0003: {
|
||||
why: (p) => `Location "${stringifyRoute(p.location)}" resolved to "${p.href}". A resolved location cannot start with multiple slashes.`,
|
||||
fix: "Remove the leading slashes from the location or fix the route configuration."
|
||||
},
|
||||
VUE_ROUTER_R0004: {
|
||||
why: (p) => `No match found for location with path "${stringifyRoute(p.path)}"`,
|
||||
fix: "Add a route matching this path or check for typos in the location.",
|
||||
docs: "https://router.vuejs.org/guide/essentials/dynamic-matching.html#Catch-all-404-Not-found-Route"
|
||||
},
|
||||
VUE_ROUTER_R0005: {
|
||||
why: (p) => `router.resolve() was passed an invalid location. This will fail in production.\nLocation: ${stringifyRoute(p.rawLocation)}`,
|
||||
fix: "Pass a valid route location: a string path or an object with `path` or `name`."
|
||||
},
|
||||
VUE_ROUTER_R0006: {
|
||||
why: (p) => `Path "${p.path}" was passed with params but they will be ignored because a "path" was passed.`,
|
||||
fix: "Use a named route `{ name, params }` instead of `{ path, params }`.",
|
||||
docs: "https://router.vuejs.org/guide/essentials/navigation.html#Navigate-to-a-different-location"
|
||||
},
|
||||
VUE_ROUTER_R0007: {
|
||||
why: (p) => `A \`hash\` should always start with the character "#" but received "${p.hash}".`,
|
||||
fix: (p) => `Prepend "#" to the hash in your route location: use "#${p.hash}".`
|
||||
},
|
||||
VUE_ROUTER_R0008: {
|
||||
why: (p) => `Invalid redirect found:\n${p.target}\n when navigating to "${p.to}".\nThis will break in production.`,
|
||||
fix: "A redirect must resolve to a location with a `name` or `path`; return one of those (or a string path) from `redirect`.",
|
||||
docs: "https://router.vuejs.org/guide/essentials/redirect-and-alias.html#Redirect"
|
||||
},
|
||||
VUE_ROUTER_R0009: {
|
||||
why: (p) => `Detected a possibly infinite redirection in a navigation guard when going from "${p.from}" to "${p.to}". Aborting to avoid a Stack Overflow. This might break in production if not fixed.`,
|
||||
fix: "A guard is returning a new location on every call; make that return conditional so it only redirects when actually needed.",
|
||||
docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Global-Before-Guards"
|
||||
},
|
||||
VUE_ROUTER_R0010: {
|
||||
why: "Uncaught error during route navigation",
|
||||
fix: "Register an error handler with `router.onError()` to handle navigation errors."
|
||||
},
|
||||
VUE_ROUTER_R0011: {
|
||||
why: "Unexpected error when starting the router:",
|
||||
fix: "Inspect the actual cause; a navigation guard or async component likely threw during the initial navigation."
|
||||
},
|
||||
VUE_ROUTER_R0020: {
|
||||
why: (p) => `No active route record was found when calling \`${p.fn}()\`. Maybe you called it inside of App.vue?`,
|
||||
fix: "Call it from a component rendered inside <router-view> (a page component or one of its children), not from App.vue.",
|
||||
docs: "https://router.vuejs.org/guide/advanced/composition-api.html#Navigation-Guards"
|
||||
},
|
||||
VUE_ROUTER_R0021: {
|
||||
why: "No active route record was found when reactivating component with navigation guard. This is likely a bug in vue-router.",
|
||||
fix: "Report with a minimal reproduction at https://github.com/vuejs/router/issues/new/choose."
|
||||
},
|
||||
VUE_ROUTER_R0022: {
|
||||
why: (p) => `${p.fn}() was called outside of component setup but it must be called at the top of a setup function`,
|
||||
fix: "Call it synchronously at the top of `setup()`, before any `await`.",
|
||||
docs: "https://router.vuejs.org/guide/advanced/composition-api.html#Navigation-Guards"
|
||||
},
|
||||
VUE_ROUTER_R0023: {
|
||||
why: (p) => `The "next" callback was never called inside of ${p.name ? `"${p.name}"` : ""}:\n${p.guard}`,
|
||||
fix: "Make sure `next()` runs on every branch, including early returns and async paths, or drop the `next` parameter and return the value instead.",
|
||||
docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Optional-third-argument-next"
|
||||
},
|
||||
VUE_ROUTER_R0024: {
|
||||
why: (p) => `The "next" callback was called more than once in one navigation guard when going from "${p.from}" to "${p.to}". This will fail in production.`,
|
||||
fix: "Call `next()` exactly once per guard: remove the extra call, or migrate to returning the value you passed to `next()`.",
|
||||
docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Optional-third-argument-next"
|
||||
},
|
||||
VUE_ROUTER_R0025: {
|
||||
why: "The `next()` callback in navigation guards is deprecated.",
|
||||
fix: "Return the value instead: `next()` becomes `return`, `next(false)` becomes `return false`, `next(\"/path\")` becomes `return \"/path\"`.",
|
||||
docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Optional-third-argument-next"
|
||||
},
|
||||
VUE_ROUTER_R0026: {
|
||||
why: (p) => `Record with path "${p.path}" is either missing a "component(s)" or "children" property.`,
|
||||
fix: "Add a `component`, `components`, or `children` to the route record.",
|
||||
docs: "https://router.vuejs.org/guide/essentials/nested-routes.html"
|
||||
},
|
||||
VUE_ROUTER_R0027: {
|
||||
why: (p) => `Component "${p.name}" in record with path "${p.path}" is not a valid component. Received "${p.received}".`,
|
||||
fix: "Pass a component or a function returning a Promise that resolves to one."
|
||||
},
|
||||
VUE_ROUTER_R0028: {
|
||||
why: (p) => `Component "${p.name}" in record with path "${p.path}" is a Promise instead of a function that returns a Promise. This will break in production if not fixed.`,
|
||||
fix: `Defer the import in an arrow function so it loads lazily: write "() => import('./MyPage.vue')", not "import('./MyPage.vue')".`,
|
||||
docs: "https://router.vuejs.org/guide/advanced/lazy-loading.html"
|
||||
},
|
||||
VUE_ROUTER_R0029: {
|
||||
why: (p) => `Component "${p.name}" in record with path "${p.path}" is defined using "defineAsyncComponent()".`,
|
||||
fix: `Drop the wrapper and pass "() => import('./MyPage.vue')" directly; the router handles lazy components itself.`,
|
||||
docs: "https://router.vuejs.org/guide/advanced/lazy-loading.html#Relationship-to-async-components"
|
||||
},
|
||||
VUE_ROUTER_R0030: {
|
||||
why: (p) => `Component "${p.name}" in record with path "${p.path}" is a function that does not return a Promise. This will break in production if not fixed.`,
|
||||
fix: "Return a dynamic import (`() => import(\"./MyPage.vue\")`) from the function, or add a `displayName` if it is a functional component.",
|
||||
docs: "https://router.vuejs.org/guide/advanced/lazy-loading.html"
|
||||
},
|
||||
VUE_ROUTER_R0040: {
|
||||
why: (p) => `Because "${p.el}" starts with "#", scrollBehavior resolves it as an element id via document.getElementById("${p.el.slice(1)}"), not as a CSS selector. No element has that id, but "${p.el}" does match an element with document.querySelector().`,
|
||||
fix: (p) => `Resolve the element yourself and return the node: el: document.querySelector('${p.el}').`,
|
||||
docs: "https://router.vuejs.org/guide/advanced/scroll-behavior.html"
|
||||
},
|
||||
VUE_ROUTER_R0041: {
|
||||
why: (p) => `The selector "${p.el}" is invalid. See https://mathiasbynens.be/notes/css-escapes or CSS.escape (https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape) for the escaping rules.`,
|
||||
fix: "Build an id selector as `#${CSS.escape(id)}` so special characters in the id are escaped.",
|
||||
docs: "https://router.vuejs.org/guide/advanced/scroll-behavior.html"
|
||||
},
|
||||
VUE_ROUTER_R0042: {
|
||||
why: (p) => `Couldn't find element using selector "${p.el}" returned by scrollBehavior.`,
|
||||
fix: "Return a selector that matches an existing element, or guard against missing elements.",
|
||||
docs: "https://router.vuejs.org/guide/advanced/scroll-behavior.html"
|
||||
},
|
||||
VUE_ROUTER_R0050: {
|
||||
why: (p) => {
|
||||
let to;
|
||||
try {
|
||||
to = p.to === void 0 ? "undefined" : JSON.stringify(p.to);
|
||||
} catch {
|
||||
to = String(p.to);
|
||||
}
|
||||
return `Invalid value for prop "to" in useLink()\n- to: ${to}`;
|
||||
},
|
||||
fix: "Pass a valid route location (a string path or an object) to the \"to\" prop."
|
||||
},
|
||||
VUE_ROUTER_R0060: {
|
||||
why: (p) => `<router-view> can no longer be used directly inside <${p.comp}>.`,
|
||||
fix: (p) => `Wrap the slot's resolved component with <${p.comp}> instead of nesting <router-view> in it:\n\n<router-view v-slot="{ Component }">\n <${p.comp}>\n <component :is="Component" />\n </${p.comp}>\n</router-view>`,
|
||||
docs: "https://router.vuejs.org/guide/advanced/router-view-slot.html#KeepAlive-Transition"
|
||||
},
|
||||
VUE_ROUTER_R0070: {
|
||||
why: (p) => `Cannot resolve a relative location without an absolute path. Trying to resolve "${p.to}" from "${p.from}".`,
|
||||
fix: (p) => `Resolve from an absolute \`from\` path that starts with "/", e.g. "/${p.from}".`
|
||||
},
|
||||
VUE_ROUTER_R0080: {
|
||||
why: (p) => `Error decoding "${p.text}". Using original value`,
|
||||
fix: "Ensure the value is correctly percent-encoded."
|
||||
},
|
||||
VUE_ROUTER_R0090: {
|
||||
why: (p) => `Found duplicated params with name "${p.name}" for path "${p.path}". Only the last one will be available on "$route.params".`,
|
||||
fix: "Give each param a unique name within the path.",
|
||||
docs: "https://router.vuejs.org/guide/essentials/route-matching-syntax.html"
|
||||
},
|
||||
VUE_ROUTER_R0100: {
|
||||
why: (p) => `Discarded invalid param(s) "${p.params}" when navigating.` + p.inherited + ` See https://github.com/vuejs/router/commit/e887570 for more details.`,
|
||||
fix: "Only pass params that exist on the target route."
|
||||
},
|
||||
VUE_ROUTER_R0101: {
|
||||
why: (p) => `The Matcher cannot resolve relative paths but received "${p.path}". Unless you directly called \`matcher.resolve("${p.path}")\`, this is probably a bug in vue-router. Please open an issue at https://github.com/vuejs/router/issues/new/choose.`,
|
||||
fix: "Pass an absolute path (starting with \"/\") to the matcher."
|
||||
},
|
||||
VUE_ROUTER_R0102: {
|
||||
why: (p) => `Alias "${p.alias}" and the original record: "${p.original}" must have the exact same param named "${p.name}"`,
|
||||
fix: "Use the same param names in the alias as in the original route.",
|
||||
docs: "https://router.vuejs.org/guide/essentials/redirect-and-alias.html#Alias"
|
||||
},
|
||||
VUE_ROUTER_R0103: {
|
||||
why: (p) => `The route named "${p.name}" has a child without a name, an empty path, and no children. Using that name won't render the empty path child, so this is probably a mistake.`,
|
||||
fix: "Move the `name` onto the empty-path child; or, if intentional, give the child its own name to silence this.",
|
||||
docs: "https://router.vuejs.org/guide/essentials/nested-routes.html#Nested-Named-Routes"
|
||||
},
|
||||
VUE_ROUTER_R0104: {
|
||||
why: (p) => `Absolute path "${p.path}" must have the exact same param named "${p.name}" as its parent "${p.parent}".`,
|
||||
fix: "Include the parent route params in the absolute child path.",
|
||||
docs: "https://router.vuejs.org/guide/essentials/nested-routes.html"
|
||||
},
|
||||
VUE_ROUTER_R0105: {
|
||||
why: (p) => `Finding ancestor route "${p.ancestor}" failed for "${p.record}"`,
|
||||
fix: "Report a reproduction at https://github.com/vuejs/router/issues/new/choose."
|
||||
},
|
||||
VUE_ROUTER_R0110: {
|
||||
why: `A hash base must end with a "#"`,
|
||||
fix: (p) => `Append "#" to the "base" argument passed to "createWebHashHistory()": "${p.base}" should be "${p.suggestion}".`
|
||||
},
|
||||
VUE_ROUTER_R0120: {
|
||||
why: "Error with push/replace State",
|
||||
fix: "The browser rejected the history API call; check for cross-origin or rate-limit issues."
|
||||
},
|
||||
VUE_ROUTER_R0121: {
|
||||
why: "history.state seems to have been manually replaced without preserving the necessary values.\nYou can find more information at https://router.vuejs.org/guide/migration/#Usage-of-history-state",
|
||||
fix: "Merge the router's state into your own when calling it manually: `history.replaceState({ ...history.state, ...yourState }, '', url)`.",
|
||||
docs: "https://router.vuejs.org/guide/migration.html#Usage-of-history-state"
|
||||
},
|
||||
VUE_ROUTER_R1001: {
|
||||
why: (p) => `Data loader "${String(p.key)}" has a different parent than the current context. This shouldn't be happening.`,
|
||||
fix: "Report a bug with a minimal reproduction at https://github.com/vuejs/router/."
|
||||
},
|
||||
VUE_ROUTER_R1002: {
|
||||
why: "Returning a NavigationResult is deprecated.",
|
||||
fix: "Replace `return new NavigationResult(to)` with `reroute(to)`, which throws internally to reroute.",
|
||||
docs: "https://router.vuejs.org/data-loaders/navigation-aware.html#Controlling-the-navigation-with-reroute-"
|
||||
},
|
||||
VUE_ROUTER_R1003: {
|
||||
why: (p) => `Loader "${p.key}"'s "commit()" was called but there is no staged data.`,
|
||||
fix: "Ensure the loader resolved before calling `commit()`.",
|
||||
docs: "https://router.vuejs.org/data-loaders/defining-loaders.html#Delaying-data-updates-with-commit"
|
||||
},
|
||||
VUE_ROUTER_R1004: {
|
||||
why: (p) => "A loader returned a NavigationResult but is not registered on the route." + p.key,
|
||||
fix: "Export the loader from the page component so it gets registered, e.g. `export const useUserData = defineLoader(...)`.",
|
||||
docs: "https://router.vuejs.org/data-loaders/organization.html"
|
||||
},
|
||||
VUE_ROUTER_R1005: {
|
||||
why: (p) => `Data loader "${p.key}" has itself as parent. This shouldn't be happening.`,
|
||||
fix: "Report a bug with a minimal reproduction at https://github.com/vuejs/router/."
|
||||
},
|
||||
VUE_ROUTER_R1006: {
|
||||
why: (p) => `A query was defined with the same key as the loader "[${p.key}]".\nSee https://pinia-colada.esm.dev/#TODO`,
|
||||
fix: "If the key is meant to match, use the data loader directly; otherwise rename the `useQuery()` key so it no longer collides.",
|
||||
docs: "https://router.vuejs.org/data-loaders/colada.html"
|
||||
},
|
||||
VUE_ROUTER_R1007: {
|
||||
why: "Data Loader was setup twice.",
|
||||
fix: "Register `DataLoaderPlugin` a single time via `app.use()`.",
|
||||
docs: "https://router.vuejs.org/data-loaders.html#Installation"
|
||||
},
|
||||
VUE_ROUTER_R1008: {
|
||||
why: "Data Loader is experimental and subject to breaking changes in the future.",
|
||||
docs: "https://router.vuejs.org/data-loaders.html"
|
||||
},
|
||||
VUE_ROUTER_R1009: {
|
||||
why: "Returning a NavigationResult from a loader is deprecated.",
|
||||
fix: "Call `reroute(to)` inside the loader instead of returning `new NavigationResult(to)`; it throws internally to reroute.",
|
||||
docs: "https://router.vuejs.org/data-loaders/navigation-aware.html#Controlling-the-navigation-with-reroute-"
|
||||
}
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
//#region src/injectionSymbols.ts
|
||||
/**
|
||||
* RouteRecord being rendered by the closest ancestor Router View. Used for
|
||||
* `onBeforeRouteUpdate` and `onBeforeRouteLeave`. rvlm stands for Router View
|
||||
* Location Matched
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const matchedRouteKey = Symbol(process.env.NODE_ENV !== "production" ? "router view location matched" : "");
|
||||
/**
|
||||
* Allows overriding the router view depth to control which component in
|
||||
* `matched` is rendered. rvd stands for Router View Depth
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const viewDepthKey = Symbol(process.env.NODE_ENV !== "production" ? "router view depth" : "");
|
||||
/**
|
||||
* Allows overriding the router instance returned by `useRouter` in tests. r
|
||||
* stands for router
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const routerKey = Symbol(process.env.NODE_ENV !== "production" ? "router" : "");
|
||||
/**
|
||||
* Allows overriding the current route returned by `useRoute` in tests. rl
|
||||
* stands for route location
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const routeLocationKey = Symbol(process.env.NODE_ENV !== "production" ? "route location" : "");
|
||||
/**
|
||||
* Allows overriding the current route used by router-view. Internally this is
|
||||
* used when the `route` prop is passed.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const routerViewLocationKey = Symbol(process.env.NODE_ENV !== "production" ? "router view location" : "");
|
||||
//#endregion
|
||||
//#region src/useApi.ts
|
||||
/**
|
||||
* Returns the router instance. Equivalent to using `$router` inside
|
||||
* templates.
|
||||
*/
|
||||
function useRouter() {
|
||||
return inject(routerKey);
|
||||
}
|
||||
/**
|
||||
* Returns the current route location. Equivalent to using `$route` inside
|
||||
* templates.
|
||||
*/
|
||||
function useRoute(_name) {
|
||||
return inject(routeLocationKey);
|
||||
}
|
||||
//#endregion
|
||||
export { isRouteComponent as _, routerKey as a, diagnostics as c, isNavigationFailure as d, applyToParams as f, isESModule as g, isArray as h, routeLocationKey as i, NavigationFailureType as l, identityFn as m, useRouter as n, routerViewLocationKey as o, assign as p, matchedRouteKey as r, viewDepthKey as s, useRoute as t, createRouterError as u, mergeOptions as v, noop as y };
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
let muggle_string = require("muggle-string");
|
||||
//#region src/volar/entries/sfc-route-blocks.ts
|
||||
const allCodeFeatures = {
|
||||
verification: true,
|
||||
completion: true,
|
||||
semantic: true,
|
||||
navigation: true,
|
||||
structure: true,
|
||||
format: true
|
||||
};
|
||||
const plugin = () => {
|
||||
const routeBlockIdPrefix = "route_";
|
||||
const routeBlockIdRe = new RegExp(`^${routeBlockIdPrefix}(\\d+)$`);
|
||||
return {
|
||||
version: 2.1,
|
||||
getEmbeddedCodes(_fileName, sfc) {
|
||||
const embeddedCodes = [];
|
||||
for (let i = 0; i < sfc.customBlocks.length; i++) {
|
||||
const block = sfc.customBlocks[i];
|
||||
if (block.type === "route") {
|
||||
const lang = block.lang === "txt" ? "json" : block.lang;
|
||||
embeddedCodes.push({
|
||||
id: `${routeBlockIdPrefix}${i}`,
|
||||
lang
|
||||
});
|
||||
}
|
||||
}
|
||||
return embeddedCodes;
|
||||
},
|
||||
resolveEmbeddedCode(_fileName, sfc, embeddedCode) {
|
||||
const match = embeddedCode.id.match(routeBlockIdRe);
|
||||
if (match) {
|
||||
const i = parseInt(match[1]);
|
||||
const block = sfc.customBlocks[i];
|
||||
if (!block) return;
|
||||
embeddedCode.content.push([
|
||||
block.content,
|
||||
block.name,
|
||||
0,
|
||||
allCodeFeatures
|
||||
]);
|
||||
if (embeddedCode.lang === "json") {
|
||||
const contentStr = (0, muggle_string.toString)(embeddedCode.content);
|
||||
if (contentStr.trim().startsWith("{") && !contentStr.includes("$schema")) (0, muggle_string.replace)(embeddedCode.content, "{", "{\n \"$schema\": \"https://router.vuejs.org/schemas/route.schema.json\",");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
//#endregion
|
||||
module.exports = plugin;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { VueLanguagePlugin } from "@vue/language-core";
|
||||
//#region src/volar/entries/sfc-route-blocks.d.ts
|
||||
declare const plugin: VueLanguagePlugin;
|
||||
export = plugin;
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
let muggle_string = require("muggle-string");
|
||||
let pathe = require("pathe");
|
||||
//#region src/volar/utils/augment-vls-ctx.ts
|
||||
/**
|
||||
* Augments the VLS context (volar) with additianal type information.
|
||||
*
|
||||
* @param content - content retrieved from the volar pluign
|
||||
* @param codes - codes to add to the VLS context
|
||||
*/
|
||||
function augmentVlsCtx(content, codes) {
|
||||
let from = -1;
|
||||
for (let i = 0; i < content.length; i++) {
|
||||
const code = content[i];
|
||||
if (typeof code !== "string") continue;
|
||||
if (from === -1 && code.startsWith(`const __VLS_ctx`)) from = i;
|
||||
else if (from !== -1) {
|
||||
if (code === `}`) {
|
||||
content.splice(i, 0, ...codes.map((code) => `...${code},\n`));
|
||||
break;
|
||||
} else if (code === `;\n`) {
|
||||
content.splice(from + 1, i - from, `{\n`, `...`, ...content.slice(from + 1, i), `,\n`, ...codes.map((code) => `...${code},\n`), `}`, `;\n`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
//#region src/volar/entries/sfc-typed-router.ts
|
||||
const plugin = ({ compilerOptions, modules: { typescript: ts }, config: { options } }) => {
|
||||
const rootDir = options?.rootDir ?? compilerOptions.rootDir;
|
||||
if (!rootDir) console.warn("[vue-router] No rootDir specified. Set it in the Volar plugin options or tsconfig compilerOptions.rootDir for proper typed routes.");
|
||||
const RE = { DOLLAR_ROUTE: {
|
||||
/**
|
||||
* When using `$route` in a template, it is referred
|
||||
* to as `__VLS_ctx.$route` in the virtual file.
|
||||
*/
|
||||
VLS_CTX: /\b__VLS_ctx.\$route\b/g } };
|
||||
return {
|
||||
version: 2.1,
|
||||
resolveEmbeddedCode(fileName, sfc, embeddedCode) {
|
||||
if (!embeddedCode.id.startsWith("script_")) return;
|
||||
const escapedFilePath = (rootDir ? (0, pathe.relative)(rootDir, fileName) : fileName).replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
||||
const useRouteNameTypeParam = `<${`import('vue-router/auto-routes')._RouteNamesForFilePath<'${escapedFilePath}'>`}>`;
|
||||
const definePageFilePathTypeParam = `<'${escapedFilePath}'>`;
|
||||
if (sfc.scriptSetup) visit(sfc.scriptSetup.ast);
|
||||
function visit(node) {
|
||||
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && ts.idText(node.expression) === "useRoute" && !node.typeArguments && !node.arguments.length) if (!sfc.scriptSetup.lang.startsWith("js")) (0, muggle_string.replaceSourceRange)(embeddedCode.content, sfc.scriptSetup.name, node.expression.end, node.expression.end, useRouteNameTypeParam);
|
||||
else {
|
||||
const { start, end } = getStartEnd(node, sfc.scriptSetup.ast);
|
||||
(0, muggle_string.replaceSourceRange)(embeddedCode.content, sfc.scriptSetup.name, start, start, `(`);
|
||||
(0, muggle_string.replaceSourceRange)(embeddedCode.content, sfc.scriptSetup.name, end, end, ` as ReturnType<typeof useRoute${useRouteNameTypeParam}>)`);
|
||||
}
|
||||
else if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && ts.idText(node.expression) === "definePage" && !node.typeArguments && node.arguments.length === 1 && !sfc.scriptSetup.lang.startsWith("js")) (0, muggle_string.replaceSourceRange)(embeddedCode.content, sfc.scriptSetup.name, node.expression.end, node.expression.end, definePageFilePathTypeParam);
|
||||
else ts.forEachChild(node, visit);
|
||||
}
|
||||
const contentStr = (0, muggle_string.toString)(embeddedCode.content);
|
||||
const vlsCtxAugmentations = [];
|
||||
if (contentStr.match(RE.DOLLAR_ROUTE.VLS_CTX)) vlsCtxAugmentations.push(`{} as { $route: ReturnType<typeof import('vue-router').useRoute${useRouteNameTypeParam}> }`);
|
||||
if (vlsCtxAugmentations.length) augmentVlsCtx(embeddedCode.content, vlsCtxAugmentations);
|
||||
}
|
||||
};
|
||||
function getStartEnd(node, ast) {
|
||||
return {
|
||||
start: ts.getTokenPosOfNode(node, ast),
|
||||
end: node.end
|
||||
};
|
||||
}
|
||||
};
|
||||
//#endregion
|
||||
module.exports = plugin;
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { VueLanguagePlugin } from "@vue/language-core";
|
||||
//#region src/volar/entries/sfc-typed-router.d.ts
|
||||
declare const plugin: VueLanguagePlugin<{
|
||||
options?: {
|
||||
rootDir?: string;
|
||||
};
|
||||
}>;
|
||||
export = plugin;
|
||||
+3025
File diff suppressed because it is too large
Load Diff
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* vue-router v5.2.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { $ as RouteLocationAsPath, $t as RouteQueryAndHash, A as useLink, Ar as LocationQueryValue, At as ParamValue, B as RouterClassic, Bt as LocationAsRelativeRaw, C as RouterView, Cr as createRouterMatcher, Ct as RouteLocationResolvedTypedList, D as UseLinkOptions, Dr as RouteRecordNormalized, Dt as RouteRecordNameGeneric, E as RouterLinkProps, Er as RouteRecord, Et as RouteRecordName, F as routeLocationKey, Ft as RouteParamsRaw, G as createWebHashHistory, Gt as RouteLocationNamedRaw, H as createRouter, Ht as MatcherLocationAsPath, I as routerKey, It as RouteMap, J as NavigationGuardNextCallback, Jt as RouteMeta, K as NavigationGuard, Kt as RouteLocationOptions, L as routerViewLocationKey, Lt as RouteMapGeneric, M as onBeforeRouteLeave, Mr as parseQuery, Mt as ParamValueZeroOrMore, N as onBeforeRouteUpdate, Nr as stringifyQuery, Nt as ParamValueZeroOrOne, O as UseLinkReturn, Or as LocationQuery, Ot as RouteRecordRedirectOption, P as matchedRouteKey, Pr as TypesConfig, Pt as RouteParams, Q as RouteLocation, Qt as RouteParamsRawGeneric, R as viewDepthKey, Rt as RouteRecordInfo, S as useRouter, Sr as RouterMatcher, St as RouteLocationResolvedTyped, T as RouterLink, Tr as _PathParserOptions, Tt as RouteLocationTypedList, U as createMemoryHistory, Ut as RouteComponent, V as RouterOptions, Vt as MatcherLocation, W as createWebHistory, Wt as RouteLocationMatched, X as NavigationGuardWithThis, Xt as RouteParamValueRaw, Y as NavigationGuardReturn, Yt as RouteParamValue, Z as NavigationHookAfter, Zt as RouteParamsGeneric, _r as NavigationFailureType, _t as RouteLocationNormalizedTyped, an as RouteRecordSingleViewWithChildren, at as RouteLocationAsRelativeTyped, br as HistoryState, bt as RouteLocationResolved, ct as RouteLocationAsStringTyped, dr as _Awaitable, dt as RouteLocationNormalized, en as RouteRecordMultipleViews, er as START_LOCATION_NORMALIZED, et as RouteLocationAsPathGeneric, ft as RouteLocationNormalizedGeneric, gr as NavigationFailure, gt as RouteLocationNormalizedLoadedTypedList, hr as ErrorTypes, ht as RouteLocationNormalizedLoadedTyped, in as RouteRecordSingleView, it as RouteLocationAsRelativeGeneric, j as loadRouteLocation, jr as LocationQueryValueRaw, jt as ParamValueOneOrMore, k as _RouterLinkI, kr as LocationQueryRaw, kt as _RouteRecordProps, lt as RouteLocationAsStringTypedList, mt as RouteLocationNormalizedLoadedGeneric, nn as RouteRecordRaw, nt as RouteLocationAsPathTypedList, on as _RouteLocationBase, ot as RouteLocationAsRelativeTypedList, pr as RouterScrollBehavior, pt as RouteLocationNormalizedLoaded, q as NavigationGuardNext, qt as RouteLocationPathRaw, rn as RouteRecordRedirect, rt as RouteLocationAsRelative, sn as _RouteRecordBase, st as RouteLocationAsString, tn as RouteRecordMultipleViewsWithChildren, tt as RouteLocationAsPathTyped, ut as RouteLocationGeneric, vr as NavigationRedirectError, vt as RouteLocationNormalizedTypedList, w as RouterViewProps, wr as PathParserOptions, wt as RouteLocationTyped, x as useRoute, xr as RouterHistory, xt as RouteLocationResolvedGeneric, yr as isNavigationFailure, yt as RouteLocationRaw, z as Router, zt as RouteRecordInfoGeneric } from "./index-BN0B0y8a.js";
|
||||
export { type ErrorTypes, type HistoryState, type LocationAsRelativeRaw, type LocationQuery, type LocationQueryRaw, type LocationQueryValue, type LocationQueryValueRaw, type MatcherLocation, type MatcherLocationAsPath, type NavigationFailure, NavigationFailureType, type NavigationGuard, type NavigationGuardNext, type NavigationGuardNextCallback, type NavigationGuardReturn, type NavigationGuardWithThis, type NavigationHookAfter, type NavigationRedirectError, type ParamValue, type ParamValueOneOrMore, type ParamValueZeroOrMore, type ParamValueZeroOrOne, type PathParserOptions, type RouteComponent, type RouteLocation, type RouteLocationAsPath, type RouteLocationAsPathGeneric, type RouteLocationAsPathTyped, type RouteLocationAsPathTypedList, type RouteLocationAsRelative, type RouteLocationAsRelativeGeneric, type RouteLocationAsRelativeTyped, type RouteLocationAsRelativeTypedList, type RouteLocationAsString, type RouteLocationAsStringTyped, type RouteLocationAsStringTypedList, type RouteLocationGeneric, type RouteLocationMatched, type RouteLocationNamedRaw, type RouteLocationNormalized, type RouteLocationNormalizedGeneric, type RouteLocationNormalizedLoaded, type RouteLocationNormalizedLoadedGeneric, type RouteLocationNormalizedLoadedTyped, type RouteLocationNormalizedLoadedTypedList, type RouteLocationNormalizedTyped, type RouteLocationNormalizedTypedList, type RouteLocationOptions, type RouteLocationPathRaw, type RouteLocationRaw, type RouteLocationResolved, type RouteLocationResolvedGeneric, type RouteLocationResolvedTyped, type RouteLocationResolvedTypedList, type RouteLocationTyped, type RouteLocationTypedList, type RouteMap, type RouteMapGeneric, type RouteMeta, type RouteParamValue, type RouteParamValueRaw, type RouteParams, type RouteParamsGeneric, type RouteParamsRaw, type RouteParamsRawGeneric, type RouteQueryAndHash, type RouteRecord, type RouteRecordInfo, type RouteRecordInfoGeneric, type RouteRecordMultipleViews, type RouteRecordMultipleViewsWithChildren, type RouteRecordName, type RouteRecordNameGeneric, type RouteRecordNormalized, type RouteRecordRaw, type RouteRecordRedirect, type RouteRecordRedirectOption, type RouteRecordSingleView, type RouteRecordSingleViewWithChildren, type Router, type RouterHistory, RouterLink, type RouterLinkProps, type RouterMatcher, type RouterOptions, type RouterScrollBehavior, RouterView, type RouterViewProps, START_LOCATION_NORMALIZED as START_LOCATION, type TypesConfig, type UseLinkOptions, type UseLinkReturn, type _Awaitable, type _PathParserOptions, type _RouteLocationBase, type _RouteRecordBase, type _RouteRecordProps, type RouterClassic as _RouterClassic, type _RouterLinkI, createMemoryHistory, createRouter, createRouterMatcher, createWebHashHistory, createWebHistory, isNavigationFailure, loadRouteLocation, matchedRouteKey, onBeforeRouteLeave, onBeforeRouteUpdate, parseQuery, routeLocationKey, routerKey, routerViewLocationKey, stringifyQuery, useLink, useRoute, useRouter, viewDepthKey };
|
||||
+2995
File diff suppressed because it is too large
Load Diff
+6
File diff suppressed because one or more lines are too long
+2
@@ -0,0 +1,2 @@
|
||||
console.warn("[vue-router]: importing from 'vue-router/dist/vue-router.esm-bundler.js' is deprecated. Use 'vue-router' directly.")
|
||||
export * from './vue-router.js'
|
||||
+2673
File diff suppressed because it is too large
Load Diff
+6
File diff suppressed because one or more lines are too long
+1543
File diff suppressed because it is too large
Load Diff
+10
File diff suppressed because one or more lines are too long
+7
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./dist/vue-router.prod.cjs')
|
||||
} else {
|
||||
module.exports = require('./dist/vue-router.cjs')
|
||||
}
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
{
|
||||
"name": "vue-router",
|
||||
"version": "5.2.0",
|
||||
"homepage": "https://router.vuejs.org",
|
||||
"bugs": {
|
||||
"url": "https://github.com/vuejs/router/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Eduardo San Martin Morote",
|
||||
"email": "posva13@gmail.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vuejs/router.git"
|
||||
},
|
||||
"funding": "https://github.com/sponsors/posva",
|
||||
"files": [
|
||||
"dist",
|
||||
"index.cjs",
|
||||
"README.md",
|
||||
"route.schema.json",
|
||||
"vue-router-auto-resolver.d.mts",
|
||||
"vue-router-auto-routes.d.mts",
|
||||
"vue-router-auto.d.ts",
|
||||
"vue-router.node.mjs",
|
||||
"vetur/attributes.json",
|
||||
"vetur/tags.json"
|
||||
],
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"main": "index.cjs",
|
||||
"module": "dist/vue-router.js",
|
||||
"types": "dist/vue-router.d.ts",
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"vite": [
|
||||
"./dist/unplugin/vite.d.mts"
|
||||
],
|
||||
"unplugin": [
|
||||
"./dist/unplugin/index.d.mts"
|
||||
],
|
||||
"unplugin/*": [
|
||||
"./dist/unplugin/*.d.mts"
|
||||
],
|
||||
"volar/*": [
|
||||
"./dist/volar/*.d.cts"
|
||||
]
|
||||
}
|
||||
},
|
||||
"unpkg": "dist/vue-router.global.js",
|
||||
"jsdelivr": "dist/vue-router.global.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/vue-router.d.ts",
|
||||
"node": {
|
||||
"import": {
|
||||
"production": "./vue-router.node.mjs",
|
||||
"development": "./vue-router.node.mjs",
|
||||
"default": "./vue-router.node.mjs"
|
||||
},
|
||||
"require": {
|
||||
"production": "./dist/vue-router.prod.cjs",
|
||||
"development": "./dist/vue-router.cjs",
|
||||
"default": "./index.cjs"
|
||||
}
|
||||
},
|
||||
"import": "./dist/vue-router.js",
|
||||
"require": "./index.cjs"
|
||||
},
|
||||
"./vetur/*": "./vetur/*",
|
||||
"./package.json": "./package.json",
|
||||
"./experimental": {
|
||||
"types": "./dist/experimental/index.d.ts",
|
||||
"import": "./dist/experimental/index.js"
|
||||
},
|
||||
"./experimental/pinia-colada": {
|
||||
"types": "./dist/experimental/pinia-colada.d.ts",
|
||||
"import": "./dist/experimental/pinia-colada.js"
|
||||
},
|
||||
"./auto-resolver": {
|
||||
"types": "./vue-router-auto-resolver.d.mts"
|
||||
},
|
||||
"./auto-routes": {
|
||||
"types": "./vue-router-auto-routes.d.mts"
|
||||
},
|
||||
"./auto": {
|
||||
"types": "./vue-router-auto.d.ts",
|
||||
"node": {
|
||||
"import": {
|
||||
"production": "./vue-router.node.mjs",
|
||||
"development": "./vue-router.node.mjs",
|
||||
"default": "./vue-router.node.mjs"
|
||||
},
|
||||
"require": {
|
||||
"production": "./dist/vue-router.prod.cjs",
|
||||
"development": "./dist/vue-router.cjs",
|
||||
"default": "./index.cjs"
|
||||
}
|
||||
},
|
||||
"import": "./dist/vue-router.js",
|
||||
"require": "./index.cjs"
|
||||
},
|
||||
"./vite": {
|
||||
"types": "./dist/unplugin/vite.d.mts",
|
||||
"import": "./dist/unplugin/vite.mjs",
|
||||
"require": "./dist/unplugin/vite.cjs"
|
||||
},
|
||||
"./unplugin": {
|
||||
"types": "./dist/unplugin/index.d.mts",
|
||||
"import": "./dist/unplugin/index.mjs",
|
||||
"require": "./dist/unplugin/index.cjs"
|
||||
},
|
||||
"./unplugin/*": "./dist/unplugin/*",
|
||||
"./volar/sfc-route-blocks": {
|
||||
"types": "./dist/volar/sfc-route-blocks.d.cts",
|
||||
"default": "./dist/volar/sfc-route-blocks.cjs"
|
||||
},
|
||||
"./volar/sfc-typed-router": {
|
||||
"types": "./dist/volar/sfc-typed-router.d.cts",
|
||||
"default": "./dist/volar/sfc-typed-router.cjs"
|
||||
},
|
||||
"./dist/*": "./dist/*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/generator": "^8.0.0",
|
||||
"@vue-macros/common": "^3.1.3",
|
||||
"@vue/devtools-api": "^8.1.5",
|
||||
"ast-walker-scope": "^0.9.0",
|
||||
"chokidar": "^5.0.0",
|
||||
"json5": "^2.2.3",
|
||||
"local-pkg": "^1.2.1",
|
||||
"magic-string": "^0.30.21",
|
||||
"mlly": "^1.8.2",
|
||||
"muggle-string": "^0.4.1",
|
||||
"nostics": "^1.1.4",
|
||||
"pathe": "^2.0.3",
|
||||
"picomatch": "^4.0.5",
|
||||
"scule": "^1.3.0",
|
||||
"tinyglobby": "^0.2.17",
|
||||
"unplugin": "^3.3.0",
|
||||
"unplugin-utils": "^0.3.2",
|
||||
"yaml": "^2.9.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/types": "^8.0.0",
|
||||
"@pinia/colada": "^1.3.1",
|
||||
"@playwright/test": "^1.61.1",
|
||||
"@rollup/plugin-commonjs": "^29.0.3",
|
||||
"@rollup/plugin-node-resolve": "^16.0.3",
|
||||
"@rollup/plugin-replace": "^6.0.3",
|
||||
"@rollup/plugin-terser": "^1.0.0",
|
||||
"@standard-schema/spec": "^1.1.0",
|
||||
"@types/babel__generator": "^7.27.0",
|
||||
"@types/picomatch": "^4.0.3",
|
||||
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
||||
"@vitejs/plugin-vue": "^6.0.7",
|
||||
"@vue/compiler-sfc": "^3.5.34",
|
||||
"@vue/language-core": "^3.3.7",
|
||||
"@vue/server-renderer": "^3.5.34",
|
||||
"@vue/test-utils": "^2.4.11",
|
||||
"connect-history-api-fallback": "^2.0.0",
|
||||
"faked-promise": "^2.2.2",
|
||||
"happy-dom": "^20.10.6",
|
||||
"pinia": "^3.0.4",
|
||||
"rimraf": "^6.1.3",
|
||||
"rollup": "^4.62.2",
|
||||
"rollup-plugin-typescript2": "^0.36.0",
|
||||
"tsdown": "^0.22.7",
|
||||
"tsup": "^8.5.1",
|
||||
"valibot": "^1.4.2",
|
||||
"vite": "^7.3.0",
|
||||
"vue": "^3.5.34",
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@pinia/colada": ">=0.21.2",
|
||||
"@vue/compiler-sfc": "^3.5.34 || ^4.0.0",
|
||||
"pinia": "^3.0.4 || ^4.0.2",
|
||||
"vite": "^7.3.0 || ^8.0.0",
|
||||
"vue": "^3.5.34 || ^4.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@vue/compiler-sfc": {
|
||||
"optional": true
|
||||
},
|
||||
"pinia": {
|
||||
"optional": true
|
||||
},
|
||||
"@pinia/colada": {
|
||||
"optional": true
|
||||
},
|
||||
"vite": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"vetur": {
|
||||
"tags": "vetur/tags.json",
|
||||
"attributes": "vetur/attributes.json"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vitest --ui",
|
||||
"build": "tsdown",
|
||||
"build:old": "rimraf dist && rollup -c rollup.config.mjs",
|
||||
"build:playground": "vue-tsc --noEmit && vite build --config playground/vite.config.ts",
|
||||
"build:e2e": "vue-tsc --noEmit && vite build --config e2e/vite.config.mjs",
|
||||
"build:size": "pnpm run build && rollup -c size-checks/rollup.config.mjs",
|
||||
"dev:e2e": "vite --config e2e/vite.config.mjs",
|
||||
"test:types": "tsgo --build tsconfig.json ./test-dts/tsconfig.experimental.json",
|
||||
"test:unit": "vitest --coverage run",
|
||||
"test": "pnpm run build && pnpm run '/^(test:unit|test:types)$/' && pnpm run test:e2e",
|
||||
"test:e2e": "playwright test"
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://raw.githubusercontent.com/posva/unplugin-vue-router/main/route.schema.json",
|
||||
"title": "Route custom block",
|
||||
"description": "An SFC custom block to add information to a route",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "The name of the route"
|
||||
},
|
||||
"path": {
|
||||
"type": "string",
|
||||
"description": "The path of the route"
|
||||
},
|
||||
"meta": {
|
||||
"type": "object",
|
||||
"description": "The meta of the route"
|
||||
},
|
||||
"props": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the route should be passed its params as props"
|
||||
}
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": {
|
||||
"type": "string | symbol",
|
||||
"description": "When a `<router-view>` has a `name` prop, it will render the component with the corresponding name in the matched route record's components option."
|
||||
},
|
||||
"route": {
|
||||
"description": "When a `<router-view>` has a `route` prop, it will use that resolved Route Location instead of the current location."
|
||||
},
|
||||
"to": {
|
||||
"description": "Denotes the target route of the link. When clicked, the value of the `to` prop will be internally passed to `router.push()`, so the value can be either a string or a location descriptor object."
|
||||
},
|
||||
"replace": {
|
||||
"type": "boolean",
|
||||
"description": "Setting replace prop will call `router.replace()` instead of `router.push()` when clicked, so the navigation will replace the current history entry."
|
||||
},
|
||||
"custom": {
|
||||
"type": "boolean",
|
||||
"description": "Whether `<router-link>` should not wrap its content in an `<a>` tag."
|
||||
},
|
||||
"active-class": {
|
||||
"type": "string",
|
||||
"description": "Configure the active CSS class applied when the link is active. Note the default value can also be configured globally via the `linkActiveClass` router constructor option."
|
||||
},
|
||||
"exact-active-class": {
|
||||
"type": "string",
|
||||
"description": "Configure the active CSS class applied when the link is exactly active. Note the default value can also be configured globally via the `linkExactActiveClass` router constructor option."
|
||||
},
|
||||
"aria-current-value": {
|
||||
"options": ["page", "step", "location", "date", "time", "true", "false"],
|
||||
"description": "Configure the value of `aria-current` when the link is active with exact match. It must be one of the [allowed values for `aria-current`](https://www.w3.org/TR/wai-aria-1.2/#aria-current) in the ARIA spec. In most cases, the default of `page` should be the best fit."
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"router-view": {
|
||||
"attributes": ["name", "route"],
|
||||
"description": "Component that renders the matched component for the current location. Components rendered by `<router-view>` can also contain their own `<router-view>` to render nested routes."
|
||||
},
|
||||
"router-link": {
|
||||
"attributes": [
|
||||
"to",
|
||||
"replace",
|
||||
"custom",
|
||||
"active-class",
|
||||
"exact-active-class",
|
||||
"aria-current-value"
|
||||
],
|
||||
"description": "Component that renders an `<a>` with the correct `href` attribute and click listeners to trigger a local navigation when clicked. Can also customize its rendering by providing the `custom` prop and using its `v-slot` API."
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* TODO: remove the declaration if possible when merging unplugin-vue-router
|
||||
* into this monorepo in v6
|
||||
*/
|
||||
|
||||
import type {
|
||||
EXPERIMENTAL_Router,
|
||||
EXPERIMENTAL_RouterOptions,
|
||||
} from 'vue-router/experimental'
|
||||
|
||||
/**
|
||||
* Handles HMR.
|
||||
* Generated by unplugin-vue-router
|
||||
*/
|
||||
export function handleHotUpdate(router: EXPERIMENTAL_Router): void
|
||||
|
||||
/**
|
||||
* Custom resolver automatically generated at build time
|
||||
* Generated by unplugin-vue-router
|
||||
*/
|
||||
export declare const resolver: EXPERIMENTAL_RouterOptions['resolver']
|
||||
|
||||
// TODO:move to the generated route map so it can import the correct version (custom resolvers or not)
|
||||
// Make the macros globally available
|
||||
// declare global {
|
||||
// const definePage: (typeof import("vue-router/experimental"))["definePage"];
|
||||
// }
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
import type { Router, RouteRecordRaw } from 'vue-router'
|
||||
|
||||
/**
|
||||
* Array of routes generated by vue-router file based routing
|
||||
*/
|
||||
export declare const routes: RouteRecordRaw[]
|
||||
|
||||
/**
|
||||
* Setups hot module replacement for routes.
|
||||
*
|
||||
* @param router - The router instance
|
||||
* @param hotUpdateCallback - Callback to be called after replacing the routes and before the navigation
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import { createRouter, createWebHistory } from 'vue-router'
|
||||
* import { routes, handleHotUpdate } from 'vue-router/auto-routes'
|
||||
* const router = createRouter({
|
||||
* history: createWebHistory(),
|
||||
* routes,
|
||||
* })
|
||||
* if (import.meta.hot) {
|
||||
* handleHotUpdate(router)
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare function handleHotUpdate(
|
||||
router: Router,
|
||||
hotUpdateCallback?: (newRoutes: RouteRecordRaw[]) => void
|
||||
): void
|
||||
|
||||
// The actual `RouteNamedMap` body is generated by the unplugin into the user's
|
||||
// `routes.d.ts` and wired into `vue-router`'s `TypesConfig` from there, so the
|
||||
// typed routes work even if this module is never imported (e.g. when only
|
||||
// `vue-router/auto-resolver` is used). See vuejs/router#2696.
|
||||
// TODO(v6): rename to `RouteMap` and host the interface directly on `vue-router`.
|
||||
export interface RouteNamedMap {}
|
||||
|
||||
/**
|
||||
* Map of route file paths (relative to the project root) to information about
|
||||
* the routes they declare. Augmented from the user's generated `routes.d.ts`
|
||||
* by the unplugin. Used by the `definePage` macro typing and the
|
||||
* `sfc-typed-router` Volar plugin to type `useRoute()` per file.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export interface _RouteFileInfoMap {}
|
||||
|
||||
// Make the macros globally available
|
||||
declare global {
|
||||
const definePage: (typeof import('vue-router/experimental'))['definePage']
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// DEPRECATED: will be removed in future versions
|
||||
// This file is augmented by the file-based routing plugin (vue-router/vite or vue-router/unplugin)
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
global.__VUE_PROD_DEVTOOLS__ = false
|
||||
export * from './dist/vue-router.js'
|
||||
Reference in New Issue
Block a user