Module

Hylograph.Kernel.WASM

Package
purescript-hylograph-wasm-kernel
Repository
afcondon/purescript-hylograph-wasm-kernel

The Rust/WASM force kernel of hylograph-simulation, carried inside this package: the compiled module travels as base64 in this module's foreign file, so nothing has to be built, served or fetched.

import Hylograph.Kernel.WASM as Kernel

main = launchAff_ do
  Kernel.install
  -- engine: WASM and Stepped.Rust now work

The foreign file is generated from the kernel's source by generate.mjs in this package's repository; its header names the kernel commit and the tools it was built with.

#load Source

load :: Aff KernelModule

Decode the embedded module, instantiate it, and give back the initialised kernel. No network request is made. The kernel is instantiated once per JavaScript realm; later calls give back the same one.

#install Source

install :: Aff Unit

load, then install the kernel into hylograph-simulation, so that engine: WASM (in Hylograph.Simulation) and Stepped.Rust work. If a kernel is already installed there (by this or by initWasm), that one stays: see Hylograph.ForceEngine.WASM.installKernel.

Re-exports from Hylograph.ForceEngine.WASM

#KernelModule Source

data KernelModule

The kernel's wasm-bindgen module, already instantiated: what the loader generated by wasm-pack (--target web) exports once its default export has been awaited, with Simulation among its exports. Made by whatever carries the module (the hylograph-wasm-kernel package makes one from bytes it carries) and handed to installKernel.