Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,23 @@
import { defineNuxtPlugin } from "../nuxt.js";
export default defineNuxtPlugin({
name: "nuxt:browser-devtools-timing",
enforce: "pre",
setup(nuxtApp) {
nuxtApp.hooks.beforeEach((event) => {
event.__startTime = performance.now();
});
nuxtApp.hooks.afterEach((event) => {
performance.measure(event.name, {
// @ts-expect-error __startTime is not a public API
start: event.__startTime,
detail: {
devtools: {
dataType: "track-entry",
track: "nuxt",
color: "tertiary-dark"
}
}
});
});
}
});

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,28 @@
import { nextTick } from "vue";
import { defineNuxtPlugin } from "../nuxt.js";
import { onNuxtReady } from "../composables/ready.js";
import { useError } from "../composables/error.js";
import layouts from "#build/layouts";
export default defineNuxtPlugin({
name: "nuxt:checkIfLayoutUsed",
setup(nuxtApp) {
const error = useError();
function checkIfLayoutUsed() {
if (!error.value && !nuxtApp._isNuxtLayoutUsed && Object.keys(layouts).length > 0) {
console.warn("[nuxt] Your project has layouts but the `<NuxtLayout />` component has not been used.");
}
}
if (import.meta.server) {
nuxtApp.hook("app:rendered", ({ renderResult }) => {
if (renderResult?.html) {
nextTick(checkIfLayoutUsed);
}
});
} else {
onNuxtReady(checkIfLayoutUsed);
}
},
env: {
islands: false
}
});

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,39 @@
import { defineNuxtPlugin } from "../nuxt.js";
import { getAppManifest } from "../composables/manifest.js";
import { onNuxtReady } from "../composables/ready.js";
import { buildAssetsURL } from "#internal/nuxt/paths";
import { outdatedBuildInterval } from "#build/nuxt.config.mjs";
export default defineNuxtPlugin((nuxtApp) => {
if (import.meta.test) {
return;
}
let timeout;
async function getLatestManifest() {
let currentManifest;
try {
currentManifest = await getAppManifest();
} catch (e) {
const err = e;
if (!("status" in err && (err.status === 404 || err.status === 403))) {
throw err;
}
}
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(getLatestManifest, outdatedBuildInterval);
try {
const meta = await $fetch(buildAssetsURL("builds/latest.json") + `?${Date.now()}`);
if (meta.id !== currentManifest?.id) {
nuxtApp.hooks.callHook("app:manifest:update", meta);
if (timeout) {
clearTimeout(timeout);
}
}
} catch {
}
}
onNuxtReady(() => {
timeout = setTimeout(getLatestManifest, outdatedBuildInterval);
});
});

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,20 @@
import { joinURL } from "ufo";
import { defineNuxtPlugin, useRuntimeConfig } from "../nuxt.js";
import { reloadNuxtApp } from "../composables/chunk.js";
import { addRouteMiddleware } from "../composables/router.js";
export default defineNuxtPlugin({
name: "nuxt:chunk-reload-immediate",
setup(nuxtApp) {
let currentlyNavigationTo = null;
addRouteMiddleware((to) => {
currentlyNavigationTo = to;
});
const config = useRuntimeConfig();
function reloadAppAtPath(to) {
const path = joinURL(config.app.baseURL, to.fullPath);
reloadNuxtApp({ path, persistState: true });
}
nuxtApp.hook("app:chunkError", () => reloadAppAtPath(currentlyNavigationTo ?? nuxtApp._route));
nuxtApp.hook("app:manifest:update", () => reloadAppAtPath(nuxtApp._route));
}
});

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,30 @@
import { joinURL } from "ufo";
import { defineNuxtPlugin, useRuntimeConfig } from "../nuxt.js";
import { useRouter } from "../composables/router.js";
import { reloadNuxtApp } from "../composables/chunk.js";
export default defineNuxtPlugin({
name: "nuxt:chunk-reload",
setup(nuxtApp) {
const router = useRouter();
const config = useRuntimeConfig();
const chunkErrors = /* @__PURE__ */ new Set();
router.beforeEach(() => {
chunkErrors.clear();
});
nuxtApp.hook("app:chunkError", ({ error }) => {
chunkErrors.add(error);
});
function reloadAppAtPath(to) {
const path = joinURL(config.app.baseURL, to.fullPath);
reloadNuxtApp({ path, persistState: true });
}
nuxtApp.hook("app:manifest:update", () => {
router.beforeResolve(reloadAppAtPath);
});
router.onError((error, to) => {
if (chunkErrors.has(error)) {
reloadAppAtPath(to);
}
});
}
});

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,37 @@
import { ref } from "vue";
import { defineNuxtPlugin } from "../nuxt.js";
import { useHead } from "../composables/head.js";
const SUPPORTED_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
export default defineNuxtPlugin({
name: "nuxt:cross-origin-prefetch",
setup(nuxtApp) {
const externalURLs = ref(/* @__PURE__ */ new Set());
function generateRules() {
return {
type: "speculationrules",
key: "speculationrules",
innerHTML: JSON.stringify({
prefetch: [
{
source: "list",
urls: [...externalURLs.value],
requires: ["anonymous-client-ip-when-cross-origin"]
}
]
})
};
}
const head = useHead({
script: [generateRules()]
});
nuxtApp.hook("link:prefetch", (url) => {
for (const protocol of SUPPORTED_PROTOCOLS) {
if (url.startsWith(protocol) && SUPPORTED_PROTOCOLS.has(new URL(url).protocol)) {
externalURLs.value.add(url);
head?.patch({ script: [generateRules()] });
return;
}
}
});
}
});

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,9 @@
import { createDebugger } from "hookable";
import { defineNuxtPlugin } from "../nuxt.js";
export default defineNuxtPlugin({
name: "nuxt:debug:hooks",
enforce: "pre",
setup(nuxtApp) {
createDebugger(nuxtApp.hooks, { tag: "nuxt-app" });
}
});

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,60 @@
import { createConsola } from "consola";
import { parse } from "devalue";
import { h } from "vue";
import { defineNuxtPlugin } from "../nuxt.js";
import { devLogs, devRootDir } from "#build/nuxt.config.mjs";
const devRevivers = import.meta.server ? {} : {
VNode: (data) => h(data.type, data.props),
URL: (data) => new URL(data)
};
export default defineNuxtPlugin(async (nuxtApp) => {
if (import.meta.test) {
return;
}
if (import.meta.server) {
nuxtApp.ssrContext.event.context._payloadReducers = nuxtApp.ssrContext._payloadReducers;
return;
}
if (devLogs !== "silent") {
const logger = createConsola({
formatOptions: {
colors: true,
date: true
}
});
nuxtApp.hook("dev:ssr-logs", (logs) => {
for (const log of logs) {
logger.log(normalizeServerLog({ ...log }));
}
});
}
if (typeof window !== "undefined") {
const nuxtLogsElement = document.querySelector(`[data-nuxt-logs="${nuxtApp._id}"]`);
const content = nuxtLogsElement?.textContent;
const logs = content ? parse(content, { ...devRevivers, ...nuxtApp._payloadRevivers }) : [];
await nuxtApp.hooks.callHook("dev:ssr-logs", logs);
}
});
function normalizeFilenames(stack) {
if (!stack) {
return "";
}
let message = "";
for (const item of stack) {
const source = item.source.replace(`${devRootDir}/`, "");
if (item.function) {
message += ` at ${item.function} (${source})
`;
} else {
message += ` at ${source}
`;
}
}
return message;
}
function normalizeServerLog(log) {
log.additional = normalizeFilenames(log.stack);
log.tag = "ssr";
delete log.stack;
return log;
}

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,16 @@
import { defineNuxtPlugin } from "../nuxt.js";
import { onNuxtReady } from "../composables/ready.js";
import { useRouter } from "../composables/router.js";
export default defineNuxtPlugin(() => {
const router = useRouter();
onNuxtReady(() => {
router.beforeResolve(async () => {
await new Promise((resolve) => {
setTimeout(resolve, 100);
requestAnimationFrame(() => {
setTimeout(resolve, 0);
});
});
});
});
});

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,50 @@
import { defineNuxtPlugin } from "../nuxt.js";
import { loadPayload } from "../composables/payload.js";
import { onNuxtReady } from "../composables/ready.js";
import { useRouter } from "../composables/router.js";
import { getAppManifest } from "../composables/manifest.js";
import { appManifest as isAppManifestEnabled, purgeCachedData } from "#build/nuxt.config.mjs";
export default defineNuxtPlugin({
name: "nuxt:payload",
setup(nuxtApp) {
if (import.meta.dev) {
return;
}
const staticKeysToRemove = /* @__PURE__ */ new Set();
useRouter().beforeResolve(async (to, from) => {
if (to.path === from.path) {
return;
}
const payload = await loadPayload(to.path);
if (!payload) {
return;
}
if (purgeCachedData) {
for (const key of staticKeysToRemove) {
delete nuxtApp.static.data[key];
}
}
for (const key in payload.data) {
if (purgeCachedData) {
if (!(key in nuxtApp.static.data)) {
staticKeysToRemove.add(key);
}
}
nuxtApp.static.data[key] = payload.data[key];
}
});
onNuxtReady(() => {
nuxtApp.hooks.hook("link:prefetch", async (url) => {
const { hostname } = new URL(url, window.location.href);
if (hostname === window.location.hostname) {
await loadPayload(url).catch(() => {
console.warn("[nuxt] Error preloading payload for", url);
});
}
});
if (isAppManifestEnabled && navigator.connection?.effectiveType !== "slow-2g") {
setTimeout(getAppManifest, 1e3);
}
});
}
});

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,13 @@
import { defineNuxtPlugin } from "../nuxt.js";
export default defineNuxtPlugin({
name: "nuxt:webpack-preload",
setup(nuxtApp) {
nuxtApp.vueApp.mixin({
beforeCreate() {
const { modules } = this.$nuxt.ssrContext;
const { __moduleIdentifier } = this.$options;
modules.add(__moduleIdentifier);
}
});
}
});

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,18 @@
import destr from "destr";
import { defineNuxtPlugin, useNuxtApp } from "../nuxt.js";
export default defineNuxtPlugin({
name: "nuxt:restore-state",
hooks: {
"app:mounted"() {
const nuxtApp = useNuxtApp();
try {
const state = sessionStorage.getItem("nuxt:reload:state");
if (state) {
sessionStorage.removeItem("nuxt:reload:state");
Object.assign(nuxtApp.payload.state, destr(state)?.state);
}
} catch {
}
}
}
});

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,44 @@
import { reactive, ref, shallowReactive, shallowRef } from "vue";
import destr from "destr";
import { definePayloadReviver, getNuxtClientPayload } from "../composables/payload.js";
import { createError } from "../composables/error.js";
import { defineNuxtPlugin, useNuxtApp } from "../nuxt.js";
import { componentIslands } from "#build/nuxt.config.mjs";
const revivers = [
["NuxtError", (data) => createError(data)],
["EmptyShallowRef", (data) => shallowRef(data === "_" ? void 0 : data === "0n" ? BigInt(0) : destr(data))],
["EmptyRef", (data) => ref(data === "_" ? void 0 : data === "0n" ? BigInt(0) : destr(data))],
["ShallowRef", (data) => shallowRef(data)],
["ShallowReactive", (data) => shallowReactive(data)],
["Ref", (data) => ref(data)],
["Reactive", (data) => reactive(data)]
];
if (componentIslands) {
revivers.push(["Island", ({ key, params, result }) => {
const nuxtApp = useNuxtApp();
if (!nuxtApp.isHydrating) {
nuxtApp.payload.data[key] ||= $fetch(`/__nuxt_island/${key}.json`, {
responseType: "json",
...params ? { params } : {}
}).then((r) => {
nuxtApp.payload.data[key] = r;
return r;
});
}
return {
html: "",
...result
};
}]);
}
export default defineNuxtPlugin({
name: "nuxt:revive-payload:client",
order: -30,
async setup(nuxtApp) {
for (const [reviver, fn] of revivers) {
definePayloadReviver(reviver, fn);
}
Object.assign(nuxtApp.payload, await nuxtApp.runWithContext(getNuxtClientPayload));
window.__NUXT__ = nuxtApp.payload;
}
});

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,26 @@
import { isReactive, isRef, isShallow, toRaw } from "vue";
import { definePayloadReducer } from "../composables/payload.js";
import { isNuxtError } from "../composables/error.js";
import { defineNuxtPlugin } from "../nuxt.js";
import { componentIslands } from "#build/nuxt.config.mjs";
import { isValidIslandKey } from "./utils.js";
const reducers = [
["NuxtError", (data) => isNuxtError(data) && data.toJSON()],
["EmptyShallowRef", (data) => isRef(data) && isShallow(data) && !data.value && (typeof data.value === "bigint" ? "0n" : JSON.stringify(data.value) || "_")],
["EmptyRef", (data) => isRef(data) && !data.value && (typeof data.value === "bigint" ? "0n" : JSON.stringify(data.value) || "_")],
["ShallowRef", (data) => isRef(data) && isShallow(data) && data.value],
["ShallowReactive", (data) => isReactive(data) && isShallow(data) && toRaw(data)],
["Ref", (data) => isRef(data) && data.value],
["Reactive", (data) => isReactive(data) && toRaw(data)]
];
if (componentIslands) {
reducers.push(["Island", (data) => data && data?.__nuxt_island && isValidIslandKey(data.__nuxt_island.key) && data.__nuxt_island]);
}
export default defineNuxtPlugin({
name: "nuxt:revive-payload:server",
setup() {
for (const [reducer, fn] of reducers) {
definePayloadReducer(reducer, fn);
}
}
});

