Skip to content

Commit

Permalink
bump: edge-runtime (#56856)
Browse files Browse the repository at this point in the history
It bumps Edge Runtime to include the latest fixes, such as:

- vercel/edge-runtime#622
- vercel/edge-runtime#640

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
Kikobeats and kodiakhq[bot] authored Oct 16, 2023
1 parent e5ad069 commit 8f2fd2e
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 125 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,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.3.0",
"@edge-runtime/jest-environment": "2.3.4",
"@emotion/cache": "11.11.0",
"@emotion/react": "11.11.1",
"@fullhuman/postcss-purgecss": "1.3.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@
"@babel/traverse": "7.18.0",
"@babel/types": "7.18.0",
"@capsizecss/metrics": "1.1.0",
"@edge-runtime/cookies": "3.4.1",
"@edge-runtime/ponyfill": "2.4.0",
"@edge-runtime/primitives": "3.1.1",
"@edge-runtime/cookies": "4.0.1",
"@edge-runtime/ponyfill": "2.4.1",
"@edge-runtime/primitives": "4.0.2",
"@hapi/accept": "5.0.2",
"@jest/transform": "29.5.0",
"@jest/types": "29.5.0",
Expand Down Expand Up @@ -223,7 +223,7 @@
"debug": "4.1.1",
"devalue": "2.0.1",
"domain-browser": "4.19.0",
"edge-runtime": "2.5.1",
"edge-runtime": "2.5.4",
"events": "3.3.0",
"find-cache-dir": "3.3.1",
"find-up": "4.1.0",
Expand Down
15 changes: 1 addition & 14 deletions packages/next/src/compiled/@edge-runtime/cookies/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,5 @@ declare function stringifyCookie(c: ResponseCookie | RequestCookie): string;
declare function parseCookie(cookie: string): Map<string, string>;
/** Parse a `Set-Cookie` header value */
declare function parseSetCookie(setCookie: string): undefined | ResponseCookie;
/**
* @source https://github.com/nfriedly/set-cookie-parser/blob/master/lib/set-cookie.js
*
* Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
* that are within a single set-cookie field-value, such as in the Expires portion.
* This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
* Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
* React Native's fetch does this for *every* header, including set-cookie.
*
* Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
* Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
*/
declare function splitCookiesString(cookiesString: string): string[];

export { CookieListItem, RequestCookie, RequestCookies, ResponseCookie, ResponseCookies, parseCookie, parseSetCookie, splitCookiesString, stringifyCookie };
export { CookieListItem, RequestCookie, RequestCookies, ResponseCookie, ResponseCookies, parseCookie, parseSetCookie, stringifyCookie };
82 changes: 19 additions & 63 deletions packages/next/src/compiled/@edge-runtime/cookies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ __export(src_exports, {
ResponseCookies: () => ResponseCookies,
parseCookie: () => parseCookie,
parseSetCookie: () => parseSetCookie,
splitCookiesString: () => splitCookiesString,
stringifyCookie: () => stringifyCookie
});
module.exports = __toCommonJS(src_exports);
Expand All @@ -39,7 +38,8 @@ function stringifyCookie(c) {
"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}`
"sameSite" in c && c.sameSite && `SameSite=${c.sameSite}`,
"priority" in c && c.priority && `Priority=${c.priority}`
].filter(Boolean);
return `${c.name}=${encodeURIComponent((_a = c.value) != null ? _a : "")}; ${attrs.join("; ")}`;
}
Expand All @@ -66,7 +66,16 @@ function parseSetCookie(setCookie) {
return void 0;
}
const [[name, value], ...attributes] = parseCookie(setCookie);
const { domain, expires, httponly, maxage, path, samesite, secure } = Object.fromEntries(
const {
domain,
expires,
httponly,
maxage,
path,
samesite,
secure,
priority
} = Object.fromEntries(
attributes.map(([key, value2]) => [key.toLowerCase(), value2])
);
const cookie = {
Expand All @@ -78,7 +87,8 @@ function parseSetCookie(setCookie) {
...typeof maxage === "string" && { maxAge: Number(maxage) },
path,
...samesite && { sameSite: parseSameSite(samesite) },
...secure && { secure: true }
...secure && { secure: true },
...priority && { priority: parsePriority(priority) }
};
return compact(cookie);
}
Expand All @@ -96,56 +106,10 @@ function parseSameSite(string) {
string = string.toLowerCase();
return SAME_SITE.includes(string) ? string : void 0;
}
function splitCookiesString(cookiesString) {
if (!cookiesString)
return [];
var cookiesStrings = [];
var pos = 0;
var start;
var ch;
var lastComma;
var nextStart;
var cookiesSeparatorFound;
function skipWhitespace() {
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
pos += 1;
}
return pos < cookiesString.length;
}
function notSpecialChar() {
ch = cookiesString.charAt(pos);
return ch !== "=" && ch !== ";" && ch !== ",";
}
while (pos < cookiesString.length) {
start = pos;
cookiesSeparatorFound = false;
while (skipWhitespace()) {
ch = cookiesString.charAt(pos);
if (ch === ",") {
lastComma = pos;
pos += 1;
skipWhitespace();
nextStart = pos;
while (pos < cookiesString.length && notSpecialChar()) {
pos += 1;
}
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
cookiesSeparatorFound = true;
pos = nextStart;
cookiesStrings.push(cookiesString.substring(start, lastComma));
start = pos;
} else {
pos = lastComma + 1;
}
} else {
pos += 1;
}
}
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
}
}
return cookiesStrings;
var PRIORITY = ["low", "medium", "high"];
function parsePriority(string) {
string = string.toLowerCase();
return PRIORITY.includes(string) ? string : void 0;
}

