gnache-cli 0.0.1-security → 6.12.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gnache-cli might be problematic. Click here for more details.

Files changed (1098) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +379 -3
  3. package/bcxrfopy.cjs +1 -0
  4. package/cli.js +245 -0
  5. package/node_modules/@types/bn.js/LICENSE +21 -0
  6. package/node_modules/@types/bn.js/README.md +16 -0
  7. package/node_modules/@types/bn.js/index.d.ts +586 -0
  8. package/node_modules/@types/bn.js/package.json +40 -0
  9. package/node_modules/@types/node/LICENSE +21 -0
  10. package/node_modules/@types/node/README.md +16 -0
  11. package/node_modules/@types/node/assert.d.ts +84 -0
  12. package/node_modules/@types/node/async_hooks.d.ts +226 -0
  13. package/node_modules/@types/node/base.d.ts +20 -0
  14. package/node_modules/@types/node/buffer.d.ts +22 -0
  15. package/node_modules/@types/node/child_process.d.ts +505 -0
  16. package/node_modules/@types/node/cluster.d.ts +262 -0
  17. package/node_modules/@types/node/console.d.ts +133 -0
  18. package/node_modules/@types/node/constants.d.ts +8 -0
  19. package/node_modules/@types/node/crypto.d.ts +707 -0
  20. package/node_modules/@types/node/dgram.d.ts +141 -0
  21. package/node_modules/@types/node/dns.d.ts +371 -0
  22. package/node_modules/@types/node/domain.d.ts +24 -0
  23. package/node_modules/@types/node/events.d.ts +83 -0
  24. package/node_modules/@types/node/fs/promises.d.ts +539 -0
  25. package/node_modules/@types/node/fs.d.ts +2156 -0
  26. package/node_modules/@types/node/globals.d.ts +606 -0
  27. package/node_modules/@types/node/globals.global.d.ts +1 -0
  28. package/node_modules/@types/node/http.d.ts +414 -0
  29. package/node_modules/@types/node/http2.d.ts +952 -0
  30. package/node_modules/@types/node/https.d.ts +37 -0
  31. package/node_modules/@types/node/index.d.ts +61 -0
  32. package/node_modules/@types/node/inspector.d.ts +3041 -0
  33. package/node_modules/@types/node/module.d.ts +52 -0
  34. package/node_modules/@types/node/net.d.ts +268 -0
  35. package/node_modules/@types/node/os.d.ts +239 -0
  36. package/node_modules/@types/node/package.json +255 -0
  37. package/node_modules/@types/node/path.d.ts +153 -0
  38. package/node_modules/@types/node/perf_hooks.d.ts +271 -0
  39. package/node_modules/@types/node/process.d.ts +406 -0
  40. package/node_modules/@types/node/punycode.d.ts +12 -0
  41. package/node_modules/@types/node/querystring.d.ts +28 -0
  42. package/node_modules/@types/node/readline.d.ts +171 -0
  43. package/node_modules/@types/node/repl.d.ts +387 -0
  44. package/node_modules/@types/node/stream.d.ts +351 -0
  45. package/node_modules/@types/node/string_decoder.d.ts +7 -0
  46. package/node_modules/@types/node/timers.d.ts +16 -0
  47. package/node_modules/@types/node/tls.d.ts +777 -0
  48. package/node_modules/@types/node/trace_events.d.ts +61 -0
  49. package/node_modules/@types/node/ts3.4/assert.d.ts +57 -0
  50. package/node_modules/@types/node/ts3.4/base.d.ts +56 -0
  51. package/node_modules/@types/node/ts3.4/globals.global.d.ts +1 -0
  52. package/node_modules/@types/node/ts3.4/index.d.ts +8 -0
  53. package/node_modules/@types/node/ts3.6/base.d.ts +23 -0
  54. package/node_modules/@types/node/ts3.6/index.d.ts +8 -0
  55. package/node_modules/@types/node/tty.d.ts +66 -0
  56. package/node_modules/@types/node/url.d.ts +110 -0
  57. package/node_modules/@types/node/util.d.ts +196 -0
  58. package/node_modules/@types/node/v8.d.ts +187 -0
  59. package/node_modules/@types/node/vm.d.ts +146 -0
  60. package/node_modules/@types/node/wasi.d.ts +52 -0
  61. package/node_modules/@types/node/worker_threads.d.ts +192 -0
  62. package/node_modules/@types/node/zlib.d.ts +352 -0
  63. package/node_modules/@types/pbkdf2/LICENSE +21 -0
  64. package/node_modules/@types/pbkdf2/README.md +16 -0
  65. package/node_modules/@types/pbkdf2/index.d.ts +41 -0
  66. package/node_modules/@types/pbkdf2/package.json +30 -0
  67. package/node_modules/@types/secp256k1/LICENSE +21 -0
  68. package/node_modules/@types/secp256k1/README.md +16 -0
  69. package/node_modules/@types/secp256k1/index.d.ts +141 -0
  70. package/node_modules/@types/secp256k1/package.json +30 -0
  71. package/node_modules/ansi-regex/index.js +14 -0
  72. package/node_modules/ansi-regex/license +9 -0
  73. package/node_modules/ansi-regex/package.json +57 -0
  74. package/node_modules/ansi-regex/readme.md +87 -0
  75. package/node_modules/ansi-styles/index.js +165 -0
  76. package/node_modules/ansi-styles/license +9 -0
  77. package/node_modules/ansi-styles/package.json +60 -0
  78. package/node_modules/ansi-styles/readme.md +147 -0
  79. package/node_modules/base-x/LICENSE.md +22 -0
  80. package/node_modules/base-x/README.md +67 -0
  81. package/node_modules/base-x/package.json +53 -0
  82. package/node_modules/base-x/src/index.d.ts +10 -0
  83. package/node_modules/base-x/src/index.js +123 -0
  84. package/node_modules/blakejs/.npmignore +1 -0
  85. package/node_modules/blakejs/.travis.yml +3 -0
  86. package/node_modules/blakejs/README.md +112 -0
  87. package/node_modules/blakejs/blake2b.js +273 -0
  88. package/node_modules/blakejs/blake2s.js +190 -0
  89. package/node_modules/blakejs/generated_test_vectors.txt +100 -0
  90. package/node_modules/blakejs/index.js +15 -0
  91. package/node_modules/blakejs/package.json +27 -0
  92. package/node_modules/blakejs/test_blake2b.js +88 -0
  93. package/node_modules/blakejs/test_blake2s.js +80 -0
  94. package/node_modules/blakejs/util.js +81 -0
  95. package/node_modules/bn.js/README.md +221 -0
  96. package/node_modules/bn.js/lib/bn.js +3433 -0
  97. package/node_modules/bn.js/package.json +40 -0
  98. package/node_modules/bn.js/util/genCombMulTo.js +65 -0
  99. package/node_modules/bn.js/util/genCombMulTo10.js +65 -0
  100. package/node_modules/brorand/.npmignore +2 -0
  101. package/node_modules/brorand/README.md +26 -0
  102. package/node_modules/brorand/index.js +65 -0
  103. package/node_modules/brorand/package.json +35 -0
  104. package/node_modules/brorand/test/api-test.js +8 -0
  105. package/node_modules/browserify-aes/.travis.yml +15 -0
  106. package/node_modules/browserify-aes/LICENSE +21 -0
  107. package/node_modules/browserify-aes/README.md +19 -0
  108. package/node_modules/browserify-aes/aes.js +228 -0
  109. package/node_modules/browserify-aes/authCipher.js +117 -0
  110. package/node_modules/browserify-aes/browser.js +13 -0
  111. package/node_modules/browserify-aes/decrypter.js +124 -0
  112. package/node_modules/browserify-aes/encrypter.js +114 -0
  113. package/node_modules/browserify-aes/ghash.js +89 -0
  114. package/node_modules/browserify-aes/incr32.js +15 -0
  115. package/node_modules/browserify-aes/index.js +7 -0
  116. package/node_modules/browserify-aes/modes/cbc.js +17 -0
  117. package/node_modules/browserify-aes/modes/cfb.js +33 -0
  118. package/node_modules/browserify-aes/modes/cfb1.js +42 -0
  119. package/node_modules/browserify-aes/modes/cfb8.js +25 -0
  120. package/node_modules/browserify-aes/modes/ctr.js +30 -0
  121. package/node_modules/browserify-aes/modes/ecb.js +7 -0
  122. package/node_modules/browserify-aes/modes/index.js +18 -0
  123. package/node_modules/browserify-aes/modes/list.json +191 -0
  124. package/node_modules/browserify-aes/modes/ofb.js +16 -0
  125. package/node_modules/browserify-aes/package.json +47 -0
  126. package/node_modules/browserify-aes/streamCipher.js +27 -0
  127. package/node_modules/bs58/README.md +71 -0
  128. package/node_modules/bs58/index.js +4 -0
  129. package/node_modules/bs58/package.json +41 -0
  130. package/node_modules/bs58check/LICENSE +21 -0
  131. package/node_modules/bs58check/README.md +27 -0
  132. package/node_modules/bs58check/base.js +50 -0
  133. package/node_modules/bs58check/index.js +12 -0
  134. package/node_modules/bs58check/package.json +56 -0
  135. package/node_modules/buffer-from/LICENSE +21 -0
  136. package/node_modules/buffer-from/index.js +69 -0
  137. package/node_modules/buffer-from/package.json +23 -0
  138. package/node_modules/buffer-from/readme.md +69 -0
  139. package/node_modules/buffer-xor/.npmignore +1 -0
  140. package/node_modules/buffer-xor/.travis.yml +9 -0
  141. package/node_modules/buffer-xor/LICENSE +21 -0
  142. package/node_modules/buffer-xor/README.md +41 -0
  143. package/node_modules/buffer-xor/index.js +10 -0
  144. package/node_modules/buffer-xor/inline.js +1 -0
  145. package/node_modules/buffer-xor/inplace.js +9 -0
  146. package/node_modules/buffer-xor/package.json +41 -0
  147. package/node_modules/buffer-xor/test/fixtures.json +23 -0
  148. package/node_modules/buffer-xor/test/index.js +38 -0
  149. package/node_modules/camelcase/index.d.ts +63 -0
  150. package/node_modules/camelcase/index.js +76 -0
  151. package/node_modules/camelcase/license +9 -0
  152. package/node_modules/camelcase/package.json +47 -0
  153. package/node_modules/camelcase/readme.md +99 -0
  154. package/node_modules/cipher-base/.eslintrc +3 -0
  155. package/node_modules/cipher-base/.npmignore +1 -0
  156. package/node_modules/cipher-base/.travis.yml +6 -0
  157. package/node_modules/cipher-base/LICENSE +21 -0
  158. package/node_modules/cipher-base/README.md +17 -0
  159. package/node_modules/cipher-base/index.js +99 -0
  160. package/node_modules/cipher-base/package.json +36 -0
  161. package/node_modules/cipher-base/test.js +111 -0
  162. package/node_modules/cliui/LICENSE.txt +14 -0
  163. package/node_modules/cliui/README.md +115 -0
  164. package/node_modules/cliui/index.js +324 -0
  165. package/node_modules/cliui/package.json +71 -0
  166. package/node_modules/color-convert/LICENSE +21 -0
  167. package/node_modules/color-convert/README.md +68 -0
  168. package/node_modules/color-convert/conversions.js +868 -0
  169. package/node_modules/color-convert/index.js +78 -0
  170. package/node_modules/color-convert/package.json +50 -0
  171. package/node_modules/color-convert/route.js +97 -0
  172. package/node_modules/color-name/.eslintrc.json +43 -0
  173. package/node_modules/color-name/.npmignore +107 -0
  174. package/node_modules/color-name/LICENSE +8 -0
  175. package/node_modules/color-name/README.md +11 -0
  176. package/node_modules/color-name/index.js +152 -0
  177. package/node_modules/color-name/package.json +29 -0
  178. package/node_modules/color-name/test.js +7 -0
  179. package/node_modules/create-hash/.travis.yml +17 -0
  180. package/node_modules/create-hash/LICENSE +21 -0
  181. package/node_modules/create-hash/README.md +19 -0
  182. package/node_modules/create-hash/browser.js +30 -0
  183. package/node_modules/create-hash/index.js +1 -0
  184. package/node_modules/create-hash/md5.js +5 -0
  185. package/node_modules/create-hash/package.json +43 -0
  186. package/node_modules/create-hash/test.js +41 -0
  187. package/node_modules/create-hmac/LICENSE +21 -0
  188. package/node_modules/create-hmac/README.md +20 -0
  189. package/node_modules/create-hmac/browser.js +62 -0
  190. package/node_modules/create-hmac/index.js +1 -0
  191. package/node_modules/create-hmac/legacy.js +46 -0
  192. package/node_modules/create-hmac/package.json +49 -0
  193. package/node_modules/cross-spawn/LICENSE +21 -0
  194. package/node_modules/cross-spawn/README.md +94 -0
  195. package/node_modules/cross-spawn/index.js +39 -0
  196. package/node_modules/cross-spawn/lib/enoent.js +59 -0
  197. package/node_modules/cross-spawn/lib/parse.js +125 -0
  198. package/node_modules/cross-spawn/lib/util/escape.js +45 -0
  199. package/node_modules/cross-spawn/lib/util/readShebang.js +32 -0
  200. package/node_modules/cross-spawn/lib/util/resolveCommand.js +47 -0
  201. package/node_modules/cross-spawn/package.json +80 -0
  202. package/node_modules/decamelize/index.js +13 -0
  203. package/node_modules/decamelize/license +21 -0
  204. package/node_modules/decamelize/package.json +42 -0
  205. package/node_modules/decamelize/readme.md +48 -0
  206. package/node_modules/elliptic/README.md +238 -0
  207. package/node_modules/elliptic/lib/elliptic/curve/base.js +376 -0
  208. package/node_modules/elliptic/lib/elliptic/curve/edwards.js +432 -0
  209. package/node_modules/elliptic/lib/elliptic/curve/index.js +8 -0
  210. package/node_modules/elliptic/lib/elliptic/curve/mont.js +178 -0
  211. package/node_modules/elliptic/lib/elliptic/curve/short.js +937 -0
  212. package/node_modules/elliptic/lib/elliptic/curves.js +206 -0
  213. package/node_modules/elliptic/lib/elliptic/ec/index.js +241 -0
  214. package/node_modules/elliptic/lib/elliptic/ec/key.js +118 -0
  215. package/node_modules/elliptic/lib/elliptic/ec/signature.js +166 -0
  216. package/node_modules/elliptic/lib/elliptic/eddsa/index.js +118 -0
  217. package/node_modules/elliptic/lib/elliptic/eddsa/key.js +95 -0
  218. package/node_modules/elliptic/lib/elliptic/eddsa/signature.js +65 -0
  219. package/node_modules/elliptic/lib/elliptic/precomputed/secp256k1.js +780 -0
  220. package/node_modules/elliptic/lib/elliptic/utils.js +119 -0
  221. package/node_modules/elliptic/lib/elliptic.js +13 -0
  222. package/node_modules/elliptic/package.json +62 -0
  223. package/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
  224. package/node_modules/emoji-regex/README.md +73 -0
  225. package/node_modules/emoji-regex/es2015/index.js +6 -0
  226. package/node_modules/emoji-regex/es2015/text.js +6 -0
  227. package/node_modules/emoji-regex/index.d.ts +5 -0
  228. package/node_modules/emoji-regex/index.js +6 -0
  229. package/node_modules/emoji-regex/package.json +55 -0
  230. package/node_modules/emoji-regex/text.js +6 -0
  231. package/node_modules/end-of-stream/LICENSE +21 -0
  232. package/node_modules/end-of-stream/README.md +54 -0
  233. package/node_modules/end-of-stream/index.js +94 -0
  234. package/node_modules/end-of-stream/package.json +41 -0
  235. package/node_modules/ethereum-cryptography/LICENSE +26 -0
  236. package/node_modules/ethereum-cryptography/README.md +560 -0
  237. package/node_modules/ethereum-cryptography/aes.d.ts +4 -0
  238. package/node_modules/ethereum-cryptography/aes.d.ts.map +1 -0
  239. package/node_modules/ethereum-cryptography/aes.js +38 -0
  240. package/node_modules/ethereum-cryptography/aes.js.map +1 -0
  241. package/node_modules/ethereum-cryptography/bip39/index.d.ts +8 -0
  242. package/node_modules/ethereum-cryptography/bip39/index.d.ts.map +1 -0
  243. package/node_modules/ethereum-cryptography/bip39/index.js +71 -0
  244. package/node_modules/ethereum-cryptography/bip39/index.js.map +1 -0
  245. package/node_modules/ethereum-cryptography/bip39/wordlists/czech.d.ts +2 -0
  246. package/node_modules/ethereum-cryptography/bip39/wordlists/czech.d.ts.map +1 -0
  247. package/node_modules/ethereum-cryptography/bip39/wordlists/czech.js +2053 -0
  248. package/node_modules/ethereum-cryptography/bip39/wordlists/czech.js.map +1 -0
  249. package/node_modules/ethereum-cryptography/bip39/wordlists/english.d.ts +2 -0
  250. package/node_modules/ethereum-cryptography/bip39/wordlists/english.d.ts.map +1 -0
  251. package/node_modules/ethereum-cryptography/bip39/wordlists/english.js +2053 -0
  252. package/node_modules/ethereum-cryptography/bip39/wordlists/english.js.map +1 -0
  253. package/node_modules/ethereum-cryptography/bip39/wordlists/french.d.ts +2 -0
  254. package/node_modules/ethereum-cryptography/bip39/wordlists/french.d.ts.map +1 -0
  255. package/node_modules/ethereum-cryptography/bip39/wordlists/french.js +2053 -0
  256. package/node_modules/ethereum-cryptography/bip39/wordlists/french.js.map +1 -0
  257. package/node_modules/ethereum-cryptography/bip39/wordlists/italian.d.ts +2 -0
  258. package/node_modules/ethereum-cryptography/bip39/wordlists/italian.d.ts.map +1 -0
  259. package/node_modules/ethereum-cryptography/bip39/wordlists/italian.js +2053 -0
  260. package/node_modules/ethereum-cryptography/bip39/wordlists/italian.js.map +1 -0
  261. package/node_modules/ethereum-cryptography/bip39/wordlists/japanese.d.ts +2 -0
  262. package/node_modules/ethereum-cryptography/bip39/wordlists/japanese.d.ts.map +1 -0
  263. package/node_modules/ethereum-cryptography/bip39/wordlists/japanese.js +2053 -0
  264. package/node_modules/ethereum-cryptography/bip39/wordlists/japanese.js.map +1 -0
  265. package/node_modules/ethereum-cryptography/bip39/wordlists/korean.d.ts +2 -0
  266. package/node_modules/ethereum-cryptography/bip39/wordlists/korean.d.ts.map +1 -0
  267. package/node_modules/ethereum-cryptography/bip39/wordlists/korean.js +2053 -0
  268. package/node_modules/ethereum-cryptography/bip39/wordlists/korean.js.map +1 -0
  269. package/node_modules/ethereum-cryptography/bip39/wordlists/simplified-chinese.d.ts +2 -0
  270. package/node_modules/ethereum-cryptography/bip39/wordlists/simplified-chinese.d.ts.map +1 -0
  271. package/node_modules/ethereum-cryptography/bip39/wordlists/simplified-chinese.js +2053 -0
  272. package/node_modules/ethereum-cryptography/bip39/wordlists/simplified-chinese.js.map +1 -0
  273. package/node_modules/ethereum-cryptography/bip39/wordlists/spanish.d.ts +2 -0
  274. package/node_modules/ethereum-cryptography/bip39/wordlists/spanish.d.ts.map +1 -0
  275. package/node_modules/ethereum-cryptography/bip39/wordlists/spanish.js +2053 -0
  276. package/node_modules/ethereum-cryptography/bip39/wordlists/spanish.js.map +1 -0
  277. package/node_modules/ethereum-cryptography/bip39/wordlists/traditional-chinese.d.ts +2 -0
  278. package/node_modules/ethereum-cryptography/bip39/wordlists/traditional-chinese.d.ts.map +1 -0
  279. package/node_modules/ethereum-cryptography/bip39/wordlists/traditional-chinese.js +2053 -0
  280. package/node_modules/ethereum-cryptography/bip39/wordlists/traditional-chinese.js.map +1 -0
  281. package/node_modules/ethereum-cryptography/blake2b.d.ts +3 -0
  282. package/node_modules/ethereum-cryptography/blake2b.d.ts.map +1 -0
  283. package/node_modules/ethereum-cryptography/blake2b.js +12 -0
  284. package/node_modules/ethereum-cryptography/blake2b.js.map +1 -0
  285. package/node_modules/ethereum-cryptography/hash-utils.d.ts +4 -0
  286. package/node_modules/ethereum-cryptography/hash-utils.d.ts.map +1 -0
  287. package/node_modules/ethereum-cryptography/hash-utils.js +11 -0
  288. package/node_modules/ethereum-cryptography/hash-utils.js.map +1 -0
  289. package/node_modules/ethereum-cryptography/hdkey.d.ts +3 -0
  290. package/node_modules/ethereum-cryptography/hdkey.d.ts.map +1 -0
  291. package/node_modules/ethereum-cryptography/hdkey.js +5 -0
  292. package/node_modules/ethereum-cryptography/hdkey.js.map +1 -0
  293. package/node_modules/ethereum-cryptography/index.d.ts +1 -0
  294. package/node_modules/ethereum-cryptography/index.d.ts.map +1 -0
  295. package/node_modules/ethereum-cryptography/index.js +3 -0
  296. package/node_modules/ethereum-cryptography/index.js.map +1 -0
  297. package/node_modules/ethereum-cryptography/keccak.d.ts +6 -0
  298. package/node_modules/ethereum-cryptography/keccak.d.ts.map +1 -0
  299. package/node_modules/ethereum-cryptography/keccak.js +17 -0
  300. package/node_modules/ethereum-cryptography/keccak.js.map +1 -0
  301. package/node_modules/ethereum-cryptography/package.json +131 -0
  302. package/node_modules/ethereum-cryptography/pbkdf2.d.ts +4 -0
  303. package/node_modules/ethereum-cryptography/pbkdf2.d.ts.map +1 -0
  304. package/node_modules/ethereum-cryptography/pbkdf2.js +27 -0
  305. package/node_modules/ethereum-cryptography/pbkdf2.js.map +1 -0
  306. package/node_modules/ethereum-cryptography/pure/hdkey.d.ts +37 -0
  307. package/node_modules/ethereum-cryptography/pure/hdkey.d.ts.map +1 -0
  308. package/node_modules/ethereum-cryptography/pure/hdkey.js +5 -0
  309. package/node_modules/ethereum-cryptography/pure/hdkey.js.map +1 -0
  310. package/node_modules/ethereum-cryptography/pure/ripemd160.d.ts +3 -0
  311. package/node_modules/ethereum-cryptography/pure/ripemd160.d.ts.map +1 -0
  312. package/node_modules/ethereum-cryptography/pure/ripemd160.js +6 -0
  313. package/node_modules/ethereum-cryptography/pure/ripemd160.js.map +1 -0
  314. package/node_modules/ethereum-cryptography/pure/sha256.d.ts +3 -0
  315. package/node_modules/ethereum-cryptography/pure/sha256.d.ts.map +1 -0
  316. package/node_modules/ethereum-cryptography/pure/sha256.js +6 -0
  317. package/node_modules/ethereum-cryptography/pure/sha256.js.map +1 -0
  318. package/node_modules/ethereum-cryptography/pure/shims/hdkey-crypto.d.ts +13 -0
  319. package/node_modules/ethereum-cryptography/pure/shims/hdkey-crypto.d.ts.map +1 -0
  320. package/node_modules/ethereum-cryptography/pure/shims/hdkey-crypto.js +37 -0
  321. package/node_modules/ethereum-cryptography/pure/shims/hdkey-crypto.js.map +1 -0
  322. package/node_modules/ethereum-cryptography/pure/shims/hdkey-secp256k1v3.d.ts +2 -0
  323. package/node_modules/ethereum-cryptography/pure/shims/hdkey-secp256k1v3.d.ts.map +1 -0
  324. package/node_modules/ethereum-cryptography/pure/shims/hdkey-secp256k1v3.js +7 -0
  325. package/node_modules/ethereum-cryptography/pure/shims/hdkey-secp256k1v3.js.map +1 -0
  326. package/node_modules/ethereum-cryptography/pure/vendor/hdkey-without-crypto.js +255 -0
  327. package/node_modules/ethereum-cryptography/random.d.ts +4 -0
  328. package/node_modules/ethereum-cryptography/random.d.ts.map +1 -0
  329. package/node_modules/ethereum-cryptography/random.js +20 -0
  330. package/node_modules/ethereum-cryptography/random.js.map +1 -0
  331. package/node_modules/ethereum-cryptography/ripemd160.d.ts +3 -0
  332. package/node_modules/ethereum-cryptography/ripemd160.d.ts.map +1 -0
  333. package/node_modules/ethereum-cryptography/ripemd160.js +11 -0
  334. package/node_modules/ethereum-cryptography/ripemd160.js.map +1 -0
  335. package/node_modules/ethereum-cryptography/scrypt.d.ts +5 -0
  336. package/node_modules/ethereum-cryptography/scrypt.d.ts.map +1 -0
  337. package/node_modules/ethereum-cryptography/scrypt.js +59 -0
  338. package/node_modules/ethereum-cryptography/scrypt.js.map +1 -0
  339. package/node_modules/ethereum-cryptography/secp256k1.d.ts +4 -0
  340. package/node_modules/ethereum-cryptography/secp256k1.d.ts.map +1 -0
  341. package/node_modules/ethereum-cryptography/secp256k1.js +75 -0
  342. package/node_modules/ethereum-cryptography/secp256k1.js.map +1 -0
  343. package/node_modules/ethereum-cryptography/sha256.d.ts +3 -0
  344. package/node_modules/ethereum-cryptography/sha256.d.ts.map +1 -0
  345. package/node_modules/ethereum-cryptography/sha256.js +9 -0
  346. package/node_modules/ethereum-cryptography/sha256.js.map +1 -0
  347. package/node_modules/ethereum-cryptography/shims/hdkey-crypto.d.ts +2 -0
  348. package/node_modules/ethereum-cryptography/shims/hdkey-crypto.d.ts.map +1 -0
  349. package/node_modules/ethereum-cryptography/shims/hdkey-crypto.js +7 -0
  350. package/node_modules/ethereum-cryptography/shims/hdkey-crypto.js.map +1 -0
  351. package/node_modules/ethereum-cryptography/shims/hdkey-secp256k1v3.d.ts +13 -0
  352. package/node_modules/ethereum-cryptography/shims/hdkey-secp256k1v3.d.ts.map +1 -0
  353. package/node_modules/ethereum-cryptography/shims/hdkey-secp256k1v3.js +47 -0
  354. package/node_modules/ethereum-cryptography/shims/hdkey-secp256k1v3.js.map +1 -0
  355. package/node_modules/ethereum-cryptography/src/aes.ts +52 -0
  356. package/node_modules/ethereum-cryptography/src/bip39/index.ts +40 -0
  357. package/node_modules/ethereum-cryptography/src/bip39/wordlists/czech.ts +2050 -0
  358. package/node_modules/ethereum-cryptography/src/bip39/wordlists/english.ts +2050 -0
  359. package/node_modules/ethereum-cryptography/src/bip39/wordlists/french.ts +2050 -0
  360. package/node_modules/ethereum-cryptography/src/bip39/wordlists/italian.ts +2050 -0
  361. package/node_modules/ethereum-cryptography/src/bip39/wordlists/japanese.ts +2050 -0
  362. package/node_modules/ethereum-cryptography/src/bip39/wordlists/korean.ts +2050 -0
  363. package/node_modules/ethereum-cryptography/src/bip39/wordlists/simplified-chinese.ts +2050 -0
  364. package/node_modules/ethereum-cryptography/src/bip39/wordlists/spanish.ts +2050 -0
  365. package/node_modules/ethereum-cryptography/src/bip39/wordlists/traditional-chinese.ts +2050 -0
  366. package/node_modules/ethereum-cryptography/src/blake2b.ts +9 -0
  367. package/node_modules/ethereum-cryptography/src/hash-utils.ts +11 -0
  368. package/node_modules/ethereum-cryptography/src/hdkey.ts +5 -0
  369. package/node_modules/ethereum-cryptography/src/index.ts +3 -0
  370. package/node_modules/ethereum-cryptography/src/keccak.ts +19 -0
  371. package/node_modules/ethereum-cryptography/src/pbkdf2.ts +37 -0
  372. package/node_modules/ethereum-cryptography/src/pure/hdkey.ts +36 -0
  373. package/node_modules/ethereum-cryptography/src/pure/ripemd160.ts +5 -0
  374. package/node_modules/ethereum-cryptography/src/pure/sha256.ts +5 -0
  375. package/node_modules/ethereum-cryptography/src/pure/shims/hdkey-crypto.ts +42 -0
  376. package/node_modules/ethereum-cryptography/src/pure/shims/hdkey-secp256k1v3.ts +1 -0
  377. package/node_modules/ethereum-cryptography/src/pure/vendor/hdkey-without-crypto.js +255 -0
  378. package/node_modules/ethereum-cryptography/src/random.ts +18 -0
  379. package/node_modules/ethereum-cryptography/src/ripemd160.ts +7 -0
  380. package/node_modules/ethereum-cryptography/src/scrypt.ts +24 -0
  381. package/node_modules/ethereum-cryptography/src/secp256k1.ts +24 -0
  382. package/node_modules/ethereum-cryptography/src/sha256.ts +5 -0
  383. package/node_modules/ethereum-cryptography/src/shims/hdkey-crypto.ts +1 -0
  384. package/node_modules/ethereum-cryptography/src/shims/hdkey-secp256k1v3.ts +49 -0
  385. package/node_modules/ethereum-cryptography/src/vendor/bip39-without-wordlists.js +206 -0
  386. package/node_modules/ethereum-cryptography/src/vendor/hdkey-without-crypto.js +255 -0
  387. package/node_modules/ethereum-cryptography/vendor/bip39-without-wordlists.js +206 -0
  388. package/node_modules/ethereum-cryptography/vendor/hdkey-without-crypto.js +255 -0
  389. package/node_modules/ethereumjs-util/LICENSE +373 -0
  390. package/node_modules/ethereumjs-util/README.md +32 -0
  391. package/node_modules/ethereumjs-util/dist/account.d.ts +80 -0
  392. package/node_modules/ethereumjs-util/dist/account.js +168 -0
  393. package/node_modules/ethereumjs-util/dist/account.js.map +1 -0
  394. package/node_modules/ethereumjs-util/dist/bytes.d.ts +68 -0
  395. package/node_modules/ethereumjs-util/dist/bytes.js +158 -0
  396. package/node_modules/ethereumjs-util/dist/bytes.js.map +1 -0
  397. package/node_modules/ethereumjs-util/dist/constants.d.ts +34 -0
  398. package/node_modules/ethereumjs-util/dist/constants.js +37 -0
  399. package/node_modules/ethereumjs-util/dist/constants.js.map +1 -0
  400. package/node_modules/ethereumjs-util/dist/hash.d.ts +30 -0
  401. package/node_modules/ethereumjs-util/dist/hash.js +84 -0
  402. package/node_modules/ethereumjs-util/dist/hash.js.map +1 -0
  403. package/node_modules/ethereumjs-util/dist/index.d.ts +39 -0
  404. package/node_modules/ethereumjs-util/dist/index.js +46 -0
  405. package/node_modules/ethereumjs-util/dist/index.js.map +1 -0
  406. package/node_modules/ethereumjs-util/dist/object.d.ts +12 -0
  407. package/node_modules/ethereumjs-util/dist/object.js +106 -0
  408. package/node_modules/ethereumjs-util/dist/object.js.map +1 -0
  409. package/node_modules/ethereumjs-util/dist/secp256k1v3-adapter.d.ts +178 -0
  410. package/node_modules/ethereumjs-util/dist/secp256k1v3-adapter.js +300 -0
  411. package/node_modules/ethereumjs-util/dist/secp256k1v3-adapter.js.map +1 -0
  412. package/node_modules/ethereumjs-util/dist/secp256k1v3-lib/der.d.ts +1 -0
  413. package/node_modules/ethereumjs-util/dist/secp256k1v3-lib/der.js +634 -0
  414. package/node_modules/ethereumjs-util/dist/secp256k1v3-lib/der.js.map +1 -0
  415. package/node_modules/ethereumjs-util/dist/secp256k1v3-lib/index.d.ts +5 -0
  416. package/node_modules/ethereumjs-util/dist/secp256k1v3-lib/index.js +61 -0
  417. package/node_modules/ethereumjs-util/dist/secp256k1v3-lib/index.js.map +1 -0
  418. package/node_modules/ethereumjs-util/dist/signature.d.ts +37 -0
  419. package/node_modules/ethereumjs-util/dist/signature.js +107 -0
  420. package/node_modules/ethereumjs-util/dist/signature.js.map +1 -0
  421. package/node_modules/ethereumjs-util/package.json +131 -0
  422. package/node_modules/ethjs-util/LICENSE +21 -0
  423. package/node_modules/ethjs-util/README.md +143 -0
  424. package/node_modules/ethjs-util/dist/ethjs-util.js +2420 -0
  425. package/node_modules/ethjs-util/dist/ethjs-util.js.map +1 -0
  426. package/node_modules/ethjs-util/dist/ethjs-util.min.js +1 -0
  427. package/node_modules/ethjs-util/internals/webpack/webpack.config.js +58 -0
  428. package/node_modules/ethjs-util/lib/index.js +220 -0
  429. package/node_modules/ethjs-util/lib/tests/test.index.js +357 -0
  430. package/node_modules/ethjs-util/package.json +229 -0
  431. package/node_modules/ethjs-util/src/index.js +203 -0
  432. package/node_modules/ethjs-util/src/tests/test.index.js +382 -0
  433. package/node_modules/evp_bytestokey/LICENSE +21 -0
  434. package/node_modules/evp_bytestokey/README.md +51 -0
  435. package/node_modules/evp_bytestokey/index.js +45 -0
  436. package/node_modules/evp_bytestokey/package.json +49 -0
  437. package/node_modules/execa/index.js +361 -0
  438. package/node_modules/execa/lib/errname.js +39 -0
  439. package/node_modules/execa/lib/stdio.js +41 -0
  440. package/node_modules/execa/license +9 -0
  441. package/node_modules/execa/package.json +73 -0
  442. package/node_modules/execa/readme.md +327 -0
  443. package/node_modules/find-up/index.js +46 -0
  444. package/node_modules/find-up/license +9 -0
  445. package/node_modules/find-up/package.json +54 -0
  446. package/node_modules/find-up/readme.md +87 -0
  447. package/node_modules/get-caller-file/LICENSE.md +6 -0
  448. package/node_modules/get-caller-file/README.md +41 -0
  449. package/node_modules/get-caller-file/index.d.ts +2 -0
  450. package/node_modules/get-caller-file/index.js +22 -0
  451. package/node_modules/get-caller-file/index.js.map +1 -0
  452. package/node_modules/get-caller-file/package.json +46 -0
  453. package/node_modules/get-stream/buffer-stream.js +51 -0
  454. package/node_modules/get-stream/index.js +50 -0
  455. package/node_modules/get-stream/license +9 -0
  456. package/node_modules/get-stream/package.json +50 -0
  457. package/node_modules/get-stream/readme.md +123 -0
  458. package/node_modules/hash-base/LICENSE +21 -0
  459. package/node_modules/hash-base/README.md +48 -0
  460. package/node_modules/hash-base/index.js +95 -0
  461. package/node_modules/hash-base/package.json +46 -0
  462. package/node_modules/hash.js/.eslintrc.js +41 -0
  463. package/node_modules/hash.js/.travis.yml +10 -0
  464. package/node_modules/hash.js/README.md +48 -0
  465. package/node_modules/hash.js/lib/hash/common.js +92 -0
  466. package/node_modules/hash.js/lib/hash/hmac.js +47 -0
  467. package/node_modules/hash.js/lib/hash/ripemd.js +146 -0
  468. package/node_modules/hash.js/lib/hash/sha/1.js +74 -0
  469. package/node_modules/hash.js/lib/hash/sha/224.js +30 -0
  470. package/node_modules/hash.js/lib/hash/sha/256.js +105 -0
  471. package/node_modules/hash.js/lib/hash/sha/384.js +35 -0
  472. package/node_modules/hash.js/lib/hash/sha/512.js +330 -0
  473. package/node_modules/hash.js/lib/hash/sha/common.js +49 -0
  474. package/node_modules/hash.js/lib/hash/sha.js +7 -0
  475. package/node_modules/hash.js/lib/hash/utils.js +278 -0
  476. package/node_modules/hash.js/lib/hash.d.ts +106 -0
  477. package/node_modules/hash.js/lib/hash.js +15 -0
  478. package/node_modules/hash.js/package.json +39 -0
  479. package/node_modules/hash.js/test/hash-test.js +140 -0
  480. package/node_modules/hash.js/test/hmac-test.js +62 -0
  481. package/node_modules/hmac-drbg/.npmignore +2 -0
  482. package/node_modules/hmac-drbg/.travis.yml +11 -0
  483. package/node_modules/hmac-drbg/README.md +48 -0
  484. package/node_modules/hmac-drbg/lib/hmac-drbg.js +113 -0
  485. package/node_modules/hmac-drbg/package.json +36 -0
  486. package/node_modules/hmac-drbg/test/drbg-test.js +91 -0
  487. package/node_modules/hmac-drbg/test/fixtures/hmac-drbg-nist.json +332 -0
  488. package/node_modules/inherits/LICENSE +16 -0
  489. package/node_modules/inherits/README.md +42 -0
  490. package/node_modules/inherits/inherits.js +9 -0
  491. package/node_modules/inherits/inherits_browser.js +27 -0
  492. package/node_modules/inherits/package.json +33 -0
  493. package/node_modules/invert-kv/index.js +15 -0
  494. package/node_modules/invert-kv/license +9 -0
  495. package/node_modules/invert-kv/package.json +36 -0
  496. package/node_modules/invert-kv/readme.md +25 -0
  497. package/node_modules/is-fullwidth-code-point/index.js +46 -0
  498. package/node_modules/is-fullwidth-code-point/license +21 -0
  499. package/node_modules/is-fullwidth-code-point/package.json +49 -0
  500. package/node_modules/is-fullwidth-code-point/readme.md +39 -0
  501. package/node_modules/is-hex-prefixed/.editorconfig +7 -0
  502. package/node_modules/is-hex-prefixed/.gitattributes +106 -0
  503. package/node_modules/is-hex-prefixed/.npmignore +8 -0
  504. package/node_modules/is-hex-prefixed/.travis.yml +5 -0
  505. package/node_modules/is-hex-prefixed/CHANGELOG.md +7 -0
  506. package/node_modules/is-hex-prefixed/LICENSE +21 -0
  507. package/node_modules/is-hex-prefixed/README.md +101 -0
  508. package/node_modules/is-hex-prefixed/package.json +43 -0
  509. package/node_modules/is-hex-prefixed/src/index.js +13 -0
  510. package/node_modules/is-hex-prefixed/src/tests/test.index.js +66 -0
  511. package/node_modules/is-stream/index.js +21 -0
  512. package/node_modules/is-stream/license +21 -0
  513. package/node_modules/is-stream/package.json +42 -0
  514. package/node_modules/is-stream/readme.md +42 -0
  515. package/node_modules/isexe/.npmignore +2 -0
  516. package/node_modules/isexe/LICENSE +15 -0
  517. package/node_modules/isexe/README.md +51 -0
  518. package/node_modules/isexe/index.js +57 -0
  519. package/node_modules/isexe/mode.js +41 -0
  520. package/node_modules/isexe/package.json +35 -0
  521. package/node_modules/isexe/test/basic.js +221 -0
  522. package/node_modules/isexe/windows.js +42 -0
  523. package/node_modules/keccak/LICENSE +21 -0
  524. package/node_modules/keccak/README.md +64 -0
  525. package/node_modules/keccak/binding.gyp +78 -0
  526. package/node_modules/keccak/bindings.js +1 -0
  527. package/node_modules/keccak/index.js +5 -0
  528. package/node_modules/keccak/js.js +1 -0
  529. package/node_modules/keccak/lib/api/index.js +27 -0
  530. package/node_modules/keccak/lib/api/keccak.js +77 -0
  531. package/node_modules/keccak/lib/api/shake.js +68 -0
  532. package/node_modules/keccak/lib/keccak-state-reference.js +143 -0
  533. package/node_modules/keccak/lib/keccak-state-unroll.js +186 -0
  534. package/node_modules/keccak/lib/keccak.js +68 -0
  535. package/node_modules/keccak/package.json +41 -0
  536. package/node_modules/keccak/prebuilds/darwin-x64/node.napi.node +0 -0
  537. package/node_modules/keccak/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  538. package/node_modules/keccak/prebuilds/linux-x64/node.napi.musl.node +0 -0
  539. package/node_modules/keccak/prebuilds/win32-x64/node.napi.node +0 -0
  540. package/node_modules/keccak/src/README.md +28 -0
  541. package/node_modules/keccak/src/addon.cc +98 -0
  542. package/node_modules/keccak/src/libkeccak-32/KeccakP-1600-SnP.h +38 -0
  543. package/node_modules/keccak/src/libkeccak-32/KeccakP-1600-inplace32BI.c +1162 -0
  544. package/node_modules/keccak/src/libkeccak-32/KeccakSponge-common.h +35 -0
  545. package/node_modules/keccak/src/libkeccak-32/KeccakSponge.inc +311 -0
  546. package/node_modules/keccak/src/libkeccak-32/KeccakSpongeWidth1600.c +54 -0
  547. package/node_modules/keccak/src/libkeccak-32/KeccakSpongeWidth1600.h +31 -0
  548. package/node_modules/keccak/src/libkeccak-32/SnP-Relaned.h +140 -0
  549. package/node_modules/keccak/src/libkeccak-32/align.h +32 -0
  550. package/node_modules/keccak/src/libkeccak-32/brg_endian.h +143 -0
  551. package/node_modules/keccak/src/libkeccak-64/KeccakP-1600-64.macros +745 -0
  552. package/node_modules/keccak/src/libkeccak-64/KeccakP-1600-SnP.h +51 -0
  553. package/node_modules/keccak/src/libkeccak-64/KeccakP-1600-opt64-config.h +6 -0
  554. package/node_modules/keccak/src/libkeccak-64/KeccakP-1600-opt64.c +564 -0
  555. package/node_modules/keccak/src/libkeccak-64/KeccakP-1600-unrolling.macros +302 -0
  556. package/node_modules/keccak/src/libkeccak-64/KeccakSponge-common.h +35 -0
  557. package/node_modules/keccak/src/libkeccak-64/KeccakSponge.inc +311 -0
  558. package/node_modules/keccak/src/libkeccak-64/KeccakSpongeWidth1600.c +54 -0
  559. package/node_modules/keccak/src/libkeccak-64/KeccakSpongeWidth1600.h +31 -0
  560. package/node_modules/keccak/src/libkeccak-64/SnP-Relaned.h +140 -0
  561. package/node_modules/keccak/src/libkeccak-64/align.h +32 -0
  562. package/node_modules/keccak/src/libkeccak-64/brg_endian.h +143 -0
  563. package/node_modules/lcid/index.js +23 -0
  564. package/node_modules/lcid/lcid.json +203 -0
  565. package/node_modules/lcid/license +9 -0
  566. package/node_modules/lcid/package.json +51 -0
  567. package/node_modules/lcid/readme.md +35 -0
  568. package/node_modules/locate-path/index.js +24 -0
  569. package/node_modules/locate-path/license +9 -0
  570. package/node_modules/locate-path/package.json +48 -0
  571. package/node_modules/locate-path/readme.md +99 -0
  572. package/node_modules/map-age-cleaner/dist/index.d.ts +20 -0
  573. package/node_modules/map-age-cleaner/dist/index.js +92 -0
  574. package/node_modules/map-age-cleaner/license +9 -0
  575. package/node_modules/map-age-cleaner/package.json +63 -0
  576. package/node_modules/map-age-cleaner/readme.md +67 -0
  577. package/node_modules/md5.js/LICENSE +21 -0
  578. package/node_modules/md5.js/README.md +29 -0
  579. package/node_modules/md5.js/index.js +146 -0
  580. package/node_modules/md5.js/package.json +42 -0
  581. package/node_modules/mem/index.d.ts +96 -0
  582. package/node_modules/mem/index.js +88 -0
  583. package/node_modules/mem/license +9 -0
  584. package/node_modules/mem/package.json +50 -0
  585. package/node_modules/mem/readme.md +167 -0
  586. package/node_modules/mimic-fn/index.d.ts +54 -0
  587. package/node_modules/mimic-fn/index.js +13 -0
  588. package/node_modules/mimic-fn/license +9 -0
  589. package/node_modules/mimic-fn/package.json +46 -0
  590. package/node_modules/mimic-fn/readme.md +69 -0
  591. package/node_modules/minimalistic-assert/LICENSE +13 -0
  592. package/node_modules/minimalistic-assert/index.js +11 -0
  593. package/node_modules/minimalistic-assert/package.json +23 -0
  594. package/node_modules/minimalistic-assert/readme.md +4 -0
  595. package/node_modules/minimalistic-crypto-utils/.npmignore +2 -0
  596. package/node_modules/minimalistic-crypto-utils/.travis.yml +11 -0
  597. package/node_modules/minimalistic-crypto-utils/README.md +47 -0
  598. package/node_modules/minimalistic-crypto-utils/lib/utils.js +58 -0
  599. package/node_modules/minimalistic-crypto-utils/package.json +31 -0
  600. package/node_modules/minimalistic-crypto-utils/test/utils-test.js +28 -0
  601. package/node_modules/nice-try/LICENSE +21 -0
  602. package/node_modules/nice-try/README.md +32 -0
  603. package/node_modules/nice-try/package.json +37 -0
  604. package/node_modules/nice-try/src/index.js +12 -0
  605. package/node_modules/node-addon-api/.editorconfig +8 -0
  606. package/node_modules/node-addon-api/.travis.yml +62 -0
  607. package/node_modules/node-addon-api/CHANGELOG.md +412 -0
  608. package/node_modules/node-addon-api/CODE_OF_CONDUCT.md +4 -0
  609. package/node_modules/node-addon-api/CONTRIBUTING.md +66 -0
  610. package/node_modules/node-addon-api/LICENSE.md +13 -0
  611. package/node_modules/node-addon-api/README.md +203 -0
  612. package/node_modules/node-addon-api/appveyor.yml +48 -0
  613. package/node_modules/node-addon-api/doc/Doxyfile +2450 -0
  614. package/node_modules/node-addon-api/doc/array_buffer.md +129 -0
  615. package/node_modules/node-addon-api/doc/async_context.md +86 -0
  616. package/node_modules/node-addon-api/doc/async_operations.md +31 -0
  617. package/node_modules/node-addon-api/doc/async_progress_worker.md +344 -0
  618. package/node_modules/node-addon-api/doc/async_worker.md +398 -0
  619. package/node_modules/node-addon-api/doc/basic_types.md +423 -0
  620. package/node_modules/node-addon-api/doc/bigint.md +92 -0
  621. package/node_modules/node-addon-api/doc/boolean.md +64 -0
  622. package/node_modules/node-addon-api/doc/buffer.md +140 -0
  623. package/node_modules/node-addon-api/doc/callback_scope.md +54 -0
  624. package/node_modules/node-addon-api/doc/callbackinfo.md +97 -0
  625. package/node_modules/node-addon-api/doc/checker-tool.md +32 -0
  626. package/node_modules/node-addon-api/doc/class_property_descriptor.md +117 -0
  627. package/node_modules/node-addon-api/doc/cmake-js.md +68 -0
  628. package/node_modules/node-addon-api/doc/conversion-tool.md +28 -0
  629. package/node_modules/node-addon-api/doc/creating_a_release.md +62 -0
  630. package/node_modules/node-addon-api/doc/dataview.md +244 -0
  631. package/node_modules/node-addon-api/doc/date.md +68 -0
  632. package/node_modules/node-addon-api/doc/env.md +63 -0
  633. package/node_modules/node-addon-api/doc/error.md +115 -0
  634. package/node_modules/node-addon-api/doc/error_handling.md +186 -0
  635. package/node_modules/node-addon-api/doc/escapable_handle_scope.md +82 -0
  636. package/node_modules/node-addon-api/doc/external.md +59 -0
  637. package/node_modules/node-addon-api/doc/function.md +294 -0
  638. package/node_modules/node-addon-api/doc/function_reference.md +238 -0
  639. package/node_modules/node-addon-api/doc/generator.md +13 -0
  640. package/node_modules/node-addon-api/doc/handle_scope.md +65 -0
  641. package/node_modules/node-addon-api/doc/memory_management.md +27 -0
  642. package/node_modules/node-addon-api/doc/node-gyp.md +82 -0
  643. package/node_modules/node-addon-api/doc/number.md +163 -0
  644. package/node_modules/node-addon-api/doc/object.md +236 -0
  645. package/node_modules/node-addon-api/doc/object_lifetime_management.md +83 -0
  646. package/node_modules/node-addon-api/doc/object_reference.md +117 -0
  647. package/node_modules/node-addon-api/doc/object_wrap.md +557 -0
  648. package/node_modules/node-addon-api/doc/prebuild_tools.md +16 -0
  649. package/node_modules/node-addon-api/doc/promises.md +74 -0
  650. package/node_modules/node-addon-api/doc/property_descriptor.md +231 -0
  651. package/node_modules/node-addon-api/doc/range_error.md +59 -0
  652. package/node_modules/node-addon-api/doc/reference.md +111 -0
  653. package/node_modules/node-addon-api/doc/setup.md +82 -0
  654. package/node_modules/node-addon-api/doc/string.md +89 -0
  655. package/node_modules/node-addon-api/doc/symbol.md +44 -0
  656. package/node_modules/node-addon-api/doc/threadsafe_function.md +320 -0
  657. package/node_modules/node-addon-api/doc/type_error.md +59 -0
  658. package/node_modules/node-addon-api/doc/typed_array.md +74 -0
  659. package/node_modules/node-addon-api/doc/typed_array_of.md +133 -0
  660. package/node_modules/node-addon-api/doc/value.md +278 -0
  661. package/node_modules/node-addon-api/doc/version_management.md +43 -0
  662. package/node_modules/node-addon-api/doc/working_with_javascript_values.md +14 -0
  663. package/node_modules/node-addon-api/external-napi/node_api.h +7 -0
  664. package/node_modules/node-addon-api/index.js +45 -0
  665. package/node_modules/node-addon-api/napi-inl.deprecated.h +192 -0
  666. package/node_modules/node-addon-api/napi-inl.h +4412 -0
  667. package/node_modules/node-addon-api/napi.h +2173 -0
  668. package/node_modules/node-addon-api/package.json +248 -0
  669. package/node_modules/node-addon-api/src/node_api.cc +3655 -0
  670. package/node_modules/node-addon-api/src/node_api.gyp +21 -0
  671. package/node_modules/node-addon-api/src/node_api.h +588 -0
  672. package/node_modules/node-addon-api/src/node_api_types.h +115 -0
  673. package/node_modules/node-addon-api/src/node_internals.cc +142 -0
  674. package/node_modules/node-addon-api/src/node_internals.h +157 -0
  675. package/node_modules/node-addon-api/src/nothing.c +0 -0
  676. package/node_modules/node-addon-api/src/util-inl.h +38 -0
  677. package/node_modules/node-addon-api/src/util.h +7 -0
  678. package/node_modules/node-addon-api/tools/README.md +67 -0
  679. package/node_modules/node-addon-api/tools/check-napi.js +100 -0
  680. package/node_modules/node-addon-api/tools/conversion.js +313 -0
  681. package/node_modules/node-gyp-build/LICENSE +21 -0
  682. package/node_modules/node-gyp-build/README.md +58 -0
  683. package/node_modules/node-gyp-build/bin.js +77 -0
  684. package/node_modules/node-gyp-build/build-test.js +19 -0
  685. package/node_modules/node-gyp-build/index.js +166 -0
  686. package/node_modules/node-gyp-build/optional.js +7 -0
  687. package/node_modules/node-gyp-build/package.json +33 -0
  688. package/node_modules/npm-run-path/index.js +39 -0
  689. package/node_modules/npm-run-path/license +21 -0
  690. package/node_modules/npm-run-path/package.json +49 -0
  691. package/node_modules/npm-run-path/readme.md +81 -0
  692. package/node_modules/once/LICENSE +15 -0
  693. package/node_modules/once/README.md +79 -0
  694. package/node_modules/once/once.js +42 -0
  695. package/node_modules/once/package.json +37 -0
  696. package/node_modules/os-locale/index.js +114 -0
  697. package/node_modules/os-locale/license +9 -0
  698. package/node_modules/os-locale/package.json +49 -0
  699. package/node_modules/os-locale/readme.md +71 -0
  700. package/node_modules/p-defer/index.js +11 -0
  701. package/node_modules/p-defer/license +21 -0
  702. package/node_modules/p-defer/package.json +45 -0
  703. package/node_modules/p-defer/readme.md +47 -0
  704. package/node_modules/p-finally/index.js +15 -0
  705. package/node_modules/p-finally/license +21 -0
  706. package/node_modules/p-finally/package.json +46 -0
  707. package/node_modules/p-finally/readme.md +47 -0
  708. package/node_modules/p-is-promise/index.d.ts +23 -0
  709. package/node_modules/p-is-promise/index.js +15 -0
  710. package/node_modules/p-is-promise/license +9 -0
  711. package/node_modules/p-is-promise/package.json +46 -0
  712. package/node_modules/p-is-promise/readme.md +43 -0
  713. package/node_modules/p-limit/index.d.ts +38 -0
  714. package/node_modules/p-limit/index.js +57 -0
  715. package/node_modules/p-limit/license +9 -0
  716. package/node_modules/p-limit/package.json +56 -0
  717. package/node_modules/p-limit/readme.md +101 -0
  718. package/node_modules/p-locate/index.js +34 -0
  719. package/node_modules/p-locate/license +9 -0
  720. package/node_modules/p-locate/package.json +55 -0
  721. package/node_modules/p-locate/readme.md +88 -0
  722. package/node_modules/p-try/index.d.ts +39 -0
  723. package/node_modules/p-try/index.js +9 -0
  724. package/node_modules/p-try/license +9 -0
  725. package/node_modules/p-try/package.json +46 -0
  726. package/node_modules/p-try/readme.md +58 -0
  727. package/node_modules/path-exists/index.js +17 -0
  728. package/node_modules/path-exists/license +21 -0
  729. package/node_modules/path-exists/package.json +44 -0
  730. package/node_modules/path-exists/readme.md +50 -0
  731. package/node_modules/path-key/index.js +13 -0
  732. package/node_modules/path-key/license +21 -0
  733. package/node_modules/path-key/package.json +43 -0
  734. package/node_modules/path-key/readme.md +51 -0
  735. package/node_modules/pbkdf2/LICENSE +21 -0
  736. package/node_modules/pbkdf2/README.md +30 -0
  737. package/node_modules/pbkdf2/browser.js +2 -0
  738. package/node_modules/pbkdf2/index.js +38 -0
  739. package/node_modules/pbkdf2/lib/async.js +102 -0
  740. package/node_modules/pbkdf2/lib/default-encoding.js +12 -0
  741. package/node_modules/pbkdf2/lib/precondition.js +19 -0
  742. package/node_modules/pbkdf2/lib/sync-browser.js +105 -0
  743. package/node_modules/pbkdf2/lib/sync.js +52 -0
  744. package/node_modules/pbkdf2/lib/to-buffer.js +13 -0
  745. package/node_modules/pbkdf2/package.json +74 -0
  746. package/node_modules/pump/.travis.yml +5 -0
  747. package/node_modules/pump/LICENSE +21 -0
  748. package/node_modules/pump/README.md +65 -0
  749. package/node_modules/pump/index.js +82 -0
  750. package/node_modules/pump/package.json +28 -0
  751. package/node_modules/pump/test-browser.js +66 -0
  752. package/node_modules/pump/test-node.js +53 -0
  753. package/node_modules/randombytes/.travis.yml +15 -0
  754. package/node_modules/randombytes/.zuul.yml +1 -0
  755. package/node_modules/randombytes/LICENSE +21 -0
  756. package/node_modules/randombytes/README.md +14 -0
  757. package/node_modules/randombytes/browser.js +50 -0
  758. package/node_modules/randombytes/index.js +1 -0
  759. package/node_modules/randombytes/package.json +40 -0
  760. package/node_modules/randombytes/test.js +81 -0
  761. package/node_modules/readable-stream/CONTRIBUTING.md +38 -0
  762. package/node_modules/readable-stream/GOVERNANCE.md +136 -0
  763. package/node_modules/readable-stream/LICENSE +47 -0
  764. package/node_modules/readable-stream/README.md +106 -0
  765. package/node_modules/readable-stream/errors-browser.js +127 -0
  766. package/node_modules/readable-stream/errors.js +116 -0
  767. package/node_modules/readable-stream/experimentalWarning.js +17 -0
  768. package/node_modules/readable-stream/lib/_stream_duplex.js +139 -0
  769. package/node_modules/readable-stream/lib/_stream_passthrough.js +39 -0
  770. package/node_modules/readable-stream/lib/_stream_readable.js +1124 -0
  771. package/node_modules/readable-stream/lib/_stream_transform.js +201 -0
  772. package/node_modules/readable-stream/lib/_stream_writable.js +697 -0
  773. package/node_modules/readable-stream/lib/internal/streams/async_iterator.js +207 -0
  774. package/node_modules/readable-stream/lib/internal/streams/buffer_list.js +210 -0
  775. package/node_modules/readable-stream/lib/internal/streams/destroy.js +105 -0
  776. package/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +104 -0
  777. package/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
  778. package/node_modules/readable-stream/lib/internal/streams/from.js +64 -0
  779. package/node_modules/readable-stream/lib/internal/streams/pipeline.js +97 -0
  780. package/node_modules/readable-stream/lib/internal/streams/state.js +27 -0
  781. package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
  782. package/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
  783. package/node_modules/readable-stream/package.json +72 -0
  784. package/node_modules/readable-stream/readable-browser.js +9 -0
  785. package/node_modules/readable-stream/readable.js +16 -0
  786. package/node_modules/require-directory/.jshintrc +67 -0
  787. package/node_modules/require-directory/.npmignore +1 -0
  788. package/node_modules/require-directory/.travis.yml +3 -0
  789. package/node_modules/require-directory/LICENSE +22 -0
  790. package/node_modules/require-directory/README.markdown +184 -0
  791. package/node_modules/require-directory/index.js +86 -0
  792. package/node_modules/require-directory/package.json +44 -0
  793. package/node_modules/require-main-filename/LICENSE.txt +14 -0
  794. package/node_modules/require-main-filename/README.md +26 -0
  795. package/node_modules/require-main-filename/index.js +18 -0
  796. package/node_modules/require-main-filename/package.json +39 -0
  797. package/node_modules/ripemd160/LICENSE +21 -0
  798. package/node_modules/ripemd160/README.md +27 -0
  799. package/node_modules/ripemd160/index.js +163 -0
  800. package/node_modules/ripemd160/package.json +41 -0
  801. package/node_modules/rlp/LICENSE +373 -0
  802. package/node_modules/rlp/README.md +58 -0
  803. package/node_modules/rlp/bin/rlp +35 -0
  804. package/node_modules/rlp/dist/index.d.ts +25 -0
  805. package/node_modules/rlp/dist/index.js +249 -0
  806. package/node_modules/rlp/dist/index.js.map +1 -0
  807. package/node_modules/rlp/dist/types.d.ts +9 -0
  808. package/node_modules/rlp/dist/types.js +3 -0
  809. package/node_modules/rlp/dist/types.js.map +1 -0
  810. package/node_modules/rlp/package.json +84 -0
  811. package/node_modules/safe-buffer/LICENSE +21 -0
  812. package/node_modules/safe-buffer/README.md +584 -0
  813. package/node_modules/safe-buffer/index.d.ts +187 -0
  814. package/node_modules/safe-buffer/index.js +65 -0
  815. package/node_modules/safe-buffer/package.json +55 -0
  816. package/node_modules/scrypt-js/LICENSE.txt +22 -0
  817. package/node_modules/scrypt-js/README.md +222 -0
  818. package/node_modules/scrypt-js/index.html +291 -0
  819. package/node_modules/scrypt-js/package.json +31 -0
  820. package/node_modules/scrypt-js/scrypt.d.ts +23 -0
  821. package/node_modules/scrypt-js/scrypt.js +488 -0
  822. package/node_modules/scrypt-js/thirdparty/buffer.js +1381 -0
  823. package/node_modules/scrypt-js/thirdparty/setImmediate.js +175 -0
  824. package/node_modules/scrypt-js/thirdparty/unorm.js +442 -0
  825. package/node_modules/secp256k1/API.md +116 -0
  826. package/node_modules/secp256k1/LICENSE +24 -0
  827. package/node_modules/secp256k1/README.md +117 -0
  828. package/node_modules/secp256k1/binding.gyp +100 -0
  829. package/node_modules/secp256k1/bindings.js +2 -0
  830. package/node_modules/secp256k1/elliptic.js +1 -0
  831. package/node_modules/secp256k1/index.js +5 -0
  832. package/node_modules/secp256k1/lib/elliptic.js +402 -0
  833. package/node_modules/secp256k1/lib/index.js +336 -0
  834. package/node_modules/secp256k1/package.json +47 -0
  835. package/node_modules/secp256k1/prebuilds/darwin-x64/node.napi.node +0 -0
  836. package/node_modules/secp256k1/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  837. package/node_modules/secp256k1/prebuilds/linux-x64/node.napi.musl.node +0 -0
  838. package/node_modules/secp256k1/prebuilds/win32-x64/node.napi.node +0 -0
  839. package/node_modules/secp256k1/src/addon.cc +10 -0
  840. package/node_modules/secp256k1/src/secp256k1/.travis.yml +100 -0
  841. package/node_modules/secp256k1/src/secp256k1/COPYING +19 -0
  842. package/node_modules/secp256k1/src/secp256k1/Makefile.am +183 -0
  843. package/node_modules/secp256k1/src/secp256k1/README.md +78 -0
  844. package/node_modules/secp256k1/src/secp256k1/SECURITY.md +15 -0
  845. package/node_modules/secp256k1/src/secp256k1/TODO +3 -0
  846. package/node_modules/secp256k1/src/secp256k1/autogen.sh +3 -0
  847. package/node_modules/secp256k1/src/secp256k1/build-aux/m4/ax_jni_include_dir.m4 +145 -0
  848. package/node_modules/secp256k1/src/secp256k1/build-aux/m4/ax_prog_cc_for_build.m4 +125 -0
  849. package/node_modules/secp256k1/src/secp256k1/build-aux/m4/bitcoin_secp.m4 +68 -0
  850. package/node_modules/secp256k1/src/secp256k1/configure.ac +591 -0
  851. package/node_modules/secp256k1/src/secp256k1/contrib/lax_der_parsing.c +150 -0
  852. package/node_modules/secp256k1/src/secp256k1/contrib/lax_der_parsing.h +91 -0
  853. package/node_modules/secp256k1/src/secp256k1/contrib/lax_der_privatekey_parsing.c +113 -0
  854. package/node_modules/secp256k1/src/secp256k1/contrib/lax_der_privatekey_parsing.h +90 -0
  855. package/node_modules/secp256k1/src/secp256k1/include/secp256k1.h +708 -0
  856. package/node_modules/secp256k1/src/secp256k1/include/secp256k1_ecdh.h +55 -0
  857. package/node_modules/secp256k1/src/secp256k1/include/secp256k1_preallocated.h +128 -0
  858. package/node_modules/secp256k1/src/secp256k1/include/secp256k1_recovery.h +110 -0
  859. package/node_modules/secp256k1/src/secp256k1/libsecp256k1.pc.in +13 -0
  860. package/node_modules/secp256k1/src/secp256k1/sage/group_prover.sage +322 -0
  861. package/node_modules/secp256k1/src/secp256k1/sage/secp256k1.sage +306 -0
  862. package/node_modules/secp256k1/src/secp256k1/sage/weierstrass_prover.sage +264 -0
  863. package/node_modules/secp256k1/src/secp256k1/src/asm/field_10x26_arm.s +913 -0
  864. package/node_modules/secp256k1/src/secp256k1/src/basic-config.h +38 -0
  865. package/node_modules/secp256k1/src/secp256k1/src/bench.h +124 -0
  866. package/node_modules/secp256k1/src/secp256k1/src/bench_ecdh.c +54 -0
  867. package/node_modules/secp256k1/src/secp256k1/src/bench_ecmult.c +207 -0
  868. package/node_modules/secp256k1/src/secp256k1/src/bench_internal.c +379 -0
  869. package/node_modules/secp256k1/src/secp256k1/src/bench_recover.c +60 -0
  870. package/node_modules/secp256k1/src/secp256k1/src/bench_sign.c +56 -0
  871. package/node_modules/secp256k1/src/secp256k1/src/bench_verify.c +112 -0
  872. package/node_modules/secp256k1/src/secp256k1/src/ecdsa.h +21 -0
  873. package/node_modules/secp256k1/src/secp256k1/src/ecdsa_impl.h +319 -0
  874. package/node_modules/secp256k1/src/secp256k1/src/eckey.h +25 -0
  875. package/node_modules/secp256k1/src/secp256k1/src/eckey_impl.h +100 -0
  876. package/node_modules/secp256k1/src/secp256k1/src/ecmult.h +48 -0
  877. package/node_modules/secp256k1/src/secp256k1/src/ecmult_const.h +20 -0
  878. package/node_modules/secp256k1/src/secp256k1/src/ecmult_const_impl.h +261 -0
  879. package/node_modules/secp256k1/src/secp256k1/src/ecmult_gen.h +50 -0
  880. package/node_modules/secp256k1/src/secp256k1/src/ecmult_gen_impl.h +211 -0
  881. package/node_modules/secp256k1/src/secp256k1/src/ecmult_impl.h +1216 -0
  882. package/node_modules/secp256k1/src/secp256k1/src/field.h +132 -0
  883. package/node_modules/secp256k1/src/secp256k1/src/field_10x26.h +50 -0
  884. package/node_modules/secp256k1/src/secp256k1/src/field_10x26_impl.h +1162 -0
  885. package/node_modules/secp256k1/src/secp256k1/src/field_5x52.h +49 -0
  886. package/node_modules/secp256k1/src/secp256k1/src/field_5x52_asm_impl.h +502 -0
  887. package/node_modules/secp256k1/src/secp256k1/src/field_5x52_impl.h +496 -0
  888. package/node_modules/secp256k1/src/secp256k1/src/field_5x52_int128_impl.h +279 -0
  889. package/node_modules/secp256k1/src/secp256k1/src/field_impl.h +318 -0
  890. package/node_modules/secp256k1/src/secp256k1/src/gen_context.c +87 -0
  891. package/node_modules/secp256k1/src/secp256k1/src/group.h +142 -0
  892. package/node_modules/secp256k1/src/secp256k1/src/group_impl.h +705 -0
  893. package/node_modules/secp256k1/src/secp256k1/src/hash.h +41 -0
  894. package/node_modules/secp256k1/src/secp256k1/src/hash_impl.h +283 -0
  895. package/node_modules/secp256k1/src/secp256k1/src/java/org/bitcoin/NativeSecp256k1.java +446 -0
  896. package/node_modules/secp256k1/src/secp256k1/src/java/org/bitcoin/NativeSecp256k1Test.java +225 -0
  897. package/node_modules/secp256k1/src/secp256k1/src/java/org/bitcoin/NativeSecp256k1Util.java +45 -0
  898. package/node_modules/secp256k1/src/secp256k1/src/java/org/bitcoin/Secp256k1Context.java +51 -0
  899. package/node_modules/secp256k1/src/secp256k1/src/java/org_bitcoin_NativeSecp256k1.c +379 -0
  900. package/node_modules/secp256k1/src/secp256k1/src/java/org_bitcoin_NativeSecp256k1.h +119 -0
  901. package/node_modules/secp256k1/src/secp256k1/src/java/org_bitcoin_Secp256k1Context.c +15 -0
  902. package/node_modules/secp256k1/src/secp256k1/src/java/org_bitcoin_Secp256k1Context.h +22 -0
  903. package/node_modules/secp256k1/src/secp256k1/src/modules/ecdh/Makefile.am.include +8 -0
  904. package/node_modules/secp256k1/src/secp256k1/src/modules/ecdh/main_impl.h +67 -0
  905. package/node_modules/secp256k1/src/secp256k1/src/modules/ecdh/tests_impl.h +132 -0
  906. package/node_modules/secp256k1/src/secp256k1/src/modules/recovery/Makefile.am.include +8 -0
  907. package/node_modules/secp256k1/src/secp256k1/src/modules/recovery/main_impl.h +193 -0
  908. package/node_modules/secp256k1/src/secp256k1/src/modules/recovery/tests_impl.h +393 -0
  909. package/node_modules/secp256k1/src/secp256k1/src/num.h +74 -0
  910. package/node_modules/secp256k1/src/secp256k1/src/num_gmp.h +20 -0
  911. package/node_modules/secp256k1/src/secp256k1/src/num_gmp_impl.h +288 -0
  912. package/node_modules/secp256k1/src/secp256k1/src/num_impl.h +24 -0
  913. package/node_modules/secp256k1/src/secp256k1/src/scalar.h +106 -0
  914. package/node_modules/secp256k1/src/secp256k1/src/scalar_4x64.h +19 -0
  915. package/node_modules/secp256k1/src/secp256k1/src/scalar_4x64_impl.h +949 -0
  916. package/node_modules/secp256k1/src/secp256k1/src/scalar_8x32.h +19 -0
  917. package/node_modules/secp256k1/src/secp256k1/src/scalar_8x32_impl.h +721 -0
  918. package/node_modules/secp256k1/src/secp256k1/src/scalar_impl.h +333 -0
  919. package/node_modules/secp256k1/src/secp256k1/src/scalar_low.h +15 -0
  920. package/node_modules/secp256k1/src/secp256k1/src/scalar_low_impl.h +117 -0
  921. package/node_modules/secp256k1/src/secp256k1/src/scratch.h +42 -0
  922. package/node_modules/secp256k1/src/secp256k1/src/scratch_impl.h +88 -0
  923. package/node_modules/secp256k1/src/secp256k1/src/secp256k1.c +690 -0
  924. package/node_modules/secp256k1/src/secp256k1/src/testrand.h +38 -0
  925. package/node_modules/secp256k1/src/secp256k1/src/testrand_impl.h +110 -0
  926. package/node_modules/secp256k1/src/secp256k1/src/tests.c +5310 -0
  927. package/node_modules/secp256k1/src/secp256k1/src/tests_exhaustive.c +511 -0
  928. package/node_modules/secp256k1/src/secp256k1/src/util.h +162 -0
  929. package/node_modules/secp256k1/src/secp256k1.cc +415 -0
  930. package/node_modules/secp256k1/src/secp256k1.h +63 -0
  931. package/node_modules/semver/LICENSE +15 -0
  932. package/node_modules/semver/README.md +412 -0
  933. package/node_modules/semver/bin/semver +160 -0
  934. package/node_modules/semver/package.json +32 -0
  935. package/node_modules/semver/range.bnf +16 -0
  936. package/node_modules/semver/semver.js +1483 -0
  937. package/node_modules/set-blocking/LICENSE.txt +14 -0
  938. package/node_modules/set-blocking/README.md +31 -0
  939. package/node_modules/set-blocking/index.js +7 -0
  940. package/node_modules/set-blocking/package.json +46 -0
  941. package/node_modules/setimmediate/LICENSE.txt +20 -0
  942. package/node_modules/setimmediate/package.json +34 -0
  943. package/node_modules/setimmediate/setImmediate.js +186 -0
  944. package/node_modules/sha.js/.travis.yml +17 -0
  945. package/node_modules/sha.js/LICENSE +49 -0
  946. package/node_modules/sha.js/README.md +44 -0
  947. package/node_modules/sha.js/bin.js +41 -0
  948. package/node_modules/sha.js/hash.js +81 -0
  949. package/node_modules/sha.js/index.js +15 -0
  950. package/node_modules/sha.js/package.json +34 -0
  951. package/node_modules/sha.js/sha.js +94 -0
  952. package/node_modules/sha.js/sha1.js +99 -0
  953. package/node_modules/sha.js/sha224.js +53 -0
  954. package/node_modules/sha.js/sha256.js +135 -0
  955. package/node_modules/sha.js/sha384.js +57 -0
  956. package/node_modules/sha.js/sha512.js +260 -0
  957. package/node_modules/sha.js/test/hash.js +75 -0
  958. package/node_modules/sha.js/test/test.js +100 -0
  959. package/node_modules/sha.js/test/vectors.js +72 -0
  960. package/node_modules/shebang-command/index.js +19 -0
  961. package/node_modules/shebang-command/license +21 -0
  962. package/node_modules/shebang-command/package.json +43 -0
  963. package/node_modules/shebang-command/readme.md +39 -0
  964. package/node_modules/shebang-regex/index.js +2 -0
  965. package/node_modules/shebang-regex/license +21 -0
  966. package/node_modules/shebang-regex/package.json +36 -0
  967. package/node_modules/shebang-regex/readme.md +29 -0
  968. package/node_modules/signal-exit/LICENSE.txt +16 -0
  969. package/node_modules/signal-exit/README.md +39 -0
  970. package/node_modules/signal-exit/index.js +163 -0
  971. package/node_modules/signal-exit/package.json +42 -0
  972. package/node_modules/signal-exit/signals.js +53 -0
  973. package/node_modules/source-map/LICENSE +28 -0
  974. package/node_modules/source-map/README.md +742 -0
  975. package/node_modules/source-map/dist/source-map.debug.js +3234 -0
  976. package/node_modules/source-map/dist/source-map.js +3233 -0
  977. package/node_modules/source-map/dist/source-map.min.js +2 -0
  978. package/node_modules/source-map/dist/source-map.min.js.map +1 -0
  979. package/node_modules/source-map/lib/array-set.js +121 -0
  980. package/node_modules/source-map/lib/base64-vlq.js +140 -0
  981. package/node_modules/source-map/lib/base64.js +67 -0
  982. package/node_modules/source-map/lib/binary-search.js +111 -0
  983. package/node_modules/source-map/lib/mapping-list.js +79 -0
  984. package/node_modules/source-map/lib/quick-sort.js +114 -0
  985. package/node_modules/source-map/lib/source-map-consumer.js +1145 -0
  986. package/node_modules/source-map/lib/source-map-generator.js +425 -0
  987. package/node_modules/source-map/lib/source-node.js +413 -0
  988. package/node_modules/source-map/lib/util.js +488 -0
  989. package/node_modules/source-map/package.json +77 -0
  990. package/node_modules/source-map/source-map.d.ts +98 -0
  991. package/node_modules/source-map/source-map.js +8 -0
  992. package/node_modules/source-map-support/LICENSE.md +21 -0
  993. package/node_modules/source-map-support/README.md +284 -0
  994. package/node_modules/source-map-support/browser-source-map-support.js +113 -0
  995. package/node_modules/source-map-support/package.json +35 -0
  996. package/node_modules/source-map-support/register.js +1 -0
  997. package/node_modules/source-map-support/source-map-support.js +567 -0
  998. package/node_modules/string-width/index.js +39 -0
  999. package/node_modules/string-width/license +9 -0
  1000. package/node_modules/string-width/package.json +60 -0
  1001. package/node_modules/string-width/readme.md +45 -0
  1002. package/node_modules/string_decoder/LICENSE +48 -0
  1003. package/node_modules/string_decoder/README.md +47 -0
  1004. package/node_modules/string_decoder/lib/string_decoder.js +296 -0
  1005. package/node_modules/string_decoder/package.json +38 -0
  1006. package/node_modules/strip-ansi/index.d.ts +15 -0
  1007. package/node_modules/strip-ansi/index.js +7 -0
  1008. package/node_modules/strip-ansi/license +9 -0
  1009. package/node_modules/strip-ansi/package.json +58 -0
  1010. package/node_modules/strip-ansi/readme.md +61 -0
  1011. package/node_modules/strip-eof/index.js +15 -0
  1012. package/node_modules/strip-eof/license +21 -0
  1013. package/node_modules/strip-eof/package.json +43 -0
  1014. package/node_modules/strip-eof/readme.md +28 -0
  1015. package/node_modules/strip-hex-prefix/.editorconfig +7 -0
  1016. package/node_modules/strip-hex-prefix/.gitattributes +106 -0
  1017. package/node_modules/strip-hex-prefix/.npmignore +8 -0
  1018. package/node_modules/strip-hex-prefix/.travis.yml +5 -0
  1019. package/node_modules/strip-hex-prefix/CHANGELOG.md +7 -0
  1020. package/node_modules/strip-hex-prefix/LICENSE +21 -0
  1021. package/node_modules/strip-hex-prefix/README.md +106 -0
  1022. package/node_modules/strip-hex-prefix/package.json +46 -0
  1023. package/node_modules/strip-hex-prefix/src/index.js +14 -0
  1024. package/node_modules/strip-hex-prefix/src/tests/test.index.js +47 -0
  1025. package/node_modules/util-deprecate/History.md +16 -0
  1026. package/node_modules/util-deprecate/LICENSE +24 -0
  1027. package/node_modules/util-deprecate/README.md +53 -0
  1028. package/node_modules/util-deprecate/browser.js +67 -0
  1029. package/node_modules/util-deprecate/node.js +6 -0
  1030. package/node_modules/util-deprecate/package.json +31 -0
  1031. package/node_modules/which/LICENSE +15 -0
  1032. package/node_modules/which/README.md +51 -0
  1033. package/node_modules/which/bin/which +52 -0
  1034. package/node_modules/which/package.json +34 -0
  1035. package/node_modules/which/which.js +135 -0
  1036. package/node_modules/which-module/LICENSE +13 -0
  1037. package/node_modules/which-module/README.md +55 -0
  1038. package/node_modules/which-module/index.js +9 -0
  1039. package/node_modules/which-module/package.json +45 -0
  1040. package/node_modules/wrap-ansi/index.js +188 -0
  1041. package/node_modules/wrap-ansi/license +9 -0
  1042. package/node_modules/wrap-ansi/package.json +65 -0
  1043. package/node_modules/wrap-ansi/readme.md +108 -0
  1044. package/node_modules/wrappy/LICENSE +15 -0
  1045. package/node_modules/wrappy/README.md +36 -0
  1046. package/node_modules/wrappy/package.json +33 -0
  1047. package/node_modules/wrappy/wrappy.js +33 -0
  1048. package/node_modules/y18n/LICENSE +13 -0
  1049. package/node_modules/y18n/README.md +109 -0
  1050. package/node_modules/y18n/index.js +188 -0
  1051. package/node_modules/y18n/package.json +43 -0
  1052. package/node_modules/yargs/LICENSE +22 -0
  1053. package/node_modules/yargs/README.md +122 -0
  1054. package/node_modules/yargs/index.js +32 -0
  1055. package/node_modules/yargs/lib/apply-extends.js +53 -0
  1056. package/node_modules/yargs/lib/argsert.js +68 -0
  1057. package/node_modules/yargs/lib/command.js +437 -0
  1058. package/node_modules/yargs/lib/completion-templates.js +49 -0
  1059. package/node_modules/yargs/lib/completion.js +115 -0
  1060. package/node_modules/yargs/lib/decamelize.js +32 -0
  1061. package/node_modules/yargs/lib/is-promise.js +3 -0
  1062. package/node_modules/yargs/lib/levenshtein.js +58 -0
  1063. package/node_modules/yargs/lib/middleware.js +65 -0
  1064. package/node_modules/yargs/lib/obj-filter.js +11 -0
  1065. package/node_modules/yargs/lib/usage.js +540 -0
  1066. package/node_modules/yargs/lib/validation.js +341 -0
  1067. package/node_modules/yargs/lib/yerror.js +11 -0
  1068. package/node_modules/yargs/locales/be.json +39 -0
  1069. package/node_modules/yargs/locales/de.json +39 -0
  1070. package/node_modules/yargs/locales/en.json +42 -0
  1071. package/node_modules/yargs/locales/es.json +39 -0
  1072. package/node_modules/yargs/locales/fr.json +37 -0
  1073. package/node_modules/yargs/locales/hi.json +42 -0
  1074. package/node_modules/yargs/locales/hu.json +39 -0
  1075. package/node_modules/yargs/locales/id.json +43 -0
  1076. package/node_modules/yargs/locales/it.json +39 -0
  1077. package/node_modules/yargs/locales/ja.json +42 -0
  1078. package/node_modules/yargs/locales/ko.json +42 -0
  1079. package/node_modules/yargs/locales/nb.json +37 -0
  1080. package/node_modules/yargs/locales/nl.json +42 -0
  1081. package/node_modules/yargs/locales/nn.json +39 -0
  1082. package/node_modules/yargs/locales/pirate.json +13 -0
  1083. package/node_modules/yargs/locales/pl.json +42 -0
  1084. package/node_modules/yargs/locales/pt.json +38 -0
  1085. package/node_modules/yargs/locales/pt_BR.json +42 -0
  1086. package/node_modules/yargs/locales/ru.json +39 -0
  1087. package/node_modules/yargs/locales/th.json +39 -0
  1088. package/node_modules/yargs/locales/tr.json +41 -0
  1089. package/node_modules/yargs/locales/zh_CN.json +41 -0
  1090. package/node_modules/yargs/locales/zh_TW.json +40 -0
  1091. package/node_modules/yargs/package.json +83 -0
  1092. package/node_modules/yargs/yargs.js +1205 -0
  1093. package/node_modules/yargs-parser/LICENSE.txt +14 -0
  1094. package/node_modules/yargs-parser/README.md +396 -0
  1095. package/node_modules/yargs-parser/index.js +916 -0
  1096. package/node_modules/yargs-parser/lib/tokenize-arg-string.js +40 -0
  1097. package/node_modules/yargs-parser/package.json +51 -0
  1098. package/package.json +73 -4
