jaelis-node 1.3.2 → 1.4.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/README.md +62 -1
- package/lib/JAELIS-VM/lib/adapters/evm-adapter.js +454 -0
- package/lib/JAELIS-VM/lib/adapters/index.js +411 -0
- package/lib/JAELIS-VM/lib/adapters/svm-adapter.js +457 -0
- package/lib/JAELIS-VM/lib/compiler/jir-compiler.js +1097 -0
- package/lib/JAELIS-VM/lib/execution/engine.js +1183 -0
- package/lib/JAELIS-VM/lib/index.js +440 -0
- package/lib/JAELIS-VM/lib/integration/jaelis-integration.js +543 -0
- package/lib/JAELIS-VM/lib/serialization/serializer.js +819 -0
- package/lib/JAELIS-VM/lib/state/state-manager.js +1116 -0
- package/lib/JAELIS-VM/lib/translator/bytecode-translator.js +1222 -0
- package/lib/JAELIS-VM/lib/unified/cross-chain-state.js +836 -0
- package/lib/JAELIS-VM/lib/unified/dynamic-contracts.js +1127 -0
- package/lib/JAELIS-VM/lib/unified/index.js +378 -0
- package/lib/JAELIS-VM/lib/unified/jaelis-abi.js +1150 -0
- package/lib/JAELIS-VM/lib/unified/unified-compiler.js +1350 -0
- package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds +12 -0
- package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds +12 -0
- package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages +12 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional +12 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test +12 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/.package-lock.json +127 -0
- package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/README.md +1 -0
- package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/index.js +0 -0
- package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/node.abi115.node +0 -0
- package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/node.napi.node +0 -0
- package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/package.json +17 -0
- package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/README.md +1 -0
- package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/index.js +0 -0
- package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/node.abi115.node +0 -0
- package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/node.napi.node +0 -0
- package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/package.json +17 -0
- package/lib/JAELIS-VM/node_modules/cbor-extract/LICENSE +21 -0
- package/lib/JAELIS-VM/node_modules/cbor-extract/README.md +5 -0
- package/lib/JAELIS-VM/node_modules/cbor-extract/bin/download-prebuilds.js +11 -0
- package/lib/JAELIS-VM/node_modules/cbor-extract/binding.gyp +60 -0
- package/lib/JAELIS-VM/node_modules/cbor-extract/index.js +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-extract/package.json +50 -0
- package/lib/JAELIS-VM/node_modules/cbor-extract/src/extract.cpp +198 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/LICENSE +21 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/README.md +380 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/SECURITY.md +11 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/benchmark.md +73 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/browser.js +11 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/decode.d.ts +2 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/decode.js +1300 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/decode-no-eval.cjs +1244 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/decode-no-eval.cjs.map +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.cjs +2509 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.cjs.map +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.min.js +2 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.min.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.js +2508 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.min.js +2 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.min.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/node.cjs +2629 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/node.cjs.map +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/test.js +3343 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/test.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/encode.d.ts +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/encode.js +1231 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/index.d.ts +79 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/index.js +3 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/iterators.js +85 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/node-index.js +24 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/package.json +94 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/rollup.config.js +88 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/stream.js +61 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/webpack.config.js +19 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/LICENSE +201 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/README.md +163 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/index.d.ts +14 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/lib/detect-libc.js +313 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/lib/elf.js +39 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/lib/filesystem.js +51 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/lib/process.js +24 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/package.json +44 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/LICENSE +21 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/README.md +372 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/SECURITY.md +11 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/benchmark.md +67 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.cjs +2407 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.cjs.map +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.min.js +2 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.min.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.js +2406 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.min.js +2 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.min.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/node.cjs +3320 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/node.cjs.map +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/test.js +4540 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/test.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/unpack-no-eval.cjs +1250 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/unpack-no-eval.cjs.map +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/index.d.cts +91 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/index.d.ts +91 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/index.js +5 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/iterators.js +87 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/node-index.js +25 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/pack.d.cts +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/pack.d.ts +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/pack.js +1141 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/package.json +104 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/rollup.config.js +88 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/stream.js +57 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/struct.js +815 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/test-worker.js +3 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/unpack.d.cts +2 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/unpack.d.ts +2 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/unpack.js +1221 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/LICENSE +21 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/README.md +5 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/bin/download-prebuilds.js +13 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/binding.gyp +63 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/index.js +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages +12 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional +12 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test +12 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/LICENSE +21 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/README.md +58 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/bin.js +82 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/build-test.js +19 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/index.js +6 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/node-gyp-build.js +236 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/optional.js +7 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/package.json +32 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/package.json +50 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/src/extract.cpp +274 -0
- package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/LICENSE +21 -0
- package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/README.md +58 -0
- package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/bin.js +77 -0
- package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/build-test.js +19 -0
- package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/index.js +224 -0
- package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/optional.js +7 -0
- package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/package.json +32 -0
- package/lib/JAELIS-VM/package-lock.json +284 -0
- package/lib/JAELIS-VM/package.json +38 -0
- package/lib/JAELIS-VM/test/comprehensive.test.js +267 -0
- package/lib/JAELIS-VM/test/cross-chain-test.js +470 -0
- package/lib/JAELIS-VM/test/unified-vm-test.js +459 -0
- package/lib/JAELIS-VM/test/unified.test.js +166 -0
- package/lib/JAELIS-VM/test/vm.test.js +599 -0
- package/lib/index.js +240 -4
- package/package.json +2 -2
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
var fs = require('fs')
|
|
2
|
+
var path = require('path')
|
|
3
|
+
var url = require('url')
|
|
4
|
+
var os = require('os')
|
|
5
|
+
// Workaround to fix webpack's build warnings: 'the request of a dependency is an expression'
|
|
6
|
+
var runtimeRequire = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require // eslint-disable-line
|
|
7
|
+
|
|
8
|
+
var vars = (process.config && process.config.variables) || {}
|
|
9
|
+
var prebuildsOnly = !!process.env.PREBUILDS_ONLY
|
|
10
|
+
var versions = process.versions
|
|
11
|
+
var abi = versions.modules
|
|
12
|
+
if (versions.deno || process.isBun) {
|
|
13
|
+
// both Deno and Bun made the very poor decision to shoot themselves in the foot and lie about support for ABI
|
|
14
|
+
// (which they do not have)
|
|
15
|
+
abi = 'unsupported'
|
|
16
|
+
}
|
|
17
|
+
var runtime = isElectron() ? 'electron' : (isNwjs() ? 'node-webkit' : 'node')
|
|
18
|
+
var arch = process.env.npm_config_arch || os.arch()
|
|
19
|
+
var platform = process.env.npm_config_platform || os.platform()
|
|
20
|
+
var libc = process.env.LIBC || (isMusl(platform) ? 'musl' : 'glibc')
|
|
21
|
+
|
|
22
|
+
var armv = process.env.ARM_VERSION || (arch === 'arm64' ? '8' : vars.arm_version) || ''
|
|
23
|
+
var uv = (versions.uv || '').split('.')[0]
|
|
24
|
+
|
|
25
|
+
module.exports = load
|
|
26
|
+
|
|
27
|
+
function load (dir) {
|
|
28
|
+
return runtimeRequire(load.resolve(dir))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
load.resolve = load.path = function (dir) {
|
|
32
|
+
dir = path.resolve(dir || '.')
|
|
33
|
+
var packageName = ''
|
|
34
|
+
var packageNameError
|
|
35
|
+
try {
|
|
36
|
+
packageName = runtimeRequire(path.join(dir, 'package.json')).name;
|
|
37
|
+
var varName = packageName.toUpperCase().replace(/-/g, '_')
|
|
38
|
+
if (process.env[varName + '_PREBUILD']) dir = process.env[varName + '_PREBUILD']
|
|
39
|
+
} catch (err) {
|
|
40
|
+
packageNameError = err;
|
|
41
|
+
}
|
|
42
|
+
if (!prebuildsOnly) {
|
|
43
|
+
var release = getFirst(path.join(dir, 'build/Release'), matchBuild)
|
|
44
|
+
if (release) return release
|
|
45
|
+
|
|
46
|
+
var debug = getFirst(path.join(dir, 'build/Debug'), matchBuild)
|
|
47
|
+
if (debug) return debug
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var prebuild = resolve(dir)
|
|
51
|
+
if (prebuild) return prebuild
|
|
52
|
+
|
|
53
|
+
var nearby = resolve(path.dirname(process.execPath))
|
|
54
|
+
if (nearby) return nearby
|
|
55
|
+
|
|
56
|
+
var platformPackage = (packageName[0] == '@' ? '' : '@' + packageName + '/') + packageName + '-' + platform + '-' + arch
|
|
57
|
+
var packageResolutionError
|
|
58
|
+
try {
|
|
59
|
+
var prebuildPackage = path.dirname(require('module').createRequire(url.pathToFileURL(path.join(dir, 'package.json'))).resolve(platformPackage))
|
|
60
|
+
return resolveFile(prebuildPackage)
|
|
61
|
+
} catch(error) {
|
|
62
|
+
packageResolutionError = error
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var target = [
|
|
66
|
+
'platform=' + platform,
|
|
67
|
+
'arch=' + arch,
|
|
68
|
+
'runtime=' + runtime,
|
|
69
|
+
'abi=' + abi,
|
|
70
|
+
'uv=' + uv,
|
|
71
|
+
armv ? 'armv=' + armv : '',
|
|
72
|
+
'libc=' + libc,
|
|
73
|
+
'node=' + process.versions.node,
|
|
74
|
+
process.versions.electron ? 'electron=' + process.versions.electron : '',
|
|
75
|
+
typeof __webpack_require__ === 'function' ? 'webpack=true' : '' // eslint-disable-line
|
|
76
|
+
].filter(Boolean).join(' ')
|
|
77
|
+
let errMessage = 'No native build was found for ' + target + '\n attempted loading from: ' + dir + ' and package:' +
|
|
78
|
+
' ' + platformPackage + '\n';
|
|
79
|
+
if (packageNameError) {
|
|
80
|
+
errMessage += 'Error finding package.json: ' + packageNameError.message + '\n';
|
|
81
|
+
}
|
|
82
|
+
if (packageResolutionError) {
|
|
83
|
+
errMessage += 'Error resolving package: ' + packageResolutionError.message + '\n';
|
|
84
|
+
}
|
|
85
|
+
throw new Error(errMessage)
|
|
86
|
+
|
|
87
|
+
function resolve (dir) {
|
|
88
|
+
// Find matching "prebuilds/<platform>-<arch>" directory
|
|
89
|
+
var tuples = readdirSync(path.join(dir, 'prebuilds')).map(parseTuple)
|
|
90
|
+
var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0]
|
|
91
|
+
if (!tuple) return
|
|
92
|
+
return resolveFile(path.join(dir, 'prebuilds', tuple.name))
|
|
93
|
+
}
|
|
94
|
+
function resolveFile (prebuilds) {
|
|
95
|
+
// Find most specific flavor first
|
|
96
|
+
var parsed = readdirSync(prebuilds).map(parseTags)
|
|
97
|
+
var candidates = parsed.filter(matchTags(runtime, abi))
|
|
98
|
+
var winner = candidates.sort(compareTags(runtime))[0]
|
|
99
|
+
if (winner) return path.join(prebuilds, winner.file)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function readdirSync (dir) {
|
|
104
|
+
try {
|
|
105
|
+
return fs.readdirSync(dir)
|
|
106
|
+
} catch (err) {
|
|
107
|
+
return []
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function getFirst (dir, filter) {
|
|
112
|
+
var files = readdirSync(dir).filter(filter)
|
|
113
|
+
return files[0] && path.join(dir, files[0])
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function matchBuild (name) {
|
|
117
|
+
return /\.node$/.test(name)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function parseTuple (name) {
|
|
121
|
+
// Example: darwin-x64+arm64
|
|
122
|
+
var arr = name.split('-')
|
|
123
|
+
if (arr.length !== 2) return
|
|
124
|
+
|
|
125
|
+
var platform = arr[0]
|
|
126
|
+
var architectures = arr[1].split('+')
|
|
127
|
+
|
|
128
|
+
if (!platform) return
|
|
129
|
+
if (!architectures.length) return
|
|
130
|
+
if (!architectures.every(Boolean)) return
|
|
131
|
+
|
|
132
|
+
return { name, platform, architectures }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function matchTuple (platform, arch) {
|
|
136
|
+
return function (tuple) {
|
|
137
|
+
if (tuple == null) return false
|
|
138
|
+
if (tuple.platform !== platform) return false
|
|
139
|
+
return tuple.architectures.includes(arch)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function compareTuples (a, b) {
|
|
144
|
+
// Prefer single-arch prebuilds over multi-arch
|
|
145
|
+
return a.architectures.length - b.architectures.length
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function parseTags (file) {
|
|
149
|
+
var arr = file.split('.')
|
|
150
|
+
var extension = arr.pop()
|
|
151
|
+
var tags = { file: file, specificity: 0 }
|
|
152
|
+
|
|
153
|
+
if (extension !== 'node') return
|
|
154
|
+
|
|
155
|
+
for (var i = 0; i < arr.length; i++) {
|
|
156
|
+
var tag = arr[i]
|
|
157
|
+
|
|
158
|
+
if (tag === 'node' || tag === 'electron' || tag === 'node-webkit') {
|
|
159
|
+
tags.runtime = tag
|
|
160
|
+
} else if (tag === 'napi') {
|
|
161
|
+
tags.napi = true
|
|
162
|
+
} else if (tag.slice(0, 3) === 'abi') {
|
|
163
|
+
tags.abi = tag.slice(3)
|
|
164
|
+
} else if (tag.slice(0, 2) === 'uv') {
|
|
165
|
+
tags.uv = tag.slice(2)
|
|
166
|
+
} else if (tag.slice(0, 4) === 'armv') {
|
|
167
|
+
tags.armv = tag.slice(4)
|
|
168
|
+
} else if (tag === 'glibc' || tag === 'musl') {
|
|
169
|
+
tags.libc = tag
|
|
170
|
+
} else {
|
|
171
|
+
continue
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
tags.specificity++
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return tags
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function matchTags (runtime, abi) {
|
|
181
|
+
return function (tags) {
|
|
182
|
+
if (tags == null) return false
|
|
183
|
+
if (tags.runtime !== runtime && !runtimeAgnostic(tags)) return false
|
|
184
|
+
if (tags.abi !== abi && !tags.napi) return false
|
|
185
|
+
if (tags.uv && tags.uv !== uv) return false
|
|
186
|
+
if (tags.armv && tags.armv !== armv) return false
|
|
187
|
+
if (tags.libc && tags.libc !== libc) return false
|
|
188
|
+
|
|
189
|
+
return true
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function runtimeAgnostic (tags) {
|
|
194
|
+
return tags.runtime === 'node' && tags.napi
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function compareTags (runtime) {
|
|
198
|
+
// Precedence: non-agnostic runtime, abi over napi, then by specificity.
|
|
199
|
+
return function (a, b) {
|
|
200
|
+
if (a.runtime !== b.runtime) {
|
|
201
|
+
return a.runtime === runtime ? -1 : 1
|
|
202
|
+
} else if (a.abi !== b.abi) {
|
|
203
|
+
return a.abi ? -1 : 1
|
|
204
|
+
} else if (a.specificity !== b.specificity) {
|
|
205
|
+
return a.specificity > b.specificity ? -1 : 1
|
|
206
|
+
} else {
|
|
207
|
+
return 0
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function isNwjs () {
|
|
213
|
+
return !!(process.versions && process.versions.nw)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function isElectron () {
|
|
217
|
+
if (process.versions && process.versions.electron) return true
|
|
218
|
+
if (process.env.ELECTRON_RUN_AS_NODE) return true
|
|
219
|
+
return typeof window !== 'undefined' && window.process && window.process.type === 'renderer'
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function isMusl (platform) {
|
|
223
|
+
if (platform !== 'linux') return false;
|
|
224
|
+
const { familySync, MUSL } = require('detect-libc');
|
|
225
|
+
return familySync() === MUSL;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Exposed for unit tests
|
|
229
|
+
// TODO: move to lib
|
|
230
|
+
load.parseTags = parseTags
|
|
231
|
+
load.matchTags = matchTags
|
|
232
|
+
load.compareTags = compareTags
|
|
233
|
+
load.parseTuple = parseTuple
|
|
234
|
+
load.matchTuple = matchTuple
|
|
235
|
+
load.compareTuples = compareTuples
|
|
236
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "node-gyp-build-optional-packages",
|
|
3
|
+
"version": "5.2.2",
|
|
4
|
+
"description": "Build tool and bindings loader for node-gyp that supports prebuilds",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"array-shuffle": "^1.0.1",
|
|
8
|
+
"standard": "^14.0.0",
|
|
9
|
+
"tape": "^5.0.0"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"detect-libc": "^2.0.1"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "standard && node test"
|
|
16
|
+
},
|
|
17
|
+
"bin": {
|
|
18
|
+
"node-gyp-build-optional-packages": "./bin.js",
|
|
19
|
+
"node-gyp-build-optional-packages-optional": "./optional.js",
|
|
20
|
+
"node-gyp-build-optional-packages-test": "./build-test.js"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/prebuild/node-gyp-build.git"
|
|
25
|
+
},
|
|
26
|
+
"author": "Mathias Buus (@mafintosh)",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/prebuild/node-gyp-build/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/prebuild/node-gyp-build"
|
|
32
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "msgpackr-extract",
|
|
3
|
+
"author": "Kris Zyp",
|
|
4
|
+
"version": "3.0.3",
|
|
5
|
+
"description": "Node addon for string extraction for msgpackr",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "http://github.com/kriszyp/msgpackr-extract"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"install": "node-gyp-build-optional-packages",
|
|
13
|
+
"recompile": "node-gyp rebuild",
|
|
14
|
+
"before-publish": "prebuildify-ci download && node set-optional-deps.cjs",
|
|
15
|
+
"prebuild": "prebuildify-platform-packages --target 20.14.0",
|
|
16
|
+
"prebuild-win32": "prebuildify-platform-packages --target 20.14.0 && set ENABLE_V8_FUNCTIONS=false&& prebuildify-platform-packages --platform-packages --napi --target 20.14.0",
|
|
17
|
+
"prebuild-libc": "prebuildify-platform-packages --tag-libc --target 20.14.0 && prebuildify-platform-packages --platform-packages --napi --tag-libc --target 22.2.0 && ENABLE_V8_FUNCTIONS=false prebuildify-platform-packages --platform-packages --napi --tag-libc --target 20.14.0",
|
|
18
|
+
"prebuild-libc-napi": "ENABLE_V8_FUNCTIONS=false prebuildify-platform-packages --platform-packages --napi --tag-libc --target 20.14.0",
|
|
19
|
+
"prebuild-libc-alpine": "prebuildify-cross --image alpine --tag-libc --target 20.14.0",
|
|
20
|
+
"publish-all": "cd prebuilds/win32-x64 && npm publish --access public && cd ../darwin-x64 && npm publish --access public && cd ../darwin-arm64 && npm publish --access public && cd ../linux-x64 && npm publish --access public && cd ../linux-arm64 && npm publish --access public && cd ../linux-arm && npm publish --access public && cd ../.. && npm publish --access public",
|
|
21
|
+
"test": "node ./index.js"
|
|
22
|
+
},
|
|
23
|
+
"main": "./index.js",
|
|
24
|
+
"gypfile": true,
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"node-gyp-build-optional-packages": "5.2.2"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"index.js",
|
|
30
|
+
"/src",
|
|
31
|
+
"/*.gyp",
|
|
32
|
+
"/bin"
|
|
33
|
+
],
|
|
34
|
+
"bin": {
|
|
35
|
+
"download-msgpackr-prebuilds": "./bin/download-prebuilds.js"
|
|
36
|
+
},
|
|
37
|
+
"optionalDependencies": {
|
|
38
|
+
"@msgpackr-extract/msgpackr-extract-darwin-arm64": "3.0.3",
|
|
39
|
+
"@msgpackr-extract/msgpackr-extract-darwin-x64": "3.0.3",
|
|
40
|
+
"@msgpackr-extract/msgpackr-extract-linux-arm": "3.0.3",
|
|
41
|
+
"@msgpackr-extract/msgpackr-extract-linux-arm64": "3.0.3",
|
|
42
|
+
"@msgpackr-extract/msgpackr-extract-linux-x64": "3.0.3",
|
|
43
|
+
"@msgpackr-extract/msgpackr-extract-win32-x64": "3.0.3"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"prebuildify-platform-packages": "5.0.4",
|
|
47
|
+
"prebuildify-ci": "^1.0.5",
|
|
48
|
+
"prebuildify-cross": "5.0.0"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This is responsible for extracting the strings, in bulk, from a MessagePack buffer. Creating strings from buffers can
|
|
3
|
+
be one of the biggest performance bottlenecks of parsing, but creating an array of extracting strings all at once
|
|
4
|
+
provides much better performance. This will parse and produce up to 256 strings at once .The JS parser can call this multiple
|
|
5
|
+
times as necessary to get more strings. This must be partially capable of parsing MessagePack so it can know where to
|
|
6
|
+
find the string tokens and determine their position and length. All strings are decoded as UTF-8.
|
|
7
|
+
*/
|
|
8
|
+
#include <node_api.h>
|
|
9
|
+
#if ENABLE_V8_API
|
|
10
|
+
#include <v8.h>
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
#ifndef thread_local
|
|
14
|
+
#ifdef __GNUC__
|
|
15
|
+
# define thread_local __thread
|
|
16
|
+
#elif __STDC_VERSION__ >= 201112L
|
|
17
|
+
# define thread_local _Thread_local
|
|
18
|
+
#elif defined(_MSC_VER)
|
|
19
|
+
# define thread_local __declspec(thread)
|
|
20
|
+
#else
|
|
21
|
+
# define thread_local
|
|
22
|
+
#endif
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
const int MAX_TARGET_SIZE = 255;
|
|
26
|
+
const uint32_t UNEXPECTED_END = 0xffffffff;
|
|
27
|
+
typedef uint32_t (*token_handler)(uint8_t* source, uint32_t position, uint32_t size);
|
|
28
|
+
token_handler tokenTable[256] = {};
|
|
29
|
+
napi_value unexpectedEnd(napi_env env) {
|
|
30
|
+
napi_value returnValue;
|
|
31
|
+
napi_get_undefined(env, &returnValue);
|
|
32
|
+
napi_throw_type_error(env, NULL, "Unexpected end of buffer reading string");
|
|
33
|
+
return returnValue;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
class Extractor {
|
|
37
|
+
public:
|
|
38
|
+
// napi_ref targetArray; // could consider reenabling this optimization for napi
|
|
39
|
+
bool hasTargetArray = false;
|
|
40
|
+
uint8_t* source;
|
|
41
|
+
uint32_t position = 0;
|
|
42
|
+
uint32_t writePosition = 0;
|
|
43
|
+
uint32_t stringStart = 0;
|
|
44
|
+
uint32_t lastStringEnd = 0;
|
|
45
|
+
|
|
46
|
+
void readString(napi_env env, uint32_t length, bool allowStringBlocks, napi_value* target) {
|
|
47
|
+
uint32_t start = position;
|
|
48
|
+
uint32_t end = position + length;
|
|
49
|
+
if (allowStringBlocks) { // for larger strings, we don't bother to check every character for being latin, and just go right to creating a new string
|
|
50
|
+
while(position < end) {
|
|
51
|
+
if (source[position] < 0x80) // ensure we character is latin and can be decoded as one byte
|
|
52
|
+
position++;
|
|
53
|
+
else {
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (position < end) {
|
|
59
|
+
// non-latin character
|
|
60
|
+
if (lastStringEnd) {
|
|
61
|
+
napi_value value;
|
|
62
|
+
napi_create_string_latin1(env, (const char*) source + stringStart, lastStringEnd - stringStart, &value);
|
|
63
|
+
target[writePosition++] = value;
|
|
64
|
+
lastStringEnd = 0;
|
|
65
|
+
}
|
|
66
|
+
// use standard utf-8 conversion
|
|
67
|
+
napi_value value;
|
|
68
|
+
napi_create_string_utf8(env, (const char*) source + start, (int) length, &value);
|
|
69
|
+
target[writePosition++] = value;
|
|
70
|
+
position = end;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (lastStringEnd) {
|
|
75
|
+
if (start - lastStringEnd > 40 || end - stringStart > 6000) {
|
|
76
|
+
napi_value value;
|
|
77
|
+
napi_create_string_latin1(env, (const char*) source + stringStart, lastStringEnd - stringStart, &value);
|
|
78
|
+
target[writePosition++] = value;
|
|
79
|
+
stringStart = start;
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
stringStart = start;
|
|
83
|
+
}
|
|
84
|
+
lastStringEnd = end;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
napi_value extractStrings(napi_env env, uint32_t startingPosition, uint32_t size, uint8_t* inputSource) {
|
|
88
|
+
napi_value target[MAX_TARGET_SIZE + 1]; // leave one for the queued string
|
|
89
|
+
writePosition = 0;
|
|
90
|
+
lastStringEnd = 0;
|
|
91
|
+
position = startingPosition;
|
|
92
|
+
source = inputSource;
|
|
93
|
+
while (position < size) {
|
|
94
|
+
uint8_t token = source[position++];
|
|
95
|
+
if (token < 0xa0) {
|
|
96
|
+
// all one byte tokens
|
|
97
|
+
} else if (token < 0xc0) {
|
|
98
|
+
// fixstr, we want to convert this
|
|
99
|
+
token -= 0xa0;
|
|
100
|
+
if (token + position > size) {
|
|
101
|
+
return unexpectedEnd(env);
|
|
102
|
+
}
|
|
103
|
+
readString(env, token, true, target);
|
|
104
|
+
if (writePosition >= MAX_TARGET_SIZE)
|
|
105
|
+
break;
|
|
106
|
+
} else if (token <= 0xdb && token >= 0xd9) {
|
|
107
|
+
if (token == 0xd9) { //str 8
|
|
108
|
+
if (position >= size) {
|
|
109
|
+
return unexpectedEnd(env);
|
|
110
|
+
}
|
|
111
|
+
uint32_t length = source[position++];
|
|
112
|
+
if (length + position > size) {
|
|
113
|
+
return unexpectedEnd(env);
|
|
114
|
+
}
|
|
115
|
+
readString(env,length, true, target);
|
|
116
|
+
} else if (token == 0xda) { //str 16
|
|
117
|
+
if (2 + position > size) {
|
|
118
|
+
return unexpectedEnd(env);
|
|
119
|
+
}
|
|
120
|
+
uint32_t length = source[position++] << 8;
|
|
121
|
+
length += source[position++];
|
|
122
|
+
if (length + position > size) {
|
|
123
|
+
return unexpectedEnd(env);
|
|
124
|
+
}
|
|
125
|
+
readString(env,length, false, target);
|
|
126
|
+
} else { //str 32
|
|
127
|
+
if (4 + position > size) {
|
|
128
|
+
return unexpectedEnd(env);
|
|
129
|
+
}
|
|
130
|
+
uint32_t length = source[position++] << 24;
|
|
131
|
+
length += source[position++] << 16;
|
|
132
|
+
length += source[position++] << 8;
|
|
133
|
+
length += source[position++];
|
|
134
|
+
if (length + position > size) {
|
|
135
|
+
return unexpectedEnd(env);
|
|
136
|
+
}
|
|
137
|
+
readString(env, length, false, target);
|
|
138
|
+
}
|
|
139
|
+
if (writePosition >= MAX_TARGET_SIZE)
|
|
140
|
+
break;
|
|
141
|
+
} else {
|
|
142
|
+
auto handle = tokenTable[token];
|
|
143
|
+
if ((size_t ) handle < 20) {
|
|
144
|
+
position += (size_t ) handle;
|
|
145
|
+
} else {
|
|
146
|
+
position = tokenTable[token](source, position, size);
|
|
147
|
+
if (position == UNEXPECTED_END) {
|
|
148
|
+
return unexpectedEnd(env);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (lastStringEnd) {
|
|
155
|
+
napi_value value;
|
|
156
|
+
napi_create_string_latin1(env, (const char*) source + stringStart, lastStringEnd - stringStart, &value);
|
|
157
|
+
if (writePosition == 0) {
|
|
158
|
+
return value;
|
|
159
|
+
}
|
|
160
|
+
target[writePosition++] = value;
|
|
161
|
+
} else if (writePosition == 1) {
|
|
162
|
+
return target[0];
|
|
163
|
+
}
|
|
164
|
+
napi_value array;
|
|
165
|
+
#if ENABLE_V8_API
|
|
166
|
+
v8::Local<v8::Array> v8Array = v8::Array::New(v8::Isolate::GetCurrent(), (v8::Local<v8::Value>*) target, writePosition);
|
|
167
|
+
memcpy(&array, &v8Array, sizeof(array));
|
|
168
|
+
#else
|
|
169
|
+
napi_create_array_with_length(env, writePosition, &array);
|
|
170
|
+
for (uint32_t i = 0; i < writePosition; i++) {
|
|
171
|
+
napi_set_element(env, array, i, target[i]);
|
|
172
|
+
}
|
|
173
|
+
#endif
|
|
174
|
+
return array;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
void setupTokenTable() {
|
|
179
|
+
for (int i = 0; i < 256; i++) {
|
|
180
|
+
tokenTable[i] = nullptr;
|
|
181
|
+
}
|
|
182
|
+
// uint8, int8
|
|
183
|
+
tokenTable[0xcc] = tokenTable[0xd0] = (token_handler) 1;
|
|
184
|
+
// uint16, int16, array 16, map 16, fixext 1
|
|
185
|
+
tokenTable[0xcd] = tokenTable[0xd1] = tokenTable[0xdc] = tokenTable[0xde] = tokenTable[0xd4] = (token_handler) 2;
|
|
186
|
+
// fixext 16
|
|
187
|
+
tokenTable[0xd5] = (token_handler) 3;
|
|
188
|
+
// uint32, int32, float32, array 32, map 32
|
|
189
|
+
tokenTable[0xce] = tokenTable[0xd2] = tokenTable[0xca] = tokenTable[0xdd] = tokenTable[0xdf] = (token_handler) 4;
|
|
190
|
+
// fixext 4
|
|
191
|
+
tokenTable[0xd6] = (token_handler) 5;
|
|
192
|
+
// uint64, int64, float64, fixext 8
|
|
193
|
+
tokenTable[0xcf] = tokenTable[0xd3] = tokenTable[0xcb] = (token_handler) 8;
|
|
194
|
+
// fixext 8
|
|
195
|
+
tokenTable[0xd7] = (token_handler) 9;
|
|
196
|
+
// fixext 16
|
|
197
|
+
tokenTable[0xd8] = (token_handler) 17;
|
|
198
|
+
// bin 8
|
|
199
|
+
tokenTable[0xc4] = ([](uint8_t* source, uint32_t position, uint32_t size) -> uint32_t {
|
|
200
|
+
if (position >= size) {
|
|
201
|
+
return UNEXPECTED_END;
|
|
202
|
+
}
|
|
203
|
+
uint32_t length = source[position++];
|
|
204
|
+
return position + length;
|
|
205
|
+
});
|
|
206
|
+
// bin 16
|
|
207
|
+
tokenTable[0xc5] = ([](uint8_t* source, uint32_t position, uint32_t size) -> uint32_t {
|
|
208
|
+
if (position + 2 > size) {
|
|
209
|
+
return UNEXPECTED_END;
|
|
210
|
+
}
|
|
211
|
+
uint32_t length = source[position++] << 8;
|
|
212
|
+
length += source[position++];
|
|
213
|
+
return position + length;
|
|
214
|
+
});
|
|
215
|
+
// bin 32
|
|
216
|
+
tokenTable[0xc6] = ([](uint8_t* source, uint32_t position, uint32_t size) -> uint32_t {
|
|
217
|
+
if (position + 4 > size)
|
|
218
|
+
return UNEXPECTED_END;
|
|
219
|
+
uint32_t length = source[position++] << 24;
|
|
220
|
+
length += source[position++] << 16;
|
|
221
|
+
length += source[position++] << 8;
|
|
222
|
+
length += source[position++];
|
|
223
|
+
return position + length;
|
|
224
|
+
});
|
|
225
|
+
// ext 8
|
|
226
|
+
tokenTable[0xc7] = ([](uint8_t* source, uint32_t position, uint32_t size) -> uint32_t {
|
|
227
|
+
if (position >= size)
|
|
228
|
+
return UNEXPECTED_END;
|
|
229
|
+
uint32_t length = source[position++];
|
|
230
|
+
position++;
|
|
231
|
+
return position + length;
|
|
232
|
+
});
|
|
233
|
+
// ext 16
|
|
234
|
+
tokenTable[0xc8] = ([](uint8_t* source, uint32_t position, uint32_t size) -> uint32_t {
|
|
235
|
+
if (position + 2 > size)
|
|
236
|
+
return UNEXPECTED_END;
|
|
237
|
+
uint32_t length = source[position++] << 8;
|
|
238
|
+
length += source[position++];
|
|
239
|
+
position++;
|
|
240
|
+
return position + length;
|
|
241
|
+
});
|
|
242
|
+
// ext 32
|
|
243
|
+
tokenTable[0xc9] = ([](uint8_t* source, uint32_t position, uint32_t size) -> uint32_t {
|
|
244
|
+
if (position + 4 > size)
|
|
245
|
+
return UNEXPECTED_END;
|
|
246
|
+
uint32_t length = source[position++] << 24;
|
|
247
|
+
length += source[position++] << 16;
|
|
248
|
+
length += source[position++] << 8;
|
|
249
|
+
length += source[position++];
|
|
250
|
+
position++;
|
|
251
|
+
return position + length;
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
static thread_local Extractor* extractor;
|
|
255
|
+
napi_value extractStrings(napi_env env, napi_callback_info info) {
|
|
256
|
+
size_t argc = 3;
|
|
257
|
+
napi_value args[3];
|
|
258
|
+
napi_get_cb_info(env, info, &argc, args, NULL, NULL);
|
|
259
|
+
uint32_t position;
|
|
260
|
+
uint32_t size;
|
|
261
|
+
napi_get_value_uint32(env, args[0], &position);
|
|
262
|
+
napi_get_value_uint32(env, args[1], &size);
|
|
263
|
+
uint8_t* source;
|
|
264
|
+
size_t buffer_size;
|
|
265
|
+
napi_get_arraybuffer_info(env, args[2], (void**) &source, &buffer_size);
|
|
266
|
+
return extractor->extractStrings(env, position, size, source);
|
|
267
|
+
}
|
|
268
|
+
#define EXPORT_NAPI_FUNCTION(name, func) { napi_property_descriptor desc = { name, 0, func, 0, 0, 0, (napi_property_attributes) (napi_writable | napi_configurable), 0 }; napi_define_properties(env, exports, 1, &desc); }
|
|
269
|
+
NAPI_MODULE_INIT() {
|
|
270
|
+
extractor = new Extractor(); // create our thread-local extractor
|
|
271
|
+
setupTokenTable();
|
|
272
|
+
EXPORT_NAPI_FUNCTION("extractStrings", extractStrings);
|
|
273
|
+
return exports;
|
|
274
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Mathias Buus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# node-gyp-build
|
|
2
|
+
|
|
3
|
+
> Build tool and bindings loader for [`node-gyp`][node-gyp] that supports prebuilds.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install node-gyp-build
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
[](https://github.com/prebuild/node-gyp-build/actions/workflows/test.yml)
|
|
10
|
+
|
|
11
|
+
Use together with [`prebuildify`][prebuildify] to easily support prebuilds for your native modules.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
> **Note.** Prebuild names have changed in [`prebuildify@3`][prebuildify] and `node-gyp-build@4`. Please see the documentation below.
|
|
16
|
+
|
|
17
|
+
`node-gyp-build` works similar to [`node-gyp build`][node-gyp] except that it will check if a build or prebuild is present before rebuilding your project.
|
|
18
|
+
|
|
19
|
+
It's main intended use is as an npm install script and bindings loader for native modules that bundle prebuilds using [`prebuildify`][prebuildify].
|
|
20
|
+
|
|
21
|
+
First add `node-gyp-build` as an install script to your native project
|
|
22
|
+
|
|
23
|
+
``` js
|
|
24
|
+
{
|
|
25
|
+
...
|
|
26
|
+
"scripts": {
|
|
27
|
+
"install": "node-gyp-build"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Then in your `index.js`, instead of using the [`bindings`](https://www.npmjs.com/package/bindings) module use `node-gyp-build` to load your binding.
|
|
33
|
+
|
|
34
|
+
``` js
|
|
35
|
+
var binding = require('node-gyp-build')(__dirname)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If you do these two things and bundle prebuilds with [`prebuildify`][prebuildify] your native module will work for most platforms
|
|
39
|
+
without having to compile on install time AND will work in both node and electron without the need to recompile between usage.
|
|
40
|
+
|
|
41
|
+
Users can override `node-gyp-build` and force compiling by doing `npm install --build-from-source`.
|
|
42
|
+
|
|
43
|
+
Prebuilds will be attempted loaded from `MODULE_PATH/prebuilds/...` and then next `EXEC_PATH/prebuilds/...` (the latter allowing use with `zeit/pkg`)
|
|
44
|
+
|
|
45
|
+
## Supported prebuild names
|
|
46
|
+
|
|
47
|
+
If so desired you can bundle more specific flavors, for example `musl` builds to support Alpine, or targeting a numbered ARM architecture version.
|
|
48
|
+
|
|
49
|
+
These prebuilds can be bundled in addition to generic prebuilds; `node-gyp-build` will try to find the most specific flavor first. Prebuild filenames are composed of _tags_. The runtime tag takes precedence, as does an `abi` tag over `napi`. For more details on tags, please see [`prebuildify`][prebuildify].
|
|
50
|
+
|
|
51
|
+
Values for the `libc` and `armv` tags are auto-detected but can be overridden through the `LIBC` and `ARM_VERSION` environment variables, respectively.
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
MIT
|
|
56
|
+
|
|
57
|
+
[prebuildify]: https://github.com/prebuild/prebuildify
|
|
58
|
+
[node-gyp]: https://www.npmjs.com/package/node-gyp
|