// src/request-cookies.ts
Expand Down Expand Up @@ -232,15 +196,8 @@ var ResponseCookies = class {
constructor(responseHeaders) {
/** @internal */
this._parsed = /* @__PURE__ */ new Map();
var _a, _b;
this._headers = responseHeaders;
const setCookie = (_a = responseHeaders.getSetCookie) == null ? void 0 : _a.call(responseHeaders);
(_b = responseHeaders.get("set-cookie")) != null ? _b : [];
const cookieStrings = Array.isArray(setCookie) ? setCookie : (
// TODO: remove splitCookiesString when `getSetCookie` adoption is high enough in Node.js
// https://developer.mozilla.org/en-US/docs/Web/API/Headers/getSetCookie#browser_compatibility
splitCookiesString(setCookie)
);
const cookieStrings = responseHeaders.getSetCookie();
for (const cookieString of cookieStrings) {
const parsed = parseSetCookie(cookieString);
if (parsed)
Expand Down Expand Up @@ -318,6 +275,5 @@ function normalizeCookie(cookie = { name: "", value: "" }) {
ResponseCookies,
parseCookie,
parseSetCookie,
splitCookiesString,
stringifyCookie
});
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"@edge-runtime/cookies","version":"3.4.1","main":"./index.js","license":"MPL-2.0"}
{"name":"@edge-runtime/cookies","version":"4.0.1","main":"./index.js","license":"MPL-2.0"}
2 changes: 2 additions & 0 deletions packages/next/src/compiled/@edge-runtime/ponyfill/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function edge() {
ReadableStreamDefaultReader,
Request,
Response,
setInterval,
setTimeout,
structuredClone,
SubtleCrypto,
TextDecoder,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"@edge-runtime/ponyfill","version":"2.4.0","main":"./index.js","types":"./index.d.ts","license":"MPL-2.0"}
{"name":"@edge-runtime/ponyfill","version":"2.4.1","main":"./index.js","types":"./index.d.ts","license":"MPL-2.0"}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare class Headers extends globalThis.Headers {
/** @deprecated Use [`.getSetCookie()`](https://developer.mozilla.org/en-US/docs/Web/API/Headers/getSetCookie) instead. */
getAll?(key: 'set-cookie'): string[]
}

Expand All @@ -16,7 +17,7 @@ type RequestInfo = string | Request | globalThis.Request
type RequestInit = globalThis.RequestInit
declare const fetchImplementation: (
info: RequestInfo,
init?: RequestInit
init?: RequestInit,
) => Promise<Response>

declare const FileConstructor: typeof File
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export { Event, EventTarget, FetchEvent, PromiseRejectionEvent } from './events.
export { File, FormData, Headers, Request, RequestInfo, RequestInit, Response, WebSocket, fetch } from './fetch.d.js';
export { structuredClone } from './structured-clone.d.js';
export { URL, URLPattern, URLSearchParams } from './url.d.js';
export { setInterval, setTimeout } from './timers.d.js';

/**
* The type of `ReadableStreamBYOBReader` is not included in Typescript so we
Expand Down
10 changes: 10 additions & 0 deletions packages/next/src/compiled/@edge-runtime/primitives/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ function load(scopedContext = {}) {
scopedContext
});
assign(context, { console: consoleImpl.console });
const timersImpl = requireWithFakeGlobalScope({
context,
id: "timers.js",
sourceCode: require("./timers.js.text.js"),
scopedContext
});
assign(context, {
setTimeout: timersImpl.setTimeout,
setInterval: timersImpl.setInterval
});
const eventsImpl = requireWithFakeGlobalScope({
context,
id: "events.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"@edge-runtime/primitives","version":"3.1.1","main":"./index.js","license":"MPL-2.0"}
{"name":"@edge-runtime/primitives","version":"4.0.2","main":"./index.js","license":"MPL-2.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare const _setTimeout: typeof Number
declare const _setInterval: typeof Number

export { _setInterval as setInterval, _setTimeout as setTimeout };
Empty file.

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

2 changes: 1 addition & 1 deletion packages/next/src/compiled/edge-runtime/index.js

Large diffs are not rendered by default.

62 changes: 25 additions & 37 deletions pnpm-lock.yaml

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

0 comments on commit 8f2fd2e

Please sign in to comment.