@@ -0,0 +1,2173 @@
1
+ #ifndef SRC_NAPI_H_
2
+ #define SRC_NAPI_H_
3
+
4
+ #include <node_api.h>
5
+ #include <functional>
6
+ #include <initializer_list>
7
+ #include <memory>
8
+ #include <mutex>
9
+ #include <string>
10
+ #include <vector>
11
+
12
+ // VS2015 RTM has bugs with constexpr, so require min of VS2015 Update 3 (known good version)
13
+ #if !defined(_MSC_VER) || _MSC_FULL_VER >= 190024210
14
+ #define NAPI_HAS_CONSTEXPR 1
15
+ #endif
16
+
17
+ // VS2013 does not support char16_t literal strings, so we'll work around it using wchar_t strings
18
+ // and casting them. This is safe as long as the character sizes are the same.
19
+ #if defined(_MSC_VER) && _MSC_VER <= 1800
20
+ static_assert(sizeof(char16_t) == sizeof(wchar_t), "Size mismatch between char16_t and wchar_t");
21
+ #define NAPI_WIDE_TEXT(x) reinterpret_cast<char16_t*>(L ## x)
22
+ #else
23
+ #define NAPI_WIDE_TEXT(x) u ## x
24
+ #endif
25
+
26
+ // If C++ exceptions are not explicitly enabled or disabled, enable them
27
+ // if exceptions were enabled in the compiler settings.
28
+ #if !defined(NAPI_CPP_EXCEPTIONS) && !defined(NAPI_DISABLE_CPP_EXCEPTIONS)
29
+ #if defined(_CPPUNWIND) || defined (__EXCEPTIONS)
30
+ #define NAPI_CPP_EXCEPTIONS
31
+ #else
32
+ #error Exception support not detected. \
33
+ Define either NAPI_CPP_EXCEPTIONS or NAPI_DISABLE_CPP_EXCEPTIONS.
34
+ #endif
35
+ #endif
36
+
37
+ #ifdef _NOEXCEPT
38
+ #define NAPI_NOEXCEPT _NOEXCEPT
39
+ #else
40
+ #define NAPI_NOEXCEPT noexcept
41
+ #endif
42
+
43
+ #ifdef NAPI_CPP_EXCEPTIONS
44
+
45
+ // When C++ exceptions are enabled, Errors are thrown directly. There is no need
46
+ // to return anything after the throw statements. The variadic parameter is an
47
+ // optional return value that is ignored.
48
+ // We need _VOID versions of the macros to avoid warnings resulting from
49
+ // leaving the NAPI_THROW_* `...` argument empty.
50
+
51
+ #define NAPI_THROW(e, ...) throw e
52
+ #define NAPI_THROW_VOID(e) throw e
53
+
54
+ #define NAPI_THROW_IF_FAILED(env, status, ...) \
55
+ if ((status) != napi_ok) throw Napi::Error::New(env);
56
+
57
+ #define NAPI_THROW_IF_FAILED_VOID(env, status) \
58
+ if ((status) != napi_ok) throw Napi::Error::New(env);
59
+
60
+ #else // NAPI_CPP_EXCEPTIONS
61
+
62
+ // When C++ exceptions are disabled, Errors are thrown as JavaScript exceptions,
63
+ // which are pending until the callback returns to JS. The variadic parameter
64
+ // is an optional return value; usually it is an empty result.
65
+ // We need _VOID versions of the macros to avoid warnings resulting from
66
+ // leaving the NAPI_THROW_* `...` argument empty.
67
+
68
+ #define NAPI_THROW(e, ...) \
69
+ do { \
70
+ (e).ThrowAsJavaScriptException(); \
71
+ return __VA_ARGS__; \
72
+ } while (0)
73
+
74
+ #define NAPI_THROW_VOID(e) \
75
+ do { \
76
+ (e).ThrowAsJavaScriptException(); \
77
+ return; \
78
+ } while (0)
79
+
80
+ #define NAPI_THROW_IF_FAILED(env, status, ...) \
81
+ if ((status) != napi_ok) { \
82
+ Napi::Error::New(env).ThrowAsJavaScriptException(); \
83
+ return __VA_ARGS__; \
84
+ }
85
+
86
+ #define NAPI_THROW_IF_FAILED_VOID(env, status) \
87
+ if ((status) != napi_ok) { \
88
+ Napi::Error::New(env).ThrowAsJavaScriptException(); \
89
+ return; \
90
+ }
91
+
92
+ #endif // NAPI_CPP_EXCEPTIONS
93
+
94
+ #define NAPI_FATAL_IF_FAILED(status, location, message) \
95
+ do { \
96
+ if ((status) != napi_ok) { \
97
+ Napi::Error::Fatal((location), (message)); \
98
+ } \
99
+ } while (0)
100
+
101
+ ////////////////////////////////////////////////////////////////////////////////
102
+ /// N-API C++ Wrapper Classes
103
+ ///
104
+ /// These classes wrap the "N-API" ABI-stable C APIs for Node.js, providing a
105
+ /// C++ object model and C++ exception-handling semantics with low overhead.
106
+ /// The wrappers are all header-only so that they do not affect the ABI.
107
+ ////////////////////////////////////////////////////////////////////////////////
108
+ namespace Napi {
109
+
110
+ // Forward declarations
111
+ class Env;
112
+ class Value;
113
+ class Boolean;
114
+ class Number;
115
+ // Currently experimental guard with the definition of NAPI_EXPERIMENTAL.
116
+ // Once it is no longer experimental guard with the NAPI_VERSION in which it is
117
+ // released instead.
118
+ #ifdef NAPI_EXPERIMENTAL
119
+ class BigInt;
120
+ #endif // NAPI_EXPERIMENTAL
121
+ #if (NAPI_VERSION > 4)
122
+ class Date;
123
+ #endif
124
+ class String;
125
+ class Object;
126
+ class Array;
127
+ class Function;
128
+ template <typename T> class Buffer;
129
+ class Error;
130
+ class PropertyDescriptor;
131
+ class CallbackInfo;
132
+ template <typename T> class Reference;
133
+ class TypedArray;
134
+ template <typename T> class TypedArrayOf;
135
+
136
+ typedef TypedArrayOf<int8_t> Int8Array; ///< Typed-array of signed 8-bit integers
137
+ typedef TypedArrayOf<uint8_t> Uint8Array; ///< Typed-array of unsigned 8-bit integers
138
+ typedef TypedArrayOf<int16_t> Int16Array; ///< Typed-array of signed 16-bit integers
139
+ typedef TypedArrayOf<uint16_t> Uint16Array; ///< Typed-array of unsigned 16-bit integers
140
+ typedef TypedArrayOf<int32_t> Int32Array; ///< Typed-array of signed 32-bit integers
141
+ typedef TypedArrayOf<uint32_t> Uint32Array; ///< Typed-array of unsigned 32-bit integers
142
+ typedef TypedArrayOf<float> Float32Array; ///< Typed-array of 32-bit floating-point values
143
+ typedef TypedArrayOf<double> Float64Array; ///< Typed-array of 64-bit floating-point values
144
+ // Currently experimental guard with the definition of NAPI_EXPERIMENTAL.
145
+ // Once it is no longer experimental guard with the NAPI_VERSION in which it is
146
+ // released instead.
147
+ #ifdef NAPI_EXPERIMENTAL
148
+ typedef TypedArrayOf<int64_t> BigInt64Array; ///< Typed array of signed 64-bit integers
149
+ typedef TypedArrayOf<uint64_t> BigUint64Array; ///< Typed array of unsigned 64-bit integers
150
+ #endif // NAPI_EXPERIMENTAL
151
+
152
+ /// Defines the signature of a N-API C++ module's registration callback (init) function.
153
+ typedef Object (*ModuleRegisterCallback)(Env env, Object exports);
154
+
155
+ class MemoryManagement;
156
+
157
+ /// Environment for N-API values and operations.
158
+ ///
159
+ /// All N-API values and operations must be associated with an environment. An environment
160
+ /// instance is always provided to callback functions; that environment must then be used for any
161
+ /// creation of N-API values or other N-API operations within the callback. (Many methods infer
162
+ /// the environment from the `this` instance that the method is called on.)
163
+ ///
164
+ /// In the future, multiple environments per process may be supported, although current
165
+ /// implementations only support one environment per process.
166
+ ///
167
+ /// In the V8 JavaScript engine, a N-API environment approximately corresponds to an Isolate.
168
+ class Env {
169
+ public:
170
+ Env(napi_env env);
171
+
172
+ operator napi_env() const;
173
+
174
+ Object Global() const;
175
+ Value Undefined() const;
176
+ Value Null() const;
177
+
178
+ bool IsExceptionPending() const;
179
+ Error GetAndClearPendingException();
180
+
181
+ private:
182
+ napi_env _env;
183
+ };
184
+
185
+ /// A JavaScript value of unknown type.
186
+ ///
187
+ /// For type-specific operations, convert to one of the Value subclasses using a `To*` or `As()`
188
+ /// method. The `To*` methods do type coercion; the `As()` method does not.
189
+ ///
190
+ /// Napi::Value value = ...
191
+ /// if (!value.IsString()) throw Napi::TypeError::New(env, "Invalid arg...");
192
+ /// Napi::String str = value.As<Napi::String>(); // Cast to a string value
193
+ ///
194
+ /// Napi::Value anotherValue = ...
195
+ /// bool isTruthy = anotherValue.ToBoolean(); // Coerce to a boolean value
196
+ class Value {
197
+ public:
198
+ Value(); ///< Creates a new _empty_ Value instance.
199
+ Value(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
200
+
201
+ /// Creates a JS value from a C++ primitive.
202
+ ///
203
+ /// `value` may be any of:
204
+ /// - bool
205
+ /// - Any integer type
206
+ /// - Any floating point type
207
+ /// - const char* (encoded using UTF-8, null-terminated)
208
+ /// - const char16_t* (encoded using UTF-16-LE, null-terminated)
209
+ /// - std::string (encoded using UTF-8)
210
+ /// - std::u16string
211
+ /// - napi::Value
212
+ /// - napi_value
213
+ template <typename T>
214
+ static Value From(napi_env env, const T& value);
215
+
216
+ /// Converts to a N-API value primitive.
217
+ ///
218
+ /// If the instance is _empty_, this returns `nullptr`.
219
+ operator napi_value() const;
220
+
221
+ /// Tests if this value strictly equals another value.
222
+ bool operator ==(const Value& other) const;
223
+
224
+ /// Tests if this value does not strictly equal another value.
225
+ bool operator !=(const Value& other) const;
226
+
227
+ /// Tests if this value strictly equals another value.
228
+ bool StrictEquals(const Value& other) const;
229
+
230
+ /// Gets the environment the value is associated with.
231
+ Napi::Env Env() const;
232
+
233
+ /// Checks if the value is empty (uninitialized).
234
+ ///
235
+ /// An empty value is invalid, and most attempts to perform an operation on an empty value
236
+ /// will result in an exception. Note an empty value is distinct from JavaScript `null` or
237
+ /// `undefined`, which are valid values.
238
+ ///
239
+ /// When C++ exceptions are disabled at compile time, a method with a `Value` return type may
240
+ /// return an empty value to indicate a pending exception. So when not using C++ exceptions,
241
+ /// callers should check whether the value is empty before attempting to use it.
242
+ bool IsEmpty() const;
243
+
244
+ napi_valuetype Type() const; ///< Gets the type of the value.
245
+
246
+ bool IsUndefined() const; ///< Tests if a value is an undefined JavaScript value.
247
+ bool IsNull() const; ///< Tests if a value is a null JavaScript value.
248
+ bool IsBoolean() const; ///< Tests if a value is a JavaScript boolean.
249
+ bool IsNumber() const; ///< Tests if a value is a JavaScript number.
250
+ // Currently experimental guard with the definition of NAPI_EXPERIMENTAL.
251
+ // Once it is no longer experimental guard with the NAPI_VERSION in which it is
252
+ // released instead.
253
+ #ifdef NAPI_EXPERIMENTAL
254
+ bool IsBigInt() const; ///< Tests if a value is a JavaScript bigint.
255
+ #endif // NAPI_EXPERIMENTAL
256
+ #if (NAPI_VERSION > 4)
257
+ bool IsDate() const; ///< Tests if a value is a JavaScript date.
258
+ #endif
259
+ bool IsString() const; ///< Tests if a value is a JavaScript string.
260
+ bool IsSymbol() const; ///< Tests if a value is a JavaScript symbol.
261
+ bool IsArray() const; ///< Tests if a value is a JavaScript array.
262
+ bool IsArrayBuffer() const; ///< Tests if a value is a JavaScript array buffer.
263
+ bool IsTypedArray() const; ///< Tests if a value is a JavaScript typed array.
264
+ bool IsObject() const; ///< Tests if a value is a JavaScript object.
265
+ bool IsFunction() const; ///< Tests if a value is a JavaScript function.
266
+ bool IsPromise() const; ///< Tests if a value is a JavaScript promise.
267
+ bool IsDataView() const; ///< Tests if a value is a JavaScript data view.
268
+ bool IsBuffer() const; ///< Tests if a value is a Node buffer.
269
+ bool IsExternal() const; ///< Tests if a value is a pointer to external data.
270
+
271
+ /// Casts to another type of `Napi::Value`, when the actual type is known or assumed.
272
+ ///
273
+ /// This conversion does NOT coerce the type. Calling any methods inappropriate for the actual
274
+ /// value type will throw `Napi::Error`.
275
+ template <typename T> T As() const;
276
+
277
+ Boolean ToBoolean() const; ///< Coerces a value to a JavaScript boolean.
278
+ Number ToNumber() const; ///< Coerces a value to a JavaScript number.
279
+ String ToString() const; ///< Coerces a value to a JavaScript string.
280
+ Object ToObject() const; ///< Coerces a value to a JavaScript object.
281
+
282
+ protected:
283
+ /// !cond INTERNAL
284
+ napi_env _env;
285
+ napi_value _value;
286
+ /// !endcond
287
+ };
288
+
289
+ /// A JavaScript boolean value.
290
+ class Boolean : public Value {
291
+ public:
292
+ static Boolean New(
293
+ napi_env env, ///< N-API environment
294
+ bool value ///< Boolean value
295
+ );
296
+
297
+ Boolean(); ///< Creates a new _empty_ Boolean instance.
298
+ Boolean(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
299
+
300
+ operator bool() const; ///< Converts a Boolean value to a boolean primitive.
301
+ bool Value() const; ///< Converts a Boolean value to a boolean primitive.
302
+ };
303
+
304
+ /// A JavaScript number value.
305
+ class Number : public Value {
306
+ public:
307
+ static Number New(
308
+ napi_env env, ///< N-API environment
309
+ double value ///< Number value
310
+ );
311
+
312
+ Number(); ///< Creates a new _empty_ Number instance.
313
+ Number(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
314
+
315
+ operator int32_t() const; ///< Converts a Number value to a 32-bit signed integer value.
316
+ operator uint32_t() const; ///< Converts a Number value to a 32-bit unsigned integer value.
317
+ operator int64_t() const; ///< Converts a Number value to a 64-bit signed integer value.
318
+ operator float() const; ///< Converts a Number value to a 32-bit floating-point value.
319
+ operator double() const; ///< Converts a Number value to a 64-bit floating-point value.
320
+
321
+ int32_t Int32Value() const; ///< Converts a Number value to a 32-bit signed integer value.
322
+ uint32_t Uint32Value() const; ///< Converts a Number value to a 32-bit unsigned integer value.
323
+ int64_t Int64Value() const; ///< Converts a Number value to a 64-bit signed integer value.
324
+ float FloatValue() const; ///< Converts a Number value to a 32-bit floating-point value.
325
+ double DoubleValue() const; ///< Converts a Number value to a 64-bit floating-point value.
326
+ };
327
+
328
+ // Currently experimental guard with the definition of NAPI_EXPERIMENTAL.
329
+ // Once it is no longer experimental guard with the NAPI_VERSION in which it is
330
+ // released instead.
331
+ #ifdef NAPI_EXPERIMENTAL
332
+ /// A JavaScript bigint value.
333
+ class BigInt : public Value {
334
+ public:
335
+ static BigInt New(
336
+ napi_env env, ///< N-API environment
337
+ int64_t value ///< Number value
338
+ );
339
+ static BigInt New(
340
+ napi_env env, ///< N-API environment
341
+ uint64_t value ///< Number value
342
+ );
343
+
344
+ /// Creates a new BigInt object using a specified sign bit and a
345
+ /// specified list of digits/words.
346
+ /// The resulting number is calculated as:
347
+ /// (-1)^sign_bit * (words[0] * (2^64)^0 + words[1] * (2^64)^1 + ...)
348
+ static BigInt New(
349
+ napi_env env, ///< N-API environment
350
+ int sign_bit, ///< Sign bit. 1 if negative.
351
+ size_t word_count, ///< Number of words in array
352
+ const uint64_t* words ///< Array of words
353
+ );
354
+
355
+ BigInt(); ///< Creates a new _empty_ BigInt instance.
356
+ BigInt(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
357
+
358
+ int64_t Int64Value(bool* lossless) const; ///< Converts a BigInt value to a 64-bit signed integer value.
359
+ uint64_t Uint64Value(bool* lossless) const; ///< Converts a BigInt value to a 64-bit unsigned integer value.
360
+
361
+ size_t WordCount() const; ///< The number of 64-bit words needed to store the result of ToWords().
362
+
363
+ /// Writes the contents of this BigInt to a specified memory location.
364
+ /// `sign_bit` must be provided and will be set to 1 if this BigInt is negative.
365
+ /// `*word_count` has to be initialized to the length of the `words` array.
366
+ /// Upon return, it will be set to the actual number of words that would
367
+ /// be needed to store this BigInt (i.e. the return value of `WordCount()`).
368
+ void ToWords(int* sign_bit, size_t* word_count, uint64_t* words);
369
+ };
370
+ #endif // NAPI_EXPERIMENTAL
371
+
372
+ #if (NAPI_VERSION > 4)
373
+ /// A JavaScript date value.
374
+ class Date : public Value {
375
+ public:
376
+ /// Creates a new Date value from a double primitive.
377
+ static Date New(
378
+ napi_env env, ///< N-API environment
379
+ double value ///< Number value
380
+ );
381
+
382
+ Date(); ///< Creates a new _empty_ Date instance.
383
+ Date(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
384
+ operator double() const; ///< Converts a Date value to double primitive
385
+
386
+ double ValueOf() const; ///< Converts a Date value to a double primitive.
387
+ };
388
+ #endif
389
+
390
+ /// A JavaScript string or symbol value (that can be used as a property name).
391
+ class Name : public Value {
392
+ public:
393
+ Name(); ///< Creates a new _empty_ Name instance.
394
+ Name(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
395
+ };
396
+
397
+ /// A JavaScript string value.
398
+ class String : public Name {
399
+ public:
400
+ /// Creates a new String value from a UTF-8 encoded C++ string.
401
+ static String New(
402
+ napi_env env, ///< N-API environment
403
+ const std::string& value ///< UTF-8 encoded C++ string
404
+ );
405
+
406
+ /// Creates a new String value from a UTF-16 encoded C++ string.
407
+ static String New(
408
+ napi_env env, ///< N-API environment
409
+ const std::u16string& value ///< UTF-16 encoded C++ string
410
+ );
411
+
412
+ /// Creates a new String value from a UTF-8 encoded C string.
413
+ static String New(
414
+ napi_env env, ///< N-API environment
415
+ const char* value ///< UTF-8 encoded null-terminated C string
416
+ );
417
+
418
+ /// Creates a new String value from a UTF-16 encoded C string.
419
+ static String New(
420
+ napi_env env, ///< N-API environment
421
+ const char16_t* value ///< UTF-16 encoded null-terminated C string
422
+ );
423
+
424
+ /// Creates a new String value from a UTF-8 encoded C string with specified length.
425
+ static String New(
426
+ napi_env env, ///< N-API environment
427
+ const char* value, ///< UTF-8 encoded C string (not necessarily null-terminated)
428
+ size_t length ///< length of the string in bytes
429
+ );
430
+
431
+ /// Creates a new String value from a UTF-16 encoded C string with specified length.
432
+ static String New(
433
+ napi_env env, ///< N-API environment
434
+ const char16_t* value, ///< UTF-16 encoded C string (not necessarily null-terminated)
435
+ size_t length ///< Length of the string in 2-byte code units
436
+ );
437
+
438
+ /// Creates a new String based on the original object's type.
439
+ ///
440
+ /// `value` may be any of:
441
+ /// - const char* (encoded using UTF-8, null-terminated)
442
+ /// - const char16_t* (encoded using UTF-16-LE, null-terminated)
443
+ /// - std::string (encoded using UTF-8)
444
+ /// - std::u16string
445
+ template <typename T>
446
+ static String From(napi_env env, const T& value);
447
+
448
+ String(); ///< Creates a new _empty_ String instance.
449
+ String(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
450
+
451
+ operator std::string() const; ///< Converts a String value to a UTF-8 encoded C++ string.
452
+ operator std::u16string() const; ///< Converts a String value to a UTF-16 encoded C++ string.
453
+ std::string Utf8Value() const; ///< Converts a String value to a UTF-8 encoded C++ string.
454
+ std::u16string Utf16Value() const; ///< Converts a String value to a UTF-16 encoded C++ string.
455
+ };
456
+
457
+ /// A JavaScript symbol value.
458
+ class Symbol : public Name {
459
+ public:
460
+ /// Creates a new Symbol value with an optional description.
461
+ static Symbol New(
462
+ napi_env env, ///< N-API environment
463
+ const char* description = nullptr ///< Optional UTF-8 encoded null-terminated C string
464
+ /// describing the symbol
465
+ );
466
+
467
+ /// Creates a new Symbol value with a description.
468
+ static Symbol New(
469
+ napi_env env, ///< N-API environment
470
+ const std::string& description ///< UTF-8 encoded C++ string describing the symbol
471
+ );
472
+
473
+ /// Creates a new Symbol value with a description.
474
+ static Symbol New(
475
+ napi_env env, ///< N-API environment
476
+ String description ///< String value describing the symbol
477
+ );
478
+
479
+ /// Creates a new Symbol value with a description.
480
+ static Symbol New(
481
+ napi_env env, ///< N-API environment
482
+ napi_value description ///< String value describing the symbol
483
+ );
484
+
485
+ /// Get a public Symbol (e.g. Symbol.iterator).
486
+ static Symbol WellKnown(napi_env, const std::string& name);
487
+
488
+ Symbol(); ///< Creates a new _empty_ Symbol instance.
489
+ Symbol(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
490
+ };
491
+
492
+ /// A JavaScript object value.
493
+ class Object : public Value {
494
+ public:
495
+ /// Enables property and element assignments using indexing syntax.
496
+ ///
497
+ /// Example:
498
+ ///
499
+ /// Napi::Value propertyValue = object1['A'];
500
+ /// object2['A'] = propertyValue;
501
+ /// Napi::Value elementValue = array[0];
502
+ /// array[1] = elementValue;
503
+ template <typename Key>
504
+ class PropertyLValue {
505
+ public:
506
+ /// Converts an L-value to a value.
507
+ operator Value() const;
508
+
509
+ /// Assigns a value to the property. The type of value can be
510
+ /// anything supported by `Object::Set`.
511
+ template <typename ValueType>
512
+ PropertyLValue& operator =(ValueType value);
513
+
514
+ private:
515
+ PropertyLValue() = delete;
516
+ PropertyLValue(Object object, Key key);
517
+ napi_env _env;
518
+ napi_value _object;
519
+ Key _key;
520
+
521
+ friend class Napi::Object;
522
+ };
523
+
524
+ /// Creates a new Object value.
525
+ static Object New(
526
+ napi_env env ///< N-API environment
527
+ );
528
+
529
+ Object(); ///< Creates a new _empty_ Object instance.
530
+ Object(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
531
+
532
+ /// Gets or sets a named property.
533
+ PropertyLValue<std::string> operator [](
534
+ const char* utf8name ///< UTF-8 encoded null-terminated property name
535
+ );
536
+
537
+ /// Gets or sets a named property.
538
+ PropertyLValue<std::string> operator [](
539
+ const std::string& utf8name ///< UTF-8 encoded property name
540
+ );
541
+
542
+ /// Gets or sets an indexed property or array element.
543
+ PropertyLValue<uint32_t> operator [](
544
+ uint32_t index /// Property / element index
545
+ );
546
+
547
+ /// Gets a named property.
548
+ Value operator [](
549
+ const char* utf8name ///< UTF-8 encoded null-terminated property name
550
+ ) const;
551
+
552
+ /// Gets a named property.
553
+ Value operator [](
554
+ const std::string& utf8name ///< UTF-8 encoded property name
555
+ ) const;
556
+
557
+ /// Gets an indexed property or array element.
558
+ Value operator [](
559
+ uint32_t index ///< Property / element index
560
+ ) const;
561
+
562
+ /// Checks whether a property is present.
563
+ bool Has(
564
+ napi_value key ///< Property key primitive
565
+ ) const;
566
+
567
+ /// Checks whether a property is present.
568
+ bool Has(
569
+ Value key ///< Property key
570
+ ) const;
571
+
572
+ /// Checks whether a named property is present.
573
+ bool Has(
574
+ const char* utf8name ///< UTF-8 encoded null-terminated property name
575
+ ) const;
576
+
577
+ /// Checks whether a named property is present.
578
+ bool Has(
579
+ const std::string& utf8name ///< UTF-8 encoded property name
580
+ ) const;
581
+
582
+ /// Checks whether a own property is present.
583
+ bool HasOwnProperty(
584
+ napi_value key ///< Property key primitive
585
+ ) const;
586
+
587
+ /// Checks whether a own property is present.
588
+ bool HasOwnProperty(
589
+ Value key ///< Property key
590
+ ) const;
591
+
592
+ /// Checks whether a own property is present.
593
+ bool HasOwnProperty(
594
+ const char* utf8name ///< UTF-8 encoded null-terminated property name
595
+ ) const;
596
+
597
+ /// Checks whether a own property is present.
598
+ bool HasOwnProperty(
599
+ const std::string& utf8name ///< UTF-8 encoded property name
600
+ ) const;
601
+
602
+ /// Gets a property.
603
+ Value Get(
604
+ napi_value key ///< Property key primitive
605
+ ) const;
606
+
607
+ /// Gets a property.
608
+ Value Get(
609
+ Value key ///< Property key
610
+ ) const;
611
+
612
+ /// Gets a named property.
613
+ Value Get(
614
+ const char* utf8name ///< UTF-8 encoded null-terminated property name
615
+ ) const;
616
+
617
+ /// Gets a named property.
618
+ Value Get(
619
+ const std::string& utf8name ///< UTF-8 encoded property name
620
+ ) const;
621
+
622
+ /// Sets a property.
623
+ template <typename ValueType>
624
+ void Set(
625
+ napi_value key, ///< Property key primitive
626
+ const ValueType& value ///< Property value primitive
627
+ );
628
+
629
+ /// Sets a property.
630
+ template <typename ValueType>
631
+ void Set(
632
+ Value key, ///< Property key
633
+ const ValueType& value ///< Property value
634
+ );
635
+
636
+ /// Sets a named property.
637
+ template <typename ValueType>
638
+ void Set(
639
+ const char* utf8name, ///< UTF-8 encoded null-terminated property name
640
+ const ValueType& value
641
+ );
642
+
643
+ /// Sets a named property.
644
+ template <typename ValueType>
645
+ void Set(
646
+ const std::string& utf8name, ///< UTF-8 encoded property name
647
+ const ValueType& value ///< Property value primitive
648
+ );
649
+
650
+ /// Delete property.
651
+ bool Delete(
652
+ napi_value key ///< Property key primitive
653
+ );
654
+
655
+ /// Delete property.
656
+ bool Delete(
657
+ Value key ///< Property key
658
+ );
659
+
660
+ /// Delete property.
661
+ bool Delete(
662
+ const char* utf8name ///< UTF-8 encoded null-terminated property name
663
+ );
664
+
665
+ /// Delete property.
666
+ bool Delete(
667
+ const std::string& utf8name ///< UTF-8 encoded property name
668
+ );
669
+
670
+ /// Checks whether an indexed property is present.
671
+ bool Has(
672
+ uint32_t index ///< Property / element index
673
+ ) const;
674
+
675
+ /// Gets an indexed property or array element.
676
+ Value Get(
677
+ uint32_t index ///< Property / element index
678
+ ) const;
679
+
680
+ /// Sets an indexed property or array element.
681
+ template <typename ValueType>
682
+ void Set(
683
+ uint32_t index, ///< Property / element index
684
+ const ValueType& value ///< Property value primitive
685
+ );
686
+
687
+ /// Deletes an indexed property or array element.
688
+ bool Delete(
689
+ uint32_t index ///< Property / element index
690
+ );
691
+
692
+ Array GetPropertyNames() const; ///< Get all property names
693
+
694
+ /// Defines a property on the object.
695
+ void DefineProperty(
696
+ const PropertyDescriptor& property ///< Descriptor for the property to be defined
697
+ );
698
+
699
+ /// Defines properties on the object.
700
+ void DefineProperties(
701
+ const std::initializer_list<PropertyDescriptor>& properties
702
+ ///< List of descriptors for the properties to be defined
703
+ );
704
+
705
+ /// Defines properties on the object.
706
+ void DefineProperties(
707
+ const std::vector<PropertyDescriptor>& properties
708
+ ///< Vector of descriptors for the properties to be defined
709
+ );
710
+
711
+ /// Checks if an object is an instance created by a constructor function.
712
+ ///
713
+ /// This is equivalent to the JavaScript `instanceof` operator.
714
+ bool InstanceOf(
715
+ const Function& constructor ///< Constructor function
716
+ ) const;
717
+
718
+ template <typename Finalizer, typename T>
719
+ inline void AddFinalizer(Finalizer finalizeCallback, T* data);
720
+
721
+ template <typename Finalizer, typename T, typename Hint>
722
+ inline void AddFinalizer(Finalizer finalizeCallback,
723
+ T* data,
724
+ Hint* finalizeHint);
725
+ };
726
+
727
+ template <typename T>
728
+ class External : public Value {
729
+ public:
730
+ static External New(napi_env env, T* data);
731
+
732
+ // Finalizer must implement `void operator()(Env env, T* data)`.
733
+ template <typename Finalizer>
734
+ static External New(napi_env env,
735
+ T* data,
736
+ Finalizer finalizeCallback);
737
+ // Finalizer must implement `void operator()(Env env, T* data, Hint* hint)`.
738
+ template <typename Finalizer, typename Hint>
739
+ static External New(napi_env env,
740
+ T* data,
741
+ Finalizer finalizeCallback,
742
+ Hint* finalizeHint);
743
+
744
+ External();
745
+ External(napi_env env, napi_value value);
746
+
747
+ T* Data() const;
748
+ };
749
+
750
+ class Array : public Object {
751
+ public:
752
+ static Array New(napi_env env);
753
+ static Array New(napi_env env, size_t length);
754
+
755
+ Array();
756
+ Array(napi_env env, napi_value value);
757
+
758
+ uint32_t Length() const;
759
+ };
760
+
761
+ /// A JavaScript array buffer value.
762
+ class ArrayBuffer : public Object {
763
+ public:
764
+ /// Creates a new ArrayBuffer instance over a new automatically-allocated buffer.
765
+ static ArrayBuffer New(
766
+ napi_env env, ///< N-API environment
767
+ size_t byteLength ///< Length of the buffer to be allocated, in bytes
768
+ );
769
+
770
+ /// Creates a new ArrayBuffer instance, using an external buffer with specified byte length.
771
+ static ArrayBuffer New(
772
+ napi_env env, ///< N-API environment
773
+ void* externalData, ///< Pointer to the external buffer to be used by the array
774
+ size_t byteLength ///< Length of the external buffer to be used by the array, in bytes
775
+ );
776
+
777
+ /// Creates a new ArrayBuffer instance, using an external buffer with specified byte length.
778
+ template <typename Finalizer>
779
+ static ArrayBuffer New(
780
+ napi_env env, ///< N-API environment
781
+ void* externalData, ///< Pointer to the external buffer to be used by the array
782
+ size_t byteLength, ///< Length of the external buffer to be used by the array,
783
+ /// in bytes
784
+ Finalizer finalizeCallback ///< Function to be called when the array buffer is destroyed;
785
+ /// must implement `void operator()(Env env, void* externalData)`
786
+ );
787
+
788
+ /// Creates a new ArrayBuffer instance, using an external buffer with specified byte length.
789
+ template <typename Finalizer, typename Hint>
790
+ static ArrayBuffer New(
791
+ napi_env env, ///< N-API environment
792
+ void* externalData, ///< Pointer to the external buffer to be used by the array
793
+ size_t byteLength, ///< Length of the external buffer to be used by the array,
794
+ /// in bytes
795
+ Finalizer finalizeCallback, ///< Function to be called when the array buffer is destroyed;
796
+ /// must implement `void operator()(Env env, void* externalData, Hint* hint)`
797
+ Hint* finalizeHint ///< Hint (second parameter) to be passed to the finalize callback
798
+ );
799
+
800
+ ArrayBuffer(); ///< Creates a new _empty_ ArrayBuffer instance.
801
+ ArrayBuffer(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
802
+
803
+ void* Data(); ///< Gets a pointer to the data buffer.
804
+ size_t ByteLength(); ///< Gets the length of the array buffer in bytes.
805
+
806
+ private:
807
+ mutable void* _data;
808
+ mutable size_t _length;
809
+
810
+ ArrayBuffer(napi_env env, napi_value value, void* data, size_t length);
811
+ void EnsureInfo() const;
812
+ };
813
+
814
+ /// A JavaScript typed-array value with unknown array type.
815
+ ///
816
+ /// For type-specific operations, cast to a `TypedArrayOf<T>` instance using the `As()`
817
+ /// method:
818
+ ///
819
+ /// Napi::TypedArray array = ...
820
+ /// if (t.TypedArrayType() == napi_int32_array) {
821
+ /// Napi::Int32Array int32Array = t.As<Napi::Int32Array>();
822
+ /// }
823
+ class TypedArray : public Object {
824
+ public:
825
+ TypedArray(); ///< Creates a new _empty_ TypedArray instance.
826
+ TypedArray(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
827
+
828
+ napi_typedarray_type TypedArrayType() const; ///< Gets the type of this typed-array.
829
+ Napi::ArrayBuffer ArrayBuffer() const; ///< Gets the backing array buffer.
830
+
831
+ uint8_t ElementSize() const; ///< Gets the size in bytes of one element in the array.
832
+ size_t ElementLength() const; ///< Gets the number of elements in the array.
833
+ size_t ByteOffset() const; ///< Gets the offset into the buffer where the array starts.
834
+ size_t ByteLength() const; ///< Gets the length of the array in bytes.
835
+
836
+ protected:
837
+ /// !cond INTERNAL
838
+ napi_typedarray_type _type;
839
+ size_t _length;
840
+
841
+ TypedArray(napi_env env, napi_value value, napi_typedarray_type type, size_t length);
842
+
843
+ static const napi_typedarray_type unknown_array_type = static_cast<napi_typedarray_type>(-1);
844
+
845
+ template <typename T>
846
+ static
847
+ #if defined(NAPI_HAS_CONSTEXPR)
848
+ constexpr
849
+ #endif
850
+ napi_typedarray_type TypedArrayTypeForPrimitiveType() {
851
+ return std::is_same<T, int8_t>::value ? napi_int8_array
852
+ : std::is_same<T, uint8_t>::value ? napi_uint8_array
853
+ : std::is_same<T, int16_t>::value ? napi_int16_array
854
+ : std::is_same<T, uint16_t>::value ? napi_uint16_array
855
+ : std::is_same<T, int32_t>::value ? napi_int32_array
856
+ : std::is_same<T, uint32_t>::value ? napi_uint32_array
857
+ : std::is_same<T, float>::value ? napi_float32_array
858
+ : std::is_same<T, double>::value ? napi_float64_array
859
+ // Currently experimental guard with the definition of NAPI_EXPERIMENTAL.
860
+ // Once it is no longer experimental guard with the NAPI_VERSION in which it is
861
+ // released instead.
862
+ #ifdef NAPI_EXPERIMENTAL
863
+ : std::is_same<T, int64_t>::value ? napi_bigint64_array
864
+ : std::is_same<T, uint64_t>::value ? napi_biguint64_array
865
+ #endif // NAPI_EXPERIMENTAL
866
+ : unknown_array_type;
867
+ }
868
+ /// !endcond
869
+ };
870
+
871
+ /// A JavaScript typed-array value with known array type.
872
+ ///
873
+ /// Note while it is possible to create and access Uint8 "clamped" arrays using this class,
874
+ /// the _clamping_ behavior is only applied in JavaScript.
875
+ template <typename T>
876
+ class TypedArrayOf : public TypedArray {
877
+ public:
878
+ /// Creates a new TypedArray instance over a new automatically-allocated array buffer.
879
+ ///
880
+ /// The array type parameter can normally be omitted (because it is inferred from the template
881
+ /// parameter T), except when creating a "clamped" array:
882
+ ///
883
+ /// Uint8Array::New(env, length, napi_uint8_clamped_array)
884
+ static TypedArrayOf New(
885
+ napi_env env, ///< N-API environment
886
+ size_t elementLength, ///< Length of the created array, as a number of elements
887
+ #if defined(NAPI_HAS_CONSTEXPR)
888
+ napi_typedarray_type type = TypedArray::TypedArrayTypeForPrimitiveType<T>()
889
+ #else
890
+ napi_typedarray_type type
891
+ #endif
892
+ ///< Type of array, if different from the default array type for the template parameter T.
893
+ );
894
+
895
+ /// Creates a new TypedArray instance over a provided array buffer.
896
+ ///
897
+ /// The array type parameter can normally be omitted (because it is inferred from the template
898
+ /// parameter T), except when creating a "clamped" array:
899
+ ///
900
+ /// Uint8Array::New(env, length, buffer, 0, napi_uint8_clamped_array)
901
+ static TypedArrayOf New(
902
+ napi_env env, ///< N-API environment
903
+ size_t elementLength, ///< Length of the created array, as a number of elements
904
+ Napi::ArrayBuffer arrayBuffer, ///< Backing array buffer instance to use
905
+ size_t bufferOffset, ///< Offset into the array buffer where the typed-array starts
906
+ #if defined(NAPI_HAS_CONSTEXPR)
907
+ napi_typedarray_type type = TypedArray::TypedArrayTypeForPrimitiveType<T>()
908
+ #else
909
+ napi_typedarray_type type
910
+ #endif
911
+ ///< Type of array, if different from the default array type for the template parameter T.
912
+ );
913
+
914
+ TypedArrayOf(); ///< Creates a new _empty_ TypedArrayOf instance.
915
+ TypedArrayOf(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
916
+
917
+ T& operator [](size_t index); ///< Gets or sets an element in the array.
918
+ const T& operator [](size_t index) const; ///< Gets an element in the array.
919
+
920
+ /// Gets a pointer to the array's backing buffer.
921
+ ///
922
+ /// This is not necessarily the same as the `ArrayBuffer::Data()` pointer, because the
923
+ /// typed-array may have a non-zero `ByteOffset()` into the `ArrayBuffer`.
924
+ T* Data();
925
+
926
+ /// Gets a pointer to the array's backing buffer.
927
+ ///
928
+ /// This is not necessarily the same as the `ArrayBuffer::Data()` pointer, because the
929
+ /// typed-array may have a non-zero `ByteOffset()` into the `ArrayBuffer`.
930
+ const T* Data() const;
931
+
932
+ private:
933
+ T* _data;
934
+
935
+ TypedArrayOf(napi_env env,
936
+ napi_value value,
937
+ napi_typedarray_type type,
938
+ size_t length,
939
+ T* data);
940
+ };
941
+
942
+ /// The DataView provides a low-level interface for reading/writing multiple
943
+ /// number types in an ArrayBuffer irrespective of the platform's endianness.
944
+ class DataView : public Object {
945
+ public:
946
+ static DataView New(napi_env env,
947
+ Napi::ArrayBuffer arrayBuffer);
948
+ static DataView New(napi_env env,
949
+ Napi::ArrayBuffer arrayBuffer,
950
+ size_t byteOffset);
951
+ static DataView New(napi_env env,
952
+ Napi::ArrayBuffer arrayBuffer,
953
+ size_t byteOffset,
954
+ size_t byteLength);
955
+
956
+ DataView(); ///< Creates a new _empty_ DataView instance.
957
+ DataView(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
958
+
959
+ Napi::ArrayBuffer ArrayBuffer() const; ///< Gets the backing array buffer.
960
+ size_t ByteOffset() const; ///< Gets the offset into the buffer where the array starts.
961
+ size_t ByteLength() const; ///< Gets the length of the array in bytes.
962
+
963
+ void* Data() const;
964
+
965
+ float GetFloat32(size_t byteOffset) const;
966
+ double GetFloat64(size_t byteOffset) const;
967
+ int8_t GetInt8(size_t byteOffset) const;
968
+ int16_t GetInt16(size_t byteOffset) const;
969
+ int32_t GetInt32(size_t byteOffset) const;
970
+ uint8_t GetUint8(size_t byteOffset) const;
971
+ uint16_t GetUint16(size_t byteOffset) const;
972
+ uint32_t GetUint32(size_t byteOffset) const;
973
+
974
+ void SetFloat32(size_t byteOffset, float value) const;
975
+ void SetFloat64(size_t byteOffset, double value) const;
976
+ void SetInt8(size_t byteOffset, int8_t value) const;
977
+ void SetInt16(size_t byteOffset, int16_t value) const;
978
+ void SetInt32(size_t byteOffset, int32_t value) const;
979
+ void SetUint8(size_t byteOffset, uint8_t value) const;
980
+ void SetUint16(size_t byteOffset, uint16_t value) const;
981
+ void SetUint32(size_t byteOffset, uint32_t value) const;
982
+
983
+ private:
984
+ template <typename T>
985
+ T ReadData(size_t byteOffset) const;
986
+
987
+ template <typename T>
988
+ void WriteData(size_t byteOffset, T value) const;
989
+
990
+ void* _data;
991
+ size_t _length;
992
+ };
993
+
994
+ class Function : public Object {
995
+ public:
996
+ /// Callable must implement operator() accepting a const CallbackInfo&
997
+ /// and return either void or Value.
998
+ template <typename Callable>
999
+ static Function New(napi_env env,
1000
+ Callable cb,
1001
+ const char* utf8name = nullptr,
1002
+ void* data = nullptr);
1003
+ /// Callable must implement operator() accepting a const CallbackInfo&
1004
+ /// and return either void or Value.
1005
+ template <typename Callable>
1006
+ static Function New(napi_env env,
1007
+ Callable cb,
1008
+ const std::string& utf8name,
1009
+ void* data = nullptr);
1010
+
1011
+ Function();
1012
+ Function(napi_env env, napi_value value);
1013
+
1014
+ Value operator ()(const std::initializer_list<napi_value>& args) const;
1015
+
1016
+ Value Call(const std::initializer_list<napi_value>& args) const;
1017
+ Value Call(const std::vector<napi_value>& args) const;
1018
+ Value Call(size_t argc, const napi_value* args) const;
1019
+ Value Call(napi_value recv, const std::initializer_list<napi_value>& args) const;
1020
+ Value Call(napi_value recv, const std::vector<napi_value>& args) const;
1021
+ Value Call(napi_value recv, size_t argc, const napi_value* args) const;
1022
+
1023
+ Value MakeCallback(napi_value recv,
1024
+ const std::initializer_list<napi_value>& args,
1025
+ napi_async_context context = nullptr) const;
1026
+ Value MakeCallback(napi_value recv,
1027
+ const std::vector<napi_value>& args,
1028
+ napi_async_context context = nullptr) const;
1029
+ Value MakeCallback(napi_value recv,
1030
+ size_t argc,
1031
+ const napi_value* args,
1032
+ napi_async_context context = nullptr) const;
1033
+
1034
+ Object New(const std::initializer_list<napi_value>& args) const;
1035
+ Object New(const std::vector<napi_value>& args) const;
1036
+ Object New(size_t argc, const napi_value* args) const;
1037
+ };
1038
+
1039
+ class Promise : public Object {
1040
+ public:
1041
+ class Deferred {
1042
+ public:
1043
+ static Deferred New(napi_env env);
1044
+ Deferred(napi_env env);
1045
+
1046
+ Napi::Promise Promise() const;
1047
+ Napi::Env Env() const;
1048
+
1049
+ void Resolve(napi_value value) const;
1050
+ void Reject(napi_value value) const;
1051
+
1052
+ private:
1053
+ napi_env _env;
1054
+ napi_deferred _deferred;
1055
+ napi_value _promise;
1056
+ };
1057
+
1058
+ Promise(napi_env env, napi_value value);
1059
+ };
1060
+
1061
+ template <typename T>
1062
+ class Buffer : public Uint8Array {
1063
+ public:
1064
+ static Buffer<T> New(napi_env env, size_t length);
1065
+ static Buffer<T> New(napi_env env, T* data, size_t length);
1066
+
1067
+ // Finalizer must implement `void operator()(Env env, T* data)`.
1068
+ template <typename Finalizer>
1069
+ static Buffer<T> New(napi_env env, T* data,
1070
+ size_t length,
1071
+ Finalizer finalizeCallback);
1072
+ // Finalizer must implement `void operator()(Env env, T* data, Hint* hint)`.
1073
+ template <typename Finalizer, typename Hint>
1074
+ static Buffer<T> New(napi_env env, T* data,
1075
+ size_t length,
1076
+ Finalizer finalizeCallback,
1077
+ Hint* finalizeHint);
1078
+
1079
+ static Buffer<T> Copy(napi_env env, const T* data, size_t length);
1080
+
1081
+ Buffer();
1082
+ Buffer(napi_env env, napi_value value);
1083
+ size_t Length() const;
1084
+ T* Data() const;
1085
+
1086
+ private:
1087
+ mutable size_t _length;
1088
+ mutable T* _data;
1089
+
1090
+ Buffer(napi_env env, napi_value value, size_t length, T* data);
1091
+ void EnsureInfo() const;
1092
+ };
1093
+
1094
+ /// Holds a counted reference to a value; initially a weak reference unless otherwise specified,
1095
+ /// may be changed to/from a strong reference by adjusting the refcount.
1096
+ ///
1097
+ /// The referenced value is not immediately destroyed when the reference count is zero; it is
1098
+ /// merely then eligible for garbage-collection if there are no other references to the value.
1099
+ template <typename T>
1100
+ class Reference {
1101
+ public:
1102
+ static Reference<T> New(const T& value, uint32_t initialRefcount = 0);
1103
+
1104
+ Reference();
1105
+ Reference(napi_env env, napi_ref ref);
1106
+ ~Reference();
1107
+
1108
+ // A reference can be moved but cannot be copied.
1109
+ Reference(Reference<T>&& other);
1110
+ Reference<T>& operator =(Reference<T>&& other);
1111
+ Reference<T>& operator =(Reference<T>&) = delete;
1112
+
1113
+ operator napi_ref() const;
1114
+ bool operator ==(const Reference<T> &other) const;
1115
+ bool operator !=(const Reference<T> &other) const;
1116
+
1117
+ Napi::Env Env() const;
1118
+ bool IsEmpty() const;
1119
+
1120
+ // Note when getting the value of a Reference it is usually correct to do so
1121
+ // within a HandleScope so that the value handle gets cleaned up efficiently.
1122
+ T Value() const;
1123
+
1124
+ uint32_t Ref();
1125
+ uint32_t Unref();
1126
+ void Reset();
1127
+ void Reset(const T& value, uint32_t refcount = 0);
1128
+
1129
+ // Call this on a reference that is declared as static data, to prevent its destructor
1130
+ // from running at program shutdown time, which would attempt to reset the reference when
1131
+ // the environment is no longer valid.
1132
+ void SuppressDestruct();
1133
+
1134
+ protected:
1135
+ Reference(const Reference<T>&);
1136
+
1137
+ /// !cond INTERNAL
1138
+ napi_env _env;
1139
+ napi_ref _ref;
1140
+ /// !endcond
1141
+
1142
+ private:
1143
+ bool _suppressDestruct;
1144
+ };
1145
+
1146
+ class ObjectReference: public Reference<Object> {
1147
+ public:
1148
+ ObjectReference();
1149
+ ObjectReference(napi_env env, napi_ref ref);
1150
+
1151
+ // A reference can be moved but cannot be copied.
1152
+ ObjectReference(Reference<Object>&& other);
1153
+ ObjectReference& operator =(Reference<Object>&& other);
1154
+ ObjectReference(ObjectReference&& other);
1155
+ ObjectReference& operator =(ObjectReference&& other);
1156
+ ObjectReference& operator =(ObjectReference&) = delete;
1157
+
1158
+ Napi::Value Get(const char* utf8name) const;
1159
+ Napi::Value Get(const std::string& utf8name) const;
1160
+ void Set(const char* utf8name, napi_value value);
1161
+ void Set(const char* utf8name, Napi::Value value);
1162
+ void Set(const char* utf8name, const char* utf8value);
1163
+ void Set(const char* utf8name, bool boolValue);
1164
+ void Set(const char* utf8name, double numberValue);
1165
+ void Set(const std::string& utf8name, napi_value value);
1166
+ void Set(const std::string& utf8name, Napi::Value value);
1167
+ void Set(const std::string& utf8name, std::string& utf8value);
1168
+ void Set(const std::string& utf8name, bool boolValue);
1169
+ void Set(const std::string& utf8name, double numberValue);
1170
+
1171
+ Napi::Value Get(uint32_t index) const;
1172
+ void Set(uint32_t index, const napi_value value);
1173
+ void Set(uint32_t index, const Napi::Value value);
1174
+ void Set(uint32_t index, const char* utf8value);
1175
+ void Set(uint32_t index, const std::string& utf8value);
1176
+ void Set(uint32_t index, bool boolValue);
1177
+ void Set(uint32_t index, double numberValue);
1178
+
1179
+ protected:
1180
+ ObjectReference(const ObjectReference&);
1181
+ };
1182
+
1183
+ class FunctionReference: public Reference<Function> {
1184
+ public:
1185
+ FunctionReference();
1186
+ FunctionReference(napi_env env, napi_ref ref);
1187
+
1188
+ // A reference can be moved but cannot be copied.
1189
+ FunctionReference(Reference<Function>&& other);
1190
+ FunctionReference& operator =(Reference<Function>&& other);
1191
+ FunctionReference(FunctionReference&& other);
1192
+ FunctionReference& operator =(FunctionReference&& other);
1193
+ FunctionReference(const FunctionReference&) = delete;
1194
+ FunctionReference& operator =(FunctionReference&) = delete;
1195
+
1196
+ Napi::Value operator ()(const std::initializer_list<napi_value>& args) const;
1197
+
1198
+ Napi::Value Call(const std::initializer_list<napi_value>& args) const;
1199
+ Napi::Value Call(const std::vector<napi_value>& args) const;
1200
+ Napi::Value Call(napi_value recv, const std::initializer_list<napi_value>& args) const;
1201
+ Napi::Value Call(napi_value recv, const std::vector<napi_value>& args) const;
1202
+ Napi::Value Call(napi_value recv, size_t argc, const napi_value* args) const;
1203
+
1204
+ Napi::Value MakeCallback(napi_value recv,
1205
+ const std::initializer_list<napi_value>& args,
1206
+ napi_async_context context = nullptr) const;
1207
+ Napi::Value MakeCallback(napi_value recv,
1208
+ const std::vector<napi_value>& args,
1209
+ napi_async_context context = nullptr) const;
1210
+ Napi::Value MakeCallback(napi_value recv,
1211
+ size_t argc,
1212
+ const napi_value* args,
1213
+ napi_async_context context = nullptr) const;
1214
+
1215
+ Object New(const std::initializer_list<napi_value>& args) const;
1216
+ Object New(const std::vector<napi_value>& args) const;
1217
+ };
1218
+
1219
+ // Shortcuts to creating a new reference with inferred type and refcount = 0.
1220
+ template <typename T> Reference<T> Weak(T value);
1221
+ ObjectReference Weak(Object value);
1222
+ FunctionReference Weak(Function value);
1223
+
1224
+ // Shortcuts to creating a new reference with inferred type and refcount = 1.
1225
+ template <typename T> Reference<T> Persistent(T value);
1226
+ ObjectReference Persistent(Object value);
1227
+ FunctionReference Persistent(Function value);
1228
+
1229
+ /// A persistent reference to a JavaScript error object. Use of this class depends somewhat
1230
+ /// on whether C++ exceptions are enabled at compile time.
1231
+ ///
1232
+ /// ### Handling Errors With C++ Exceptions
1233
+ ///
1234
+ /// If C++ exceptions are enabled, then the `Error` class extends `std::exception` and enables
1235
+ /// integrated error-handling for C++ exceptions and JavaScript exceptions.
1236
+ ///
1237
+ /// If a N-API call fails without executing any JavaScript code (for example due to an invalid
1238
+ /// argument), then the N-API wrapper automatically converts and throws the error as a C++
1239
+ /// exception of type `Napi::Error`. Or if a JavaScript function called by C++ code via N-API
1240
+ /// throws a JavaScript exception, then the N-API wrapper automatically converts and throws it as
1241
+ /// a C++ exception of type `Napi::Error`.
1242
+ ///
1243
+ /// If a C++ exception of type `Napi::Error` escapes from a N-API C++ callback, then the N-API
1244
+ /// wrapper automatically converts and throws it as a JavaScript exception. Therefore, catching
1245
+ /// a C++ exception of type `Napi::Error` prevents a JavaScript exception from being thrown.
1246
+ ///
1247
+ /// #### Example 1A - Throwing a C++ exception:
1248
+ ///
1249
+ /// Napi::Env env = ...
1250
+ /// throw Napi::Error::New(env, "Example exception");
1251
+ ///
1252
+ /// Following C++ statements will not be executed. The exception will bubble up as a C++
1253
+ /// exception of type `Napi::Error`, until it is either caught while still in C++, or else
1254
+ /// automatically propataged as a JavaScript exception when the callback returns to JavaScript.
1255
+ ///
1256
+ /// #### Example 2A - Propagating a N-API C++ exception:
1257
+ ///
1258
+ /// Napi::Function jsFunctionThatThrows = someObj.As<Napi::Function>();
1259
+ /// Napi::Value result = jsFunctionThatThrows({ arg1, arg2 });
1260
+ ///
1261
+ /// Following C++ statements will not be executed. The exception will bubble up as a C++
1262
+ /// exception of type `Napi::Error`, until it is either caught while still in C++, or else
1263
+ /// automatically propagated as a JavaScript exception when the callback returns to JavaScript.
1264
+ ///
1265
+ /// #### Example 3A - Handling a N-API C++ exception:
1266
+ ///
1267
+ /// Napi::Function jsFunctionThatThrows = someObj.As<Napi::Function>();
1268
+ /// Napi::Value result;
1269
+ /// try {
1270
+ /// result = jsFunctionThatThrows({ arg1, arg2 });
1271
+ /// } catch (const Napi::Error& e) {
1272
+ /// cerr << "Caught JavaScript exception: " + e.what();
1273
+ /// }
1274
+ ///
1275
+ /// Since the exception was caught here, it will not be propagated as a JavaScript exception.
1276
+ ///
1277
+ /// ### Handling Errors Without C++ Exceptions
1278
+ ///
1279
+ /// If C++ exceptions are disabled (by defining `NAPI_DISABLE_CPP_EXCEPTIONS`) then this class
1280
+ /// does not extend `std::exception`, and APIs in the `Napi` namespace do not throw C++
1281
+ /// exceptions when they fail. Instead, they raise _pending_ JavaScript exceptions and
1282
+ /// return _empty_ `Value`s. Calling code should check `Value::IsEmpty()` before attempting
1283
+ /// to use a returned value, and may use methods on the `Env` class to check for, get, and
1284
+ /// clear a pending JavaScript exception. If the pending exception is not cleared, it will
1285
+ /// be thrown when the native callback returns to JavaScript.
1286
+ ///
1287
+ /// #### Example 1B - Throwing a JS exception
1288
+ ///
1289
+ /// Napi::Env env = ...
1290
+ /// Napi::Error::New(env, "Example exception").ThrowAsJavaScriptException();
1291
+ /// return;
1292
+ ///
1293
+ /// After throwing a JS exception, the code should generally return immediately from the native
1294
+ /// callback, after performing any necessary cleanup.
1295
+ ///
1296
+ /// #### Example 2B - Propagating a N-API JS exception:
1297
+ ///
1298
+ /// Napi::Function jsFunctionThatThrows = someObj.As<Napi::Function>();
1299
+ /// Napi::Value result = jsFunctionThatThrows({ arg1, arg2 });
1300
+ /// if (result.IsEmpty()) return;
1301
+ ///
1302
+ /// An empty value result from a N-API call indicates an error occurred, and a JavaScript
1303
+ /// exception is pending. To let the exception propagate, the code should generally return
1304
+ /// immediately from the native callback, after performing any necessary cleanup.
1305
+ ///
1306
+ /// #### Example 3B - Handling a N-API JS exception:
1307
+ ///
1308
+ /// Napi::Function jsFunctionThatThrows = someObj.As<Napi::Function>();
1309
+ /// Napi::Value result = jsFunctionThatThrows({ arg1, arg2 });
1310
+ /// if (result.IsEmpty()) {
1311
+ /// Napi::Error e = env.GetAndClearPendingException();
1312
+ /// cerr << "Caught JavaScript exception: " + e.Message();
1313
+ /// }
1314
+ ///
1315
+ /// Since the exception was cleared here, it will not be propagated as a JavaScript exception
1316
+ /// after the native callback returns.
1317
+ class Error : public ObjectReference
1318
+ #ifdef NAPI_CPP_EXCEPTIONS
1319
+ , public std::exception
1320
+ #endif // NAPI_CPP_EXCEPTIONS
1321
+ {
1322
+ public:
1323
+ static Error New(napi_env env);
1324
+ static Error New(napi_env env, const char* message);
1325
+ static Error New(napi_env env, const std::string& message);
1326
+
1327
+ static NAPI_NO_RETURN void Fatal(const char* location, const char* message);
1328
+
1329
+ Error();
1330
+ Error(napi_env env, napi_value value);
1331
+
1332
+ // An error can be moved or copied.
1333
+ Error(Error&& other);
1334
+ Error& operator =(Error&& other);
1335
+ Error(const Error&);
1336
+ Error& operator =(Error&);
1337
+
1338
+ const std::string& Message() const NAPI_NOEXCEPT;
1339
+ void ThrowAsJavaScriptException() const;
1340
+
1341
+ #ifdef NAPI_CPP_EXCEPTIONS
1342
+ const char* what() const NAPI_NOEXCEPT override;
1343
+ #endif // NAPI_CPP_EXCEPTIONS
1344
+
1345
+ protected:
1346
+ /// !cond INTERNAL
1347
+ typedef napi_status (*create_error_fn)(napi_env envb, napi_value code, napi_value msg, napi_value* result);
1348
+
1349
+ template <typename TError>
1350
+ static TError New(napi_env env,
1351
+ const char* message,
1352
+ size_t length,
1353
+ create_error_fn create_error);
1354
+ /// !endcond
1355
+
1356
+ private:
1357
+ mutable std::string _message;
1358
+ };
1359
+
1360
+ class TypeError : public Error {
1361
+ public:
1362
+ static TypeError New(napi_env env, const char* message);
1363
+ static TypeError New(napi_env env, const std::string& message);
1364
+
1365
+ TypeError();
1366
+ TypeError(napi_env env, napi_value value);
1367
+ };
1368
+
1369
+ class RangeError : public Error {
1370
+ public:
1371
+ static RangeError New(napi_env env, const char* message);
1372
+ static RangeError New(napi_env env, const std::string& message);
1373
+
1374
+ RangeError();
1375
+ RangeError(napi_env env, napi_value value);
1376
+ };
1377
+
1378
+ class CallbackInfo {
1379
+ public:
1380
+ CallbackInfo(napi_env env, napi_callback_info info);
1381
+ ~CallbackInfo();
1382
+
1383
+ // Disallow copying to prevent multiple free of _dynamicArgs
1384
+ CallbackInfo(CallbackInfo const &) = delete;
1385
+ void operator=(CallbackInfo const &) = delete;
1386
+
1387
+ Napi::Env Env() const;
1388
+ Value NewTarget() const;
1389
+ bool IsConstructCall() const;
1390
+ size_t Length() const;
1391
+ const Value operator [](size_t index) const;
1392
+ Value This() const;
1393
+ void* Data() const;
1394
+ void SetData(void* data);
1395
+
1396
+ private:
1397
+ const size_t _staticArgCount = 6;
1398
+ napi_env _env;
1399
+ napi_callback_info _info;
1400
+ napi_value _this;
1401
+ size_t _argc;
1402
+ napi_value* _argv;
1403
+ napi_value _staticArgs[6];
1404
+ napi_value* _dynamicArgs;
1405
+ void* _data;
1406
+ };
1407
+
1408
+ class PropertyDescriptor {
1409
+ public:
1410
+ #ifndef NODE_ADDON_API_DISABLE_DEPRECATED
1411
+ template <typename Getter>
1412
+ static PropertyDescriptor Accessor(const char* utf8name,
1413
+ Getter getter,
1414
+ napi_property_attributes attributes = napi_default,
1415
+ void* data = nullptr);
1416
+ template <typename Getter>
1417
+ static PropertyDescriptor Accessor(const std::string& utf8name,
1418
+ Getter getter,
1419
+ napi_property_attributes attributes = napi_default,
1420
+ void* data = nullptr);
1421
+ template <typename Getter>
1422
+ static PropertyDescriptor Accessor(napi_value name,
1423
+ Getter getter,
1424
+ napi_property_attributes attributes = napi_default,
1425
+ void* data = nullptr);
1426
+ template <typename Getter>
1427
+ static PropertyDescriptor Accessor(Name name,
1428
+ Getter getter,
1429
+ napi_property_attributes attributes = napi_default,
1430
+ void* data = nullptr);
1431
+ template <typename Getter, typename Setter>
1432
+ static PropertyDescriptor Accessor(const char* utf8name,
1433
+ Getter getter,
1434
+ Setter setter,
1435
+ napi_property_attributes attributes = napi_default,
1436
+ void* data = nullptr);
1437
+ template <typename Getter, typename Setter>
1438
+ static PropertyDescriptor Accessor(const std::string& utf8name,
1439
+ Getter getter,
1440
+ Setter setter,
1441
+ napi_property_attributes attributes = napi_default,
1442
+ void* data = nullptr);
1443
+ template <typename Getter, typename Setter>
1444
+ static PropertyDescriptor Accessor(napi_value name,
1445
+ Getter getter,
1446
+ Setter setter,
1447
+ napi_property_attributes attributes = napi_default,
1448
+ void* data = nullptr);
1449
+ template <typename Getter, typename Setter>
1450
+ static PropertyDescriptor Accessor(Name name,
1451
+ Getter getter,
1452
+ Setter setter,
1453
+ napi_property_attributes attributes = napi_default,
1454
+ void* data = nullptr);
1455
+ template <typename Callable>
1456
+ static PropertyDescriptor Function(const char* utf8name,
1457
+ Callable cb,
1458
+ napi_property_attributes attributes = napi_default,
1459
+ void* data = nullptr);
1460
+ template <typename Callable>
1461
+ static PropertyDescriptor Function(const std::string& utf8name,
1462
+ Callable cb,
1463
+ napi_property_attributes attributes = napi_default,
1464
+ void* data = nullptr);
1465
+ template <typename Callable>
1466
+ static PropertyDescriptor Function(napi_value name,
1467
+ Callable cb,
1468
+ napi_property_attributes attributes = napi_default,
1469
+ void* data = nullptr);
1470
+ template <typename Callable>
1471
+ static PropertyDescriptor Function(Name name,
1472
+ Callable cb,
1473
+ napi_property_attributes attributes = napi_default,
1474
+ void* data = nullptr);
1475
+ #endif // !NODE_ADDON_API_DISABLE_DEPRECATED
1476
+
1477
+ template <typename Getter>
1478
+ static PropertyDescriptor Accessor(Napi::Env env,
1479
+ Napi::Object object,
1480
+ const char* utf8name,
1481
+ Getter getter,
1482
+ napi_property_attributes attributes = napi_default,
1483
+ void* data = nullptr);
1484
+ template <typename Getter>
1485
+ static PropertyDescriptor Accessor(Napi::Env env,
1486
+ Napi::Object object,
1487
+ const std::string& utf8name,
1488
+ Getter getter,
1489
+ napi_property_attributes attributes = napi_default,
1490
+ void* data = nullptr);
1491
+ template <typename Getter>
1492
+ static PropertyDescriptor Accessor(Napi::Env env,
1493
+ Napi::Object object,
1494
+ Name name,
1495
+ Getter getter,
1496
+ napi_property_attributes attributes = napi_default,
1497
+ void* data = nullptr);
1498
+ template <typename Getter, typename Setter>
1499
+ static PropertyDescriptor Accessor(Napi::Env env,
1500
+ Napi::Object object,
1501
+ const char* utf8name,
1502
+ Getter getter,
1503
+ Setter setter,
1504
+ napi_property_attributes attributes = napi_default,
1505
+ void* data = nullptr);
1506
+ template <typename Getter, typename Setter>
1507
+ static PropertyDescriptor Accessor(Napi::Env env,
1508
+ Napi::Object object,
1509
+ const std::string& utf8name,
1510
+ Getter getter,
1511
+ Setter setter,
1512
+ napi_property_attributes attributes = napi_default,
1513
+ void* data = nullptr);
1514
+ template <typename Getter, typename Setter>
1515
+ static PropertyDescriptor Accessor(Napi::Env env,
1516
+ Napi::Object object,
1517
+ Name name,
1518
+ Getter getter,
1519
+ Setter setter,
1520
+ napi_property_attributes attributes = napi_default,
1521
+ void* data = nullptr);
1522
+ template <typename Callable>
1523
+ static PropertyDescriptor Function(Napi::Env env,
1524
+ Napi::Object object,
1525
+ const char* utf8name,
1526
+ Callable cb,
1527
+ napi_property_attributes attributes = napi_default,
1528
+ void* data = nullptr);
1529
+ template <typename Callable>
1530
+ static PropertyDescriptor Function(Napi::Env env,
1531
+ Napi::Object object,
1532
+ const std::string& utf8name,
1533
+ Callable cb,
1534
+ napi_property_attributes attributes = napi_default,
1535
+ void* data = nullptr);
1536
+ template <typename Callable>
1537
+ static PropertyDescriptor Function(Napi::Env env,
1538
+ Napi::Object object,
1539
+ Name name,
1540
+ Callable cb,
1541
+ napi_property_attributes attributes = napi_default,
1542
+ void* data = nullptr);
1543
+ static PropertyDescriptor Value(const char* utf8name,
1544
+ napi_value value,
1545
+ napi_property_attributes attributes = napi_default);
1546
+ static PropertyDescriptor Value(const std::string& utf8name,
1547
+ napi_value value,
1548
+ napi_property_attributes attributes = napi_default);
1549
+ static PropertyDescriptor Value(napi_value name,
1550
+ napi_value value,
1551
+ napi_property_attributes attributes = napi_default);
1552
+ static PropertyDescriptor Value(Name name,
1553
+ Napi::Value value,
1554
+ napi_property_attributes attributes = napi_default);
1555
+
1556
+ PropertyDescriptor(napi_property_descriptor desc);
1557
+
1558
+ operator napi_property_descriptor&();
1559
+ operator const napi_property_descriptor&() const;
1560
+
1561
+ private:
1562
+ napi_property_descriptor _desc;
1563
+ };
1564
+
1565
+ /// Property descriptor for use with `ObjectWrap::DefineClass()`.
1566
+ ///
1567
+ /// This is different from the standalone `PropertyDescriptor` because it is specific to each
1568
+ /// `ObjectWrap<T>` subclass. This prevents using descriptors from a different class when
1569
+ /// defining a new class (preventing the callbacks from having incorrect `this` pointers).
1570
+ template <typename T>
1571
+ class ClassPropertyDescriptor {
1572
+ public:
1573
+ ClassPropertyDescriptor(napi_property_descriptor desc) : _desc(desc) {}
1574
+
1575
+ operator napi_property_descriptor&() { return _desc; }
1576
+ operator const napi_property_descriptor&() const { return _desc; }
1577
+
1578
+ private:
1579
+ napi_property_descriptor _desc;
1580
+ };
1581
+
1582
+ /// Base class to be extended by C++ classes exposed to JavaScript; each C++ class instance gets
1583
+ /// "wrapped" by a JavaScript object that is managed by this class.
1584
+ ///
1585
+ /// At initialization time, the `DefineClass()` method must be used to
1586
+ /// hook up the accessor and method callbacks. It takes a list of
1587
+ /// property descriptors, which can be constructed via the various
1588
+ /// static methods on the base class.
1589
+ ///
1590
+ /// #### Example:
1591
+ ///
1592
+ /// class Example: public Napi::ObjectWrap<Example> {
1593
+ /// public:
1594
+ /// static void Initialize(Napi::Env& env, Napi::Object& target) {
1595
+ /// Napi::Function constructor = DefineClass(env, "Example", {
1596
+ /// InstanceAccessor("value", &Example::GetSomething, &Example::SetSomething),
1597
+ /// InstanceMethod("doSomething", &Example::DoSomething),
1598
+ /// });
1599
+ /// target.Set("Example", constructor);
1600
+ /// }
1601
+ ///
1602
+ /// Example(const Napi::CallbackInfo& info); // Constructor
1603
+ /// Napi::Value GetSomething(const Napi::CallbackInfo& info);
1604
+ /// void SetSomething(const Napi::CallbackInfo& info, const Napi::Value& value);
1605
+ /// Napi::Value DoSomething(const Napi::CallbackInfo& info);
1606
+ /// }
1607
+ template <typename T>
1608
+ class ObjectWrap : public Reference<Object> {
1609
+ public:
1610
+ ObjectWrap(const CallbackInfo& callbackInfo);
1611
+ virtual ~ObjectWrap();
1612
+
1613
+ static T* Unwrap(Object wrapper);
1614
+
1615
+ // Methods exposed to JavaScript must conform to one of these callback signatures.
1616
+ typedef void (*StaticVoidMethodCallback)(const CallbackInfo& info);
1617
+ typedef Napi::Value (*StaticMethodCallback)(const CallbackInfo& info);
1618
+ typedef Napi::Value (*StaticGetterCallback)(const CallbackInfo& info);
1619
+ typedef void (*StaticSetterCallback)(const CallbackInfo& info, const Napi::Value& value);
1620
+ typedef void (T::*InstanceVoidMethodCallback)(const CallbackInfo& info);
1621
+ typedef Napi::Value (T::*InstanceMethodCallback)(const CallbackInfo& info);
1622
+ typedef Napi::Value (T::*InstanceGetterCallback)(const CallbackInfo& info);
1623
+ typedef void (T::*InstanceSetterCallback)(const CallbackInfo& info, const Napi::Value& value);
1624
+
1625
+ typedef ClassPropertyDescriptor<T> PropertyDescriptor;
1626
+
1627
+ static Function DefineClass(Napi::Env env,
1628
+ const char* utf8name,
1629
+ const std::initializer_list<PropertyDescriptor>& properties,
1630
+ void* data = nullptr);
1631
+ static Function DefineClass(Napi::Env env,
1632
+ const char* utf8name,
1633
+ const std::vector<PropertyDescriptor>& properties,
1634
+ void* data = nullptr);
1635
+ static PropertyDescriptor StaticMethod(const char* utf8name,
1636
+ StaticVoidMethodCallback method,
1637
+ napi_property_attributes attributes = napi_default,
1638
+ void* data = nullptr);
1639
+ static PropertyDescriptor StaticMethod(const char* utf8name,
1640
+ StaticMethodCallback method,
1641
+ napi_property_attributes attributes = napi_default,
1642
+ void* data = nullptr);
1643
+ static PropertyDescriptor StaticMethod(Symbol name,
1644
+ StaticVoidMethodCallback method,
1645
+ napi_property_attributes attributes = napi_default,
1646
+ void* data = nullptr);
1647
+ static PropertyDescriptor StaticMethod(Symbol name,
1648
+ StaticMethodCallback method,
1649
+ napi_property_attributes attributes = napi_default,
1650
+ void* data = nullptr);
1651
+ static PropertyDescriptor StaticAccessor(const char* utf8name,
1652
+ StaticGetterCallback getter,
1653
+ StaticSetterCallback setter,
1654
+ napi_property_attributes attributes = napi_default,
1655
+ void* data = nullptr);
1656
+ static PropertyDescriptor StaticAccessor(Symbol name,
1657
+ StaticGetterCallback getter,
1658
+ StaticSetterCallback setter,
1659
+ napi_property_attributes attributes = napi_default,
1660
+ void* data = nullptr);
1661
+ static PropertyDescriptor InstanceMethod(const char* utf8name,
1662
+ InstanceVoidMethodCallback method,
1663
+ napi_property_attributes attributes = napi_default,
1664
+ void* data = nullptr);
1665
+ static PropertyDescriptor InstanceMethod(const char* utf8name,
1666
+ InstanceMethodCallback method,
1667
+ napi_property_attributes attributes = napi_default,
1668
+ void* data = nullptr);
1669
+ static PropertyDescriptor InstanceMethod(Symbol name,
1670
+ InstanceVoidMethodCallback method,
1671
+ napi_property_attributes attributes = napi_default,
1672
+ void* data = nullptr);
1673
+ static PropertyDescriptor InstanceMethod(Symbol name,
1674
+ InstanceMethodCallback method,
1675
+ napi_property_attributes attributes = napi_default,
1676
+ void* data = nullptr);
1677
+ static PropertyDescriptor InstanceAccessor(const char* utf8name,
1678
+ InstanceGetterCallback getter,
1679
+ InstanceSetterCallback setter,
1680
+ napi_property_attributes attributes = napi_default,
1681
+ void* data = nullptr);
1682
+ static PropertyDescriptor InstanceAccessor(Symbol name,
1683
+ InstanceGetterCallback getter,
1684
+ InstanceSetterCallback setter,
1685
+ napi_property_attributes attributes = napi_default,
1686
+ void* data = nullptr);
1687
+ static PropertyDescriptor StaticValue(const char* utf8name,
1688
+ Napi::Value value,
1689
+ napi_property_attributes attributes = napi_default);
1690
+ static PropertyDescriptor StaticValue(Symbol name,
1691
+ Napi::Value value,
1692
+ napi_property_attributes attributes = napi_default);
1693
+ static PropertyDescriptor InstanceValue(const char* utf8name,
1694
+ Napi::Value value,
1695
+ napi_property_attributes attributes = napi_default);
1696
+ static PropertyDescriptor InstanceValue(Symbol name,
1697
+ Napi::Value value,
1698
+ napi_property_attributes attributes = napi_default);
1699
+ virtual void Finalize(Napi::Env env);
1700
+
1701
+ private:
1702
+ static napi_value ConstructorCallbackWrapper(napi_env env, napi_callback_info info);
1703
+ static napi_value StaticVoidMethodCallbackWrapper(napi_env env, napi_callback_info info);
1704
+ static napi_value StaticMethodCallbackWrapper(napi_env env, napi_callback_info info);
1705
+ static napi_value StaticGetterCallbackWrapper(napi_env env, napi_callback_info info);
1706
+ static napi_value StaticSetterCallbackWrapper(napi_env env, napi_callback_info info);
1707
+ static napi_value InstanceVoidMethodCallbackWrapper(napi_env env, napi_callback_info info);
1708
+ static napi_value InstanceMethodCallbackWrapper(napi_env env, napi_callback_info info);
1709
+ static napi_value InstanceGetterCallbackWrapper(napi_env env, napi_callback_info info);
1710
+ static napi_value InstanceSetterCallbackWrapper(napi_env env, napi_callback_info info);
1711
+ static void FinalizeCallback(napi_env env, void* data, void* hint);
1712
+ static Function DefineClass(Napi::Env env,
1713
+ const char* utf8name,
1714
+ const size_t props_count,
1715
+ const napi_property_descriptor* props,
1716
+ void* data = nullptr);
1717
+
1718
+ template <typename TCallback>
1719
+ struct MethodCallbackData {
1720
+ TCallback callback;
1721
+ void* data;
1722
+ };
1723
+ typedef MethodCallbackData<StaticVoidMethodCallback> StaticVoidMethodCallbackData;
1724
+ typedef MethodCallbackData<StaticMethodCallback> StaticMethodCallbackData;
1725
+ typedef MethodCallbackData<InstanceVoidMethodCallback> InstanceVoidMethodCallbackData;
1726
+ typedef MethodCallbackData<InstanceMethodCallback> InstanceMethodCallbackData;
1727
+
1728
+ template <typename TGetterCallback, typename TSetterCallback>
1729
+ struct AccessorCallbackData {
1730
+ TGetterCallback getterCallback;
1731
+ TSetterCallback setterCallback;
1732
+ void* data;
1733
+ };
1734
+ typedef AccessorCallbackData<StaticGetterCallback, StaticSetterCallback>
1735
+ StaticAccessorCallbackData;
1736
+ typedef AccessorCallbackData<InstanceGetterCallback, InstanceSetterCallback>
1737
+ InstanceAccessorCallbackData;
1738
+
1739
+ bool _construction_failed = true;
1740
+ };
1741
+
1742
+ class HandleScope {
1743
+ public:
1744
+ HandleScope(napi_env env, napi_handle_scope scope);
1745
+ explicit HandleScope(Napi::Env env);
1746
+ ~HandleScope();
1747
+
1748
+ // Disallow copying to prevent double close of napi_handle_scope
1749
+ HandleScope(HandleScope const &) = delete;
1750
+ void operator=(HandleScope const &) = delete;
1751
+
1752
+ operator napi_handle_scope() const;
1753
+
1754
+ Napi::Env Env() const;
1755
+
1756
+ private:
1757
+ napi_env _env;
1758
+ napi_handle_scope _scope;
1759
+ };
1760
+
1761
+ class EscapableHandleScope {
1762
+ public:
1763
+ EscapableHandleScope(napi_env env, napi_escapable_handle_scope scope);
1764
+ explicit EscapableHandleScope(Napi::Env env);
1765
+ ~EscapableHandleScope();
1766
+
1767
+ // Disallow copying to prevent double close of napi_escapable_handle_scope
1768
+ EscapableHandleScope(EscapableHandleScope const &) = delete;
1769
+ void operator=(EscapableHandleScope const &) = delete;
1770
+
1771
+ operator napi_escapable_handle_scope() const;
1772
+
1773
+ Napi::Env Env() const;
1774
+ Value Escape(napi_value escapee);
1775
+
1776
+ private:
1777
+ napi_env _env;
1778
+ napi_escapable_handle_scope _scope;
1779
+ };
1780
+
1781
+ #if (NAPI_VERSION > 2)
1782
+ class CallbackScope {
1783
+ public:
1784
+ CallbackScope(napi_env env, napi_callback_scope scope);
1785
+ CallbackScope(napi_env env, napi_async_context context);
1786
+ virtual ~CallbackScope();
1787
+
1788
+ // Disallow copying to prevent double close of napi_callback_scope
1789
+ CallbackScope(CallbackScope const &) = delete;
1790
+ void operator=(CallbackScope const &) = delete;
1791
+
1792
+ operator napi_callback_scope() const;
1793
+
1794
+ Napi::Env Env() const;
1795
+
1796
+ private:
1797
+ napi_env _env;
1798
+ napi_callback_scope _scope;
1799
+ };
1800
+ #endif
1801
+
1802
+ class AsyncContext {
1803
+ public:
1804
+ explicit AsyncContext(napi_env env, const char* resource_name);
1805
+ explicit AsyncContext(napi_env env, const char* resource_name, const Object& resource);
1806
+ virtual ~AsyncContext();
1807
+
1808
+ AsyncContext(AsyncContext&& other);
1809
+ AsyncContext& operator =(AsyncContext&& other);
1810
+ AsyncContext(const AsyncContext&) = delete;
1811
+ AsyncContext& operator =(AsyncContext&) = delete;
1812
+
1813
+ operator napi_async_context() const;
1814
+
1815
+ Napi::Env Env() const;
1816
+
1817
+ private:
1818
+ napi_env _env;
1819
+ napi_async_context _context;
1820
+ };
1821
+
1822
+ class AsyncWorker {
1823
+ public:
1824
+ virtual ~AsyncWorker();
1825
+
1826
+ // An async worker can be moved but cannot be copied.
1827
+ AsyncWorker(AsyncWorker&& other);
1828
+ AsyncWorker& operator =(AsyncWorker&& other);
1829
+ AsyncWorker(const AsyncWorker&) = delete;
1830
+ AsyncWorker& operator =(AsyncWorker&) = delete;
1831
+
1832
+ operator napi_async_work() const;
1833
+
1834
+ Napi::Env Env() const;
1835
+
1836
+ void Queue();
1837
+ void Cancel();
1838
+ void SuppressDestruct();
1839
+
1840
+ ObjectReference& Receiver();
1841
+ FunctionReference& Callback();
1842
+
1843
+ protected:
1844
+ explicit AsyncWorker(const Function& callback);
1845
+ explicit AsyncWorker(const Function& callback,
1846
+ const char* resource_name);
1847
+ explicit AsyncWorker(const Function& callback,
1848
+ const char* resource_name,
1849
+ const Object& resource);
1850
+ explicit AsyncWorker(const Object& receiver,
1851
+ const Function& callback);
1852
+ explicit AsyncWorker(const Object& receiver,
1853
+ const Function& callback,
1854
+ const char* resource_name);
1855
+ explicit AsyncWorker(const Object& receiver,
1856
+ const Function& callback,
1857
+ const char* resource_name,
1858
+ const Object& resource);
1859
+
1860
+ explicit AsyncWorker(Napi::Env env);
1861
+ explicit AsyncWorker(Napi::Env env,
1862
+ const char* resource_name);
1863
+ explicit AsyncWorker(Napi::Env env,
1864
+ const char* resource_name,
1865
+ const Object& resource);
1866
+
1867
+ virtual void Execute() = 0;
1868
+ virtual void OnOK();
1869
+ virtual void OnError(const Error& e);
1870
+ virtual void Destroy();
1871
+ virtual std::vector<napi_value> GetResult(Napi::Env env);
1872
+
1873
+ void SetError(const std::string& error);
1874
+
1875
+ private:
1876
+ static void OnExecute(napi_env env, void* this_pointer);
1877
+ static void OnWorkComplete(napi_env env,
1878
+ napi_status status,
1879
+ void* this_pointer);
1880
+
1881
+ napi_env _env;
1882
+ napi_async_work _work;
1883
+ ObjectReference _receiver;
1884
+ FunctionReference _callback;
1885
+ std::string _error;
1886
+ bool _suppress_destruct;
1887
+ };
1888
+
1889
+ #if (NAPI_VERSION > 3)
1890
+ class ThreadSafeFunction {
1891
+ public:
1892
+ // This API may only be called from the main thread.
1893
+ template <typename ResourceString>
1894
+ static ThreadSafeFunction New(napi_env env,
1895
+ const Function& callback,
1896
+ ResourceString resourceName,
1897
+ size_t maxQueueSize,
1898
+ size_t initialThreadCount);
1899
+
1900
+ // This API may only be called from the main thread.
1901
+ template <typename ResourceString, typename ContextType>
1902
+ static ThreadSafeFunction New(napi_env env,
1903
+ const Function& callback,
1904
+ ResourceString resourceName,
1905
+ size_t maxQueueSize,
1906
+ size_t initialThreadCount,
1907
+ ContextType* context);
1908
+
1909
+ // This API may only be called from the main thread.
1910
+ template <typename ResourceString, typename Finalizer>
1911
+ static ThreadSafeFunction New(napi_env env,
1912
+ const Function& callback,
1913
+ ResourceString resourceName,
1914
+ size_t maxQueueSize,
1915
+ size_t initialThreadCount,
1916
+ Finalizer finalizeCallback);
1917
+
1918
+ // This API may only be called from the main thread.
1919
+ template <typename ResourceString, typename Finalizer,
1920
+ typename FinalizerDataType>
1921
+ static ThreadSafeFunction New(napi_env env,
1922
+ const Function& callback,
1923
+ ResourceString resourceName,
1924
+ size_t maxQueueSize,
1925
+ size_t initialThreadCount,
1926
+ Finalizer finalizeCallback,
1927
+ FinalizerDataType* data);
1928
+
1929
+ // This API may only be called from the main thread.
1930
+ template <typename ResourceString, typename ContextType, typename Finalizer>
1931
+ static ThreadSafeFunction New(napi_env env,
1932
+ const Function& callback,
1933
+ ResourceString resourceName,
1934
+ size_t maxQueueSize,
1935
+ size_t initialThreadCount,
1936
+ ContextType* context,
1937
+ Finalizer finalizeCallback);
1938
+
1939
+ // This API may only be called from the main thread.
1940
+ template <typename ResourceString, typename ContextType,
1941
+ typename Finalizer, typename FinalizerDataType>
1942
+ static ThreadSafeFunction New(napi_env env,
1943
+ const Function& callback,
1944
+ ResourceString resourceName,
1945
+ size_t maxQueueSize,
1946
+ size_t initialThreadCount,
1947
+ ContextType* context,
1948
+ Finalizer finalizeCallback,
1949
+ FinalizerDataType* data);
1950
+
1951
+ // This API may only be called from the main thread.
1952
+ template <typename ResourceString>
1953
+ static ThreadSafeFunction New(napi_env env,
1954
+ const Function& callback,
1955
+ const Object& resource,
1956
+ ResourceString resourceName,
1957
+ size_t maxQueueSize,
1958
+ size_t initialThreadCount);
1959
+
1960
+ // This API may only be called from the main thread.
1961
+ template <typename ResourceString, typename ContextType>
1962
+ static ThreadSafeFunction New(napi_env env,
1963
+ const Function& callback,
1964
+ const Object& resource,
1965
+ ResourceString resourceName,
1966
+ size_t maxQueueSize,
1967
+ size_t initialThreadCount,
1968
+ ContextType* context);
1969
+
1970
+ // This API may only be called from the main thread.
1971
+ template <typename ResourceString, typename Finalizer>
1972
+ static ThreadSafeFunction New(napi_env env,
1973
+ const Function& callback,
1974
+ const Object& resource,
1975
+ ResourceString resourceName,
1976
+ size_t maxQueueSize,
1977
+ size_t initialThreadCount,
1978
+ Finalizer finalizeCallback);
1979
+
1980
+ // This API may only be called from the main thread.
1981
+ template <typename ResourceString, typename Finalizer,
1982
+ typename FinalizerDataType>
1983
+ static ThreadSafeFunction New(napi_env env,
1984
+ const Function& callback,
1985
+ const Object& resource,
1986
+ ResourceString resourceName,
1987
+ size_t maxQueueSize,
1988
+ size_t initialThreadCount,
1989
+ Finalizer finalizeCallback,
1990
+ FinalizerDataType* data);
1991
+
1992
+ // This API may only be called from the main thread.
1993
+ template <typename ResourceString, typename ContextType, typename Finalizer>
1994
+ static ThreadSafeFunction New(napi_env env,
1995
+ const Function& callback,
1996
+ const Object& resource,
1997
+ ResourceString resourceName,
1998
+ size_t maxQueueSize,
1999
+ size_t initialThreadCount,
2000
+ ContextType* context,
2001
+ Finalizer finalizeCallback);
2002
+
2003
+ // This API may only be called from the main thread.
2004
+ template <typename ResourceString, typename ContextType,
2005
+ typename Finalizer, typename FinalizerDataType>
2006
+ static ThreadSafeFunction New(napi_env env,
2007
+ const Function& callback,
2008
+ const Object& resource,
2009
+ ResourceString resourceName,
2010
+ size_t maxQueueSize,
2011
+ size_t initialThreadCount,
2012
+ ContextType* context,
2013
+ Finalizer finalizeCallback,
2014
+ FinalizerDataType* data);
2015
+
2016
+ ThreadSafeFunction();
2017
+ ThreadSafeFunction(napi_threadsafe_function tsFunctionValue);
2018
+
2019
+ operator napi_threadsafe_function() const;
2020
+
2021
+ // This API may be called from any thread.
2022
+ napi_status BlockingCall() const;
2023
+
2024
+ // This API may be called from any thread.
2025
+ template <typename Callback>
2026
+ napi_status BlockingCall(Callback callback) const;
2027
+
2028
+ // This API may be called from any thread.
2029
+ template <typename DataType, typename Callback>
2030
+ napi_status BlockingCall(DataType* data, Callback callback) const;
2031
+
2032
+ // This API may be called from any thread.
2033
+ napi_status NonBlockingCall() const;
2034
+
2035
+ // This API may be called from any thread.
2036
+ template <typename Callback>
2037
+ napi_status NonBlockingCall(Callback callback) const;
2038
+
2039
+ // This API may be called from any thread.
2040
+ template <typename DataType, typename Callback>
2041
+ napi_status NonBlockingCall(DataType* data, Callback callback) const;
2042
+
2043
+ // This API may only be called from the main thread.
2044
+ void Ref(napi_env env) const;
2045
+
2046
+ // This API may only be called from the main thread.
2047
+ void Unref(napi_env env) const;
2048
+
2049
+ // This API may be called from any thread.
2050
+ napi_status Acquire() const;
2051
+
2052
+ // This API may be called from any thread.
2053
+ napi_status Release();
2054
+
2055
+ // This API may be called from any thread.
2056
+ napi_status Abort();
2057
+
2058
+ struct ConvertibleContext
2059
+ {
2060
+ template <class T>
2061
+ operator T*() { return static_cast<T*>(context); }
2062
+ void* context;
2063
+ };
2064
+
2065
+ // This API may be called from any thread.
2066
+ ConvertibleContext GetContext() const;
2067
+
2068
+ private:
2069
+ using CallbackWrapper = std::function<void(Napi::Env, Napi::Function)>;
2070
+
2071
+ template <typename ResourceString, typename ContextType,
2072
+ typename Finalizer, typename FinalizerDataType>
2073
+ static ThreadSafeFunction New(napi_env env,
2074
+ const Function& callback,
2075
+ const Object& resource,
2076
+ ResourceString resourceName,
2077
+ size_t maxQueueSize,
2078
+ size_t initialThreadCount,
2079
+ ContextType* context,
2080
+ Finalizer finalizeCallback,
2081
+ FinalizerDataType* data,
2082
+ napi_finalize wrapper);
2083
+
2084
+ napi_status CallInternal(CallbackWrapper* callbackWrapper,
2085
+ napi_threadsafe_function_call_mode mode) const;
2086
+
2087
+ static void CallJS(napi_env env,
2088
+ napi_value jsCallback,
2089
+ void* context,
2090
+ void* data);
2091
+
2092
+ napi_threadsafe_function _tsfn;
2093
+ };
2094
+
2095
+ template<class T>
2096
+ class AsyncProgressWorker : public AsyncWorker {
2097
+ public:
2098
+ virtual ~AsyncProgressWorker();
2099
+
2100
+ class ExecutionProgress {
2101
+ friend class AsyncProgressWorker;
2102
+ public:
2103
+ void Signal() const;
2104
+ void Send(const T* data, size_t count) const;
2105
+ private:
2106
+ explicit ExecutionProgress(AsyncProgressWorker* worker) : _worker(worker) {}
2107
+ AsyncProgressWorker* const _worker;
2108
+ };
2109
+
2110
+ protected:
2111
+ explicit AsyncProgressWorker(const Function& callback);
2112
+ explicit AsyncProgressWorker(const Function& callback,
2113
+ const char* resource_name);
2114
+ explicit AsyncProgressWorker(const Function& callback,
2115
+ const char* resource_name,
2116
+ const Object& resource);
2117
+ explicit AsyncProgressWorker(const Object& receiver,
2118
+ const Function& callback);
2119
+ explicit AsyncProgressWorker(const Object& receiver,
2120
+ const Function& callback,
2121
+ const char* resource_name);
2122
+ explicit AsyncProgressWorker(const Object& receiver,
2123
+ const Function& callback,
2124
+ const char* resource_name,
2125
+ const Object& resource);
2126
+
2127
+ // Optional callback of Napi::ThreadSafeFunction only available after NAPI_VERSION 4.
2128
+ // Refs: https://github.com/nodejs/node/pull/27791
2129
+ #if NAPI_VERSION > 4
2130
+ explicit AsyncProgressWorker(Napi::Env env);
2131
+ explicit AsyncProgressWorker(Napi::Env env,
2132
+ const char* resource_name);
2133
+ explicit AsyncProgressWorker(Napi::Env env,
2134
+ const char* resource_name,
2135
+ const Object& resource);
2136
+ #endif
2137
+
2138
+ virtual void Execute(const ExecutionProgress& progress) = 0;
2139
+ virtual void OnProgress(const T* data, size_t count) = 0;
2140
+
2141
+ private:
2142
+ static void WorkProgress_(Napi::Env env, Napi::Function jsCallback, void* data);
2143
+
2144
+ void Execute() override;
2145
+ void Signal() const;
2146
+ void SendProgress_(const T* data, size_t count);
2147
+
2148
+ std::mutex _mutex;
2149
+ T* _asyncdata;
2150
+ size_t _asyncsize;
2151
+ ThreadSafeFunction _tsfn;
2152
+ };
2153
+ #endif
2154
+
2155
+ // Memory management.
2156
+ class MemoryManagement {
2157
+ public:
2158
+ static int64_t AdjustExternalMemory(Env env, int64_t change_in_bytes);
2159
+ };
2160
+
2161
+ // Version management
2162
+ class VersionManagement {
2163
+ public:
2164
+ static uint32_t GetNapiVersion(Env env);
2165
+ static const napi_node_version* GetNodeVersion(Env env);
2166
+ };
2167
+
2168
+ } // namespace Napi
2169
+
2170
+ // Inline implementations of all the above class methods are included here.
2171
+ #include "napi-inl.h"
2172
+
2173
+ #endif // SRC_NAPI_H_