Unverified Commit 2e02204d authored by Kiko Beats's avatar Kiko Beats Committed by GitHub
parent 976ccce5
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
"@babel/plugin-proposal-object-rest-spread": "7.14.7", "@babel/plugin-proposal-object-rest-spread": "7.14.7",
"@babel/preset-flow": "7.14.5", "@babel/preset-flow": "7.14.5",
"@babel/preset-react": "7.14.5", "@babel/preset-react": "7.14.5",
"@edge-runtime/jest-environment": "1.1.0-beta.31", "@edge-runtime/jest-environment": "1.1.0-beta.33",
"@fullhuman/postcss-purgecss": "1.3.0", "@fullhuman/postcss-purgecss": "1.3.0",
"@mdx-js/loader": "0.18.0", "@mdx-js/loader": "0.18.0",
"@next/bundle-analyzer": "workspace:*", "@next/bundle-analyzer": "workspace:*",
......
declare const AbortControllerConstructor: AbortController declare const AbortControllerConstructor: typeof AbortController
declare const DOMExceptionConstructor: typeof DOMException
declare var AbortSignal: { declare var AbortSignal: {
prototype: typeof AbortSignal prototype: typeof AbortSignal
...@@ -9,4 +11,4 @@ declare var AbortSignal: { ...@@ -9,4 +11,4 @@ declare var AbortSignal: {
abort(reason?: string): AbortSignal abort(reason?: string): AbortSignal
} }
export { AbortControllerConstructor as AbortController, AbortSignal }; export { AbortControllerConstructor as AbortController, AbortSignal, DOMExceptionConstructor as DOMException };
declare function createCaches(): { declare function createCaches():
| undefined
| {
cacheStorage: () => CacheStorage cacheStorage: () => CacheStorage
Cache: typeof Cache Cache: typeof Cache
CacheStorage: typeof CacheStorage CacheStorage: typeof CacheStorage
} }
declare const caches: CacheStorage declare const caches: CacheStorage
......
This source diff could not be displayed because it is too large. You can view the blob instead.
{"name":"@edge-runtime/primitives","version":"1.1.0-beta.31","main":"./index.js","license":"MPLv2"} {"name":"@edge-runtime/primitives","version":"1.1.0-beta.34","main":"./index.js","license":"MPLv2"}
...@@ -48,8 +48,8 @@ interface URLPatternComponentResult { ...@@ -48,8 +48,8 @@ interface URLPatternComponentResult {
}; };
} }
declare const URLPatternConstructor: typeof URLPattern declare const _URL: typeof URL
declare const URLConstructor: typeof URL declare const _URLSearchParams: typeof URLSearchParams
declare const URLSearchParamsConstructor: typeof URLSearchParams declare class _URLPattern extends URLPattern {}
export { URLConstructor as URL, URLPatternConstructor as URLPattern, URLSearchParamsConstructor as URLSearchParams }; export { _URL as URL, _URLPattern as URLPattern, _URLSearchParams as URLSearchParams };
...@@ -3372,10 +3372,10 @@ module.exports = __toCommonJS(url_exports); ...@@ -3372,10 +3372,10 @@ module.exports = __toCommonJS(url_exports);
init_define_process(); init_define_process();
var import_whatwg_url = __toESM(require_whatwg_url()); var import_whatwg_url = __toESM(require_whatwg_url());
// ../../node_modules/.pnpm/urlpattern-polyfill@5.0.6/node_modules/urlpattern-polyfill/index.js // ../../node_modules/.pnpm/urlpattern-polyfill@5.0.9/node_modules/urlpattern-polyfill/index.js
init_define_process(); init_define_process();
// ../../node_modules/.pnpm/urlpattern-polyfill@5.0.6/node_modules/urlpattern-polyfill/dist/urlpattern.js // ../../node_modules/.pnpm/urlpattern-polyfill@5.0.9/node_modules/urlpattern-polyfill/dist/urlpattern.js
init_define_process(); init_define_process();
var regexIdentifierStart = /[$_\p{ID_Start}]/u; var regexIdentifierStart = /[$_\p{ID_Start}]/u;
var regexIdentifierPart = /[$_\u200C\u200D\p{ID_Continue}]/u; var regexIdentifierPart = /[$_\u200C\u200D\p{ID_Continue}]/u;
...@@ -3489,10 +3489,9 @@ function lexer(str, lenient = false) { ...@@ -3489,10 +3489,9 @@ function lexer(str, lenient = false) {
} }
__name(lexer, "lexer"); __name(lexer, "lexer");
function parse(str, options = {}) { function parse(str, options = {}) {
var _a;
const tokens = lexer(str); const tokens = lexer(str);
const { prefixes = "./" } = options; const { prefixes = "./" } = options;
const defaultPattern = `[^${escapeString((_a = options.delimiter) != null ? _a : "/#?")}]+?`; const defaultPattern = `[^${escapeString(options.delimiter === void 0 ? "/#?" : options.delimiter)}]+?`;
const result = []; const result = [];
let key = 0; let key = 0;
let i = 0; let i = 0;
...@@ -3641,15 +3640,14 @@ function stringToRegexp(path, keys, options) { ...@@ -3641,15 +3640,14 @@ function stringToRegexp(path, keys, options) {
} }
__name(stringToRegexp, "stringToRegexp"); __name(stringToRegexp, "stringToRegexp");
function tokensToRegexp(tokens, keys, options = {}) { function tokensToRegexp(tokens, keys, options = {}) {
var _a, _b;
const { const {
strict = false, strict = false,
start = true, start = true,
end = true, end = true,
encode = /* @__PURE__ */ __name((x) => x, "encode") encode = /* @__PURE__ */ __name((x) => x, "encode")
} = options; } = options;
const endsWith = `[${escapeString((_a = options.endsWith) != null ? _a : "")}]|$`; const endsWith = `[${escapeString(options.endsWith === void 0 ? "" : options.endsWith)}]|$`;
const delimiter = `[${escapeString((_b = options.delimiter) != null ? _b : "/#?")}]`; const delimiter = `[${escapeString(options.delimiter === void 0 ? "/#?" : options.delimiter)}]`;
let route = start ? "^" : ""; let route = start ? "^" : "";
for (const token of tokens) { for (const token of tokens) {
if (typeof token === "string") { if (typeof token === "string") {
...@@ -4334,9 +4332,8 @@ function escapeRegexpString(value) { ...@@ -4334,9 +4332,8 @@ function escapeRegexpString(value) {
} }
__name(escapeRegexpString, "escapeRegexpString"); __name(escapeRegexpString, "escapeRegexpString");
function tokensToPattern(tokens, options) { function tokensToPattern(tokens, options) {
var _a;
const wildcardPattern = ".*"; const wildcardPattern = ".*";
const segmentWildcardPattern = `[^${escapeRegexpString((_a = options.delimiter) != null ? _a : "/#?")}]+?`; const segmentWildcardPattern = `[^${escapeRegexpString(options.delimiter === void 0 ? "/#?" : options.delimiter)}]+?`;
const regexIdentifierPart2 = /[$_\u200C\u200D\p{ID_Continue}]/u; const regexIdentifierPart2 = /[$_\u200C\u200D\p{ID_Continue}]/u;
let result = ""; let result = "";
for (let i = 0; i < tokens.length; ++i) { for (let i = 0; i < tokens.length; ++i) {
...@@ -4617,7 +4614,7 @@ var URLPattern = /* @__PURE__ */ __name(class { ...@@ -4617,7 +4614,7 @@ var URLPattern = /* @__PURE__ */ __name(class {
} }
}, "URLPattern"); }, "URLPattern");
// ../../node_modules/.pnpm/urlpattern-polyfill@5.0.6/node_modules/urlpattern-polyfill/index.js // ../../node_modules/.pnpm/urlpattern-polyfill@5.0.9/node_modules/urlpattern-polyfill/index.js
if (!globalThis.URLPattern) { if (!globalThis.URLPattern) {
globalThis.URLPattern = URLPattern; globalThis.URLPattern = URLPattern;
} }
......
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
"@babel/runtime": "7.15.4", "@babel/runtime": "7.15.4",
"@babel/traverse": "7.18.0", "@babel/traverse": "7.18.0",
"@babel/types": "7.18.0", "@babel/types": "7.18.0",
"@edge-runtime/primitives": "1.1.0-beta.31", "@edge-runtime/primitives": "1.1.0-beta.34",
"@hapi/accept": "5.0.2", "@hapi/accept": "5.0.2",
"@napi-rs/cli": "2.7.0", "@napi-rs/cli": "2.7.0",
"@napi-rs/triples": "1.1.0", "@napi-rs/triples": "1.1.0",
...@@ -193,7 +193,7 @@ ...@@ -193,7 +193,7 @@
"debug": "4.1.1", "debug": "4.1.1",
"devalue": "2.0.1", "devalue": "2.0.1",
"domain-browser": "4.19.0", "domain-browser": "4.19.0",
"edge-runtime": "1.1.0-beta.31", "edge-runtime": "1.1.0-beta.34",
"events": "3.3.0", "events": "3.3.0",
"find-cache-dir": "3.3.1", "find-cache-dir": "3.3.1",
"find-up": "4.1.0", "find-up": "4.1.0",
......
...@@ -3,11 +3,14 @@ import { PassThrough, Readable } from 'stream' ...@@ -3,11 +3,14 @@ import { PassThrough, Readable } from 'stream'
export function requestToBodyStream( export function requestToBodyStream(
context: { ReadableStream: typeof ReadableStream }, context: { ReadableStream: typeof ReadableStream },
KUint8Array: typeof Uint8Array,
stream: Readable stream: Readable
) { ) {
return new context.ReadableStream({ return new context.ReadableStream({
start(controller) { start(controller) {
stream.on('data', (chunk) => controller.enqueue(chunk)) stream.on('data', (chunk) =>
controller.enqueue(new KUint8Array([...new Uint8Array(chunk)]))
)
stream.on('end', () => controller.close()) stream.on('end', () => controller.close())
stream.on('error', (err) => controller.error(err)) stream.on('error', (err) => controller.error(err))
}, },
......
...@@ -34,7 +34,7 @@ export async function fetchInlineAsset(options: { ...@@ -34,7 +34,7 @@ export async function fetchInlineAsset(options: {
if (fileIsReadable) { if (fileIsReadable) {
const readStream = createReadStream(filePath) const readStream = createReadStream(filePath)
return new options.context.Response( return new options.context.Response(
requestToBodyStream(options.context, readStream) requestToBodyStream(options.context, Uint8Array, readStream)
) )
} }
} }
...@@ -92,11 +92,14 @@ export const run = withTaggedErrors(async (params) => { ...@@ -92,11 +92,14 @@ export const run = withTaggedErrors(async (params) => {
? params.request.body?.cloneBodyStream() ? params.request.body?.cloneBodyStream()
: undefined : undefined
const KUint8Array = runtime.evaluate('Uint8Array')
try { try {
const result = await edgeFunction({ const result = await edgeFunction({
request: { request: {
...params.request, ...params.request,
body: cloned && requestToBodyStream(runtime.context, cloned), body:
cloned && requestToBodyStream(runtime.context, KUint8Array, cloned),
}, },
}) })
for (const headerName of FORBIDDEN_HEADERS) { for (const headerName of FORBIDDEN_HEADERS) {
......
This diff is collapsed.
...@@ -440,7 +440,7 @@ describe('Middleware Runtime', () => { ...@@ -440,7 +440,7 @@ describe('Middleware Runtime', () => {
const payload = readMiddlewareJSON(response) const payload = readMiddlewareJSON(response)
expect('error' in payload).toBe(true) expect('error' in payload).toBe(true)
expect(payload.error.name).toBe('AbortError') expect(payload.error.name).toBe('AbortError')
expect(payload.error.message).toBe('The operation was aborted') expect(payload.error.message).toBe('The operation was aborted.')
}) })
it(`should validate & parse request url from any route`, async () => { it(`should validate & parse request url from any route`, async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment