inklecate-wasm
Version:
A package bundling the desktop executable for inklecate, and all its dependencies, into a WebAssembly module executable fully in-browser.
35 lines (28 loc) • 1.3 kB
text/typescript
import {
assertValid,
} from 'ts-assertions';
const getModule = () => require('./mono/Module').Module;
const getRuntime = () => require('./mono/MonoRuntime').MonoRuntime;
export class WebAssemblyApp {
public static wasmSession: string;
public static readonly init = () => {
getRuntime().callMethod(WebAssemblyApp.mainMethod, null, []);
WebAssemblyApp.wasmSession = 'main';
};
public static readonly mainAssembly = assertValid<number>(
getRuntime().assemblyLoad(getModule().entryPoint.assemblyName),
`Could not find main module "${getModule().entryPoint.assemblyName}.dll".`,
);
public static readonly mainClass = assertValid<number>(
getRuntime().findClass(
WebAssemblyApp.mainAssembly,
getModule().entryPoint.namespace,
getModule().entryPoint.className,
),
`Could not find class "${getModule().entryPoint.className}" in module "${getModule().entryPoint.assemblyName}".`,
);
public static readonly mainMethod = assertValid<number>(
getRuntime().findMethod(WebAssemblyApp.mainClass, getModule().entryPoint.mainMethodName, -1),
`Could not find method "${getModule().entryPoint.mainMethodName}" in class "${WebAssemblyApp.mainClass}" of assembly "${WebAssemblyApp.mainAssembly}".`,
);
}