AvoidLib.load() looks for libavoid.wasm next to the JS file that loads it.
If your bundler or server puts the wasm somewhere else, pass its URL:
await AvoidLib.load('/assets/libavoid.wasm');
The file to serve is node_modules/libavoid-js/dist/libavoid.wasm.
RuntimeError: Aborted(CompileError: WebAssembly.instantiate(): expected magic word ...The libavoid.wasm the browser received is not a valid wasm file, typically an
HTML error page or a file mangled by a dev server. Check in the Network tab of
the browser that it is downloaded without errors and that its size is the same
as that of the libavoid.wasm file.
AvoidLib.load() fails with
RuntimeError: Aborted(CompileError: WebAssembly.instantiate(): Wasm code generation disallowed by embedder)
or, in a browser, a CompileError that refers to the Content Security Policy.
The environment does not allow compiling WebAssembly:
Content Security Policy: add 'wasm-unsafe-eval' to its script-src
directive. It allows compiling WebAssembly, not eval() of JavaScript.
A runtime that does not allow compiling WebAssembly, but compiles the
.wasm files you import: import libavoid-js/libavoid.wasm and pass the
WebAssembly.Module you get to load(), which then only instantiates it:
import wasmModule from "libavoid-js/libavoid.wasm";
import { AvoidLib } from "libavoid-js";
await AvoidLib.load(wasmModule);
If TypeScript reports Cannot find module 'libavoid-js/libavoid.wasm' and
your runtime's types do not declare .wasm imports, declare them yourself:
declare module "*.wasm" {
const module: WebAssembly.Module;
export default module;
}
Avoid library should be initialized before usingAvoidLib.getInstance() was called before
await AvoidLib.load() finished.
index.htmlBrowsers do not load wasm from file:// URLs. Serve the directory with an
HTTP server, e.g. npx http-server examples.
false, the router found no
route, for example because pin directions or obstacles rule out every path,
and fell back to a straight line.{ shape, pin }. A shape's bounds
passed as an end are read as a free { x, y } point; see
Connectors.TypeError or RangeError from a methodArguments are checked before they reach wasm, and the message names the method
and the argument, e.g.
Router.setRoutingParameter: invalid RoutingParameter value 9. A misspelt enum
name such as Avoid.ConnType.Orthogonal is undefined and throws a
TypeError; a number that is not a value of the enum throws a RangeError.
The @throws sections of the API reference list the errors of each method.
Ask in GitHub Issues.