@howso/engine
TypeScript icon, indicating that this package has built-in type declarations

4.0.3 • Public • Published

Introduction

An interface surrounding @howso/amalgam-lang WASM to create a simplified client.

Getting Started

Install dependencies

npm install @howso/engine

Create a client using a Worker

import { AmalgamWasmService, initRuntime } from "@howso/amalgam-lang";
import wasmDataUri from "@howso/amalgam-lang/lib/amalgam-st.data?url";
import wasmUri from "@howso/amalgam-lang/lib/amalgam-st.wasm?url";

(async function () {
  const svc = new AmalgamWasmService((options) => {
    return initRuntime(options, {
      locateFile: (path: string) => {
        // Override file paths so we can use hashed version in build
        if (path.endsWith("amalgam-st.wasm")) {
          return wasmUri;
        } else if (path.endsWith("amalgam-st.data")) {
          return wasmDataUri;
        }
        return self.location.href + path;
      },
    });
  });
  self.onmessage = async (ev) => {
    svc.dispatch(ev);
  };
  self.postMessage({ type: "event", event: "ready" });
})();

You can then create the worker client using a url import:

import howsoUrl from "@/data/engine/howso.caml?url";
import migrationsUrl from "@/data/engine/migrations.caml?url";
import { type ClientOptions, Trainee, WasmClient } from "@howso/engine";

const getClient = async (): Promise<WasmClient> => {
  const worker = new Worker(new URL("@/workers/AmalgamWorker", import.meta.url), { type: "module" });
  const client = new WasmClient(worker, {
    howsoUrl,
    migrationsUrl,
    ...options,
  });
  return client.setup();
};

Publishing

Documentation changes do not require a version publishing. For functional changes, follow SemVer standards updating the package.json and package-lock.json files in your pull request.

When you are ready to publish a new version, use the Github Release action.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 4.0.3
    68
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 4.0.3
    68
  • 4.0.2
    70

Package Sidebar

Install

npm i @howso/engine

Weekly Downloads

138

Version

4.0.3

License

AGPL-3.0-only

Unpacked Size

541 kB

Total Files

127

Last publish

Collaborators

  • lance.gliser
  • wgoddin
  • dmglennie