Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
21
Frontend-Learner/node_modules/unplugin-vue-router/LICENSE
generated
vendored
Normal file
21
Frontend-Learner/node_modules/unplugin-vue-router/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2022 Eduardo San Martin Morote
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
208
Frontend-Learner/node_modules/unplugin-vue-router/README.md
generated
vendored
Normal file
208
Frontend-Learner/node_modules/unplugin-vue-router/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
# unplugin-vue-router
|
||||
|
||||
[](https://www.npmjs.com/package/unplugin-vue-router) [](https://github.com/posva/unplugin-vue-router/actions/workflows/ci.yml) [](https://codecov.io/gh/posva/unplugin-vue-router)
|
||||
|
||||
> Automatic file based Routing in Vue with TS support ✨
|
||||
|
||||
<!-- https://user-images.githubusercontent.com/664177/176622756-3d10acc6-caac-40ff-a41f-9bdccadf7f1d.mp4 -->
|
||||
|
||||
<p align="center">
|
||||
<img src="https://user-images.githubusercontent.com/664177/176623167-0153f9fb-79cd-49a7-8575-429ce323dd11.gif" >
|
||||
</p>
|
||||
|
||||
- [StackBlitz Demo](https://stackblitz.com/github/posva/uvr-demo)
|
||||
|
||||
This build-time plugin simplifies your routing setup **and** makes it safer and easier to use thanks to TypeScript. Requires Vue Router >=4.4.0.
|
||||
|
||||
> [!WARNING]
|
||||
> While unplugin-vue-router typed routing and file based routing is fundamentally stable, it contains other experimental APIs that are subject to change (e.g. Data Loaders). Make sure to check the relevant [Documentation](https://uvr.esm.is) for the latest information.
|
||||
> If you find any issue, design flaw, or have ideas to improve it, please, open open an [issue](https://github.com/posva/unplugin-vue-router/issues/new/choose) or a [Discussion](https://github.com/posva/unplugin-vue-router/discussions).
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm i -D unplugin-vue-router
|
||||
```
|
||||
|
||||
Add VueRouter plugin **before** Vue plugin:
|
||||
|
||||
<details>
|
||||
<summary>Vite</summary><br>
|
||||
|
||||
```ts
|
||||
// vite.config.ts
|
||||
import VueRouter from 'unplugin-vue-router/vite'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
VueRouter({
|
||||
/* options */
|
||||
}),
|
||||
// ⚠️ Vue must be placed after VueRouter()
|
||||
Vue(),
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
Example: [`playground/`](./playground/)
|
||||
|
||||
<br></details>
|
||||
|
||||
<details>
|
||||
<summary>Rollup</summary><br>
|
||||
|
||||
```ts
|
||||
// rollup.config.js
|
||||
import VueRouter from 'unplugin-vue-router/rollup'
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
VueRouter({
|
||||
/* options */
|
||||
}),
|
||||
// ⚠️ Vue must be placed after VueRouter()
|
||||
Vue(),
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
<br></details>
|
||||
|
||||
<details>
|
||||
<summary>Webpack</summary><br>
|
||||
|
||||
```ts
|
||||
// webpack.config.js
|
||||
module.exports = {
|
||||
/* ... */
|
||||
plugins: [
|
||||
require('unplugin-vue-router/webpack')({
|
||||
/* options */
|
||||
}),
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
<br></details>
|
||||
|
||||
<details>
|
||||
<summary>Vue CLI</summary><br>
|
||||
|
||||
```ts
|
||||
// vue.config.js
|
||||
module.exports = {
|
||||
configureWebpack: {
|
||||
plugins: [
|
||||
require('unplugin-vue-router/webpack')({
|
||||
/* options */
|
||||
}),
|
||||
],
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
<br></details>
|
||||
|
||||
<details>
|
||||
<summary>esbuild</summary><br>
|
||||
|
||||
```ts
|
||||
// esbuild.config.js
|
||||
import { build } from 'esbuild'
|
||||
import VueRouter from 'unplugin-vue-router/esbuild'
|
||||
|
||||
build({
|
||||
plugins: [VueRouter()],
|
||||
})
|
||||
```
|
||||
|
||||
<br></details>
|
||||
|
||||
## Setup
|
||||
|
||||
After installing, **you should run your dev server** (usually `npm run dev`) **to generate the first version of the types**. Then you need to add the types to your `tsconfig.json`.
|
||||
|
||||
```json
|
||||
{
|
||||
"include": [
|
||||
// ...
|
||||
"./typed-router.d.ts"
|
||||
],
|
||||
// ...
|
||||
"compilerOptions": {
|
||||
// ...
|
||||
"moduleResolution": "Bundler"
|
||||
// ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then, if you have an `env.d.ts` file like the one created by `npm vue create <my-project>`, add the `unplugin-vue-router/client` types to it:
|
||||
|
||||
```ts
|
||||
// env.d.ts
|
||||
/// <reference types="vite/client" />
|
||||
/// <reference types="unplugin-vue-router/client" />
|
||||
```
|
||||
|
||||
If you don't have an `env.d.ts` file, you can create one and add the unplugin-vue-router types to it _or_ you can add them to the `types` property in your `tsconfig.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
// ...
|
||||
"types": ["unplugin-vue-router/client"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Finally, import the generated routes from `vue-router/auto-routes` and pass them to the router:
|
||||
|
||||
```diff
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
+import { routes } from 'vue-router/auto-routes'
|
||||
|
||||
createRouter({
|
||||
history: createWebHistory(),
|
||||
// pass the generated routes written by the plugin 🤖
|
||||
+ routes,
|
||||
})
|
||||
```
|
||||
|
||||
Alternatively, **you can also import the `routes` array** and create the router manually or pass it to some plugin. Here is an example with [Vitesse starter](https://github.com/antfu-collective/vitesse/blob/main/src/main.ts):
|
||||
|
||||
```diff
|
||||
import { ViteSSG } from 'vite-ssg'
|
||||
import { setupLayouts } from 'virtual:generated-layouts'
|
||||
import App from './App.vue'
|
||||
import type { UserModule } from './types'
|
||||
-import generatedRoutes from '~pages'
|
||||
+import { routes } from 'vue-router/auto-routes'
|
||||
|
||||
import '@unocss/reset/tailwind.css'
|
||||
import './styles/main.css'
|
||||
import 'uno.css'
|
||||
|
||||
-const routes = setupLayouts(generatedRoutes)
|
||||
|
||||
// https://github.com/antfu/vite-ssg
|
||||
export const createApp = ViteSSG(
|
||||
App,
|
||||
{
|
||||
- routes,
|
||||
+ routes: setupLayouts(routes),
|
||||
base: import.meta.env.BASE_URL
|
||||
},
|
||||
(ctx) => {
|
||||
// install all modules under `modules/`
|
||||
Object.values(import.meta.glob<{ install: UserModule }>('./modules/*.ts', { eager: true }))
|
||||
.forEach(i => i.install?.(ctx))
|
||||
},
|
||||
)
|
||||
```
|
||||
|
||||
- [📖 Check more in the Documentation](https://uvr.esm.is).
|
||||
|
||||
## License
|
||||
|
||||
[MIT](http://opensource.org/licenses/MIT)
|
||||
50
Frontend-Learner/node_modules/unplugin-vue-router/client.d.ts
generated
vendored
Normal file
50
Frontend-Learner/node_modules/unplugin-vue-router/client.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
declare module 'vue-router/auto-routes' {
|
||||
import type { RouteRecordRaw, Router } from 'vue-router'
|
||||
|
||||
/**
|
||||
* Array of routes generated by unplugin-vue-router
|
||||
*/
|
||||
export const routes: readonly RouteRecordRaw[]
|
||||
|
||||
/**
|
||||
* Setups hot module replacement for routes.
|
||||
*
|
||||
* @param router - The router instance
|
||||
* @param hotUpdateCallback - Callback to be called after replacing the routes and before the navigation
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import { createRouter, createWebHistory } from 'vue-router'
|
||||
* import { routes, handleHotUpdate } from 'vue-router/auto-routes'
|
||||
* const router = createRouter({
|
||||
* history: createWebHistory(),
|
||||
* routes,
|
||||
* })
|
||||
* if (import.meta.hot) {
|
||||
* handleHotUpdate(router)
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export function handleHotUpdate(
|
||||
router: Router,
|
||||
hotUpdateCallback?: (newRoutes: RouteRecordRaw[]) => void
|
||||
): void
|
||||
}
|
||||
|
||||
declare module 'vue-router' {
|
||||
import type { RouteNamedMap } from 'vue-router/auto-routes'
|
||||
import type { ParamParserCustom } from 'vue-router/auto-resolver'
|
||||
|
||||
export interface TypesConfig {
|
||||
RouteNamedMap: RouteNamedMap
|
||||
ParamParsers: ParamParserCustom
|
||||
}
|
||||
}
|
||||
|
||||
// Make the macros globally available
|
||||
declare global {
|
||||
const definePage: (typeof import('unplugin-vue-router/runtime'))['definePage']
|
||||
}
|
||||
|
||||
export {}
|
||||
185
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/basic.cjs
generated
vendored
Normal file
185
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/basic.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
const require_createDataLoader = require('./createDataLoader-CBwrbo71.cjs');
|
||||
let vue_router = require("vue-router");
|
||||
let unplugin_vue_router_data_loaders = require("unplugin-vue-router/data-loaders");
|
||||
let vue = require("vue");
|
||||
require("scule");
|
||||
|
||||
//#region src/core/utils.ts
|
||||
function warn(msg, type = "warn") {
|
||||
console[type](`⚠️ [unplugin-vue-router]: ${msg}`);
|
||||
}
|
||||
/**
|
||||
* Type safe alternative to Array.isArray
|
||||
* https://github.com/microsoft/TypeScript/pull/48228
|
||||
*/
|
||||
const isArray = Array.isArray;
|
||||
|
||||
//#endregion
|
||||
//#region src/data-loaders/defineLoader.ts
|
||||
function defineBasicLoader(nameOrLoader, _loaderOrOptions, opts) {
|
||||
const loader = typeof nameOrLoader === "function" ? nameOrLoader : _loaderOrOptions;
|
||||
opts = typeof _loaderOrOptions === "object" ? _loaderOrOptions : opts;
|
||||
const options = {
|
||||
...DEFAULT_DEFINE_LOADER_OPTIONS,
|
||||
...opts,
|
||||
commit: opts?.commit || DEFAULT_DEFINE_LOADER_OPTIONS.commit
|
||||
};
|
||||
function load(to, router, from, parent) {
|
||||
const entries = router[unplugin_vue_router_data_loaders.LOADER_ENTRIES_KEY];
|
||||
const isSSR = router[unplugin_vue_router_data_loaders.IS_SSR_KEY];
|
||||
if (!entries.has(loader)) entries.set(loader, {
|
||||
data: (0, vue.shallowRef)(),
|
||||
isLoading: (0, vue.shallowRef)(false),
|
||||
error: (0, vue.shallowRef)(null),
|
||||
to,
|
||||
options,
|
||||
children: /* @__PURE__ */ new Set(),
|
||||
resetPending() {
|
||||
this.pendingLoad = null;
|
||||
this.pendingTo = null;
|
||||
},
|
||||
pendingLoad: null,
|
||||
pendingTo: null,
|
||||
staged: unplugin_vue_router_data_loaders.STAGED_NO_VALUE,
|
||||
stagedError: null,
|
||||
stagedNavigationResult: null,
|
||||
commit
|
||||
});
|
||||
const entry = entries.get(loader);
|
||||
if (entry.pendingTo === to && entry.pendingLoad) return entry.pendingLoad;
|
||||
const { error, isLoading, data } = entry;
|
||||
const initialRootData = router[INITIAL_DATA_KEY];
|
||||
const key = options.key || "";
|
||||
let initialData = unplugin_vue_router_data_loaders.STAGED_NO_VALUE;
|
||||
if (initialRootData && key in initialRootData) {
|
||||
initialData = initialRootData[key];
|
||||
delete initialRootData[key];
|
||||
}
|
||||
if (initialData !== unplugin_vue_router_data_loaders.STAGED_NO_VALUE) {
|
||||
data.value = initialData;
|
||||
return entry.pendingLoad = Promise.resolve();
|
||||
}
|
||||
entry.pendingTo = to;
|
||||
isLoading.value = true;
|
||||
const currentContext = (0, unplugin_vue_router_data_loaders.getCurrentContext)();
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
if (parent !== currentContext[0]) console.warn(`❌👶 "${options.key}" has a different parent than the current context. This shouldn't be happening. Please report a bug with a reproduction to https://github.com/posva/unplugin-vue-router/`);
|
||||
}
|
||||
(0, unplugin_vue_router_data_loaders.setCurrentContext)([
|
||||
entry,
|
||||
router,
|
||||
to
|
||||
]);
|
||||
entry.staged = unplugin_vue_router_data_loaders.STAGED_NO_VALUE;
|
||||
entry.stagedError = error.value;
|
||||
entry.stagedNavigationResult = null;
|
||||
const currentLoad = Promise.resolve(loader(to, { signal: to.meta[unplugin_vue_router_data_loaders.ABORT_CONTROLLER_KEY]?.signal })).then((d) => {
|
||||
if (entry.pendingLoad === currentLoad) if (d instanceof unplugin_vue_router_data_loaders.NavigationResult) {
|
||||
to.meta[unplugin_vue_router_data_loaders.NAVIGATION_RESULTS_KEY].push(d);
|
||||
entry.stagedNavigationResult = d;
|
||||
if (process.env.NODE_ENV !== "production") warnNonExposedLoader({
|
||||
to,
|
||||
options,
|
||||
useDataLoader
|
||||
});
|
||||
} else {
|
||||
entry.staged = d;
|
||||
entry.stagedError = null;
|
||||
}
|
||||
}).catch((error$1) => {
|
||||
if (entry.pendingLoad === currentLoad) {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
if (error$1 instanceof unplugin_vue_router_data_loaders.NavigationResult) warnNonExposedLoader({
|
||||
to,
|
||||
options,
|
||||
useDataLoader
|
||||
});
|
||||
}
|
||||
entry.stagedError = error$1;
|
||||
if (!require_createDataLoader.toLazyValue(options.lazy, to, from) || isSSR) throw error$1;
|
||||
}
|
||||
}).finally(() => {
|
||||
(0, unplugin_vue_router_data_loaders.setCurrentContext)(currentContext);
|
||||
if (entry.pendingLoad === currentLoad) {
|
||||
isLoading.value = false;
|
||||
if (options.commit === "immediate" || !router[unplugin_vue_router_data_loaders.PENDING_LOCATION_KEY]) entry.commit(to);
|
||||
}
|
||||
});
|
||||
(0, unplugin_vue_router_data_loaders.setCurrentContext)(currentContext);
|
||||
entry.pendingLoad = currentLoad;
|
||||
return currentLoad;
|
||||
}
|
||||
function commit(to) {
|
||||
if (this.pendingTo === to) {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
if (this.staged === unplugin_vue_router_data_loaders.STAGED_NO_VALUE && this.stagedError === null && this.stagedNavigationResult === null) console.warn(`Loader "${options.key}"'s "commit()" was called but there is no staged data.`);
|
||||
}
|
||||
if (this.staged !== unplugin_vue_router_data_loaders.STAGED_NO_VALUE) this.data.value = this.staged;
|
||||
this.error.value = this.stagedError;
|
||||
this.staged = unplugin_vue_router_data_loaders.STAGED_NO_VALUE;
|
||||
this.stagedError = this.error.value;
|
||||
this.pendingTo = null;
|
||||
this.to = to;
|
||||
for (const childEntry of this.children) childEntry.commit(to);
|
||||
}
|
||||
}
|
||||
const useDataLoader = () => {
|
||||
const currentContext = (0, unplugin_vue_router_data_loaders.getCurrentContext)();
|
||||
const [parentEntry, _router, _route] = currentContext;
|
||||
const router = _router || (0, vue_router.useRouter)();
|
||||
const route = _route || (0, vue_router.useRoute)();
|
||||
const entries = router[unplugin_vue_router_data_loaders.LOADER_ENTRIES_KEY];
|
||||
let entry = entries.get(loader);
|
||||
if (!entry || parentEntry && entry.pendingTo !== route || !entry.pendingLoad) router[unplugin_vue_router_data_loaders.APP_KEY].runWithContext(() => load(route, router, void 0, parentEntry));
|
||||
entry = entries.get(loader);
|
||||
if (parentEntry) {
|
||||
if (parentEntry === entry) console.warn(`👶❌ "${options.key}" has itself as parent. This shouldn't be happening. Please report a bug with a reproduction to https://github.com/posva/unplugin-vue-router/`);
|
||||
parentEntry.children.add(entry);
|
||||
}
|
||||
const { data, error, isLoading } = entry;
|
||||
const useDataLoaderResult = {
|
||||
data,
|
||||
error,
|
||||
isLoading,
|
||||
reload: (to = router.currentRoute.value) => router[unplugin_vue_router_data_loaders.APP_KEY].runWithContext(() => load(to, router)).then(() => entry.commit(to))
|
||||
};
|
||||
const promise = entry.pendingLoad.then(() => {
|
||||
return entry.staged === unplugin_vue_router_data_loaders.STAGED_NO_VALUE ? entry.stagedNavigationResult ? Promise.reject(entry.stagedNavigationResult) : data.value : entry.staged;
|
||||
}).catch((e) => parentEntry ? Promise.reject(e) : null);
|
||||
(0, unplugin_vue_router_data_loaders.setCurrentContext)(currentContext);
|
||||
return Object.assign(promise, useDataLoaderResult);
|
||||
};
|
||||
useDataLoader[unplugin_vue_router_data_loaders.IS_USE_DATA_LOADER_KEY] = true;
|
||||
useDataLoader._ = {
|
||||
load,
|
||||
options,
|
||||
getEntry(router) {
|
||||
return router[unplugin_vue_router_data_loaders.LOADER_ENTRIES_KEY].get(loader);
|
||||
}
|
||||
};
|
||||
return useDataLoader;
|
||||
}
|
||||
/**
|
||||
* Dev only warning for loaders that return/throw NavigationResult but are not exposed
|
||||
*
|
||||
* @param to - target location
|
||||
* @param options - options used to define the loader
|
||||
* @param useDataLoader - the data loader composable
|
||||
*/
|
||||
function warnNonExposedLoader({ to, options, useDataLoader }) {
|
||||
const loaders = to.meta[unplugin_vue_router_data_loaders.LOADER_SET_KEY];
|
||||
if (loaders && !loaders.has(useDataLoader)) warn("A loader returned a NavigationResult but is not registered on the route. Did you forget to \"export\" it from the page component?" + (options.key ? ` (loader key: "${options.key}")` : ""));
|
||||
}
|
||||
const DEFAULT_DEFINE_LOADER_OPTIONS = {
|
||||
lazy: false,
|
||||
server: true,
|
||||
commit: "after-load"
|
||||
};
|
||||
/**
|
||||
* Initial data generated on server and consumed on client.
|
||||
* @internal
|
||||
*/
|
||||
const INITIAL_DATA_KEY = Symbol();
|
||||
|
||||
//#endregion
|
||||
exports.defineBasicLoader = defineBasicLoader;
|
||||
79
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/basic.d.cts
generated
vendored
Normal file
79
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/basic.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
import { d as ErrorDefault$1, i as DefineDataLoaderOptionsBase_DefinedData } from "./createDataLoader-DgP0poyl.cjs";
|
||||
import { RouteLocationNormalizedLoaded, RouteMap } from "vue-router";
|
||||
import { DataLoaderContextBase, DataLoaderEntryBase, DefineDataLoaderOptionsBase_LaxData, DefineLoaderFn, UseDataLoader } from "unplugin-vue-router/data-loaders";
|
||||
|
||||
//#region src/data-loaders/defineLoader.d.ts
|
||||
|
||||
/**
|
||||
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version `data` is always defined.
|
||||
*
|
||||
* @param name - name of the route
|
||||
* @param loader - function that returns a promise with the data
|
||||
* @param options - options to configure the data loader
|
||||
*/
|
||||
declare function defineBasicLoader<Name extends keyof RouteMap, Data>(name: Name, loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded<Name>>, options?: DefineDataLoaderOptions_DefinedData): UseDataLoaderBasic_DefinedData<Data>;
|
||||
/**
|
||||
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version, `data` can be `undefined`.
|
||||
*
|
||||
* @param name - name of the route
|
||||
* @param loader - function that returns a promise with the data
|
||||
* @param options - options to configure the data loader
|
||||
*/
|
||||
declare function defineBasicLoader<Name extends keyof RouteMap, Data>(name: Name, loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded<Name>>, options: DefineDataLoaderOptions_LaxData): UseDataLoaderBasic_LaxData<Data>;
|
||||
/**
|
||||
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version `data` is always defined.
|
||||
*
|
||||
* @param loader - function that returns a promise with the data
|
||||
* @param options - options to configure the data loader
|
||||
*/
|
||||
declare function defineBasicLoader<Data>(loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded>, options?: DefineDataLoaderOptions_DefinedData): UseDataLoaderBasic_DefinedData<Data>;
|
||||
/**
|
||||
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version, `data` can be `undefined`.
|
||||
*
|
||||
* @param loader - function that returns a promise with the data
|
||||
* @param options - options to configure the data loader
|
||||
*/
|
||||
declare function defineBasicLoader<Data>(loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded>, options: DefineDataLoaderOptions_LaxData): UseDataLoaderBasic_LaxData<Data>;
|
||||
interface DefineDataLoaderOptions_LaxData extends DefineDataLoaderOptionsBase_LaxData {
|
||||
/**
|
||||
* Key to use for SSR state. This will be used to read the initial data from `initialData`'s object.
|
||||
*/
|
||||
key?: string;
|
||||
}
|
||||
interface DefineDataLoaderOptions_DefinedData extends DefineDataLoaderOptionsBase_DefinedData {
|
||||
key?: string;
|
||||
}
|
||||
/**
|
||||
* @deprecated use {@link DefineDataLoaderOptions_LaxData} instead
|
||||
*/
|
||||
type DefineDataLoaderOptions = DefineDataLoaderOptions_LaxData;
|
||||
interface DataLoaderContext extends DataLoaderContextBase {}
|
||||
/**
|
||||
* Symbol used to store the data in the router so it can be retrieved after the initial navigation.
|
||||
* @internal
|
||||
*/
|
||||
declare const SERVER_INITIAL_DATA_KEY: unique symbol;
|
||||
/**
|
||||
* Initial data generated on server and consumed on client.
|
||||
* @internal
|
||||
*/
|
||||
declare const INITIAL_DATA_KEY: unique symbol;
|
||||
declare module 'vue-router' {
|
||||
interface Router {
|
||||
/**
|
||||
* Gives access to the initial state during rendering. Should be set to `false` once it's consumed.
|
||||
* @internal
|
||||
*/
|
||||
[SERVER_INITIAL_DATA_KEY]?: Record<string, unknown> | false;
|
||||
[INITIAL_DATA_KEY]?: Record<string, unknown> | false;
|
||||
}
|
||||
}
|
||||
interface UseDataLoaderBasic_LaxData<Data> extends UseDataLoader<Data | undefined, ErrorDefault$1> {}
|
||||
/**
|
||||
* @deprecated use {@link UseDataLoaderBasic_LaxData} instead
|
||||
*/
|
||||
type UseDataLoaderBasic<Data> = UseDataLoaderBasic_LaxData<Data>;
|
||||
interface UseDataLoaderBasic_DefinedData<Data> extends UseDataLoader<Data, ErrorDefault$1> {}
|
||||
interface DataLoaderBasicEntry<TData, TError = unknown, TDataInitial extends TData | undefined = TData | undefined> extends DataLoaderEntryBase<TData, TError, TDataInitial> {}
|
||||
//#endregion
|
||||
export { type DataLoaderBasicEntry, type DataLoaderContext, type DefineDataLoaderOptions, type DefineDataLoaderOptions_DefinedData, type DefineDataLoaderOptions_LaxData, type UseDataLoaderBasic, type UseDataLoaderBasic_DefinedData, type UseDataLoaderBasic_LaxData, defineBasicLoader };
|
||||
79
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/basic.d.mts
generated
vendored
Normal file
79
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/basic.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
import { d as ErrorDefault$1, i as DefineDataLoaderOptionsBase_DefinedData } from "./createDataLoader-C8o8GrdD.mjs";
|
||||
import { RouteLocationNormalizedLoaded, RouteMap } from "vue-router";
|
||||
import { DataLoaderContextBase, DataLoaderEntryBase, DefineDataLoaderOptionsBase_LaxData, DefineLoaderFn, UseDataLoader } from "unplugin-vue-router/data-loaders";
|
||||
|
||||
//#region src/data-loaders/defineLoader.d.ts
|
||||
|
||||
/**
|
||||
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version `data` is always defined.
|
||||
*
|
||||
* @param name - name of the route
|
||||
* @param loader - function that returns a promise with the data
|
||||
* @param options - options to configure the data loader
|
||||
*/
|
||||
declare function defineBasicLoader<Name extends keyof RouteMap, Data>(name: Name, loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded<Name>>, options?: DefineDataLoaderOptions_DefinedData): UseDataLoaderBasic_DefinedData<Data>;
|
||||
/**
|
||||
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version, `data` can be `undefined`.
|
||||
*
|
||||
* @param name - name of the route
|
||||
* @param loader - function that returns a promise with the data
|
||||
* @param options - options to configure the data loader
|
||||
*/
|
||||
declare function defineBasicLoader<Name extends keyof RouteMap, Data>(name: Name, loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded<Name>>, options: DefineDataLoaderOptions_LaxData): UseDataLoaderBasic_LaxData<Data>;
|
||||
/**
|
||||
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version `data` is always defined.
|
||||
*
|
||||
* @param loader - function that returns a promise with the data
|
||||
* @param options - options to configure the data loader
|
||||
*/
|
||||
declare function defineBasicLoader<Data>(loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded>, options?: DefineDataLoaderOptions_DefinedData): UseDataLoaderBasic_DefinedData<Data>;
|
||||
/**
|
||||
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version, `data` can be `undefined`.
|
||||
*
|
||||
* @param loader - function that returns a promise with the data
|
||||
* @param options - options to configure the data loader
|
||||
*/
|
||||
declare function defineBasicLoader<Data>(loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded>, options: DefineDataLoaderOptions_LaxData): UseDataLoaderBasic_LaxData<Data>;
|
||||
interface DefineDataLoaderOptions_LaxData extends DefineDataLoaderOptionsBase_LaxData {
|
||||
/**
|
||||
* Key to use for SSR state. This will be used to read the initial data from `initialData`'s object.
|
||||
*/
|
||||
key?: string;
|
||||
}
|
||||
interface DefineDataLoaderOptions_DefinedData extends DefineDataLoaderOptionsBase_DefinedData {
|
||||
key?: string;
|
||||
}
|
||||
/**
|
||||
* @deprecated use {@link DefineDataLoaderOptions_LaxData} instead
|
||||
*/
|
||||
type DefineDataLoaderOptions = DefineDataLoaderOptions_LaxData;
|
||||
interface DataLoaderContext extends DataLoaderContextBase {}
|
||||
/**
|
||||
* Symbol used to store the data in the router so it can be retrieved after the initial navigation.
|
||||
* @internal
|
||||
*/
|
||||
declare const SERVER_INITIAL_DATA_KEY: unique symbol;
|
||||
/**
|
||||
* Initial data generated on server and consumed on client.
|
||||
* @internal
|
||||
*/
|
||||
declare const INITIAL_DATA_KEY: unique symbol;
|
||||
declare module 'vue-router' {
|
||||
interface Router {
|
||||
/**
|
||||
* Gives access to the initial state during rendering. Should be set to `false` once it's consumed.
|
||||
* @internal
|
||||
*/
|
||||
[SERVER_INITIAL_DATA_KEY]?: Record<string, unknown> | false;
|
||||
[INITIAL_DATA_KEY]?: Record<string, unknown> | false;
|
||||
}
|
||||
}
|
||||
interface UseDataLoaderBasic_LaxData<Data> extends UseDataLoader<Data | undefined, ErrorDefault$1> {}
|
||||
/**
|
||||
* @deprecated use {@link UseDataLoaderBasic_LaxData} instead
|
||||
*/
|
||||
type UseDataLoaderBasic<Data> = UseDataLoaderBasic_LaxData<Data>;
|
||||
interface UseDataLoaderBasic_DefinedData<Data> extends UseDataLoader<Data, ErrorDefault$1> {}
|
||||
interface DataLoaderBasicEntry<TData, TError = unknown, TDataInitial extends TData | undefined = TData | undefined> extends DataLoaderEntryBase<TData, TError, TDataInitial> {}
|
||||
//#endregion
|
||||
export { type DataLoaderBasicEntry, type DataLoaderContext, type DefineDataLoaderOptions, type DefineDataLoaderOptions_DefinedData, type DefineDataLoaderOptions_LaxData, type UseDataLoaderBasic, type UseDataLoaderBasic_DefinedData, type UseDataLoaderBasic_LaxData, defineBasicLoader };
|
||||
185
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/basic.mjs
generated
vendored
Normal file
185
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/basic.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
import { t as toLazyValue } from "./createDataLoader-BK9Gdnky.mjs";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { ABORT_CONTROLLER_KEY, APP_KEY, IS_SSR_KEY, IS_USE_DATA_LOADER_KEY, LOADER_ENTRIES_KEY, LOADER_SET_KEY, NAVIGATION_RESULTS_KEY, NavigationResult, PENDING_LOCATION_KEY, STAGED_NO_VALUE, getCurrentContext, setCurrentContext } from "unplugin-vue-router/data-loaders";
|
||||
import { shallowRef } from "vue";
|
||||
import "scule";
|
||||
|
||||
//#region src/core/utils.ts
|
||||
function warn(msg, type = "warn") {
|
||||
console[type](`⚠️ [unplugin-vue-router]: ${msg}`);
|
||||
}
|
||||
/**
|
||||
* Type safe alternative to Array.isArray
|
||||
* https://github.com/microsoft/TypeScript/pull/48228
|
||||
*/
|
||||
const isArray = Array.isArray;
|
||||
|
||||
//#endregion
|
||||
//#region src/data-loaders/defineLoader.ts
|
||||
function defineBasicLoader(nameOrLoader, _loaderOrOptions, opts) {
|
||||
const loader = typeof nameOrLoader === "function" ? nameOrLoader : _loaderOrOptions;
|
||||
opts = typeof _loaderOrOptions === "object" ? _loaderOrOptions : opts;
|
||||
const options = {
|
||||
...DEFAULT_DEFINE_LOADER_OPTIONS,
|
||||
...opts,
|
||||
commit: opts?.commit || DEFAULT_DEFINE_LOADER_OPTIONS.commit
|
||||
};
|
||||
function load(to, router, from, parent) {
|
||||
const entries = router[LOADER_ENTRIES_KEY];
|
||||
const isSSR = router[IS_SSR_KEY];
|
||||
if (!entries.has(loader)) entries.set(loader, {
|
||||
data: shallowRef(),
|
||||
isLoading: shallowRef(false),
|
||||
error: shallowRef(null),
|
||||
to,
|
||||
options,
|
||||
children: /* @__PURE__ */ new Set(),
|
||||
resetPending() {
|
||||
this.pendingLoad = null;
|
||||
this.pendingTo = null;
|
||||
},
|
||||
pendingLoad: null,
|
||||
pendingTo: null,
|
||||
staged: STAGED_NO_VALUE,
|
||||
stagedError: null,
|
||||
stagedNavigationResult: null,
|
||||
commit
|
||||
});
|
||||
const entry = entries.get(loader);
|
||||
if (entry.pendingTo === to && entry.pendingLoad) return entry.pendingLoad;
|
||||
const { error, isLoading, data } = entry;
|
||||
const initialRootData = router[INITIAL_DATA_KEY];
|
||||
const key = options.key || "";
|
||||
let initialData = STAGED_NO_VALUE;
|
||||
if (initialRootData && key in initialRootData) {
|
||||
initialData = initialRootData[key];
|
||||
delete initialRootData[key];
|
||||
}
|
||||
if (initialData !== STAGED_NO_VALUE) {
|
||||
data.value = initialData;
|
||||
return entry.pendingLoad = Promise.resolve();
|
||||
}
|
||||
entry.pendingTo = to;
|
||||
isLoading.value = true;
|
||||
const currentContext = getCurrentContext();
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
if (parent !== currentContext[0]) console.warn(`❌👶 "${options.key}" has a different parent than the current context. This shouldn't be happening. Please report a bug with a reproduction to https://github.com/posva/unplugin-vue-router/`);
|
||||
}
|
||||
setCurrentContext([
|
||||
entry,
|
||||
router,
|
||||
to
|
||||
]);
|
||||
entry.staged = STAGED_NO_VALUE;
|
||||
entry.stagedError = error.value;
|
||||
entry.stagedNavigationResult = null;
|
||||
const currentLoad = Promise.resolve(loader(to, { signal: to.meta[ABORT_CONTROLLER_KEY]?.signal })).then((d) => {
|
||||
if (entry.pendingLoad === currentLoad) if (d instanceof NavigationResult) {
|
||||
to.meta[NAVIGATION_RESULTS_KEY].push(d);
|
||||
entry.stagedNavigationResult = d;
|
||||
if (process.env.NODE_ENV !== "production") warnNonExposedLoader({
|
||||
to,
|
||||
options,
|
||||
useDataLoader
|
||||
});
|
||||
} else {
|
||||
entry.staged = d;
|
||||
entry.stagedError = null;
|
||||
}
|
||||
}).catch((error$1) => {
|
||||
if (entry.pendingLoad === currentLoad) {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
if (error$1 instanceof NavigationResult) warnNonExposedLoader({
|
||||
to,
|
||||
options,
|
||||
useDataLoader
|
||||
});
|
||||
}
|
||||
entry.stagedError = error$1;
|
||||
if (!toLazyValue(options.lazy, to, from) || isSSR) throw error$1;
|
||||
}
|
||||
}).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) {
|
||||
if (this.pendingTo === to) {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
if (this.staged === STAGED_NO_VALUE && this.stagedError === null && this.stagedNavigationResult === null) console.warn(`Loader "${options.key}"'s "commit()" was called but there is no staged data.`);
|
||||
}
|
||||
if (this.staged !== STAGED_NO_VALUE) this.data.value = this.staged;
|
||||
this.error.value = this.stagedError;
|
||||
this.staged = STAGED_NO_VALUE;
|
||||
this.stagedError = this.error.value;
|
||||
this.pendingTo = null;
|
||||
this.to = to;
|
||||
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 entries = router[LOADER_ENTRIES_KEY];
|
||||
let entry = entries.get(loader);
|
||||
if (!entry || parentEntry && entry.pendingTo !== route || !entry.pendingLoad) router[APP_KEY].runWithContext(() => load(route, router, void 0, parentEntry));
|
||||
entry = entries.get(loader);
|
||||
if (parentEntry) {
|
||||
if (parentEntry === entry) console.warn(`👶❌ "${options.key}" has itself as parent. This shouldn't be happening. Please report a bug with a reproduction to https://github.com/posva/unplugin-vue-router/`);
|
||||
parentEntry.children.add(entry);
|
||||
}
|
||||
const { data, error, isLoading } = entry;
|
||||
const useDataLoaderResult = {
|
||||
data,
|
||||
error,
|
||||
isLoading,
|
||||
reload: (to = router.currentRoute.value) => router[APP_KEY].runWithContext(() => load(to, router)).then(() => entry.commit(to))
|
||||
};
|
||||
const promise = entry.pendingLoad.then(() => {
|
||||
return entry.staged === STAGED_NO_VALUE ? entry.stagedNavigationResult ? Promise.reject(entry.stagedNavigationResult) : data.value : entry.staged;
|
||||
}).catch((e) => parentEntry ? Promise.reject(e) : null);
|
||||
setCurrentContext(currentContext);
|
||||
return Object.assign(promise, useDataLoaderResult);
|
||||
};
|
||||
useDataLoader[IS_USE_DATA_LOADER_KEY] = true;
|
||||
useDataLoader._ = {
|
||||
load,
|
||||
options,
|
||||
getEntry(router) {
|
||||
return router[LOADER_ENTRIES_KEY].get(loader);
|
||||
}
|
||||
};
|
||||
return useDataLoader;
|
||||
}
|
||||
/**
|
||||
* Dev only warning for loaders that return/throw NavigationResult but are not exposed
|
||||
*
|
||||
* @param to - target location
|
||||
* @param options - options used to define the loader
|
||||
* @param useDataLoader - the data loader composable
|
||||
*/
|
||||
function warnNonExposedLoader({ to, options, useDataLoader }) {
|
||||
const loaders = to.meta[LOADER_SET_KEY];
|
||||
if (loaders && !loaders.has(useDataLoader)) warn("A loader returned a NavigationResult but is not registered on the route. Did you forget to \"export\" it from the page component?" + (options.key ? ` (loader key: "${options.key}")` : ""));
|
||||
}
|
||||
const DEFAULT_DEFINE_LOADER_OPTIONS = {
|
||||
lazy: false,
|
||||
server: true,
|
||||
commit: "after-load"
|
||||
};
|
||||
/**
|
||||
* Initial data generated on server and consumed on client.
|
||||
* @internal
|
||||
*/
|
||||
const INITIAL_DATA_KEY = Symbol();
|
||||
|
||||
//#endregion
|
||||
export { defineBasicLoader };
|
||||
5
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/createDataLoader-BK9Gdnky.mjs
generated
vendored
Normal file
5
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/createDataLoader-BK9Gdnky.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
//#region src/data-loaders/createDataLoader.ts
|
||||
const toLazyValue = (lazy, to, from) => typeof lazy === "function" ? lazy(to, from) : lazy;
|
||||
|
||||
//#endregion
|
||||
export { toLazyValue as t };
|
||||
513
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/createDataLoader-C8o8GrdD.d.mts
generated
vendored
Normal file
513
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/createDataLoader-C8o8GrdD.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,513 @@
|
|||
import * as vue_router0 from "vue-router";
|
||||
import { LocationQuery, NavigationGuard, NavigationGuardReturn, RouteLocationNormalizedLoaded, Router } from "vue-router";
|
||||
import { App, EffectScope, ShallowRef } from "vue";
|
||||
|
||||
//#region src/data-loaders/symbols.d.ts
|
||||
/**
|
||||
* Retrieves the internal version of loaders.
|
||||
* @internal
|
||||
*/
|
||||
declare const LOADER_SET_KEY: unique symbol;
|
||||
/**
|
||||
* Retrieves the internal version of loader entries.
|
||||
* @internal
|
||||
*/
|
||||
declare const LOADER_ENTRIES_KEY: unique symbol;
|
||||
/**
|
||||
* Added to the loaders returned by `defineLoader()` to identify them.
|
||||
* Allows to extract exported useData() from a component.
|
||||
* @internal
|
||||
*/
|
||||
declare const IS_USE_DATA_LOADER_KEY: unique symbol;
|
||||
/**
|
||||
* Symbol used to save the pending location on the router.
|
||||
* @internal
|
||||
*/
|
||||
declare const PENDING_LOCATION_KEY: unique symbol;
|
||||
/**
|
||||
* Symbol used to know there is no value staged for the loader and that commit should be skipped.
|
||||
* @internal
|
||||
*/
|
||||
declare const STAGED_NO_VALUE: unique symbol;
|
||||
/**
|
||||
* Gives access to the current app and it's `runWithContext` method.
|
||||
* @internal
|
||||
*/
|
||||
declare const APP_KEY: unique symbol;
|
||||
/**
|
||||
* Gives access to an AbortController that aborts when the navigation is canceled.
|
||||
* @internal
|
||||
*/
|
||||
declare const ABORT_CONTROLLER_KEY: unique symbol;
|
||||
/**
|
||||
* Gives access to the navigation results when the navigation is aborted by the user within a data loader.
|
||||
* @internal
|
||||
*/
|
||||
declare const NAVIGATION_RESULTS_KEY: unique symbol;
|
||||
/**
|
||||
* Symbol used to save the initial data on the router.
|
||||
* @internal
|
||||
*/
|
||||
declare const IS_SSR_KEY: unique symbol;
|
||||
/**
|
||||
* Symbol used to get the effect scope used for data loaders.
|
||||
* @internal
|
||||
*/
|
||||
declare const DATA_LOADERS_EFFECT_SCOPE_KEY: unique symbol;
|
||||
//#endregion
|
||||
//#region src/utils/index.d.ts
|
||||
/**
|
||||
* Maybe a promise maybe not
|
||||
* @internal
|
||||
*/
|
||||
type _Awaitable<T> = T | PromiseLike<T>;
|
||||
//#endregion
|
||||
//#region src/data-loaders/navigation-guard.d.ts
|
||||
|
||||
/**
|
||||
* Options to initialize the data loader guard.
|
||||
*/
|
||||
interface SetupLoaderGuardOptions extends DataLoaderPluginOptions {
|
||||
/**
|
||||
* The Vue app instance. Used to access the `provide` and `inject` APIs.
|
||||
*/
|
||||
app: App<unknown>;
|
||||
/**
|
||||
* The effect scope to use for the data loaders.
|
||||
*/
|
||||
effect: EffectScope;
|
||||
}
|
||||
/**
|
||||
* Possible values to change the result of a navigation within a loader
|
||||
* @internal
|
||||
*/
|
||||
type _DataLoaderRedirectResult = Exclude<ReturnType<NavigationGuard>, Promise<unknown> | Function | true | void | undefined>;
|
||||
/**
|
||||
* Possible values to change the result of a navigation within a loader. Can be returned from a data loader and will
|
||||
* appear in `selectNavigationResult`. If thrown, it will immediately cancel the navigation. It can only contain values
|
||||
* that cancel the navigation.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* export const useUserData = defineLoader(async (to) => {
|
||||
* const user = await fetchUser(to.params.id)
|
||||
* if (!user) {
|
||||
* return new NavigationResult('/404')
|
||||
* }
|
||||
* return user
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
declare class NavigationResult {
|
||||
readonly value: _DataLoaderRedirectResult;
|
||||
constructor(value: _DataLoaderRedirectResult);
|
||||
}
|
||||
/**
|
||||
* 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)
|
||||
* ```
|
||||
*/
|
||||
declare function DataLoaderPlugin(app: App, options: DataLoaderPluginOptions): void;
|
||||
/**
|
||||
* Options passed to the DataLoaderPlugin.
|
||||
*/
|
||||
interface DataLoaderPluginOptions {
|
||||
/**
|
||||
* The router instance. Adds the guards to it
|
||||
*/
|
||||
router: Router;
|
||||
isSSR?: boolean;
|
||||
/**
|
||||
* Called if any data loader returns a `NavigationResult` with an array of them. Should decide what is the outcome of
|
||||
* the data fetching guard. Note this isn't called if no data loaders return a `NavigationResult` or if an error is thrown.
|
||||
* @defaultValue `(results) => results[0].value`
|
||||
*/
|
||||
selectNavigationResult?: (results: NavigationResult[]) => _Awaitable<Exclude<NavigationGuardReturn, Function | Promise<unknown>>>;
|
||||
/**
|
||||
* List of _expected_ errors that shouldn't abort the navigation (for non-lazy loaders). Provide a list of
|
||||
* constructors that can be checked with `instanceof` or a custom function that returns `true` for expected errors.
|
||||
*/
|
||||
errors?: Array<new (...args: any) => any> | ((reason?: unknown) => boolean);
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
declare function useIsDataLoading(): ShallowRef<boolean>;
|
||||
//#endregion
|
||||
//#region src/data-loaders/meta-extensions.d.ts
|
||||
/**
|
||||
* Map type for the entries used by data loaders.
|
||||
* @internal
|
||||
*/
|
||||
type _DefineLoaderEntryMap<DataLoaderEntry extends DataLoaderEntryBase<unknown> = DataLoaderEntryBase<unknown>> = WeakMap<object, DataLoaderEntry>;
|
||||
declare module 'vue-router' {
|
||||
interface Router {
|
||||
/**
|
||||
* The entries used by data loaders. Put on the router for convenience.
|
||||
* @internal
|
||||
*/
|
||||
[LOADER_ENTRIES_KEY]: _DefineLoaderEntryMap;
|
||||
/**
|
||||
* Pending navigation that is waiting for data loaders to resolve.
|
||||
* @internal
|
||||
*/
|
||||
[PENDING_LOCATION_KEY]: RouteLocationNormalizedLoaded | null;
|
||||
/**
|
||||
* The app instance that is used by the router.
|
||||
* @internal
|
||||
*/
|
||||
[APP_KEY]: App<unknown>;
|
||||
/**
|
||||
* Whether the router is running in server-side rendering mode.
|
||||
* @internal
|
||||
*/
|
||||
[IS_SSR_KEY]: boolean;
|
||||
/**
|
||||
* The effect scope used to run data loaders.
|
||||
* @internal
|
||||
*/
|
||||
[DATA_LOADERS_EFFECT_SCOPE_KEY]: EffectScope;
|
||||
}
|
||||
interface RouteMeta {
|
||||
/**
|
||||
* The data loaders for a route record. Add any data loader to this array to have it called when the route is
|
||||
* navigated to. Note this is only needed when **not** using lazy components (`() => import('./pages/Home.vue')`) or
|
||||
* when not explicitly exporting data loaders from page components.
|
||||
*/
|
||||
loaders?: UseDataLoader[];
|
||||
/**
|
||||
* Set of loaders for the current route. This is built once during navigation and is used to merge the loaders from
|
||||
* the lazy import in components or the `loaders` array in the route record.
|
||||
* @internal
|
||||
*/
|
||||
[LOADER_SET_KEY]?: Set<UseDataLoader>;
|
||||
/**
|
||||
* The signal that is aborted when the navigation is canceled or an error occurs.
|
||||
* @internal
|
||||
*/
|
||||
[ABORT_CONTROLLER_KEY]?: AbortController;
|
||||
/**
|
||||
* The navigation results when the navigation is canceled by the user within a data loader.
|
||||
* @internal
|
||||
*/
|
||||
[NAVIGATION_RESULTS_KEY]?: NavigationResult[];
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
//#region src/data-loaders/utils.d.ts
|
||||
/**
|
||||
* @internal: data loaders authoring only. Use `getCurrentContext` instead.
|
||||
*/
|
||||
declare let currentContext: readonly [entry: DataLoaderEntryBase, router: Router, route: RouteLocationNormalizedLoaded] | undefined | null;
|
||||
declare function getCurrentContext(): readonly [entry: DataLoaderEntryBase<unknown, unknown, unknown>, router: Router, route: vue_router0.RouteLocationNormalizedLoadedGeneric] | readonly [];
|
||||
/**
|
||||
* Sets the current context for data loaders. This allows for nested loaders to be aware of their parent context.
|
||||
* INTERNAL ONLY.
|
||||
*
|
||||
* @param context - the context to set
|
||||
* @internal
|
||||
*/
|
||||
declare function setCurrentContext(context?: typeof currentContext | readonly []): void;
|
||||
/**
|
||||
* Restore the current context after a promise is resolved.
|
||||
* @param promise - promise to wrap
|
||||
*/
|
||||
declare function withLoaderContext<P extends Promise<unknown>>(promise: P): P;
|
||||
/**
|
||||
* Object and promise of the object itself. Used when we can await some of the properties of an object to be loaded.
|
||||
* @internal
|
||||
*/
|
||||
type _PromiseMerged<PromiseType, RawType = PromiseType> = RawType & Promise<PromiseType>;
|
||||
declare const assign: {
|
||||
<T extends {}, U>(target: T, source: U): T & U;
|
||||
<T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V;
|
||||
<T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
|
||||
(target: object, ...sources: any[]): any;
|
||||
};
|
||||
/**
|
||||
* Track the reads of a route and its properties
|
||||
* @internal
|
||||
* @param route - route to track
|
||||
*/
|
||||
declare function trackRoute(route: RouteLocationNormalizedLoaded): readonly [{
|
||||
readonly hash: string;
|
||||
readonly params: vue_router0.RouteParamsGeneric;
|
||||
readonly query: LocationQuery;
|
||||
readonly matched: vue_router0.RouteLocationMatched[];
|
||||
readonly name: vue_router0.RouteRecordNameGeneric;
|
||||
readonly fullPath: string;
|
||||
readonly redirectedFrom: vue_router0.RouteLocation | undefined;
|
||||
readonly path: string;
|
||||
readonly meta: vue_router0.RouteMeta;
|
||||
}, Partial<vue_router0.RouteParamsGeneric>, Partial<LocationQuery>, {
|
||||
v: string | null;
|
||||
}];
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
declare function isSubsetOf(inner: Partial<LocationQuery>, outer: LocationQuery): boolean;
|
||||
//#endregion
|
||||
//#region src/data-loaders/types-config.d.ts
|
||||
/**
|
||||
* Allows you to extend the default types of the library.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // types-extension.d.ts
|
||||
* import 'unplugin-vue-router/data-loaders'
|
||||
* export {}
|
||||
* declare module 'unplugin-vue-router/data-loaders' {
|
||||
* interface TypesConfig {
|
||||
* Error: MyCustomError
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface TypesConfig {}
|
||||
/**
|
||||
* The default error type used.
|
||||
* @internal
|
||||
*/
|
||||
type ErrorDefault = TypesConfig extends Record<'Error', infer E> ? E : Error;
|
||||
//#endregion
|
||||
//#region src/data-loaders/createDataLoader.d.ts
|
||||
/**
|
||||
* Base type for a data loader entry. Each Data Loader has its own entry in the `loaderEntries` (accessible via `[LOADER_ENTRIES_KEY]`) map.
|
||||
*/
|
||||
interface DataLoaderEntryBase<TData = unknown, TError = unknown, TDataInitial extends TData | undefined = TData | undefined> {
|
||||
/**
|
||||
* Data stored in the entry.
|
||||
*/
|
||||
data: ShallowRef<TData | TDataInitial>;
|
||||
/**
|
||||
* Error if there was an error.
|
||||
*/
|
||||
error: ShallowRef<TError | null>;
|
||||
/**
|
||||
* Location the data was loaded for or `null` if the data is not loaded.
|
||||
*/
|
||||
to: RouteLocationNormalizedLoaded | null;
|
||||
/**
|
||||
* Whether there is an ongoing request.
|
||||
*/
|
||||
isLoading: ShallowRef<boolean>;
|
||||
options: DefineDataLoaderOptionsBase_LaxData;
|
||||
/**
|
||||
* Called by the navigation guard when the navigation is duplicated. Should be used to reset pendingTo and pendingLoad and any other property that should be reset.
|
||||
*/
|
||||
resetPending: () => void;
|
||||
/**
|
||||
* The latest pending load. Allows to verify if the load is still valid when it resolves.
|
||||
*/
|
||||
pendingLoad: Promise<void> | null;
|
||||
/**
|
||||
* The latest pending navigation's `to` route. Used to verify if the navigation is still valid when it resolves.
|
||||
*/
|
||||
pendingTo: RouteLocationNormalizedLoaded | null;
|
||||
/**
|
||||
* Data that was staged by a loader. This is used to avoid showing the old data while the new data is loading. Calling
|
||||
* the internal `commit()` function will replace the data with the staged data.
|
||||
*/
|
||||
staged: TData | typeof STAGED_NO_VALUE;
|
||||
/**
|
||||
* Error that was staged by a loader. This is used to avoid showing the old error while the new data is loading.
|
||||
* Calling the internal `commit()` function will replace the error with the staged error.
|
||||
*/
|
||||
stagedError: TError | null;
|
||||
/**
|
||||
* NavigationResult that was returned by a loader. Used to avoid treating it as data.
|
||||
*/
|
||||
stagedNavigationResult: NavigationResult | null;
|
||||
/**
|
||||
* Other data loaders that depend on this one. This is used to invalidate the data when a dependency is invalidated.
|
||||
*/
|
||||
children: Set<DataLoaderEntryBase>;
|
||||
/**
|
||||
* Commits the pending data to the entry. This is called by the navigation guard when all non-lazy loaders have
|
||||
* finished loading. It should be implemented by the loader. It **must be called** from the entry itself:
|
||||
* `entry.commit(to)`.
|
||||
*/
|
||||
commit(to: RouteLocationNormalizedLoaded): void;
|
||||
}
|
||||
/**
|
||||
* Common properties for the options of `defineLoader()`. Types are `unknown` to allow for more specific types in the
|
||||
* extended types while having documentation in one single place.
|
||||
* @internal
|
||||
*/
|
||||
interface _DefineDataLoaderOptionsBase_Common {
|
||||
/**
|
||||
* When the data should be committed to the entry. In the case of lazy loaders, the loader will try to commit the data
|
||||
* after all non-lazy loaders have finished loading, but it might not be able to if the lazy loader hasn't been
|
||||
* resolved yet.
|
||||
*
|
||||
* @see {@link DefineDataLoaderCommit}
|
||||
* @defaultValue `'after-load'`
|
||||
*/
|
||||
commit?: DefineDataLoaderCommit;
|
||||
/**
|
||||
* Whether the data should be lazy loaded without blocking the client side navigation or not. When set to true, the loader will no longer block the navigation and the returned composable can be called even
|
||||
* without having the data ready.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
*/
|
||||
lazy?: unknown;
|
||||
/**
|
||||
* Whether this loader should be awaited on the server side or not. Combined with the `lazy` option, this gives full
|
||||
* control over how to await for the data.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
server?: unknown;
|
||||
/**
|
||||
* List of _expected_ errors that shouldn't abort the navigation (for non-lazy loaders). Provide a list of
|
||||
* constructors that can be checked with `instanceof` or a custom function that returns `true` for expected errors. Can also be set to `true` to accept all globally defined errors. Defaults to `false` to abort on any error.
|
||||
* @default `false`
|
||||
*/
|
||||
errors?: unknown;
|
||||
}
|
||||
/**
|
||||
* Options for a data loader that returns a data that is possibly `undefined`. Available for data loaders
|
||||
* implementations so they can be used in `defineLoader()` overloads.
|
||||
*/
|
||||
interface DefineDataLoaderOptionsBase_LaxData extends _DefineDataLoaderOptionsBase_Common {
|
||||
lazy?: boolean | ((to: RouteLocationNormalizedLoaded, from?: RouteLocationNormalizedLoaded) => boolean);
|
||||
server?: boolean;
|
||||
errors?: boolean | Array<new (...args: any[]) => any> | ((reason?: unknown) => boolean);
|
||||
}
|
||||
/**
|
||||
* Options for a data loader making the data defined without it being possibly `undefined`. Available for data loaders
|
||||
* implementations so they can be used in `defineLoader()` overloads.
|
||||
*/
|
||||
interface DefineDataLoaderOptionsBase_DefinedData extends _DefineDataLoaderOptionsBase_Common {
|
||||
lazy?: false;
|
||||
server?: true;
|
||||
errors?: false;
|
||||
}
|
||||
declare const toLazyValue: (lazy: undefined | DefineDataLoaderOptionsBase_LaxData["lazy"], to: RouteLocationNormalizedLoaded, from?: RouteLocationNormalizedLoaded) => boolean | undefined;
|
||||
/**
|
||||
* When the data should be committed to the entry.
|
||||
* - `immediate`: the data is committed as soon as it is loaded.
|
||||
* - `after-load`: the data is committed after all non-lazy loaders have finished loading.
|
||||
*/
|
||||
type DefineDataLoaderCommit = 'immediate' | 'after-load';
|
||||
interface DataLoaderContextBase {
|
||||
/**
|
||||
* Signal associated with the current navigation. It is aborted when the navigation is canceled or an error occurs.
|
||||
*/
|
||||
signal: AbortSignal | undefined;
|
||||
}
|
||||
/**
|
||||
* Data Loader composable returned by `defineLoader()`.
|
||||
* @see {@link DefineDataLoader}
|
||||
*/
|
||||
interface UseDataLoader<Data = unknown, TError = unknown> {
|
||||
[IS_USE_DATA_LOADER_KEY]: true;
|
||||
/**
|
||||
* Data Loader composable returned by `defineLoader()`.
|
||||
*
|
||||
* @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>, UseDataLoaderResult<Exclude<Data, NavigationResult>, TError>>;
|
||||
/**
|
||||
* Internals of the data loader.
|
||||
* @internal
|
||||
*/
|
||||
_: UseDataLoaderInternals<Exclude<Data, NavigationResult | undefined>, TError>;
|
||||
}
|
||||
/**
|
||||
* Internal properties of a data loader composable. Used by the internal implementation of `defineLoader()`. **Should
|
||||
* not be used in application code.**
|
||||
*/
|
||||
interface UseDataLoaderInternals<Data = unknown, TError = unknown> {
|
||||
/**
|
||||
* Loads the data from the cache if possible, otherwise loads it from the loader and awaits it.
|
||||
*
|
||||
* @param to - route location to load the data for
|
||||
* @param router - router instance
|
||||
* @param from - route location we are coming from
|
||||
* @param parent - parent data loader entry
|
||||
*/
|
||||
load: (to: RouteLocationNormalizedLoaded, router: Router, from?: RouteLocationNormalizedLoaded, parent?: DataLoaderEntryBase) => Promise<void>;
|
||||
/**
|
||||
* Resolved options for the loader.
|
||||
*/
|
||||
options: DefineDataLoaderOptionsBase_LaxData;
|
||||
/**
|
||||
* Gets the entry associated with the router instance. Assumes the data loader has been loaded and that the entry
|
||||
* exists.
|
||||
*
|
||||
* @param router - router instance
|
||||
*/
|
||||
getEntry(router: Router): DataLoaderEntryBase<Data, TError>;
|
||||
}
|
||||
/**
|
||||
* Return value of a loader composable defined with `defineLoader()`.
|
||||
*/
|
||||
interface UseDataLoaderResult<TData = unknown, TError = ErrorDefault> {
|
||||
/**
|
||||
* Data returned by the loader. If the data loader is lazy, it will be undefined until the first load.
|
||||
*/
|
||||
data: ShallowRef<TData>;
|
||||
/**
|
||||
* Whether there is an ongoing request.
|
||||
*/
|
||||
isLoading: ShallowRef<boolean>;
|
||||
/**
|
||||
* Error if there was an error.
|
||||
*/
|
||||
error: ShallowRef<TError | null>;
|
||||
/**
|
||||
* Reload the data using the current route location. Returns a promise that resolves when the data is reloaded. This
|
||||
* method should not be called during a navigation as it can conflict with an ongoing load and lead to
|
||||
* inconsistencies.
|
||||
*/
|
||||
reload(): Promise<void>;
|
||||
/**
|
||||
* Reload the data using the route location passed as argument. Returns a promise that resolves when the data is reloaded.
|
||||
*
|
||||
* @param route - route location to load the data for
|
||||
*/
|
||||
reload(route: RouteLocationNormalizedLoaded): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Loader function that can be passed to `defineLoader()`.
|
||||
*/
|
||||
interface DefineLoaderFn<Data, Context extends DataLoaderContextBase = DataLoaderContextBase, Route = RouteLocationNormalizedLoaded> {
|
||||
(route: Route, context: Context): Promise<Data>;
|
||||
}
|
||||
/**
|
||||
* @deprecated Use `DefineDataLoaderOptionsBase_LaxData` instead.
|
||||
*/
|
||||
type DefineDataLoaderOptionsBase = DefineDataLoaderOptionsBase_LaxData;
|
||||
//#endregion
|
||||
export { DATA_LOADERS_EFFECT_SCOPE_KEY as A, DataLoaderPluginOptions as C, useIsDataLoading as D, _DataLoaderRedirectResult as E, NAVIGATION_RESULTS_KEY as F, PENDING_LOCATION_KEY as I, STAGED_NO_VALUE as L, IS_USE_DATA_LOADER_KEY as M, LOADER_ENTRIES_KEY as N, ABORT_CONTROLLER_KEY as O, LOADER_SET_KEY as P, DataLoaderPlugin as S, SetupLoaderGuardOptions as T, isSubsetOf as _, DefineDataLoaderOptionsBase_LaxData as a, withLoaderContext as b, UseDataLoaderInternals as c, ErrorDefault as d, TypesConfig as f, getCurrentContext as g, currentContext as h, DefineDataLoaderOptionsBase_DefinedData as i, IS_SSR_KEY as j, APP_KEY as k, UseDataLoaderResult as l, assign as m, DataLoaderEntryBase as n, DefineLoaderFn as o, _PromiseMerged as p, DefineDataLoaderOptionsBase as r, UseDataLoader as s, DataLoaderContextBase as t, toLazyValue as u, setCurrentContext as v, NavigationResult as w, _DefineLoaderEntryMap as x, trackRoute as y };
|
||||
11
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/createDataLoader-CBwrbo71.cjs
generated
vendored
Normal file
11
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/createDataLoader-CBwrbo71.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
//#region src/data-loaders/createDataLoader.ts
|
||||
const toLazyValue = (lazy, to, from) => typeof lazy === "function" ? lazy(to, from) : lazy;
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, 'toLazyValue', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return toLazyValue;
|
||||
}
|
||||
});
|
||||
513
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/createDataLoader-DgP0poyl.d.cts
generated
vendored
Normal file
513
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/createDataLoader-DgP0poyl.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,513 @@
|
|||
import * as vue_router0 from "vue-router";
|
||||
import { LocationQuery, NavigationGuard, NavigationGuardReturn, RouteLocationNormalizedLoaded, Router } from "vue-router";
|
||||
import { App, EffectScope, ShallowRef } from "vue";
|
||||
|
||||
//#region src/data-loaders/symbols.d.ts
|
||||
/**
|
||||
* Retrieves the internal version of loaders.
|
||||
* @internal
|
||||
*/
|
||||
declare const LOADER_SET_KEY: unique symbol;
|
||||
/**
|
||||
* Retrieves the internal version of loader entries.
|
||||
* @internal
|
||||
*/
|
||||
declare const LOADER_ENTRIES_KEY: unique symbol;
|
||||
/**
|
||||
* Added to the loaders returned by `defineLoader()` to identify them.
|
||||
* Allows to extract exported useData() from a component.
|
||||
* @internal
|
||||
*/
|
||||
declare const IS_USE_DATA_LOADER_KEY: unique symbol;
|
||||
/**
|
||||
* Symbol used to save the pending location on the router.
|
||||
* @internal
|
||||
*/
|
||||
declare const PENDING_LOCATION_KEY: unique symbol;
|
||||
/**
|
||||
* Symbol used to know there is no value staged for the loader and that commit should be skipped.
|
||||
* @internal
|
||||
*/
|
||||
declare const STAGED_NO_VALUE: unique symbol;
|
||||
/**
|
||||
* Gives access to the current app and it's `runWithContext` method.
|
||||
* @internal
|
||||
*/
|
||||
declare const APP_KEY: unique symbol;
|
||||
/**
|
||||
* Gives access to an AbortController that aborts when the navigation is canceled.
|
||||
* @internal
|
||||
*/
|
||||
declare const ABORT_CONTROLLER_KEY: unique symbol;
|
||||
/**
|
||||
* Gives access to the navigation results when the navigation is aborted by the user within a data loader.
|
||||
* @internal
|
||||
*/
|
||||
declare const NAVIGATION_RESULTS_KEY: unique symbol;
|
||||
/**
|
||||
* Symbol used to save the initial data on the router.
|
||||
* @internal
|
||||
*/
|
||||
declare const IS_SSR_KEY: unique symbol;
|
||||
/**
|
||||
* Symbol used to get the effect scope used for data loaders.
|
||||
* @internal
|
||||
*/
|
||||
declare const DATA_LOADERS_EFFECT_SCOPE_KEY: unique symbol;
|
||||
//#endregion
|
||||
//#region src/utils/index.d.ts
|
||||
/**
|
||||
* Maybe a promise maybe not
|
||||
* @internal
|
||||
*/
|
||||
type _Awaitable<T> = T | PromiseLike<T>;
|
||||
//#endregion
|
||||
//#region src/data-loaders/navigation-guard.d.ts
|
||||
|
||||
/**
|
||||
* Options to initialize the data loader guard.
|
||||
*/
|
||||
interface SetupLoaderGuardOptions extends DataLoaderPluginOptions {
|
||||
/**
|
||||
* The Vue app instance. Used to access the `provide` and `inject` APIs.
|
||||
*/
|
||||
app: App<unknown>;
|
||||
/**
|
||||
* The effect scope to use for the data loaders.
|
||||
*/
|
||||
effect: EffectScope;
|
||||
}
|
||||
/**
|
||||
* Possible values to change the result of a navigation within a loader
|
||||
* @internal
|
||||
*/
|
||||
type _DataLoaderRedirectResult = Exclude<ReturnType<NavigationGuard>, Promise<unknown> | Function | true | void | undefined>;
|
||||
/**
|
||||
* Possible values to change the result of a navigation within a loader. Can be returned from a data loader and will
|
||||
* appear in `selectNavigationResult`. If thrown, it will immediately cancel the navigation. It can only contain values
|
||||
* that cancel the navigation.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* export const useUserData = defineLoader(async (to) => {
|
||||
* const user = await fetchUser(to.params.id)
|
||||
* if (!user) {
|
||||
* return new NavigationResult('/404')
|
||||
* }
|
||||
* return user
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
declare class NavigationResult {
|
||||
readonly value: _DataLoaderRedirectResult;
|
||||
constructor(value: _DataLoaderRedirectResult);
|
||||
}
|
||||
/**
|
||||
* 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)
|
||||
* ```
|
||||
*/
|
||||
declare function DataLoaderPlugin(app: App, options: DataLoaderPluginOptions): void;
|
||||
/**
|
||||
* Options passed to the DataLoaderPlugin.
|
||||
*/
|
||||
interface DataLoaderPluginOptions {
|
||||
/**
|
||||
* The router instance. Adds the guards to it
|
||||
*/
|
||||
router: Router;
|
||||
isSSR?: boolean;
|
||||
/**
|
||||
* Called if any data loader returns a `NavigationResult` with an array of them. Should decide what is the outcome of
|
||||
* the data fetching guard. Note this isn't called if no data loaders return a `NavigationResult` or if an error is thrown.
|
||||
* @defaultValue `(results) => results[0].value`
|
||||
*/
|
||||
selectNavigationResult?: (results: NavigationResult[]) => _Awaitable<Exclude<NavigationGuardReturn, Function | Promise<unknown>>>;
|
||||
/**
|
||||
* List of _expected_ errors that shouldn't abort the navigation (for non-lazy loaders). Provide a list of
|
||||
* constructors that can be checked with `instanceof` or a custom function that returns `true` for expected errors.
|
||||
*/
|
||||
errors?: Array<new (...args: any) => any> | ((reason?: unknown) => boolean);
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
declare function useIsDataLoading(): ShallowRef<boolean>;
|
||||
//#endregion
|
||||
//#region src/data-loaders/meta-extensions.d.ts
|
||||
/**
|
||||
* Map type for the entries used by data loaders.
|
||||
* @internal
|
||||
*/
|
||||
type _DefineLoaderEntryMap<DataLoaderEntry extends DataLoaderEntryBase<unknown> = DataLoaderEntryBase<unknown>> = WeakMap<object, DataLoaderEntry>;
|
||||
declare module 'vue-router' {
|
||||
interface Router {
|
||||
/**
|
||||
* The entries used by data loaders. Put on the router for convenience.
|
||||
* @internal
|
||||
*/
|
||||
[LOADER_ENTRIES_KEY]: _DefineLoaderEntryMap;
|
||||
/**
|
||||
* Pending navigation that is waiting for data loaders to resolve.
|
||||
* @internal
|
||||
*/
|
||||
[PENDING_LOCATION_KEY]: RouteLocationNormalizedLoaded | null;
|
||||
/**
|
||||
* The app instance that is used by the router.
|
||||
* @internal
|
||||
*/
|
||||
[APP_KEY]: App<unknown>;
|
||||
/**
|
||||
* Whether the router is running in server-side rendering mode.
|
||||
* @internal
|
||||
*/
|
||||
[IS_SSR_KEY]: boolean;
|
||||
/**
|
||||
* The effect scope used to run data loaders.
|
||||
* @internal
|
||||
*/
|
||||
[DATA_LOADERS_EFFECT_SCOPE_KEY]: EffectScope;
|
||||
}
|
||||
interface RouteMeta {
|
||||
/**
|
||||
* The data loaders for a route record. Add any data loader to this array to have it called when the route is
|
||||
* navigated to. Note this is only needed when **not** using lazy components (`() => import('./pages/Home.vue')`) or
|
||||
* when not explicitly exporting data loaders from page components.
|
||||
*/
|
||||
loaders?: UseDataLoader[];
|
||||
/**
|
||||
* Set of loaders for the current route. This is built once during navigation and is used to merge the loaders from
|
||||
* the lazy import in components or the `loaders` array in the route record.
|
||||
* @internal
|
||||
*/
|
||||
[LOADER_SET_KEY]?: Set<UseDataLoader>;
|
||||
/**
|
||||
* The signal that is aborted when the navigation is canceled or an error occurs.
|
||||
* @internal
|
||||
*/
|
||||
[ABORT_CONTROLLER_KEY]?: AbortController;
|
||||
/**
|
||||
* The navigation results when the navigation is canceled by the user within a data loader.
|
||||
* @internal
|
||||
*/
|
||||
[NAVIGATION_RESULTS_KEY]?: NavigationResult[];
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
//#region src/data-loaders/utils.d.ts
|
||||
/**
|
||||
* @internal: data loaders authoring only. Use `getCurrentContext` instead.
|
||||
*/
|
||||
declare let currentContext: readonly [entry: DataLoaderEntryBase, router: Router, route: RouteLocationNormalizedLoaded] | undefined | null;
|
||||
declare function getCurrentContext(): readonly [entry: DataLoaderEntryBase<unknown, unknown, unknown>, router: Router, route: vue_router0.RouteLocationNormalizedLoadedGeneric] | readonly [];
|
||||
/**
|
||||
* Sets the current context for data loaders. This allows for nested loaders to be aware of their parent context.
|
||||
* INTERNAL ONLY.
|
||||
*
|
||||
* @param context - the context to set
|
||||
* @internal
|
||||
*/
|
||||
declare function setCurrentContext(context?: typeof currentContext | readonly []): void;
|
||||
/**
|
||||
* Restore the current context after a promise is resolved.
|
||||
* @param promise - promise to wrap
|
||||
*/
|
||||
declare function withLoaderContext<P extends Promise<unknown>>(promise: P): P;
|
||||
/**
|
||||
* Object and promise of the object itself. Used when we can await some of the properties of an object to be loaded.
|
||||
* @internal
|
||||
*/
|
||||
type _PromiseMerged<PromiseType, RawType = PromiseType> = RawType & Promise<PromiseType>;
|
||||
declare const assign: {
|
||||
<T extends {}, U>(target: T, source: U): T & U;
|
||||
<T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V;
|
||||
<T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
|
||||
(target: object, ...sources: any[]): any;
|
||||
};
|
||||
/**
|
||||
* Track the reads of a route and its properties
|
||||
* @internal
|
||||
* @param route - route to track
|
||||
*/
|
||||
declare function trackRoute(route: RouteLocationNormalizedLoaded): readonly [{
|
||||
readonly hash: string;
|
||||
readonly params: vue_router0.RouteParamsGeneric;
|
||||
readonly query: LocationQuery;
|
||||
readonly matched: vue_router0.RouteLocationMatched[];
|
||||
readonly name: vue_router0.RouteRecordNameGeneric;
|
||||
readonly fullPath: string;
|
||||
readonly redirectedFrom: vue_router0.RouteLocation | undefined;
|
||||
readonly path: string;
|
||||
readonly meta: vue_router0.RouteMeta;
|
||||
}, Partial<vue_router0.RouteParamsGeneric>, Partial<LocationQuery>, {
|
||||
v: string | null;
|
||||
}];
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
declare function isSubsetOf(inner: Partial<LocationQuery>, outer: LocationQuery): boolean;
|
||||
//#endregion
|
||||
//#region src/data-loaders/types-config.d.ts
|
||||
/**
|
||||
* Allows you to extend the default types of the library.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // types-extension.d.ts
|
||||
* import 'unplugin-vue-router/data-loaders'
|
||||
* export {}
|
||||
* declare module 'unplugin-vue-router/data-loaders' {
|
||||
* interface TypesConfig {
|
||||
* Error: MyCustomError
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface TypesConfig {}
|
||||
/**
|
||||
* The default error type used.
|
||||
* @internal
|
||||
*/
|
||||
type ErrorDefault = TypesConfig extends Record<'Error', infer E> ? E : Error;
|
||||
//#endregion
|
||||
//#region src/data-loaders/createDataLoader.d.ts
|
||||
/**
|
||||
* Base type for a data loader entry. Each Data Loader has its own entry in the `loaderEntries` (accessible via `[LOADER_ENTRIES_KEY]`) map.
|
||||
*/
|
||||
interface DataLoaderEntryBase<TData = unknown, TError = unknown, TDataInitial extends TData | undefined = TData | undefined> {
|
||||
/**
|
||||
* Data stored in the entry.
|
||||
*/
|
||||
data: ShallowRef<TData | TDataInitial>;
|
||||
/**
|
||||
* Error if there was an error.
|
||||
*/
|
||||
error: ShallowRef<TError | null>;
|
||||
/**
|
||||
* Location the data was loaded for or `null` if the data is not loaded.
|
||||
*/
|
||||
to: RouteLocationNormalizedLoaded | null;
|
||||
/**
|
||||
* Whether there is an ongoing request.
|
||||
*/
|
||||
isLoading: ShallowRef<boolean>;
|
||||
options: DefineDataLoaderOptionsBase_LaxData;
|
||||
/**
|
||||
* Called by the navigation guard when the navigation is duplicated. Should be used to reset pendingTo and pendingLoad and any other property that should be reset.
|
||||
*/
|
||||
resetPending: () => void;
|
||||
/**
|
||||
* The latest pending load. Allows to verify if the load is still valid when it resolves.
|
||||
*/
|
||||
pendingLoad: Promise<void> | null;
|
||||
/**
|
||||
* The latest pending navigation's `to` route. Used to verify if the navigation is still valid when it resolves.
|
||||
*/
|
||||
pendingTo: RouteLocationNormalizedLoaded | null;
|
||||
/**
|
||||
* Data that was staged by a loader. This is used to avoid showing the old data while the new data is loading. Calling
|
||||
* the internal `commit()` function will replace the data with the staged data.
|
||||
*/
|
||||
staged: TData | typeof STAGED_NO_VALUE;
|
||||
/**
|
||||
* Error that was staged by a loader. This is used to avoid showing the old error while the new data is loading.
|
||||
* Calling the internal `commit()` function will replace the error with the staged error.
|
||||
*/
|
||||
stagedError: TError | null;
|
||||
/**
|
||||
* NavigationResult that was returned by a loader. Used to avoid treating it as data.
|
||||
*/
|
||||
stagedNavigationResult: NavigationResult | null;
|
||||
/**
|
||||
* Other data loaders that depend on this one. This is used to invalidate the data when a dependency is invalidated.
|
||||
*/
|
||||
children: Set<DataLoaderEntryBase>;
|
||||
/**
|
||||
* Commits the pending data to the entry. This is called by the navigation guard when all non-lazy loaders have
|
||||
* finished loading. It should be implemented by the loader. It **must be called** from the entry itself:
|
||||
* `entry.commit(to)`.
|
||||
*/
|
||||
commit(to: RouteLocationNormalizedLoaded): void;
|
||||
}
|
||||
/**
|
||||
* Common properties for the options of `defineLoader()`. Types are `unknown` to allow for more specific types in the
|
||||
* extended types while having documentation in one single place.
|
||||
* @internal
|
||||
*/
|
||||
interface _DefineDataLoaderOptionsBase_Common {
|
||||
/**
|
||||
* When the data should be committed to the entry. In the case of lazy loaders, the loader will try to commit the data
|
||||
* after all non-lazy loaders have finished loading, but it might not be able to if the lazy loader hasn't been
|
||||
* resolved yet.
|
||||
*
|
||||
* @see {@link DefineDataLoaderCommit}
|
||||
* @defaultValue `'after-load'`
|
||||
*/
|
||||
commit?: DefineDataLoaderCommit;
|
||||
/**
|
||||
* Whether the data should be lazy loaded without blocking the client side navigation or not. When set to true, the loader will no longer block the navigation and the returned composable can be called even
|
||||
* without having the data ready.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
*/
|
||||
lazy?: unknown;
|
||||
/**
|
||||
* Whether this loader should be awaited on the server side or not. Combined with the `lazy` option, this gives full
|
||||
* control over how to await for the data.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
server?: unknown;
|
||||
/**
|
||||
* List of _expected_ errors that shouldn't abort the navigation (for non-lazy loaders). Provide a list of
|
||||
* constructors that can be checked with `instanceof` or a custom function that returns `true` for expected errors. Can also be set to `true` to accept all globally defined errors. Defaults to `false` to abort on any error.
|
||||
* @default `false`
|
||||
*/
|
||||
errors?: unknown;
|
||||
}
|
||||
/**
|
||||
* Options for a data loader that returns a data that is possibly `undefined`. Available for data loaders
|
||||
* implementations so they can be used in `defineLoader()` overloads.
|
||||
*/
|
||||
interface DefineDataLoaderOptionsBase_LaxData extends _DefineDataLoaderOptionsBase_Common {
|
||||
lazy?: boolean | ((to: RouteLocationNormalizedLoaded, from?: RouteLocationNormalizedLoaded) => boolean);
|
||||
server?: boolean;
|
||||
errors?: boolean | Array<new (...args: any[]) => any> | ((reason?: unknown) => boolean);
|
||||
}
|
||||
/**
|
||||
* Options for a data loader making the data defined without it being possibly `undefined`. Available for data loaders
|
||||
* implementations so they can be used in `defineLoader()` overloads.
|
||||
*/
|
||||
interface DefineDataLoaderOptionsBase_DefinedData extends _DefineDataLoaderOptionsBase_Common {
|
||||
lazy?: false;
|
||||
server?: true;
|
||||
errors?: false;
|
||||
}
|
||||
declare const toLazyValue: (lazy: undefined | DefineDataLoaderOptionsBase_LaxData["lazy"], to: RouteLocationNormalizedLoaded, from?: RouteLocationNormalizedLoaded) => boolean | undefined;
|
||||
/**
|
||||
* When the data should be committed to the entry.
|
||||
* - `immediate`: the data is committed as soon as it is loaded.
|
||||
* - `after-load`: the data is committed after all non-lazy loaders have finished loading.
|
||||
*/
|
||||
type DefineDataLoaderCommit = 'immediate' | 'after-load';
|
||||
interface DataLoaderContextBase {
|
||||
/**
|
||||
* Signal associated with the current navigation. It is aborted when the navigation is canceled or an error occurs.
|
||||
*/
|
||||
signal: AbortSignal | undefined;
|
||||
}
|
||||
/**
|
||||
* Data Loader composable returned by `defineLoader()`.
|
||||
* @see {@link DefineDataLoader}
|
||||
*/
|
||||
interface UseDataLoader<Data = unknown, TError = unknown> {
|
||||
[IS_USE_DATA_LOADER_KEY]: true;
|
||||
/**
|
||||
* Data Loader composable returned by `defineLoader()`.
|
||||
*
|
||||
* @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>, UseDataLoaderResult<Exclude<Data, NavigationResult>, TError>>;
|
||||
/**
|
||||
* Internals of the data loader.
|
||||
* @internal
|
||||
*/
|
||||
_: UseDataLoaderInternals<Exclude<Data, NavigationResult | undefined>, TError>;
|
||||
}
|
||||
/**
|
||||
* Internal properties of a data loader composable. Used by the internal implementation of `defineLoader()`. **Should
|
||||
* not be used in application code.**
|
||||
*/
|
||||
interface UseDataLoaderInternals<Data = unknown, TError = unknown> {
|
||||
/**
|
||||
* Loads the data from the cache if possible, otherwise loads it from the loader and awaits it.
|
||||
*
|
||||
* @param to - route location to load the data for
|
||||
* @param router - router instance
|
||||
* @param from - route location we are coming from
|
||||
* @param parent - parent data loader entry
|
||||
*/
|
||||
load: (to: RouteLocationNormalizedLoaded, router: Router, from?: RouteLocationNormalizedLoaded, parent?: DataLoaderEntryBase) => Promise<void>;
|
||||
/**
|
||||
* Resolved options for the loader.
|
||||
*/
|
||||
options: DefineDataLoaderOptionsBase_LaxData;
|
||||
/**
|
||||
* Gets the entry associated with the router instance. Assumes the data loader has been loaded and that the entry
|
||||
* exists.
|
||||
*
|
||||
* @param router - router instance
|
||||
*/
|
||||
getEntry(router: Router): DataLoaderEntryBase<Data, TError>;
|
||||
}
|
||||
/**
|
||||
* Return value of a loader composable defined with `defineLoader()`.
|
||||
*/
|
||||
interface UseDataLoaderResult<TData = unknown, TError = ErrorDefault> {
|
||||
/**
|
||||
* Data returned by the loader. If the data loader is lazy, it will be undefined until the first load.
|
||||
*/
|
||||
data: ShallowRef<TData>;
|
||||
/**
|
||||
* Whether there is an ongoing request.
|
||||
*/
|
||||
isLoading: ShallowRef<boolean>;
|
||||
/**
|
||||
* Error if there was an error.
|
||||
*/
|
||||
error: ShallowRef<TError | null>;
|
||||
/**
|
||||
* Reload the data using the current route location. Returns a promise that resolves when the data is reloaded. This
|
||||
* method should not be called during a navigation as it can conflict with an ongoing load and lead to
|
||||
* inconsistencies.
|
||||
*/
|
||||
reload(): Promise<void>;
|
||||
/**
|
||||
* Reload the data using the route location passed as argument. Returns a promise that resolves when the data is reloaded.
|
||||
*
|
||||
* @param route - route location to load the data for
|
||||
*/
|
||||
reload(route: RouteLocationNormalizedLoaded): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Loader function that can be passed to `defineLoader()`.
|
||||
*/
|
||||
interface DefineLoaderFn<Data, Context extends DataLoaderContextBase = DataLoaderContextBase, Route = RouteLocationNormalizedLoaded> {
|
||||
(route: Route, context: Context): Promise<Data>;
|
||||
}
|
||||
/**
|
||||
* @deprecated Use `DefineDataLoaderOptionsBase_LaxData` instead.
|
||||
*/
|
||||
type DefineDataLoaderOptionsBase = DefineDataLoaderOptionsBase_LaxData;
|
||||
//#endregion
|
||||
export { DATA_LOADERS_EFFECT_SCOPE_KEY as A, DataLoaderPluginOptions as C, useIsDataLoading as D, _DataLoaderRedirectResult as E, NAVIGATION_RESULTS_KEY as F, PENDING_LOCATION_KEY as I, STAGED_NO_VALUE as L, IS_USE_DATA_LOADER_KEY as M, LOADER_ENTRIES_KEY as N, ABORT_CONTROLLER_KEY as O, LOADER_SET_KEY as P, DataLoaderPlugin as S, SetupLoaderGuardOptions as T, isSubsetOf as _, DefineDataLoaderOptionsBase_LaxData as a, withLoaderContext as b, UseDataLoaderInternals as c, ErrorDefault as d, TypesConfig as f, getCurrentContext as g, currentContext as h, DefineDataLoaderOptionsBase_DefinedData as i, IS_SSR_KEY as j, APP_KEY as k, UseDataLoaderResult as l, assign as m, DataLoaderEntryBase as n, DefineLoaderFn as o, _PromiseMerged as p, DefineDataLoaderOptionsBase as r, UseDataLoader as s, DataLoaderContextBase as t, toLazyValue as u, setCurrentContext as v, NavigationResult as w, _DefineLoaderEntryMap as x, trackRoute as y };
|
||||
188
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/index.cjs
generated
vendored
Normal file
188
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/index.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
const require_createDataLoader = require('./createDataLoader-CBwrbo71.cjs');
|
||||
const require_utils = require('./utils-CL409u9D.cjs');
|
||||
let vue_router = require("vue-router");
|
||||
let vue = require("vue");
|
||||
|
||||
//#region src/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 = [], selectNavigationResult = (results) => results[0].value }) {
|
||||
if (router[require_utils.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[require_utils.LOADER_ENTRIES_KEY] = /* @__PURE__ */ new WeakMap();
|
||||
router[require_utils.APP_KEY] = app;
|
||||
router[require_utils.DATA_LOADERS_EFFECT_SCOPE_KEY] = scope;
|
||||
router[require_utils.IS_SSR_KEY] = !!isSSR;
|
||||
const isDataLoading = scope.run(() => (0, vue.shallowRef)(false));
|
||||
app.provide(IS_DATA_LOADING_KEY, isDataLoading);
|
||||
const removeLoaderGuard = router.beforeEach((to) => {
|
||||
if (router[require_utils.PENDING_LOCATION_KEY]) router[require_utils.PENDING_LOCATION_KEY].meta[require_utils.ABORT_CONTROLLER_KEY]?.abort();
|
||||
router[require_utils.PENDING_LOCATION_KEY] = to;
|
||||
to.meta[require_utils.LOADER_SET_KEY] = /* @__PURE__ */ new Set();
|
||||
to.meta[require_utils.ABORT_CONTROLLER_KEY] = new AbortController();
|
||||
to.meta[require_utils.NAVIGATION_RESULTS_KEY] = [];
|
||||
for (const record of to.matched) record.meta[require_utils.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[require_utils.LOADER_SET_KEY]) to.meta[require_utils.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 (require_utils.isDataLoader(exportValue)) to.meta[require_utils.LOADER_SET_KEY].add(exportValue);
|
||||
}
|
||||
const component = record.components?.[componentName];
|
||||
if (component && Array.isArray(component.__loaders)) {
|
||||
for (const loader of component.__loaders) if (require_utils.isDataLoader(loader)) to.meta[require_utils.LOADER_SET_KEY].add(loader);
|
||||
}
|
||||
}
|
||||
}
|
||||
const loaders = Array.from(to.meta[require_utils.LOADER_SET_KEY]);
|
||||
const { signal } = to.meta[require_utils.ABORT_CONTROLLER_KEY];
|
||||
require_utils.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 && require_createDataLoader.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(() => {
|
||||
if (to.meta[require_utils.NAVIGATION_RESULTS_KEY].length) return selectNavigationResult(to.meta[require_utils.NAVIGATION_RESULTS_KEY]);
|
||||
}).catch((error) => error instanceof NavigationResult ? error.value : signal.aborted && error === signal.reason ? false : Promise.reject(error)).finally(() => {
|
||||
require_utils.setCurrentContext([]);
|
||||
isDataLoading.value = false;
|
||||
});
|
||||
});
|
||||
const removeAfterEach = router.afterEach((to, from, failure) => {
|
||||
if (failure) {
|
||||
to.meta[require_utils.ABORT_CONTROLLER_KEY]?.abort(failure);
|
||||
if ((0, vue_router.isNavigationFailure)(failure, 16)) for (const loader of to.meta[require_utils.LOADER_SET_KEY]) loader._.getEntry(router).resetPending();
|
||||
} else for (const loader of to.meta[require_utils.LOADER_SET_KEY]) {
|
||||
const { commit, lazy } = loader._.options;
|
||||
if (commit === "after-load") {
|
||||
const entry = loader._.getEntry(router);
|
||||
if (entry && (!require_createDataLoader.toLazyValue(lazy, to, from) || !entry.isLoading.value)) entry.commit(to);
|
||||
}
|
||||
}
|
||||
if (router[require_utils.PENDING_LOCATION_KEY] === to) router[require_utils.PENDING_LOCATION_KEY] = null;
|
||||
});
|
||||
const removeOnError = router.onError((error, to) => {
|
||||
to.meta[require_utils.ABORT_CONTROLLER_KEY]?.abort(error);
|
||||
if (router[require_utils.PENDING_LOCATION_KEY] === to) router[require_utils.PENDING_LOCATION_KEY] = null;
|
||||
});
|
||||
return () => {
|
||||
delete router[require_utils.LOADER_ENTRIES_KEY];
|
||||
delete router[require_utils.APP_KEY];
|
||||
removeLoaderGuard();
|
||||
removeDataLoaderGuard();
|
||||
removeAfterEach();
|
||||
removeOnError();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Possible values to change the result of a navigation within a loader. Can be returned from a data loader and will
|
||||
* appear in `selectNavigationResult`. If thrown, it will immediately cancel the navigation. It can only contain values
|
||||
* that cancel the navigation.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* export const useUserData = defineLoader(async (to) => {
|
||||
* const user = await fetchUser(to.params.id)
|
||||
* if (!user) {
|
||||
* return new NavigationResult('/404')
|
||||
* }
|
||||
* return user
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
var NavigationResult = class {
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 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 = (0, vue.effectScope)(true);
|
||||
const removeGuards = setupLoaderGuard(require_utils.assign({
|
||||
app,
|
||||
effect
|
||||
}, options));
|
||||
const { unmount } = app;
|
||||
app.unmount = () => {
|
||||
effect.stop();
|
||||
removeGuards();
|
||||
unmount.call(app);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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 (0, vue.inject)(IS_DATA_LOADING_KEY);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
exports.ABORT_CONTROLLER_KEY = require_utils.ABORT_CONTROLLER_KEY;
|
||||
exports.APP_KEY = require_utils.APP_KEY;
|
||||
exports.DATA_LOADERS_EFFECT_SCOPE_KEY = require_utils.DATA_LOADERS_EFFECT_SCOPE_KEY;
|
||||
exports.DataLoaderPlugin = DataLoaderPlugin;
|
||||
exports.IS_SSR_KEY = require_utils.IS_SSR_KEY;
|
||||
exports.IS_USE_DATA_LOADER_KEY = require_utils.IS_USE_DATA_LOADER_KEY;
|
||||
exports.LOADER_ENTRIES_KEY = require_utils.LOADER_ENTRIES_KEY;
|
||||
exports.LOADER_SET_KEY = require_utils.LOADER_SET_KEY;
|
||||
exports.NAVIGATION_RESULTS_KEY = require_utils.NAVIGATION_RESULTS_KEY;
|
||||
exports.NavigationResult = NavigationResult;
|
||||
exports.PENDING_LOCATION_KEY = require_utils.PENDING_LOCATION_KEY;
|
||||
exports.STAGED_NO_VALUE = require_utils.STAGED_NO_VALUE;
|
||||
exports.assign = require_utils.assign;
|
||||
Object.defineProperty(exports, 'currentContext', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return require_utils.currentContext;
|
||||
}
|
||||
});
|
||||
exports.getCurrentContext = require_utils.getCurrentContext;
|
||||
exports.isSubsetOf = require_utils.isSubsetOf;
|
||||
exports.setCurrentContext = require_utils.setCurrentContext;
|
||||
exports.toLazyValue = require_createDataLoader.toLazyValue;
|
||||
exports.trackRoute = require_utils.trackRoute;
|
||||
exports.useIsDataLoading = useIsDataLoading;
|
||||
exports.withLoaderContext = require_utils.withLoaderContext;
|
||||
2
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/index.d.cts
generated
vendored
Normal file
2
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/index.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import { A as DATA_LOADERS_EFFECT_SCOPE_KEY, C as DataLoaderPluginOptions, D as useIsDataLoading, E as _DataLoaderRedirectResult, F as NAVIGATION_RESULTS_KEY, I as PENDING_LOCATION_KEY, L as STAGED_NO_VALUE, M as IS_USE_DATA_LOADER_KEY, N as LOADER_ENTRIES_KEY, O as ABORT_CONTROLLER_KEY, P as LOADER_SET_KEY, S as DataLoaderPlugin, T as SetupLoaderGuardOptions, _ as isSubsetOf, a as DefineDataLoaderOptionsBase_LaxData, b as withLoaderContext, c as UseDataLoaderInternals, d as ErrorDefault, f as TypesConfig, g as getCurrentContext, h as currentContext, i as DefineDataLoaderOptionsBase_DefinedData, j as IS_SSR_KEY, k as APP_KEY, l as UseDataLoaderResult, m as assign, n as DataLoaderEntryBase, o as DefineLoaderFn, p as _PromiseMerged, r as DefineDataLoaderOptionsBase, s as UseDataLoader, t as DataLoaderContextBase, u as toLazyValue, v as setCurrentContext, w as NavigationResult, x as _DefineLoaderEntryMap, y as trackRoute } from "./createDataLoader-DgP0poyl.cjs";
|
||||
export { ABORT_CONTROLLER_KEY, APP_KEY, DATA_LOADERS_EFFECT_SCOPE_KEY, type DataLoaderContextBase, type DataLoaderEntryBase, DataLoaderPlugin, type DataLoaderPluginOptions, type DefineDataLoaderOptionsBase, type DefineDataLoaderOptionsBase_DefinedData, type DefineDataLoaderOptionsBase_LaxData, type DefineLoaderFn, type ErrorDefault, IS_SSR_KEY, IS_USE_DATA_LOADER_KEY, LOADER_ENTRIES_KEY, LOADER_SET_KEY, NAVIGATION_RESULTS_KEY, NavigationResult, PENDING_LOCATION_KEY, STAGED_NO_VALUE, type SetupLoaderGuardOptions, type TypesConfig, type UseDataLoader, type UseDataLoaderInternals, type UseDataLoaderResult, type _DataLoaderRedirectResult, _DefineLoaderEntryMap, type _PromiseMerged, assign, currentContext, getCurrentContext, isSubsetOf, setCurrentContext, toLazyValue, trackRoute, useIsDataLoading, withLoaderContext };
|
||||
2
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/index.d.mts
generated
vendored
Normal file
2
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/index.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import { A as DATA_LOADERS_EFFECT_SCOPE_KEY, C as DataLoaderPluginOptions, D as useIsDataLoading, E as _DataLoaderRedirectResult, F as NAVIGATION_RESULTS_KEY, I as PENDING_LOCATION_KEY, L as STAGED_NO_VALUE, M as IS_USE_DATA_LOADER_KEY, N as LOADER_ENTRIES_KEY, O as ABORT_CONTROLLER_KEY, P as LOADER_SET_KEY, S as DataLoaderPlugin, T as SetupLoaderGuardOptions, _ as isSubsetOf, a as DefineDataLoaderOptionsBase_LaxData, b as withLoaderContext, c as UseDataLoaderInternals, d as ErrorDefault, f as TypesConfig, g as getCurrentContext, h as currentContext, i as DefineDataLoaderOptionsBase_DefinedData, j as IS_SSR_KEY, k as APP_KEY, l as UseDataLoaderResult, m as assign, n as DataLoaderEntryBase, o as DefineLoaderFn, p as _PromiseMerged, r as DefineDataLoaderOptionsBase, s as UseDataLoader, t as DataLoaderContextBase, u as toLazyValue, v as setCurrentContext, w as NavigationResult, x as _DefineLoaderEntryMap, y as trackRoute } from "./createDataLoader-C8o8GrdD.mjs";
|
||||
export { ABORT_CONTROLLER_KEY, APP_KEY, DATA_LOADERS_EFFECT_SCOPE_KEY, type DataLoaderContextBase, type DataLoaderEntryBase, DataLoaderPlugin, type DataLoaderPluginOptions, type DefineDataLoaderOptionsBase, type DefineDataLoaderOptionsBase_DefinedData, type DefineDataLoaderOptionsBase_LaxData, type DefineLoaderFn, type ErrorDefault, IS_SSR_KEY, IS_USE_DATA_LOADER_KEY, LOADER_ENTRIES_KEY, LOADER_SET_KEY, NAVIGATION_RESULTS_KEY, NavigationResult, PENDING_LOCATION_KEY, STAGED_NO_VALUE, type SetupLoaderGuardOptions, type TypesConfig, type UseDataLoader, type UseDataLoaderInternals, type UseDataLoaderResult, type _DataLoaderRedirectResult, _DefineLoaderEntryMap, type _PromiseMerged, assign, currentContext, getCurrentContext, isSubsetOf, setCurrentContext, toLazyValue, trackRoute, useIsDataLoading, withLoaderContext };
|
||||
163
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/index.mjs
generated
vendored
Normal file
163
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/index.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
import { t as toLazyValue } from "./createDataLoader-BK9Gdnky.mjs";
|
||||
import { _ as PENDING_LOCATION_KEY, a as isSubsetOf, c as withLoaderContext, d as DATA_LOADERS_EFFECT_SCOPE_KEY, f as IS_SSR_KEY, g as NAVIGATION_RESULTS_KEY, h as LOADER_SET_KEY, i as isDataLoader, l as ABORT_CONTROLLER_KEY, m as LOADER_ENTRIES_KEY, n as currentContext, o as setCurrentContext, p as IS_USE_DATA_LOADER_KEY, r as getCurrentContext, s as trackRoute, t as assign, u as APP_KEY, v as STAGED_NO_VALUE } from "./utils-C5t8q_dT.mjs";
|
||||
import { isNavigationFailure } from "vue-router";
|
||||
import { effectScope, inject, shallowRef } from "vue";
|
||||
|
||||
//#region src/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 = [], selectNavigationResult = (results) => results[0].value }) {
|
||||
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();
|
||||
to.meta[NAVIGATION_RESULTS_KEY] = [];
|
||||
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(() => {
|
||||
if (to.meta[NAVIGATION_RESULTS_KEY].length) return selectNavigationResult(to.meta[NAVIGATION_RESULTS_KEY]);
|
||||
}).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();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Possible values to change the result of a navigation within a loader. Can be returned from a data loader and will
|
||||
* appear in `selectNavigationResult`. If thrown, it will immediately cancel the navigation. It can only contain values
|
||||
* that cancel the navigation.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* export const useUserData = defineLoader(async (to) => {
|
||||
* const user = await fetchUser(to.params.id)
|
||||
* if (!user) {
|
||||
* return new NavigationResult('/404')
|
||||
* }
|
||||
* return user
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
var NavigationResult = class {
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 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));
|
||||
const { unmount } = app;
|
||||
app.unmount = () => {
|
||||
effect.stop();
|
||||
removeGuards();
|
||||
unmount.call(app);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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 { ABORT_CONTROLLER_KEY, APP_KEY, DATA_LOADERS_EFFECT_SCOPE_KEY, DataLoaderPlugin, IS_SSR_KEY, IS_USE_DATA_LOADER_KEY, LOADER_ENTRIES_KEY, LOADER_SET_KEY, NAVIGATION_RESULTS_KEY, NavigationResult, PENDING_LOCATION_KEY, STAGED_NO_VALUE, assign, currentContext, getCurrentContext, isSubsetOf, setCurrentContext, toLazyValue, trackRoute, useIsDataLoading, withLoaderContext };
|
||||
229
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/pinia-colada.cjs
generated
vendored
Normal file
229
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/pinia-colada.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
const require_createDataLoader = require('./createDataLoader-CBwrbo71.cjs');
|
||||
let vue_router = require("vue-router");
|
||||
let unplugin_vue_router_data_loaders = require("unplugin-vue-router/data-loaders");
|
||||
let vue = require("vue");
|
||||
let __pinia_colada = require("@pinia/colada");
|
||||
|
||||
//#region src/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 = (0, __pinia_colada.defineQuery)(() => {
|
||||
const router = (0, vue_router.useRouter)();
|
||||
const entry = router[unplugin_vue_router_data_loaders.LOADER_ENTRIES_KEY].get(loader);
|
||||
return (0, __pinia_colada.useQuery)({
|
||||
...options,
|
||||
query: () => {
|
||||
const route = entry.route.value;
|
||||
const [trackedRoute, params, query, hash] = (0, unplugin_vue_router_data_loaders.trackRoute)(route);
|
||||
entry.tracked.set(joinKeys(serializeQueryKey(options.key, trackedRoute)), {
|
||||
ready: false,
|
||||
params,
|
||||
query,
|
||||
hash
|
||||
});
|
||||
return router[unplugin_vue_router_data_loaders.APP_KEY].runWithContext(() => loader(trackedRoute, { signal: route.meta[unplugin_vue_router_data_loaders.ABORT_CONTROLLER_KEY]?.signal }));
|
||||
},
|
||||
key: () => toValueWithParameters(options.key, entry.route.value)
|
||||
});
|
||||
});
|
||||
function load(to, router, from, parent, reload) {
|
||||
const entries = router[unplugin_vue_router_data_loaders.LOADER_ENTRIES_KEY];
|
||||
const isSSR = router[unplugin_vue_router_data_loaders.IS_SSR_KEY];
|
||||
const key = serializeQueryKey(options.key, to);
|
||||
if (!entries.has(loader)) {
|
||||
const route = (0, vue.shallowRef)(to);
|
||||
entries.set(loader, {
|
||||
data: (0, vue.shallowRef)(),
|
||||
isLoading: (0, vue.shallowRef)(false),
|
||||
error: (0, vue.shallowRef)(null),
|
||||
to,
|
||||
options,
|
||||
children: /* @__PURE__ */ new Set(),
|
||||
resetPending() {
|
||||
this.pendingTo = null;
|
||||
this.pendingLoad = null;
|
||||
this.isLoading.value = false;
|
||||
},
|
||||
staged: unplugin_vue_router_data_loaders.STAGED_NO_VALUE,
|
||||
stagedError: null,
|
||||
stagedNavigationResult: 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 = (0, unplugin_vue_router_data_loaders.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/posva/unplugin-vue-router/`);
|
||||
}
|
||||
(0, unplugin_vue_router_data_loaders.setCurrentContext)([
|
||||
entry,
|
||||
router,
|
||||
to
|
||||
]);
|
||||
if (!entry.ext) {
|
||||
entry.ext = useDefinedQuery();
|
||||
(0, __pinia_colada.useQueryCache)().get(toValueWithParameters(options.key, to))?.deps.delete(router[unplugin_vue_router_data_loaders.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;
|
||||
(0, unplugin_vue_router_data_loaders.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 = unplugin_vue_router_data_loaders.STAGED_NO_VALUE;
|
||||
entry.stagedError = error.value;
|
||||
entry.stagedNavigationResult = null;
|
||||
const currentLoad = ext[reload ? "refetch" : "refresh"]().then(() => {
|
||||
if (entry.pendingLoad === currentLoad) {
|
||||
const newError = ext.error.value;
|
||||
if (newError) {
|
||||
entry.stagedError = newError;
|
||||
if (!require_createDataLoader.toLazyValue(options.lazy, to, from) || isSSR) throw newError;
|
||||
} else {
|
||||
const newData = ext.data.value;
|
||||
if (newData instanceof unplugin_vue_router_data_loaders.NavigationResult) {
|
||||
to.meta[unplugin_vue_router_data_loaders.NAVIGATION_RESULTS_KEY].push(newData);
|
||||
entry.stagedNavigationResult = newData;
|
||||
} else {
|
||||
entry.staged = newData;
|
||||
entry.stagedError = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}).finally(() => {
|
||||
(0, unplugin_vue_router_data_loaders.setCurrentContext)(currentContext);
|
||||
if (entry.pendingLoad === currentLoad) {
|
||||
isLoading.value = false;
|
||||
if (options.commit === "immediate" || !router[unplugin_vue_router_data_loaders.PENDING_LOCATION_KEY]) entry.commit(to);
|
||||
}
|
||||
});
|
||||
(0, unplugin_vue_router_data_loaders.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 === unplugin_vue_router_data_loaders.STAGED_NO_VALUE && this.stagedError === null && this.stagedNavigationResult === null) console.warn(`Loader "${key}"'s "commit()" was called but there is no staged data.`);
|
||||
}
|
||||
if (this.staged !== unplugin_vue_router_data_loaders.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 = unplugin_vue_router_data_loaders.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 currentEntry = (0, unplugin_vue_router_data_loaders.getCurrentContext)();
|
||||
const [parentEntry, _router, _route] = currentEntry;
|
||||
const router = _router || (0, vue_router.useRouter)();
|
||||
const route = _route || (0, vue_router.useRoute)();
|
||||
const app = router[unplugin_vue_router_data_loaders.APP_KEY];
|
||||
const entries = router[unplugin_vue_router_data_loaders.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();
|
||||
(0, __pinia_colada.useQueryCache)().get(toValueWithParameters(options.key, route))?.deps.delete(router[unplugin_vue_router_data_loaders.DATA_LOADERS_EFFECT_SCOPE_KEY]);
|
||||
(0, vue.watch)(ext.data, (newData) => {
|
||||
if (!router[unplugin_vue_router_data_loaders.PENDING_LOCATION_KEY]) data.value = newData;
|
||||
});
|
||||
(0, vue.watch)(ext.isLoading, (isFetching) => {
|
||||
if (!router[unplugin_vue_router_data_loaders.PENDING_LOCATION_KEY]) isLoading.value = isFetching;
|
||||
});
|
||||
(0, vue.watch)(ext.error, (newError) => {
|
||||
if (!router[unplugin_vue_router_data_loaders.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(() => {
|
||||
return entry.staged === unplugin_vue_router_data_loaders.STAGED_NO_VALUE ? entry.stagedNavigationResult ? Promise.reject(entry.stagedNavigationResult) : ext.data.value : entry.staged;
|
||||
}).catch((e) => parentEntry ? Promise.reject(e) : null);
|
||||
(0, unplugin_vue_router_data_loaders.setCurrentContext)(currentEntry);
|
||||
return (0, unplugin_vue_router_data_loaders.assign)(promise, useDataLoaderResult);
|
||||
};
|
||||
useDataLoader[unplugin_vue_router_data_loaders.IS_USE_DATA_LOADER_KEY] = true;
|
||||
useDataLoader._ = {
|
||||
load,
|
||||
options,
|
||||
getEntry(router) {
|
||||
return router[unplugin_vue_router_data_loaders.LOADER_ENTRIES_KEY].get(loader);
|
||||
}
|
||||
};
|
||||
return useDataLoader;
|
||||
}
|
||||
const joinKeys = (keys) => keys.join("|");
|
||||
function hasRouteChanged(to, tracked) {
|
||||
return !tracked.ready || !(0, unplugin_vue_router_data_loaders.isSubsetOf)(tracked.params, to.params) || !(0, unplugin_vue_router_data_loaders.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
|
||||
exports.defineColadaLoader = defineColadaLoader;
|
||||
150
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/pinia-colada.d.cts
generated
vendored
Normal file
150
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/pinia-colada.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
import { i as DefineDataLoaderOptionsBase_DefinedData } from "./createDataLoader-DgP0poyl.cjs";
|
||||
import { LocationQuery, RouteLocationNormalizedLoaded, RouteMap } from "vue-router";
|
||||
import { DataLoaderContextBase, DataLoaderEntryBase, DefineDataLoaderOptionsBase_LaxData, DefineLoaderFn, ErrorDefault, NavigationResult, UseDataLoader, UseDataLoaderResult, _PromiseMerged } from "unplugin-vue-router/data-loaders";
|
||||
import { ShallowRef } from "vue";
|
||||
import { EntryKey, UseQueryOptions, UseQueryReturn } from "@pinia/colada";
|
||||
|
||||
//#region src/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_LaxData, type UseDataLoaderColadaResult, type UseDataLoaderColada_DefinedData, type UseDataLoaderColada_LaxData, defineColadaLoader };
|
||||
150
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/pinia-colada.d.mts
generated
vendored
Normal file
150
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/pinia-colada.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
import { i as DefineDataLoaderOptionsBase_DefinedData } from "./createDataLoader-C8o8GrdD.mjs";
|
||||
import { LocationQuery, RouteLocationNormalizedLoaded, RouteMap } from "vue-router";
|
||||
import { DataLoaderContextBase, DataLoaderEntryBase, DefineDataLoaderOptionsBase_LaxData, DefineLoaderFn, ErrorDefault, NavigationResult, UseDataLoader, UseDataLoaderResult, _PromiseMerged } from "unplugin-vue-router/data-loaders";
|
||||
import { ShallowRef } from "vue";
|
||||
import { EntryKey, UseQueryOptions, UseQueryReturn } from "@pinia/colada";
|
||||
|
||||
//#region src/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_LaxData, type UseDataLoaderColadaResult, type UseDataLoaderColada_DefinedData, type UseDataLoaderColada_LaxData, defineColadaLoader };
|
||||
229
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/pinia-colada.mjs
generated
vendored
Normal file
229
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/pinia-colada.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
import { t as toLazyValue } from "./createDataLoader-BK9Gdnky.mjs";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { ABORT_CONTROLLER_KEY, APP_KEY, DATA_LOADERS_EFFECT_SCOPE_KEY, IS_SSR_KEY, IS_USE_DATA_LOADER_KEY, LOADER_ENTRIES_KEY, NAVIGATION_RESULTS_KEY, NavigationResult, PENDING_LOCATION_KEY, STAGED_NO_VALUE, assign, getCurrentContext, isSubsetOf, setCurrentContext, trackRoute } from "unplugin-vue-router/data-loaders";
|
||||
import { shallowRef, watch } from "vue";
|
||||
import { defineQuery, useQuery, useQueryCache } from "@pinia/colada";
|
||||
|
||||
//#region src/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,
|
||||
stagedNavigationResult: 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/posva/unplugin-vue-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;
|
||||
entry.stagedNavigationResult = null;
|
||||
const currentLoad = ext[reload ? "refetch" : "refresh"]().then(() => {
|
||||
if (entry.pendingLoad === currentLoad) {
|
||||
const newError = ext.error.value;
|
||||
if (newError) {
|
||||
entry.stagedError = newError;
|
||||
if (!toLazyValue(options.lazy, to, from) || isSSR) throw newError;
|
||||
} else {
|
||||
const newData = ext.data.value;
|
||||
if (newData instanceof NavigationResult) {
|
||||
to.meta[NAVIGATION_RESULTS_KEY].push(newData);
|
||||
entry.stagedNavigationResult = 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 && this.stagedNavigationResult === 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 currentEntry = getCurrentContext();
|
||||
const [parentEntry, _router, _route] = currentEntry;
|
||||
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(() => {
|
||||
return entry.staged === STAGED_NO_VALUE ? entry.stagedNavigationResult ? Promise.reject(entry.stagedNavigationResult) : ext.data.value : entry.staged;
|
||||
}).catch((e) => parentEntry ? Promise.reject(e) : null);
|
||||
setCurrentContext(currentEntry);
|
||||
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 };
|
||||
147
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/utils-C5t8q_dT.mjs
generated
vendored
Normal file
147
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/utils-C5t8q_dT.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
//#region src/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();
|
||||
/**
|
||||
* Gives access to the navigation results when the navigation is aborted by the user within a data loader.
|
||||
* @internal
|
||||
*/
|
||||
const NAVIGATION_RESULTS_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/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
|
||||
export { PENDING_LOCATION_KEY as _, isSubsetOf as a, withLoaderContext as c, DATA_LOADERS_EFFECT_SCOPE_KEY as d, IS_SSR_KEY as f, NAVIGATION_RESULTS_KEY as g, LOADER_SET_KEY as h, isDataLoader as i, ABORT_CONTROLLER_KEY as l, LOADER_ENTRIES_KEY as m, currentContext as n, setCurrentContext as o, IS_USE_DATA_LOADER_KEY as p, getCurrentContext as r, trackRoute as s, assign as t, APP_KEY as u, STAGED_NO_VALUE as v };
|
||||
255
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/utils-CL409u9D.cjs
generated
vendored
Normal file
255
Frontend-Learner/node_modules/unplugin-vue-router/dist/data-loaders/utils-CL409u9D.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
|
||||
//#region src/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();
|
||||
/**
|
||||
* Gives access to the navigation results when the navigation is aborted by the user within a data loader.
|
||||
* @internal
|
||||
*/
|
||||
const NAVIGATION_RESULTS_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/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
|
||||
Object.defineProperty(exports, 'ABORT_CONTROLLER_KEY', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return ABORT_CONTROLLER_KEY;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'APP_KEY', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return APP_KEY;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'DATA_LOADERS_EFFECT_SCOPE_KEY', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return DATA_LOADERS_EFFECT_SCOPE_KEY;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'IS_SSR_KEY', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return IS_SSR_KEY;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'IS_USE_DATA_LOADER_KEY', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return IS_USE_DATA_LOADER_KEY;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'LOADER_ENTRIES_KEY', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return LOADER_ENTRIES_KEY;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'LOADER_SET_KEY', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return LOADER_SET_KEY;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'NAVIGATION_RESULTS_KEY', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return NAVIGATION_RESULTS_KEY;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'PENDING_LOCATION_KEY', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return PENDING_LOCATION_KEY;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'STAGED_NO_VALUE', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return STAGED_NO_VALUE;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'assign', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return assign;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'currentContext', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return currentContext;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'getCurrentContext', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return getCurrentContext;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'isDataLoader', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return isDataLoader;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'isSubsetOf', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return isSubsetOf;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'setCurrentContext', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return setCurrentContext;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'trackRoute', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return trackRoute;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'withLoaderContext', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return withLoaderContext;
|
||||
}
|
||||
});
|
||||
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/esbuild.cjs
generated
vendored
Normal file
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/esbuild.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
const require_src = require('./src-DKnuUuX8.cjs');
|
||||
require('./options-CpfNkO-E.cjs');
|
||||
|
||||
//#region src/esbuild.ts
|
||||
var esbuild_default = require_src.src_default.esbuild;
|
||||
|
||||
//#endregion
|
||||
module.exports = esbuild_default;
|
||||
6
Frontend-Learner/node_modules/unplugin-vue-router/dist/esbuild.d.cts
generated
vendored
Normal file
6
Frontend-Learner/node_modules/unplugin-vue-router/dist/esbuild.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { r as Options } from "./options-BCiDuX1m.cjs";
|
||||
import * as esbuild0 from "esbuild";
|
||||
|
||||
//#region src/esbuild.d.ts
|
||||
declare const _default: (options?: Options | undefined) => esbuild0.Plugin;
|
||||
export = _default;
|
||||
7
Frontend-Learner/node_modules/unplugin-vue-router/dist/esbuild.d.mts
generated
vendored
Normal file
7
Frontend-Learner/node_modules/unplugin-vue-router/dist/esbuild.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { r as Options } from "./options-DG3niQXy.mjs";
|
||||
import * as esbuild0 from "esbuild";
|
||||
|
||||
//#region src/esbuild.d.ts
|
||||
declare const _default: (options?: Options | undefined) => esbuild0.Plugin;
|
||||
//#endregion
|
||||
export { _default as default };
|
||||
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/esbuild.mjs
generated
vendored
Normal file
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/esbuild.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "./options-CAGVi1wo.mjs";
|
||||
import { n as src_default } from "./src-CZrWKhKa.mjs";
|
||||
|
||||
//#region src/esbuild.ts
|
||||
var esbuild_default = src_default.esbuild;
|
||||
|
||||
//#endregion
|
||||
export { esbuild_default as default };
|
||||
13
Frontend-Learner/node_modules/unplugin-vue-router/dist/index.cjs
generated
vendored
Normal file
13
Frontend-Learner/node_modules/unplugin-vue-router/dist/index.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
const require_src = require('./src-DKnuUuX8.cjs');
|
||||
const require_options = require('./options-CpfNkO-E.cjs');
|
||||
|
||||
exports.AutoExportLoaders = require_src.AutoExportLoaders;
|
||||
exports.DEFAULT_OPTIONS = require_options.DEFAULT_OPTIONS;
|
||||
exports.EditableTreeNode = require_src.EditableTreeNode;
|
||||
exports.VueRouterAutoImports = require_src.VueRouterAutoImports;
|
||||
exports.createRoutesContext = require_src.createRoutesContext;
|
||||
exports.createTreeNodeValue = require_src.createTreeNodeValue;
|
||||
exports.default = require_src.src_default;
|
||||
exports.getFileBasedRouteName = require_options.getFileBasedRouteName;
|
||||
exports.getPascalCaseRouteName = require_options.getPascalCaseRouteName;
|
||||
65
Frontend-Learner/node_modules/unplugin-vue-router/dist/index.d.cts
generated
vendored
Normal file
65
Frontend-Learner/node_modules/unplugin-vue-router/dist/index.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import { C as createTreeNodeValue, S as TreeNodeValueStatic, _ as getPascalCaseRouteName, a as ResolvedOptions, b as TreeNodeValueGroup, g as getFileBasedRouteName, h as EditableTreeNode, l as ServerContext, r as Options, t as DEFAULT_OPTIONS, v as TreeNode, x as TreeNodeValueParam, y as TreeNodeValue } from "./options-BCiDuX1m.cjs";
|
||||
import "./types-Dulnjx6t.cjs";
|
||||
import * as unplugin0 from "unplugin";
|
||||
import { StringFilter } from "unplugin";
|
||||
import { Plugin } from "vite";
|
||||
|
||||
//#region src/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): unplugin0.Thenable<unplugin0.TransformResult>;
|
||||
};
|
||||
//#endregion
|
||||
//#region src/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/index.d.ts
|
||||
declare const _default: unplugin0.UnpluginInstance<Options | undefined, boolean>;
|
||||
/**
|
||||
* Adds useful auto imports to the AutoImport config:
|
||||
* @example
|
||||
* ```js
|
||||
* import { VueRouterAutoImports } from 'unplugin-vue-router'
|
||||
*
|
||||
* AutoImport({
|
||||
* imports: [VueRouterAutoImports],
|
||||
* }),
|
||||
* ```
|
||||
*/
|
||||
declare const VueRouterAutoImports: Record<string, Array<string | [importName: string, alias: string]>>;
|
||||
//#endregion
|
||||
export { AutoExportLoaders, type AutoExportLoadersOptions, DEFAULT_OPTIONS, EditableTreeNode, Options, TreeNode, TreeNodeValue, TreeNodeValueGroup, TreeNodeValueParam, TreeNodeValueStatic, VueRouterAutoImports, createRoutesContext, createTreeNodeValue, _default as default, getFileBasedRouteName, getPascalCaseRouteName };
|
||||
65
Frontend-Learner/node_modules/unplugin-vue-router/dist/index.d.mts
generated
vendored
Normal file
65
Frontend-Learner/node_modules/unplugin-vue-router/dist/index.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import { C as createTreeNodeValue, S as TreeNodeValueStatic, _ as getPascalCaseRouteName, a as ResolvedOptions, b as TreeNodeValueGroup, g as getFileBasedRouteName, h as EditableTreeNode, l as ServerContext, r as Options, t as DEFAULT_OPTIONS, v as TreeNode, x as TreeNodeValueParam, y as TreeNodeValue } from "./options-DG3niQXy.mjs";
|
||||
import "./types-CF4U0ZkR.mjs";
|
||||
import * as unplugin0 from "unplugin";
|
||||
import { StringFilter } from "unplugin";
|
||||
import { Plugin } from "vite";
|
||||
|
||||
//#region src/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): unplugin0.Thenable<unplugin0.TransformResult>;
|
||||
};
|
||||
//#endregion
|
||||
//#region src/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/index.d.ts
|
||||
declare const _default: unplugin0.UnpluginInstance<Options | undefined, boolean>;
|
||||
/**
|
||||
* Adds useful auto imports to the AutoImport config:
|
||||
* @example
|
||||
* ```js
|
||||
* import { VueRouterAutoImports } from 'unplugin-vue-router'
|
||||
*
|
||||
* AutoImport({
|
||||
* imports: [VueRouterAutoImports],
|
||||
* }),
|
||||
* ```
|
||||
*/
|
||||
declare const VueRouterAutoImports: Record<string, Array<string | [importName: string, alias: string]>>;
|
||||
//#endregion
|
||||
export { AutoExportLoaders, type AutoExportLoadersOptions, DEFAULT_OPTIONS, EditableTreeNode, Options, TreeNode, TreeNodeValue, TreeNodeValueGroup, TreeNodeValueParam, TreeNodeValueStatic, VueRouterAutoImports, createRoutesContext, createTreeNodeValue, _default as default, getFileBasedRouteName, getPascalCaseRouteName };
|
||||
4
Frontend-Learner/node_modules/unplugin-vue-router/dist/index.mjs
generated
vendored
Normal file
4
Frontend-Learner/node_modules/unplugin-vue-router/dist/index.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import { d as getPascalCaseRouteName, t as DEFAULT_OPTIONS, u as getFileBasedRouteName } from "./options-CAGVi1wo.mjs";
|
||||
import { a as EditableTreeNode, i as createRoutesContext, n as src_default, o as createTreeNodeValue, r as AutoExportLoaders, t as VueRouterAutoImports } from "./src-CZrWKhKa.mjs";
|
||||
|
||||
export { AutoExportLoaders, DEFAULT_OPTIONS, EditableTreeNode, VueRouterAutoImports, createRoutesContext, createTreeNodeValue, src_default as default, getFileBasedRouteName, getPascalCaseRouteName };
|
||||
933
Frontend-Learner/node_modules/unplugin-vue-router/dist/options-BCiDuX1m.d.cts
generated
vendored
Normal file
933
Frontend-Learner/node_modules/unplugin-vue-router/dist/options-BCiDuX1m.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,933 @@
|
|||
import { RouteMeta, RouteRecordRaw, TypesConfig } from "vue-router";
|
||||
|
||||
//#region src/runtime.d.ts
|
||||
|
||||
type ParamParserType_Native = 'int' | 'bool';
|
||||
type ParamParserType = (TypesConfig extends Record<'ParamParsers', infer ParamParsers> ? ParamParsers : never) | ParamParserType_Native;
|
||||
/**
|
||||
* Configures how to extract a route param from a specific query parameter.
|
||||
*/
|
||||
interface DefinePageQueryParamOptions<T = unknown> {
|
||||
/**
|
||||
* The type of the query parameter. Allowed values are native param parsers
|
||||
* and any parser in the {@link https://uvr.esm.is/TODO | params folder }. If
|
||||
* not provided, the value will kept as is.
|
||||
*/
|
||||
parser?: ParamParserType;
|
||||
/**
|
||||
* Default value if the query parameter is missing or if the match fails
|
||||
* (e.g. a invalid number is passed to the int param parser). If not provided
|
||||
* and the param parser throws, the route will not match.
|
||||
*/
|
||||
default?: (() => T) | T;
|
||||
/**
|
||||
* How to format the query parameter value.
|
||||
*
|
||||
* - 'value' - keep the first value only and pass that to parser
|
||||
* - 'array' - keep all values (even one or none) as an array and pass that to parser
|
||||
*
|
||||
* @default 'value'
|
||||
*/
|
||||
format?: 'value' | 'array';
|
||||
}
|
||||
//#endregion
|
||||
//#region src/core/customBlock.d.ts
|
||||
interface CustomRouteBlock extends Partial<Omit<RouteRecordRaw, 'components' | 'component' | 'children' | 'beforeEnter' | 'name'>> {
|
||||
name?: string | undefined | false;
|
||||
params?: {
|
||||
path?: Record<string, string>;
|
||||
query?: Record<string, string | CustomRouteBlockQueryParamOptions>;
|
||||
};
|
||||
}
|
||||
interface CustomRouteBlockQueryParamOptions {
|
||||
parser?: string;
|
||||
format?: DefinePageQueryParamOptions['format'];
|
||||
default?: string;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/core/treeNodeValue.d.ts
|
||||
declare const enum TreeNodeType {
|
||||
static = 0,
|
||||
group = 1,
|
||||
param = 2,
|
||||
}
|
||||
interface RouteRecordOverride extends Partial<Pick<RouteRecordRaw, 'meta' | 'props' | 'alias' | 'path'>> {
|
||||
name?: string | undefined | false;
|
||||
/**
|
||||
* Param Parsers information.
|
||||
*/
|
||||
params?: {
|
||||
path?: Record<string, string>;
|
||||
query?: Record<string, string | RouteRecordOverrideQueryParamOptions>;
|
||||
};
|
||||
}
|
||||
interface RouteRecordOverrideQueryParamOptions extends CustomRouteBlockQueryParamOptions {
|
||||
default?: string;
|
||||
}
|
||||
type SubSegment = string | TreePathParam;
|
||||
declare class _TreeNodeValueBase {
|
||||
/**
|
||||
* flag based on the type of the segment
|
||||
*/
|
||||
_type: TreeNodeType;
|
||||
parent: TreeNodeValue | undefined;
|
||||
/**
|
||||
* segment as defined by the file structure e.g. keeps the `index` name, `(group-name)`
|
||||
*/
|
||||
rawSegment: string;
|
||||
/**
|
||||
* transformed version of the segment into a vue-router path. e.g. `'index'` becomes `''` and `[param]` becomes
|
||||
* `:param`, `prefix-[param]-end` becomes `prefix-:param-end`.
|
||||
*/
|
||||
pathSegment: string;
|
||||
/**
|
||||
* Array of sub segments. This is usually one single elements but can have more for paths like `prefix-[param]-end.vue`
|
||||
*/
|
||||
subSegments: SubSegment[];
|
||||
/**
|
||||
* Overrides defined by each file. The map is necessary to handle named views.
|
||||
*/
|
||||
private _overrides;
|
||||
/**
|
||||
* View name (Vue Router feature) mapped to their corresponding file. By default, the view name is `default` unless
|
||||
* specified with a `@` e.g. `index@aux.vue` will have a view name of `aux`.
|
||||
*/
|
||||
components: Map<string, string>;
|
||||
constructor(rawSegment: string, parent: TreeNodeValue | undefined, pathSegment?: string, subSegments?: SubSegment[]);
|
||||
/**
|
||||
* Path of the node. Can be absolute or not. If it has been overridden, it
|
||||
* will return the overridden path.
|
||||
*/
|
||||
get path(): string;
|
||||
/**
|
||||
* Full path of the node including parent nodes.
|
||||
*/
|
||||
get fullPath(): string;
|
||||
/**
|
||||
* Gets all the query params for the node. This does not include params from parent nodes.
|
||||
*/
|
||||
get queryParams(): TreeQueryParam[];
|
||||
/**
|
||||
* Gets all the params for the node including path and query params. This
|
||||
* does not include params from parent nodes.
|
||||
*/
|
||||
get params(): (TreePathParam | TreeQueryParam)[];
|
||||
toString(): string;
|
||||
isParam(): this is TreeNodeValueParam;
|
||||
isStatic(): this is TreeNodeValueStatic;
|
||||
isGroup(): this is TreeNodeValueGroup;
|
||||
get overrides(): RouteRecordOverride;
|
||||
setOverride(filePath: string, routeBlock: CustomRouteBlock | undefined): void;
|
||||
/**
|
||||
* Remove all overrides for a given key.
|
||||
*
|
||||
* @param key - key to remove from the override, e.g. path, name, etc
|
||||
*/
|
||||
removeOverride(key: keyof CustomRouteBlock): void;
|
||||
/**
|
||||
* Add an override to the current node by merging with the existing values.
|
||||
*
|
||||
* @param filePath - The file path to add to the override
|
||||
* @param routeBlock - The route block to add to the override
|
||||
*/
|
||||
mergeOverride(filePath: string, routeBlock: CustomRouteBlock): void;
|
||||
/**
|
||||
* Add an override to the current node using the special file path `@@edits` that makes this added at build time.
|
||||
*
|
||||
* @param routeBlock - The route block to add to the override
|
||||
*/
|
||||
addEditOverride(routeBlock: CustomRouteBlock): void;
|
||||
/**
|
||||
* Set a specific value in the _edits_ override.
|
||||
*
|
||||
* @param key - key to set in the override, e.g. path, name, etc
|
||||
* @param value - value to set in the override
|
||||
*/
|
||||
setEditOverride<K extends keyof RouteRecordOverride>(key: K, value: RouteRecordOverride[K]): void;
|
||||
}
|
||||
/**
|
||||
* - Static
|
||||
* - Static + Custom Param (subSegments)
|
||||
* - Static + Param (subSegments)
|
||||
* - Custom Param
|
||||
* - Param
|
||||
* - CatchAll
|
||||
*/
|
||||
/**
|
||||
* Static path like `/users`, `/users/list`, etc
|
||||
* @extends _TreeNodeValueBase
|
||||
*/
|
||||
declare class TreeNodeValueStatic extends _TreeNodeValueBase {
|
||||
_type: TreeNodeType.static;
|
||||
readonly score: number[];
|
||||
constructor(rawSegment: string, parent: TreeNodeValue | undefined, pathSegment?: string);
|
||||
}
|
||||
declare class TreeNodeValueGroup extends _TreeNodeValueBase {
|
||||
_type: TreeNodeType.group;
|
||||
groupName: string;
|
||||
readonly score: number[];
|
||||
constructor(rawSegment: string, parent: TreeNodeValue | undefined, pathSegment: string, groupName: string);
|
||||
}
|
||||
interface TreePathParam {
|
||||
paramName: string;
|
||||
modifier: string;
|
||||
optional: boolean;
|
||||
repeatable: boolean;
|
||||
isSplat: boolean;
|
||||
parser: string | null;
|
||||
}
|
||||
interface TreeQueryParam {
|
||||
paramName: string;
|
||||
queryKey?: string;
|
||||
parser: string | null;
|
||||
format: 'value' | 'array';
|
||||
/**
|
||||
* Expression to be passed as is to the default value of the param.
|
||||
*/
|
||||
defaultValue?: string;
|
||||
}
|
||||
declare class TreeNodeValueParam extends _TreeNodeValueBase {
|
||||
pathParams: TreePathParam[];
|
||||
_type: TreeNodeType.param;
|
||||
constructor(rawSegment: string, parent: TreeNodeValue | undefined, pathParams: TreePathParam[], pathSegment: string, subSegments: SubSegment[]);
|
||||
get score(): number[];
|
||||
/**
|
||||
* Generates the regex pattern for the path segment.
|
||||
*/
|
||||
get re(): string;
|
||||
toString(): string;
|
||||
}
|
||||
type TreeNodeValue = TreeNodeValueStatic | TreeNodeValueParam | TreeNodeValueGroup;
|
||||
interface TreeNodeValueOptions extends ParseSegmentOptions {
|
||||
/**
|
||||
* Format of the route path. Defaults to `file` which is the format used by unplugin-vue-router and matches the file
|
||||
* structure (e.g. `index`, ``, or `users/[id]`). In `path` format, routes are expected in the format of vue-router
|
||||
* (e.g. `/` or '/users/:id' ).
|
||||
*
|
||||
* @default `'file'`
|
||||
*/
|
||||
format?: 'file' | 'path';
|
||||
}
|
||||
/**
|
||||
* Creates a new TreeNodeValue based on the segment. The result can be a static segment, group segment or a param segment.
|
||||
*
|
||||
* @param segment - path segment
|
||||
* @param parent - parent node
|
||||
* @param options - options
|
||||
*/
|
||||
declare function createTreeNodeValue(segment: string, parent?: TreeNodeValue, opts?: TreeNodeValueOptions): TreeNodeValue;
|
||||
/**
|
||||
* Options passed to `parseSegment()`to control how a segment of a file path is
|
||||
* parsed. e.g. in `/users/[id]`, `users` and `[id]` are segments.
|
||||
*/
|
||||
interface ParseSegmentOptions {
|
||||
/**
|
||||
* Should we allow dot nesting in the param name. e.g. `users.[id]` will be
|
||||
* parsed as `users/[id]` if this is `true`, nesting. Note this only works
|
||||
* for the `file` format.
|
||||
*
|
||||
* @default `true`
|
||||
*/
|
||||
dotNesting?: boolean;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/core/tree.d.ts
|
||||
interface TreeNodeOptions extends ResolvedOptions {
|
||||
treeNodeOptions?: TreeNodeValueOptions;
|
||||
}
|
||||
/**
|
||||
* Parts used by MatcherPatternPathDynamic to match a route.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
type TreeNodeValueMatcherPart = Array<string | number | Array<string | number>>;
|
||||
/**
|
||||
* Makes the `name` property required and a string. Used for readability
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
type TreeNodeNamed = TreeNode & {
|
||||
name: Extract<TreeNode['name'], string>;
|
||||
};
|
||||
declare class TreeNode {
|
||||
/**
|
||||
* value of the node
|
||||
*/
|
||||
value: TreeNodeValue;
|
||||
/**
|
||||
* children of the node
|
||||
*/
|
||||
children: Map<string, TreeNode>;
|
||||
/**
|
||||
* Parent node.
|
||||
*/
|
||||
parent: TreeNode | undefined;
|
||||
/**
|
||||
* Plugin options taken into account by the tree.
|
||||
*/
|
||||
options: TreeNodeOptions;
|
||||
/**
|
||||
* Should this page import the page info
|
||||
*/
|
||||
hasDefinePage: boolean;
|
||||
/**
|
||||
* Creates a new tree node.
|
||||
*
|
||||
* @param options - TreeNodeOptions shared by all nodes
|
||||
* @param pathSegment - path segment of this node e.g. `users` or `:id`
|
||||
* @param parent
|
||||
*/
|
||||
constructor(options: TreeNodeOptions, pathSegment: string, parent?: TreeNode);
|
||||
/**
|
||||
* Adds a path to the tree. `path` cannot start with a `/`.
|
||||
*
|
||||
* @param path - path segment to insert. **It shouldn't contain the file extension**
|
||||
* @param filePath - file path, must be a file (not a folder)
|
||||
*/
|
||||
insert(path: string, filePath: string): TreeNode;
|
||||
/**
|
||||
* Adds a path that has already been parsed to the tree. `path` cannot start with a `/`. This method is similar to
|
||||
* `insert` but the path argument should be already parsed. e.g. `users/:id` for a file named `users/[id].vue`.
|
||||
*
|
||||
* @param path - path segment to insert, already parsed (e.g. users/:id)
|
||||
* @param filePath - file path, defaults to path for convenience and testing
|
||||
*/
|
||||
insertParsedPath(path: string, filePath?: string): TreeNode;
|
||||
/**
|
||||
* Saves a custom route block for a specific file path. The file path is used as a key. Some special file paths will
|
||||
* have a lower or higher priority.
|
||||
*
|
||||
* @param filePath - file path where the custom block is located
|
||||
* @param routeBlock - custom block to set
|
||||
*/
|
||||
setCustomRouteBlock(filePath: string, routeBlock: CustomRouteBlock | undefined): void;
|
||||
/**
|
||||
* Generator that yields all descendants without sorting.
|
||||
* Use with Array.from() for now, native .map() support in Node 22+.
|
||||
*/
|
||||
getChildrenDeep(): Generator<TreeNode>;
|
||||
/**
|
||||
* Comparator function for sorting TreeNodes.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
static compare(a: TreeNode, b: TreeNode): number;
|
||||
/**
|
||||
* Get the children of this node sorted by their path.
|
||||
*/
|
||||
getChildrenSorted(): TreeNode[];
|
||||
/**
|
||||
* Calls {@link getChildrenDeep} and sorts the result by path in the end.
|
||||
*/
|
||||
getChildrenDeepSorted(): TreeNode[];
|
||||
/**
|
||||
* Delete and detach itself from the tree.
|
||||
*/
|
||||
delete(): void;
|
||||
/**
|
||||
* Remove a route from the tree. The path shouldn't start with a `/` but it can be a nested one. e.g. `foo/bar`.
|
||||
* The `path` should be relative to the page folder.
|
||||
*
|
||||
* @param path - path segment of the file
|
||||
*/
|
||||
remove(path: string): void;
|
||||
/**
|
||||
* Returns the route path of the node without parent paths. If the path was overridden, it returns the override.
|
||||
*/
|
||||
get path(): string;
|
||||
/**
|
||||
* Returns the route path of the node including parent paths.
|
||||
*/
|
||||
get fullPath(): string;
|
||||
/**
|
||||
* Object of components (filepaths) for this node.
|
||||
*/
|
||||
get components(): {
|
||||
[k: string]: string;
|
||||
};
|
||||
/**
|
||||
* Does this node render any component?
|
||||
*/
|
||||
get hasComponents(): boolean;
|
||||
/**
|
||||
* Returns the route name of the node. If the name was overridden, it returns the override.
|
||||
*/
|
||||
get name(): string | false;
|
||||
/**
|
||||
* Returns the meta property as an object.
|
||||
*/
|
||||
get metaAsObject(): Readonly<RouteMeta>;
|
||||
/**
|
||||
* Returns the JSON string of the meta object of the node. If the meta was overridden, it returns the override. If
|
||||
* there is no override, it returns an empty string.
|
||||
*/
|
||||
get meta(): string;
|
||||
/**
|
||||
* Array of route params for this node. It includes **all** the params from the parents as well.
|
||||
*/
|
||||
get params(): (TreePathParam | TreeQueryParam)[];
|
||||
/**
|
||||
* Array of route params coming from the path. It includes all the params from the parents as well.
|
||||
*/
|
||||
get pathParams(): TreePathParam[];
|
||||
/**
|
||||
* Array of query params extracted from definePage. Only returns query params from this specific node.
|
||||
*/
|
||||
get queryParams(): TreeQueryParam[];
|
||||
/**
|
||||
* Generates a regexp based on this node and its parents. This regexp is used by the custom resolver
|
||||
*/
|
||||
get regexp(): string;
|
||||
/**
|
||||
* Score of the path used for sorting routes.
|
||||
*/
|
||||
get score(): number[][];
|
||||
/**
|
||||
* Is this node a splat (catch-all) param
|
||||
*/
|
||||
get isSplat(): boolean;
|
||||
/**
|
||||
* Returns an array of matcher parts that is consumed by
|
||||
* MatcherPatternPathDynamic to render the path.
|
||||
*/
|
||||
get matcherPatternPathDynamicParts(): TreeNodeValueMatcherPart;
|
||||
/**
|
||||
* Is this tree node matchable? A matchable node has at least one component
|
||||
* and a name.
|
||||
*/
|
||||
isMatchable(): this is TreeNode & {
|
||||
name: string;
|
||||
};
|
||||
/**
|
||||
* Returns wether this tree node is the root node of the tree.
|
||||
*
|
||||
* @returns true if the node is the root node
|
||||
*/
|
||||
isRoot(): this is PrefixTree;
|
||||
/**
|
||||
* Returns wether this tree node has a name. This allows to coerce the type
|
||||
* of TreeNode
|
||||
*/
|
||||
isNamed(): this is TreeNodeNamed;
|
||||
toString(): string;
|
||||
}
|
||||
/**
|
||||
* Creates a new prefix tree. This is meant to only be the root node. It has access to extra methods that only make
|
||||
* sense on the root node.
|
||||
*/
|
||||
declare class PrefixTree extends TreeNode {
|
||||
map: Map<string, TreeNode>;
|
||||
constructor(options: ResolvedOptions);
|
||||
insert(path: string, filePath: string): TreeNode;
|
||||
/**
|
||||
* Returns the tree node of the given file path.
|
||||
*
|
||||
* @param filePath - file path of the tree node to get
|
||||
*/
|
||||
getChild(filePath: string): TreeNode | undefined;
|
||||
/**
|
||||
* Removes the tree node of the given file path.
|
||||
*
|
||||
* @param filePath - file path of the tree node to remove
|
||||
*/
|
||||
removeChild(filePath: string): void;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/core/utils.d.ts
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
declare function getPascalCaseRouteName(node: TreeNode): string;
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
declare function getFileBasedRouteName(node: TreeNode): string;
|
||||
//#endregion
|
||||
//#region src/core/extendRoutes.d.ts
|
||||
/**
|
||||
* A route node that can be modified by the user. The tree can be iterated to be traversed.
|
||||
* @example
|
||||
* ```js
|
||||
* [...node] // creates an array of all the children
|
||||
* for (const child of node) {
|
||||
* // do something with the child node
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
declare class EditableTreeNode {
|
||||
private node;
|
||||
constructor(node: TreeNode);
|
||||
/**
|
||||
* Remove and detach the current route node from the tree. Subsequently, its children will be removed as well.
|
||||
*/
|
||||
delete(): void;
|
||||
/**
|
||||
* Inserts a new route as a child of this route. This route cannot use `definePage()`. If it was meant to be included,
|
||||
* add it to the `routesFolder` option.
|
||||
*
|
||||
* @param path - path segment to insert. Note this is relative to the current route. **It shouldn't start with `/`**. If it does, it will be added to the root of the tree.
|
||||
* @param filePath - file path
|
||||
* @returns the new editable route node
|
||||
*/
|
||||
insert(path: string, filePath: string): EditableTreeNode;
|
||||
/**
|
||||
* Get an editable version of the parent node if it exists.
|
||||
*/
|
||||
get parent(): EditableTreeNode | undefined;
|
||||
/**
|
||||
* Return a Map of the files associated to the current route. The key of the map represents the name of the view (Vue
|
||||
* Router feature) while the value is the **resolved** file path.
|
||||
* By default, the name of the view is `default`.
|
||||
*/
|
||||
get components(): Map<string, string>;
|
||||
/**
|
||||
* Alias for `route.components.get('default')`.
|
||||
*/
|
||||
get component(): string | undefined;
|
||||
/**
|
||||
* Name of the route. Note that **all routes are named** but when the final `routes` array is generated, routes
|
||||
* without a `component` will not include their `name` property to avoid accidentally navigating to them and display
|
||||
* nothing.
|
||||
* @see {@link isPassThrough}
|
||||
*/
|
||||
get name(): string | false;
|
||||
/**
|
||||
* Override the name of the route.
|
||||
*/
|
||||
set name(name: string | undefined);
|
||||
/**
|
||||
* Whether the route is a pass-through route. A pass-through route is a route that does not have a component and is
|
||||
* used to group other routes under the same prefix `path` and/or `meta` properties.
|
||||
*/
|
||||
get isPassThrough(): boolean;
|
||||
/**
|
||||
* Meta property of the route as an object. Note this property is readonly and will be serialized as JSON. It won't contain the meta properties defined with `definePage()` as it could contain expressions **but it does contain the meta properties defined with `<route>` blocks**.
|
||||
*/
|
||||
get meta(): Readonly<RouteMeta>;
|
||||
/**
|
||||
* Override the meta property of the route. This will discard any other meta property defined with `<route>` blocks or
|
||||
* through other means. If you want to keep the existing meta properties, use `addToMeta`.
|
||||
* @see {@link addToMeta}
|
||||
*/
|
||||
set meta(meta: RouteMeta);
|
||||
/**
|
||||
* Add meta properties to the route keeping the existing ones. The passed object will be deeply merged with the
|
||||
* existing meta object if any. Note that the meta property is later on serialized as JSON so you can't pass functions
|
||||
* or any other non-serializable value.
|
||||
*/
|
||||
addToMeta(meta: Partial<RouteMeta>): void;
|
||||
/**
|
||||
* Path of the route without parent paths.
|
||||
*/
|
||||
get path(): string;
|
||||
/**
|
||||
* Override the path of the route. You must ensure `params` match with the existing path.
|
||||
*/
|
||||
set path(path: string);
|
||||
/**
|
||||
* Alias of the route.
|
||||
*/
|
||||
get alias(): string | string[] | undefined;
|
||||
/**
|
||||
* Add an alias to the route.
|
||||
*
|
||||
* @param alias - Alias to add to the route
|
||||
*/
|
||||
addAlias(alias: CustomRouteBlock['alias']): void;
|
||||
/**
|
||||
* Array of the route params and all of its parent's params. Note that
|
||||
* changing the params will not update the path, you need to update both.
|
||||
*/
|
||||
get params(): TreePathParam[];
|
||||
/**
|
||||
* Path of the route including parent paths.
|
||||
*/
|
||||
get fullPath(): string;
|
||||
/**
|
||||
* Computes an array of EditableTreeNode from the current node. Differently from iterating over the tree, this method
|
||||
* **only returns direct children**.
|
||||
*/
|
||||
get children(): EditableTreeNode[];
|
||||
/**
|
||||
* DFS traversal of the tree.
|
||||
* @example
|
||||
* ```ts
|
||||
* for (const node of tree) {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
traverseDFS(): Generator<EditableTreeNode, void, unknown>;
|
||||
[Symbol.iterator](): Generator<EditableTreeNode, void, unknown>;
|
||||
/**
|
||||
* BFS traversal of the tree as a generator.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* for (const node of tree) {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
traverseBFS(): Generator<EditableTreeNode, void, unknown>;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/utils/index.d.ts
|
||||
/**
|
||||
* Maybe a promise maybe not
|
||||
* @internal
|
||||
*/
|
||||
type _Awaitable<T> = T | PromiseLike<T>;
|
||||
//#endregion
|
||||
//#region src/options.d.ts
|
||||
/**
|
||||
* Options for a routes folder.
|
||||
*/
|
||||
interface RoutesFolderOption {
|
||||
/**
|
||||
* Folder to scan files that should be used for routes. **Cannot be a glob**, use the `path`, `filePatterns`, and
|
||||
* `exclude` options to filter out files. This section will **be removed** from the resulting path.
|
||||
*/
|
||||
src: string;
|
||||
/**
|
||||
* Prefix to add to the route path **as is**. Defaults to `''`. Can also be a function
|
||||
* to reuse parts of the filepath, in that case you should return a **modified version of the filepath**.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* {
|
||||
* src: 'src/pages',
|
||||
* // this is equivalent to the default behavior
|
||||
* path: (file) => file.slice(file.lastIndexOf('src/pages') + 'src/pages'.length
|
||||
* },
|
||||
* {
|
||||
* src: 'src/features',
|
||||
* // match all files (note the \ is not needed in real code)
|
||||
* filePatterns: '*/pages/**\/',
|
||||
* path: (file) => {
|
||||
* const prefix = 'src/features'
|
||||
* // remove the everything before src/features and removes /pages
|
||||
* // /src/features/feature1/pages/index.vue -> feature1/index.vue
|
||||
* return file.slice(file.lastIndexOf(prefix) + prefix.length + 1).replace('/pages', '')
|
||||
* },
|
||||
* },
|
||||
* {
|
||||
* src: 'src/docs',
|
||||
* // adds a prefix with a param
|
||||
* path: 'docs/[lang]/',
|
||||
* },
|
||||
* ```
|
||||
*/
|
||||
path?: string | ((filepath: string) => string);
|
||||
/**
|
||||
* Allows to override the global `filePattern` option for this folder. It can also extend the global values by passing
|
||||
* a function that returns an array.
|
||||
*/
|
||||
filePatterns?: _OverridableOption<string[], string | string[]>;
|
||||
/**
|
||||
* Allows to override the global `exclude` option for this folder. It can
|
||||
* also extend the global values by passing a function that returns an array.
|
||||
*/
|
||||
exclude?: _OverridableOption<string[], string | string[]>;
|
||||
/**
|
||||
* Allows to override the global `extensions` option for this folder. It can
|
||||
* also extend the global values by passing a function that returns an array.
|
||||
* The provided extensions are removed from the final route. For example,
|
||||
* `.page.vue` allows to suffix all pages with `.page.vue` and remove it from
|
||||
* the route name.
|
||||
*/
|
||||
extensions?: _OverridableOption<string[]>;
|
||||
}
|
||||
/**
|
||||
* Normalized options for a routes folder.
|
||||
*/
|
||||
interface RoutesFolderOptionResolved extends RoutesFolderOption {
|
||||
path: string | ((filepath: string) => string);
|
||||
/**
|
||||
* Final glob pattern to match files in the folder.
|
||||
*/
|
||||
pattern: string[];
|
||||
filePatterns: string[];
|
||||
exclude: string[];
|
||||
extensions: string[];
|
||||
}
|
||||
type _OverridableOption<T, AllowedTypes = T> = AllowedTypes | ((existing: T) => T);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
declare function resolveOverridableOption<T>(defaultValue: T, value?: _OverridableOption<T, T>): T;
|
||||
type _RoutesFolder = string | RoutesFolderOption;
|
||||
type RoutesFolder = _RoutesFolder[] | _RoutesFolder;
|
||||
/**
|
||||
* unplugin-vue-router plugin options.
|
||||
*/
|
||||
interface Options {
|
||||
/**
|
||||
* Extensions of files to be considered as pages. Cannot be empty. This allows to strip a
|
||||
* bigger part of the filename e.g. `index.page.vue` -> `index` if an extension of `.page.vue` is provided.
|
||||
* @default `['.vue']`
|
||||
*/
|
||||
extensions?: string[];
|
||||
/**
|
||||
* Folder(s) to scan for files and generate routes. Can also be an array if you want to add multiple
|
||||
* folders, or an object if you want to define a route prefix. Supports glob patterns but must be a folder, use
|
||||
* `extensions` and `exclude` to filter files.
|
||||
*
|
||||
* @default `"src/pages"`
|
||||
*/
|
||||
routesFolder?: RoutesFolder;
|
||||
/**
|
||||
* Array of `picomatch` globs to ignore. Note the globs are relative to the cwd, so avoid writing
|
||||
* something like `['ignored']` to match folders named that way, instead provide a path similar to the `routesFolder`:
|
||||
* `['src/pages/ignored/**']` or use `['**/ignored']` to match every folder named `ignored`.
|
||||
* @default `[]`
|
||||
*/
|
||||
exclude?: string[] | string;
|
||||
/**
|
||||
* Pattern to match files in the `routesFolder`. Defaults to `*\/*` plus a
|
||||
* combination of all the possible extensions, e.g. `*\/*.{vue,md}` if
|
||||
* `extensions` is set to `['.vue', '.md']`. This is relative to the {@link
|
||||
* RoutesFolderOption['src']} and
|
||||
*
|
||||
* @default `['*\/*']`
|
||||
*/
|
||||
filePatterns?: string[] | string;
|
||||
/**
|
||||
* Method to generate the name of a route. It's recommended to keep the default value to guarantee a consistent,
|
||||
* unique, and predictable naming.
|
||||
*/
|
||||
getRouteName?: (node: TreeNode) => string;
|
||||
/**
|
||||
* Allows to extend a route by modifying its node, adding children, or even deleting it. This will be invoked once for
|
||||
* each route.
|
||||
*
|
||||
* @param route - {@link EditableTreeNode} of the route to extend
|
||||
*/
|
||||
extendRoute?: (route: EditableTreeNode) => _Awaitable<void>;
|
||||
/**
|
||||
* Allows to do some changes before writing the files. This will be invoked **every time** the files need to be written.
|
||||
*
|
||||
* @param rootRoute - {@link EditableTreeNode} of the root route
|
||||
*/
|
||||
beforeWriteFiles?: (rootRoute: EditableTreeNode) => _Awaitable<void>;
|
||||
/**
|
||||
* Defines how page components should be imported. Defaults to dynamic imports to enable lazy loading of pages.
|
||||
* @default `'async'`
|
||||
*/
|
||||
importMode?: 'sync' | 'async' | ((filepath: string) => 'sync' | 'async');
|
||||
/**
|
||||
* Root of the project. All paths are resolved relatively to this one.
|
||||
* @default `process.cwd()`
|
||||
*/
|
||||
root?: string;
|
||||
/**
|
||||
* Language for `<route>` blocks in SFC files.
|
||||
* @default `'json5'`
|
||||
*/
|
||||
routeBlockLang?: 'yaml' | 'yml' | 'json5' | 'json';
|
||||
/**
|
||||
* Should we generate d.ts files or ont. Defaults to `true` if `typescript` is installed. Can be set to a string of
|
||||
* the filepath to write the d.ts files to. By default it will generate a file named `typed-router.d.ts`.
|
||||
* @default `true`
|
||||
*/
|
||||
dts?: boolean | string;
|
||||
/**
|
||||
* Allows inspection by vite-plugin-inspect by not adding the leading `\0` to the id of virtual modules.
|
||||
* @internal
|
||||
*/
|
||||
_inspect?: boolean;
|
||||
/**
|
||||
* Activates debug logs.
|
||||
*/
|
||||
logs?: boolean;
|
||||
/**
|
||||
* @inheritDoc ParseSegmentOptions
|
||||
*/
|
||||
pathParser?: ParseSegmentOptions;
|
||||
/**
|
||||
* Whether to watch the files for changes.
|
||||
*
|
||||
* Defaults to `true` unless the `CI` environment variable is set.
|
||||
*
|
||||
* @default `!process.env.CI`
|
||||
*/
|
||||
watch?: boolean;
|
||||
/**
|
||||
* Experimental options. **Warning**: these can change or be removed at any time, even it patch releases. Keep an eye
|
||||
* on the Changelog.
|
||||
*/
|
||||
experimental?: {
|
||||
/**
|
||||
* (Vite only). File paths or globs where loaders are exported. This will be used to filter out imported loaders and
|
||||
* automatically re export them in page components. You can for example set this to `'src/loaders/**\/*'` (without
|
||||
* the backslash) to automatically re export any imported variable from files in the `src/loaders` folder within a
|
||||
* page component.
|
||||
*/
|
||||
autoExportsDataLoaders?: string | string[];
|
||||
/**
|
||||
* Enable experimental support for the new custom resolvers and allows
|
||||
* defining custom param matchers.
|
||||
*/
|
||||
paramParsers?: boolean | ParamParsersOptions;
|
||||
};
|
||||
}
|
||||
interface ParamParsersOptions {
|
||||
/**
|
||||
* Folder(s) to scan for param matchers. Set to an empty array to disable the feature.
|
||||
*
|
||||
* @default `['src/params']`
|
||||
*/
|
||||
dir?: string | string[];
|
||||
}
|
||||
declare const DEFAULT_PARAM_PARSERS_OPTIONS: {
|
||||
dir: string[];
|
||||
};
|
||||
declare const DEFAULT_OPTIONS: {
|
||||
extensions: string[];
|
||||
exclude: never[];
|
||||
routesFolder: string;
|
||||
filePatterns: string[];
|
||||
routeBlockLang: "json5";
|
||||
getRouteName: typeof getFileBasedRouteName;
|
||||
importMode: "async";
|
||||
root: string;
|
||||
dts: boolean;
|
||||
logs: false;
|
||||
_inspect: false;
|
||||
pathParser: {
|
||||
dotNesting: true;
|
||||
};
|
||||
watch: boolean;
|
||||
experimental: {};
|
||||
};
|
||||
interface ServerContext {
|
||||
/**
|
||||
* Invalidates a module by its id.
|
||||
* @param module - module id to invalidate
|
||||
*
|
||||
* @returns A promise that resolves when the module is invalidated, or `false` if the module was not found.
|
||||
*/
|
||||
invalidate: (module: string) => Promise<void> | false;
|
||||
/**
|
||||
* Invalidates all modules associated with a page file.
|
||||
* @param filepath - file path of the page to invalidate
|
||||
*
|
||||
* @returns A promise that resolves when the page is invalidated, or `false` if no modules were found for the page.
|
||||
*/
|
||||
invalidatePage: (filepath: string) => Promise<void> | false;
|
||||
/**
|
||||
* Triggers HMR for the routes module.
|
||||
*/
|
||||
updateRoutes: () => Promise<void>;
|
||||
/**
|
||||
* Triggers a full page reload.
|
||||
*/
|
||||
reload: () => void;
|
||||
}
|
||||
/**
|
||||
* Normalize user options with defaults and resolved paths.
|
||||
*
|
||||
* @param options - user provided options
|
||||
* @returns normalized options
|
||||
*/
|
||||
declare function resolveOptions(options: Options): {
|
||||
experimental: {
|
||||
autoExportsDataLoaders: string[] | undefined;
|
||||
paramParsers: {
|
||||
dir: string[];
|
||||
} | undefined;
|
||||
};
|
||||
routesFolder: {
|
||||
src: string;
|
||||
filePatterns: string[] | ((existing: string[]) => string[]) | undefined;
|
||||
exclude: string[] | ((existing: string[]) => string[]) | undefined;
|
||||
/**
|
||||
* Prefix to add to the route path **as is**. Defaults to `''`. Can also be a function
|
||||
* to reuse parts of the filepath, in that case you should return a **modified version of the filepath**.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* {
|
||||
* src: 'src/pages',
|
||||
* // this is equivalent to the default behavior
|
||||
* path: (file) => file.slice(file.lastIndexOf('src/pages') + 'src/pages'.length
|
||||
* },
|
||||
* {
|
||||
* src: 'src/features',
|
||||
* // match all files (note the \ is not needed in real code)
|
||||
* filePatterns: '*/pages/**\/',
|
||||
* path: (file) => {
|
||||
* const prefix = 'src/features'
|
||||
* // remove the everything before src/features and removes /pages
|
||||
* // /src/features/feature1/pages/index.vue -> feature1/index.vue
|
||||
* return file.slice(file.lastIndexOf(prefix) + prefix.length + 1).replace('/pages', '')
|
||||
* },
|
||||
* },
|
||||
* {
|
||||
* src: 'src/docs',
|
||||
* // adds a prefix with a param
|
||||
* path: 'docs/[lang]/',
|
||||
* },
|
||||
* ```
|
||||
*/
|
||||
path?: string | ((filepath: string) => string);
|
||||
/**
|
||||
* Allows to override the global `extensions` option for this folder. It can
|
||||
* also extend the global values by passing a function that returns an array.
|
||||
* The provided extensions are removed from the final route. For example,
|
||||
* `.page.vue` allows to suffix all pages with `.page.vue` and remove it from
|
||||
* the route name.
|
||||
*/
|
||||
extensions?: _OverridableOption<string[]>;
|
||||
}[];
|
||||
filePatterns: string[];
|
||||
exclude: string[];
|
||||
extensions: string[];
|
||||
getRouteName: typeof getFileBasedRouteName;
|
||||
/**
|
||||
* Allows to extend a route by modifying its node, adding children, or even deleting it. This will be invoked once for
|
||||
* each route.
|
||||
*
|
||||
* @param route - {@link EditableTreeNode} of the route to extend
|
||||
*/
|
||||
extendRoute?: (route: EditableTreeNode) => _Awaitable<void>;
|
||||
/**
|
||||
* Allows to do some changes before writing the files. This will be invoked **every time** the files need to be written.
|
||||
*
|
||||
* @param rootRoute - {@link EditableTreeNode} of the root route
|
||||
*/
|
||||
beforeWriteFiles?: (rootRoute: EditableTreeNode) => _Awaitable<void>;
|
||||
importMode: "sync" | "async" | ((filepath: string) => "sync" | "async");
|
||||
root: string;
|
||||
routeBlockLang: "yaml" | "yml" | "json5" | "json";
|
||||
dts: boolean | string;
|
||||
_inspect: boolean;
|
||||
logs: boolean;
|
||||
pathParser: ParseSegmentOptions;
|
||||
watch: boolean;
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type ResolvedOptions = ReturnType<typeof resolveOptions>;
|
||||
/**
|
||||
* Merge all the possible extensions as an array of unique values
|
||||
* @param options - user provided options
|
||||
* @internal
|
||||
*/
|
||||
declare function mergeAllExtensions(options: ResolvedOptions): string[];
|
||||
//#endregion
|
||||
export { createTreeNodeValue as C, TreeNodeValueStatic as S, getPascalCaseRouteName as _, ResolvedOptions as a, TreeNodeValueGroup as b, RoutesFolderOptionResolved as c, _RoutesFolder as d, mergeAllExtensions as f, getFileBasedRouteName as g, EditableTreeNode as h, ParamParsersOptions as i, ServerContext as l, resolveOverridableOption as m, DEFAULT_PARAM_PARSERS_OPTIONS as n, RoutesFolder as o, resolveOptions as p, Options as r, RoutesFolderOption as s, DEFAULT_OPTIONS as t, _OverridableOption as u, TreeNode as v, TreeNodeValueParam as x, TreeNodeValue as y };
|
||||
311
Frontend-Learner/node_modules/unplugin-vue-router/dist/options-CAGVi1wo.mjs
generated
vendored
Normal file
311
Frontend-Learner/node_modules/unplugin-vue-router/dist/options-CAGVi1wo.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,311 @@
|
|||
import { pascalCase } from "scule";
|
||||
import { resolve } from "pathe";
|
||||
import { isPackageExists } from "local-pkg";
|
||||
|
||||
//#region src/core/utils.ts
|
||||
function warn(msg, type = "warn") {
|
||||
console[type](`⚠️ [unplugin-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$1, extensions) {
|
||||
for (const extension of extensions) {
|
||||
const lastDot = path$1.endsWith(extension) ? -extension.length : 0;
|
||||
if (lastDot < 0) return path$1.slice(0, lastDot);
|
||||
}
|
||||
return path$1;
|
||||
}
|
||||
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$1 of paths) result = result.replace(TRAILING_SLASH_RE, "") + (path$1 && "/" + path$1.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: path$1 = "", extensions }, filePath) {
|
||||
return trimExtension(typeof path$1 === "string" ? path$1 + filePath.slice(src.length + 1) : path$1(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$1, importEntry) {
|
||||
if (!this.map.has(path$1)) this.map.set(path$1, /* @__PURE__ */ new Map());
|
||||
const imports = this.map.get(path$1);
|
||||
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$1, name) {
|
||||
return this.map.has(path$1) && this.map.get(path$1).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$1, as) {
|
||||
return this.add(path$1, {
|
||||
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$1) {
|
||||
if (!this.map.has(path$1)) return [];
|
||||
return Array.from(this.map.get(path$1)).map(([as, name]) => ({
|
||||
as: as || name,
|
||||
name
|
||||
}));
|
||||
}
|
||||
toString() {
|
||||
let importStatements = "";
|
||||
for (const [path$1, imports] of this.map) {
|
||||
if (!imports.size) continue;
|
||||
if (imports.size === 1) {
|
||||
const [[importName, maybeDefault]] = [...imports.entries()];
|
||||
if (maybeDefault === "default") {
|
||||
importStatements += `import ${importName} from '${path$1}'\n`;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
importStatements += `import { ${Array.from(imports).map(([as, name]) => as === name ? name : `${name} as ${as}`).join(", ")} } from '${path$1}'\n`;
|
||||
}
|
||||
return importStatements;
|
||||
}
|
||||
get size() {
|
||||
return this.map.size;
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/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
|
||||
*/
|
||||
function resolveOverridableOption(defaultValue, value) {
|
||||
return typeof value === "function" ? value(defaultValue) : value ?? defaultValue;
|
||||
}
|
||||
const DEFAULT_PARAM_PARSERS_OPTIONS = { dir: ["src/params"] };
|
||||
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 autoExportsDataLoaders = options.experimental?.autoExportsDataLoaders ? (isArray(options.experimental.autoExportsDataLoaders) ? options.experimental.autoExportsDataLoaders : [options.experimental.autoExportsDataLoaders]).map((path$1) => resolve(root, path$1)) : void 0;
|
||||
const experimental = {
|
||||
...options.experimental,
|
||||
autoExportsDataLoaders,
|
||||
paramParsers: paramParsers && {
|
||||
...paramParsers,
|
||||
dir: paramParsersDir
|
||||
}
|
||||
};
|
||||
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 { resolveOverridableOption as a, 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 };
|
||||
407
Frontend-Learner/node_modules/unplugin-vue-router/dist/options-CpfNkO-E.cjs
generated
vendored
Normal file
407
Frontend-Learner/node_modules/unplugin-vue-router/dist/options-CpfNkO-E.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,407 @@
|
|||
const require_src = require('./src-DKnuUuX8.cjs');
|
||||
let scule = require("scule");
|
||||
let pathe = require("pathe");
|
||||
let local_pkg = require("local-pkg");
|
||||
|
||||
//#region src/core/utils.ts
|
||||
function warn(msg, type = "warn") {
|
||||
console[type](`⚠️ [unplugin-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;
|
||||
if (imports.size === 1) {
|
||||
const [[importName, maybeDefault]] = [...imports.entries()];
|
||||
if (maybeDefault === "default") {
|
||||
importStatements += `import ${importName} from '${path}'\n`;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
importStatements += `import { ${Array.from(imports).map(([as, name]) => as === name ? name : `${name} as ${as}`).join(", ")} } from '${path}'\n`;
|
||||
}
|
||||
return importStatements;
|
||||
}
|
||||
get size() {
|
||||
return this.map.size;
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/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
|
||||
*/
|
||||
function resolveOverridableOption(defaultValue, value) {
|
||||
return typeof value === "function" ? value(defaultValue) : value ?? defaultValue;
|
||||
}
|
||||
const DEFAULT_PARAM_PARSERS_OPTIONS = { dir: ["src/params"] };
|
||||
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 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
|
||||
}
|
||||
};
|
||||
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, '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, '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, 'warn', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return warn;
|
||||
}
|
||||
});
|
||||
933
Frontend-Learner/node_modules/unplugin-vue-router/dist/options-DG3niQXy.d.mts
generated
vendored
Normal file
933
Frontend-Learner/node_modules/unplugin-vue-router/dist/options-DG3niQXy.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,933 @@
|
|||
import { RouteMeta, RouteRecordRaw, TypesConfig } from "vue-router";
|
||||
|
||||
//#region src/runtime.d.ts
|
||||
|
||||
type ParamParserType_Native = 'int' | 'bool';
|
||||
type ParamParserType = (TypesConfig extends Record<'ParamParsers', infer ParamParsers> ? ParamParsers : never) | ParamParserType_Native;
|
||||
/**
|
||||
* Configures how to extract a route param from a specific query parameter.
|
||||
*/
|
||||
interface DefinePageQueryParamOptions<T = unknown> {
|
||||
/**
|
||||
* The type of the query parameter. Allowed values are native param parsers
|
||||
* and any parser in the {@link https://uvr.esm.is/TODO | params folder }. If
|
||||
* not provided, the value will kept as is.
|
||||
*/
|
||||
parser?: ParamParserType;
|
||||
/**
|
||||
* Default value if the query parameter is missing or if the match fails
|
||||
* (e.g. a invalid number is passed to the int param parser). If not provided
|
||||
* and the param parser throws, the route will not match.
|
||||
*/
|
||||
default?: (() => T) | T;
|
||||
/**
|
||||
* How to format the query parameter value.
|
||||
*
|
||||
* - 'value' - keep the first value only and pass that to parser
|
||||
* - 'array' - keep all values (even one or none) as an array and pass that to parser
|
||||
*
|
||||
* @default 'value'
|
||||
*/
|
||||
format?: 'value' | 'array';
|
||||
}
|
||||
//#endregion
|
||||
//#region src/core/customBlock.d.ts
|
||||
interface CustomRouteBlock extends Partial<Omit<RouteRecordRaw, 'components' | 'component' | 'children' | 'beforeEnter' | 'name'>> {
|
||||
name?: string | undefined | false;
|
||||
params?: {
|
||||
path?: Record<string, string>;
|
||||
query?: Record<string, string | CustomRouteBlockQueryParamOptions>;
|
||||
};
|
||||
}
|
||||
interface CustomRouteBlockQueryParamOptions {
|
||||
parser?: string;
|
||||
format?: DefinePageQueryParamOptions['format'];
|
||||
default?: string;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/core/treeNodeValue.d.ts
|
||||
declare const enum TreeNodeType {
|
||||
static = 0,
|
||||
group = 1,
|
||||
param = 2,
|
||||
}
|
||||
interface RouteRecordOverride extends Partial<Pick<RouteRecordRaw, 'meta' | 'props' | 'alias' | 'path'>> {
|
||||
name?: string | undefined | false;
|
||||
/**
|
||||
* Param Parsers information.
|
||||
*/
|
||||
params?: {
|
||||
path?: Record<string, string>;
|
||||
query?: Record<string, string | RouteRecordOverrideQueryParamOptions>;
|
||||
};
|
||||
}
|
||||
interface RouteRecordOverrideQueryParamOptions extends CustomRouteBlockQueryParamOptions {
|
||||
default?: string;
|
||||
}
|
||||
type SubSegment = string | TreePathParam;
|
||||
declare class _TreeNodeValueBase {
|
||||
/**
|
||||
* flag based on the type of the segment
|
||||
*/
|
||||
_type: TreeNodeType;
|
||||
parent: TreeNodeValue | undefined;
|
||||
/**
|
||||
* segment as defined by the file structure e.g. keeps the `index` name, `(group-name)`
|
||||
*/
|
||||
rawSegment: string;
|
||||
/**
|
||||
* transformed version of the segment into a vue-router path. e.g. `'index'` becomes `''` and `[param]` becomes
|
||||
* `:param`, `prefix-[param]-end` becomes `prefix-:param-end`.
|
||||
*/
|
||||
pathSegment: string;
|
||||
/**
|
||||
* Array of sub segments. This is usually one single elements but can have more for paths like `prefix-[param]-end.vue`
|
||||
*/
|
||||
subSegments: SubSegment[];
|
||||
/**
|
||||
* Overrides defined by each file. The map is necessary to handle named views.
|
||||
*/
|
||||
private _overrides;
|
||||
/**
|
||||
* View name (Vue Router feature) mapped to their corresponding file. By default, the view name is `default` unless
|
||||
* specified with a `@` e.g. `index@aux.vue` will have a view name of `aux`.
|
||||
*/
|
||||
components: Map<string, string>;
|
||||
constructor(rawSegment: string, parent: TreeNodeValue | undefined, pathSegment?: string, subSegments?: SubSegment[]);
|
||||
/**
|
||||
* Path of the node. Can be absolute or not. If it has been overridden, it
|
||||
* will return the overridden path.
|
||||
*/
|
||||
get path(): string;
|
||||
/**
|
||||
* Full path of the node including parent nodes.
|
||||
*/
|
||||
get fullPath(): string;
|
||||
/**
|
||||
* Gets all the query params for the node. This does not include params from parent nodes.
|
||||
*/
|
||||
get queryParams(): TreeQueryParam[];
|
||||
/**
|
||||
* Gets all the params for the node including path and query params. This
|
||||
* does not include params from parent nodes.
|
||||
*/
|
||||
get params(): (TreePathParam | TreeQueryParam)[];
|
||||
toString(): string;
|
||||
isParam(): this is TreeNodeValueParam;
|
||||
isStatic(): this is TreeNodeValueStatic;
|
||||
isGroup(): this is TreeNodeValueGroup;
|
||||
get overrides(): RouteRecordOverride;
|
||||
setOverride(filePath: string, routeBlock: CustomRouteBlock | undefined): void;
|
||||
/**
|
||||
* Remove all overrides for a given key.
|
||||
*
|
||||
* @param key - key to remove from the override, e.g. path, name, etc
|
||||
*/
|
||||
removeOverride(key: keyof CustomRouteBlock): void;
|
||||
/**
|
||||
* Add an override to the current node by merging with the existing values.
|
||||
*
|
||||
* @param filePath - The file path to add to the override
|
||||
* @param routeBlock - The route block to add to the override
|
||||
*/
|
||||
mergeOverride(filePath: string, routeBlock: CustomRouteBlock): void;
|
||||
/**
|
||||
* Add an override to the current node using the special file path `@@edits` that makes this added at build time.
|
||||
*
|
||||
* @param routeBlock - The route block to add to the override
|
||||
*/
|
||||
addEditOverride(routeBlock: CustomRouteBlock): void;
|
||||
/**
|
||||
* Set a specific value in the _edits_ override.
|
||||
*
|
||||
* @param key - key to set in the override, e.g. path, name, etc
|
||||
* @param value - value to set in the override
|
||||
*/
|
||||
setEditOverride<K extends keyof RouteRecordOverride>(key: K, value: RouteRecordOverride[K]): void;
|
||||
}
|
||||
/**
|
||||
* - Static
|
||||
* - Static + Custom Param (subSegments)
|
||||
* - Static + Param (subSegments)
|
||||
* - Custom Param
|
||||
* - Param
|
||||
* - CatchAll
|
||||
*/
|
||||
/**
|
||||
* Static path like `/users`, `/users/list`, etc
|
||||
* @extends _TreeNodeValueBase
|
||||
*/
|
||||
declare class TreeNodeValueStatic extends _TreeNodeValueBase {
|
||||
_type: TreeNodeType.static;
|
||||
readonly score: number[];
|
||||
constructor(rawSegment: string, parent: TreeNodeValue | undefined, pathSegment?: string);
|
||||
}
|
||||
declare class TreeNodeValueGroup extends _TreeNodeValueBase {
|
||||
_type: TreeNodeType.group;
|
||||
groupName: string;
|
||||
readonly score: number[];
|
||||
constructor(rawSegment: string, parent: TreeNodeValue | undefined, pathSegment: string, groupName: string);
|
||||
}
|
||||
interface TreePathParam {
|
||||
paramName: string;
|
||||
modifier: string;
|
||||
optional: boolean;
|
||||
repeatable: boolean;
|
||||
isSplat: boolean;
|
||||
parser: string | null;
|
||||
}
|
||||
interface TreeQueryParam {
|
||||
paramName: string;
|
||||
queryKey?: string;
|
||||
parser: string | null;
|
||||
format: 'value' | 'array';
|
||||
/**
|
||||
* Expression to be passed as is to the default value of the param.
|
||||
*/
|
||||
defaultValue?: string;
|
||||
}
|
||||
declare class TreeNodeValueParam extends _TreeNodeValueBase {
|
||||
pathParams: TreePathParam[];
|
||||
_type: TreeNodeType.param;
|
||||
constructor(rawSegment: string, parent: TreeNodeValue | undefined, pathParams: TreePathParam[], pathSegment: string, subSegments: SubSegment[]);
|
||||
get score(): number[];
|
||||
/**
|
||||
* Generates the regex pattern for the path segment.
|
||||
*/
|
||||
get re(): string;
|
||||
toString(): string;
|
||||
}
|
||||
type TreeNodeValue = TreeNodeValueStatic | TreeNodeValueParam | TreeNodeValueGroup;
|
||||
interface TreeNodeValueOptions extends ParseSegmentOptions {
|
||||
/**
|
||||
* Format of the route path. Defaults to `file` which is the format used by unplugin-vue-router and matches the file
|
||||
* structure (e.g. `index`, ``, or `users/[id]`). In `path` format, routes are expected in the format of vue-router
|
||||
* (e.g. `/` or '/users/:id' ).
|
||||
*
|
||||
* @default `'file'`
|
||||
*/
|
||||
format?: 'file' | 'path';
|
||||
}
|
||||
/**
|
||||
* Creates a new TreeNodeValue based on the segment. The result can be a static segment, group segment or a param segment.
|
||||
*
|
||||
* @param segment - path segment
|
||||
* @param parent - parent node
|
||||
* @param options - options
|
||||
*/
|
||||
declare function createTreeNodeValue(segment: string, parent?: TreeNodeValue, opts?: TreeNodeValueOptions): TreeNodeValue;
|
||||
/**
|
||||
* Options passed to `parseSegment()`to control how a segment of a file path is
|
||||
* parsed. e.g. in `/users/[id]`, `users` and `[id]` are segments.
|
||||
*/
|
||||
interface ParseSegmentOptions {
|
||||
/**
|
||||
* Should we allow dot nesting in the param name. e.g. `users.[id]` will be
|
||||
* parsed as `users/[id]` if this is `true`, nesting. Note this only works
|
||||
* for the `file` format.
|
||||
*
|
||||
* @default `true`
|
||||
*/
|
||||
dotNesting?: boolean;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/core/tree.d.ts
|
||||
interface TreeNodeOptions extends ResolvedOptions {
|
||||
treeNodeOptions?: TreeNodeValueOptions;
|
||||
}
|
||||
/**
|
||||
* Parts used by MatcherPatternPathDynamic to match a route.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
type TreeNodeValueMatcherPart = Array<string | number | Array<string | number>>;
|
||||
/**
|
||||
* Makes the `name` property required and a string. Used for readability
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
type TreeNodeNamed = TreeNode & {
|
||||
name: Extract<TreeNode['name'], string>;
|
||||
};
|
||||
declare class TreeNode {
|
||||
/**
|
||||
* value of the node
|
||||
*/
|
||||
value: TreeNodeValue;
|
||||
/**
|
||||
* children of the node
|
||||
*/
|
||||
children: Map<string, TreeNode>;
|
||||
/**
|
||||
* Parent node.
|
||||
*/
|
||||
parent: TreeNode | undefined;
|
||||
/**
|
||||
* Plugin options taken into account by the tree.
|
||||
*/
|
||||
options: TreeNodeOptions;
|
||||
/**
|
||||
* Should this page import the page info
|
||||
*/
|
||||
hasDefinePage: boolean;
|
||||
/**
|
||||
* Creates a new tree node.
|
||||
*
|
||||
* @param options - TreeNodeOptions shared by all nodes
|
||||
* @param pathSegment - path segment of this node e.g. `users` or `:id`
|
||||
* @param parent
|
||||
*/
|
||||
constructor(options: TreeNodeOptions, pathSegment: string, parent?: TreeNode);
|
||||
/**
|
||||
* Adds a path to the tree. `path` cannot start with a `/`.
|
||||
*
|
||||
* @param path - path segment to insert. **It shouldn't contain the file extension**
|
||||
* @param filePath - file path, must be a file (not a folder)
|
||||
*/
|
||||
insert(path: string, filePath: string): TreeNode;
|
||||
/**
|
||||
* Adds a path that has already been parsed to the tree. `path` cannot start with a `/`. This method is similar to
|
||||
* `insert` but the path argument should be already parsed. e.g. `users/:id` for a file named `users/[id].vue`.
|
||||
*
|
||||
* @param path - path segment to insert, already parsed (e.g. users/:id)
|
||||
* @param filePath - file path, defaults to path for convenience and testing
|
||||
*/
|
||||
insertParsedPath(path: string, filePath?: string): TreeNode;
|
||||
/**
|
||||
* Saves a custom route block for a specific file path. The file path is used as a key. Some special file paths will
|
||||
* have a lower or higher priority.
|
||||
*
|
||||
* @param filePath - file path where the custom block is located
|
||||
* @param routeBlock - custom block to set
|
||||
*/
|
||||
setCustomRouteBlock(filePath: string, routeBlock: CustomRouteBlock | undefined): void;
|
||||
/**
|
||||
* Generator that yields all descendants without sorting.
|
||||
* Use with Array.from() for now, native .map() support in Node 22+.
|
||||
*/
|
||||
getChildrenDeep(): Generator<TreeNode>;
|
||||
/**
|
||||
* Comparator function for sorting TreeNodes.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
static compare(a: TreeNode, b: TreeNode): number;
|
||||
/**
|
||||
* Get the children of this node sorted by their path.
|
||||
*/
|
||||
getChildrenSorted(): TreeNode[];
|
||||
/**
|
||||
* Calls {@link getChildrenDeep} and sorts the result by path in the end.
|
||||
*/
|
||||
getChildrenDeepSorted(): TreeNode[];
|
||||
/**
|
||||
* Delete and detach itself from the tree.
|
||||
*/
|
||||
delete(): void;
|
||||
/**
|
||||
* Remove a route from the tree. The path shouldn't start with a `/` but it can be a nested one. e.g. `foo/bar`.
|
||||
* The `path` should be relative to the page folder.
|
||||
*
|
||||
* @param path - path segment of the file
|
||||
*/
|
||||
remove(path: string): void;
|
||||
/**
|
||||
* Returns the route path of the node without parent paths. If the path was overridden, it returns the override.
|
||||
*/
|
||||
get path(): string;
|
||||
/**
|
||||
* Returns the route path of the node including parent paths.
|
||||
*/
|
||||
get fullPath(): string;
|
||||
/**
|
||||
* Object of components (filepaths) for this node.
|
||||
*/
|
||||
get components(): {
|
||||
[k: string]: string;
|
||||
};
|
||||
/**
|
||||
* Does this node render any component?
|
||||
*/
|
||||
get hasComponents(): boolean;
|
||||
/**
|
||||
* Returns the route name of the node. If the name was overridden, it returns the override.
|
||||
*/
|
||||
get name(): string | false;
|
||||
/**
|
||||
* Returns the meta property as an object.
|
||||
*/
|
||||
get metaAsObject(): Readonly<RouteMeta>;
|
||||
/**
|
||||
* Returns the JSON string of the meta object of the node. If the meta was overridden, it returns the override. If
|
||||
* there is no override, it returns an empty string.
|
||||
*/
|
||||
get meta(): string;
|
||||
/**
|
||||
* Array of route params for this node. It includes **all** the params from the parents as well.
|
||||
*/
|
||||
get params(): (TreePathParam | TreeQueryParam)[];
|
||||
/**
|
||||
* Array of route params coming from the path. It includes all the params from the parents as well.
|
||||
*/
|
||||
get pathParams(): TreePathParam[];
|
||||
/**
|
||||
* Array of query params extracted from definePage. Only returns query params from this specific node.
|
||||
*/
|
||||
get queryParams(): TreeQueryParam[];
|
||||
/**
|
||||
* Generates a regexp based on this node and its parents. This regexp is used by the custom resolver
|
||||
*/
|
||||
get regexp(): string;
|
||||
/**
|
||||
* Score of the path used for sorting routes.
|
||||
*/
|
||||
get score(): number[][];
|
||||
/**
|
||||
* Is this node a splat (catch-all) param
|
||||
*/
|
||||
get isSplat(): boolean;
|
||||
/**
|
||||
* Returns an array of matcher parts that is consumed by
|
||||
* MatcherPatternPathDynamic to render the path.
|
||||
*/
|
||||
get matcherPatternPathDynamicParts(): TreeNodeValueMatcherPart;
|
||||
/**
|
||||
* Is this tree node matchable? A matchable node has at least one component
|
||||
* and a name.
|
||||
*/
|
||||
isMatchable(): this is TreeNode & {
|
||||
name: string;
|
||||
};
|
||||
/**
|
||||
* Returns wether this tree node is the root node of the tree.
|
||||
*
|
||||
* @returns true if the node is the root node
|
||||
*/
|
||||
isRoot(): this is PrefixTree;
|
||||
/**
|
||||
* Returns wether this tree node has a name. This allows to coerce the type
|
||||
* of TreeNode
|
||||
*/
|
||||
isNamed(): this is TreeNodeNamed;
|
||||
toString(): string;
|
||||
}
|
||||
/**
|
||||
* Creates a new prefix tree. This is meant to only be the root node. It has access to extra methods that only make
|
||||
* sense on the root node.
|
||||
*/
|
||||
declare class PrefixTree extends TreeNode {
|
||||
map: Map<string, TreeNode>;
|
||||
constructor(options: ResolvedOptions);
|
||||
insert(path: string, filePath: string): TreeNode;
|
||||
/**
|
||||
* Returns the tree node of the given file path.
|
||||
*
|
||||
* @param filePath - file path of the tree node to get
|
||||
*/
|
||||
getChild(filePath: string): TreeNode | undefined;
|
||||
/**
|
||||
* Removes the tree node of the given file path.
|
||||
*
|
||||
* @param filePath - file path of the tree node to remove
|
||||
*/
|
||||
removeChild(filePath: string): void;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/core/utils.d.ts
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
declare function getPascalCaseRouteName(node: TreeNode): string;
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
declare function getFileBasedRouteName(node: TreeNode): string;
|
||||
//#endregion
|
||||
//#region src/core/extendRoutes.d.ts
|
||||
/**
|
||||
* A route node that can be modified by the user. The tree can be iterated to be traversed.
|
||||
* @example
|
||||
* ```js
|
||||
* [...node] // creates an array of all the children
|
||||
* for (const child of node) {
|
||||
* // do something with the child node
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
declare class EditableTreeNode {
|
||||
private node;
|
||||
constructor(node: TreeNode);
|
||||
/**
|
||||
* Remove and detach the current route node from the tree. Subsequently, its children will be removed as well.
|
||||
*/
|
||||
delete(): void;
|
||||
/**
|
||||
* Inserts a new route as a child of this route. This route cannot use `definePage()`. If it was meant to be included,
|
||||
* add it to the `routesFolder` option.
|
||||
*
|
||||
* @param path - path segment to insert. Note this is relative to the current route. **It shouldn't start with `/`**. If it does, it will be added to the root of the tree.
|
||||
* @param filePath - file path
|
||||
* @returns the new editable route node
|
||||
*/
|
||||
insert(path: string, filePath: string): EditableTreeNode;
|
||||
/**
|
||||
* Get an editable version of the parent node if it exists.
|
||||
*/
|
||||
get parent(): EditableTreeNode | undefined;
|
||||
/**
|
||||
* Return a Map of the files associated to the current route. The key of the map represents the name of the view (Vue
|
||||
* Router feature) while the value is the **resolved** file path.
|
||||
* By default, the name of the view is `default`.
|
||||
*/
|
||||
get components(): Map<string, string>;
|
||||
/**
|
||||
* Alias for `route.components.get('default')`.
|
||||
*/
|
||||
get component(): string | undefined;
|
||||
/**
|
||||
* Name of the route. Note that **all routes are named** but when the final `routes` array is generated, routes
|
||||
* without a `component` will not include their `name` property to avoid accidentally navigating to them and display
|
||||
* nothing.
|
||||
* @see {@link isPassThrough}
|
||||
*/
|
||||
get name(): string | false;
|
||||
/**
|
||||
* Override the name of the route.
|
||||
*/
|
||||
set name(name: string | undefined);
|
||||
/**
|
||||
* Whether the route is a pass-through route. A pass-through route is a route that does not have a component and is
|
||||
* used to group other routes under the same prefix `path` and/or `meta` properties.
|
||||
*/
|
||||
get isPassThrough(): boolean;
|
||||
/**
|
||||
* Meta property of the route as an object. Note this property is readonly and will be serialized as JSON. It won't contain the meta properties defined with `definePage()` as it could contain expressions **but it does contain the meta properties defined with `<route>` blocks**.
|
||||
*/
|
||||
get meta(): Readonly<RouteMeta>;
|
||||
/**
|
||||
* Override the meta property of the route. This will discard any other meta property defined with `<route>` blocks or
|
||||
* through other means. If you want to keep the existing meta properties, use `addToMeta`.
|
||||
* @see {@link addToMeta}
|
||||
*/
|
||||
set meta(meta: RouteMeta);
|
||||
/**
|
||||
* Add meta properties to the route keeping the existing ones. The passed object will be deeply merged with the
|
||||
* existing meta object if any. Note that the meta property is later on serialized as JSON so you can't pass functions
|
||||
* or any other non-serializable value.
|
||||
*/
|
||||
addToMeta(meta: Partial<RouteMeta>): void;
|
||||
/**
|
||||
* Path of the route without parent paths.
|
||||
*/
|
||||
get path(): string;
|
||||
/**
|
||||
* Override the path of the route. You must ensure `params` match with the existing path.
|
||||
*/
|
||||
set path(path: string);
|
||||
/**
|
||||
* Alias of the route.
|
||||
*/
|
||||
get alias(): string | string[] | undefined;
|
||||
/**
|
||||
* Add an alias to the route.
|
||||
*
|
||||
* @param alias - Alias to add to the route
|
||||
*/
|
||||
addAlias(alias: CustomRouteBlock['alias']): void;
|
||||
/**
|
||||
* Array of the route params and all of its parent's params. Note that
|
||||
* changing the params will not update the path, you need to update both.
|
||||
*/
|
||||
get params(): TreePathParam[];
|
||||
/**
|
||||
* Path of the route including parent paths.
|
||||
*/
|
||||
get fullPath(): string;
|
||||
/**
|
||||
* Computes an array of EditableTreeNode from the current node. Differently from iterating over the tree, this method
|
||||
* **only returns direct children**.
|
||||
*/
|
||||
get children(): EditableTreeNode[];
|
||||
/**
|
||||
* DFS traversal of the tree.
|
||||
* @example
|
||||
* ```ts
|
||||
* for (const node of tree) {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
traverseDFS(): Generator<EditableTreeNode, void, unknown>;
|
||||
[Symbol.iterator](): Generator<EditableTreeNode, void, unknown>;
|
||||
/**
|
||||
* BFS traversal of the tree as a generator.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* for (const node of tree) {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
traverseBFS(): Generator<EditableTreeNode, void, unknown>;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/utils/index.d.ts
|
||||
/**
|
||||
* Maybe a promise maybe not
|
||||
* @internal
|
||||
*/
|
||||
type _Awaitable<T> = T | PromiseLike<T>;
|
||||
//#endregion
|
||||
//#region src/options.d.ts
|
||||
/**
|
||||
* Options for a routes folder.
|
||||
*/
|
||||
interface RoutesFolderOption {
|
||||
/**
|
||||
* Folder to scan files that should be used for routes. **Cannot be a glob**, use the `path`, `filePatterns`, and
|
||||
* `exclude` options to filter out files. This section will **be removed** from the resulting path.
|
||||
*/
|
||||
src: string;
|
||||
/**
|
||||
* Prefix to add to the route path **as is**. Defaults to `''`. Can also be a function
|
||||
* to reuse parts of the filepath, in that case you should return a **modified version of the filepath**.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* {
|
||||
* src: 'src/pages',
|
||||
* // this is equivalent to the default behavior
|
||||
* path: (file) => file.slice(file.lastIndexOf('src/pages') + 'src/pages'.length
|
||||
* },
|
||||
* {
|
||||
* src: 'src/features',
|
||||
* // match all files (note the \ is not needed in real code)
|
||||
* filePatterns: '*/pages/**\/',
|
||||
* path: (file) => {
|
||||
* const prefix = 'src/features'
|
||||
* // remove the everything before src/features and removes /pages
|
||||
* // /src/features/feature1/pages/index.vue -> feature1/index.vue
|
||||
* return file.slice(file.lastIndexOf(prefix) + prefix.length + 1).replace('/pages', '')
|
||||
* },
|
||||
* },
|
||||
* {
|
||||
* src: 'src/docs',
|
||||
* // adds a prefix with a param
|
||||
* path: 'docs/[lang]/',
|
||||
* },
|
||||
* ```
|
||||
*/
|
||||
path?: string | ((filepath: string) => string);
|
||||
/**
|
||||
* Allows to override the global `filePattern` option for this folder. It can also extend the global values by passing
|
||||
* a function that returns an array.
|
||||
*/
|
||||
filePatterns?: _OverridableOption<string[], string | string[]>;
|
||||
/**
|
||||
* Allows to override the global `exclude` option for this folder. It can
|
||||
* also extend the global values by passing a function that returns an array.
|
||||
*/
|
||||
exclude?: _OverridableOption<string[], string | string[]>;
|
||||
/**
|
||||
* Allows to override the global `extensions` option for this folder. It can
|
||||
* also extend the global values by passing a function that returns an array.
|
||||
* The provided extensions are removed from the final route. For example,
|
||||
* `.page.vue` allows to suffix all pages with `.page.vue` and remove it from
|
||||
* the route name.
|
||||
*/
|
||||
extensions?: _OverridableOption<string[]>;
|
||||
}
|
||||
/**
|
||||
* Normalized options for a routes folder.
|
||||
*/
|
||||
interface RoutesFolderOptionResolved extends RoutesFolderOption {
|
||||
path: string | ((filepath: string) => string);
|
||||
/**
|
||||
* Final glob pattern to match files in the folder.
|
||||
*/
|
||||
pattern: string[];
|
||||
filePatterns: string[];
|
||||
exclude: string[];
|
||||
extensions: string[];
|
||||
}
|
||||
type _OverridableOption<T, AllowedTypes = T> = AllowedTypes | ((existing: T) => T);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
declare function resolveOverridableOption<T>(defaultValue: T, value?: _OverridableOption<T, T>): T;
|
||||
type _RoutesFolder = string | RoutesFolderOption;
|
||||
type RoutesFolder = _RoutesFolder[] | _RoutesFolder;
|
||||
/**
|
||||
* unplugin-vue-router plugin options.
|
||||
*/
|
||||
interface Options {
|
||||
/**
|
||||
* Extensions of files to be considered as pages. Cannot be empty. This allows to strip a
|
||||
* bigger part of the filename e.g. `index.page.vue` -> `index` if an extension of `.page.vue` is provided.
|
||||
* @default `['.vue']`
|
||||
*/
|
||||
extensions?: string[];
|
||||
/**
|
||||
* Folder(s) to scan for files and generate routes. Can also be an array if you want to add multiple
|
||||
* folders, or an object if you want to define a route prefix. Supports glob patterns but must be a folder, use
|
||||
* `extensions` and `exclude` to filter files.
|
||||
*
|
||||
* @default `"src/pages"`
|
||||
*/
|
||||
routesFolder?: RoutesFolder;
|
||||
/**
|
||||
* Array of `picomatch` globs to ignore. Note the globs are relative to the cwd, so avoid writing
|
||||
* something like `['ignored']` to match folders named that way, instead provide a path similar to the `routesFolder`:
|
||||
* `['src/pages/ignored/**']` or use `['**/ignored']` to match every folder named `ignored`.
|
||||
* @default `[]`
|
||||
*/
|
||||
exclude?: string[] | string;
|
||||
/**
|
||||
* Pattern to match files in the `routesFolder`. Defaults to `*\/*` plus a
|
||||
* combination of all the possible extensions, e.g. `*\/*.{vue,md}` if
|
||||
* `extensions` is set to `['.vue', '.md']`. This is relative to the {@link
|
||||
* RoutesFolderOption['src']} and
|
||||
*
|
||||
* @default `['*\/*']`
|
||||
*/
|
||||
filePatterns?: string[] | string;
|
||||
/**
|
||||
* Method to generate the name of a route. It's recommended to keep the default value to guarantee a consistent,
|
||||
* unique, and predictable naming.
|
||||
*/
|
||||
getRouteName?: (node: TreeNode) => string;
|
||||
/**
|
||||
* Allows to extend a route by modifying its node, adding children, or even deleting it. This will be invoked once for
|
||||
* each route.
|
||||
*
|
||||
* @param route - {@link EditableTreeNode} of the route to extend
|
||||
*/
|
||||
extendRoute?: (route: EditableTreeNode) => _Awaitable<void>;
|
||||
/**
|
||||
* Allows to do some changes before writing the files. This will be invoked **every time** the files need to be written.
|
||||
*
|
||||
* @param rootRoute - {@link EditableTreeNode} of the root route
|
||||
*/
|
||||
beforeWriteFiles?: (rootRoute: EditableTreeNode) => _Awaitable<void>;
|
||||
/**
|
||||
* Defines how page components should be imported. Defaults to dynamic imports to enable lazy loading of pages.
|
||||
* @default `'async'`
|
||||
*/
|
||||
importMode?: 'sync' | 'async' | ((filepath: string) => 'sync' | 'async');
|
||||
/**
|
||||
* Root of the project. All paths are resolved relatively to this one.
|
||||
* @default `process.cwd()`
|
||||
*/
|
||||
root?: string;
|
||||
/**
|
||||
* Language for `<route>` blocks in SFC files.
|
||||
* @default `'json5'`
|
||||
*/
|
||||
routeBlockLang?: 'yaml' | 'yml' | 'json5' | 'json';
|
||||
/**
|
||||
* Should we generate d.ts files or ont. Defaults to `true` if `typescript` is installed. Can be set to a string of
|
||||
* the filepath to write the d.ts files to. By default it will generate a file named `typed-router.d.ts`.
|
||||
* @default `true`
|
||||
*/
|
||||
dts?: boolean | string;
|
||||
/**
|
||||
* Allows inspection by vite-plugin-inspect by not adding the leading `\0` to the id of virtual modules.
|
||||
* @internal
|
||||
*/
|
||||
_inspect?: boolean;
|
||||
/**
|
||||
* Activates debug logs.
|
||||
*/
|
||||
logs?: boolean;
|
||||
/**
|
||||
* @inheritDoc ParseSegmentOptions
|
||||
*/
|
||||
pathParser?: ParseSegmentOptions;
|
||||
/**
|
||||
* Whether to watch the files for changes.
|
||||
*
|
||||
* Defaults to `true` unless the `CI` environment variable is set.
|
||||
*
|
||||
* @default `!process.env.CI`
|
||||
*/
|
||||
watch?: boolean;
|
||||
/**
|
||||
* Experimental options. **Warning**: these can change or be removed at any time, even it patch releases. Keep an eye
|
||||
* on the Changelog.
|
||||
*/
|
||||
experimental?: {
|
||||
/**
|
||||
* (Vite only). File paths or globs where loaders are exported. This will be used to filter out imported loaders and
|
||||
* automatically re export them in page components. You can for example set this to `'src/loaders/**\/*'` (without
|
||||
* the backslash) to automatically re export any imported variable from files in the `src/loaders` folder within a
|
||||
* page component.
|
||||
*/
|
||||
autoExportsDataLoaders?: string | string[];
|
||||
/**
|
||||
* Enable experimental support for the new custom resolvers and allows
|
||||
* defining custom param matchers.
|
||||
*/
|
||||
paramParsers?: boolean | ParamParsersOptions;
|
||||
};
|
||||
}
|
||||
interface ParamParsersOptions {
|
||||
/**
|
||||
* Folder(s) to scan for param matchers. Set to an empty array to disable the feature.
|
||||
*
|
||||
* @default `['src/params']`
|
||||
*/
|
||||
dir?: string | string[];
|
||||
}
|
||||
declare const DEFAULT_PARAM_PARSERS_OPTIONS: {
|
||||
dir: string[];
|
||||
};
|
||||
declare const DEFAULT_OPTIONS: {
|
||||
extensions: string[];
|
||||
exclude: never[];
|
||||
routesFolder: string;
|
||||
filePatterns: string[];
|
||||
routeBlockLang: "json5";
|
||||
getRouteName: typeof getFileBasedRouteName;
|
||||
importMode: "async";
|
||||
root: string;
|
||||
dts: boolean;
|
||||
logs: false;
|
||||
_inspect: false;
|
||||
pathParser: {
|
||||
dotNesting: true;
|
||||
};
|
||||
watch: boolean;
|
||||
experimental: {};
|
||||
};
|
||||
interface ServerContext {
|
||||
/**
|
||||
* Invalidates a module by its id.
|
||||
* @param module - module id to invalidate
|
||||
*
|
||||
* @returns A promise that resolves when the module is invalidated, or `false` if the module was not found.
|
||||
*/
|
||||
invalidate: (module: string) => Promise<void> | false;
|
||||
/**
|
||||
* Invalidates all modules associated with a page file.
|
||||
* @param filepath - file path of the page to invalidate
|
||||
*
|
||||
* @returns A promise that resolves when the page is invalidated, or `false` if no modules were found for the page.
|
||||
*/
|
||||
invalidatePage: (filepath: string) => Promise<void> | false;
|
||||
/**
|
||||
* Triggers HMR for the routes module.
|
||||
*/
|
||||
updateRoutes: () => Promise<void>;
|
||||
/**
|
||||
* Triggers a full page reload.
|
||||
*/
|
||||
reload: () => void;
|
||||
}
|
||||
/**
|
||||
* Normalize user options with defaults and resolved paths.
|
||||
*
|
||||
* @param options - user provided options
|
||||
* @returns normalized options
|
||||
*/
|
||||
declare function resolveOptions(options: Options): {
|
||||
experimental: {
|
||||
autoExportsDataLoaders: string[] | undefined;
|
||||
paramParsers: {
|
||||
dir: string[];
|
||||
} | undefined;
|
||||
};
|
||||
routesFolder: {
|
||||
src: string;
|
||||
filePatterns: string[] | ((existing: string[]) => string[]) | undefined;
|
||||
exclude: string[] | ((existing: string[]) => string[]) | undefined;
|
||||
/**
|
||||
* Prefix to add to the route path **as is**. Defaults to `''`. Can also be a function
|
||||
* to reuse parts of the filepath, in that case you should return a **modified version of the filepath**.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* {
|
||||
* src: 'src/pages',
|
||||
* // this is equivalent to the default behavior
|
||||
* path: (file) => file.slice(file.lastIndexOf('src/pages') + 'src/pages'.length
|
||||
* },
|
||||
* {
|
||||
* src: 'src/features',
|
||||
* // match all files (note the \ is not needed in real code)
|
||||
* filePatterns: '*/pages/**\/',
|
||||
* path: (file) => {
|
||||
* const prefix = 'src/features'
|
||||
* // remove the everything before src/features and removes /pages
|
||||
* // /src/features/feature1/pages/index.vue -> feature1/index.vue
|
||||
* return file.slice(file.lastIndexOf(prefix) + prefix.length + 1).replace('/pages', '')
|
||||
* },
|
||||
* },
|
||||
* {
|
||||
* src: 'src/docs',
|
||||
* // adds a prefix with a param
|
||||
* path: 'docs/[lang]/',
|
||||
* },
|
||||
* ```
|
||||
*/
|
||||
path?: string | ((filepath: string) => string);
|
||||
/**
|
||||
* Allows to override the global `extensions` option for this folder. It can
|
||||
* also extend the global values by passing a function that returns an array.
|
||||
* The provided extensions are removed from the final route. For example,
|
||||
* `.page.vue` allows to suffix all pages with `.page.vue` and remove it from
|
||||
* the route name.
|
||||
*/
|
||||
extensions?: _OverridableOption<string[]>;
|
||||
}[];
|
||||
filePatterns: string[];
|
||||
exclude: string[];
|
||||
extensions: string[];
|
||||
getRouteName: typeof getFileBasedRouteName;
|
||||
/**
|
||||
* Allows to extend a route by modifying its node, adding children, or even deleting it. This will be invoked once for
|
||||
* each route.
|
||||
*
|
||||
* @param route - {@link EditableTreeNode} of the route to extend
|
||||
*/
|
||||
extendRoute?: (route: EditableTreeNode) => _Awaitable<void>;
|
||||
/**
|
||||
* Allows to do some changes before writing the files. This will be invoked **every time** the files need to be written.
|
||||
*
|
||||
* @param rootRoute - {@link EditableTreeNode} of the root route
|
||||
*/
|
||||
beforeWriteFiles?: (rootRoute: EditableTreeNode) => _Awaitable<void>;
|
||||
importMode: "sync" | "async" | ((filepath: string) => "sync" | "async");
|
||||
root: string;
|
||||
routeBlockLang: "yaml" | "yml" | "json5" | "json";
|
||||
dts: boolean | string;
|
||||
_inspect: boolean;
|
||||
logs: boolean;
|
||||
pathParser: ParseSegmentOptions;
|
||||
watch: boolean;
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type ResolvedOptions = ReturnType<typeof resolveOptions>;
|
||||
/**
|
||||
* Merge all the possible extensions as an array of unique values
|
||||
* @param options - user provided options
|
||||
* @internal
|
||||
*/
|
||||
declare function mergeAllExtensions(options: ResolvedOptions): string[];
|
||||
//#endregion
|
||||
export { createTreeNodeValue as C, TreeNodeValueStatic as S, getPascalCaseRouteName as _, ResolvedOptions as a, TreeNodeValueGroup as b, RoutesFolderOptionResolved as c, _RoutesFolder as d, mergeAllExtensions as f, getFileBasedRouteName as g, EditableTreeNode as h, ParamParsersOptions as i, ServerContext as l, resolveOverridableOption as m, DEFAULT_PARAM_PARSERS_OPTIONS as n, RoutesFolder as o, resolveOptions as p, Options as r, RoutesFolderOption as s, DEFAULT_OPTIONS as t, _OverridableOption as u, TreeNode as v, TreeNodeValueParam as x, TreeNodeValue as y };
|
||||
7
Frontend-Learner/node_modules/unplugin-vue-router/dist/options.cjs
generated
vendored
Normal file
7
Frontend-Learner/node_modules/unplugin-vue-router/dist/options.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
const require_options = require('./options-CpfNkO-E.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;
|
||||
2
Frontend-Learner/node_modules/unplugin-vue-router/dist/options.d.cts
generated
vendored
Normal file
2
Frontend-Learner/node_modules/unplugin-vue-router/dist/options.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
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-BCiDuX1m.cjs";
|
||||
export { DEFAULT_OPTIONS, DEFAULT_PARAM_PARSERS_OPTIONS, Options, ParamParsersOptions, ResolvedOptions, RoutesFolder, RoutesFolderOption, RoutesFolderOptionResolved, ServerContext, _OverridableOption, _RoutesFolder, mergeAllExtensions, resolveOptions, resolveOverridableOption };
|
||||
2
Frontend-Learner/node_modules/unplugin-vue-router/dist/options.d.mts
generated
vendored
Normal file
2
Frontend-Learner/node_modules/unplugin-vue-router/dist/options.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
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-DG3niQXy.mjs";
|
||||
export { DEFAULT_OPTIONS, DEFAULT_PARAM_PARSERS_OPTIONS, Options, ParamParsersOptions, ResolvedOptions, RoutesFolder, RoutesFolderOption, RoutesFolderOptionResolved, ServerContext, _OverridableOption, _RoutesFolder, mergeAllExtensions, resolveOptions, resolveOverridableOption };
|
||||
3
Frontend-Learner/node_modules/unplugin-vue-router/dist/options.mjs
generated
vendored
Normal file
3
Frontend-Learner/node_modules/unplugin-vue-router/dist/options.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import { a as resolveOverridableOption, i as resolveOptions, n as DEFAULT_PARAM_PARSERS_OPTIONS, r as mergeAllExtensions, t as DEFAULT_OPTIONS } from "./options-CAGVi1wo.mjs";
|
||||
|
||||
export { DEFAULT_OPTIONS, DEFAULT_PARAM_PARSERS_OPTIONS, mergeAllExtensions, resolveOptions, resolveOverridableOption };
|
||||
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/rolldown.cjs
generated
vendored
Normal file
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/rolldown.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
const require_src = require('./src-DKnuUuX8.cjs');
|
||||
require('./options-CpfNkO-E.cjs');
|
||||
|
||||
//#region src/rolldown.ts
|
||||
var rolldown_default = require_src.src_default.rolldown;
|
||||
|
||||
//#endregion
|
||||
module.exports = rolldown_default;
|
||||
6
Frontend-Learner/node_modules/unplugin-vue-router/dist/rolldown.d.cts
generated
vendored
Normal file
6
Frontend-Learner/node_modules/unplugin-vue-router/dist/rolldown.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { r as Options } from "./options-BCiDuX1m.cjs";
|
||||
import * as rolldown0 from "rolldown";
|
||||
|
||||
//#region src/rolldown.d.ts
|
||||
declare const _default: (options?: Options | undefined) => rolldown0.Plugin<any> | rolldown0.Plugin<any>[];
|
||||
export = _default;
|
||||
7
Frontend-Learner/node_modules/unplugin-vue-router/dist/rolldown.d.mts
generated
vendored
Normal file
7
Frontend-Learner/node_modules/unplugin-vue-router/dist/rolldown.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { r as Options } from "./options-DG3niQXy.mjs";
|
||||
import * as rolldown0 from "rolldown";
|
||||
|
||||
//#region src/rolldown.d.ts
|
||||
declare const _default: (options?: Options | undefined) => rolldown0.Plugin<any> | rolldown0.Plugin<any>[];
|
||||
//#endregion
|
||||
export { _default as default };
|
||||
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/rolldown.mjs
generated
vendored
Normal file
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/rolldown.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "./options-CAGVi1wo.mjs";
|
||||
import { n as src_default } from "./src-CZrWKhKa.mjs";
|
||||
|
||||
//#region src/rolldown.ts
|
||||
var rolldown_default = src_default.rolldown;
|
||||
|
||||
//#endregion
|
||||
export { rolldown_default as default };
|
||||
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/rollup.cjs
generated
vendored
Normal file
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/rollup.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
const require_src = require('./src-DKnuUuX8.cjs');
|
||||
require('./options-CpfNkO-E.cjs');
|
||||
|
||||
//#region src/rollup.ts
|
||||
var rollup_default = require_src.src_default.rollup;
|
||||
|
||||
//#endregion
|
||||
module.exports = rollup_default;
|
||||
6
Frontend-Learner/node_modules/unplugin-vue-router/dist/rollup.d.cts
generated
vendored
Normal file
6
Frontend-Learner/node_modules/unplugin-vue-router/dist/rollup.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { r as Options } from "./options-BCiDuX1m.cjs";
|
||||
import * as rollup0 from "rollup";
|
||||
|
||||
//#region src/rollup.d.ts
|
||||
declare const _default: (options?: Options | undefined) => rollup0.Plugin<any> | rollup0.Plugin<any>[];
|
||||
export = _default;
|
||||
7
Frontend-Learner/node_modules/unplugin-vue-router/dist/rollup.d.mts
generated
vendored
Normal file
7
Frontend-Learner/node_modules/unplugin-vue-router/dist/rollup.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { r as Options } from "./options-DG3niQXy.mjs";
|
||||
import * as rollup0 from "rollup";
|
||||
|
||||
//#region src/rollup.d.ts
|
||||
declare const _default: (options?: Options | undefined) => rollup0.Plugin<any> | rollup0.Plugin<any>[];
|
||||
//#endregion
|
||||
export { _default as default };
|
||||
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/rollup.mjs
generated
vendored
Normal file
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/rollup.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "./options-CAGVi1wo.mjs";
|
||||
import { n as src_default } from "./src-CZrWKhKa.mjs";
|
||||
|
||||
//#region src/rollup.ts
|
||||
var rollup_default = src_default.rollup;
|
||||
|
||||
//#endregion
|
||||
export { rollup_default as default };
|
||||
37
Frontend-Learner/node_modules/unplugin-vue-router/dist/runtime.cjs
generated
vendored
Normal file
37
Frontend-Learner/node_modules/unplugin-vue-router/dist/runtime.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
//#region src/runtime.ts
|
||||
/**
|
||||
* Defines properties of the route for the current page component.
|
||||
*
|
||||
* @param route - route information to be added to this page
|
||||
*/
|
||||
const definePage = (route) => route;
|
||||
/**
|
||||
* Merges route records.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param main - main route record
|
||||
* @param routeRecords - route records to merge
|
||||
* @returns merged route record
|
||||
*/
|
||||
function _mergeRouteRecord(main, ...routeRecords) {
|
||||
return routeRecords.reduce((acc, routeRecord) => {
|
||||
const meta = Object.assign({}, acc.meta, routeRecord.meta);
|
||||
const alias = [].concat(acc.alias || [], routeRecord.alias || []);
|
||||
Object.assign(acc, routeRecord);
|
||||
acc.meta = meta;
|
||||
acc.alias = alias;
|
||||
return acc;
|
||||
}, main);
|
||||
}
|
||||
/**
|
||||
* TODO: native parsers ideas:
|
||||
* - json -> just JSON.parse(value)
|
||||
* - boolean -> 'true' | 'false' -> boolean
|
||||
* - number -> Number(value) -> NaN if not a number
|
||||
*/
|
||||
|
||||
//#endregion
|
||||
exports._mergeRouteRecord = _mergeRouteRecord;
|
||||
exports.definePage = definePage;
|
||||
72
Frontend-Learner/node_modules/unplugin-vue-router/dist/runtime.d.cts
generated
vendored
Normal file
72
Frontend-Learner/node_modules/unplugin-vue-router/dist/runtime.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import { RouteRecordRaw, TypesConfig } from "vue-router";
|
||||
|
||||
//#region src/runtime.d.ts
|
||||
|
||||
/**
|
||||
* Defines properties of the route for the current page component.
|
||||
*
|
||||
* @param route - route information to be added to this page
|
||||
*/
|
||||
declare const definePage: (route: DefinePage) => DefinePage;
|
||||
/**
|
||||
* Merges route records.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param main - main route record
|
||||
* @param routeRecords - route records to merge
|
||||
* @returns merged route record
|
||||
*/
|
||||
declare function _mergeRouteRecord(main: RouteRecordRaw, ...routeRecords: Partial<RouteRecordRaw>[]): RouteRecordRaw;
|
||||
/**
|
||||
* Type to define a page. Can be augmented to add custom properties.
|
||||
*/
|
||||
interface DefinePage extends Partial<Omit<RouteRecordRaw, 'children' | 'components' | 'component' | 'name'>> {
|
||||
/**
|
||||
* A route name. If not provided, the name will be generated based on the file path.
|
||||
* Can be set to `false` to remove the name from types.
|
||||
*/
|
||||
name?: string | false;
|
||||
/**
|
||||
* Custom parameters for the route. Requires `experimental.paramParsers` enabled.
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
params?: {
|
||||
path?: Record<string, ParamParserType>;
|
||||
/**
|
||||
* Parameters extracted from the query.
|
||||
*/
|
||||
query?: Record<string, DefinePageQueryParamOptions | ParamParserType>;
|
||||
};
|
||||
}
|
||||
type ParamParserType_Native = 'int' | 'bool';
|
||||
type ParamParserType = (TypesConfig extends Record<'ParamParsers', infer ParamParsers> ? ParamParsers : never) | ParamParserType_Native;
|
||||
/**
|
||||
* Configures how to extract a route param from a specific query parameter.
|
||||
*/
|
||||
interface DefinePageQueryParamOptions<T = unknown> {
|
||||
/**
|
||||
* The type of the query parameter. Allowed values are native param parsers
|
||||
* and any parser in the {@link https://uvr.esm.is/TODO | params folder }. If
|
||||
* not provided, the value will kept as is.
|
||||
*/
|
||||
parser?: ParamParserType;
|
||||
/**
|
||||
* Default value if the query parameter is missing or if the match fails
|
||||
* (e.g. a invalid number is passed to the int param parser). If not provided
|
||||
* and the param parser throws, the route will not match.
|
||||
*/
|
||||
default?: (() => T) | T;
|
||||
/**
|
||||
* How to format the query parameter value.
|
||||
*
|
||||
* - 'value' - keep the first value only and pass that to parser
|
||||
* - 'array' - keep all values (even one or none) as an array and pass that to parser
|
||||
*
|
||||
* @default 'value'
|
||||
*/
|
||||
format?: 'value' | 'array';
|
||||
}
|
||||
//#endregion
|
||||
export { DefinePage, DefinePageQueryParamOptions, ParamParserType, ParamParserType_Native, _mergeRouteRecord, definePage };
|
||||
72
Frontend-Learner/node_modules/unplugin-vue-router/dist/runtime.d.mts
generated
vendored
Normal file
72
Frontend-Learner/node_modules/unplugin-vue-router/dist/runtime.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import { RouteRecordRaw, TypesConfig } from "vue-router";
|
||||
|
||||
//#region src/runtime.d.ts
|
||||
|
||||
/**
|
||||
* Defines properties of the route for the current page component.
|
||||
*
|
||||
* @param route - route information to be added to this page
|
||||
*/
|
||||
declare const definePage: (route: DefinePage) => DefinePage;
|
||||
/**
|
||||
* Merges route records.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param main - main route record
|
||||
* @param routeRecords - route records to merge
|
||||
* @returns merged route record
|
||||
*/
|
||||
declare function _mergeRouteRecord(main: RouteRecordRaw, ...routeRecords: Partial<RouteRecordRaw>[]): RouteRecordRaw;
|
||||
/**
|
||||
* Type to define a page. Can be augmented to add custom properties.
|
||||
*/
|
||||
interface DefinePage extends Partial<Omit<RouteRecordRaw, 'children' | 'components' | 'component' | 'name'>> {
|
||||
/**
|
||||
* A route name. If not provided, the name will be generated based on the file path.
|
||||
* Can be set to `false` to remove the name from types.
|
||||
*/
|
||||
name?: string | false;
|
||||
/**
|
||||
* Custom parameters for the route. Requires `experimental.paramParsers` enabled.
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
params?: {
|
||||
path?: Record<string, ParamParserType>;
|
||||
/**
|
||||
* Parameters extracted from the query.
|
||||
*/
|
||||
query?: Record<string, DefinePageQueryParamOptions | ParamParserType>;
|
||||
};
|
||||
}
|
||||
type ParamParserType_Native = 'int' | 'bool';
|
||||
type ParamParserType = (TypesConfig extends Record<'ParamParsers', infer ParamParsers> ? ParamParsers : never) | ParamParserType_Native;
|
||||
/**
|
||||
* Configures how to extract a route param from a specific query parameter.
|
||||
*/
|
||||
interface DefinePageQueryParamOptions<T = unknown> {
|
||||
/**
|
||||
* The type of the query parameter. Allowed values are native param parsers
|
||||
* and any parser in the {@link https://uvr.esm.is/TODO | params folder }. If
|
||||
* not provided, the value will kept as is.
|
||||
*/
|
||||
parser?: ParamParserType;
|
||||
/**
|
||||
* Default value if the query parameter is missing or if the match fails
|
||||
* (e.g. a invalid number is passed to the int param parser). If not provided
|
||||
* and the param parser throws, the route will not match.
|
||||
*/
|
||||
default?: (() => T) | T;
|
||||
/**
|
||||
* How to format the query parameter value.
|
||||
*
|
||||
* - 'value' - keep the first value only and pass that to parser
|
||||
* - 'array' - keep all values (even one or none) as an array and pass that to parser
|
||||
*
|
||||
* @default 'value'
|
||||
*/
|
||||
format?: 'value' | 'array';
|
||||
}
|
||||
//#endregion
|
||||
export { DefinePage, DefinePageQueryParamOptions, ParamParserType, ParamParserType_Native, _mergeRouteRecord, definePage };
|
||||
35
Frontend-Learner/node_modules/unplugin-vue-router/dist/runtime.mjs
generated
vendored
Normal file
35
Frontend-Learner/node_modules/unplugin-vue-router/dist/runtime.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
//#region src/runtime.ts
|
||||
/**
|
||||
* Defines properties of the route for the current page component.
|
||||
*
|
||||
* @param route - route information to be added to this page
|
||||
*/
|
||||
const definePage = (route) => route;
|
||||
/**
|
||||
* Merges route records.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param main - main route record
|
||||
* @param routeRecords - route records to merge
|
||||
* @returns merged route record
|
||||
*/
|
||||
function _mergeRouteRecord(main, ...routeRecords) {
|
||||
return routeRecords.reduce((acc, routeRecord) => {
|
||||
const meta = Object.assign({}, acc.meta, routeRecord.meta);
|
||||
const alias = [].concat(acc.alias || [], routeRecord.alias || []);
|
||||
Object.assign(acc, routeRecord);
|
||||
acc.meta = meta;
|
||||
acc.alias = alias;
|
||||
return acc;
|
||||
}, main);
|
||||
}
|
||||
/**
|
||||
* TODO: native parsers ideas:
|
||||
* - json -> just JSON.parse(value)
|
||||
* - boolean -> 'true' | 'false' -> boolean
|
||||
* - number -> Number(value) -> NaN if not a number
|
||||
*/
|
||||
|
||||
//#endregion
|
||||
export { _mergeRouteRecord, definePage };
|
||||
2374
Frontend-Learner/node_modules/unplugin-vue-router/dist/src-CZrWKhKa.mjs
generated
vendored
Normal file
2374
Frontend-Learner/node_modules/unplugin-vue-router/dist/src-CZrWKhKa.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
2446
Frontend-Learner/node_modules/unplugin-vue-router/dist/src-DKnuUuX8.cjs
generated
vendored
Normal file
2446
Frontend-Learner/node_modules/unplugin-vue-router/dist/src-DKnuUuX8.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
Frontend-Learner/node_modules/unplugin-vue-router/dist/types-CF4U0ZkR.d.mts
generated
vendored
Normal file
1
Frontend-Learner/node_modules/unplugin-vue-router/dist/types-CF4U0ZkR.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { };
|
||||
1
Frontend-Learner/node_modules/unplugin-vue-router/dist/types-Dulnjx6t.d.cts
generated
vendored
Normal file
1
Frontend-Learner/node_modules/unplugin-vue-router/dist/types-Dulnjx6t.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { };
|
||||
0
Frontend-Learner/node_modules/unplugin-vue-router/dist/types.cjs
generated
vendored
Normal file
0
Frontend-Learner/node_modules/unplugin-vue-router/dist/types.cjs
generated
vendored
Normal file
3
Frontend-Learner/node_modules/unplugin-vue-router/dist/types.d.cts
generated
vendored
Normal file
3
Frontend-Learner/node_modules/unplugin-vue-router/dist/types.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import { S as TreeNodeValueStatic, b as TreeNodeValueGroup, h as EditableTreeNode, r as Options, v as TreeNode, x as TreeNodeValueParam, y as TreeNodeValue } from "./options-BCiDuX1m.cjs";
|
||||
import "./types-Dulnjx6t.cjs";
|
||||
export { EditableTreeNode, Options, TreeNode, TreeNodeValue, TreeNodeValueGroup, TreeNodeValueParam, TreeNodeValueStatic };
|
||||
3
Frontend-Learner/node_modules/unplugin-vue-router/dist/types.d.mts
generated
vendored
Normal file
3
Frontend-Learner/node_modules/unplugin-vue-router/dist/types.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import { S as TreeNodeValueStatic, b as TreeNodeValueGroup, h as EditableTreeNode, r as Options, v as TreeNode, x as TreeNodeValueParam, y as TreeNodeValue } from "./options-DG3niQXy.mjs";
|
||||
import "./types-CF4U0ZkR.mjs";
|
||||
export { EditableTreeNode, Options, TreeNode, TreeNodeValue, TreeNodeValueGroup, TreeNodeValueParam, TreeNodeValueStatic };
|
||||
1
Frontend-Learner/node_modules/unplugin-vue-router/dist/types.mjs
generated
vendored
Normal file
1
Frontend-Learner/node_modules/unplugin-vue-router/dist/types.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { };
|
||||
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/vite.cjs
generated
vendored
Normal file
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/vite.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
const require_src = require('./src-DKnuUuX8.cjs');
|
||||
require('./options-CpfNkO-E.cjs');
|
||||
|
||||
//#region src/vite.ts
|
||||
var vite_default = require_src.src_default.vite;
|
||||
|
||||
//#endregion
|
||||
module.exports = vite_default;
|
||||
6
Frontend-Learner/node_modules/unplugin-vue-router/dist/vite.d.cts
generated
vendored
Normal file
6
Frontend-Learner/node_modules/unplugin-vue-router/dist/vite.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { r as Options } from "./options-BCiDuX1m.cjs";
|
||||
import * as vite0 from "vite";
|
||||
|
||||
//#region src/vite.d.ts
|
||||
declare const _default: (options?: Options | undefined) => vite0.Plugin<any> | vite0.Plugin<any>[];
|
||||
export = _default;
|
||||
7
Frontend-Learner/node_modules/unplugin-vue-router/dist/vite.d.mts
generated
vendored
Normal file
7
Frontend-Learner/node_modules/unplugin-vue-router/dist/vite.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { r as Options } from "./options-DG3niQXy.mjs";
|
||||
import * as vite0 from "vite";
|
||||
|
||||
//#region src/vite.d.ts
|
||||
declare const _default: (options?: Options | undefined) => vite0.Plugin<any> | vite0.Plugin<any>[];
|
||||
//#endregion
|
||||
export { _default as default };
|
||||
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/vite.mjs
generated
vendored
Normal file
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/vite.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "./options-CAGVi1wo.mjs";
|
||||
import { n as src_default } from "./src-CZrWKhKa.mjs";
|
||||
|
||||
//#region src/vite.ts
|
||||
var vite_default = src_default.vite;
|
||||
|
||||
//#endregion
|
||||
export { vite_default as default };
|
||||
47
Frontend-Learner/node_modules/unplugin-vue-router/dist/volar/sfc-route-blocks.cjs
generated
vendored
Normal file
47
Frontend-Learner/node_modules/unplugin-vue-router/dist/volar/sfc-route-blocks.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
let __vue_language_core = require("@vue/language-core");
|
||||
let muggle_string = require("muggle-string");
|
||||
|
||||
//#region src/volar/entries/sfc-route-blocks.ts
|
||||
const plugin = () => {
|
||||
const routeBlockIdPrefix = "route_";
|
||||
const routeBlockIdRe = /* @__PURE__ */ 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,
|
||||
__vue_language_core.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://raw.githubusercontent.com/posva/unplugin-vue-router/main/route.schema.json\",");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
var sfc_route_blocks_default = plugin;
|
||||
|
||||
//#endregion
|
||||
module.exports = sfc_route_blocks_default;
|
||||
5
Frontend-Learner/node_modules/unplugin-vue-router/dist/volar/sfc-route-blocks.d.cts
generated
vendored
Normal file
5
Frontend-Learner/node_modules/unplugin-vue-router/dist/volar/sfc-route-blocks.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { VueLanguagePlugin } from "@vue/language-core";
|
||||
|
||||
//#region src/volar/entries/sfc-route-blocks.d.ts
|
||||
declare const plugin: VueLanguagePlugin;
|
||||
export = plugin;
|
||||
58
Frontend-Learner/node_modules/unplugin-vue-router/dist/volar/sfc-typed-router.cjs
generated
vendored
Normal file
58
Frontend-Learner/node_modules/unplugin-vue-router/dist/volar/sfc-typed-router.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
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$1) => `...${code$1},\n`));
|
||||
break;
|
||||
} else if (code === `;\n`) {
|
||||
content.splice(from + 1, i - from, `{\n`, `...`, ...content.slice(from + 1, i), `,\n`, ...codes.map((code$1) => `...${code$1},\n`), `}`, `;\n`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/volar/entries/sfc-typed-router.ts
|
||||
const plugin = ({ compilerOptions, modules: { typescript: ts } }) => {
|
||||
const RE = { DOLLAR_ROUTE: { VLS_CTX: /\b__VLS_ctx.\$route\b/g } };
|
||||
return {
|
||||
version: 2.1,
|
||||
resolveEmbeddedCode(fileName, sfc, embeddedCode) {
|
||||
if (!embeddedCode.id.startsWith("script_")) return;
|
||||
const useRouteNameTypeParam = `<${`import('vue-router/auto-routes')._RouteNamesForFilePath<'${compilerOptions.rootDir ? (0, pathe.relative)(compilerOptions.rootDir, fileName) : fileName}'>`}>`;
|
||||
if (sfc.scriptSetup) visit(sfc.scriptSetup.ast);
|
||||
function visit(node) {
|
||||
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "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 = node.getStart(sfc.scriptSetup.ast);
|
||||
(0, muggle_string.replaceSourceRange)(embeddedCode.content, sfc.scriptSetup.name, start, start, `(`);
|
||||
(0, muggle_string.replaceSourceRange)(embeddedCode.content, sfc.scriptSetup.name, node.end, node.end, ` as ReturnType<typeof useRoute${useRouteNameTypeParam}>)`);
|
||||
}
|
||||
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);
|
||||
}
|
||||
};
|
||||
};
|
||||
var sfc_typed_router_default = plugin;
|
||||
|
||||
//#endregion
|
||||
module.exports = sfc_typed_router_default;
|
||||
5
Frontend-Learner/node_modules/unplugin-vue-router/dist/volar/sfc-typed-router.d.cts
generated
vendored
Normal file
5
Frontend-Learner/node_modules/unplugin-vue-router/dist/volar/sfc-typed-router.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { VueLanguagePlugin } from "@vue/language-core";
|
||||
|
||||
//#region src/volar/entries/sfc-typed-router.d.ts
|
||||
declare const plugin: VueLanguagePlugin;
|
||||
export = plugin;
|
||||
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/webpack.cjs
generated
vendored
Normal file
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/webpack.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
const require_src = require('./src-DKnuUuX8.cjs');
|
||||
require('./options-CpfNkO-E.cjs');
|
||||
|
||||
//#region src/webpack.ts
|
||||
var webpack_default = require_src.src_default.webpack;
|
||||
|
||||
//#endregion
|
||||
module.exports = webpack_default;
|
||||
6
Frontend-Learner/node_modules/unplugin-vue-router/dist/webpack.d.cts
generated
vendored
Normal file
6
Frontend-Learner/node_modules/unplugin-vue-router/dist/webpack.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { r as Options } from "./options-BCiDuX1m.cjs";
|
||||
import * as webpack0 from "webpack";
|
||||
|
||||
//#region src/webpack.d.ts
|
||||
declare const _default: (options?: Options | undefined) => webpack0.WebpackPluginInstance;
|
||||
export = _default;
|
||||
7
Frontend-Learner/node_modules/unplugin-vue-router/dist/webpack.d.mts
generated
vendored
Normal file
7
Frontend-Learner/node_modules/unplugin-vue-router/dist/webpack.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { r as Options } from "./options-DG3niQXy.mjs";
|
||||
import * as webpack0 from "webpack";
|
||||
|
||||
//#region src/webpack.d.ts
|
||||
declare const _default: (options?: Options | undefined) => webpack0.WebpackPluginInstance;
|
||||
//#endregion
|
||||
export { _default as default };
|
||||
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/webpack.mjs
generated
vendored
Normal file
8
Frontend-Learner/node_modules/unplugin-vue-router/dist/webpack.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "./options-CAGVi1wo.mjs";
|
||||
import { n as src_default } from "./src-CZrWKhKa.mjs";
|
||||
|
||||
//#region src/webpack.ts
|
||||
var webpack_default = src_default.webpack;
|
||||
|
||||
//#endregion
|
||||
export { webpack_default as default };
|
||||
43
Frontend-Learner/node_modules/unplugin-vue-router/node_modules/unplugin-utils/LICENSE
generated
vendored
Normal file
43
Frontend-Learner/node_modules/unplugin-vue-router/node_modules/unplugin-utils/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright © 2025-PRESENT Kevin Deng (https://github.com/sxzz)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
74
Frontend-Learner/node_modules/unplugin-vue-router/node_modules/unplugin-utils/README.md
generated
vendored
Normal file
74
Frontend-Learner/node_modules/unplugin-vue-router/node_modules/unplugin-utils/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
# unplugin-utils
|
||||
|
||||
[![npm version][npm-version-src]][npm-version-href]
|
||||
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
||||
[![Unit Test][unit-test-src]][unit-test-href]
|
||||
[![codecov][codecov-src]][codecov-href]
|
||||
|
||||
A set of utility functions commonly used by unplugins.
|
||||
|
||||
Thanks to [@rollup/pluginutils](https://github.com/rollup/plugins/tree/master/packages/pluginutils). This projects is heavily copied from it.
|
||||
|
||||
## Why Fork?
|
||||
|
||||
- 🌍 Platform agnostic, supports running in the browser, Node.js...
|
||||
- ✂️ Subset, smaller bundle size.
|
||||
- **💯 Coverage**: 100% test coverage.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm i unplugin-utils
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### createFilter
|
||||
|
||||
```ts
|
||||
export default function myPlugin(options = {}) {
|
||||
const filter = createFilter(options.include, options.exclude)
|
||||
|
||||
return {
|
||||
transform(code, id) {
|
||||
if (!filter(id)) return
|
||||
|
||||
// proceed with the transformation...
|
||||
},
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### normalizePath
|
||||
|
||||
```ts
|
||||
import { normalizePath } from 'unplugin-utils'
|
||||
|
||||
normalizePath(String.raw`foo\bar`) // 'foo/bar'
|
||||
normalizePath('foo/bar') // 'foo/bar'
|
||||
```
|
||||
|
||||
## Sponsors
|
||||
|
||||
<p align="center">
|
||||
<a href="https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg">
|
||||
<img src='https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg'/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE) License © 2025-PRESENT [Kevin Deng](https://github.com/sxzz)
|
||||
|
||||
[MIT](./LICENSE) Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)
|
||||
|
||||
<!-- Badges -->
|
||||
|
||||
[npm-version-src]: https://img.shields.io/npm/v/unplugin-utils.svg
|
||||
[npm-version-href]: https://npmjs.com/package/unplugin-utils
|
||||
[npm-downloads-src]: https://img.shields.io/npm/dm/unplugin-utils
|
||||
[npm-downloads-href]: https://www.npmcharts.com/compare/unplugin-utils?interval=30
|
||||
[unit-test-src]: https://github.com/sxzz/unplugin-utils/actions/workflows/unit-test.yml/badge.svg
|
||||
[unit-test-href]: https://github.com/sxzz/unplugin-utils/actions/workflows/unit-test.yml
|
||||
[codecov-src]: https://codecov.io/gh/sxzz/unplugin-utils/graph/badge.svg?token=VDWXCPSL1O
|
||||
[codecov-href]: https://codecov.io/gh/sxzz/unplugin-utils
|
||||
31
Frontend-Learner/node_modules/unplugin-vue-router/node_modules/unplugin-utils/dist/index.d.ts
generated
vendored
Normal file
31
Frontend-Learner/node_modules/unplugin-vue-router/node_modules/unplugin-utils/dist/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//#region src/filter.d.ts
|
||||
/**
|
||||
* A valid `picomatch` glob pattern, or array of patterns.
|
||||
*/
|
||||
type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
|
||||
/**
|
||||
* Constructs a filter function which can be used to determine whether or not
|
||||
* certain modules should be operated upon.
|
||||
* @param include If `include` is omitted or has zero length, filter will return `true` by default.
|
||||
* @param exclude ID must not match any of the `exclude` patterns.
|
||||
* @param options Additional options.
|
||||
* @param options.resolve Optionally resolves the patterns against a directory other than `process.cwd()`.
|
||||
* If a `string` is specified, then the value will be used as the base directory.
|
||||
* Relative paths will be resolved against `process.cwd()` first.
|
||||
* If `false`, then the patterns will not be resolved against any directory.
|
||||
* This can be useful if you want to create a filter for virtual module names.
|
||||
*/
|
||||
declare function createFilter(include?: FilterPattern, exclude?: FilterPattern, options?: {
|
||||
resolve?: string | false | null;
|
||||
}): (id: string | unknown) => boolean;
|
||||
//#endregion
|
||||
//#region src/path.d.ts
|
||||
/**
|
||||
* Converts path separators to forward slash.
|
||||
*/
|
||||
declare function normalizePath(filename: string): string;
|
||||
//#endregion
|
||||
//#region src/utils.d.ts
|
||||
declare function toArray<T>(thing: readonly T[] | T | undefined | null): readonly T[];
|
||||
//#endregion
|
||||
export { FilterPattern, createFilter, normalizePath, toArray };
|
||||
67
Frontend-Learner/node_modules/unplugin-vue-router/node_modules/unplugin-utils/dist/index.js
generated
vendored
Normal file
67
Frontend-Learner/node_modules/unplugin-vue-router/node_modules/unplugin-utils/dist/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import { isAbsolute, join, resolve } from "pathe";
|
||||
import pm from "picomatch";
|
||||
|
||||
//#region src/path.ts
|
||||
/**
|
||||
* Converts path separators to forward slash.
|
||||
*/
|
||||
function normalizePath(filename) {
|
||||
return filename.replaceAll("\\", "/");
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/utils.ts
|
||||
const isArray = Array.isArray;
|
||||
function toArray(thing) {
|
||||
if (isArray(thing)) return thing;
|
||||
if (thing == null) return [];
|
||||
return [thing];
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/filter.ts
|
||||
const escapeMark = "[_#EsCaPe#_]";
|
||||
function getMatcherString(id, resolutionBase) {
|
||||
if (resolutionBase === false || isAbsolute(id) || id.startsWith("**")) return normalizePath(id);
|
||||
const basePath = normalizePath(resolve(resolutionBase || "")).replaceAll(/[-^$*+?.()|[\]{}]/g, `${escapeMark}$&`);
|
||||
return join(basePath, normalizePath(id)).replaceAll(escapeMark, "\\");
|
||||
}
|
||||
/**
|
||||
* Constructs a filter function which can be used to determine whether or not
|
||||
* certain modules should be operated upon.
|
||||
* @param include If `include` is omitted or has zero length, filter will return `true` by default.
|
||||
* @param exclude ID must not match any of the `exclude` patterns.
|
||||
* @param options Additional options.
|
||||
* @param options.resolve Optionally resolves the patterns against a directory other than `process.cwd()`.
|
||||
* If a `string` is specified, then the value will be used as the base directory.
|
||||
* Relative paths will be resolved against `process.cwd()` first.
|
||||
* If `false`, then the patterns will not be resolved against any directory.
|
||||
* This can be useful if you want to create a filter for virtual module names.
|
||||
*/
|
||||
function createFilter(include, exclude, options) {
|
||||
const resolutionBase = options && options.resolve;
|
||||
const getMatcher = (id) => id instanceof RegExp ? id : { test: (what) => {
|
||||
const pattern = getMatcherString(id, resolutionBase);
|
||||
return pm(pattern, { dot: true })(what);
|
||||
} };
|
||||
const includeMatchers = toArray(include).map(getMatcher);
|
||||
const excludeMatchers = toArray(exclude).map(getMatcher);
|
||||
if (!includeMatchers.length && !excludeMatchers.length) return (id) => typeof id === "string" && !id.includes("\0");
|
||||
return function result(id) {
|
||||
if (typeof id !== "string") return false;
|
||||
if (id.includes("\0")) return false;
|
||||
const pathId = normalizePath(id);
|
||||
for (const matcher of excludeMatchers) {
|
||||
if (matcher instanceof RegExp) matcher.lastIndex = 0;
|
||||
if (matcher.test(pathId)) return false;
|
||||
}
|
||||
for (const matcher of includeMatchers) {
|
||||
if (matcher instanceof RegExp) matcher.lastIndex = 0;
|
||||
if (matcher.test(pathId)) return true;
|
||||
}
|
||||
return !includeMatchers.length;
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { createFilter, normalizePath, toArray };
|
||||
67
Frontend-Learner/node_modules/unplugin-vue-router/node_modules/unplugin-utils/package.json
generated
vendored
Normal file
67
Frontend-Learner/node_modules/unplugin-vue-router/node_modules/unplugin-utils/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
"name": "unplugin-utils",
|
||||
"version": "0.3.1",
|
||||
"description": "A set of utility functions commonly used by unplugins.",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/sxzz/unplugin-utils#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sxzz/unplugin-utils/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sxzz/unplugin-utils.git"
|
||||
},
|
||||
"author": "Kevin Deng <sxzz@sxzz.moe>",
|
||||
"funding": "https://github.com/sponsors/sxzz",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"pathe": "^2.0.3",
|
||||
"picomatch": "^4.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sxzz/eslint-config": "^7.2.7",
|
||||
"@sxzz/prettier-config": "^2.2.4",
|
||||
"@types/node": "^24.7.0",
|
||||
"@types/picomatch": "^4.0.2",
|
||||
"@vitest/coverage-v8": "3.2.4",
|
||||
"bumpp": "^10.3.1",
|
||||
"eslint": "^9.37.0",
|
||||
"oxc-transform": "^0.94.0",
|
||||
"prettier": "^3.6.2",
|
||||
"tsdown": "^0.15.6",
|
||||
"tsx": "^4.20.6",
|
||||
"typescript": "^5.9.3",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.19.0"
|
||||
},
|
||||
"prettier": "@sxzz/prettier-config",
|
||||
"tsdown": {
|
||||
"platform": "neutral",
|
||||
"exports": true
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --cache .",
|
||||
"lint:fix": "pnpm run lint --fix",
|
||||
"build": "tsdown",
|
||||
"dev": "tsdown --watch",
|
||||
"test": "vitest",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"format": "prettier --cache --write .",
|
||||
"release": "bumpp"
|
||||
}
|
||||
}
|
||||
225
Frontend-Learner/node_modules/unplugin-vue-router/package.json
generated
vendored
Normal file
225
Frontend-Learner/node_modules/unplugin-vue-router/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
{
|
||||
"name": "unplugin-vue-router",
|
||||
"version": "0.19.2",
|
||||
"type": "module",
|
||||
"description": "File based typed routing for Vue Router",
|
||||
"keywords": [
|
||||
"unplugin",
|
||||
"vite",
|
||||
"webpack",
|
||||
"rolldown",
|
||||
"rollup",
|
||||
"vue-router",
|
||||
"pages",
|
||||
"filesystem",
|
||||
"types",
|
||||
"typed",
|
||||
"vue",
|
||||
"nuxt",
|
||||
"router"
|
||||
],
|
||||
"homepage": "https://uvr.esm.is",
|
||||
"bugs": {
|
||||
"url": "https://github.com/posva/unplugin-vue-router/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": "posva/unplugin-vue-router",
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.mts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"./vite": {
|
||||
"import": "./dist/vite.mjs",
|
||||
"require": "./dist/vite.cjs"
|
||||
},
|
||||
"./webpack": {
|
||||
"import": "./dist/webpack.mjs",
|
||||
"require": "./dist/webpack.cjs"
|
||||
},
|
||||
"./rolldown": {
|
||||
"import": "./dist/rolldown.mjs",
|
||||
"require": "./dist/rolldown.cjs"
|
||||
},
|
||||
"./rollup": {
|
||||
"import": "./dist/rollup.mjs",
|
||||
"require": "./dist/rollup.cjs"
|
||||
},
|
||||
"./esbuild": {
|
||||
"import": "./dist/esbuild.mjs",
|
||||
"require": "./dist/esbuild.cjs"
|
||||
},
|
||||
"./options": {
|
||||
"import": "./dist/options.mjs",
|
||||
"require": "./dist/options.cjs"
|
||||
},
|
||||
"./runtime": {
|
||||
"import": "./dist/runtime.mjs",
|
||||
"require": "./dist/runtime.cjs"
|
||||
},
|
||||
"./types": {
|
||||
"types": {
|
||||
"import": "./dist/types.d.mts",
|
||||
"require": "./dist/types.d.cts"
|
||||
}
|
||||
},
|
||||
"./data-loaders": {
|
||||
"import": "./dist/data-loaders/index.mjs",
|
||||
"require": "./dist/data-loaders/index.cjs"
|
||||
},
|
||||
"./data-loaders/basic": {
|
||||
"import": "./dist/data-loaders/basic.mjs",
|
||||
"require": "./dist/data-loaders/basic.cjs"
|
||||
},
|
||||
"./data-loaders/pinia-colada": {
|
||||
"import": "./dist/data-loaders/pinia-colada.mjs",
|
||||
"require": "./dist/data-loaders/pinia-colada.cjs"
|
||||
},
|
||||
"./volar/sfc-route-blocks": {
|
||||
"types": "./dist/volar/sfc-route-blocks.d.cts",
|
||||
"default": "./dist/volar/sfc-route-blocks.cjs"
|
||||
},
|
||||
"./volar/sfc-typed-router": {
|
||||
"types": "./dist/volar/sfc-typed-router.d.cts",
|
||||
"default": "./dist/volar/sfc-typed-router.cjs"
|
||||
},
|
||||
"./client": {
|
||||
"types": "./client.d.ts"
|
||||
}
|
||||
},
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"data-loaders": [
|
||||
"./dist/data-loaders/index.d.mts"
|
||||
],
|
||||
"data-loaders/basic": [
|
||||
"./dist/data-loaders/basic.d.mts"
|
||||
],
|
||||
"data-loaders/pinia-colada": [
|
||||
"./dist/data-loaders/pinia-colada.d.mts"
|
||||
],
|
||||
"volar/sfc-route-blocks": [
|
||||
"./dist/volar/sfc-route-blocks.d.cts"
|
||||
],
|
||||
"volar/sfc-typed-router": [
|
||||
"./dist/volar/sfc-typed-router.d.cts"
|
||||
],
|
||||
"*": [
|
||||
"./dist/*",
|
||||
"./*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"client.d.ts",
|
||||
"route.schema.json"
|
||||
],
|
||||
"gitHooks": {
|
||||
"pre-commit": "lint-staged",
|
||||
"commit-msg": "node scripts/verifyCommit.mjs"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,mjs,json,cjs,md}": [
|
||||
"prettier --write"
|
||||
],
|
||||
"*.ts?(x)": [
|
||||
"prettier --parser=typescript --write"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/generator": "^7.28.5",
|
||||
"@vue-macros/common": "^3.1.1",
|
||||
"@vue/language-core": "^3.2.1",
|
||||
"ast-walker-scope": "^0.8.3",
|
||||
"chokidar": "^5.0.0",
|
||||
"json5": "^2.2.3",
|
||||
"local-pkg": "^1.1.2",
|
||||
"magic-string": "^0.30.21",
|
||||
"mlly": "^1.8.0",
|
||||
"muggle-string": "^0.4.1",
|
||||
"pathe": "^2.0.3",
|
||||
"picomatch": "^4.0.3",
|
||||
"scule": "^1.3.0",
|
||||
"tinyglobby": "^0.2.15",
|
||||
"unplugin": "^2.3.11",
|
||||
"unplugin-utils": "^0.3.1",
|
||||
"yaml": "^2.8.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@vue/compiler-sfc": "^3.5.17",
|
||||
"vue-router": "^4.6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"vue-router": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/types": "^7.28.5",
|
||||
"@pinia/colada": "^0.18.1",
|
||||
"@playwright/test": "^1.57.0",
|
||||
"@posva/prompts": "^2.4.4",
|
||||
"@shikijs/vitepress-twoslash": "3.20.0",
|
||||
"@tanstack/vue-query": "^5.92.1",
|
||||
"@types/babel__generator": "^7.27.0",
|
||||
"@types/node": "^24.10.1",
|
||||
"@types/picomatch": "^4.0.2",
|
||||
"@vitest/coverage-v8": "^4.0.16",
|
||||
"@vitest/ui": "^4.0.16",
|
||||
"@vue/language-core": "^3.1.5",
|
||||
"@vue/test-utils": "^2.4.6",
|
||||
"chalk": "^5.6.2",
|
||||
"conventional-changelog": "^7.1.1",
|
||||
"conventional-changelog-angular": "^8.1.0",
|
||||
"execa": "^9.6.1",
|
||||
"happy-dom": "^20.0.11",
|
||||
"lint-staged": "^16.2.7",
|
||||
"nodemon": "^3.1.11",
|
||||
"pinia": "^3.0.4",
|
||||
"prettier": "^3.7.4",
|
||||
"rimraf": "^6.1.2",
|
||||
"rolldown": "1.0.0-beta.54",
|
||||
"rollup": "^4.54.0",
|
||||
"semver": "^7.7.3",
|
||||
"ts-expect": "^1.3.0",
|
||||
"tsdown": "0.17.4",
|
||||
"typescript": "^5.9.3",
|
||||
"unplugin-auto-import": "^20.3.0",
|
||||
"unplugin-vue-markdown": "^29.2.0",
|
||||
"vite": "^7.3.0",
|
||||
"vite-plugin-vue-devtools": "^8.0.5",
|
||||
"vitepress": "^1.6.4",
|
||||
"vitepress-plugin-llms": "^1.10.0",
|
||||
"vitest": "^4.0.16",
|
||||
"vue": "^3.5.26",
|
||||
"vue-router": "^4.6.4",
|
||||
"vue-router-mock": "^2.0.0",
|
||||
"vue-tsc": "^3.2.1",
|
||||
"vuefire": "^3.2.2",
|
||||
"webpack": "^5.104.1",
|
||||
"yorkie": "^2.0.0",
|
||||
"unplugin-vue-router": "0.19.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "pnpm run --stream \"/^build:/\"",
|
||||
"build:core": "tsdown",
|
||||
"build:runtime": "tsdown --config tsdown-runtime.config.ts",
|
||||
"dev": "pnpm run vitest --ui",
|
||||
"vitest": "vitest --typecheck",
|
||||
"playwright": "playwright test",
|
||||
"docs": "vitepress dev docs",
|
||||
"docs:build": "vitepress build docs",
|
||||
"docs:preview": "vitepress preview docs",
|
||||
"lint": "prettier -c '{src,test,e2e,examples,playground}/**/*.{ts,vue}'",
|
||||
"play": "pnpm -C playground run dev",
|
||||
"play:build": "pnpm -C playground run build",
|
||||
"release": "node scripts/release.ts",
|
||||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
|
||||
"pretest": "pnpm run lint",
|
||||
"test": "pnpm run build && vitest --typecheck --coverage run && pnpm run playwright && pnpm run docs:build"
|
||||
}
|
||||
}
|
||||
25
Frontend-Learner/node_modules/unplugin-vue-router/route.schema.json
generated
vendored
Normal file
25
Frontend-Learner/node_modules/unplugin-vue-router/route.schema.json
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://raw.githubusercontent.com/posva/unplugin-vue-router/main/route.schema.json",
|
||||
"title": "Route custom block",
|
||||
"description": "An SFC custom block to add information to a route",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "The name of the route"
|
||||
},
|
||||
"path": {
|
||||
"type": "string",
|
||||
"description": "The path of the route"
|
||||
},
|
||||
"meta": {
|
||||
"type": "object",
|
||||
"description": "The meta of the route"
|
||||
},
|
||||
"props": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the route should be passed its params as props"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue