From 8d5c0112fbbed188f97218ace2357feba3a8746f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 10 Nov 2022 22:03:28 +0100 Subject: feat: don't require --unstable flag for npm programs (#16520) This PR adds copies of several unstable APIs that are available in "Deno[Deno.internal].nodeUnstable" namespace. These copies do not perform unstable check (ie. don't require "--unstable" flag to be present). Otherwise they work exactly the same, including permission checks. These APIs are not meant to be used by users directly and can change at any time. Copies of following APIs are available in that namespace: - Deno.spawnChild - Deno.spawn - Deno.spawnSync - Deno.serve - Deno.upgradeHttpRaw - Deno.listenDatagram --- ext/flash/lib.rs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'ext/flash/lib.rs') diff --git a/ext/flash/lib.rs b/ext/flash/lib.rs index 1f3686760..b077b8d21 100644 --- a/ext/flash/lib.rs +++ b/ext/flash/lib.rs @@ -1171,15 +1171,13 @@ pub fn resolve_addr_sync( Ok(result) } -#[op] -fn op_flash_serve

( +fn flash_serve

( state: &mut OpState, opts: ListenOpts, ) -> Result where P: FlashPermissions + 'static, { - check_unstable(state, "Deno.serve"); state .borrow_mut::

() .check_net(&(&opts.hostname, Some(opts.port)), "Deno.serve()")?; @@ -1223,6 +1221,29 @@ where Ok(server_id) } +#[op] +fn op_flash_serve

( + state: &mut OpState, + opts: ListenOpts, +) -> Result +where + P: FlashPermissions + 'static, +{ + check_unstable(state, "Deno.serve"); + flash_serve::

(state, opts) +} + +#[op] +fn op_node_unstable_flash_serve

( + state: &mut OpState, + opts: ListenOpts, +) -> Result +where + P: FlashPermissions + 'static, +{ + flash_serve::

(state, opts) +} + #[op] fn op_flash_wait_for_listening( state: &mut OpState, @@ -1445,6 +1466,7 @@ pub fn init(unstable: bool) -> Extension { )) .ops(vec![ op_flash_serve::decl::

(), + op_node_unstable_flash_serve::decl::

(), op_flash_respond::decl(), op_flash_respond_async::decl(), op_flash_respond_chuncked::decl(), -- cgit v1.2.3