View file

@ -0,0 +1,59 @@
import type { Ref } from 'vue';
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>;
/** compatibility type for vue-router */
matched: never[];
}
type RouteGuardReturn = void | Error | string | boolean;
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: Ref<Route>;
isReady: () => Promise<void>;
options: Record<string, unknown>;
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("../nuxt.js").Plugin<{
route: Route;
router: Router;
}> & import("../nuxt.js").ObjectPlugin<{
route: Route;
router: Router;
}>;
export default _default;

View file

@ -0,0 +1,222 @@
import { computed, defineComponent, h, isReadonly, reactive } from "vue";
import { isEqual, joinURL, parseQuery, stringifyParsedURL, stringifyQuery, withoutBase } from "ufo";
import { createError } from "h3";
import { defineNuxtPlugin, useRuntimeConfig } from "../nuxt.js";
import { getRouteRules } from "../composables/manifest.js";
import { clearError, showError } from "../composables/error.js";
import { navigateTo } from "../composables/router.js";
import { globalMiddleware } from "#build/middleware";
import { appManifest as isAppManifestEnabled } from "#build/nuxt.config.mjs";
function getRouteFromPath(fullPath) {
const route = fullPath && typeof fullPath === "object" ? fullPath : {};
if (typeof fullPath === "object") {
fullPath = stringifyParsedURL({
pathname: fullPath.path || "",
search: stringifyQuery(fullPath.query || {}),
hash: fullPath.hash || ""
});
}
const url = new URL(fullPath.toString(), import.meta.client ? window.location.href : "http://localhost");
return {
path: url.pathname,
fullPath,
query: parseQuery(url.search),
hash: url.hash,
// stub properties for compat with vue-router
params: route.params || {},
name: void 0,
matched: route.matched || [],
redirectedFrom: void 0,
meta: route.meta || {},
href: fullPath
};
}
export default defineNuxtPlugin({
name: "nuxt:router",
enforce: "pre",
setup(nuxtApp) {
const initialURL = import.meta.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 (typeof result === "string" && result.length) {
return handleNavigation(result, true);
}
}
for (const handler of hooks["resolve:before"]) {
await handler(to, route);
}
Object.assign(route, to);
if (import.meta.client) {
window.history[replace ? "replaceState" : "pushState"]({}, "", joinURL(baseURL, to.fullPath));
if (!nuxtApp.isHydrating) {
await nuxtApp.runWithContext(clearError);
}
}
for (const middleware of hooks["navigate:after"]) {
await middleware(to, route);
}
} catch (err) {
if (import.meta.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 currentRoute = computed(() => route);
const router = {
currentRoute,
isReady: () => Promise.resolve(),
// These options provide a similar API to vue-router but have no effect
options: {},
install: () => Promise.resolve(),
// Navigation
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),
// Guards
beforeResolve: (guard) => registerHook("resolve:before", guard),
beforeEach: (guard) => registerHook("navigate:before", guard),
afterEach: (guard) => registerHook("navigate:after", guard),
onError: (handler) => registerHook("error", handler),
// Routes
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", defineComponent({
functional: true,
props: {
to: {
type: String,
required: true
},
custom: Boolean,
replace: Boolean,
// Not implemented
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 (import.meta.client) {
window.addEventListener("popstate", (event) => {
const location = event.target.location;
router.replace(location.href.replace(location.origin, ""));
});
}
nuxtApp._route = route;
nuxtApp._middleware ||= {
global: [],
named: {}
};
const initialLayout = nuxtApp.payload.state._layout;
nuxtApp.hooks.hookOnce("app:created", async () => {
router.beforeEach(async (to, from) => {
to.meta = reactive(to.meta || {});
if (nuxtApp.isHydrating && initialLayout && !isReadonly(to.meta.layout)) {
to.meta.layout = initialLayout;
}
nuxtApp._processingMiddleware = true;
if (import.meta.client || !nuxtApp.ssrContext?.islandContext) {
const middlewareEntries = /* @__PURE__ */ new Set([...globalMiddleware, ...nuxtApp._middleware.global]);
if (isAppManifestEnabled) {
const routeRules = await nuxtApp.runWithContext(() => getRouteRules({ path: to.path }));
if (routeRules.appMiddleware) {
for (const key in routeRules.appMiddleware) {
const guard = nuxtApp._middleware.named[key];
if (!guard) {
return;
}
if (routeRules.appMiddleware[key]) {
middlewareEntries.add(guard);
} else {
middlewareEntries.delete(guard);
}
}
}
}
for (const middleware of middlewareEntries) {
if (import.meta.dev) {
nuxtApp._processingMiddleware = middleware._path || true;
}
const result = await nuxtApp.runWithContext(() => middleware(to, from));
if (import.meta.server) {
if (result === false || result instanceof Error) {
const error = result || createError({
statusCode: 404,
statusMessage: `Page Not Found: ${initialURL}`,
data: {
path: initialURL
}
});
delete nuxtApp._processingMiddleware;
return nuxtApp.runWithContext(() => showError(error));
}
}
if (result === true) {
continue;
}
if (result || result === false) {
return result;
}
}
}
});
router.afterEach(() => {
delete nuxtApp._processingMiddleware;
});
await router.replace(initialURL);
if (!isEqual(route.fullPath, initialURL)) {
await nuxtApp.runWithContext(() => navigateTo(route.fullPath));
}
});
return {
provide: {
route,
router
}
};
}
});

View file

@ -0,0 +1 @@
export declare function isValidIslandKey(key: string): boolean;

View file

@ -0,0 +1,4 @@
const VALID_ISLAND_KEY_RE = /^[a-z][a-z\d-]*_[a-z\d]+$/i;
export function isValidIslandKey(key) {
return typeof key === "string" && VALID_ISLAND_KEY_RE.test(key) && key.length <= 100;
}

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,55 @@
import { isChangingPage } from "../components/utils.js";
import { useRouter } from "../composables/router.js";
import { defineNuxtPlugin } from "../nuxt.js";
import { appViewTransition as defaultViewTransition } from "#build/nuxt.config.mjs";
export default defineNuxtPlugin((nuxtApp) => {
if (!document.startViewTransition) {
return;
}
let transition;
let hasUAVisualTransition = false;
let finishTransition;
let abortTransition;
const resetTransitionState = () => {
transition = void 0;
hasUAVisualTransition = false;
abortTransition = void 0;
finishTransition = void 0;
};
window.addEventListener("popstate", (event) => {
hasUAVisualTransition = event.hasUAVisualTransition;
if (hasUAVisualTransition) {
transition?.skipTransition();
}
});
const router = useRouter();
router.beforeResolve(async (to, from) => {
const viewTransitionMode = to.meta.viewTransition ?? defaultViewTransition;
const prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const prefersNoTransition = prefersReducedMotion && viewTransitionMode !== "always";
if (viewTransitionMode === false || prefersNoTransition || hasUAVisualTransition || !isChangingPage(to, from)) {
return;
}
const promise = new Promise((resolve, reject) => {
finishTransition = resolve;
abortTransition = reject;
});
let changeRoute;
const ready = new Promise((resolve) => changeRoute = resolve);
transition = document.startViewTransition(() => {
changeRoute();
return promise;
});
transition.finished.then(resetTransitionState);
await nuxtApp.callHook("page:view-transition:start", transition);
return ready;
});
nuxtApp.hook("vue:error", () => {
abortTransition?.();
resetTransitionState();
});
nuxtApp.hook("page:finish", () => {
finishTransition?.();
resetTransitionState();
});
});

View file

@ -0,0 +1,2 @@
declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
export default _default;

View file

@ -0,0 +1,6 @@
import { defineNuxtPlugin } from "../nuxt.js";
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.config.warnHandler ??= (msg, _instance, trace) => {
console.warn(`[Vue warn]: ${msg}`, trace);
};
});