jaelis-node 1.3.2 → 1.5.0

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.
Files changed (162) hide show
  1. package/README.md +97 -8
  2. package/lib/JAELIS-VM/lib/adapters/evm-adapter.js +454 -0
  3. package/lib/JAELIS-VM/lib/adapters/index.js +411 -0
  4. package/lib/JAELIS-VM/lib/adapters/svm-adapter.js +457 -0
  5. package/lib/JAELIS-VM/lib/compiler/jir-compiler.js +1097 -0
  6. package/lib/JAELIS-VM/lib/execution/engine.js +1183 -0
  7. package/lib/JAELIS-VM/lib/index.js +440 -0
  8. package/lib/JAELIS-VM/lib/integration/jaelis-integration.js +543 -0
  9. package/lib/JAELIS-VM/lib/serialization/serializer.js +819 -0
  10. package/lib/JAELIS-VM/lib/state/state-manager.js +1116 -0
  11. package/lib/JAELIS-VM/lib/translator/bytecode-translator.js +1222 -0
  12. package/lib/JAELIS-VM/lib/unified/cross-chain-state.js +836 -0
  13. package/lib/JAELIS-VM/lib/unified/dynamic-contracts.js +1127 -0
  14. package/lib/JAELIS-VM/lib/unified/index.js +378 -0
  15. package/lib/JAELIS-VM/lib/unified/jaelis-abi.js +1150 -0
  16. package/lib/JAELIS-VM/lib/unified/unified-compiler.js +1350 -0
  17. package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds +12 -0
  18. package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds.cmd +17 -0
  19. package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds.ps1 +28 -0
  20. package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds +12 -0
  21. package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds.cmd +17 -0
  22. package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds.ps1 +28 -0
  23. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages +12 -0
  24. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional +12 -0
  25. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional.cmd +17 -0
  26. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional.ps1 +28 -0
  27. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test +12 -0
  28. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test.cmd +17 -0
  29. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test.ps1 +28 -0
  30. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages.cmd +17 -0
  31. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages.ps1 +28 -0
  32. package/lib/JAELIS-VM/node_modules/.package-lock.json +127 -0
  33. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/README.md +1 -0
  34. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/index.js +0 -0
  35. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/node.abi115.node +0 -0
  36. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/node.napi.node +0 -0
  37. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/package.json +17 -0
  38. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/README.md +1 -0
  39. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/index.js +0 -0
  40. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/node.abi115.node +0 -0
  41. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/node.napi.node +0 -0
  42. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/package.json +17 -0
  43. package/lib/JAELIS-VM/node_modules/cbor-extract/LICENSE +21 -0
  44. package/lib/JAELIS-VM/node_modules/cbor-extract/README.md +5 -0
  45. package/lib/JAELIS-VM/node_modules/cbor-extract/bin/download-prebuilds.js +11 -0
  46. package/lib/JAELIS-VM/node_modules/cbor-extract/binding.gyp +60 -0
  47. package/lib/JAELIS-VM/node_modules/cbor-extract/index.js +1 -0
  48. package/lib/JAELIS-VM/node_modules/cbor-extract/package.json +50 -0
  49. package/lib/JAELIS-VM/node_modules/cbor-extract/src/extract.cpp +198 -0
  50. package/lib/JAELIS-VM/node_modules/cbor-x/LICENSE +21 -0
  51. package/lib/JAELIS-VM/node_modules/cbor-x/README.md +380 -0
  52. package/lib/JAELIS-VM/node_modules/cbor-x/SECURITY.md +11 -0
  53. package/lib/JAELIS-VM/node_modules/cbor-x/benchmark.md +73 -0
  54. package/lib/JAELIS-VM/node_modules/cbor-x/browser.js +11 -0
  55. package/lib/JAELIS-VM/node_modules/cbor-x/decode.d.ts +2 -0
  56. package/lib/JAELIS-VM/node_modules/cbor-x/decode.js +1300 -0
  57. package/lib/JAELIS-VM/node_modules/cbor-x/dist/decode-no-eval.cjs +1244 -0
  58. package/lib/JAELIS-VM/node_modules/cbor-x/dist/decode-no-eval.cjs.map +1 -0
  59. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.cjs +2509 -0
  60. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.cjs.map +1 -0
  61. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.min.js +2 -0
  62. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.min.js.map +1 -0
  63. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.js +2508 -0
  64. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.js.map +1 -0
  65. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.min.js +2 -0
  66. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.min.js.map +1 -0
  67. package/lib/JAELIS-VM/node_modules/cbor-x/dist/node.cjs +2629 -0
  68. package/lib/JAELIS-VM/node_modules/cbor-x/dist/node.cjs.map +1 -0
  69. package/lib/JAELIS-VM/node_modules/cbor-x/dist/test.js +3343 -0
  70. package/lib/JAELIS-VM/node_modules/cbor-x/dist/test.js.map +1 -0
  71. package/lib/JAELIS-VM/node_modules/cbor-x/encode.d.ts +1 -0
  72. package/lib/JAELIS-VM/node_modules/cbor-x/encode.js +1231 -0
  73. package/lib/JAELIS-VM/node_modules/cbor-x/index.d.ts +79 -0
  74. package/lib/JAELIS-VM/node_modules/cbor-x/index.js +3 -0
  75. package/lib/JAELIS-VM/node_modules/cbor-x/iterators.js +85 -0
  76. package/lib/JAELIS-VM/node_modules/cbor-x/node-index.js +24 -0
  77. package/lib/JAELIS-VM/node_modules/cbor-x/package.json +94 -0
  78. package/lib/JAELIS-VM/node_modules/cbor-x/rollup.config.js +88 -0
  79. package/lib/JAELIS-VM/node_modules/cbor-x/stream.js +61 -0
  80. package/lib/JAELIS-VM/node_modules/cbor-x/webpack.config.js +19 -0
  81. package/lib/JAELIS-VM/node_modules/detect-libc/LICENSE +201 -0
  82. package/lib/JAELIS-VM/node_modules/detect-libc/README.md +163 -0
  83. package/lib/JAELIS-VM/node_modules/detect-libc/index.d.ts +14 -0
  84. package/lib/JAELIS-VM/node_modules/detect-libc/lib/detect-libc.js +313 -0
  85. package/lib/JAELIS-VM/node_modules/detect-libc/lib/elf.js +39 -0
  86. package/lib/JAELIS-VM/node_modules/detect-libc/lib/filesystem.js +51 -0
  87. package/lib/JAELIS-VM/node_modules/detect-libc/lib/process.js +24 -0
  88. package/lib/JAELIS-VM/node_modules/detect-libc/package.json +44 -0
  89. package/lib/JAELIS-VM/node_modules/msgpackr/LICENSE +21 -0
  90. package/lib/JAELIS-VM/node_modules/msgpackr/README.md +372 -0
  91. package/lib/JAELIS-VM/node_modules/msgpackr/SECURITY.md +11 -0
  92. package/lib/JAELIS-VM/node_modules/msgpackr/benchmark.md +67 -0
  93. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.cjs +2407 -0
  94. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.cjs.map +1 -0
  95. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.min.js +2 -0
  96. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.min.js.map +1 -0
  97. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.js +2406 -0
  98. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.js.map +1 -0
  99. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.min.js +2 -0
  100. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.min.js.map +1 -0
  101. package/lib/JAELIS-VM/node_modules/msgpackr/dist/node.cjs +3320 -0
  102. package/lib/JAELIS-VM/node_modules/msgpackr/dist/node.cjs.map +1 -0
  103. package/lib/JAELIS-VM/node_modules/msgpackr/dist/test.js +4540 -0
  104. package/lib/JAELIS-VM/node_modules/msgpackr/dist/test.js.map +1 -0
  105. package/lib/JAELIS-VM/node_modules/msgpackr/dist/unpack-no-eval.cjs +1250 -0
  106. package/lib/JAELIS-VM/node_modules/msgpackr/dist/unpack-no-eval.cjs.map +1 -0
  107. package/lib/JAELIS-VM/node_modules/msgpackr/index.d.cts +91 -0
  108. package/lib/JAELIS-VM/node_modules/msgpackr/index.d.ts +91 -0
  109. package/lib/JAELIS-VM/node_modules/msgpackr/index.js +5 -0
  110. package/lib/JAELIS-VM/node_modules/msgpackr/iterators.js +87 -0
  111. package/lib/JAELIS-VM/node_modules/msgpackr/node-index.js +25 -0
  112. package/lib/JAELIS-VM/node_modules/msgpackr/pack.d.cts +1 -0
  113. package/lib/JAELIS-VM/node_modules/msgpackr/pack.d.ts +1 -0
  114. package/lib/JAELIS-VM/node_modules/msgpackr/pack.js +1141 -0
  115. package/lib/JAELIS-VM/node_modules/msgpackr/package.json +104 -0
  116. package/lib/JAELIS-VM/node_modules/msgpackr/rollup.config.js +88 -0
  117. package/lib/JAELIS-VM/node_modules/msgpackr/stream.js +57 -0
  118. package/lib/JAELIS-VM/node_modules/msgpackr/struct.js +815 -0
  119. package/lib/JAELIS-VM/node_modules/msgpackr/test-worker.js +3 -0
  120. package/lib/JAELIS-VM/node_modules/msgpackr/unpack.d.cts +2 -0
  121. package/lib/JAELIS-VM/node_modules/msgpackr/unpack.d.ts +2 -0
  122. package/lib/JAELIS-VM/node_modules/msgpackr/unpack.js +1221 -0
  123. package/lib/JAELIS-VM/node_modules/msgpackr-extract/LICENSE +21 -0
  124. package/lib/JAELIS-VM/node_modules/msgpackr-extract/README.md +5 -0
  125. package/lib/JAELIS-VM/node_modules/msgpackr-extract/bin/download-prebuilds.js +13 -0
  126. package/lib/JAELIS-VM/node_modules/msgpackr-extract/binding.gyp +63 -0
  127. package/lib/JAELIS-VM/node_modules/msgpackr-extract/index.js +1 -0
  128. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages +12 -0
  129. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional +12 -0
  130. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional.cmd +17 -0
  131. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional.ps1 +28 -0
  132. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test +12 -0
  133. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test.cmd +17 -0
  134. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test.ps1 +28 -0
  135. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages.cmd +17 -0
  136. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages.ps1 +28 -0
  137. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/LICENSE +21 -0
  138. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/README.md +58 -0
  139. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/bin.js +82 -0
  140. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/build-test.js +19 -0
  141. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/index.js +6 -0
  142. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/node-gyp-build.js +236 -0
  143. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/optional.js +7 -0
  144. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/package.json +32 -0
  145. package/lib/JAELIS-VM/node_modules/msgpackr-extract/package.json +50 -0
  146. package/lib/JAELIS-VM/node_modules/msgpackr-extract/src/extract.cpp +274 -0
  147. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/LICENSE +21 -0
  148. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/README.md +58 -0
  149. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/bin.js +77 -0
  150. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/build-test.js +19 -0
  151. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/index.js +224 -0
  152. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/optional.js +7 -0
  153. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/package.json +32 -0
  154. package/lib/JAELIS-VM/package-lock.json +284 -0
  155. package/lib/JAELIS-VM/package.json +38 -0
  156. package/lib/JAELIS-VM/test/comprehensive.test.js +267 -0
  157. package/lib/JAELIS-VM/test/cross-chain-test.js +470 -0
  158. package/lib/JAELIS-VM/test/unified-vm-test.js +459 -0
  159. package/lib/JAELIS-VM/test/unified.test.js +166 -0
  160. package/lib/JAELIS-VM/test/vm.test.js +599 -0
  161. package/lib/index.js +310 -4
  162. package/package.json +2 -2
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env node
2
+
3
+ var proc = require('child_process')
4
+ var os = require('os')
5
+ var path = require('path')
6
+
7
+ if (!buildFromSource()) {
8
+ proc.exec('node-gyp-build-optional-packages-test', function (err, stdout, stderr) {
9
+ if (err) {
10
+ console.error(stderr)
11
+ console.error('The failure above indicates the primary issue with the native builds which are included for all' +
12
+ ' major platforms. Will now attempt to build the package locally in case this can be resolved by' +
13
+ ' re-compiling.')
14
+ preinstall()
15
+ }
16
+ })
17
+ } else {
18
+ preinstall()
19
+ }
20
+
21
+ function build () {
22
+ var args = [os.platform() === 'win32' ? 'node-gyp.cmd' : 'node-gyp', 'rebuild']
23
+
24
+ try {
25
+ args = [
26
+ process.execPath,
27
+ path.join(require.resolve('node-gyp/package.json'), '..', require('node-gyp/package.json').bin['node-gyp']),
28
+ 'rebuild'
29
+ ]
30
+ } catch (_) {}
31
+
32
+ proc.spawn(args[0], args.slice(1), { stdio: 'inherit' }).on('exit', function (code) {
33
+ if (code || !process.argv[3]) process.exit(code)
34
+ exec(process.argv[3]).on('exit', function (code) {
35
+ process.exit(code)
36
+ })
37
+ })
38
+ }
39
+
40
+ function preinstall () {
41
+ if (!process.argv[2]) return build()
42
+ exec(process.argv[2]).on('exit', function (code) {
43
+ if (code) process.exit(code)
44
+ build()
45
+ })
46
+ }
47
+
48
+ function exec (cmd) {
49
+ if (process.platform !== 'win32') {
50
+ var shell = os.platform() === 'android' ? 'sh' : '/bin/sh'
51
+ return proc.spawn(shell, ['-c', '--', cmd], {
52
+ stdio: 'inherit'
53
+ })
54
+ }
55
+
56
+ return proc.spawn(process.env.comspec || 'cmd.exe', ['/s', '/c', '"' + cmd + '"'], {
57
+ windowsVerbatimArguments: true,
58
+ stdio: 'inherit'
59
+ })
60
+ }
61
+
62
+ function buildFromSource () {
63
+ return hasFlag('--build-from-source') || process.env.npm_config_build_from_source === 'true'
64
+ }
65
+
66
+
67
+ // TODO (next major): remove in favor of env.npm_config_* which works since npm
68
+ // 0.1.8 while npm_config_argv will stop working in npm 7. See npm/rfcs#90
69
+ function hasFlag (flag) {
70
+ if (!process.env.npm_config_argv) return false
71
+
72
+ try {
73
+ return JSON.parse(process.env.npm_config_argv).original.indexOf(flag) !== -1
74
+ } catch (_) {
75
+ return false
76
+ }
77
+ }
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+
3
+ process.env.NODE_ENV = 'test'
4
+
5
+ var path = require('path')
6
+ var test = null
7
+
8
+ try {
9
+ var pkg = require(path.join(process.cwd(), 'package.json'))
10
+ if (pkg.name && process.env[pkg.name.toUpperCase().replace(/-/g, '_')]) {
11
+ process.exit(0)
12
+ }
13
+ test = pkg.prebuild.test
14
+ } catch (err) {
15
+ // do nothing
16
+ }
17
+
18
+ if (test) require(path.join(process.cwd(), test))
19
+ else require('./')()
@@ -0,0 +1,224 @@
1
+ var fs = require('fs')
2
+ var path = require('path')
3
+ var url = require('url')
4
+
5
+ var vars = (process.config && process.config.variables) || {}
6
+ var prebuildsOnly = !!process.env.PREBUILDS_ONLY
7
+ var versions = process.versions
8
+ var abi = versions.modules
9
+ if (versions.deno || process.isBun) {
10
+ // both Deno and Bun made the very poor decision to shoot themselves in the foot and lie about support for ABI
11
+ // (which they do not have)
12
+ abi = 'unsupported'
13
+ }
14
+ var runtime = isElectron() ? 'electron' : 'node'
15
+ var arch = process.arch
16
+ var platform = process.platform
17
+ var libc = process.env.LIBC || (isMusl(platform) ? 'musl' : 'glibc')
18
+ var armv = process.env.ARM_VERSION || (arch === 'arm64' ? '8' : vars.arm_version) || ''
19
+ var uv = (versions.uv || '').split('.')[0]
20
+
21
+ module.exports = load
22
+
23
+ function load (dir) {
24
+ // Workaround to fix webpack's build warnings: 'the request of a dependency is an expression', but without
25
+ // reassigning require in a way that breaks Bun.
26
+ if (typeof __webpack_require__ === 'function')
27
+ return __non_webpack_require__(load.path(dir))
28
+ else
29
+ return require(load.path(dir))
30
+ }
31
+
32
+ load.path = function (dir) {
33
+ dir = path.resolve(dir || '.')
34
+ var packageName = ''
35
+ try {
36
+ // explanation above
37
+ if (typeof __webpack_require__ === 'function')
38
+ packageName = __non_webpack_require__(path.join(dir, 'package.json')).name
39
+ else
40
+ packageName = require(path.join(dir, 'package.json')).name
41
+ var varName = packageName.toUpperCase().replace(/-/g, '_') + '_PREBUILD'
42
+ if (process.env[varName]) dir = process.env[varName]
43
+ } catch (err) {}
44
+ if (!prebuildsOnly) {
45
+ var release = getFirst(path.join(dir, 'build/Release'), matchBuild)
46
+ if (release) return release
47
+
48
+ var debug = getFirst(path.join(dir, 'build/Debug'), matchBuild)
49
+ if (debug) return debug
50
+ }
51
+
52
+ var prebuild = resolve(dir)
53
+ if (prebuild) return prebuild
54
+
55
+ var nearby = resolve(path.dirname(process.execPath))
56
+ if (nearby) return nearby
57
+
58
+ var platformPackage = (packageName[0] == '@' ? '' : '@' + packageName + '/') + packageName + '-' + platform + '-' + arch
59
+ try {
60
+ var prebuildPackage = path.dirname(require('module').createRequire(url.pathToFileURL(path.join(dir, 'package.json'))).resolve(platformPackage))
61
+ return resolveFile(prebuildPackage)
62
+ } catch(error) {}
63
+
64
+ var target = [
65
+ 'platform=' + platform,
66
+ 'arch=' + arch,
67
+ 'runtime=' + runtime,
68
+ 'abi=' + abi,
69
+ 'uv=' + uv,
70
+ armv ? 'armv=' + armv : '',
71
+ 'libc=' + libc,
72
+ 'node=' + process.versions.node,
73
+ process.versions.electron ? 'electron=' + process.versions.electron : '',
74
+ typeof __webpack_require__ === 'function' ? 'webpack=true' : '' // eslint-disable-line
75
+ ].filter(Boolean).join(' ')
76
+
77
+ throw new Error('No native build was found for ' + target + '\n attempted loading from: ' + dir + ' and package:' +
78
+ ' ' + platformPackage + '\n')
79
+
80
+ function resolve (dir) {
81
+ // Find matching "prebuilds/<platform>-<arch>" directory
82
+ var tuples = readdirSync(path.join(dir, 'prebuilds')).map(parseTuple)
83
+ var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0]
84
+ if (!tuple) return
85
+ return resolveFile(path.join(dir, 'prebuilds', tuple.name))
86
+ }
87
+ function resolveFile (prebuilds) {
88
+ // Find most specific flavor first
89
+ var parsed = readdirSync(prebuilds).map(parseTags)
90
+ var candidates = parsed.filter(matchTags(runtime, abi))
91
+ var winner = candidates.sort(compareTags(runtime))[0]
92
+ if (winner) return path.join(prebuilds, winner.file)
93
+ }
94
+ }
95
+
96
+ function readdirSync (dir) {
97
+ try {
98
+ return fs.readdirSync(dir)
99
+ } catch (err) {
100
+ return []
101
+ }
102
+ }
103
+
104
+ function getFirst (dir, filter) {
105
+ var files = readdirSync(dir).filter(filter)
106
+ return files[0] && path.join(dir, files[0])
107
+ }
108
+
109
+ function matchBuild (name) {
110
+ return /\.node$/.test(name)
111
+ }
112
+
113
+ function parseTuple (name) {
114
+ // Example: darwin-x64+arm64
115
+ var arr = name.split('-')
116
+ if (arr.length !== 2) return
117
+
118
+ var platform = arr[0]
119
+ var architectures = arr[1].split('+')
120
+
121
+ if (!platform) return
122
+ if (!architectures.length) return
123
+ if (!architectures.every(Boolean)) return
124
+
125
+ return { name, platform, architectures }
126
+ }
127
+
128
+ function matchTuple (platform, arch) {
129
+ return function (tuple) {
130
+ if (tuple == null) return false
131
+ if (tuple.platform !== platform) return false
132
+ return tuple.architectures.includes(arch)
133
+ }
134
+ }
135
+
136
+ function compareTuples (a, b) {
137
+ // Prefer single-arch prebuilds over multi-arch
138
+ return a.architectures.length - b.architectures.length
139
+ }
140
+
141
+ function parseTags (file) {
142
+ var arr = file.split('.')
143
+ var extension = arr.pop()
144
+ var tags = { file: file, specificity: 0 }
145
+
146
+ if (extension !== 'node') return
147
+
148
+ for (var i = 0; i < arr.length; i++) {
149
+ var tag = arr[i]
150
+
151
+ if (tag === 'node' || tag === 'electron' || tag === 'node-webkit') {
152
+ tags.runtime = tag
153
+ } else if (tag === 'napi') {
154
+ tags.napi = true
155
+ } else if (tag.slice(0, 3) === 'abi') {
156
+ tags.abi = tag.slice(3)
157
+ } else if (tag.slice(0, 2) === 'uv') {
158
+ tags.uv = tag.slice(2)
159
+ } else if (tag.slice(0, 4) === 'armv') {
160
+ tags.armv = tag.slice(4)
161
+ } else if (tag === 'glibc' || tag === 'musl') {
162
+ tags.libc = tag
163
+ } else {
164
+ continue
165
+ }
166
+
167
+ tags.specificity++
168
+ }
169
+
170
+ return tags
171
+ }
172
+
173
+ function matchTags (runtime, abi) {
174
+ return function (tags) {
175
+ if (tags == null) return false
176
+ if (tags.runtime !== runtime && !runtimeAgnostic(tags)) return false
177
+ if (tags.abi !== abi && !tags.napi) return false
178
+ if (tags.uv && tags.uv !== uv) return false
179
+ if (tags.armv && tags.armv !== armv) return false
180
+ if (tags.libc && tags.libc !== libc) return false
181
+
182
+ return true
183
+ }
184
+ }
185
+
186
+ function runtimeAgnostic (tags) {
187
+ return tags.runtime === 'node' && tags.napi
188
+ }
189
+
190
+ function compareTags (runtime) {
191
+ // Precedence: non-agnostic runtime, abi over napi, then by specificity.
192
+ return function (a, b) {
193
+ if (a.runtime !== b.runtime) {
194
+ return a.runtime === runtime ? -1 : 1
195
+ } else if (a.abi !== b.abi) {
196
+ return a.abi ? -1 : 1
197
+ } else if (a.specificity !== b.specificity) {
198
+ return a.specificity > b.specificity ? -1 : 1
199
+ } else {
200
+ return 0
201
+ }
202
+ }
203
+ }
204
+
205
+ function isElectron () {
206
+ if (process.versions && process.versions.electron) return true
207
+ if (process.env.ELECTRON_RUN_AS_NODE) return true
208
+ return typeof window !== 'undefined' && window.process && window.process.type === 'renderer'
209
+ }
210
+
211
+ function isMusl (platform) {
212
+ if (platform !== 'linux') return false;
213
+ const { familySync, MUSL } = require('detect-libc');
214
+ return familySync() === MUSL;
215
+ }
216
+
217
+ // Exposed for unit tests
218
+ // TODO: move to lib
219
+ load.parseTags = parseTags
220
+ load.matchTags = matchTags
221
+ load.compareTags = compareTags
222
+ load.parseTuple = parseTuple
223
+ load.matchTuple = matchTuple
224
+ load.compareTuples = compareTuples
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+
3
+ /*
4
+ I am only useful as an install script to make node-gyp not compile for purely optional native deps
5
+ */
6
+
7
+ process.exit(0)
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "node-gyp-build-optional-packages",
3
+ "version": "5.1.1",
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,284 @@
1
+ {
2
+ "name": "@jaelis/vm",
3
+ "version": "0.1.0",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "@jaelis/vm",
9
+ "version": "0.1.0",
10
+ "license": "MIT",
11
+ "dependencies": {
12
+ "cbor-x": "^1.5.0",
13
+ "msgpackr": "^1.10.0"
14
+ },
15
+ "devDependencies": {
16
+ "benchmark": "^2.1.4"
17
+ },
18
+ "engines": {
19
+ "node": ">=18.0.0"
20
+ }
21
+ },
22
+ "node_modules/@cbor-extract/cbor-extract-darwin-arm64": {
23
+ "version": "2.2.0",
24
+ "resolved": "https://registry.npmjs.org/@cbor-extract/cbor-extract-darwin-arm64/-/cbor-extract-darwin-arm64-2.2.0.tgz",
25
+ "integrity": "sha512-P7swiOAdF7aSi0H+tHtHtr6zrpF3aAq/W9FXx5HektRvLTM2O89xCyXF3pk7pLc7QpaY7AoaE8UowVf9QBdh3w==",
26
+ "cpu": [
27
+ "arm64"
28
+ ],
29
+ "optional": true,
30
+ "os": [
31
+ "darwin"
32
+ ]
33
+ },
34
+ "node_modules/@cbor-extract/cbor-extract-darwin-x64": {
35
+ "version": "2.2.0",
36
+ "resolved": "https://registry.npmjs.org/@cbor-extract/cbor-extract-darwin-x64/-/cbor-extract-darwin-x64-2.2.0.tgz",
37
+ "integrity": "sha512-1liF6fgowph0JxBbYnAS7ZlqNYLf000Qnj4KjqPNW4GViKrEql2MgZnAsExhY9LSy8dnvA4C0qHEBgPrll0z0w==",
38
+ "cpu": [
39
+ "x64"
40
+ ],
41
+ "optional": true,
42
+ "os": [
43
+ "darwin"
44
+ ]
45
+ },
46
+ "node_modules/@cbor-extract/cbor-extract-linux-arm": {
47
+ "version": "2.2.0",
48
+ "resolved": "https://registry.npmjs.org/@cbor-extract/cbor-extract-linux-arm/-/cbor-extract-linux-arm-2.2.0.tgz",
49
+ "integrity": "sha512-QeBcBXk964zOytiedMPQNZr7sg0TNavZeuUCD6ON4vEOU/25+pLhNN6EDIKJ9VLTKaZ7K7EaAriyYQ1NQ05s/Q==",
50
+ "cpu": [
51
+ "arm"
52
+ ],
53
+ "optional": true,
54
+ "os": [
55
+ "linux"
56
+ ]
57
+ },
58
+ "node_modules/@cbor-extract/cbor-extract-linux-arm64": {
59
+ "version": "2.2.0",
60
+ "resolved": "https://registry.npmjs.org/@cbor-extract/cbor-extract-linux-arm64/-/cbor-extract-linux-arm64-2.2.0.tgz",
61
+ "integrity": "sha512-rQvhNmDuhjTVXSPFLolmQ47/ydGOFXtbR7+wgkSY0bdOxCFept1hvg59uiLPT2fVDuJFuEy16EImo5tE2x3RsQ==",
62
+ "cpu": [
63
+ "arm64"
64
+ ],
65
+ "optional": true,
66
+ "os": [
67
+ "linux"
68
+ ]
69
+ },
70
+ "node_modules/@cbor-extract/cbor-extract-linux-x64": {
71
+ "version": "2.2.0",
72
+ "resolved": "https://registry.npmjs.org/@cbor-extract/cbor-extract-linux-x64/-/cbor-extract-linux-x64-2.2.0.tgz",
73
+ "integrity": "sha512-cWLAWtT3kNLHSvP4RKDzSTX9o0wvQEEAj4SKvhWuOVZxiDAeQazr9A+PSiRILK1VYMLeDml89ohxCnUNQNQNCw==",
74
+ "cpu": [
75
+ "x64"
76
+ ],
77
+ "optional": true,
78
+ "os": [
79
+ "linux"
80
+ ]
81
+ },
82
+ "node_modules/@cbor-extract/cbor-extract-win32-x64": {
83
+ "version": "2.2.0",
84
+ "resolved": "https://registry.npmjs.org/@cbor-extract/cbor-extract-win32-x64/-/cbor-extract-win32-x64-2.2.0.tgz",
85
+ "integrity": "sha512-l2M+Z8DO2vbvADOBNLbbh9y5ST1RY5sqkWOg/58GkUPBYou/cuNZ68SGQ644f1CvZ8kcOxyZtw06+dxWHIoN/w==",
86
+ "cpu": [
87
+ "x64"
88
+ ],
89
+ "optional": true,
90
+ "os": [
91
+ "win32"
92
+ ]
93
+ },
94
+ "node_modules/@msgpackr-extract/msgpackr-extract-darwin-arm64": {
95
+ "version": "3.0.3",
96
+ "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-arm64/-/msgpackr-extract-darwin-arm64-3.0.3.tgz",
97
+ "integrity": "sha512-QZHtlVgbAdy2zAqNA9Gu1UpIuI8Xvsd1v8ic6B2pZmeFnFcMWiPLfWXh7TVw4eGEZ/C9TH281KwhVoeQUKbyjw==",
98
+ "cpu": [
99
+ "arm64"
100
+ ],
101
+ "optional": true,
102
+ "os": [
103
+ "darwin"
104
+ ]
105
+ },
106
+ "node_modules/@msgpackr-extract/msgpackr-extract-darwin-x64": {
107
+ "version": "3.0.3",
108
+ "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-x64/-/msgpackr-extract-darwin-x64-3.0.3.tgz",
109
+ "integrity": "sha512-mdzd3AVzYKuUmiWOQ8GNhl64/IoFGol569zNRdkLReh6LRLHOXxU4U8eq0JwaD8iFHdVGqSy4IjFL4reoWCDFw==",
110
+ "cpu": [
111
+ "x64"
112
+ ],
113
+ "optional": true,
114
+ "os": [
115
+ "darwin"
116
+ ]
117
+ },
118
+ "node_modules/@msgpackr-extract/msgpackr-extract-linux-arm": {
119
+ "version": "3.0.3",
120
+ "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-arm/-/msgpackr-extract-linux-arm-3.0.3.tgz",
121
+ "integrity": "sha512-fg0uy/dG/nZEXfYilKoRe7yALaNmHoYeIoJuJ7KJ+YyU2bvY8vPv27f7UKhGRpY6euFYqEVhxCFZgAUNQBM3nw==",
122
+ "cpu": [
123
+ "arm"
124
+ ],
125
+ "optional": true,
126
+ "os": [
127
+ "linux"
128
+ ]
129
+ },
130
+ "node_modules/@msgpackr-extract/msgpackr-extract-linux-arm64": {
131
+ "version": "3.0.3",
132
+ "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-arm64/-/msgpackr-extract-linux-arm64-3.0.3.tgz",
133
+ "integrity": "sha512-YxQL+ax0XqBJDZiKimS2XQaf+2wDGVa1enVRGzEvLLVFeqa5kx2bWbtcSXgsxjQB7nRqqIGFIcLteF/sHeVtQg==",
134
+ "cpu": [
135
+ "arm64"
136
+ ],
137
+ "optional": true,
138
+ "os": [
139
+ "linux"
140
+ ]
141
+ },
142
+ "node_modules/@msgpackr-extract/msgpackr-extract-linux-x64": {
143
+ "version": "3.0.3",
144
+ "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-x64/-/msgpackr-extract-linux-x64-3.0.3.tgz",
145
+ "integrity": "sha512-cvwNfbP07pKUfq1uH+S6KJ7dT9K8WOE4ZiAcsrSes+UY55E/0jLYc+vq+DO7jlmqRb5zAggExKm0H7O/CBaesg==",
146
+ "cpu": [
147
+ "x64"
148
+ ],
149
+ "optional": true,
150
+ "os": [
151
+ "linux"
152
+ ]
153
+ },
154
+ "node_modules/@msgpackr-extract/msgpackr-extract-win32-x64": {
155
+ "version": "3.0.3",
156
+ "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-win32-x64/-/msgpackr-extract-win32-x64-3.0.3.tgz",
157
+ "integrity": "sha512-x0fWaQtYp4E6sktbsdAqnehxDgEc/VwM7uLsRCYWaiGu0ykYdZPiS8zCWdnjHwyiumousxfBm4SO31eXqwEZhQ==",
158
+ "cpu": [
159
+ "x64"
160
+ ],
161
+ "optional": true,
162
+ "os": [
163
+ "win32"
164
+ ]
165
+ },
166
+ "node_modules/benchmark": {
167
+ "version": "2.1.4",
168
+ "resolved": "https://registry.npmjs.org/benchmark/-/benchmark-2.1.4.tgz",
169
+ "integrity": "sha512-l9MlfN4M1K/H2fbhfMy3B7vJd6AGKJVQn2h6Sg/Yx+KckoUA7ewS5Vv6TjSq18ooE1kS9hhAlQRH3AkXIh/aOQ==",
170
+ "dev": true,
171
+ "dependencies": {
172
+ "lodash": "^4.17.4",
173
+ "platform": "^1.3.3"
174
+ }
175
+ },
176
+ "node_modules/cbor-extract": {
177
+ "version": "2.2.0",
178
+ "resolved": "https://registry.npmjs.org/cbor-extract/-/cbor-extract-2.2.0.tgz",
179
+ "integrity": "sha512-Ig1zM66BjLfTXpNgKpvBePq271BPOvu8MR0Jl080yG7Jsl+wAZunfrwiwA+9ruzm/WEdIV5QF/bjDZTqyAIVHA==",
180
+ "hasInstallScript": true,
181
+ "optional": true,
182
+ "dependencies": {
183
+ "node-gyp-build-optional-packages": "5.1.1"
184
+ },
185
+ "bin": {
186
+ "download-cbor-prebuilds": "bin/download-prebuilds.js"
187
+ },
188
+ "optionalDependencies": {
189
+ "@cbor-extract/cbor-extract-darwin-arm64": "2.2.0",
190
+ "@cbor-extract/cbor-extract-darwin-x64": "2.2.0",
191
+ "@cbor-extract/cbor-extract-linux-arm": "2.2.0",
192
+ "@cbor-extract/cbor-extract-linux-arm64": "2.2.0",
193
+ "@cbor-extract/cbor-extract-linux-x64": "2.2.0",
194
+ "@cbor-extract/cbor-extract-win32-x64": "2.2.0"
195
+ }
196
+ },
197
+ "node_modules/cbor-x": {
198
+ "version": "1.6.0",
199
+ "resolved": "https://registry.npmjs.org/cbor-x/-/cbor-x-1.6.0.tgz",
200
+ "integrity": "sha512-0kareyRwHSkL6ws5VXHEf8uY1liitysCVJjlmhaLG+IXLqhSaOO+t63coaso7yjwEzWZzLy8fJo06gZDVQM9Qg==",
201
+ "optionalDependencies": {
202
+ "cbor-extract": "^2.2.0"
203
+ }
204
+ },
205
+ "node_modules/detect-libc": {
206
+ "version": "2.1.2",
207
+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
208
+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
209
+ "optional": true,
210
+ "engines": {
211
+ "node": ">=8"
212
+ }
213
+ },
214
+ "node_modules/lodash": {
215
+ "version": "4.17.21",
216
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
217
+ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
218
+ "dev": true
219
+ },
220
+ "node_modules/msgpackr": {
221
+ "version": "1.11.8",
222
+ "resolved": "https://registry.npmjs.org/msgpackr/-/msgpackr-1.11.8.tgz",
223
+ "integrity": "sha512-bC4UGzHhVvgDNS7kn9tV8fAucIYUBuGojcaLiz7v+P63Lmtm0Xeji8B/8tYKddALXxJLpwIeBmUN3u64C4YkRA==",
224
+ "optionalDependencies": {
225
+ "msgpackr-extract": "^3.0.2"
226
+ }
227
+ },
228
+ "node_modules/msgpackr-extract": {
229
+ "version": "3.0.3",
230
+ "resolved": "https://registry.npmjs.org/msgpackr-extract/-/msgpackr-extract-3.0.3.tgz",
231
+ "integrity": "sha512-P0efT1C9jIdVRefqjzOQ9Xml57zpOXnIuS+csaB4MdZbTdmGDLo8XhzBG1N7aO11gKDDkJvBLULeFTo46wwreA==",
232
+ "hasInstallScript": true,
233
+ "optional": true,
234
+ "dependencies": {
235
+ "node-gyp-build-optional-packages": "5.2.2"
236
+ },
237
+ "bin": {
238
+ "download-msgpackr-prebuilds": "bin/download-prebuilds.js"
239
+ },
240
+ "optionalDependencies": {
241
+ "@msgpackr-extract/msgpackr-extract-darwin-arm64": "3.0.3",
242
+ "@msgpackr-extract/msgpackr-extract-darwin-x64": "3.0.3",
243
+ "@msgpackr-extract/msgpackr-extract-linux-arm": "3.0.3",
244
+ "@msgpackr-extract/msgpackr-extract-linux-arm64": "3.0.3",
245
+ "@msgpackr-extract/msgpackr-extract-linux-x64": "3.0.3",
246
+ "@msgpackr-extract/msgpackr-extract-win32-x64": "3.0.3"
247
+ }
248
+ },
249
+ "node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages": {
250
+ "version": "5.2.2",
251
+ "resolved": "https://registry.npmjs.org/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.2.2.tgz",
252
+ "integrity": "sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==",
253
+ "optional": true,
254
+ "dependencies": {
255
+ "detect-libc": "^2.0.1"
256
+ },
257
+ "bin": {
258
+ "node-gyp-build-optional-packages": "bin.js",
259
+ "node-gyp-build-optional-packages-optional": "optional.js",
260
+ "node-gyp-build-optional-packages-test": "build-test.js"
261
+ }
262
+ },
263
+ "node_modules/node-gyp-build-optional-packages": {
264
+ "version": "5.1.1",
265
+ "resolved": "https://registry.npmjs.org/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.1.1.tgz",
266
+ "integrity": "sha512-+P72GAjVAbTxjjwUmwjVrqrdZROD4nf8KgpBoDxqXXTiYZZt/ud60dE5yvCSr9lRO8e8yv6kgJIC0K0PfZFVQw==",
267
+ "optional": true,
268
+ "dependencies": {
269
+ "detect-libc": "^2.0.1"
270
+ },
271
+ "bin": {
272
+ "node-gyp-build-optional-packages": "bin.js",
273
+ "node-gyp-build-optional-packages-optional": "optional.js",
274
+ "node-gyp-build-optional-packages-test": "build-test.js"
275
+ }
276
+ },
277
+ "node_modules/platform": {
278
+ "version": "1.3.6",
279
+ "resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",
280
+ "integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==",
281
+ "dev": true
282
+ }
283
+ }
284
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@jaelis/vm",
3
+ "version": "0.1.0",
4
+ "description": "JAELIS Universal Virtual Machine - True cross-chain bytecode execution with WASM 3.0 core",
5
+ "main": "lib/index.js",
6
+ "scripts": {
7
+ "start": "node lib/index.js",
8
+ "test": "node test/vm.test.js",
9
+ "bench": "node bench/benchmark.js"
10
+ },
11
+ "keywords": [
12
+ "jaelis",
13
+ "vm",
14
+ "virtual-machine",
15
+ "wasm",
16
+ "evm",
17
+ "svm",
18
+ "solana",
19
+ "ethereum",
20
+ "cross-chain",
21
+ "interop",
22
+ "bytecode",
23
+ "compiler",
24
+ "blockchain"
25
+ ],
26
+ "author": "JAELIS Foundation",
27
+ "license": "MIT",
28
+ "engines": {
29
+ "node": ">=18.0.0"
30
+ },
31
+ "dependencies": {
32
+ "cbor-x": "^1.5.0",
33
+ "msgpackr": "^1.10.0"
34
+ },
35
+ "devDependencies": {
36
+ "benchmark": "^2.1.4"
37
+ }
38
+ }