initial commit

This commit is contained in:
Zoe
2023-01-03 09:29:04 -06:00
commit 7851137d88
12889 changed files with 2557443 additions and 0 deletions

40
node_modules/nuxt/dist/app/composables/asyncData.d.ts generated vendored Normal file
View File

@@ -0,0 +1,40 @@
import type { Ref, WatchSource } from 'vue';
import { NuxtApp } from '../nuxt';
export type _Transform<Input = any, Output = any> = (input: Input) => Output;
export type PickFrom<T, K extends Array<string>> = T extends Array<any> ? T : T extends Record<string, any> ? keyof T extends K[number] ? T : Pick<T, K[number]> : T;
export type KeysOf<T> = Array<T extends T ? keyof T extends string ? keyof T : string : never>;
export type KeyOfRes<Transform extends _Transform> = KeysOf<ReturnType<Transform>>;
type MultiWatchSources = (WatchSource<unknown> | object)[];
export interface AsyncDataOptions<DataT, Transform extends _Transform<DataT, any> = _Transform<DataT, DataT>, PickKeys extends KeyOfRes<_Transform> = KeyOfRes<Transform>> {
server?: boolean;
lazy?: boolean;
default?: () => DataT | Ref<DataT> | null;
transform?: Transform;
pick?: PickKeys;
watch?: MultiWatchSources;
immediate?: boolean;
}
export interface AsyncDataExecuteOptions {
_initial?: boolean;
/**
* Force a refresh, even if there is already a pending request. Previous requests will
* not be cancelled, but their result will not affect the data/pending state - and any
* previously awaited promises will not resolve until this new request resolves.
*/
dedupe?: boolean;
}
export interface _AsyncData<DataT, ErrorT> {
data: Ref<DataT | null>;
pending: Ref<boolean>;
refresh: (opts?: AsyncDataExecuteOptions) => Promise<void>;
execute: (opts?: AsyncDataExecuteOptions) => Promise<void>;
error: Ref<ErrorT | null>;
}
export type AsyncData<Data, Error> = _AsyncData<Data, Error> & Promise<_AsyncData<Data, Error>>;
export declare function useAsyncData<DataT, DataE = Error, Transform extends _Transform<DataT> = _Transform<DataT, DataT>, PickKeys extends KeyOfRes<Transform> = KeyOfRes<Transform>>(handler: (ctx?: NuxtApp) => Promise<DataT>, options?: AsyncDataOptions<DataT, Transform, PickKeys>): AsyncData<PickFrom<ReturnType<Transform>, PickKeys>, DataE | null>;
export declare function useAsyncData<DataT, DataE = Error, Transform extends _Transform<DataT> = _Transform<DataT, DataT>, PickKeys extends KeyOfRes<Transform> = KeyOfRes<Transform>>(key: string, handler: (ctx?: NuxtApp) => Promise<DataT>, options?: AsyncDataOptions<DataT, Transform, PickKeys>): AsyncData<PickFrom<ReturnType<Transform>, PickKeys>, DataE | null>;
export declare function useLazyAsyncData<DataT, DataE = Error, Transform extends _Transform<DataT> = _Transform<DataT, DataT>, PickKeys extends KeyOfRes<Transform> = KeyOfRes<Transform>>(handler: (ctx?: NuxtApp) => Promise<DataT>, options?: Omit<AsyncDataOptions<DataT, Transform, PickKeys>, 'lazy'>): AsyncData<PickFrom<ReturnType<Transform>, PickKeys>, DataE | null>;
export declare function useLazyAsyncData<DataT, DataE = Error, Transform extends _Transform<DataT> = _Transform<DataT, DataT>, PickKeys extends KeyOfRes<Transform> = KeyOfRes<Transform>>(key: string, handler: (ctx?: NuxtApp) => Promise<DataT>, options?: Omit<AsyncDataOptions<DataT, Transform, PickKeys>, 'lazy'>): AsyncData<PickFrom<ReturnType<Transform>, PickKeys>, DataE | null>;
export declare function refreshNuxtData(keys?: string | string[]): Promise<void>;
export declare function clearNuxtData(keys?: string | string[] | ((key: string) => boolean)): void;
export {};

169
node_modules/nuxt/dist/app/composables/asyncData.mjs generated vendored Normal file
View File

@@ -0,0 +1,169 @@
import { onBeforeMount, onServerPrefetch, onUnmounted, ref, getCurrentInstance, watch, unref } from "vue";
import { useNuxtApp } from "../nuxt.mjs";
import { createError } from "./error.mjs";
const getDefault = () => null;
export function useAsyncData(...args) {
const autoKey = typeof args[args.length - 1] === "string" ? args.pop() : void 0;
if (typeof args[0] !== "string") {
args.unshift(autoKey);
}
let [key, handler, options = {}] = args;
if (typeof key !== "string") {
throw new TypeError("[nuxt] [asyncData] key must be a string.");
}
if (typeof handler !== "function") {
throw new TypeError("[nuxt] [asyncData] handler must be a function.");
}
options.server = options.server ?? true;
options.default = options.default ?? getDefault;
options.lazy = options.lazy ?? false;
options.immediate = options.immediate ?? true;
const nuxt = useNuxtApp();
const getCachedData = () => nuxt.isHydrating ? nuxt.payload.data[key] : nuxt.static.data[key];
const hasCachedData = () => getCachedData() !== void 0;
if (!nuxt._asyncData[key]) {
nuxt._asyncData[key] = {
data: ref(getCachedData() ?? options.default?.() ?? null),
pending: ref(!hasCachedData()),
error: ref(nuxt.payload._errors[key] ? createError(nuxt.payload._errors[key]) : null)
};
}
const asyncData = { ...nuxt._asyncData[key] };
asyncData.refresh = asyncData.execute = (opts = {}) => {
if (nuxt._asyncDataPromises[key]) {
if (opts.dedupe === false) {
return nuxt._asyncDataPromises[key];
}
nuxt._asyncDataPromises[key].cancelled = true;
}
if (opts._initial && hasCachedData()) {
return getCachedData();
}
asyncData.pending.value = true;
const promise = new Promise(
(resolve, reject) => {
try {
resolve(handler(nuxt));
} catch (err) {
reject(err);
}
}
).then((result) => {
if (promise.cancelled) {
return nuxt._asyncDataPromises[key];
}
if (options.transform) {
result = options.transform(result);
}
if (options.pick) {
result = pick(result, options.pick);
}
asyncData.data.value = result;
asyncData.error.value = null;
}).catch((error) => {
if (promise.cancelled) {
return nuxt._asyncDataPromises[key];
}
asyncData.error.value = error;
asyncData.data.value = unref(options.default?.() ?? null);
}).finally(() => {
if (promise.cancelled) {
return;
}
asyncData.pending.value = false;
nuxt.payload.data[key] = asyncData.data.value;
if (asyncData.error.value) {
nuxt.payload._errors[key] = createError(asyncData.error.value);
}
delete nuxt._asyncDataPromises[key];
});
nuxt._asyncDataPromises[key] = promise;
return nuxt._asyncDataPromises[key];
};
const initialFetch = () => asyncData.refresh({ _initial: true });
const fetchOnServer = options.server !== false && nuxt.payload.serverRendered;
if (process.server && fetchOnServer && options.immediate) {
const promise = initialFetch();
onServerPrefetch(() => promise);
}
if (process.client) {
const instance = getCurrentInstance();
if (instance && !instance._nuxtOnBeforeMountCbs) {
instance._nuxtOnBeforeMountCbs = [];
const cbs = instance._nuxtOnBeforeMountCbs;
if (instance) {
onBeforeMount(() => {
cbs.forEach((cb) => {
cb();
});
cbs.splice(0, cbs.length);
});
onUnmounted(() => cbs.splice(0, cbs.length));
}
}
if (fetchOnServer && nuxt.isHydrating && hasCachedData()) {
asyncData.pending.value = false;
} else if (instance && (nuxt.payload.serverRendered && nuxt.isHydrating || options.lazy) && options.immediate) {
instance._nuxtOnBeforeMountCbs.push(initialFetch);
} else if (options.immediate) {
initialFetch();
}
if (options.watch) {
watch(options.watch, () => asyncData.refresh());
}
const off = nuxt.hook("app:data:refresh", (keys) => {
if (!keys || keys.includes(key)) {
return asyncData.refresh();
}
});
if (instance) {
onUnmounted(off);
}
}
const asyncDataPromise = Promise.resolve(nuxt._asyncDataPromises[key]).then(() => asyncData);
Object.assign(asyncDataPromise, asyncData);
return asyncDataPromise;
}
export function useLazyAsyncData(...args) {
const autoKey = typeof args[args.length - 1] === "string" ? args.pop() : void 0;
if (typeof args[0] !== "string") {
args.unshift(autoKey);
}
const [key, handler, options] = args;
return useAsyncData(key, handler, { ...options, lazy: true }, null);
}
export async function refreshNuxtData(keys) {
if (process.server) {
return Promise.resolve();
}
const _keys = keys ? Array.isArray(keys) ? keys : [keys] : void 0;
await useNuxtApp().hooks.callHookParallel("app:data:refresh", _keys);
}
export function clearNuxtData(keys) {
const nuxtApp = useNuxtApp();
const _allKeys = Object.keys(nuxtApp.payload.data);
const _keys = !keys ? _allKeys : typeof keys === "function" ? _allKeys.filter(keys) : Array.isArray(keys) ? keys : [keys];
for (const key of _keys) {
if (key in nuxtApp.payload.data) {
nuxtApp.payload.data[key] = void 0;
}
if (key in nuxtApp.payload._errors) {
nuxtApp.payload._errors[key] = void 0;
}
if (nuxtApp._asyncData[key]) {
nuxtApp._asyncData[key].data.value = void 0;
nuxtApp._asyncData[key].error.value = void 0;
nuxtApp._asyncData[key].pending.value = false;
}
if (key in nuxtApp._asyncDataPromises) {
nuxtApp._asyncDataPromises[key] = void 0;
}
}
}
function pick(obj, keys) {
const newObj = {};
for (const key of keys) {
newObj[key] = obj[key];
}
return newObj;
}

