Skip to main content

Home

WebAssembly plugin for WILL SDK for ink

The plugin provides 2 distributions: digital-ink-wasm and digital-ink-wasm-st.

digital-ink-wasm

This distribution targets SharedArrayBuffer-enabled environments. It also provides multi-threaded support for the pipeline build process. To enable Site Isolation mode, provide the following headers on the server:

  response.setHeader("Cross-Origin-Embedder-Policy", "require-corp")  response.setHeader("Cross-Origin-Opener-Policy", "same-origin")

More information can be found here: Cross-origin isolation overview

digital-ink-wasm-st

This distribution should be used when SharedArrayBuffer is not available in the underlying environment. It is a single-thread distribution. The application still gains a performance boost, but for larger files, the main thread load should be handled manually.

Integration

The WILL SDK for ink expects the plugin to be installed first. PluginsManager static property DEPENDENCIES_SRC defaults to '/node_modules'.

import {PluginsManager} from "digital-ink"// import in webpack envimport factory from "@digital-ink/wasm"// init application callbackasync init() {  ...  const singleThreadDistribution = (typeof SharedArrayBuffer == "undefined");  // mjs  const wasm = await PluginsManager.installWASM(singleThreadDistribution)  // webpack  const wasm =  PluginsManager.connectWASM(factory, singleThreadDistribution)  ...}

wasm namespace (install result)

  • Provides const string version.
  • Provides a function getExceptionMessage with argument exception message pointer.
  • Provides namespace workers when loaded distribution allows multi-threading; for single-thread distribution, this namespace is not available.

Webpack configuration

  • WASM is a low-level assembly-like language with a compact binary format that runs with near-native performance and provides languages such as C/C++, C# and Rust with a compilation target so that they can run on the web.
  • It can be run in modern web browsers. WASM does not allow bundling.
  • It is also designed to run alongside JavaScript, allowing both to work together.
  • Webpack would treat @digital-ink/wasm as an external dependency. To provide visibility for it, it should be accessible from webpack env. Webpack configuration should be extended. This configuration targets the copy-webpack-plugin plugin.
/* package.json */"devDependencies": {    ...    "copy-webpack-plugin": "^11.x"}

To update the webpack configuration:

/* config-overrides.js */const webpack = require("webpack");const CopyPlugin = require("copy-webpack-plugin");module.exports = function override(config, env) {    if (!config.eternals) {        config.externals = [];    }    if (!config.plugins) {        config.plugins = [];    }    config.externals = [...config.externals, "bindings"];    config.plugins.push(        new CopyPlugin({            patterns: [                {                  from: "node_modules/@digital-ink/wasm/native",                  to: "static/js/native"                }            ]        })    );    return config;}

License

End user license agreement for Wacom Ink SDK

Home