nuxtseo-shared 5.3.8 → 5.3.10
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/kit.mjs +28 -4
- package/dist/module.json +1 -1
- package/package.json +1 -1
package/dist/kit.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { pathToFileURL } from 'node:url';
|
|
2
|
-
import { getNuxtVersion, addTypeTemplate, useNuxt, createResolver, addTemplate, loadNuxtModuleInstance, tryUseNuxt, hasNuxtModule, hasNuxtModuleCompatibility, useLogger } from '@nuxt/kit';
|
|
2
|
+
import { getNuxtVersion, addTypeTemplate, useNuxt, resolveModule, createResolver, addTemplate, loadNuxtModuleInstance, tryUseNuxt, hasNuxtModule, hasNuxtModuleCompatibility, useLogger } from '@nuxt/kit';
|
|
3
3
|
import { relative, dirname } from 'pathe';
|
|
4
4
|
import { resolvePackageJSON, readPackageJSON } from 'pkg-types';
|
|
5
5
|
import { provider, env } from 'std-env';
|
|
6
6
|
|
|
7
7
|
const NITRO_RUNTIME_MODULE = "#nuxtseo/nitro";
|
|
8
8
|
const H3_RUNTIME_MODULE = "#nuxtseo/h3";
|
|
9
|
+
const OFETCH_RUNTIME_MODULE = "#nuxtseo/ofetch";
|
|
9
10
|
const TYPE_TEMPLATE_FILENAME = "types/nuxtseo-nitro.d.ts";
|
|
10
11
|
const legacySetupMarker = Symbol.for("nuxtseo:nitro-runtime-compatibility");
|
|
11
12
|
const typeSetupMarker = Symbol.for("nuxtseo:nitro-runtime-compatibility:request-context-types");
|
|
@@ -38,6 +39,9 @@ const nitroV2Runtime = `export {
|
|
|
38
39
|
export function fetchWithEvent(event, request, options) {
|
|
39
40
|
return event.$fetch(request, options)
|
|
40
41
|
}
|
|
42
|
+
export function fetchRawWithEvent(event, request, init) {
|
|
43
|
+
return event.fetch(request, init)
|
|
44
|
+
}
|
|
41
45
|
`;
|
|
42
46
|
const nitroV2RuntimeTypes = `export {
|
|
43
47
|
defineNitroPlugin,
|
|
@@ -51,9 +55,11 @@ const nitroV2RuntimeTypes = `export {
|
|
|
51
55
|
runTask,
|
|
52
56
|
} from 'nitropack/runtime'
|
|
53
57
|
export function fetchWithEvent<T>(event: import('h3').H3Event, request: import('ofetch').FetchRequest, options?: import('ofetch').FetchOptions): Promise<T>
|
|
58
|
+
export function fetchRawWithEvent(event: import('h3').H3Event, request: RequestInfo | URL, init?: RequestInit): Promise<Response>
|
|
54
59
|
`;
|
|
55
|
-
const nitroV3Runtime = `import { createFetch } from '
|
|
56
|
-
import { fetchWithEvent as
|
|
60
|
+
const nitroV3Runtime = `import { createFetch } from '${OFETCH_RUNTIME_MODULE}'
|
|
61
|
+
import { fetchWithEvent as fetchH3WithEvent, getProxyRequestHeaders } from 'nitro/h3'
|
|
62
|
+
import { useNitroApp as _useNitroApp } from 'nitro/app'
|
|
57
63
|
export { definePlugin as defineNitroPlugin } from 'nitro'
|
|
58
64
|
export { useNitroApp } from 'nitro/app'
|
|
59
65
|
export { useRequest as useEvent } from 'nitro/context'
|
|
@@ -62,9 +68,24 @@ export function useRuntimeConfig(_event) { return _useRuntimeConfig() }
|
|
|
62
68
|
export { defineCachedFunction, defineCachedHandler as defineCachedEventHandler } from 'nitro/cache'
|
|
63
69
|
export { useStorage } from 'nitro/storage'
|
|
64
70
|
export { defineTask, runTask } from 'nitro/task'
|
|
71
|
+
function fetchRaw(event, input, init) {
|
|
72
|
+
if (typeof input !== 'string' || !input.startsWith('/'))
|
|
73
|
+
return fetchH3WithEvent(event, input, init)
|
|
74
|
+
const headers = new Headers(getProxyRequestHeaders(event, { host: true }))
|
|
75
|
+
for (const [name, value] of new Headers(init?.headers))
|
|
76
|
+
headers.set(name, value)
|
|
77
|
+
const request = new Request(new URL(input, event.url), { ...init, headers })
|
|
78
|
+
request.runtime = event.req.runtime
|
|
79
|
+
request.waitUntil = event.req.waitUntil
|
|
80
|
+
request.ip = event.req.ip
|
|
81
|
+
return _useNitroApp().fetch(request)
|
|
82
|
+
}
|
|
83
|
+
export function fetchRawWithEvent(event, request, init) {
|
|
84
|
+
return fetchRaw(event, request, init)
|
|
85
|
+
}
|
|
65
86
|
export function fetchWithEvent(event, request, options) {
|
|
66
87
|
const localFetch = createFetch({
|
|
67
|
-
fetch: (input, init) =>
|
|
88
|
+
fetch: (input, init) => fetchRaw(event, input, init),
|
|
68
89
|
})
|
|
69
90
|
return localFetch(request, options)
|
|
70
91
|
}
|
|
@@ -77,6 +98,7 @@ export { defineCachedFunction, defineCachedHandler as defineCachedEventHandler }
|
|
|
77
98
|
export { useStorage } from 'nitro/storage'
|
|
78
99
|
export { defineTask, runTask } from 'nitro/task'
|
|
79
100
|
export function fetchWithEvent<T>(event: import('nitro/h3').H3Event, request: import('ofetch').FetchRequest, options?: import('ofetch').FetchOptions): Promise<T>
|
|
101
|
+
export function fetchRawWithEvent(event: import('nitro/h3').H3Event, request: RequestInfo | URL, init?: RequestInit): Promise<Response>
|
|
80
102
|
`;
|
|
81
103
|
function indent(value, spaces) {
|
|
82
104
|
const padding = " ".repeat(spaces);
|
|
@@ -109,6 +131,8 @@ function applyNitroRuntimeCompatibility(nuxt, compatibility) {
|
|
|
109
131
|
nitroOptions.alias ||= {};
|
|
110
132
|
nitroOptions.virtual ||= {};
|
|
111
133
|
nitroOptions.alias[H3_RUNTIME_MODULE] = compatibility._tag === "nitro-v3" ? "nitro/h3" : "h3";
|
|
134
|
+
if (compatibility._tag === "nitro-v3")
|
|
135
|
+
nitroOptions.alias[OFETCH_RUNTIME_MODULE] = resolveModule("ofetch", { url: new URL(import.meta.url) });
|
|
112
136
|
nitroOptions.virtual[NITRO_RUNTIME_MODULE] = compatibility._tag === "nitro-v3" ? nitroV3Runtime : nitroV2Runtime;
|
|
113
137
|
}
|
|
114
138
|
function renderNitroTypeAugmentations(compatibility, augmentations) {
|
package/dist/module.json
CHANGED