View File

@@ -0,0 +1,3 @@
import { defineComponent } from 'vue';
export declare const NuxtComponentIndicator = "__nuxt_component";
export declare const defineNuxtComponent: typeof defineComponent;

46
node_modules/nuxt/dist/app/composables/component.mjs generated vendored Normal file
View File

@@ -0,0 +1,46 @@
import { getCurrentInstance, reactive, toRefs } from "vue";
import { useNuxtApp } from "../nuxt.mjs";
import { useAsyncData } from "./asyncData.mjs";
import { useRoute } from "./router.mjs";
import { useHead } from "#head";
export const NuxtComponentIndicator = "__nuxt_component";
async function runLegacyAsyncData(res, fn) {
const nuxt = useNuxtApp();
const route = useRoute();
const vm = getCurrentInstance();
const { fetchKey } = vm.proxy.$options;
const key = typeof fetchKey === "function" ? fetchKey(() => "") : fetchKey || route.fullPath;
const { data } = await useAsyncData(`options:asyncdata:${key}`, () => fn(nuxt));
if (data.value && typeof data.value === "object") {
Object.assign(await res, toRefs(reactive(data.value)));
} else if (process.dev) {
console.warn("[nuxt] asyncData should return an object", data);
}
}
export const defineNuxtComponent = function defineNuxtComponent2(options) {
const { setup } = options;
if (!setup && !options.asyncData && !options.head) {
return {
[NuxtComponentIndicator]: true,
...options
};
}
return {
[NuxtComponentIndicator]: true,
...options,
setup(props, ctx) {
const res = setup?.(props, ctx) || {};
const promises = [];
if (options.asyncData) {
promises.push(runLegacyAsyncData(res, options.asyncData));
}
if (options.head) {
const nuxtApp = useNuxtApp();
useHead(typeof options.head === "function" ? () => options.head(nuxtApp) : options.head);
}
return Promise.resolve(res).then(() => Promise.all(promises)).then(() => res).finally(() => {
promises.length = 0;
});
}
};
};

12
node_modules/nuxt/dist/app/composables/cookie.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
import { Ref } from 'vue';
import { CookieParseOptions, CookieSerializeOptions } from 'cookie-es';
type _CookieOptions = Omit<CookieSerializeOptions & CookieParseOptions, 'decode' | 'encode'>;
export interface CookieOptions<T = any> extends _CookieOptions {
decode?(value: string): T;
encode?(value: T): string;
default?: () => T | Ref<T>;
}
export interface CookieRef<T> extends Ref<T | null> {
}
export declare function useCookie<T = string>(name: string, _opts?: CookieOptions<T>): CookieRef<T>;
export {};

58
node_modules/nuxt/dist/app/composables/cookie.mjs generated vendored Normal file
View File

