@edgeone/nuxt-pages
Version:
A professional deployment package that seamlessly deploys your Nuxt 3/4 applications to Tencent Cloud EdgeOne platform with optimized performance and intelligent caching.
192 lines (184 loc) • 6.93 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/run/storage/storage.cts
var storage_exports = {};
__export(storage_exports, {
getMemoizedKeyValueStoreBackedByRegionalBlobStore: () => getMemoizedKeyValueStoreBackedByRegionalBlobStore,
setFetchBeforeNuxtPatchedIt: () => setFetchBeforeNuxtPatchedIt,
setInMemoryCacheMaxSizeFromNuxtConfig: () => setInMemoryCacheMaxSizeFromNuxtConfig
});
module.exports = __toCommonJS(storage_exports);
// node_modules/lru-cache/dist/esm/index.js
var perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
var PROCESS = typeof process === "object" && !!process ? process : {};
var emitWarning = (msg, type, code, fn) => {
typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
};
var AC = globalThis.AbortController;
var AS = globalThis.AbortSignal;
if (typeof AC === "undefined") {
AS = class AbortSignal {
onabort;
_onabort = [];
reason;
aborted = false;
addEventListener(_, fn) {
this._onabort.push(fn);
}
};
AC = class AbortController {
constructor() {
warnACPolyfill();
}
signal = new AS();
abort(reason) {
if (this.signal.aborted)
return;
this.signal.reason = reason;
this.signal.aborted = true;
for (const fn of this.signal._onabort) {
fn(reason);
}
this.signal.onabort?.(reason);
}
};
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1";
const warnACPolyfill = () => {
if (!printACPolyfillWarning)
return;
printACPolyfillWarning = false;
emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", warnACPolyfill);
};
}
var TYPE = Symbol("type");
// node_modules/@netlify/functions/dist/internal.js
var import_process = require("process");
var systemLogTag = "__nfSystemLog";
var serializeError = (error) => {
const cause = error?.cause instanceof Error ? serializeError(error.cause) : error.cause;
return {
error: error.message,
error_cause: cause,
error_stack: error.stack
};
};
var SystemLogger = class _SystemLogger {
fields;
logLevel;
constructor(fields = {}, logLevel = 2) {
this.fields = fields;
this.logLevel = logLevel;
}
doLog(logger, message) {
if (import_process.env.NETLIFY_DEV && !import_process.env.NETLIFY_ENABLE_SYSTEM_LOGGING) {
return;
}
logger(systemLogTag, JSON.stringify({ msg: message, fields: this.fields }));
}
log(message) {
if (this.logLevel > 2) {
return;
}
this.doLog(console.log, message);
}
debug(message) {
if (this.logLevel > 1) {
return;
}
this.doLog(console.debug, message);
}
error(message) {
if (this.logLevel > 3) {
return;
}
this.doLog(console.error, message);
}
withLogLevel(level) {
return new _SystemLogger(this.fields, level);
}
withFields(fields) {
return new _SystemLogger(
{
...this.fields,
...fields
},
this.logLevel
);
}
withError(error) {
const fields = error instanceof Error ? serializeError(error) : { error };
return this.withFields(fields);
}
};
var systemLogger = new SystemLogger();
// src/run/handlers/request-context.cts
var REQUEST_CONTEXT_GLOBAL_KEY = Symbol.for("nf-request-context-async-local-storage");
var REQUEST_COUNTER_KEY = Symbol.for("nf-request-counter");
// src/run/storage/request-scoped-in-memory-cache.cts
var NullValue = Symbol.for("null-value");
var IN_MEMORY_CACHE_MAX_SIZE = Symbol.for("nf-in-memory-cache-max-size");
var IN_MEMORY_LRU_CACHE = Symbol.for("nf-in-memory-lru-cache");
var extendedGlobalThis = globalThis;
var DEFAULT_FALLBACK_MAX_SIZE = 50 * 1024 * 1024;
function setInMemoryCacheMaxSizeFromNuxtConfig(size) {
if (typeof size === "number") {
extendedGlobalThis[IN_MEMORY_CACHE_MAX_SIZE] = size;
}
}
// src/run/storage/regional-blob-store.cts
var FETCH_BEFORE_NUXT_PATCHED_IT = Symbol.for("nf-not-patched-fetch");
var extendedGlobalThis2 = globalThis;
function attemptToGetOriginalFetch(fetch) {
return fetch._nuxtOriginalFetch ?? fetch;
}
function forceOptOutOfUsingDataCache(fetch) {
return (input, init) => {
return fetch(input, {
...init,
next: {
...init?.next,
// setting next.internal = true should prevent from trying to use data cache
// https://github.com/vercel/next.js/blob/fa214c74c1d8023098c0e94e57f917ef9f1afd1a/packages/next/src/server/lib/patch-fetch.ts#L174
// https://github.com/vercel/next.js/blob/fa214c74c1d8023098c0e94e57f917ef9f1afd1a/packages/next/src/server/lib/patch-fetch.ts#L210-L213
// this is last line of defense in case we didn't manage to get unpatched fetch that will not affect
// fetch if it's unpatched so it should be safe to apply always if we aren't sure if we use patched fetch
// @ts-expect-error - this is an internal field that Next.js doesn't add to its global
// type overrides for RequestInit type (like `next.revalidate` or `next.tags`)
internal: true
}
});
};
}
var setFetchBeforeNuxtPatchedIt = (fetch) => {
extendedGlobalThis2[FETCH_BEFORE_NUXT_PATCHED_IT] = forceOptOutOfUsingDataCache(
attemptToGetOriginalFetch(fetch)
);
};
var fetchBeforeNuxtPatchedItFallback = forceOptOutOfUsingDataCache(
attemptToGetOriginalFetch(globalThis.fetch)
);
// src/run/storage/storage.cts
var getMemoizedKeyValueStoreBackedByRegionalBlobStore = (...args) => {
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
getMemoizedKeyValueStoreBackedByRegionalBlobStore,
setFetchBeforeNuxtPatchedIt,
setInMemoryCacheMaxSizeFromNuxtConfig
});