@neon-rs/load 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.load = exports.currentTarget = void 0;
27
+ const path = __importStar(require("path"));
28
+ const fs = __importStar(require("fs"));
29
+ function currentTarget() {
30
+ let os = null;
31
+ switch (process.platform) {
32
+ case 'android':
33
+ switch (process.arch) {
34
+ case 'arm':
35
+ return 'android-arm-eabi';
36
+ case 'arm64':
37
+ return 'android-arm64';
38
+ }
39
+ os = 'Android';
40
+ break;
41
+ case 'win32':
42
+ switch (process.arch) {
43
+ case 'x64':
44
+ return 'win32-x64-msvc';
45
+ case 'arm64':
46
+ return 'win32-arm64-msvc';
47
+ case 'ia32':
48
+ return 'win32-ia32-msvc';
49
+ }
50
+ os = 'Windows';
51
+ break;
52
+ case 'darwin':
53
+ switch (process.arch) {
54
+ case 'x64':
55
+ return 'darwin-x64';
56
+ case 'arm64':
57
+ return 'darwin-arm64';
58
+ }
59
+ os = 'macOS';
60
+ break;
61
+ case 'linux':
62
+ switch (process.arch) {
63
+ case 'x64':
64
+ case 'arm64':
65
+ return isGlibc()
66
+ ? `linux-${process.arch}-gnu`
67
+ : `linux-${process.arch}-musl`;
68
+ case 'arm':
69
+ return 'linux-arm-gnueabihf';
70
+ }
71
+ os = 'Linux';
72
+ break;
73
+ case 'freebsd':
74
+ if (process.arch === 'x64') {
75
+ return 'freebsd-x64';
76
+ }
77
+ os = 'FreeBSD';
78
+ break;
79
+ }
80
+ if (os) {
81
+ throw new Error(`Neon: unsupported ${os} architecture: ${process.arch}`);
82
+ }
83
+ throw new Error(`Neon: unsupported system: ${process.platform}`);
84
+ }
85
+ exports.currentTarget = currentTarget;
86
+ function isGlibc() {
87
+ // Cast to unknown to work around a bug in the type definition:
88
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/40140
89
+ const report = process.report?.getReport();
90
+ if ((typeof report !== 'object') || !report || (!('header' in report))) {
91
+ return false;
92
+ }
93
+ const header = report.header;
94
+ return (typeof header === 'object') &&
95
+ !!header &&
96
+ ('glibcVersionRuntime' in header);
97
+ }
98
+ function load(dirname) {
99
+ const m = path.join(dirname, "index.node");
100
+ return fs.existsSync(m) ? require(m) : null;
101
+ }
102
+ exports.load = load;
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@neon-rs/load",
3
+ "version": "0.0.1",
4
+ "description": "Utilities for loading Neon modules.",
5
+ "main": "dist/index.js",
6
+ "types": "types/index.d.ts",
7
+ "files": [
8
+ "dist/**/*",
9
+ "types/**/*"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "pretest": "npm run build",
14
+ "prepack": "npm run build",
15
+ "test": "echo \"Error: no test specified\" && exit 1"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/dherman/neon-rs.git"
20
+ },
21
+ "keywords": [
22
+ "Neon",
23
+ "Rust",
24
+ "Node"
25
+ ],
26
+ "author": "Dave Herman <david.herman@gmail.com>",
27
+ "license": "MIT",
28
+ "bugs": {
29
+ "url": "https://github.com/dherman/neon-rs/issues"
30
+ },
31
+ "homepage": "https://github.com/dherman/neon-rs#readme",
32
+ "devDependencies": {
33
+ "@tsconfig/node16": "^1.0.3",
34
+ "@types/node": "^18.15.11",
35
+ "typescript": "^5.0.4"
36
+ }
37
+ }
@@ -0,0 +1,2 @@
1
+ export declare function currentTarget(): string;
2
+ export declare function load(dirname: string): any;