@@ -0,0 +1,58 @@
import { ref, watch } from "vue";
import { parse, serialize } from "cookie-es";
import { appendHeader } from "h3";
import destr from "destr";
import { isEqual } from "ohash";
import { useNuxtApp } from "../nuxt.mjs";
import { useRequestEvent } from "./ssr.mjs";
const CookieDefaults = {
path: "/",
decode: (val) => destr(decodeURIComponent(val)),
encode: (val) => encodeURIComponent(typeof val === "string" ? val : JSON.stringify(val))
};
export function useCookie(name, _opts) {
const opts = { ...CookieDefaults, ..._opts };
const cookies = readRawCookies(opts) || {};
const cookie = ref(cookies[name] ?? opts.default?.());
if (process.client) {
watch(cookie, () => {
writeClientCookie(name, cookie.value, opts);
});
} else if (process.server) {
const nuxtApp = useNuxtApp();
const writeFinalCookieValue = () => {
if (!isEqual(cookie.value, cookies[name])) {
writeServerCookie(useRequestEvent(nuxtApp), name, cookie.value, opts);
}
};
const unhook = nuxtApp.hooks.hookOnce("app:rendered", writeFinalCookieValue);
nuxtApp.hooks.hookOnce("app:redirected", () => {
unhook();
return writeFinalCookieValue();
});
}
return cookie;
}
function readRawCookies(opts = {}) {
if (process.server) {
return parse(useRequestEvent()?.req.headers.cookie || "", opts);
} else if (process.client) {
return parse(document.cookie, opts);
}
}
function serializeCookie(name, value, opts = {}) {
if (value === null || value === void 0) {
return serialize(name, value, { ...opts, maxAge: -1 });
}
return serialize(name, value, opts);
}
function writeClientCookie(name, value, opts = {}) {
if (process.client) {
document.cookie = serializeCookie(name, value, opts);
}
}
function writeServerCookie(event, name, value, opts = {}) {
if (event) {
appendHeader(event, "Set-Cookie", serializeCookie(name, value, opts));
}
}

17
node_modules/nuxt/dist/app/composables/error.d.ts generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import { H3Error } from 'h3';
export declare const useError: () => import("vue").Ref<Error | {
url: string;
statusCode: string;
statusMessage: string;
message: string;
description: string;
data?: any;
} | null | undefined>;
export interface NuxtError extends H3Error {
}
export declare const showError: (_err: string | Error | Partial<NuxtError>) => NuxtError;
export declare const clearError: (options?: {
redirect?: string;
}) => Promise<void>;
export declare const isNuxtError: (err?: string | object) => err is NuxtError;
export declare const createError: (err: string | Partial<NuxtError>) => NuxtError;

31
node_modules/nuxt/dist/app/composables/error.mjs generated vendored Normal file
View File

@@ -0,0 +1,31 @@
import { createError as _createError } from "h3";
import { toRef } from "vue";
import { useNuxtApp } from "../nuxt.mjs";
export const useError = () => toRef(useNuxtApp().payload, "error");
export const showError = (_err) => {
const err = createError(_err);
try {
const nuxtApp = useNuxtApp();
nuxtApp.callHook("app:error", err);
const error = useError();
error.value = error.value || err;
} catch {
throw err;
}
return err;
};
export const clearError = async (options = {}) => {
const nuxtApp = useNuxtApp();
const error = useError();
nuxtApp.callHook("app:error:cleared", options);
if (options.redirect) {
await nuxtApp.$router.replace(options.redirect);
}
error.value = null;
};
export const isNuxtError = (err) => !!(err && typeof err === "object" && "__nuxt_error" in err);
export const createError = (err) => {
const _err = _createError(err);
_err.__nuxt_error = true;
return _err;
};

15
node_modules/nuxt/dist/app/composables/fetch.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import type { FetchError, FetchOptions } from 'ofetch';
import type { TypedInternalResponse, NitroFetchRequest } from 'nitropack';
import { Ref } from 'vue';
import type { AsyncDataOptions, _Transform, KeyOfRes, AsyncData, PickFrom } from './asyncData';
export type FetchResult<ReqT extends NitroFetchRequest> = TypedInternalResponse<ReqT, unknown>;
type ComputedOptions<T extends Record<string, any>> = {
[K in keyof T]: T[K] extends Function ? T[K] : T[K] extends Record<string, any> ? ComputedOptions<T[K]> | Ref<T[K]> | T[K] : Ref<T[K]> | T[K];
};
type ComputedFetchOptions = ComputedOptions<FetchOptions>;
export interface UseFetchOptions<DataT, Transform extends _Transform<DataT, any> = _Transform<DataT, DataT>, PickKeys extends KeyOfRes<Transform> = KeyOfRes<Transform>> extends AsyncDataOptions<DataT, Transform, PickKeys>, ComputedFetchOptions {
key?: string;
}
export declare function useFetch<ResT = void, ErrorT = FetchError, ReqT extends NitroFetchRequest = NitroFetchRequest, _ResT = ResT extends void ? FetchResult<ReqT> : ResT, Transform extends (res: _ResT) => any = (res: _ResT) => _ResT, PickKeys extends KeyOfRes<Transform> = KeyOfRes<Transform>>(request: Ref<ReqT> | ReqT | (() => ReqT), opts?: UseFetchOptions<_ResT, Transform, PickKeys>): AsyncData<PickFrom<ReturnType<Transform>, PickKeys>, ErrorT | null>;
export declare function useLazyFetch<ResT = void, ErrorT = FetchError, ReqT extends NitroFetchRequest = NitroFetchRequest, _ResT = ResT extends void ? FetchResult<ReqT> : ResT, Transform extends (res: _ResT) => any = (res: _ResT) => _ResT, PickKeys extends KeyOfRes<Transform> = KeyOfRes<Transform>>(request: Ref<ReqT> | ReqT | (() => ReqT), opts?: Omit<UseFetchOptions<_ResT, Transform, PickKeys>, 'lazy'>): AsyncData<PickFrom<ReturnType<Transform>, PickKeys>, ErrorT | null>;
export {};

