@towns-protocol/vodozemac
v0.1.0
Published
These are the Javascript bindings for [vodozemac](https://github.com/matrix-org/vodozemac). Web based environments are supported as well as node based ones.
Keywords
Readme
@towns-protocol/vodozemac
These are the Javascript bindings for vodozemac. Web based environments are supported as well as node based ones.
This package was highly inspired by matrix-rust-sdk-crpyto-wasm.
Usage
Install in your project:
yarn add @towns-protocol/vodozemacImport the library into your project and initialise it.
On Web platforms, the library must be initialised by calling
initAsyncbefore it can be used, else it will throw an error. This is also recommended on other platforms, as it allows the WebAssembly module to be loaded asynchronously.import * as Vodozemac from "@towns-protocol/vodozemac"; async function loadVodozemac() { // Do this before any other calls to the library await Vodozemac.initAsync(); return Vodozemac; }Build your project.
The packaging of this library aims to "just work" the same as any plain-javascript project would: it includes separate entry points for Node.js-like environments (which read the WASM file via
fs.readFile()) and web-like environments (which download the WASM file withfetch()). There are both CommonJS and ES Module entry points for each environment; an appropriate entrypoint should be selected automatically.If your environment supports the experimental ES Module Integration Proposal for WebAssembly, you can instead use that, by setting the
towns-protocol:wasm-esmcustom export condition. This is only supported when the library is imported as an ES Module. For example:- In Webpack, set
experiments.asyncWebAssemblytotrueandresolve.conditionNamesto["towns-protocol:wasm-esm", "..."](the"..."preserves default condition names). - In Node.js, invoke with commandline arguments
--experimental-wasm-modules--conditions=wasm-esm.
- In Webpack, set
Contributing
TBD: npm publish guide
Third-Party Code
Some parts of this project are derived from code licensed under the Apache License, Version 2.0:
- index-wasm-esm.mjs: originally from matrix-rust-sdk-crpyto-wasm
- index.d.ts: originally from matrix-rust-sdk-crpyto-wasm
- index.mjs: originally from matrix-rust-sdk-crpyto-wasm
- node.cjs: originally from matrix-rust-sdk-crpyto-wasm
- node.mjs: originally from matrix-rust-sdk-crpyto-wasm
