Skip to content

Commit 8f2fd2e

Browse files
Kikobeatskodiakhq[bot]
andauthoredOct 16, 2023
bump: edge-runtime (#56856)
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>
1 parent e5ad069 commit 8f2fd2e

17 files changed

+75
-125
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"@babel/plugin-proposal-object-rest-spread": "7.14.7",
6767
"@babel/preset-flow": "7.14.5",
6868
"@babel/preset-react": "7.14.5",
69-
"@edge-runtime/jest-environment": "2.3.0",
69+
"@edge-runtime/jest-environment": "2.3.4",
7070
"@emotion/cache": "11.11.0",
7171
"@emotion/react": "11.11.1",
7272
"@fullhuman/postcss-purgecss": "1.3.0",

‎packages/next/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@
135135
"@babel/traverse": "7.18.0",
136136
"@babel/types": "7.18.0",
137137
"@capsizecss/metrics": "1.1.0",
138-
"@edge-runtime/cookies": "3.4.1",
139-
"@edge-runtime/ponyfill": "2.4.0",
140-
"@edge-runtime/primitives": "3.1.1",
138+
"@edge-runtime/cookies": "4.0.1",
139+
"@edge-runtime/ponyfill": "2.4.1",
140+
"@edge-runtime/primitives": "4.0.2",
141141
"@hapi/accept": "5.0.2",
142142
"@jest/transform": "29.5.0",
143143
"@jest/types": "29.5.0",
@@ -223,7 +223,7 @@
223223
"debug": "4.1.1",
224224
"devalue": "2.0.1",
225225
"domain-browser": "4.19.0",
226-
"edge-runtime": "2.5.1",
226+
"edge-runtime": "2.5.4",
227227
"events": "3.3.0",
228228
"find-cache-dir": "3.3.1",
229229
"find-up": "4.1.0",

‎packages/next/src/compiled/@edge-runtime/cookies/index.d.ts

+1-14
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,5 @@ declare function stringifyCookie(c: ResponseCookie | RequestCookie): string;
192192
declare function parseCookie(cookie: string): Map<string, string>;
193193
/** Parse a `Set-Cookie` header value */
194194
declare function parseSetCookie(setCookie: string): undefined | ResponseCookie;
195-
/**
196-
* @source https://github.com/nfriedly/set-cookie-parser/blob/master/lib/set-cookie.js
197-
*
198-
* Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
199-
* that are within a single set-cookie field-value, such as in the Expires portion.
200-
* This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
201-
* Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
202-
* React Native's fetch does this for *every* header, including set-cookie.
203-
*
204-
* Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
205-
* Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
206-
*/
207-
declare function splitCookiesString(cookiesString: string): string[];
208195

209-
export { CookieListItem, RequestCookie, RequestCookies, ResponseCookie, ResponseCookies, parseCookie, parseSetCookie, splitCookiesString, stringifyCookie };
196+
export { CookieListItem, RequestCookie, RequestCookies, ResponseCookie, ResponseCookies, parseCookie, parseSetCookie, stringifyCookie };

‎packages/next/src/compiled/@edge-runtime/cookies/index.js

+19-63
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ __export(src_exports, {
2424
ResponseCookies: () => ResponseCookies,
2525
parseCookie: () => parseCookie,
2626
parseSetCookie: () => parseSetCookie,
27-
splitCookiesString: () => splitCookiesString,
2827
stringifyCookie: () => stringifyCookie
2928
});
3029
module.exports = __toCommonJS(src_exports);
@@ -39,7 +38,8 @@ function stringifyCookie(c) {
3938
"domain" in c && c.domain && `Domain=${c.domain}`,
4039
"secure" in c && c.secure && "Secure",
4140
"httpOnly" in c && c.httpOnly && "HttpOnly",
42-
"sameSite" in c && c.sameSite && `SameSite=${c.sameSite}`
41+
"sameSite" in c && c.sameSite && `SameSite=${c.sameSite}`,
42+
"priority" in c && c.priority && `Priority=${c.priority}`
4343
].filter(Boolean);
4444
return `${c.name}=${encodeURIComponent((_a = c.value) != null ? _a : "")}; ${attrs.join("; ")}`;
4545
}
@@ -66,7 +66,16 @@ function parseSetCookie(setCookie) {
6666
return void 0;
6767
}
6868
const [[name, value], ...attributes] = parseCookie(setCookie);
69-
const { domain, expires, httponly, maxage, path, samesite, secure } = Object.fromEntries(
69+
const {
70+
domain,
71+
expires,
72+
httponly,
73+
maxage,
74+
path,
75+
samesite,
76+
secure,
77+
priority
78+
} = Object.fromEntries(
7079
attributes.map(([key, value2]) => [key.toLowerCase(), value2])
7180
);
7281
const cookie = {
@@ -78,7 +87,8 @@ function parseSetCookie(setCookie) {
7887
...typeof maxage === "string" && { maxAge: Number(maxage) },
7988
path,
8089
...samesite && { sameSite: parseSameSite(samesite) },
81-
...secure && { secure: true }
90+
...secure && { secure: true },
91+
...priority && { priority: parsePriority(priority) }
8292
};
8393
return compact(cookie);
8494
}
@@ -96,56 +106,10 @@ function parseSameSite(string) {
96106
string = string.toLowerCase();
97107
return SAME_SITE.includes(string) ? string : void 0;
98108
}
99-
function splitCookiesString(cookiesString) {
100-
if (!cookiesString)
101-
return [];
102-
var cookiesStrings = [];
103-
var pos = 0;
104-
var start;
105-
var ch;
106-
var lastComma;
107-
var nextStart;
108-
var cookiesSeparatorFound;
109-
function skipWhitespace() {
110-
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
111-
pos += 1;
112-
}
113-
return pos < cookiesString.length;
114-
}
115-
function notSpecialChar() {
116-
ch = cookiesString.charAt(pos);
117-
return ch !== "=" && ch !== ";" && ch !== ",";
118-
}
119-
while (pos < cookiesString.length) {
120-
start = pos;
121-
cookiesSeparatorFound = false;
122-
while (skipWhitespace()) {
123-
ch = cookiesString.charAt(pos);
124-
if (ch === ",") {
125-
lastComma = pos;
126-
pos += 1;
127-
skipWhitespace();
128-
nextStart = pos;
129-
while (pos < cookiesString.length && notSpecialChar()) {
130-
pos += 1;
131-
}
132-
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
133-
cookiesSeparatorFound = true;
134-
pos = nextStart;
135-
cookiesStrings.push(cookiesString.substring(start, lastComma));
136-
start = pos;
137-
} else {
138-
pos = lastComma + 1;
139-
}
140-
} else {
141-
pos += 1;
142-
}
143-
}
144-
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
145-
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
146-
}
147-
}
148-
return cookiesStrings;
109+
var PRIORITY = ["low", "medium", "high"];
110+
function parsePriority(string) {
111+
string = string.toLowerCase();
112+
return PRIORITY.includes(string) ? string : void 0;
149113
}
150114

151115
// src/request-cookies.ts
@@ -232,15 +196,8 @@ var ResponseCookies = class {
232196
constructor(responseHeaders) {
233197
/** @internal */
234198
this._parsed = /* @__PURE__ */ new Map();
235-
var _a, _b;
236199
this._headers = responseHeaders;
237-
const setCookie = (_a = responseHeaders.getSetCookie) == null ? void 0 : _a.call(responseHeaders);
238-
(_b = responseHeaders.get("set-cookie")) != null ? _b : [];
239-
const cookieStrings = Array.isArray(setCookie) ? setCookie : (
240-
// TODO: remove splitCookiesString when `getSetCookie` adoption is high enough in Node.js
241-
// https://developer.mozilla.org/en-US/docs/Web/API/Headers/getSetCookie#browser_compatibility
242-
splitCookiesString(setCookie)
243-
);
200+
const cookieStrings = responseHeaders.getSetCookie();
244201
for (const cookieString of cookieStrings) {
245202
const parsed = parseSetCookie(cookieString);
246203
if (parsed)
@@ -318,6 +275,5 @@ function normalizeCookie(cookie = { name: "", value: "" }) {
318275
ResponseCookies,
319276
parseCookie,
320277
parseSetCookie,
321-
splitCookiesString,
322278
stringifyCookie
323279
});
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"name":"@edge-runtime/cookies","version":"3.4.1","main":"./index.js","license":"MPL-2.0"}
1+
{"name":"@edge-runtime/cookies","version":"4.0.1","main":"./index.js","license":"MPL-2.0"}

‎packages/next/src/compiled/@edge-runtime/ponyfill/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ function edge() {
2626
ReadableStreamDefaultReader,
2727
Request,
2828
Response,
29+
setInterval,
30+
setTimeout,
2931
structuredClone,
3032
SubtleCrypto,
3133
TextDecoder,
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"name":"@edge-runtime/ponyfill","version":"2.4.0","main":"./index.js","types":"./index.d.ts","license":"MPL-2.0"}
1+
{"name":"@edge-runtime/ponyfill","version":"2.4.1","main":"./index.js","types":"./index.d.ts","license":"MPL-2.0"}

‎packages/next/src/compiled/@edge-runtime/primitives/fetch.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
declare class Headers extends globalThis.Headers {
2+
/** @deprecated Use [`.getSetCookie()`](https://developer.mozilla.org/en-US/docs/Web/API/Headers/getSetCookie) instead. */
23
getAll?(key: 'set-cookie'): string[]
34
}
45

@@ -16,7 +17,7 @@ type RequestInfo = string | Request | globalThis.Request
1617
type RequestInit = globalThis.RequestInit
1718
declare const fetchImplementation: (
1819
info: RequestInfo,
19-
init?: RequestInit
20+
init?: RequestInit,
2021
) => Promise<Response>
2122

2223
declare const FileConstructor: typeof File

‎packages/next/src/compiled/@edge-runtime/primitives/fetch.js.text.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/next/src/compiled/@edge-runtime/primitives/index.d.ts

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

1112
/**
1213
* The type of `ReadableStreamBYOBReader` is not included in Typescript so we

‎packages/next/src/compiled/@edge-runtime/primitives/load.js

+10
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ function load(scopedContext = {}) {
9595
scopedContext
9696
});
9797
assign(context, { console: consoleImpl.console });
98+
const timersImpl = requireWithFakeGlobalScope({
99+
context,
100+
id: "timers.js",
101+
sourceCode: require("./timers.js.text.js"),
102+
scopedContext
103+
});
104+
assign(context, {
105+
setTimeout: timersImpl.setTimeout,
106+
setInterval: timersImpl.setInterval
107+
});
98108
const eventsImpl = requireWithFakeGlobalScope({
99109
context,
100110
id: "events.js",
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"name":"@edge-runtime/primitives","version":"3.1.1","main":"./index.js","license":"MPL-2.0"}
1+
{"name":"@edge-runtime/primitives","version":"4.0.2","main":"./index.js","license":"MPL-2.0"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare const _setTimeout: typeof Number
2+
declare const _setInterval: typeof Number
3+
4+
export { _setInterval as setInterval, _setTimeout as setTimeout };

‎packages/next/src/compiled/@edge-runtime/primitives/timers.js.LEGAL.txt

Whitespace-only changes.

‎packages/next/src/compiled/@edge-runtime/primitives/timers.js.text.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/next/src/compiled/edge-runtime/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-lock.yaml

+25-37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.