-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(*): support wasi-wasm32 target (#752)
* feat(*): support wasi-wasm32 target * patch * fix filter
- Loading branch information
1 parent
d38c394
commit 12f25b5
Showing
148 changed files
with
1,776 additions
and
549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ node_modules | |
lib | ||
.yarn | ||
yarn.lock | ||
packages/*/*.wasi.js | ||
packages/*/index.js | ||
packages/*/index.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#[cfg(not(target_family = "wasm"))] | ||
#[global_allocator] | ||
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* eslint-disable */ | ||
/* prettier-ignore */ | ||
|
||
/* auto-generated by NAPI-RS */ | ||
|
||
const __nodeFs= require('node:fs') | ||
const __nodePath = require('node:path') | ||
const { WASI: __nodeWASI } = require('node:wasi') | ||
const { Worker } = require('node:worker_threads') | ||
|
||
const { instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync } = require('@emnapi/core') | ||
const { getDefaultContext: __emnapiGetDefaultContext } = require('@emnapi/runtime') | ||
|
||
const __wasi = new __nodeWASI({ | ||
version: 'preview1', | ||
env: process.env, | ||
preopens: { | ||
'/': '/' | ||
} | ||
}) | ||
|
||
const __emnapiContext = __emnapiGetDefaultContext() | ||
|
||
const __sharedMemory = new WebAssembly.Memory({ | ||
initial: 1024, | ||
maximum: 10240, | ||
shared: true, | ||
}) | ||
|
||
let __wasmFilePath = __nodePath.join(__dirname, 'argon2.wasm32-wasi.wasm') | ||
|
||
if (!__nodeFs.existsSync(__wasmFilePath)) { | ||
try { | ||
__wasmFilePath = __nodePath.resolve('@node-rs/argon2-wasm32-wasi') | ||
} catch { | ||
throw new Error('Cannot find argon2.wasm32-wasi.wasm file, and @node-rs/argon2-wasm32-wasi package is not installed.') | ||
} | ||
} | ||
|
||
const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule } = __emnapiInstantiateNapiModuleSync(__nodeFs.readFileSync(__wasmFilePath), { | ||
context: __emnapiContext, | ||
asyncWorkPoolSize: (function() { | ||
const threadsSizeFromEnv = Number(process.env.NAPI_RS_ASYNC_WORK_POOL_SIZE ?? process.env.UV_THREADPOOL_SIZE) | ||
// NaN > 0 is false | ||
if (threadsSizeFromEnv > 0) { | ||
return threadsSizeFromEnv | ||
} else { | ||
return 4 | ||
} | ||
})(), | ||
wasi: __wasi, | ||
onCreateWorker() { | ||
return new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), { | ||
env: process.env, | ||
execArgv: ['--experimental-wasi-unstable-preview1'], | ||
}) | ||
}, | ||
overwriteImports(importObject) { | ||
importObject.env = { | ||
...importObject.env, | ||
...importObject.napi, | ||
...importObject.emnapi, | ||
memory: __sharedMemory, | ||
} | ||
return importObject | ||
}, | ||
beforeInit({ instance }) { | ||
__napi_rs_initialize_modules(instance) | ||
} | ||
}) | ||
|
||
function __napi_rs_initialize_modules(__napiInstance) { | ||
__napiInstance.exports['__napi_register__Algorithm_0']?.() | ||
__napiInstance.exports['__napi_register__Version_1']?.() | ||
__napiInstance.exports['__napi_register__Options_struct_2']?.() | ||
__napiInstance.exports['__napi_register__HashTask_impl_3']?.() | ||
__napiInstance.exports['__napi_register__hash_4']?.() | ||
__napiInstance.exports['__napi_register__hash_sync_5']?.() | ||
__napiInstance.exports['__napi_register__RawHashTask_impl_6']?.() | ||
__napiInstance.exports['__napi_register__hash_raw_7']?.() | ||
__napiInstance.exports['__napi_register__hash_raw_sync_8']?.() | ||
__napiInstance.exports['__napi_register__VerifyTask_impl_9']?.() | ||
__napiInstance.exports['__napi_register__verify_10']?.() | ||
__napiInstance.exports['__napi_register__verify_sync_11']?.() | ||
} | ||
module.exports.Algorithm = __napiModule.exports.Algorithm, | ||
module.exports.hash = __napiModule.exports.hash, | ||
module.exports.hashRaw = __napiModule.exports.hashRaw, | ||
module.exports.hashRawSync = __napiModule.exports.hashRawSync, | ||
module.exports.hashSync = __napiModule.exports.hashSync, | ||
module.exports.verify = __napiModule.exports.verify, | ||
module.exports.verifySync = __napiModule.exports.verifySync, | ||
module.exports.Version = __napiModule.exports.Version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.