nuxtseo-shared 5.3.15 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/brand.d.mts +140 -0
- package/dist/brand.d.ts +140 -0
- package/dist/brand.mjs +353 -0
- package/dist/checklist.d.mts +69 -0
- package/dist/checklist.d.ts +69 -0
- package/dist/checklist.mjs +354 -0
- package/dist/const.d.mts +1 -3
- package/dist/const.d.ts +1 -3
- package/dist/const.mjs +5 -7
- package/dist/devtools.d.mts +11 -14
- package/dist/devtools.d.ts +11 -14
- package/dist/devtools.mjs +73 -385
- package/dist/fetch.d.mts +7 -0
- package/dist/fetch.d.ts +7 -0
- package/dist/fetch.mjs +15 -0
- package/dist/i18n.mjs +26 -3
- package/dist/kit.d.mts +17 -17
- package/dist/kit.d.ts +17 -17
- package/dist/kit.mjs +119 -54
- package/dist/module.d.mts +1 -0
- package/dist/module.d.ts +1 -0
- package/dist/module.json +2 -2
- package/dist/module.mjs +4 -4
- package/dist/prerender.d.mts +22 -0
- package/dist/prerender.d.ts +22 -0
- package/dist/prerender.mjs +74 -0
- package/dist/pro.mjs +8 -7
- package/package.json +37 -25
package/dist/devtools.mjs
CHANGED
|
@@ -1,402 +1,90 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import {
|
|
3
|
-
import { createRequire } from 'node:module';
|
|
4
|
-
import { join
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import { useNuxt } from '@nuxt/kit';
|
|
8
|
-
import { detectPackageManager } from 'nypm';
|
|
9
|
-
import sirv from 'sirv';
|
|
10
|
-
import { modules } from './const.mjs';
|
|
11
|
-
import { detectNuxtSeoModules } from './kit.mjs';
|
|
12
|
-
import 'node:url';
|
|
13
|
-
import 'pathe';
|
|
14
|
-
import 'pkg-types';
|
|
15
|
-
import 'std-env';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { createRequire, findPackageJSON } from 'node:module';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
6
|
+
import { useNuxt, useLogger, getAddDependencyCommand } from '@nuxt/kit';
|
|
16
7
|
|
|
17
|
-
function npmForSlug(slug) {
|
|
18
|
-
return modules.find((m) => m.slug === slug)?.npm;
|
|
19
|
-
}
|
|
20
8
|
const UNIFIED_CLIENT_ROUTE = "/__nuxt-seo-devtools";
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<style>html,body{margin:0;height:100%;font-family:'Hubot Sans',system-ui,sans-serif;background:oklch(98.4% 0.005 292);color:oklch(16% 0.036 292)}@media(prefers-color-scheme:dark){html,body{background:oklch(11% 0.029 292);color:oklch(96.8% 0.009 292)}}.wrap{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:24px;text-align:center}.spin{width:34px;height:34px;border-radius:50%;border:3px solid color-mix(in oklab,oklch(54% 0.225 292) 25%,transparent);border-top-color:oklch(54% 0.225 292);animation:s .8s linear infinite}@keyframes s{to{transform:rotate(360deg)}}h1{font-size:15px;font-weight:600;margin:0}p{font-size:13px;opacity:.6;margin:0;max-width:440px}.mods{display:flex;flex-wrap:wrap;gap:6px;justify-content:center;max-width:420px}.chip{font-size:11px;padding:2px 9px;border-radius:999px;background:color-mix(in oklab,oklch(54% 0.225 292) 14%,transparent);color:oklch(54% 0.225 292)}.btn{font:inherit;font-size:13px;font-weight:600;padding:7px 16px;border-radius:8px;border:0;background:oklch(54% 0.225 292);color:#fff;cursor:pointer}.btn:hover{background:oklch(49% 0.225 292)}.btn:disabled{opacity:.6;cursor:default}.hide{display:none}.step{font-size:12px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;opacity:.55;max-width:520px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-height:16px}.t{font-variant-numeric:tabular-nums;opacity:.85}.err .spin{border-top-color:oklch(60% 0.2 25);border-color:color-mix(in oklab,oklch(60% 0.2 25) 25%,transparent);animation:none}</style></head>
|
|
26
|
-
<body><div class="wrap" id="wrap"><div class="spin" id="spin"></div><h1 id="title">Nuxt SEO DevTools</h1><div class="mods" id="mods"></div><p id="desc">Starting\u2026</p><button class="btn hide" id="install">Install</button><div class="step" id="step"></div></div>
|
|
27
|
-
<script>
|
|
28
|
-
const $=id=>document.getElementById(id)
|
|
29
|
-
const esc=s=>(s||'').replace(/[<>&]/g,c=>({'<':'<','>':'>','&':'&'}[c]))
|
|
30
|
-
let mods=false,clicked=false
|
|
31
|
-
$('install').addEventListener('click',async()=>{
|
|
32
|
-
clicked=true
|
|
33
|
-
$('install').disabled=true;$('install').classList.add('hide')
|
|
34
|
-
$('spin').classList.remove('hide')
|
|
35
|
-
$('title').textContent='Installing\u2026'
|
|
36
|
-
$('desc').textContent='Adding the dev-only DevTools UI to your project.'
|
|
37
|
-
try{await fetch('${UNIFIED_CLIENT_ROUTE}/__install')}catch{}
|
|
38
|
-
})
|
|
39
|
-
async function poll(){
|
|
40
|
-
try{
|
|
41
|
-
const j=await (await fetch('${UNIFIED_CLIENT_ROUTE}/__status')).json()
|
|
42
|
-
if(j.ready){location.reload();return}
|
|
43
|
-
if(!mods&&Array.isArray(j.modules)&&j.modules.length){mods=true;$('mods').innerHTML=j.modules.map(m=>'<span class="chip">'+esc(m)+'</span>').join('')}
|
|
44
|
-
if(j.failed){$('wrap').classList.add('err');$('spin').classList.remove('hide');$('install').classList.add('hide');$('title').textContent='DevTools unavailable';$('desc').textContent='';$('step').textContent=j.step||'';return}
|
|
45
|
-
if(j.needsInstall&&!clicked){
|
|
46
|
-
const pkg=j.packageName||'nuxtseo-devtools'
|
|
47
|
-
$('spin').classList.add('hide')
|
|
48
|
-
$('install').classList.remove('hide');$('install').disabled=false;$('install').textContent='Install '+pkg
|
|
49
|
-
$('title').textContent='Nuxt SEO DevTools'
|
|
50
|
-
$('desc').textContent='The panel needs '+pkg+' (dev only). Installing it adds the package to your devDependencies; nothing is changed until you choose to install.'
|
|
51
|
-
$('step').textContent=''
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
$('spin').classList.remove('hide');$('install').classList.add('hide')
|
|
55
|
-
$('title').textContent=j.installing?'Installing\u2026':'Building Nuxt SEO DevTools\u2026'
|
|
56
|
-
$('desc').textContent=j.installing?'Adding the dev-only DevTools UI to your project.':'Assembling panels for your installed modules. This runs once.'
|
|
57
|
-
const t=j.elapsed?' \xB7 <span class="t">'+Math.round(j.elapsed/1000)+'s</span>':''
|
|
58
|
-
$('step').innerHTML=esc(j.step)+t
|
|
59
|
-
}catch{}
|
|
60
|
-
}
|
|
61
|
-
setInterval(poll,800);poll()
|
|
62
|
-
<\/script></body></html>`;
|
|
63
|
-
}
|
|
64
|
-
function deriveRoutes(layerDir, slug) {
|
|
65
|
-
const routes = [`/${slug}`];
|
|
66
|
-
const pagesDir = join(layerDir, "pages", slug);
|
|
67
|
-
if (existsSync(pagesDir)) {
|
|
68
|
-
for (const f of readdirSync(pagesDir)) {
|
|
69
|
-
if (f.endsWith(".vue") && f !== "index.vue")
|
|
70
|
-
routes.push(`/${slug}/${f.slice(0, -4)}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return routes;
|
|
74
|
-
}
|
|
75
|
-
function registerSharedRpcOnce(nuxt) {
|
|
76
|
-
if (nuxt._seoDevtoolsRpcRegistered)
|
|
77
|
-
return;
|
|
78
|
-
nuxt._seoDevtoolsRpcRegistered = true;
|
|
79
|
-
onDevToolsInitialized(() => {
|
|
80
|
-
extendServerRpc("nuxt-seo-modules", {
|
|
81
|
-
// Registered modules (those that shipped a devtools panel) carry the iframe route.
|
|
82
|
-
// detectNuxtSeoModules adds every *installed* SEO module from nuxt's module list —
|
|
83
|
-
// independent of whether it self-registered a panel or which shared version it ships —
|
|
84
|
-
// so the picker reflects the full install (e.g. site-config, which has no panel).
|
|
85
|
-
getInstalledSeoModules: () => {
|
|
86
|
-
const byNpm = /* @__PURE__ */ new Map();
|
|
87
|
-
for (const m of nuxt._seoDevtoolsModules || []) {
|
|
88
|
-
if (m.npm)
|
|
89
|
-
byNpm.set(m.npm, m);
|
|
90
|
-
}
|
|
91
|
-
for (const det of detectNuxtSeoModules(nuxt)) {
|
|
92
|
-
if (!byNpm.has(det.name)) {
|
|
93
|
-
const meta = modules.find((s) => s.npm === det.name);
|
|
94
|
-
byNpm.set(det.name, { name: meta?.slug ?? det.name, npm: det.name, title: meta?.label ?? det.name, icon: meta?.icon ?? "", route: "" });
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return [...byNpm.values()];
|
|
98
|
-
}
|
|
99
|
-
}, nuxt);
|
|
100
|
-
}, nuxt);
|
|
101
|
-
}
|
|
102
|
-
function resolveBaseLayer(installed) {
|
|
103
|
-
for (const m of installed) {
|
|
104
|
-
try {
|
|
105
|
-
return dirname(createRequire(join(m.layerDir, "index.js")).resolve("nuxtseo-layer-devtools"));
|
|
106
|
-
} catch {
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
console.warn("[nuxt-seo] could not resolve nuxtseo-layer-devtools from any installed SEO module \u2014 add it to the module's dependencies. Falling back to a bare specifier, which only works when your app installs it directly.");
|
|
110
|
-
return "nuxtseo-layer-devtools";
|
|
111
|
-
}
|
|
112
|
-
function resolveNuxtCli(rootDir) {
|
|
113
|
-
const bases = [process.argv[1], join(rootDir, "index.js")].filter(Boolean);
|
|
114
|
-
for (const base of bases) {
|
|
115
|
-
let req;
|
|
116
|
-
try {
|
|
117
|
-
req = createRequire(base);
|
|
118
|
-
} catch {
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
for (const spec of ["nuxi", "nuxt", "@nuxt/cli"]) {
|
|
122
|
-
try {
|
|
123
|
-
const pkgPath = req.resolve(`${spec}/package.json`);
|
|
124
|
-
const bin = JSON.parse(readFileSync(pkgPath, "utf8")).bin;
|
|
125
|
-
const rel = typeof bin === "string" ? bin : bin?.nuxi ?? bin?.nuxt;
|
|
126
|
-
if (rel)
|
|
127
|
-
return join(dirname(pkgPath), rel);
|
|
128
|
-
} catch {
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
const stripAnsi = (s) => s.replace(new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g"), "");
|
|
135
|
-
function toolchainInstalled(rootDir) {
|
|
9
|
+
const HOST_PACKAGE = "nuxtseo-devtools-host@1.0.0";
|
|
10
|
+
function loadHost(nuxt) {
|
|
11
|
+
const require = createRequire(join(nuxt.options.rootDir, "package.json"));
|
|
12
|
+
let entry;
|
|
136
13
|
try {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const pm = await detectPackageManager(rootDir).catch((error) => {
|
|
145
|
-
console.warn(`[nuxt-seo] could not detect the package manager in "${rootDir}", falling back to npm:`, error);
|
|
146
|
-
return null;
|
|
147
|
-
});
|
|
148
|
-
const name = pm?.name ?? "npm";
|
|
149
|
-
if (name === "npm")
|
|
150
|
-
return { command: "npm", args: ["install", "--save-dev", TOOLCHAIN_PACKAGE] };
|
|
151
|
-
if (name === "yarn")
|
|
152
|
-
return { command: "yarn", args: ["add", "--dev", TOOLCHAIN_PACKAGE] };
|
|
153
|
-
return { command: name, args: ["add", "-D", TOOLCHAIN_PACKAGE] };
|
|
154
|
-
}
|
|
155
|
-
async function installToolchain(rootDir, nuxt, onProgress) {
|
|
156
|
-
const { command, args } = await devAddArgs(rootDir);
|
|
157
|
-
onProgress(`Installing ${TOOLCHAIN_PACKAGE} with ${command}\u2026`);
|
|
158
|
-
return await new Promise((resolve) => {
|
|
159
|
-
const { getProcess } = startSubprocess(
|
|
160
|
-
{ command, args, cwd: rootDir },
|
|
161
|
-
{ id: "nuxt-seo:install-devtools", name: `Install ${TOOLCHAIN_PACKAGE}`, icon: "carbon:download" },
|
|
162
|
-
nuxt
|
|
163
|
-
);
|
|
164
|
-
const proc = getProcess();
|
|
165
|
-
if (!proc) {
|
|
166
|
-
resolve(false);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
proc.on("exit", (code) => resolve(code === 0 && toolchainInstalled(rootDir)));
|
|
170
|
-
proc.on("error", (err) => {
|
|
171
|
-
console.error(`[nuxt-seo] could not run "${command} ${args.join(" ")}": ${err.message}`);
|
|
172
|
-
resolve(false);
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
function generateAndBuild(cacheDir, rootDir, installed, hooks) {
|
|
177
|
-
const routes = ["/", ...installed.flatMap((m) => deriveRoutes(m.layerDir, m.slug))];
|
|
178
|
-
const extendsList = [resolveBaseLayer(installed), ...installed.map((m) => m.layerDir)];
|
|
179
|
-
mkdirSync(join(cacheDir, "pages"), { recursive: true });
|
|
180
|
-
writeFileSync(join(cacheDir, "nuxt.config.ts"), `export default defineNuxtConfig({
|
|
181
|
-
extends: ${JSON.stringify(extendsList, null, 2)},
|
|
182
|
-
ssr: false,
|
|
183
|
-
robots: false,
|
|
184
|
-
content: false,
|
|
185
|
-
sitemap: false,
|
|
186
|
-
nitro: { prerender: { routes: ${JSON.stringify(routes)} }, output: { publicDir: ${JSON.stringify(join(cacheDir, "dist/devtools"))} } },
|
|
187
|
-
app: { baseURL: '${UNIFIED_CLIENT_ROUTE}' },
|
|
188
|
-
compatibilityDate: '2026-03-13',
|
|
189
|
-
})
|
|
190
|
-
`);
|
|
191
|
-
writeFileSync(join(cacheDir, "app.vue"), `<template><NuxtPage /></template>
|
|
192
|
-
`);
|
|
193
|
-
writeFileSync(join(cacheDir, "pages/index.vue"), `<template><div class="p-4">${installed.map((m) => `<NuxtLink to="/${m.slug}" class="block underline">${m.title}</NuxtLink>`).join("")}</div></template>
|
|
194
|
-
`);
|
|
195
|
-
console.log(`[nuxt-seo] building devtools client for: ${installed.map((m) => m.slug).join(", ")}`);
|
|
196
|
-
const cliBin = resolveNuxtCli(rootDir);
|
|
197
|
-
const child = cliBin ? spawn(process.execPath, [cliBin, "build"], { cwd: cacheDir, stdio: ["inherit", "pipe", "pipe"] }) : spawn("npx", ["nuxi", "build"], { cwd: cacheDir, stdio: ["inherit", "pipe", "pipe"], shell: true });
|
|
198
|
-
const statusLine = /^(?:[ℹ✔✓✨⚠✖✗●➜√]|\[\w)/;
|
|
199
|
-
const buffered = [];
|
|
200
|
-
let drawing = false;
|
|
201
|
-
const capture = (chunk) => {
|
|
202
|
-
buffered.push(chunk);
|
|
203
|
-
const step = stripAnsi(chunk.toString()).split("\n").map((l) => l.trim()).filter((l) => statusLine.test(l)).pop();
|
|
204
|
-
if (step) {
|
|
205
|
-
hooks.onProgress(step);
|
|
206
|
-
process.stdout.write(`\r\x1B[2K[nuxt-seo] ${step}`);
|
|
207
|
-
drawing = true;
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
const endLine = () => {
|
|
211
|
-
if (drawing) {
|
|
212
|
-
process.stdout.write("\n");
|
|
213
|
-
drawing = false;
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
child.stdout?.on("data", capture);
|
|
217
|
-
child.stderr?.on("data", capture);
|
|
218
|
-
child.on("error", (err) => {
|
|
219
|
-
endLine();
|
|
220
|
-
console.error(`[nuxt-seo] could not build devtools client, the panel will stay unavailable: ${err.message}`);
|
|
221
|
-
hooks.onError();
|
|
222
|
-
});
|
|
223
|
-
child.on("exit", (code) => {
|
|
224
|
-
endLine();
|
|
225
|
-
if (code === 0) {
|
|
226
|
-
writeFileSync(join(cacheDir, ".installed-hash"), hashSet(installed.map((m) => m.slug).sort()));
|
|
227
|
-
hooks.onReady();
|
|
228
|
-
console.log("[nuxt-seo] devtools client ready");
|
|
229
|
-
} else {
|
|
230
|
-
process.stderr.write(Buffer.concat(buffered));
|
|
231
|
-
console.error(`[nuxt-seo] devtools client build exited with code ${code}, the panel will stay unavailable`);
|
|
232
|
-
hooks.onError();
|
|
14
|
+
const metadataPath = findPackageJSON("nuxtseo-devtools-host", pathToFileURL(join(nuxt.options.rootDir, "package.json")));
|
|
15
|
+
if (!metadataPath)
|
|
16
|
+
return void 0;
|
|
17
|
+
const metadata = JSON.parse(readFileSync(metadataPath, "utf8"));
|
|
18
|
+
if (!metadata || typeof metadata !== "object" || !("version" in metadata) || typeof metadata.version !== "string" || !metadata.version.startsWith("1.")) {
|
|
19
|
+
useLogger("nuxt-seo").warn(`Install ${HOST_PACKAGE} to use this DevTools integration.`);
|
|
20
|
+
return void 0;
|
|
233
21
|
}
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const modules = nuxt._seoDevtoolsModules ??= [];
|
|
240
|
-
modules.push({ name: config.name, npm: npmForSlug(slug), title: config.title, icon: config.icon, route: clientRoute });
|
|
241
|
-
const layers = nuxt._seoDevtoolsLayers ??= [];
|
|
242
|
-
layers.push({ slug, name: config.name, title: config.title, icon: config.icon, layerDir });
|
|
243
|
-
addCustomTab({ name: `nuxt-seo-${slug}`, title: config.title, icon: config.icon, view: { type: "iframe", src: clientRoute } });
|
|
244
|
-
if (nuxt._seoDevtoolsInit)
|
|
245
|
-
return;
|
|
246
|
-
nuxt._seoDevtoolsInit = true;
|
|
247
|
-
const cacheDir = join(nuxt.options.rootDir, "node_modules/.cache/nuxt-seo-devtools");
|
|
248
|
-
const dist = join(cacheDir, "dist/devtools");
|
|
249
|
-
const state = { ready: false, building: false, installing: false, needsInstall: false, failed: false, startedAt: 0, step: "", modules: [] };
|
|
250
|
-
const rootDir = nuxt.options.rootDir;
|
|
251
|
-
function ensureBuilt() {
|
|
252
|
-
if (state.ready || state.building)
|
|
253
|
-
return;
|
|
254
|
-
state.building = true;
|
|
255
|
-
state.failed = false;
|
|
256
|
-
state.startedAt = Date.now();
|
|
257
|
-
state.step = "Starting build\u2026";
|
|
258
|
-
const installed = nuxt._seoDevtoolsLayers;
|
|
259
|
-
state.modules = installed.map((m) => m.title);
|
|
260
|
-
generateAndBuild(cacheDir, rootDir, installed, {
|
|
261
|
-
onProgress: (step) => {
|
|
262
|
-
state.step = step;
|
|
263
|
-
},
|
|
264
|
-
onReady: () => {
|
|
265
|
-
state.ready = true;
|
|
266
|
-
state.building = false;
|
|
267
|
-
},
|
|
268
|
-
onError: (message) => {
|
|
269
|
-
state.building = false;
|
|
270
|
-
state.failed = true;
|
|
271
|
-
state.step = message ?? "Build failed, see the dev server logs";
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
function startInstall() {
|
|
276
|
-
if (state.installing || state.building || state.ready)
|
|
277
|
-
return;
|
|
278
|
-
state.installing = true;
|
|
279
|
-
state.needsInstall = false;
|
|
280
|
-
state.failed = false;
|
|
281
|
-
state.startedAt = Date.now();
|
|
282
|
-
state.step = `Installing ${TOOLCHAIN_PACKAGE}\u2026`;
|
|
283
|
-
installToolchain(rootDir, nuxt, (step) => {
|
|
284
|
-
state.step = step;
|
|
285
|
-
}).then((ok) => {
|
|
286
|
-
state.installing = false;
|
|
287
|
-
if (ok) {
|
|
288
|
-
ensureBuilt();
|
|
289
|
-
} else {
|
|
290
|
-
state.failed = true;
|
|
291
|
-
state.step = `Could not install ${TOOLCHAIN_PACKAGE} \u2014 see the dev server logs`;
|
|
292
|
-
}
|
|
293
|
-
}).catch((err) => {
|
|
294
|
-
state.installing = false;
|
|
295
|
-
state.failed = true;
|
|
296
|
-
state.step = `Could not install ${TOOLCHAIN_PACKAGE} \u2014 see the dev server logs`;
|
|
297
|
-
console.error(`[nuxt-seo] devtools toolchain install failed: ${err.message}`);
|
|
298
|
-
});
|
|
22
|
+
entry = require.resolve("nuxtseo-devtools-host");
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error && typeof error === "object" && "code" in error && (error.code === "MODULE_NOT_FOUND" || error.code === "ERR_MODULE_NOT_FOUND"))
|
|
25
|
+
return void 0;
|
|
26
|
+
throw error;
|
|
299
27
|
}
|
|
300
|
-
|
|
301
|
-
const installed = nuxt._seoDevtoolsLayers;
|
|
302
|
-
const key = hashSet(installed.map((m) => m.slug).sort());
|
|
303
|
-
state.ready = existsSync(join(cacheDir, ".installed-hash")) && readFileSync(join(cacheDir, ".installed-hash"), "utf8") === key && existsSync(dist);
|
|
304
|
-
});
|
|
305
|
-
nuxt.hook("vite:serverCreated", (server) => {
|
|
306
|
-
const serve = sirv(dist, { dev: true, single: "200.html" });
|
|
307
|
-
server.middlewares.use(UNIFIED_CLIENT_ROUTE, (req, res, next) => {
|
|
308
|
-
const url = req.url || "/";
|
|
309
|
-
if (url.startsWith("/__install")) {
|
|
310
|
-
startInstall();
|
|
311
|
-
res.setHeader("content-type", "application/json");
|
|
312
|
-
return res.end(JSON.stringify({ installing: state.installing }));
|
|
313
|
-
}
|
|
314
|
-
if (url.startsWith("/__status")) {
|
|
315
|
-
if (!state.ready && !state.building && !state.installing) {
|
|
316
|
-
if (toolchainInstalled(rootDir))
|
|
317
|
-
ensureBuilt();
|
|
318
|
-
else
|
|
319
|
-
state.needsInstall = true;
|
|
320
|
-
}
|
|
321
|
-
res.setHeader("content-type", "application/json");
|
|
322
|
-
return res.end(JSON.stringify({
|
|
323
|
-
ready: state.ready,
|
|
324
|
-
failed: state.failed,
|
|
325
|
-
needsInstall: state.needsInstall,
|
|
326
|
-
installing: state.installing,
|
|
327
|
-
packageName: TOOLCHAIN_PACKAGE,
|
|
328
|
-
step: state.step,
|
|
329
|
-
modules: state.modules,
|
|
330
|
-
elapsed: state.startedAt ? Date.now() - state.startedAt : 0
|
|
331
|
-
}));
|
|
332
|
-
}
|
|
333
|
-
if (!state.ready) {
|
|
334
|
-
res.setHeader("content-type", "text/html");
|
|
335
|
-
return res.end(placeholderHtml());
|
|
336
|
-
}
|
|
337
|
-
return serve(req, res, next);
|
|
338
|
-
});
|
|
339
|
-
});
|
|
28
|
+
return require(entry);
|
|
340
29
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
nuxt.hook("vite:extendConfig", (viteConfig) => {
|
|
354
|
-
Object.assign(viteConfig, {
|
|
355
|
-
server: {
|
|
356
|
-
...viteConfig.server,
|
|
357
|
-
proxy: {
|
|
358
|
-
...viteConfig.server?.proxy,
|
|
359
|
-
[route]: {
|
|
360
|
-
target: `http://localhost:${devPort}${route}`,
|
|
361
|
-
changeOrigin: true,
|
|
362
|
-
followRedirects: true,
|
|
363
|
-
ws: true,
|
|
364
|
-
rewrite: (p) => p.replace(route, ""),
|
|
365
|
-
configure: (proxy) => {
|
|
366
|
-
proxy.on("error", (err, _req, res) => {
|
|
367
|
-
if (res.headersSent)
|
|
368
|
-
return;
|
|
369
|
-
res.writeHead(502, { "Content-Type": "text/plain" });
|
|
370
|
-
res.end(`Devtools client not ready: ${err.message}`);
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
30
|
+
const installs = /* @__PURE__ */ new WeakMap();
|
|
31
|
+
async function installHost(nuxt) {
|
|
32
|
+
const pending = installs.get(nuxt);
|
|
33
|
+
if (pending)
|
|
34
|
+
return pending;
|
|
35
|
+
const operation = (async () => {
|
|
36
|
+
const command = await getAddDependencyCommand(HOST_PACKAGE, nuxt.options.rootDir, { dev: true });
|
|
37
|
+
const [executable, ...args] = command.split(" ");
|
|
38
|
+
await new Promise((resolve, reject) => {
|
|
39
|
+
const child = spawn(executable, args, { cwd: nuxt.options.rootDir, stdio: "inherit" });
|
|
40
|
+
const unhook = nuxt.hook("close", () => {
|
|
41
|
+
child.kill();
|
|
376
42
|
});
|
|
43
|
+
child.once("close", unhook);
|
|
44
|
+
child.once("error", reject);
|
|
45
|
+
child.once("exit", (code) => code === 0 ? resolve() : reject(new Error(`DevTools package installation failed with exit code ${code}.`)));
|
|
377
46
|
});
|
|
47
|
+
})();
|
|
48
|
+
installs.set(nuxt, operation);
|
|
49
|
+
try {
|
|
50
|
+
await operation;
|
|
51
|
+
} finally {
|
|
52
|
+
installs.delete(nuxt);
|
|
378
53
|
}
|
|
379
|
-
addCustomTab({ name, title, icon, view: { type: "iframe", src: route } });
|
|
380
54
|
}
|
|
381
55
|
function setupDevToolsUI(config, resolve, nuxt = useNuxt()) {
|
|
382
|
-
if (!nuxt.options.dev)
|
|
56
|
+
if (!nuxt.options.dev || nuxt.options.devtools === false || typeof nuxt.options.devtools === "object" && nuxt.options.devtools.enabled === false)
|
|
383
57
|
return;
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
58
|
+
const host = loadHost(nuxt);
|
|
59
|
+
if (host) {
|
|
60
|
+
host.setupDevToolsUI(config, resolve, nuxt);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
let installed = false;
|
|
64
|
+
let pending = false;
|
|
65
|
+
let failure;
|
|
66
|
+
const hook = nuxt.hook;
|
|
67
|
+
hook("devtools:customTabs", (tabs) => {
|
|
68
|
+
tabs.push({ name: `nuxt-seo-${config.slug ?? config.name}`, title: config.title, icon: config.icon, view: { type: "launch", description: installed ? "Restart the Nuxt dev server to load Nuxt SEO DevTools." : failure ?? `Install ${HOST_PACKAGE} as a development dependency to open this panel.`, actions: installed ? [] : [{ label: `Install ${HOST_PACKAGE}`, pending, handle: async () => {
|
|
69
|
+
pending = true;
|
|
70
|
+
failure = void 0;
|
|
71
|
+
try {
|
|
72
|
+
await installHost(nuxt);
|
|
73
|
+
installed = true;
|
|
74
|
+
} catch (error) {
|
|
75
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
76
|
+
failure = `Installation failed: ${message} Choose Install to retry.`;
|
|
77
|
+
throw error;
|
|
78
|
+
} finally {
|
|
79
|
+
pending = false;
|
|
80
|
+
}
|
|
81
|
+
} }] } });
|
|
399
82
|
});
|
|
400
83
|
}
|
|
84
|
+
function setupDevToolsRpc(namespace, functions, nuxt = useNuxt()) {
|
|
85
|
+
if (!nuxt.options.dev || nuxt.options.devtools === false || typeof nuxt.options.devtools === "object" && nuxt.options.devtools.enabled === false)
|
|
86
|
+
return Promise.resolve(void 0);
|
|
87
|
+
return loadHost(nuxt)?.setupDevToolsRpc(namespace, functions, nuxt) ?? Promise.resolve(void 0);
|
|
88
|
+
}
|
|
401
89
|
|
|
402
90
|
export { UNIFIED_CLIENT_ROUTE, setupDevToolsRpc, setupDevToolsUI };
|
package/dist/fetch.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequestEvent } from 'nuxt/schema';
|
|
2
|
+
import { FetchRequest, FetchOptions } from 'ofetch';
|
|
3
|
+
|
|
4
|
+
/** Preserve ofetch options while using Nuxt's in-process transport for local app routes. */
|
|
5
|
+
declare function fetchWithEvent<T>(event: Pick<RequestEvent, 'req' | 'context'>, request: FetchRequest, options?: FetchOptions): Promise<T>;
|
|
6
|
+
|
|
7
|
+
export { fetchWithEvent };
|
package/dist/fetch.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequestEvent } from 'nuxt/schema';
|
|
2
|
+
import { FetchRequest, FetchOptions } from 'ofetch';
|
|
3
|
+
|
|
4
|
+
/** Preserve ofetch options while using Nuxt's in-process transport for local app routes. */
|
|
5
|
+
declare function fetchWithEvent<T>(event: Pick<RequestEvent, 'req' | 'context'>, request: FetchRequest, options?: FetchOptions): Promise<T>;
|
|
6
|
+
|
|
7
|
+
export { fetchWithEvent };
|
package/dist/fetch.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { serverFetch } from 'nuxt/server';
|
|
2
|
+
import { createFetch } from 'ofetch';
|
|
3
|
+
|
|
4
|
+
function fetchWithEvent(event, request, options) {
|
|
5
|
+
const client = createFetch({
|
|
6
|
+
fetch: (input, init) => {
|
|
7
|
+
if (typeof input === "string" && input.startsWith("//"))
|
|
8
|
+
return globalThis.fetch(new URL(input, event.req.url).href, init);
|
|
9
|
+
return typeof input === "string" && input.startsWith("/") ? serverFetch(event, input, init) : globalThis.fetch(input, init);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return client(request, options);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { fetchWithEvent };
|
package/dist/i18n.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { getNuxtModuleVersion, hasNuxtModuleCompatibility, hasNuxtModule } from '@nuxt/kit';
|
|
2
2
|
import { withHttps, withBase } from 'ufo';
|
|
3
|
-
import { localePath, resolveLocaleAlternates, resolveLocaleFromRoute } from './i18n-runtime.mjs';
|
|
3
|
+
import { localePath, resolveLocaleAlternates, resolveI18nDomain, resolveLocaleFromRoute } from './i18n-runtime.mjs';
|
|
4
4
|
import { getNuxtModuleOptions } from './kit.mjs';
|
|
5
|
+
import 'node:fs/promises';
|
|
6
|
+
import 'node:module';
|
|
7
|
+
import 'node:path';
|
|
5
8
|
import 'node:url';
|
|
6
|
-
import 'pathe';
|
|
7
|
-
import 'pkg-types';
|
|
8
9
|
import 'std-env';
|
|
9
10
|
|
|
10
11
|
const I18N_MODULES = ["@nuxtjs/i18n", "nuxt-i18n-micro"];
|
|
@@ -26,6 +27,28 @@ function generatePathForI18nPages(ctx) {
|
|
|
26
27
|
return locale?.domain ? withHttps(withBase(path, locale.domain)) : path;
|
|
27
28
|
}
|
|
28
29
|
function splitPathForI18nLocales(path, autoI18n) {
|
|
30
|
+
if (autoI18n.multiDomainLocales && path && !path.startsWith("/_")) {
|
|
31
|
+
const i18n2 = toRuntimeI18nConfig(autoI18n);
|
|
32
|
+
const hosts = [...new Set(i18n2.locales.flatMap((locale) => [
|
|
33
|
+
...locale.domains || [],
|
|
34
|
+
...locale.defaultForDomains || [],
|
|
35
|
+
...locale.domain ? [locale.domain] : []
|
|
36
|
+
]))];
|
|
37
|
+
if (hosts.length) {
|
|
38
|
+
const normalizedPath2 = path.startsWith("/") ? path : `/${path}`;
|
|
39
|
+
if (i18n2.locales.some((locale) => normalizedPath2 === `/${locale.code}` || normalizedPath2.startsWith(`/${locale.code}/`)))
|
|
40
|
+
return path;
|
|
41
|
+
const paths = /* @__PURE__ */ new Set([path]);
|
|
42
|
+
for (const host of hosts) {
|
|
43
|
+
for (const locale of resolveI18nDomain(host, i18n2).locales) {
|
|
44
|
+
paths.add(localePath(path, locale.code, i18n2, { host }));
|
|
45
|
+
if (i18n2.strategy === "prefix_and_default")
|
|
46
|
+
paths.add(localePath(path, locale.code, { ...i18n2, strategy: "prefix" }, { host }));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return [...paths];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
29
52
|
const selectedLocales = autoI18n.strategy === "prefix_except_default" ? autoI18n.locales.filter((l) => l.code !== autoI18n.defaultLocale) : autoI18n.locales;
|
|
30
53
|
if (!path || path.startsWith("/_"))
|
|
31
54
|
return path;
|
package/dist/kit.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Nuxt } from '@nuxt/schema';
|
|
2
2
|
import { Nitro } from 'nitropack';
|
|
3
3
|
import { NitroConfig } from 'nitropack/types';
|
|
4
|
-
import { NuxtPage, NuxtModule } from 'nuxt/schema';
|
|
4
|
+
import { Nuxt as Nuxt$1, NuxtPage, NuxtModule } from 'nuxt/schema';
|
|
5
5
|
import { useLogger } from '@nuxt/kit';
|
|
6
|
+
export { isAgent, isCI } from 'std-env';
|
|
6
7
|
|
|
7
8
|
type NitroRuntimeCompatibility = {
|
|
8
9
|
_tag: 'nitro-v2';
|
|
@@ -27,8 +28,21 @@ interface NitroTypeAugmentations {
|
|
|
27
28
|
declare function renderNitroTypeAugmentations(compatibility: NitroRuntimeCompatibility, augmentations: NitroTypeAugmentations): string;
|
|
28
29
|
declare function setupNitroRuntimeCompatibility(nuxt?: Nuxt): NitroRuntimeCompatibility;
|
|
29
30
|
|
|
31
|
+
type RuntimeAliasOptions = {
|
|
32
|
+
namespace: `#${string}`;
|
|
33
|
+
} & ({
|
|
34
|
+
app: string;
|
|
35
|
+
server?: string;
|
|
36
|
+
} | {
|
|
37
|
+
app?: string;
|
|
38
|
+
server: string;
|
|
39
|
+
});
|
|
40
|
+
/** Register curated directory entry points with separate app and server types. */
|
|
41
|
+
declare function setupRuntimeAliases(options: RuntimeAliasOptions, nuxt?: Nuxt$1): void;
|
|
42
|
+
|
|
30
43
|
interface NuxtSeoModuleDetection {
|
|
31
44
|
name: string;
|
|
45
|
+
disabled?: boolean;
|
|
32
46
|
version?: string;
|
|
33
47
|
entryPath?: string;
|
|
34
48
|
features?: Record<string, boolean | string | number>;
|
|
@@ -83,20 +97,6 @@ declare function resolveNuxtContentVersion(): Promise<false | NuxtContentVersion
|
|
|
83
97
|
* `undefined` when the package can't be resolved or has no parseable version.
|
|
84
98
|
*/
|
|
85
99
|
declare function resolvePackageMajor(id: string, rootDir: string): Promise<number | undefined>;
|
|
86
|
-
type UnheadMajor = 2 | 3;
|
|
87
|
-
/**
|
|
88
|
-
* Resolve the major of the unhead the host app renders with.
|
|
89
|
-
*
|
|
90
|
-
* `@unhead/vue` is what the head-stack packages peer-depend on, so it's the
|
|
91
|
-
* primary signal; falls back to the core `unhead` package, then to `3` (the
|
|
92
|
-
* current default major) when neither resolves.
|
|
93
|
-
*
|
|
94
|
-
* Used to keep head-stack dependencies on a compatible major. For example,
|
|
95
|
-
* `@unhead/schema-org` v3 attaches an object `_resolver` to every graph node
|
|
96
|
-
* that unhead v2's `walkResolver` invokes as a thunk, crashing render; a module
|
|
97
|
-
* that ships both majors can use this to alias to the matching one.
|
|
98
|
-
*/
|
|
99
|
-
declare function resolveHostUnheadMajor(rootDir: string): Promise<UnheadMajor>;
|
|
100
100
|
declare const COMARK_CONTENT_MODULE = "@harlan-zw/comark-content";
|
|
101
101
|
/**
|
|
102
102
|
* The Markdown content module backing this app, if any.
|
|
@@ -139,5 +139,5 @@ declare function hasContentFileHooks(provider: ContentProvider): boolean;
|
|
|
139
139
|
*/
|
|
140
140
|
declare function setupContentRuntime(provider: ContentProvider, nuxt?: Nuxt): void;
|
|
141
141
|
|
|
142
|
-
export { COMARK_CONTENT_MODULE, createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, hasContentFileHooks, isNuxtGenerate, renderNitroTypeAugmentations, resolveContentProvider,
|
|
143
|
-
export type { ContentProvider, NitroRuntimeCompatibility, NitroTypeAugmentations, NuxtContentVersion, NuxtSeoModuleDetection,
|
|
142
|
+
export { COMARK_CONTENT_MODULE, createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, hasContentFileHooks, isNuxtGenerate, renderNitroTypeAugmentations, resolveContentProvider, resolveNitroPreset, resolveNuxtContentVersion, resolvePackageMajor, setupContentRuntime, setupNitroRuntimeCompatibility, setupRuntimeAliases, useModuleLogger };
|
|
143
|
+
export type { ContentProvider, NitroRuntimeCompatibility, NitroTypeAugmentations, NuxtContentVersion, NuxtSeoModuleDetection, RuntimeAliasOptions };
|