Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove imported ops from Deno.core.ops #22194

Merged
merged 11 commits into from
Jan 31, 2024
Next Next commit
refactor: remove imported ops from Deno.core.ops
  • Loading branch information
bartlomieju committed Jan 30, 2024
commit 6ec50e0aba06a12758ddf64700601d033a54b1fb
239 changes: 239 additions & 0 deletions runtime/js/99_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,245 @@ function exposeUnstableFeaturesForWindowOrWorkerGlobalScope(options) {
}
}

// NOTE(bartlomieju): remove all the ops that have already been imported using
// "virtual op module" (`ext:core/ops`).
const NOT_IMPORTED_OPS = [
"op_close",
"op_try_close",
"op_print",
"op_resources",
"op_void_sync",
"op_error_async",
"op_error_async_deferred",
"op_void_async",
"op_add",
"op_add_async",
"op_read",
"op_write",
"op_read_sync",
"op_write_sync",
"op_write_all",
"op_write_type_error",
"op_shutdown",
"op_format_file_name",
"op_str_byte_length",
"op_panic",
"op_is_any_array_buffer",
"op_is_arguments_object",
"op_is_array_buffer",
"op_is_array_buffer_view",
"op_is_async_function",
"op_is_big_int_object",
"op_is_boolean_object",
"op_is_boxed_primitive",
"op_is_data_view",
"op_is_date",
"op_is_generator_function",
"op_is_generator_object",
"op_is_map",
"op_is_map_iterator",
"op_is_module_namespace_object",
"op_is_native_error",
"op_is_number_object",
"op_is_promise",
"op_is_proxy",
"op_is_reg_exp",
"op_is_set",
"op_is_set_iterator",
"op_is_shared_array_buffer",
"op_is_string_object",
"op_is_symbol_object",
"op_is_typed_array",
"op_is_weak_map",
"op_is_weak_set",
"op_set_handled_promise_rejection_handler",
"op_timer_queue",
"op_timer_cancel",
"op_timer_ref",
"op_timer_unref",
"op_ref_op",
"op_unref_op",
"op_run_microtasks",
"op_has_tick_scheduled",
"op_set_has_tick_scheduled",
"op_eval_context",
"op_queue_microtask",
"op_encode",
"op_decode",
"op_serialize",
"op_deserialize",
"op_set_promise_hooks",
"op_get_promise_details",
"op_get_proxy_details",
"op_memory_usage",
"op_set_wasm_streaming_callback",
"op_abort_wasm_streaming",
"op_destructure_error",
"op_dispatch_exception",
"op_op_names",
"op_apply_source_map",
"op_apply_source_map_filename",
"op_current_user_call_site",
"op_set_format_exception_callback",
"op_event_loop_has_more_work",
"op_image_process",
"op_image_decode_png",
"op_ws_send_pong",
"op_broadcast_unsubscribe",
"op_ffi_load",
"op_ffi_get_static",
"op_ffi_call_nonblocking",
"op_ffi_call_ptr",
"op_ffi_call_ptr_nonblocking",
"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_get_buf",
"op_ffi_buf_copy_into",
"op_ffi_cstr_read",
"op_ffi_read_bool",
"op_ffi_read_u8",
"op_ffi_read_i8",
"op_ffi_read_u16",
"op_ffi_read_i16",
"op_ffi_read_u32",
"op_ffi_read_i32",
"op_ffi_read_u64",
"op_ffi_read_i64",
"op_ffi_read_f32",
"op_ffi_read_f64",
"op_ffi_read_ptr",
"op_ffi_unsafe_callback_create",
"op_ffi_unsafe_callback_close",
"op_ffi_unsafe_callback_ref",
"op_node_unstable_net_listen_udp",
"op_node_unstable_net_listen_unixpacket",
"op_http_get_request_header",
"op_raw_write_vectored",
"op_can_write_vectored",
"op_node_create_decipheriv",
"op_node_cipheriv_encrypt",
"op_node_cipheriv_final",
"op_node_cipheriv_set_aad",
"op_node_decipheriv_set_aad",
"op_node_create_cipheriv",
"op_node_create_hash",
"op_node_get_hashes",
"op_node_decipheriv_decrypt",
"op_node_decipheriv_final",
"op_node_hash_update",
"op_node_hash_update_str",
"op_node_hash_digest",
"op_node_hash_digest_hex",
"op_node_hash_clone",
"op_node_private_encrypt",
"op_node_private_decrypt",
"op_node_public_encrypt",
"op_node_pbkdf2",
"op_node_pbkdf2_async",
"op_node_hkdf",
"op_node_hkdf_async",
"op_node_sign",
"op_node_verify",
"op_node_random_int",
"op_node_scrypt_sync",
"op_node_scrypt_async",
"op_node_x509_parse",
"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_subject",
"op_node_x509_get_valid_from",
"op_node_x509_get_valid_to",
"op_node_x509_get_serial_number",
"op_node_x509_key_usage",
"op_node_fs_exists_sync",
"op_node_cp_sync",
"op_node_cp",
"op_node_sys_to_uv_error",
"op_v8_cached_data_version_tag",
"op_v8_get_heap_statistics",
"op_vm_run_in_new_context",
"op_node_idna_domain_to_ascii",
"op_node_idna_domain_to_unicode",
"op_node_idna_punycode_decode",
"op_node_idna_punycode_encode",
"op_zlib_new",
"op_zlib_close",
"op_zlib_close_if_pending",
"op_zlib_write",
"op_zlib_write_async",
"op_zlib_init",
"op_zlib_reset",
"op_brotli_compress",
"op_brotli_compress_async",
"op_create_brotli_compress",
"op_brotli_compress_stream",
"op_brotli_compress_stream_end",
"op_brotli_decompress",
"op_brotli_decompress_async",
"op_create_brotli_decompress",
"op_brotli_decompress_stream",
"op_brotli_decompress_stream_end",
"op_http2_connect",
"op_http2_poll_client_connection",
"op_http2_client_request",
"op_http2_client_get_response",
"op_http2_client_get_response_body_chunk",
"op_http2_client_send_data",
"op_http2_client_end_stream",
"op_http2_client_reset_stream",
"op_http2_client_send_trailers",
"op_http2_client_get_response_trailers",
"op_http2_accept",
"op_http2_listen",
"op_http2_send_response",
"op_node_os_get_priority",
"op_node_os_set_priority",
"op_node_os_username",
"op_cpus",
"op_node_is_promise_rejected",
"op_npm_process_state",
"op_node_guess_handle_type",
"op_node_create_private_key",
"op_node_ipc_write",
"op_node_ipc_read",
"op_main_module",
"op_ppid",
"op_bootstrap_args",
"op_bootstrap_pid",
"op_bootstrap_no_color",
"op_bootstrap_is_tty",
"op_snapshot_options",
"op_pledge_test_permissions",
"op_restore_test_permissions",
"op_register_test",
"op_register_test_step",
"op_test_event_step_wait",
"op_test_event_step_result_ok",
"op_test_event_step_result_ignored",
"op_test_event_step_result_failed",
"op_test_op_sanitizer_collect",
"op_test_op_sanitizer_finish",
"op_test_op_sanitizer_report",
];

{
const allOpNames = ObjectKeys(ops);
for (let i = 0; i < allOpNames.length; i++) {
const opName = ops[allOpNames[i]];
if (NOT_IMPORTED_OPS.indexOf(opName) < 0) {
delete ops[opName];
}
}
}

// FIXME(bartlomieju): temporarily add whole `Deno.core` to
// `Deno[Deno.internal]` namespace. It should be removed and only necessary
// methods should be left there.
Expand Down