Detalhes do pacote

emscripten-wasm-loader

kwonoj102.8kMIT3.0.3

Common interface to load wasm module into isomorphic environment

readme (leia-me)

Build Status Build status codecov npm

Emscripten-wasm-loader

Wraps up common initialization logic with predefined preprocessor object. This module intended to support specific scoped usecase for wasm binary built with MODULARIZED and SINGLE_FILE.

Usage

import { getModuleLoader } from 'emscripten-wasm-loader';

const loader = getModuleLoader(factoryLoader, require('wasm/wasmlibaray'), { additional: ''});

getModuleLoader is higher order function returns actual module loader.

getModuleLoader<T, R extends AsmRuntimeType>(
  factoryLoader: (runtime: R) => T,
  runtimeModule: runtimeModuleType,
  module?: Record<string, any>
) => moduleLoaderType<T>;

/**
 * Asynchronously load and initialize asm module.
 *
 * @returns {T} Factory function manages lifecycle of hunspell and virtual files.
 */
type moduleLoaderType<T> = () => Promise<T>;

factoryLoader is callback function to be called to create actual instance of module using initialized wasm binary runtime for customized init steps for each consumer. runtimeModule is function loaded via require to emscripten preamble js for wasm binaries. It expects wasm binary should be built with MODULARIZE=1 with SINGLE_FILE=1 option. Lastly module is object to be inherited when execute runtimeModule. Emscripten's modularized preamble construct scoped wasm runtime module named Module, allows to have predefined object if needed. Internally getModuleLoader augments given object and set default interfaces like initializeRuntime.

changelog (log de mudanças)

3.0.3 (2019-07-19)

Bug Fixes

  • getmoduleloader: raise exception when init timeout occurs (6169bb3)

3.0.2 (2019-06-13)

Bug Fixes

  • mountbuffer: fix dependencies (911c8b7)

3.0.1 (2019-06-12)

Features

  • baseasmmodule: update types (6b29049)

3.0.0 (2019-06-12)

BREAKING CHANGES: targeting es2018 for output

2.2.3 (2019-01-31)

Features

  • asmmodule: export malloc (45388c6)

2.2.2 (2018-10-23)

  • Support browser field for treeshaking

2.2.1 (2018-10-23)

Features

  • constructmodule: support binaryendpoint (e38d740)
  • free: export free interface (08d09bc)
  • getmoduleloader: expose timeout for wasm module loading (f74a268)

2.1.1 (2018-07-11)

Bug Fixes

  • mountdirectory: remove redundant env param (c751ec9)

2.1.0 (2018-07-11)

Features

  • index: export path modules (ea5f0fd)
  • ismounted: implement ismounted (38368cd)
  • mkdirtree: implement mkdirtree (9d7fc9f)
  • mountbuffer: implement mountbuffer (f24c13a)
  • mountdirectory: implement mountdirectory (325e1f4)
  • unmount: implement unmount (19739d7)

2.0.0 (2018-07-11)

Bug Fixes

  • constructmodule: deprecate environment (5a39c45)
  • getmoduleloader: deprecate environment (1fc7e3f)

BREAKING CHANGES

  • constructmodule: no longer able to specify environment in runtime

1.0.0 (2017-11-29)

Features

  • getmoduleloader: drop custom binarypath support (2f9fb92)

BREAKING CHANGES

  • getmoduleloader: Loader now accepts single file, native wasm module only

0.0.8 (2017-09-18)

0.0.7 (2017-09-17)

Features

  • constructmodule: wire onAbort callback (6440650)
  • loadmodule: enhance error handling (4f3004f)

0.0.6 (2017-09-17)

Features

  • getmoduleloader: forward environment to factoryloader (244fdb9)

0.0.5 (2017-09-15)

Bug Fixes

  • environment: correct environement for emscripten preamble (8a65acf)

0.0.4 (2017-09-15)

Bug Fixes

  • constructmodule: inject environment (9f4b82a)

0.0.3 (2017-09-15)

0.0.2 (2017-09-15)

Bug Fixes

  • asmruntimetype: fix interface type (cd087b1)

0.0.1 (2017-09-15)

Bug Fixes

  • constructmodule: correct node.js locatefile (5680d7e)
  • getmoduleloader: correct wasm binary loading (ccac577)

Features

  • constructmodule: implements constructmodule (82a269f)
  • enum: export enums (400f8a9)
  • getmoduleloader: implements getmoduleloader (d46c18d)
  • index: export interfaces (a01a478)
  • index: export interfaces (f4a6933)
  • isnode: implements isNode (115af40)
  • iswasmenabled: implements isWasmEnabled (121d4b0)
  • logger: implements logger (a902c4c)