8958867d91
https://github.com/vercel/edge-runtime/compare/v1.1.0-beta.27...v1.1.0-beta.31 Related: https://github.com/vercel/next.js/issues/38658
229 lines
7.4 KiB
JavaScript
229 lines
7.4 KiB
JavaScript
"use strict";
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
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/primitives/structured-clone.js
|
|
var structured_clone_exports = {};
|
|
__export(structured_clone_exports, {
|
|
structuredClone: () => esm_default
|
|
});
|
|
module.exports = __toCommonJS(structured_clone_exports);
|
|
|
|
// ../../node_modules/.pnpm/@ungap+structured-clone@1.0.1/node_modules/@ungap/structured-clone/esm/types.js
|
|
var VOID = -1;
|
|
var PRIMITIVE = 0;
|
|
var ARRAY = 1;
|
|
var OBJECT = 2;
|
|
var DATE = 3;
|
|
var REGEXP = 4;
|
|
var MAP = 5;
|
|
var SET = 6;
|
|
var ERROR = 7;
|
|
var BIGINT = 8;
|
|
|
|
// ../../node_modules/.pnpm/@ungap+structured-clone@1.0.1/node_modules/@ungap/structured-clone/esm/deserialize.js
|
|
var env = typeof self === "object" ? self : globalThis;
|
|
var deserializer = /* @__PURE__ */ __name(($, _) => {
|
|
const as = /* @__PURE__ */ __name((out, index) => {
|
|
$.set(index, out);
|
|
return out;
|
|
}, "as");
|
|
const unpair = /* @__PURE__ */ __name((index) => {
|
|
if ($.has(index))
|
|
return $.get(index);
|
|
const [type, value] = _[index];
|
|
switch (type) {
|
|
case PRIMITIVE:
|
|
case VOID:
|
|
return as(value, index);
|
|
case ARRAY: {
|
|
const arr = as([], index);
|
|
for (const index2 of value)
|
|
arr.push(unpair(index2));
|
|
return arr;
|
|
}
|
|
case OBJECT: {
|
|
const object = as({}, index);
|
|
for (const [key, index2] of value)
|
|
object[unpair(key)] = unpair(index2);
|
|
return object;
|
|
}
|
|
case DATE:
|
|
return as(new Date(value), index);
|
|
case REGEXP: {
|
|
const { source, flags } = value;
|
|
return as(new RegExp(source, flags), index);
|
|
}
|
|
case MAP: {
|
|
const map = as(/* @__PURE__ */ new Map(), index);
|
|
for (const [key, index2] of value)
|
|
map.set(unpair(key), unpair(index2));
|
|
return map;
|
|
}
|
|
case SET: {
|
|
const set = as(/* @__PURE__ */ new Set(), index);
|
|
for (const index2 of value)
|
|
set.add(unpair(index2));
|
|
return set;
|
|
}
|
|
case ERROR: {
|
|
const { name, message } = value;
|
|
return as(new env[name](message), index);
|
|
}
|
|
case BIGINT:
|
|
return as(BigInt(value), index);
|
|
case "BigInt":
|
|
return as(Object(BigInt(value)), index);
|
|
}
|
|
return as(new env[type](value), index);
|
|
}, "unpair");
|
|
return unpair;
|
|
}, "deserializer");
|
|
var deserialize = /* @__PURE__ */ __name((serialized) => deserializer(/* @__PURE__ */ new Map(), serialized)(0), "deserialize");
|
|
|
|
// ../../node_modules/.pnpm/@ungap+structured-clone@1.0.1/node_modules/@ungap/structured-clone/esm/serialize.js
|
|
var EMPTY = "";
|
|
var { toString } = {};
|
|
var { keys } = Object;
|
|
var typeOf = /* @__PURE__ */ __name((value) => {
|
|
const type = typeof value;
|
|
if (type !== "object" || !value)
|
|
return [PRIMITIVE, type];
|
|
const asString = toString.call(value).slice(8, -1);
|
|
switch (asString) {
|
|
case "Array":
|
|
return [ARRAY, EMPTY];
|
|
case "Object":
|
|
return [OBJECT, EMPTY];
|
|
case "Date":
|
|
return [DATE, EMPTY];
|
|
case "RegExp":
|
|
return [REGEXP, EMPTY];
|
|
case "Map":
|
|
return [MAP, EMPTY];
|
|
case "Set":
|
|
return [SET, EMPTY];
|
|
}
|
|
if (asString.includes("Array"))
|
|
return [ARRAY, asString];
|
|
if (asString.includes("Error"))
|
|
return [ERROR, asString];
|
|
return [OBJECT, asString];
|
|
}, "typeOf");
|
|
var shouldSkip = /* @__PURE__ */ __name(([TYPE, type]) => TYPE === PRIMITIVE && (type === "function" || type === "symbol"), "shouldSkip");
|
|
var serializer = /* @__PURE__ */ __name((strict, json, $, _) => {
|
|
const as = /* @__PURE__ */ __name((out, value) => {
|
|
const index = _.push(out) - 1;
|
|
$.set(value, index);
|
|
return index;
|
|
}, "as");
|
|
const pair = /* @__PURE__ */ __name((value) => {
|
|
if ($.has(value))
|
|
return $.get(value);
|
|
let [TYPE, type] = typeOf(value);
|
|
switch (TYPE) {
|
|
case PRIMITIVE: {
|
|
let entry = value;
|
|
switch (type) {
|
|
case "bigint":
|
|
TYPE = BIGINT;
|
|
entry = value.toString();
|
|
break;
|
|
case "function":
|
|
case "symbol":
|
|
if (strict)
|
|
throw new TypeError("unable to serialize " + type);
|
|
entry = null;
|
|
break;
|
|
case "undefined":
|
|
return as([VOID], value);
|
|
}
|
|
return as([TYPE, entry], value);
|
|
}
|
|
case ARRAY: {
|
|
if (type)
|
|
return as([type, [...value]], value);
|
|
const arr = [];
|
|
const index = as([TYPE, arr], value);
|
|
for (const entry of value)
|
|
arr.push(pair(entry));
|
|
return index;
|
|
}
|
|
case OBJECT: {
|
|
if (type) {
|
|
switch (type) {
|
|
case "BigInt":
|
|
return as([type, value.toString()], value);
|
|
case "Boolean":
|
|
case "Number":
|
|
case "String":
|
|
return as([type, value.valueOf()], value);
|
|
}
|
|
}
|
|
if (json && "toJSON" in value)
|
|
return pair(value.toJSON());
|
|
const entries = [];
|
|
const index = as([TYPE, entries], value);
|
|
for (const key of keys(value)) {
|
|
if (strict || !shouldSkip(typeOf(value[key])))
|
|
entries.push([pair(key), pair(value[key])]);
|
|
}
|
|
return index;
|
|
}
|
|
case DATE:
|
|
return as([TYPE, value.toISOString()], value);
|
|
case REGEXP: {
|
|
const { source, flags } = value;
|
|
return as([TYPE, { source, flags }], value);
|
|
}
|
|
case MAP: {
|
|
const entries = [];
|
|
const index = as([TYPE, entries], value);
|
|
for (const [key, entry] of value) {
|
|
if (strict || !(shouldSkip(typeOf(key)) || shouldSkip(typeOf(entry))))
|
|
entries.push([pair(key), pair(entry)]);
|
|
}
|
|
return index;
|
|
}
|
|
case SET: {
|
|
const entries = [];
|
|
const index = as([TYPE, entries], value);
|
|
for (const entry of value) {
|
|
if (strict || !shouldSkip(typeOf(entry)))
|
|
entries.push(pair(entry));
|
|
}
|
|
return index;
|
|
}
|
|
}
|
|
const { message } = value;
|
|
return as([TYPE, { name: type, message }], value);
|
|
}, "pair");
|
|
return pair;
|
|
}, "serializer");
|
|
var serialize = /* @__PURE__ */ __name((value, { json, lossy } = {}) => {
|
|
const _ = [];
|
|
return serializer(!(json || lossy), !!json, /* @__PURE__ */ new Map(), _)(value), _;
|
|
}, "serialize");
|
|
|
|
// ../../node_modules/.pnpm/@ungap+structured-clone@1.0.1/node_modules/@ungap/structured-clone/esm/index.js
|
|
var esm_default = typeof structuredClone === "function" ? (any, options) => options && ("json" in options || "lossy" in options) ? deserialize(serialize(any, options)) : structuredClone(any) : (any, options) => deserialize(serialize(any, options));
|
|
// Annotate the CommonJS export names for ESM import in node:
|
|
0 && (module.exports = {
|
|
structuredClone
|
|
});
|