summaryrefslogtreecommitdiff
path: root/ext/flash/lib.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-11-10 22:03:28 +0100
committerGitHub <noreply@github.com>2022-11-10 22:03:28 +0100
commit8d5c0112fbbed188f97218ace2357feba3a8746f (patch)
treecf08da990c8bf90da116e8db3ac6332cd37578a1 /ext/flash/lib.rs
parent53e974b276b095faf52918c4c6e988e9d2788cef (diff)
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
Diffstat (limited to 'ext/flash/lib.rs')
-rw-r--r--ext/flash/lib.rs28
1 files changed, 25 insertions, 3 deletions
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<P>(
+fn flash_serve<P>(
state: &mut OpState,
opts: ListenOpts,
) -> Result<u32, AnyError>
where
P: FlashPermissions + 'static,
{
- check_unstable(state, "Deno.serve");
state
.borrow_mut::<P>()
.check_net(&(&opts.hostname, Some(opts.port)), "Deno.serve()")?;
@@ -1224,6 +1222,29 @@ where
}
#[op]
+fn op_flash_serve<P>(
+ state: &mut OpState,
+ opts: ListenOpts,
+) -> Result<u32, AnyError>
+where
+ P: FlashPermissions + 'static,
+{
+ check_unstable(state, "Deno.serve");
+ flash_serve::<P>(state, opts)
+}
+
+#[op]
+fn op_node_unstable_flash_serve<P>(
+ state: &mut OpState,
+ opts: ListenOpts,
+) -> Result<u32, AnyError>
+where
+ P: FlashPermissions + 'static,
+{
+ flash_serve::<P>(state, opts)
+}
+
+#[op]
fn op_flash_wait_for_listening(
state: &mut OpState,
server_id: u32,
@@ -1445,6 +1466,7 @@ pub fn init<P: FlashPermissions + 'static>(unstable: bool) -> Extension {
))
.ops(vec![
op_flash_serve::decl::<P>(),
+ op_node_unstable_flash_serve::decl::<P>(),
op_flash_respond::decl(),
op_flash_respond_async::decl(),
op_flash_respond_chuncked::decl(),