66
node_modules/nuxt/dist/app/composables/fetch.mjs generated vendored Normal file
View File

@@ -0,0 +1,66 @@
import { computed, unref, reactive } from "vue";
import { hash } from "ohash";
import { useAsyncData } from "./asyncData.mjs";
export function useFetch(request, arg1, arg2) {
const [opts = {}, autoKey] = typeof arg1 === "string" ? [{}, arg1] : [arg1, arg2];
const _key = opts.key || hash([autoKey, unref(opts.baseURL), typeof request === "string" ? request : "", unref(opts.params)]);
if (!_key || typeof _key !== "string") {
throw new TypeError("[nuxt] [useFetch] key must be a string: " + _key);
}
if (!request) {
throw new Error("[nuxt] [useFetch] request is missing.");
}
const key = _key === autoKey ? "$f" + _key : _key;
const _request = computed(() => {
let r = request;
if (typeof r === "function") {
r = r();
}
return unref(r);
});
const {
server,
lazy,
default: defaultFn,
transform,
pick,
watch,
immediate,
...fetchOptions
} = opts;
const _fetchOptions = reactive({
...fetchOptions,
cache: typeof opts.cache === "boolean" ? void 0 : opts.cache
});
const _asyncDataOptions = {
server,
lazy,
default: defaultFn,
transform,
pick,
immediate,
watch: [
_fetchOptions,
_request,
...watch || []
]
};
let controller;
const asyncData = useAsyncData(key, () => {
controller?.abort?.();
controller = typeof AbortController !== "undefined" ? new AbortController() : {};
return $fetch(_request.value, { signal: controller.signal, ..._fetchOptions });
}, _asyncDataOptions);
return asyncData;
}
export function useLazyFetch(request, arg1, arg2) {
const [opts, autoKey] = typeof arg1 === "string" ? [{}, arg1] : [arg1, arg2];
return useFetch(
request,
{
...opts,
lazy: true
},
autoKey
);
}

8
node_modules/nuxt/dist/app/composables/hydrate.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
/**
* Allows full control of the hydration cycle to set and receive data from the server.
*
* @param key a unique key to identify the data in the Nuxt payload
* @param get a function that returns the value to set the initial data
* @param set a function that will receive the data on the client-side
*/
export declare const useHydration: <T>(key: string, get: () => T, set: (value: T) => void) => void;

14
node_modules/nuxt/dist/app/composables/hydrate.mjs generated vendored Normal file
View File

@@ -0,0 +1,14 @@
import { useNuxtApp } from "../nuxt.mjs";
export const useHydration = (key, get, set) => {
const nuxt = useNuxtApp();
if (process.server) {
nuxt.hooks.hook("app:rendered", () => {
nuxt.payload[key] = get();
});
}
if (process.client) {
nuxt.hooks.hook("app:created", () => {
set(nuxt.payload[key]);
});
}
};

16
node_modules/nuxt/dist/app/composables/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
export { defineNuxtComponent } from './component';
export { useAsyncData, useLazyAsyncData, refreshNuxtData, clearNuxtData } from './asyncData';
export type { AsyncDataOptions, AsyncData } from './asyncData';
export { useHydration } from './hydrate';
export { useState } from './state';
export { clearError, createError, isNuxtError, showError, useError } from './error';
export type { NuxtError } from './error';
export { useFetch, useLazyFetch } from './fetch';
export type { FetchResult, UseFetchOptions } from './fetch';
export { useCookie } from './cookie';
export type { CookieOptions, CookieRef } from './cookie';
export { useRequestHeaders, useRequestEvent, setResponseStatus } from './ssr';
export { abortNavigation, addRouteMiddleware, defineNuxtRouteMiddleware, onBeforeRouteLeave, onBeforeRouteUpdate, setPageLayout, navigateTo, useRoute, useRouter } from './router';
export type { AddRouteMiddlewareOptions, RouteMiddleware } from './router';
export { preloadComponents, prefetchComponents, preloadRouteComponents } from './preload';
export { isPrerendered, loadPayload, preloadPayload } from './payload';

11
node_modules/nuxt/dist/app/composables/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,11 @@
export { defineNuxtComponent } from "./component.mjs";
export { useAsyncData, useLazyAsyncData, refreshNuxtData, clearNuxtData } from "./asyncData.mjs";
export { useHydration } from "./hydrate.mjs";
export { useState } from "./state.mjs";
export { clearError, createError, isNuxtError, showError, useError } from "./error.mjs";
export { useFetch, useLazyFetch } from "./fetch.mjs";
export { useCookie } from "./cookie.mjs";
export { useRequestHeaders, useRequestEvent, setResponseStatus } from "./ssr.mjs";
export { abortNavigation, addRouteMiddleware, defineNuxtRouteMiddleware, onBeforeRouteLeave, onBeforeRouteUpdate, setPageLayout, navigateTo, useRoute, useRouter } from "./router.mjs";
export { preloadComponents, prefetchComponents, preloadRouteComponents } from "./preload.mjs";
export { isPrerendered, loadPayload, preloadPayload } from "./payload.mjs";

8
node_modules/nuxt/dist/app/composables/payload.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
interface LoadPayloadOptions {
fresh?: boolean;
hash?: string;
}
export declare function loadPayload(url: string, opts?: LoadPayloadOptions): any;
export declare function preloadPayload(url: string, opts?: LoadPayloadOptions): void;
export declare function isPrerendered(): boolean;
export {};

58
node_modules/nuxt/dist/app/composables/payload.mjs generated vendored Normal file
View File

@@ -0,0 +1,58 @@
import { joinURL } from "ufo";
import { useNuxtApp } from "../nuxt.mjs";
import { useHead, useRuntimeConfig } from "../index.mjs";
export function loadPayload(url, opts = {}) {
if (process.server) {
return null;
}
const payloadURL = _getPayloadURL(url, opts);
const nuxtApp = useNuxtApp();
const cache = nuxtApp._payloadCache = nuxtApp._payloadCache || {};
if (cache[url]) {
return cache[url];
}
cache[url] = _importPayload(payloadURL).then((payload) => {
if (!payload) {
delete cache[url];
return null;
}
return payload;
});
return cache[url];
}
export function preloadPayload(url, opts = {}) {
const payloadURL = _getPayloadURL(url, opts);
useHead({
link: [
{ rel: "modulepreload", href: payloadURL }
]
});
}
function _getPayloadURL(url, opts = {}) {
const u = new URL(url, "http://localhost");
if (u.search) {
throw new Error("Payload URL cannot contain search params: " + url);
}
if (u.host !== "localhost") {
throw new Error("Payload URL cannot contain host: " + url);
}
const hash = opts.hash || (opts.fresh ? Date.now() : "");
return joinURL(useRuntimeConfig().app.baseURL, u.pathname, hash ? `_payload.${hash}.js` : "_payload.js");
}
async function _importPayload(payloadURL) {
if (process.server) {
return null;
}
const res = await import(
/* webpackIgnore: true */
/* @vite-ignore */
payloadURL
).catch((err) => {
console.warn("[nuxt] Cannot load payload ", payloadURL, err);
});
return res?.default || null;
}
export function isPrerendered() {
const nuxtApp = useNuxtApp();
return !!nuxtApp.payload.prerenderedAt;
}

17
node_modules/nuxt/dist/app/composables/preload.d.ts generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import type { Router } from 'vue-router';
/**
* Preload a component or components that have been globally registered.
*
* @param components Pascal-cased name or names of components to prefetch
*/
export declare const preloadComponents: (components: string | string[]) => Promise<void>;
/**
* Prefetch a component or components that have been globally registered.
*
* @param components Pascal-cased name or names of components to prefetch
*/
export declare const prefetchComponents: (components: string | string[]) => Promise<void>;
export declare function preloadRouteComponents(to: string, router?: Router & {
_routePreloaded?: Set<string>;
_preloadPromises?: Array<Promise<any>>;
}): Promise<void>;

41
node_modules/nuxt/dist/app/composables/preload.mjs generated vendored Normal file
View File

