feat: init

This commit is contained in:
2026-02-13 22:02:30 +01:00
commit 8f9ff830fb
16711 changed files with 3307340 additions and 0 deletions

21
node_modules/@nuxt/nitro-server/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016-present - Nuxt Team
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.

119
node_modules/@nuxt/nitro-server/README.md generated vendored Normal file
View File

@@ -0,0 +1,119 @@
[![Nuxt banner](https://github.com/nuxt/nuxt/blob/main/.github/assets/banner.svg)](https://nuxt.com)
# Nuxt
<p>
<a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
<a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/dm/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
<a href="https://github.com/nuxt/nuxt/blob/main/LICENSE"><img src="https://img.shields.io/github/license/nuxt/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
<a href="https://nuxt.com/modules"><img src="https://img.shields.io/badge/dynamic/json?url=https://nuxt.com/api/v1/modules&query=$.stats.modules&label=Modules&style=flat&colorA=18181B&colorB=28CF8D" alt="Modules"></a>
<a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt%20Docs-18181B?logo=nuxt" alt="Website"></a>
<a href="https://chat.nuxt.dev"><img src="https://img.shields.io/badge/Nuxt%20Discord-18181B?logo=discord" alt="Discord"></a>
<a href="https://securityscorecards.dev/"><img src="https://api.securityscorecards.dev/projects/github.com/nuxt/nuxt/badge" alt="Nuxt openssf scorecard score"></a>
<a href="https://deepwiki.com/nuxt/nuxt"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
</p>
Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.
It provides a number of features that make it easy to build fast, SEO-friendly, and scalable web applications, including:
- Server-side rendering, static site generation, hybrid rendering and edge-side rendering
- Automatic routing with code-splitting and pre-fetching
- Data fetching and state management
- Search engine optimization and defining meta tags
- Auto imports of components, composables and utils
- TypeScript with zero configuration
- Go full-stack with our server/ directory
- Extensible with [300+ modules](https://nuxt.com/modules)
- Deployment to a variety of [hosting platforms](https://nuxt.com/deploy)
- ...[and much more](https://nuxt.com) 🚀
### Table of Contents
- 🚀 [Getting Started](#getting-started)
- 💻 [Vue Development](#vue-development)
- 📖 [Documentation](#documentation)
- 🧩 [Modules](#modules)
- ❤️ [Contribute](#contribute)
- 🏠 [Local Development](#local-development)
- 🛟 [Professional Support](#professional-support)
- 🔗 [Follow Us](#follow-us)
- ⚖️ [License](#license)
---
## <a name="getting-started">🚀 Getting Started</a>
Use the following command to create a new starter project. This will create a starter project with all the necessary files and dependencies:
```bash
npm create nuxt@latest <my-project>
```
> [!TIP]
> Discover also [nuxt.new](https://nuxt.new): Open a Nuxt starter on CodeSandbox, StackBlitz or locally to get up and running in a few seconds.
## <a name="vue-development">💻 Vue Development</a>
Simple, intuitive and powerful, Nuxt lets you write Vue components in a way that makes sense. Every repetitive task is automated, so you can focus on writing your full-stack Vue application with confidence.
Example of an `app.vue`:
```vue
<script setup lang="ts">
useSeoMeta({
title: 'Meet Nuxt',
description: 'The Intuitive Vue Framework.',
})
</script>
<template>
<div id="app">
<AppHeader />
<NuxtPage />
<AppFooter />
</div>
</template>
<style scoped>
#app {
background-color: #020420;
color: #00DC82;
}
</style>
```
## <a name="documentation">📖 Documentation</a>
We highly recommend you take a look at the [Nuxt documentation](https://nuxt.com/docs) to level up. Its a great resource for learning more about the framework. It covers everything from getting started to advanced topics.
## <a name="modules">🧩 Modules</a>
Discover our [list of modules](https://nuxt.com/modules) to supercharge your Nuxt project, created by the Nuxt team and community.
## <a name="contribute">❤️ Contribute</a>
We invite you to contribute and help improve Nuxt 💚
Here are a few ways you can get involved:
- **Reporting Bugs:** If you come across any bugs or issues, please check out the [reporting bugs guide](https://nuxt.com/docs/4.x/community/reporting-bugs) to learn how to submit a bug report.
- **Suggestions:** Have ideas to enhance Nuxt? We'd love to hear them! Check out the [contribution guide](https://nuxt.com/docs/4.x/community/contribution) to share your suggestions.
- **Questions:** If you have questions or need assistance, the [getting help guide](https://nuxt.com/docs/4.x/community/getting-help) provides resources to help you out.
## <a name="local-development">🏠 Local Development</a>
Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/docs/4.x/community/framework-contribution#setup) to contribute to the framework and documentation.
## <a name="professional-support">🛟 Professional Support</a>
- Technical audit & consulting: [Nuxt Experts](https://nuxt.com/enterprise/support)
- Custom development & more: [Nuxt Agencies Partners](https://nuxt.com/enterprise/agencies)
## <a name="follow-us">🔗 Follow Us</a>
<p valign="center">
<a href="https://go.nuxt.com/discord"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/discord.svg" alt="Discord"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/x"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/twitter.svg" alt="Twitter"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/github"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/github.svg" alt="GitHub"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/bluesky"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/bluesky.svg" alt="Bluesky"></a>
</p>
## <a name="license">⚖️ License</a>
[MIT](https://github.com/nuxt/nuxt/blob/main/LICENSE)

View File

@@ -0,0 +1,18 @@
# Licenses of Bundled Dependencies
The published artifact additionally contains code with the following licenses:
MIT
# Bundled Dependencies
## @nuxt/schema
License: MIT
Repository: https://github.com/nuxt/nuxt
---------------------------------------
## nuxt
License: MIT
Repository: https://github.com/nuxt/nuxt

50747
node_modules/@nuxt/nitro-server/dist/index.d.mts generated vendored Normal file

File diff suppressed because one or more lines are too long

761
node_modules/@nuxt/nitro-server/dist/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,761 @@
import { fileURLToPath, pathToFileURL } from "node:url";
import { existsSync, promises, readFileSync } from "node:fs";
import { cpus } from "node:os";
import process from "node:process";
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { randomUUID } from "node:crypto";
import { addRoute, createRouter, findAllRoutes } from "rou3";
import { compileRouterToString } from "rou3/compiler";
import { dirname, isAbsolute, join, relative, resolve } from "pathe";
import { readPackageJSON } from "pkg-types";
import { joinURL, withTrailingSlash } from "ufo";
import { hash } from "ohash";
import { build, copyPublicAssets, createDevServer, createNitro, prepare, prerender, scanHandlers, writeTypes } from "nitropack";
import { addPlugin, addTemplate, addVitePlugin, createIsIgnored, findPath, getDirectory, getLayerDirectories, logger, resolveAlias, resolveIgnorePatterns, resolveNuxtModule } from "@nuxt/kit";
import escapeRE from "escape-string-regexp";
import { defu } from "defu";
import { defineEventHandler, dynamicEventHandler, handleCors, setHeader } from "h3";
import { isWindows } from "std-env";
import { ImpoundPlugin } from "impound";
import { resolveModulePath } from "exsolve";
import { runtimeDependencies } from "nitropack/runtime/meta";
var version = "4.3.1";
function toArray(value) {
return Array.isArray(value) ? value : [value];
}
let _distDir = dirname(fileURLToPath(import.meta.url));
if (/(?:chunks|shared)$/.test(_distDir)) _distDir = dirname(_distDir);
const distDir = _distDir;
const template = () => {
return "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"80\" fill=\"none\" class=\"nuxt-spa-loading\" viewBox=\"0 0 37 25\"><path d=\"M24.236 22.006h10.742L25.563 5.822l-8.979 14.31a4 4 0 0 1-3.388 1.874H2.978l11.631-20 5.897 10.567\"/></svg><style>.nuxt-spa-loading{left:50%;position:fixed;top:50%;transform:translate(-50%,-50%)}.nuxt-spa-loading>path{animation:nuxt-spa-loading-move 3s linear infinite;fill:none;stroke:#00dc82;stroke-dasharray:128;stroke-dashoffset:128;stroke-linecap:round;stroke-linejoin:round;stroke-width:4px}@keyframes nuxt-spa-loading-move{to{stroke-dashoffset:-128}}</style>";
};
function createImportProtectionPatterns(nuxt, options) {
const patterns = [];
const context = contextFlags[options.context];
patterns.push([/^(nuxt|nuxt3|nuxt-nightly)$/, `\`nuxt\`, or \`nuxt-nightly\` cannot be imported directly in ${context}.` + (options.context === "nuxt-app" ? " Instead, import runtime Nuxt composables from `#app` or `#imports`." : "")]);
patterns.push([/^((~|~~|@|@@)?\/)?nuxt\.config(\.|$)/, "Importing directly from a `nuxt.config` file is not allowed. Instead, use runtime config or a module."]);
patterns.push([/(^|node_modules\/)@vue\/composition-api/]);
for (const mod of nuxt.options._installedModules) if (mod.entryPath) patterns.push([new RegExp(`^${escapeRE(mod.entryPath)}$`), "Importing directly from module entry-points is not allowed."]);
for (const i of [
/(^|node_modules\/)@nuxt\/(cli|kit|test-utils)/,
/(^|node_modules\/)nuxi/,
/(^|node_modules\/)nitro(?:pack)?(?:-nightly)?(?:$|\/)(?!(?:dist\/)?(?:node_modules|presets|runtime|types))/,
/(^|node_modules\/)nuxt\/(config|kit|schema)/
]) patterns.push([i, `This module cannot be imported in ${context}.`]);
if (options.context === "nitro-app" || options.context === "shared") for (const i of ["#app", /^#build(\/|$)/]) patterns.push([i, `Vue app aliases are not allowed in ${context}.`]);
if (options.context === "nuxt-app" || options.context === "shared") {
patterns.push([new RegExp(escapeRE(relative(nuxt.options.srcDir, resolve(nuxt.options.srcDir, nuxt.options.serverDir || "server"))) + "\\/(api|routes|middleware|plugins)\\/"), `Importing from server is not allowed in ${context}.`]);
patterns.push([/^#server(\/|$)/, `Server aliases are not allowed in ${context}.`]);
}
return patterns;
}
const contextFlags = {
"nitro-app": "server runtime",
"nuxt-app": "the Vue part of your app",
"shared": "the #shared directory"
};
const nitroSchemaTemplate = {
filename: "types/nitro-nuxt.d.ts",
async getContents({ nuxt }) {
const references = [];
const declarations = [];
await nuxt.callHook("nitro:prepare:types", {
references,
declarations
});
const typesDir = join(nuxt.options.buildDir, "types");
return `
${[...references.map((ref) => renderReference(ref, typesDir)), ...declarations].join("\n")}
import type { RuntimeConfig } from 'nuxt/schema'
import type { H3Event } from 'h3'
import type { LogObject } from 'consola'
import type { NuxtIslandContext, NuxtIslandResponse, NuxtRenderHTMLContext } from 'nuxt/app'
declare module 'nitropack' {
interface NitroRuntimeConfigApp {
buildAssetsDir: string
cdnURL: string
}
interface NitroRuntimeConfig extends RuntimeConfig {}
interface NitroRouteConfig {
ssr?: boolean
noScripts?: boolean
/** @deprecated Use \`noScripts\` instead */
experimentalNoScripts?: boolean
}
interface NitroRouteRules {
ssr?: boolean
noScripts?: boolean
/** @deprecated Use \`noScripts\` instead */
experimentalNoScripts?: boolean
appMiddleware?: Record<string, boolean>
appLayout?: string | false
}
interface NitroRuntimeHooks {
'dev:ssr-logs': (ctx: { logs: LogObject[], path: string }) => void | Promise<void>
'render:html': (htmlContext: NuxtRenderHTMLContext, context: { event: H3Event }) => void | Promise<void>
'render:island': (islandResponse: NuxtIslandResponse, context: { event: H3Event, islandContext: NuxtIslandContext }) => void | Promise<void>
}
}
declare module 'nitropack/types' {
interface NitroRuntimeConfigApp {
buildAssetsDir: string
cdnURL: string
}
interface NitroRuntimeConfig extends RuntimeConfig {}
interface NitroRouteConfig {
ssr?: boolean
noScripts?: boolean
/** @deprecated Use \`noScripts\` instead */
experimentalNoScripts?: boolean
}
interface NitroRouteRules {
ssr?: boolean
noScripts?: boolean
/** @deprecated Use \`noScripts\` instead */
experimentalNoScripts?: boolean
appMiddleware?: Record<string, boolean>
appLayout?: string | false
}
interface NitroRuntimeHooks {
'dev:ssr-logs': (ctx: { logs: LogObject[], path: string }) => void | Promise<void>
'render:html': (htmlContext: NuxtRenderHTMLContext, context: { event: H3Event }) => void | Promise<void>
'render:island': (islandResponse: NuxtIslandResponse, context: { event: H3Event, islandContext: NuxtIslandContext }) => void | Promise<void>
}
}
`;
}
};
function renderReference(ref, baseDir) {
return `/// <reference ${"path" in ref ? `path="${isAbsolute(ref.path) ? relative(baseDir, ref.path) : ref.path}"` : `types="${ref.types}"`} />`;
}
const logLevelMapReverse = {
silent: 0,
info: 3,
verbose: 3
};
const NODE_MODULES_RE = /(?<=\/)node_modules\/(.+)$/;
const PNPM_NODE_MODULES_RE = /\.pnpm\/.+\/node_modules\/(.+)$/;
async function bundle(nuxt) {
const layerDirs = getLayerDirectories(nuxt);
const excludePaths = [];
for (const dirs of layerDirs) {
const paths = [dirs.root.match(NODE_MODULES_RE)?.[1]?.replace(/\/$/, ""), dirs.root.match(PNPM_NODE_MODULES_RE)?.[1]?.replace(/\/$/, "")];
for (const dir of paths) if (dir) excludePaths.push(escapeRE(dir));
}
const layerPublicAssetsDirs = [];
for (const dirs of layerDirs) if (existsSync(dirs.public)) layerPublicAssetsDirs.push({ dir: dirs.public });
const excludePattern = excludePaths.length ? [new RegExp(`node_modules\\/(?!${excludePaths.join("|")})`)] : [/node_modules/];
const rootDirWithSlash = withTrailingSlash(nuxt.options.rootDir);
const moduleEntryPaths = [];
for (const m of nuxt.options._installedModules) {
const path = m.meta?.rawPath || m.entryPath;
if (path) moduleEntryPaths.push(getDirectory(path));
}
const modules = await resolveNuxtModule(rootDirWithSlash, moduleEntryPaths);
addTemplate(nitroSchemaTemplate);
const sharedDirs = /* @__PURE__ */ new Set();
if (nuxt.options.nitro.imports !== false && nuxt.options.imports.scan !== false) for (const layer of nuxt.options._layers) {
if (layer.config?.imports?.scan === false) continue;
sharedDirs.add(resolve(layer.config.rootDir, layer.config.dir?.shared ?? "shared", "utils"));
sharedDirs.add(resolve(layer.config.rootDir, layer.config.dir?.shared ?? "shared", "types"));
}
nuxt.options.nitro.plugins ||= [];
nuxt.options.nitro.plugins = nuxt.options.nitro.plugins.map((plugin) => plugin ? resolveAlias(plugin, nuxt.options.alias) : plugin);
if (nuxt.options.dev && nuxt.options.features.devLogs) {
addPlugin(resolve(nuxt.options.appDir, "plugins/dev-server-logs"));
nuxt.options.nitro.plugins.push(resolve(distDir, "runtime/plugins/dev-server-logs"));
nuxt.options.nitro.externals = defu(nuxt.options.nitro.externals, { inline: [/#internal\/dev-server-logs-options/] });
nuxt.options.nitro.virtual = defu(nuxt.options.nitro.virtual, { "#internal/dev-server-logs-options": () => `export const rootDir = ${JSON.stringify(nuxt.options.rootDir)};` });
}
if (nuxt.options.experimental.componentIslands) {
nuxt.options.nitro.virtual ||= {};
nuxt.options.nitro.virtual["#internal/nuxt/island-renderer.mjs"] = () => {
if (nuxt.options.dev || nuxt.options.experimental.componentIslands !== "auto" || nuxt.apps.default?.pages?.some((p) => p.mode === "server") || nuxt.apps.default?.components?.some((c) => c.mode === "server" && !nuxt.apps.default?.components.some((other) => other.pascalName === c.pascalName && other.mode === "client"))) return `export { default } from '${resolve(distDir, "runtime/handlers/island")}'`;
return `import { defineEventHandler } from 'h3'; export default defineEventHandler(() => {});`;
};
nuxt.options.nitro.handlers ||= [];
nuxt.options.nitro.handlers.push({
route: "/__nuxt_island/**",
handler: "#internal/nuxt/island-renderer.mjs"
});
if (!nuxt.options.ssr && nuxt.options.experimental.componentIslands !== "auto") {
nuxt.options.ssr = true;
nuxt.options.nitro.routeRules ||= {};
nuxt.options.nitro.routeRules["/**"] = defu(nuxt.options.nitro.routeRules["/**"], { ssr: false });
}
}
const mockProxy = resolveModulePath("mocked-exports/proxy", { from: import.meta.url });
const { version: nuxtVersion } = await readPackageJSON("nuxt", { from: import.meta.url });
const nitroConfig = defu(nuxt.options.nitro, {
debug: nuxt.options.debug ? nuxt.options.debug.nitro : false,
rootDir: nuxt.options.rootDir,
workspaceDir: nuxt.options.workspaceDir,
srcDir: nuxt.options.serverDir,
dev: nuxt.options.dev,
buildDir: nuxt.options.buildDir,
experimental: {
asyncContext: nuxt.options.experimental.asyncContext,
typescriptBundlerResolution: nuxt.options.future.typescriptBundlerResolution || nuxt.options.typescript?.tsConfig?.compilerOptions?.moduleResolution?.toLowerCase() === "bundler" || nuxt.options.nitro.typescript?.tsConfig?.compilerOptions?.moduleResolution?.toLowerCase() === "bundler"
},
framework: {
name: "nuxt",
version: nuxtVersion || version
},
imports: nuxt.options.experimental.nitroAutoImports === false ? false : {
autoImport: nuxt.options.imports.autoImport,
dirs: [...sharedDirs],
imports: [
{
as: "__buildAssetsURL",
name: "buildAssetsURL",
from: resolve(distDir, "runtime/utils/paths")
},
{
as: "__publicAssetsURL",
name: "publicAssetsURL",
from: resolve(distDir, "runtime/utils/paths")
},
{
as: "defineAppConfig",
name: "defineAppConfig",
from: resolve(distDir, "runtime/utils/config"),
priority: -1
}
],
presets: [{
from: "h3",
imports: ["H3Event", "H3Error"]
}, {
from: "h3",
type: true,
imports: [
"EventHandler",
"EventHandlerRequest",
"EventHandlerResponse",
"EventHandlerObject",
"H3EventContext"
]
}],
exclude: [...excludePattern, /[\\/]\.git[\\/]/]
},
esbuild: { options: { exclude: excludePattern } },
analyze: !nuxt.options.test && nuxt.options.build.analyze && (nuxt.options.build.analyze === true || nuxt.options.build.analyze.enabled) ? {
template: "treemap",
projectRoot: nuxt.options.rootDir,
filename: join(nuxt.options.analyzeDir, "{name}.html")
} : false,
scanDirs: layerDirs.map((dirs) => dirs.server),
renderer: resolve(distDir, "runtime/handlers/renderer"),
nodeModulesDirs: nuxt.options.modulesDir,
handlers: nuxt.options.serverHandlers,
devHandlers: [],
baseURL: nuxt.options.app.baseURL,
virtual: {
"#internal/nuxt.config.mjs": () => nuxt.vfs["#build/nuxt.config.mjs"] || "",
"#internal/nuxt/app-config": () => nuxt.vfs["#build/app.config.mjs"]?.replace(/\/\*\* client \*\*\/[\s\S]*\/\*\* client-end \*\*\//, "") || "",
"#spa-template": async () => `export const template = ${JSON.stringify(await spaLoadingTemplate(nuxt))}`,
"#internal/entry-chunk.mjs": () => `export const entryFileName = undefined`,
"#internal/nuxt/entry-ids.mjs": () => `export default []`,
"#internal/nuxt/nitro-config.mjs": () => {
const hasCachedRoutes = Object.values(nitro.options.routeRules).some((r) => r.isr || r.cache);
return [
`export const NUXT_NO_SSR = ${nuxt.options.ssr === false}`,
`export const NUXT_EARLY_HINTS = ${nuxt.options.experimental.writeEarlyHints !== false}`,
`export const NUXT_NO_SCRIPTS = ${nuxt.options.features.noScripts === "all" || !!nuxt.options.features.noScripts && !nuxt.options.dev}`,
`export const NUXT_INLINE_STYLES = ${!!nuxt.options.features.inlineStyles}`,
`export const PARSE_ERROR_DATA = ${!!nuxt.options.experimental.parseErrorData}`,
`export const NUXT_JSON_PAYLOADS = ${!!nuxt.options.experimental.renderJsonPayloads}`,
`export const NUXT_ASYNC_CONTEXT = ${!!nuxt.options.experimental.asyncContext}`,
`export const NUXT_SHARED_DATA = ${!!nuxt.options.experimental.sharedPrerenderData}`,
`export const NUXT_PAYLOAD_EXTRACTION = ${!!nuxt.options.experimental.payloadExtraction}`,
`export const NUXT_RUNTIME_PAYLOAD_EXTRACTION = ${hasCachedRoutes}`
].join("\n");
}
},
routeRules: { "/__nuxt_error": { cache: false } },
appConfig: nuxt.options.appConfig,
appConfigFiles: layerDirs.map((dirs) => join(dirs.app, "app.config")),
typescript: {
strict: true,
generateTsConfig: true,
tsconfigPath: "tsconfig.server.json",
tsConfig: {
compilerOptions: {
lib: [
"esnext",
"webworker",
"dom.iterable"
],
skipLibCheck: true,
noUncheckedIndexedAccess: true,
allowArbitraryExtensions: true
},
include: [
join(nuxt.options.buildDir, "types/nitro-nuxt.d.ts"),
...modules.flatMap((m) => {
const moduleDir = relativeWithDot(nuxt.options.buildDir, m);
return [join(moduleDir, "runtime/server"), join(moduleDir, "dist/runtime/server")];
}),
...layerDirs.map((dirs) => relativeWithDot(nuxt.options.buildDir, join(dirs.server, "**/*"))),
...layerDirs.map((dirs) => relativeWithDot(nuxt.options.buildDir, join(dirs.shared, "**/*.d.ts")))
],
exclude: [...nuxt.options.modulesDir.map((m) => relativeWithDot(nuxt.options.buildDir, m)), relativeWithDot(nuxt.options.buildDir, resolve(nuxt.options.rootDir, "dist"))]
}
},
publicAssets: [nuxt.options.dev ? { dir: resolve(nuxt.options.buildDir, "dist/client") } : {
dir: join(nuxt.options.buildDir, "dist/client", nuxt.options.app.buildAssetsDir),
maxAge: 31536e3,
baseURL: nuxt.options.app.buildAssetsDir
}, ...layerPublicAssetsDirs],
prerender: {
ignoreUnprefixedPublicAssets: true,
failOnError: true,
concurrency: cpus().length * 4 || 4,
routes: [].concat(nuxt.options.generate.routes)
},
sourceMap: nuxt.options.sourcemap.server,
externals: {
inline: [
...nuxt.options.dev ? [] : [
...nuxt.options.experimental.externalVue ? [] : ["vue", "@vue/"],
"@nuxt/",
nuxt.options.buildDir
],
...nuxt.options.build.transpile.filter((i) => typeof i === "string"),
"nuxt/dist",
"nuxt3/dist",
"nuxt-nightly/dist",
distDir,
...layerDirs.map((dirs) => join(dirs.app, "app.config"))
],
traceInclude: [...nuxt.options.vue.runtimeCompiler && !nuxt.options.experimental.externalVue ? [...nuxt.options.modulesDir.reduce((targets, path) => {
const serverRendererPath = resolve(path, "vue/server-renderer/index.js");
if (existsSync(serverRendererPath)) targets.push(serverRendererPath);
return targets;
}, [])] : []]
},
alias: {
...nuxt.options.vue.runtimeCompiler || nuxt.options.experimental.externalVue ? {} : {
"estree-walker": mockProxy,
"@babel/parser": mockProxy,
"@vue/compiler-core": mockProxy,
"@vue/compiler-dom": mockProxy,
"@vue/compiler-ssr": mockProxy
},
"@vue/devtools-api": "vue-devtools-stub",
...nuxt.options.alias,
"#internal/nuxt/paths": resolve(distDir, "runtime/utils/paths")
},
replace: { "__VUE_PROD_DEVTOOLS__": String(false) },
rollupConfig: {
output: { generatedCode: { symbols: true } },
plugins: []
},
logLevel: logLevelMapReverse[nuxt.options.logLevel]
});
if (nuxt.options.experimental.serverAppConfig === true && nitroConfig.imports) {
nitroConfig.imports.imports ||= [];
nitroConfig.imports.imports.push({
name: "useAppConfig",
from: resolve(distDir, "runtime/utils/app-config"),
priority: -1
});
}
if (!nitroConfig.errorHandler && (nuxt.options.dev || !nuxt.options.experimental.noVueServer)) nitroConfig.errorHandler = resolve(distDir, "runtime/handlers/error");
nitroConfig.srcDir = resolve(nuxt.options.rootDir, nuxt.options.srcDir, nitroConfig.srcDir);
nitroConfig.ignore ||= [];
nitroConfig.ignore.push(...resolveIgnorePatterns(nitroConfig.srcDir), `!${join(nuxt.options.buildDir, "dist/client", nuxt.options.app.buildAssetsDir, "**/*")}`);
const validManifestKeys = [
"prerender",
"redirect",
"appMiddleware",
"appLayout",
"cache",
"isr",
"swr"
];
function getRouteRulesRouter() {
const routeRulesRouter = createRouter();
if (nuxt._nitro) for (const [route, rules] of Object.entries(nuxt._nitro.options.routeRules)) {
if (route === "/__nuxt_error") continue;
if (validManifestKeys.every((key) => !(key in rules))) continue;
addRoute(routeRulesRouter, void 0, route, rules);
}
return routeRulesRouter;
}
const cachedMatchers = {};
addTemplate({
filename: "route-rules.mjs",
getContents() {
const key = hash(nuxt._nitro?.options.routeRules || {});
if (cachedMatchers[key]) return cachedMatchers[key];
return cachedMatchers[key] = `
import { defu } from 'defu'
const matcher = ${compileRouterToString(getRouteRulesRouter(), "", {
matchAll: true,
serialize(routeRules) {
return `{${Object.entries(routeRules).filter(([name, value]) => value !== void 0 && validManifestKeys.includes(name)).map(([name, value]) => {
if (name === "redirect") {
const redirectOptions = value;
value = typeof redirectOptions === "string" ? redirectOptions : redirectOptions.to;
}
if (name === "appMiddleware") {
const appMiddlewareOptions = value;
if (typeof appMiddlewareOptions === "string") value = { [appMiddlewareOptions]: true };
else if (Array.isArray(appMiddlewareOptions)) {
const normalizedRules = {};
for (const middleware of appMiddlewareOptions) normalizedRules[middleware] = true;
value = normalizedRules;
}
}
if (name === "cache" || name === "isr" || name === "swr") {
name = "payload";
value = Boolean(value);
}
return `${name}: ${JSON.stringify(value)}`;
}).join(",")}}`;
}
})}
export default (path) => defu({}, ...matcher('', path).map(r => r.data).reverse())
`;
}
});
if (nuxt.options.experimental.payloadExtraction) {
if (nuxt.options.dev) nuxt.hook("nitro:config", (nitroConfig) => {
nitroConfig.prerender ||= {};
nitroConfig.prerender.routes ||= [];
nitroConfig.routeRules ||= {};
for (const route of nitroConfig.prerender.routes) {
if (!route) continue;
nitroConfig.routeRules[route] = defu(nitroConfig.routeRules[route], { prerender: true });
}
});
nuxt.hook("nitro:init", (nitro) => {
nitro.hooks.hook("build:before", (nitro) => {
for (const [route, value] of Object.entries(nitro.options.routeRules)) if (!route.endsWith("*") && !route.endsWith("/_payload.json")) {
if (value.isr || value.cache || value.prerender && nuxt.options.dev) {
const payloadKey = route + "/_payload.json";
const defaults = {};
for (const key of [
"isr",
"cache",
...nuxt.options.dev ? ["prerender"] : []
]) if (key in value) defaults[key] = value[key];
nitro.options.routeRules[payloadKey] = defu(nitro.options.routeRules[payloadKey], defaults);
}
}
});
});
}
if (nuxt.options.experimental.appManifest) {
const buildId = nuxt.options.runtimeConfig.app.buildId ||= nuxt.options.buildId;
const buildTimestamp = Date.now();
const manifestPrefix = joinURL(nuxt.options.app.buildAssetsDir, "builds");
const tempDir = join(nuxt.options.buildDir, "manifest");
nitroConfig.prerender ||= {};
nitroConfig.prerender.ignore ||= [];
nitroConfig.prerender.ignore.push(joinURL(nuxt.options.app.baseURL, manifestPrefix));
nitroConfig.publicAssets.unshift({
dir: join(tempDir, "meta"),
maxAge: 31536e3,
baseURL: joinURL(manifestPrefix, "meta")
}, {
dir: tempDir,
maxAge: 1,
baseURL: manifestPrefix
});
nuxt.options.alias["#app-manifest"] = join(tempDir, `meta/${buildId}.json`);
if (!nuxt.options.dev) nuxt.hook("build:before", async () => {
await promises.mkdir(join(tempDir, "meta"), { recursive: true });
await promises.writeFile(join(tempDir, `meta/${buildId}.json`), JSON.stringify({}));
});
nuxt.hook("nitro:config", (config) => {
config.alias ||= {};
config.alias["#app-manifest"] = join(tempDir, `meta/${buildId}.json`);
});
nuxt.hook("nitro:init", (nitro) => {
nitro.hooks.hook("rollup:before", async (nitro) => {
const prerenderedRoutes = /* @__PURE__ */ new Set();
const routeRulesMatcher = getRouteRulesRouter();
if (nitro._prerenderedRoutes?.length) {
const payloadSuffix = nuxt.options.experimental.renderJsonPayloads ? "/_payload.json" : "/_payload.js";
for (const route of nitro._prerenderedRoutes) if (!route.error && route.route.endsWith(payloadSuffix)) {
const url = route.route.slice(0, -payloadSuffix.length) || "/";
if (!defu({}, ...findAllRoutes(routeRulesMatcher, void 0, url).reverse()).prerender) prerenderedRoutes.add(url);
}
}
const manifest = {
id: buildId,
timestamp: buildTimestamp,
prerendered: nuxt.options.dev ? [] : [...prerenderedRoutes]
};
await promises.mkdir(join(tempDir, "meta"), { recursive: true });
await promises.writeFile(join(tempDir, "latest.json"), JSON.stringify({
id: buildId,
timestamp: buildTimestamp
}));
await promises.writeFile(join(tempDir, `meta/${buildId}.json`), JSON.stringify(manifest));
});
});
}
if (!nuxt.options.experimental.appManifest) nuxt.options.alias["#app-manifest"] = mockProxy;
const FORWARD_SLASH_RE = /\//g;
if (!nuxt.options.ssr) {
nitroConfig.virtual["#build/dist/server/server.mjs"] = "export default () => {}";
if (process.platform === "win32") nitroConfig.virtual["#build/dist/server/server.mjs".replace(FORWARD_SLASH_RE, "\\")] = "export default () => {}";
}
if (nuxt.options.dev) {
nitroConfig.virtual["#build/dist/server/styles.mjs"] = "export default {}";
if (process.platform === "win32") nitroConfig.virtual["#build/dist/server/styles.mjs".replace(FORWARD_SLASH_RE, "\\")] = "export default {}";
}
nitroConfig.rollupConfig.plugins = await nitroConfig.rollupConfig.plugins || [];
nitroConfig.rollupConfig.plugins = toArray(nitroConfig.rollupConfig.plugins);
const sharedDir = withTrailingSlash(resolve(nuxt.options.rootDir, nuxt.options.dir.shared));
const relativeSharedDir = withTrailingSlash(relative(nuxt.options.rootDir, resolve(nuxt.options.rootDir, nuxt.options.dir.shared)));
const sharedPatterns = [
/^#shared\//,
new RegExp("^" + escapeRE(sharedDir)),
new RegExp("^" + escapeRE(relativeSharedDir))
];
nitroConfig.rollupConfig.plugins.push(ImpoundPlugin.rollup({
cwd: nuxt.options.rootDir,
include: sharedPatterns,
patterns: createImportProtectionPatterns(nuxt, { context: "shared" })
}), ImpoundPlugin.rollup({
cwd: nuxt.options.rootDir,
patterns: createImportProtectionPatterns(nuxt, { context: "nitro-app" }),
exclude: [/node_modules[\\/]nitro(?:pack)?(?:-nightly)?[\\/]|(packages|@nuxt)[\\/]nitro-server(?:-nightly)?[\\/](src|dist)[\\/]runtime[\\/]/, ...sharedPatterns]
}));
const isIgnored = createIsIgnored(nuxt);
nitroConfig.devStorage ??= {};
nitroConfig.devStorage.root ??= {
driver: "fs",
readOnly: true,
base: nitroConfig.rootDir,
watchOptions: { ignored: [isIgnored] }
};
nitroConfig.devStorage.src ??= {
driver: "fs",
readOnly: true,
base: nitroConfig.srcDir,
watchOptions: { ignored: [isIgnored] }
};
nuxt.options.typescript.hoist.push("nitro/types", "nitro/runtime", "nitropack/types", "nitropack/runtime", "nitropack", "defu", "h3", "consola", "ofetch", "crossws");
await nuxt.callHook("nitro:config", nitroConfig);
if (nitroConfig.static && nuxt.options.dev) {
nitroConfig.routeRules ||= {};
nitroConfig.routeRules["/**"] = defu(nitroConfig.routeRules["/**"], { prerender: true });
}
const excludedAlias = [
/^@vue\/.*$/,
"vue",
/vue-router/,
"vite/client",
"#imports",
"vue-demi",
/^#app/,
"~",
"@",
"~~",
"@@"
];
const basePath = nitroConfig.typescript.tsConfig.compilerOptions?.baseUrl ? resolve(nuxt.options.buildDir, nitroConfig.typescript.tsConfig.compilerOptions?.baseUrl) : nuxt.options.buildDir;
const aliases = nitroConfig.alias;
const tsConfig = nitroConfig.typescript.tsConfig;
tsConfig.compilerOptions ||= {};
tsConfig.compilerOptions.paths ||= {};
for (const _alias in aliases) {
const alias = _alias;
if (excludedAlias.some((pattern) => typeof pattern === "string" ? alias === pattern : pattern.test(alias))) continue;
if (alias in tsConfig.compilerOptions.paths) continue;
const absolutePath = resolve(basePath, aliases[alias]);
const isDirectory = aliases[alias].endsWith("/") || await promises.stat(absolutePath).then((r) => r.isDirectory()).catch(() => null);
tsConfig.compilerOptions.paths[alias] = [absolutePath];
if (isDirectory) tsConfig.compilerOptions.paths[`${alias}/*`] = [`${absolutePath}/*`];
}
const nitro = await createNitro(nitroConfig, {
compatibilityDate: nuxt.options.compatibilityDate,
dotenv: nuxt.options._loadOptions?.dotenv
});
if (nuxt.options.experimental.serverAppConfig === false && nitro.options.imports) {
nitro.options.imports.presets ||= [];
nitro.options.imports.presets = nitro.options.imports.presets.map((preset) => typeof preset === "string" || !("imports" in preset) ? preset : {
...preset,
imports: preset.imports.filter((i) => i !== "useAppConfig")
});
}
if (nitro.options.static && nuxt.options.experimental.payloadExtraction === void 0) {
logger.warn("Using experimental payload extraction for full-static output. You can opt-out by setting `experimental.payloadExtraction` to `false`.");
nuxt.options.experimental.payloadExtraction = true;
}
const spaLoadingTemplateFilePath = await spaLoadingTemplatePath(nuxt);
nuxt.hook("builder:watch", async (_event, relativePath) => {
if (resolve(nuxt.options.srcDir, relativePath) === spaLoadingTemplateFilePath) await nitro.hooks.callHook("rollup:reload");
});
const cacheDir = resolve(nuxt.options.buildDir, "cache/nitro/prerender");
const cacheDriverPath = join(distDir, "runtime/utils/cache-driver.js");
await promises.rm(cacheDir, {
recursive: true,
force: true
}).catch(() => {});
nitro.options._config.storage = defu(nitro.options._config.storage, { "internal:nuxt:prerender": {
driver: isWindows ? pathToFileURL(cacheDriverPath).href : cacheDriverPath,
base: cacheDir
} });
nuxt._nitro = nitro;
await nuxt.callHook("nitro:init", nitro);
nuxt["~runtimeDependencies"] ||= [];
nuxt["~runtimeDependencies"].push(...runtimeDependencies, "unhead", "@unhead/vue", "@nuxt/devalue", "unstorage", ...nitro.options.inlineDynamicImports ? ["vue", "@vue/server-renderer"] : []);
nitro.vfs = nuxt.vfs = nitro.vfs || nuxt.vfs || {};
nuxt.hook("close", () => nitro.hooks.callHook("close"));
nitro.hooks.hook("prerender:routes", (routes) => {
return nuxt.callHook("prerender:routes", { routes });
});
if (nuxt.options.vue.runtimeCompiler) {
addVitePlugin({
name: "nuxt:vue:runtime-compiler",
applyToEnvironment: (environment) => environment.name === "client",
enforce: "pre",
resolveId(id, importer) {
if (id === "vue") return this.resolve("vue/dist/vue.esm-bundler", importer, { skipSelf: true });
}
});
for (const hook of ["webpack:config", "rspack:config"]) nuxt.hook(hook, (configuration) => {
const clientConfig = configuration.find((config) => config.name === "client");
if (!clientConfig.resolve) clientConfig.resolve.alias = {};
if (Array.isArray(clientConfig.resolve.alias)) clientConfig.resolve.alias.push({
name: "vue",
alias: "vue/dist/vue.esm-bundler"
});
else clientConfig.resolve.alias.vue = "vue/dist/vue.esm-bundler";
});
}
const devMiddlewareHandler = dynamicEventHandler();
nitro.options.devHandlers.unshift({ handler: devMiddlewareHandler });
nitro.options.devHandlers.push(...nuxt.options.devServerHandlers);
nitro.options.handlers.unshift({
route: "/__nuxt_error",
lazy: true,
handler: resolve(distDir, "runtime/handlers/renderer")
});
if (nuxt.options.experimental.chromeDevtoolsProjectSettings) {
const cacheDir = resolve(nuxt.options.rootDir, "node_modules/.cache/nuxt");
let projectConfiguration = await readFile(join(cacheDir, "chrome-workspace.json"), "utf-8").then((r) => JSON.parse(r)).catch(() => null);
if (!projectConfiguration) {
projectConfiguration = { uuid: randomUUID() };
await mkdir(cacheDir, { recursive: true });
await writeFile(join(cacheDir, "chrome-workspace.json"), JSON.stringify(projectConfiguration), "utf-8");
}
nitro.options.devHandlers.push({
route: "/.well-known/appspecific/com.chrome.devtools.json",
handler: defineEventHandler(() => ({ workspace: {
...projectConfiguration,
root: nuxt.options.rootDir
} }))
});
}
if (!nuxt.options.dev && nuxt.options.experimental.noVueServer) nitro.hooks.hook("rollup:before", (nitro) => {
if (nitro.options.preset === "nitro-prerender") {
nitro.options.errorHandler = resolve(distDir, "runtime/handlers/error");
return;
}
const nuxtErrorHandler = nitro.options.handlers.findIndex((h) => h.route === "/__nuxt_error");
if (nuxtErrorHandler >= 0) nitro.options.handlers.splice(nuxtErrorHandler, 1);
nitro.options.renderer = void 0;
});
nitro.hooks.hook("types:extend", (types) => {
types.tsConfig ||= {};
const rootDirGlob = relativeWithDot(nuxt.options.buildDir, join(nuxt.options.rootDir, "**/*"));
types.tsConfig.include = types.tsConfig.include?.filter((i) => i !== rootDirGlob);
});
nuxt.hook("prepare:types", async (opts) => {
if (!nuxt.options.dev) {
await scanHandlers(nitro);
await writeTypes(nitro);
}
opts.tsConfig.exclude ||= [];
opts.tsConfig.exclude.push(relative(nuxt.options.buildDir, resolve(nuxt.options.rootDir, nitro.options.output.dir)));
opts.tsConfig.exclude.push(relative(nuxt.options.buildDir, resolve(nuxt.options.rootDir, nuxt.options.serverDir)));
opts.references.push({ path: resolve(nuxt.options.buildDir, "types/nitro.d.ts") });
opts.sharedTsConfig.compilerOptions ||= {};
opts.sharedTsConfig.compilerOptions.paths ||= {};
for (const key in nuxt.options.alias) if (nitro.options.alias[key] && nitro.options.alias[key] === nuxt.options.alias[key]) {
const dirKey = join(key, "*");
if (opts.tsConfig.compilerOptions?.paths[key]) opts.sharedTsConfig.compilerOptions.paths[key] = opts.tsConfig.compilerOptions.paths[key];
if (opts.tsConfig.compilerOptions?.paths[dirKey]) opts.sharedTsConfig.compilerOptions.paths[dirKey] = opts.tsConfig.compilerOptions.paths[dirKey];
}
});
if (nitro.options.static) nitro.hooks.hook("prerender:routes", (routes) => {
for (const route of ["/200.html", "/404.html"]) routes.add(route);
if (!nuxt.options.ssr) routes.add("/index.html");
});
if (!nuxt.options.dev) nitro.hooks.hook("rollup:before", async (nitro) => {
await copyPublicAssets(nitro);
await nuxt.callHook("nitro:build:public-assets", nitro);
});
async function symlinkDist() {
if (nitro.options.static) {
const distDir = resolve(nuxt.options.rootDir, "dist");
if (!existsSync(distDir)) await promises.symlink(nitro.options.output.publicDir, distDir, "junction").catch(() => {});
}
}
nuxt.hook("build:done", async () => {
await nuxt.callHook("nitro:build:before", nitro);
await prepare(nitro);
if (nuxt.options.dev) return build(nitro);
await prerender(nitro);
logger.restoreAll();
await build(nitro);
logger.wrapAll();
await symlinkDist();
});
if (nuxt.options.dev) {
for (const builder of ["webpack", "rspack"]) {
nuxt.hook(`${builder}:compile`, ({ name, compiler }) => {
if (name === "server") {
const memfs = compiler.outputFileSystem;
nitro.options.virtual["#build/dist/server/server.mjs"] = () => memfs.readFileSync(join(nuxt.options.buildDir, "dist/server/server.mjs"), "utf-8");
}
});
nuxt.hook(`${builder}:compiled`, () => {
nuxt.server.reload();
});
}
nuxt.hook("vite:compiled", () => {
nuxt.server.reload();
});
nuxt.hook("server:devHandler", (h, options) => {
devMiddlewareHandler.set(defineEventHandler((event) => {
if (options.cors(event.path)) {
if (handleCors(event, nuxt.options.devServer.cors)) return null;
setHeader(event, "Vary", "Origin");
}
return h(event);
}));
});
nuxt.server = createDevServer(nitro);
const waitUntilCompile = new Promise((resolve) => nitro.hooks.hook("compiled", () => resolve()));
nuxt.hook("build:done", () => waitUntilCompile);
}
}
const RELATIVE_RE = /^([^.])/;
function relativeWithDot(from, to) {
return relative(from, to).replace(RELATIVE_RE, "./$1") || ".";
}
async function spaLoadingTemplatePath(nuxt) {
if (typeof nuxt.options.spaLoadingTemplate === "string") return resolve(nuxt.options.srcDir, nuxt.options.spaLoadingTemplate);
return await findPath(nuxt.options._layers.map((layer) => resolve(layer.config.srcDir, layer.config.dir?.app || "app", "spa-loading-template.html"))) ?? resolve(nuxt.options.srcDir, nuxt.options.dir?.app || "app", "spa-loading-template.html");
}
async function spaLoadingTemplate(nuxt) {
if (nuxt.options.spaLoadingTemplate === false) return "";
const spaLoadingTemplate = await spaLoadingTemplatePath(nuxt);
try {
if (existsSync(spaLoadingTemplate)) return readFileSync(spaLoadingTemplate, "utf-8").trim();
} catch {}
if (nuxt.options.spaLoadingTemplate === true) return template();
if (nuxt.options.spaLoadingTemplate) logger.warn(`Could not load custom \`spaLoadingTemplate\` path as it does not exist: \`${nuxt.options.spaLoadingTemplate}\`.`);
return "";
}
export { bundle };

View File

@@ -0,0 +1,3 @@
import type { NitroErrorHandler } from "nitropack/types";
declare const _default: NitroErrorHandler;
export default _default;

View File

@@ -0,0 +1,77 @@
import { joinURL, withQuery, withoutBase } from "ufo";
import { appendResponseHeader, getRequestHeaders, send, setResponseHeader, setResponseHeaders, setResponseStatus } from "h3";
import { useNitroApp, useRuntimeConfig } from "nitropack/runtime";
import { isJsonRequest } from "../utils/error.mjs";
import { generateErrorOverlayHTML } from "../utils/dev.mjs";
export default (async function errorhandler(error, event, { defaultHandler }) {
if (event.handled || isJsonRequest(event)) {
// let Nitro handle JSON errors
return;
}
// invoke default Nitro error handler (which will log appropriately if required)
const defaultRes = await defaultHandler(error, event, { json: true });
// let Nitro handle redirect if appropriate
const status = error.status || error.statusCode || 500;
if (status === 404 && defaultRes.status === 302) {
setResponseHeaders(event, defaultRes.headers);
setResponseStatus(event, defaultRes.status, defaultRes.statusText);
return send(event, JSON.stringify(defaultRes.body, null, 2));
}
if (import.meta.dev && typeof defaultRes.body !== "string" && Array.isArray(defaultRes.body.stack)) {
// normalize to string format expected by nuxt `error.vue`
defaultRes.body.stack = defaultRes.body.stack.join("\n");
}
const errorObject = defaultRes.body;
// remove proto/hostname/port from URL
const url = new URL(errorObject.url);
errorObject.url = withoutBase(url.pathname, useRuntimeConfig(event).app.baseURL) + url.search + url.hash;
// add default server message (keep sanitized for unhandled errors)
errorObject.message = error.unhandled ? errorObject.message || "Server Error" : error.message || errorObject.message || "Server Error";
// we will be rendering this error internally so we can pass along the error.data safely
errorObject.data ||= error.data;
errorObject.statusText ||= error.statusText || error.statusMessage;
delete defaultRes.headers["content-type"];
delete defaultRes.headers["content-security-policy"];
setResponseHeaders(event, defaultRes.headers);
// Access request headers
const reqHeaders = getRequestHeaders(event);
// Detect to avoid recursion in SSR rendering of errors
const isRenderingError = event.path.startsWith("/__nuxt_error") || !!reqHeaders["x-nuxt-error"];
// HTML response (via SSR)
const res = isRenderingError ? null : await useNitroApp().localFetch(withQuery(joinURL(useRuntimeConfig(event).app.baseURL, "/__nuxt_error"), errorObject), {
headers: {
...reqHeaders,
"x-nuxt-error": "true"
},
redirect: "manual"
}).catch(() => null);
if (event.handled) {
return;
}
// Fallback to static rendered error page
if (!res) {
const { template } = await import("../templates/error-500");
if (import.meta.dev) {
// TODO: Support `message` in template
errorObject.description = errorObject.message;
}
setResponseHeader(event, "Content-Type", "text/html;charset=UTF-8");
return send(event, template(errorObject));
}
const html = await res.text();
for (const [header, value] of res.headers.entries()) {
if (header === "set-cookie") {
appendResponseHeader(event, header, value);
continue;
}
setResponseHeader(event, header, value);
}
setResponseStatus(event, res.status && res.status !== 200 ? res.status : defaultRes.status, res.statusText || defaultRes.statusText);
if (import.meta.dev && !import.meta.test && typeof html === "string") {
const prettyResponse = await defaultHandler(error, event, { json: false });
if (typeof prettyResponse.body === "string") {
return send(event, html.replace("</body>", `${generateErrorOverlayHTML(prettyResponse.body, { startMinimized: 300 <= status && status < 500 })}</body>`));
}
}
return send(event, html);
});

View File

@@ -0,0 +1,2 @@
declare const _default;
export default _default;

View File

@@ -0,0 +1,120 @@
import { useNitroApp } from "nitropack/runtime";
import { destr } from "destr";
import { defineEventHandler, getQuery, readBody, setResponseHeaders } from "h3";
import { resolveUnrefHeadInput } from "@unhead/vue";
import { getRequestDependencies } from "vue-bundle-renderer/runtime";
import { getQuery as getURLQuery } from "ufo";
import { islandCache, islandPropCache } from "../utils/cache.mjs";
import { createSSRContext } from "../utils/renderer/app.mjs";
import { getSSRRenderer } from "../utils/renderer/build-files.mjs";
import { renderInlineStyles } from "../utils/renderer/inline-styles.mjs";
import { getClientIslandResponse, getServerComponentHTML, getSlotIslandResponse } from "../utils/renderer/islands.mjs";
const ISLAND_SUFFIX_RE = /\.json(?:\?.*)?$/;
export default defineEventHandler(async (event) => {
const nitroApp = useNitroApp();
setResponseHeaders(event, {
"content-type": "application/json;charset=utf-8",
"x-powered-by": "Nuxt"
});
if (import.meta.prerender && event.path && await islandCache.hasItem(event.path)) {
return islandCache.getItem(event.path);
}
const islandContext = await getIslandContext(event);
const ssrContext = {
...createSSRContext(event),
islandContext,
noSSR: false,
url: islandContext.url
};
// Render app
const renderer = await getSSRRenderer();
const renderResult = await renderer.renderToString(ssrContext).catch(async (err) => {
await ssrContext.nuxt?.hooks.callHook("app:error", err);
throw err;
});
// Handle errors
if (ssrContext.payload?.error) {
throw ssrContext.payload.error;
}
const inlinedStyles = await renderInlineStyles(ssrContext.modules ?? []);
await ssrContext.nuxt?.hooks.callHook("app:rendered", {
ssrContext,
renderResult
});
if (inlinedStyles.length) {
ssrContext.head.push({ style: inlinedStyles });
}
if (import.meta.dev) {
const { styles } = getRequestDependencies(ssrContext, renderer.rendererContext);
const link = [];
for (const resource of Object.values(styles)) {
// Do not add links to resources that are inlined (vite v5+)
if ("inline" in getURLQuery(resource.file)) {
continue;
}
// Add CSS links in <head> for CSS files
// - in dev mode when rendering an island and the file has scoped styles and is not a page
if (resource.file.includes("scoped") && !resource.file.includes("pages/")) {
link.push({
rel: "stylesheet",
href: renderer.rendererContext.buildAssetsURL(resource.file),
crossorigin: ""
});
}
}
if (link.length) {
ssrContext.head.push({ link }, { mode: "server" });
}
}
const islandHead = {};
for (const entry of ssrContext.head.entries.values()) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
for (const [key, value] of Object.entries(resolveUnrefHeadInput(entry.input))) {
const currentValue = islandHead[key];
if (Array.isArray(currentValue)) {
currentValue.push(...value);
} else {
islandHead[key] = value;
}
}
}
const islandResponse = {
id: islandContext.id,
head: islandHead,
html: getServerComponentHTML(renderResult.html),
components: getClientIslandResponse(ssrContext),
slots: getSlotIslandResponse(ssrContext)
};
await nitroApp.hooks.callHook("render:island", islandResponse, {
event,
islandContext
});
if (import.meta.prerender) {
await islandCache.setItem(`/__nuxt_island/${islandContext.name}_${islandContext.id}.json`, islandResponse);
await islandPropCache.setItem(`/__nuxt_island/${islandContext.name}_${islandContext.id}.json`, event.path);
}
return islandResponse;
});
async function getIslandContext(event) {
// TODO: Strict validation for url
let url = event.path || "";
if (import.meta.prerender && event.path && await islandPropCache.hasItem(event.path)) {
// rehydrate props from cache so we can rerender island if cache does not have it any more
url = await islandPropCache.getItem(event.path);
}
const componentParts = url.substring("/__nuxt_island".length + 1).replace(ISLAND_SUFFIX_RE, "").split("_");
const hashId = componentParts.length > 1 ? componentParts.pop() : undefined;
const componentName = componentParts.join("_");
// TODO: Validate context
const context = event.method === "GET" ? getQuery(event) : await readBody(event);
const ctx = {
url: "/",
...context,
id: hashId,
name: componentName,
props: destr(context.props) || {},
slots: {},
components: {}
};
return ctx;
}

View File

@@ -0,0 +1,2 @@
declare const _default;
export default _default;

View File

@@ -0,0 +1,305 @@
import { AsyncLocalStorage } from "node:async_hooks";
import { getPrefetchLinks, getPreloadLinks, getRequestDependencies, renderResourceHeaders } from "vue-bundle-renderer/runtime";
import { appendResponseHeader, createError, getQuery, getResponseStatus, getResponseStatusText, writeEarlyHints } from "h3";
import { getQuery as getURLQuery, joinURL } from "ufo";
import { propsToString, renderSSRHead } from "@unhead/vue/server";
import destr from "destr";
import { defineRenderHandler, getRouteRules, useNitroApp } from "nitropack/runtime";
import { getRenderer } from "../utils/renderer/build-files.mjs";
import { payloadCache } from "../utils/cache.mjs";
import { renderPayloadJsonScript, renderPayloadResponse, renderPayloadScript, splitPayload } from "../utils/renderer/payload.mjs";
import { createSSRContext, setSSRError } from "../utils/renderer/app.mjs";
import { renderInlineStyles } from "../utils/renderer/inline-styles.mjs";
import { replaceIslandTeleports } from "../utils/renderer/islands.mjs";
// @ts-expect-error virtual file
import { renderSSRHeadOptions } from "#internal/unhead.config.mjs";
// @ts-expect-error virtual file
import { NUXT_ASYNC_CONTEXT, NUXT_EARLY_HINTS, NUXT_INLINE_STYLES, NUXT_JSON_PAYLOADS, NUXT_NO_SCRIPTS, NUXT_PAYLOAD_EXTRACTION, NUXT_RUNTIME_PAYLOAD_EXTRACTION, PARSE_ERROR_DATA } from "#internal/nuxt/nitro-config.mjs";
// @ts-expect-error virtual file
import { appHead, appTeleportAttrs, appTeleportTag, componentIslands, appManifest as isAppManifestEnabled } from "#internal/nuxt.config.mjs";
// @ts-expect-error virtual file
import entryIds from "#internal/nuxt/entry-ids.mjs";
// @ts-expect-error virtual file
import { entryFileName } from "#internal/entry-chunk.mjs";
// @ts-expect-error virtual file
import { buildAssetsURL, publicAssetsURL } from "#internal/nuxt/paths";
import { relative } from "pathe";
// @ts-expect-error private property consumed by vite-generated url helpers
globalThis.__buildAssetsURL = buildAssetsURL;
// @ts-expect-error private property consumed by vite-generated url helpers
globalThis.__publicAssetsURL = publicAssetsURL;
// Polyfill for unctx (https://github.com/unjs/unctx#native-async-context)
if (NUXT_ASYNC_CONTEXT && !("AsyncLocalStorage" in globalThis)) {
globalThis.AsyncLocalStorage = AsyncLocalStorage;
}
const HAS_APP_TELEPORTS = !!(appTeleportTag && appTeleportAttrs.id);
const APP_TELEPORT_OPEN_TAG = HAS_APP_TELEPORTS ? `<${appTeleportTag}${propsToString(appTeleportAttrs)}>` : "";
const APP_TELEPORT_CLOSE_TAG = HAS_APP_TELEPORTS ? `</${appTeleportTag}>` : "";
const PAYLOAD_URL_RE = NUXT_JSON_PAYLOADS ? /^[^?]*\/_payload.json(?:\?.*)?$/ : /^[^?]*\/_payload.js(?:\?.*)?$/;
const PAYLOAD_FILENAME = NUXT_JSON_PAYLOADS ? "_payload.json" : "_payload.js";
let entryPath;
export default defineRenderHandler(async (event) => {
const nitroApp = useNitroApp();
// Whether we're rendering an error page
const ssrError = event.path.startsWith("/__nuxt_error") ? getQuery(event) : null;
if (ssrError && !("__unenv__" in event.node.req)) {
throw createError({
status: 404,
statusText: "Page Not Found: /__nuxt_error",
message: "Page Not Found: /__nuxt_error"
});
}
// Initialize ssr context
const ssrContext = createSSRContext(event);
// needed for hash hydration plugin to work
const headEntryOptions = { mode: "server" };
ssrContext.head.push(appHead, headEntryOptions);
if (ssrError) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const status = ssrError.status || ssrError.statusCode;
if (status) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
ssrError.status = ssrError.statusCode = Number.parseInt(status);
}
if (PARSE_ERROR_DATA && typeof ssrError.data === "string") {
try {
ssrError.data = destr(ssrError.data);
} catch {}
}
setSSRError(ssrContext, ssrError);
}
// Get route options (for `ssr: false`, `isr`, `cache` and `noScripts`)
const routeOptions = getRouteRules(event);
// Whether we are prerendering route or using ISR/SWR caching
const _PAYLOAD_EXTRACTION = !ssrContext.noSSR && (import.meta.prerender && NUXT_PAYLOAD_EXTRACTION || NUXT_RUNTIME_PAYLOAD_EXTRACTION && (routeOptions.isr || routeOptions.cache));
const isRenderingPayload = (_PAYLOAD_EXTRACTION || import.meta.dev && routeOptions.prerender) && PAYLOAD_URL_RE.test(ssrContext.url);
if (isRenderingPayload) {
const url = ssrContext.url.substring(0, ssrContext.url.lastIndexOf("/")) || "/";
ssrContext.url = url;
event._path = event.node.req.url = url;
if (import.meta.prerender && await payloadCache.hasItem(url)) {
return payloadCache.getItem(url);
}
}
if (routeOptions.ssr === false) {
ssrContext.noSSR = true;
}
const payloadURL = _PAYLOAD_EXTRACTION ? joinURL(ssrContext.runtimeConfig.app.cdnURL || ssrContext.runtimeConfig.app.baseURL, ssrContext.url.replace(/\?.*$/, ""), PAYLOAD_FILENAME) + "?" + ssrContext.runtimeConfig.app.buildId : undefined;
// Render app
const renderer = await getRenderer(ssrContext);
// Render 103 Early Hints
if (NUXT_EARLY_HINTS && !isRenderingPayload && !import.meta.prerender) {
const { link } = renderResourceHeaders({}, renderer.rendererContext);
if (link) {
writeEarlyHints(event, link);
}
}
if (NUXT_INLINE_STYLES) {
for (const id of entryIds) {
ssrContext.modules.add(id);
}
}
const _rendered = await renderer.renderToString(ssrContext).catch(async (error) => {
// We use error to bypass full render if we have an early response we can make
// TODO: remove _renderResponse in nuxt v5
if ((ssrContext["~renderResponse"] || ssrContext._renderResponse) && error.message === "skipping render") {
return {};
}
// Use explicitly thrown error in preference to subsequent rendering errors
const _err = !ssrError && ssrContext.payload?.error || error;
await ssrContext.nuxt?.hooks.callHook("app:error", _err);
throw _err;
});
// Render inline styles
// TODO: remove _renderResponse in nuxt v5
const inlinedStyles = NUXT_INLINE_STYLES && !ssrContext["~renderResponse"] && !ssrContext._renderResponse && !isRenderingPayload ? await renderInlineStyles(ssrContext.modules ?? []) : [];
await ssrContext.nuxt?.hooks.callHook("app:rendered", {
ssrContext,
renderResult: _rendered
});
if (ssrContext["~renderResponse"] || ssrContext._renderResponse) {
// TODO: remove _renderResponse in nuxt v5
return ssrContext["~renderResponse"] || ssrContext._renderResponse;
}
// Handle errors
if (ssrContext.payload?.error && !ssrError) {
throw ssrContext.payload.error;
}
// Directly render payload routes
if (isRenderingPayload) {
const response = renderPayloadResponse(ssrContext);
if (import.meta.prerender) {
await payloadCache.setItem(ssrContext.url, response);
}
return response;
}
if (_PAYLOAD_EXTRACTION && import.meta.prerender) {
// Hint nitro to prerender payload for this route
appendResponseHeader(event, "x-nitro-prerender", joinURL(ssrContext.url.replace(/\?.*$/, ""), PAYLOAD_FILENAME));
// Use same ssr context to generate payload for this route
await payloadCache.setItem(ssrContext.url === "/" ? "/" : ssrContext.url.replace(/\/$/, ""), renderPayloadResponse(ssrContext));
}
const NO_SCRIPTS = NUXT_NO_SCRIPTS || routeOptions.noScripts;
// Setup head
const { styles, scripts } = getRequestDependencies(ssrContext, renderer.rendererContext);
// 0. Add import map for stable chunk hashes
if (entryFileName && !NO_SCRIPTS) {
let path = entryPath;
if (!path) {
path = buildAssetsURL(entryFileName);
if (ssrContext.runtimeConfig.app.cdnURL || /^(?:\/|\.+\/)/.test(path)) {
// cache absolute entry path
entryPath = path;
} else {
// TODO: provide support for relative paths in assets as well
// relativise path
path = relative(event.path.replace(/\/[^/]+$/, "/"), joinURL("/", path));
if (!/^(?:\/|\.+\/)/.test(path)) {
path = `./${path}`;
}
}
}
ssrContext.head.push({ script: [{
tagPosition: "head",
tagPriority: -2,
type: "importmap",
innerHTML: JSON.stringify({ imports: { "#entry": path } })
}] }, headEntryOptions);
}
// 1. Preload payloads and app manifest
if (_PAYLOAD_EXTRACTION && !NO_SCRIPTS) {
ssrContext.head.push({ link: [NUXT_JSON_PAYLOADS ? {
rel: "preload",
as: "fetch",
crossorigin: "anonymous",
href: payloadURL
} : {
rel: "modulepreload",
crossorigin: "",
href: payloadURL
}] }, headEntryOptions);
}
if (isAppManifestEnabled && ssrContext["~preloadManifest"] && !NO_SCRIPTS) {
ssrContext.head.push({ link: [{
rel: "preload",
as: "fetch",
fetchpriority: "low",
crossorigin: "anonymous",
href: buildAssetsURL(`builds/meta/${ssrContext.runtimeConfig.app.buildId}.json`)
}] }, {
...headEntryOptions,
tagPriority: "low"
});
}
// 2. Styles
if (inlinedStyles.length) {
ssrContext.head.push({ style: inlinedStyles });
}
const link = [];
for (const resource of Object.values(styles)) {
// Do not add links to resources that are inlined (vite v5+)
if (import.meta.dev && "inline" in getURLQuery(resource.file)) {
continue;
}
// Add CSS links in <head> for CSS files
// - in production
// - in dev mode when not rendering an island
link.push({
rel: "stylesheet",
href: renderer.rendererContext.buildAssetsURL(resource.file),
crossorigin: ""
});
}
if (link.length) {
ssrContext.head.push({ link }, headEntryOptions);
}
if (!NO_SCRIPTS) {
// 4. Resource Hints
// Remove lazy hydrated modules from ssrContext.modules so they don't get preloaded
// (CSS links are already added above, this only affects JS preloads)
if (ssrContext["~lazyHydratedModules"]) {
for (const id of ssrContext["~lazyHydratedModules"]) {
ssrContext.modules?.delete(id);
}
}
ssrContext.head.push({ link: getPreloadLinks(ssrContext, renderer.rendererContext) }, headEntryOptions);
ssrContext.head.push({ link: getPrefetchLinks(ssrContext, renderer.rendererContext) }, headEntryOptions);
// 5. Payloads
ssrContext.head.push({ script: _PAYLOAD_EXTRACTION ? NUXT_JSON_PAYLOADS ? renderPayloadJsonScript({
ssrContext,
data: splitPayload(ssrContext).initial,
src: payloadURL
}) : renderPayloadScript({
ssrContext,
data: splitPayload(ssrContext).initial,
routeOptions,
src: payloadURL
}) : NUXT_JSON_PAYLOADS ? renderPayloadJsonScript({
ssrContext,
data: ssrContext.payload
}) : renderPayloadScript({
ssrContext,
data: ssrContext.payload,
routeOptions
}) }, {
...headEntryOptions,
tagPosition: "bodyClose",
tagPriority: "high"
});
}
// 6. Scripts
if (!routeOptions.noScripts) {
const tagPosition = _PAYLOAD_EXTRACTION && !NUXT_JSON_PAYLOADS ? "bodyClose" : "head";
ssrContext.head.push({ script: Object.values(scripts).map((resource) => ({
type: resource.module ? "module" : null,
src: renderer.rendererContext.buildAssetsURL(resource.file),
defer: resource.module ? null : true,
tagPosition,
crossorigin: ""
})) }, headEntryOptions);
}
const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = await renderSSRHead(ssrContext.head, renderSSRHeadOptions);
// Create render context
const htmlContext = {
htmlAttrs: htmlAttrs ? [htmlAttrs] : [],
head: normalizeChunks([headTags]),
bodyAttrs: bodyAttrs ? [bodyAttrs] : [],
bodyPrepend: normalizeChunks([bodyTagsOpen, ssrContext.teleports?.body]),
body: [componentIslands ? replaceIslandTeleports(ssrContext, _rendered.html) : _rendered.html, APP_TELEPORT_OPEN_TAG + (HAS_APP_TELEPORTS ? joinTags([ssrContext.teleports?.[`#${appTeleportAttrs.id}`]]) : "") + APP_TELEPORT_CLOSE_TAG],
bodyAppend: [bodyTags]
};
// Allow hooking into the rendered result
await nitroApp.hooks.callHook("render:html", htmlContext, { event });
// Construct HTML response
return {
body: renderHTMLDocument(htmlContext),
statusCode: getResponseStatus(event),
statusMessage: getResponseStatusText(event),
headers: {
"content-type": "text/html;charset=utf-8",
"x-powered-by": "Nuxt"
}
};
});
function normalizeChunks(chunks) {
const result = [];
for (const _chunk of chunks) {
const chunk = _chunk?.trim();
if (chunk) {
result.push(chunk);
}
}
return result;
}
function joinTags(tags) {
return tags.join("");
}
function joinAttrs(chunks) {
if (chunks.length === 0) {
return "";
}
return " " + chunks.join(" ");
}
function renderHTMLDocument(html) {
return "<!DOCTYPE html>" + `<html${joinAttrs(html.htmlAttrs)}>` + `<head>${joinTags(html.head)}</head>` + `<body${joinAttrs(html.bodyAttrs)}>${joinTags(html.bodyPrepend)}${joinTags(html.body)}${joinTags(html.bodyAppend)}</body>` + "</html>";
}

View File

@@ -0,0 +1,2 @@
declare const _default;
export default _default;

View File

@@ -0,0 +1,7 @@
import { defineEventHandler, getRequestHeader } from "h3";
export default defineEventHandler((event) => {
if (getRequestHeader(event, "x-nuxt-no-ssr")) {
event.context.nuxt ||= {};
event.context.nuxt.noSSR = true;
}
});

View File

@@ -0,0 +1,2 @@
declare const _default;
export default _default;

View File

@@ -0,0 +1,94 @@
import { AsyncLocalStorage } from "node:async_hooks";
import { consola } from "consola";
import { stringify } from "devalue";
import { withTrailingSlash } from "ufo";
import { getContext } from "unctx";
import { captureRawStackTrace, parseRawStackTrace } from "errx";
import { isVNode } from "vue";
// @ts-expect-error virtual file
import { rootDir } from "#internal/dev-server-logs-options";
// @ts-expect-error virtual file
import { appId } from "#internal/nuxt.config.mjs";
const devReducers = {
VNode: (data) => isVNode(data) ? {
type: data.type,
props: data.props
} : undefined,
URL: (data) => data instanceof URL ? data.toString() : undefined
};
const asyncContext = getContext("nuxt-dev", {
asyncContext: true,
AsyncLocalStorage
});
export default (nitroApp) => {
const handler = nitroApp.h3App.handler;
nitroApp.h3App.handler = (event) => {
return asyncContext.callAsync({
logs: [],
event
}, () => handler(event));
};
onConsoleLog((_log) => {
const ctx = asyncContext.tryUse();
if (!ctx) {
return;
}
const rawStack = captureRawStackTrace();
if (!rawStack || rawStack.includes("runtime/vite-node.mjs")) {
return;
}
const trace = [];
let filename = "";
for (const entry of parseRawStackTrace(rawStack)) {
if (entry.source === import.meta.url) {
continue;
}
if (EXCLUDE_TRACE_RE.test(entry.source)) {
continue;
}
filename ||= entry.source.replace(withTrailingSlash(rootDir), "");
trace.push({
...entry,
source: entry.source.startsWith("file://") ? entry.source.replace("file://", "") : entry.source
});
}
const log = {
..._log,
filename,
stack: trace
};
// retain log to be include in the next render
ctx.logs.push(log);
});
nitroApp.hooks.hook("afterResponse", () => {
const ctx = asyncContext.tryUse();
if (!ctx) {
return;
}
return nitroApp.hooks.callHook("dev:ssr-logs", {
logs: ctx.logs,
path: ctx.event.path
});
});
// Pass any logs to the client
nitroApp.hooks.hook("render:html", (htmlContext) => {
const ctx = asyncContext.tryUse();
if (!ctx) {
return;
}
try {
const reducers = Object.assign(Object.create(null), devReducers, ctx.event.context["~payloadReducers"]);
htmlContext.bodyAppend.unshift(`<script type="application/json" data-nuxt-logs="${appId}">${stringify(ctx.logs, reducers)}<\/script>`);
} catch (e) {
const shortError = e instanceof Error && "toString" in e ? ` Received \`${e.toString()}\`.` : "";
console.warn(`[nuxt] Failed to stringify dev server logs.${shortError} You can define your own reducer/reviver for rich types following the instructions in https://nuxt.com/docs/4.x/api/composables/use-nuxt-app#payload.`);
}
});
};
const EXCLUDE_TRACE_RE = /\/node_modules\/(?:.*\/)?(?:nuxt|nuxt-nightly|nuxt-edge|nuxt3|consola|@vue)\/|core\/runtime\/nitro/;
function onConsoleLog(callback) {
consola.addReporter({ log(logObj) {
callback(logObj);
} });
consola.wrapConsole();
}

View File

@@ -0,0 +1,2 @@
export type DefaultMessages = Record<"appName" | "status" | "statusText" | "description" | "refresh", string | boolean | number>;
export declare const template: (messages: Partial<DefaultMessages>) => string;

View File

@@ -0,0 +1,15 @@
import { escapeHtml } from "@vue/shared";
const _messages = {
"appName": "Nuxt",
"status": 500,
"statusText": "Internal server error",
"description": "This page is temporarily unavailable.",
"refresh": "Refresh this page"
};
export const template = (messages) => {
messages = {
..._messages,
...messages
};
return "<!DOCTYPE html><html lang=\"en\"><head><title>" + escapeHtml(messages.status) + " - " + escapeHtml(messages.statusText) + " | " + escapeHtml(messages.appName) + "</title><meta charset=\"utf-8\"><meta content=\"width=device-width,initial-scale=1.0,minimum-scale=1.0\" name=\"viewport\"><script>!function(){const e=document.createElement(\"link\").relList;if(!(e&&e.supports&&e.supports(\"modulepreload\"))){for(const e of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(e);new MutationObserver(e=>{for(const o of e)if(\"childList\"===o.type)for(const e of o.addedNodes)\"LINK\"===e.tagName&&\"modulepreload\"===e.rel&&r(e)}).observe(document,{childList:!0,subtree:!0})}function r(e){if(e.ep)return;e.ep=!0;const r=function(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),\"use-credentials\"===e.crossOrigin?r.credentials=\"include\":\"anonymous\"===e.crossOrigin?r.credentials=\"omit\":r.credentials=\"same-origin\",r}(e);fetch(e.href,r)}}();<\/script><style>*,:after,:before{border-color:var(--un-default-border-color,#e5e7eb);border-style:solid;border-width:0;box-sizing:border-box}:after,:before{--un-content:\"\"}html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}h1,h2{font-size:inherit;font-weight:inherit}h1,h2,p{margin:0}*,:after,:before{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 transparent;--un-ring-shadow:0 0 transparent;--un-shadow-inset: ;--un-shadow:0 0 transparent;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgba(147,197,253,.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }.grid{display:grid}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.max-w-520px{max-width:520px}.min-h-screen{min-height:100vh}.place-content-center{place-content:center}.overflow-hidden{overflow:hidden}.bg-white{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-2{padding-left:.5rem;padding-right:.5rem}.text-center{text-align:center}.text-\\[80px\\]{font-size:80px}.text-2xl{font-size:1.5rem;line-height:2rem}.text-\\[\\#020420\\]{--un-text-opacity:1;color:rgb(2 4 32/var(--un-text-opacity))}.text-\\[\\#64748B\\]{--un-text-opacity:1;color:rgb(100 116 139/var(--un-text-opacity))}.font-semibold{font-weight:600}.leading-none{line-height:1}.tracking-wide{letter-spacing:.025em}.font-sans{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.tabular-nums{--un-numeric-spacing:tabular-nums;font-variant-numeric:var(--un-ordinal) var(--un-slashed-zero) var(--un-numeric-figure) var(--un-numeric-spacing) var(--un-numeric-fraction)}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media(prefers-color-scheme:dark){.dark\\:bg-\\[\\#020420\\]{--un-bg-opacity:1;background-color:rgb(2 4 32/var(--un-bg-opacity))}.dark\\:text-white{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media(min-width:640px){.sm\\:text-\\[110px\\]{font-size:110px}.sm\\:text-3xl{font-size:1.875rem;line-height:2.25rem}}</style></head><body class=\"antialiased bg-white dark:bg-[#020420] dark:text-white font-sans grid min-h-screen overflow-hidden place-content-center text-[#020420] tracking-wide\"><div class=\"max-w-520px text-center\"><h1 class=\"font-semibold leading-none mb-4 sm:text-[110px] tabular-nums text-[80px]\">" + escapeHtml(messages.status) + "</h1><h2 class=\"font-semibold mb-2 sm:text-3xl text-2xl\">" + escapeHtml(messages.statusText) + "</h2><p class=\"mb-4 px-2 text-[#64748B] text-md\">" + escapeHtml(messages.description) + "</p></div></body></html>";
};

View File

@@ -0,0 +1,3 @@
import type { H3Event } from "h3";
import type { AppConfig } from "@nuxt/schema";
export declare function useAppConfig(event?: H3Event): AppConfig;

View File

@@ -0,0 +1,31 @@
import { klona } from "klona";
// @ts-expect-error virtual file
import _inlineAppConfig from "#internal/nuxt/app-config";
// App config
const _sharedAppConfig = _deepFreeze(klona(_inlineAppConfig));
export function useAppConfig(event) {
// Backwards compatibility with ambient context
if (!event) {
return _sharedAppConfig;
}
event.context.nuxt ||= {};
// Reuse cached app config from event context
if (event.context.nuxt.appConfig) {
return event.context.nuxt.appConfig;
}
// Prepare app config for event context
const appConfig = klona(_inlineAppConfig);
event.context.nuxt.appConfig = appConfig;
return appConfig;
}
// --- Utils ---
function _deepFreeze(object) {
const propNames = Object.getOwnPropertyNames(object);
for (const name of propNames) {
const value = object[name];
if (value && typeof value === "object") {
_deepFreeze(value);
}
}
return Object.freeze(object);
}

View File

@@ -0,0 +1,42 @@
// @ts-check
import crypto from 'node:crypto'
import { defineDriver } from 'unstorage'
import fsDriver from 'unstorage/drivers/fs-lite'
import lruCache from 'unstorage/drivers/lru-cache'
/**
* @param {string} item
*/
function normalizeFsKey (item) {
const safe = item.replace(/[^\w.-]/g, '_')
const prefix = safe.slice(0, 20)
const hash = crypto.createHash('sha256').update(item).digest('hex')
return `${prefix}-${hash}`
}
export default defineDriver(
/**
* @param {{ base?: string }} opts
*/
(opts) => {
const fs = fsDriver({ base: opts.base })
const lru = lruCache({ max: 1000 })
return {
...fs, // fall back to file system - only the bottom three methods are used in renderer
async setItem (key, value, opts) {
await Promise.all([
fs.setItem?.(normalizeFsKey(key), value, opts),
lru.setItem?.(key, value, opts),
])
},
async hasItem (key, opts) {
return await lru.hasItem(key, opts) || await fs.hasItem(normalizeFsKey(key), opts)
},
async getItem (key, opts) {
return await lru.getItem(key, opts) || await fs.getItem(normalizeFsKey(key), opts)
},
}
},
)

View File

@@ -0,0 +1,5 @@
export declare const payloadCache: unknown;
export declare const islandCache: unknown;
export declare const islandPropCache: unknown;
export declare const sharedPrerenderPromises: unknown;
export declare const sharedPrerenderCache: unknown;

View File

@@ -0,0 +1,20 @@
import { useStorage } from "nitropack/runtime";
// @ts-expect-error virtual file
import { NUXT_SHARED_DATA } from "#internal/nuxt/nitro-config.mjs";
export const payloadCache = import.meta.prerender ? useStorage("internal:nuxt:prerender:payload") : null;
export const islandCache = import.meta.prerender ? useStorage("internal:nuxt:prerender:island") : null;
export const islandPropCache = import.meta.prerender ? useStorage("internal:nuxt:prerender:island-props") : null;
export const sharedPrerenderPromises = import.meta.prerender && NUXT_SHARED_DATA ? new Map() : null;
const sharedPrerenderKeys = new Set();
export const sharedPrerenderCache = import.meta.prerender && NUXT_SHARED_DATA ? {
get(key) {
if (sharedPrerenderKeys.has(key)) {
return sharedPrerenderPromises.get(key) ?? useStorage("internal:nuxt:prerender:shared").getItem(key);
}
},
async set(key, value) {
sharedPrerenderKeys.add(key);
sharedPrerenderPromises.set(key, value);
useStorage("internal:nuxt:prerender:shared").setItem(key, await value).finally(() => sharedPrerenderPromises.delete(key));
}
} : null;

View File

@@ -0,0 +1 @@
export declare const defineAppConfig: unknown;

View File

@@ -0,0 +1 @@
export const defineAppConfig = (config) => config;

View File

@@ -0,0 +1,3 @@
export declare function generateErrorOverlayHTML(html: string, options?: {
startMinimized?: boolean;
}): string;

View File

@@ -0,0 +1,985 @@
const iframeStorageBridge = (nonce) => `
(function () {
const NONCE = ${JSON.stringify(nonce)};
const memoryStore = Object.create(null);
const post = (type, payload) => {
window.parent.postMessage({ type, nonce: NONCE, ...payload }, '*');
};
const isValid = (data) => data && data.nonce === NONCE;
const mockStorage = {
getItem(key) {
return Object.hasOwn(memoryStore, key)
? memoryStore[key]
: null;
},
setItem(key, value) {
const v = String(value);
memoryStore[key] = v;
post('storage-set', { key, value: v });
},
removeItem(key) {
delete memoryStore[key];
post('storage-remove', { key });
},
clear() {
for (const key of Object.keys(memoryStore))
delete memoryStore[key];
post('storage-clear', {});
},
key(index) {
const keys = Object.keys(memoryStore);
return keys[index] ?? null;
},
get length() {
return Object.keys(memoryStore).length;
}
};
const defineLocalStorage = () => {
try {
Object.defineProperty(window, 'localStorage', {
value: mockStorage,
writable: false,
configurable: true
});
} catch {
window.localStorage = mockStorage;
}
};
defineLocalStorage();
window.addEventListener('message', (event) => {
const data = event.data;
if (!isValid(data) || data.type !== 'storage-sync-data') return;
const incoming = data.data || {};
for (const key of Object.keys(incoming))
memoryStore[key] = incoming[key];
if (typeof window.initTheme === 'function')
window.initTheme();
window.dispatchEvent(new Event('storage-ready'));
});
// Clipboard API is unavailable in data: URL iframe, so we use postMessage
document.addEventListener('DOMContentLoaded', function() {
window.copyErrorMessage = function(button) {
post('clipboard-copy', { text: button.dataset.errorText });
button.classList.add('copied');
setTimeout(function() { button.classList.remove('copied'); }, 2000);
};
});
post('storage-sync-request', {});
})();
`;
const parentStorageBridge = (nonce) => `
(function () {
const host = document.querySelector('nuxt-error-overlay');
if (!host) return;
const NONCE = ${JSON.stringify(nonce)};
const isValid = (data) => data && data.nonce === NONCE;
// Handle clipboard copy from iframe
window.addEventListener('message', function(e) {
if (isValid(e) && e.data.type === 'clipboard-copy') {
navigator.clipboard.writeText(e.data.text).catch(function() {});
}
});
const collectLocalStorage = () => {
const all = {};
for (let i = 0; i < localStorage.length; i++) {
const k = localStorage.key(i);
if (k != null) all[k] = localStorage.getItem(k);
}
return all;
};
const attachWhenReady = () => {
const root = host.shadowRoot;
if (!root)
return false;
const iframe = root.getElementById('frame');
if (!iframe || !iframe.contentWindow)
return false;
const handlers = {
'storage-set': (d) => localStorage.setItem(d.key, d.value),
'storage-remove': (d) => localStorage.removeItem(d.key),
'storage-clear': () => localStorage.clear(),
'storage-sync-request': () => {
iframe.contentWindow.postMessage({
type: 'storage-sync-data',
data: collectLocalStorage(),
nonce: NONCE
}, '*');
}
};
window.addEventListener('message', (event) => {
const data = event.data;
if (!isValid(data)) return;
const fn = handlers[data.type];
if (fn) fn(data);
});
return true;
};
if (attachWhenReady())
return;
const obs = new MutationObserver(() => {
if (attachWhenReady())
obs.disconnect();
});
obs.observe(host, { childList: true, subtree: true });
})();
`;
const errorCSS = `
:host {
--preview-width: 240px;
--preview-height: 180px;
--base-width: 1200px;
--base-height: 900px;
--z-base: 999999998;
--error-pip-left: auto;
--error-pip-top: auto;
--error-pip-right: 5px;
--error-pip-bottom: 5px;
--error-pip-origin: bottom right;
--app-preview-left: auto;
--app-preview-top: auto;
--app-preview-right: 5px;
--app-preview-bottom: 5px;
all: initial;
display: contents;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
#frame {
position: fixed;
left: 0;
top: 0;
width: 100vw;
height: 100vh;
border: none;
z-index: var(--z-base);
}
#frame[inert] {
left: var(--error-pip-left);
top: var(--error-pip-top);
right: var(--error-pip-right);
bottom: var(--error-pip-bottom);
width: var(--base-width);
height: var(--base-height);
transform: scale(calc(240 / 1200));
transform-origin: var(--error-pip-origin);
overflow: hidden;
border-radius: calc(1200 * 8px / 240);
}
#preview {
position: fixed;
left: var(--app-preview-left);
top: var(--app-preview-top);
right: var(--app-preview-right);
bottom: var(--app-preview-bottom);
width: var(--preview-width);
height: var(--preview-height);
overflow: hidden;
border-radius: 6px;
pointer-events: none;
z-index: var(--z-base);
background: white;
display: none;
}
#preview iframe {
transform-origin: var(--error-pip-origin);
}
#frame:not([inert]) + #preview {
display: block;
}
#toggle {
position: fixed;
left: var(--app-preview-left);
top: var(--app-preview-top);
right: calc(var(--app-preview-right) - 3px);
bottom: calc(var(--app-preview-bottom) - 3px);
width: var(--preview-width);
height: var(--preview-height);
background: none;
border: 3px solid #00DC82;
border-radius: 8px;
cursor: pointer;
opacity: 0.8;
transition: opacity 0.2s, box-shadow 0.2s;
z-index: calc(var(--z-base) + 1);
display: flex;
align-items: center;
justify-content: center;
}
#toggle:hover,
#toggle:focus {
opacity: 1;
box-shadow: 0 0 20px rgba(0, 220, 130, 0.6);
}
#toggle:focus-visible {
outline: 3px solid #00DC82;
outline-offset: 0;
box-shadow: 0 0 24px rgba(0, 220, 130, 0.8);
}
#frame[inert] ~ #toggle {
left: var(--error-pip-left);
top: var(--error-pip-top);
right: calc(var(--error-pip-right) - 3px);
bottom: calc(var(--error-pip-bottom) - 3px);
cursor: grab;
}
:host(.dragging) #frame[inert] ~ #toggle {
cursor: grabbing;
}
#frame:not([inert]) ~ #toggle,
#frame:not([inert]) + #preview {
cursor: grab;
}
:host(.dragging-preview) #frame:not([inert]) ~ #toggle,
:host(.dragging-preview) #frame:not([inert]) + #preview {
cursor: grabbing;
}
#pip-close {
position: absolute;
top: 6px;
right: 6px;
width: 24px;
height: 24px;
border-radius: 50%;
border: none;
background: rgba(0, 0, 0, 0.75);
color: #fff;
font-size: 16px;
line-height: 1;
display: inline-flex;
align-items: center;
justify-content: center;
cursor: pointer;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
pointer-events: auto;
}
#pip-close:focus-visible {
outline: 2px solid #00DC82;
outline-offset: 2px;
}
#pip-restore {
position: fixed;
right: 16px;
bottom: 16px;
padding: 8px 14px;
border-radius: 999px;
border: 2px solid #00DC82;
background: #111;
color: #fff;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
font-size: 14px;
display: inline-flex;
align-items: center;
gap: 6px;
z-index: calc(var(--z-base) + 2);
cursor: grab;
}
#pip-restore:focus-visible {
outline: 2px solid #00DC82;
outline-offset: 2px;
}
:host(.dragging-restore) #pip-restore {
cursor: grabbing;
}
#frame[hidden],
#toggle[hidden],
#preview[hidden],
#pip-restore[hidden],
#pip-close[hidden] {
display: none !important;
}
@media (prefers-reduced-motion: reduce) {
#toggle {
transition: none;
}
}
`;
function webComponentScript(base64HTML, startMinimized) {
return `
(function () {
try {
// =========================
// Host + Shadow
// =========================
const host = document.querySelector('nuxt-error-overlay');
if (!host)
return;
const shadow = host.attachShadow({ mode: 'open' });
// =========================
// DOM helpers
// =========================
const el = (tag) => document.createElement(tag);
const on = (node, type, fn, opts) => node.addEventListener(type, fn, opts);
const hide = (node, v) => node.toggleAttribute('hidden', !!v);
const setVar = (name, value) => host.style.setProperty(name, value);
const unsetVar = (name) => host.style.removeProperty(name);
// =========================
// Create DOM
// =========================
const style = el('style');
style.textContent = ${JSON.stringify(errorCSS)};
const iframe = el('iframe');
iframe.id = 'frame';
iframe.src = 'data:text/html;base64,${base64HTML}';
iframe.title = 'Detailed error stack trace';
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
const preview = el('div');
preview.id = 'preview';
const toggle = el('div');
toggle.id = 'toggle';
toggle.setAttribute('aria-expanded', 'true');
toggle.setAttribute('role', 'button');
toggle.setAttribute('tabindex', '0');
toggle.innerHTML = '<span class="sr-only">Toggle detailed error view</span>';
const liveRegion = el('div');
liveRegion.setAttribute('role', 'status');
liveRegion.setAttribute('aria-live', 'polite');
liveRegion.className = 'sr-only';
const pipCloseButton = el('button');
pipCloseButton.id = 'pip-close';
pipCloseButton.setAttribute('type', 'button');
pipCloseButton.setAttribute('aria-label', 'Hide error preview overlay');
pipCloseButton.innerHTML = '&times;';
pipCloseButton.hidden = true;
toggle.appendChild(pipCloseButton);
const pipRestoreButton = el('button');
pipRestoreButton.id = 'pip-restore';
pipRestoreButton.setAttribute('type', 'button');
pipRestoreButton.setAttribute('aria-label', 'Show error overlay');
pipRestoreButton.innerHTML = '<span aria-hidden="true">⟲</span><span>Show error overlay</span>';
pipRestoreButton.hidden = true;
// Order matters: #frame + #preview adjacency
shadow.appendChild(style);
shadow.appendChild(liveRegion);
shadow.appendChild(iframe);
shadow.appendChild(preview);
shadow.appendChild(toggle);
shadow.appendChild(pipRestoreButton);
// =========================
// Constants / keys
// =========================
const POS_KEYS = {
position: 'nuxt-error-overlay:position',
hiddenPretty: 'nuxt-error-overlay:error-pip:hidden',
hiddenPreview: 'nuxt-error-overlay:app-preview:hidden'
};
const CSS_VARS = {
pip: {
left: '--error-pip-left',
top: '--error-pip-top',
right: '--error-pip-right',
bottom: '--error-pip-bottom'
},
preview: {
left: '--app-preview-left',
top: '--app-preview-top',
right: '--app-preview-right',
bottom: '--app-preview-bottom'
}
};
const MIN_GAP = 5;
const DRAG_THRESHOLD = 2;
// =========================
// Local storage safe access + state
// =========================
let storageReady = true;
let isPrettyHidden = false;
let isPreviewHidden = false;
const safeGet = (k) => {
try {
return localStorage.getItem(k);
} catch {
return null;
}
};
const safeSet = (k, v) => {
if (!storageReady)
return;
try {
localStorage.setItem(k, v);
} catch {}
};
// =========================
// Sizing helpers
// =========================
const vvSize = () => {
const v = window.visualViewport;
return v ? { w: v.width, h: v.height } : { w: window.innerWidth, h: window.innerHeight };
};
const previewSize = () => {
const styles = getComputedStyle(host);
const w = parseFloat(styles.getPropertyValue('--preview-width')) || 240;
const h = parseFloat(styles.getPropertyValue('--preview-height')) || 180;
return { w, h };
};
const sizeForTarget = (target) => {
if (!target)
return previewSize();
const rect = target.getBoundingClientRect();
if (rect.width && rect.height)
return { w: rect.width, h: rect.height };
return previewSize();
};
// =========================
// Dock model + offset/alignment calculations
// =========================
const dock = { edge: null, offset: null, align: null, gap: null };
const maxOffsetFor = (edge, size) => {
const vv = vvSize();
if (edge === 'left' || edge === 'right')
return Math.max(MIN_GAP, vv.h - size.h - MIN_GAP);
return Math.max(MIN_GAP, vv.w - size.w - MIN_GAP);
};
const clampOffset = (edge, value, size) => {
const max = maxOffsetFor(edge, size);
return Math.min(Math.max(value, MIN_GAP), max);
};
const updateDockAlignment = (size) => {
if (!dock.edge || dock.offset == null)
return;
const max = maxOffsetFor(dock.edge, size);
if (dock.offset <= max / 2) {
dock.align = 'start';
dock.gap = dock.offset;
} else {
dock.align = 'end';
dock.gap = Math.max(0, max - dock.offset);
}
};
const appliedOffsetFor = (size) => {
if (!dock.edge || dock.offset == null)
return null;
const max = maxOffsetFor(dock.edge, size);
if (dock.align === 'end' && typeof dock.gap === 'number') {
return clampOffset(dock.edge, max - dock.gap, size);
}
if (dock.align === 'start' && typeof dock.gap === 'number') {
return clampOffset(dock.edge, dock.gap, size);
}
return clampOffset(dock.edge, dock.offset, size);
};
const nearestEdgeAt = (x, y) => {
const { w, h } = vvSize();
const d = { left: x, right: w - x, top: y, bottom: h - y };
return Object.keys(d).reduce((a, b) => (d[a] < d[b] ? a : b));
};
const cornerDefaultDock = () => {
const vv = vvSize();
const size = previewSize();
const offset = Math.max(MIN_GAP, vv.w - size.w - MIN_GAP);
return { edge: 'bottom', offset };
};
const currentTransformOrigin = () => {
if (!dock.edge) return null;
if (dock.edge === 'left' || dock.edge === 'top')
return 'top left';
if (dock.edge === 'right')
return 'top right';
return 'bottom left';
};
// =========================
// Persist / load dock
// =========================
const loadDock = () => {
const raw = safeGet(POS_KEYS.position);
if (!raw)
return;
try {
const parsed = JSON.parse(raw);
const { edge, offset, align, gap } = parsed || {};
if (!['left', 'right', 'top', 'bottom'].includes(edge))
return;
if (typeof offset !== 'number')
return;
dock.edge = edge;
dock.offset = clampOffset(edge, offset, previewSize());
dock.align = align === 'start' || align === 'end' ? align : null;
dock.gap = typeof gap === 'number' ? gap : null;
if (!dock.align || dock.gap == null)
updateDockAlignment(previewSize());
} catch {}
};
const persistDock = () => {
if (!dock.edge || dock.offset == null)
return;
safeSet(POS_KEYS.position, JSON.stringify({
edge: dock.edge,
offset: dock.offset,
align: dock.align,
gap: dock.gap
}));
};
// =========================
// Apply dock
// =========================
const dockToVars = (vars) => ({
set: (side, v) => host.style.setProperty(vars[side], v),
clear: (side) => host.style.removeProperty(vars[side])
});
const dockToEl = (node) => ({
set: (side, v) => { node.style[side] = v; },
clear: (side) => { node.style[side] = ''; }
});
const applyDock = (target, size, opts) => {
if (!dock.edge || dock.offset == null) {
target.clear('left');
target.clear('top');
target.clear('right');
target.clear('bottom');
return;
}
target.set('left', 'auto');
target.set('top', 'auto');
target.set('right', 'auto');
target.set('bottom', 'auto');
const applied = appliedOffsetFor(size);
if (dock.edge === 'left') {
target.set('left', MIN_GAP + 'px');
target.set('top', applied + 'px');
} else if (dock.edge === 'right') {
target.set('right', MIN_GAP + 'px');
target.set('top', applied + 'px');
} else if (dock.edge === 'top') {
target.set('top', MIN_GAP + 'px');
target.set('left', applied + 'px');
} else {
target.set('bottom', MIN_GAP + 'px');
target.set('left', applied + 'px');
}
if (!opts || opts.persist !== false)
persistDock();
};
const applyDockAll = (opts) => {
applyDock(dockToVars(CSS_VARS.pip), previewSize(), opts);
applyDock(dockToVars(CSS_VARS.preview), previewSize(), opts);
applyDock(dockToEl(pipRestoreButton), sizeForTarget(pipRestoreButton), opts);
};
const repaintToDock = () => {
if (!dock.edge || dock.offset == null)
return;
const origin = currentTransformOrigin();
if (origin)
setVar('--error-pip-origin', origin);
else
unsetVar('--error-pip-origin');
applyDockAll({ persist: false });
};
// =========================
// Hidden state + UI
// =========================
const loadHidden = () => {
const rawPretty = safeGet(POS_KEYS.hiddenPretty);
if (rawPretty != null)
isPrettyHidden = rawPretty === '1' || rawPretty === 'true';
const rawPreview = safeGet(POS_KEYS.hiddenPreview);
if (rawPreview != null)
isPreviewHidden = rawPreview === '1' || rawPreview === 'true';
};
const setPrettyHidden = (v) => {
isPrettyHidden = !!v;
safeSet(POS_KEYS.hiddenPretty, isPrettyHidden ? '1' : '0');
updateUI();
};
const setPreviewHidden = (v) => {
isPreviewHidden = !!v;
safeSet(POS_KEYS.hiddenPreview, isPreviewHidden ? '1' : '0');
updateUI();
};
const isMinimized = () => iframe.hasAttribute('inert');
const setMinimized = (v) => {
if (v) {
iframe.setAttribute('inert', '');
toggle.setAttribute('aria-expanded', 'false');
} else {
iframe.removeAttribute('inert');
toggle.setAttribute('aria-expanded', 'true');
}
};
const setRestoreLabel = (kind) => {
if (kind === 'pretty') {
pipRestoreButton.innerHTML = '<span aria-hidden="true">⟲</span><span>Show error overlay</span>';
pipRestoreButton.setAttribute('aria-label', 'Show error overlay');
} else {
pipRestoreButton.innerHTML = '<span aria-hidden="true">⟲</span><span>Show error page</span>';
pipRestoreButton.setAttribute('aria-label', 'Show error page');
}
};
const updateUI = () => {
const minimized = isMinimized();
const showPiP = minimized && !isPrettyHidden;
const showPreview = !minimized && !isPreviewHidden;
const pipHiddenByUser = minimized && isPrettyHidden;
const previewHiddenByUser = !minimized && isPreviewHidden;
const showToggle = minimized ? showPiP : showPreview;
const showRestore = pipHiddenByUser || previewHiddenByUser;
hide(iframe, pipHiddenByUser);
hide(preview, !showPreview);
hide(toggle, !showToggle);
hide(pipCloseButton, !showToggle);
hide(pipRestoreButton, !showRestore);
pipCloseButton.setAttribute('aria-label', minimized ? 'Hide error overlay' : 'Hide error page preview');
if (pipHiddenByUser)
setRestoreLabel('pretty');
else if (previewHiddenByUser)
setRestoreLabel('preview');
host.classList.toggle('pip-hidden', isPrettyHidden);
host.classList.toggle('preview-hidden', isPreviewHidden);
};
// =========================
// Preview snapshot
// =========================
const updatePreview = () => {
try {
let previewIframe = preview.querySelector('iframe');
if (!previewIframe) {
previewIframe = el('iframe');
previewIframe.style.cssText = 'width: 1200px; height: 900px; transform: scale(0.2); transform-origin: top left; border: none;';
previewIframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
preview.appendChild(previewIframe);
}
const doctype = document.doctype ? '<!DOCTYPE ' + document.doctype.name + '>' : '';
const cleanedHTML = document.documentElement.outerHTML
.replace(/<nuxt-error-overlay[^>]*>.*?<\\/nuxt-error-overlay>/gs, '')
.replace(/<script[^>]*>.*?<\\/script>/gs, '');
const iframeDoc = previewIframe.contentDocument || previewIframe.contentWindow.document;
iframeDoc.open();
iframeDoc.write(doctype + cleanedHTML);
iframeDoc.close();
} catch (err) {
console.error('Failed to update preview:', err);
}
};
// =========================
// View toggling
// =========================
const toggleView = () => {
if (isMinimized()) {
updatePreview();
setMinimized(false);
liveRegion.textContent = 'Showing detailed error view';
setTimeout(() => {
try {
iframe.contentWindow.focus();
} catch {}
}, 100);
} else {
setMinimized(true);
liveRegion.textContent = 'Showing error page';
repaintToDock();
void iframe.offsetWidth;
}
updateUI();
};
// =========================
// Dragging (unified, rAF throttled)
// =========================
let drag = null;
let rafId = null;
let suppressToggleClick = false;
let suppressRestoreClick = false;
const beginDrag = (e) => {
if (drag)
return;
if (!dock.edge || dock.offset == null) {
const def = cornerDefaultDock();
dock.edge = def.edge;
dock.offset = def.offset;
updateDockAlignment(previewSize());
}
const isRestoreTarget = e.currentTarget === pipRestoreButton;
drag = {
kind: isRestoreTarget ? 'restore' : (isMinimized() ? 'pip' : 'preview'),
pointerId: e.pointerId,
startX: e.clientX,
startY: e.clientY,
lastX: e.clientX,
lastY: e.clientY,
moved: false,
target: e.currentTarget
};
drag.target.setPointerCapture(e.pointerId);
if (drag.kind === 'restore')
host.classList.add('dragging-restore');
else
host.classList.add(drag.kind === 'pip' ? 'dragging' : 'dragging-preview');
e.preventDefault();
};
const moveDrag = (e) => {
if (!drag || drag.pointerId !== e.pointerId)
return;
drag.lastX = e.clientX;
drag.lastY = e.clientY;
const dx = drag.lastX - drag.startX;
const dy = drag.lastY - drag.startY;
if (!drag.moved && (Math.abs(dx) > DRAG_THRESHOLD || Math.abs(dy) > DRAG_THRESHOLD)) {
drag.moved = true;
}
if (!drag.moved)
return;
if (rafId)
return;
rafId = requestAnimationFrame(() => {
rafId = null;
const edge = nearestEdgeAt(drag.lastX, drag.lastY);
const size = sizeForTarget(drag.target);
let offset;
if (edge === 'left' || edge === 'right') {
const top = drag.lastY - (size.h / 2);
offset = clampOffset(edge, Math.round(top), size);
} else {
const left = drag.lastX - (size.w / 2);
offset = clampOffset(edge, Math.round(left), size);
}
dock.edge = edge;
dock.offset = offset;
updateDockAlignment(size);
const origin = currentTransformOrigin();
setVar('--error-pip-origin', origin || 'bottom right');
applyDockAll({ persist: false });
});
};
const endDrag = (e) => {
if (!drag || drag.pointerId !== e.pointerId)
return;
const endedKind = drag.kind;
drag.target.releasePointerCapture(e.pointerId);
if (endedKind === 'restore')
host.classList.remove('dragging-restore');
else
host.classList.remove(endedKind === 'pip' ? 'dragging' : 'dragging-preview');
const didMove = drag.moved;
drag = null;
if (didMove) {
persistDock();
if (endedKind === 'restore')
suppressRestoreClick = true;
else
suppressToggleClick = true;
e.preventDefault();
e.stopPropagation();
}
};
const bindDragTarget = (node) => {
on(node, 'pointerdown', beginDrag);
on(node, 'pointermove', moveDrag);
on(node, 'pointerup', endDrag);
on(node, 'pointercancel', endDrag);
};
bindDragTarget(toggle);
bindDragTarget(pipRestoreButton);
// =========================
// Events (toggle / close / restore)
// =========================
on(toggle, 'click', (e) => {
if (suppressToggleClick) {
e.preventDefault();
suppressToggleClick = false;
return;
}
toggleView();
});
on(toggle, 'keydown', (e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
toggleView();
}
});
on(pipCloseButton, 'click', (e) => {
e.preventDefault();
e.stopPropagation();
if (isMinimized())
setPrettyHidden(true);
else
setPreviewHidden(true);
});
on(pipCloseButton, 'pointerdown', (e) => {
e.stopPropagation();
});
on(pipRestoreButton, 'click', (e) => {
if (suppressRestoreClick) {
e.preventDefault();
suppressRestoreClick = false;
return;
}
e.preventDefault();
e.stopPropagation();
if (isMinimized())
setPrettyHidden(false);
else
setPreviewHidden(false);
});
// =========================
// Lifecycle: load / sync / repaint
// =========================
const loadState = () => {
loadDock();
loadHidden();
if (isPrettyHidden && !isMinimized())
setMinimized(true);
updateUI();
repaintToDock();
};
loadState();
on(window, 'storage-ready', () => {
storageReady = true;
loadState();
});
const onViewportChange = () => repaintToDock();
on(window, 'resize', onViewportChange);
if (window.visualViewport) {
on(window.visualViewport, 'resize', onViewportChange);
on(window.visualViewport, 'scroll', onViewportChange);
}
// initial preview
setTimeout(updatePreview, 100);
// initial minimized option
if (${startMinimized}) {
setMinimized(true);
repaintToDock();
void iframe.offsetWidth;
updateUI();
}
} catch (err) {
console.error('Failed to initialize Nuxt error overlay:', err);
}
})();
`;
}
export function generateErrorOverlayHTML(html, options) {
const nonce = Array.from(crypto.getRandomValues(new Uint8Array(16)), (b) => b.toString(16).padStart(2, "0")).join("");
const errorPage = html.replace("<head>", `<head><script>${iframeStorageBridge(nonce)}<\/script>`);
const base64HTML = Buffer.from(errorPage, "utf8").toString("base64");
return `
<script>${parentStorageBridge(nonce)}<\/script>
<nuxt-error-overlay></nuxt-error-overlay>
<script>${webComponentScript(base64HTML, options?.startMinimized ?? false)}<\/script>
`;
}

View File

@@ -0,0 +1,6 @@
import type { H3Event } from "h3";
/**
* Nitro internal functions extracted from https://github.com/nitrojs/nitro/blob/v2/src/runtime/internal/utils.ts
*/
export declare function isJsonRequest(event: H3Event): boolean;
export declare function hasReqHeader(event: H3Event, name: string, includes: string);

View File

@@ -0,0 +1,15 @@
import { getRequestHeader } from "h3";
/**
* Nitro internal functions extracted from https://github.com/nitrojs/nitro/blob/v2/src/runtime/internal/utils.ts
*/
export function isJsonRequest(event) {
// If the client specifically requests HTML, then avoid classifying as JSON.
if (hasReqHeader(event, "accept", "text/html")) {
return false;
}
return hasReqHeader(event, "accept", "application/json") || hasReqHeader(event, "user-agent", "curl/") || hasReqHeader(event, "user-agent", "httpie/") || hasReqHeader(event, "sec-fetch-mode", "cors") || event.path.startsWith("/api/") || event.path.endsWith(".json");
}
export function hasReqHeader(event, name, includes) {
const value = getRequestHeader(event, name);
return value && typeof value === "string" && value.toLowerCase().includes(includes);
}

View File

@@ -0,0 +1,4 @@
export declare function baseURL(): string;
export declare function buildAssetsDir(): string;
export declare function buildAssetsURL(...path: string[]): string;
export declare function publicAssetsURL(...path: string[]): string;

View File

@@ -0,0 +1,19 @@
import { joinRelativeURL } from "ufo";
import { useRuntimeConfig } from "nitropack/runtime";
export function baseURL() {
// TODO: support passing event to `useRuntimeConfig`
return useRuntimeConfig().app.baseURL;
}
export function buildAssetsDir() {
// TODO: support passing event to `useRuntimeConfig`
return useRuntimeConfig().app.buildAssetsDir;
}
export function buildAssetsURL(...path) {
return joinRelativeURL(publicAssetsURL(), buildAssetsDir(), ...path);
}
export function publicAssetsURL(...path) {
// TODO: support passing event to `useRuntimeConfig`
const app = useRuntimeConfig().app;
const publicBase = app.cdnURL || app.baseURL;
return path.length ? joinRelativeURL(publicBase, ...path) : publicBase;
}

View File

@@ -0,0 +1,6 @@
import type { H3Event } from "h3";
import type { NuxtPayload, NuxtSSRContext } from "nuxt/app";
export declare function createSSRContext(event: H3Event): NuxtSSRContext;
export declare function setSSRError(ssrContext: NuxtSSRContext, error: NuxtPayload["error"] & {
url: string;
}): void;

View File

@@ -0,0 +1,38 @@
import { useRuntimeConfig } from "nitropack/runtime";
import { createHead } from "@unhead/vue/server";
import { sharedPrerenderCache } from "../cache.mjs";
// @ts-expect-error virtual file
import unheadOptions from "#internal/unhead-options.mjs";
// @ts-expect-error virtual file
import { NUXT_NO_SSR, NUXT_SHARED_DATA } from "#internal/nuxt/nitro-config.mjs";
const PRERENDER_NO_SSR_ROUTES = new Set([
"/index.html",
"/200.html",
"/404.html"
]);
export function createSSRContext(event) {
const ssrContext = {
url: event.path,
event,
runtimeConfig: useRuntimeConfig(event),
noSSR: !!NUXT_NO_SSR || event.context.nuxt?.noSSR || (import.meta.prerender ? PRERENDER_NO_SSR_ROUTES.has(event.path) : false),
head: createHead(unheadOptions),
error: false,
nuxt: undefined,
payload: {},
["~payloadReducers"]: Object.create(null),
modules: new Set()
};
if (import.meta.prerender) {
if (NUXT_SHARED_DATA) {
ssrContext["~sharedPrerenderCache"] = sharedPrerenderCache;
}
ssrContext.payload.prerenderedAt = Date.now();
}
return ssrContext;
}
export function setSSRError(ssrContext, error) {
ssrContext.error = true;
ssrContext.payload = { error };
ssrContext.url = error.url;
}

View File

@@ -0,0 +1,16 @@
import type { RendererContext } from "vue-bundle-renderer/runtime";
import type { NuxtSSRContext } from "nuxt/app";
interface Renderer {
rendererContext: RendererContext;
renderToString(ssrContext: NuxtSSRContext): Promise<{
html: string;
renderResourceHeaders: () => Record<string, string>;
renderResourceHints: () => string;
renderStyles: () => string;
renderScripts: () => string;
}>;
}
export declare const getSSRRenderer: unknown;
export declare function getRenderer(ssrContext: NuxtSSRContext): Promise<Renderer>;
export declare const getSSRStyles: unknown;
export {};

View File

@@ -0,0 +1,100 @@
import { createRenderer } from "vue-bundle-renderer/runtime";
import { renderToString as _renderToString } from "vue/server-renderer";
import { propsToString } from "@unhead/vue/server";
import { useRuntimeConfig } from "nitropack/runtime";
// @ts-expect-error virtual file
import { NUXT_NO_SSR } from "#internal/nuxt/nitro-config.mjs";
// @ts-expect-error virtual file
import { appRootAttrs, appRootTag, appSpaLoaderAttrs, appSpaLoaderTag, spaLoadingTemplateOutside } from "#internal/nuxt.config.mjs";
// @ts-expect-error virtual file
import { buildAssetsURL } from "#internal/nuxt/paths";
const APP_ROOT_OPEN_TAG = `<${appRootTag}${propsToString(appRootAttrs)}>`;
const APP_ROOT_CLOSE_TAG = `</${appRootTag}>`;
// @ts-expect-error file will be produced after app build
const getServerEntry = () => import("#build/dist/server/server.mjs").then((r) => r.default || r);
// @ts-expect-error file will be produced after app build
const getClientManifest = () => import("#build/dist/server/client.manifest.mjs").then((r) => r.default || r).then((r) => typeof r === "function" ? r() : r);
// @ts-expect-error file will be produced after app build
const getPrecomputedDependencies = () => import("#build/dist/server/client.precomputed.mjs").then((r) => r.default || r).then((r) => typeof r === "function" ? r() : r);
// -- SSR Renderer --
export const getSSRRenderer = lazyCachedFunction(async () => {
// Load server bundle
const createSSRApp = await getServerEntry();
if (!createSSRApp) {
throw new Error("Server bundle is not available");
}
// Load precomputed dependencies
const precomputed = import.meta.dev ? undefined : await getPrecomputedDependencies();
// Create renderer
const renderer = createRenderer(createSSRApp, {
precomputed,
manifest: import.meta.dev ? await getClientManifest() : undefined,
renderToString,
buildAssetsURL
});
async function renderToString(input, context) {
const html = await _renderToString(input, context);
// In development with vite-node, the manifest is on-demand and will be available after rendering
// eslint-disable-next-line no-restricted-globals
if (import.meta.dev && process.env.NUXT_VITE_NODE_OPTIONS) {
renderer.rendererContext.updateManifest(await getClientManifest());
}
return APP_ROOT_OPEN_TAG + html + APP_ROOT_CLOSE_TAG;
}
return renderer;
});
// -- SPA Renderer --
const getSPARenderer = lazyCachedFunction(async () => {
const precomputed = import.meta.dev ? undefined : await getPrecomputedDependencies();
// @ts-expect-error virtual file
const spaTemplate = await import("#spa-template").then((r) => r.template).catch(() => "").then((r) => {
if (spaLoadingTemplateOutside) {
const APP_SPA_LOADER_OPEN_TAG = `<${appSpaLoaderTag}${propsToString(appSpaLoaderAttrs)}>`;
const APP_SPA_LOADER_CLOSE_TAG = `</${appSpaLoaderTag}>`;
const appTemplate = APP_ROOT_OPEN_TAG + APP_ROOT_CLOSE_TAG;
const loaderTemplate = r ? APP_SPA_LOADER_OPEN_TAG + r + APP_SPA_LOADER_CLOSE_TAG : "";
return appTemplate + loaderTemplate;
} else {
return APP_ROOT_OPEN_TAG + r + APP_ROOT_CLOSE_TAG;
}
});
// Create SPA renderer and cache the result for all requests
const renderer = createRenderer(() => () => {}, {
precomputed,
manifest: import.meta.dev ? await getClientManifest() : undefined,
renderToString: () => spaTemplate,
buildAssetsURL
});
const result = await renderer.renderToString({});
const renderToString = (ssrContext) => {
const config = useRuntimeConfig(ssrContext.event);
ssrContext.modules ||= new Set();
ssrContext.payload.serverRendered = false;
ssrContext.config = {
public: config.public,
app: config.app
};
return Promise.resolve(result);
};
return {
rendererContext: renderer.rendererContext,
renderToString
};
});
function lazyCachedFunction(fn) {
let res = null;
return () => {
if (res === null) {
res = fn().catch((err) => {
res = null;
throw err;
});
}
return res;
};
}
export function getRenderer(ssrContext) {
return NUXT_NO_SSR || ssrContext.noSSR ? getSPARenderer() : getSSRRenderer();
}
// @ts-expect-error file will be produced after app build
export const getSSRStyles = lazyCachedFunction(() => import("#build/dist/server/styles.mjs").then((r) => r.default || r));

View File

@@ -0,0 +1,2 @@
import type { Style } from "@unhead/vue/types";
export declare function renderInlineStyles(usedModules: Set<string> | string[]): Promise<Style[]>;

View File

@@ -0,0 +1,13 @@
import { getSSRStyles } from "./build-files.mjs";
export async function renderInlineStyles(usedModules) {
const styleMap = await getSSRStyles();
const inlinedStyles = new Set();
for (const mod of usedModules) {
if (mod in styleMap && styleMap[mod]) {
for (const style of await styleMap[mod]()) {
inlinedStyles.add(style);
}
}
}
return Array.from(inlinedStyles).map((style) => ({ innerHTML: style }));
}

View File

@@ -0,0 +1,9 @@
import type { NuxtIslandResponse, NuxtSSRContext } from "nuxt/app";
/**
* remove the root node from the html body
*/
export declare function getServerComponentHTML(body: string): string;
export declare function getSlotIslandResponse(ssrContext: NuxtSSRContext): NuxtIslandResponse["slots"];
export declare function getClientIslandResponse(ssrContext: NuxtSSRContext): NuxtIslandResponse["components"];
export declare function getComponentSlotTeleport(clientUid: string, teleports: Record<string, string>): Record<string, string>;
export declare function replaceIslandTeleports(ssrContext: NuxtSSRContext, html: string): string;

View File

@@ -0,0 +1,87 @@
// @ts-expect-error virtual file
import { appRootTag } from "#internal/nuxt.config.mjs";
const ROOT_NODE_REGEX = new RegExp(`^<${appRootTag}[^>]*>([\\s\\S]*)<\\/${appRootTag}>$`);
/**
* remove the root node from the html body
*/
export function getServerComponentHTML(body) {
const match = body.match(ROOT_NODE_REGEX);
return match?.[1] || body;
}
const SSR_SLOT_TELEPORT_MARKER = /^uid=([^;]*);slot=(.*)$/;
const SSR_CLIENT_TELEPORT_MARKER = /^uid=([^;]*);client=(.*)$/;
const SSR_CLIENT_SLOT_MARKER = /^island-slot=([^;]*);(.*)$/;
export function getSlotIslandResponse(ssrContext) {
if (!ssrContext.islandContext || !Object.keys(ssrContext.islandContext.slots).length) {
return undefined;
}
const response = {};
for (const [name, slot] of Object.entries(ssrContext.islandContext.slots)) {
response[name] = {
...slot,
fallback: ssrContext.teleports?.[`island-fallback=${name}`]
};
}
return response;
}
export function getClientIslandResponse(ssrContext) {
if (!ssrContext.islandContext || !Object.keys(ssrContext.islandContext.components).length) {
return undefined;
}
const response = {};
for (const [clientUid, component] of Object.entries(ssrContext.islandContext.components)) {
// remove teleport anchor to avoid hydration issues
const html = ssrContext.teleports?.[clientUid]?.replaceAll("<!--teleport start anchor-->", "") || "";
response[clientUid] = {
...component,
html,
slots: getComponentSlotTeleport(clientUid, ssrContext.teleports ?? {})
};
}
return response;
}
export function getComponentSlotTeleport(clientUid, teleports) {
const entries = Object.entries(teleports);
const slots = {};
for (const [key, value] of entries) {
const match = key.match(SSR_CLIENT_SLOT_MARKER);
if (match) {
const [, id, slot] = match;
if (!slot || clientUid !== id) {
continue;
}
slots[slot] = value;
}
}
return slots;
}
export function replaceIslandTeleports(ssrContext, html) {
const { teleports, islandContext } = ssrContext;
if (islandContext || !teleports) {
return html;
}
for (const key in teleports) {
const matchClientComp = key.match(SSR_CLIENT_TELEPORT_MARKER);
if (matchClientComp) {
const [, uid, clientId] = matchClientComp;
if (!uid || !clientId) {
continue;
}
html = html.replace(new RegExp(` data-island-uid="${uid}" data-island-component="${clientId}"[^>]*>`), (full) => {
return full + teleports[key];
});
continue;
}
const matchSlot = key.match(SSR_SLOT_TELEPORT_MARKER);
if (matchSlot) {
const [, uid, slot] = matchSlot;
if (!uid || !slot) {
continue;
}
html = html.replace(new RegExp(` data-island-uid="${uid}" data-island-slot="${slot}"[^>]*>`), (full) => {
return full + teleports[key];
});
}
}
return html;
}

View File

@@ -0,0 +1,24 @@
import type { NitroRouteRules, RenderResponse } from "nitropack/types";
import type { Script } from "@unhead/vue";
import type { NuxtPayload, NuxtSSRContext } from "nuxt/app";
export declare function renderPayloadResponse(ssrContext: NuxtSSRContext): RenderResponse;
export declare function renderPayloadJsonScript(opts: {
ssrContext: NuxtSSRContext;
data?: any;
src?: string;
}): Script[];
export declare function renderPayloadScript(opts: {
ssrContext: NuxtSSRContext;
routeOptions: NitroRouteRules;
data?: any;
src?: string;
}): Script[];
interface SplitPayload {
initial: Omit<NuxtPayload, "data">;
payload: {
data?: NuxtPayload["data"];
prerenderedAt?: NuxtPayload["prerenderedAt"];
};
}
export declare function splitPayload(ssrContext: NuxtSSRContext): SplitPayload;
export {};

View File

@@ -0,0 +1,64 @@
import { getResponseStatus, getResponseStatusText } from "h3";
import devalue from "@nuxt/devalue";
import { stringify, uneval } from "devalue";
// @ts-expect-error virtual file
import { appId, multiApp } from "#internal/nuxt.config.mjs";
// @ts-expect-error virtual file
import { NUXT_JSON_PAYLOADS, NUXT_NO_SSR, NUXT_PAYLOAD_EXTRACTION, NUXT_RUNTIME_PAYLOAD_EXTRACTION } from "#internal/nuxt/nitro-config.mjs";
export function renderPayloadResponse(ssrContext) {
return {
body: NUXT_JSON_PAYLOADS ? stringify(splitPayload(ssrContext).payload, ssrContext["~payloadReducers"]) : `export default ${devalue(splitPayload(ssrContext).payload)}`,
statusCode: getResponseStatus(ssrContext.event),
statusMessage: getResponseStatusText(ssrContext.event),
headers: {
"content-type": NUXT_JSON_PAYLOADS ? "application/json;charset=utf-8" : "text/javascript;charset=utf-8",
"x-powered-by": "Nuxt"
}
};
}
export function renderPayloadJsonScript(opts) {
const contents = opts.data ? stringify(opts.data, opts.ssrContext["~payloadReducers"]) : "";
const payload = {
"type": "application/json",
"innerHTML": contents,
"data-nuxt-data": appId,
"data-ssr": !(NUXT_NO_SSR || opts.ssrContext.noSSR)
};
if (!multiApp) {
payload.id = "__NUXT_DATA__";
}
if (opts.src) {
payload["data-src"] = opts.src;
}
const config = uneval(opts.ssrContext.config);
return [payload, { innerHTML: multiApp ? `window.__NUXT__=window.__NUXT__||{};window.__NUXT__[${JSON.stringify(appId)}]={config:${config}}` : `window.__NUXT__={};window.__NUXT__.config=${config}` }];
}
export function renderPayloadScript(opts) {
opts.data.config = opts.ssrContext.config;
const _PAYLOAD_EXTRACTION = !opts.ssrContext.noSSR && (import.meta.prerender && NUXT_PAYLOAD_EXTRACTION || NUXT_RUNTIME_PAYLOAD_EXTRACTION && (opts.routeOptions.isr || opts.routeOptions.cache));
const nuxtData = devalue(opts.data);
if (_PAYLOAD_EXTRACTION) {
const singleAppPayload = `import p from "${opts.src}";window.__NUXT__={...p,...(${nuxtData})}`;
const multiAppPayload = `import p from "${opts.src}";window.__NUXT__=window.__NUXT__||{};window.__NUXT__[${JSON.stringify(appId)}]={...p,...(${nuxtData})}`;
return [{
type: "module",
innerHTML: multiApp ? multiAppPayload : singleAppPayload
}];
}
const singleAppPayload = `window.__NUXT__=${nuxtData}`;
const multiAppPayload = `window.__NUXT__=window.__NUXT__||{};window.__NUXT__[${JSON.stringify(appId)}]=${nuxtData}`;
return [{ innerHTML: multiApp ? multiAppPayload : singleAppPayload }];
}
export function splitPayload(ssrContext) {
const { data, prerenderedAt, ...initial } = ssrContext.payload;
return {
initial: {
...initial,
prerenderedAt
},
payload: {
data,
prerenderedAt
}
};
}

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016-present - Nuxt Team
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.

View File

@@ -0,0 +1,119 @@
[![Nuxt banner](https://github.com/nuxt/nuxt/blob/main/.github/assets/banner.svg)](https://nuxt.com)
# Nuxt
<p>
<a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
<a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/dm/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
<a href="https://github.com/nuxt/nuxt/blob/main/LICENSE"><img src="https://img.shields.io/github/license/nuxt/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
<a href="https://nuxt.com/modules"><img src="https://img.shields.io/badge/dynamic/json?url=https://nuxt.com/api/v1/modules&query=$.stats.modules&label=Modules&style=flat&colorA=18181B&colorB=28CF8D" alt="Modules"></a>
<a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt%20Docs-18181B?logo=nuxt" alt="Website"></a>
<a href="https://chat.nuxt.dev"><img src="https://img.shields.io/badge/Nuxt%20Discord-18181B?logo=discord" alt="Discord"></a>
<a href="https://securityscorecards.dev/"><img src="https://api.securityscorecards.dev/projects/github.com/nuxt/nuxt/badge" alt="Nuxt openssf scorecard score"></a>
<a href="https://deepwiki.com/nuxt/nuxt"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
</p>
Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.
It provides a number of features that make it easy to build fast, SEO-friendly, and scalable web applications, including:
- Server-side rendering, static site generation, hybrid rendering and edge-side rendering
- Automatic routing with code-splitting and pre-fetching
- Data fetching and state management
- Search engine optimization and defining meta tags
- Auto imports of components, composables and utils
- TypeScript with zero configuration
- Go full-stack with our server/ directory
- Extensible with [300+ modules](https://nuxt.com/modules)
- Deployment to a variety of [hosting platforms](https://nuxt.com/deploy)
- ...[and much more](https://nuxt.com) 🚀
### Table of Contents
- 🚀 [Getting Started](#getting-started)
- 💻 [Vue Development](#vue-development)
- 📖 [Documentation](#documentation)
- 🧩 [Modules](#modules)
- ❤️ [Contribute](#contribute)
- 🏠 [Local Development](#local-development)
- 🛟 [Professional Support](#professional-support)
- 🔗 [Follow Us](#follow-us)
- ⚖️ [License](#license)
---
## <a name="getting-started">🚀 Getting Started</a>
Use the following command to create a new starter project. This will create a starter project with all the necessary files and dependencies:
```bash
npm create nuxt@latest <my-project>
```
> [!TIP]
> Discover also [nuxt.new](https://nuxt.new): Open a Nuxt starter on CodeSandbox, StackBlitz or locally to get up and running in a few seconds.
## <a name="vue-development">💻 Vue Development</a>
Simple, intuitive and powerful, Nuxt lets you write Vue components in a way that makes sense. Every repetitive task is automated, so you can focus on writing your full-stack Vue application with confidence.
Example of an `app.vue`:
```vue
<script setup lang="ts">
useSeoMeta({
title: 'Meet Nuxt',
description: 'The Intuitive Vue Framework.',
})
</script>
<template>
<div id="app">
<AppHeader />
<NuxtPage />
<AppFooter />
</div>
</template>
<style scoped>
#app {
background-color: #020420;
color: #00DC82;
}
</style>
```
## <a name="documentation">📖 Documentation</a>
We highly recommend you take a look at the [Nuxt documentation](https://nuxt.com/docs) to level up. Its a great resource for learning more about the framework. It covers everything from getting started to advanced topics.
## <a name="modules">🧩 Modules</a>
Discover our [list of modules](https://nuxt.com/modules) to supercharge your Nuxt project, created by the Nuxt team and community.
## <a name="contribute">❤️ Contribute</a>
We invite you to contribute and help improve Nuxt 💚
Here are a few ways you can get involved:
- **Reporting Bugs:** If you come across any bugs or issues, please check out the [reporting bugs guide](https://nuxt.com/docs/4.x/community/reporting-bugs) to learn how to submit a bug report.
- **Suggestions:** Have ideas to enhance Nuxt? We'd love to hear them! Check out the [contribution guide](https://nuxt.com/docs/4.x/community/contribution) to share your suggestions.
- **Questions:** If you have questions or need assistance, the [getting help guide](https://nuxt.com/docs/4.x/community/getting-help) provides resources to help you out.
## <a name="local-development">🏠 Local Development</a>
Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/docs/4.x/community/framework-contribution#setup) to contribute to the framework and documentation.
## <a name="professional-support">🛟 Professional Support</a>
- Technical audit & consulting: [Nuxt Experts](https://nuxt.com/enterprise/support)
- Custom development & more: [Nuxt Agencies Partners](https://nuxt.com/enterprise/agencies)
## <a name="follow-us">🔗 Follow Us</a>
<p valign="center">
<a href="https://go.nuxt.com/discord"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/discord.svg" alt="Discord"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/x"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/twitter.svg" alt="Twitter"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/github"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/github.svg" alt="GitHub"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/bluesky"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/bluesky.svg" alt="Bluesky"></a>
</p>
## <a name="license">⚖️ License</a>
[MIT](https://github.com/nuxt/nuxt/blob/main/LICENSE)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,63 @@
//#region ../../node_modules/.pnpm/@rolldown+pluginutils@1.0.0-rc.3/node_modules/@rolldown/pluginutils/dist/filter/composable-filters.d.ts
type StringOrRegExp = string | RegExp;
type PluginModuleType = 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'base64' | 'dataurl' | 'binary' | 'empty' | (string & {});
type FilterExpression = And | Or | Not | Id | ImporterId | ModuleType | Code | Query;
type TopLevelFilterExpression = Include | Exclude;
declare class And {
kind: 'and';
args: FilterExpression[];
constructor(...args: FilterExpression[]);
}
declare class Or {
kind: 'or';
args: FilterExpression[];
constructor(...args: FilterExpression[]);
}
declare class Not {
kind: 'not';
expr: FilterExpression;
constructor(expr: FilterExpression);
}
interface IdParams {
cleanUrl?: boolean;
}
declare class Id {
kind: 'id';
pattern: StringOrRegExp;
params: IdParams;
constructor(pattern: StringOrRegExp, params?: IdParams);
}
declare class ImporterId {
kind: 'importerId';
pattern: StringOrRegExp;
params: IdParams;
constructor(pattern: StringOrRegExp, params?: IdParams);
}
declare class ModuleType {
kind: 'moduleType';
pattern: PluginModuleType;
constructor(pattern: PluginModuleType);
}
declare class Code {
kind: 'code';
pattern: StringOrRegExp;
constructor(expr: StringOrRegExp);
}
declare class Query {
kind: 'query';
key: string;
pattern: StringOrRegExp | boolean;
constructor(key: string, pattern: StringOrRegExp | boolean);
}
declare class Include {
kind: 'include';
expr: FilterExpression;
constructor(expr: FilterExpression);
}
declare class Exclude {
kind: 'exclude';
expr: FilterExpression;
constructor(expr: FilterExpression);
}
//#endregion
export { TopLevelFilterExpression as t };

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,114 @@
import * as fs from "fs";
//#region ../../node_modules/.pnpm/@vercel+nft@1.2.0_rollup@4.57.1/node_modules/@vercel/nft/out/node-file-trace.d.ts
declare class Job {
ts: boolean;
base: string;
cwd: string;
conditions: string[];
exportsOnly: boolean;
paths: Record<string, string>;
ignoreFn: (path: string, parent?: string) => boolean;
log: boolean;
mixedModules: boolean;
analysis: {
emitGlobs?: boolean;
computeFileReferences?: boolean;
evaluatePureExpressions?: boolean;
};
private analysisCache;
fileList: Set<string>;
esmFileList: Set<string>;
processed: Set<string>;
warnings: Set<Error>;
reasons: NodeFileTraceReasons;
private cachedFileSystem;
private remappings;
constructor({
base,
processCwd,
exports,
conditions,
exportsOnly,
paths,
ignore,
log,
mixedModules,
ts,
analysis,
cache,
fileIOConcurrency
}: NodeFileTraceOptions);
addRemapping(path: string, dep: string): void;
readlink(path: string): Promise<string | null>;
isFile(path: string): Promise<boolean>;
isDir(path: string): Promise<boolean>;
stat(path: string): Promise<fs.Stats | null>;
private maybeEmitDep;
resolve(id: string, parent: string, job: Job, cjsResolve: boolean): Promise<string | string[]>;
readFile(path: string): Promise<Buffer | string | null>;
realpath(path: string, parent?: string, seen?: Set<unknown>): Promise<string>;
emitFile(path: string, reasonType: NodeFileTraceReasonType, parent?: string, isRealpath?: boolean): Promise<boolean>;
getPjsonBoundary(path: string): Promise<string | undefined>;
emitDependency(path: string, parent?: string): Promise<void>;
}
//#endregion
//#region ../../node_modules/.pnpm/@vercel+nft@1.2.0_rollup@4.57.1/node_modules/@vercel/nft/out/types.d.ts
interface Stats {
isFile(): boolean;
isDirectory(): boolean;
isBlockDevice(): boolean;
isCharacterDevice(): boolean;
isSymbolicLink(): boolean;
isFIFO(): boolean;
isSocket(): boolean;
dev: number;
ino: number;
mode: number;
nlink: number;
uid: number;
gid: number;
rdev: number;
size: number;
blksize: number;
blocks: number;
atimeMs: number;
mtimeMs: number;
ctimeMs: number;
birthtimeMs: number;
atime: Date;
mtime: Date;
ctime: Date;
birthtime: Date;
}
interface NodeFileTraceOptions {
base?: string;
processCwd?: string;
exports?: string[];
conditions?: string[];
exportsOnly?: boolean;
ignore?: string | string[] | ((path: string) => boolean);
analysis?: boolean | {
emitGlobs?: boolean;
computeFileReferences?: boolean;
evaluatePureExpressions?: boolean;
};
cache?: any;
paths?: Record<string, string>;
ts?: boolean;
log?: boolean;
mixedModules?: boolean;
readFile?: (path: string) => Promise<Buffer | string | null>;
stat?: (path: string) => Promise<Stats | null>;
readlink?: (path: string) => Promise<string | null>;
resolve?: (id: string, parent: string, job: Job, cjsResolve: boolean) => Promise<string | string[]>;
fileIOConcurrency?: number;
}
type NodeFileTraceReasonType = 'initial' | 'resolve' | 'dependency' | 'asset' | 'sharedlib';
interface NodeFileTraceReasons extends Map<string, {
type: NodeFileTraceReasonType[];
ignored: boolean;
parents: Set<string>;
}> {}
//#endregion
export { NodeFileTraceOptions as t };

View File

@@ -0,0 +1,34 @@
import { Stats } from "node:fs";
import { Readable } from "node:stream";
import { EventEmitter } from "node:events";
//#region ../../node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/index.d.ts
type AWF = {
stabilityThreshold: number;
pollInterval: number;
};
type BasicOpts = {
persistent: boolean;
ignoreInitial: boolean;
followSymlinks: boolean;
cwd?: string;
usePolling: boolean;
interval: number;
binaryInterval: number;
alwaysStat?: boolean;
depth?: number;
ignorePermissionErrors: boolean;
atomic: boolean | number;
};
type ChokidarOptions = Partial<BasicOpts & {
ignored: Matcher | Matcher[];
awaitWriteFinish: boolean | Partial<AWF>;
}>;
type MatchFunction = (val: string, stats?: Stats) => boolean;
interface MatcherObject {
path: string;
recursive?: boolean;
}
type Matcher = string | RegExp | MatchFunction | MatcherObject;
//#endregion
export { ChokidarOptions as t };

View File

@@ -0,0 +1,47 @@
//#region ../../node_modules/.pnpm/compatx@0.2.0/node_modules/compatx/dist/index.d.mts
/**
* Known platform names
*/
declare const platforms: readonly ["aws", "azure", "cloudflare", "deno", "firebase", "netlify", "vercel"];
/**
* Known platform name
*/
type PlatformName = (typeof platforms)[number] | (string & {});
/**
* Normalize the compatibility dates from input config and defaults.
*/
type Year = `${number}${number}${number}${number}`;
type Month = `${"0" | "1"}${number}`;
type Day = `${"0" | "1" | "2" | "3"}${number}`;
/**
* Typed date string in `YYYY-MM-DD` format
*
* Empty string is used to represent an "unspecified" date.
*
* "latest" is used to represent the latest date available (date of today).
*/
type DateString = "" | "latest" | `${Year}-${Month}-${Day}`;
/**
* Last known compatibility dates for platforms
*
* @example
* {
* "default": "2024-01-01",
* "cloudflare": "2024-03-01",
* }
*/
type CompatibilityDates = {
/**
* Default compatibility date for all unspecified platforms (required)
*/
default: DateString;
} & Partial<Record<PlatformName, DateString>>;
/**
* Last known compatibility date for the used platform
*/
type CompatibilityDateSpec = DateString | Partial<CompatibilityDates>;
/**
* Get compatibility updates applicable for the user given platform and date range.
*/
//#endregion
export { CompatibilityDates as n, CompatibilityDateSpec as t };

View File

@@ -0,0 +1,7 @@
import { URL } from "node:url";
import { Duplex } from "node:stream";
import "node:tls";
import "events";
import "node:http";
import "node:https";
import "node:zlib";

View File

@@ -0,0 +1,8 @@
import "node:sqlite";
//#region ../../node_modules/.pnpm/db0@0.3.4/node_modules/db0/dist/index.d.mts
//#endregion
//#region src/_connectors.d.ts
type ConnectorName = "better-sqlite3" | "bun-sqlite" | "bun" | "cloudflare-d1" | "cloudflare-hyperdrive-mysql" | "cloudflare-hyperdrive-postgresql" | "libsql-core" | "libsql-http" | "libsql-node" | "libsql" | "libsql-web" | "mysql2" | "node-sqlite" | "sqlite" | "pglite" | "planetscale" | "postgresql" | "sqlite3";
//#endregion
export { ConnectorName as t };

View File

@@ -0,0 +1,137 @@
//#region ../../node_modules/.pnpm/esbuild@0.27.3/node_modules/esbuild/lib/main.d.ts
type Platform = 'browser' | 'node' | 'neutral';
type Format = 'iife' | 'cjs' | 'esm';
type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'local-css' | 'text' | 'ts' | 'tsx';
type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent';
type Charset = 'ascii' | 'utf8';
type Drop = 'console' | 'debugger';
type AbsPaths = 'code' | 'log' | 'metafile';
interface CommonOptions {
/** Documentation: https://esbuild.github.io/api/#sourcemap */
sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both';
/** Documentation: https://esbuild.github.io/api/#legal-comments */
legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external';
/** Documentation: https://esbuild.github.io/api/#source-root */
sourceRoot?: string;
/** Documentation: https://esbuild.github.io/api/#sources-content */
sourcesContent?: boolean;
/** Documentation: https://esbuild.github.io/api/#format */
format?: Format;
/** Documentation: https://esbuild.github.io/api/#global-name */
globalName?: string;
/** Documentation: https://esbuild.github.io/api/#target */
target?: string | string[];
/** Documentation: https://esbuild.github.io/api/#supported */
supported?: Record<string, boolean>;
/** Documentation: https://esbuild.github.io/api/#platform */
platform?: Platform;
/** Documentation: https://esbuild.github.io/api/#mangle-props */
mangleProps?: RegExp;
/** Documentation: https://esbuild.github.io/api/#mangle-props */
reserveProps?: RegExp;
/** Documentation: https://esbuild.github.io/api/#mangle-props */
mangleQuoted?: boolean;
/** Documentation: https://esbuild.github.io/api/#mangle-props */
mangleCache?: Record<string, string | false>;
/** Documentation: https://esbuild.github.io/api/#drop */
drop?: Drop[];
/** Documentation: https://esbuild.github.io/api/#drop-labels */
dropLabels?: string[];
/** Documentation: https://esbuild.github.io/api/#minify */
minify?: boolean;
/** Documentation: https://esbuild.github.io/api/#minify */
minifyWhitespace?: boolean;
/** Documentation: https://esbuild.github.io/api/#minify */
minifyIdentifiers?: boolean;
/** Documentation: https://esbuild.github.io/api/#minify */
minifySyntax?: boolean;
/** Documentation: https://esbuild.github.io/api/#line-limit */
lineLimit?: number;
/** Documentation: https://esbuild.github.io/api/#charset */
charset?: Charset;
/** Documentation: https://esbuild.github.io/api/#tree-shaking */
treeShaking?: boolean;
/** Documentation: https://esbuild.github.io/api/#ignore-annotations */
ignoreAnnotations?: boolean;
/** Documentation: https://esbuild.github.io/api/#jsx */
jsx?: 'transform' | 'preserve' | 'automatic';
/** Documentation: https://esbuild.github.io/api/#jsx-factory */
jsxFactory?: string;
/** Documentation: https://esbuild.github.io/api/#jsx-fragment */
jsxFragment?: string;
/** Documentation: https://esbuild.github.io/api/#jsx-import-source */
jsxImportSource?: string;
/** Documentation: https://esbuild.github.io/api/#jsx-development */
jsxDev?: boolean;
/** Documentation: https://esbuild.github.io/api/#jsx-side-effects */
jsxSideEffects?: boolean;
/** Documentation: https://esbuild.github.io/api/#define */
define?: {
[key: string]: string;
};
/** Documentation: https://esbuild.github.io/api/#pure */
pure?: string[];
/** Documentation: https://esbuild.github.io/api/#keep-names */
keepNames?: boolean;
/** Documentation: https://esbuild.github.io/api/#abs-paths */
absPaths?: AbsPaths[];
/** Documentation: https://esbuild.github.io/api/#color */
color?: boolean;
/** Documentation: https://esbuild.github.io/api/#log-level */
logLevel?: LogLevel;
/** Documentation: https://esbuild.github.io/api/#log-limit */
logLimit?: number;
/** Documentation: https://esbuild.github.io/api/#log-override */
logOverride?: Record<string, LogLevel>;
/** Documentation: https://esbuild.github.io/api/#tsconfig-raw */
tsconfigRaw?: string | TsconfigRaw;
}
interface TsconfigRaw {
compilerOptions?: {
alwaysStrict?: boolean;
baseUrl?: string;
experimentalDecorators?: boolean;
importsNotUsedAsValues?: 'remove' | 'preserve' | 'error';
jsx?: 'preserve' | 'react-native' | 'react' | 'react-jsx' | 'react-jsxdev';
jsxFactory?: string;
jsxFragmentFactory?: string;
jsxImportSource?: string;
paths?: Record<string, string[]>;
preserveValueImports?: boolean;
strict?: boolean;
target?: string;
useDefineForClassFields?: boolean;
verbatimModuleSyntax?: boolean;
};
}
interface TransformOptions extends CommonOptions {
/** Documentation: https://esbuild.github.io/api/#sourcefile */
sourcefile?: string;
/** Documentation: https://esbuild.github.io/api/#loader */
loader?: Loader;
/** Documentation: https://esbuild.github.io/api/#banner */
banner?: string;
/** Documentation: https://esbuild.github.io/api/#footer */
footer?: string;
}
// Note: These declarations exist to avoid type errors when you omit "dom" from
// "lib" in your "tsconfig.json" file. TypeScript confusingly declares the
// global "WebAssembly" type in "lib.dom.d.ts" even though it has nothing to do
// with the browser DOM and is present in many non-browser JavaScript runtimes
// (e.g. node and deno). Declaring it here allows esbuild's API to be used in
// these scenarios.
//
// There's an open issue about getting this problem corrected (although these
// declarations will need to remain even if this is fixed for backward
// compatibility with older TypeScript versions):
//
// https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/826
//
declare global {
namespace WebAssembly {
interface Module {}
}
interface URL {}
}
//#endregion
export { TransformOptions as n, Loader as t };

View File

@@ -0,0 +1,79 @@
import * as stream from "node:stream";
import { EventEmitter } from "node:events";
import "node:http";
//#region ../../node_modules/.pnpm/httpxy@0.1.7/node_modules/httpxy/dist/index.d.ts
interface ProxyTargetDetailed {
host: string;
port: number;
protocol?: string;
hostname?: string;
socketPath?: string;
key?: string;
passphrase?: string;
pfx?: Buffer | string;
cert?: string;
ca?: string;
ciphers?: string;
secureProtocol?: string;
}
type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed;
type ProxyTargetUrl = string | Partial<URL>;
interface ProxyServerOptions {
/** URL string to be parsed with the url module. */
target?: ProxyTarget;
/** URL string to be parsed with the url module. */
forward?: ProxyTargetUrl;
/** Object to be passed to http(s).request. */
agent?: any;
/** Object to be passed to https.createServer(). */
ssl?: any;
/** If you want to proxy websockets. */
ws?: boolean;
/** Adds x- forward headers. */
xfwd?: boolean;
/** Verify SSL certificate. */
secure?: boolean;
/** Explicitly specify if we are proxying to another proxy. */
toProxy?: boolean;
/** Specify whether you want to prepend the target's path to the proxy path. */
prependPath?: boolean;
/** Specify whether you want to ignore the proxy path of the incoming request. */
ignorePath?: boolean;
/** Local interface string to bind for outgoing connections. */
localAddress?: string;
/** Changes the origin of the host header to the target URL. */
changeOrigin?: boolean;
/** specify whether you want to keep letter case of response header key */
preserveHeaderKeyCase?: boolean;
/** Basic authentication i.e. 'user:password' to compute an Authorization header. */
auth?: string;
/** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
hostRewrite?: string;
/** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
autoRewrite?: boolean;
/** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
protocolRewrite?: string;
/** Rewrites domain of set-cookie headers. */
cookieDomainRewrite?: false | string | {
[oldDomain: string]: string;
};
/** Rewrites path of set-cookie headers. Default: false */
cookiePathRewrite?: false | string | {
[oldPath: string]: string;
};
/** Object with extra headers to be added to target requests. */
headers?: {
[header: string]: string;
};
/** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
proxyTimeout?: number;
/** Timeout (in milliseconds) for incoming requests */
timeout?: number;
/** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */
selfHandleResponse?: boolean;
/** Buffer */
buffer?: stream.Stream;
}
//#endregion
export { ProxyServerOptions as t };

View File

@@ -0,0 +1,6 @@
/// <reference types="node" />
import "events";
import "net";
import "tls";
import "stream";
import "dns";

View File

@@ -0,0 +1,7 @@
import { ConsolaInstance } from "consola";
import "h3";
import "node:net";
import "node:http";
import "node:https";
import "http";
import "jiti/lib/types";

View File

@@ -0,0 +1,220 @@
//#region ../../node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.d.mts
interface SourceMapOptions {
/**
* Whether the mapping should be high-resolution.
* Hi-res mappings map every single character, meaning (for example) your devtools will always
* be able to pinpoint the exact location of function calls and so on.
* With lo-res mappings, devtools may only be able to identify the correct
* line - but they're quicker to generate and less bulky.
* You can also set `"boundary"` to generate a semi-hi-res mappings segmented per word boundary
* instead of per character, suitable for string semantics that are separated by words.
* If sourcemap locations have been specified with s.addSourceMapLocation(), they will be used here.
*/
hires?: boolean | 'boundary';
/**
* The filename where you plan to write the sourcemap.
*/
file?: string;
/**
* The filename of the file containing the original source.
*/
source?: string;
/**
* Whether to include the original content in the map's sourcesContent array.
*/
includeContent?: boolean;
}
type SourceMapSegment = [number] | [number, number, number, number] | [number, number, number, number, number];
interface DecodedSourceMap {
file: string;
sources: string[];
sourcesContent?: string[];
names: string[];
mappings: SourceMapSegment[][];
x_google_ignoreList?: number[];
}
declare class SourceMap {
constructor(properties: DecodedSourceMap);
version: number;
file: string;
sources: string[];
sourcesContent?: string[];
names: string[];
mappings: string;
x_google_ignoreList?: number[];
debugId?: string;
/**
* Returns the equivalent of `JSON.stringify(map)`
*/
toString(): string;
/**
* Returns a DataURI containing the sourcemap. Useful for doing this sort of thing:
* `generateMap(options?: SourceMapOptions): SourceMap;`
*/
toUrl(): string;
}
type ExclusionRange = [number, number];
interface MagicStringOptions {
filename?: string;
indentExclusionRanges?: ExclusionRange | Array<ExclusionRange>;
offset?: number;
}
interface IndentOptions {
exclude?: ExclusionRange | Array<ExclusionRange>;
indentStart?: boolean;
}
interface OverwriteOptions {
storeName?: boolean;
contentOnly?: boolean;
}
interface UpdateOptions {
storeName?: boolean;
overwrite?: boolean;
}
declare class MagicString {
constructor(str: string, options?: MagicStringOptions);
/**
* Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
*/
addSourcemapLocation(char: number): void;
/**
* Appends the specified content to the end of the string.
*/
append(content: string): this;
/**
* Appends the specified content at the index in the original string.
* If a range *ending* with index is subsequently moved, the insert will be moved with it.
* See also `s.prependLeft(...)`.
*/
appendLeft(index: number, content: string): this;
/**
* Appends the specified content at the index in the original string.
* If a range *starting* with index is subsequently moved, the insert will be moved with it.
* See also `s.prependRight(...)`.
*/
appendRight(index: number, content: string): this;
/**
* Does what you'd expect.
*/
clone(): this;
/**
* Generates a version 3 sourcemap.
*/
generateMap(options?: SourceMapOptions): SourceMap;
/**
* Generates a sourcemap object with raw mappings in array form, rather than encoded as a string.
* Useful if you need to manipulate the sourcemap further, but most of the time you will use `generateMap` instead.
*/
generateDecodedMap(options?: SourceMapOptions): DecodedSourceMap;
getIndentString(): string;
/**
* Prefixes each line of the string with prefix.
* If prefix is not supplied, the indentation will be guessed from the original content, falling back to a single tab character.
*/
indent(options?: IndentOptions): this;
/**
* Prefixes each line of the string with prefix.
* If prefix is not supplied, the indentation will be guessed from the original content, falling back to a single tab character.
*
* The options argument can have an exclude property, which is an array of [start, end] character ranges.
* These ranges will be excluded from the indentation - useful for (e.g.) multiline strings.
*/
indent(indentStr?: string, options?: IndentOptions): this;
indentExclusionRanges: ExclusionRange | Array<ExclusionRange>;
/**
* Moves the characters from `start` and `end` to `index`.
*/
move(start: number, end: number, index: number): this;
/**
* Replaces the characters from `start` to `end` with `content`, along with the appended/prepended content in
* that range. The same restrictions as `s.remove()` apply.
*
* The fourth argument is optional. It can have a storeName property — if true, the original name will be stored
* for later inclusion in a sourcemap's names array — and a contentOnly property which determines whether only
* the content is overwritten, or anything that was appended/prepended to the range as well.
*
* It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
*/
overwrite(start: number, end: number, content: string, options?: boolean | OverwriteOptions): this;
/**
* Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply.
*
* The fourth argument is optional. It can have a storeName property — if true, the original name will be stored
* for later inclusion in a sourcemap's names array — and an overwrite property which determines whether only
* the content is overwritten, or anything that was appended/prepended to the range as well.
*/
update(start: number, end: number, content: string, options?: boolean | UpdateOptions): this;
/**
* Prepends the string with the specified content.
*/
prepend(content: string): this;
/**
* Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index
*/
prependLeft(index: number, content: string): this;
/**
* Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
*/
prependRight(index: number, content: string): this;
/**
* Removes the characters from `start` to `end` (of the original string, **not** the generated string).
* Removing the same content twice, or making removals that partially overlap, will cause an error.
*/
remove(start: number, end: number): this;
/**
* Reset the modified characters from `start` to `end` (of the original string, **not** the generated string).
*/
reset(start: number, end: number): this;
/**
* Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string.
* Throws error if the indices are for characters that were already removed.
*/
slice(start: number, end: number): string;
/**
* Returns a clone of `s`, with all content before the `start` and `end` characters of the original string removed.
*/
snip(start: number, end: number): this;
/**
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start and end.
*/
trim(charType?: string): this;
/**
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.
*/
trimStart(charType?: string): this;
/**
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end.
*/
trimEnd(charType?: string): this;
/**
* Removes empty lines from the start and end.
*/
trimLines(): this;
/**
* String replacement with RegExp or string.
*/
replace(regex: RegExp | string, replacement: string | ((substring: string, ...args: any[]) => string)): this;
/**
* Same as `s.replace`, but replace all matched strings instead of just one.
*/
replaceAll(regex: RegExp | string, replacement: string | ((substring: string, ...args: any[]) => string)): this;
lastChar(): string;
lastLine(): string;
/**
* Returns true if the resulting source is empty (disregarding white space).
*/
isEmpty(): boolean;
length(): number;
/**
* Indicates if the string has been changed.
*/
hasChanged(): boolean;
original: string;
/**
* Returns the generated string.
*/
toString(): string;
offset: number;
}
//#endregion
export { MagicString as t };

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,594 @@
import { i as NitroRouteConfig$1, n as NitroDevEventHandler$1, r as NitroEventHandler$1, t as Nitro$1 } from "./_chunks/libs/nitro.mjs";
import { i as NitroRouteConfig$2, n as NitroDevEventHandler$2, r as NitroEventHandler$2, t as Nitro$2 } from "./_chunks/libs/nitropack.mjs";
import "./_chunks/libs/db0.mjs";
import "./_chunks/libs/chokidar.mjs";
import "./_chunks/libs/ioredis.mjs";
import "./_chunks/libs/@rollup/plugin-commonjs.mjs";
import "./_chunks/libs/httpxy.mjs";
import "./_chunks/libs/esbuild.mjs";
import "./_chunks/libs/crossws.mjs";
import "./_chunks/libs/listhen.mjs";
import "./_chunks/libs/@vercel/nft.mjs";
import { ConsolaInstance, ConsolaOptions } from "consola";
import { UseContext } from "unctx";
import { TSConfig } from "pkg-types";
import { GlobOptions } from "tinyglobby";
import { LoadConfigOptions } from "c12";
import { Component, ComponentsDir, ModuleDefinition, ModuleMeta, ModuleOptions, Nuxt, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, NuxtConfig, NuxtHooks, NuxtMiddleware, NuxtModule, NuxtOptions, NuxtPlugin, NuxtPluginTemplate, NuxtServerTemplate, NuxtTemplate, NuxtTypeTemplate, ResolvedNuxtTemplate, SchemaDefinition } from "@nuxt/schema";
import { Import, InlinePreset } from "unimport";
import { Configuration, WebpackPluginInstance } from "webpack";
import { RspackPluginInstance } from "@rspack/core";
import { Plugin, UserConfig } from "vite";
//#region src/module/define.d.ts
/**
* Define a Nuxt module, automatically merging defaults with user provided options, installing
* any hooks that are provided, and calling an optional setup function for full control.
*/
declare function defineNuxtModule<TOptions extends ModuleOptions>(definition: ModuleDefinition<TOptions, Partial<TOptions>, false> | NuxtModule<TOptions, Partial<TOptions>, false>): NuxtModule<TOptions, TOptions, false>;
declare function defineNuxtModule<TOptions extends ModuleOptions>(): {
with: <TOptionsDefaults extends Partial<TOptions>>(definition: ModuleDefinition<TOptions, TOptionsDefaults, true> | NuxtModule<TOptions, TOptionsDefaults, true>) => NuxtModule<TOptions, TOptionsDefaults, true>;
};
//#endregion
//#region src/module/install.d.ts
type ModuleToInstall = string | NuxtModule<ModuleOptions, Partial<ModuleOptions>, false>;
/**
* Installs a set of modules on a Nuxt instance.
* @internal
*/
declare function installModules(modulesToInstall: Map<ModuleToInstall, Record<string, any>>, resolvedModulePaths: Set<string>, nuxt?: Nuxt): Promise<void>;
/**
* Installs a module on a Nuxt instance.
* @deprecated Use module dependencies.
*/
declare function installModule<T extends string | NuxtModule, Config extends Extract<NonNullable<NuxtConfig["modules"]>[number], [T, any]>>(moduleToInstall: T, inlineOptions?: [Config] extends [never] ? any : Config[1], nuxt?: Nuxt): Promise<void>;
declare function resolveModuleWithOptions(definition: NuxtModule<any> | string | false | undefined | null | [(NuxtModule | string)?, Record<string, any>?], nuxt: Nuxt): {
resolvedPath?: string;
module: string | NuxtModule<any>;
options: Record<string, any>;
} | undefined;
declare function loadNuxtModuleInstance(nuxtModule: string | NuxtModule, nuxt?: Nuxt): Promise<{
nuxtModule: NuxtModule<any>;
buildTimeModuleMeta: ModuleMeta;
resolvedModulePath?: string;
}>;
declare function getDirectory(p: string): string;
declare const normalizeModuleTranspilePath: (p: string) => string;
//#endregion
//#region src/module/compatibility.d.ts
/**
* Check if a Nuxt module is installed by name.
*
* This will check both the installed modules and the modules to be installed. Note
* that it cannot detect if a module is _going to be_ installed programmatically by another module.
*/
declare function hasNuxtModule(moduleName: string, nuxt?: Nuxt): boolean;
/**
* Checks if a Nuxt module is compatible with a given semver version.
*/
declare function hasNuxtModuleCompatibility(module: string | NuxtModule, semverVersion: string, nuxt?: Nuxt): Promise<boolean>;
/**
* Get the version of a Nuxt module.
*
* Scans installed modules for the version, if it's not found it will attempt to load the module instance and get the version from there.
*/
declare function getNuxtModuleVersion(module: string | NuxtModule, nuxt?: Nuxt | any): Promise<string | false>;
//#endregion
//#region src/loader/config.d.ts
interface LoadNuxtConfigOptions extends Omit<LoadConfigOptions<NuxtConfig>, "overrides"> {
overrides?: Exclude<LoadConfigOptions<NuxtConfig>["overrides"], Promise<any> | Function>;
}
declare function loadNuxtConfig(opts: LoadNuxtConfigOptions): Promise<NuxtOptions>;
//#endregion
//#region src/loader/schema.d.ts
declare function extendNuxtSchema(def: SchemaDefinition | (() => SchemaDefinition)): void;
//#endregion
//#region src/loader/nuxt.d.ts
interface LoadNuxtOptions extends LoadNuxtConfigOptions {
/** Load nuxt with development mode */
dev?: boolean;
/** Use lazy initialization of nuxt if set to false */
ready?: boolean;
}
declare function loadNuxt(opts: LoadNuxtOptions): Promise<Nuxt>;
declare function buildNuxt(nuxt: Nuxt): Promise<any>;
//#endregion
//#region src/layers.d.ts
interface LayerDirectories {
/** Nuxt rootDir (`/` by default) */
readonly root: string;
/** Nitro source directory (`/server` by default) */
readonly server: string;
/** Local modules directory (`/modules` by default) */
readonly modules: string;
/** Shared directory (`/shared` by default) */
readonly shared: string;
/** Public directory (`/public` by default) */
readonly public: string;
/** Nuxt srcDir (`/app/` by default) */
readonly app: string;
/** Layouts directory (`/app/layouts` by default) */
readonly appLayouts: string;
/** Middleware directory (`/app/middleware` by default) */
readonly appMiddleware: string;
/** Pages directory (`/app/pages` by default) */
readonly appPages: string;
/** Plugins directory (`/app/plugins` by default) */
readonly appPlugins: string;
}
/**
* Get the resolved directory paths for all layers in a Nuxt application.
*
* Returns an array of LayerDirectories objects, ordered by layer priority:
* - The first layer is the user/project layer (highest priority)
* - Earlier layers override later layers in the array
* - Base layers appear last in the array (lowest priority)
*
* @param nuxt - The Nuxt instance to get layers from. Defaults to the current Nuxt context.
* @returns Array of LayerDirectories objects, ordered by priority (user layer first)
*/
declare function getLayerDirectories(nuxt?: Nuxt): LayerDirectories[];
//#endregion
//#region src/head.d.ts
declare function setGlobalHead(head: NuxtAppConfig["head"]): void;
//#endregion
//#region src/imports.d.ts
declare function addImports(imports: Import | Import[]): void;
declare function addImportsDir(dirs: string | string[], opts?: {
prepend?: boolean;
}): void;
declare function addImportsSources(presets: InlinePreset | InlinePreset[]): void;
//#endregion
//#region src/runtime-config.d.ts
/**
* Access 'resolved' Nuxt runtime configuration, with values updated from environment.
*
* This mirrors the runtime behavior of Nitro.
*/
declare function useRuntimeConfig(): Record<string, any>;
/**
* Update Nuxt runtime configuration.
*/
declare function updateRuntimeConfig(runtimeConfig: Record<string, unknown>): void | Promise<void>;
//#endregion
//#region src/build.d.ts
type Arrayable<T> = T | T[];
type Thenable<T> = T | Promise<T>;
interface ExtendConfigOptions {
/**
* Install plugin on dev
* @default true
*/
dev?: boolean;
/**
* Install plugin on build
* @default true
*/
build?: boolean;
/**
* Install plugin on server side
* @default true
*/
server?: boolean;
/**
* Install plugin on client side
* @default true
*/
client?: boolean;
/**
* Prepends the plugin to the array with `unshift()` instead of `push()`.
*/
prepend?: boolean;
}
interface ExtendWebpackConfigOptions extends ExtendConfigOptions {}
interface ExtendViteConfigOptions extends Omit<ExtendConfigOptions, "server" | "client"> {
/**
* Extend server Vite configuration
* @default true
* @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
* Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
* You can likely use a Vite plugin to achieve the same result.
*/
server?: boolean;
/**
* Extend client Vite configuration
* @default true
* @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
* Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
* You can likely use a Vite plugin to achieve the same result.
*/
client?: boolean;
}
type ExtendWebpacklikeConfig = (fn: (config: Configuration) => void, options?: ExtendWebpackConfigOptions) => void;
/**
* Extend webpack config
*
* The fallback function might be called multiple times
* when applying to both client and server builds.
*/
declare const extendWebpackConfig: ExtendWebpacklikeConfig;
/**
* Extend rspack config
*
* The fallback function might be called multiple times
* when applying to both client and server builds.
*/
declare const extendRspackConfig: ExtendWebpacklikeConfig;
/**
* Extend Vite config
*/
declare function extendViteConfig(fn: ((config: UserConfig) => Thenable<void>), options?: ExtendViteConfigOptions): (() => void) | undefined;
/**
* Append webpack plugin to the config.
*/
declare function addWebpackPlugin(pluginOrGetter: Arrayable<WebpackPluginInstance> | (() => Thenable<Arrayable<WebpackPluginInstance>>), options?: ExtendWebpackConfigOptions): void;
/**
* Append rspack plugin to the config.
*/
declare function addRspackPlugin(pluginOrGetter: Arrayable<RspackPluginInstance> | (() => Thenable<Arrayable<RspackPluginInstance>>), options?: ExtendWebpackConfigOptions): void;
/**
* Append Vite plugin to the config.
*/
declare function addVitePlugin(pluginOrGetter: Arrayable<Plugin> | (() => Thenable<Arrayable<Plugin>>), options?: ExtendConfigOptions): void;
interface AddBuildPluginFactory {
vite?: () => Thenable<Arrayable<Plugin>>;
webpack?: () => Thenable<Arrayable<WebpackPluginInstance>>;
rspack?: () => Thenable<Arrayable<RspackPluginInstance>>;
}
declare function addBuildPlugin(pluginFactory: AddBuildPluginFactory, options?: ExtendConfigOptions): void;
//#endregion
//#region src/compatibility.d.ts
declare function normalizeSemanticVersion(version: string): string;
/**
* Check version constraints and return incompatibility issues as an array
*/
declare function checkNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<NuxtCompatibilityIssues>;
/**
* Check version constraints and throw a detailed error if has any, otherwise returns true
*/
declare function assertNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<true>;
/**
* Check version constraints and return true if passed, otherwise returns false
*/
declare function hasNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<boolean>;
type NuxtMajorVersion = 2 | 3 | 4;
/**
* Check if current Nuxt instance is of specified major version
*/
declare function isNuxtMajorVersion(majorVersion: NuxtMajorVersion, nuxt?: Nuxt): boolean;
/**
* @deprecated Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
*/
declare function isNuxt2(nuxt?: Nuxt): boolean;
/**
* @deprecated Use `isNuxtMajorVersion(3, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
*/
declare function isNuxt3(nuxt?: Nuxt): boolean;
/**
* Get nuxt version
*/
declare function getNuxtVersion(nuxt?: Nuxt | any): string;
//#endregion
//#region src/components.d.ts
/**
* Register a directory to be scanned for components and imported only when used.
*/
declare function addComponentsDir(dir: ComponentsDir, opts?: {
prepend?: boolean;
}): void;
type AddComponentOptions = {
name: string;
filePath: string;
} & Partial<Exclude<Component, "shortPath" | "async" | "level" | "import" | "asyncImport">>;
/**
* This utility takes a file path or npm package that is scanned for named exports, which are get added automatically
*/
declare function addComponentExports(opts: Omit<AddComponentOptions, "name"> & {
prefix?: string;
}): void;
/**
* Register a component by its name and filePath.
*/
declare function addComponent(opts: AddComponentOptions): void;
//#endregion
//#region src/context.d.ts
/**
* Direct access to the Nuxt global context - see https://github.com/unjs/unctx.
* @deprecated Use `getNuxtCtx` instead
*/
declare const nuxtCtx: UseContext<Nuxt>;
/** Direct access to the Nuxt context with asyncLocalStorage - see https://github.com/unjs/unctx. */
declare const getNuxtCtx: () => Nuxt | null;
/**
* Get access to Nuxt instance.
*
* Throws an error if Nuxt instance is unavailable.
* @example
* ```js
* const nuxt = useNuxt()
* ```
*/
declare function useNuxt(): Nuxt;
/**
* Get access to Nuxt instance.
*
* Returns null if Nuxt instance is unavailable.
* @example
* ```js
* const nuxt = tryUseNuxt()
* if (nuxt) {
* // Do something
* }
* ```
*/
declare function tryUseNuxt(): Nuxt | null;
declare function runWithNuxtContext<T extends (...args: any[]) => any>(nuxt: Nuxt, fn: T): ReturnType<T>;
//#endregion
//#region src/ignore.d.ts
declare function createIsIgnored(nuxt?: Nuxt | null | undefined): (pathname: string, stats?: unknown) => boolean;
/**
* Return a filter function to filter an array of paths
*/
declare function isIgnored(pathname: string, _stats?: unknown, nuxt?: Nuxt | null | undefined): boolean;
declare function resolveIgnorePatterns(relativePath?: string): string[];
//#endregion
//#region src/layout.d.ts
declare function addLayout(template: NuxtTemplate | string, name?: string): void;
//#endregion
//#region src/nitro-types.d.ts
type isNitroV2 = "options" extends keyof Nitro$2 ? "___INVALID" extends keyof Nitro$2 ? false : true : false;
type isNitroV3 = "options" extends keyof Nitro$1 ? "___INVALID" extends keyof Nitro$1 ? false : true : false;
type Nitro = isNitroV2 extends true ? isNitroV3 extends true ? Nitro$2 | Nitro$1 : Nitro$2 : Nitro$1;
type NitroDevEventHandler = isNitroV2 extends true ? isNitroV3 extends true ? NitroDevEventHandler$2 | NitroDevEventHandler$1 : NitroDevEventHandler$2 : NitroDevEventHandler$1;
type NitroEventHandler = isNitroV2 extends true ? isNitroV3 extends true ? NitroEventHandler$2 | NitroEventHandler$1 : NitroEventHandler$2 : NitroEventHandler$1;
type NitroRouteConfig = isNitroV2 extends true ? isNitroV3 extends true ? NitroRouteConfig$2 | NitroRouteConfig$1 : NitroRouteConfig$2 : NitroRouteConfig$1;
//#endregion
//#region src/pages.d.ts
declare function extendPages(cb: NuxtHooks["pages:extend"]): void;
interface ExtendRouteRulesOptions {
/**
* Override route rule config
* @default false
*/
override?: boolean;
}
declare function extendRouteRules(route: string, rule: NitroRouteConfig, options?: ExtendRouteRulesOptions): void;
interface AddRouteMiddlewareOptions {
/**
* Override existing middleware with the same name, if it exists
* @default false
*/
override?: boolean;
/**
* Prepend middleware to the list
* @default false
*/
prepend?: boolean;
}
declare function addRouteMiddleware(input: NuxtMiddleware | NuxtMiddleware[], options?: AddRouteMiddlewareOptions): void;
//#endregion
//#region src/plugin.d.ts
declare function normalizePlugin(plugin: NuxtPlugin | string): NuxtPlugin;
/**
* Registers a nuxt plugin and to the plugins array.
*
* Note: You can use mode or .client and .server modifiers with fileName option
* to use plugin only in client or server side.
*
* Note: By default plugin is prepended to the plugins array. You can use second argument to append (push) instead.
* @example
* ```js
* import { createResolver } from '@nuxt/kit'
* const resolver = createResolver(import.meta.url)
*
* addPlugin({
* src: resolver.resolve('templates/foo.js'),
* filename: 'foo.server.js' // [optional] only include in server bundle
* })
* ```
*/
interface AddPluginOptions {
append?: boolean;
}
declare function addPlugin(_plugin: NuxtPlugin | string, opts?: AddPluginOptions): NuxtPlugin;
/**
* Adds a template and registers as a nuxt plugin.
*/
declare function addPluginTemplate(plugin: NuxtPluginTemplate | string, opts?: AddPluginOptions): NuxtPlugin;
//#endregion
//#region src/resolve.d.ts
interface ResolvePathOptions {
/** Base for resolving paths from. Default is Nuxt rootDir. */
cwd?: string;
/** An object of aliases. Default is Nuxt configured aliases. */
alias?: Record<string, string>;
/**
* The file extensions to try.
* Default is Nuxt configured extensions.
*
* Isn't considered when `type` is set to `'dir'`.
*/
extensions?: string[];
/**
* Whether to resolve files that exist in the Nuxt VFS (for example, as a Nuxt template).
* @default false
*/
virtual?: boolean;
/**
* Whether to fallback to the original path if the resolved path does not exist instead of returning the normalized input path.
* @default false
*/
fallbackToOriginal?: boolean;
/**
* The type of the path to be resolved.
* @default 'file'
*/
type?: PathType;
}
/**
* Resolve the full path to a file or a directory (based on the provided type), respecting Nuxt alias and extensions options.
*
* If a path cannot be resolved, normalized input will be returned unless the `fallbackToOriginal` option is set to `true`,
* in which case the original input path will be returned.
*/
declare function resolvePath(path: string, opts?: ResolvePathOptions): Promise<string>;
/**
* Try to resolve first existing file in paths
*/
declare function findPath(paths: string | string[], opts?: ResolvePathOptions, pathType?: PathType): Promise<string | null>;
/**
* Resolve path aliases respecting Nuxt alias options
*/
declare function resolveAlias(path: string, alias?: Record<string, string>): string;
interface Resolver {
resolve(...path: string[]): string;
resolvePath(path: string, opts?: ResolvePathOptions): Promise<string>;
}
/**
* Create a relative resolver
*/
declare function createResolver(base: string | URL): Resolver;
declare function resolveNuxtModule(base: string, paths: string[]): Promise<string[]>;
type PathType = "file" | "dir";
/**
* Resolve absolute file paths in the provided directory with respect to `.nuxtignore` and return them sorted.
* @param path path to the directory to resolve files in
* @param pattern glob pattern or an array of glob patterns to match files
* @param opts options for globbing
* @param opts.followSymbolicLinks whether to follow symbolic links, default is `true`
* @param opts.ignore additional glob patterns to ignore
* @returns sorted array of absolute file paths
*/
declare function resolveFiles(path: string, pattern: string | string[], opts?: {
followSymbolicLinks?: boolean;
ignore?: GlobOptions["ignore"];
}): Promise<string[]>;
//#endregion
//#region src/nitro.d.ts
/**
* Adds a nitro server handler
*
*/
declare function addServerHandler(handler: NitroEventHandler): void;
/**
* Adds a nitro server handler for development-only
*
*/
declare function addDevServerHandler(handler: NitroDevEventHandler): void;
/**
* Adds a Nitro plugin
*/
declare function addServerPlugin(plugin: string): void;
/**
* Adds routes to be prerendered
*/
declare function addPrerenderRoutes(routes: string | string[]): void;
/**
* Access to the Nitro instance
*
* **Note:** You can call `useNitro()` only after `ready` hook.
*
* **Note:** Changes to the Nitro instance configuration are not applied.
* @example
*
* ```ts
* nuxt.hook('ready', () => {
* console.log(useNitro())
* })
* ```
*/
declare function useNitro(): Nitro;
/**
* Add server imports to be auto-imported by Nitro
*/
declare function addServerImports(imports: Import | Import[]): void;
/**
* Add directories to be scanned for auto-imports by Nitro
*/
declare function addServerImportsDir(dirs: string | string[], opts?: {
prepend?: boolean;
}): void;
/**
* Add directories to be scanned by Nitro. It will check for subdirectories,
* which will be registered just like the `~~/server` folder is.
*/
declare function addServerScanDir(dirs: string | string[], opts?: {
prepend?: boolean;
}): void;
//#endregion
//#region src/template.d.ts
/**
* Renders given template during build into the virtual file system (and optionally to disk in the project `buildDir`)
*/
declare function addTemplate<T>(_template: NuxtTemplate<T> | string): ResolvedNuxtTemplate<T>;
/**
* Adds a virtual file that can be used within the Nuxt Nitro server build.
*/
declare function addServerTemplate(template: NuxtServerTemplate): NuxtServerTemplate;
/**
* Renders given types during build to disk in the project `buildDir`
* and register them as types.
*
* You can pass a second context object to specify in which context the type should be added.
*
* If no context object is passed, then it will only be added to the nuxt context.
*/
declare function addTypeTemplate<T>(_template: NuxtTypeTemplate<T>, context?: {
nitro?: boolean;
nuxt?: boolean;
node?: boolean;
shared?: boolean;
}): ResolvedNuxtTemplate<T>;
/**
* Normalize a nuxt template object
*/
declare function normalizeTemplate<T>(template: NuxtTemplate<T> | string, buildDir?: string): ResolvedNuxtTemplate<T>;
/**
* Trigger rebuilding Nuxt templates
*
* You can pass a filter within the options to selectively regenerate a subset of templates.
*/
declare function updateTemplates(options?: {
filter?: (template: ResolvedNuxtTemplate<any>) => boolean;
}): Promise<void>;
declare function writeTypes(nuxt: Nuxt): Promise<void>;
//#endregion
//#region src/logger.d.ts
declare const logger: ConsolaInstance;
declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>): ConsolaInstance;
//#endregion
//#region src/internal/esm.d.ts
interface ResolveModuleOptions {
/** @deprecated use `url` with URLs pointing at a file - never a directory */
paths?: string | string[];
url?: URL | URL[];
/** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
extensions?: string[];
}
declare function directoryToURL(dir: string): URL;
/**
* Resolve a module from a given root path using an algorithm patterned on
* the upcoming `import.meta.resolve`. It returns a file URL
*
* @internal
*/
declare function tryResolveModule(id: string, url: URL | URL[]): Promise<string | undefined>;
/** @deprecated pass URLs pointing at files */
declare function tryResolveModule(id: string, url: string | string[]): Promise<string | undefined>;
declare function resolveModule(id: string, options?: ResolveModuleOptions): string;
interface ImportModuleOptions extends ResolveModuleOptions {
/** Automatically de-default the result of requiring the module. */
interopDefault?: boolean;
}
declare function importModule<T = unknown>(id: string, opts?: ImportModuleOptions): Promise<T>;
declare function tryImportModule<T = unknown>(id: string, opts?: ImportModuleOptions): Promise<T | undefined> | undefined;
/**
* @deprecated Please use `importModule` instead.
*/
declare function requireModule<T = unknown>(id: string, opts?: ImportModuleOptions): T;
/**
* @deprecated Please use `tryImportModule` instead.
*/
declare function tryRequireModule<T = unknown>(id: string, opts?: ImportModuleOptions): T | undefined;
//#endregion
export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type ImportModuleOptions, type LayerDirectories, type LoadNuxtConfigOptions, type LoadNuxtOptions, type NuxtMajorVersion, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, setGlobalHead, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,63 @@
{
"name": "@nuxt/kit",
"version": "4.3.1",
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt/nuxt.git",
"directory": "packages/kit"
},
"homepage": "https://nuxt.com/docs/4.x/api/kit",
"description": "Toolkit for authoring modules and interacting with Nuxt",
"license": "MIT",
"type": "module",
"types": "./dist/index.d.mts",
"exports": {
".": "./dist/index.mjs",
"./package.json": "./package.json"
},
"files": [
"dist"
],
"dependencies": {
"c12": "^3.3.3",
"consola": "^3.4.2",
"defu": "^6.1.4",
"destr": "^2.0.5",
"errx": "^0.1.0",
"exsolve": "^1.0.8",
"ignore": "^7.0.5",
"jiti": "^2.6.1",
"klona": "^2.0.6",
"mlly": "^1.8.0",
"ohash": "^2.0.11",
"pathe": "^2.0.3",
"pkg-types": "^2.3.0",
"rc9": "^3.0.0",
"scule": "^1.3.0",
"semver": "^7.7.4",
"tinyglobby": "^0.2.15",
"ufo": "^1.6.3",
"unctx": "^2.5.0",
"untyped": "^2.0.0"
},
"devDependencies": {
"@rspack/core": "1.7.5",
"@types/semver": "7.7.1",
"hookable": "5.5.3",
"nitro": "3.0.1-alpha.2",
"nitropack": "2.13.1",
"obuild": "0.4.27",
"unimport": "5.6.0",
"vite": "7.3.1",
"vitest": "4.0.18",
"webpack": "5.104.1",
"@nuxt/schema": "4.3.1"
},
"engines": {
"node": ">=18.12.0"
},
"scripts": {
"build:stub": "obuild --stub",
"test:attw": "attw --pack"
}
}

View File

@@ -0,0 +1,70 @@
MIT License
Copyright (c) Pooya Parsa <pooya@pi0.io> - Daniel Roe <daniel@roe.dev>
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.
---
Copyright Joyent, Inc. and other Node 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.
---
Bundled zeptomatch (https://github.com/fabiospampinato/zeptomatch)
The MIT License (MIT)
Copyright (c) 2023-present Fabio Spampinato
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.

View File

@@ -0,0 +1,73 @@
# 🛣️ pathe
> Universal filesystem path utils
[![version][npm-v-src]][npm-v-href]
[![downloads][npm-d-src]][npm-d-href]
[![size][size-src]][size-href]
## ❓ Why
For [historical reasons](https://docs.microsoft.com/en-us/archive/blogs/larryosterman/why-is-the-dos-path-character), windows followed MS-DOS and used backslash for separating paths rather than slash used for macOS, Linux, and other Posix operating systems. Nowadays, [Windows](https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN) supports both Slash and Backslash for paths. [Node.js's built-in `path` module](https://nodejs.org/api/path.html) in the default operation of the path module varies based on the operating system on which a Node.js application is running. Specifically, when running on a Windows operating system, the path module will assume that Windows-style paths are being used. **This makes inconsistent code behavior between Windows and POSIX.**
Compared to popular [upath](https://github.com/anodynos/upath), pathe provides **identical exports** of Node.js with normalization on **all operations** and is written in modern **ESM/TypeScript** and has **no dependency on Node.js**!
This package is a drop-in replacement of the Node.js's [path module](https://nodejs.org/api/path.html) module and ensures paths are normalized with slash `/` and work in environments including Node.js.
## 💿 Usage
Install using npm or yarn:
```bash
# npm
npm i pathe
# yarn
yarn add pathe
# pnpm
pnpm i pathe
```
Import:
```js
// ESM / Typescript
import { resolve, matchesGlob } from "pathe";
// CommonJS
const { resolve, matchesGlob } = require("pathe");
```
Read more about path utils from [Node.js documentation](https://nodejs.org/api/path.html) and rest assured behavior is consistently like POSIX regardless of your input paths format and running platform (the only exception is `delimiter` constant export, it will be set to `;` on windows platform).
### Extra utilities
Pathe exports some extra utilities that do not exist in standard Node.js [path module](https://nodejs.org/api/path.html).
In order to use them, you can import from `pathe/utils` subpath:
```js
import {
filename,
normalizeAliases,
resolveAlias,
reverseResolveAlias,
} from "pathe/utils";
```
## License
Made with 💛 Published under the [MIT](./LICENSE) license.
Some code was used from the Node.js project. Glob supported is powered by [zeptomatch](https://github.com/fabiospampinato/zeptomatch).
<!-- Refs -->
[npm-v-src]: https://img.shields.io/npm/v/pathe?style=flat-square
[npm-v-href]: https://npmjs.com/package/pathe
[npm-d-src]: https://img.shields.io/npm/dm/pathe?style=flat-square
[npm-d-href]: https://npmjs.com/package/pathe
[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/pathe/ci/main?style=flat-square
[github-actions-href]: https://github.com/unjs/pathe/actions?query=workflow%3Aci
[size-src]: https://packagephobia.now.sh/badge?p=pathe
[size-href]: https://packagephobia.now.sh/result?p=pathe

View File

@@ -0,0 +1,39 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const _path = require('./shared/pathe.BSlhyZSM.cjs');
const delimiter = /* @__PURE__ */ (() => globalThis.process?.platform === "win32" ? ";" : ":")();
const _platforms = { posix: void 0, win32: void 0 };
const mix = (del = delimiter) => {
return new Proxy(_path._path, {
get(_, prop) {
if (prop === "delimiter") return del;
if (prop === "posix") return posix;
if (prop === "win32") return win32;
return _platforms[prop] || _path._path[prop];
}
});
};
const posix = /* @__PURE__ */ mix(":");
const win32 = /* @__PURE__ */ mix(";");
exports.basename = _path.basename;
exports.dirname = _path.dirname;
exports.extname = _path.extname;
exports.format = _path.format;
exports.isAbsolute = _path.isAbsolute;
exports.join = _path.join;
exports.matchesGlob = _path.matchesGlob;
exports.normalize = _path.normalize;
exports.normalizeString = _path.normalizeString;
exports.parse = _path.parse;
exports.relative = _path.relative;
exports.resolve = _path.resolve;
exports.sep = _path.sep;
exports.toNamespacedPath = _path.toNamespacedPath;
exports.default = posix;
exports.delimiter = delimiter;
exports.posix = posix;
exports.win32 = win32;

View File

@@ -0,0 +1,47 @@
import * as path from 'node:path';
import path__default from 'node:path';
/**
* Constant for path separator.
*
* Always equals to `"/"`.
*/
declare const sep = "/";
declare const normalize: typeof path__default.normalize;
declare const join: typeof path__default.join;
declare const resolve: typeof path__default.resolve;
/**
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
*
* @param path - The path to normalise.
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
* @returns the normalised path string.
*/
declare function normalizeString(path: string, allowAboveRoot: boolean): string;
declare const isAbsolute: typeof path__default.isAbsolute;
declare const toNamespacedPath: typeof path__default.toNamespacedPath;
declare const extname: typeof path__default.extname;
declare const relative: typeof path__default.relative;
declare const dirname: typeof path__default.dirname;
declare const format: typeof path__default.format;
declare const basename: typeof path__default.basename;
declare const parse: typeof path__default.parse;
/**
* The `path.matchesGlob()` method determines if `path` matches the `pattern`.
* @param path The path to glob-match against.
* @param pattern The glob to check the path against.
*/
declare const matchesGlob: (path: string, pattern: string | string[]) => boolean;
type NodePath = typeof path;
/**
* The platform-specific file delimiter.
*
* Equals to `";"` in windows and `":"` in all other platforms.
*/
declare const delimiter: ";" | ":";
declare const posix: NodePath["posix"];
declare const win32: NodePath["win32"];
declare const _default: NodePath;
export { basename, _default as default, delimiter, dirname, extname, format, isAbsolute, join, matchesGlob, normalize, normalizeString, parse, posix, relative, resolve, sep, toNamespacedPath, win32 };

View File

@@ -0,0 +1,47 @@
import * as path from 'node:path';
import path__default from 'node:path';
/**
* Constant for path separator.
*
* Always equals to `"/"`.
*/
declare const sep = "/";
declare const normalize: typeof path__default.normalize;
declare const join: typeof path__default.join;
declare const resolve: typeof path__default.resolve;
/**
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
*
* @param path - The path to normalise.
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
* @returns the normalised path string.
*/
declare function normalizeString(path: string, allowAboveRoot: boolean): string;
declare const isAbsolute: typeof path__default.isAbsolute;
declare const toNamespacedPath: typeof path__default.toNamespacedPath;
declare const extname: typeof path__default.extname;
declare const relative: typeof path__default.relative;
declare const dirname: typeof path__default.dirname;
declare const format: typeof path__default.format;
declare const basename: typeof path__default.basename;
declare const parse: typeof path__default.parse;
/**
* The `path.matchesGlob()` method determines if `path` matches the `pattern`.
* @param path The path to glob-match against.
* @param pattern The glob to check the path against.
*/
declare const matchesGlob: (path: string, pattern: string | string[]) => boolean;
type NodePath = typeof path;
/**
* The platform-specific file delimiter.
*
* Equals to `";"` in windows and `":"` in all other platforms.
*/
declare const delimiter: ";" | ":";
declare const posix: NodePath["posix"];
declare const win32: NodePath["win32"];
declare const _default: NodePath;
export { basename, _default as default, delimiter, dirname, extname, format, isAbsolute, join, matchesGlob, normalize, normalizeString, parse, posix, relative, resolve, sep, toNamespacedPath, win32 };

View File

@@ -0,0 +1,47 @@
import * as path from 'node:path';
import path__default from 'node:path';
/**
* Constant for path separator.
*
* Always equals to `"/"`.
*/
declare const sep = "/";
declare const normalize: typeof path__default.normalize;
declare const join: typeof path__default.join;
declare const resolve: typeof path__default.resolve;
/**
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
*
* @param path - The path to normalise.
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
* @returns the normalised path string.
*/
declare function normalizeString(path: string, allowAboveRoot: boolean): string;
declare const isAbsolute: typeof path__default.isAbsolute;
declare const toNamespacedPath: typeof path__default.toNamespacedPath;
declare const extname: typeof path__default.extname;
declare const relative: typeof path__default.relative;
declare const dirname: typeof path__default.dirname;
declare const format: typeof path__default.format;
declare const basename: typeof path__default.basename;
declare const parse: typeof path__default.parse;
/**
* The `path.matchesGlob()` method determines if `path` matches the `pattern`.
* @param path The path to glob-match against.
* @param pattern The glob to check the path against.
*/
declare const matchesGlob: (path: string, pattern: string | string[]) => boolean;
type NodePath = typeof path;
/**
* The platform-specific file delimiter.
*
* Equals to `";"` in windows and `":"` in all other platforms.
*/
declare const delimiter: ";" | ":";
declare const posix: NodePath["posix"];
declare const win32: NodePath["win32"];
declare const _default: NodePath;
export { basename, _default as default, delimiter, dirname, extname, format, isAbsolute, join, matchesGlob, normalize, normalizeString, parse, posix, relative, resolve, sep, toNamespacedPath, win32 };

View File

@@ -0,0 +1,19 @@
import { _ as _path } from './shared/pathe.M-eThtNZ.mjs';
export { c as basename, d as dirname, e as extname, f as format, i as isAbsolute, j as join, m as matchesGlob, n as normalize, a as normalizeString, p as parse, b as relative, r as resolve, s as sep, t as toNamespacedPath } from './shared/pathe.M-eThtNZ.mjs';
const delimiter = /* @__PURE__ */ (() => globalThis.process?.platform === "win32" ? ";" : ":")();
const _platforms = { posix: void 0, win32: void 0 };
const mix = (del = delimiter) => {
return new Proxy(_path, {
get(_, prop) {
if (prop === "delimiter") return del;
if (prop === "posix") return posix;
if (prop === "win32") return win32;
return _platforms[prop] || _path[prop];
}
});
};
const posix = /* @__PURE__ */ mix(":");
const win32 = /* @__PURE__ */ mix(";");
export { posix as default, delimiter, posix, win32 };

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,82 @@
'use strict';
const _path = require('./shared/pathe.BSlhyZSM.cjs');
const pathSeparators = /* @__PURE__ */ new Set(["/", "\\", void 0]);
const normalizedAliasSymbol = Symbol.for("pathe:normalizedAlias");
const SLASH_RE = /[/\\]/;
function normalizeAliases(_aliases) {
if (_aliases[normalizedAliasSymbol]) {
return _aliases;
}
const aliases = Object.fromEntries(
Object.entries(_aliases).sort(([a], [b]) => _compareAliases(a, b))
);
for (const key in aliases) {
for (const alias in aliases) {
if (alias === key || key.startsWith(alias)) {
continue;
}
if (aliases[key]?.startsWith(alias) && pathSeparators.has(aliases[key][alias.length])) {
aliases[key] = aliases[alias] + aliases[key].slice(alias.length);
}
}
}
Object.defineProperty(aliases, normalizedAliasSymbol, {
value: true,
enumerable: false
});
return aliases;
}
function resolveAlias(path, aliases) {
const _path$1 = _path.normalizeWindowsPath(path);
aliases = normalizeAliases(aliases);
for (const [alias, to] of Object.entries(aliases)) {
if (!_path$1.startsWith(alias)) {
continue;
}
const _alias = hasTrailingSlash(alias) ? alias.slice(0, -1) : alias;
if (hasTrailingSlash(_path$1[_alias.length])) {
return _path.join(to, _path$1.slice(alias.length));
}
}
return _path$1;
}
function reverseResolveAlias(path, aliases) {
const _path$1 = _path.normalizeWindowsPath(path);
aliases = normalizeAliases(aliases);
const matches = [];
for (const [to, alias] of Object.entries(aliases)) {
if (!_path$1.startsWith(alias)) {
continue;
}
const _alias = hasTrailingSlash(alias) ? alias.slice(0, -1) : alias;
if (hasTrailingSlash(_path$1[_alias.length])) {
matches.push(_path.join(to, _path$1.slice(alias.length)));
}
}
return matches.sort((a, b) => b.length - a.length);
}
function filename(path) {
const base = path.split(SLASH_RE).pop();
if (!base) {
return void 0;
}
const separatorIndex = base.lastIndexOf(".");
if (separatorIndex <= 0) {
return base;
}
return base.slice(0, separatorIndex);
}
function _compareAliases(a, b) {
return b.split("/").length - a.split("/").length;
}
function hasTrailingSlash(path = "/") {
const lastChar = path[path.length - 1];
return lastChar === "/" || lastChar === "\\";
}
exports.filename = filename;
exports.normalizeAliases = normalizeAliases;
exports.resolveAlias = resolveAlias;
exports.reverseResolveAlias = reverseResolveAlias;

View File

@@ -0,0 +1,32 @@
/**
* Normalises alias mappings, ensuring that more specific aliases are resolved before less specific ones.
* This function also ensures that aliases do not resolve to themselves cyclically.
*
* @param _aliases - A set of alias mappings where each key is an alias and its value is the actual path it points to.
* @returns a set of normalised alias mappings.
*/
declare function normalizeAliases(_aliases: Record<string, string>): Record<string, string>;
/**
* Resolves a path string to its alias if applicable, otherwise returns the original path.
* This function normalises the path, resolves the alias and then joins it to the alias target if necessary.
*
* @param path - The path string to resolve.
* @param aliases - A set of alias mappings to use for resolution.
* @returns the resolved path as a string.
*/
declare function resolveAlias(path: string, aliases: Record<string, string>): string;
/**
* Resolves a path string to its possible alias.
*
* Returns an array of possible alias resolutions (could be empty), sorted by specificity (longest first).
*/
declare function reverseResolveAlias(path: string, aliases: Record<string, string>): string[];
/**
* Extracts the filename from a given path, excluding any directory paths and the file extension.
*
* @param path - The full path of the file from which to extract the filename.
* @returns the filename without the extension, or `undefined` if the filename cannot be extracted.
*/
declare function filename(path: string): string | undefined;
export { filename, normalizeAliases, resolveAlias, reverseResolveAlias };

View File

@@ -0,0 +1,32 @@
/**
* Normalises alias mappings, ensuring that more specific aliases are resolved before less specific ones.
* This function also ensures that aliases do not resolve to themselves cyclically.
*
* @param _aliases - A set of alias mappings where each key is an alias and its value is the actual path it points to.
* @returns a set of normalised alias mappings.
*/
declare function normalizeAliases(_aliases: Record<string, string>): Record<string, string>;
/**
* Resolves a path string to its alias if applicable, otherwise returns the original path.
* This function normalises the path, resolves the alias and then joins it to the alias target if necessary.
*
* @param path - The path string to resolve.
* @param aliases - A set of alias mappings to use for resolution.
* @returns the resolved path as a string.
*/
declare function resolveAlias(path: string, aliases: Record<string, string>): string;
/**
* Resolves a path string to its possible alias.
*
* Returns an array of possible alias resolutions (could be empty), sorted by specificity (longest first).
*/
declare function reverseResolveAlias(path: string, aliases: Record<string, string>): string[];
/**
* Extracts the filename from a given path, excluding any directory paths and the file extension.
*
* @param path - The full path of the file from which to extract the filename.
* @returns the filename without the extension, or `undefined` if the filename cannot be extracted.
*/
declare function filename(path: string): string | undefined;
export { filename, normalizeAliases, resolveAlias, reverseResolveAlias };

View File

@@ -0,0 +1,32 @@
/**
* Normalises alias mappings, ensuring that more specific aliases are resolved before less specific ones.
* This function also ensures that aliases do not resolve to themselves cyclically.
*
* @param _aliases - A set of alias mappings where each key is an alias and its value is the actual path it points to.
* @returns a set of normalised alias mappings.
*/
declare function normalizeAliases(_aliases: Record<string, string>): Record<string, string>;
/**
* Resolves a path string to its alias if applicable, otherwise returns the original path.
* This function normalises the path, resolves the alias and then joins it to the alias target if necessary.
*
* @param path - The path string to resolve.
* @param aliases - A set of alias mappings to use for resolution.
* @returns the resolved path as a string.
*/
declare function resolveAlias(path: string, aliases: Record<string, string>): string;
/**
* Resolves a path string to its possible alias.
*
* Returns an array of possible alias resolutions (could be empty), sorted by specificity (longest first).
*/
declare function reverseResolveAlias(path: string, aliases: Record<string, string>): string[];
/**
* Extracts the filename from a given path, excluding any directory paths and the file extension.
*
* @param path - The full path of the file from which to extract the filename.
* @returns the filename without the extension, or `undefined` if the filename cannot be extracted.
*/
declare function filename(path: string): string | undefined;
export { filename, normalizeAliases, resolveAlias, reverseResolveAlias };

View File

@@ -0,0 +1,77 @@
import { g as normalizeWindowsPath, j as join } from './shared/pathe.M-eThtNZ.mjs';
const pathSeparators = /* @__PURE__ */ new Set(["/", "\\", void 0]);
const normalizedAliasSymbol = Symbol.for("pathe:normalizedAlias");
const SLASH_RE = /[/\\]/;
function normalizeAliases(_aliases) {
if (_aliases[normalizedAliasSymbol]) {
return _aliases;
}
const aliases = Object.fromEntries(
Object.entries(_aliases).sort(([a], [b]) => _compareAliases(a, b))
);
for (const key in aliases) {
for (const alias in aliases) {
if (alias === key || key.startsWith(alias)) {
continue;
}
if (aliases[key]?.startsWith(alias) && pathSeparators.has(aliases[key][alias.length])) {
aliases[key] = aliases[alias] + aliases[key].slice(alias.length);
}
}
}
Object.defineProperty(aliases, normalizedAliasSymbol, {
value: true,
enumerable: false
});
return aliases;
}
function resolveAlias(path, aliases) {
const _path = normalizeWindowsPath(path);
aliases = normalizeAliases(aliases);
for (const [alias, to] of Object.entries(aliases)) {
if (!_path.startsWith(alias)) {
continue;
}
const _alias = hasTrailingSlash(alias) ? alias.slice(0, -1) : alias;
if (hasTrailingSlash(_path[_alias.length])) {
return join(to, _path.slice(alias.length));
}
}
return _path;
}
function reverseResolveAlias(path, aliases) {
const _path = normalizeWindowsPath(path);
aliases = normalizeAliases(aliases);
const matches = [];
for (const [to, alias] of Object.entries(aliases)) {
if (!_path.startsWith(alias)) {
continue;
}
const _alias = hasTrailingSlash(alias) ? alias.slice(0, -1) : alias;
if (hasTrailingSlash(_path[_alias.length])) {
matches.push(join(to, _path.slice(alias.length)));
}
}
return matches.sort((a, b) => b.length - a.length);
}
function filename(path) {
const base = path.split(SLASH_RE).pop();
if (!base) {
return void 0;
}
const separatorIndex = base.lastIndexOf(".");
if (separatorIndex <= 0) {
return base;
}
return base.slice(0, separatorIndex);
}
function _compareAliases(a, b) {
return b.split("/").length - a.split("/").length;
}
function hasTrailingSlash(path = "/") {
const lastChar = path[path.length - 1];
return lastChar === "/" || lastChar === "\\";
}
export { filename, normalizeAliases, resolveAlias, reverseResolveAlias };

View File

@@ -0,0 +1,61 @@
{
"name": "pathe",
"version": "2.0.3",
"description": "Universal filesystem path utils",
"repository": "unjs/pathe",
"license": "MIT",
"sideEffects": false,
"type": "module",
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./utils": {
"import": {
"types": "./dist/utils.d.mts",
"default": "./dist/utils.mjs"
},
"require": {
"types": "./dist/utils.d.cts",
"default": "./dist/utils.cjs"
}
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist",
"utils.d.ts"
],
"devDependencies": {
"@types/node": "^22.13.1",
"@vitest/coverage-v8": "^3.0.5",
"changelogen": "^0.5.7",
"esbuild": "^0.25.0",
"eslint": "^9.20.1",
"eslint-config-unjs": "^0.4.2",
"jiti": "^2.4.2",
"prettier": "^3.5.0",
"typescript": "^5.7.3",
"unbuild": "^3.3.1",
"vitest": "^3.0.5",
"zeptomatch": "^2.0.0"
},
"scripts": {
"build": "unbuild",
"dev": "vitest",
"lint": "eslint . && prettier -c src test",
"lint:fix": "eslint . --fix && prettier -w src test",
"release": "pnpm test && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
"test": "pnpm lint && vitest run --coverage",
"test:types": "tsc --noEmit"
}
}

View File

@@ -0,0 +1 @@
export * from "./dist/utils";

65
node_modules/@nuxt/nitro-server/package.json generated vendored Normal file
View File

@@ -0,0 +1,65 @@
{
"name": "@nuxt/nitro-server",
"version": "4.3.1",
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt/nuxt.git",
"directory": "packages/nitro-server"
},
"description": "Nitro server integration for Nuxt",
"homepage": "https://nuxt.com",
"license": "MIT",
"type": "module",
"types": "./dist/index.d.mts",
"exports": {
".": "./dist/index.mjs"
},
"files": [
"dist"
],
"dependencies": {
"@nuxt/devalue": "^2.0.2",
"@unhead/vue": "^2.1.3",
"@vue/shared": "^3.5.27",
"consola": "^3.4.2",
"defu": "^6.1.4",
"destr": "^2.0.5",
"devalue": "^5.6.2",
"errx": "^0.1.0",
"escape-string-regexp": "^5.0.0",
"exsolve": "^1.0.8",
"h3": "^1.15.5",
"impound": "^1.0.0",
"klona": "^2.0.6",
"mocked-exports": "^0.1.1",
"nitropack": "^2.13.1",
"ohash": "^2.0.11",
"pathe": "^2.0.3",
"pkg-types": "^2.3.0",
"rou3": "^0.7.12",
"std-env": "^3.10.0",
"ufo": "^1.6.3",
"unctx": "^2.5.0",
"unstorage": "^1.17.4",
"vue": "^3.5.27",
"vue-bundle-renderer": "^2.2.0",
"vue-devtools-stub": "^0.1.0",
"@nuxt/kit": "4.3.1"
},
"peerDependencies": {
"nuxt": "^4.3.1"
},
"devDependencies": {
"obuild": "0.4.27",
"vitest": "4.0.18",
"@nuxt/schema": "4.3.1",
"nuxt": "4.3.1"
},
"engines": {
"node": "^20.19.0 || >=22.12.0"
},
"scripts": {
"build:stub": "obuild --stub",
"test:attw": "attw --pack"
}
}