Releases: toyobayashi/emnapi
Releases · toyobayashi/emnapi
v0.36.0
What's Changed
- prebuilt library use emscripten 3.1.34
- fix prebuilt library use wrong symbol after emscripten 3.1.32 #41 (comment)
- allow symbol as reference target by @toyobayashi in #43
- allow
napi_create_string_*
receiveNULL
as parameter if length is set to0
in #43 - (BREAKING CHANGE) rename
onInstantiated
tobeforeInit
and change function signature 8c208e4
Full Changelog: v0.35.0...v0.36.0
v0.35.0
What's Changed
- Implement multithreaded async work in JS by @toyobayashi in #40
Full Changelog: v0.34.0...v0.35.0
v0.34.0
- Add tsfn JS implementation so that tsfn can be used with
libemnapi-basic.a
v0.33.1
small fix
v0.33.0
v0.32.2
- fix
SyntaxError
when using keywords as name (#36) - Prebuild
libemnapi-basic.a
(excludenapi_*_{async_work,threadsafe_function}
) and implement async work in single thread (#37)
Breaking Change
(non-emscripten) Now napiModule.init
receive an object as first parameter and require a WebAssembly.Module
in module
field.
before:
import { createNapiModule } from '@emnapi/core'
const napiModule = createNapiModule({ /* ... */ })
WebAssembly.instantiate(/* ... */).then(({ instance }) => {
const binding = napiModule.init(instance, memory, table)
})
after:
import { createNapiModule } from '@emnapi/core'
const napiModule = createNapiModule({ /* ... */ })
WebAssembly.instantiate(/* ... */).then(({ instance, module }) => {
const binding = napiModule.init({
instance,
module,
memory,
table
})
})
v0.31.0
v0.30.0
v0.29.1
- Port
emmalloc
, publishlibemmalloc.a
v0.29.0
-
Add basic support for standard clang
wasm32-unknown-unknown
target, wasi-sdk and napi-rs, without async work and tsfn. #29 -
Publish
@tybys/emnapi-core
package for non-emscripten, which can be used for raw wasm initializationimport { createNapiModule } from '@tybys/emnapi-core' import { createContext } from '@tybys/emnapi-runtime' const context = createContext() const napiModule = createNapiModule({ context }) WebAssembly.instantiate(wasmBuffer, { env: { ...napiModule.imports.env, // Currently napi-rs imports all symbols from env module ...napiModule.imports.napi, ...napiModule.imports.emnapi }, // clang napi: napiModule.imports.napi, emnapi: napiModule.imports.emnapi }).then(({ instance }) => { const binding = napiModule.init(instance, instance.exports.memory, instance.exports.__indirect_function_table) // binding === napiModule.exports })
Using WASI on Node.js
import { createNapiModule } from '@tybys/emnapi-core' import { createContext } from '@tybys/emnapi-runtime' + import { WASI } from 'node:wasi' const context = createContext() const napiModule = createNapiModule({ context }) + const wasi = new WASI({ /* ... */ }) WebAssembly.instantiate(wasmBuffer, { + wasi_snapshot_preview1: wasi.wasiImport, env: { ...napiModule.imports.env, // Currently napi-rs imports all symbols from env module ...napiModule.imports.napi, ...napiModule.imports.emnapi }, // clang napi: napiModule.imports.napi, emnapi: napiModule.imports.emnapi }).then(({ instance }) => { + wasi.initialize(instance) const binding = napiModule.init(instance, instance.exports.memory, instance.exports.__indirect_function_table) // binding === napiModule.exports })
Using WASI on browser, I have made a WASI polyfill in wasm-util, and memfs-browser
import { createNapiModule } from '@tybys/emnapi-core' import { createContext } from '@tybys/emnapi-runtime' + import { WASI } from '@tybys/wasm-util' + import { Volumn, createFsFromVolume } from 'memfs-browser' const context = createContext() const napiModule = createNapiModule({ context }) + const fs = createFsFromVolume(Volume.from({ /* ... */ }) + const wasi = WASI.createSync({ fs, /* ... */ }) WebAssembly.instantiate(wasmBuffer, { + wasi_snapshot_preview1: wasi.wasiImport, env: { ...napiModule.imports.env, // Currently napi-rs imports all symbols from env module ...napiModule.imports.napi, ...napiModule.imports.emnapi }, // clang napi: napiModule.imports.napi, emnapi: napiModule.imports.emnapi }).then(({ instance }) => { + wasi.initialize(instance) const binding = napiModule.init(instance, instance.exports.memory, instance.exports.__indirect_function_table) // binding === napiModule.exports })
-
Publish precompiled static library in
@tybys/emnapi
package, include targets:wasm32-unknown-unknown
,wasm32-wasi
,wasm32-unknown-emscripten
-
Port dlmalloc for
wasm32-unknown-unknown