Base UI
NPM Installation / build (16.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (16.x, windows-latest) (push) Has been cancelled
NPM Installation / build (17.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (17.x, windows-latest) (push) Has been cancelled
NPM Installation / build (18.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (18.x, windows-latest) (push) Has been cancelled
NPM Installation / build (16.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (16.x, windows-latest) (push) Has been cancelled
NPM Installation / build (17.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (17.x, windows-latest) (push) Has been cancelled
NPM Installation / build (18.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (18.x, windows-latest) (push) Has been cancelled
This commit is contained in:
+1034
File diff suppressed because it is too large
Load Diff
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* vue-router v5.1.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-BQLwgiyK.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 };
|
||||
+1109
File diff suppressed because it is too large
Load Diff
+152
@@ -0,0 +1,152 @@
|
||||
/*!
|
||||
* vue-router v5.1.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-BQLwgiyK.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.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { n as useRouter, t as useRoute } from "../useApi-s_02lHjl.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-B8OQKdL7.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]) console.warn(`❌👶 "${key}" has a different parent than the current context. This shouldn't be happening. Please report a bug with a reproduction to https://github.com/vuejs/router/`);
|
||||
}
|
||||
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") console.warn("[vue-router]: Returning a NavigationResult is deprecated. Use reroute() instead, which throws internally.");
|
||||
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) console.warn(`Loader "${key}"'s "commit()" was called but there is no staged data.`);
|
||||
}
|
||||
if (this.staged !== STAGED_NO_VALUE) {
|
||||
this.data.value = this.staged;
|
||||
if (process.env.NODE_ENV !== "production" && !this.tracked.has(joinKeys(key))) {
|
||||
console.warn(`A query was defined with the same key as the loader "[${key.join(", ")}]". If the "key" is meant to be the same, you should directly use the data loader instead. If not, change the key of the "useQuery()".\nSee https://pinia-colada.esm.dev/#TODO`);
|
||||
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 };
|
||||
+3300
File diff suppressed because one or more lines are too long
+316
@@ -0,0 +1,316 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { u as isNavigationFailure } from "./useApi-s_02lHjl.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") console.warn("[vue-router]: Data Loader was setup twice. Make sure to setup only once.");
|
||||
return () => {};
|
||||
}
|
||||
if (process.env.NODE_ENV === "development" && !isSSR) console.warn("[vue-router]: Data Loader is experimental and subject to breaking changes in the future.");
|
||||
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) {
|
||||
console.warn("[vue-router]: Returning a NavigationResult from a loader is deprecated. Use reroute() instead, which throws internally.");
|
||||
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 };
|
||||
+2920
File diff suppressed because it is too large
Load Diff
+492
@@ -0,0 +1,492 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
require("./unplugin-Vw8dABVY.cjs");
|
||||
let scule = require("scule");
|
||||
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 warn(msg, type = "warn") {
|
||||
console[type](`⚠️ [vue-router]: ${msg}`);
|
||||
}
|
||||
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 = [...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/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(".")) {
|
||||
warn(`Invalid extension "${ext}". Extensions must start with a dot.`);
|
||||
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, "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;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "warn", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return warn;
|
||||
}
|
||||
});
|
||||
+372
@@ -0,0 +1,372 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { pascalCase } from "scule";
|
||||
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 warn(msg, type = "warn") {
|
||||
console[type](`⚠️ [vue-router]: ${msg}`);
|
||||
}
|
||||
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 = [...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/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(".")) {
|
||||
warn(`Invalid extension "${ext}". Extensions must start with a dot.`);
|
||||
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, appendExtensionListToPattern as c, getPascalCaseRouteName as d, joinPath as f, warn as g, throttle as h, resolveOptions as i, asRoutePath as l, mergeRouteRecordOverride as m, DEFAULT_PARAM_PARSERS_OPTIONS as n, ESCAPED_TRAILING_SLASH_RE as o, logTree as p, mergeAllExtensions as r, ImportsMap as s, DEFAULT_OPTIONS as t, getFileBasedRouteName as u, pad as v, toStringLiteral as y };
|
||||
+2920
File diff suppressed because it is too large
Load Diff
+2693
File diff suppressed because it is too large
Load Diff
+2760
File diff suppressed because it is too large
Load Diff
+13
@@ -0,0 +1,13 @@
|
||||
/*!
|
||||
* vue-router v5.1.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-Vw8dABVY.cjs").unplugin_default.esbuild;
|
||||
//#endregion
|
||||
exports.default = esbuild_default;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-B8uG6j8p.cjs";
|
||||
|
||||
//#region src/unplugin/esbuild.d.ts
|
||||
declare const _default: (options?: Options | undefined) => import("esbuild").Plugin;
|
||||
export = _default;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-_KKPn1xZ.mjs";
|
||||
|
||||
//#region src/unplugin/esbuild.d.ts
|
||||
declare const _default: (options?: Options | undefined) => import("esbuild").Plugin;
|
||||
//#endregion
|
||||
export { _default as default };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { n as unplugin_default } from "../unplugin-4B3GmLui.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.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
Object.defineProperties(exports, {
|
||||
__esModule: { value: true },
|
||||
[Symbol.toStringTag]: { value: "Module" }
|
||||
});
|
||||
const require_unplugin = require("../unplugin-Vw8dABVY.cjs");
|
||||
const require_options = require("../options-BOEzfG3T.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;
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*!
|
||||
* vue-router v5.1.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-B8uG6j8p.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 };
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*!
|
||||
* vue-router v5.1.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-_KKPn1xZ.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.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { d as getPascalCaseRouteName, i as resolveOptions, t as DEFAULT_OPTIONS, u as getFileBasedRouteName } from "../options-C1qMILzC.mjs";
|
||||
import { a as EditableTreeNode, i as createRoutesContext, n as unplugin_default, o as createTreeNodeValue, r as AutoExportLoaders, t as VueRouterAutoImports } from "../unplugin-4B3GmLui.mjs";
|
||||
export { AutoExportLoaders, DEFAULT_OPTIONS, EditableTreeNode, VueRouterAutoImports, createRoutesContext, createTreeNodeValue, unplugin_default as default, getFileBasedRouteName, getPascalCaseRouteName, resolveOptions };
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const require_options = require("../options-BOEzfG3T.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.1.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-B8uG6j8p.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.1.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-_KKPn1xZ.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.1.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-C1qMILzC.mjs";
|
||||
export { DEFAULT_OPTIONS, DEFAULT_PARAM_PARSERS_OPTIONS, mergeAllExtensions, resolveOptions, resolveOverridableOption };
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/*!
|
||||
* vue-router v5.1.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-Vw8dABVY.cjs").unplugin_default.rolldown;
|
||||
//#endregion
|
||||
exports.default = rolldown_default;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-B8uG6j8p.cjs";
|
||||
|
||||
//#region src/unplugin/rolldown.d.ts
|
||||
declare const _default: (options?: Options | undefined) => import("rolldown").Plugin<any> | import("rolldown").Plugin<any>[];
|
||||
export = _default;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-_KKPn1xZ.mjs";
|
||||
|
||||
//#region src/unplugin/rolldown.d.ts
|
||||
declare const _default: (options?: Options | undefined) => import("rolldown").Plugin<any> | import("rolldown").Plugin<any>[];
|
||||
//#endregion
|
||||
export { _default as default };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { n as unplugin_default } from "../unplugin-4B3GmLui.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.1.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-Vw8dABVY.cjs").unplugin_default.rollup;
|
||||
//#endregion
|
||||
exports.default = rollup_default;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-B8uG6j8p.cjs";
|
||||
|
||||
//#region src/unplugin/rollup.d.ts
|
||||
declare const _default: (options?: Options | undefined) => import("rollup").Plugin<any> | import("rollup").Plugin<any>[];
|
||||
export = _default;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-_KKPn1xZ.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.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { n as unplugin_default } from "../unplugin-4B3GmLui.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.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* vue-router v5.1.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-B8uG6j8p.cjs";
|
||||
export type { EditableTreeNode, Options, TreeNode, TreeNodeValue, TreeNodeValueGroup, TreeNodeValueParam, TreeNodeValueStatic };
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* vue-router v5.1.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-_KKPn1xZ.mjs";
|
||||
export type { EditableTreeNode, Options, TreeNode, TreeNodeValue, TreeNodeValueGroup, TreeNodeValueParam, TreeNodeValueStatic };
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
export {};
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/*!
|
||||
* vue-router v5.1.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-Vw8dABVY.cjs").unplugin_default.vite;
|
||||
//#endregion
|
||||
exports.default = vite_default;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-B8uG6j8p.cjs";
|
||||
|
||||
//#region src/unplugin/vite.d.ts
|
||||
declare const _default: (options?: Options | undefined) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
|
||||
export = _default;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-_KKPn1xZ.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.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { n as unplugin_default } from "../unplugin-4B3GmLui.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.1.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-Vw8dABVY.cjs").unplugin_default.webpack;
|
||||
//#endregion
|
||||
exports.default = webpack_default;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-B8uG6j8p.cjs";
|
||||
|
||||
//#region src/unplugin/webpack.d.ts
|
||||
declare const _default: (options?: Options | undefined) => WebpackPluginInstance;
|
||||
export = _default;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { r as Options } from "../options-_KKPn1xZ.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.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { n as unplugin_default } from "../unplugin-4B3GmLui.mjs";
|
||||
//#region src/unplugin/webpack.ts
|
||||
var webpack_default = unplugin_default.webpack;
|
||||
//#endregion
|
||||
export { webpack_default as default };
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
/*!
|
||||
* vue-router v5.1.0
|
||||
* (c) 2026 Eduardo San Martin Morote
|
||||
* @license MIT
|
||||
*/
|
||||
import { inject } from "vue";
|
||||
//#region src/utils/env.ts
|
||||
const isBrowser = typeof document !== "undefined";
|
||||
//#endregion
|
||||
//#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"
|
||||
];
|
||||
function stringifyRoute(to) {
|
||||
if (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/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 { mergeOptions as _, routerKey as a, NavigationFailureType as c, applyToParams as d, assign as f, isRouteComponent as g, isESModule as h, routeLocationKey as i, createRouterError as l, isArray as m, useRouter as n, routerViewLocationKey as o, identityFn as p, matchedRouteKey as r, viewDepthKey as s, useRoute as t, isNavigationFailure as u, noop as v, isBrowser as y };
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*!
|
||||
* vue-router v5.1.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;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* vue-router v5.1.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.1.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;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/*!
|
||||
* vue-router v5.1.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;
|
||||
+2704
File diff suppressed because it is too large
Load Diff
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* vue-router v5.1.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-BQLwgiyK.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 };
|
||||
+2674
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'
|
||||
+2353
File diff suppressed because it is too large
Load Diff
+6
File diff suppressed because one or more lines are too long
+1499
File diff suppressed because it is too large
Load Diff
+19
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user