1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -05:00

refactor: migrate 'ext/node' extension to virtual ops module (#22157)

Follow up to https://github.com/denoland/deno/pull/22135
This commit is contained in:
Bartek Iwańczuk 2024-01-29 14:58:08 +01:00 committed by GitHub
parent aed5e4997d
commit 909986fa6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 52 additions and 111 deletions

View file

@ -3,7 +3,7 @@
// 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 { import {
op_require_as_file_path, op_require_as_file_path,
op_require_break_on_next_statement, op_require_break_on_next_statement,
op_require_init_paths, op_require_init_paths,
@ -25,7 +25,7 @@ const {
op_require_stat, op_require_stat,
op_require_try_self, op_require_try_self,
op_require_try_self_parent_path, op_require_try_self_parent_path,
} = core.ensureFastOps(); } from "ext:core/ops";
const { const {
op_napi_open, op_napi_open,
op_require_read_closest_package_json, op_require_read_closest_package_json,

View file

@ -4,7 +4,7 @@
// 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 { import {
op_brotli_compress, op_brotli_compress,
op_brotli_compress_async, op_brotli_compress_async,
op_brotli_compress_stream, op_brotli_compress_stream,
@ -14,7 +14,7 @@ const {
op_brotli_decompress_stream, op_brotli_decompress_stream,
op_create_brotli_compress, op_create_brotli_compress,
op_create_brotli_decompress, op_create_brotli_decompress,
} = core.ensureFastOps(); } from "ext:core/ops";
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";

View file

@ -2,11 +2,7 @@
// deno-lint-ignore-file prefer-primordials // deno-lint-ignore-file prefer-primordials
import { core } from "ext:core/mod.js"; import { op_node_cp, op_node_cp_sync } from "ext:core/ops";
const {
op_node_cp,
op_node_cp_sync,
} = core.ensureFastOps();
import { import {
getValidatedPath, getValidatedPath,

View file

@ -3,10 +3,7 @@
// 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 { op_node_fs_exists_sync } from "ext:core/ops";
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";

View file

@ -43,8 +43,7 @@ export const DEFLATERAW = 5;
export const INFLATERAW = 6; export const INFLATERAW = 6;
export const UNZIP = 7; export const UNZIP = 7;
import { core } from "ext:core/mod.js"; import {
const {
op_zlib_close, op_zlib_close,
op_zlib_close_if_pending, op_zlib_close_if_pending,
op_zlib_init, op_zlib_init,
@ -52,7 +51,7 @@ const {
op_zlib_reset, op_zlib_reset,
op_zlib_write, op_zlib_write,
op_zlib_write_async, op_zlib_write_async,
} = core.ensureFastOps(); } from "ext:core/ops";
const writeResult = new Uint32Array(2); const writeResult = new Uint32Array(2);

View file

@ -8,9 +8,7 @@
// 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 { import { op_node_is_promise_rejected } from "ext:core/ops";
op_node_is_promise_rejected,
} = core.ensureFastOps();
import { validateFunction } from "ext:deno_node/internal/validators.mjs"; import { validateFunction } from "ext:deno_node/internal/validators.mjs";
function assert(cond: boolean) { function assert(cond: boolean) {

View file

@ -7,10 +7,10 @@
// 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 { import {
op_node_child_ipc_pipe,
op_bootstrap_unstable_args, op_bootstrap_unstable_args,
} = core.ensureFastOps(); op_node_child_ipc_pipe,
} from "ext:core/ops";
const { const {
op_npm_process_state, op_npm_process_state,
} = core.ensureFastOps(true); } = core.ensureFastOps(true);

View file

@ -4,10 +4,7 @@
// 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 { import { op_fetch_response_upgrade, op_node_http_request } from "ext:core/ops";
op_fetch_response_upgrade,
op_node_http_request,
} = core.ensureFastOps();
// TODO(bartlomieju): this ops is also used in `ext/fetch/26_fetch.js`. // TODO(bartlomieju): this ops is also used in `ext/fetch/26_fetch.js`.
const { const {
op_fetch_send, op_fetch_send,

View file

@ -5,8 +5,7 @@
// 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 { import {
op_http2_connect,
op_http2_client_get_response, op_http2_client_get_response,
op_http2_client_get_response_body_chunk, op_http2_client_get_response_body_chunk,
op_http2_client_get_response_trailers, op_http2_client_get_response_trailers,
@ -14,8 +13,9 @@ const {
op_http2_client_reset_stream, op_http2_client_reset_stream,
op_http2_client_send_data, op_http2_client_send_data,
op_http2_client_send_trailers, op_http2_client_send_trailers,
op_http2_connect,
op_http2_poll_client_connection, op_http2_poll_client_connection,
} = core.ensureFastOps(); } from "ext:core/ops";
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";

View file

@ -7,10 +7,7 @@
// 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 { import { op_node_ipc_read, op_node_ipc_write } from "ext:core/ops";
op_node_ipc_read,
op_node_ipc_write,
} = core.ensureFastOps();
import { import {
ArrayIsArray, ArrayIsArray,
ArrayPrototypeFilter, ArrayPrototypeFilter,

View file

@ -3,10 +3,7 @@
// 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 { op_node_random_int } from "ext: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;

View file

@ -8,7 +8,7 @@ import { core } from "ext:core/mod.js";
const { const {
encode, encode,
} = core; } = core;
const { import {
op_node_cipheriv_encrypt, op_node_cipheriv_encrypt,
op_node_cipheriv_final, op_node_cipheriv_final,
op_node_cipheriv_set_aad, op_node_cipheriv_set_aad,
@ -20,7 +20,7 @@ const {
op_node_private_decrypt, op_node_private_decrypt,
op_node_private_encrypt, op_node_private_encrypt,
op_node_public_encrypt, op_node_public_encrypt,
} = core.ensureFastOps(); } from "ext:core/ops";
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 {

View file

@ -5,13 +5,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 { import {
op_node_dh_compute_secret, op_node_dh_compute_secret,
op_node_dh_generate2, op_node_dh_generate2,
op_node_ecdh_compute_public_key,
op_node_ecdh_compute_secret, op_node_ecdh_compute_secret,
op_node_ecdh_generate_keys, op_node_ecdh_generate_keys,
op_node_ecdh_compute_public_key, } from "ext:core/ops";
} = core.ensureFastOps();
const { const {
op_node_gen_prime, op_node_gen_prime,
} = core.ensureFastOps(true); } = core.ensureFastOps(true);

View file

@ -4,16 +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
import { core } from "ext:core/mod.js"; import {
const {
op_node_create_hash, op_node_create_hash,
op_node_get_hashes, op_node_get_hashes,
op_node_hash_clone, op_node_hash_clone,
op_node_hash_digest_hex,
op_node_hash_digest, op_node_hash_digest,
op_node_hash_update_str, op_node_hash_digest_hex,
op_node_hash_update, op_node_hash_update,
} = core.ensureFastOps(); op_node_hash_update_str,
} from "ext:core/ops";
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";

View file

@ -4,11 +4,7 @@
// 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 { op_node_hkdf, op_node_hkdf_async } from "ext:core/ops";
const {
op_node_hkdf,
op_node_hkdf_async,
} = core.ensureFastOps();
import { import {
validateFunction, validateFunction,

View file

@ -30,7 +30,7 @@ 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";
import { core } from "ext:core/mod.js"; import { core } from "ext:core/mod.js";
const { import {
op_node_dh_generate, op_node_dh_generate,
op_node_dh_generate_async, op_node_dh_generate_async,
op_node_dh_generate_group, op_node_dh_generate_group,
@ -45,7 +45,7 @@ const {
op_node_generate_rsa_async, op_node_generate_rsa_async,
op_node_x25519_generate, op_node_x25519_generate,
op_node_x25519_generate_async, op_node_x25519_generate_async,
} = core.ensureFastOps(); } from "ext:core/ops";
const { const {
op_node_generate_secret, op_node_generate_secret,
op_node_generate_secret_async, op_node_generate_secret_async,

View file

@ -4,10 +4,7 @@
// 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 { op_node_create_private_key } from "ext:core/ops";
const {
op_node_create_private_key,
} = core.ensureFastOps();
import { import {
kHandle, kHandle,

View file

@ -3,11 +3,7 @@
// 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 { op_node_pbkdf2, op_node_pbkdf2_async } from "ext:core/ops";
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";

View file

@ -5,13 +5,13 @@
// deno-lint-ignore-file prefer-primordials // deno-lint-ignore-file prefer-primordials
import { core, primordials } from "ext:core/mod.js"; import { core, primordials } from "ext:core/mod.js";
const { import {
op_node_check_prime, op_node_check_prime,
op_node_check_prime_async, op_node_check_prime_async,
op_node_check_prime_bytes, op_node_check_prime_bytes,
op_node_check_prime_bytes_async, op_node_check_prime_bytes_async,
op_node_gen_prime_async, op_node_gen_prime_async,
} = core.ensureFastOps(); } from "ext:core/ops";
const { const {
op_node_gen_prime, op_node_gen_prime,
} = core.ensureFastOps(true); } = core.ensureFastOps(true);

View file

@ -28,12 +28,7 @@ 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";
import { op_node_scrypt_async, op_node_scrypt_sync } from "ext:core/ops";
import { core } from "ext:core/mod.js";
const {
op_node_scrypt_sync,
op_node_scrypt_async,
} = core.ensureFastOps();
type Opts = Partial<{ type Opts = Partial<{
N: number; N: number;

View file

@ -4,11 +4,7 @@
// 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 { op_node_sign, op_node_verify } from "ext:core/ops";
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 {

View file

@ -4,8 +4,7 @@
// 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 {
const {
op_node_x509_ca, op_node_x509_ca,
op_node_x509_check_email, op_node_x509_check_email,
op_node_x509_fingerprint, op_node_x509_fingerprint,
@ -18,7 +17,7 @@ const {
op_node_x509_get_valid_to, op_node_x509_get_valid_to,
op_node_x509_key_usage, op_node_x509_key_usage,
op_node_x509_parse, op_node_x509_parse,
} = core.ensureFastOps(); } from "ext:core/ops";
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";

View file

@ -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 { core } from "ext:core/mod.js"; import { op_node_sys_to_uv_error } from "ext:core/ops";
const {
op_node_sys_to_uv_error,
} = core.ensureFastOps();
export function uvTranslateSysError(sysErrno: number): string { export function uvTranslateSysError(sysErrno: number): string {
return op_node_sys_to_uv_error(sysErrno); return op_node_sys_to_uv_error(sysErrno);

View file

@ -32,10 +32,7 @@
import { core } from "ext:core/mod.js"; import { core } from "ext:core/mod.js";
const { internalRidSymbol } = core; const { internalRidSymbol } = core;
const { import { op_can_write_vectored, op_raw_write_vectored } from "ext:core/ops";
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";

View file

@ -23,11 +23,10 @@
// 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 {
const {
op_node_unstable_net_listen_udp, op_node_unstable_net_listen_udp,
op_node_unstable_net_listen_unixpacket, op_node_unstable_net_listen_unixpacket,
} = core.ensureFastOps(); } from "ext:core/ops";
import { import {
AsyncWrap, AsyncWrap,

View file

@ -28,10 +28,7 @@
// 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 { op_node_guess_handle_type } from "ext: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 {

View file

@ -23,13 +23,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 {
const {
op_cpus, op_cpus,
op_node_os_get_priority, op_node_os_get_priority,
op_node_os_set_priority, op_node_os_set_priority,
op_node_os_username, op_node_os_username,
} = core.ensureFastOps(); } from "ext:core/ops";
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";

View file

@ -5,10 +5,7 @@
// 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 { import { op_geteuid, op_process_abort } from "ext:core/ops";
op_process_abort,
op_geteuid,
} = core.ensureFastOps();
const { const {
op_set_exit_code, op_set_exit_code,
} = core.ensureFastOps(true); } = core.ensureFastOps(true);

View file

@ -1,12 +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 } from "ext:core/mod.js"; import {
const { op_node_idna_domain_to_ascii,
op_node_idna_domain_to_unicode, op_node_idna_domain_to_unicode,
op_node_idna_punycode_decode, op_node_idna_punycode_decode,
op_node_idna_punycode_encode, op_node_idna_punycode_encode,
op_node_idna_domain_to_ascii, } from "ext:core/ops";
} = core.ensureFastOps();
import { ucs2 } from "ext:deno_node/internal/idna.ts"; import { ucs2 } from "ext:deno_node/internal/idna.ts";

View file

@ -4,11 +4,10 @@
// 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 {
const {
op_v8_cached_data_version_tag, op_v8_cached_data_version_tag,
op_v8_get_heap_statistics, op_v8_get_heap_statistics,
} = core.ensureFastOps(); } from "ext:core/ops";
import { notImplemented } from "ext:deno_node/_utils.ts"; import { notImplemented } from "ext:deno_node/_utils.ts";

View file

@ -5,9 +5,7 @@
import { core } from "ext:core/mod.js"; import { core } from "ext:core/mod.js";
import { notImplemented } from "ext:deno_node/_utils.ts"; import { notImplemented } from "ext:deno_node/_utils.ts";
const { import { op_vm_run_in_new_context } from "ext:core/ops";
op_vm_run_in_new_context,
} = core.ensureFastOps();
export class Script { export class Script {
code: string; code: string;