1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

refactor: migrate extensions to virtual ops module (#22135)

First pass of migrating away from `Deno.core.ensureFastOps()`.

A few "tricky" ones have been left for a follow up.
This commit is contained in:
Bartek Iwańczuk 2024-01-26 23:46:46 +01:00 committed by GitHub
parent d889f99657
commit 462ce14a78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 93 additions and 156 deletions

View file

@ -3,12 +3,12 @@
/// <reference path="../../core/internal.d.ts" />
import { core, primordials } from "ext:core/mod.js";
const {
import {
op_broadcast_recv,
op_broadcast_send,
op_broadcast_subscribe,
op_broadcast_unsubscribe,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayPrototypeIndexOf,
ArrayPrototypePush,

View file

@ -1,13 +1,13 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core, primordials } from "ext:core/mod.js";
const {
import { primordials } from "ext:core/mod.js";
import {
op_cache_delete,
op_cache_match,
op_cache_put,
op_cache_storage_delete,
op_cache_storage_has,
op_cache_storage_open,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayPrototypePush,
ObjectPrototypeIsPrototypeOf,

View file

@ -4,10 +4,7 @@ import { core, internals, primordials } from "ext:core/mod.js";
const {
isPromise,
} = core;
const {
op_cron_create,
op_cron_next,
} = core.ensureFastOps();
import { op_cron_create, op_cron_next } from "ext:core/ops";
const {
ArrayPrototypeJoin,
NumberPrototypeToString,

View file

@ -12,7 +12,7 @@ const {
isTypedArray,
isDataView,
} = core;
const {
import {
op_crypto_base64url_decode,
op_crypto_base64url_encode,
op_crypto_decrypt,
@ -42,7 +42,7 @@ const {
op_crypto_verify_ed25519,
op_crypto_verify_key,
op_crypto_wrap_key,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayBufferIsView,
ArrayBufferPrototypeGetByteLength,

View file

@ -13,9 +13,7 @@
import { core } from "ext:core/mod.js";
import { SymbolDispose } from "ext:deno_web/00_infra.js";
const {
op_fetch_custom_client,
} = core.ensureFastOps();
import { op_fetch_custom_client } from "ext:core/ops";
/**
* @param {Deno.CreateHttpClientOptions} options

View file

@ -11,11 +11,11 @@
/// <reference lib="esnext" />
import { core, primordials } from "ext:core/mod.js";
const {
import {
op_fetch,
op_wasm_streaming_feed,
op_wasm_streaming_set_url,
} = core.ensureFastOps();
} from "ext:core/ops";
// TODO(bartlomieju): this ops is also used in `ext/node/polyfills/http.ts`.
const {
op_fetch_send,

View file

@ -2,10 +2,8 @@
/// <reference path="../../core/internal.d.ts" />
import { core, primordials } from "ext:core/mod.js";
const {
op_utf8_to_byte_string,
} = core.ensureFastOps();
import { primordials } from "ext:core/mod.js";
import { op_utf8_to_byte_string } from "ext:core/ops";
const {
ArrayPrototypeFind,
Number,

View file

@ -5,7 +5,7 @@ const {
isDate,
internalRidSymbol,
} = core;
const {
import {
op_fs_chdir,
op_fs_chmod_async,
op_fs_chmod_sync,
@ -15,16 +15,16 @@ const {
op_fs_copy_file_sync,
op_fs_cwd,
op_fs_fdatasync_async,
op_fs_fdatasync_sync,
op_fs_fdatasync_async_unstable,
op_fs_fdatasync_sync,
op_fs_fdatasync_sync_unstable,
op_fs_flock_async,
op_fs_flock_sync,
op_fs_fstat_async,
op_fs_fstat_sync,
op_fs_fsync_async,
op_fs_fsync_sync,
op_fs_fsync_async_unstable,
op_fs_fsync_sync,
op_fs_fsync_sync_unstable,
op_fs_ftruncate_async,
op_fs_ftruncate_sync,
@ -71,7 +71,7 @@ const {
op_fs_utime_sync,
op_fs_write_file_async,
op_fs_write_file_sync,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
op_cancel_handle,
} = core.ensureFastOps(true);

View file

@ -6,7 +6,9 @@ const {
InterruptedPrototype,
internalRidSymbol,
} = core;
const {
import {
op_http_cancel,
op_http_close,
op_http_close_after_finish,
op_http_get_request_headers,
op_http_get_request_method_and_url,
@ -20,13 +22,11 @@ const {
op_http_set_response_header,
op_http_set_response_headers,
op_http_set_response_trailers,
op_http_try_wait,
op_http_upgrade_raw,
op_http_upgrade_websocket_next,
op_http_try_wait,
op_http_wait,
op_http_cancel,
op_http_close,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayPrototypePush,
ObjectHasOwn,

View file

@ -5,7 +5,7 @@ const {
BadResourcePrototype,
InterruptedPrototype,
} = core;
const {
import {
op_http_accept,
op_http_headers,
op_http_shutdown,
@ -14,7 +14,7 @@ const {
op_http_write,
op_http_write_headers,
op_http_write_resource,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayPrototypeIncludes,
ArrayPrototypeMap,

View file

@ -4,7 +4,7 @@ import { core, primordials } from "ext:core/mod.js";
const {
isPromise,
} = core;
const {
import {
op_kv_atomic_write,
op_kv_database_open,
op_kv_dequeue_next_message,
@ -13,7 +13,7 @@ const {
op_kv_snapshot_read,
op_kv_watch,
op_kv_watch_next,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayFrom,
ArrayPrototypeMap,

View file

@ -6,7 +6,7 @@ const {
InterruptedPrototype,
internalRidSymbol,
} = core;
const {
import {
op_dns_resolve,
op_net_accept_tcp,
op_net_accept_unix,
@ -26,7 +26,7 @@ const {
op_net_set_multi_ttl_udp,
op_set_keepalive,
op_set_nodelay,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
op_cancel_handle,
} = core.ensureFastOps(true);

View file

@ -2,13 +2,13 @@
import { core, internals, primordials } from "ext:core/mod.js";
const { internalRidSymbol } = core;
const {
import {
op_net_accept_tls,
op_net_connect_tls,
op_net_listen_tls,
op_tls_handshake,
op_tls_start,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
Number,
ObjectDefineProperty,

View file

@ -5,15 +5,15 @@
/// <reference path="../../core/lib.deno_core.d.ts" />
/// <reference path="../webidl/internal.d.ts" />
import { core, primordials } from "ext:core/mod.js";
const {
import { primordials } from "ext:core/mod.js";
import {
op_url_get_serialization,
op_url_parse,
op_url_parse_search_params,
op_url_parse_with_base,
op_url_reparse,
op_url_stringify_search_params,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayIsArray,
ArrayPrototypeMap,

View file

@ -7,11 +7,11 @@
/// <reference path="./internal.d.ts" />
/// <reference path="./lib.deno_url.d.ts" />
import { core, primordials } from "ext:core/mod.js";
const {
import { primordials } from "ext:core/mod.js";
import {
op_urlpattern_parse,
op_urlpattern_process_match_input,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayPrototypePush,
MathRandom,

View file

@ -7,10 +7,7 @@
/// <reference path="../web/lib.deno_web.d.ts" />
import { core, internals, primordials } from "ext:core/mod.js";
const {
op_base64_encode,
op_base64_decode,
} = core.ensureFastOps();
import { op_base64_decode, op_base64_encode } from "ext:core/ops";
const {
ArrayPrototypeJoin,
ArrayPrototypeMap,

View file

@ -1,12 +1,12 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core, primordials } from "ext:core/mod.js";
const {
import {
op_now,
op_sleep,
op_timer_handle,
op_void_async_deferred,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayPrototypePush,
ArrayPrototypeShift,

View file

@ -6,11 +6,8 @@
/// <reference path="../web/internal.d.ts" />
/// <reference lib="esnext" />
import { core, primordials } from "ext:core/mod.js";
const {
op_base64_atob,
op_base64_btoa,
} = core.ensureFastOps();
import { primordials } from "ext:core/mod.js";
import { op_base64_atob, op_base64_btoa } from "ext:core/ops";
const {
ObjectPrototypeIsPrototypeOf,
TypeErrorPrototype,

View file

@ -13,18 +13,18 @@ const {
isSharedArrayBuffer,
isTypedArray,
} = core;
const {
import {
op_arraybuffer_was_detached,
op_transfer_arraybuffer,
op_readable_stream_resource_allocate,
op_readable_stream_resource_allocate_sized,
op_readable_stream_resource_get_sink,
op_readable_stream_resource_write_error,
op_readable_stream_resource_write_buf,
op_readable_stream_resource_write_sync,
op_readable_stream_resource_close,
op_readable_stream_resource_await_close,
} = core.ensureFastOps();
op_readable_stream_resource_close,
op_readable_stream_resource_get_sink,
op_readable_stream_resource_write_buf,
op_readable_stream_resource_write_error,
op_readable_stream_resource_write_sync,
op_transfer_arraybuffer,
} from "ext:core/ops";
const {
// TODO(mmastrac): use readAll
op_read_all,

View file

@ -15,14 +15,14 @@ const {
isSharedArrayBuffer,
isTypedArray,
} = core;
const {
import {
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();
} from "ext:core/ops";
const {
DataViewPrototypeGetBuffer,
DataViewPrototypeGetByteLength,

View file

@ -17,7 +17,7 @@ const {
isDataView,
isTypedArray,
} = core;
const {
import {
op_blob_create_object_url,
op_blob_create_part,
op_blob_from_object_url,
@ -25,7 +25,7 @@ const {
op_blob_remove_part,
op_blob_revoke_object_url,
op_blob_slice_part,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayBufferIsView,
ArrayBufferPrototypeGetByteLength,

View file

@ -10,10 +10,8 @@
/// <reference path="./internal.d.ts" />
/// <reference lib="esnext" />
import { core, primordials } from "ext:core/mod.js";
const {
op_encode_binary_string,
} = core.ensureFastOps();
import { primordials } from "ext:core/mod.js";
import { op_encode_binary_string } from "ext:core/ops";
const {
ArrayPrototypePush,
ArrayPrototypeReduce,

View file

@ -7,11 +7,11 @@
/// <reference path="./lib.deno_web.d.ts" />
import { core, primordials } from "ext:core/mod.js";
const {
import {
op_message_port_create_entangled,
op_message_port_post_message,
op_message_port_recv_message,
op_message_port_create_entangled,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayBufferPrototypeGetByteLength,
ArrayPrototypeFilter,

View file

@ -5,12 +5,12 @@
/// <reference path="./internal.d.ts" />
/// <reference path="./lib.deno_web.d.ts" />
import { core, primordials } from "ext:core/mod.js";
const {
import { primordials } from "ext:core/mod.js";
import {
op_compression_finish,
op_compression_new,
op_compression_write,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
SymbolFor,
ObjectPrototypeIsPrototypeOf,

View file

@ -11,7 +11,7 @@ const {
isDataView,
isTypedArray,
} = core;
const {
import {
op_webgpu_buffer_get_map_async,
op_webgpu_buffer_get_mapped_range,
op_webgpu_buffer_unmap,
@ -87,7 +87,7 @@ const {
op_webgpu_request_device,
op_webgpu_write_buffer,
op_webgpu_write_texture,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayBuffer,
ArrayBufferPrototypeGetByteLength,

View file

@ -6,13 +6,13 @@
/// <reference path="../web/lib.deno_web.d.ts" />
/// <reference path="./lib.deno_webgpu.d.ts" />
import { core, primordials } from "ext:core/mod.js";
const {
op_webgpu_surface_create,
import { primordials } from "ext:core/mod.js";
import {
op_webgpu_surface_configure,
op_webgpu_surface_create,
op_webgpu_surface_get_current_texture,
op_webgpu_surface_present,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ObjectPrototypeIsPrototypeOf,
Symbol,

View file

@ -1,35 +0,0 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core } from "ext:core/mod.js";
const {
op_ws_create,
op_ws_close,
op_ws_send_binary,
op_ws_send_binary_ab,
op_ws_send_text,
op_ws_next_event,
op_ws_get_buffer,
op_ws_get_buffer_as_string,
op_ws_get_error,
op_ws_send_ping,
op_ws_get_buffered_amount,
op_ws_send_text_async,
op_ws_send_binary_async,
op_ws_check_permission_and_cancel_handle,
} = core.ensureFastOps();
export {
op_ws_check_permission_and_cancel_handle,
op_ws_close,
op_ws_create,
op_ws_get_buffer,
op_ws_get_buffer_as_string,
op_ws_get_buffered_amount,
op_ws_get_error,
op_ws_next_event,
op_ws_send_binary,
op_ws_send_binary_ab,
op_ws_send_binary_async,
op_ws_send_ping,
op_ws_send_text,
op_ws_send_text_async,
};

View file

@ -20,7 +20,7 @@ import {
op_ws_send_binary_ab,
op_ws_send_ping,
op_ws_send_text,
} from "ext:deno_websocket/00_ops.js";
} from "ext:core/ops";
const {
ArrayBufferIsView,
ArrayPrototypeJoin,

View file

@ -13,7 +13,7 @@ import {
op_ws_next_event,
op_ws_send_binary_async,
op_ws_send_text_async,
} from "ext:deno_websocket/00_ops.js";
} from "ext:core/ops";
const {
ArrayPrototypeJoin,
ArrayPrototypeMap,

View file

@ -842,7 +842,7 @@ deno_core::extension!(deno_websocket,
op_ws_send_pong,
op_ws_get_buffered_amount,
],
esm = [ "00_ops.js", "01_websocket.js", "02_websocketstream.js" ],
esm = [ "01_websocket.js", "02_websocketstream.js" ],
options = {
user_agent: String,
root_cert_store_provider: Option<Arc<dyn RootCertStoreProvider>>,

View file

@ -2,8 +2,8 @@
/// <reference path="../../core/internal.d.ts" />
import { core, primordials } from "ext:core/mod.js";
const {
import { primordials } from "ext:core/mod.js";
import {
op_webstorage_clear,
op_webstorage_get,
op_webstorage_iterate_keys,
@ -11,7 +11,7 @@ const {
op_webstorage_length,
op_webstorage_remove,
op_webstorage_set,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
Symbol,
SymbolFor,

View file

@ -1,9 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core, primordials } from "ext:core/mod.js";
const {
op_bootstrap_log_level,
} = core.ensureFastOps();
import { primordials } from "ext:core/mod.js";
import { op_bootstrap_log_level } from "ext:core/ops";
const {
Promise,
SafeArrayIterator,

View file

@ -1,11 +1,11 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core, primordials } from "ext:core/mod.js";
const {
import { primordials } from "ext:core/mod.js";
import {
op_query_permission,
op_request_permission,
op_revoke_permission,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayIsArray,
ArrayPrototypeIncludes,

View file

@ -1,13 +1,13 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core, primordials } from "ext:core/mod.js";
const {
import { primordials } from "ext:core/mod.js";
import {
op_create_worker,
op_host_post_message,
op_host_recv_ctrl,
op_host_recv_message,
op_host_terminate_worker,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayPrototypeFilter,
Error,

View file

@ -1,7 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core, primordials } from "ext:core/mod.js";
const {
import { primordials } from "ext:core/mod.js";
import {
op_delete_env,
op_env,
op_exec_path,
@ -14,12 +14,10 @@ const {
op_os_release,
op_os_uptime,
op_set_env,
op_set_exit_code,
op_system_memory_info,
op_uid,
} = core.ensureFastOps();
const {
op_set_exit_code,
} = core.ensureFastOps(true);
} from "ext:core/ops";
const {
Error,
FunctionPrototypeBind,

View file

@ -1,14 +1,11 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core, internals, primordials } from "ext:core/mod.js";
import { op_fs_events_open, op_fs_events_poll } from "ext:core/ops";
const {
BadResourcePrototype,
InterruptedPrototype,
} = core;
const {
op_fs_events_open,
op_fs_events_poll,
} = core.ensureFastOps();
const {
ArrayIsArray,
ObjectPrototypeIsPrototypeOf,

View file

@ -1,7 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core, internals } from "ext:core/mod.js";
import { op_http_start } from "ext:core/ops";
const { internalRidSymbol } = core;
const { op_http_start } = core.ensureFastOps();
import { HttpConn } from "ext:deno_http/01_http.js";

View file

@ -1,7 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core, internals, primordials } from "ext:core/mod.js";
const {
import {
op_kill,
op_run,
op_run_status,
@ -9,7 +9,7 @@ const {
op_spawn_kill,
op_spawn_sync,
op_spawn_wait,
} = core.ensureFastOps();
} from "ext:core/ops";
const {
ArrayPrototypeMap,
ArrayPrototypeSlice,

View file

@ -1,11 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core, primordials } from "ext:core/mod.js";
const {
op_signal_bind,
op_signal_poll,
op_signal_unbind,
} = core.ensureFastOps();
import { op_signal_bind, op_signal_poll, op_signal_unbind } from "ext:core/ops";
const {
SafeSet,
SafeSetIterator,

View file

@ -1,8 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core, primordials } from "ext:core/mod.js";
const {
op_read_line_prompt,
} = core.ensureFastOps();
import { op_read_line_prompt } from "ext:core/ops";
const {
ArrayPrototypePush,
StringPrototypeCharCodeAt,

View file

@ -1,11 +1,11 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core, internals } from "ext:core/mod.js";
const {
import {
op_net_listen_udp,
op_net_listen_unixpacket,
op_runtime_memory_usage,
} = core.ensureFastOps();
} from "ext:core/ops";
import * as timers from "ext:deno_web/02_timers.js";
import * as httpClient from "ext:deno_fetch/22_http_client.js";