diff options
Diffstat (limited to 'ext/web')
-rw-r--r-- | ext/web/00_infra.js | 10 | ||||
-rw-r--r-- | ext/web/01_dom_exception.js | 1 | ||||
-rw-r--r-- | ext/web/01_mimesniff.js | 1 | ||||
-rw-r--r-- | ext/web/02_event.js | 7 | ||||
-rw-r--r-- | ext/web/02_structured_clone.js | 9 | ||||
-rw-r--r-- | ext/web/02_timers.js | 13 | ||||
-rw-r--r-- | ext/web/03_abort_signal.js | 21 | ||||
-rw-r--r-- | ext/web/05_base64.js | 14 | ||||
-rw-r--r-- | ext/web/06_streams.js | 35 | ||||
-rw-r--r-- | ext/web/08_text_encoding.js | 36 | ||||
-rw-r--r-- | ext/web/09_file.js | 44 | ||||
-rw-r--r-- | ext/web/10_filereader.js | 21 | ||||
-rw-r--r-- | ext/web/12_location.js | 5 | ||||
-rw-r--r-- | ext/web/14_compression.js | 19 | ||||
-rw-r--r-- | ext/web/15_performance.js | 1 | ||||
-rw-r--r-- | ext/web/16_image_data.js | 9 |
16 files changed, 145 insertions, 101 deletions
diff --git a/ext/web/00_infra.js b/ext/web/00_infra.js index 9dc3a0c37..da6fe0f88 100644 --- a/ext/web/00_infra.js +++ b/ext/web/00_infra.js @@ -7,7 +7,10 @@ /// <reference path="../web/lib.deno_web.d.ts" /> import { core, internals, primordials } from "ext:core/mod.js"; -const ops = core.ops; +const { + op_base64_encode, + op_base64_decode, +} = core.ensureFastOps(); const { ArrayPrototypeJoin, ArrayPrototypeMap, @@ -33,6 +36,7 @@ const { Symbol, TypeError, } = primordials; + import { URLPrototype } from "ext:deno_url/00_url.js"; const ASCII_DIGIT = ["\u0030-\u0039"]; @@ -245,7 +249,7 @@ function collectHttpQuotedString(input, position, extractValue) { * @returns {string} */ function forgivingBase64Encode(data) { - return ops.op_base64_encode(data); + return op_base64_encode(data); } /** @@ -253,7 +257,7 @@ function forgivingBase64Encode(data) { * @returns {Uint8Array} */ function forgivingBase64Decode(data) { - return ops.op_base64_decode(data); + return op_base64_decode(data); } // Taken from std/encoding/base64url.ts diff --git a/ext/web/01_dom_exception.js b/ext/web/01_dom_exception.js index 14cabc286..9bab4881a 100644 --- a/ext/web/01_dom_exception.js +++ b/ext/web/01_dom_exception.js @@ -20,6 +20,7 @@ const { Symbol, SymbolFor, } = primordials; + import * as webidl from "ext:deno_webidl/00_webidl.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; diff --git a/ext/web/01_mimesniff.js b/ext/web/01_mimesniff.js index 575afd437..2978a0762 100644 --- a/ext/web/01_mimesniff.js +++ b/ext/web/01_mimesniff.js @@ -19,6 +19,7 @@ const { StringPrototypeReplaceAll, StringPrototypeToLowerCase, } = primordials; + import { collectHttpQuotedString, collectSequenceOfCodepoints, diff --git a/ext/web/02_event.js b/ext/web/02_event.js index d014b7a73..026e46374 100644 --- a/ext/web/02_event.js +++ b/ext/web/02_event.js @@ -6,9 +6,6 @@ // and impossible logic branches based on what Deno currently supports. import { core, primordials } from "ext:core/mod.js"; -import * as webidl from "ext:deno_webidl/00_webidl.js"; -import { DOMException } from "ext:deno_web/01_dom_exception.js"; -import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; const { ArrayPrototypeFilter, ArrayPrototypeIncludes, @@ -37,6 +34,10 @@ const { TypeError, } = primordials; +import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { DOMException } from "ext:deno_web/01_dom_exception.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; + // This should be set via setGlobalThis this is required so that if even // user deletes globalThis it is still usable let globalThis_; diff --git a/ext/web/02_structured_clone.js b/ext/web/02_structured_clone.js index 13275e2d8..bd08e761f 100644 --- a/ext/web/02_structured_clone.js +++ b/ext/web/02_structured_clone.js @@ -7,7 +7,9 @@ /// <reference path="../web/lib.deno_web.d.ts" /> import { core, primordials } from "ext:core/mod.js"; -import { DOMException } from "ext:deno_web/01_dom_exception.js"; +const { + isArrayBuffer, +} = core; const { ArrayBuffer, ArrayBufferPrototypeGetByteLength, @@ -37,9 +39,8 @@ const { Float32Array, Float64Array, } = primordials; -const { - isArrayBuffer, -} = core; + +import { DOMException } from "ext:deno_web/01_dom_exception.js"; const objectCloneMemo = new SafeWeakMap(); diff --git a/ext/web/02_timers.js b/ext/web/02_timers.js index 6fc03dd10..0687c9a71 100644 --- a/ext/web/02_timers.js +++ b/ext/web/02_timers.js @@ -1,7 +1,12 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. import { core, primordials } from "ext:core/mod.js"; -const ops = core.ops; +const { + op_now, + op_sleep, + op_timer_handle, + op_void_async_deferred, +} = core.ensureFastOps(); const { ArrayPrototypePush, ArrayPrototypeShift, @@ -19,15 +24,15 @@ const { TypeError, indirectEval, } = primordials; + import * as webidl from "ext:deno_webidl/00_webidl.js"; import { reportException } from "ext:deno_web/02_event.js"; import { assert } from "ext:deno_web/00_infra.js"; -const { op_sleep, op_void_async_deferred } = core.ensureFastOps(); const hrU8 = new Uint8Array(8); const hr = new Uint32Array(TypedArrayPrototypeGetBuffer(hrU8)); function opNow() { - ops.op_now(hrU8); + op_now(hrU8); return (hr[0] * 1000 + hr[1] / 1e6); } @@ -111,7 +116,7 @@ function initializeTimer( // TODO(@andreubotella): Deal with overflow. // https://github.com/whatwg/html/issues/7358 id = nextId++; - const cancelRid = ops.op_timer_handle(); + const cancelRid = op_timer_handle(); timerInfo = { cancelRid, isRef: true, promise: null }; // Step 4 in "run steps after a timeout". diff --git a/ext/web/03_abort_signal.js b/ext/web/03_abort_signal.js index 0a975d04b..2bca29529 100644 --- a/ext/web/03_abort_signal.js +++ b/ext/web/03_abort_signal.js @@ -3,16 +3,6 @@ // @ts-check /// <reference path="../../core/internal.d.ts" /> -import * as webidl from "ext:deno_webidl/00_webidl.js"; -import { assert } from "ext:deno_web/00_infra.js"; -import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; -import { - defineEventHandler, - Event, - EventTarget, - listenerCount, - setIsTrusted, -} from "ext:deno_web/02_event.js"; import { primordials } from "ext:core/mod.js"; const { ArrayPrototypeEvery, @@ -32,6 +22,17 @@ const { WeakSetPrototypeAdd, WeakSetPrototypeHas, } = primordials; + +import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { assert } from "ext:deno_web/00_infra.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; +import { + defineEventHandler, + Event, + EventTarget, + listenerCount, + setIsTrusted, +} from "ext:deno_web/02_event.js"; import { refTimer, setTimeout, unrefTimer } from "ext:deno_web/02_timers.js"; // Since WeakSet is not a iterable, WeakRefSet class is provided to store and diff --git a/ext/web/05_base64.js b/ext/web/05_base64.js index c6e92d390..335cd041c 100644 --- a/ext/web/05_base64.js +++ b/ext/web/05_base64.js @@ -7,14 +7,18 @@ /// <reference lib="esnext" /> import { core, primordials } from "ext:core/mod.js"; -const ops = core.ops; -import * as webidl from "ext:deno_webidl/00_webidl.js"; -import { DOMException } from "ext:deno_web/01_dom_exception.js"; +const { + op_base64_atob, + op_base64_btoa, +} = core.ensureFastOps(); const { ObjectPrototypeIsPrototypeOf, TypeErrorPrototype, } = primordials; +import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { DOMException } from "ext:deno_web/01_dom_exception.js"; + /** * @param {string} data * @returns {string} @@ -24,7 +28,7 @@ function atob(data) { webidl.requiredArguments(arguments.length, 1, prefix); data = webidl.converters.DOMString(data, prefix, "Argument 1"); try { - return ops.op_base64_atob(data); + return op_base64_atob(data); } catch (e) { if (ObjectPrototypeIsPrototypeOf(TypeErrorPrototype, e)) { throw new DOMException( @@ -45,7 +49,7 @@ function btoa(data) { webidl.requiredArguments(arguments.length, 1, prefix); data = webidl.converters.DOMString(data, prefix, "Argument 1"); try { - return ops.op_base64_btoa(data); + return op_base64_btoa(data); } catch (e) { if (ObjectPrototypeIsPrototypeOf(TypeErrorPrototype, e)) { throw new DOMException( diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 49c1eb41c..976f62347 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -8,6 +8,12 @@ import { core, internals, primordials } from "ext:core/mod.js"; const { + isAnyArrayBuffer, + isArrayBuffer, + isSharedArrayBuffer, + isTypedArray, +} = core; +const { op_arraybuffer_was_detached, op_transfer_arraybuffer, op_readable_stream_resource_allocate, @@ -19,20 +25,10 @@ const { op_readable_stream_resource_close, op_readable_stream_resource_await_close, } = core.ensureFastOps(); -// TODO(mmastrac): use readAll const { + // TODO(mmastrac): use readAll op_read_all, } = core.ensureFastOps(true); - -import * as webidl from "ext:deno_webidl/00_webidl.js"; -import { structuredClone } from "ext:deno_web/02_structured_clone.js"; -import { - AbortSignalPrototype, - add, - newSignal, - remove, - signalAbort, -} from "ext:deno_web/03_abort_signal.js"; const { ArrayBuffer, ArrayBufferIsView, @@ -95,12 +91,17 @@ const { WeakMapPrototypeSet, queueMicrotask, } = primordials; -const { - isAnyArrayBuffer, - isArrayBuffer, - isSharedArrayBuffer, - isTypedArray, -} = core; + +import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { structuredClone } from "ext:deno_web/02_structured_clone.js"; +import { + AbortSignalPrototype, + add, + newSignal, + remove, + signalAbort, +} from "ext:deno_web/03_abort_signal.js"; + import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; import { assert, AssertionError } from "ext:deno_web/00_infra.js"; diff --git a/ext/web/08_text_encoding.js b/ext/web/08_text_encoding.js index e563c8bd4..5d41e4cd9 100644 --- a/ext/web/08_text_encoding.js +++ b/ext/web/08_text_encoding.js @@ -10,9 +10,19 @@ /// <reference lib="esnext" /> import { core, primordials } from "ext:core/mod.js"; -const ops = core.ops; -import * as webidl from "ext:deno_webidl/00_webidl.js"; -import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; +const { + isDataView, + isSharedArrayBuffer, + isTypedArray, +} = core; +const { + op_encoding_decode, + op_encoding_decode_single, + op_encoding_decode_utf8, + op_encoding_encode_into, + op_encoding_new_decoder, + op_encoding_normalize_label, +} = core.ensureFastOps(); const { DataViewPrototypeGetBuffer, DataViewPrototypeGetByteLength, @@ -32,11 +42,9 @@ const { Uint32Array, Uint8Array, } = primordials; -const { - isDataView, - isSharedArrayBuffer, - isTypedArray, -} = core; + +import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; class TextDecoder { /** @type {string} */ @@ -63,7 +71,7 @@ class TextDecoder { prefix, "Argument 2", ); - const encoding = ops.op_encoding_normalize_label(label); + const encoding = op_encoding_normalize_label(label); this.#encoding = encoding; this.#fatal = options.fatal; this.#ignoreBOM = options.ignoreBOM; @@ -154,10 +162,10 @@ class TextDecoder { if (!stream && this.#rid === null) { // Fast path for utf8 single pass encoding. if (this.#utf8SinglePass) { - return ops.op_encoding_decode_utf8(input, this.#ignoreBOM); + return op_encoding_decode_utf8(input, this.#ignoreBOM); } - return ops.op_encoding_decode_single( + return op_encoding_decode_single( input, this.#encoding, this.#fatal, @@ -166,13 +174,13 @@ class TextDecoder { } if (this.#rid === null) { - this.#rid = ops.op_encoding_new_decoder( + this.#rid = op_encoding_new_decoder( this.#encoding, this.#fatal, this.#ignoreBOM, ); } - return ops.op_encoding_decode(input, this.#rid, stream); + return op_encoding_decode(input, this.#rid, stream); } finally { if (!stream && this.#rid !== null) { core.close(this.#rid); @@ -246,7 +254,7 @@ class TextEncoder { allowShared: true, }, ); - ops.op_encoding_encode_into(source, destination, encodeIntoBuf); + op_encoding_encode_into(source, destination, encodeIntoBuf); return { read: encodeIntoBuf[0], written: encodeIntoBuf[1], diff --git a/ext/web/09_file.js b/ext/web/09_file.js index c38fbd101..1b35b6aa4 100644 --- a/ext/web/09_file.js +++ b/ext/web/09_file.js @@ -11,10 +11,21 @@ /// <reference lib="esnext" /> import { core, primordials } from "ext:core/mod.js"; -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 { + isAnyArrayBuffer, + isArrayBuffer, + isDataView, + isTypedArray, +} = core; +const { + op_blob_create_object_url, + op_blob_create_part, + op_blob_from_object_url, + op_blob_read_part, + op_blob_remove_part, + op_blob_revoke_object_url, + op_blob_slice_part, +} = core.ensureFastOps(); const { ArrayBufferIsView, ArrayBufferPrototypeGetByteLength, @@ -44,16 +55,11 @@ const { TypedArrayPrototypeSet, Uint8Array, } = primordials; -const { - isAnyArrayBuffer, - isArrayBuffer, - isDataView, - isTypedArray, -} = core; + +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"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; -const { - op_blob_read_part, -} = core.ensureFastOps(); // TODO(lucacasonato): this needs to not be hardcoded and instead depend on // host os. @@ -568,7 +574,7 @@ webidl.converters["FilePropertyBag"] = webidl.createDictionaryConverter( // A finalization registry to deallocate a blob part when its JS reference is // garbage collected. const registry = new SafeFinalizationRegistry((uuid) => { - ops.op_blob_remove_part(uuid); + op_blob_remove_part(uuid); }); // TODO(lucacasonato): get a better stream from Rust in BlobReference#stream @@ -596,7 +602,7 @@ class BlobReference { * @returns {BlobReference} */ static fromUint8Array(data) { - const id = ops.op_blob_create_part(data); + const id = op_blob_create_part(data); return new BlobReference(id, TypedArrayPrototypeGetByteLength(data)); } @@ -611,7 +617,7 @@ class BlobReference { */ slice(start, end) { const size = end - start; - const id = ops.op_blob_slice_part(this._id, { + const id = op_blob_slice_part(this._id, { start, len: size, }); @@ -651,7 +657,7 @@ class BlobReference { * @returns {Blob | null} */ function blobFromObjectUrl(url) { - const blobData = ops.op_blob_from_object_url(url); + const blobData = op_blob_from_object_url(url); if (blobData === null) { return null; } @@ -682,7 +688,7 @@ function createObjectURL(blob) { 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)); + return op_blob_create_object_url(blob.type, getParts(blob)); } /** @@ -694,7 +700,7 @@ function revokeObjectURL(url) { webidl.requiredArguments(arguments.length, 1, prefix); url = webidl.converters["DOMString"](url, prefix, "Argument 1"); - ops.op_blob_revoke_object_url(url); + op_blob_revoke_object_url(url); } URL.createObjectURL = createObjectURL; diff --git a/ext/web/10_filereader.js b/ext/web/10_filereader.js index 2a75ff8d6..321d844fa 100644 --- a/ext/web/10_filereader.js +++ b/ext/web/10_filereader.js @@ -11,14 +11,9 @@ /// <reference lib="esnext" /> import { core, primordials } from "ext:core/mod.js"; -const ops = core.ops; -import * as webidl from "ext:deno_webidl/00_webidl.js"; -import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; -import { forgivingBase64Encode } from "ext:deno_web/00_infra.js"; -import { EventTarget, ProgressEvent } from "ext:deno_web/02_event.js"; -import { decode, TextDecoder } from "ext:deno_web/08_text_encoding.js"; -import { parseMimeType } from "ext:deno_web/01_mimesniff.js"; -import { DOMException } from "ext:deno_web/01_dom_exception.js"; +const { + op_encode_binary_string, +} = core.ensureFastOps(); const { ArrayPrototypePush, ArrayPrototypeReduce, @@ -40,6 +35,14 @@ const { Uint8Array, } = primordials; +import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; +import { forgivingBase64Encode } from "ext:deno_web/00_infra.js"; +import { EventTarget, ProgressEvent } from "ext:deno_web/02_event.js"; +import { decode, TextDecoder } from "ext:deno_web/08_text_encoding.js"; +import { parseMimeType } from "ext:deno_web/01_mimesniff.js"; +import { DOMException } from "ext:deno_web/01_dom_exception.js"; + const state = Symbol("[[state]]"); const result = Symbol("[[result]]"); const error = Symbol("[[error]]"); @@ -171,7 +174,7 @@ class FileReader extends EventTarget { break; } case "BinaryString": - this[result] = ops.op_encode_binary_string(bytes); + this[result] = op_encode_binary_string(bytes); break; case "Text": { let decoder = undefined; diff --git a/ext/web/12_location.js b/ext/web/12_location.js index 5cc850262..b3417ce6e 100644 --- a/ext/web/12_location.js +++ b/ext/web/12_location.js @@ -2,8 +2,6 @@ /// <reference path="../../core/internal.d.ts" /> -import { URL } from "ext:deno_url/00_url.js"; -import { DOMException } from "ext:deno_web/01_dom_exception.js"; import { primordials } from "ext:core/mod.js"; const { Error, @@ -17,6 +15,9 @@ const { WeakMapPrototypeSet, } = primordials; +import { URL } from "ext:deno_url/00_url.js"; +import { DOMException } from "ext:deno_web/01_dom_exception.js"; + const locationConstructorKey = Symbol("locationConstructorKey"); // The differences between the definitions of `Location` and `WorkerLocation` diff --git a/ext/web/14_compression.js b/ext/web/14_compression.js index bc16f0448..411fa8c84 100644 --- a/ext/web/14_compression.js +++ b/ext/web/14_compression.js @@ -6,12 +6,17 @@ /// <reference path="./lib.deno_web.d.ts" /> import { core, primordials } from "ext:core/mod.js"; -const ops = core.ops; +const { + op_compression_finish, + op_compression_new, + op_compression_write, +} = core.ensureFastOps(); const { SymbolFor, ObjectPrototypeIsPrototypeOf, TypedArrayPrototypeGetByteLength, } = primordials; + import * as webidl from "ext:deno_webidl/00_webidl.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; import { TransformStream } from "ext:deno_web/06_streams.js"; @@ -33,19 +38,19 @@ class CompressionStream { webidl.requiredArguments(arguments.length, 1, prefix); format = webidl.converters.CompressionFormat(format, prefix, "Argument 1"); - const rid = ops.op_compression_new(format, false); + const rid = op_compression_new(format, false); this.#transform = new TransformStream({ transform(chunk, controller) { chunk = webidl.converters.BufferSource(chunk, prefix, "chunk"); - const output = ops.op_compression_write( + const output = op_compression_write( rid, chunk, ); maybeEnqueue(controller, output); }, flush(controller) { - const output = ops.op_compression_finish(rid); + const output = op_compression_finish(rid); maybeEnqueue(controller, output); }, }); @@ -92,19 +97,19 @@ class DecompressionStream { webidl.requiredArguments(arguments.length, 1, prefix); format = webidl.converters.CompressionFormat(format, prefix, "Argument 1"); - const rid = ops.op_compression_new(format, true); + const rid = op_compression_new(format, true); this.#transform = new TransformStream({ transform(chunk, controller) { chunk = webidl.converters.BufferSource(chunk, prefix, "chunk"); - const output = ops.op_compression_write( + const output = op_compression_write( rid, chunk, ); maybeEnqueue(controller, output); }, flush(controller) { - const output = ops.op_compression_finish(rid); + const output = op_compression_finish(rid); maybeEnqueue(controller, output); }, }); diff --git a/ext/web/15_performance.js b/ext/web/15_performance.js index b686f75dd..73e6686f7 100644 --- a/ext/web/15_performance.js +++ b/ext/web/15_performance.js @@ -14,6 +14,7 @@ const { SymbolFor, TypeError, } = primordials; + import * as webidl from "ext:deno_webidl/00_webidl.js"; import { structuredClone } from "ext:deno_web/02_structured_clone.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; diff --git a/ext/web/16_image_data.js b/ext/web/16_image_data.js index c7f8795f5..3dc6a46da 100644 --- a/ext/web/16_image_data.js +++ b/ext/web/16_image_data.js @@ -1,9 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import * as webidl from "ext:deno_webidl/00_webidl.js"; -import { DOMException } from "ext:deno_web/01_dom_exception.js"; -import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ObjectPrototypeIsPrototypeOf, SymbolFor, @@ -12,6 +9,10 @@ const { Uint8ClampedArray, } = primordials; +import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { DOMException } from "ext:deno_web/01_dom_exception.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; + webidl.converters["PredefinedColorSpace"] = webidl.createEnumConverter( "PredefinedColorSpace", [ |