From f34fcd16ea4d504c8a87c0873c65598d70bb1d07 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Tue, 9 May 2023 12:37:13 +0200 Subject: fix(core): let V8 drive extension ESM loads (#18997) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This now allows circular imports across extensions. Instead of load + eval of all ESM files in declaration order, all files are only loaded. Eval is done recursively by V8, only evaluating files that are listed in `Extension::esm_entry_point` fields. --------- Co-authored-by: Bartek IwaƄczuk --- ext/web/09_file.js | 28 ++++++++++++++++++++++++++++ ext/web/11_blob_url.js | 45 --------------------------------------------- ext/web/lib.rs | 1 - 3 files changed, 28 insertions(+), 46 deletions(-) delete mode 100644 ext/web/11_blob_url.js (limited to 'ext/web') diff --git a/ext/web/09_file.js b/ext/web/09_file.js index a81176b38..d65a512f9 100644 --- a/ext/web/09_file.js +++ b/ext/web/09_file.js @@ -14,6 +14,7 @@ const core = globalThis.Deno.core; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { ReadableStream } from "ext:deno_web/06_streams.js"; +import { URL } from "ext:deno_url/00_url.js"; const primordials = globalThis.__bootstrap.primordials; const { ArrayBufferPrototype, @@ -653,6 +654,33 @@ function blobFromObjectUrl(url) { return blob; } +/** + * @param {Blob} blob + * @returns {string} + */ +function createObjectURL(blob) { + const prefix = "Failed to execute 'createObjectURL' on 'URL'"; + webidl.requiredArguments(arguments.length, 1, prefix); + blob = webidl.converters["Blob"](blob, prefix, "Argument 1"); + + return ops.op_blob_create_object_url(blob.type, getParts(blob)); +} + +/** + * @param {string} url + * @returns {void} + */ +function revokeObjectURL(url) { + const prefix = "Failed to execute 'revokeObjectURL' on 'URL'"; + webidl.requiredArguments(arguments.length, 1, prefix); + url = webidl.converters["DOMString"](url, prefix, "Argument 1"); + + ops.op_blob_revoke_object_url(url); +} + +URL.createObjectURL = createObjectURL; +URL.revokeObjectURL = revokeObjectURL; + export { Blob, blobFromObjectUrl, diff --git a/ext/web/11_blob_url.js b/ext/web/11_blob_url.js deleted file mode 100644 index 3ac240d90..000000000 --- a/ext/web/11_blob_url.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. - -// @ts-check -/// -/// -/// -/// -/// -/// -/// -/// -/// - -const core = globalThis.Deno.core; -const ops = core.ops; -import * as webidl from "ext:deno_webidl/00_webidl.js"; -import { getParts } from "ext:deno_web/09_file.js"; -import { URL } from "ext:deno_url/00_url.js"; - -/** - * @param {Blob} blob - * @returns {string} - */ -function createObjectURL(blob) { - const prefix = "Failed to execute 'createObjectURL' on 'URL'"; - webidl.requiredArguments(arguments.length, 1, prefix); - blob = webidl.converters["Blob"](blob, prefix, "Argument 1"); - - return ops.op_blob_create_object_url(blob.type, getParts(blob)); -} - -/** - * @param {string} url - * @returns {void} - */ -function revokeObjectURL(url) { - const prefix = "Failed to execute 'revokeObjectURL' on 'URL'"; - webidl.requiredArguments(arguments.length, 1, prefix); - url = webidl.converters["DOMString"](url, prefix, "Argument 1"); - - ops.op_blob_revoke_object_url(url); -} - -URL.createObjectURL = createObjectURL; -URL.revokeObjectURL = revokeObjectURL; diff --git a/ext/web/lib.rs b/ext/web/lib.rs index b0dc0d56d..3f4468f1f 100644 --- a/ext/web/lib.rs +++ b/ext/web/lib.rs @@ -103,7 +103,6 @@ deno_core::extension!(deno_web, "08_text_encoding.js", "09_file.js", "10_filereader.js", - "11_blob_url.js", "12_location.js", "13_message_port.js", "14_compression.js", -- cgit v1.2.3