|
| 1 | +/* eslint-disable */ |
| 2 | +/* prettier-ignore */ |
| 3 | + |
| 4 | +/* auto-generated by NAPI-RS */ |
| 5 | + |
| 6 | +const __nodeFs= require('node:fs') |
| 7 | +const __nodePath = require('node:path') |
| 8 | +const { WASI: __nodeWASI } = require('node:wasi') |
| 9 | +const { Worker } = require('node:worker_threads') |
| 10 | + |
| 11 | +const { instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync } = require('@emnapi/core') |
| 12 | +const { getDefaultContext: __emnapiGetDefaultContext } = require('@emnapi/runtime') |
| 13 | + |
| 14 | +const __wasi = new __nodeWASI({ |
| 15 | + version: 'preview1', |
| 16 | + env: process.env, |
| 17 | + preopens: { |
| 18 | + '/': '/' |
| 19 | + } |
| 20 | +}) |
| 21 | + |
| 22 | +const __emnapiContext = __emnapiGetDefaultContext() |
| 23 | + |
| 24 | +const __sharedMemory = new WebAssembly.Memory({ |
| 25 | + initial: 1024, |
| 26 | + maximum: 10240, |
| 27 | + shared: true, |
| 28 | +}) |
| 29 | + |
| 30 | +let __wasmFilePath = __nodePath.join(__dirname, 'argon2.wasm32-wasi.wasm') |
| 31 | + |
| 32 | +if (!__nodeFs.existsSync(__wasmFilePath)) { |
| 33 | + try { |
| 34 | + __wasmFilePath = __nodePath.resolve('@node-rs/argon2-wasm32-wasi') |
| 35 | + } catch { |
| 36 | + throw new Error('Cannot find argon2.wasm32-wasi.wasm file, and @node-rs/argon2-wasm32-wasi package is not installed.') |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule } = __emnapiInstantiateNapiModuleSync(__nodeFs.readFileSync(__wasmFilePath), { |
| 41 | + context: __emnapiContext, |
| 42 | + asyncWorkPoolSize: (function() { |
| 43 | + const threadsSizeFromEnv = Number(process.env.NAPI_RS_ASYNC_WORK_POOL_SIZE ?? process.env.UV_THREADPOOL_SIZE) |
| 44 | + // NaN > 0 is false |
| 45 | + if (threadsSizeFromEnv > 0) { |
| 46 | + return threadsSizeFromEnv |
| 47 | + } else { |
| 48 | + return 4 |
| 49 | + } |
| 50 | + })(), |
| 51 | + wasi: __wasi, |
| 52 | + onCreateWorker() { |
| 53 | + return new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), { |
| 54 | + env: process.env, |
| 55 | + execArgv: ['--experimental-wasi-unstable-preview1'], |
| 56 | + }) |
| 57 | + }, |
| 58 | + overwriteImports(importObject) { |
| 59 | + importObject.env = { |
| 60 | + ...importObject.env, |
| 61 | + ...importObject.napi, |
| 62 | + ...importObject.emnapi, |
| 63 | + memory: __sharedMemory, |
| 64 | + } |
| 65 | + return importObject |
| 66 | + }, |
| 67 | + beforeInit({ instance }) { |
| 68 | + __napi_rs_initialize_modules(instance) |
| 69 | + } |
| 70 | +}) |
| 71 | + |
| 72 | +function __napi_rs_initialize_modules(__napiInstance) { |
| 73 | + __napiInstance.exports['__napi_register__Algorithm_0']?.() |
| 74 | + __napiInstance.exports['__napi_register__Version_1']?.() |
| 75 | + __napiInstance.exports['__napi_register__Options_struct_2']?.() |
| 76 | + __napiInstance.exports['__napi_register__HashTask_impl_3']?.() |
| 77 | + __napiInstance.exports['__napi_register__hash_4']?.() |
| 78 | + __napiInstance.exports['__napi_register__hash_sync_5']?.() |
| 79 | + __napiInstance.exports['__napi_register__RawHashTask_impl_6']?.() |
| 80 | + __napiInstance.exports['__napi_register__hash_raw_7']?.() |
| 81 | + __napiInstance.exports['__napi_register__hash_raw_sync_8']?.() |
| 82 | + __napiInstance.exports['__napi_register__VerifyTask_impl_9']?.() |
| 83 | + __napiInstance.exports['__napi_register__verify_10']?.() |
| 84 | + __napiInstance.exports['__napi_register__verify_sync_11']?.() |
| 85 | +} |
| 86 | +module.exports.Algorithm = __napiModule.exports.Algorithm, |
| 87 | +module.exports.hash = __napiModule.exports.hash, |
| 88 | +module.exports.hashRaw = __napiModule.exports.hashRaw, |
| 89 | +module.exports.hashRawSync = __napiModule.exports.hashRawSync, |
| 90 | +module.exports.hashSync = __napiModule.exports.hashSync, |
| 91 | +module.exports.verify = __napiModule.exports.verify, |
| 92 | +module.exports.verifySync = __napiModule.exports.verifySync, |
| 93 | +module.exports.Version = __napiModule.exports.Version |
0 commit comments