wasmer-pack 0.7.1

A code generator that lets you treat WebAssembly modules like native dependencies.
Documentation
// @ts-ignore
{%- if has_wasi_libraries %}
import type { WasiConfig } from "@wasmer/wasi";
{%- endif %}

{%- for lib in libraries %}
import { {{lib.exports.class_name}} as _{{lib.exports.class_name}} } from "./{{lib.exports.interface_name}}/{{lib.exports.interface_name}}";
{%- for import in lib.imports %}
import { {{import.class_name}} as _{{lib.exports.class_name}}__{{import.class_name}} } from "./{{lib.exports.interface_name}}/{{import.interface_name}}";
{%- endfor %}
{%- endfor %}

/**
 * Options used when initializing the bindings.
 */
export type LoadOptions = {
    /** Additional imports to be provided to the WebAssembly module */
    imports: WebAssembly.Imports,
    /**
     * A user-specified WebAssembly module to use instead of the one bundled
     * with this package.
     */
    module: WebAssembly.Module,
};

{%- if has_wasi_libraries %}
/**
* Extended options used when loading a WASI library.
 */
export type WasiLoadOptions = LoadOptions & {
    /** Configuration used to initialize the WASI environment. */
    wasi: Partial<WasiConfig>,
};
{%- endif %}

export default class Bindings {
    {%- for lib in libraries %}
    {%- if lib.wasi %}
    {{lib.ident}}(
        {%- for import in lib.imports %}{{import.interface_name}}: _{{lib.exports.class_name}}__{{import.class_name}},  {% endfor -%}
        options?: Partial<WasiLoadOptions>): Promise<_{{lib.exports.class_name}}>;
    {%- else %}
    {{lib.ident}}(
        {%- for import in lib.imports %}{{import.interface_name}}: _{{lib.exports.class_name}}__{{import.class_name}}, {% endfor -%}
        options?: Partial<LoadOptions>): Promise<_{{lib.exports.class_name}}>;
    {%- endif %}
    {%- endfor %}
}