mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
refactor: use core.ensureFastOps()
(#21888)
This commit is contained in:
parent
d4893eb51a
commit
515a34b4de
107 changed files with 1653 additions and 1147 deletions
|
@ -1,14 +1,8 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
// deno-lint-ignore-file
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
import { core, internals, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const ops = core.ops;
|
||||||
|
|
||||||
import { setExitHandler } from "ext:runtime/30_os.js";
|
|
||||||
import { Console } from "ext:deno_console/01_console.js";
|
|
||||||
import { serializePermissions } from "ext:runtime/10_permissions.js";
|
|
||||||
import { setTimeout } from "ext:deno_web/02_timers.js";
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeFilter,
|
ArrayPrototypeFilter,
|
||||||
ArrayPrototypeJoin,
|
ArrayPrototypeJoin,
|
||||||
|
@ -30,6 +24,11 @@ const {
|
||||||
TypeError,
|
TypeError,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import { setExitHandler } from "ext:runtime/30_os.js";
|
||||||
|
import { Console } from "ext:deno_console/01_console.js";
|
||||||
|
import { serializePermissions } from "ext:runtime/10_permissions.js";
|
||||||
|
import { setTimeout } from "ext:deno_web/02_timers.js";
|
||||||
|
|
||||||
const opSanitizerDelayResolveQueue = [];
|
const opSanitizerDelayResolveQueue = [];
|
||||||
let hasSetOpSanitizerDelayMacrotask = false;
|
let hasSetOpSanitizerDelayMacrotask = false;
|
||||||
|
|
||||||
|
@ -158,7 +157,7 @@ let opIdHostRecvCtrl = -1;
|
||||||
let opNames = null;
|
let opNames = null;
|
||||||
|
|
||||||
function populateOpNames() {
|
function populateOpNames() {
|
||||||
opNames = core.ops.op_op_names();
|
opNames = ops.op_op_names();
|
||||||
opIdHostRecvMessage = opNames.indexOf("op_host_recv_message");
|
opIdHostRecvMessage = opNames.indexOf("op_host_recv_message");
|
||||||
opIdHostRecvCtrl = opNames.indexOf("op_host_recv_ctrl");
|
opIdHostRecvCtrl = opNames.indexOf("op_host_recv_ctrl");
|
||||||
}
|
}
|
||||||
|
@ -172,7 +171,7 @@ function assertOps(fn) {
|
||||||
/** @param desc {TestDescription | TestStepDescription} */
|
/** @param desc {TestDescription | TestStepDescription} */
|
||||||
return async function asyncOpSanitizer(desc) {
|
return async function asyncOpSanitizer(desc) {
|
||||||
if (opNames === null) populateOpNames();
|
if (opNames === null) populateOpNames();
|
||||||
const res = core.ops.op_test_op_sanitizer_collect(
|
const res = ops.op_test_op_sanitizer_collect(
|
||||||
desc.id,
|
desc.id,
|
||||||
false,
|
false,
|
||||||
opIdHostRecvMessage,
|
opIdHostRecvMessage,
|
||||||
|
@ -180,7 +179,7 @@ function assertOps(fn) {
|
||||||
);
|
);
|
||||||
if (res !== 0) {
|
if (res !== 0) {
|
||||||
await opSanitizerDelay(res === 2);
|
await opSanitizerDelay(res === 2);
|
||||||
core.ops.op_test_op_sanitizer_collect(
|
ops.op_test_op_sanitizer_collect(
|
||||||
desc.id,
|
desc.id,
|
||||||
true,
|
true,
|
||||||
opIdHostRecvMessage,
|
opIdHostRecvMessage,
|
||||||
|
@ -195,7 +194,7 @@ function assertOps(fn) {
|
||||||
const innerResult = await fn(desc);
|
const innerResult = await fn(desc);
|
||||||
if (innerResult) return innerResult;
|
if (innerResult) return innerResult;
|
||||||
} finally {
|
} finally {
|
||||||
let res = core.ops.op_test_op_sanitizer_finish(
|
let res = ops.op_test_op_sanitizer_finish(
|
||||||
desc.id,
|
desc.id,
|
||||||
false,
|
false,
|
||||||
opIdHostRecvMessage,
|
opIdHostRecvMessage,
|
||||||
|
@ -203,7 +202,7 @@ function assertOps(fn) {
|
||||||
);
|
);
|
||||||
if (res === 1 || res === 2) {
|
if (res === 1 || res === 2) {
|
||||||
await opSanitizerDelay(res === 2);
|
await opSanitizerDelay(res === 2);
|
||||||
res = core.ops.op_test_op_sanitizer_finish(
|
res = ops.op_test_op_sanitizer_finish(
|
||||||
desc.id,
|
desc.id,
|
||||||
true,
|
true,
|
||||||
opIdHostRecvMessage,
|
opIdHostRecvMessage,
|
||||||
|
@ -212,7 +211,7 @@ function assertOps(fn) {
|
||||||
}
|
}
|
||||||
postTraces = new Map(core.opCallTraces);
|
postTraces = new Map(core.opCallTraces);
|
||||||
if (res === 3) {
|
if (res === 3) {
|
||||||
report = core.ops.op_test_op_sanitizer_report(desc.id);
|
report = ops.op_test_op_sanitizer_report(desc.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,20 +3,11 @@
|
||||||
/// <reference path="../../core/internal.d.ts" />
|
/// <reference path="../../core/internal.d.ts" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
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 {
|
|
||||||
defineEventHandler,
|
|
||||||
EventTarget,
|
|
||||||
setIsTrusted,
|
|
||||||
setTarget,
|
|
||||||
} from "ext:deno_web/02_event.js";
|
|
||||||
import { defer } from "ext:deno_web/02_timers.js";
|
|
||||||
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
|
||||||
const {
|
const {
|
||||||
op_broadcast_recv,
|
op_broadcast_recv,
|
||||||
op_broadcast_send,
|
op_broadcast_send,
|
||||||
|
op_broadcast_subscribe,
|
||||||
|
op_broadcast_unsubscribe,
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeIndexOf,
|
ArrayPrototypeIndexOf,
|
||||||
|
@ -28,6 +19,17 @@ const {
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
|
import {
|
||||||
|
defineEventHandler,
|
||||||
|
EventTarget,
|
||||||
|
setIsTrusted,
|
||||||
|
setTarget,
|
||||||
|
} from "ext:deno_web/02_event.js";
|
||||||
|
import { defer } from "ext:deno_web/02_timers.js";
|
||||||
|
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
||||||
|
|
||||||
const _name = Symbol("[[name]]");
|
const _name = Symbol("[[name]]");
|
||||||
const _closed = Symbol("[[closed]]");
|
const _closed = Symbol("[[closed]]");
|
||||||
|
|
||||||
|
@ -95,7 +97,7 @@ class BroadcastChannel extends EventTarget {
|
||||||
if (rid === null) {
|
if (rid === null) {
|
||||||
// Create the rid immediately, otherwise there is a time window (and a
|
// Create the rid immediately, otherwise there is a time window (and a
|
||||||
// race condition) where messages can get lost, because recv() is async.
|
// race condition) where messages can get lost, because recv() is async.
|
||||||
rid = ops.op_broadcast_subscribe();
|
rid = op_broadcast_subscribe();
|
||||||
recv();
|
recv();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +138,7 @@ class BroadcastChannel extends EventTarget {
|
||||||
|
|
||||||
ArrayPrototypeSplice(channels, index, 1);
|
ArrayPrototypeSplice(channels, index, 1);
|
||||||
if (channels.length === 0) {
|
if (channels.length === 0) {
|
||||||
ops.op_broadcast_unsubscribe(rid);
|
op_broadcast_unsubscribe(rid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
40
ext/cache/01_cache.js
vendored
40
ext/cache/01_cache.js
vendored
|
@ -1,24 +1,5 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
|
||||||
const {
|
|
||||||
ArrayPrototypePush,
|
|
||||||
ObjectPrototypeIsPrototypeOf,
|
|
||||||
StringPrototypeSplit,
|
|
||||||
StringPrototypeTrim,
|
|
||||||
Symbol,
|
|
||||||
SymbolFor,
|
|
||||||
TypeError,
|
|
||||||
} = primordials;
|
|
||||||
import {
|
|
||||||
Request,
|
|
||||||
RequestPrototype,
|
|
||||||
toInnerRequest,
|
|
||||||
} from "ext:deno_fetch/23_request.js";
|
|
||||||
import { toInnerResponse } from "ext:deno_fetch/23_response.js";
|
|
||||||
import { URLPrototype } from "ext:deno_url/00_url.js";
|
|
||||||
import { getHeader } from "ext:deno_fetch/20_headers.js";
|
|
||||||
import { readableStreamForRid } from "ext:deno_web/06_streams.js";
|
|
||||||
const {
|
const {
|
||||||
op_cache_delete,
|
op_cache_delete,
|
||||||
op_cache_match,
|
op_cache_match,
|
||||||
|
@ -28,6 +9,27 @@ const {
|
||||||
op_cache_storage_has,
|
op_cache_storage_has,
|
||||||
op_cache_storage_open,
|
op_cache_storage_open,
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
ArrayPrototypePush,
|
||||||
|
ObjectPrototypeIsPrototypeOf,
|
||||||
|
StringPrototypeSplit,
|
||||||
|
StringPrototypeTrim,
|
||||||
|
Symbol,
|
||||||
|
SymbolFor,
|
||||||
|
TypeError,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
|
import {
|
||||||
|
Request,
|
||||||
|
RequestPrototype,
|
||||||
|
toInnerRequest,
|
||||||
|
} from "ext:deno_fetch/23_request.js";
|
||||||
|
import { toInnerResponse } from "ext:deno_fetch/23_response.js";
|
||||||
|
import { URLPrototype } from "ext:deno_url/00_url.js";
|
||||||
|
import { getHeader } from "ext:deno_fetch/20_headers.js";
|
||||||
|
import { readableStreamForRid } from "ext:deno_web/06_streams.js";
|
||||||
|
|
||||||
class CacheStorage {
|
class CacheStorage {
|
||||||
constructor() {
|
constructor() {
|
||||||
webidl.illegalConstructor();
|
webidl.illegalConstructor();
|
||||||
|
|
|
@ -3,6 +3,36 @@
|
||||||
/// <reference path="../../core/internal.d.ts" />
|
/// <reference path="../../core/internal.d.ts" />
|
||||||
|
|
||||||
import { core, internals, primordials } from "ext:core/mod.js";
|
import { core, internals, primordials } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
isAnyArrayBuffer,
|
||||||
|
isArgumentsObject,
|
||||||
|
isArrayBuffer,
|
||||||
|
isAsyncFunction,
|
||||||
|
isBigIntObject,
|
||||||
|
isBooleanObject,
|
||||||
|
isBoxedPrimitive,
|
||||||
|
isDataView,
|
||||||
|
isDate,
|
||||||
|
isGeneratorFunction,
|
||||||
|
isMap,
|
||||||
|
isMapIterator,
|
||||||
|
isModuleNamespaceObject,
|
||||||
|
isNativeError,
|
||||||
|
isNumberObject,
|
||||||
|
isPromise,
|
||||||
|
isRegExp,
|
||||||
|
isSet,
|
||||||
|
isSetIterator,
|
||||||
|
isStringObject,
|
||||||
|
isTypedArray,
|
||||||
|
isWeakMap,
|
||||||
|
isWeakSet,
|
||||||
|
} = core;
|
||||||
|
const {
|
||||||
|
op_get_constructor_name,
|
||||||
|
op_get_non_index_property_names,
|
||||||
|
op_preview_entries,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
const {
|
const {
|
||||||
Array,
|
Array,
|
||||||
ArrayBufferPrototypeGetByteLength,
|
ArrayBufferPrototypeGetByteLength,
|
||||||
|
@ -30,13 +60,12 @@ const {
|
||||||
DatePrototypeGetTime,
|
DatePrototypeGetTime,
|
||||||
DatePrototypeToISOString,
|
DatePrototypeToISOString,
|
||||||
Error,
|
Error,
|
||||||
ErrorPrototype,
|
|
||||||
ErrorCaptureStackTrace,
|
ErrorCaptureStackTrace,
|
||||||
|
ErrorPrototype,
|
||||||
ErrorPrototypeToString,
|
ErrorPrototypeToString,
|
||||||
FunctionPrototypeBind,
|
FunctionPrototypeBind,
|
||||||
FunctionPrototypeCall,
|
FunctionPrototypeCall,
|
||||||
FunctionPrototypeToString,
|
FunctionPrototypeToString,
|
||||||
NumberIsNaN,
|
|
||||||
MapPrototypeDelete,
|
MapPrototypeDelete,
|
||||||
MapPrototypeEntries,
|
MapPrototypeEntries,
|
||||||
MapPrototypeForEach,
|
MapPrototypeForEach,
|
||||||
|
@ -52,6 +81,7 @@ const {
|
||||||
MathSqrt,
|
MathSqrt,
|
||||||
Number,
|
Number,
|
||||||
NumberIsInteger,
|
NumberIsInteger,
|
||||||
|
NumberIsNaN,
|
||||||
NumberParseInt,
|
NumberParseInt,
|
||||||
NumberPrototypeToString,
|
NumberPrototypeToString,
|
||||||
NumberPrototypeValueOf,
|
NumberPrototypeValueOf,
|
||||||
|
@ -90,8 +120,8 @@ const {
|
||||||
SafeSetIterator,
|
SafeSetIterator,
|
||||||
SafeStringIterator,
|
SafeStringIterator,
|
||||||
SetPrototypeAdd,
|
SetPrototypeAdd,
|
||||||
SetPrototypeHas,
|
|
||||||
SetPrototypeGetSize,
|
SetPrototypeGetSize,
|
||||||
|
SetPrototypeHas,
|
||||||
SetPrototypeValues,
|
SetPrototypeValues,
|
||||||
String,
|
String,
|
||||||
StringPrototypeCharCodeAt,
|
StringPrototypeCharCodeAt,
|
||||||
|
@ -125,36 +155,6 @@ const {
|
||||||
TypedArrayPrototypeGetLength,
|
TypedArrayPrototypeGetLength,
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
const {
|
|
||||||
isAnyArrayBuffer,
|
|
||||||
isArgumentsObject,
|
|
||||||
isArrayBuffer,
|
|
||||||
isAsyncFunction,
|
|
||||||
isBigIntObject,
|
|
||||||
isBooleanObject,
|
|
||||||
isBoxedPrimitive,
|
|
||||||
isDataView,
|
|
||||||
isDate,
|
|
||||||
isGeneratorFunction,
|
|
||||||
isMap,
|
|
||||||
isMapIterator,
|
|
||||||
isModuleNamespaceObject,
|
|
||||||
isNativeError,
|
|
||||||
isNumberObject,
|
|
||||||
isPromise,
|
|
||||||
isRegExp,
|
|
||||||
isSet,
|
|
||||||
isSetIterator,
|
|
||||||
isStringObject,
|
|
||||||
isTypedArray,
|
|
||||||
isWeakSet,
|
|
||||||
isWeakMap,
|
|
||||||
} = core;
|
|
||||||
const {
|
|
||||||
op_get_non_index_property_names,
|
|
||||||
op_get_constructor_name,
|
|
||||||
op_preview_entries,
|
|
||||||
} = core.ensureFastOps(true);
|
|
||||||
|
|
||||||
let noColor = () => false;
|
let noColor = () => false;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, internals, primordials } from "ext:core/mod.js";
|
import { core, internals, primordials } from "ext:core/mod.js";
|
||||||
const {
|
|
||||||
ArrayPrototypeJoin,
|
|
||||||
NumberPrototypeToString,
|
|
||||||
TypeError,
|
|
||||||
} = primordials;
|
|
||||||
const {
|
const {
|
||||||
isPromise,
|
isPromise,
|
||||||
} = core;
|
} = core;
|
||||||
|
@ -13,6 +8,11 @@ const {
|
||||||
op_cron_create,
|
op_cron_create,
|
||||||
op_cron_next,
|
op_cron_next,
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
ArrayPrototypeJoin,
|
||||||
|
NumberPrototypeToString,
|
||||||
|
TypeError,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
export function formatToCronSchedule(
|
export function formatToCronSchedule(
|
||||||
value?: number | { exact: number | number[] } | {
|
value?: number | { exact: number | number[] } | {
|
||||||
|
|
|
@ -7,20 +7,42 @@
|
||||||
/// <reference path="../web/lib.deno_web.d.ts" />
|
/// <reference path="../web/lib.deno_web.d.ts" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
|
||||||
const {
|
const {
|
||||||
|
isArrayBuffer,
|
||||||
|
isTypedArray,
|
||||||
|
isDataView,
|
||||||
|
} = core;
|
||||||
|
const {
|
||||||
|
op_crypto_base64url_decode,
|
||||||
|
op_crypto_base64url_encode,
|
||||||
op_crypto_decrypt,
|
op_crypto_decrypt,
|
||||||
op_crypto_derive_bits,
|
op_crypto_derive_bits,
|
||||||
|
op_crypto_derive_bits_x25519,
|
||||||
op_crypto_encrypt,
|
op_crypto_encrypt,
|
||||||
|
op_crypto_export_key,
|
||||||
|
op_crypto_export_pkcs8_ed25519,
|
||||||
|
op_crypto_export_pkcs8_x25519,
|
||||||
|
op_crypto_export_spki_ed25519,
|
||||||
|
op_crypto_export_spki_x25519,
|
||||||
|
op_crypto_generate_ed25519_keypair,
|
||||||
op_crypto_generate_key,
|
op_crypto_generate_key,
|
||||||
|
op_crypto_generate_x25519_keypair,
|
||||||
|
op_crypto_get_random_values,
|
||||||
|
op_crypto_import_key,
|
||||||
|
op_crypto_import_pkcs8_ed25519,
|
||||||
|
op_crypto_import_pkcs8_x25519,
|
||||||
|
op_crypto_import_spki_ed25519,
|
||||||
|
op_crypto_import_spki_x25519,
|
||||||
|
op_crypto_jwk_x_ed25519,
|
||||||
|
op_crypto_random_uuid,
|
||||||
|
op_crypto_sign_ed25519,
|
||||||
op_crypto_sign_key,
|
op_crypto_sign_key,
|
||||||
op_crypto_subtle_digest,
|
op_crypto_subtle_digest,
|
||||||
|
op_crypto_unwrap_key,
|
||||||
|
op_crypto_verify_ed25519,
|
||||||
op_crypto_verify_key,
|
op_crypto_verify_key,
|
||||||
|
op_crypto_wrap_key,
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
|
||||||
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
|
||||||
const {
|
const {
|
||||||
ArrayBufferIsView,
|
ArrayBufferIsView,
|
||||||
ArrayBufferPrototypeGetByteLength,
|
ArrayBufferPrototypeGetByteLength,
|
||||||
|
@ -57,11 +79,10 @@ const {
|
||||||
WeakMapPrototypeGet,
|
WeakMapPrototypeGet,
|
||||||
WeakMapPrototypeSet,
|
WeakMapPrototypeSet,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
const {
|
|
||||||
isArrayBuffer,
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
isTypedArray,
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
isDataView,
|
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
||||||
} = core;
|
|
||||||
|
|
||||||
const supportedNamedCurves = ["P-256", "P-384", "P-521"];
|
const supportedNamedCurves = ["P-256", "P-384", "P-521"];
|
||||||
const recognisedUsages = [
|
const recognisedUsages = [
|
||||||
|
@ -897,7 +918,7 @@ class SubtleCrypto {
|
||||||
// https://briansmith.org/rustdoc/src/ring/ec/curve25519/ed25519/signing.rs.html#260
|
// https://briansmith.org/rustdoc/src/ring/ec/curve25519/ed25519/signing.rs.html#260
|
||||||
const SIGNATURE_LEN = 32 * 2; // ELEM_LEN + SCALAR_LEN
|
const SIGNATURE_LEN = 32 * 2; // ELEM_LEN + SCALAR_LEN
|
||||||
const signature = new Uint8Array(SIGNATURE_LEN);
|
const signature = new Uint8Array(SIGNATURE_LEN);
|
||||||
if (!ops.op_crypto_sign_ed25519(keyData, data, signature)) {
|
if (!op_crypto_sign_ed25519(keyData, data, signature)) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"Failed to sign",
|
"Failed to sign",
|
||||||
"OperationError",
|
"OperationError",
|
||||||
|
@ -1371,7 +1392,7 @@ class SubtleCrypto {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ops.op_crypto_verify_ed25519(keyData, data, signature);
|
return op_crypto_verify_ed25519(keyData, data, signature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1461,7 +1482,7 @@ class SubtleCrypto {
|
||||||
|
|
||||||
switch (normalizedAlgorithm.name) {
|
switch (normalizedAlgorithm.name) {
|
||||||
case "AES-KW": {
|
case "AES-KW": {
|
||||||
const cipherText = await ops.op_crypto_wrap_key({
|
const cipherText = await op_crypto_wrap_key({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: normalizedAlgorithm.name,
|
algorithm: normalizedAlgorithm.name,
|
||||||
}, bytes);
|
}, bytes);
|
||||||
|
@ -1593,7 +1614,7 @@ class SubtleCrypto {
|
||||||
|
|
||||||
switch (normalizedAlgorithm.name) {
|
switch (normalizedAlgorithm.name) {
|
||||||
case "AES-KW": {
|
case "AES-KW": {
|
||||||
const plainText = await ops.op_crypto_unwrap_key({
|
const plainText = await op_crypto_unwrap_key({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: normalizedAlgorithm.name,
|
algorithm: normalizedAlgorithm.name,
|
||||||
}, wrappedKey);
|
}, wrappedKey);
|
||||||
|
@ -2007,7 +2028,7 @@ async function generateKey(normalizedAlgorithm, extractable, usages) {
|
||||||
}
|
}
|
||||||
const privateKeyData = new Uint8Array(32);
|
const privateKeyData = new Uint8Array(32);
|
||||||
const publicKeyData = new Uint8Array(32);
|
const publicKeyData = new Uint8Array(32);
|
||||||
ops.op_crypto_generate_x25519_keypair(privateKeyData, publicKeyData);
|
op_crypto_generate_x25519_keypair(privateKeyData, publicKeyData);
|
||||||
|
|
||||||
const handle = {};
|
const handle = {};
|
||||||
WeakMapPrototypeSet(KEY_STORE, handle, privateKeyData);
|
WeakMapPrototypeSet(KEY_STORE, handle, privateKeyData);
|
||||||
|
@ -2052,7 +2073,7 @@ async function generateKey(normalizedAlgorithm, extractable, usages) {
|
||||||
const privateKeyData = new Uint8Array(ED25519_SEED_LEN);
|
const privateKeyData = new Uint8Array(ED25519_SEED_LEN);
|
||||||
const publicKeyData = new Uint8Array(ED25519_PUBLIC_KEY_LEN);
|
const publicKeyData = new Uint8Array(ED25519_PUBLIC_KEY_LEN);
|
||||||
if (
|
if (
|
||||||
!ops.op_crypto_generate_ed25519_keypair(privateKeyData, publicKeyData)
|
!op_crypto_generate_ed25519_keypair(privateKeyData, publicKeyData)
|
||||||
) {
|
) {
|
||||||
throw new DOMException("Failed to generate key", "OperationError");
|
throw new DOMException("Failed to generate key", "OperationError");
|
||||||
}
|
}
|
||||||
|
@ -2189,7 +2210,7 @@ function importKeyEd25519(
|
||||||
}
|
}
|
||||||
|
|
||||||
const publicKeyData = new Uint8Array(32);
|
const publicKeyData = new Uint8Array(32);
|
||||||
if (!ops.op_crypto_import_spki_ed25519(keyData, publicKeyData)) {
|
if (!op_crypto_import_spki_ed25519(keyData, publicKeyData)) {
|
||||||
throw new DOMException("Invalid key data", "DataError");
|
throw new DOMException("Invalid key data", "DataError");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2220,7 +2241,7 @@ function importKeyEd25519(
|
||||||
}
|
}
|
||||||
|
|
||||||
const privateKeyData = new Uint8Array(32);
|
const privateKeyData = new Uint8Array(32);
|
||||||
if (!ops.op_crypto_import_pkcs8_ed25519(keyData, privateKeyData)) {
|
if (!op_crypto_import_pkcs8_ed25519(keyData, privateKeyData)) {
|
||||||
throw new DOMException("Invalid key data", "DataError");
|
throw new DOMException("Invalid key data", "DataError");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2326,7 +2347,7 @@ function importKeyEd25519(
|
||||||
// https://www.rfc-editor.org/rfc/rfc8037#section-2
|
// https://www.rfc-editor.org/rfc/rfc8037#section-2
|
||||||
let privateKeyData;
|
let privateKeyData;
|
||||||
try {
|
try {
|
||||||
privateKeyData = ops.op_crypto_base64url_decode(jwk.d);
|
privateKeyData = op_crypto_base64url_decode(jwk.d);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
throw new DOMException("invalid private key data", "DataError");
|
throw new DOMException("invalid private key data", "DataError");
|
||||||
}
|
}
|
||||||
|
@ -2349,7 +2370,7 @@ function importKeyEd25519(
|
||||||
// https://www.rfc-editor.org/rfc/rfc8037#section-2
|
// https://www.rfc-editor.org/rfc/rfc8037#section-2
|
||||||
let publicKeyData;
|
let publicKeyData;
|
||||||
try {
|
try {
|
||||||
publicKeyData = ops.op_crypto_base64url_decode(jwk.x);
|
publicKeyData = op_crypto_base64url_decode(jwk.x);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
throw new DOMException("invalid public key data", "DataError");
|
throw new DOMException("invalid public key data", "DataError");
|
||||||
}
|
}
|
||||||
|
@ -2412,7 +2433,7 @@ function importKeyX25519(
|
||||||
}
|
}
|
||||||
|
|
||||||
const publicKeyData = new Uint8Array(32);
|
const publicKeyData = new Uint8Array(32);
|
||||||
if (!ops.op_crypto_import_spki_x25519(keyData, publicKeyData)) {
|
if (!op_crypto_import_spki_x25519(keyData, publicKeyData)) {
|
||||||
throw new DOMException("Invalid key data", "DataError");
|
throw new DOMException("Invalid key data", "DataError");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2443,7 +2464,7 @@ function importKeyX25519(
|
||||||
}
|
}
|
||||||
|
|
||||||
const privateKeyData = new Uint8Array(32);
|
const privateKeyData = new Uint8Array(32);
|
||||||
if (!ops.op_crypto_import_pkcs8_x25519(keyData, privateKeyData)) {
|
if (!op_crypto_import_pkcs8_x25519(keyData, privateKeyData)) {
|
||||||
throw new DOMException("Invalid key data", "DataError");
|
throw new DOMException("Invalid key data", "DataError");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2539,7 +2560,7 @@ function importKeyX25519(
|
||||||
// 9.
|
// 9.
|
||||||
if (jwk.d !== undefined) {
|
if (jwk.d !== undefined) {
|
||||||
// https://www.rfc-editor.org/rfc/rfc8037#section-2
|
// https://www.rfc-editor.org/rfc/rfc8037#section-2
|
||||||
const privateKeyData = ops.op_crypto_base64url_decode(jwk.d);
|
const privateKeyData = op_crypto_base64url_decode(jwk.d);
|
||||||
|
|
||||||
const handle = {};
|
const handle = {};
|
||||||
WeakMapPrototypeSet(KEY_STORE, handle, privateKeyData);
|
WeakMapPrototypeSet(KEY_STORE, handle, privateKeyData);
|
||||||
|
@ -2557,7 +2578,7 @@ function importKeyX25519(
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// https://www.rfc-editor.org/rfc/rfc8037#section-2
|
// https://www.rfc-editor.org/rfc/rfc8037#section-2
|
||||||
const publicKeyData = ops.op_crypto_base64url_decode(jwk.x);
|
const publicKeyData = op_crypto_base64url_decode(jwk.x);
|
||||||
|
|
||||||
const handle = {};
|
const handle = {};
|
||||||
WeakMapPrototypeSet(KEY_STORE, handle, publicKeyData);
|
WeakMapPrototypeSet(KEY_STORE, handle, publicKeyData);
|
||||||
|
@ -2600,7 +2621,7 @@ function exportKeyAES(
|
||||||
};
|
};
|
||||||
|
|
||||||
// 3.
|
// 3.
|
||||||
const data = ops.op_crypto_export_key({
|
const data = op_crypto_export_key({
|
||||||
format: "jwksecret",
|
format: "jwksecret",
|
||||||
algorithm: "AES",
|
algorithm: "AES",
|
||||||
}, innerKey);
|
}, innerKey);
|
||||||
|
@ -2697,7 +2718,7 @@ function importKeyAES(
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.
|
// 4.
|
||||||
const { rawData } = ops.op_crypto_import_key(
|
const { rawData } = op_crypto_import_key(
|
||||||
{ algorithm: "AES" },
|
{ algorithm: "AES" },
|
||||||
{ jwkSecret: jwk },
|
{ jwkSecret: jwk },
|
||||||
);
|
);
|
||||||
|
@ -2857,7 +2878,7 @@ function importKeyHMAC(
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.
|
// 4.
|
||||||
const { rawData } = ops.op_crypto_import_key(
|
const { rawData } = op_crypto_import_key(
|
||||||
{ algorithm: "HMAC" },
|
{ algorithm: "HMAC" },
|
||||||
{ jwkSecret: jwk },
|
{ jwkSecret: jwk },
|
||||||
);
|
);
|
||||||
|
@ -3042,7 +3063,7 @@ function importKeyEC(
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.
|
// 3.
|
||||||
const { rawData } = ops.op_crypto_import_key({
|
const { rawData } = op_crypto_import_key({
|
||||||
algorithm: normalizedAlgorithm.name,
|
algorithm: normalizedAlgorithm.name,
|
||||||
namedCurve: normalizedAlgorithm.namedCurve,
|
namedCurve: normalizedAlgorithm.namedCurve,
|
||||||
}, { raw: keyData });
|
}, { raw: keyData });
|
||||||
|
@ -3083,7 +3104,7 @@ function importKeyEC(
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2-9.
|
// 2-9.
|
||||||
const { rawData } = ops.op_crypto_import_key({
|
const { rawData } = op_crypto_import_key({
|
||||||
algorithm: normalizedAlgorithm.name,
|
algorithm: normalizedAlgorithm.name,
|
||||||
namedCurve: normalizedAlgorithm.namedCurve,
|
namedCurve: normalizedAlgorithm.namedCurve,
|
||||||
}, { pkcs8: keyData });
|
}, { pkcs8: keyData });
|
||||||
|
@ -3126,7 +3147,7 @@ function importKeyEC(
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2-12
|
// 2-12
|
||||||
const { rawData } = ops.op_crypto_import_key({
|
const { rawData } = op_crypto_import_key({
|
||||||
algorithm: normalizedAlgorithm.name,
|
algorithm: normalizedAlgorithm.name,
|
||||||
namedCurve: normalizedAlgorithm.namedCurve,
|
namedCurve: normalizedAlgorithm.namedCurve,
|
||||||
}, { spki: keyData });
|
}, { spki: keyData });
|
||||||
|
@ -3270,7 +3291,7 @@ function importKeyEC(
|
||||||
|
|
||||||
if (jwk.d !== undefined) {
|
if (jwk.d !== undefined) {
|
||||||
// it's also a Private key
|
// it's also a Private key
|
||||||
const { rawData } = ops.op_crypto_import_key({
|
const { rawData } = op_crypto_import_key({
|
||||||
algorithm: normalizedAlgorithm.name,
|
algorithm: normalizedAlgorithm.name,
|
||||||
namedCurve: normalizedAlgorithm.namedCurve,
|
namedCurve: normalizedAlgorithm.namedCurve,
|
||||||
}, { jwkPrivateEc: jwk });
|
}, { jwkPrivateEc: jwk });
|
||||||
|
@ -3293,7 +3314,7 @@ function importKeyEC(
|
||||||
|
|
||||||
return key;
|
return key;
|
||||||
} else {
|
} else {
|
||||||
const { rawData } = ops.op_crypto_import_key({
|
const { rawData } = op_crypto_import_key({
|
||||||
algorithm: normalizedAlgorithm.name,
|
algorithm: normalizedAlgorithm.name,
|
||||||
namedCurve: normalizedAlgorithm.namedCurve,
|
namedCurve: normalizedAlgorithm.namedCurve,
|
||||||
}, { jwkPublicEc: jwk });
|
}, { jwkPublicEc: jwk });
|
||||||
|
@ -3374,15 +3395,14 @@ function importKeyRSA(
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2-9.
|
// 2-9.
|
||||||
const { modulusLength, publicExponent, rawData } = ops
|
const { modulusLength, publicExponent, rawData } = op_crypto_import_key(
|
||||||
.op_crypto_import_key(
|
{
|
||||||
{
|
algorithm: normalizedAlgorithm.name,
|
||||||
algorithm: normalizedAlgorithm.name,
|
// Needed to perform step 7 without normalization.
|
||||||
// Needed to perform step 7 without normalization.
|
hash: normalizedAlgorithm.hash.name,
|
||||||
hash: normalizedAlgorithm.hash.name,
|
},
|
||||||
},
|
{ pkcs8: keyData },
|
||||||
{ pkcs8: keyData },
|
);
|
||||||
);
|
|
||||||
|
|
||||||
const handle = {};
|
const handle = {};
|
||||||
WeakMapPrototypeSet(KEY_STORE, handle, rawData);
|
WeakMapPrototypeSet(KEY_STORE, handle, rawData);
|
||||||
|
@ -3420,15 +3440,14 @@ function importKeyRSA(
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2-9.
|
// 2-9.
|
||||||
const { modulusLength, publicExponent, rawData } = ops
|
const { modulusLength, publicExponent, rawData } = op_crypto_import_key(
|
||||||
.op_crypto_import_key(
|
{
|
||||||
{
|
algorithm: normalizedAlgorithm.name,
|
||||||
algorithm: normalizedAlgorithm.name,
|
// Needed to perform step 7 without normalization.
|
||||||
// Needed to perform step 7 without normalization.
|
hash: normalizedAlgorithm.hash.name,
|
||||||
hash: normalizedAlgorithm.hash.name,
|
},
|
||||||
},
|
{ spki: keyData },
|
||||||
{ spki: keyData },
|
);
|
||||||
);
|
|
||||||
|
|
||||||
const handle = {};
|
const handle = {};
|
||||||
WeakMapPrototypeSet(KEY_STORE, handle, rawData);
|
WeakMapPrototypeSet(KEY_STORE, handle, rawData);
|
||||||
|
@ -3670,14 +3689,13 @@ function importKeyRSA(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { modulusLength, publicExponent, rawData } = ops
|
const { modulusLength, publicExponent, rawData } = op_crypto_import_key(
|
||||||
.op_crypto_import_key(
|
{
|
||||||
{
|
algorithm: normalizedAlgorithm.name,
|
||||||
algorithm: normalizedAlgorithm.name,
|
hash: normalizedAlgorithm.hash.name,
|
||||||
hash: normalizedAlgorithm.hash.name,
|
},
|
||||||
},
|
{ jwkPrivateRsa: jwk },
|
||||||
{ jwkPrivateRsa: jwk },
|
);
|
||||||
);
|
|
||||||
|
|
||||||
const handle = {};
|
const handle = {};
|
||||||
WeakMapPrototypeSet(KEY_STORE, handle, rawData);
|
WeakMapPrototypeSet(KEY_STORE, handle, rawData);
|
||||||
|
@ -3713,14 +3731,13 @@ function importKeyRSA(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { modulusLength, publicExponent, rawData } = ops
|
const { modulusLength, publicExponent, rawData } = op_crypto_import_key(
|
||||||
.op_crypto_import_key(
|
{
|
||||||
{
|
algorithm: normalizedAlgorithm.name,
|
||||||
algorithm: normalizedAlgorithm.name,
|
hash: normalizedAlgorithm.hash.name,
|
||||||
hash: normalizedAlgorithm.hash.name,
|
},
|
||||||
},
|
{ jwkPublicRsa: jwk },
|
||||||
{ jwkPublicRsa: jwk },
|
);
|
||||||
);
|
|
||||||
|
|
||||||
const handle = {};
|
const handle = {};
|
||||||
WeakMapPrototypeSet(KEY_STORE, handle, rawData);
|
WeakMapPrototypeSet(KEY_STORE, handle, rawData);
|
||||||
|
@ -3875,7 +3892,7 @@ function exportKeyHMAC(format, key, innerKey) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// 3.
|
// 3.
|
||||||
const data = ops.op_crypto_export_key({
|
const data = op_crypto_export_key({
|
||||||
format: "jwksecret",
|
format: "jwksecret",
|
||||||
algorithm: key[_algorithm].name,
|
algorithm: key[_algorithm].name,
|
||||||
}, innerKey);
|
}, innerKey);
|
||||||
|
@ -3929,7 +3946,7 @@ function exportKeyRSA(format, key, innerKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
const data = ops.op_crypto_export_key({
|
const data = op_crypto_export_key({
|
||||||
algorithm: key[_algorithm].name,
|
algorithm: key[_algorithm].name,
|
||||||
format: "pkcs8",
|
format: "pkcs8",
|
||||||
}, innerKey);
|
}, innerKey);
|
||||||
|
@ -3947,7 +3964,7 @@ function exportKeyRSA(format, key, innerKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
const data = ops.op_crypto_export_key({
|
const data = op_crypto_export_key({
|
||||||
algorithm: key[_algorithm].name,
|
algorithm: key[_algorithm].name,
|
||||||
format: "spki",
|
format: "spki",
|
||||||
}, innerKey);
|
}, innerKey);
|
||||||
|
@ -4028,7 +4045,7 @@ function exportKeyRSA(format, key, innerKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5-6.
|
// 5-6.
|
||||||
const data = ops.op_crypto_export_key({
|
const data = op_crypto_export_key({
|
||||||
format: key[_type] === "private" ? "jwkprivate" : "jwkpublic",
|
format: key[_type] === "private" ? "jwkprivate" : "jwkpublic",
|
||||||
algorithm: key[_algorithm].name,
|
algorithm: key[_algorithm].name,
|
||||||
}, innerKey);
|
}, innerKey);
|
||||||
|
@ -4070,7 +4087,7 @@ function exportKeyEd25519(format, key, innerKey) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const spkiDer = ops.op_crypto_export_spki_ed25519(innerKey);
|
const spkiDer = op_crypto_export_spki_ed25519(innerKey);
|
||||||
return TypedArrayPrototypeGetBuffer(spkiDer);
|
return TypedArrayPrototypeGetBuffer(spkiDer);
|
||||||
}
|
}
|
||||||
case "pkcs8": {
|
case "pkcs8": {
|
||||||
|
@ -4082,7 +4099,7 @@ function exportKeyEd25519(format, key, innerKey) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const pkcs8Der = ops.op_crypto_export_pkcs8_ed25519(
|
const pkcs8Der = op_crypto_export_pkcs8_ed25519(
|
||||||
new Uint8Array([0x04, 0x22, ...new SafeArrayIterator(innerKey)]),
|
new Uint8Array([0x04, 0x22, ...new SafeArrayIterator(innerKey)]),
|
||||||
);
|
);
|
||||||
pkcs8Der[15] = 0x20;
|
pkcs8Der[15] = 0x20;
|
||||||
|
@ -4090,8 +4107,8 @@ function exportKeyEd25519(format, key, innerKey) {
|
||||||
}
|
}
|
||||||
case "jwk": {
|
case "jwk": {
|
||||||
const x = key[_type] === "private"
|
const x = key[_type] === "private"
|
||||||
? ops.op_crypto_jwk_x_ed25519(innerKey)
|
? op_crypto_jwk_x_ed25519(innerKey)
|
||||||
: ops.op_crypto_base64url_encode(innerKey);
|
: op_crypto_base64url_encode(innerKey);
|
||||||
const jwk = {
|
const jwk = {
|
||||||
kty: "OKP",
|
kty: "OKP",
|
||||||
crv: "Ed25519",
|
crv: "Ed25519",
|
||||||
|
@ -4100,7 +4117,7 @@ function exportKeyEd25519(format, key, innerKey) {
|
||||||
ext: key[_extractable],
|
ext: key[_extractable],
|
||||||
};
|
};
|
||||||
if (key[_type] === "private") {
|
if (key[_type] === "private") {
|
||||||
jwk.d = ops.op_crypto_base64url_encode(innerKey);
|
jwk.d = op_crypto_base64url_encode(innerKey);
|
||||||
}
|
}
|
||||||
return jwk;
|
return jwk;
|
||||||
}
|
}
|
||||||
|
@ -4132,7 +4149,7 @@ function exportKeyX25519(format, key, innerKey) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const spkiDer = ops.op_crypto_export_spki_x25519(innerKey);
|
const spkiDer = op_crypto_export_spki_x25519(innerKey);
|
||||||
return TypedArrayPrototypeGetBuffer(spkiDer);
|
return TypedArrayPrototypeGetBuffer(spkiDer);
|
||||||
}
|
}
|
||||||
case "pkcs8": {
|
case "pkcs8": {
|
||||||
|
@ -4144,7 +4161,7 @@ function exportKeyX25519(format, key, innerKey) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const pkcs8Der = ops.op_crypto_export_pkcs8_x25519(
|
const pkcs8Der = op_crypto_export_pkcs8_x25519(
|
||||||
new Uint8Array([0x04, 0x22, ...new SafeArrayIterator(innerKey)]),
|
new Uint8Array([0x04, 0x22, ...new SafeArrayIterator(innerKey)]),
|
||||||
);
|
);
|
||||||
pkcs8Der[15] = 0x20;
|
pkcs8Der[15] = 0x20;
|
||||||
|
@ -4154,7 +4171,7 @@ function exportKeyX25519(format, key, innerKey) {
|
||||||
if (key[_type] === "private") {
|
if (key[_type] === "private") {
|
||||||
throw new DOMException("Not implemented", "NotSupportedError");
|
throw new DOMException("Not implemented", "NotSupportedError");
|
||||||
}
|
}
|
||||||
const x = ops.op_crypto_base64url_encode(innerKey);
|
const x = op_crypto_base64url_encode(innerKey);
|
||||||
const jwk = {
|
const jwk = {
|
||||||
kty: "OKP",
|
kty: "OKP",
|
||||||
crv: "X25519",
|
crv: "X25519",
|
||||||
|
@ -4181,7 +4198,7 @@ function exportKeyEC(format, key, innerKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
const data = ops.op_crypto_export_key({
|
const data = op_crypto_export_key({
|
||||||
algorithm: key[_algorithm].name,
|
algorithm: key[_algorithm].name,
|
||||||
namedCurve: key[_algorithm].namedCurve,
|
namedCurve: key[_algorithm].namedCurve,
|
||||||
format: "raw",
|
format: "raw",
|
||||||
|
@ -4199,7 +4216,7 @@ function exportKeyEC(format, key, innerKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
const data = ops.op_crypto_export_key({
|
const data = op_crypto_export_key({
|
||||||
algorithm: key[_algorithm].name,
|
algorithm: key[_algorithm].name,
|
||||||
namedCurve: key[_algorithm].namedCurve,
|
namedCurve: key[_algorithm].namedCurve,
|
||||||
format: "pkcs8",
|
format: "pkcs8",
|
||||||
|
@ -4217,7 +4234,7 @@ function exportKeyEC(format, key, innerKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
const data = ops.op_crypto_export_key({
|
const data = op_crypto_export_key({
|
||||||
algorithm: key[_algorithm].name,
|
algorithm: key[_algorithm].name,
|
||||||
namedCurve: key[_algorithm].namedCurve,
|
namedCurve: key[_algorithm].namedCurve,
|
||||||
format: "spki",
|
format: "spki",
|
||||||
|
@ -4261,7 +4278,7 @@ function exportKeyEC(format, key, innerKey) {
|
||||||
jwk.alg = algNamedCurve;
|
jwk.alg = algNamedCurve;
|
||||||
|
|
||||||
// 3.2 - 3.4.
|
// 3.2 - 3.4.
|
||||||
const data = ops.op_crypto_export_key({
|
const data = op_crypto_export_key({
|
||||||
format: key[_type] === "private" ? "jwkprivate" : "jwkpublic",
|
format: key[_type] === "private" ? "jwkprivate" : "jwkpublic",
|
||||||
algorithm: key[_algorithm].name,
|
algorithm: key[_algorithm].name,
|
||||||
namedCurve: key[_algorithm].namedCurve,
|
namedCurve: key[_algorithm].namedCurve,
|
||||||
|
@ -4288,7 +4305,7 @@ function exportKeyEC(format, key, innerKey) {
|
||||||
jwk.crv = key[_algorithm].namedCurve;
|
jwk.crv = key[_algorithm].namedCurve;
|
||||||
|
|
||||||
// 3.2 - 3.4
|
// 3.2 - 3.4
|
||||||
const data = ops.op_crypto_export_key({
|
const data = op_crypto_export_key({
|
||||||
format: key[_type] === "private" ? "jwkprivate" : "jwkpublic",
|
format: key[_type] === "private" ? "jwkprivate" : "jwkpublic",
|
||||||
algorithm: key[_algorithm].name,
|
algorithm: key[_algorithm].name,
|
||||||
namedCurve: key[_algorithm].namedCurve,
|
namedCurve: key[_algorithm].namedCurve,
|
||||||
|
@ -4490,7 +4507,7 @@ async function deriveBits(normalizedAlgorithm, baseKey, length) {
|
||||||
const u = WeakMapPrototypeGet(KEY_STORE, uHandle);
|
const u = WeakMapPrototypeGet(KEY_STORE, uHandle);
|
||||||
|
|
||||||
const secret = new Uint8Array(32);
|
const secret = new Uint8Array(32);
|
||||||
const isIdentity = ops.op_crypto_derive_bits_x25519(k, u, secret);
|
const isIdentity = op_crypto_derive_bits_x25519(k, u, secret);
|
||||||
|
|
||||||
// 6.
|
// 6.
|
||||||
if (isIdentity) {
|
if (isIdentity) {
|
||||||
|
@ -4696,7 +4713,7 @@ class Crypto {
|
||||||
// Fast path for Uint8Array
|
// Fast path for Uint8Array
|
||||||
const tag = TypedArrayPrototypeGetSymbolToStringTag(typedArray);
|
const tag = TypedArrayPrototypeGetSymbolToStringTag(typedArray);
|
||||||
if (tag === "Uint8Array") {
|
if (tag === "Uint8Array") {
|
||||||
ops.op_crypto_get_random_values(typedArray);
|
op_crypto_get_random_values(typedArray);
|
||||||
return typedArray;
|
return typedArray;
|
||||||
}
|
}
|
||||||
typedArray = webidl.converters.ArrayBufferView(
|
typedArray = webidl.converters.ArrayBufferView(
|
||||||
|
@ -4725,13 +4742,13 @@ class Crypto {
|
||||||
TypedArrayPrototypeGetByteOffset(typedArray),
|
TypedArrayPrototypeGetByteOffset(typedArray),
|
||||||
TypedArrayPrototypeGetByteLength(typedArray),
|
TypedArrayPrototypeGetByteLength(typedArray),
|
||||||
);
|
);
|
||||||
ops.op_crypto_get_random_values(ui8);
|
op_crypto_get_random_values(ui8);
|
||||||
return typedArray;
|
return typedArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
randomUUID() {
|
randomUUID() {
|
||||||
webidl.assertBranded(this, CryptoPrototype);
|
webidl.assertBranded(this, CryptoPrototype);
|
||||||
return ops.op_crypto_random_uuid();
|
return op_crypto_random_uuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
get subtle() {
|
get subtle() {
|
||||||
|
|
|
@ -9,16 +9,6 @@
|
||||||
/// <reference path="./lib.deno_fetch.d.ts" />
|
/// <reference path="./lib.deno_fetch.d.ts" />
|
||||||
/// <reference lib="esnext" />
|
/// <reference lib="esnext" />
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
|
||||||
import {
|
|
||||||
byteLowerCase,
|
|
||||||
collectHttpQuotedString,
|
|
||||||
collectSequenceOfCodepoints,
|
|
||||||
HTTP_TAB_OR_SPACE_PREFIX_RE,
|
|
||||||
HTTP_TAB_OR_SPACE_SUFFIX_RE,
|
|
||||||
HTTP_TOKEN_CODE_POINT_RE,
|
|
||||||
httpTrim,
|
|
||||||
} from "ext:deno_web/00_infra.js";
|
|
||||||
import { primordials } from "ext:core/mod.js";
|
import { primordials } from "ext:core/mod.js";
|
||||||
const {
|
const {
|
||||||
ArrayIsArray,
|
ArrayIsArray,
|
||||||
|
@ -38,6 +28,17 @@ const {
|
||||||
TypeError,
|
TypeError,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
|
import {
|
||||||
|
byteLowerCase,
|
||||||
|
collectHttpQuotedString,
|
||||||
|
collectSequenceOfCodepoints,
|
||||||
|
HTTP_TAB_OR_SPACE_PREFIX_RE,
|
||||||
|
HTTP_TAB_OR_SPACE_SUFFIX_RE,
|
||||||
|
HTTP_TOKEN_CODE_POINT_RE,
|
||||||
|
httpTrim,
|
||||||
|
} from "ext:deno_web/00_infra.js";
|
||||||
|
|
||||||
const _headerList = Symbol("header list");
|
const _headerList = Symbol("header list");
|
||||||
const _iterableHeaders = Symbol("iterable headers");
|
const _iterableHeaders = Symbol("iterable headers");
|
||||||
const _iterableHeadersCache = Symbol("iterable headers cache");
|
const _iterableHeadersCache = Symbol("iterable headers cache");
|
||||||
|
|
|
@ -12,6 +12,28 @@
|
||||||
/// <reference lib="esnext" />
|
/// <reference lib="esnext" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
isAnyArrayBuffer,
|
||||||
|
isArrayBuffer,
|
||||||
|
} = core;
|
||||||
|
const {
|
||||||
|
ArrayBufferIsView,
|
||||||
|
ArrayPrototypeMap,
|
||||||
|
DataViewPrototypeGetBuffer,
|
||||||
|
DataViewPrototypeGetByteLength,
|
||||||
|
DataViewPrototypeGetByteOffset,
|
||||||
|
JSONParse,
|
||||||
|
ObjectDefineProperties,
|
||||||
|
ObjectPrototypeIsPrototypeOf,
|
||||||
|
TypedArrayPrototypeGetBuffer,
|
||||||
|
TypedArrayPrototypeGetByteLength,
|
||||||
|
TypedArrayPrototypeGetByteOffset,
|
||||||
|
TypedArrayPrototypeGetSymbolToStringTag,
|
||||||
|
TypedArrayPrototypeSlice,
|
||||||
|
TypeError,
|
||||||
|
Uint8Array,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
import {
|
import {
|
||||||
parseUrlEncoded,
|
parseUrlEncoded,
|
||||||
|
@ -36,27 +58,6 @@ import {
|
||||||
readableStreamTee,
|
readableStreamTee,
|
||||||
readableStreamThrowIfErrored,
|
readableStreamThrowIfErrored,
|
||||||
} from "ext:deno_web/06_streams.js";
|
} from "ext:deno_web/06_streams.js";
|
||||||
const {
|
|
||||||
ArrayBufferIsView,
|
|
||||||
ArrayPrototypeMap,
|
|
||||||
DataViewPrototypeGetBuffer,
|
|
||||||
DataViewPrototypeGetByteLength,
|
|
||||||
DataViewPrototypeGetByteOffset,
|
|
||||||
JSONParse,
|
|
||||||
ObjectDefineProperties,
|
|
||||||
ObjectPrototypeIsPrototypeOf,
|
|
||||||
TypedArrayPrototypeGetBuffer,
|
|
||||||
TypedArrayPrototypeGetByteLength,
|
|
||||||
TypedArrayPrototypeGetByteOffset,
|
|
||||||
TypedArrayPrototypeGetSymbolToStringTag,
|
|
||||||
TypedArrayPrototypeSlice,
|
|
||||||
TypeError,
|
|
||||||
Uint8Array,
|
|
||||||
} = primordials;
|
|
||||||
const {
|
|
||||||
isAnyArrayBuffer,
|
|
||||||
isArrayBuffer,
|
|
||||||
} = core;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Uint8Array | string} chunk
|
* @param {Uint8Array | string} chunk
|
||||||
|
|
|
@ -11,8 +11,11 @@
|
||||||
/// <reference lib="esnext" />
|
/// <reference lib="esnext" />
|
||||||
|
|
||||||
import { core } from "ext:core/mod.js";
|
import { core } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
|
||||||
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
||||||
|
const {
|
||||||
|
op_fetch_custom_client,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Deno.CreateHttpClientOptions} options
|
* @param {Deno.CreateHttpClientOptions} options
|
||||||
|
@ -21,7 +24,7 @@ import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
||||||
function createHttpClient(options) {
|
function createHttpClient(options) {
|
||||||
options.caCerts ??= [];
|
options.caCerts ??= [];
|
||||||
return new HttpClient(
|
return new HttpClient(
|
||||||
ops.op_fetch_custom_client(
|
op_fetch_custom_client(
|
||||||
options,
|
options,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -9,6 +9,20 @@
|
||||||
/// <reference path="./lib.deno_fetch.d.ts" />
|
/// <reference path="./lib.deno_fetch.d.ts" />
|
||||||
/// <reference lib="esnext" />
|
/// <reference lib="esnext" />
|
||||||
|
|
||||||
|
import { primordials } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
ArrayPrototypeMap,
|
||||||
|
ArrayPrototypeSlice,
|
||||||
|
ArrayPrototypeSplice,
|
||||||
|
ObjectKeys,
|
||||||
|
ObjectPrototypeIsPrototypeOf,
|
||||||
|
RegExpPrototypeExec,
|
||||||
|
StringPrototypeStartsWith,
|
||||||
|
Symbol,
|
||||||
|
SymbolFor,
|
||||||
|
TypeError,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
import { assert } from "ext:deno_web/00_infra.js";
|
import { assert } from "ext:deno_web/00_infra.js";
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
|
@ -30,19 +44,6 @@ import {
|
||||||
} from "ext:deno_fetch/20_headers.js";
|
} from "ext:deno_fetch/20_headers.js";
|
||||||
import { HttpClientPrototype } from "ext:deno_fetch/22_http_client.js";
|
import { HttpClientPrototype } from "ext:deno_fetch/22_http_client.js";
|
||||||
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
|
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
|
||||||
import { primordials } from "ext:core/mod.js";
|
|
||||||
const {
|
|
||||||
ArrayPrototypeMap,
|
|
||||||
ArrayPrototypeSlice,
|
|
||||||
ArrayPrototypeSplice,
|
|
||||||
ObjectKeys,
|
|
||||||
ObjectPrototypeIsPrototypeOf,
|
|
||||||
RegExpPrototypeExec,
|
|
||||||
StringPrototypeStartsWith,
|
|
||||||
Symbol,
|
|
||||||
SymbolFor,
|
|
||||||
TypeError,
|
|
||||||
} = primordials;
|
|
||||||
|
|
||||||
const _request = Symbol("request");
|
const _request = Symbol("request");
|
||||||
const _headers = Symbol("headers");
|
const _headers = Symbol("headers");
|
||||||
|
|
|
@ -11,10 +11,29 @@
|
||||||
/// <reference lib="esnext" />
|
/// <reference lib="esnext" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
|
||||||
const {
|
const {
|
||||||
|
op_fetch,
|
||||||
op_fetch_send,
|
op_fetch_send,
|
||||||
|
op_wasm_streaming_feed,
|
||||||
|
op_wasm_streaming_set_url,
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
ArrayPrototypePush,
|
||||||
|
ArrayPrototypeSplice,
|
||||||
|
ArrayPrototypeFilter,
|
||||||
|
ArrayPrototypeIncludes,
|
||||||
|
Error,
|
||||||
|
ObjectPrototypeIsPrototypeOf,
|
||||||
|
Promise,
|
||||||
|
PromisePrototypeThen,
|
||||||
|
PromisePrototypeCatch,
|
||||||
|
SafeArrayIterator,
|
||||||
|
String,
|
||||||
|
StringPrototypeStartsWith,
|
||||||
|
StringPrototypeToLowerCase,
|
||||||
|
TypeError,
|
||||||
|
TypedArrayPrototypeGetSymbolToStringTag,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
import { byteLowerCase } from "ext:deno_web/00_infra.js";
|
import { byteLowerCase } from "ext:deno_web/00_infra.js";
|
||||||
|
@ -36,23 +55,6 @@ import {
|
||||||
toInnerResponse,
|
toInnerResponse,
|
||||||
} from "ext:deno_fetch/23_response.js";
|
} from "ext:deno_fetch/23_response.js";
|
||||||
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
|
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
|
||||||
const {
|
|
||||||
ArrayPrototypePush,
|
|
||||||
ArrayPrototypeSplice,
|
|
||||||
ArrayPrototypeFilter,
|
|
||||||
ArrayPrototypeIncludes,
|
|
||||||
Error,
|
|
||||||
ObjectPrototypeIsPrototypeOf,
|
|
||||||
Promise,
|
|
||||||
PromisePrototypeThen,
|
|
||||||
PromisePrototypeCatch,
|
|
||||||
SafeArrayIterator,
|
|
||||||
String,
|
|
||||||
StringPrototypeStartsWith,
|
|
||||||
StringPrototypeToLowerCase,
|
|
||||||
TypeError,
|
|
||||||
TypedArrayPrototypeGetSymbolToStringTag,
|
|
||||||
} = primordials;
|
|
||||||
|
|
||||||
const REQUEST_BODY_HEADER_NAMES = [
|
const REQUEST_BODY_HEADER_NAMES = [
|
||||||
"content-encoding",
|
"content-encoding",
|
||||||
|
@ -147,7 +149,7 @@ async function mainFetch(req, recursive, terminator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { requestRid, cancelHandleRid } = ops.op_fetch(
|
const { requestRid, cancelHandleRid } = op_fetch(
|
||||||
req.method,
|
req.method,
|
||||||
req.currentUrl(),
|
req.currentUrl(),
|
||||||
req.headerList,
|
req.headerList,
|
||||||
|
@ -448,7 +450,7 @@ function handleWasmStreaming(source, rid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass the resolved URL to v8.
|
// Pass the resolved URL to v8.
|
||||||
ops.op_wasm_streaming_set_url(rid, res.url);
|
op_wasm_streaming_set_url(rid, res.url);
|
||||||
|
|
||||||
if (res.body !== null) {
|
if (res.body !== null) {
|
||||||
// 2.6.
|
// 2.6.
|
||||||
|
@ -460,7 +462,7 @@ function handleWasmStreaming(source, rid) {
|
||||||
while (true) {
|
while (true) {
|
||||||
const { value: chunk, done } = await reader.read();
|
const { value: chunk, done } = await reader.read();
|
||||||
if (done) break;
|
if (done) break;
|
||||||
ops.op_wasm_streaming_feed(rid, chunk);
|
op_wasm_streaming_feed(rid, chunk);
|
||||||
}
|
}
|
||||||
})(),
|
})(),
|
||||||
// 2.7
|
// 2.7
|
||||||
|
|
|
@ -3,22 +3,9 @@
|
||||||
/// <reference path="../../core/internal.d.ts" />
|
/// <reference path="../../core/internal.d.ts" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
op_utf8_to_byte_string,
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
} = core.ensureFastOps();
|
||||||
import { URL } from "ext:deno_url/00_url.js";
|
|
||||||
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
|
||||||
import {
|
|
||||||
defineEventHandler,
|
|
||||||
EventTarget,
|
|
||||||
setIsTrusted,
|
|
||||||
} from "ext:deno_web/02_event.js";
|
|
||||||
import { TransformStream } from "ext:deno_web/06_streams.js";
|
|
||||||
import { TextDecoderStream } from "ext:deno_web/08_text_encoding.js";
|
|
||||||
import { getLocationHref } from "ext:deno_web/12_location.js";
|
|
||||||
import { newInnerRequest } from "ext:deno_fetch/23_request.js";
|
|
||||||
import { mainFetch } from "ext:deno_fetch/26_fetch.js";
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeFind,
|
ArrayPrototypeFind,
|
||||||
Number,
|
Number,
|
||||||
|
@ -38,6 +25,21 @@ const {
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
|
import { URL } from "ext:deno_url/00_url.js";
|
||||||
|
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
||||||
|
import {
|
||||||
|
defineEventHandler,
|
||||||
|
EventTarget,
|
||||||
|
setIsTrusted,
|
||||||
|
} from "ext:deno_web/02_event.js";
|
||||||
|
import { TransformStream } from "ext:deno_web/06_streams.js";
|
||||||
|
import { TextDecoderStream } from "ext:deno_web/08_text_encoding.js";
|
||||||
|
import { getLocationHref } from "ext:deno_web/12_location.js";
|
||||||
|
import { newInnerRequest } from "ext:deno_fetch/23_request.js";
|
||||||
|
import { mainFetch } from "ext:deno_fetch/26_fetch.js";
|
||||||
|
|
||||||
// Copied from https://github.com/denoland/deno_std/blob/e0753abe0c8602552862a568348c046996709521/streams/text_line_stream.ts#L20-L74
|
// Copied from https://github.com/denoland/deno_std/blob/e0753abe0c8602552862a568348c046996709521/streams/text_line_stream.ts#L20-L74
|
||||||
export class TextLineStream extends TransformStream {
|
export class TextLineStream extends TransformStream {
|
||||||
#allowCR;
|
#allowCR;
|
||||||
|
@ -205,7 +207,7 @@ class EventSource extends EventTarget {
|
||||||
["accept", "text/event-stream"],
|
["accept", "text/event-stream"],
|
||||||
[
|
[
|
||||||
"Last-Event-Id",
|
"Last-Event-Id",
|
||||||
core.ops.op_utf8_to_byte_string(lastEventIDValueCopy),
|
op_utf8_to_byte_string(lastEventIDValueCopy),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
null,
|
null,
|
||||||
|
|
|
@ -1,7 +1,42 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
|
isArrayBuffer,
|
||||||
|
isDataView,
|
||||||
|
isTypedArray,
|
||||||
|
} = core;
|
||||||
|
const {
|
||||||
|
op_ffi_buf_copy_into,
|
||||||
|
op_ffi_call_nonblocking,
|
||||||
|
op_ffi_call_ptr,
|
||||||
|
op_ffi_call_ptr_nonblocking,
|
||||||
|
op_ffi_cstr_read,
|
||||||
|
op_ffi_get_buf,
|
||||||
|
op_ffi_get_static,
|
||||||
|
op_ffi_load,
|
||||||
|
op_ffi_ptr_create,
|
||||||
|
op_ffi_ptr_equals,
|
||||||
|
op_ffi_ptr_of,
|
||||||
|
op_ffi_ptr_of_exact,
|
||||||
|
op_ffi_ptr_offset,
|
||||||
|
op_ffi_ptr_value,
|
||||||
|
op_ffi_read_bool,
|
||||||
|
op_ffi_read_f32,
|
||||||
|
op_ffi_read_f64,
|
||||||
|
op_ffi_read_i16,
|
||||||
|
op_ffi_read_i32,
|
||||||
|
op_ffi_read_i64,
|
||||||
|
op_ffi_read_i8,
|
||||||
|
op_ffi_read_ptr,
|
||||||
|
op_ffi_read_u16,
|
||||||
|
op_ffi_read_u32,
|
||||||
|
op_ffi_read_u64,
|
||||||
|
op_ffi_read_u8,
|
||||||
|
op_ffi_unsafe_callback_close,
|
||||||
|
op_ffi_unsafe_callback_create,
|
||||||
|
op_ffi_unsafe_callback_ref,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
const {
|
const {
|
||||||
ArrayBufferIsView,
|
ArrayBufferIsView,
|
||||||
ArrayBufferPrototypeGetByteLength,
|
ArrayBufferPrototypeGetByteLength,
|
||||||
|
@ -30,19 +65,8 @@ const {
|
||||||
SafeArrayIterator,
|
SafeArrayIterator,
|
||||||
SafeWeakMap,
|
SafeWeakMap,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
const {
|
|
||||||
isArrayBuffer,
|
|
||||||
isDataView,
|
|
||||||
isTypedArray,
|
|
||||||
} = core;
|
|
||||||
import { pathFromURL } from "ext:deno_web/00_infra.js";
|
import { pathFromURL } from "ext:deno_web/00_infra.js";
|
||||||
const {
|
|
||||||
op_ffi_call_nonblocking,
|
|
||||||
op_ffi_unsafe_callback_ref,
|
|
||||||
} = core.ensureFastOps();
|
|
||||||
const {
|
|
||||||
op_ffi_call_ptr_nonblocking,
|
|
||||||
} = core.ensureFastOps(true);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {BufferSource} source
|
* @param {BufferSource} source
|
||||||
|
@ -67,56 +91,56 @@ class UnsafePointerView {
|
||||||
}
|
}
|
||||||
|
|
||||||
getBool(offset = 0) {
|
getBool(offset = 0) {
|
||||||
return ops.op_ffi_read_bool(
|
return op_ffi_read_bool(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUint8(offset = 0) {
|
getUint8(offset = 0) {
|
||||||
return ops.op_ffi_read_u8(
|
return op_ffi_read_u8(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getInt8(offset = 0) {
|
getInt8(offset = 0) {
|
||||||
return ops.op_ffi_read_i8(
|
return op_ffi_read_i8(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUint16(offset = 0) {
|
getUint16(offset = 0) {
|
||||||
return ops.op_ffi_read_u16(
|
return op_ffi_read_u16(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getInt16(offset = 0) {
|
getInt16(offset = 0) {
|
||||||
return ops.op_ffi_read_i16(
|
return op_ffi_read_i16(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUint32(offset = 0) {
|
getUint32(offset = 0) {
|
||||||
return ops.op_ffi_read_u32(
|
return op_ffi_read_u32(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getInt32(offset = 0) {
|
getInt32(offset = 0) {
|
||||||
return ops.op_ffi_read_i32(
|
return op_ffi_read_i32(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getBigUint64(offset = 0) {
|
getBigUint64(offset = 0) {
|
||||||
ops.op_ffi_read_u64(
|
op_ffi_read_u64(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
U32_BUFFER,
|
U32_BUFFER,
|
||||||
|
@ -125,7 +149,7 @@ class UnsafePointerView {
|
||||||
}
|
}
|
||||||
|
|
||||||
getBigInt64(offset = 0) {
|
getBigInt64(offset = 0) {
|
||||||
ops.op_ffi_read_i64(
|
op_ffi_read_i64(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
U32_BUFFER,
|
U32_BUFFER,
|
||||||
|
@ -134,42 +158,42 @@ class UnsafePointerView {
|
||||||
}
|
}
|
||||||
|
|
||||||
getFloat32(offset = 0) {
|
getFloat32(offset = 0) {
|
||||||
return ops.op_ffi_read_f32(
|
return op_ffi_read_f32(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getFloat64(offset = 0) {
|
getFloat64(offset = 0) {
|
||||||
return ops.op_ffi_read_f64(
|
return op_ffi_read_f64(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPointer(offset = 0) {
|
getPointer(offset = 0) {
|
||||||
return ops.op_ffi_read_ptr(
|
return op_ffi_read_ptr(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCString(offset = 0) {
|
getCString(offset = 0) {
|
||||||
return ops.op_ffi_cstr_read(
|
return op_ffi_cstr_read(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getCString(pointer, offset = 0) {
|
static getCString(pointer, offset = 0) {
|
||||||
return ops.op_ffi_cstr_read(
|
return op_ffi_cstr_read(
|
||||||
pointer,
|
pointer,
|
||||||
offset,
|
offset,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getArrayBuffer(byteLength, offset = 0) {
|
getArrayBuffer(byteLength, offset = 0) {
|
||||||
return ops.op_ffi_get_buf(
|
return op_ffi_get_buf(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
byteLength,
|
byteLength,
|
||||||
|
@ -177,7 +201,7 @@ class UnsafePointerView {
|
||||||
}
|
}
|
||||||
|
|
||||||
static getArrayBuffer(pointer, byteLength, offset = 0) {
|
static getArrayBuffer(pointer, byteLength, offset = 0) {
|
||||||
return ops.op_ffi_get_buf(
|
return op_ffi_get_buf(
|
||||||
pointer,
|
pointer,
|
||||||
offset,
|
offset,
|
||||||
byteLength,
|
byteLength,
|
||||||
|
@ -185,7 +209,7 @@ class UnsafePointerView {
|
||||||
}
|
}
|
||||||
|
|
||||||
copyInto(destination, offset = 0) {
|
copyInto(destination, offset = 0) {
|
||||||
ops.op_ffi_buf_copy_into(
|
op_ffi_buf_copy_into(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
offset,
|
offset,
|
||||||
destination,
|
destination,
|
||||||
|
@ -194,7 +218,7 @@ class UnsafePointerView {
|
||||||
}
|
}
|
||||||
|
|
||||||
static copyInto(pointer, destination, offset = 0) {
|
static copyInto(pointer, destination, offset = 0) {
|
||||||
ops.op_ffi_buf_copy_into(
|
op_ffi_buf_copy_into(
|
||||||
pointer,
|
pointer,
|
||||||
offset,
|
offset,
|
||||||
destination,
|
destination,
|
||||||
|
@ -210,14 +234,14 @@ const OUT_BUFFER_64 = new BigInt64Array(
|
||||||
const POINTER_TO_BUFFER_WEAK_MAP = new SafeWeakMap();
|
const POINTER_TO_BUFFER_WEAK_MAP = new SafeWeakMap();
|
||||||
class UnsafePointer {
|
class UnsafePointer {
|
||||||
static create(value) {
|
static create(value) {
|
||||||
return ops.op_ffi_ptr_create(value);
|
return op_ffi_ptr_create(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static equals(a, b) {
|
static equals(a, b) {
|
||||||
if (a === null || b === null) {
|
if (a === null || b === null) {
|
||||||
return a === b;
|
return a === b;
|
||||||
}
|
}
|
||||||
return ops.op_ffi_ptr_equals(a, b);
|
return op_ffi_ptr_equals(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static of(value) {
|
static of(value) {
|
||||||
|
@ -227,15 +251,15 @@ class UnsafePointer {
|
||||||
let pointer;
|
let pointer;
|
||||||
if (ArrayBufferIsView(value)) {
|
if (ArrayBufferIsView(value)) {
|
||||||
if (value.length === 0) {
|
if (value.length === 0) {
|
||||||
pointer = ops.op_ffi_ptr_of_exact(value);
|
pointer = op_ffi_ptr_of_exact(value);
|
||||||
} else {
|
} else {
|
||||||
pointer = ops.op_ffi_ptr_of(value);
|
pointer = op_ffi_ptr_of(value);
|
||||||
}
|
}
|
||||||
} else if (isArrayBuffer(value)) {
|
} else if (isArrayBuffer(value)) {
|
||||||
if (value.length === 0) {
|
if (value.length === 0) {
|
||||||
pointer = ops.op_ffi_ptr_of_exact(new Uint8Array(value));
|
pointer = op_ffi_ptr_of_exact(new Uint8Array(value));
|
||||||
} else {
|
} else {
|
||||||
pointer = ops.op_ffi_ptr_of(new Uint8Array(value));
|
pointer = op_ffi_ptr_of(new Uint8Array(value));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
|
@ -249,14 +273,14 @@ class UnsafePointer {
|
||||||
}
|
}
|
||||||
|
|
||||||
static offset(value, offset) {
|
static offset(value, offset) {
|
||||||
return ops.op_ffi_ptr_offset(value, offset);
|
return op_ffi_ptr_offset(value, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static value(value) {
|
static value(value) {
|
||||||
if (ObjectPrototypeIsPrototypeOf(UnsafeCallbackPrototype, value)) {
|
if (ObjectPrototypeIsPrototypeOf(UnsafeCallbackPrototype, value)) {
|
||||||
value = value.pointer;
|
value = value.pointer;
|
||||||
}
|
}
|
||||||
ops.op_ffi_ptr_value(value, OUT_BUFFER);
|
op_ffi_ptr_value(value, OUT_BUFFER);
|
||||||
const result = OUT_BUFFER[0] + 2 ** 32 * OUT_BUFFER[1];
|
const result = OUT_BUFFER[0] + 2 ** 32 * OUT_BUFFER[1];
|
||||||
if (NumberIsSafeInteger(result)) {
|
if (NumberIsSafeInteger(result)) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -300,14 +324,14 @@ class UnsafeFnPointer {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.#structSize === null) {
|
if (this.#structSize === null) {
|
||||||
return ops.op_ffi_call_ptr(
|
return op_ffi_call_ptr(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
this.definition,
|
this.definition,
|
||||||
parameters,
|
parameters,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const buffer = new Uint8Array(this.#structSize);
|
const buffer = new Uint8Array(this.#structSize);
|
||||||
ops.op_ffi_call_ptr(
|
op_ffi_call_ptr(
|
||||||
this.pointer,
|
this.pointer,
|
||||||
this.definition,
|
this.definition,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -401,7 +425,7 @@ class UnsafeCallback {
|
||||||
"Invalid UnsafeCallback, cannot be nonblocking",
|
"Invalid UnsafeCallback, cannot be nonblocking",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const { 0: rid, 1: pointer } = ops.op_ffi_unsafe_callback_create(
|
const { 0: rid, 1: pointer } = op_ffi_unsafe_callback_create(
|
||||||
definition,
|
definition,
|
||||||
callback,
|
callback,
|
||||||
);
|
);
|
||||||
|
@ -443,7 +467,7 @@ class UnsafeCallback {
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.#refcount = 0;
|
this.#refcount = 0;
|
||||||
ops.op_ffi_unsafe_callback_close(this.#rid);
|
op_ffi_unsafe_callback_close(this.#rid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,7 +478,7 @@ class DynamicLibrary {
|
||||||
symbols = {};
|
symbols = {};
|
||||||
|
|
||||||
constructor(path, symbols) {
|
constructor(path, symbols) {
|
||||||
({ 0: this.#rid, 1: this.symbols } = ops.op_ffi_load({ path, symbols }));
|
({ 0: this.#rid, 1: this.symbols } = op_ffi_load({ path, symbols }));
|
||||||
for (const symbol in symbols) {
|
for (const symbol in symbols) {
|
||||||
if (!ObjectHasOwn(symbols, symbol)) {
|
if (!ObjectHasOwn(symbols, symbol)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -475,7 +499,7 @@ class DynamicLibrary {
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = symbols[symbol].name || symbol;
|
const name = symbols[symbol].name || symbol;
|
||||||
const value = ops.op_ffi_get_static(
|
const value = op_ffi_get_static(
|
||||||
this.#rid,
|
this.#rid,
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
|
|
122
ext/fs/30_fs.js
122
ext/fs/30_fs.js
|
@ -1,39 +1,75 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
|
||||||
const {
|
const {
|
||||||
|
isDate,
|
||||||
|
} = core;
|
||||||
|
const {
|
||||||
|
op_fs_chdir,
|
||||||
op_fs_chmod_async,
|
op_fs_chmod_async,
|
||||||
op_fs_ftruncate_async,
|
op_fs_chmod_sync,
|
||||||
op_fs_truncate_async,
|
|
||||||
op_fs_link_async,
|
|
||||||
op_fs_flock_async,
|
|
||||||
op_fs_chown_async,
|
op_fs_chown_async,
|
||||||
|
op_fs_chown_sync,
|
||||||
op_fs_copy_file_async,
|
op_fs_copy_file_async,
|
||||||
|
op_fs_copy_file_sync,
|
||||||
|
op_fs_cwd,
|
||||||
op_fs_fdatasync_async,
|
op_fs_fdatasync_async,
|
||||||
|
op_fs_fdatasync_sync,
|
||||||
|
op_fs_flock_async,
|
||||||
|
op_fs_flock_sync,
|
||||||
op_fs_fstat_async,
|
op_fs_fstat_async,
|
||||||
|
op_fs_fstat_sync,
|
||||||
op_fs_fsync_async,
|
op_fs_fsync_async,
|
||||||
|
op_fs_fsync_sync,
|
||||||
|
op_fs_ftruncate_async,
|
||||||
|
op_fs_ftruncate_sync,
|
||||||
op_fs_funlock_async,
|
op_fs_funlock_async,
|
||||||
|
op_fs_funlock_sync,
|
||||||
op_fs_futime_async,
|
op_fs_futime_async,
|
||||||
|
op_fs_futime_sync,
|
||||||
|
op_fs_link_async,
|
||||||
|
op_fs_link_sync,
|
||||||
op_fs_lstat_async,
|
op_fs_lstat_async,
|
||||||
|
op_fs_lstat_sync,
|
||||||
op_fs_make_temp_dir_async,
|
op_fs_make_temp_dir_async,
|
||||||
|
op_fs_make_temp_dir_sync,
|
||||||
op_fs_make_temp_file_async,
|
op_fs_make_temp_file_async,
|
||||||
|
op_fs_make_temp_file_sync,
|
||||||
op_fs_mkdir_async,
|
op_fs_mkdir_async,
|
||||||
|
op_fs_mkdir_sync,
|
||||||
op_fs_open_async,
|
op_fs_open_async,
|
||||||
|
op_fs_open_sync,
|
||||||
op_fs_read_dir_async,
|
op_fs_read_dir_async,
|
||||||
|
op_fs_read_dir_sync,
|
||||||
op_fs_read_file_async,
|
op_fs_read_file_async,
|
||||||
|
op_fs_read_file_sync,
|
||||||
op_fs_read_file_text_async,
|
op_fs_read_file_text_async,
|
||||||
|
op_fs_read_file_text_sync,
|
||||||
op_fs_read_link_async,
|
op_fs_read_link_async,
|
||||||
|
op_fs_read_link_sync,
|
||||||
op_fs_realpath_async,
|
op_fs_realpath_async,
|
||||||
|
op_fs_realpath_sync,
|
||||||
op_fs_remove_async,
|
op_fs_remove_async,
|
||||||
|
op_fs_remove_sync,
|
||||||
op_fs_rename_async,
|
op_fs_rename_async,
|
||||||
|
op_fs_rename_sync,
|
||||||
op_fs_seek_async,
|
op_fs_seek_async,
|
||||||
|
op_fs_seek_sync,
|
||||||
op_fs_stat_async,
|
op_fs_stat_async,
|
||||||
|
op_fs_stat_sync,
|
||||||
op_fs_symlink_async,
|
op_fs_symlink_async,
|
||||||
|
op_fs_symlink_sync,
|
||||||
|
op_fs_truncate_async,
|
||||||
|
op_fs_truncate_sync,
|
||||||
|
op_fs_umask,
|
||||||
op_fs_utime_async,
|
op_fs_utime_async,
|
||||||
|
op_fs_utime_sync,
|
||||||
op_fs_write_file_async,
|
op_fs_write_file_async,
|
||||||
|
op_fs_write_file_sync,
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
op_cancel_handle,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeFilter,
|
ArrayPrototypeFilter,
|
||||||
Date,
|
Date,
|
||||||
|
@ -50,9 +86,7 @@ const {
|
||||||
SymbolIterator,
|
SymbolIterator,
|
||||||
Uint32Array,
|
Uint32Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
const {
|
|
||||||
isDate,
|
|
||||||
} = core;
|
|
||||||
import { read, readSync, write, writeSync } from "ext:deno_io/12_io.js";
|
import { read, readSync, write, writeSync } from "ext:deno_io/12_io.js";
|
||||||
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
|
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
|
||||||
import {
|
import {
|
||||||
|
@ -63,7 +97,7 @@ import {
|
||||||
import { pathFromURL, SymbolDispose } from "ext:deno_web/00_infra.js";
|
import { pathFromURL, SymbolDispose } from "ext:deno_web/00_infra.js";
|
||||||
|
|
||||||
function chmodSync(path, mode) {
|
function chmodSync(path, mode) {
|
||||||
ops.op_fs_chmod_sync(pathFromURL(path), mode);
|
op_fs_chmod_sync(pathFromURL(path), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function chmod(path, mode) {
|
async function chmod(path, mode) {
|
||||||
|
@ -75,7 +109,7 @@ function chownSync(
|
||||||
uid,
|
uid,
|
||||||
gid,
|
gid,
|
||||||
) {
|
) {
|
||||||
ops.op_fs_chown_sync(pathFromURL(path), uid, gid);
|
op_fs_chown_sync(pathFromURL(path), uid, gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function chown(
|
async function chown(
|
||||||
|
@ -94,7 +128,7 @@ function copyFileSync(
|
||||||
fromPath,
|
fromPath,
|
||||||
toPath,
|
toPath,
|
||||||
) {
|
) {
|
||||||
ops.op_fs_copy_file_sync(
|
op_fs_copy_file_sync(
|
||||||
pathFromURL(fromPath),
|
pathFromURL(fromPath),
|
||||||
pathFromURL(toPath),
|
pathFromURL(toPath),
|
||||||
);
|
);
|
||||||
|
@ -111,15 +145,15 @@ async function copyFile(
|
||||||
}
|
}
|
||||||
|
|
||||||
function cwd() {
|
function cwd() {
|
||||||
return ops.op_fs_cwd();
|
return op_fs_cwd();
|
||||||
}
|
}
|
||||||
|
|
||||||
function chdir(directory) {
|
function chdir(directory) {
|
||||||
ops.op_fs_chdir(pathFromURL(directory));
|
op_fs_chdir(pathFromURL(directory));
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeTempDirSync(options = {}) {
|
function makeTempDirSync(options = {}) {
|
||||||
return ops.op_fs_make_temp_dir_sync(
|
return op_fs_make_temp_dir_sync(
|
||||||
options.dir,
|
options.dir,
|
||||||
options.prefix,
|
options.prefix,
|
||||||
options.suffix,
|
options.suffix,
|
||||||
|
@ -135,7 +169,7 @@ function makeTempDir(options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeTempFileSync(options = {}) {
|
function makeTempFileSync(options = {}) {
|
||||||
return ops.op_fs_make_temp_file_sync(
|
return op_fs_make_temp_file_sync(
|
||||||
options.dir,
|
options.dir,
|
||||||
options.prefix,
|
options.prefix,
|
||||||
options.suffix,
|
options.suffix,
|
||||||
|
@ -151,7 +185,7 @@ function makeTempFile(options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mkdirSync(path, options) {
|
function mkdirSync(path, options) {
|
||||||
ops.op_fs_mkdir_sync(
|
op_fs_mkdir_sync(
|
||||||
pathFromURL(path),
|
pathFromURL(path),
|
||||||
options?.recursive ?? false,
|
options?.recursive ?? false,
|
||||||
options?.mode,
|
options?.mode,
|
||||||
|
@ -167,7 +201,7 @@ async function mkdir(path, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function readDirSync(path) {
|
function readDirSync(path) {
|
||||||
return ops.op_fs_read_dir_sync(pathFromURL(path))[
|
return op_fs_read_dir_sync(pathFromURL(path))[
|
||||||
SymbolIterator
|
SymbolIterator
|
||||||
]();
|
]();
|
||||||
}
|
}
|
||||||
|
@ -187,7 +221,7 @@ function readDir(path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function readLinkSync(path) {
|
function readLinkSync(path) {
|
||||||
return ops.op_fs_read_link_sync(pathFromURL(path));
|
return op_fs_read_link_sync(pathFromURL(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
function readLink(path) {
|
function readLink(path) {
|
||||||
|
@ -195,7 +229,7 @@ function readLink(path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function realPathSync(path) {
|
function realPathSync(path) {
|
||||||
return ops.op_fs_realpath_sync(pathFromURL(path));
|
return op_fs_realpath_sync(pathFromURL(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
function realPath(path) {
|
function realPath(path) {
|
||||||
|
@ -206,7 +240,7 @@ function removeSync(
|
||||||
path,
|
path,
|
||||||
options = {},
|
options = {},
|
||||||
) {
|
) {
|
||||||
ops.op_fs_remove_sync(
|
op_fs_remove_sync(
|
||||||
pathFromURL(path),
|
pathFromURL(path),
|
||||||
!!options.recursive,
|
!!options.recursive,
|
||||||
);
|
);
|
||||||
|
@ -223,7 +257,7 @@ async function remove(
|
||||||
}
|
}
|
||||||
|
|
||||||
function renameSync(oldpath, newpath) {
|
function renameSync(oldpath, newpath) {
|
||||||
ops.op_fs_rename_sync(
|
op_fs_rename_sync(
|
||||||
pathFromURL(oldpath),
|
pathFromURL(oldpath),
|
||||||
pathFromURL(newpath),
|
pathFromURL(newpath),
|
||||||
);
|
);
|
||||||
|
@ -357,7 +391,7 @@ function parseFileInfo(response) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function fstatSync(rid) {
|
function fstatSync(rid) {
|
||||||
ops.op_fs_fstat_sync(rid, statBuf);
|
op_fs_fstat_sync(rid, statBuf);
|
||||||
return statStruct(statBuf);
|
return statStruct(statBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +405,7 @@ async function lstat(path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function lstatSync(path) {
|
function lstatSync(path) {
|
||||||
ops.op_fs_lstat_sync(pathFromURL(path), statBuf);
|
op_fs_lstat_sync(pathFromURL(path), statBuf);
|
||||||
return statStruct(statBuf);
|
return statStruct(statBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,7 +415,7 @@ async function stat(path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function statSync(path) {
|
function statSync(path) {
|
||||||
ops.op_fs_stat_sync(pathFromURL(path), statBuf);
|
op_fs_stat_sync(pathFromURL(path), statBuf);
|
||||||
return statStruct(statBuf);
|
return statStruct(statBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +427,7 @@ function coerceLen(len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ftruncateSync(rid, len) {
|
function ftruncateSync(rid, len) {
|
||||||
ops.op_fs_ftruncate_sync(rid, coerceLen(len));
|
op_fs_ftruncate_sync(rid, coerceLen(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ftruncate(rid, len) {
|
async function ftruncate(rid, len) {
|
||||||
|
@ -401,7 +435,7 @@ async function ftruncate(rid, len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function truncateSync(path, len) {
|
function truncateSync(path, len) {
|
||||||
ops.op_fs_truncate_sync(path, coerceLen(len));
|
op_fs_truncate_sync(path, coerceLen(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function truncate(path, len) {
|
async function truncate(path, len) {
|
||||||
|
@ -409,11 +443,11 @@ async function truncate(path, len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function umask(mask) {
|
function umask(mask) {
|
||||||
return ops.op_fs_umask(mask);
|
return op_fs_umask(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
function linkSync(oldpath, newpath) {
|
function linkSync(oldpath, newpath) {
|
||||||
ops.op_fs_link_sync(oldpath, newpath);
|
op_fs_link_sync(oldpath, newpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function link(oldpath, newpath) {
|
async function link(oldpath, newpath) {
|
||||||
|
@ -448,7 +482,7 @@ function futimeSync(
|
||||||
) {
|
) {
|
||||||
const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime);
|
const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime);
|
||||||
const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime);
|
const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime);
|
||||||
ops.op_fs_futime_sync(rid, atimeSec, atimeNsec, mtimeSec, mtimeNsec);
|
op_fs_futime_sync(rid, atimeSec, atimeNsec, mtimeSec, mtimeNsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function futime(
|
async function futime(
|
||||||
|
@ -474,7 +508,7 @@ function utimeSync(
|
||||||
) {
|
) {
|
||||||
const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime);
|
const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime);
|
||||||
const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime);
|
const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime);
|
||||||
ops.op_fs_utime_sync(
|
op_fs_utime_sync(
|
||||||
pathFromURL(path),
|
pathFromURL(path),
|
||||||
atimeSec,
|
atimeSec,
|
||||||
atimeNsec,
|
atimeNsec,
|
||||||
|
@ -504,7 +538,7 @@ function symlinkSync(
|
||||||
newpath,
|
newpath,
|
||||||
options,
|
options,
|
||||||
) {
|
) {
|
||||||
ops.op_fs_symlink_sync(
|
op_fs_symlink_sync(
|
||||||
pathFromURL(oldpath),
|
pathFromURL(oldpath),
|
||||||
pathFromURL(newpath),
|
pathFromURL(newpath),
|
||||||
options?.type,
|
options?.type,
|
||||||
|
@ -524,7 +558,7 @@ async function symlink(
|
||||||
}
|
}
|
||||||
|
|
||||||
function fdatasyncSync(rid) {
|
function fdatasyncSync(rid) {
|
||||||
ops.op_fs_fdatasync_sync(rid);
|
op_fs_fdatasync_sync(rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fdatasync(rid) {
|
async function fdatasync(rid) {
|
||||||
|
@ -532,7 +566,7 @@ async function fdatasync(rid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function fsyncSync(rid) {
|
function fsyncSync(rid) {
|
||||||
ops.op_fs_fsync_sync(rid);
|
op_fs_fsync_sync(rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fsync(rid) {
|
async function fsync(rid) {
|
||||||
|
@ -540,7 +574,7 @@ async function fsync(rid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function flockSync(rid, exclusive) {
|
function flockSync(rid, exclusive) {
|
||||||
ops.op_fs_flock_sync(rid, exclusive === true);
|
op_fs_flock_sync(rid, exclusive === true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function flock(rid, exclusive) {
|
async function flock(rid, exclusive) {
|
||||||
|
@ -548,7 +582,7 @@ async function flock(rid, exclusive) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function funlockSync(rid) {
|
function funlockSync(rid) {
|
||||||
ops.op_fs_funlock_sync(rid);
|
op_fs_funlock_sync(rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function funlock(rid) {
|
async function funlock(rid) {
|
||||||
|
@ -560,7 +594,7 @@ function seekSync(
|
||||||
offset,
|
offset,
|
||||||
whence,
|
whence,
|
||||||
) {
|
) {
|
||||||
return ops.op_fs_seek_sync(rid, offset, whence);
|
return op_fs_seek_sync(rid, offset, whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
function seek(
|
function seek(
|
||||||
|
@ -576,7 +610,7 @@ function openSync(
|
||||||
options,
|
options,
|
||||||
) {
|
) {
|
||||||
if (options) checkOpenOptions(options);
|
if (options) checkOpenOptions(options);
|
||||||
const rid = ops.op_fs_open_sync(
|
const rid = op_fs_open_sync(
|
||||||
pathFromURL(path),
|
pathFromURL(path),
|
||||||
options,
|
options,
|
||||||
);
|
);
|
||||||
|
@ -720,7 +754,7 @@ function checkOpenOptions(options) {
|
||||||
const File = FsFile;
|
const File = FsFile;
|
||||||
|
|
||||||
function readFileSync(path) {
|
function readFileSync(path) {
|
||||||
return ops.op_fs_read_file_sync(pathFromURL(path));
|
return op_fs_read_file_sync(pathFromURL(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readFile(path, options) {
|
async function readFile(path, options) {
|
||||||
|
@ -728,7 +762,7 @@ async function readFile(path, options) {
|
||||||
let abortHandler;
|
let abortHandler;
|
||||||
if (options?.signal) {
|
if (options?.signal) {
|
||||||
options.signal.throwIfAborted();
|
options.signal.throwIfAborted();
|
||||||
cancelRid = ops.op_cancel_handle();
|
cancelRid = op_cancel_handle();
|
||||||
abortHandler = () => core.tryClose(cancelRid);
|
abortHandler = () => core.tryClose(cancelRid);
|
||||||
options.signal[abortSignal.add](abortHandler);
|
options.signal[abortSignal.add](abortHandler);
|
||||||
}
|
}
|
||||||
|
@ -750,7 +784,7 @@ async function readFile(path, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function readTextFileSync(path) {
|
function readTextFileSync(path) {
|
||||||
return ops.op_fs_read_file_text_sync(pathFromURL(path));
|
return op_fs_read_file_text_sync(pathFromURL(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readTextFile(path, options) {
|
async function readTextFile(path, options) {
|
||||||
|
@ -758,7 +792,7 @@ async function readTextFile(path, options) {
|
||||||
let abortHandler;
|
let abortHandler;
|
||||||
if (options?.signal) {
|
if (options?.signal) {
|
||||||
options.signal.throwIfAborted();
|
options.signal.throwIfAborted();
|
||||||
cancelRid = ops.op_cancel_handle();
|
cancelRid = op_cancel_handle();
|
||||||
abortHandler = () => core.tryClose(cancelRid);
|
abortHandler = () => core.tryClose(cancelRid);
|
||||||
options.signal[abortSignal.add](abortHandler);
|
options.signal[abortSignal.add](abortHandler);
|
||||||
}
|
}
|
||||||
|
@ -785,7 +819,7 @@ function writeFileSync(
|
||||||
options = {},
|
options = {},
|
||||||
) {
|
) {
|
||||||
options.signal?.throwIfAborted();
|
options.signal?.throwIfAborted();
|
||||||
ops.op_fs_write_file_sync(
|
op_fs_write_file_sync(
|
||||||
pathFromURL(path),
|
pathFromURL(path),
|
||||||
options.mode,
|
options.mode,
|
||||||
options.append ?? false,
|
options.append ?? false,
|
||||||
|
@ -804,7 +838,7 @@ async function writeFile(
|
||||||
let abortHandler;
|
let abortHandler;
|
||||||
if (options.signal) {
|
if (options.signal) {
|
||||||
options.signal.throwIfAborted();
|
options.signal.throwIfAborted();
|
||||||
cancelRid = ops.op_cancel_handle();
|
cancelRid = op_cancel_handle();
|
||||||
abortHandler = () => core.tryClose(cancelRid);
|
abortHandler = () => core.tryClose(cancelRid);
|
||||||
options.signal[abortSignal.add](abortHandler);
|
options.signal[abortSignal.add](abortHandler);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,43 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, internals, primordials } from "ext:core/mod.js";
|
import { core, internals, primordials } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
BadResourcePrototype,
|
||||||
|
InterruptedPrototype,
|
||||||
|
} = core;
|
||||||
|
const {
|
||||||
|
op_http_close_after_finish,
|
||||||
|
op_http_get_request_headers,
|
||||||
|
op_http_get_request_method_and_url,
|
||||||
|
op_http_read_request_body,
|
||||||
|
op_http_serve,
|
||||||
|
op_http_serve_on,
|
||||||
|
op_http_set_promise_complete,
|
||||||
|
op_http_set_response_body_bytes,
|
||||||
|
op_http_set_response_body_resource,
|
||||||
|
op_http_set_response_body_text,
|
||||||
|
op_http_set_response_header,
|
||||||
|
op_http_set_response_headers,
|
||||||
|
op_http_set_response_trailers,
|
||||||
|
op_http_upgrade_raw,
|
||||||
|
op_http_upgrade_websocket_next,
|
||||||
|
op_http_try_wait,
|
||||||
|
op_http_wait,
|
||||||
|
op_http_cancel,
|
||||||
|
op_http_close,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
ArrayPrototypePush,
|
||||||
|
ObjectHasOwn,
|
||||||
|
ObjectPrototypeIsPrototypeOf,
|
||||||
|
PromisePrototypeCatch,
|
||||||
|
PromisePrototypeThen,
|
||||||
|
Symbol,
|
||||||
|
TypeError,
|
||||||
|
TypedArrayPrototypeGetSymbolToStringTag,
|
||||||
|
Uint8Array,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
const { BadResourcePrototype, InterruptedPrototype } = core;
|
|
||||||
import { InnerBody } from "ext:deno_fetch/22_body.js";
|
import { InnerBody } from "ext:deno_fetch/22_body.js";
|
||||||
import { Event } from "ext:deno_web/02_event.js";
|
import { Event } from "ext:deno_web/02_event.js";
|
||||||
import {
|
import {
|
||||||
|
@ -36,39 +71,7 @@ import {
|
||||||
import { listen, listenOptionApiName, TcpConn } from "ext:deno_net/01_net.js";
|
import { listen, listenOptionApiName, TcpConn } from "ext:deno_net/01_net.js";
|
||||||
import { listenTls } from "ext:deno_net/02_tls.js";
|
import { listenTls } from "ext:deno_net/02_tls.js";
|
||||||
import { SymbolAsyncDispose } from "ext:deno_web/00_infra.js";
|
import { SymbolAsyncDispose } from "ext:deno_web/00_infra.js";
|
||||||
const {
|
|
||||||
ArrayPrototypePush,
|
|
||||||
ObjectHasOwn,
|
|
||||||
ObjectPrototypeIsPrototypeOf,
|
|
||||||
PromisePrototypeCatch,
|
|
||||||
PromisePrototypeThen,
|
|
||||||
Symbol,
|
|
||||||
TypeError,
|
|
||||||
TypedArrayPrototypeGetSymbolToStringTag,
|
|
||||||
Uint8Array,
|
|
||||||
} = primordials;
|
|
||||||
|
|
||||||
const {
|
|
||||||
op_http_close_after_finish,
|
|
||||||
op_http_get_request_headers,
|
|
||||||
op_http_get_request_method_and_url,
|
|
||||||
op_http_read_request_body,
|
|
||||||
op_http_serve,
|
|
||||||
op_http_serve_on,
|
|
||||||
op_http_set_promise_complete,
|
|
||||||
op_http_set_response_body_bytes,
|
|
||||||
op_http_set_response_body_resource,
|
|
||||||
op_http_set_response_body_text,
|
|
||||||
op_http_set_response_header,
|
|
||||||
op_http_set_response_headers,
|
|
||||||
op_http_set_response_trailers,
|
|
||||||
op_http_upgrade_raw,
|
|
||||||
op_http_upgrade_websocket_next,
|
|
||||||
op_http_try_wait,
|
|
||||||
op_http_wait,
|
|
||||||
op_http_cancel,
|
|
||||||
op_http_close,
|
|
||||||
} = core.ensureFastOps();
|
|
||||||
const _upgraded = Symbol("_upgraded");
|
const _upgraded = Symbol("_upgraded");
|
||||||
|
|
||||||
function internalServerError() {
|
function internalServerError() {
|
||||||
|
|
|
@ -1,7 +1,43 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, internals, primordials } from "ext:core/mod.js";
|
import { core, internals, primordials } from "ext:core/mod.js";
|
||||||
const { BadResourcePrototype, InterruptedPrototype, ops } = core;
|
const {
|
||||||
|
BadResourcePrototype,
|
||||||
|
InterruptedPrototype,
|
||||||
|
} = core;
|
||||||
|
const {
|
||||||
|
op_http_accept,
|
||||||
|
op_http_headers,
|
||||||
|
op_http_shutdown,
|
||||||
|
op_http_upgrade,
|
||||||
|
op_http_upgrade_websocket,
|
||||||
|
op_http_websocket_accept_header,
|
||||||
|
op_http_write,
|
||||||
|
op_http_write_headers,
|
||||||
|
op_http_write_resource,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
ArrayPrototypeIncludes,
|
||||||
|
ArrayPrototypeMap,
|
||||||
|
ArrayPrototypePush,
|
||||||
|
Error,
|
||||||
|
ObjectPrototypeIsPrototypeOf,
|
||||||
|
SafeSet,
|
||||||
|
SafeSetIterator,
|
||||||
|
SetPrototypeAdd,
|
||||||
|
SetPrototypeDelete,
|
||||||
|
StringPrototypeCharCodeAt,
|
||||||
|
StringPrototypeIncludes,
|
||||||
|
StringPrototypeSplit,
|
||||||
|
StringPrototypeToLowerCase,
|
||||||
|
StringPrototypeToUpperCase,
|
||||||
|
Symbol,
|
||||||
|
SymbolAsyncIterator,
|
||||||
|
TypeError,
|
||||||
|
TypedArrayPrototypeGetSymbolToStringTag,
|
||||||
|
Uint8Array,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
import { InnerBody } from "ext:deno_fetch/22_body.js";
|
import { InnerBody } from "ext:deno_fetch/22_body.js";
|
||||||
import { Event, setEventTargetData } from "ext:deno_web/02_event.js";
|
import { Event, setEventTargetData } from "ext:deno_web/02_event.js";
|
||||||
import { BlobPrototype } from "ext:deno_web/09_file.js";
|
import { BlobPrototype } from "ext:deno_web/09_file.js";
|
||||||
|
@ -42,36 +78,6 @@ import {
|
||||||
} from "ext:deno_web/06_streams.js";
|
} from "ext:deno_web/06_streams.js";
|
||||||
import { serve } from "ext:deno_http/00_serve.js";
|
import { serve } from "ext:deno_http/00_serve.js";
|
||||||
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
||||||
const {
|
|
||||||
ArrayPrototypeIncludes,
|
|
||||||
ArrayPrototypeMap,
|
|
||||||
ArrayPrototypePush,
|
|
||||||
Error,
|
|
||||||
ObjectPrototypeIsPrototypeOf,
|
|
||||||
SafeSet,
|
|
||||||
SafeSetIterator,
|
|
||||||
SetPrototypeAdd,
|
|
||||||
SetPrototypeDelete,
|
|
||||||
StringPrototypeCharCodeAt,
|
|
||||||
StringPrototypeIncludes,
|
|
||||||
StringPrototypeSplit,
|
|
||||||
StringPrototypeToLowerCase,
|
|
||||||
StringPrototypeToUpperCase,
|
|
||||||
Symbol,
|
|
||||||
SymbolAsyncIterator,
|
|
||||||
TypeError,
|
|
||||||
TypedArrayPrototypeGetSymbolToStringTag,
|
|
||||||
Uint8Array,
|
|
||||||
} = primordials;
|
|
||||||
const {
|
|
||||||
op_http_accept,
|
|
||||||
op_http_shutdown,
|
|
||||||
op_http_upgrade,
|
|
||||||
op_http_write,
|
|
||||||
op_http_upgrade_websocket,
|
|
||||||
op_http_write_headers,
|
|
||||||
op_http_write_resource,
|
|
||||||
} = core.ensureFastOps();
|
|
||||||
|
|
||||||
const connErrorSymbol = Symbol("connError");
|
const connErrorSymbol = Symbol("connError");
|
||||||
const _deferred = Symbol("upgradeHttpDeferred");
|
const _deferred = Symbol("upgradeHttpDeferred");
|
||||||
|
@ -152,7 +158,7 @@ class HttpConn {
|
||||||
const innerRequest = newInnerRequest(
|
const innerRequest = newInnerRequest(
|
||||||
method,
|
method,
|
||||||
url,
|
url,
|
||||||
() => ops.op_http_headers(streamRid),
|
() => op_http_headers(streamRid),
|
||||||
body !== null ? new InnerBody(body) : null,
|
body !== null ? new InnerBody(body) : null,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
@ -455,7 +461,7 @@ function upgradeWebSocket(request, options = {}) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const accept = ops.op_http_websocket_accept_header(websocketKey);
|
const accept = op_http_websocket_accept_header(websocketKey);
|
||||||
|
|
||||||
const r = newInnerResponse(101);
|
const r = newInnerResponse(101);
|
||||||
r.headerList = [
|
r.headerList = [
|
||||||
|
|
|
@ -5,11 +5,9 @@
|
||||||
// Thank you! We love Go! <3
|
// Thank you! We love Go! <3
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
import {
|
op_stdin_set_raw,
|
||||||
readableStreamForRid,
|
} = core.ensureFastOps(true);
|
||||||
writableStreamForRid,
|
|
||||||
} from "ext:deno_web/06_streams.js";
|
|
||||||
const {
|
const {
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
|
@ -18,6 +16,11 @@ const {
|
||||||
TypedArrayPrototypeGetByteLength,
|
TypedArrayPrototypeGetByteLength,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import {
|
||||||
|
readableStreamForRid,
|
||||||
|
writableStreamForRid,
|
||||||
|
} from "ext:deno_web/06_streams.js";
|
||||||
|
|
||||||
const DEFAULT_BUFFER_SIZE = 32 * 1024;
|
const DEFAULT_BUFFER_SIZE = 32 * 1024;
|
||||||
// Seek whence values.
|
// Seek whence values.
|
||||||
// https://golang.org/pkg/io/#pkg-constants
|
// https://golang.org/pkg/io/#pkg-constants
|
||||||
|
@ -192,7 +195,7 @@ class Stdin {
|
||||||
|
|
||||||
setRaw(mode, options = {}) {
|
setRaw(mode, options = {}) {
|
||||||
const cbreak = !!(options.cbreak ?? false);
|
const cbreak = !!(options.cbreak ?? false);
|
||||||
ops.op_stdin_set_raw(mode, cbreak);
|
op_stdin_set_raw(mode, cbreak);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,19 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
const {
|
||||||
import { ReadableStream } from "ext:deno_web/06_streams.js";
|
isPromise,
|
||||||
|
} = core;
|
||||||
|
const {
|
||||||
|
op_kv_atomic_write,
|
||||||
|
op_kv_database_open,
|
||||||
|
op_kv_dequeue_next_message,
|
||||||
|
op_kv_encode_cursor,
|
||||||
|
op_kv_finish_dequeued_message,
|
||||||
|
op_kv_snapshot_read,
|
||||||
|
op_kv_watch,
|
||||||
|
op_kv_watch_next,
|
||||||
|
} = core.ensureFastOps();
|
||||||
const {
|
const {
|
||||||
ArrayFrom,
|
ArrayFrom,
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
|
@ -30,19 +41,9 @@ const {
|
||||||
TypeError,
|
TypeError,
|
||||||
TypedArrayPrototypeGetSymbolToStringTag,
|
TypedArrayPrototypeGetSymbolToStringTag,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
const {
|
|
||||||
isPromise,
|
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
||||||
} = core;
|
import { ReadableStream } from "ext:deno_web/06_streams.js";
|
||||||
const {
|
|
||||||
op_kv_atomic_write,
|
|
||||||
op_kv_database_open,
|
|
||||||
op_kv_dequeue_next_message,
|
|
||||||
op_kv_encode_cursor,
|
|
||||||
op_kv_finish_dequeued_message,
|
|
||||||
op_kv_snapshot_read,
|
|
||||||
op_kv_watch,
|
|
||||||
op_kv_watch_next,
|
|
||||||
} = core.ensureFastOps();
|
|
||||||
|
|
||||||
const encodeCursor: (
|
const encodeCursor: (
|
||||||
selector: [Deno.KvKey | null, Deno.KvKey | null, Deno.KvKey | null],
|
selector: [Deno.KvKey | null, Deno.KvKey | null, Deno.KvKey | null],
|
||||||
|
|
|
@ -1,33 +1,34 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const { BadResourcePrototype, InterruptedPrototype, ops } = core;
|
const {
|
||||||
import {
|
BadResourcePrototype,
|
||||||
readableStreamForRidUnrefable,
|
InterruptedPrototype,
|
||||||
readableStreamForRidUnrefableRef,
|
} = core;
|
||||||
readableStreamForRidUnrefableUnref,
|
|
||||||
writableStreamForRid,
|
|
||||||
} from "ext:deno_web/06_streams.js";
|
|
||||||
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
|
|
||||||
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
|
||||||
const {
|
const {
|
||||||
op_dns_resolve,
|
op_dns_resolve,
|
||||||
op_net_accept_tcp,
|
op_net_accept_tcp,
|
||||||
op_net_accept_unix,
|
op_net_accept_unix,
|
||||||
op_net_connect_tcp,
|
op_net_connect_tcp,
|
||||||
op_net_connect_unix,
|
op_net_connect_unix,
|
||||||
|
op_net_join_multi_v4_udp,
|
||||||
|
op_net_join_multi_v6_udp,
|
||||||
|
op_net_leave_multi_v4_udp,
|
||||||
|
op_net_leave_multi_v6_udp,
|
||||||
|
op_net_listen_tcp,
|
||||||
|
op_net_listen_unix,
|
||||||
op_net_recv_udp,
|
op_net_recv_udp,
|
||||||
op_net_recv_unixpacket,
|
op_net_recv_unixpacket,
|
||||||
op_net_send_udp,
|
op_net_send_udp,
|
||||||
op_net_send_unixpacket,
|
op_net_send_unixpacket,
|
||||||
op_net_set_multi_loopback_udp,
|
op_net_set_multi_loopback_udp,
|
||||||
op_net_set_multi_ttl_udp,
|
op_net_set_multi_ttl_udp,
|
||||||
op_net_join_multi_v4_udp,
|
op_set_keepalive,
|
||||||
op_net_join_multi_v6_udp,
|
op_set_nodelay,
|
||||||
op_net_leave_multi_v4_udp,
|
|
||||||
op_net_leave_multi_v6_udp,
|
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
op_cancel_handle,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
const {
|
const {
|
||||||
Error,
|
Error,
|
||||||
Number,
|
Number,
|
||||||
|
@ -44,6 +45,15 @@ const {
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import {
|
||||||
|
readableStreamForRidUnrefable,
|
||||||
|
readableStreamForRidUnrefableRef,
|
||||||
|
readableStreamForRidUnrefableUnref,
|
||||||
|
writableStreamForRid,
|
||||||
|
} from "ext:deno_web/06_streams.js";
|
||||||
|
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
|
||||||
|
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
||||||
|
|
||||||
async function write(rid, data) {
|
async function write(rid, data) {
|
||||||
return await core.write(rid, data);
|
return await core.write(rid, data);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +67,7 @@ async function resolveDns(query, recordType, options) {
|
||||||
let abortHandler;
|
let abortHandler;
|
||||||
if (options?.signal) {
|
if (options?.signal) {
|
||||||
options.signal.throwIfAborted();
|
options.signal.throwIfAborted();
|
||||||
cancelRid = ops.op_cancel_handle();
|
cancelRid = op_cancel_handle();
|
||||||
abortHandler = () => core.tryClose(cancelRid);
|
abortHandler = () => core.tryClose(cancelRid);
|
||||||
options.signal[abortSignal.add](abortHandler);
|
options.signal[abortSignal.add](abortHandler);
|
||||||
}
|
}
|
||||||
|
@ -184,11 +194,11 @@ class Conn {
|
||||||
|
|
||||||
class TcpConn extends Conn {
|
class TcpConn extends Conn {
|
||||||
setNoDelay(noDelay = true) {
|
setNoDelay(noDelay = true) {
|
||||||
return ops.op_set_nodelay(this.rid, noDelay);
|
return op_set_nodelay(this.rid, noDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
setKeepAlive(keepAlive = true) {
|
setKeepAlive(keepAlive = true) {
|
||||||
return ops.op_set_keepalive(this.rid, keepAlive);
|
return op_set_keepalive(this.rid, keepAlive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,7 +463,7 @@ const listenOptionApiName = Symbol("listenOptionApiName");
|
||||||
function listen(args) {
|
function listen(args) {
|
||||||
switch (args.transport ?? "tcp") {
|
switch (args.transport ?? "tcp") {
|
||||||
case "tcp": {
|
case "tcp": {
|
||||||
const { 0: rid, 1: addr } = ops.op_net_listen_tcp({
|
const { 0: rid, 1: addr } = op_net_listen_tcp({
|
||||||
hostname: args.hostname ?? "0.0.0.0",
|
hostname: args.hostname ?? "0.0.0.0",
|
||||||
port: Number(args.port),
|
port: Number(args.port),
|
||||||
}, args.reusePort);
|
}, args.reusePort);
|
||||||
|
@ -461,7 +471,7 @@ function listen(args) {
|
||||||
return new Listener(rid, addr);
|
return new Listener(rid, addr);
|
||||||
}
|
}
|
||||||
case "unix": {
|
case "unix": {
|
||||||
const { 0: rid, 1: path } = ops.op_net_listen_unix(
|
const { 0: rid, 1: path } = op_net_listen_unix(
|
||||||
args.path,
|
args.path,
|
||||||
args[listenOptionApiName] ?? "Deno.listen",
|
args[listenOptionApiName] ?? "Deno.listen",
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
|
||||||
import { Conn, Listener } from "ext:deno_net/01_net.js";
|
|
||||||
const { Number, TypeError } = primordials;
|
|
||||||
const {
|
const {
|
||||||
op_tls_handshake,
|
|
||||||
op_tls_start,
|
|
||||||
op_net_accept_tls,
|
op_net_accept_tls,
|
||||||
op_net_connect_tls,
|
op_net_connect_tls,
|
||||||
|
op_net_listen_tls,
|
||||||
|
op_tls_handshake,
|
||||||
|
op_tls_start,
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
Number,
|
||||||
|
TypeError,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
|
import { Conn, Listener } from "ext:deno_net/01_net.js";
|
||||||
|
|
||||||
function opStartTls(args) {
|
function opStartTls(args) {
|
||||||
return op_tls_start(args);
|
return op_tls_start(args);
|
||||||
|
@ -72,7 +76,7 @@ function listenTls({
|
||||||
if (transport !== "tcp") {
|
if (transport !== "tcp") {
|
||||||
throw new TypeError(`Unsupported transport: '${transport}'`);
|
throw new TypeError(`Unsupported transport: '${transport}'`);
|
||||||
}
|
}
|
||||||
const { 0: rid, 1: localAddr } = ops.op_net_listen_tls(
|
const { 0: rid, 1: localAddr } = op_net_listen_tls(
|
||||||
{ hostname, port: Number(port) },
|
{ hostname, port: Number(port) },
|
||||||
{ cert, certFile, key, keyFile, alpnProtocols, reusePort },
|
{ cert, certFile, key, keyFile, alpnProtocols, reusePort },
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,7 +3,33 @@
|
||||||
// deno-lint-ignore-file
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
import { core, internals, primordials } from "ext:core/mod.js";
|
import { core, internals, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
|
op_require_as_file_path,
|
||||||
|
op_require_break_on_next_statement,
|
||||||
|
op_require_init_paths,
|
||||||
|
op_require_is_deno_dir_package,
|
||||||
|
op_require_is_request_relative,
|
||||||
|
op_require_node_module_paths,
|
||||||
|
op_require_package_imports_resolve,
|
||||||
|
op_require_path_basename,
|
||||||
|
op_require_path_dirname,
|
||||||
|
op_require_path_is_absolute,
|
||||||
|
op_require_path_resolve,
|
||||||
|
op_require_proxy_path,
|
||||||
|
op_require_read_file,
|
||||||
|
op_require_read_package_scope,
|
||||||
|
op_require_real_path,
|
||||||
|
op_require_resolve_deno_dir,
|
||||||
|
op_require_resolve_exports,
|
||||||
|
op_require_resolve_lookup_paths,
|
||||||
|
op_require_stat,
|
||||||
|
op_require_try_self,
|
||||||
|
op_require_try_self_parent_path,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
op_napi_open,
|
||||||
|
op_require_read_closest_package_json,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
const {
|
const {
|
||||||
ArrayIsArray,
|
ArrayIsArray,
|
||||||
ArrayPrototypeIncludes,
|
ArrayPrototypeIncludes,
|
||||||
|
@ -12,32 +38,33 @@ const {
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
ArrayPrototypeSlice,
|
ArrayPrototypeSlice,
|
||||||
ArrayPrototypeSplice,
|
ArrayPrototypeSplice,
|
||||||
|
Error,
|
||||||
|
JSONParse,
|
||||||
|
ObjectCreate,
|
||||||
|
ObjectEntries,
|
||||||
ObjectGetOwnPropertyDescriptor,
|
ObjectGetOwnPropertyDescriptor,
|
||||||
ObjectGetPrototypeOf,
|
ObjectGetPrototypeOf,
|
||||||
ObjectHasOwn,
|
ObjectHasOwn,
|
||||||
ObjectSetPrototypeOf,
|
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
ObjectEntries,
|
|
||||||
ObjectPrototype,
|
ObjectPrototype,
|
||||||
ObjectCreate,
|
ObjectSetPrototypeOf,
|
||||||
Proxy,
|
Proxy,
|
||||||
|
RegExpPrototypeTest,
|
||||||
|
SafeArrayIterator,
|
||||||
SafeMap,
|
SafeMap,
|
||||||
SafeWeakMap,
|
SafeWeakMap,
|
||||||
SafeArrayIterator,
|
|
||||||
JSONParse,
|
|
||||||
String,
|
String,
|
||||||
|
StringPrototypeCharCodeAt,
|
||||||
StringPrototypeEndsWith,
|
StringPrototypeEndsWith,
|
||||||
StringPrototypeIndexOf,
|
|
||||||
StringPrototypeIncludes,
|
StringPrototypeIncludes,
|
||||||
|
StringPrototypeIndexOf,
|
||||||
StringPrototypeMatch,
|
StringPrototypeMatch,
|
||||||
StringPrototypeSlice,
|
StringPrototypeSlice,
|
||||||
StringPrototypeSplit,
|
StringPrototypeSplit,
|
||||||
StringPrototypeStartsWith,
|
StringPrototypeStartsWith,
|
||||||
StringPrototypeCharCodeAt,
|
|
||||||
RegExpPrototypeTest,
|
|
||||||
Error,
|
|
||||||
TypeError,
|
TypeError,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
import { nodeGlobals } from "ext:deno_node/00_globals.js";
|
import { nodeGlobals } from "ext:deno_node/00_globals.js";
|
||||||
|
|
||||||
import _httpAgent from "ext:deno_node/_http_agent.mjs";
|
import _httpAgent from "ext:deno_node/_http_agent.mjs";
|
||||||
|
@ -248,11 +275,11 @@ function pathDirname(filepath) {
|
||||||
} else if (filepath === "") {
|
} else if (filepath === "") {
|
||||||
return ".";
|
return ".";
|
||||||
}
|
}
|
||||||
return ops.op_require_path_dirname(filepath);
|
return op_require_path_dirname(filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pathResolve(...args) {
|
function pathResolve(...args) {
|
||||||
return ops.op_require_path_resolve(args);
|
return op_require_path_resolve(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
const nativeModulePolyfill = new SafeMap();
|
const nativeModulePolyfill = new SafeMap();
|
||||||
|
@ -276,7 +303,7 @@ function stat(filename) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const result = ops.op_require_stat(filename);
|
const result = op_require_stat(filename);
|
||||||
if (statCache !== null && result >= 0) {
|
if (statCache !== null && result >= 0) {
|
||||||
statCache.set(filename, result);
|
statCache.set(filename, result);
|
||||||
}
|
}
|
||||||
|
@ -306,7 +333,7 @@ function tryPackage(requestPath, exts, isMain, originalPath) {
|
||||||
requestPath,
|
requestPath,
|
||||||
"package.json",
|
"package.json",
|
||||||
);
|
);
|
||||||
const pkg = ops.op_require_read_package_scope(packageJsonPath)?.main;
|
const pkg = op_require_read_package_scope(packageJsonPath)?.main;
|
||||||
if (!pkg) {
|
if (!pkg) {
|
||||||
return tryExtensions(
|
return tryExtensions(
|
||||||
pathResolve(requestPath, "index"),
|
pathResolve(requestPath, "index"),
|
||||||
|
@ -360,7 +387,7 @@ function toRealPath(requestPath) {
|
||||||
if (maybeCached) {
|
if (maybeCached) {
|
||||||
return maybeCached;
|
return maybeCached;
|
||||||
}
|
}
|
||||||
const rp = ops.op_require_real_path(requestPath);
|
const rp = op_require_real_path(requestPath);
|
||||||
realpathCache.set(requestPath, rp);
|
realpathCache.set(requestPath, rp);
|
||||||
return rp;
|
return rp;
|
||||||
}
|
}
|
||||||
|
@ -379,7 +406,7 @@ function tryExtensions(p, exts, isMain) {
|
||||||
// Find the longest (possibly multi-dot) extension registered in
|
// Find the longest (possibly multi-dot) extension registered in
|
||||||
// Module._extensions
|
// Module._extensions
|
||||||
function findLongestRegisteredExtension(filename) {
|
function findLongestRegisteredExtension(filename) {
|
||||||
const name = ops.op_require_path_basename(filename);
|
const name = op_require_path_basename(filename);
|
||||||
let currentExtension;
|
let currentExtension;
|
||||||
let index;
|
let index;
|
||||||
let startIndex = 0;
|
let startIndex = 0;
|
||||||
|
@ -513,7 +540,7 @@ function resolveExports(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ops.op_require_resolve_exports(
|
return op_require_resolve_exports(
|
||||||
usesLocalNodeModulesDir,
|
usesLocalNodeModulesDir,
|
||||||
modulesPath,
|
modulesPath,
|
||||||
request,
|
request,
|
||||||
|
@ -524,7 +551,7 @@ function resolveExports(
|
||||||
}
|
}
|
||||||
|
|
||||||
Module._findPath = function (request, paths, isMain, parentPath) {
|
Module._findPath = function (request, paths, isMain, parentPath) {
|
||||||
const absoluteRequest = ops.op_require_path_is_absolute(request);
|
const absoluteRequest = op_require_path_is_absolute(request);
|
||||||
if (absoluteRequest) {
|
if (absoluteRequest) {
|
||||||
paths = [""];
|
paths = [""];
|
||||||
} else if (!paths || paths.length === 0) {
|
} else if (!paths || paths.length === 0) {
|
||||||
|
@ -568,10 +595,10 @@ Module._findPath = function (request, paths, isMain, parentPath) {
|
||||||
if (usesLocalNodeModulesDir) {
|
if (usesLocalNodeModulesDir) {
|
||||||
basePath = pathResolve(curPath, request);
|
basePath = pathResolve(curPath, request);
|
||||||
} else {
|
} else {
|
||||||
const isDenoDirPackage = ops.op_require_is_deno_dir_package(
|
const isDenoDirPackage = op_require_is_deno_dir_package(
|
||||||
curPath,
|
curPath,
|
||||||
);
|
);
|
||||||
const isRelative = ops.op_require_is_request_relative(
|
const isRelative = op_require_is_request_relative(
|
||||||
request,
|
request,
|
||||||
);
|
);
|
||||||
basePath = (isDenoDirPackage && !isRelative)
|
basePath = (isDenoDirPackage && !isRelative)
|
||||||
|
@ -618,16 +645,16 @@ Module._findPath = function (request, paths, isMain, parentPath) {
|
||||||
* @returns {string[]} List of module directories
|
* @returns {string[]} List of module directories
|
||||||
*/
|
*/
|
||||||
Module._nodeModulePaths = function (fromPath) {
|
Module._nodeModulePaths = function (fromPath) {
|
||||||
return ops.op_require_node_module_paths(fromPath);
|
return op_require_node_module_paths(fromPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
Module._resolveLookupPaths = function (request, parent) {
|
Module._resolveLookupPaths = function (request, parent) {
|
||||||
const paths = [];
|
const paths = [];
|
||||||
|
|
||||||
if (ops.op_require_is_request_relative(request)) {
|
if (op_require_is_request_relative(request)) {
|
||||||
ArrayPrototypePush(
|
ArrayPrototypePush(
|
||||||
paths,
|
paths,
|
||||||
parent?.filename ? ops.op_require_path_dirname(parent.filename) : ".",
|
parent?.filename ? op_require_path_dirname(parent.filename) : ".",
|
||||||
);
|
);
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
@ -635,7 +662,7 @@ Module._resolveLookupPaths = function (request, parent) {
|
||||||
if (
|
if (
|
||||||
!usesLocalNodeModulesDir && parent?.filename && parent.filename.length > 0
|
!usesLocalNodeModulesDir && parent?.filename && parent.filename.length > 0
|
||||||
) {
|
) {
|
||||||
const denoDirPath = ops.op_require_resolve_deno_dir(
|
const denoDirPath = op_require_resolve_deno_dir(
|
||||||
request,
|
request,
|
||||||
parent.filename,
|
parent.filename,
|
||||||
);
|
);
|
||||||
|
@ -643,7 +670,7 @@ Module._resolveLookupPaths = function (request, parent) {
|
||||||
ArrayPrototypePush(paths, denoDirPath);
|
ArrayPrototypePush(paths, denoDirPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const lookupPathsResult = ops.op_require_resolve_lookup_paths(
|
const lookupPathsResult = op_require_resolve_lookup_paths(
|
||||||
request,
|
request,
|
||||||
parent?.paths,
|
parent?.paths,
|
||||||
parent?.filename ?? "",
|
parent?.filename ?? "",
|
||||||
|
@ -765,7 +792,7 @@ Module._resolveFilename = function (
|
||||||
|
|
||||||
if (typeof options === "object" && options !== null) {
|
if (typeof options === "object" && options !== null) {
|
||||||
if (ArrayIsArray(options.paths)) {
|
if (ArrayIsArray(options.paths)) {
|
||||||
const isRelative = ops.op_require_is_request_relative(
|
const isRelative = op_require_is_request_relative(
|
||||||
request,
|
request,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -800,7 +827,7 @@ Module._resolveFilename = function (
|
||||||
|
|
||||||
if (parent?.filename) {
|
if (parent?.filename) {
|
||||||
if (request[0] === "#") {
|
if (request[0] === "#") {
|
||||||
const maybeResolved = ops.op_require_package_imports_resolve(
|
const maybeResolved = op_require_package_imports_resolve(
|
||||||
parent.filename,
|
parent.filename,
|
||||||
request,
|
request,
|
||||||
);
|
);
|
||||||
|
@ -811,12 +838,12 @@ Module._resolveFilename = function (
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try module self resolution first
|
// Try module self resolution first
|
||||||
const parentPath = ops.op_require_try_self_parent_path(
|
const parentPath = op_require_try_self_parent_path(
|
||||||
!!parent,
|
!!parent,
|
||||||
parent?.filename,
|
parent?.filename,
|
||||||
parent?.id,
|
parent?.id,
|
||||||
);
|
);
|
||||||
const selfResolved = ops.op_require_try_self(parentPath, request);
|
const selfResolved = op_require_try_self(parentPath, request);
|
||||||
if (selfResolved) {
|
if (selfResolved) {
|
||||||
const cacheKey = request + "\x00" +
|
const cacheKey = request + "\x00" +
|
||||||
(paths.length === 1 ? paths[0] : ArrayPrototypeJoin(paths, "\x00"));
|
(paths.length === 1 ? paths[0] : ArrayPrototypeJoin(paths, "\x00"));
|
||||||
|
@ -832,7 +859,7 @@ Module._resolveFilename = function (
|
||||||
parentPath,
|
parentPath,
|
||||||
);
|
);
|
||||||
if (filename) {
|
if (filename) {
|
||||||
return ops.op_require_real_path(filename);
|
return op_require_real_path(filename);
|
||||||
}
|
}
|
||||||
const requireStack = [];
|
const requireStack = [];
|
||||||
for (let cursor = parent; cursor; cursor = moduleParentCache.get(cursor)) {
|
for (let cursor = parent; cursor; cursor = moduleParentCache.get(cursor)) {
|
||||||
|
@ -876,7 +903,7 @@ Module.prototype.load = function (filename) {
|
||||||
|
|
||||||
// Canonicalize the path so it's not pointing to the symlinked directory
|
// Canonicalize the path so it's not pointing to the symlinked directory
|
||||||
// in `node_modules` directory of the referrer.
|
// in `node_modules` directory of the referrer.
|
||||||
this.filename = ops.op_require_real_path(filename);
|
this.filename = op_require_real_path(filename);
|
||||||
this.paths = Module._nodeModulePaths(
|
this.paths = Module._nodeModulePaths(
|
||||||
pathDirname(this.filename),
|
pathDirname(this.filename),
|
||||||
);
|
);
|
||||||
|
@ -989,7 +1016,7 @@ Module.prototype._compile = function (content, filename) {
|
||||||
|
|
||||||
if (hasInspectBrk && !hasBrokenOnInspectBrk) {
|
if (hasInspectBrk && !hasBrokenOnInspectBrk) {
|
||||||
hasBrokenOnInspectBrk = true;
|
hasBrokenOnInspectBrk = true;
|
||||||
ops.op_require_break_on_next_statement();
|
op_require_break_on_next_statement();
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -1032,10 +1059,10 @@ Module.prototype._compile = function (content, filename) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Module._extensions[".js"] = function (module, filename) {
|
Module._extensions[".js"] = function (module, filename) {
|
||||||
const content = ops.op_require_read_file(filename);
|
const content = op_require_read_file(filename);
|
||||||
|
|
||||||
if (StringPrototypeEndsWith(filename, ".js")) {
|
if (StringPrototypeEndsWith(filename, ".js")) {
|
||||||
const pkg = ops.op_require_read_closest_package_json(filename);
|
const pkg = op_require_read_closest_package_json(filename);
|
||||||
if (pkg && pkg.exists && pkg.typ === "module") {
|
if (pkg && pkg.exists && pkg.typ === "module") {
|
||||||
throw createRequireEsmError(
|
throw createRequireEsmError(
|
||||||
filename,
|
filename,
|
||||||
|
@ -1070,7 +1097,7 @@ function stripBOM(content) {
|
||||||
|
|
||||||
// Native extension for .json
|
// Native extension for .json
|
||||||
Module._extensions[".json"] = function (module, filename) {
|
Module._extensions[".json"] = function (module, filename) {
|
||||||
const content = ops.op_require_read_file(filename);
|
const content = op_require_read_file(filename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
module.exports = JSONParse(stripBOM(content));
|
module.exports = JSONParse(stripBOM(content));
|
||||||
|
@ -1085,11 +1112,11 @@ Module._extensions[".node"] = function (module, filename) {
|
||||||
if (filename.endsWith("fsevents.node")) {
|
if (filename.endsWith("fsevents.node")) {
|
||||||
throw new Error("Using fsevents module is currently not supported");
|
throw new Error("Using fsevents module is currently not supported");
|
||||||
}
|
}
|
||||||
module.exports = ops.op_napi_open(filename, globalThis);
|
module.exports = op_napi_open(filename, globalThis);
|
||||||
};
|
};
|
||||||
|
|
||||||
function createRequireFromPath(filename) {
|
function createRequireFromPath(filename) {
|
||||||
const proxyPath = ops.op_require_proxy_path(filename);
|
const proxyPath = op_require_proxy_path(filename);
|
||||||
const mod = new Module(proxyPath);
|
const mod = new Module(proxyPath);
|
||||||
mod.filename = proxyPath;
|
mod.filename = proxyPath;
|
||||||
mod.paths = Module._nodeModulePaths(mod.path);
|
mod.paths = Module._nodeModulePaths(mod.path);
|
||||||
|
@ -1152,14 +1179,14 @@ function createRequire(filenameOrUrl) {
|
||||||
`The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ${filenameOrUrl}`,
|
`The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ${filenameOrUrl}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const filename = ops.op_require_as_file_path(fileUrlStr);
|
const filename = op_require_as_file_path(fileUrlStr);
|
||||||
return createRequireFromPath(filename);
|
return createRequireFromPath(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
Module.createRequire = createRequire;
|
Module.createRequire = createRequire;
|
||||||
|
|
||||||
Module._initPaths = function () {
|
Module._initPaths = function () {
|
||||||
const paths = ops.op_require_init_paths();
|
const paths = op_require_init_paths();
|
||||||
modulePaths = paths;
|
modulePaths = paths;
|
||||||
Module.globalPaths = ArrayPrototypeSlice(modulePaths);
|
Module.globalPaths = ArrayPrototypeSlice(modulePaths);
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
// deno-lint-ignore-file
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
const internals = globalThis.__bootstrap.internals;
|
import { internals } from "ext:core/mod.js";
|
||||||
const requireImpl = internals.requireImpl;
|
const requireImpl = internals.requireImpl;
|
||||||
|
|
||||||
import { nodeGlobals } from "ext:deno_node/00_globals.js";
|
import { nodeGlobals } from "ext:deno_node/00_globals.js";
|
||||||
import "node:module";
|
import "node:module";
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,23 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_brotli_compress,
|
||||||
|
op_brotli_compress_async,
|
||||||
|
op_brotli_compress_stream,
|
||||||
|
op_brotli_compress_stream_end,
|
||||||
|
op_brotli_decompress,
|
||||||
|
op_brotli_decompress_async,
|
||||||
|
op_brotli_decompress_stream,
|
||||||
|
op_create_brotli_compress,
|
||||||
|
op_create_brotli_decompress,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import { zlib as constants } from "ext:deno_node/internal_binding/constants.ts";
|
import { zlib as constants } from "ext:deno_node/internal_binding/constants.ts";
|
||||||
import { TextEncoder } from "ext:deno_web/08_text_encoding.js";
|
import { TextEncoder } from "ext:deno_web/08_text_encoding.js";
|
||||||
import { Transform } from "node:stream";
|
import { Transform } from "node:stream";
|
||||||
import { Buffer } from "node:buffer";
|
import { Buffer } from "node:buffer";
|
||||||
const { core } = globalThis.__bootstrap;
|
|
||||||
const { ops } = core;
|
|
||||||
const {
|
|
||||||
op_brotli_compress_async,
|
|
||||||
} = core.ensureFastOps();
|
|
||||||
|
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
const toU8 = (input) => {
|
const toU8 = (input) => {
|
||||||
|
@ -44,7 +52,7 @@ export class BrotliDecompress extends Transform {
|
||||||
transform(chunk, _encoding, callback) {
|
transform(chunk, _encoding, callback) {
|
||||||
const input = toU8(chunk);
|
const input = toU8(chunk);
|
||||||
const output = new Uint8Array(1024);
|
const output = new Uint8Array(1024);
|
||||||
const avail = ops.op_brotli_decompress_stream(context, input, output);
|
const avail = op_brotli_decompress_stream(context, input, output);
|
||||||
this.push(output.slice(0, avail));
|
this.push(output.slice(0, avail));
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
|
@ -54,7 +62,7 @@ export class BrotliDecompress extends Transform {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
this.#context = ops.op_create_brotli_decompress();
|
this.#context = op_create_brotli_decompress();
|
||||||
const context = this.#context;
|
const context = this.#context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,20 +76,20 @@ export class BrotliCompress extends Transform {
|
||||||
transform(chunk, _encoding, callback) {
|
transform(chunk, _encoding, callback) {
|
||||||
const input = toU8(chunk);
|
const input = toU8(chunk);
|
||||||
const output = new Uint8Array(brotliMaxCompressedSize(input.length));
|
const output = new Uint8Array(brotliMaxCompressedSize(input.length));
|
||||||
const avail = ops.op_brotli_compress_stream(context, input, output);
|
const avail = op_brotli_compress_stream(context, input, output);
|
||||||
this.push(output.slice(0, avail));
|
this.push(output.slice(0, avail));
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
flush(callback) {
|
flush(callback) {
|
||||||
const output = new Uint8Array(1024);
|
const output = new Uint8Array(1024);
|
||||||
const avail = ops.op_brotli_compress_stream_end(context, output);
|
const avail = op_brotli_compress_stream_end(context, output);
|
||||||
this.push(output.slice(0, avail));
|
this.push(output.slice(0, avail));
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const params = Object.values(options?.params ?? {});
|
const params = Object.values(options?.params ?? {});
|
||||||
this.#context = ops.op_create_brotli_compress(params);
|
this.#context = op_create_brotli_compress(params);
|
||||||
const context = this.#context;
|
const context = this.#context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,17 +146,17 @@ export function brotliCompressSync(
|
||||||
const output = new Uint8Array(brotliMaxCompressedSize(buf.length));
|
const output = new Uint8Array(brotliMaxCompressedSize(buf.length));
|
||||||
|
|
||||||
const { quality, lgwin, mode } = oneOffCompressOptions(options);
|
const { quality, lgwin, mode } = oneOffCompressOptions(options);
|
||||||
const len = ops.op_brotli_compress(buf, output, quality, lgwin, mode);
|
const len = op_brotli_compress(buf, output, quality, lgwin, mode);
|
||||||
return Buffer.from(output.subarray(0, len));
|
return Buffer.from(output.subarray(0, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function brotliDecompress(input) {
|
export function brotliDecompress(input) {
|
||||||
const buf = toU8(input);
|
const buf = toU8(input);
|
||||||
return ops.op_brotli_decompress_async(buf)
|
return op_brotli_decompress_async(buf)
|
||||||
.then((result) => callback(null, Buffer.from(result)))
|
.then((result) => callback(null, Buffer.from(result)))
|
||||||
.catch((err) => callback(err));
|
.catch((err) => callback(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function brotliDecompressSync(input) {
|
export function brotliDecompressSync(input) {
|
||||||
return Buffer.from(ops.op_brotli_decompress(toU8(input)));
|
return Buffer.from(op_brotli_decompress(toU8(input)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,22 +2,24 @@
|
||||||
|
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_cp,
|
||||||
|
op_node_cp_sync,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getValidatedPath,
|
getValidatedPath,
|
||||||
validateCpOptions,
|
validateCpOptions,
|
||||||
} from "ext:deno_node/internal/fs/utils.mjs";
|
} from "ext:deno_node/internal/fs/utils.mjs";
|
||||||
import { promisify } from "ext:deno_node/internal/util.mjs";
|
import { promisify } from "ext:deno_node/internal/util.mjs";
|
||||||
|
|
||||||
const core = globalThis.__bootstrap.core;
|
|
||||||
const ops = core.ops;
|
|
||||||
const { op_node_cp } = core.ensureFastOps();
|
|
||||||
|
|
||||||
export function cpSync(src, dest, options) {
|
export function cpSync(src, dest, options) {
|
||||||
validateCpOptions(options);
|
validateCpOptions(options);
|
||||||
const srcPath = getValidatedPath(src, "src");
|
const srcPath = getValidatedPath(src, "src");
|
||||||
const destPath = getValidatedPath(dest, "dest");
|
const destPath = getValidatedPath(dest, "dest");
|
||||||
|
|
||||||
ops.op_node_cp_sync(srcPath, destPath);
|
op_node_cp_sync(srcPath, destPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function cp(src, dest, options, callback) {
|
export function cp(src, dest, options, callback) {
|
||||||
|
|
|
@ -2,7 +2,12 @@
|
||||||
|
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
const core = globalThis.__bootstrap.core;
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_fs_exists_sync,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import { pathFromURL } from "ext:deno_web/00_infra.js";
|
import { pathFromURL } from "ext:deno_web/00_infra.js";
|
||||||
|
|
||||||
type ExistsCallback = (exists: boolean) => void;
|
type ExistsCallback = (exists: boolean) => void;
|
||||||
|
@ -35,5 +40,5 @@ Object.defineProperty(exists, kCustomPromisifiedSymbol, {
|
||||||
*/
|
*/
|
||||||
export function existsSync(path: string | URL): boolean {
|
export function existsSync(path: string | URL): boolean {
|
||||||
path = path instanceof URL ? pathFromURL(path) : path;
|
path = path instanceof URL ? pathFromURL(path) : path;
|
||||||
return core.ops.op_node_fs_exists_sync(path);
|
return op_node_fs_exists_sync(path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
|
||||||
import { validateFunction } from "ext:deno_node/internal/validators.mjs";
|
import { validateFunction } from "ext:deno_node/internal/validators.mjs";
|
||||||
import { _exiting } from "ext:deno_node/_process/exiting.ts";
|
import { _exiting } from "ext:deno_node/_process/exiting.ts";
|
||||||
import { FixedQueue } from "ext:deno_node/internal/fixed_queue.ts";
|
import { FixedQueue } from "ext:deno_node/internal/fixed_queue.ts";
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
|
||||||
|
|
||||||
interface Tock {
|
interface Tock {
|
||||||
callback: (...args: Array<unknown>) => void;
|
callback: (...args: Array<unknown>) => void;
|
||||||
args: Array<unknown>;
|
args: Array<unknown>;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
// They have to be split this way to prevent a circular dependency
|
// They have to be split this way to prevent a circular dependency
|
||||||
|
|
||||||
import { core } from "ext:core/mod.js";
|
import { core } from "ext:core/mod.js";
|
||||||
|
|
||||||
import { nextTick as _nextTick } from "ext:deno_node/_next_tick.ts";
|
import { nextTick as _nextTick } from "ext:deno_node/_next_tick.ts";
|
||||||
import { _exiting } from "ext:deno_node/_process/exiting.ts";
|
import { _exiting } from "ext:deno_node/_process/exiting.ts";
|
||||||
import * as fs from "ext:deno_fs/30_fs.js";
|
import * as fs from "ext:deno_fs/30_fs.js";
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
// These are simplified versions of the "real" errors in Node.
|
// These are simplified versions of the "real" errors in Node.
|
||||||
|
|
||||||
import { primordials } from "ext:core/mod.js";
|
import { primordials } from "ext:core/mod.js";
|
||||||
import { nextTick } from "ext:deno_node/_next_tick.ts";
|
|
||||||
const {
|
const {
|
||||||
ArrayPrototypePop,
|
ArrayPrototypePop,
|
||||||
Error,
|
Error,
|
||||||
|
@ -36,6 +35,8 @@ const {
|
||||||
TypeError,
|
TypeError,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import { nextTick } from "ext:deno_node/_next_tick.ts";
|
||||||
|
|
||||||
class NodeFalsyValueRejectionError extends Error {
|
class NodeFalsyValueRejectionError extends Error {
|
||||||
public reason: unknown;
|
public reason: unknown;
|
||||||
public code = "ERR_FALSY_VALUE_REJECTION";
|
public code = "ERR_FALSY_VALUE_REJECTION";
|
||||||
|
|
|
@ -3,12 +3,13 @@
|
||||||
// (with some modifications)
|
// (with some modifications)
|
||||||
|
|
||||||
import { primordials } from "ext:core/mod.js";
|
import { primordials } from "ext:core/mod.js";
|
||||||
import { clearTimeout, setTimeout } from "ext:deno_web/02_timers.js";
|
|
||||||
const {
|
const {
|
||||||
Promise,
|
Promise,
|
||||||
PromiseReject,
|
PromiseReject,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import { clearTimeout, setTimeout } from "ext:deno_web/02_timers.js";
|
||||||
|
|
||||||
/** Resolve a Promise after a given amount of milliseconds. */
|
/** Resolve a Promise after a given amount of milliseconds. */
|
||||||
export function delay(
|
export function delay(
|
||||||
ms: number,
|
ms: number,
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core } from "ext:core/mod.js";
|
import { core } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
|
op_node_build_os,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
|
|
||||||
export type OSType =
|
export type OSType =
|
||||||
| "windows"
|
| "windows"
|
||||||
|
@ -11,7 +13,7 @@ export type OSType =
|
||||||
| "freebsd"
|
| "freebsd"
|
||||||
| "openbsd";
|
| "openbsd";
|
||||||
|
|
||||||
export const osType: OSType = ops.op_node_build_os();
|
export const osType: OSType = op_node_build_os();
|
||||||
|
|
||||||
export const isWindows = osType === "windows";
|
export const isWindows = osType === "windows";
|
||||||
export const isLinux = osType === "linux" || osType === "android";
|
export const isLinux = osType === "linux" || osType === "android";
|
||||||
|
|
|
@ -2,13 +2,6 @@
|
||||||
// vendored from std/assert/mod.ts
|
// vendored from std/assert/mod.ts
|
||||||
|
|
||||||
import { primordials } from "ext:core/mod.js";
|
import { primordials } from "ext:core/mod.js";
|
||||||
import { URLPrototype } from "ext:deno_url/00_url.js";
|
|
||||||
import { red } from "ext:deno_node/_util/std_fmt_colors.ts";
|
|
||||||
import {
|
|
||||||
buildMessage,
|
|
||||||
diff,
|
|
||||||
diffstr,
|
|
||||||
} from "ext:deno_node/_util/std_testing_diff.ts";
|
|
||||||
const {
|
const {
|
||||||
DatePrototype,
|
DatePrototype,
|
||||||
ArrayPrototypeJoin,
|
ArrayPrototypeJoin,
|
||||||
|
@ -37,6 +30,14 @@ const {
|
||||||
WeakRefPrototypeDeref,
|
WeakRefPrototypeDeref,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import { URLPrototype } from "ext:deno_url/00_url.js";
|
||||||
|
import { red } from "ext:deno_node/_util/std_fmt_colors.ts";
|
||||||
|
import {
|
||||||
|
buildMessage,
|
||||||
|
diff,
|
||||||
|
diffstr,
|
||||||
|
} from "ext:deno_node/_util/std_testing_diff.ts";
|
||||||
|
|
||||||
const FORMAT_PATTERN = new SafeRegExp(/(?=["\\])/g);
|
const FORMAT_PATTERN = new SafeRegExp(/(?=["\\])/g);
|
||||||
|
|
||||||
/** Converts the input into a string. Objects, Sets and Maps are sorted so as to
|
/** Converts the input into a string. Objects, Sets and Maps are sorted so as to
|
||||||
|
|
|
@ -2,15 +2,6 @@
|
||||||
// This file was vendored from std/testing/_diff.ts
|
// This file was vendored from std/testing/_diff.ts
|
||||||
|
|
||||||
import { primordials } from "ext:core/mod.js";
|
import { primordials } from "ext:core/mod.js";
|
||||||
import {
|
|
||||||
bgGreen,
|
|
||||||
bgRed,
|
|
||||||
bold,
|
|
||||||
gray,
|
|
||||||
green,
|
|
||||||
red,
|
|
||||||
white,
|
|
||||||
} from "ext:deno_node/_util/std_fmt_colors.ts";
|
|
||||||
const {
|
const {
|
||||||
ArrayFrom,
|
ArrayFrom,
|
||||||
ArrayPrototypeFilter,
|
ArrayPrototypeFilter,
|
||||||
|
@ -23,19 +14,29 @@ const {
|
||||||
ArrayPrototypeReverse,
|
ArrayPrototypeReverse,
|
||||||
ArrayPrototypeShift,
|
ArrayPrototypeShift,
|
||||||
ArrayPrototypeSlice,
|
ArrayPrototypeSlice,
|
||||||
ArrayPrototypeSplice,
|
|
||||||
ArrayPrototypeSome,
|
ArrayPrototypeSome,
|
||||||
|
ArrayPrototypeSplice,
|
||||||
ArrayPrototypeUnshift,
|
ArrayPrototypeUnshift,
|
||||||
SafeArrayIterator,
|
|
||||||
SafeRegExp,
|
|
||||||
StringPrototypeSplit,
|
|
||||||
StringPrototypeReplace,
|
|
||||||
StringPrototypeTrim,
|
|
||||||
MathMin,
|
MathMin,
|
||||||
ObjectFreeze,
|
ObjectFreeze,
|
||||||
|
SafeArrayIterator,
|
||||||
|
SafeRegExp,
|
||||||
|
StringPrototypeReplace,
|
||||||
|
StringPrototypeSplit,
|
||||||
|
StringPrototypeTrim,
|
||||||
Uint32Array,
|
Uint32Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import {
|
||||||
|
bgGreen,
|
||||||
|
bgRed,
|
||||||
|
bold,
|
||||||
|
gray,
|
||||||
|
green,
|
||||||
|
red,
|
||||||
|
white,
|
||||||
|
} from "ext:deno_node/_util/std_fmt_colors.ts";
|
||||||
|
|
||||||
interface FarthestPoint {
|
interface FarthestPoint {
|
||||||
y: number;
|
y: number;
|
||||||
id: number;
|
id: number;
|
||||||
|
|
|
@ -43,9 +43,14 @@ export const DEFLATERAW = 5;
|
||||||
export const INFLATERAW = 6;
|
export const INFLATERAW = 6;
|
||||||
export const UNZIP = 7;
|
export const UNZIP = 7;
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
import { core } from "ext:core/mod.js";
|
||||||
const { ops } = core;
|
|
||||||
const {
|
const {
|
||||||
|
op_zlib_close,
|
||||||
|
op_zlib_close_if_pending,
|
||||||
|
op_zlib_init,
|
||||||
|
op_zlib_new,
|
||||||
|
op_zlib_reset,
|
||||||
|
op_zlib_write,
|
||||||
op_zlib_write_async,
|
op_zlib_write_async,
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
|
@ -55,11 +60,11 @@ class Zlib {
|
||||||
#handle;
|
#handle;
|
||||||
|
|
||||||
constructor(mode) {
|
constructor(mode) {
|
||||||
this.#handle = ops.op_zlib_new(mode);
|
this.#handle = op_zlib_new(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
ops.op_zlib_close(this.#handle);
|
op_zlib_close(this.#handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeSync(
|
writeSync(
|
||||||
|
@ -71,7 +76,7 @@ class Zlib {
|
||||||
out_off,
|
out_off,
|
||||||
out_len,
|
out_len,
|
||||||
) {
|
) {
|
||||||
const err = ops.op_zlib_write(
|
const err = op_zlib_write(
|
||||||
this.#handle,
|
this.#handle,
|
||||||
flush,
|
flush,
|
||||||
input,
|
input,
|
||||||
|
@ -145,7 +150,7 @@ class Zlib {
|
||||||
strategy,
|
strategy,
|
||||||
dictionary,
|
dictionary,
|
||||||
) {
|
) {
|
||||||
const err = ops.op_zlib_init(
|
const err = op_zlib_init(
|
||||||
this.#handle,
|
this.#handle,
|
||||||
level,
|
level,
|
||||||
windowBits,
|
windowBits,
|
||||||
|
@ -164,7 +169,7 @@ class Zlib {
|
||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
const err = ops.op_zlib_reset(this.#handle);
|
const err = op_zlib_reset(this.#handle);
|
||||||
if (err != Z_OK) {
|
if (err != Z_OK) {
|
||||||
this.#error("Failed to reset stream", err);
|
this.#error("Failed to reset stream", err);
|
||||||
}
|
}
|
||||||
|
@ -172,7 +177,7 @@ class Zlib {
|
||||||
|
|
||||||
#error(message, err) {
|
#error(message, err) {
|
||||||
this.onerror(message, err);
|
this.onerror(message, err);
|
||||||
ops.op_zlib_close_if_pending(this.#handle);
|
op_zlib_close_if_pending(this.#handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,14 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core, internals } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_child_ipc_pipe,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
op_npm_process_state,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ChildProcess,
|
ChildProcess,
|
||||||
ChildProcessOptions,
|
ChildProcessOptions,
|
||||||
|
@ -48,9 +56,6 @@ import {
|
||||||
kEmptyObject,
|
kEmptyObject,
|
||||||
} from "ext:deno_node/internal/util.mjs";
|
} from "ext:deno_node/internal/util.mjs";
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
|
||||||
const ops = core.ops;
|
|
||||||
|
|
||||||
const MAX_BUFFER = 1024 * 1024;
|
const MAX_BUFFER = 1024 * 1024;
|
||||||
|
|
||||||
type ForkOptions = ChildProcessOptions;
|
type ForkOptions = ChildProcessOptions;
|
||||||
|
@ -151,8 +156,7 @@ export function fork(
|
||||||
options.shell = false;
|
options.shell = false;
|
||||||
|
|
||||||
Object.assign(options.env ??= {}, {
|
Object.assign(options.env ??= {}, {
|
||||||
DENO_DONT_USE_INTERNAL_NODE_COMPAT_STATE: core.ops
|
DENO_DONT_USE_INTERNAL_NODE_COMPAT_STATE: op_npm_process_state(),
|
||||||
.op_npm_process_state(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return spawn(options.execPath, args, options);
|
return spawn(options.execPath, args, options);
|
||||||
|
@ -824,13 +828,12 @@ export function execFileSync(
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupChildProcessIpcChannel() {
|
function setupChildProcessIpcChannel() {
|
||||||
const fd = ops.op_node_child_ipc_pipe();
|
const fd = op_node_child_ipc_pipe();
|
||||||
if (typeof fd != "number" || fd < 0) return;
|
if (typeof fd != "number" || fd < 0) return;
|
||||||
setupChannel(process, fd);
|
setupChannel(process, fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
globalThis.__bootstrap.internals.__setupChildProcessIpcChannel =
|
internals.__setupChildProcessIpcChannel = setupChildProcessIpcChannel;
|
||||||
setupChildProcessIpcChannel;
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
fork,
|
fork,
|
||||||
|
|
|
@ -3,9 +3,13 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
// import { ReadableStreamPrototype } from "ext:deno_web/06_streams.js";
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_fetch_response_upgrade,
|
||||||
|
op_fetch_send,
|
||||||
|
op_node_http_request,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
const core = globalThis.__bootstrap.core;
|
|
||||||
import { TextEncoder } from "ext:deno_web/08_text_encoding.js";
|
import { TextEncoder } from "ext:deno_web/08_text_encoding.js";
|
||||||
import { setTimeout } from "ext:deno_web/02_timers.js";
|
import { setTimeout } from "ext:deno_web/02_timers.js";
|
||||||
import {
|
import {
|
||||||
|
@ -60,10 +64,6 @@ import { timerId } from "ext:deno_web/03_abort_signal.js";
|
||||||
import { clearTimeout as webClearTimeout } from "ext:deno_web/02_timers.js";
|
import { clearTimeout as webClearTimeout } from "ext:deno_web/02_timers.js";
|
||||||
import { resourceForReadableStream } from "ext:deno_web/06_streams.js";
|
import { resourceForReadableStream } from "ext:deno_web/06_streams.js";
|
||||||
import { TcpConn } from "ext:deno_net/01_net.js";
|
import { TcpConn } from "ext:deno_net/01_net.js";
|
||||||
const {
|
|
||||||
op_fetch_response_upgrade,
|
|
||||||
op_fetch_send,
|
|
||||||
} = core.ensureFastOps();
|
|
||||||
|
|
||||||
enum STATUS_CODES {
|
enum STATUS_CODES {
|
||||||
/** RFC 7231, 6.2.1 */
|
/** RFC 7231, 6.2.1 */
|
||||||
|
@ -606,7 +606,7 @@ class ClientRequest extends OutgoingMessage {
|
||||||
this._bodyWriteRid = resourceForReadableStream(readable);
|
this._bodyWriteRid = resourceForReadableStream(readable);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._req = core.ops.op_node_http_request(
|
this._req = op_node_http_request(
|
||||||
this.method,
|
this.method,
|
||||||
url,
|
url,
|
||||||
headers,
|
headers,
|
||||||
|
|
|
@ -5,6 +5,18 @@
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
import { core } from "ext:core/mod.js";
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_http2_connect,
|
||||||
|
op_http2_client_get_response,
|
||||||
|
op_http2_client_get_response_body_chunk,
|
||||||
|
op_http2_client_get_response_trailers,
|
||||||
|
op_http2_client_request,
|
||||||
|
op_http2_client_reset_stream,
|
||||||
|
op_http2_client_send_data,
|
||||||
|
op_http2_client_send_trailers,
|
||||||
|
op_http2_poll_client_connection,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import { notImplemented, warnNotImplemented } from "ext:deno_node/_utils.ts";
|
import { notImplemented, warnNotImplemented } from "ext:deno_node/_utils.ts";
|
||||||
import { EventEmitter } from "node:events";
|
import { EventEmitter } from "node:events";
|
||||||
import { Buffer } from "node:buffer";
|
import { Buffer } from "node:buffer";
|
||||||
|
@ -43,18 +55,6 @@ import {
|
||||||
} from "ext:deno_node/internal/errors.ts";
|
} from "ext:deno_node/internal/errors.ts";
|
||||||
import { _checkIsHttpToken } from "ext:deno_node/_http_common.ts";
|
import { _checkIsHttpToken } from "ext:deno_node/_http_common.ts";
|
||||||
|
|
||||||
const {
|
|
||||||
op_http2_connect,
|
|
||||||
op_http2_client_get_response,
|
|
||||||
op_http2_client_get_response_body_chunk,
|
|
||||||
op_http2_client_get_response_trailers,
|
|
||||||
op_http2_client_request,
|
|
||||||
op_http2_client_reset_stream,
|
|
||||||
op_http2_client_send_data,
|
|
||||||
op_http2_client_send_trailers,
|
|
||||||
op_http2_poll_client_connection,
|
|
||||||
} = core.ensureFastOps();
|
|
||||||
|
|
||||||
const kSession = Symbol("session");
|
const kSession = Symbol("session");
|
||||||
const kAlpnProtocol = Symbol("alpnProtocol");
|
const kAlpnProtocol = Symbol("alpnProtocol");
|
||||||
const kAuthority = Symbol("authority");
|
const kAuthority = Symbol("authority");
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
|
||||||
import { TextDecoder, TextEncoder } from "ext:deno_web/08_text_encoding.js";
|
import { TextDecoder, TextEncoder } from "ext:deno_web/08_text_encoding.js";
|
||||||
import { codes } from "ext:deno_node/internal/error_codes.ts";
|
import { codes } from "ext:deno_node/internal/error_codes.ts";
|
||||||
import { encodings } from "ext:deno_node/internal_binding/string_decoder.ts";
|
import { encodings } from "ext:deno_node/internal_binding/string_decoder.ts";
|
||||||
|
@ -35,8 +37,6 @@ import {
|
||||||
import { atob, btoa } from "ext:deno_web/05_base64.js";
|
import { atob, btoa } from "ext:deno_web/05_base64.js";
|
||||||
import { Blob } from "ext:deno_web/09_file.js";
|
import { Blob } from "ext:deno_web/09_file.js";
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
|
||||||
|
|
||||||
export { atob, Blob, btoa };
|
export { atob, Blob, btoa };
|
||||||
|
|
||||||
const utf8Encoder = new TextEncoder();
|
const utf8Encoder = new TextEncoder();
|
||||||
|
|
|
@ -7,6 +7,22 @@
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
import { core, internals } from "ext:core/mod.js";
|
import { core, internals } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_ipc_read,
|
||||||
|
op_node_ipc_write,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
import {
|
||||||
|
ArrayIsArray,
|
||||||
|
ArrayPrototypeFilter,
|
||||||
|
ArrayPrototypeJoin,
|
||||||
|
ArrayPrototypePush,
|
||||||
|
ArrayPrototypeSlice,
|
||||||
|
ArrayPrototypeSort,
|
||||||
|
ArrayPrototypeUnshift,
|
||||||
|
ObjectHasOwn,
|
||||||
|
StringPrototypeToUpperCase,
|
||||||
|
} from "ext:deno_node/internal/primordials.mjs";
|
||||||
|
|
||||||
import { assert } from "ext:deno_node/_util/asserts.ts";
|
import { assert } from "ext:deno_node/_util/asserts.ts";
|
||||||
import { EventEmitter } from "node:events";
|
import { EventEmitter } from "node:events";
|
||||||
import { os } from "ext:deno_node/internal_binding/constants.ts";
|
import { os } from "ext:deno_node/internal_binding/constants.ts";
|
||||||
|
@ -30,27 +46,10 @@ import {
|
||||||
validateObject,
|
validateObject,
|
||||||
validateString,
|
validateString,
|
||||||
} from "ext:deno_node/internal/validators.mjs";
|
} from "ext:deno_node/internal/validators.mjs";
|
||||||
import {
|
|
||||||
ArrayIsArray,
|
|
||||||
ArrayPrototypeFilter,
|
|
||||||
ArrayPrototypeJoin,
|
|
||||||
ArrayPrototypePush,
|
|
||||||
ArrayPrototypeSlice,
|
|
||||||
ArrayPrototypeSort,
|
|
||||||
ArrayPrototypeUnshift,
|
|
||||||
ObjectHasOwn,
|
|
||||||
StringPrototypeToUpperCase,
|
|
||||||
} from "ext:deno_node/internal/primordials.mjs";
|
|
||||||
import { kEmptyObject } from "ext:deno_node/internal/util.mjs";
|
import { kEmptyObject } from "ext:deno_node/internal/util.mjs";
|
||||||
import { getValidatedPath } from "ext:deno_node/internal/fs/utils.mjs";
|
import { getValidatedPath } from "ext:deno_node/internal/fs/utils.mjs";
|
||||||
import process from "node:process";
|
import process from "node:process";
|
||||||
|
|
||||||
const core = globalThis.__bootstrap.core;
|
|
||||||
const {
|
|
||||||
op_node_ipc_read,
|
|
||||||
op_node_ipc_write,
|
|
||||||
} = core.ensureFastOps();
|
|
||||||
|
|
||||||
export function mapValues<T, O>(
|
export function mapValues<T, O>(
|
||||||
record: Readonly<Record<string, T>>,
|
record: Readonly<Record<string, T>>,
|
||||||
transformer: (value: T) => O,
|
transformer: (value: T) => O,
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
|
||||||
const { ops } = globalThis.__bootstrap.core;
|
import { isWindows } from "ext:deno_node/_util/os.ts";
|
||||||
const isWindows = ops.op_node_build_os() === "windows";
|
|
||||||
|
|
||||||
// Alphabet chars.
|
// Alphabet chars.
|
||||||
export const CHAR_UPPERCASE_A = 65; /* A */
|
export const CHAR_UPPERCASE_A = 65; /* A */
|
||||||
|
|
|
@ -3,17 +3,18 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_generate_secret,
|
||||||
|
op_node_generate_secret_async,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
|
|
||||||
import {
|
import {
|
||||||
MAX_SIZE as kMaxUint32,
|
MAX_SIZE as kMaxUint32,
|
||||||
} from "ext:deno_node/internal/crypto/_randomBytes.ts";
|
} from "ext:deno_node/internal/crypto/_randomBytes.ts";
|
||||||
import { Buffer } from "node:buffer";
|
import { Buffer } from "node:buffer";
|
||||||
import { isAnyArrayBuffer, isArrayBufferView } from "node:util/types";
|
import { isAnyArrayBuffer, isArrayBufferView } from "node:util/types";
|
||||||
import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
|
import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
|
||||||
const { core } = globalThis.__bootstrap;
|
|
||||||
const { ops } = core;
|
|
||||||
const {
|
|
||||||
op_node_generate_secret_async,
|
|
||||||
} = core.ensureFastOps();
|
|
||||||
|
|
||||||
const kBufferMaxLength = 0x7fffffff;
|
const kBufferMaxLength = 0x7fffffff;
|
||||||
|
|
||||||
|
@ -87,7 +88,7 @@ export function randomFillSync(buf, offset = 0, size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const bytes = new Uint8Array(buf.buffer ? buf.buffer : buf, offset, size);
|
const bytes = new Uint8Array(buf.buffer ? buf.buffer : buf, offset, size);
|
||||||
ops.op_node_generate_secret(bytes);
|
op_node_generate_secret(bytes);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
import { core } from "ext:core/mod.js";
|
import { core } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
|
op_node_random_int,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
export default function randomInt(max: number): number;
|
export default function randomInt(max: number): number;
|
||||||
export default function randomInt(min: number, max: number): number;
|
export default function randomInt(min: number, max: number): number;
|
||||||
|
@ -49,7 +51,7 @@ export default function randomInt(
|
||||||
|
|
||||||
min = Math.ceil(min);
|
min = Math.ceil(min);
|
||||||
max = Math.floor(max);
|
max = Math.floor(max);
|
||||||
const result = ops.op_node_random_int(min, max);
|
const result = op_node_random_int(min, max);
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(null, result);
|
cb(null, result);
|
||||||
|
|
|
@ -4,6 +4,24 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
encode,
|
||||||
|
} = core;
|
||||||
|
const {
|
||||||
|
op_node_cipheriv_encrypt,
|
||||||
|
op_node_cipheriv_final,
|
||||||
|
op_node_cipheriv_set_aad,
|
||||||
|
op_node_create_cipheriv,
|
||||||
|
op_node_create_decipheriv,
|
||||||
|
op_node_decipheriv_decrypt,
|
||||||
|
op_node_decipheriv_final,
|
||||||
|
op_node_decipheriv_set_aad,
|
||||||
|
op_node_private_decrypt,
|
||||||
|
op_node_private_encrypt,
|
||||||
|
op_node_public_encrypt,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
|
import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
|
||||||
import {
|
import {
|
||||||
validateInt32,
|
validateInt32,
|
||||||
|
@ -35,8 +53,6 @@ export function isStringOrBuffer(val) {
|
||||||
Buffer.isBuffer(val);
|
Buffer.isBuffer(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { ops, encode } = globalThis.__bootstrap.core;
|
|
||||||
|
|
||||||
const NO_TAG = new Uint8Array();
|
const NO_TAG = new Uint8Array();
|
||||||
|
|
||||||
export type CipherCCMTypes =
|
export type CipherCCMTypes =
|
||||||
|
@ -168,7 +184,7 @@ export class Cipheriv extends Transform implements Cipher {
|
||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
this.#cache = new BlockModeCache(false);
|
this.#cache = new BlockModeCache(false);
|
||||||
this.#context = ops.op_node_create_cipheriv(cipher, toU8(key), toU8(iv));
|
this.#context = op_node_create_cipheriv(cipher, toU8(key), toU8(iv));
|
||||||
this.#needsBlockCache =
|
this.#needsBlockCache =
|
||||||
!(cipher == "aes-128-gcm" || cipher == "aes-256-gcm");
|
!(cipher == "aes-128-gcm" || cipher == "aes-256-gcm");
|
||||||
if (this.#context == 0) {
|
if (this.#context == 0) {
|
||||||
|
@ -178,7 +194,7 @@ export class Cipheriv extends Transform implements Cipher {
|
||||||
|
|
||||||
final(encoding: string = getDefaultEncoding()): Buffer | string {
|
final(encoding: string = getDefaultEncoding()): Buffer | string {
|
||||||
const buf = new Buffer(16);
|
const buf = new Buffer(16);
|
||||||
const maybeTag = ops.op_node_cipheriv_final(
|
const maybeTag = op_node_cipheriv_final(
|
||||||
this.#context,
|
this.#context,
|
||||||
this.#cache.cache,
|
this.#cache.cache,
|
||||||
buf,
|
buf,
|
||||||
|
@ -200,7 +216,7 @@ export class Cipheriv extends Transform implements Cipher {
|
||||||
plaintextLength: number;
|
plaintextLength: number;
|
||||||
},
|
},
|
||||||
): this {
|
): this {
|
||||||
ops.op_node_cipheriv_set_aad(this.#context, buffer);
|
op_node_cipheriv_set_aad(this.#context, buffer);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +239,7 @@ export class Cipheriv extends Transform implements Cipher {
|
||||||
let output;
|
let output;
|
||||||
if (!this.#needsBlockCache) {
|
if (!this.#needsBlockCache) {
|
||||||
output = Buffer.allocUnsafe(buf.length);
|
output = Buffer.allocUnsafe(buf.length);
|
||||||
ops.op_node_cipheriv_encrypt(this.#context, buf, output);
|
op_node_cipheriv_encrypt(this.#context, buf, output);
|
||||||
return outputEncoding === "buffer"
|
return outputEncoding === "buffer"
|
||||||
? output
|
? output
|
||||||
: output.toString(outputEncoding);
|
: output.toString(outputEncoding);
|
||||||
|
@ -236,7 +252,7 @@ export class Cipheriv extends Transform implements Cipher {
|
||||||
output = Buffer.alloc(0);
|
output = Buffer.alloc(0);
|
||||||
} else {
|
} else {
|
||||||
output = Buffer.allocUnsafe(input.length);
|
output = Buffer.allocUnsafe(input.length);
|
||||||
ops.op_node_cipheriv_encrypt(this.#context, input, output);
|
op_node_cipheriv_encrypt(this.#context, input, output);
|
||||||
}
|
}
|
||||||
return outputEncoding === "buffer"
|
return outputEncoding === "buffer"
|
||||||
? output
|
? output
|
||||||
|
@ -311,7 +327,7 @@ export class Decipheriv extends Transform implements Cipher {
|
||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
this.#cache = new BlockModeCache(true);
|
this.#cache = new BlockModeCache(true);
|
||||||
this.#context = ops.op_node_create_decipheriv(cipher, toU8(key), toU8(iv));
|
this.#context = op_node_create_decipheriv(cipher, toU8(key), toU8(iv));
|
||||||
this.#needsBlockCache =
|
this.#needsBlockCache =
|
||||||
!(cipher == "aes-128-gcm" || cipher == "aes-256-gcm");
|
!(cipher == "aes-128-gcm" || cipher == "aes-256-gcm");
|
||||||
if (this.#context == 0) {
|
if (this.#context == 0) {
|
||||||
|
@ -321,7 +337,7 @@ export class Decipheriv extends Transform implements Cipher {
|
||||||
|
|
||||||
final(encoding: string = getDefaultEncoding()): Buffer | string {
|
final(encoding: string = getDefaultEncoding()): Buffer | string {
|
||||||
let buf = new Buffer(16);
|
let buf = new Buffer(16);
|
||||||
ops.op_node_decipheriv_final(
|
op_node_decipheriv_final(
|
||||||
this.#context,
|
this.#context,
|
||||||
this.#cache.cache,
|
this.#cache.cache,
|
||||||
buf,
|
buf,
|
||||||
|
@ -342,7 +358,7 @@ export class Decipheriv extends Transform implements Cipher {
|
||||||
plaintextLength: number;
|
plaintextLength: number;
|
||||||
},
|
},
|
||||||
): this {
|
): this {
|
||||||
ops.op_node_decipheriv_set_aad(this.#context, buffer);
|
op_node_decipheriv_set_aad(this.#context, buffer);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,7 +385,7 @@ export class Decipheriv extends Transform implements Cipher {
|
||||||
let output;
|
let output;
|
||||||
if (!this.#needsBlockCache) {
|
if (!this.#needsBlockCache) {
|
||||||
output = Buffer.allocUnsafe(buf.length);
|
output = Buffer.allocUnsafe(buf.length);
|
||||||
ops.op_node_decipheriv_decrypt(this.#context, buf, output);
|
op_node_decipheriv_decrypt(this.#context, buf, output);
|
||||||
return outputEncoding === "buffer"
|
return outputEncoding === "buffer"
|
||||||
? output
|
? output
|
||||||
: output.toString(outputEncoding);
|
: output.toString(outputEncoding);
|
||||||
|
@ -381,7 +397,7 @@ export class Decipheriv extends Transform implements Cipher {
|
||||||
output = Buffer.alloc(0);
|
output = Buffer.alloc(0);
|
||||||
} else {
|
} else {
|
||||||
output = new Buffer(input.length);
|
output = new Buffer(input.length);
|
||||||
ops.op_node_decipheriv_decrypt(this.#context, input, output);
|
op_node_decipheriv_decrypt(this.#context, input, output);
|
||||||
}
|
}
|
||||||
return outputEncoding === "buffer"
|
return outputEncoding === "buffer"
|
||||||
? output
|
? output
|
||||||
|
@ -432,7 +448,7 @@ export function privateEncrypt(
|
||||||
const padding = privateKey.padding || 1;
|
const padding = privateKey.padding || 1;
|
||||||
|
|
||||||
buffer = getArrayBufferOrView(buffer, "buffer");
|
buffer = getArrayBufferOrView(buffer, "buffer");
|
||||||
return ops.op_node_private_encrypt(data, buffer, padding);
|
return op_node_private_encrypt(data, buffer, padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function privateDecrypt(
|
export function privateDecrypt(
|
||||||
|
@ -443,7 +459,7 @@ export function privateDecrypt(
|
||||||
const padding = privateKey.padding || 1;
|
const padding = privateKey.padding || 1;
|
||||||
|
|
||||||
buffer = getArrayBufferOrView(buffer, "buffer");
|
buffer = getArrayBufferOrView(buffer, "buffer");
|
||||||
return ops.op_node_private_decrypt(data, buffer, padding);
|
return op_node_private_decrypt(data, buffer, padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function publicEncrypt(
|
export function publicEncrypt(
|
||||||
|
@ -454,7 +470,7 @@ export function publicEncrypt(
|
||||||
const padding = publicKey.padding || 1;
|
const padding = publicKey.padding || 1;
|
||||||
|
|
||||||
buffer = getArrayBufferOrView(buffer, "buffer");
|
buffer = getArrayBufferOrView(buffer, "buffer");
|
||||||
return ops.op_node_public_encrypt(data, buffer, padding);
|
return op_node_public_encrypt(data, buffer, padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function prepareKey(key) {
|
export function prepareKey(key) {
|
||||||
|
|
|
@ -4,6 +4,18 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_dh_compute_secret,
|
||||||
|
op_node_dh_generate2,
|
||||||
|
op_node_ecdh_compute_secret,
|
||||||
|
op_node_ecdh_generate_keys,
|
||||||
|
op_node_ecdh_compute_public_key,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
op_node_gen_prime,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
|
|
||||||
import { notImplemented } from "ext:deno_node/_utils.ts";
|
import { notImplemented } from "ext:deno_node/_utils.ts";
|
||||||
import {
|
import {
|
||||||
isAnyArrayBuffer,
|
isAnyArrayBuffer,
|
||||||
|
@ -33,8 +45,6 @@ import type {
|
||||||
import { KeyObject } from "ext:deno_node/internal/crypto/keys.ts";
|
import { KeyObject } from "ext:deno_node/internal/crypto/keys.ts";
|
||||||
import type { BufferEncoding } from "ext:deno_node/_global.d.ts";
|
import type { BufferEncoding } from "ext:deno_node/_global.d.ts";
|
||||||
|
|
||||||
const { ops } = Deno.core;
|
|
||||||
|
|
||||||
const DH_GENERATOR = 2;
|
const DH_GENERATOR = 2;
|
||||||
|
|
||||||
export class DiffieHellman {
|
export class DiffieHellman {
|
||||||
|
@ -92,7 +102,7 @@ export class DiffieHellman {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#prime = Buffer.from(
|
this.#prime = Buffer.from(
|
||||||
ops.op_node_gen_prime(this.#primeLength).buffer,
|
op_node_gen_prime(this.#primeLength).buffer,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +183,7 @@ export class DiffieHellman {
|
||||||
buf = Buffer.from(otherPublicKey.buffer);
|
buf = Buffer.from(otherPublicKey.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
const sharedSecret = ops.op_node_dh_compute_secret(
|
const sharedSecret = op_node_dh_compute_secret(
|
||||||
this.#prime,
|
this.#prime,
|
||||||
this.#privateKey,
|
this.#privateKey,
|
||||||
buf,
|
buf,
|
||||||
|
@ -190,7 +200,7 @@ export class DiffieHellman {
|
||||||
generateKeys(encoding: BinaryToTextEncoding): string;
|
generateKeys(encoding: BinaryToTextEncoding): string;
|
||||||
generateKeys(_encoding?: BinaryToTextEncoding): Buffer | string {
|
generateKeys(_encoding?: BinaryToTextEncoding): Buffer | string {
|
||||||
const generator = this.#checkGenerator();
|
const generator = this.#checkGenerator();
|
||||||
const [privateKey, publicKey] = ops.op_node_dh_generate2(
|
const [privateKey, publicKey] = op_node_dh_generate2(
|
||||||
this.#prime,
|
this.#prime,
|
||||||
this.#primeLength ?? 0,
|
this.#primeLength ?? 0,
|
||||||
generator,
|
generator,
|
||||||
|
@ -1215,7 +1225,7 @@ export class ECDH {
|
||||||
): Buffer | string {
|
): Buffer | string {
|
||||||
const secretBuf = Buffer.alloc(this.#curve.sharedSecretSize);
|
const secretBuf = Buffer.alloc(this.#curve.sharedSecretSize);
|
||||||
|
|
||||||
ops.op_node_ecdh_compute_secret(
|
op_node_ecdh_compute_secret(
|
||||||
this.#curve.name,
|
this.#curve.name,
|
||||||
this.#privbuf,
|
this.#privbuf,
|
||||||
otherPublicKey,
|
otherPublicKey,
|
||||||
|
@ -1231,7 +1241,7 @@ export class ECDH {
|
||||||
encoding?: BinaryToTextEncoding,
|
encoding?: BinaryToTextEncoding,
|
||||||
_format?: ECDHKeyFormat,
|
_format?: ECDHKeyFormat,
|
||||||
): Buffer | string {
|
): Buffer | string {
|
||||||
ops.op_node_ecdh_generate_keys(
|
op_node_ecdh_generate_keys(
|
||||||
this.#curve.name,
|
this.#curve.name,
|
||||||
this.#pubbuf,
|
this.#pubbuf,
|
||||||
this.#privbuf,
|
this.#privbuf,
|
||||||
|
@ -1273,7 +1283,7 @@ export class ECDH {
|
||||||
this.#privbuf = privateKey;
|
this.#privbuf = privateKey;
|
||||||
this.#pubbuf = Buffer.alloc(this.#curve.publicKeySize);
|
this.#pubbuf = Buffer.alloc(this.#curve.publicKeySize);
|
||||||
|
|
||||||
ops.op_node_ecdh_compute_public_key(
|
op_node_ecdh_compute_public_key(
|
||||||
this.#curve.name,
|
this.#curve.name,
|
||||||
this.#privbuf,
|
this.#privbuf,
|
||||||
this.#pubbuf,
|
this.#pubbuf,
|
||||||
|
|
|
@ -4,6 +4,17 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_create_hash,
|
||||||
|
op_node_get_hashes,
|
||||||
|
op_node_hash_clone,
|
||||||
|
op_node_hash_digest_hex,
|
||||||
|
op_node_hash_digest,
|
||||||
|
op_node_hash_update_str,
|
||||||
|
op_node_hash_update,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import { TextEncoder } from "ext:deno_web/08_text_encoding.js";
|
import { TextEncoder } from "ext:deno_web/08_text_encoding.js";
|
||||||
import { Buffer } from "node:buffer";
|
import { Buffer } from "node:buffer";
|
||||||
import { Transform } from "node:stream";
|
import { Transform } from "node:stream";
|
||||||
|
@ -23,8 +34,6 @@ import {
|
||||||
prepareSecretKey,
|
prepareSecretKey,
|
||||||
} from "ext:deno_node/internal/crypto/keys.ts";
|
} from "ext:deno_node/internal/crypto/keys.ts";
|
||||||
|
|
||||||
const { ops } = globalThis.__bootstrap.core;
|
|
||||||
|
|
||||||
// TODO(@littledivy): Use Result<T, E> instead of boolean when
|
// TODO(@littledivy): Use Result<T, E> instead of boolean when
|
||||||
// https://bugs.chromium.org/p/v8/issues/detail?id=13600 is fixed.
|
// https://bugs.chromium.org/p/v8/issues/detail?id=13600 is fixed.
|
||||||
function unwrapErr(ok: boolean) {
|
function unwrapErr(ok: boolean) {
|
||||||
|
@ -65,7 +74,7 @@ export class Hash extends Transform {
|
||||||
) {
|
) {
|
||||||
super({
|
super({
|
||||||
transform(chunk: string, _encoding: string, callback: () => void) {
|
transform(chunk: string, _encoding: string, callback: () => void) {
|
||||||
ops.op_node_hash_update(context, coerceToBytes(chunk));
|
op_node_hash_update(context, coerceToBytes(chunk));
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
flush(callback: () => void) {
|
flush(callback: () => void) {
|
||||||
|
@ -75,7 +84,7 @@ export class Hash extends Transform {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof algorithm === "string") {
|
if (typeof algorithm === "string") {
|
||||||
this.#context = ops.op_node_create_hash(
|
this.#context = op_node_create_hash(
|
||||||
algorithm.toLowerCase(),
|
algorithm.toLowerCase(),
|
||||||
);
|
);
|
||||||
if (this.#context === 0) {
|
if (this.#context === 0) {
|
||||||
|
@ -89,7 +98,7 @@ export class Hash extends Transform {
|
||||||
}
|
}
|
||||||
|
|
||||||
copy(): Hash {
|
copy(): Hash {
|
||||||
return new Hash(ops.op_node_clone_hash(this.#context));
|
return new Hash(op_node_hash_clone(this.#context));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,9 +106,9 @@ export class Hash extends Transform {
|
||||||
*/
|
*/
|
||||||
update(data: string | ArrayBuffer, _encoding?: string): this {
|
update(data: string | ArrayBuffer, _encoding?: string): this {
|
||||||
if (typeof data === "string") {
|
if (typeof data === "string") {
|
||||||
unwrapErr(ops.op_node_hash_update_str(this.#context, data));
|
unwrapErr(op_node_hash_update_str(this.#context, data));
|
||||||
} else {
|
} else {
|
||||||
unwrapErr(ops.op_node_hash_update(this.#context, coerceToBytes(data)));
|
unwrapErr(op_node_hash_update(this.#context, coerceToBytes(data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@ -114,10 +123,10 @@ export class Hash extends Transform {
|
||||||
*/
|
*/
|
||||||
digest(encoding?: string): Buffer | string {
|
digest(encoding?: string): Buffer | string {
|
||||||
if (encoding === "hex") {
|
if (encoding === "hex") {
|
||||||
return ops.op_node_hash_digest_hex(this.#context);
|
return op_node_hash_digest_hex(this.#context);
|
||||||
}
|
}
|
||||||
|
|
||||||
const digest = ops.op_node_hash_digest(this.#context);
|
const digest = op_node_hash_digest(this.#context);
|
||||||
if (encoding === undefined) {
|
if (encoding === undefined) {
|
||||||
return Buffer.from(digest);
|
return Buffer.from(digest);
|
||||||
}
|
}
|
||||||
|
@ -237,7 +246,7 @@ export function createHash(algorithm: string, opts?: TransformOptions) {
|
||||||
* @returns Array of hash algorithm names.
|
* @returns Array of hash algorithm names.
|
||||||
*/
|
*/
|
||||||
export function getHashes() {
|
export function getHashes() {
|
||||||
return ops.op_node_get_hashes();
|
return op_node_get_hashes();
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_hkdf,
|
||||||
|
op_node_hkdf_async,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import {
|
import {
|
||||||
validateFunction,
|
validateFunction,
|
||||||
validateInteger,
|
validateInteger,
|
||||||
|
@ -31,12 +37,6 @@ import {
|
||||||
isArrayBufferView,
|
isArrayBufferView,
|
||||||
} from "ext:deno_node/internal/util/types.ts";
|
} from "ext:deno_node/internal/util/types.ts";
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
|
||||||
const { ops } = core;
|
|
||||||
const {
|
|
||||||
op_node_hkdf_async,
|
|
||||||
} = core.ensureFastOps();
|
|
||||||
|
|
||||||
const validateParameters = hideStackFrames((hash, key, salt, info, length) => {
|
const validateParameters = hideStackFrames((hash, key, salt, info, length) => {
|
||||||
validateString(hash, "digest");
|
validateString(hash, "digest");
|
||||||
key = new Uint8Array(prepareKey(key));
|
key = new Uint8Array(prepareKey(key));
|
||||||
|
@ -134,7 +134,7 @@ export function hkdfSync(
|
||||||
|
|
||||||
const okm = new Uint8Array(length);
|
const okm = new Uint8Array(length);
|
||||||
try {
|
try {
|
||||||
ops.op_node_hkdf(hash, key, salt, info, okm);
|
op_node_hkdf(hash, key, salt, info, okm);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new ERR_CRYPTO_INVALID_DIGEST(e);
|
throw new ERR_CRYPTO_INVALID_DIGEST(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,18 +29,27 @@ import {
|
||||||
import { Buffer } from "node:buffer";
|
import { Buffer } from "node:buffer";
|
||||||
import { KeyFormat, KeyType } from "ext:deno_node/internal/crypto/types.ts";
|
import { KeyFormat, KeyType } from "ext:deno_node/internal/crypto/types.ts";
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
import { core } from "ext:core/mod.js";
|
||||||
const { ops } = core;
|
|
||||||
const {
|
const {
|
||||||
|
op_node_dh_generate,
|
||||||
op_node_dh_generate_async,
|
op_node_dh_generate_async,
|
||||||
|
op_node_dh_generate_group,
|
||||||
op_node_dh_generate_group_async,
|
op_node_dh_generate_group_async,
|
||||||
|
op_node_dsa_generate,
|
||||||
op_node_dsa_generate_async,
|
op_node_dsa_generate_async,
|
||||||
|
op_node_ec_generate,
|
||||||
op_node_ec_generate_async,
|
op_node_ec_generate_async,
|
||||||
op_node_generate_rsa_async,
|
op_node_ed25519_generate,
|
||||||
op_node_generate_secret_async,
|
|
||||||
op_node_ed25519_generate_async,
|
op_node_ed25519_generate_async,
|
||||||
|
op_node_generate_rsa,
|
||||||
|
op_node_generate_rsa_async,
|
||||||
|
op_node_x25519_generate,
|
||||||
op_node_x25519_generate_async,
|
op_node_x25519_generate_async,
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
op_node_generate_secret,
|
||||||
|
op_node_generate_secret_async,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
|
|
||||||
function validateGenerateKey(
|
function validateGenerateKey(
|
||||||
type: "hmac" | "aes",
|
type: "hmac" | "aes",
|
||||||
|
@ -75,7 +84,7 @@ export function generateKeySync(
|
||||||
const { length } = options;
|
const { length } = options;
|
||||||
|
|
||||||
const key = new Uint8Array(Math.floor(length / 8));
|
const key = new Uint8Array(Math.floor(length / 8));
|
||||||
ops.op_node_generate_secret(key);
|
op_node_generate_secret(key);
|
||||||
|
|
||||||
return new SecretKeyObject(setOwnedKey(key));
|
return new SecretKeyObject(setOwnedKey(key));
|
||||||
}
|
}
|
||||||
|
@ -804,7 +813,7 @@ function createJob(mode, type, options) {
|
||||||
|
|
||||||
if (type === "rsa") {
|
if (type === "rsa") {
|
||||||
if (mode === kSync) {
|
if (mode === kSync) {
|
||||||
return ops.op_node_generate_rsa(
|
return op_node_generate_rsa(
|
||||||
modulusLength,
|
modulusLength,
|
||||||
publicExponent,
|
publicExponent,
|
||||||
);
|
);
|
||||||
|
@ -859,7 +868,7 @@ function createJob(mode, type, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode === kSync) {
|
if (mode === kSync) {
|
||||||
return ops.op_node_generate_rsa(
|
return op_node_generate_rsa(
|
||||||
modulusLength,
|
modulusLength,
|
||||||
publicExponent,
|
publicExponent,
|
||||||
);
|
);
|
||||||
|
@ -883,7 +892,7 @@ function createJob(mode, type, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode === kSync) {
|
if (mode === kSync) {
|
||||||
return ops.op_node_dsa_generate(modulusLength, divisorLength);
|
return op_node_dsa_generate(modulusLength, divisorLength);
|
||||||
}
|
}
|
||||||
return op_node_dsa_generate_async(
|
return op_node_dsa_generate_async(
|
||||||
modulusLength,
|
modulusLength,
|
||||||
|
@ -905,20 +914,20 @@ function createJob(mode, type, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode === kSync) {
|
if (mode === kSync) {
|
||||||
return ops.op_node_ec_generate(namedCurve);
|
return op_node_ec_generate(namedCurve);
|
||||||
} else {
|
} else {
|
||||||
return op_node_ec_generate_async(namedCurve);
|
return op_node_ec_generate_async(namedCurve);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "ed25519": {
|
case "ed25519": {
|
||||||
if (mode === kSync) {
|
if (mode === kSync) {
|
||||||
return ops.op_node_ed25519_generate();
|
return op_node_ed25519_generate();
|
||||||
}
|
}
|
||||||
return op_node_ed25519_generate_async();
|
return op_node_ed25519_generate_async();
|
||||||
}
|
}
|
||||||
case "x25519": {
|
case "x25519": {
|
||||||
if (mode === kSync) {
|
if (mode === kSync) {
|
||||||
return ops.op_node_x25519_generate();
|
return op_node_x25519_generate();
|
||||||
}
|
}
|
||||||
return op_node_x25519_generate_async();
|
return op_node_x25519_generate_async();
|
||||||
}
|
}
|
||||||
|
@ -944,7 +953,7 @@ function createJob(mode, type, options) {
|
||||||
validateString(group, "options.group");
|
validateString(group, "options.group");
|
||||||
|
|
||||||
if (mode === kSync) {
|
if (mode === kSync) {
|
||||||
return ops.op_node_dh_generate_group(group);
|
return op_node_dh_generate_group(group);
|
||||||
} else {
|
} else {
|
||||||
return op_node_dh_generate_group_async(group);
|
return op_node_dh_generate_group_async(group);
|
||||||
}
|
}
|
||||||
|
@ -971,7 +980,7 @@ function createJob(mode, type, options) {
|
||||||
const g = generator == null ? 2 : generator;
|
const g = generator == null ? 2 : generator;
|
||||||
|
|
||||||
if (mode === kSync) {
|
if (mode === kSync) {
|
||||||
return ops.op_node_dh_generate(prime, primeLength ?? 0, g);
|
return op_node_dh_generate(prime, primeLength ?? 0, g);
|
||||||
} else {
|
} else {
|
||||||
return op_node_dh_generate_async(
|
return op_node_dh_generate_async(
|
||||||
prime,
|
prime,
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_create_private_key,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import {
|
import {
|
||||||
kHandle,
|
kHandle,
|
||||||
kKeyObject,
|
kKeyObject,
|
||||||
|
@ -39,9 +44,6 @@ import {
|
||||||
forgivingBase64UrlEncode as encodeToBase64Url,
|
forgivingBase64UrlEncode as encodeToBase64Url,
|
||||||
} from "ext:deno_web/00_infra.js";
|
} from "ext:deno_web/00_infra.js";
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
|
||||||
const { ops } = core;
|
|
||||||
|
|
||||||
export const getArrayBufferOrView = hideStackFrames(
|
export const getArrayBufferOrView = hideStackFrames(
|
||||||
(
|
(
|
||||||
buffer,
|
buffer,
|
||||||
|
@ -234,7 +236,7 @@ export function createPrivateKey(
|
||||||
key: PrivateKeyInput | string | Buffer | JsonWebKeyInput,
|
key: PrivateKeyInput | string | Buffer | JsonWebKeyInput,
|
||||||
): PrivateKeyObject {
|
): PrivateKeyObject {
|
||||||
const { data, format, type } = prepareAsymmetricKey(key);
|
const { data, format, type } = prepareAsymmetricKey(key);
|
||||||
const details = ops.op_node_create_private_key(data, format, type);
|
const details = op_node_create_private_key(data, format, type);
|
||||||
const handle = setOwnedKey(copyBuffer(data));
|
const handle = setOwnedKey(copyBuffer(data));
|
||||||
return new PrivateKeyObject(handle, details);
|
return new PrivateKeyObject(handle, details);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,15 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_pbkdf2,
|
||||||
|
op_node_pbkdf2_async,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import { Buffer } from "node:buffer";
|
import { Buffer } from "node:buffer";
|
||||||
import { HASH_DATA } from "ext:deno_node/internal/crypto/types.ts";
|
import { HASH_DATA } from "ext:deno_node/internal/crypto/types.ts";
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
|
||||||
const { ops } = core;
|
|
||||||
const { op_node_pbkdf2_async } = core.ensureFastOps();
|
|
||||||
|
|
||||||
export const MAX_ALLOC = Math.pow(2, 30) - 1;
|
export const MAX_ALLOC = Math.pow(2, 30) - 1;
|
||||||
|
|
||||||
export type NormalizedAlgorithms =
|
export type NormalizedAlgorithms =
|
||||||
|
@ -51,7 +53,7 @@ export function pbkdf2Sync(
|
||||||
}
|
}
|
||||||
|
|
||||||
const DK = new Uint8Array(keylen);
|
const DK = new Uint8Array(keylen);
|
||||||
if (!ops.op_node_pbkdf2(password, salt, iterations, digest, DK)) {
|
if (!op_node_pbkdf2(password, salt, iterations, digest, DK)) {
|
||||||
throw new Error("Invalid digest");
|
throw new Error("Invalid digest");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,22 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_check_prime,
|
||||||
|
op_node_check_prime_async,
|
||||||
|
op_node_check_prime_bytes,
|
||||||
|
op_node_check_prime_bytes_async,
|
||||||
|
op_node_gen_prime_async,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
op_node_gen_prime,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
|
const {
|
||||||
|
StringPrototypePadStart,
|
||||||
|
StringPrototypeToString,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
import { notImplemented } from "ext:deno_node/_utils.ts";
|
import { notImplemented } from "ext:deno_node/_utils.ts";
|
||||||
import randomBytes from "ext:deno_node/internal/crypto/_randomBytes.ts";
|
import randomBytes from "ext:deno_node/internal/crypto/_randomBytes.ts";
|
||||||
import randomFill, {
|
import randomFill, {
|
||||||
|
@ -32,17 +48,6 @@ export {
|
||||||
} from "ext:deno_node/internal/crypto/_randomFill.mjs";
|
} from "ext:deno_node/internal/crypto/_randomFill.mjs";
|
||||||
export { default as randomInt } from "ext:deno_node/internal/crypto/_randomInt.ts";
|
export { default as randomInt } from "ext:deno_node/internal/crypto/_randomInt.ts";
|
||||||
|
|
||||||
import { primordials } from "ext:core/mod.js";
|
|
||||||
const { StringPrototypePadStart, StringPrototypeToString } = primordials;
|
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
|
||||||
const { ops } = core;
|
|
||||||
const {
|
|
||||||
op_node_gen_prime_async,
|
|
||||||
op_node_check_prime_bytes_async,
|
|
||||||
op_node_check_prime_async,
|
|
||||||
} = Deno.core.ensureFastOps();
|
|
||||||
|
|
||||||
export type LargeNumberLike =
|
export type LargeNumberLike =
|
||||||
| ArrayBufferView
|
| ArrayBufferView
|
||||||
| SharedArrayBuffer
|
| SharedArrayBuffer
|
||||||
|
@ -129,7 +134,7 @@ export function checkPrimeSync(
|
||||||
validateInt32(checks, "options.checks", 0);
|
validateInt32(checks, "options.checks", 0);
|
||||||
|
|
||||||
if (typeof candidate === "bigint") {
|
if (typeof candidate === "bigint") {
|
||||||
return ops.op_node_check_prime(candidate, checks);
|
return op_node_check_prime(candidate, checks);
|
||||||
} else if (!isAnyArrayBuffer(candidate) && !isArrayBufferView(candidate)) {
|
} else if (!isAnyArrayBuffer(candidate) && !isArrayBufferView(candidate)) {
|
||||||
throw new ERR_INVALID_ARG_TYPE(
|
throw new ERR_INVALID_ARG_TYPE(
|
||||||
"candidate",
|
"candidate",
|
||||||
|
@ -144,7 +149,7 @@ export function checkPrimeSync(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ops.op_node_check_prime_bytes(candidate, checks);
|
return op_node_check_prime_bytes(candidate, checks);
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GeneratePrimeOptions {
|
export interface GeneratePrimeOptions {
|
||||||
|
@ -186,7 +191,7 @@ export function generatePrimeSync(
|
||||||
bigint,
|
bigint,
|
||||||
} = validateRandomPrimeJob(size, options);
|
} = validateRandomPrimeJob(size, options);
|
||||||
|
|
||||||
const prime = ops.op_node_gen_prime(size);
|
const prime = op_node_gen_prime(size);
|
||||||
if (bigint) return arrayBufferToUnsignedBigInt(prime.buffer);
|
if (bigint) return arrayBufferToUnsignedBigInt(prime.buffer);
|
||||||
return prime.buffer;
|
return prime.buffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,9 @@ SOFTWARE.
|
||||||
import { Buffer } from "node:buffer";
|
import { Buffer } from "node:buffer";
|
||||||
import { HASH_DATA } from "ext:deno_node/internal/crypto/types.ts";
|
import { HASH_DATA } from "ext:deno_node/internal/crypto/types.ts";
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
import { core } from "ext:core/mod.js";
|
||||||
const { ops } = core;
|
|
||||||
const {
|
const {
|
||||||
|
op_node_scrypt_sync,
|
||||||
op_node_scrypt_async,
|
op_node_scrypt_async,
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ export function scryptSync(
|
||||||
}
|
}
|
||||||
|
|
||||||
const buf = Buffer.alloc(keylen);
|
const buf = Buffer.alloc(keylen);
|
||||||
ops.op_node_scrypt_sync(
|
op_node_scrypt_sync(
|
||||||
password,
|
password,
|
||||||
salt,
|
salt,
|
||||||
keylen,
|
keylen,
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_sign,
|
||||||
|
op_node_verify,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import { notImplemented } from "ext:deno_node/_utils.ts";
|
import { notImplemented } from "ext:deno_node/_utils.ts";
|
||||||
import {
|
import {
|
||||||
validateFunction,
|
validateFunction,
|
||||||
|
@ -28,9 +34,6 @@ import { KeyFormat, KeyType } from "ext:deno_node/internal/crypto/types.ts";
|
||||||
import { isArrayBufferView } from "ext:deno_node/internal/util/types.ts";
|
import { isArrayBufferView } from "ext:deno_node/internal/util/types.ts";
|
||||||
import { ERR_CRYPTO_SIGN_KEY_REQUIRED } from "ext:deno_node/internal/errors.ts";
|
import { ERR_CRYPTO_SIGN_KEY_REQUIRED } from "ext:deno_node/internal/errors.ts";
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
|
||||||
const { ops } = core;
|
|
||||||
|
|
||||||
export type DSAEncoding = "der" | "ieee-p1363";
|
export type DSAEncoding = "der" | "ieee-p1363";
|
||||||
|
|
||||||
export interface SigningOptions {
|
export interface SigningOptions {
|
||||||
|
@ -81,7 +84,7 @@ export class SignImpl extends Writable {
|
||||||
encoding?: BinaryToTextEncoding,
|
encoding?: BinaryToTextEncoding,
|
||||||
): Buffer | string {
|
): Buffer | string {
|
||||||
const { data, format, type } = prepareAsymmetricKey(privateKey);
|
const { data, format, type } = prepareAsymmetricKey(privateKey);
|
||||||
const ret = Buffer.from(ops.op_node_sign(
|
const ret = Buffer.from(op_node_sign(
|
||||||
this.hash.digest(),
|
this.hash.digest(),
|
||||||
this.#digestType,
|
this.#digestType,
|
||||||
data!,
|
data!,
|
||||||
|
@ -157,7 +160,7 @@ export class VerifyImpl extends Writable {
|
||||||
"crypto.Verify.prototype.verify with non BinaryLike input",
|
"crypto.Verify.prototype.verify with non BinaryLike input",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return ops.op_node_verify(
|
return op_node_verify(
|
||||||
this.hash.digest(),
|
this.hash.digest(),
|
||||||
this.#digestType,
|
this.#digestType,
|
||||||
keyData!,
|
keyData!,
|
||||||
|
|
|
@ -4,6 +4,22 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_x509_ca,
|
||||||
|
op_node_x509_check_email,
|
||||||
|
op_node_x509_fingerprint,
|
||||||
|
op_node_x509_fingerprint256,
|
||||||
|
op_node_x509_fingerprint512,
|
||||||
|
op_node_x509_get_issuer,
|
||||||
|
op_node_x509_get_serial_number,
|
||||||
|
op_node_x509_get_subject,
|
||||||
|
op_node_x509_get_valid_from,
|
||||||
|
op_node_x509_get_valid_to,
|
||||||
|
op_node_x509_key_usage,
|
||||||
|
op_node_x509_parse,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import { KeyObject } from "ext:deno_node/internal/crypto/keys.ts";
|
import { KeyObject } from "ext:deno_node/internal/crypto/keys.ts";
|
||||||
import { Buffer } from "node:buffer";
|
import { Buffer } from "node:buffer";
|
||||||
import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
|
import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
|
||||||
|
@ -12,8 +28,6 @@ import { validateString } from "ext:deno_node/internal/validators.mjs";
|
||||||
import { notImplemented } from "ext:deno_node/_utils.ts";
|
import { notImplemented } from "ext:deno_node/_utils.ts";
|
||||||
import { BinaryLike } from "ext:deno_node/internal/crypto/types.ts";
|
import { BinaryLike } from "ext:deno_node/internal/crypto/types.ts";
|
||||||
|
|
||||||
const { ops } = globalThis.__bootstrap.core;
|
|
||||||
|
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
export type PeerCertificate = any;
|
export type PeerCertificate = any;
|
||||||
|
|
||||||
|
@ -56,11 +70,11 @@ export class X509Certificate {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#handle = ops.op_node_x509_parse(buffer);
|
this.#handle = op_node_x509_parse(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
get ca(): boolean {
|
get ca(): boolean {
|
||||||
return ops.op_node_x509_ca(this.#handle);
|
return op_node_x509_ca(this.#handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkEmail(
|
checkEmail(
|
||||||
|
@ -68,7 +82,7 @@ export class X509Certificate {
|
||||||
_options?: Pick<X509CheckOptions, "subject">,
|
_options?: Pick<X509CheckOptions, "subject">,
|
||||||
): string | undefined {
|
): string | undefined {
|
||||||
validateString(email, "email");
|
validateString(email, "email");
|
||||||
if (ops.op_node_x509_check_email(this.#handle, email)) {
|
if (op_node_x509_check_email(this.#handle, email)) {
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,15 +104,15 @@ export class X509Certificate {
|
||||||
}
|
}
|
||||||
|
|
||||||
get fingerprint(): string {
|
get fingerprint(): string {
|
||||||
return ops.op_node_x509_fingerprint(this.#handle);
|
return op_node_x509_fingerprint(this.#handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
get fingerprint256(): string {
|
get fingerprint256(): string {
|
||||||
return ops.op_node_x509_fingerprint256(this.#handle);
|
return op_node_x509_fingerprint256(this.#handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
get fingerprint512(): string {
|
get fingerprint512(): string {
|
||||||
return ops.op_node_x509_fingerprint512(this.#handle);
|
return op_node_x509_fingerprint512(this.#handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
get infoAccess(): string | undefined {
|
get infoAccess(): string | undefined {
|
||||||
|
@ -108,7 +122,7 @@ export class X509Certificate {
|
||||||
}
|
}
|
||||||
|
|
||||||
get issuer(): string {
|
get issuer(): string {
|
||||||
return ops.op_node_x509_get_issuer(this.#handle);
|
return op_node_x509_get_issuer(this.#handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
get issuerCertificate(): X509Certificate | undefined {
|
get issuerCertificate(): X509Certificate | undefined {
|
||||||
|
@ -116,7 +130,7 @@ export class X509Certificate {
|
||||||
}
|
}
|
||||||
|
|
||||||
get keyUsage(): string[] | undefined {
|
get keyUsage(): string[] | undefined {
|
||||||
const flags = ops.op_node_x509_key_usage(this.#handle);
|
const flags = op_node_x509_key_usage(this.#handle);
|
||||||
if (flags === 0) return undefined;
|
if (flags === 0) return undefined;
|
||||||
const result: string[] = [];
|
const result: string[] = [];
|
||||||
if (flags & 0x01) result.push("DigitalSignature");
|
if (flags & 0x01) result.push("DigitalSignature");
|
||||||
|
@ -144,11 +158,11 @@ export class X509Certificate {
|
||||||
}
|
}
|
||||||
|
|
||||||
get serialNumber(): string {
|
get serialNumber(): string {
|
||||||
return ops.op_node_x509_get_serial_number(this.#handle);
|
return op_node_x509_get_serial_number(this.#handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
get subject(): string {
|
get subject(): string {
|
||||||
return ops.op_node_x509_get_subject(this.#handle);
|
return op_node_x509_get_subject(this.#handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
get subjectAltName(): string | undefined {
|
get subjectAltName(): string | undefined {
|
||||||
|
@ -168,11 +182,11 @@ export class X509Certificate {
|
||||||
}
|
}
|
||||||
|
|
||||||
get validFrom(): string {
|
get validFrom(): string {
|
||||||
return ops.op_node_x509_get_valid_from(this.#handle);
|
return op_node_x509_get_valid_from(this.#handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
get validTo(): string {
|
get validTo(): string {
|
||||||
return ops.op_node_x509_get_valid_to(this.#handle);
|
return op_node_x509_get_valid_to(this.#handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
verify(_publicKey: KeyObject): boolean {
|
verify(_publicKey: KeyObject): boolean {
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { arch, versions } from "ext:deno_node/_process/process.ts";
|
|
||||||
import { cpus, hostname, networkInterfaces } from "node:os";
|
|
||||||
|
|
||||||
import { primordials } from "ext:core/mod.js";
|
import { primordials } from "ext:core/mod.js";
|
||||||
const {
|
const {
|
||||||
Error,
|
Error,
|
||||||
|
@ -13,6 +10,9 @@ const {
|
||||||
DatePrototypeGetTime,
|
DatePrototypeGetTime,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import { arch, versions } from "ext:deno_node/_process/process.ts";
|
||||||
|
import { cpus, hostname, networkInterfaces } from "node:os";
|
||||||
|
|
||||||
function writeReport(_filename: string, _err: typeof Error) {
|
function writeReport(_filename: string, _err: typeof Error) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,17 +4,17 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
import { codes } from "ext:deno_node/internal/error_codes.ts";
|
|
||||||
import { hideStackFrames } from "ext:deno_node/internal/hide_stack_frames.ts";
|
|
||||||
import { isArrayBufferView } from "ext:deno_node/internal/util/types.ts";
|
|
||||||
import { normalizeEncoding } from "ext:deno_node/internal/normalize_encoding.mjs";
|
|
||||||
|
|
||||||
import { primordials } from "ext:core/mod.js";
|
import { primordials } from "ext:core/mod.js";
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeIncludes,
|
ArrayPrototypeIncludes,
|
||||||
ArrayPrototypeJoin,
|
ArrayPrototypeJoin,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import { codes } from "ext:deno_node/internal/error_codes.ts";
|
||||||
|
import { hideStackFrames } from "ext:deno_node/internal/hide_stack_frames.ts";
|
||||||
|
import { isArrayBufferView } from "ext:deno_node/internal/util/types.ts";
|
||||||
|
import { normalizeEncoding } from "ext:deno_node/internal/normalize_encoding.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} value
|
* @param {number} value
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
const { ops } = globalThis.__bootstrap.core;
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_sys_to_uv_error,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
export function uvTranslateSysError(sysErrno: number): string {
|
export function uvTranslateSysError(sysErrno: number): string {
|
||||||
return ops.op_node_sys_to_uv_error(sysErrno);
|
return op_node_sys_to_uv_error(sysErrno);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_build_os,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
|
|
||||||
let os: {
|
let os: {
|
||||||
dlopen: {
|
dlopen: {
|
||||||
RTLD_DEEPBIND?: number;
|
RTLD_DEEPBIND?: number;
|
||||||
|
@ -196,8 +202,7 @@ let os: {
|
||||||
UV_UDP_REUSEADDR: number;
|
UV_UDP_REUSEADDR: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
const core = globalThis.__bootstrap.core;
|
const buildOs = op_node_build_os();
|
||||||
const buildOs = core.ops.op_node_build_os();
|
|
||||||
if (buildOs === "darwin") {
|
if (buildOs === "darwin") {
|
||||||
os = {
|
os = {
|
||||||
UV_UDP_REUSEADDR: 4,
|
UV_UDP_REUSEADDR: 4,
|
||||||
|
|
|
@ -30,6 +30,12 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_can_write_vectored,
|
||||||
|
op_raw_write_vectored,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import { TextEncoder } from "ext:deno_web/08_text_encoding.js";
|
import { TextEncoder } from "ext:deno_web/08_text_encoding.js";
|
||||||
import { Buffer } from "node:buffer";
|
import { Buffer } from "node:buffer";
|
||||||
import { notImplemented } from "ext:deno_node/_utils.ts";
|
import { notImplemented } from "ext:deno_node/_utils.ts";
|
||||||
|
@ -40,9 +46,6 @@ import {
|
||||||
} from "ext:deno_node/internal_binding/async_wrap.ts";
|
} from "ext:deno_node/internal_binding/async_wrap.ts";
|
||||||
import { codeMap } from "ext:deno_node/internal_binding/uv.ts";
|
import { codeMap } from "ext:deno_node/internal_binding/uv.ts";
|
||||||
|
|
||||||
import { core } from "ext:core/mod.js";
|
|
||||||
const { ops } = core;
|
|
||||||
|
|
||||||
interface Reader {
|
interface Reader {
|
||||||
read(p: Uint8Array): Promise<number | null>;
|
read(p: Uint8Array): Promise<number | null>;
|
||||||
}
|
}
|
||||||
|
@ -204,13 +207,13 @@ export class LibuvStreamWrap extends HandleWrap {
|
||||||
// Fast case optimization: two chunks, and all buffers.
|
// Fast case optimization: two chunks, and all buffers.
|
||||||
if (
|
if (
|
||||||
chunks.length === 2 && allBuffers && supportsWritev &&
|
chunks.length === 2 && allBuffers && supportsWritev &&
|
||||||
ops.op_can_write_vectored(rid)
|
op_can_write_vectored(rid)
|
||||||
) {
|
) {
|
||||||
// String chunks.
|
// String chunks.
|
||||||
if (typeof chunks[0] === "string") chunks[0] = Buffer.from(chunks[0]);
|
if (typeof chunks[0] === "string") chunks[0] = Buffer.from(chunks[0]);
|
||||||
if (typeof chunks[1] === "string") chunks[1] = Buffer.from(chunks[1]);
|
if (typeof chunks[1] === "string") chunks[1] = Buffer.from(chunks[1]);
|
||||||
|
|
||||||
ops.op_raw_write_vectored(
|
op_raw_write_vectored(
|
||||||
rid,
|
rid,
|
||||||
chunks[0],
|
chunks[0],
|
||||||
chunks[1],
|
chunks[1],
|
||||||
|
|
|
@ -24,7 +24,11 @@
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
import { core } from "ext:core/mod.js";
|
import { core } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
|
op_node_unstable_net_listen_udp,
|
||||||
|
op_node_unstable_net_listen_unixpacket,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AsyncWrap,
|
AsyncWrap,
|
||||||
providerType,
|
providerType,
|
||||||
|
@ -41,8 +45,8 @@ import * as net from "ext:deno_net/01_net.js";
|
||||||
import { isLinux, isWindows } from "ext:deno_node/_util/os.ts";
|
import { isLinux, isWindows } from "ext:deno_node/_util/os.ts";
|
||||||
|
|
||||||
const DenoListenDatagram = net.createListenDatagram(
|
const DenoListenDatagram = net.createListenDatagram(
|
||||||
ops.op_node_unstable_net_listen_udp,
|
op_node_unstable_net_listen_udp,
|
||||||
ops.op_node_unstable_net_listen_unixpacket,
|
op_node_unstable_net_listen_unixpacket,
|
||||||
);
|
);
|
||||||
|
|
||||||
type MessageType = string | Uint8Array | Buffer | DataView;
|
type MessageType = string | Uint8Array | Buffer | DataView;
|
||||||
|
|
|
@ -29,11 +29,13 @@
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
import { core } from "ext:core/mod.js";
|
import { core } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
|
op_node_guess_handle_type,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
const handleTypes = ["TCP", "TTY", "UDP", "FILE", "PIPE", "UNKNOWN"];
|
const handleTypes = ["TCP", "TTY", "UDP", "FILE", "PIPE", "UNKNOWN"];
|
||||||
export function guessHandleType(fd: number): string {
|
export function guessHandleType(fd: number): string {
|
||||||
const type = ops.op_node_guess_handle_type(fd);
|
const type = op_node_guess_handle_type(fd);
|
||||||
return handleTypes[type];
|
return handleTypes[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,14 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
const core = globalThis.__bootstrap.core;
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_cpus,
|
||||||
|
op_node_os_get_priority,
|
||||||
|
op_node_os_set_priority,
|
||||||
|
op_node_os_username,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import { validateIntegerRange } from "ext:deno_node/_utils.ts";
|
import { validateIntegerRange } from "ext:deno_node/_utils.ts";
|
||||||
import process from "node:process";
|
import process from "node:process";
|
||||||
import { isWindows, osType } from "ext:deno_node/_util/os.ts";
|
import { isWindows, osType } from "ext:deno_node/_util/os.ts";
|
||||||
|
@ -32,8 +39,6 @@ import { os } from "ext:deno_node/internal_binding/constants.ts";
|
||||||
import { osUptime } from "ext:runtime/30_os.js";
|
import { osUptime } from "ext:runtime/30_os.js";
|
||||||
import { Buffer } from "ext:deno_node/internal/buffer.mjs";
|
import { Buffer } from "ext:deno_node/internal/buffer.mjs";
|
||||||
|
|
||||||
const ops = core.ops;
|
|
||||||
|
|
||||||
export const constants = os;
|
export const constants = os;
|
||||||
|
|
||||||
interface CPUTimes {
|
interface CPUTimes {
|
||||||
|
@ -133,7 +138,7 @@ export function arch(): string {
|
||||||
(machine as any)[Symbol.toPrimitive] = (): string => machine();
|
(machine as any)[Symbol.toPrimitive] = (): string => machine();
|
||||||
|
|
||||||
export function cpus(): CPUCoreInfo[] {
|
export function cpus(): CPUCoreInfo[] {
|
||||||
return ops.op_cpus();
|
return op_cpus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,7 +169,7 @@ export function freemem(): number {
|
||||||
/** Not yet implemented */
|
/** Not yet implemented */
|
||||||
export function getPriority(pid = 0): number {
|
export function getPriority(pid = 0): number {
|
||||||
validateIntegerRange(pid, "pid");
|
validateIntegerRange(pid, "pid");
|
||||||
return core.ops.op_node_os_get_priority(pid);
|
return op_node_os_get_priority(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the string path of the current user's home directory. */
|
/** Returns the string path of the current user's home directory. */
|
||||||
|
@ -270,7 +275,7 @@ export function setPriority(pid: number, priority?: number) {
|
||||||
validateIntegerRange(pid, "pid");
|
validateIntegerRange(pid, "pid");
|
||||||
validateIntegerRange(priority, "priority", -20, 19);
|
validateIntegerRange(priority, "priority", -20, 19);
|
||||||
|
|
||||||
core.ops.op_node_os_set_priority(pid, priority);
|
op_node_os_set_priority(pid, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the operating system's default directory for temporary files as a string. */
|
/** Returns the operating system's default directory for temporary files as a string. */
|
||||||
|
@ -350,7 +355,7 @@ export function userInfo(
|
||||||
throw new ERR_OS_NO_HOMEDIR();
|
throw new ERR_OS_NO_HOMEDIR();
|
||||||
}
|
}
|
||||||
let shell = isWindows ? (Deno.env.get("SHELL") || null) : null;
|
let shell = isWindows ? (Deno.env.get("SHELL") || null) : null;
|
||||||
let username = core.ops.op_node_os_username();
|
let username = op_node_os_username();
|
||||||
|
|
||||||
if (options?.encoding === "buffer") {
|
if (options?.encoding === "buffer") {
|
||||||
_homedir = _homedir ? Buffer.from(_homedir) : _homedir;
|
_homedir = _homedir ? Buffer.from(_homedir) : _homedir;
|
||||||
|
|
|
@ -4,9 +4,15 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
const internals = globalThis.__bootstrap.internals;
|
import { core, internals } from "ext:core/mod.js";
|
||||||
const { core } = globalThis.__bootstrap;
|
const {
|
||||||
const { ops } = core;
|
op_process_abort,
|
||||||
|
op_geteuid,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
op_set_exit_code,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
|
|
||||||
import { notImplemented, warnNotImplemented } from "ext:deno_node/_utils.ts";
|
import { notImplemented, warnNotImplemented } from "ext:deno_node/_utils.ts";
|
||||||
import { EventEmitter } from "node:events";
|
import { EventEmitter } from "node:events";
|
||||||
import Module from "node:module";
|
import Module from "node:module";
|
||||||
|
@ -99,7 +105,7 @@ export const exit = (code?: number | string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const abort = () => {
|
export const abort = () => {
|
||||||
ops.op_process_abort();
|
op_process_abort();
|
||||||
};
|
};
|
||||||
|
|
||||||
function addReadOnlyProcessAlias(
|
function addReadOnlyProcessAlias(
|
||||||
|
@ -440,7 +446,7 @@ class Process extends EventEmitter {
|
||||||
globalProcessExitCode = code;
|
globalProcessExitCode = code;
|
||||||
code = parseInt(code) || 0;
|
code = parseInt(code) || 0;
|
||||||
if (!isNaN(code)) {
|
if (!isNaN(code)) {
|
||||||
ops.op_set_exit_code(code);
|
op_set_exit_code(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,7 +682,7 @@ class Process extends EventEmitter {
|
||||||
|
|
||||||
/** This method is removed on Windows */
|
/** This method is removed on Windows */
|
||||||
geteuid?(): number {
|
geteuid?(): number {
|
||||||
return ops.op_geteuid();
|
return op_geteuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(kt3k): Implement this when we added -e option to node compat mode
|
// TODO(kt3k): Implement this when we added -e option to node compat mode
|
||||||
|
|
|
@ -1,23 +1,29 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_node_idna_domain_to_unicode,
|
||||||
|
op_node_idna_punycode_decode,
|
||||||
|
op_node_idna_punycode_encode,
|
||||||
|
op_node_idna_domain_to_ascii,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import { ucs2 } from "ext:deno_node/internal/idna.ts";
|
import { ucs2 } from "ext:deno_node/internal/idna.ts";
|
||||||
|
|
||||||
const { ops } = globalThis.__bootstrap.core;
|
|
||||||
|
|
||||||
function toASCII(domain) {
|
function toASCII(domain) {
|
||||||
return ops.op_node_idna_domain_to_ascii(domain);
|
return op_node_idna_domain_to_ascii(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toUnicode(domain) {
|
function toUnicode(domain) {
|
||||||
return ops.op_node_idna_domain_to_unicode(domain);
|
return op_node_idna_domain_to_unicode(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
function decode(domain) {
|
function decode(domain) {
|
||||||
return ops.op_node_idna_punycode_decode(domain);
|
return op_node_idna_punycode_decode(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
function encode(domain) {
|
function encode(domain) {
|
||||||
return ops.op_node_idna_punycode_encode(domain);
|
return op_node_idna_punycode_encode(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { decode, encode, toASCII, toUnicode, ucs2 };
|
export { decode, encode, toASCII, toUnicode, ucs2 };
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
import { primordials } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
Error,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
import { ERR_INVALID_FD } from "ext:deno_node/internal/errors.ts";
|
import { ERR_INVALID_FD } from "ext:deno_node/internal/errors.ts";
|
||||||
import { LibuvStreamWrap } from "ext:deno_node/internal_binding/stream_wrap.ts";
|
import { LibuvStreamWrap } from "ext:deno_node/internal_binding/stream_wrap.ts";
|
||||||
import { providerType } from "ext:deno_node/internal_binding/async_wrap.ts";
|
import { providerType } from "ext:deno_node/internal_binding/async_wrap.ts";
|
||||||
import { Socket } from "node:net";
|
import { Socket } from "node:net";
|
||||||
import { setReadStream } from "ext:deno_node/_process/streams.mjs";
|
import { setReadStream } from "ext:deno_node/_process/streams.mjs";
|
||||||
const { Error } = globalThis.__bootstrap.primordials;
|
|
||||||
|
|
||||||
// Returns true when the given numeric fd is associated with a TTY and false otherwise.
|
// Returns true when the given numeric fd is associated with a TTY and false otherwise.
|
||||||
function isatty(fd) {
|
function isatty(fd) {
|
||||||
|
|
|
@ -1,21 +1,5 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { promisify } from "ext:deno_node/internal/util.mjs";
|
|
||||||
import { callbackify } from "ext:deno_node/_util/_util_callbackify.ts";
|
|
||||||
import { debuglog } from "ext:deno_node/internal/util/debuglog.ts";
|
|
||||||
import {
|
|
||||||
format,
|
|
||||||
formatWithOptions,
|
|
||||||
inspect,
|
|
||||||
stripVTControlCharacters,
|
|
||||||
} from "ext:deno_node/internal/util/inspect.mjs";
|
|
||||||
import { codes } from "ext:deno_node/internal/error_codes.ts";
|
|
||||||
import types from "node:util/types";
|
|
||||||
import { Buffer } from "node:buffer";
|
|
||||||
import { isDeepStrictEqual } from "ext:deno_node/internal/util/comparisons.ts";
|
|
||||||
import process from "node:process";
|
|
||||||
import { validateString } from "ext:deno_node/internal/validators.mjs";
|
|
||||||
import { parseArgs } from "ext:deno_node/internal/util/parse_args/parse_args.js";
|
|
||||||
import { primordials } from "ext:core/mod.js";
|
import { primordials } from "ext:core/mod.js";
|
||||||
const {
|
const {
|
||||||
ArrayIsArray,
|
ArrayIsArray,
|
||||||
|
@ -43,6 +27,23 @@ const {
|
||||||
StringPrototypeToWellFormed,
|
StringPrototypeToWellFormed,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import { promisify } from "ext:deno_node/internal/util.mjs";
|
||||||
|
import { callbackify } from "ext:deno_node/_util/_util_callbackify.ts";
|
||||||
|
import { debuglog } from "ext:deno_node/internal/util/debuglog.ts";
|
||||||
|
import {
|
||||||
|
format,
|
||||||
|
formatWithOptions,
|
||||||
|
inspect,
|
||||||
|
stripVTControlCharacters,
|
||||||
|
} from "ext:deno_node/internal/util/inspect.mjs";
|
||||||
|
import { codes } from "ext:deno_node/internal/error_codes.ts";
|
||||||
|
import types from "node:util/types";
|
||||||
|
import { Buffer } from "node:buffer";
|
||||||
|
import { isDeepStrictEqual } from "ext:deno_node/internal/util/comparisons.ts";
|
||||||
|
import process from "node:process";
|
||||||
|
import { validateString } from "ext:deno_node/internal/validators.mjs";
|
||||||
|
import { parseArgs } from "ext:deno_node/internal/util/parse_args/parse_args.js";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
callbackify,
|
callbackify,
|
||||||
debuglog,
|
debuglog,
|
||||||
|
|
|
@ -4,12 +4,16 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_v8_cached_data_version_tag,
|
||||||
|
op_v8_get_heap_statistics,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import { notImplemented } from "ext:deno_node/_utils.ts";
|
import { notImplemented } from "ext:deno_node/_utils.ts";
|
||||||
|
|
||||||
const { ops } = globalThis.__bootstrap.core;
|
|
||||||
|
|
||||||
export function cachedDataVersionTag() {
|
export function cachedDataVersionTag() {
|
||||||
return ops.op_v8_cached_data_version_tag();
|
return op_v8_cached_data_version_tag();
|
||||||
}
|
}
|
||||||
export function getHeapCodeStatistics() {
|
export function getHeapCodeStatistics() {
|
||||||
notImplemented("v8.getHeapCodeStatistics");
|
notImplemented("v8.getHeapCodeStatistics");
|
||||||
|
@ -24,7 +28,7 @@ export function getHeapSpaceStatistics() {
|
||||||
const buffer = new Float64Array(14);
|
const buffer = new Float64Array(14);
|
||||||
|
|
||||||
export function getHeapStatistics() {
|
export function getHeapStatistics() {
|
||||||
ops.op_v8_get_heap_statistics(buffer);
|
op_v8_get_heap_statistics(buffer);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
total_heap_size: buffer[0],
|
total_heap_size: buffer[0],
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file no-explicit-any prefer-primordials
|
// deno-lint-ignore-file no-explicit-any prefer-primordials
|
||||||
|
|
||||||
|
import { core } from "ext:core/mod.js";
|
||||||
import { notImplemented } from "ext:deno_node/_utils.ts";
|
import { notImplemented } from "ext:deno_node/_utils.ts";
|
||||||
|
const {
|
||||||
const { core } = globalThis.__bootstrap;
|
op_vm_run_in_new_context,
|
||||||
const ops = core.ops;
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
export class Script {
|
export class Script {
|
||||||
code: string;
|
code: string;
|
||||||
|
@ -32,7 +33,7 @@ export class Script {
|
||||||
"Script.runInNewContext options are currently not supported",
|
"Script.runInNewContext options are currently not supported",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return ops.op_vm_run_in_new_context(this.code, contextObject);
|
return op_vm_run_in_new_context(this.code, contextObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
createCachedData() {
|
createCachedData() {
|
||||||
|
@ -64,7 +65,7 @@ export function runInNewContext(
|
||||||
if (options) {
|
if (options) {
|
||||||
console.warn("vm.runInNewContext options are currently not supported");
|
console.warn("vm.runInNewContext options are currently not supported");
|
||||||
}
|
}
|
||||||
return ops.op_vm_run_in_new_context(code, contextObject);
|
return op_vm_run_in_new_context(code, contextObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function runInThisContext(
|
export function runInThisContext(
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core, internals } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
op_require_read_closest_package_json,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
|
|
||||||
import { isAbsolute, resolve } from "node:path";
|
import { isAbsolute, resolve } from "node:path";
|
||||||
import { notImplemented } from "ext:deno_node/_utils.ts";
|
import { notImplemented } from "ext:deno_node/_utils.ts";
|
||||||
import { EventEmitter, once } from "node:events";
|
import { EventEmitter, once } from "node:events";
|
||||||
|
@ -12,7 +17,6 @@ import { MessageChannel, MessagePort } from "ext:deno_web/13_message_port.js";
|
||||||
|
|
||||||
let environmentData = new Map();
|
let environmentData = new Map();
|
||||||
let threads = 0;
|
let threads = 0;
|
||||||
const { core } = globalThis.__bootstrap;
|
|
||||||
|
|
||||||
export interface WorkerOptions {
|
export interface WorkerOptions {
|
||||||
// only for typings
|
// only for typings
|
||||||
|
@ -120,7 +124,7 @@ class _Worker extends EventEmitter {
|
||||||
specifier = resolve(specifier);
|
specifier = resolve(specifier);
|
||||||
let pkg;
|
let pkg;
|
||||||
try {
|
try {
|
||||||
pkg = core.ops.op_require_read_closest_package_json(specifier);
|
pkg = op_require_read_closest_package_json(specifier);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// empty catch block when package json might not be present
|
// empty catch block when package json might not be present
|
||||||
}
|
}
|
||||||
|
@ -203,7 +207,7 @@ type ParentPort = typeof self & NodeEventTarget;
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
let parentPort: ParentPort = null as any;
|
let parentPort: ParentPort = null as any;
|
||||||
|
|
||||||
globalThis.__bootstrap.internals.__initWorkerThreads = () => {
|
internals.__initWorkerThreads = () => {
|
||||||
isMainThread =
|
isMainThread =
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
(globalThis as any).name !== PRIVATE_WORKER_THREAD_NAME;
|
(globalThis as any).name !== PRIVATE_WORKER_THREAD_NAME;
|
||||||
|
|
|
@ -6,9 +6,14 @@
|
||||||
/// <reference path="../webidl/internal.d.ts" />
|
/// <reference path="../webidl/internal.d.ts" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
op_url_get_serialization,
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
op_url_parse,
|
||||||
|
op_url_parse_search_params,
|
||||||
|
op_url_parse_with_base,
|
||||||
|
op_url_reparse,
|
||||||
|
op_url_stringify_search_params,
|
||||||
|
} = core.ensureFastOps();
|
||||||
const {
|
const {
|
||||||
ArrayIsArray,
|
ArrayIsArray,
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
|
@ -28,6 +33,9 @@ const {
|
||||||
Uint32Array,
|
Uint32Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
|
|
||||||
const _list = Symbol("list");
|
const _list = Symbol("list");
|
||||||
const _urlObject = Symbol("url object");
|
const _urlObject = Symbol("url object");
|
||||||
|
|
||||||
|
@ -50,7 +58,7 @@ const SET_USERNAME = 8;
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
function opUrlReparse(href, setter, value) {
|
function opUrlReparse(href, setter, value) {
|
||||||
const status = ops.op_url_reparse(
|
const status = op_url_reparse(
|
||||||
href,
|
href,
|
||||||
setter,
|
setter,
|
||||||
value,
|
value,
|
||||||
|
@ -66,9 +74,9 @@ function opUrlReparse(href, setter, value) {
|
||||||
*/
|
*/
|
||||||
function opUrlParse(href, maybeBase) {
|
function opUrlParse(href, maybeBase) {
|
||||||
if (maybeBase === undefined) {
|
if (maybeBase === undefined) {
|
||||||
return ops.op_url_parse(href, componentsBuf);
|
return op_url_parse(href, componentsBuf);
|
||||||
}
|
}
|
||||||
return ops.op_url_parse_with_base(
|
return op_url_parse_with_base(
|
||||||
href,
|
href,
|
||||||
maybeBase,
|
maybeBase,
|
||||||
componentsBuf,
|
componentsBuf,
|
||||||
|
@ -85,7 +93,7 @@ function getSerialization(status, href, maybeBase) {
|
||||||
if (status === 0) {
|
if (status === 0) {
|
||||||
return href;
|
return href;
|
||||||
} else if (status === 1) {
|
} else if (status === 1) {
|
||||||
return ops.op_url_get_serialization();
|
return op_url_get_serialization();
|
||||||
} else {
|
} else {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
`Invalid URL: '${href}'` +
|
`Invalid URL: '${href}'` +
|
||||||
|
@ -123,7 +131,7 @@ class URLSearchParams {
|
||||||
if (init[0] == "?") {
|
if (init[0] == "?") {
|
||||||
init = StringPrototypeSlice(init, 1);
|
init = StringPrototypeSlice(init, 1);
|
||||||
}
|
}
|
||||||
this[_list] = ops.op_url_parse_search_params(init);
|
this[_list] = op_url_parse_search_params(init);
|
||||||
} else if (ArrayIsArray(init)) {
|
} else if (ArrayIsArray(init)) {
|
||||||
// Overload: sequence<sequence<USVString>>
|
// Overload: sequence<sequence<USVString>>
|
||||||
this[_list] = ArrayPrototypeMap(init, (pair, i) => {
|
this[_list] = ArrayPrototypeMap(init, (pair, i) => {
|
||||||
|
@ -314,7 +322,7 @@ class URLSearchParams {
|
||||||
*/
|
*/
|
||||||
toString() {
|
toString() {
|
||||||
webidl.assertBranded(this, URLSearchParamsPrototype);
|
webidl.assertBranded(this, URLSearchParamsPrototype);
|
||||||
return ops.op_url_stringify_search_params(this[_list]);
|
return op_url_stringify_search_params(this[_list]);
|
||||||
}
|
}
|
||||||
|
|
||||||
get size() {
|
get size() {
|
||||||
|
@ -436,7 +444,7 @@ class URL {
|
||||||
#updateSearchParams() {
|
#updateSearchParams() {
|
||||||
if (this.#queryObject !== null) {
|
if (this.#queryObject !== null) {
|
||||||
const params = this.#queryObject[_list];
|
const params = this.#queryObject[_list];
|
||||||
const newParams = ops.op_url_parse_search_params(
|
const newParams = op_url_parse_search_params(
|
||||||
StringPrototypeSlice(this.search, 1),
|
StringPrototypeSlice(this.search, 1),
|
||||||
);
|
);
|
||||||
ArrayPrototypeSplice(
|
ArrayPrototypeSplice(
|
||||||
|
@ -823,7 +831,7 @@ const URLPrototype = URL.prototype;
|
||||||
* @returns {[string, string][]}
|
* @returns {[string, string][]}
|
||||||
*/
|
*/
|
||||||
function parseUrlEncoded(bytes) {
|
function parseUrlEncoded(bytes) {
|
||||||
return ops.op_url_parse_search_params(null, bytes);
|
return op_url_parse_search_params(null, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
webidl
|
webidl
|
||||||
|
|
|
@ -8,9 +8,10 @@
|
||||||
/// <reference path="./lib.deno_url.d.ts" />
|
/// <reference path="./lib.deno_url.d.ts" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
op_urlpattern_parse,
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
op_urlpattern_process_match_input,
|
||||||
|
} = core.ensureFastOps();
|
||||||
const {
|
const {
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
MathRandom,
|
MathRandom,
|
||||||
|
@ -26,6 +27,9 @@ const {
|
||||||
TypeError,
|
TypeError,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
|
|
||||||
const _components = Symbol("components");
|
const _components = Symbol("components");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,7 +156,7 @@ class URLPattern {
|
||||||
baseURL = webidl.converters.USVString(baseURL, prefix, "Argument 2");
|
baseURL = webidl.converters.USVString(baseURL, prefix, "Argument 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
const components = ops.op_urlpattern_parse(input, baseURL);
|
const components = op_urlpattern_parse(input, baseURL);
|
||||||
|
|
||||||
for (let i = 0; i < COMPONENTS_KEYS.length; ++i) {
|
for (let i = 0; i < COMPONENTS_KEYS.length; ++i) {
|
||||||
const key = COMPONENTS_KEYS[i];
|
const key = COMPONENTS_KEYS[i];
|
||||||
|
@ -225,9 +229,9 @@ class URLPattern {
|
||||||
const res = baseURL === undefined
|
const res = baseURL === undefined
|
||||||
? matchInputCache.getOrInsert(
|
? matchInputCache.getOrInsert(
|
||||||
input,
|
input,
|
||||||
ops.op_urlpattern_process_match_input,
|
op_urlpattern_process_match_input,
|
||||||
)
|
)
|
||||||
: ops.op_urlpattern_process_match_input(input, baseURL);
|
: op_urlpattern_process_match_input(input, baseURL);
|
||||||
if (res === null) return false;
|
if (res === null) return false;
|
||||||
|
|
||||||
const values = res[0];
|
const values = res[0];
|
||||||
|
@ -267,9 +271,9 @@ class URLPattern {
|
||||||
const res = baseURL === undefined
|
const res = baseURL === undefined
|
||||||
? matchInputCache.getOrInsert(
|
? matchInputCache.getOrInsert(
|
||||||
input,
|
input,
|
||||||
ops.op_urlpattern_process_match_input,
|
op_urlpattern_process_match_input,
|
||||||
)
|
)
|
||||||
: ops.op_urlpattern_process_match_input(input, baseURL);
|
: op_urlpattern_process_match_input(input, baseURL);
|
||||||
if (res === null) {
|
if (res === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
/// <reference path="../web/lib.deno_web.d.ts" />
|
/// <reference path="../web/lib.deno_web.d.ts" />
|
||||||
|
|
||||||
import { core, internals, primordials } from "ext:core/mod.js";
|
import { core, internals, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
|
op_base64_encode,
|
||||||
|
op_base64_decode,
|
||||||
|
} = core.ensureFastOps();
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeJoin,
|
ArrayPrototypeJoin,
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
|
@ -33,6 +36,7 @@ const {
|
||||||
Symbol,
|
Symbol,
|
||||||
TypeError,
|
TypeError,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
import { URLPrototype } from "ext:deno_url/00_url.js";
|
import { URLPrototype } from "ext:deno_url/00_url.js";
|
||||||
|
|
||||||
const ASCII_DIGIT = ["\u0030-\u0039"];
|
const ASCII_DIGIT = ["\u0030-\u0039"];
|
||||||
|
@ -245,7 +249,7 @@ function collectHttpQuotedString(input, position, extractValue) {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
function forgivingBase64Encode(data) {
|
function forgivingBase64Encode(data) {
|
||||||
return ops.op_base64_encode(data);
|
return op_base64_encode(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -253,7 +257,7 @@ function forgivingBase64Encode(data) {
|
||||||
* @returns {Uint8Array}
|
* @returns {Uint8Array}
|
||||||
*/
|
*/
|
||||||
function forgivingBase64Decode(data) {
|
function forgivingBase64Decode(data) {
|
||||||
return ops.op_base64_decode(data);
|
return op_base64_decode(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Taken from std/encoding/base64url.ts
|
// Taken from std/encoding/base64url.ts
|
||||||
|
|
|
@ -20,6 +20,7 @@ const {
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ const {
|
||||||
StringPrototypeReplaceAll,
|
StringPrototypeReplaceAll,
|
||||||
StringPrototypeToLowerCase,
|
StringPrototypeToLowerCase,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
import {
|
import {
|
||||||
collectHttpQuotedString,
|
collectHttpQuotedString,
|
||||||
collectSequenceOfCodepoints,
|
collectSequenceOfCodepoints,
|
||||||
|
|
|
@ -6,9 +6,6 @@
|
||||||
// and impossible logic branches based on what Deno currently supports.
|
// and impossible logic branches based on what Deno currently supports.
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
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 {
|
const {
|
||||||
ArrayPrototypeFilter,
|
ArrayPrototypeFilter,
|
||||||
ArrayPrototypeIncludes,
|
ArrayPrototypeIncludes,
|
||||||
|
@ -37,6 +34,10 @@ const {
|
||||||
TypeError,
|
TypeError,
|
||||||
} = primordials;
|
} = 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
|
// This should be set via setGlobalThis this is required so that if even
|
||||||
// user deletes globalThis it is still usable
|
// user deletes globalThis it is still usable
|
||||||
let globalThis_;
|
let globalThis_;
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
/// <reference path="../web/lib.deno_web.d.ts" />
|
/// <reference path="../web/lib.deno_web.d.ts" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
const {
|
||||||
|
isArrayBuffer,
|
||||||
|
} = core;
|
||||||
const {
|
const {
|
||||||
ArrayBuffer,
|
ArrayBuffer,
|
||||||
ArrayBufferPrototypeGetByteLength,
|
ArrayBufferPrototypeGetByteLength,
|
||||||
|
@ -37,9 +39,8 @@ const {
|
||||||
Float32Array,
|
Float32Array,
|
||||||
Float64Array,
|
Float64Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
const {
|
|
||||||
isArrayBuffer,
|
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
||||||
} = core;
|
|
||||||
|
|
||||||
const objectCloneMemo = new SafeWeakMap();
|
const objectCloneMemo = new SafeWeakMap();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
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 {
|
const {
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
ArrayPrototypeShift,
|
ArrayPrototypeShift,
|
||||||
|
@ -19,15 +24,15 @@ const {
|
||||||
TypeError,
|
TypeError,
|
||||||
indirectEval,
|
indirectEval,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
import { reportException } from "ext:deno_web/02_event.js";
|
import { reportException } from "ext:deno_web/02_event.js";
|
||||||
import { assert } from "ext:deno_web/00_infra.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 hrU8 = new Uint8Array(8);
|
||||||
const hr = new Uint32Array(TypedArrayPrototypeGetBuffer(hrU8));
|
const hr = new Uint32Array(TypedArrayPrototypeGetBuffer(hrU8));
|
||||||
function opNow() {
|
function opNow() {
|
||||||
ops.op_now(hrU8);
|
op_now(hrU8);
|
||||||
return (hr[0] * 1000 + hr[1] / 1e6);
|
return (hr[0] * 1000 + hr[1] / 1e6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +116,7 @@ function initializeTimer(
|
||||||
// TODO(@andreubotella): Deal with overflow.
|
// TODO(@andreubotella): Deal with overflow.
|
||||||
// https://github.com/whatwg/html/issues/7358
|
// https://github.com/whatwg/html/issues/7358
|
||||||
id = nextId++;
|
id = nextId++;
|
||||||
const cancelRid = ops.op_timer_handle();
|
const cancelRid = op_timer_handle();
|
||||||
timerInfo = { cancelRid, isRef: true, promise: null };
|
timerInfo = { cancelRid, isRef: true, promise: null };
|
||||||
|
|
||||||
// Step 4 in "run steps after a timeout".
|
// Step 4 in "run steps after a timeout".
|
||||||
|
|
|
@ -3,16 +3,6 @@
|
||||||
// @ts-check
|
// @ts-check
|
||||||
/// <reference path="../../core/internal.d.ts" />
|
/// <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";
|
import { primordials } from "ext:core/mod.js";
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeEvery,
|
ArrayPrototypeEvery,
|
||||||
|
@ -32,6 +22,17 @@ const {
|
||||||
WeakSetPrototypeAdd,
|
WeakSetPrototypeAdd,
|
||||||
WeakSetPrototypeHas,
|
WeakSetPrototypeHas,
|
||||||
} = primordials;
|
} = 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";
|
import { refTimer, setTimeout, unrefTimer } from "ext:deno_web/02_timers.js";
|
||||||
|
|
||||||
// Since WeakSet is not a iterable, WeakRefSet class is provided to store and
|
// Since WeakSet is not a iterable, WeakRefSet class is provided to store and
|
||||||
|
|
|
@ -7,14 +7,18 @@
|
||||||
/// <reference lib="esnext" />
|
/// <reference lib="esnext" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
op_base64_atob,
|
||||||
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
op_base64_btoa,
|
||||||
|
} = core.ensureFastOps();
|
||||||
const {
|
const {
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
TypeErrorPrototype,
|
TypeErrorPrototype,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
|
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} data
|
* @param {string} data
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
|
@ -24,7 +28,7 @@ function atob(data) {
|
||||||
webidl.requiredArguments(arguments.length, 1, prefix);
|
webidl.requiredArguments(arguments.length, 1, prefix);
|
||||||
data = webidl.converters.DOMString(data, prefix, "Argument 1");
|
data = webidl.converters.DOMString(data, prefix, "Argument 1");
|
||||||
try {
|
try {
|
||||||
return ops.op_base64_atob(data);
|
return op_base64_atob(data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (ObjectPrototypeIsPrototypeOf(TypeErrorPrototype, e)) {
|
if (ObjectPrototypeIsPrototypeOf(TypeErrorPrototype, e)) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
|
@ -45,7 +49,7 @@ function btoa(data) {
|
||||||
webidl.requiredArguments(arguments.length, 1, prefix);
|
webidl.requiredArguments(arguments.length, 1, prefix);
|
||||||
data = webidl.converters.DOMString(data, prefix, "Argument 1");
|
data = webidl.converters.DOMString(data, prefix, "Argument 1");
|
||||||
try {
|
try {
|
||||||
return ops.op_base64_btoa(data);
|
return op_base64_btoa(data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (ObjectPrototypeIsPrototypeOf(TypeErrorPrototype, e)) {
|
if (ObjectPrototypeIsPrototypeOf(TypeErrorPrototype, e)) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
|
|
|
@ -7,6 +7,12 @@
|
||||||
/// <reference lib="esnext" />
|
/// <reference lib="esnext" />
|
||||||
|
|
||||||
import { core, internals, primordials } from "ext:core/mod.js";
|
import { core, internals, primordials } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
isAnyArrayBuffer,
|
||||||
|
isArrayBuffer,
|
||||||
|
isSharedArrayBuffer,
|
||||||
|
isTypedArray,
|
||||||
|
} = core;
|
||||||
const {
|
const {
|
||||||
op_arraybuffer_was_detached,
|
op_arraybuffer_was_detached,
|
||||||
op_transfer_arraybuffer,
|
op_transfer_arraybuffer,
|
||||||
|
@ -19,20 +25,10 @@ const {
|
||||||
op_readable_stream_resource_close,
|
op_readable_stream_resource_close,
|
||||||
op_readable_stream_resource_await_close,
|
op_readable_stream_resource_await_close,
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
// TODO(mmastrac): use readAll
|
|
||||||
const {
|
const {
|
||||||
|
// TODO(mmastrac): use readAll
|
||||||
op_read_all,
|
op_read_all,
|
||||||
} = core.ensureFastOps(true);
|
} = 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 {
|
const {
|
||||||
ArrayBuffer,
|
ArrayBuffer,
|
||||||
ArrayBufferIsView,
|
ArrayBufferIsView,
|
||||||
|
@ -95,12 +91,17 @@ const {
|
||||||
WeakMapPrototypeSet,
|
WeakMapPrototypeSet,
|
||||||
queueMicrotask,
|
queueMicrotask,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
const {
|
|
||||||
isAnyArrayBuffer,
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
isArrayBuffer,
|
import { structuredClone } from "ext:deno_web/02_structured_clone.js";
|
||||||
isSharedArrayBuffer,
|
import {
|
||||||
isTypedArray,
|
AbortSignalPrototype,
|
||||||
} = core;
|
add,
|
||||||
|
newSignal,
|
||||||
|
remove,
|
||||||
|
signalAbort,
|
||||||
|
} from "ext:deno_web/03_abort_signal.js";
|
||||||
|
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
import { assert, AssertionError } from "ext:deno_web/00_infra.js";
|
import { assert, AssertionError } from "ext:deno_web/00_infra.js";
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,19 @@
|
||||||
/// <reference lib="esnext" />
|
/// <reference lib="esnext" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
isDataView,
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
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 {
|
const {
|
||||||
DataViewPrototypeGetBuffer,
|
DataViewPrototypeGetBuffer,
|
||||||
DataViewPrototypeGetByteLength,
|
DataViewPrototypeGetByteLength,
|
||||||
|
@ -32,11 +42,9 @@ const {
|
||||||
Uint32Array,
|
Uint32Array,
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
const {
|
|
||||||
isDataView,
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
isSharedArrayBuffer,
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
isTypedArray,
|
|
||||||
} = core;
|
|
||||||
|
|
||||||
class TextDecoder {
|
class TextDecoder {
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
|
@ -63,7 +71,7 @@ class TextDecoder {
|
||||||
prefix,
|
prefix,
|
||||||
"Argument 2",
|
"Argument 2",
|
||||||
);
|
);
|
||||||
const encoding = ops.op_encoding_normalize_label(label);
|
const encoding = op_encoding_normalize_label(label);
|
||||||
this.#encoding = encoding;
|
this.#encoding = encoding;
|
||||||
this.#fatal = options.fatal;
|
this.#fatal = options.fatal;
|
||||||
this.#ignoreBOM = options.ignoreBOM;
|
this.#ignoreBOM = options.ignoreBOM;
|
||||||
|
@ -154,10 +162,10 @@ class TextDecoder {
|
||||||
if (!stream && this.#rid === null) {
|
if (!stream && this.#rid === null) {
|
||||||
// Fast path for utf8 single pass encoding.
|
// Fast path for utf8 single pass encoding.
|
||||||
if (this.#utf8SinglePass) {
|
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,
|
input,
|
||||||
this.#encoding,
|
this.#encoding,
|
||||||
this.#fatal,
|
this.#fatal,
|
||||||
|
@ -166,13 +174,13 @@ class TextDecoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.#rid === null) {
|
if (this.#rid === null) {
|
||||||
this.#rid = ops.op_encoding_new_decoder(
|
this.#rid = op_encoding_new_decoder(
|
||||||
this.#encoding,
|
this.#encoding,
|
||||||
this.#fatal,
|
this.#fatal,
|
||||||
this.#ignoreBOM,
|
this.#ignoreBOM,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return ops.op_encoding_decode(input, this.#rid, stream);
|
return op_encoding_decode(input, this.#rid, stream);
|
||||||
} finally {
|
} finally {
|
||||||
if (!stream && this.#rid !== null) {
|
if (!stream && this.#rid !== null) {
|
||||||
core.close(this.#rid);
|
core.close(this.#rid);
|
||||||
|
@ -246,7 +254,7 @@ class TextEncoder {
|
||||||
allowShared: true,
|
allowShared: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
ops.op_encoding_encode_into(source, destination, encodeIntoBuf);
|
op_encoding_encode_into(source, destination, encodeIntoBuf);
|
||||||
return {
|
return {
|
||||||
read: encodeIntoBuf[0],
|
read: encodeIntoBuf[0],
|
||||||
written: encodeIntoBuf[1],
|
written: encodeIntoBuf[1],
|
||||||
|
|
|
@ -11,10 +11,21 @@
|
||||||
/// <reference lib="esnext" />
|
/// <reference lib="esnext" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
isAnyArrayBuffer,
|
||||||
import { ReadableStream } from "ext:deno_web/06_streams.js";
|
isArrayBuffer,
|
||||||
import { URL } from "ext:deno_url/00_url.js";
|
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 {
|
const {
|
||||||
ArrayBufferIsView,
|
ArrayBufferIsView,
|
||||||
ArrayBufferPrototypeGetByteLength,
|
ArrayBufferPrototypeGetByteLength,
|
||||||
|
@ -44,16 +55,11 @@ const {
|
||||||
TypedArrayPrototypeSet,
|
TypedArrayPrototypeSet,
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
const {
|
|
||||||
isAnyArrayBuffer,
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
isArrayBuffer,
|
import { ReadableStream } from "ext:deno_web/06_streams.js";
|
||||||
isDataView,
|
import { URL } from "ext:deno_url/00_url.js";
|
||||||
isTypedArray,
|
|
||||||
} = core;
|
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.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
|
// TODO(lucacasonato): this needs to not be hardcoded and instead depend on
|
||||||
// host os.
|
// host os.
|
||||||
|
@ -568,7 +574,7 @@ webidl.converters["FilePropertyBag"] = webidl.createDictionaryConverter(
|
||||||
// A finalization registry to deallocate a blob part when its JS reference is
|
// A finalization registry to deallocate a blob part when its JS reference is
|
||||||
// garbage collected.
|
// garbage collected.
|
||||||
const registry = new SafeFinalizationRegistry((uuid) => {
|
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
|
// TODO(lucacasonato): get a better stream from Rust in BlobReference#stream
|
||||||
|
@ -596,7 +602,7 @@ class BlobReference {
|
||||||
* @returns {BlobReference}
|
* @returns {BlobReference}
|
||||||
*/
|
*/
|
||||||
static fromUint8Array(data) {
|
static fromUint8Array(data) {
|
||||||
const id = ops.op_blob_create_part(data);
|
const id = op_blob_create_part(data);
|
||||||
return new BlobReference(id, TypedArrayPrototypeGetByteLength(data));
|
return new BlobReference(id, TypedArrayPrototypeGetByteLength(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -611,7 +617,7 @@ class BlobReference {
|
||||||
*/
|
*/
|
||||||
slice(start, end) {
|
slice(start, end) {
|
||||||
const size = end - start;
|
const size = end - start;
|
||||||
const id = ops.op_blob_slice_part(this._id, {
|
const id = op_blob_slice_part(this._id, {
|
||||||
start,
|
start,
|
||||||
len: size,
|
len: size,
|
||||||
});
|
});
|
||||||
|
@ -651,7 +657,7 @@ class BlobReference {
|
||||||
* @returns {Blob | null}
|
* @returns {Blob | null}
|
||||||
*/
|
*/
|
||||||
function blobFromObjectUrl(url) {
|
function blobFromObjectUrl(url) {
|
||||||
const blobData = ops.op_blob_from_object_url(url);
|
const blobData = op_blob_from_object_url(url);
|
||||||
if (blobData === null) {
|
if (blobData === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -682,7 +688,7 @@ function createObjectURL(blob) {
|
||||||
webidl.requiredArguments(arguments.length, 1, prefix);
|
webidl.requiredArguments(arguments.length, 1, prefix);
|
||||||
blob = webidl.converters["Blob"](blob, prefix, "Argument 1");
|
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);
|
webidl.requiredArguments(arguments.length, 1, prefix);
|
||||||
url = webidl.converters["DOMString"](url, prefix, "Argument 1");
|
url = webidl.converters["DOMString"](url, prefix, "Argument 1");
|
||||||
|
|
||||||
ops.op_blob_revoke_object_url(url);
|
op_blob_revoke_object_url(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
URL.createObjectURL = createObjectURL;
|
URL.createObjectURL = createObjectURL;
|
||||||
|
|
|
@ -11,14 +11,9 @@
|
||||||
/// <reference lib="esnext" />
|
/// <reference lib="esnext" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
op_encode_binary_string,
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
} = core.ensureFastOps();
|
||||||
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 {
|
const {
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
ArrayPrototypeReduce,
|
ArrayPrototypeReduce,
|
||||||
|
@ -40,6 +35,14 @@ const {
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
} = primordials;
|
} = 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 state = Symbol("[[state]]");
|
||||||
const result = Symbol("[[result]]");
|
const result = Symbol("[[result]]");
|
||||||
const error = Symbol("[[error]]");
|
const error = Symbol("[[error]]");
|
||||||
|
@ -171,7 +174,7 @@ class FileReader extends EventTarget {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "BinaryString":
|
case "BinaryString":
|
||||||
this[result] = ops.op_encode_binary_string(bytes);
|
this[result] = op_encode_binary_string(bytes);
|
||||||
break;
|
break;
|
||||||
case "Text": {
|
case "Text": {
|
||||||
let decoder = undefined;
|
let decoder = undefined;
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
/// <reference path="../../core/internal.d.ts" />
|
/// <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";
|
import { primordials } from "ext:core/mod.js";
|
||||||
const {
|
const {
|
||||||
Error,
|
Error,
|
||||||
|
@ -17,6 +15,9 @@ const {
|
||||||
WeakMapPrototypeSet,
|
WeakMapPrototypeSet,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import { URL } from "ext:deno_url/00_url.js";
|
||||||
|
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
||||||
|
|
||||||
const locationConstructorKey = Symbol("locationConstructorKey");
|
const locationConstructorKey = Symbol("locationConstructorKey");
|
||||||
|
|
||||||
// The differences between the definitions of `Location` and `WorkerLocation`
|
// The differences between the definitions of `Location` and `WorkerLocation`
|
||||||
|
|
|
@ -6,12 +6,17 @@
|
||||||
/// <reference path="./lib.deno_web.d.ts" />
|
/// <reference path="./lib.deno_web.d.ts" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
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 {
|
const {
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
TypedArrayPrototypeGetByteLength,
|
TypedArrayPrototypeGetByteLength,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
import { TransformStream } from "ext:deno_web/06_streams.js";
|
import { TransformStream } from "ext:deno_web/06_streams.js";
|
||||||
|
@ -33,19 +38,19 @@ class CompressionStream {
|
||||||
webidl.requiredArguments(arguments.length, 1, prefix);
|
webidl.requiredArguments(arguments.length, 1, prefix);
|
||||||
format = webidl.converters.CompressionFormat(format, prefix, "Argument 1");
|
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({
|
this.#transform = new TransformStream({
|
||||||
transform(chunk, controller) {
|
transform(chunk, controller) {
|
||||||
chunk = webidl.converters.BufferSource(chunk, prefix, "chunk");
|
chunk = webidl.converters.BufferSource(chunk, prefix, "chunk");
|
||||||
const output = ops.op_compression_write(
|
const output = op_compression_write(
|
||||||
rid,
|
rid,
|
||||||
chunk,
|
chunk,
|
||||||
);
|
);
|
||||||
maybeEnqueue(controller, output);
|
maybeEnqueue(controller, output);
|
||||||
},
|
},
|
||||||
flush(controller) {
|
flush(controller) {
|
||||||
const output = ops.op_compression_finish(rid);
|
const output = op_compression_finish(rid);
|
||||||
maybeEnqueue(controller, output);
|
maybeEnqueue(controller, output);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -92,19 +97,19 @@ class DecompressionStream {
|
||||||
webidl.requiredArguments(arguments.length, 1, prefix);
|
webidl.requiredArguments(arguments.length, 1, prefix);
|
||||||
format = webidl.converters.CompressionFormat(format, prefix, "Argument 1");
|
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({
|
this.#transform = new TransformStream({
|
||||||
transform(chunk, controller) {
|
transform(chunk, controller) {
|
||||||
chunk = webidl.converters.BufferSource(chunk, prefix, "chunk");
|
chunk = webidl.converters.BufferSource(chunk, prefix, "chunk");
|
||||||
const output = ops.op_compression_write(
|
const output = op_compression_write(
|
||||||
rid,
|
rid,
|
||||||
chunk,
|
chunk,
|
||||||
);
|
);
|
||||||
maybeEnqueue(controller, output);
|
maybeEnqueue(controller, output);
|
||||||
},
|
},
|
||||||
flush(controller) {
|
flush(controller) {
|
||||||
const output = ops.op_compression_finish(rid);
|
const output = op_compression_finish(rid);
|
||||||
maybeEnqueue(controller, output);
|
maybeEnqueue(controller, output);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,6 +14,7 @@ const {
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
TypeError,
|
TypeError,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
import { structuredClone } from "ext:deno_web/02_structured_clone.js";
|
import { structuredClone } from "ext:deno_web/02_structured_clone.js";
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import { primordials } from "ext:core/mod.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;
|
|
||||||
const {
|
const {
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
|
@ -12,6 +9,10 @@ const {
|
||||||
Uint8ClampedArray,
|
Uint8ClampedArray,
|
||||||
} = primordials;
|
} = 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(
|
webidl.converters["PredefinedColorSpace"] = webidl.createEnumConverter(
|
||||||
"PredefinedColorSpace",
|
"PredefinedColorSpace",
|
||||||
[
|
[
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core } from "ext:core/mod.js";
|
import { core } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
|
op_lazy_load_esm,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
|
|
||||||
let webgpu;
|
let webgpu;
|
||||||
|
|
||||||
|
@ -32,7 +34,7 @@ function webGPUNonEnumerable(getter) {
|
||||||
|
|
||||||
function loadWebGPU() {
|
function loadWebGPU() {
|
||||||
if (!webgpu) {
|
if (!webgpu) {
|
||||||
webgpu = ops.op_lazy_load_esm("ext:deno_webgpu/01_webgpu.js");
|
webgpu = op_lazy_load_esm("ext:deno_webgpu/01_webgpu.js");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,24 +7,101 @@
|
||||||
/// <reference path="./lib.deno_webgpu.d.ts" />
|
/// <reference path="./lib.deno_webgpu.d.ts" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
isDataView,
|
||||||
import { EventTarget } from "ext:deno_web/02_event.js";
|
isTypedArray,
|
||||||
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
} = core;
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
const {
|
||||||
|
op_webgpu_buffer_get_map_async,
|
||||||
|
op_webgpu_buffer_get_mapped_range,
|
||||||
|
op_webgpu_buffer_unmap,
|
||||||
|
op_webgpu_command_encoder_begin_compute_pass,
|
||||||
|
op_webgpu_command_encoder_begin_render_pass,
|
||||||
|
op_webgpu_command_encoder_clear_buffer,
|
||||||
|
op_webgpu_command_encoder_copy_buffer_to_buffer,
|
||||||
|
op_webgpu_command_encoder_copy_buffer_to_texture,
|
||||||
|
op_webgpu_command_encoder_copy_texture_to_buffer,
|
||||||
|
op_webgpu_command_encoder_copy_texture_to_texture,
|
||||||
|
op_webgpu_command_encoder_finish,
|
||||||
|
op_webgpu_command_encoder_insert_debug_marker,
|
||||||
|
op_webgpu_command_encoder_pop_debug_group,
|
||||||
|
op_webgpu_command_encoder_push_debug_group,
|
||||||
|
op_webgpu_command_encoder_resolve_query_set,
|
||||||
|
op_webgpu_command_encoder_write_timestamp,
|
||||||
|
op_webgpu_compute_pass_dispatch_workgroups,
|
||||||
|
op_webgpu_compute_pass_dispatch_workgroups_indirect,
|
||||||
|
op_webgpu_compute_pass_end,
|
||||||
|
op_webgpu_compute_pass_insert_debug_marker,
|
||||||
|
op_webgpu_compute_pass_pop_debug_group,
|
||||||
|
op_webgpu_compute_pass_push_debug_group,
|
||||||
|
op_webgpu_compute_pass_set_bind_group,
|
||||||
|
op_webgpu_compute_pass_set_pipeline,
|
||||||
|
op_webgpu_compute_pipeline_get_bind_group_layout,
|
||||||
|
op_webgpu_create_bind_group,
|
||||||
|
op_webgpu_create_bind_group_layout,
|
||||||
|
op_webgpu_create_buffer,
|
||||||
|
op_webgpu_create_command_encoder,
|
||||||
|
op_webgpu_create_compute_pipeline,
|
||||||
|
op_webgpu_create_pipeline_layout,
|
||||||
|
op_webgpu_create_query_set,
|
||||||
|
op_webgpu_create_render_bundle_encoder,
|
||||||
|
op_webgpu_create_render_pipeline,
|
||||||
|
op_webgpu_create_sampler,
|
||||||
|
op_webgpu_create_shader_module,
|
||||||
|
op_webgpu_create_texture,
|
||||||
|
op_webgpu_create_texture_view,
|
||||||
|
op_webgpu_queue_submit,
|
||||||
|
op_webgpu_render_bundle_encoder_draw,
|
||||||
|
op_webgpu_render_bundle_encoder_draw_indexed,
|
||||||
|
op_webgpu_render_bundle_encoder_draw_indirect,
|
||||||
|
op_webgpu_render_bundle_encoder_finish,
|
||||||
|
op_webgpu_render_bundle_encoder_insert_debug_marker,
|
||||||
|
op_webgpu_render_bundle_encoder_pop_debug_group,
|
||||||
|
op_webgpu_render_bundle_encoder_push_debug_group,
|
||||||
|
op_webgpu_render_bundle_encoder_set_bind_group,
|
||||||
|
op_webgpu_render_bundle_encoder_set_index_buffer,
|
||||||
|
op_webgpu_render_bundle_encoder_set_pipeline,
|
||||||
|
op_webgpu_render_bundle_encoder_set_vertex_buffer,
|
||||||
|
op_webgpu_render_pass_begin_occlusion_query,
|
||||||
|
op_webgpu_render_pass_draw,
|
||||||
|
op_webgpu_render_pass_draw_indexed,
|
||||||
|
op_webgpu_render_pass_draw_indexed_indirect,
|
||||||
|
op_webgpu_render_pass_draw_indirect,
|
||||||
|
op_webgpu_render_pass_end,
|
||||||
|
op_webgpu_render_pass_end_occlusion_query,
|
||||||
|
op_webgpu_render_pass_execute_bundles,
|
||||||
|
op_webgpu_render_pass_insert_debug_marker,
|
||||||
|
op_webgpu_render_pass_pop_debug_group,
|
||||||
|
op_webgpu_render_pass_push_debug_group,
|
||||||
|
op_webgpu_render_pass_set_bind_group,
|
||||||
|
op_webgpu_render_pass_set_blend_constant,
|
||||||
|
op_webgpu_render_pass_set_index_buffer,
|
||||||
|
op_webgpu_render_pass_set_pipeline,
|
||||||
|
op_webgpu_render_pass_set_scissor_rect,
|
||||||
|
op_webgpu_render_pass_set_stencil_reference,
|
||||||
|
op_webgpu_render_pass_set_vertex_buffer,
|
||||||
|
op_webgpu_render_pass_set_viewport,
|
||||||
|
op_webgpu_render_pipeline_get_bind_group_layout,
|
||||||
|
op_webgpu_request_adapter,
|
||||||
|
op_webgpu_request_adapter_info,
|
||||||
|
op_webgpu_request_device,
|
||||||
|
op_webgpu_write_buffer,
|
||||||
|
op_webgpu_write_texture,
|
||||||
|
} = core.ensureFastOps();
|
||||||
const {
|
const {
|
||||||
ArrayBuffer,
|
ArrayBuffer,
|
||||||
|
ArrayBufferPrototypeGetByteLength,
|
||||||
ArrayIsArray,
|
ArrayIsArray,
|
||||||
ArrayPrototypeFilter,
|
ArrayPrototypeFilter,
|
||||||
|
ArrayPrototypeIncludes,
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
ArrayPrototypePop,
|
ArrayPrototypePop,
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
ObjectHasOwn,
|
DataViewPrototypeGetBuffer,
|
||||||
ArrayPrototypeIncludes,
|
|
||||||
ArrayBufferPrototypeGetByteLength,
|
|
||||||
Error,
|
Error,
|
||||||
MathMax,
|
MathMax,
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
|
ObjectHasOwn,
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
Promise,
|
Promise,
|
||||||
PromisePrototypeCatch,
|
PromisePrototypeCatch,
|
||||||
|
@ -34,28 +111,22 @@ const {
|
||||||
SafeArrayIterator,
|
SafeArrayIterator,
|
||||||
SafePromiseAll,
|
SafePromiseAll,
|
||||||
SafeSet,
|
SafeSet,
|
||||||
TypedArrayPrototypeGetSymbolToStringTag,
|
|
||||||
TypedArrayPrototypeGetBuffer,
|
|
||||||
DataViewPrototypeGetBuffer,
|
|
||||||
SafeWeakRef,
|
SafeWeakRef,
|
||||||
SetPrototypeHas,
|
SetPrototypeHas,
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
SymbolIterator,
|
SymbolIterator,
|
||||||
TypeError,
|
TypeError,
|
||||||
|
TypedArrayPrototypeGetBuffer,
|
||||||
|
TypedArrayPrototypeGetSymbolToStringTag,
|
||||||
Uint32Array,
|
Uint32Array,
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
const {
|
|
||||||
isDataView,
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
isTypedArray,
|
import { EventTarget } from "ext:deno_web/02_event.js";
|
||||||
} = core;
|
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
||||||
const {
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
op_webgpu_buffer_get_map_async,
|
|
||||||
op_webgpu_request_adapter,
|
|
||||||
op_webgpu_request_adapter_info,
|
|
||||||
op_webgpu_request_device,
|
|
||||||
} = core.ensureFastOps();
|
|
||||||
|
|
||||||
const _rid = Symbol("[[rid]]");
|
const _rid = Symbol("[[rid]]");
|
||||||
const _size = Symbol("[[size]]");
|
const _size = Symbol("[[size]]");
|
||||||
|
@ -994,7 +1065,7 @@ class GPUDevice extends EventTarget {
|
||||||
"Argument 1",
|
"Argument 1",
|
||||||
);
|
);
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const { rid, err } = ops.op_webgpu_create_buffer(
|
const { rid, err } = op_webgpu_create_buffer(
|
||||||
device.rid,
|
device.rid,
|
||||||
descriptor.label,
|
descriptor.label,
|
||||||
descriptor.size,
|
descriptor.size,
|
||||||
|
@ -1045,7 +1116,7 @@ class GPUDevice extends EventTarget {
|
||||||
"Argument 1",
|
"Argument 1",
|
||||||
);
|
);
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const { rid, err } = ops.op_webgpu_create_texture({
|
const { rid, err } = op_webgpu_create_texture({
|
||||||
deviceRid: device.rid,
|
deviceRid: device.rid,
|
||||||
...descriptor,
|
...descriptor,
|
||||||
size: normalizeGPUExtent3D(descriptor.size),
|
size: normalizeGPUExtent3D(descriptor.size),
|
||||||
|
@ -1074,7 +1145,7 @@ class GPUDevice extends EventTarget {
|
||||||
"Argument 1",
|
"Argument 1",
|
||||||
);
|
);
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const { rid, err } = ops.op_webgpu_create_sampler({
|
const { rid, err } = op_webgpu_create_sampler({
|
||||||
deviceRid: device.rid,
|
deviceRid: device.rid,
|
||||||
...descriptor,
|
...descriptor,
|
||||||
});
|
});
|
||||||
|
@ -1118,7 +1189,7 @@ class GPUDevice extends EventTarget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { rid, err } = ops.op_webgpu_create_bind_group_layout(
|
const { rid, err } = op_webgpu_create_bind_group_layout(
|
||||||
device.rid,
|
device.rid,
|
||||||
descriptor.label,
|
descriptor.label,
|
||||||
descriptor.entries,
|
descriptor.entries,
|
||||||
|
@ -1161,7 +1232,7 @@ class GPUDevice extends EventTarget {
|
||||||
return rid;
|
return rid;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const { rid, err } = ops.op_webgpu_create_pipeline_layout(
|
const { rid, err } = op_webgpu_create_pipeline_layout(
|
||||||
device.rid,
|
device.rid,
|
||||||
descriptor.label,
|
descriptor.label,
|
||||||
bindGroupLayouts,
|
bindGroupLayouts,
|
||||||
|
@ -1246,7 +1317,7 @@ class GPUDevice extends EventTarget {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const { rid, err } = ops.op_webgpu_create_bind_group(
|
const { rid, err } = op_webgpu_create_bind_group(
|
||||||
device.rid,
|
device.rid,
|
||||||
descriptor.label,
|
descriptor.label,
|
||||||
layout,
|
layout,
|
||||||
|
@ -1276,7 +1347,7 @@ class GPUDevice extends EventTarget {
|
||||||
"Argument 1",
|
"Argument 1",
|
||||||
);
|
);
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const { rid, err } = ops.op_webgpu_create_shader_module(
|
const { rid, err } = op_webgpu_create_shader_module(
|
||||||
device.rid,
|
device.rid,
|
||||||
descriptor.label,
|
descriptor.label,
|
||||||
descriptor.code,
|
descriptor.code,
|
||||||
|
@ -1327,7 +1398,7 @@ class GPUDevice extends EventTarget {
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
|
|
||||||
const { rid, err } = ops.op_webgpu_create_compute_pipeline(
|
const { rid, err } = op_webgpu_create_compute_pipeline(
|
||||||
device.rid,
|
device.rid,
|
||||||
descriptor.label,
|
descriptor.label,
|
||||||
layout,
|
layout,
|
||||||
|
@ -1401,7 +1472,7 @@ class GPUDevice extends EventTarget {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const { rid, err } = ops.op_webgpu_create_render_pipeline({
|
const { rid, err } = op_webgpu_create_render_pipeline({
|
||||||
deviceRid: device.rid,
|
deviceRid: device.rid,
|
||||||
label: descriptor.label,
|
label: descriptor.label,
|
||||||
layout,
|
layout,
|
||||||
|
@ -1449,7 +1520,7 @@ class GPUDevice extends EventTarget {
|
||||||
"Argument 1",
|
"Argument 1",
|
||||||
);
|
);
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const { rid, err } = ops.op_webgpu_create_command_encoder(
|
const { rid, err } = op_webgpu_create_command_encoder(
|
||||||
device.rid,
|
device.rid,
|
||||||
descriptor.label,
|
descriptor.label,
|
||||||
);
|
);
|
||||||
|
@ -1479,7 +1550,7 @@ class GPUDevice extends EventTarget {
|
||||||
"Argument 1",
|
"Argument 1",
|
||||||
);
|
);
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const { rid, err } = ops.op_webgpu_create_render_bundle_encoder({
|
const { rid, err } = op_webgpu_create_render_bundle_encoder({
|
||||||
deviceRid: device.rid,
|
deviceRid: device.rid,
|
||||||
...descriptor,
|
...descriptor,
|
||||||
});
|
});
|
||||||
|
@ -1508,7 +1579,7 @@ class GPUDevice extends EventTarget {
|
||||||
"Argument 1",
|
"Argument 1",
|
||||||
);
|
);
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const { rid, err } = ops.op_webgpu_create_query_set({
|
const { rid, err } = op_webgpu_create_query_set({
|
||||||
deviceRid: device.rid,
|
deviceRid: device.rid,
|
||||||
...descriptor,
|
...descriptor,
|
||||||
});
|
});
|
||||||
|
@ -1645,7 +1716,7 @@ class GPUQueue {
|
||||||
return rid;
|
return rid;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const { err } = ops.op_webgpu_queue_submit(device.rid, commandBufferRids);
|
const { err } = op_webgpu_queue_submit(device.rid, commandBufferRids);
|
||||||
for (let i = 0; i < commandBuffers.length; ++i) {
|
for (let i = 0; i < commandBuffers.length; ++i) {
|
||||||
commandBuffers[i][_rid] = undefined;
|
commandBuffers[i][_rid] = undefined;
|
||||||
}
|
}
|
||||||
|
@ -1700,7 +1771,7 @@ class GPUQueue {
|
||||||
abLike = DataViewPrototypeGetBuffer(/** @type {DataView} */ (data));
|
abLike = DataViewPrototypeGetBuffer(/** @type {DataView} */ (data));
|
||||||
}
|
}
|
||||||
|
|
||||||
const { err } = ops.op_webgpu_write_buffer(
|
const { err } = op_webgpu_write_buffer(
|
||||||
device.rid,
|
device.rid,
|
||||||
bufferRid,
|
bufferRid,
|
||||||
bufferOffset,
|
bufferOffset,
|
||||||
|
@ -1751,7 +1822,7 @@ class GPUQueue {
|
||||||
abLike = DataViewPrototypeGetBuffer(/** @type {DataView} */ (data));
|
abLike = DataViewPrototypeGetBuffer(/** @type {DataView} */ (data));
|
||||||
}
|
}
|
||||||
|
|
||||||
const { err } = ops.op_webgpu_write_texture(
|
const { err } = op_webgpu_write_texture(
|
||||||
device.rid,
|
device.rid,
|
||||||
{
|
{
|
||||||
texture: textureRid,
|
texture: textureRid,
|
||||||
|
@ -2008,7 +2079,7 @@ class GPUBuffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
const buffer = new ArrayBuffer(rangeSize);
|
const buffer = new ArrayBuffer(rangeSize);
|
||||||
const { rid } = ops.op_webgpu_buffer_get_mapped_range(
|
const { rid } = op_webgpu_buffer_get_mapped_range(
|
||||||
bufferRid,
|
bufferRid,
|
||||||
offset,
|
offset,
|
||||||
size,
|
size,
|
||||||
|
@ -2063,7 +2134,7 @@ class GPUBuffer {
|
||||||
}
|
}
|
||||||
for (let i = 0; i < mappedRanges.length; ++i) {
|
for (let i = 0; i < mappedRanges.length; ++i) {
|
||||||
const { 0: buffer, 1: mappedRid } = mappedRanges[i];
|
const { 0: buffer, 1: mappedRid } = mappedRanges[i];
|
||||||
const { err } = ops.op_webgpu_buffer_unmap(
|
const { err } = op_webgpu_buffer_unmap(
|
||||||
bufferRid,
|
bufferRid,
|
||||||
mappedRid,
|
mappedRid,
|
||||||
...new SafeArrayIterator(write ? [new Uint8Array(buffer)] : []),
|
...new SafeArrayIterator(write ? [new Uint8Array(buffer)] : []),
|
||||||
|
@ -2235,7 +2306,7 @@ class GPUTexture {
|
||||||
);
|
);
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const textureRid = assertResource(this, prefix, "this");
|
const textureRid = assertResource(this, prefix, "this");
|
||||||
const { rid, err } = ops.op_webgpu_create_texture_view({
|
const { rid, err } = op_webgpu_create_texture_view({
|
||||||
textureRid,
|
textureRid,
|
||||||
...descriptor,
|
...descriptor,
|
||||||
});
|
});
|
||||||
|
@ -2694,8 +2765,8 @@ class GPUComputePipeline {
|
||||||
index = webidl.converters["unsigned long"](index, prefix, "Argument 1");
|
index = webidl.converters["unsigned long"](index, prefix, "Argument 1");
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const computePipelineRid = assertResource(this, prefix, "this");
|
const computePipelineRid = assertResource(this, prefix, "this");
|
||||||
const { rid, label, err } = ops
|
const { rid, label, err } =
|
||||||
.op_webgpu_compute_pipeline_get_bind_group_layout(
|
op_webgpu_compute_pipeline_get_bind_group_layout(
|
||||||
computePipelineRid,
|
computePipelineRid,
|
||||||
index,
|
index,
|
||||||
);
|
);
|
||||||
|
@ -2773,11 +2844,10 @@ class GPURenderPipeline {
|
||||||
index = webidl.converters["unsigned long"](index, prefix, "Argument 1");
|
index = webidl.converters["unsigned long"](index, prefix, "Argument 1");
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const renderPipelineRid = assertResource(this, prefix, "this");
|
const renderPipelineRid = assertResource(this, prefix, "this");
|
||||||
const { rid, label, err } = ops
|
const { rid, label, err } = op_webgpu_render_pipeline_get_bind_group_layout(
|
||||||
.op_webgpu_render_pipeline_get_bind_group_layout(
|
renderPipelineRid,
|
||||||
renderPipelineRid,
|
index,
|
||||||
index,
|
);
|
||||||
);
|
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
|
|
||||||
const bindGroupLayout = createGPUBindGroupLayout(
|
const bindGroupLayout = createGPUBindGroupLayout(
|
||||||
|
@ -3011,7 +3081,7 @@ class GPUCommandEncoder {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const { rid } = ops.op_webgpu_command_encoder_begin_render_pass(
|
const { rid } = op_webgpu_command_encoder_begin_render_pass(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
descriptor.label,
|
descriptor.label,
|
||||||
colorAttachments,
|
colorAttachments,
|
||||||
|
@ -3061,7 +3131,7 @@ class GPUCommandEncoder {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const { rid } = ops.op_webgpu_command_encoder_begin_compute_pass(
|
const { rid } = op_webgpu_command_encoder_begin_compute_pass(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
descriptor.label,
|
descriptor.label,
|
||||||
timestampWrites,
|
timestampWrites,
|
||||||
|
@ -3126,7 +3196,7 @@ class GPUCommandEncoder {
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
|
|
||||||
const { err } = ops.op_webgpu_command_encoder_copy_buffer_to_buffer(
|
const { err } = op_webgpu_command_encoder_copy_buffer_to_buffer(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
sourceRid,
|
sourceRid,
|
||||||
sourceOffset,
|
sourceOffset,
|
||||||
|
@ -3179,7 +3249,7 @@ class GPUCommandEncoder {
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
|
|
||||||
const { err } = ops.op_webgpu_command_encoder_copy_buffer_to_texture(
|
const { err } = op_webgpu_command_encoder_copy_buffer_to_texture(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
{
|
{
|
||||||
...source,
|
...source,
|
||||||
|
@ -3243,7 +3313,7 @@ class GPUCommandEncoder {
|
||||||
resourceContext: "buffer in Argument 2",
|
resourceContext: "buffer in Argument 2",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
const { err } = ops.op_webgpu_command_encoder_copy_texture_to_buffer(
|
const { err } = op_webgpu_command_encoder_copy_texture_to_buffer(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
{
|
{
|
||||||
texture: sourceTextureRid,
|
texture: sourceTextureRid,
|
||||||
|
@ -3303,7 +3373,7 @@ class GPUCommandEncoder {
|
||||||
resourceContext: "texture in Argument 2",
|
resourceContext: "texture in Argument 2",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
const { err } = ops.op_webgpu_command_encoder_copy_texture_to_texture(
|
const { err } = op_webgpu_command_encoder_copy_texture_to_texture(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
{
|
{
|
||||||
texture: sourceTextureRid,
|
texture: sourceTextureRid,
|
||||||
|
@ -3339,7 +3409,7 @@ class GPUCommandEncoder {
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const commandEncoderRid = assertResource(this, prefix, "this");
|
const commandEncoderRid = assertResource(this, prefix, "this");
|
||||||
const bufferRid = assertResource(buffer, prefix, "Argument 1");
|
const bufferRid = assertResource(buffer, prefix, "Argument 1");
|
||||||
const { err } = ops.op_webgpu_command_encoder_clear_buffer(
|
const { err } = op_webgpu_command_encoder_clear_buffer(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
bufferRid,
|
bufferRid,
|
||||||
offset,
|
offset,
|
||||||
|
@ -3358,7 +3428,7 @@ class GPUCommandEncoder {
|
||||||
groupLabel = webidl.converters.USVString(groupLabel, prefix, "Argument 1");
|
groupLabel = webidl.converters.USVString(groupLabel, prefix, "Argument 1");
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const commandEncoderRid = assertResource(this, prefix, "this");
|
const commandEncoderRid = assertResource(this, prefix, "this");
|
||||||
const { err } = ops.op_webgpu_command_encoder_push_debug_group(
|
const { err } = op_webgpu_command_encoder_push_debug_group(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
groupLabel,
|
groupLabel,
|
||||||
);
|
);
|
||||||
|
@ -3370,7 +3440,7 @@ class GPUCommandEncoder {
|
||||||
const prefix = "Failed to execute 'popDebugGroup' on 'GPUCommandEncoder'";
|
const prefix = "Failed to execute 'popDebugGroup' on 'GPUCommandEncoder'";
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const commandEncoderRid = assertResource(this, prefix, "this");
|
const commandEncoderRid = assertResource(this, prefix, "this");
|
||||||
const { err } = ops.op_webgpu_command_encoder_pop_debug_group(
|
const { err } = op_webgpu_command_encoder_pop_debug_group(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
);
|
);
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
|
@ -3391,7 +3461,7 @@ class GPUCommandEncoder {
|
||||||
);
|
);
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const commandEncoderRid = assertResource(this, prefix, "this");
|
const commandEncoderRid = assertResource(this, prefix, "this");
|
||||||
const { err } = ops.op_webgpu_command_encoder_insert_debug_marker(
|
const { err } = op_webgpu_command_encoder_insert_debug_marker(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
markerLabel,
|
markerLabel,
|
||||||
);
|
);
|
||||||
|
@ -3416,7 +3486,7 @@ class GPUCommandEncoder {
|
||||||
resourceContext: "Argument 1",
|
resourceContext: "Argument 1",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
const { err } = ops.op_webgpu_command_encoder_write_timestamp(
|
const { err } = op_webgpu_command_encoder_write_timestamp(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
querySetRid,
|
querySetRid,
|
||||||
queryIndex,
|
queryIndex,
|
||||||
|
@ -3468,7 +3538,7 @@ class GPUCommandEncoder {
|
||||||
resourceContext: "Argument 3",
|
resourceContext: "Argument 3",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
const { err } = ops.op_webgpu_command_encoder_resolve_query_set(
|
const { err } = op_webgpu_command_encoder_resolve_query_set(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
querySetRid,
|
querySetRid,
|
||||||
firstQuery,
|
firstQuery,
|
||||||
|
@ -3493,7 +3563,7 @@ class GPUCommandEncoder {
|
||||||
);
|
);
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const commandEncoderRid = assertResource(this, prefix, "this");
|
const commandEncoderRid = assertResource(this, prefix, "this");
|
||||||
const { rid, err } = ops.op_webgpu_command_encoder_finish(
|
const { rid, err } = op_webgpu_command_encoder_finish(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
descriptor.label,
|
descriptor.label,
|
||||||
);
|
);
|
||||||
|
@ -3584,7 +3654,7 @@ class GPURenderPassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const renderPassRid = assertResource(this, prefix, "this");
|
const renderPassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_pass_set_viewport({
|
op_webgpu_render_pass_set_viewport({
|
||||||
renderPassRid,
|
renderPassRid,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
|
@ -3617,7 +3687,7 @@ class GPURenderPassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const renderPassRid = assertResource(this, prefix, "this");
|
const renderPassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_pass_set_scissor_rect(
|
op_webgpu_render_pass_set_scissor_rect(
|
||||||
renderPassRid,
|
renderPassRid,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
|
@ -3638,7 +3708,7 @@ class GPURenderPassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const renderPassRid = assertResource(this, prefix, "this");
|
const renderPassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_pass_set_blend_constant(
|
op_webgpu_render_pass_set_blend_constant(
|
||||||
renderPassRid,
|
renderPassRid,
|
||||||
normalizeGPUColor(color),
|
normalizeGPUColor(color),
|
||||||
);
|
);
|
||||||
|
@ -3660,7 +3730,7 @@ class GPURenderPassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const renderPassRid = assertResource(this, prefix, "this");
|
const renderPassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_pass_set_stencil_reference(
|
op_webgpu_render_pass_set_stencil_reference(
|
||||||
renderPassRid,
|
renderPassRid,
|
||||||
reference,
|
reference,
|
||||||
);
|
);
|
||||||
|
@ -3678,7 +3748,7 @@ class GPURenderPassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const renderPassRid = assertResource(this, prefix, "this");
|
const renderPassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_pass_begin_occlusion_query(
|
op_webgpu_render_pass_begin_occlusion_query(
|
||||||
renderPassRid,
|
renderPassRid,
|
||||||
queryIndex,
|
queryIndex,
|
||||||
);
|
);
|
||||||
|
@ -3691,7 +3761,7 @@ class GPURenderPassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const renderPassRid = assertResource(this, prefix, "this");
|
const renderPassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_pass_end_occlusion_query(renderPassRid);
|
op_webgpu_render_pass_end_occlusion_query(renderPassRid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3724,7 +3794,7 @@ class GPURenderPassEncoder {
|
||||||
});
|
});
|
||||||
return rid;
|
return rid;
|
||||||
});
|
});
|
||||||
ops.op_webgpu_render_pass_execute_bundles(renderPassRid, bundleRids);
|
op_webgpu_render_pass_execute_bundles(renderPassRid, bundleRids);
|
||||||
}
|
}
|
||||||
|
|
||||||
end() {
|
end() {
|
||||||
|
@ -3741,7 +3811,7 @@ class GPURenderPassEncoder {
|
||||||
"encoder referenced by this",
|
"encoder referenced by this",
|
||||||
);
|
);
|
||||||
const renderPassRid = assertResource(this, prefix, "this");
|
const renderPassRid = assertResource(this, prefix, "this");
|
||||||
const { err } = ops.op_webgpu_render_pass_end(
|
const { err } = op_webgpu_render_pass_end(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
renderPassRid,
|
renderPassRid,
|
||||||
);
|
);
|
||||||
|
@ -3780,7 +3850,7 @@ class GPURenderPassEncoder {
|
||||||
dynamicOffsetsDataStart = 0;
|
dynamicOffsetsDataStart = 0;
|
||||||
dynamicOffsetsDataLength = dynamicOffsetsData.length;
|
dynamicOffsetsDataLength = dynamicOffsetsData.length;
|
||||||
}
|
}
|
||||||
ops.op_webgpu_render_pass_set_bind_group(
|
op_webgpu_render_pass_set_bind_group(
|
||||||
renderPassRid,
|
renderPassRid,
|
||||||
index,
|
index,
|
||||||
bindGroupRid,
|
bindGroupRid,
|
||||||
|
@ -3802,7 +3872,7 @@ class GPURenderPassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const renderPassRid = assertResource(this, prefix, "this");
|
const renderPassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_pass_push_debug_group(renderPassRid, groupLabel);
|
op_webgpu_render_pass_push_debug_group(renderPassRid, groupLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
popDebugGroup() {
|
popDebugGroup() {
|
||||||
|
@ -3812,7 +3882,7 @@ class GPURenderPassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const renderPassRid = assertResource(this, prefix, "this");
|
const renderPassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_pass_pop_debug_group(renderPassRid);
|
op_webgpu_render_pass_pop_debug_group(renderPassRid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3831,7 +3901,7 @@ class GPURenderPassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const renderPassRid = assertResource(this, prefix, "this");
|
const renderPassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_pass_insert_debug_marker(renderPassRid, markerLabel);
|
op_webgpu_render_pass_insert_debug_marker(renderPassRid, markerLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3859,7 +3929,7 @@ class GPURenderPassEncoder {
|
||||||
resourceContext: "Argument 1",
|
resourceContext: "Argument 1",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
ops.op_webgpu_render_pass_set_pipeline(renderPassRid, pipelineRid);
|
op_webgpu_render_pass_set_pipeline(renderPassRid, pipelineRid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3896,7 +3966,7 @@ class GPURenderPassEncoder {
|
||||||
resourceContext: "Argument 1",
|
resourceContext: "Argument 1",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
ops.op_webgpu_render_pass_set_index_buffer(
|
op_webgpu_render_pass_set_index_buffer(
|
||||||
renderPassRid,
|
renderPassRid,
|
||||||
bufferRid,
|
bufferRid,
|
||||||
indexFormat,
|
indexFormat,
|
||||||
|
@ -3935,7 +4005,7 @@ class GPURenderPassEncoder {
|
||||||
resourceContext: "Argument 2",
|
resourceContext: "Argument 2",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
ops.op_webgpu_render_pass_set_vertex_buffer(
|
op_webgpu_render_pass_set_vertex_buffer(
|
||||||
renderPassRid,
|
renderPassRid,
|
||||||
slot,
|
slot,
|
||||||
bufferRid,
|
bufferRid,
|
||||||
|
@ -3977,7 +4047,7 @@ class GPURenderPassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const renderPassRid = assertResource(this, prefix, "this");
|
const renderPassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_pass_draw(
|
op_webgpu_render_pass_draw(
|
||||||
renderPassRid,
|
renderPassRid,
|
||||||
vertexCount,
|
vertexCount,
|
||||||
instanceCount,
|
instanceCount,
|
||||||
|
@ -4023,7 +4093,7 @@ class GPURenderPassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const renderPassRid = assertResource(this, prefix, "this");
|
const renderPassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_pass_draw_indexed(
|
op_webgpu_render_pass_draw_indexed(
|
||||||
renderPassRid,
|
renderPassRid,
|
||||||
indexCount,
|
indexCount,
|
||||||
instanceCount,
|
instanceCount,
|
||||||
|
@ -4068,7 +4138,7 @@ class GPURenderPassEncoder {
|
||||||
resourceContext: "Argument 1",
|
resourceContext: "Argument 1",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
ops.op_webgpu_render_pass_draw_indirect(
|
op_webgpu_render_pass_draw_indirect(
|
||||||
renderPassRid,
|
renderPassRid,
|
||||||
indirectBufferRid,
|
indirectBufferRid,
|
||||||
indirectOffset,
|
indirectOffset,
|
||||||
|
@ -4111,7 +4181,7 @@ class GPURenderPassEncoder {
|
||||||
resourceContext: "Argument 1",
|
resourceContext: "Argument 1",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
ops.op_webgpu_render_pass_draw_indexed_indirect(
|
op_webgpu_render_pass_draw_indexed_indirect(
|
||||||
renderPassRid,
|
renderPassRid,
|
||||||
indirectBufferRid,
|
indirectBufferRid,
|
||||||
indirectOffset,
|
indirectOffset,
|
||||||
|
@ -4197,7 +4267,7 @@ class GPUComputePassEncoder {
|
||||||
resourceContext: "Argument 1",
|
resourceContext: "Argument 1",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
ops.op_webgpu_compute_pass_set_pipeline(computePassRid, pipelineRid);
|
op_webgpu_compute_pass_set_pipeline(computePassRid, pipelineRid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4232,7 +4302,7 @@ class GPUComputePassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const computePassRid = assertResource(this, prefix, "this");
|
const computePassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_compute_pass_dispatch_workgroups(
|
op_webgpu_compute_pass_dispatch_workgroups(
|
||||||
computePassRid,
|
computePassRid,
|
||||||
workgroupCountX,
|
workgroupCountX,
|
||||||
workgroupCountY,
|
workgroupCountY,
|
||||||
|
@ -4276,7 +4346,7 @@ class GPUComputePassEncoder {
|
||||||
resourceContext: "Argument 1",
|
resourceContext: "Argument 1",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
ops.op_webgpu_compute_pass_dispatch_workgroups_indirect(
|
op_webgpu_compute_pass_dispatch_workgroups_indirect(
|
||||||
computePassRid,
|
computePassRid,
|
||||||
indirectBufferRid,
|
indirectBufferRid,
|
||||||
indirectOffset,
|
indirectOffset,
|
||||||
|
@ -4297,7 +4367,7 @@ class GPUComputePassEncoder {
|
||||||
"encoder referenced by this",
|
"encoder referenced by this",
|
||||||
);
|
);
|
||||||
const computePassRid = assertResource(this, prefix, "this");
|
const computePassRid = assertResource(this, prefix, "this");
|
||||||
const { err } = ops.op_webgpu_compute_pass_end(
|
const { err } = op_webgpu_compute_pass_end(
|
||||||
commandEncoderRid,
|
commandEncoderRid,
|
||||||
computePassRid,
|
computePassRid,
|
||||||
);
|
);
|
||||||
|
@ -4337,7 +4407,7 @@ class GPUComputePassEncoder {
|
||||||
dynamicOffsetsDataStart = 0;
|
dynamicOffsetsDataStart = 0;
|
||||||
dynamicOffsetsDataLength = dynamicOffsetsData.length;
|
dynamicOffsetsDataLength = dynamicOffsetsData.length;
|
||||||
}
|
}
|
||||||
ops.op_webgpu_compute_pass_set_bind_group(
|
op_webgpu_compute_pass_set_bind_group(
|
||||||
computePassRid,
|
computePassRid,
|
||||||
index,
|
index,
|
||||||
bindGroupRid,
|
bindGroupRid,
|
||||||
|
@ -4359,7 +4429,7 @@ class GPUComputePassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const computePassRid = assertResource(this, prefix, "this");
|
const computePassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_compute_pass_push_debug_group(computePassRid, groupLabel);
|
op_webgpu_compute_pass_push_debug_group(computePassRid, groupLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
popDebugGroup() {
|
popDebugGroup() {
|
||||||
|
@ -4369,7 +4439,7 @@ class GPUComputePassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const computePassRid = assertResource(this, prefix, "this");
|
const computePassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_compute_pass_pop_debug_group(computePassRid);
|
op_webgpu_compute_pass_pop_debug_group(computePassRid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4388,7 +4458,7 @@ class GPUComputePassEncoder {
|
||||||
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
assertDevice(this[_encoder], prefix, "encoder referenced by this");
|
||||||
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
assertResource(this[_encoder], prefix, "encoder referenced by this");
|
||||||
const computePassRid = assertResource(this, prefix, "this");
|
const computePassRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_compute_pass_insert_debug_marker(
|
op_webgpu_compute_pass_insert_debug_marker(
|
||||||
computePassRid,
|
computePassRid,
|
||||||
markerLabel,
|
markerLabel,
|
||||||
);
|
);
|
||||||
|
@ -4510,7 +4580,7 @@ class GPURenderBundleEncoder {
|
||||||
);
|
);
|
||||||
const device = assertDevice(this, prefix, "this");
|
const device = assertDevice(this, prefix, "this");
|
||||||
const renderBundleEncoderRid = assertResource(this, prefix, "this");
|
const renderBundleEncoderRid = assertResource(this, prefix, "this");
|
||||||
const { rid, err } = ops.op_webgpu_render_bundle_encoder_finish(
|
const { rid, err } = op_webgpu_render_bundle_encoder_finish(
|
||||||
renderBundleEncoderRid,
|
renderBundleEncoderRid,
|
||||||
descriptor.label,
|
descriptor.label,
|
||||||
);
|
);
|
||||||
|
@ -4553,7 +4623,7 @@ class GPURenderBundleEncoder {
|
||||||
dynamicOffsetsDataStart = 0;
|
dynamicOffsetsDataStart = 0;
|
||||||
dynamicOffsetsDataLength = dynamicOffsetsData.length;
|
dynamicOffsetsDataLength = dynamicOffsetsData.length;
|
||||||
}
|
}
|
||||||
ops.op_webgpu_render_bundle_encoder_set_bind_group(
|
op_webgpu_render_bundle_encoder_set_bind_group(
|
||||||
renderBundleEncoderRid,
|
renderBundleEncoderRid,
|
||||||
index,
|
index,
|
||||||
bindGroupRid,
|
bindGroupRid,
|
||||||
|
@ -4574,7 +4644,7 @@ class GPURenderBundleEncoder {
|
||||||
groupLabel = webidl.converters.USVString(groupLabel, prefix, "Argument 1");
|
groupLabel = webidl.converters.USVString(groupLabel, prefix, "Argument 1");
|
||||||
assertDevice(this, prefix, "this");
|
assertDevice(this, prefix, "this");
|
||||||
const renderBundleEncoderRid = assertResource(this, prefix, "this");
|
const renderBundleEncoderRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_bundle_encoder_push_debug_group(
|
op_webgpu_render_bundle_encoder_push_debug_group(
|
||||||
renderBundleEncoderRid,
|
renderBundleEncoderRid,
|
||||||
groupLabel,
|
groupLabel,
|
||||||
);
|
);
|
||||||
|
@ -4586,7 +4656,7 @@ class GPURenderBundleEncoder {
|
||||||
"Failed to execute 'popDebugGroup' on 'GPURenderBundleEncoder'";
|
"Failed to execute 'popDebugGroup' on 'GPURenderBundleEncoder'";
|
||||||
assertDevice(this, prefix, "this");
|
assertDevice(this, prefix, "this");
|
||||||
const renderBundleEncoderRid = assertResource(this, prefix, "this");
|
const renderBundleEncoderRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_bundle_encoder_pop_debug_group(
|
op_webgpu_render_bundle_encoder_pop_debug_group(
|
||||||
renderBundleEncoderRid,
|
renderBundleEncoderRid,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -4606,7 +4676,7 @@ class GPURenderBundleEncoder {
|
||||||
);
|
);
|
||||||
assertDevice(this, prefix, "this");
|
assertDevice(this, prefix, "this");
|
||||||
const renderBundleEncoderRid = assertResource(this, prefix, "this");
|
const renderBundleEncoderRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_bundle_encoder_insert_debug_marker(
|
op_webgpu_render_bundle_encoder_insert_debug_marker(
|
||||||
renderBundleEncoderRid,
|
renderBundleEncoderRid,
|
||||||
markerLabel,
|
markerLabel,
|
||||||
);
|
);
|
||||||
|
@ -4633,7 +4703,7 @@ class GPURenderBundleEncoder {
|
||||||
resourceContext: "Argument 1",
|
resourceContext: "Argument 1",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
ops.op_webgpu_render_bundle_encoder_set_pipeline(
|
op_webgpu_render_bundle_encoder_set_pipeline(
|
||||||
renderBundleEncoderRid,
|
renderBundleEncoderRid,
|
||||||
pipelineRid,
|
pipelineRid,
|
||||||
);
|
);
|
||||||
|
@ -4666,7 +4736,7 @@ class GPURenderBundleEncoder {
|
||||||
resourceContext: "Argument 1",
|
resourceContext: "Argument 1",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
ops.op_webgpu_render_bundle_encoder_set_index_buffer(
|
op_webgpu_render_bundle_encoder_set_index_buffer(
|
||||||
renderBundleEncoderRid,
|
renderBundleEncoderRid,
|
||||||
bufferRid,
|
bufferRid,
|
||||||
indexFormat,
|
indexFormat,
|
||||||
|
@ -4700,7 +4770,7 @@ class GPURenderBundleEncoder {
|
||||||
resourceContext: "Argument 2",
|
resourceContext: "Argument 2",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
ops.op_webgpu_render_bundle_encoder_set_vertex_buffer(
|
op_webgpu_render_bundle_encoder_set_vertex_buffer(
|
||||||
renderBundleEncoderRid,
|
renderBundleEncoderRid,
|
||||||
slot,
|
slot,
|
||||||
bufferRid,
|
bufferRid,
|
||||||
|
@ -4741,7 +4811,7 @@ class GPURenderBundleEncoder {
|
||||||
);
|
);
|
||||||
assertDevice(this, prefix, "this");
|
assertDevice(this, prefix, "this");
|
||||||
const renderBundleEncoderRid = assertResource(this, prefix, "this");
|
const renderBundleEncoderRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_bundle_encoder_draw(
|
op_webgpu_render_bundle_encoder_draw(
|
||||||
renderBundleEncoderRid,
|
renderBundleEncoderRid,
|
||||||
vertexCount,
|
vertexCount,
|
||||||
instanceCount,
|
instanceCount,
|
||||||
|
@ -4787,7 +4857,7 @@ class GPURenderBundleEncoder {
|
||||||
);
|
);
|
||||||
assertDevice(this, prefix, "this");
|
assertDevice(this, prefix, "this");
|
||||||
const renderBundleEncoderRid = assertResource(this, prefix, "this");
|
const renderBundleEncoderRid = assertResource(this, prefix, "this");
|
||||||
ops.op_webgpu_render_bundle_encoder_draw_indexed(
|
op_webgpu_render_bundle_encoder_draw_indexed(
|
||||||
renderBundleEncoderRid,
|
renderBundleEncoderRid,
|
||||||
indexCount,
|
indexCount,
|
||||||
instanceCount,
|
instanceCount,
|
||||||
|
@ -4828,7 +4898,7 @@ class GPURenderBundleEncoder {
|
||||||
resourceContext: "Argument 1",
|
resourceContext: "Argument 1",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
ops.op_webgpu_render_bundle_encoder_draw_indirect(
|
op_webgpu_render_bundle_encoder_draw_indirect(
|
||||||
renderBundleEncoderRid,
|
renderBundleEncoderRid,
|
||||||
indirectBufferRid,
|
indirectBufferRid,
|
||||||
indirectOffset,
|
indirectOffset,
|
||||||
|
|
|
@ -7,10 +7,19 @@
|
||||||
/// <reference path="./lib.deno_webgpu.d.ts" />
|
/// <reference path="./lib.deno_webgpu.d.ts" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
|
op_webgpu_surface_configure,
|
||||||
|
op_webgpu_surface_get_current_texture,
|
||||||
|
op_webgpu_surface_present,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
ObjectPrototypeIsPrototypeOf,
|
||||||
|
Symbol,
|
||||||
|
SymbolFor,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
const { Symbol, SymbolFor, ObjectPrototypeIsPrototypeOf } = primordials;
|
|
||||||
import { loadWebGPU, webgpu } from "ext:deno_webgpu/00_init.js";
|
import { loadWebGPU, webgpu } from "ext:deno_webgpu/00_init.js";
|
||||||
|
|
||||||
const _surfaceRid = Symbol("[[surfaceRid]]");
|
const _surfaceRid = Symbol("[[surfaceRid]]");
|
||||||
|
@ -52,7 +61,7 @@ class GPUCanvasContext {
|
||||||
context: "configuration.device",
|
context: "configuration.device",
|
||||||
});
|
});
|
||||||
|
|
||||||
const { err } = ops.op_webgpu_surface_configure({
|
const { err } = op_webgpu_surface_configure({
|
||||||
surfaceRid: this[_surfaceRid],
|
surfaceRid: this[_surfaceRid],
|
||||||
deviceRid: device.rid,
|
deviceRid: device.rid,
|
||||||
format: configuration.format,
|
format: configuration.format,
|
||||||
|
@ -91,7 +100,7 @@ class GPUCanvasContext {
|
||||||
return this[_currentTexture];
|
return this[_currentTexture];
|
||||||
}
|
}
|
||||||
|
|
||||||
const { rid } = ops.op_webgpu_surface_get_current_texture(
|
const { rid } = op_webgpu_surface_get_current_texture(
|
||||||
device.rid,
|
device.rid,
|
||||||
this[_surfaceRid],
|
this[_surfaceRid],
|
||||||
);
|
);
|
||||||
|
@ -127,7 +136,7 @@ class GPUCanvasContext {
|
||||||
prefix,
|
prefix,
|
||||||
context: "this",
|
context: "this",
|
||||||
});
|
});
|
||||||
ops.op_webgpu_surface_present(device.rid, this[_surfaceRid]);
|
op_webgpu_surface_present(device.rid, this[_surfaceRid]);
|
||||||
this[_currentTexture].destroy();
|
this[_currentTexture].destroy();
|
||||||
this[_currentTexture] = undefined;
|
this[_currentTexture] = undefined;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,12 @@
|
||||||
/// <reference path="../../core/internal.d.ts" />
|
/// <reference path="../../core/internal.d.ts" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
|
const {
|
||||||
|
isArrayBuffer,
|
||||||
|
isDataView,
|
||||||
|
isSharedArrayBuffer,
|
||||||
|
isTypedArray,
|
||||||
|
} = core;
|
||||||
const {
|
const {
|
||||||
ArrayBufferIsView,
|
ArrayBufferIsView,
|
||||||
ArrayPrototypeForEach,
|
ArrayPrototypeForEach,
|
||||||
|
@ -80,12 +86,6 @@ const {
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
Uint8ClampedArray,
|
Uint8ClampedArray,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
const {
|
|
||||||
isArrayBuffer,
|
|
||||||
isDataView,
|
|
||||||
isSharedArrayBuffer,
|
|
||||||
isTypedArray,
|
|
||||||
} = core;
|
|
||||||
|
|
||||||
function makeException(ErrorType, message, prefix, context) {
|
function makeException(ErrorType, message, prefix, context) {
|
||||||
return new ErrorType(
|
return new ErrorType(
|
||||||
|
|
|
@ -3,23 +3,24 @@
|
||||||
/// <reference path="../../core/internal.d.ts" />
|
/// <reference path="../../core/internal.d.ts" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
import { URL } from "ext:deno_url/00_url.js";
|
const {
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
isAnyArrayBuffer,
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
isArrayBuffer,
|
||||||
import { HTTP_TOKEN_CODE_POINT_RE } from "ext:deno_web/00_infra.js";
|
} = core;
|
||||||
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
|
||||||
import {
|
import {
|
||||||
CloseEvent,
|
op_ws_check_permission_and_cancel_handle,
|
||||||
defineEventHandler,
|
op_ws_close,
|
||||||
dispatch,
|
op_ws_create,
|
||||||
ErrorEvent,
|
op_ws_get_buffer,
|
||||||
Event,
|
op_ws_get_buffer_as_string,
|
||||||
EventTarget,
|
op_ws_get_buffered_amount,
|
||||||
MessageEvent,
|
op_ws_get_error,
|
||||||
setIsTrusted,
|
op_ws_next_event,
|
||||||
} from "ext:deno_web/02_event.js";
|
op_ws_send_binary,
|
||||||
import { Blob, BlobPrototype } from "ext:deno_web/09_file.js";
|
op_ws_send_binary_ab,
|
||||||
import { getLocationHref } from "ext:deno_web/12_location.js";
|
op_ws_send_ping,
|
||||||
|
op_ws_send_text,
|
||||||
|
} from "ext:deno_websocket/00_ops.js";
|
||||||
const {
|
const {
|
||||||
ArrayBufferIsView,
|
ArrayBufferIsView,
|
||||||
ArrayPrototypeJoin,
|
ArrayPrototypeJoin,
|
||||||
|
@ -42,24 +43,24 @@ const {
|
||||||
TypedArrayPrototypeGetByteLength,
|
TypedArrayPrototypeGetByteLength,
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
const {
|
|
||||||
isAnyArrayBuffer,
|
import { URL } from "ext:deno_url/00_url.js";
|
||||||
isArrayBuffer,
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
} = core;
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
|
import { HTTP_TOKEN_CODE_POINT_RE } from "ext:deno_web/00_infra.js";
|
||||||
|
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
||||||
import {
|
import {
|
||||||
op_ws_check_permission_and_cancel_handle,
|
CloseEvent,
|
||||||
op_ws_close,
|
defineEventHandler,
|
||||||
op_ws_create,
|
dispatch,
|
||||||
op_ws_get_buffer,
|
ErrorEvent,
|
||||||
op_ws_get_buffer_as_string,
|
Event,
|
||||||
op_ws_get_buffered_amount,
|
EventTarget,
|
||||||
op_ws_get_error,
|
MessageEvent,
|
||||||
op_ws_next_event,
|
setIsTrusted,
|
||||||
op_ws_send_binary,
|
} from "ext:deno_web/02_event.js";
|
||||||
op_ws_send_binary_ab,
|
import { Blob, BlobPrototype } from "ext:deno_web/09_file.js";
|
||||||
op_ws_send_ping,
|
import { getLocationHref } from "ext:deno_web/12_location.js";
|
||||||
op_ws_send_text,
|
|
||||||
} from "ext:deno_websocket/00_ops.js";
|
|
||||||
|
|
||||||
webidl.converters["sequence<DOMString> or DOMString"] = (
|
webidl.converters["sequence<DOMString> or DOMString"] = (
|
||||||
V,
|
V,
|
||||||
|
|
|
@ -3,16 +3,17 @@
|
||||||
/// <reference path="../../core/internal.d.ts" />
|
/// <reference path="../../core/internal.d.ts" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
|
||||||
import { Deferred, writableStreamClose } from "ext:deno_web/06_streams.js";
|
|
||||||
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
|
||||||
import { add, remove } from "ext:deno_web/03_abort_signal.js";
|
|
||||||
import {
|
import {
|
||||||
fillHeaders,
|
op_ws_check_permission_and_cancel_handle,
|
||||||
headerListFromHeaders,
|
op_ws_close,
|
||||||
headersFromHeaderList,
|
op_ws_create,
|
||||||
} from "ext:deno_fetch/20_headers.js";
|
op_ws_get_buffer,
|
||||||
|
op_ws_get_buffer_as_string,
|
||||||
|
op_ws_get_error,
|
||||||
|
op_ws_next_event,
|
||||||
|
op_ws_send_binary_async,
|
||||||
|
op_ws_send_text_async,
|
||||||
|
} from "ext:deno_websocket/00_ops.js";
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeJoin,
|
ArrayPrototypeJoin,
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
|
@ -31,17 +32,17 @@ const {
|
||||||
TypedArrayPrototypeGetByteLength,
|
TypedArrayPrototypeGetByteLength,
|
||||||
TypedArrayPrototypeGetSymbolToStringTag,
|
TypedArrayPrototypeGetSymbolToStringTag,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
|
import { Deferred, writableStreamClose } from "ext:deno_web/06_streams.js";
|
||||||
|
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
||||||
|
import { add, remove } from "ext:deno_web/03_abort_signal.js";
|
||||||
import {
|
import {
|
||||||
op_ws_check_permission_and_cancel_handle,
|
fillHeaders,
|
||||||
op_ws_close,
|
headerListFromHeaders,
|
||||||
op_ws_create,
|
headersFromHeaderList,
|
||||||
op_ws_get_buffer,
|
} from "ext:deno_fetch/20_headers.js";
|
||||||
op_ws_get_buffer_as_string,
|
|
||||||
op_ws_get_error,
|
|
||||||
op_ws_next_event,
|
|
||||||
op_ws_send_binary_async,
|
|
||||||
op_ws_send_text_async,
|
|
||||||
} from "ext:deno_websocket/00_ops.js";
|
|
||||||
|
|
||||||
webidl.converters.WebSocketStreamOptions = webidl.createDictionaryConverter(
|
webidl.converters.WebSocketStreamOptions = webidl.createDictionaryConverter(
|
||||||
"WebSocketStreamOptions",
|
"WebSocketStreamOptions",
|
||||||
|
|
|
@ -3,8 +3,15 @@
|
||||||
/// <reference path="../../core/internal.d.ts" />
|
/// <reference path="../../core/internal.d.ts" />
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
op_webstorage_clear,
|
||||||
|
op_webstorage_get,
|
||||||
|
op_webstorage_iterate_keys,
|
||||||
|
op_webstorage_key,
|
||||||
|
op_webstorage_length,
|
||||||
|
op_webstorage_remove,
|
||||||
|
op_webstorage_set,
|
||||||
|
} = core.ensureFastOps();
|
||||||
const {
|
const {
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
|
@ -17,6 +24,8 @@ const {
|
||||||
Proxy,
|
Proxy,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
|
|
||||||
const _persistent = Symbol("[[persistent]]");
|
const _persistent = Symbol("[[persistent]]");
|
||||||
|
|
||||||
class Storage {
|
class Storage {
|
||||||
|
@ -28,7 +37,7 @@ class Storage {
|
||||||
|
|
||||||
get length() {
|
get length() {
|
||||||
webidl.assertBranded(this, StoragePrototype);
|
webidl.assertBranded(this, StoragePrototype);
|
||||||
return ops.op_webstorage_length(this[_persistent]);
|
return op_webstorage_length(this[_persistent]);
|
||||||
}
|
}
|
||||||
|
|
||||||
key(index) {
|
key(index) {
|
||||||
|
@ -37,7 +46,7 @@ class Storage {
|
||||||
webidl.requiredArguments(arguments.length, 1, prefix);
|
webidl.requiredArguments(arguments.length, 1, prefix);
|
||||||
index = webidl.converters["unsigned long"](index, prefix, "Argument 1");
|
index = webidl.converters["unsigned long"](index, prefix, "Argument 1");
|
||||||
|
|
||||||
return ops.op_webstorage_key(index, this[_persistent]);
|
return op_webstorage_key(index, this[_persistent]);
|
||||||
}
|
}
|
||||||
|
|
||||||
setItem(key, value) {
|
setItem(key, value) {
|
||||||
|
@ -47,7 +56,7 @@ class Storage {
|
||||||
key = webidl.converters.DOMString(key, prefix, "Argument 1");
|
key = webidl.converters.DOMString(key, prefix, "Argument 1");
|
||||||
value = webidl.converters.DOMString(value, prefix, "Argument 2");
|
value = webidl.converters.DOMString(value, prefix, "Argument 2");
|
||||||
|
|
||||||
ops.op_webstorage_set(key, value, this[_persistent]);
|
op_webstorage_set(key, value, this[_persistent]);
|
||||||
}
|
}
|
||||||
|
|
||||||
getItem(key) {
|
getItem(key) {
|
||||||
|
@ -56,7 +65,7 @@ class Storage {
|
||||||
webidl.requiredArguments(arguments.length, 1, prefix);
|
webidl.requiredArguments(arguments.length, 1, prefix);
|
||||||
key = webidl.converters.DOMString(key, prefix, "Argument 1");
|
key = webidl.converters.DOMString(key, prefix, "Argument 1");
|
||||||
|
|
||||||
return ops.op_webstorage_get(key, this[_persistent]);
|
return op_webstorage_get(key, this[_persistent]);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeItem(key) {
|
removeItem(key) {
|
||||||
|
@ -65,12 +74,12 @@ class Storage {
|
||||||
webidl.requiredArguments(arguments.length, 1, prefix);
|
webidl.requiredArguments(arguments.length, 1, prefix);
|
||||||
key = webidl.converters.DOMString(key, prefix, "Argument 1");
|
key = webidl.converters.DOMString(key, prefix, "Argument 1");
|
||||||
|
|
||||||
ops.op_webstorage_remove(key, this[_persistent]);
|
op_webstorage_remove(key, this[_persistent]);
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
webidl.assertBranded(this, StoragePrototype);
|
webidl.assertBranded(this, StoragePrototype);
|
||||||
ops.op_webstorage_clear(this[_persistent]);
|
op_webstorage_clear(this[_persistent]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +135,7 @@ function createStorage(persistent) {
|
||||||
},
|
},
|
||||||
|
|
||||||
ownKeys() {
|
ownKeys() {
|
||||||
return ops.op_webstorage_iterate_keys(persistent);
|
return op_webstorage_iterate_keys(persistent);
|
||||||
},
|
},
|
||||||
|
|
||||||
getOwnPropertyDescriptor(target, key) {
|
getOwnPropertyDescriptor(target, key) {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
const primordials = globalThis.__bootstrap.primordials;
|
import { primordials } from "ext:core/mod.js";
|
||||||
const { ObjectFreeze } = primordials;
|
const {
|
||||||
|
ObjectFreeze,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
interface Version {
|
interface Version {
|
||||||
deno: string;
|
deno: string;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
|
op_bootstrap_log_level,
|
||||||
|
} = core.ensureFastOps();
|
||||||
const {
|
const {
|
||||||
Promise,
|
Promise,
|
||||||
SafeArrayIterator,
|
SafeArrayIterator,
|
||||||
|
@ -20,7 +22,7 @@ const logSource = "JS";
|
||||||
let logLevel_ = null;
|
let logLevel_ = null;
|
||||||
function logLevel() {
|
function logLevel() {
|
||||||
if (logLevel_ === null) {
|
if (logLevel_ === null) {
|
||||||
logLevel_ = ops.op_bootstrap_log_level() || 3;
|
logLevel_ = op_bootstrap_log_level() || 3;
|
||||||
}
|
}
|
||||||
return logLevel_;
|
return logLevel_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
import { pathFromURL } from "ext:deno_web/00_infra.js";
|
op_query_permission,
|
||||||
import { Event, EventTarget } from "ext:deno_web/02_event.js";
|
op_request_permission,
|
||||||
|
op_revoke_permission,
|
||||||
|
} = core.ensureFastOps();
|
||||||
const {
|
const {
|
||||||
ArrayIsArray,
|
ArrayIsArray,
|
||||||
ArrayPrototypeIncludes,
|
ArrayPrototypeIncludes,
|
||||||
|
@ -23,6 +25,9 @@ const {
|
||||||
TypeError,
|
TypeError,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import { pathFromURL } from "ext:deno_web/00_infra.js";
|
||||||
|
import { Event, EventTarget } from "ext:deno_web/02_event.js";
|
||||||
|
|
||||||
const illegalConstructorKey = Symbol("illegalConstructorKey");
|
const illegalConstructorKey = Symbol("illegalConstructorKey");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +54,7 @@ const permissionNames = [
|
||||||
* @returns {Deno.PermissionState}
|
* @returns {Deno.PermissionState}
|
||||||
*/
|
*/
|
||||||
function opQuery(desc) {
|
function opQuery(desc) {
|
||||||
return ops.op_query_permission(desc);
|
return op_query_permission(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,7 +62,7 @@ function opQuery(desc) {
|
||||||
* @returns {Deno.PermissionState}
|
* @returns {Deno.PermissionState}
|
||||||
*/
|
*/
|
||||||
function opRevoke(desc) {
|
function opRevoke(desc) {
|
||||||
return ops.op_revoke_permission(desc);
|
return op_revoke_permission(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +70,7 @@ function opRevoke(desc) {
|
||||||
* @returns {Deno.PermissionState}
|
* @returns {Deno.PermissionState}
|
||||||
*/
|
*/
|
||||||
function opRequest(desc) {
|
function opRequest(desc) {
|
||||||
return ops.op_request_permission(desc);
|
return op_request_permission(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
class PermissionStatus extends EventTarget {
|
class PermissionStatus extends EventTarget {
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
|
op_create_worker,
|
||||||
|
op_host_post_message,
|
||||||
|
op_host_recv_ctrl,
|
||||||
|
op_host_recv_message,
|
||||||
|
op_host_terminate_worker,
|
||||||
|
} = core.ensureFastOps();
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeFilter,
|
ArrayPrototypeFilter,
|
||||||
Error,
|
Error,
|
||||||
|
@ -12,6 +18,7 @@ const {
|
||||||
SymbolIterator,
|
SymbolIterator,
|
||||||
SymbolToStringTag,
|
SymbolToStringTag,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
import { URL } from "ext:deno_url/00_url.js";
|
import { URL } from "ext:deno_url/00_url.js";
|
||||||
|
@ -30,10 +37,6 @@ import {
|
||||||
MessagePortPrototype,
|
MessagePortPrototype,
|
||||||
serializeJsMessageData,
|
serializeJsMessageData,
|
||||||
} from "ext:deno_web/13_message_port.js";
|
} from "ext:deno_web/13_message_port.js";
|
||||||
const {
|
|
||||||
op_host_recv_ctrl,
|
|
||||||
op_host_recv_message,
|
|
||||||
} = core.ensureFastOps();
|
|
||||||
|
|
||||||
function createWorker(
|
function createWorker(
|
||||||
specifier,
|
specifier,
|
||||||
|
@ -43,7 +46,7 @@ function createWorker(
|
||||||
name,
|
name,
|
||||||
workerType,
|
workerType,
|
||||||
) {
|
) {
|
||||||
return ops.op_create_worker({
|
return op_create_worker({
|
||||||
hasSourceCode,
|
hasSourceCode,
|
||||||
name,
|
name,
|
||||||
permissions: serializePermissions(permissions),
|
permissions: serializePermissions(permissions),
|
||||||
|
@ -54,11 +57,11 @@ function createWorker(
|
||||||
}
|
}
|
||||||
|
|
||||||
function hostTerminateWorker(id) {
|
function hostTerminateWorker(id) {
|
||||||
ops.op_host_terminate_worker(id);
|
op_host_terminate_worker(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hostPostMessage(id, data) {
|
function hostPostMessage(id, data) {
|
||||||
ops.op_host_post_message(id, data);
|
op_host_post_message(id, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hostRecvCtrl(id) {
|
function hostRecvCtrl(id) {
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
// Copyright 2009 The Go Authors. All rights reserved. BSD license.
|
// Copyright 2009 The Go Authors. All rights reserved. BSD license.
|
||||||
// https://github.com/golang/go/blob/master/LICENSE
|
// https://github.com/golang/go/blob/master/LICENSE
|
||||||
|
|
||||||
import { assert } from "ext:deno_web/00_infra.js";
|
import { primordials } from "ext:core/mod.js";
|
||||||
const primordials = globalThis.__bootstrap.primordials;
|
|
||||||
const {
|
const {
|
||||||
ArrayBufferPrototypeGetByteLength,
|
ArrayBufferPrototypeGetByteLength,
|
||||||
TypedArrayPrototypeSubarray,
|
TypedArrayPrototypeSubarray,
|
||||||
|
@ -20,6 +19,8 @@ const {
|
||||||
Error,
|
Error,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import { assert } from "ext:deno_web/00_infra.js";
|
||||||
|
|
||||||
// MIN_READ is the minimum ArrayBuffer size passed to a read call by
|
// MIN_READ is the minimum ArrayBuffer size passed to a read call by
|
||||||
// buffer.ReadFrom. As long as the Buffer has at least MIN_READ bytes beyond
|
// buffer.ReadFrom. As long as the Buffer has at least MIN_READ bytes beyond
|
||||||
// what is required to hold the contents of r, readFrom() will not grow the
|
// what is required to hold the contents of r, readFrom() will not grow the
|
||||||
|
|
|
@ -1,49 +1,68 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
import { Event, EventTarget } from "ext:deno_web/02_event.js";
|
op_delete_env,
|
||||||
|
op_env,
|
||||||
|
op_exec_path,
|
||||||
|
op_exit,
|
||||||
|
op_get_env,
|
||||||
|
op_gid,
|
||||||
|
op_hostname,
|
||||||
|
op_loadavg,
|
||||||
|
op_network_interfaces,
|
||||||
|
op_os_release,
|
||||||
|
op_os_uptime,
|
||||||
|
op_set_env,
|
||||||
|
op_system_memory_info,
|
||||||
|
op_uid,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
op_set_exit_code,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
const {
|
const {
|
||||||
Error,
|
Error,
|
||||||
FunctionPrototypeBind,
|
FunctionPrototypeBind,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
import { Event, EventTarget } from "ext:deno_web/02_event.js";
|
||||||
|
|
||||||
const windowDispatchEvent = FunctionPrototypeBind(
|
const windowDispatchEvent = FunctionPrototypeBind(
|
||||||
EventTarget.prototype.dispatchEvent,
|
EventTarget.prototype.dispatchEvent,
|
||||||
globalThis,
|
globalThis,
|
||||||
);
|
);
|
||||||
|
|
||||||
function loadavg() {
|
function loadavg() {
|
||||||
return ops.op_loadavg();
|
return op_loadavg();
|
||||||
}
|
}
|
||||||
|
|
||||||
function hostname() {
|
function hostname() {
|
||||||
return ops.op_hostname();
|
return op_hostname();
|
||||||
}
|
}
|
||||||
|
|
||||||
function osRelease() {
|
function osRelease() {
|
||||||
return ops.op_os_release();
|
return op_os_release();
|
||||||
}
|
}
|
||||||
|
|
||||||
function osUptime() {
|
function osUptime() {
|
||||||
return ops.op_os_uptime();
|
return op_os_uptime();
|
||||||
}
|
}
|
||||||
|
|
||||||
function systemMemoryInfo() {
|
function systemMemoryInfo() {
|
||||||
return ops.op_system_memory_info();
|
return op_system_memory_info();
|
||||||
}
|
}
|
||||||
|
|
||||||
function networkInterfaces() {
|
function networkInterfaces() {
|
||||||
return ops.op_network_interfaces();
|
return op_network_interfaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
function gid() {
|
function gid() {
|
||||||
return ops.op_gid();
|
return op_gid();
|
||||||
}
|
}
|
||||||
|
|
||||||
function uid() {
|
function uid() {
|
||||||
return ops.op_uid();
|
return op_uid();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is an internal only method used by the test harness to override the
|
// This is an internal only method used by the test harness to override the
|
||||||
|
@ -56,7 +75,7 @@ function setExitHandler(fn) {
|
||||||
function exit(code) {
|
function exit(code) {
|
||||||
// Set exit code first so unload event listeners can override it.
|
// Set exit code first so unload event listeners can override it.
|
||||||
if (typeof code === "number") {
|
if (typeof code === "number") {
|
||||||
ops.op_set_exit_code(code);
|
op_set_exit_code(code);
|
||||||
} else {
|
} else {
|
||||||
code = 0;
|
code = 0;
|
||||||
}
|
}
|
||||||
|
@ -73,26 +92,26 @@ function exit(code) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ops.op_exit();
|
op_exit();
|
||||||
throw new Error("Code not reachable");
|
throw new Error("Code not reachable");
|
||||||
}
|
}
|
||||||
|
|
||||||
function setEnv(key, value) {
|
function setEnv(key, value) {
|
||||||
ops.op_set_env(key, value);
|
op_set_env(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEnv(key) {
|
function getEnv(key) {
|
||||||
return ops.op_get_env(key) ?? undefined;
|
return op_get_env(key) ?? undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteEnv(key) {
|
function deleteEnv(key) {
|
||||||
ops.op_delete_env(key);
|
op_delete_env(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
const env = {
|
const env = {
|
||||||
get: getEnv,
|
get: getEnv,
|
||||||
toObject() {
|
toObject() {
|
||||||
return ops.op_env();
|
return op_env();
|
||||||
},
|
},
|
||||||
set: setEnv,
|
set: setEnv,
|
||||||
has(key) {
|
has(key) {
|
||||||
|
@ -102,7 +121,7 @@ const env = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function execPath() {
|
function execPath() {
|
||||||
return ops.op_exec_path();
|
return op_exec_path();
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|
|
@ -1,24 +1,29 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const { BadResourcePrototype, InterruptedPrototype, ops } = core;
|
const {
|
||||||
|
BadResourcePrototype,
|
||||||
|
InterruptedPrototype,
|
||||||
|
} = core;
|
||||||
|
const {
|
||||||
|
op_fs_events_open,
|
||||||
|
op_fs_events_poll,
|
||||||
|
} = core.ensureFastOps();
|
||||||
const {
|
const {
|
||||||
ArrayIsArray,
|
ArrayIsArray,
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
PromiseResolve,
|
PromiseResolve,
|
||||||
SymbolAsyncIterator,
|
SymbolAsyncIterator,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
||||||
const {
|
|
||||||
op_fs_events_poll,
|
|
||||||
} = core.ensureFastOps();
|
|
||||||
|
|
||||||
class FsWatcher {
|
class FsWatcher {
|
||||||
#rid = 0;
|
#rid = 0;
|
||||||
|
|
||||||
constructor(paths, options) {
|
constructor(paths, options) {
|
||||||
const { recursive } = options;
|
const { recursive } = options;
|
||||||
this.#rid = ops.op_fs_events_open({ recursive, paths });
|
this.#rid = op_fs_events_open({ recursive, paths });
|
||||||
}
|
}
|
||||||
|
|
||||||
get rid() {
|
get rid() {
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
import { core } from "ext:core/mod.js";
|
import { core } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const {
|
||||||
|
op_http_start,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import { HttpConn } from "ext:deno_http/01_http.js";
|
import { HttpConn } from "ext:deno_http/01_http.js";
|
||||||
|
|
||||||
function serveHttp(conn) {
|
function serveHttp(conn) {
|
||||||
const rid = ops.op_http_start(conn.rid);
|
const rid = op_http_start(conn.rid);
|
||||||
return new HttpConn(rid, conn.remoteAddr, conn.localAddr);
|
return new HttpConn(rid, conn.remoteAddr, conn.localAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue