initial commit
This commit is contained in:
2
node_modules/nuxt/dist/app/plugins/cross-origin-prefetch.client.d.ts
generated
vendored
Normal file
2
node_modules/nuxt/dist/app/plugins/cross-origin-prefetch.client.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare const _default: any;
|
||||
export default _default;
|
||||
28
node_modules/nuxt/dist/app/plugins/cross-origin-prefetch.client.mjs
generated
vendored
Normal file
28
node_modules/nuxt/dist/app/plugins/cross-origin-prefetch.client.mjs
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { ref } from "vue";
|
||||
import { parseURL } from "ufo";
|
||||
import { defineNuxtPlugin, useHead } from "#app";
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
const externalURLs = ref(/* @__PURE__ */ new Set());
|
||||
useHead({
|
||||
script: [
|
||||
() => ({
|
||||
type: "speculationrules",
|
||||
innerHTML: JSON.stringify({
|
||||
prefetch: [
|
||||
{
|
||||
source: "list",
|
||||
urls: [...externalURLs.value],
|
||||
requires: ["anonymous-client-ip-when-cross-origin"]
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
]
|
||||
});
|
||||
nuxtApp.hook("link:prefetch", (url) => {
|
||||
const { protocol } = parseURL(url);
|
||||
if (protocol && ["http:", "https:"].includes(protocol)) {
|
||||
externalURLs.value.add(url);
|
||||
}
|
||||
});
|
||||
});
|
||||
2
node_modules/nuxt/dist/app/plugins/debug.d.ts
generated
vendored
Normal file
2
node_modules/nuxt/dist/app/plugins/debug.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare const _default: any;
|
||||
export default _default;
|
||||
5
node_modules/nuxt/dist/app/plugins/debug.mjs
generated
vendored
Normal file
5
node_modules/nuxt/dist/app/plugins/debug.mjs
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { createDebugger } from "hookable";
|
||||
import { defineNuxtPlugin } from "#app";
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
createDebugger(nuxtApp.hooks, { tag: "nuxt-app" });
|
||||
});
|
||||
2
node_modules/nuxt/dist/app/plugins/payload.client.d.ts
generated
vendored
Normal file
2
node_modules/nuxt/dist/app/plugins/payload.client.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare const _default: any;
|
||||
export default _default;
|
||||
22
node_modules/nuxt/dist/app/plugins/payload.client.mjs
generated
vendored
Normal file
22
node_modules/nuxt/dist/app/plugins/payload.client.mjs
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { parseURL } from "ufo";
|
||||
import { defineNuxtPlugin, loadPayload, isPrerendered, useRouter } from "#app";
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
if (!isPrerendered()) {
|
||||
return;
|
||||
}
|
||||
nuxtApp.hooks.hook("link:prefetch", (url) => {
|
||||
if (!parseURL(url).protocol) {
|
||||
return loadPayload(url);
|
||||
}
|
||||
});
|
||||
useRouter().beforeResolve(async (to, from) => {
|
||||
if (to.path === from.path) {
|
||||
return;
|
||||
}
|
||||
const payload = await loadPayload(to.path);
|
||||
if (!payload) {
|
||||
return;
|
||||
}
|
||||
Object.assign(nuxtApp.static.data, payload.data);
|
||||
});
|
||||
});
|
||||
2
node_modules/nuxt/dist/app/plugins/preload.server.d.ts
generated
vendored
Normal file
2
node_modules/nuxt/dist/app/plugins/preload.server.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare const _default: any;
|
||||
export default _default;
|
||||
10
node_modules/nuxt/dist/app/plugins/preload.server.mjs
generated
vendored
Normal file
10
node_modules/nuxt/dist/app/plugins/preload.server.mjs
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { defineNuxtPlugin } from "#app";
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
nuxtApp.vueApp.mixin({
|
||||
beforeCreate() {
|
||||
const { _registeredComponents } = this.$nuxt.ssrContext;
|
||||
const { __moduleIdentifier } = this.$options;
|
||||
_registeredComponents.add(__moduleIdentifier);
|
||||
}
|
||||
});
|
||||
});
|
||||
53
node_modules/nuxt/dist/app/plugins/router.d.ts
generated
vendored
Normal file
53
node_modules/nuxt/dist/app/plugins/router.d.ts
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
interface Route {
|
||||
/** Percentage encoded pathname section of the URL. */
|
||||
path: string;
|
||||
/** The whole location including the `search` and `hash`. */
|
||||
fullPath: string;
|
||||
/** Object representation of the `search` property of the current location. */
|
||||
query: Record<string, any>;
|
||||
/** Hash of the current location. If present, starts with a `#`. */
|
||||
hash: string;
|
||||
/** Name of the matched record */
|
||||
name: string | null | undefined;
|
||||
/** Object of decoded params extracted from the `path`. */
|
||||
params: Record<string, any>;
|
||||
/**
|
||||
* The location we were initially trying to access before ending up
|
||||
* on the current location.
|
||||
*/
|
||||
redirectedFrom: Route | undefined;
|
||||
/** Merged `meta` properties from all of the matched route records. */
|
||||
meta: Record<string, any>;
|
||||
}
|
||||
type RouteGuardReturn = void | Error | string | false;
|
||||
interface RouterHooks {
|
||||
'resolve:before': (to: Route, from: Route) => RouteGuardReturn | Promise<RouteGuardReturn>;
|
||||
'navigate:before': (to: Route, from: Route) => RouteGuardReturn | Promise<RouteGuardReturn>;
|
||||
'navigate:after': (to: Route, from: Route) => void | Promise<void>;
|
||||
'error': (err: any) => void | Promise<void>;
|
||||
}
|
||||
interface Router {
|
||||
currentRoute: Route;
|
||||
isReady: () => Promise<void>;
|
||||
options: {};
|
||||
install: () => Promise<void>;
|
||||
push: (url: string) => Promise<void>;
|
||||
replace: (url: string) => Promise<void>;
|
||||
back: () => void;
|
||||
go: (delta: number) => void;
|
||||
forward: () => void;
|
||||
beforeResolve: (guard: RouterHooks['resolve:before']) => () => void;
|
||||
beforeEach: (guard: RouterHooks['navigate:before']) => () => void;
|
||||
afterEach: (guard: RouterHooks['navigate:after']) => () => void;
|
||||
onError: (handler: RouterHooks['error']) => () => void;
|
||||
resolve: (url: string | Partial<Route>) => Route;
|
||||
addRoute: (parentName: string, route: Route) => void;
|
||||
getRoutes: () => any[];
|
||||
hasRoute: (name: string) => boolean;
|
||||
removeRoute: (name: string) => void;
|
||||
}
|
||||
declare const _default: import("..").Plugin<{
|
||||
route: Route;
|
||||
router: Router;
|
||||
}>;
|
||||
export default _default;
|
||||
176
node_modules/nuxt/dist/app/plugins/router.mjs
generated
vendored
Normal file
176
node_modules/nuxt/dist/app/plugins/router.mjs
generated
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
import { reactive, h } from "vue";
|
||||
import { parseURL, stringifyParsedURL, parseQuery, stringifyQuery, withoutBase, isEqual, joinURL } from "ufo";
|
||||
import { createError } from "h3";
|
||||
import { defineNuxtPlugin, clearError, navigateTo, showError, useRuntimeConfig, useState } from "../index.mjs";
|
||||
import { callWithNuxt } from "../nuxt.mjs";
|
||||
import { globalMiddleware } from "#build/middleware";
|
||||
function getRouteFromPath(fullPath) {
|
||||
if (typeof fullPath === "object") {
|
||||
fullPath = stringifyParsedURL({
|
||||
pathname: fullPath.path || "",
|
||||
search: stringifyQuery(fullPath.query || {}),
|
||||
hash: fullPath.hash || ""
|
||||
});
|
||||
}
|
||||
const url = parseURL(fullPath.toString());
|
||||
return {
|
||||
path: url.pathname,
|
||||
fullPath,
|
||||
query: parseQuery(url.search),
|
||||
hash: url.hash,
|
||||
params: {},
|
||||
name: void 0,
|
||||
matched: [],
|
||||
redirectedFrom: void 0,
|
||||
meta: {},
|
||||
href: fullPath
|
||||
};
|
||||
}
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
const initialURL = process.client ? withoutBase(window.location.pathname, useRuntimeConfig().app.baseURL) + window.location.search + window.location.hash : nuxtApp.ssrContext.url;
|
||||
const routes = [];
|
||||
const hooks = {
|
||||
"navigate:before": [],
|
||||
"resolve:before": [],
|
||||
"navigate:after": [],
|
||||
error: []
|
||||
};
|
||||
const registerHook = (hook, guard) => {
|
||||
hooks[hook].push(guard);
|
||||
return () => hooks[hook].splice(hooks[hook].indexOf(guard), 1);
|
||||
};
|
||||
const baseURL = useRuntimeConfig().app.baseURL;
|
||||
const route = reactive(getRouteFromPath(initialURL));
|
||||
async function handleNavigation(url, replace) {
|
||||
try {
|
||||
const to = getRouteFromPath(url);
|
||||
for (const middleware of hooks["navigate:before"]) {
|
||||
const result = await middleware(to, route);
|
||||
if (result === false || result instanceof Error) {
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
return handleNavigation(result, true);
|
||||
}
|
||||
}
|
||||
for (const handler of hooks["resolve:before"]) {
|
||||
await handler(to, route);
|
||||
}
|
||||
Object.assign(route, to);
|
||||
if (process.client) {
|
||||
window.history[replace ? "replaceState" : "pushState"]({}, "", joinURL(baseURL, to.fullPath));
|
||||
if (!nuxtApp.isHydrating) {
|
||||
await callWithNuxt(nuxtApp, clearError);
|
||||
}
|
||||
}
|
||||
for (const middleware of hooks["navigate:after"]) {
|
||||
await middleware(to, route);
|
||||
}
|
||||
} catch (err) {
|
||||
if (process.dev && !hooks.error.length) {
|
||||
console.warn("No error handlers registered to handle middleware errors. You can register an error handler with `router.onError()`", err);
|
||||
}
|
||||
for (const handler of hooks.error) {
|
||||
await handler(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
const router = {
|
||||
currentRoute: route,
|
||||
isReady: () => Promise.resolve(),
|
||||
options: {},
|
||||
install: () => Promise.resolve(),
|
||||
push: (url) => handleNavigation(url, false),
|
||||
replace: (url) => handleNavigation(url, true),
|
||||
back: () => window.history.go(-1),
|
||||
go: (delta) => window.history.go(delta),
|
||||
forward: () => window.history.go(1),
|
||||
beforeResolve: (guard) => registerHook("resolve:before", guard),
|
||||
beforeEach: (guard) => registerHook("navigate:before", guard),
|
||||
afterEach: (guard) => registerHook("navigate:after", guard),
|
||||
onError: (handler) => registerHook("error", handler),
|
||||
resolve: getRouteFromPath,
|
||||
addRoute: (parentName, route2) => {
|
||||
routes.push(route2);
|
||||
},
|
||||
getRoutes: () => routes,
|
||||
hasRoute: (name) => routes.some((route2) => route2.name === name),
|
||||
removeRoute: (name) => {
|
||||
const index = routes.findIndex((route2) => route2.name === name);
|
||||
if (index !== -1) {
|
||||
routes.splice(index, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
nuxtApp.vueApp.component("RouterLink", {
|
||||
functional: true,
|
||||
props: {
|
||||
to: String,
|
||||
custom: Boolean,
|
||||
replace: Boolean,
|
||||
activeClass: String,
|
||||
exactActiveClass: String,
|
||||
ariaCurrentValue: String
|
||||
},
|
||||
setup: (props, { slots }) => {
|
||||
const navigate = () => handleNavigation(props.to, props.replace);
|
||||
return () => {
|
||||
const route2 = router.resolve(props.to);
|
||||
return props.custom ? slots.default?.({ href: props.to, navigate, route: route2 }) : h("a", { href: props.to, onClick: (e) => {
|
||||
e.preventDefault();
|
||||
return navigate();
|
||||
} }, slots);
|
||||
};
|
||||
}
|
||||
});
|
||||
if (process.client) {
|
||||
window.addEventListener("popstate", (event) => {
|
||||
const location = event.target.location;
|
||||
router.replace(location.href.replace(location.origin, ""));
|
||||
});
|
||||
}
|
||||
nuxtApp._route = route;
|
||||
nuxtApp._middleware = nuxtApp._middleware || {
|
||||
global: [],
|
||||
named: {}
|
||||
};
|
||||
const initialLayout = useState("_layout");
|
||||
nuxtApp.hooks.hookOnce("app:created", async () => {
|
||||
router.beforeEach(async (to, from) => {
|
||||
to.meta = reactive(to.meta || {});
|
||||
if (nuxtApp.isHydrating) {
|
||||
to.meta.layout = initialLayout.value ?? to.meta.layout;
|
||||
}
|
||||
nuxtApp._processingMiddleware = true;
|
||||
const middlewareEntries = /* @__PURE__ */ new Set([...globalMiddleware, ...nuxtApp._middleware.global]);
|
||||
for (const middleware of middlewareEntries) {
|
||||
const result = await callWithNuxt(nuxtApp, middleware, [to, from]);
|
||||
if (process.server) {
|
||||
if (result === false || result instanceof Error) {
|
||||
const error = result || createError({
|
||||
statusCode: 404,
|
||||
statusMessage: `Page Not Found: ${initialURL}`
|
||||
});
|
||||
return callWithNuxt(nuxtApp, showError, [error]);
|
||||
}
|
||||
}
|
||||
if (result || result === false) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
router.afterEach(() => {
|
||||
delete nuxtApp._processingMiddleware;
|
||||
});
|
||||
await router.replace(initialURL);
|
||||
if (!isEqual(route.fullPath, initialURL)) {
|
||||
await callWithNuxt(nuxtApp, navigateTo, [route.fullPath]);
|
||||
}
|
||||
});
|
||||
return {
|
||||
provide: {
|
||||
route,
|
||||
router
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user