Skip to content

Commit

Permalink
bump edge-runtime packages to beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Schniz committed May 28, 2023
1 parent 5d8d181 commit 24672bd
Show file tree
Hide file tree
Showing 52 changed files with 10,149 additions and 8,087 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@babel/plugin-proposal-object-rest-spread": "7.14.7",
"@babel/preset-flow": "7.14.5",
"@babel/preset-react": "7.14.5",
"@edge-runtime/jest-environment": "2.0.8",
"@edge-runtime/jest-environment": "2.2.0-beta.10",
"@fullhuman/postcss-purgecss": "1.3.0",
"@mdx-js/loader": "2.2.1",
"@mdx-js/react": "2.2.1",
Expand Down
7 changes: 4 additions & 3 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@
"@babel/traverse": "7.18.0",
"@babel/types": "7.18.0",
"@capsizecss/metrics": "1.1.0",
"@edge-runtime/cookies": "3.0.6",
"@edge-runtime/primitives": "2.1.2",
"@edge-runtime/cookies": "3.2.0-beta.1",
"@edge-runtime/ponyfill": "2.3.0-beta.0",
"@edge-runtime/primitives": "2.2.0-beta.9",
"@hapi/accept": "5.0.2",
"@jest/transform": "29.5.0",
"@jest/types": "29.5.0",
Expand Down Expand Up @@ -220,7 +221,7 @@
"debug": "4.1.1",
"devalue": "2.0.1",
"domain-browser": "4.19.0",
"edge-runtime": "2.1.4",
"edge-runtime": "2.3.0-beta.9",
"events": "3.3.0",
"find-cache-dir": "3.3.1",
"find-up": "4.1.0",
Expand Down
42 changes: 36 additions & 6 deletions packages/next/src/compiled/@edge-runtime/cookies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ module.exports = __toCommonJS(src_exports);