@@ -0,0 +1,41 @@
import { useNuxtApp } from "../nuxt.mjs";
import { useRouter } from "./router.mjs";
export const preloadComponents = async (components) => {
if (process.server) {
return;
}
const nuxtApp = useNuxtApp();
components = Array.isArray(components) ? components : [components];
await Promise.all(components.map((name) => _loadAsyncComponent(nuxtApp.vueApp._context.components[name])));
};
export const prefetchComponents = (components) => {
return preloadComponents(components);
};
function _loadAsyncComponent(component) {
if (component?.__asyncLoader && !component.__asyncResolved) {
return component.__asyncLoader();
}
}
export async function preloadRouteComponents(to, router = useRouter()) {
if (process.server) {
return;
}
if (!router._routePreloaded) {
router._routePreloaded = /* @__PURE__ */ new Set();
}
if (router._routePreloaded.has(to)) {
return;
}
router._routePreloaded.add(to);
const promises = router._preloadPromises = router._preloadPromises || [];
if (promises.length > 4) {
return Promise.all(promises).then(() => preloadRouteComponents(to, router));
}
const components = router.resolve(to).matched.map((component) => component.components?.default).filter((component) => typeof component === "function");
for (const component of components) {
const promise = Promise.resolve(component()).catch(() => {
}).finally(() => promises.splice(promises.indexOf(promise)));
promises.push(promise);
}
await Promise.all(promises);
}

28
node_modules/nuxt/dist/app/composables/router.d.ts generated vendored Normal file
View File

@@ -0,0 +1,28 @@
import type { Router, RouteLocationNormalizedLoaded, NavigationGuard, RouteLocationNormalized, RouteLocationRaw, NavigationFailure } from 'vue-router';
import { NuxtError } from './error';
export declare const useRouter: () => Router;
export declare const useRoute: () => RouteLocationNormalizedLoaded;
export declare const onBeforeRouteLeave: (guard: NavigationGuard) => void;
export declare const onBeforeRouteUpdate: (guard: NavigationGuard) => void;
export interface RouteMiddleware {
(to: RouteLocationNormalized, from: RouteLocationNormalized): ReturnType<NavigationGuard>;
}
export declare const defineNuxtRouteMiddleware: (middleware: RouteMiddleware) => RouteMiddleware;
export interface AddRouteMiddlewareOptions {
global?: boolean;
}
interface AddRouteMiddleware {
(name: string, middleware: RouteMiddleware, options?: AddRouteMiddlewareOptions): void;
(middleware: RouteMiddleware): void;
}
export declare const addRouteMiddleware: AddRouteMiddleware;
export interface NavigateToOptions {
replace?: boolean;
redirectCode?: number;
external?: boolean;
}
export declare const navigateTo: (to: RouteLocationRaw | undefined | null, options?: NavigateToOptions) => Promise<void | NavigationFailure> | RouteLocationRaw;
/** This will abort navigation within a Nuxt route middleware handler. */
export declare const abortNavigation: (err?: string | Partial<NuxtError>) => boolean;
export declare const setPageLayout: (layout: string) => void;
export {};

111
node_modules/nuxt/dist/app/composables/router.mjs generated vendored Normal file
View File

@@ -0,0 +1,111 @@
import { getCurrentInstance, inject, onUnmounted } from "vue";
import { sendRedirect } from "h3";
import { hasProtocol, joinURL, parseURL } from "ufo";
import { useNuxtApp, useRuntimeConfig } from "../nuxt.mjs";
import { createError } from "./error.mjs";
import { useState } from "./state.mjs";
export const useRouter = () => {
return useNuxtApp()?.$router;
};
export const useRoute = () => {
if (getCurrentInstance()) {
return inject("_route", useNuxtApp()._route);
}
return useNuxtApp()._route;
};
export const onBeforeRouteLeave = (guard) => {
const unsubscribe = useRouter().beforeEach((to, from, next) => {
if (to === from) {
return;
}
return guard(to, from, next);
});
onUnmounted(unsubscribe);
};
export const onBeforeRouteUpdate = (guard) => {
const unsubscribe = useRouter().beforeEach(guard);
onUnmounted(unsubscribe);
};
export const defineNuxtRouteMiddleware = (middleware) => middleware;
export const addRouteMiddleware = (name, middleware, options = {}) => {
const nuxtApp = useNuxtApp();
if (options.global || typeof name === "function") {
nuxtApp._middleware.global.push(typeof name === "function" ? name : middleware);
} else {
nuxtApp._middleware.named[name] = middleware;
}
};
const isProcessingMiddleware = () => {
try {
if (useNuxtApp()._processingMiddleware) {
return true;
}
} catch {
return true;
}
return false;
};
export const navigateTo = (to, options) => {
if (!to) {
to = "/";
}
const toPath = typeof to === "string" ? to : to.path || "/";
const isExternal = hasProtocol(toPath, true);
if (isExternal && !options?.external) {
throw new Error("Navigating to external URL is not allowed by default. Use `nagivateTo (url, { external: true })`.");
}
if (isExternal && parseURL(toPath).protocol === "script:") {
throw new Error("Cannot navigate to an URL with script protocol.");
}
if (process.client && !isExternal && isProcessingMiddleware()) {
return to;
}
const router = useRouter();
if (process.server) {
const nuxtApp = useNuxtApp();
if (nuxtApp.ssrContext && nuxtApp.ssrContext.event) {
const redirectLocation = isExternal ? toPath : joinURL(useRuntimeConfig().app.baseURL, router.resolve(to).fullPath || "/");
return nuxtApp.callHook("app:redirected").then(() => sendRedirect(nuxtApp.ssrContext.event, redirectLocation, options?.redirectCode || 302));
}
}
if (isExternal) {
if (options?.replace) {
location.replace(toPath);
} else {
location.href = toPath;
}
return Promise.resolve();
}
return options?.replace ? router.replace(to) : router.push(to);
};
export const abortNavigation = (err) => {
if (process.dev && !isProcessingMiddleware()) {
throw new Error("abortNavigation() is only usable inside a route middleware handler.");
}
if (err) {
throw createError(err);
}
return false;
};
export const setPageLayout = (layout) => {
if (process.server) {
if (process.dev && getCurrentInstance() && useState("_layout").value !== layout) {
console.warn("[warn] [nuxt] `setPageLayout` should not be called to change the layout on the server within a component as this will cause hydration errors.");
}
useState("_layout").value = layout;
}
const nuxtApp = useNuxtApp();
if (process.dev && nuxtApp.isHydrating && useState("_layout").value !== layout) {
console.warn("[warn] [nuxt] `setPageLayout` should not be called to change the layout during hydration as this will cause hydration errors.");
}
const inMiddleware = isProcessingMiddleware();
if (inMiddleware || process.server || nuxtApp.isHydrating) {
const unsubscribe = useRouter().beforeResolve((to) => {
to.meta.layout = layout;
unsubscribe();
});
}
if (!inMiddleware) {
useRoute().meta.layout = layout;
}
};

