File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed
Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 1+ const isNativeScriptRuntime =
2+ typeof globalThis . interop !== "undefined" ||
3+ typeof globalThis . NSObject !== "undefined" ;
4+
5+ if ( ! isNativeScriptRuntime ) {
6+ // deno-lint-ignore no-process-globals
7+ if ( typeof process !== "undefined" && typeof process . dlopen === "function" ) {
8+ // ===
9+ // If we're in a Node-like environment (e.g. Node.js, Deno, or Bun)
10+ // ===
11+
12+ const module = { exports : { } } ;
13+ process . dlopen (
14+ module ,
15+ require ( "node:path" ) . resolve (
16+ __dirname ,
17+ "./build/RelWithDebInfo/NativeScript.apple.node/macos-arm64/NativeScript.framework/Versions/A/NativeScript" ,
18+ ) ,
19+ ) ;
20+ module . exports . init ( process . env . METADATA_PATH ) ;
21+ } else if ( typeof require !== "undefined" ) {
22+ // ===
23+ // If we're in a React Native-like environment
24+ // ===
25+
26+ // react-native-node-api/babel-plugin will rewrite this to:
27+ // module.exports = require("react-native-node-api").requireNodeAddon("-nativescript-macos-node-api—-NativeScript");
28+ module . exports = require ( "./build/RelWithDebInfo/NativeScript.apple.node" ) ;
29+ }
30+ }
Original file line number Diff line number Diff line change @@ -24,13 +24,16 @@ if (!isNativeScriptRuntime) {
2424
2525 module . exports . init (
2626 // deno-lint-ignore no-process-globals
27- process . env . METADATA_PATH
27+ process . env . METADATA_PATH ,
2828 ) ;
2929 } else if ( typeof require !== "undefined" ) {
3030 // ===
3131 // If we're in a React Native-like environment
3232 // ===
3333
34+ // Hermes doesn't support MJS, so fall back to CJS. Really, the bundler
35+ // shouldn't have resolved this file in the first place.
36+
3437 // react-native-node-api/babel-plugin will rewrite this to:
3538 // module.exports = require("react-native-node-api").requireNodeAddon("-nativescript-macos-node-api—-NativeScript");
3639 module . exports = require ( "./build/RelWithDebInfo/NativeScript.apple.node" ) ;
Original file line number Diff line number Diff line change 11{
22 "name" : " @nativescript/macos-node-api" ,
3- "version" : " 0.4.1 " ,
3+ "version" : " 0.4.2 " ,
44 "description" : " An embeddable, engine-agnostic NativeScript runtime for macOS based on Node-API" ,
55 "repository" : {
66 "type" : " git" ,
4949 },
5050 "devDependencies" : {
5151 "rimraf" : " ^6.0.0"
52+ },
53+ "exports" : {
54+ "." : {
55+ "types" : " ./index.d.ts" ,
56+ "import" : " ./index.mjs" ,
57+ "require" : " ./index.cjs"
58+ },
59+ "./package.json" : " ./package.json" ,
60+ "./*" : " ./*"
5261 }
5362}
You can’t perform that action at this time.
0 commit comments