nuxt-nightly 4.2.0-29336619.cf102e88 → 4.2.0-29344147.7bcc4ca3
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/app/composables/payload.js +1 -1
- package/dist/app/types/augments.d.ts +0 -26
- package/dist/app/types.d.ts +35 -2
- package/dist/index.mjs +30 -770
- package/package.json +6 -13
- package/types.d.mts +1 -38
- package/types.d.ts +1 -38
- package/dist/core/runtime/nitro/handlers/error.d.ts +0 -3
- package/dist/core/runtime/nitro/handlers/error.js +0 -63
- package/dist/core/runtime/nitro/handlers/island.d.ts +0 -4
- package/dist/core/runtime/nitro/handlers/island.js +0 -100
- package/dist/core/runtime/nitro/handlers/renderer.d.ts +0 -16
- package/dist/core/runtime/nitro/handlers/renderer.js +0 -237
- package/dist/core/runtime/nitro/middleware/no-ssr.d.ts +0 -2
- package/dist/core/runtime/nitro/middleware/no-ssr.js +0 -7
- package/dist/core/runtime/nitro/plugins/dev-server-logs.d.ts +0 -3
- package/dist/core/runtime/nitro/plugins/dev-server-logs.js +0 -82
- package/dist/core/runtime/nitro/templates/error-500.d.ts +0 -2
- package/dist/core/runtime/nitro/templates/error-500.js +0 -6
- package/dist/core/runtime/nitro/utils/app-config.d.ts +0 -2
- package/dist/core/runtime/nitro/utils/app-config.js +0 -25
- package/dist/core/runtime/nitro/utils/cache-driver.d.ts +0 -2
- package/dist/core/runtime/nitro/utils/cache-driver.js +0 -34
- package/dist/core/runtime/nitro/utils/cache.d.ts +0 -8
- package/dist/core/runtime/nitro/utils/cache.js +0 -18
- package/dist/core/runtime/nitro/utils/config.d.ts +0 -1
- package/dist/core/runtime/nitro/utils/config.js +0 -1
- package/dist/core/runtime/nitro/utils/dev.d.ts +0 -1
- package/dist/core/runtime/nitro/utils/dev.js +0 -328
- package/dist/core/runtime/nitro/utils/error.d.ts +0 -6
- package/dist/core/runtime/nitro/utils/error.js +0 -11
- package/dist/core/runtime/nitro/utils/paths.d.ts +0 -4
- package/dist/core/runtime/nitro/utils/paths.js +0 -16
- package/dist/core/runtime/nitro/utils/renderer/app.d.ts +0 -7
- package/dist/core/runtime/nitro/utils/renderer/app.js +0 -32
- package/dist/core/runtime/nitro/utils/renderer/build-files.d.ts +0 -22
- package/dist/core/runtime/nitro/utils/renderer/build-files.js +0 -86
- package/dist/core/runtime/nitro/utils/renderer/inline-styles.d.ts +0 -2
- package/dist/core/runtime/nitro/utils/renderer/inline-styles.js +0 -13
- package/dist/core/runtime/nitro/utils/renderer/islands.d.ts +0 -36
- package/dist/core/runtime/nitro/utils/renderer/islands.js +0 -82
- package/dist/core/runtime/nitro/utils/renderer/payload.d.ts +0 -37
- package/dist/core/runtime/nitro/utils/renderer/payload.js +0 -66
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import { consola } from "consola";
|
|
3
|
-
import { stringify } from "devalue";
|
|
4
|
-
import { withTrailingSlash } from "ufo";
|
|
5
|
-
import { getContext } from "unctx";
|
|
6
|
-
import { captureRawStackTrace, parseRawStackTrace } from "errx";
|
|
7
|
-
import { isVNode } from "vue";
|
|
8
|
-
import { rootDir } from "#internal/dev-server-logs-options";
|
|
9
|
-
import { appId } from "#internal/nuxt.config.mjs";
|
|
10
|
-
const devReducers = {
|
|
11
|
-
VNode: (data) => isVNode(data) ? { type: data.type, props: data.props } : void 0,
|
|
12
|
-
URL: (data) => data instanceof URL ? data.toString() : void 0
|
|
13
|
-
};
|
|
14
|
-
const asyncContext = getContext("nuxt-dev", { asyncContext: true, AsyncLocalStorage });
|
|
15
|
-
export default (nitroApp) => {
|
|
16
|
-
const handler = nitroApp.h3App.handler;
|
|
17
|
-
nitroApp.h3App.handler = (event) => {
|
|
18
|
-
return asyncContext.callAsync({ logs: [], event }, () => handler(event));
|
|
19
|
-
};
|
|
20
|
-
onConsoleLog((_log) => {
|
|
21
|
-
const ctx = asyncContext.tryUse();
|
|
22
|
-
if (!ctx) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const rawStack = captureRawStackTrace();
|
|
26
|
-
if (!rawStack || rawStack.includes("runtime/vite-node.mjs")) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const trace = [];
|
|
30
|
-
let filename = "";
|
|
31
|
-
for (const entry of parseRawStackTrace(rawStack)) {
|
|
32
|
-
if (entry.source === import.meta.url) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (EXCLUDE_TRACE_RE.test(entry.source)) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
filename ||= entry.source.replace(withTrailingSlash(rootDir), "");
|
|
39
|
-
trace.push({
|
|
40
|
-
...entry,
|
|
41
|
-
source: entry.source.startsWith("file://") ? entry.source.replace("file://", "") : entry.source
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
const log = {
|
|
45
|
-
..._log,
|
|
46
|
-
// Pass along filename to allow the client to display more info about where log comes from
|
|
47
|
-
filename,
|
|
48
|
-
// Clean up file names in stack trace
|
|
49
|
-
stack: trace
|
|
50
|
-
};
|
|
51
|
-
ctx.logs.push(log);
|
|
52
|
-
});
|
|
53
|
-
nitroApp.hooks.hook("afterResponse", () => {
|
|
54
|
-
const ctx = asyncContext.tryUse();
|
|
55
|
-
if (!ctx) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
return nitroApp.hooks.callHook("dev:ssr-logs", { logs: ctx.logs, path: ctx.event.path });
|
|
59
|
-
});
|
|
60
|
-
nitroApp.hooks.hook("render:html", (htmlContext) => {
|
|
61
|
-
const ctx = asyncContext.tryUse();
|
|
62
|
-
if (!ctx) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
const reducers = Object.assign(/* @__PURE__ */ Object.create(null), devReducers, ctx.event.context._payloadReducers);
|
|
67
|
-
htmlContext.bodyAppend.unshift(`<script type="application/json" data-nuxt-logs="${appId}">${stringify(ctx.logs, reducers)}<\/script>`);
|
|
68
|
-
} catch (e) {
|
|
69
|
-
const shortError = e instanceof Error && "toString" in e ? ` Received \`${e.toString()}\`.` : "";
|
|
70
|
-
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.`);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
const EXCLUDE_TRACE_RE = /\/node_modules\/(?:.*\/)?(?:nuxt|nuxt-nightly|nuxt-edge|nuxt3|consola|@vue)\/|core\/runtime\/nitro/;
|
|
75
|
-
function onConsoleLog(callback) {
|
|
76
|
-
consola.addReporter({
|
|
77
|
-
log(logObj) {
|
|
78
|
-
callback(logObj);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
consola.wrapConsole();
|
|
82
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { escapeHtml } from "@vue/shared";
|
|
2
|
-
const _messages = { "appName": "Nuxt", "statusCode": 500, "statusMessage": "Internal server error", "description": "This page is temporarily unavailable.", "refresh": "Refresh this page" };
|
|
3
|
-
export const template = (messages) => {
|
|
4
|
-
messages = { ..._messages, ...messages };
|
|
5
|
-
return '<!DOCTYPE html><html lang="en"><head><title>' + escapeHtml(messages.statusCode) + " - " + escapeHtml(messages.statusMessage) + " | " + 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.statusCode) + '</h1><h2 class="font-semibold mb-2 sm:text-3xl text-2xl">' + escapeHtml(messages.statusMessage) + '</h2><p class="mb-4 px-2 text-[#64748B] text-md">' + escapeHtml(messages.description) + "</p></div></body></html>";
|
|
6
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { klona } from "klona";
|
|
2
|
-
import _inlineAppConfig from "#internal/nuxt/app-config";
|
|
3
|
-
const _sharedAppConfig = _deepFreeze(klona(_inlineAppConfig));
|
|
4
|
-
export function useAppConfig(event) {
|
|
5
|
-
if (!event) {
|
|
6
|
-
return _sharedAppConfig;
|
|
7
|
-
}
|
|
8
|
-
event.context.nuxt ||= {};
|
|
9
|
-
if (event.context.nuxt.appConfig) {
|
|
10
|
-
return event.context.nuxt.appConfig;
|
|
11
|
-
}
|
|
12
|
-
const appConfig = klona(_inlineAppConfig);
|
|
13
|
-
event.context.nuxt.appConfig = appConfig;
|
|
14
|
-
return appConfig;
|
|
15
|
-
}
|
|
16
|
-
function _deepFreeze(object) {
|
|
17
|
-
const propNames = Object.getOwnPropertyNames(object);
|
|
18
|
-
for (const name of propNames) {
|
|
19
|
-
const value = object[name];
|
|
20
|
-
if (value && typeof value === "object") {
|
|
21
|
-
_deepFreeze(value);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return Object.freeze(object);
|
|
25
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { defineDriver } from 'unstorage'
|
|
4
|
-
import fsDriver from 'unstorage/drivers/fs-lite'
|
|
5
|
-
import lruCache from 'unstorage/drivers/lru-cache'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @param {string} item
|
|
9
|
-
*/
|
|
10
|
-
const normalizeFsKey = item => decodeURIComponent(item.replaceAll(':', '_'))
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @param {{ base: string }} opts
|
|
14
|
-
*/
|
|
15
|
-
export default defineDriver((opts) => {
|
|
16
|
-
const fs = fsDriver({ base: opts.base })
|
|
17
|
-
const lru = lruCache({ max: 1000 })
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
...fs, // fall back to file system - only the bottom three methods are used in renderer
|
|
21
|
-
async setItem (key, value, opts) {
|
|
22
|
-
await Promise.all([
|
|
23
|
-
fs.setItem?.(normalizeFsKey(key), value, opts),
|
|
24
|
-
lru.setItem?.(key, value, opts),
|
|
25
|
-
])
|
|
26
|
-
},
|
|
27
|
-
async hasItem (key, opts) {
|
|
28
|
-
return await lru.hasItem(key, opts) || await fs.hasItem(normalizeFsKey(key), opts)
|
|
29
|
-
},
|
|
30
|
-
async getItem (key, opts) {
|
|
31
|
-
return await lru.getItem(key, opts) || await fs.getItem(normalizeFsKey(key), opts)
|
|
32
|
-
},
|
|
33
|
-
}
|
|
34
|
-
})
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const payloadCache: import("unstorage").Storage<import("unstorage").StorageValue> | null;
|
|
2
|
-
export declare const islandCache: import("unstorage").Storage<import("unstorage").StorageValue> | null;
|
|
3
|
-
export declare const islandPropCache: import("unstorage").Storage<import("unstorage").StorageValue> | null;
|
|
4
|
-
export declare const sharedPrerenderPromises: Map<string, Promise<any>> | null;
|
|
5
|
-
export declare const sharedPrerenderCache: {
|
|
6
|
-
get<T = unknown>(key: string): Promise<T> | undefined;
|
|
7
|
-
set<T>(key: string, value: Promise<T>): Promise<void>;
|
|
8
|
-
} | null;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useStorage } from "nitropack/runtime";
|
|
2
|
-
export const payloadCache = import.meta.prerender ? useStorage("internal:nuxt:prerender:payload") : null;
|
|
3
|
-
export const islandCache = import.meta.prerender ? useStorage("internal:nuxt:prerender:island") : null;
|
|
4
|
-
export const islandPropCache = import.meta.prerender ? useStorage("internal:nuxt:prerender:island-props") : null;
|
|
5
|
-
export const sharedPrerenderPromises = import.meta.prerender && process.env.NUXT_SHARED_DATA ? /* @__PURE__ */ new Map() : null;
|
|
6
|
-
const sharedPrerenderKeys = /* @__PURE__ */ new Set();
|
|
7
|
-
export const sharedPrerenderCache = import.meta.prerender && process.env.NUXT_SHARED_DATA ? {
|
|
8
|
-
get(key) {
|
|
9
|
-
if (sharedPrerenderKeys.has(key)) {
|
|
10
|
-
return sharedPrerenderPromises.get(key) ?? useStorage("internal:nuxt:prerender:shared").getItem(key);
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
async set(key, value) {
|
|
14
|
-
sharedPrerenderKeys.add(key);
|
|
15
|
-
sharedPrerenderPromises.set(key, value);
|
|
16
|
-
useStorage("internal:nuxt:prerender:shared").setItem(key, await value).finally(() => sharedPrerenderPromises.delete(key));
|
|
17
|
-
}
|
|
18
|
-
} : null;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const defineAppConfig: (config: any) => any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const defineAppConfig = (config) => config;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function generateErrorOverlayHTML(html: string): string;
|
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
const iframeStorageBridge = (nonce) => (
|
|
2
|
-
/* js */
|
|
3
|
-
`
|
|
4
|
-
(function() {
|
|
5
|
-
const memoryStore = {};
|
|
6
|
-
|
|
7
|
-
const NONCE = ${JSON.stringify(nonce)}
|
|
8
|
-
|
|
9
|
-
const mockStorage = {
|
|
10
|
-
getItem: function(key) {
|
|
11
|
-
return memoryStore[key] !== undefined ? memoryStore[key] : null;
|
|
12
|
-
},
|
|
13
|
-
setItem: function(key, value) {
|
|
14
|
-
memoryStore[key] = String(value);
|
|
15
|
-
window.parent.postMessage({
|
|
16
|
-
type: 'storage-set',
|
|
17
|
-
key: key,
|
|
18
|
-
value: String(value),
|
|
19
|
-
nonce: NONCE
|
|
20
|
-
}, '*');
|
|
21
|
-
},
|
|
22
|
-
removeItem: function(key) {
|
|
23
|
-
delete memoryStore[key];
|
|
24
|
-
window.parent.postMessage({
|
|
25
|
-
type: 'storage-remove',
|
|
26
|
-
key: key,
|
|
27
|
-
nonce: NONCE
|
|
28
|
-
}, '*');
|
|
29
|
-
},
|
|
30
|
-
clear: function() {
|
|
31
|
-
for (const key in memoryStore) {
|
|
32
|
-
delete memoryStore[key];
|
|
33
|
-
}
|
|
34
|
-
window.parent.postMessage({
|
|
35
|
-
type: 'storage-clear',
|
|
36
|
-
nonce: NONCE
|
|
37
|
-
}, '*');
|
|
38
|
-
},
|
|
39
|
-
key: function(index) {
|
|
40
|
-
const keys = Object.keys(memoryStore);
|
|
41
|
-
return keys[index] !== undefined ? keys[index] : null;
|
|
42
|
-
},
|
|
43
|
-
get length() {
|
|
44
|
-
return Object.keys(memoryStore).length;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
Object.defineProperty(window, 'localStorage', {
|
|
50
|
-
value: mockStorage,
|
|
51
|
-
writable: false,
|
|
52
|
-
configurable: true
|
|
53
|
-
});
|
|
54
|
-
} catch (e) {
|
|
55
|
-
window.localStorage = mockStorage;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
window.addEventListener('message', function(event) {
|
|
59
|
-
if (event.data.type === 'storage-sync-data' && event.data.nonce === NONCE) {
|
|
60
|
-
const data = event.data.data;
|
|
61
|
-
for (const key in data) {
|
|
62
|
-
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
63
|
-
memoryStore[key] = data[key];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (typeof window.initTheme === 'function') {
|
|
67
|
-
window.initTheme();
|
|
68
|
-
}
|
|
69
|
-
window.dispatchEvent(new Event('storage-ready'));
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
window.parent.postMessage({
|
|
74
|
-
type: 'storage-sync-request',
|
|
75
|
-
nonce: NONCE
|
|
76
|
-
}, '*');
|
|
77
|
-
})();
|
|
78
|
-
`
|
|
79
|
-
);
|
|
80
|
-
const parentStorageBridge = (nonce) => (
|
|
81
|
-
/* js */
|
|
82
|
-
`
|
|
83
|
-
(function() {
|
|
84
|
-
const host = document.querySelector('nuxt-error-overlay');
|
|
85
|
-
if (!host) return;
|
|
86
|
-
|
|
87
|
-
// Wait for shadow root to be attached
|
|
88
|
-
const checkShadow = setInterval(function() {
|
|
89
|
-
if (host.shadowRoot) {
|
|
90
|
-
clearInterval(checkShadow);
|
|
91
|
-
const iframe = host.shadowRoot.getElementById('frame');
|
|
92
|
-
if (!iframe) return;
|
|
93
|
-
|
|
94
|
-
const NONCE = ${JSON.stringify(nonce)}
|
|
95
|
-
|
|
96
|
-
window.addEventListener('message', function(event) {
|
|
97
|
-
if (!event.data || event.data.nonce !== NONCE) return;
|
|
98
|
-
|
|
99
|
-
const data = event.data;
|
|
100
|
-
|
|
101
|
-
if (data.type === 'storage-set') {
|
|
102
|
-
localStorage.setItem(data.key, data.value);
|
|
103
|
-
} else if (data.type === 'storage-remove') {
|
|
104
|
-
localStorage.removeItem(data.key);
|
|
105
|
-
} else if (data.type === 'storage-clear') {
|
|
106
|
-
localStorage.clear();
|
|
107
|
-
} else if (data.type === 'storage-sync-request') {
|
|
108
|
-
const allData = {};
|
|
109
|
-
for (let i = 0; i < localStorage.length; i++) {
|
|
110
|
-
const key = localStorage.key(i);
|
|
111
|
-
allData[key] = localStorage.getItem(key);
|
|
112
|
-
}
|
|
113
|
-
iframe.contentWindow.postMessage({
|
|
114
|
-
type: 'storage-sync-data',
|
|
115
|
-
data: allData,
|
|
116
|
-
nonce: NONCE
|
|
117
|
-
}, '*');
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}, 10);
|
|
122
|
-
})();
|
|
123
|
-
`
|
|
124
|
-
);
|
|
125
|
-
const errorCSS = (
|
|
126
|
-
/* css */
|
|
127
|
-
`
|
|
128
|
-
:host {
|
|
129
|
-
--preview-width: 240px;
|
|
130
|
-
--preview-height: 180px;
|
|
131
|
-
--base-width: 1200px;
|
|
132
|
-
--base-height: 900px;
|
|
133
|
-
--z-base: 999999998;
|
|
134
|
-
all: initial;
|
|
135
|
-
display: contents;
|
|
136
|
-
}
|
|
137
|
-
.sr-only {
|
|
138
|
-
position: absolute;
|
|
139
|
-
width: 1px;
|
|
140
|
-
height: 1px;
|
|
141
|
-
padding: 0;
|
|
142
|
-
margin: -1px;
|
|
143
|
-
overflow: hidden;
|
|
144
|
-
clip: rect(0, 0, 0, 0);
|
|
145
|
-
white-space: nowrap;
|
|
146
|
-
border-width: 0;
|
|
147
|
-
}
|
|
148
|
-
#frame {
|
|
149
|
-
position: fixed;
|
|
150
|
-
left: 0;
|
|
151
|
-
top: 0;
|
|
152
|
-
width: 100vw;
|
|
153
|
-
height: 100vh;
|
|
154
|
-
z-index: var(--z-base);
|
|
155
|
-
}
|
|
156
|
-
#frame[inert] {
|
|
157
|
-
right: 5px;
|
|
158
|
-
bottom: 5px;
|
|
159
|
-
left: auto;
|
|
160
|
-
top: auto;
|
|
161
|
-
width: var(--base-width);
|
|
162
|
-
height: var(--base-height);
|
|
163
|
-
transform: scale(calc(240 / 1200));
|
|
164
|
-
transform-origin: bottom right;
|
|
165
|
-
overflow: hidden;
|
|
166
|
-
border-radius: calc(1200 * 8px / 240);
|
|
167
|
-
}
|
|
168
|
-
#preview {
|
|
169
|
-
position: fixed;
|
|
170
|
-
right: 5px;
|
|
171
|
-
bottom: 5px;
|
|
172
|
-
width: var(--preview-width);
|
|
173
|
-
height: var(--preview-height);
|
|
174
|
-
overflow: hidden;
|
|
175
|
-
border-radius: 8px;
|
|
176
|
-
pointer-events: none;
|
|
177
|
-
z-index: var(--z-base);
|
|
178
|
-
background: white;
|
|
179
|
-
display: none;
|
|
180
|
-
}
|
|
181
|
-
#frame:not([inert]) + #preview {
|
|
182
|
-
display: block;
|
|
183
|
-
}
|
|
184
|
-
#toggle {
|
|
185
|
-
position: fixed;
|
|
186
|
-
right: 5px;
|
|
187
|
-
bottom: 5px;
|
|
188
|
-
width: var(--preview-width);
|
|
189
|
-
height: var(--preview-height);
|
|
190
|
-
background: none;
|
|
191
|
-
border: 3px solid #00DC82;
|
|
192
|
-
border-radius: 8px;
|
|
193
|
-
cursor: pointer;
|
|
194
|
-
opacity: 0.8;
|
|
195
|
-
transition: opacity 0.2s, box-shadow 0.2s;
|
|
196
|
-
z-index: calc(var(--z-base) + 1);
|
|
197
|
-
}
|
|
198
|
-
#toggle:hover,
|
|
199
|
-
#toggle:focus {
|
|
200
|
-
opacity: 1;
|
|
201
|
-
box-shadow: 0 0 20px rgba(0, 220, 130, 0.6);
|
|
202
|
-
}
|
|
203
|
-
#toggle:focus-visible {
|
|
204
|
-
outline: 3px solid #00DC82;
|
|
205
|
-
outline-offset: 3px;
|
|
206
|
-
box-shadow: 0 0 24px rgba(0, 220, 130, 0.8);
|
|
207
|
-
}
|
|
208
|
-
@media (prefers-reduced-motion: reduce) {
|
|
209
|
-
#toggle {
|
|
210
|
-
transition: none;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
`
|
|
214
|
-
);
|
|
215
|
-
function webComponentScript(base64HTML) {
|
|
216
|
-
return (
|
|
217
|
-
/* js */
|
|
218
|
-
`
|
|
219
|
-
(function() {
|
|
220
|
-
try {
|
|
221
|
-
const host = document.querySelector('nuxt-error-overlay');
|
|
222
|
-
if (!host) return;
|
|
223
|
-
|
|
224
|
-
const shadow = host.attachShadow({ mode: 'open' });
|
|
225
|
-
|
|
226
|
-
// Create elements
|
|
227
|
-
const style = document.createElement('style');
|
|
228
|
-
style.textContent = ${JSON.stringify(errorCSS)};
|
|
229
|
-
|
|
230
|
-
const iframe = document.createElement('iframe');
|
|
231
|
-
iframe.id = 'frame';
|
|
232
|
-
iframe.src = 'data:text/html;base64,${base64HTML}';
|
|
233
|
-
iframe.title = 'Detailed error stack trace';
|
|
234
|
-
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
|
|
235
|
-
|
|
236
|
-
const preview = document.createElement('div');
|
|
237
|
-
preview.id = 'preview';
|
|
238
|
-
|
|
239
|
-
const button = document.createElement('button');
|
|
240
|
-
button.id = 'toggle';
|
|
241
|
-
button.setAttribute('aria-expanded', 'true');
|
|
242
|
-
button.setAttribute('type', 'button');
|
|
243
|
-
button.innerHTML = '<span class="sr-only">Toggle detailed error view</span>';
|
|
244
|
-
|
|
245
|
-
const liveRegion = document.createElement('div');
|
|
246
|
-
liveRegion.setAttribute('role', 'status');
|
|
247
|
-
liveRegion.setAttribute('aria-live', 'polite');
|
|
248
|
-
liveRegion.className = 'sr-only';
|
|
249
|
-
|
|
250
|
-
// Update preview snapshot
|
|
251
|
-
function updatePreview() {
|
|
252
|
-
try {
|
|
253
|
-
let previewIframe = preview.querySelector('iframe');
|
|
254
|
-
if (!previewIframe) {
|
|
255
|
-
previewIframe = document.createElement('iframe');
|
|
256
|
-
previewIframe.style.cssText = 'width: 1200px; height: 900px; transform: scale(0.2); transform-origin: top left; border: none;';
|
|
257
|
-
previewIframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
|
|
258
|
-
preview.appendChild(previewIframe);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const doctype = document.doctype ? '<!DOCTYPE ' + document.doctype.name + '>' : '';
|
|
262
|
-
const cleanedHTML = document.documentElement.outerHTML
|
|
263
|
-
.replace(/<nuxt-error-overlay[^>]*>.*?<\\/nuxt-error-overlay>/gs, '')
|
|
264
|
-
.replace(/<script[^>]*>.*?<\\/script>/gs, '');
|
|
265
|
-
|
|
266
|
-
const iframeDoc = previewIframe.contentDocument || previewIframe.contentWindow.document;
|
|
267
|
-
iframeDoc.open();
|
|
268
|
-
iframeDoc.write(doctype + cleanedHTML);
|
|
269
|
-
iframeDoc.close();
|
|
270
|
-
} catch (error) {
|
|
271
|
-
console.error('Failed to update preview:', error);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function toggleView() {
|
|
276
|
-
const isMinimized = iframe.hasAttribute('inert');
|
|
277
|
-
|
|
278
|
-
if (isMinimized) {
|
|
279
|
-
updatePreview();
|
|
280
|
-
iframe.removeAttribute('inert');
|
|
281
|
-
button.setAttribute('aria-expanded', 'true');
|
|
282
|
-
liveRegion.textContent = 'Showing detailed error view';
|
|
283
|
-
setTimeout(function() {
|
|
284
|
-
try { iframe.contentWindow.focus(); } catch {}
|
|
285
|
-
}, 100);
|
|
286
|
-
} else {
|
|
287
|
-
iframe.setAttribute('inert', '');
|
|
288
|
-
button.setAttribute('aria-expanded', 'false');
|
|
289
|
-
liveRegion.textContent = 'Showing error page';
|
|
290
|
-
button.focus();
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
button.onclick = toggleView;
|
|
295
|
-
|
|
296
|
-
document.addEventListener('keydown', function(e) {
|
|
297
|
-
if ((e.key === 'Escape' || e.key === 'Esc') && !iframe.hasAttribute('inert')) {
|
|
298
|
-
toggleView();
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
// Append to shadow DOM
|
|
303
|
-
shadow.appendChild(style);
|
|
304
|
-
shadow.appendChild(liveRegion);
|
|
305
|
-
shadow.appendChild(iframe);
|
|
306
|
-
shadow.appendChild(preview);
|
|
307
|
-
shadow.appendChild(button);
|
|
308
|
-
|
|
309
|
-
// Initialize preview
|
|
310
|
-
setTimeout(updatePreview, 100);
|
|
311
|
-
|
|
312
|
-
} catch (error) {
|
|
313
|
-
console.error('Failed to initialize Nuxt error overlay:', error);
|
|
314
|
-
}
|
|
315
|
-
})();
|
|
316
|
-
`
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
export function generateErrorOverlayHTML(html) {
|
|
320
|
-
const nonce = Array.from(crypto.getRandomValues(new Uint8Array(16)), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
321
|
-
const errorPage = html.replace("<head>", `<head><script>${iframeStorageBridge(nonce)}<\/script>`);
|
|
322
|
-
const base64HTML = Buffer.from(errorPage, "utf8").toString("base64");
|
|
323
|
-
return `
|
|
324
|
-
<script>${parentStorageBridge(nonce)}<\/script>
|
|
325
|
-
<nuxt-error-overlay></nuxt-error-overlay>
|
|
326
|
-
<script>${webComponentScript(base64HTML)}<\/script>
|
|
327
|
-
`;
|
|
328
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { H3Event } from 'h3';
|
|
2
|
-
/**
|
|
3
|
-
* Nitro internal functions extracted from https://github.com/nitrojs/nitro/blob/main/src/runtime/internal/utils.ts
|
|
4
|
-
*/
|
|
5
|
-
export declare function isJsonRequest(event: H3Event): boolean;
|
|
6
|
-
export declare function hasReqHeader(event: H3Event, name: string, includes: string): boolean | "" | undefined;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getRequestHeader } from "h3";
|
|
2
|
-
export function isJsonRequest(event) {
|
|
3
|
-
if (hasReqHeader(event, "accept", "text/html")) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
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");
|
|
7
|
-
}
|
|
8
|
-
export function hasReqHeader(event, name, includes) {
|
|
9
|
-
const value = getRequestHeader(event, name);
|
|
10
|
-
return value && typeof value === "string" && value.toLowerCase().includes(includes);
|
|
11
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { joinRelativeURL } from "ufo";
|
|
2
|
-
import { useRuntimeConfig } from "nitropack/runtime";
|
|
3
|
-
export function baseURL() {
|
|
4
|
-
return useRuntimeConfig().app.baseURL;
|
|
5
|
-
}
|
|
6
|
-
export function buildAssetsDir() {
|
|
7
|
-
return useRuntimeConfig().app.buildAssetsDir;
|
|
8
|
-
}
|
|
9
|
-
export function buildAssetsURL(...path) {
|
|
10
|
-
return joinRelativeURL(publicAssetsURL(), buildAssetsDir(), ...path);
|
|
11
|
-
}
|
|
12
|
-
export function publicAssetsURL(...path) {
|
|
13
|
-
const app = useRuntimeConfig().app;
|
|
14
|
-
const publicBase = app.cdnURL || app.baseURL;
|
|
15
|
-
return path.length ? joinRelativeURL(publicBase, ...path) : publicBase;
|
|
16
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { H3Event } from 'h3';
|
|
2
|
-
import type { NuxtSSRContext } from '#app';
|
|
3
|
-
import type { NuxtPayload } from '#app/nuxt';
|
|
4
|
-
export declare function createSSRContext(event: H3Event): NuxtSSRContext;
|
|
5
|
-
export declare function setSSRError(ssrContext: NuxtSSRContext, error: NuxtPayload['error'] & {
|
|
6
|
-
url: string;
|
|
7
|
-
}): void;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "nitropack/runtime";
|
|
2
|
-
import { createHead } from "@unhead/vue/server";
|
|
3
|
-
import { sharedPrerenderCache } from "../cache.js";
|
|
4
|
-
import unheadOptions from "#internal/unhead-options.mjs";
|
|
5
|
-
const PRERENDER_NO_SSR_ROUTES = /* @__PURE__ */ new Set(["/index.html", "/200.html", "/404.html"]);
|
|
6
|
-
export function createSSRContext(event) {
|
|
7
|
-
const ssrContext = {
|
|
8
|
-
url: event.path,
|
|
9
|
-
event,
|
|
10
|
-
runtimeConfig: useRuntimeConfig(event),
|
|
11
|
-
noSSR: !!process.env.NUXT_NO_SSR || event.context.nuxt?.noSSR || (import.meta.prerender ? PRERENDER_NO_SSR_ROUTES.has(event.path) : false),
|
|
12
|
-
head: createHead(unheadOptions),
|
|
13
|
-
error: false,
|
|
14
|
-
nuxt: void 0,
|
|
15
|
-
/* NuxtApp */
|
|
16
|
-
payload: {},
|
|
17
|
-
_payloadReducers: /* @__PURE__ */ Object.create(null),
|
|
18
|
-
modules: /* @__PURE__ */ new Set()
|
|
19
|
-
};
|
|
20
|
-
if (import.meta.prerender) {
|
|
21
|
-
if (process.env.NUXT_SHARED_DATA) {
|
|
22
|
-
ssrContext._sharedPrerenderCache = sharedPrerenderCache;
|
|
23
|
-
}
|
|
24
|
-
ssrContext.payload.prerenderedAt = Date.now();
|
|
25
|
-
}
|
|
26
|
-
return ssrContext;
|
|
27
|
-
}
|
|
28
|
-
export function setSSRError(ssrContext, error) {
|
|
29
|
-
ssrContext.error = true;
|
|
30
|
-
ssrContext.payload = { error };
|
|
31
|
-
ssrContext.url = error.url;
|
|
32
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { NuxtSSRContext } from 'nuxt/app';
|
|
2
|
-
export declare const getSSRRenderer: () => Promise<{
|
|
3
|
-
rendererContext: import("vue-bundle-renderer/runtime").RendererContext;
|
|
4
|
-
renderToString(ssrContext: import("vue-bundle-renderer/runtime").SSRContext): Promise<{
|
|
5
|
-
html: string;
|
|
6
|
-
renderResourceHeaders: () => Record<string, string>;
|
|
7
|
-
renderResourceHints: () => string;
|
|
8
|
-
renderStyles: () => string;
|
|
9
|
-
renderScripts: () => string;
|
|
10
|
-
}>;
|
|
11
|
-
}>;
|
|
12
|
-
export declare function getRenderer(ssrContext: NuxtSSRContext): Promise<{
|
|
13
|
-
rendererContext: import("vue-bundle-renderer/runtime").RendererContext;
|
|
14
|
-
renderToString(ssrContext: import("vue-bundle-renderer/runtime").SSRContext): Promise<{
|
|
15
|
-
html: string;
|
|
16
|
-
renderResourceHeaders: () => Record<string, string>;
|
|
17
|
-
renderResourceHints: () => string;
|
|
18
|
-
renderStyles: () => string;
|
|
19
|
-
renderScripts: () => string;
|
|
20
|
-
}>;
|
|
21
|
-
}>;
|
|
22
|
-
export declare const getSSRStyles: () => Promise<Record<string, () => Promise<string[]>>>;
|