6
node_modules/nuxt/dist/app/composables/ssr.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import type { H3Event } from 'h3';
import { NuxtApp } from '../nuxt';
export declare function useRequestHeaders<K extends string = string>(include: K[]): Record<Lowercase<K>, string | undefined>;
export declare function useRequestHeaders(): Readonly<Record<string, string | undefined>>;
export declare function useRequestEvent(nuxtApp?: NuxtApp): H3Event;
export declare function setResponseStatus(code: number, message?: string): void;

23
node_modules/nuxt/dist/app/composables/ssr.mjs generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import { useNuxtApp } from "../nuxt.mjs";
export function useRequestHeaders(include) {
if (process.client) {
return {};
}
const headers = useNuxtApp().ssrContext?.event.node.req.headers ?? {};
if (!include) {
return headers;
}
return Object.fromEntries(include.map((key) => key.toLowerCase()).filter((key) => headers[key]).map((key) => [key, headers[key]]));
}
export function useRequestEvent(nuxtApp = useNuxtApp()) {
return nuxtApp.ssrContext?.event;
}
export function setResponseStatus(code, message) {
const event = process.server && useRequestEvent();
if (event) {
event.node.res.statusCode = code;
if (message) {
event.node.res.statusMessage = message;
}
}
}

9
node_modules/nuxt/dist/app/composables/state.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import type { Ref } from 'vue';
/**
* Create a global reactive ref that will be hydrated but not shared across ssr requests
*
* @param key a unique key ensuring that data fetching can be properly de-duplicated across requests
* @param init a function that provides initial value for the state when it's not initiated
*/
export declare function useState<T>(key?: string, init?: (() => T | Ref<T>)): Ref<T>;
export declare function useState<T>(init?: (() => T | Ref<T>)): Ref<T>;

27
node_modules/nuxt/dist/app/composables/state.mjs generated vendored Normal file
View File

@@ -0,0 +1,27 @@
import { isRef, toRef } from "vue";
import { useNuxtApp } from "../nuxt.mjs";
export function useState(...args) {
const autoKey = typeof args[args.length - 1] === "string" ? args.pop() : void 0;
if (typeof args[0] !== "string") {
args.unshift(autoKey);
}
const [_key, init] = args;
if (!_key || typeof _key !== "string") {
throw new TypeError("[nuxt] [useState] key must be a string: " + _key);
}
if (init !== void 0 && typeof init !== "function") {
throw new Error("[nuxt] [useState] init must be a function: " + init);
}
const key = "$s" + _key;
const nuxt = useNuxtApp();
const state = toRef(nuxt.payload.state, key);
if (state.value === void 0 && init) {
const initialValue = init();
if (isRef(initialValue)) {
nuxt.payload.state[key] = initialValue;
return initialValue;
}
state.value = initialValue;
}
return state;
}