magjac / hpcc-js-wasm

HPCC-Systems Web-Assembly (JavaScript)

Home Page:https://hpcc-systems.github.io/hpcc-js-wasm/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@hpcc-js/wasm - Version 2

Tests Coverage Status

@hpcc-js/wasm is now an ESM by default package - this is a good thing, but does require some breaking changes.

This repository contains a collection of useful c++ libraries compiled to WASM for (re)use in Node JS, Web Browsers and JavaScript Libraries:

Built with:

Homepage and Documents

Quick Migration Example

v1.x.x

import { graphviz, wasmFolder } from "@hpcc-js/wasm";

wasmFolder("https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist");

const dot = "digraph G { Hello -> World }";

graphviz.dot(dot).then(svg => {
    const div = document.getElementById("placeholder");
    div.innerHTML = svg;    
});

graphvizVersion.then(version => console.log(version));

v2.x.x

import { Graphviz } from "@hpcc-js/wasm/graphviz";

const graphviz = await Graphviz.load();

const dot = "digraph G { Hello -> World }";
const svg = graphviz.dot(dot);
console.log(graphviz.version());

Notes:

  • Import must specify which wasm library your using
  • wasmFolder is no longer needed
  • All wasm libraries have the same asynchronous load pattern
    • const instance = await Wasm.load();

TypeScript Notes

When importing an ESM package AND referencing explicit exports (like @hpcc-js/wasm/graphviz or @hpcc-js/wasm/expat), you should change the following tsconfig.json setting:

  • moduleResolution: Node16

This will ensure the correct "types" are auto discovered.

About

HPCC-Systems Web-Assembly (JavaScript)

https://hpcc-systems.github.io/hpcc-js-wasm/

License:Apache License 2.0


Languages

Language:TypeScript 60.4%Language:CMake 17.1%Language:C++ 8.2%Language:JavaScript 7.2%Language:HTML 4.1%Language:C 1.7%Language:Shell 0.8%Language:Dockerfile 0.5%