Skip to content

Releases: toyobayashi/emnapi

v0.36.0

30 Mar 09:11
Compare
Choose a tag to compare

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_* receive NULL as parameter if length is set to 0 in #43
  • (BREAKING CHANGE) rename onInstantiated to beforeInit and change function signature 8c208e4

Full Changelog: v0.35.0...v0.36.0

v0.35.0

23 Mar 13:56
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.34.0...v0.35.0

v0.34.0

16 Mar 06:34
Compare
Choose a tag to compare
  • Add tsfn JS implementation so that tsfn can be used with libemnapi-basic.a

v0.33.1...v0.34.0

v0.33.1

09 Mar 16:51
Compare
Choose a tag to compare

small fix

v0.33.0

09 Mar 13:46
Compare
Choose a tag to compare
  • Support wasm32-wasi-threads (#34)
  • Add new API for non-emscripten
    • emnapiCore.instantiateNapiModule
    • emnapiCore.instantiateNapiModuleSync
    • emnapiCore.MessageHandler

v0.32.2

26 Feb 02:59
Compare
Choose a tag to compare
  • fix SyntaxError when using keywords as name (#36)
  • Prebuild libemnapi-basic.a (exclude napi_*_{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

14 Feb 08:00
Compare
Choose a tag to compare
  • add napi_*_callback_scope for node-addon-api #32

Breaking Change

Rename package name (#33), old packages are deprecated and no longer update

Before After
@tybys/emnapi emnapi
@tybys/emnapi-runtime @emnapi/runtime
@tybys/emnapi-core @emnapi/core
@tybys/emnapi-node-binding @emnapi/node-binding

v0.30.0

14 Feb 03:51
Compare
Choose a tag to compare
  • fix napi_get_*_info (#30)
  • node-addon-api v6.0.0
  • runtime export getDefaultContext

v0.29.1

09 Feb 09:23
Compare
Choose a tag to compare
  • Port emmalloc, publish libemmalloc.a

v0.29.0

07 Feb 12:51
Compare
Choose a tag to compare
  • 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 initialization

    import { 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