-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (32 loc) · 1.36 KB
/
Copy pathindex.js
File metadata and controls
38 lines (32 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
if (typeof interop === "undefined") {
// deno-lint-ignore no-process-globals
if (process) {
// ===
// If we're in a Node-like environment (e.g. Node.js for Mobile)
// ===
const path =
"./build/RelWithDebInfo/NativeScript.apple.node/ios-arm64/NativeScript.framework/NativeScript";
let metaURL = import.meta.url;
if (!metaURL.includes("://")) {
metaURL = "file://" + metaURL;
}
const module = { exports: {} };
// `URL.pathname` is percent-encoded, but `process.dlopen` takes a filesystem path. Without
// decoding, a space in the path arrives as "%20" and the load fails with "no such file" —
// which happens for any app bundle whose path contains a space, e.g.
// /Applications/My App.app/… → /Applications/My%20App.app/…
// deno-lint-ignore no-process-globals
process.dlopen(module, decodeURIComponent(new URL(path, metaURL).pathname));
module.exports.init(
// deno-lint-ignore no-process-globals
process.env.METADATA_PATH
);
} else {
// ===
// If we're in a React Native-like environment
// ===
// react-native-node-api/babel-plugin will rewrite this to:
// module.exports = require("react-native-node-api").requireNodeAddon("-nativescript-macos-node-api—-NativeScript");
module.exports = require("./build/RelWithDebInfo/NativeScript.apple.node");
}
}