// src/serialize.ts
function serialize(c) {
var _a;
const attrs = [
"path" in c && c.path && `Path=${c.path}`,
"expires" in c && (c.expires || c.expires === 0) && `Expires=${(typeof c.expires === "number" ? new Date(c.expires) : c.expires).toUTCString()}`,
"maxAge" in c && c.maxAge && `Max-Age=${c.maxAge}`,
"maxAge" in c && typeof c.maxAge === "number" && `Max-Age=${c.maxAge}`,
"domain" in c && c.domain && `Domain=${c.domain}`,
"secure" in c && c.secure && "Secure",
"httpOnly" in c && c.httpOnly && "HttpOnly",
"sameSite" in c && c.sameSite && `SameSite=${c.sameSite}`
].filter(Boolean);
return `${c.name}=${encodeURIComponent(c.value ?? "")}; ${attrs.join("; ")}`;
return `${c.name}=${encodeURIComponent((_a = c.value) != null ? _a : "")}; ${attrs.join("; ")}`;
}
function parseCookieString(cookie) {
const map = /* @__PURE__ */ new Map();
Expand All @@ -46,7 +47,7 @@ function parseCookieString(cookie) {
const splitAt = pair.indexOf("=");
const [key, value] = [pair.slice(0, splitAt), pair.slice(splitAt + 1)];
try {
map.set(key, decodeURIComponent(value ?? "true"));
map.set(key, decodeURIComponent(value != null ? value : "true"));
} catch {
}
}
Expand Down Expand Up @@ -91,6 +92,7 @@ function parseSameSite(string) {
// src/request-cookies.ts
var RequestCookies = class {
constructor(requestHeaders) {
/** @internal */
this._parsed = /* @__PURE__ */ new Map();
this._headers = requestHeaders;
const header = requestHeaders.get("cookie");
Expand All @@ -104,6 +106,9 @@ var RequestCookies = class {
[Symbol.iterator]() {
return this._parsed[Symbol.iterator]();
}
/**
* The amount of cookies received from the client
*/
get size() {
return this._parsed.size;
}
Expand Down Expand Up @@ -133,6 +138,9 @@ var RequestCookies = class {
);
return this;
}
/**
* Delete the cookies matching the passed name or names in the request.
*/
delete(names) {
const map = this._parsed;
const result = !Array.isArray(names) ? map.delete(names) : names.map((name) => map.delete(name));
Expand All @@ -142,10 +150,16 @@ var RequestCookies = class {
);
return result;
}
/**
* Delete all the cookies in the cookies in the request.
*/
clear() {
this.delete(Array.from(this._parsed.keys()));
return this;
}
/**
* Format the cookies in the request as a string for logging
*/
[Symbol.for("edge-runtime.inspect.custom")]() {
return `RequestCookies ${JSON.stringify(Object.fromEntries(this._parsed))}`;
}
Expand All @@ -157,21 +171,31 @@ var RequestCookies = class {
// src/response-cookies.ts
var ResponseCookies = class {
constructor(responseHeaders) {
/** @internal */
this._parsed = /* @__PURE__ */ new Map();
var _a;
var _a, _b, _c;
this._headers = responseHeaders;
const setCookie = ((_a = responseHeaders.getAll) == null ? void 0 : _a.call(responseHeaders, "set-cookie")) ?? responseHeaders.get("set-cookie") ?? [];
const setCookie = (
// @ts-expect-error See https://github.com/whatwg/fetch/issues/973
(_c = (_b = (_a = responseHeaders.getAll) == null ? void 0 : _a.call(responseHeaders, "set-cookie")) != null ? _b : responseHeaders.get("set-cookie")) != null ? _c : []
);
const cookieStrings = Array.isArray(setCookie) ? setCookie : splitCookiesString(setCookie);
for (const cookieString of cookieStrings) {
const parsed = parseSetCookieString(cookieString);
if (parsed)
this._parsed.set(parsed.name, parsed);
}
}
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-get CookieStore#get} without the Promise.
*/
get(...args) {
const key = typeof args[0] === "string" ? args[0] : args[0].name;
return this._parsed.get(key);
}
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-getAll CookieStore#getAll} without the Promise.
*/
getAll(...args) {
var _a;
const all = Array.from(this._parsed.values());
Expand All @@ -181,16 +205,22 @@ var ResponseCookies = class {
const key = typeof args[0] === "string" ? args[0] : (_a = args[0]) == null ? void 0 : _a.name;
return all.filter((c) => c.name === key);
}
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-set CookieStore#set} without the Promise.
*/
set(...args) {
const [name, value, cookie] = args.length === 1 ? [args[0].name, args[0].value, args[0]] : args;
const map = this._parsed;
map.set(name, normalizeCookie({ name, value, ...cookie }));
replace(map, this._headers);
return this;
}
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-delete CookieStore#delete} without the Promise.
*/
delete(...args) {
const name = typeof args[0] === "string" ? args[0] : args[0].name;
return this.set({ name, value: "", expires: new Date(0) });
return this.set({ name, value: "", expires: /* @__PURE__ */ new Date(0) });
}
[Symbol.for("edge-runtime.inspect.custom")]() {
return `ResponseCookies ${JSON.stringify(Object.fromEntries(this._parsed))}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"@edge-runtime/cookies","version":"3.0.6","main":"./index.js","license":"MPL-2.0"}
{"name":"@edge-runtime/cookies","version":"3.2.0-beta.1","main":"./index.js","license":"MPL-2.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@edge-runtime/primitives'
43 changes: 43 additions & 0 deletions packages/next/src/compiled/@edge-runtime/ponyfill/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module.exports =
typeof EdgeRuntime === 'string' ? edge() : require("next/dist/compiled/@edge-runtime/primitives")

function edge() {
return {
AbortController,
AbortSignal,
atob,
Blob,
btoa,
console,
crypto,
Crypto,
CryptoKey,
DOMException,
Event,
EventTarget,
fetch,
FetchEvent,
File,
FormData,
Headers,
PromiseRejectionEvent,
ReadableStream,
ReadableStreamBYOBReader,
ReadableStreamDefaultReader,
Request,
Response,
structuredClone,
SubtleCrypto,
TextDecoder,
TextDecoderStream,
TextEncoder,
TextEncoderStream,
TransformStream,
URL,
URLPattern,
URLSearchParams,
WebSocket,
WritableStream,
WritableStreamDefaultWriter,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"@edge-runtime/ponyfill","version":"2.3.0-beta.0","main":"./index.js","types":"./index.d.ts","license":"MPL-2.0"}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ __export(abort_controller_exports, {
DOMException: () => DOMException
});
module.exports = __toCommonJS(abort_controller_exports);
var import_events = require("./events");
var kSignal = Symbol("kSignal");
var kAborted = Symbol("kAborted");
var kReason = Symbol("kReason");
Expand All @@ -43,7 +42,7 @@ var DOMException = class extends Error {
};
__name(DOMException, "DOMException");
function createAbortSignal() {
const signal = new import_events.EventTarget();
const signal = new EventTarget();
Object.setPrototypeOf(signal, AbortSignal.prototype);
signal[kAborted] = false;
signal[kReason] = void 0;
Expand All @@ -60,7 +59,7 @@ function abortSignalAbort(signal, reason) {
}
signal[kReason] = reason;
signal[kAborted] = true;
signal.dispatchEvent(new import_events.Event("abort"));
signal.dispatchEvent(new Event("abort"));
}
__name(abortSignalAbort, "abortSignalAbort");
var AbortController = class {
Expand All @@ -75,7 +74,7 @@ var AbortController = class {
}
};
__name(AbortController, "AbortController");
var AbortSignal = class extends import_events.EventTarget {
var AbortSignal = class extends EventTarget {
constructor() {
throw new TypeError("Illegal constructor.");
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions packages/next/src/compiled/@edge-runtime/primitives/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ var __copyProps = (to, from, except, desc) => {
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
Expand Down Expand Up @@ -364,7 +368,7 @@ var require_Blob = __commonJS({
opts = opts || {};
var a = Blob3.call(this, chunks, opts) || this;
a.name = name.replace(/\//g, ":");
a.lastModifiedDate = opts.lastModified ? new Date(opts.lastModified) : new Date();
a.lastModifiedDate = opts.lastModified ? new Date(opts.lastModified) : /* @__PURE__ */ new Date();
a.lastModified = +a.lastModifiedDate;
return a;
}
Expand Down Expand Up @@ -481,7 +485,7 @@ var require_Blob = __commonJS({
} catch (e2) {
exports2.File = function(b, d, c) {
var blob2 = new Blob(b, c);
var t = c && void 0 !== c.lastModified ? new Date(c.lastModified) : new Date();
var t = c && void 0 !== c.lastModified ? new Date(c.lastModified) : /* @__PURE__ */ new Date();
blob2.name = d.replace(/\//g, ":");
blob2.lastModifiedDate = t;
blob2.lastModified = +t;
Expand Down

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions packages/next/src/compiled/@edge-runtime/primitives/cache.d.ts

This file was deleted.

0 comments on commit 24672bd

Please sign in to comment.