Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump: edge-runtime #56856

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading