From b3c85c3548ac3c56f0cf0f3ace36a6f3de3bf823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 14 Feb 2023 15:53:00 +0100 Subject: feat(node): stabilize Node-API (#17553) This commit stabilizes Node-API, the "--unstable" flag is no longer required to load native extensions. "--allow-ffi" permission is still required to load them. --- ext/napi/lib.rs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'ext/napi') diff --git a/ext/napi/lib.rs b/ext/napi/lib.rs index 59a07136d..628ecd5a2 100644 --- a/ext/napi/lib.rs +++ b/ext/napi/lib.rs @@ -514,7 +514,7 @@ impl Env { } } -pub fn init(unstable: bool) -> Extension { +pub fn init() -> Extension { Extension::builder(env!("CARGO_PKG_NAME")) .ops(vec![op_napi_open::decl::

()]) .event_loop_middleware(|op_state_rc, cx| { @@ -578,7 +578,6 @@ pub fn init(unstable: bool) -> Extension { env_cleanup_hooks: Rc::new(RefCell::new(vec![])), tsfn_ref_counters: Arc::new(Mutex::new(vec![])), }); - state.put(Unstable(unstable)); Ok(()) }) .build() @@ -589,17 +588,6 @@ pub trait NapiPermissions { -> std::result::Result<(), AnyError>; } -pub struct Unstable(pub bool); - -fn check_unstable(state: &OpState) { - let unstable = state.borrow::(); - - if !unstable.0 { - eprintln!("Unstable API 'node-api'. The --unstable flag must be provided."); - std::process::exit(70); - } -} - #[op(v8)] fn op_napi_open( scope: &mut v8::HandleScope<'scope>, @@ -610,7 +598,6 @@ fn op_napi_open( where NP: NapiPermissions + 'static, { - check_unstable(op_state); let permissions = op_state.borrow_mut::(); permissions.check(Some(&PathBuf::from(&path)))?; -- cgit v1.2.3