nuxtseo-shared 5.3.16 → 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 +3 -2
- 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/kit.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { findPackageJSON } from 'node:module';
|
|
3
|
+
import { isAbsolute, resolve, relative, sep, join } from 'node:path';
|
|
1
4
|
import { pathToFileURL } from 'node:url';
|
|
2
|
-
import {
|
|
3
|
-
import { relative, dirname } from 'pathe';
|
|
4
|
-
import { resolvePackageJSON, readPackageJSON } from 'pkg-types';
|
|
5
|
+
import { getNitroVersion, addTypeTemplate, useNuxt, useLogger, resolveModule, directoryToURL, createResolver, addTemplate, loadNuxtModuleInstance, hasNuxtModule, tryUseNuxt, hasNuxtModuleCompatibility } from '@nuxt/kit';
|
|
5
6
|
import { provider, env } from 'std-env';
|
|
7
|
+
export { isAgent, isCI } from 'std-env';
|
|
6
8
|
|
|
7
9
|
const NITRO_RUNTIME_MODULE = "#nuxtseo/nitro";
|
|
8
10
|
const H3_RUNTIME_MODULE = "#nuxtseo/h3";
|
|
@@ -25,7 +27,8 @@ const nitroV3Compatibility = {
|
|
|
25
27
|
eventType: `import('nitro/h3').H3Event`,
|
|
26
28
|
nitroTypesModule: "nitro/types"
|
|
27
29
|
};
|
|
28
|
-
const nitroV2Runtime = `
|
|
30
|
+
const nitroV2Runtime = `import { useNitroApp as _useNitroApp } from 'nitropack/runtime'
|
|
31
|
+
export {
|
|
29
32
|
defineNitroPlugin,
|
|
30
33
|
useNitroApp,
|
|
31
34
|
useEvent,
|
|
@@ -36,6 +39,9 @@ const nitroV2Runtime = `export {
|
|
|
36
39
|
defineTask,
|
|
37
40
|
runTask,
|
|
38
41
|
} from 'nitropack/runtime'
|
|
42
|
+
export function localFetch(request, init, context) {
|
|
43
|
+
return _useNitroApp().localFetch(request, { ...init, context: context ? { _platform: context } : undefined })
|
|
44
|
+
}
|
|
39
45
|
export function fetchWithEvent(event, request, options) {
|
|
40
46
|
return event.$fetch(request, options)
|
|
41
47
|
}
|
|
@@ -54,6 +60,7 @@ const nitroV2RuntimeTypes = `export {
|
|
|
54
60
|
defineTask,
|
|
55
61
|
runTask,
|
|
56
62
|
} from 'nitropack/runtime'
|
|
63
|
+
export function localFetch(request: string | URL | Request, init?: RequestInit, context?: Record<string, unknown>): Promise<Response>
|
|
57
64
|
export function fetchWithEvent<T>(event: import('h3').H3Event, request: import('ofetch').FetchRequest, options?: import('ofetch').FetchOptions): Promise<T>
|
|
58
65
|
export function fetchRawWithEvent(event: import('h3').H3Event, request: RequestInfo | URL, init?: RequestInit): Promise<Response>
|
|
59
66
|
`;
|
|
@@ -61,7 +68,7 @@ const nitroV3Runtime = `import { createFetch } from '${OFETCH_RUNTIME_MODULE}'
|
|
|
61
68
|
import { fetchWithEvent as fetchH3WithEvent, getProxyRequestHeaders } from 'nitro/h3'
|
|
62
69
|
import { useNitroApp as _useNitroApp } from 'nitro/app'
|
|
63
70
|
export { definePlugin as defineNitroPlugin } from 'nitro'
|
|
64
|
-
export { useNitroApp } from 'nitro/app'
|
|
71
|
+
export { useNitroApp, fetch as localFetch } from 'nitro/app'
|
|
65
72
|
export { useRequest as useEvent } from 'nitro/context'
|
|
66
73
|
import { useRuntimeConfig as _useRuntimeConfig } from 'nitro/runtime-config'
|
|
67
74
|
export function useRuntimeConfig(_event) { return _useRuntimeConfig() }
|
|
@@ -69,6 +76,8 @@ export { defineCachedFunction, defineCachedHandler as defineCachedEventHandler }
|
|
|
69
76
|
export { useStorage } from 'nitro/storage'
|
|
70
77
|
export { defineTask, runTask } from 'nitro/task'
|
|
71
78
|
function fetchRaw(event, input, init) {
|
|
79
|
+
if (typeof input === 'string' && input.startsWith('//'))
|
|
80
|
+
return fetchH3WithEvent(event, new URL(input, event.url), init)
|
|
72
81
|
if (typeof input !== 'string' || !input.startsWith('/'))
|
|
73
82
|
return fetchH3WithEvent(event, input, init)
|
|
74
83
|
const headers = new Headers(getProxyRequestHeaders(event, { host: true }))
|
|
@@ -91,7 +100,7 @@ export function fetchWithEvent(event, request, options) {
|
|
|
91
100
|
}
|
|
92
101
|
`;
|
|
93
102
|
const nitroV3RuntimeTypes = `export { definePlugin as defineNitroPlugin } from 'nitro'
|
|
94
|
-
export { useNitroApp } from 'nitro/app'
|
|
103
|
+
export { useNitroApp, fetch as localFetch } from 'nitro/app'
|
|
95
104
|
export { useRequest as useEvent } from 'nitro/context'
|
|
96
105
|
export function useRuntimeConfig(event?: import('nitro/h3').H3Event): ReturnType<typeof import('nitro/runtime-config').useRuntimeConfig>
|
|
97
106
|
export { defineCachedFunction, defineCachedHandler as defineCachedEventHandler } from 'nitro/cache'
|
|
@@ -126,26 +135,40 @@ ${indent(h3Runtime.trim(), 2)}
|
|
|
126
135
|
`;
|
|
127
136
|
}
|
|
128
137
|
function resolveRuntimeModule(nuxt, id) {
|
|
138
|
+
const urls = [...nuxt.options.modulesDir.map(directoryToURL), new URL(import.meta.url)];
|
|
129
139
|
try {
|
|
130
140
|
return {
|
|
131
141
|
_tag: "resolved",
|
|
132
142
|
path: resolveModule(id, {
|
|
133
|
-
url:
|
|
143
|
+
url: urls
|
|
134
144
|
})
|
|
135
145
|
};
|
|
136
146
|
} catch (cause) {
|
|
137
|
-
|
|
147
|
+
try {
|
|
148
|
+
const nuxtEntry = resolveModule("nuxt", { url: urls });
|
|
149
|
+
const builder = resolveModule(id === "h3" ? "nitropack" : "nitro", { url: [pathToFileURL(nuxtEntry), ...urls] });
|
|
150
|
+
return { _tag: "resolved", path: resolveModule(id, { url: [pathToFileURL(builder), ...urls] }) };
|
|
151
|
+
} catch (nativeCause) {
|
|
152
|
+
return { _tag: "unresolved", cause: new AggregateError([cause, nativeCause], `Could not resolve the native server module '${id}'.`) };
|
|
153
|
+
}
|
|
138
154
|
}
|
|
139
155
|
}
|
|
140
156
|
function applyNitroRuntimeCompatibility(nuxt, compatibility, reportResolutionFailure = false) {
|
|
141
157
|
const nuxtOptions = nuxt.options;
|
|
142
158
|
const nitroOptions = nuxtOptions.nitro ||= {};
|
|
143
159
|
nitroOptions.alias ||= {};
|
|
144
|
-
nitroOptions.externals ||= {};
|
|
145
|
-
nitroOptions.externals.inline ||= [];
|
|
146
160
|
nitroOptions.virtual ||= {};
|
|
147
|
-
if (
|
|
148
|
-
nitroOptions.externals
|
|
161
|
+
if (compatibility._tag === "nitro-v2") {
|
|
162
|
+
nitroOptions.externals ||= {};
|
|
163
|
+
nitroOptions.externals.inline ||= [];
|
|
164
|
+
if (!nitroOptions.externals.inline.includes("nuxtseo-shared"))
|
|
165
|
+
nitroOptions.externals.inline.push("nuxtseo-shared");
|
|
166
|
+
} else if (nitroOptions.noExternals !== true) {
|
|
167
|
+
const inline = Array.isArray(nitroOptions.noExternals) ? nitroOptions.noExternals : [];
|
|
168
|
+
if (!inline.includes("nuxtseo-shared"))
|
|
169
|
+
inline.push("nuxtseo-shared");
|
|
170
|
+
nitroOptions.noExternals = inline;
|
|
171
|
+
}
|
|
149
172
|
const h3RuntimeModule = compatibility._tag === "nitro-v3" ? "nitro/h3" : "h3";
|
|
150
173
|
nitroOptions.alias[H3_RUNTIME_MODULE] = h3RuntimeModule;
|
|
151
174
|
const h3Resolution = resolveRuntimeModule(nuxt, h3RuntimeModule);
|
|
@@ -180,6 +203,9 @@ ${nitroInterfaces.join("\n")}
|
|
|
180
203
|
}`));
|
|
181
204
|
}
|
|
182
205
|
if (augmentations.eventContext?.trim()) {
|
|
206
|
+
declarations.push(`declare module '@nuxt/schema' {
|
|
207
|
+
${renderInterface("RequestEventContext", augmentations.eventContext)}
|
|
208
|
+
}`);
|
|
183
209
|
declarations.push(`declare module '${compatibility.eventContextModule}' {
|
|
184
210
|
${renderInterface(compatibility.eventContextType, augmentations.eventContext)}
|
|
185
211
|
}`);
|
|
@@ -187,8 +213,10 @@ ${renderInterface(compatibility.eventContextType, augmentations.eventContext)}
|
|
|
187
213
|
return declarations.join("\n\n");
|
|
188
214
|
}
|
|
189
215
|
function setupNitroRuntimeCompatibility(nuxt = useNuxt()) {
|
|
190
|
-
const major =
|
|
191
|
-
|
|
216
|
+
const major = getNitroVersion(nuxt);
|
|
217
|
+
if (major !== 2 && major !== 3)
|
|
218
|
+
throw new Error("Nuxt SEO requires a Nitro 2 or Nitro 3 server builder.");
|
|
219
|
+
const compatibility = major === 3 ? nitroV3Compatibility : nitroV2Compatibility;
|
|
192
220
|
applyNitroRuntimeCompatibility(nuxt, compatibility);
|
|
193
221
|
const nuxtWithLegacyMarker = nuxt;
|
|
194
222
|
nuxtWithLegacyMarker[legacySetupMarker] = true;
|
|
@@ -208,10 +236,56 @@ function setupNitroRuntimeCompatibility(nuxt = useNuxt()) {
|
|
|
208
236
|
return compatibility;
|
|
209
237
|
}
|
|
210
238
|
|
|
239
|
+
function setupRuntimeAliases(options, nuxt = useNuxt()) {
|
|
240
|
+
const entries = [
|
|
241
|
+
{ runtime: "app", directory: options.app },
|
|
242
|
+
{ runtime: "server", directory: options.server }
|
|
243
|
+
].filter((entry) => entry.directory !== void 0);
|
|
244
|
+
for (const { runtime, directory } of entries) {
|
|
245
|
+
if (!isAbsolute(directory))
|
|
246
|
+
throw new Error(`Runtime alias ${options.namespace}/${runtime} requires an absolute directory.`);
|
|
247
|
+
const alias = `${options.namespace}/${runtime}`;
|
|
248
|
+
nuxt.options.alias[alias] = directory;
|
|
249
|
+
if (runtime === "app" && !nuxt.options.build.transpile.includes(directory))
|
|
250
|
+
nuxt.options.build.transpile.push(directory);
|
|
251
|
+
if (runtime === "server") {
|
|
252
|
+
const options2 = nuxt.options;
|
|
253
|
+
const nitro = options2.nitro ||= {};
|
|
254
|
+
nitro.alias ||= {};
|
|
255
|
+
nitro.alias[alias] = directory;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
nuxt.hook("prepare:types", ({ tsConfig, serverTsConfig }) => {
|
|
259
|
+
const typesDir = nuxt.options.typesDir || nuxt.options.buildDir;
|
|
260
|
+
for (const { runtime, directory } of entries) {
|
|
261
|
+
const alias = `${options.namespace}/${runtime}`;
|
|
262
|
+
const config = runtime === "app" ? tsConfig : serverTsConfig;
|
|
263
|
+
config.compilerOptions ||= {};
|
|
264
|
+
config.compilerOptions.paths ||= {};
|
|
265
|
+
const base = resolve(typesDir, config.compilerOptions.baseUrl || ".");
|
|
266
|
+
const path = relative(base, directory).split(sep).join("/");
|
|
267
|
+
const prefix = path.startsWith(".") ? path : `./${path}`;
|
|
268
|
+
config.compilerOptions.paths[alias] = [join(prefix, "index").split(sep).join("/")];
|
|
269
|
+
config.compilerOptions.paths[`${alias}/*`] = [`${prefix}/*`];
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
211
274
|
function normalizePackageUrl(rootDir) {
|
|
212
275
|
const url = rootDir.startsWith("file:") ? rootDir : pathToFileURL(rootDir.endsWith("/") ? rootDir : `${rootDir}/`).href;
|
|
213
276
|
return url.endsWith("/") ? url : `${url}/`;
|
|
214
277
|
}
|
|
278
|
+
async function readPackageVersion(id, rootDir) {
|
|
279
|
+
const path = await Promise.resolve().then(() => findPackageJSON(id, new URL("package.json", normalizePackageUrl(rootDir)))).catch((error) => {
|
|
280
|
+
if (error && typeof error === "object" && "code" in error && (error.code === "ERR_MODULE_NOT_FOUND" || error.code === "ENOENT"))
|
|
281
|
+
return void 0;
|
|
282
|
+
throw error;
|
|
283
|
+
});
|
|
284
|
+
if (!path)
|
|
285
|
+
return void 0;
|
|
286
|
+
const metadata = JSON.parse(await readFile(path, "utf8"));
|
|
287
|
+
return metadata && typeof metadata === "object" && "version" in metadata && typeof metadata.version === "string" ? metadata.version : void 0;
|
|
288
|
+
}
|
|
215
289
|
const NUXT_SEO_MODULES = /* @__PURE__ */ new Set([
|
|
216
290
|
"@nuxtjs/robots",
|
|
217
291
|
"@nuxtjs/sitemap",
|
|
@@ -223,12 +297,28 @@ const NUXT_SEO_MODULES = /* @__PURE__ */ new Set([
|
|
|
223
297
|
"nuxt-skew-protection",
|
|
224
298
|
"nuxt-ai-ready"
|
|
225
299
|
]);
|
|
300
|
+
const SEO_CONFIG_KEYS = {
|
|
301
|
+
"@nuxtjs/robots": "robots",
|
|
302
|
+
"@nuxtjs/sitemap": "sitemap",
|
|
303
|
+
"nuxt-og-image": "ogImage",
|
|
304
|
+
"nuxt-schema-org": "schemaOrg",
|
|
305
|
+
"nuxt-seo-utils": "seo",
|
|
306
|
+
"nuxt-link-checker": "linkChecker",
|
|
307
|
+
"nuxt-site-config": "site",
|
|
308
|
+
"nuxt-skew-protection": "skewProtection",
|
|
309
|
+
"nuxt-ai-ready": "aiReady"
|
|
310
|
+
};
|
|
226
311
|
function detectNuxtSeoModules(nuxt = useNuxt()) {
|
|
227
|
-
return nuxt.options._installedModules.filter((m) => m.meta?.name && NUXT_SEO_MODULES.has(m.meta.name)).map((m) =>
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
312
|
+
return nuxt.options._installedModules.filter((m) => m.meta?.name && NUXT_SEO_MODULES.has(m.meta.name)).map((m) => {
|
|
313
|
+
const configKey = SEO_CONFIG_KEYS[m.meta.name];
|
|
314
|
+
const config = configKey ? nuxt.options[configKey] : void 0;
|
|
315
|
+
return {
|
|
316
|
+
name: m.meta.name,
|
|
317
|
+
disabled: m.meta.disabled || config === false || config?.enabled === false,
|
|
318
|
+
version: m.meta.version,
|
|
319
|
+
entryPath: m.entryPath
|
|
320
|
+
};
|
|
321
|
+
});
|
|
232
322
|
}
|
|
233
323
|
function useModuleLogger(name, options, nuxt = useNuxt()) {
|
|
234
324
|
const logger = useLogger(name);
|
|
@@ -294,7 +384,7 @@ function extendTypes(module, template) {
|
|
|
294
384
|
addTemplate({
|
|
295
385
|
filename: `module/${module}.d.ts`,
|
|
296
386
|
getContents: async () => {
|
|
297
|
-
const typesPath = relative(resolve(nuxt.options.rootDir, nuxt.options.buildDir, "module"), resolve("runtime/types"));
|
|
387
|
+
const typesPath = relative(resolve(nuxt.options.rootDir, nuxt.options.buildDir, "module"), resolve("runtime/types")).split(sep).join("/");
|
|
298
388
|
const s = await template({ typesPath });
|
|
299
389
|
return `// Generated by ${module}
|
|
300
390
|
${s}
|
|
@@ -331,42 +421,15 @@ async function resolveNuxtContentVersion() {
|
|
|
331
421
|
return false;
|
|
332
422
|
}
|
|
333
423
|
async function resolvePackageMajor(id, rootDir) {
|
|
334
|
-
const
|
|
335
|
-
const version = await readPackageJSON(id, { url }).then((pkg) => pkg.version).catch(() => {
|
|
336
|
-
return void 0;
|
|
337
|
-
});
|
|
424
|
+
const version = await readPackageVersion(id, rootDir);
|
|
338
425
|
const major = version ? Number.parseInt(version, 10) : Number.NaN;
|
|
339
426
|
return Number.isFinite(major) ? major : void 0;
|
|
340
427
|
}
|
|
341
|
-
async function resolveHostUnheadMajor(rootDir) {
|
|
342
|
-
const rootUrl = normalizePackageUrl(rootDir);
|
|
343
|
-
const searchUrls = [];
|
|
344
|
-
for (const id of ["@nuxt/nitro-server", "nuxt"]) {
|
|
345
|
-
const pkgJson = await resolvePackageJSON(id, { url: rootUrl }).catch(() => {
|
|
346
|
-
return void 0;
|
|
347
|
-
});
|
|
348
|
-
if (pkgJson)
|
|
349
|
-
searchUrls.push(`${dirname(pkgJson)}/`);
|
|
350
|
-
}
|
|
351
|
-
searchUrls.push(rootUrl);
|
|
352
|
-
for (const id of ["@unhead/vue", "unhead"]) {
|
|
353
|
-
for (const url of searchUrls) {
|
|
354
|
-
const major = await resolvePackageMajor(id, url);
|
|
355
|
-
if (major === 2)
|
|
356
|
-
return 2;
|
|
357
|
-
if (major !== void 0 && major >= 3)
|
|
358
|
-
return 3;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return 3;
|
|
362
|
-
}
|
|
363
428
|
const COMARK_CONTENT_MODULE = "@harlan-zw/comark-content";
|
|
364
429
|
const COMARK_CONTENT_MINIMUM = [0, 1, 2];
|
|
365
430
|
async function comarkSatisfiesMinimum(nuxt) {
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
});
|
|
369
|
-
const parts = pkg?.version?.split(".").map((part) => Number.parseInt(part, 10));
|
|
431
|
+
const version = await readPackageVersion(COMARK_CONTENT_MODULE, nuxt.options.rootDir);
|
|
432
|
+
const parts = version?.split(".").map((part) => Number.parseInt(part, 10));
|
|
370
433
|
if (!parts || parts.length < 3 || parts.some((part) => !Number.isFinite(part)))
|
|
371
434
|
return false;
|
|
372
435
|
for (const [index, minimum] of COMARK_CONTENT_MINIMUM.entries()) {
|
|
@@ -392,9 +455,11 @@ function setupContentRuntime(provider2, nuxt = useNuxt()) {
|
|
|
392
455
|
const nitro = nuxt.options.nitro ??= {};
|
|
393
456
|
nitro.alias ??= {};
|
|
394
457
|
nitro.alias["#nuxtseo/content"] = resolver.resolve(`./runtime/content/${shim}`);
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
458
|
+
if (getNitroVersion(nuxt) === 2) {
|
|
459
|
+
nitro.externals ??= {};
|
|
460
|
+
nitro.externals.inline ??= [];
|
|
461
|
+
nitro.externals.inline.push(resolver.resolve("./runtime/content/"));
|
|
462
|
+
}
|
|
398
463
|
}
|
|
399
464
|
|
|
400
|
-
export { COMARK_CONTENT_MODULE, createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, hasContentFileHooks, isNuxtGenerate, renderNitroTypeAugmentations, resolveContentProvider,
|
|
465
|
+
export { COMARK_CONTENT_MODULE, createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, hasContentFileHooks, isNuxtGenerate, renderNitroTypeAugmentations, resolveContentProvider, resolveNitroPreset, resolveNuxtContentVersion, resolvePackageMajor, setupContentRuntime, setupNitroRuntimeCompatibility, setupRuntimeAliases, useModuleLogger };
|
package/dist/module.d.mts
CHANGED
package/dist/module.d.ts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { defineNuxtModule } from '@nuxt/kit';
|
|
2
2
|
import { hookNuxtSeoProDataUpload } from './pro.mjs';
|
|
3
|
-
import 'nuxt-site-config/kit';
|
|
4
3
|
import 'ofetch';
|
|
5
4
|
import 'std-env';
|
|
6
5
|
import './kit.mjs';
|
|
6
|
+
import 'node:fs/promises';
|
|
7
|
+
import 'node:module';
|
|
8
|
+
import 'node:path';
|
|
7
9
|
import 'node:url';
|
|
8
|
-
import 'pathe';
|
|
9
|
-
import 'pkg-types';
|
|
10
10
|
|
|
11
11
|
const module$1 = defineNuxtModule({
|
|
12
12
|
meta: {
|
|
13
13
|
name: "nuxtseo-shared",
|
|
14
14
|
configKey: "nuxtSeoShared",
|
|
15
15
|
compatibility: {
|
|
16
|
-
nuxt: "
|
|
16
|
+
nuxt: "^4.6.0 || ^5.0.0"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
setup() {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { $Fetch } from 'ofetch';
|
|
2
|
+
|
|
3
|
+
interface Renderer {
|
|
4
|
+
options: {
|
|
5
|
+
builder?: string | false;
|
|
6
|
+
output: {
|
|
7
|
+
serverDir: string;
|
|
8
|
+
};
|
|
9
|
+
rollupConfig?: {
|
|
10
|
+
output?: {
|
|
11
|
+
entryFileNames?: unknown;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** Open the generated prerender app after Nitro 3 has closed its own worker. */
|
|
17
|
+
declare function createPrerenderFetch(renderer: Renderer, nitroMajor: 2 | 3): {
|
|
18
|
+
fetch: $Fetch;
|
|
19
|
+
close: () => Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { createPrerenderFetch };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { $Fetch } from 'ofetch';
|
|
2
|
+
|
|
3
|
+
interface Renderer {
|
|
4
|
+
options: {
|
|
5
|
+
builder?: string | false;
|
|
6
|
+
output: {
|
|
7
|
+
serverDir: string;
|
|
8
|
+
};
|
|
9
|
+
rollupConfig?: {
|
|
10
|
+
output?: {
|
|
11
|
+
entryFileNames?: unknown;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** Open the generated prerender app after Nitro 3 has closed its own worker. */
|
|
17
|
+
declare function createPrerenderFetch(renderer: Renderer, nitroMajor: 2 | 3): {
|
|
18
|
+
fetch: $Fetch;
|
|
19
|
+
close: () => Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { createPrerenderFetch };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import { createFetch } from 'ofetch';
|
|
4
|
+
|
|
5
|
+
const groups = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
function parseResponse(value) {
|
|
7
|
+
if (!(value instanceof Response))
|
|
8
|
+
throw new Error("The Nitro prerender app returned an invalid response.");
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
function createPrerenderFetch(renderer, nitroMajor) {
|
|
12
|
+
const group = groups.get(renderer) ?? { _tag: "open", users: 0, major: nitroMajor, transport: void 0 };
|
|
13
|
+
if (group._tag === "closed")
|
|
14
|
+
throw new Error("The prerender app has already closed.");
|
|
15
|
+
if (group.major !== nitroMajor)
|
|
16
|
+
throw new Error("Modules must use the same prerender builder.");
|
|
17
|
+
group.users++;
|
|
18
|
+
groups.set(renderer, group);
|
|
19
|
+
let lease = "active";
|
|
20
|
+
const open = async () => {
|
|
21
|
+
if (renderer.options.builder === false)
|
|
22
|
+
throw new Error("Prerender requests require a compiled Nitro app.");
|
|
23
|
+
const entryFileNames = renderer.options.rollupConfig?.output?.entryFileNames;
|
|
24
|
+
const entry = resolve(renderer.options.output.serverDir, typeof entryFileNames === "string" ? entryFileNames : "index.mjs");
|
|
25
|
+
const exports = await import(pathToFileURL(entry).href);
|
|
26
|
+
if (typeof exports !== "object" || exports === null)
|
|
27
|
+
throw new Error("The prerender app has invalid exports.");
|
|
28
|
+
const module = exports;
|
|
29
|
+
if (nitroMajor === 2) {
|
|
30
|
+
const localFetch = module.localFetch;
|
|
31
|
+
if (typeof localFetch !== "function")
|
|
32
|
+
throw new Error("The Nitro 2 prerender app does not export localFetch.");
|
|
33
|
+
return { fetch: async (input, init) => parseResponse(await localFetch(input, init)), close: async () => {
|
|
34
|
+
} };
|
|
35
|
+
}
|
|
36
|
+
const app = module.default;
|
|
37
|
+
if (typeof app !== "object" || app === null || !("fetch" in app) || !("close" in app))
|
|
38
|
+
throw new Error("The Nitro 3 prerender app does not export fetch and close.");
|
|
39
|
+
const fetch2 = app.fetch;
|
|
40
|
+
const close = app.close;
|
|
41
|
+
if (typeof fetch2 !== "function" || typeof close !== "function")
|
|
42
|
+
throw new Error("The Nitro 3 prerender app does not export fetch and close.");
|
|
43
|
+
return {
|
|
44
|
+
fetch: async (input) => parseResponse(await fetch2(input)),
|
|
45
|
+
close: async () => {
|
|
46
|
+
await close();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const fetch = createFetch({
|
|
51
|
+
fetch: async (input, init) => {
|
|
52
|
+
if (lease === "released")
|
|
53
|
+
throw new Error("This prerender client has already closed.");
|
|
54
|
+
if (typeof input !== "string" || (!input.startsWith("/") || input.startsWith("//")))
|
|
55
|
+
return globalThis.fetch(input, init);
|
|
56
|
+
group.transport ||= open();
|
|
57
|
+
const app = await group.transport;
|
|
58
|
+
return nitroMajor === 2 ? app.fetch(input, init) : app.fetch(new Request(new URL(input, "http://localhost"), init));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return { fetch, close: async () => {
|
|
62
|
+
if (lease === "released")
|
|
63
|
+
return;
|
|
64
|
+
lease = "released";
|
|
65
|
+
group.users--;
|
|
66
|
+
if (group.users === 0) {
|
|
67
|
+
groups.set(renderer, { _tag: "closed" });
|
|
68
|
+
if (group.transport)
|
|
69
|
+
await (await group.transport).close();
|
|
70
|
+
}
|
|
71
|
+
} };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { createPrerenderFetch };
|
package/dist/pro.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { useNuxt, useLogger } from '@nuxt/kit';
|
|
2
|
-
import { useSiteConfig } from 'nuxt-site-config/kit';
|
|
1
|
+
import { useNuxt, useLogger, hasNuxtModule } from '@nuxt/kit';
|
|
3
2
|
import { $fetch } from 'ofetch';
|
|
4
3
|
import { isTest } from 'std-env';
|
|
5
4
|
import { detectNuxtSeoModules } from './kit.mjs';
|
|
5
|
+
import 'node:fs/promises';
|
|
6
|
+
import 'node:module';
|
|
7
|
+
import 'node:path';
|
|
6
8
|
import 'node:url';
|
|
7
|
-
import 'pathe';
|
|
8
|
-
import 'pkg-types';
|
|
9
9
|
|
|
10
10
|
function hookNuxtSeoProDataUpload() {
|
|
11
11
|
const nuxt = useNuxt();
|
|
@@ -18,9 +18,10 @@ function hookNuxtSeoProDataUpload() {
|
|
|
18
18
|
}
|
|
19
19
|
nuxt._isNuxtSeoProUploading = true;
|
|
20
20
|
nuxt.hooks.hook("build:before", async () => {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
21
|
+
const siteConfigKit = hasNuxtModule("nuxt-site-config", nuxt) ? await import('nuxt-site-config/kit') : void 0;
|
|
22
|
+
const resolvedSiteConfig = siteConfigKit ? nuxt.runWithContext(() => siteConfigKit.useSiteConfig()) : void 0;
|
|
23
|
+
const siteUrl = resolvedSiteConfig?.url?.startsWith("http") ? resolvedSiteConfig.url : void 0;
|
|
24
|
+
const siteName = resolvedSiteConfig?.name || void 0;
|
|
24
25
|
const modules = detectNuxtSeoModules(nuxt);
|
|
25
26
|
await nuxt.hooks.callHook("nuxt-seo-pro:modules", modules);
|
|
26
27
|
await $fetch("https://nuxtseo.com/api/pro/verify", {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxtseo-shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.0.0",
|
|
5
5
|
"description": "Shared utilities for Nuxt SEO modules.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -60,21 +60,40 @@
|
|
|
60
60
|
"types": "./dist/const.d.mts",
|
|
61
61
|
"default": "./dist/const.mjs"
|
|
62
62
|
},
|
|
63
|
+
"./brand": {
|
|
64
|
+
"types": "./dist/brand.d.mts",
|
|
65
|
+
"default": "./dist/brand.mjs"
|
|
66
|
+
},
|
|
63
67
|
"./server": {
|
|
64
68
|
"types": "./dist/server.d.mts",
|
|
65
69
|
"default": "./dist/server.mjs"
|
|
66
70
|
},
|
|
67
|
-
"./
|
|
71
|
+
"./fetch": {
|
|
72
|
+
"types": "./dist/fetch.d.mts",
|
|
73
|
+
"default": "./dist/fetch.mjs"
|
|
74
|
+
},
|
|
75
|
+
"./prerender": {
|
|
76
|
+
"types": "./dist/prerender.d.mts",
|
|
77
|
+
"default": "./dist/prerender.mjs"
|
|
78
|
+
},
|
|
79
|
+
"./package.json": "./package.json",
|
|
80
|
+
"./checklist": {
|
|
81
|
+
"types": "./dist/checklist.d.mts",
|
|
82
|
+
"default": "./dist/checklist.mjs"
|
|
83
|
+
}
|
|
68
84
|
},
|
|
69
85
|
"main": "./dist/module.mjs",
|
|
70
86
|
"types": "./dist/types.d.mts",
|
|
71
87
|
"files": [
|
|
72
88
|
"dist"
|
|
73
89
|
],
|
|
90
|
+
"engines": {
|
|
91
|
+
"node": "^22.22.3 || ^24.15.0 || >=26.0.0"
|
|
92
|
+
},
|
|
74
93
|
"peerDependencies": {
|
|
75
|
-
"@nuxt/schema": "^
|
|
76
|
-
"nuxt": "^
|
|
77
|
-
"nuxt-site-config": "^
|
|
94
|
+
"@nuxt/schema": "^4.6.0 || ^5.0.0",
|
|
95
|
+
"nuxt": "^4.6.0 || ^5.0.0",
|
|
96
|
+
"nuxt-site-config": "^5.0.0",
|
|
78
97
|
"vue": "^3.5.0",
|
|
79
98
|
"zod": "^3.23.0 || ^4.0.0"
|
|
80
99
|
},
|
|
@@ -87,37 +106,30 @@
|
|
|
87
106
|
}
|
|
88
107
|
},
|
|
89
108
|
"dependencies": {
|
|
90
|
-
"@
|
|
91
|
-
"@nuxt/devtools-kit": "4.0.0-alpha.7",
|
|
92
|
-
"@nuxt/kit": "^4.5.2",
|
|
93
|
-
"birpc": "^4.0.0",
|
|
109
|
+
"@nuxt/kit": "^4.6.0",
|
|
94
110
|
"consola": "^3.4.2",
|
|
95
111
|
"defu": "^6.1.7",
|
|
96
|
-
"nypm": "^0.6.9",
|
|
97
112
|
"ofetch": "^1.5.1",
|
|
98
|
-
"pathe": "^2.0.3",
|
|
99
|
-
"pkg-types": "^2.3.1",
|
|
100
113
|
"radix3": "^1.1.2",
|
|
101
|
-
"
|
|
102
|
-
"std-env": "^4.2.0",
|
|
114
|
+
"std-env": "^4.3.0",
|
|
103
115
|
"ufo": "^1.6.4"
|
|
104
116
|
},
|
|
105
117
|
"devDependencies": {
|
|
106
118
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
107
|
-
"@harlan-zw/comark-content": "^0.
|
|
108
|
-
"@nuxt/content": "^3.
|
|
119
|
+
"@harlan-zw/comark-content": "^0.2.0",
|
|
120
|
+
"@nuxt/content": "^3.16.1",
|
|
109
121
|
"@nuxt/module-builder": "^1.0.3",
|
|
110
|
-
"@nuxt/schema": "^4.
|
|
111
|
-
"@nuxt/test-utils": "^4.
|
|
122
|
+
"@nuxt/schema": "^4.6.0",
|
|
123
|
+
"@nuxt/test-utils": "^4.3.3",
|
|
112
124
|
"@nuxtjs/i18n": "^10.6.0",
|
|
113
|
-
"h3": "^
|
|
125
|
+
"h3": "^2.0.1",
|
|
114
126
|
"nitropack": "^2.13.4",
|
|
115
|
-
"nuxt": "^4.
|
|
116
|
-
"nuxt-site-config": "^
|
|
127
|
+
"nuxt": "^4.6.0",
|
|
128
|
+
"nuxt-site-config": "^5.0.0",
|
|
117
129
|
"typescript": "6.0.3",
|
|
118
|
-
"vitest": "^
|
|
119
|
-
"vue": "^3.5.
|
|
120
|
-
"vue-tsc": "^3.3.
|
|
130
|
+
"vitest": "^5.0.3",
|
|
131
|
+
"vue": "^3.5.43",
|
|
132
|
+
"vue-tsc": "^3.3.12"
|
|
121
133
|
},
|
|
122
134
|
"scripts": {
|
|
123
135
|
"build": "nuxt-module-build build",
|
|
@@ -125,7 +137,7 @@
|
|
|
125
137
|
"stub": "nuxt-module-build build --stub",
|
|
126
138
|
"test": "vitest",
|
|
127
139
|
"test:run": "vitest run && pnpm test:nuxt5",
|
|
128
|
-
"test:nuxt5": "pnpm --dir test/fixtures/nitro-compat-nuxt5 install --frozen-lockfile && pnpm --dir test/fixtures/nitro-compat-nuxt5 test",
|
|
140
|
+
"test:nuxt5": "pnpm build && pnpm --dir test/fixtures/nitro-compat-nuxt5 install --frozen-lockfile && pnpm --dir test/fixtures/nitro-compat-nuxt5 test",
|
|
129
141
|
"test:attw": "attw --pack --profile esm-only",
|
|
130
142
|
"typecheck": "nuxt typecheck ."
|
|
131
143
|
}
|