926 lines
38 KiB
JavaScript
926 lines
38 KiB
JavaScript
// Compiles a dart2wasm-generated main module from `source` which can then
|
|
// instantiatable via the `instantiate` method.
|
|
//
|
|
// `source` needs to be a `Response` object (or promise thereof) e.g. created
|
|
// via the `fetch()` JS API.
|
|
export async function compileStreaming(source) {
|
|
const builtins = {builtins: ['js-string']};
|
|
return new CompiledApp(
|
|
await WebAssembly.compileStreaming(source, builtins), builtins);
|
|
}
|
|
|
|
// Compiles a dart2wasm-generated wasm modules from `bytes` which is then
|
|
// instantiatable via the `instantiate` method.
|
|
export async function compile(bytes) {
|
|
const builtins = {builtins: ['js-string']};
|
|
return new CompiledApp(await WebAssembly.compile(bytes, builtins), builtins);
|
|
}
|
|
|
|
// DEPRECATED: Please use `compile` or `compileStreaming` to get a compiled app,
|
|
// use `instantiate` method to get an instantiated app and then call
|
|
// `invokeMain` to invoke the main function.
|
|
export async function instantiate(modulePromise, importObjectPromise) {
|
|
var moduleOrCompiledApp = await modulePromise;
|
|
if (!(moduleOrCompiledApp instanceof CompiledApp)) {
|
|
moduleOrCompiledApp = new CompiledApp(moduleOrCompiledApp);
|
|
}
|
|
const instantiatedApp = await moduleOrCompiledApp.instantiate(await importObjectPromise);
|
|
return instantiatedApp.instantiatedModule;
|
|
}
|
|
|
|
// DEPRECATED: Please use `compile` or `compileStreaming` to get a compiled app,
|
|
// use `instantiate` method to get an instantiated app and then call
|
|
// `invokeMain` to invoke the main function.
|
|
export const invoke = (moduleInstance, ...args) => {
|
|
moduleInstance.exports.$invokeMain(args);
|
|
}
|
|
|
|
class CompiledApp {
|
|
constructor(module, builtins) {
|
|
this.module = module;
|
|
this.builtins = builtins;
|
|
}
|
|
|
|
// The second argument is an options object containing:
|
|
// `loadDeferredModule` is a JS function that takes a module name matching a
|
|
// wasm file produced by the dart2wasm compiler and returns the bytes to
|
|
// load the module. These bytes can be in either a format supported by
|
|
// `WebAssembly.compile` or `WebAssembly.compileStreaming`.
|
|
// `loadDynamicModule` is a JS function that takes two string names matching,
|
|
// in order, a wasm file produced by the dart2wasm compiler during dynamic
|
|
// module compilation and a corresponding js file produced by the same
|
|
// compilation. It should return a JS Array containing 2 elements. The first
|
|
// should be the bytes for the wasm module in a format supported by
|
|
// `WebAssembly.compile` or `WebAssembly.compileStreaming`. The second
|
|
// should be the result of using the JS 'import' API on the js file path.
|
|
// `loadDeferredId` is a JS function that takes a string corresponding to a load
|
|
// ID generated by the compiler when 'load-ids' option is passed. Each load
|
|
// ID maps to one or more WASM modules produced by the compiler. This
|
|
// function should return an array of byte arrays corresponding to all the
|
|
// modules specified by that load ID. The arrays should be in a format
|
|
// supported by `WebAssembly.compile` or `WebAssembly.compileStreaming`.
|
|
async instantiate(additionalImports,
|
|
{loadDeferredModule, loadDynamicModule, loadDeferredId} = {}) {
|
|
let dartInstance;
|
|
|
|
// Prints to the console
|
|
function printToConsole(value) {
|
|
if (typeof dartPrint == "function") {
|
|
dartPrint(value);
|
|
return;
|
|
}
|
|
if (typeof console == "object" && typeof console.log != "undefined") {
|
|
console.log(value);
|
|
return;
|
|
}
|
|
if (typeof print == "function") {
|
|
print(value);
|
|
return;
|
|
}
|
|
|
|
throw "Unable to print message: " + value;
|
|
}
|
|
|
|
// A special symbol attached to functions that wrap Dart functions.
|
|
const jsWrappedDartFunctionSymbol = Symbol("JSWrappedDartFunction");
|
|
|
|
function finalizeWrapper(dartFunction, wrapped) {
|
|
wrapped.dartFunction = dartFunction;
|
|
wrapped[jsWrappedDartFunctionSymbol] = true;
|
|
return wrapped;
|
|
}
|
|
|
|
// Imports
|
|
const dart2wasm = {
|
|
_1: (decoder, codeUnits) => decoder.decode(codeUnits),
|
|
_2: () => new TextDecoder("utf-8", {fatal: true}),
|
|
_3: () => new TextDecoder("utf-8", {fatal: false}),
|
|
_4: (s) => +s,
|
|
_5: x0 => new Uint8Array(x0),
|
|
_6: (x0,x1,x2) => x0.set(x1,x2),
|
|
_7: (x0,x1) => x0.transferFromImageBitmap(x1),
|
|
_8: x0 => x0.arrayBuffer(),
|
|
_9: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._9(f,arguments.length,x0) }),
|
|
_10: x0 => new window.FinalizationRegistry(x0),
|
|
_11: (x0,x1,x2,x3) => x0.register(x1,x2,x3),
|
|
_12: (x0,x1) => x0.unregister(x1),
|
|
_13: (x0,x1,x2) => x0.slice(x1,x2),
|
|
_14: (x0,x1) => x0.decode(x1),
|
|
_15: (x0,x1) => x0.segment(x1),
|
|
_16: () => new TextDecoder(),
|
|
_18: x0 => x0.buffer,
|
|
_19: x0 => x0.wasmMemory,
|
|
_20: () => globalThis.window._flutter_skwasmInstance,
|
|
_21: x0 => x0.rasterStartMilliseconds,
|
|
_22: x0 => x0.rasterEndMilliseconds,
|
|
_23: x0 => x0.imageBitmaps,
|
|
_139: (x0,x1) => x0.appendChild(x1),
|
|
_170: (x0,x1,x2) => x0.addEventListener(x1,x2),
|
|
_171: (x0,x1,x2) => x0.removeEventListener(x1,x2),
|
|
_172: (x0,x1) => new OffscreenCanvas(x0,x1),
|
|
_173: x0 => x0.remove(),
|
|
_174: (x0,x1) => x0.append(x1),
|
|
_176: x0 => x0.unlock(),
|
|
_177: x0 => x0.getReader(),
|
|
_178: (x0,x1) => x0.item(x1),
|
|
_179: x0 => x0.next(),
|
|
_180: x0 => x0.now(),
|
|
_181: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._181(f,arguments.length,x0) }),
|
|
_182: (x0,x1) => x0.addListener(x1),
|
|
_183: (x0,x1) => x0.removeListener(x1),
|
|
_184: (x0,x1) => x0.matchMedia(x1),
|
|
_185: (x0,x1) => x0.revokeObjectURL(x1),
|
|
_186: x0 => x0.close(),
|
|
_187: (x0,x1,x2,x3,x4) => ({type: x0,data: x1,premultiplyAlpha: x2,colorSpaceConversion: x3,preferAnimation: x4}),
|
|
_188: x0 => new window.ImageDecoder(x0),
|
|
_189: (x0,x1) => ({frameIndex: x0,completeFramesOnly: x1}),
|
|
_190: (x0,x1) => x0.decode(x1),
|
|
_191: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._191(f,arguments.length,x0) }),
|
|
_192: (x0,x1,x2,x3) => x0.addEventListener(x1,x2,x3),
|
|
_194: (x0,x1) => x0.getModifierState(x1),
|
|
_195: x0 => x0.preventDefault(),
|
|
_196: x0 => x0.stopPropagation(),
|
|
_197: (x0,x1) => x0.removeProperty(x1),
|
|
_198: (x0,x1) => x0.prepend(x1),
|
|
_199: x0 => new Intl.Locale(x0),
|
|
_200: (x0,x1) => x0.observe(x1),
|
|
_201: x0 => x0.disconnect(),
|
|
_202: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._202(f,arguments.length,x0) }),
|
|
_203: (x0,x1) => x0.getAttribute(x1),
|
|
_204: (x0,x1) => x0.contains(x1),
|
|
_205: (x0,x1) => x0.querySelector(x1),
|
|
_206: x0 => x0.blur(),
|
|
_207: x0 => x0.hasFocus(),
|
|
_208: (x0,x1) => x0.removeAttribute(x1),
|
|
_209: (x0,x1,x2) => x0.insertBefore(x1,x2),
|
|
_210: (x0,x1) => x0.hasAttribute(x1),
|
|
_211: (x0,x1) => x0.getModifierState(x1),
|
|
_212: (x0,x1) => x0.createTextNode(x1),
|
|
_213: x0 => x0.getBoundingClientRect(),
|
|
_214: (x0,x1) => x0.closest(x1),
|
|
_651: x0 => new Uint8Array(x0),
|
|
_655: () => globalThis.window.flutterConfiguration,
|
|
_657: x0 => x0.assetBase,
|
|
_662: x0 => x0.canvasKitMaximumSurfaces,
|
|
_663: x0 => x0.debugShowSemanticsNodes,
|
|
_664: x0 => x0.hostElement,
|
|
_665: x0 => x0.multiViewEnabled,
|
|
_666: x0 => x0.nonce,
|
|
_668: x0 => x0.fontFallbackBaseUrl,
|
|
_678: x0 => x0.console,
|
|
_679: x0 => x0.devicePixelRatio,
|
|
_680: x0 => x0.document,
|
|
_681: x0 => x0.history,
|
|
_682: x0 => x0.innerHeight,
|
|
_683: x0 => x0.innerWidth,
|
|
_684: x0 => x0.location,
|
|
_685: x0 => x0.navigator,
|
|
_686: x0 => x0.visualViewport,
|
|
_687: x0 => x0.performance,
|
|
_689: x0 => x0.URL,
|
|
_691: (x0,x1) => x0.getComputedStyle(x1),
|
|
_692: x0 => x0.screen,
|
|
_693: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._693(f,arguments.length,x0) }),
|
|
_694: (x0,x1) => x0.requestAnimationFrame(x1),
|
|
_698: (x0,x1) => x0.warn(x1),
|
|
_700: (x0,x1) => x0.debug(x1),
|
|
_701: x0 => globalThis.parseFloat(x0),
|
|
_702: () => globalThis.window,
|
|
_703: () => globalThis.Intl,
|
|
_704: () => globalThis.Symbol,
|
|
_705: (x0,x1,x2,x3,x4) => globalThis.createImageBitmap(x0,x1,x2,x3,x4),
|
|
_707: x0 => x0.clipboard,
|
|
_708: x0 => x0.maxTouchPoints,
|
|
_709: x0 => x0.vendor,
|
|
_710: x0 => x0.language,
|
|
_711: x0 => x0.platform,
|
|
_712: x0 => x0.userAgent,
|
|
_713: (x0,x1) => x0.vibrate(x1),
|
|
_714: x0 => x0.languages,
|
|
_715: x0 => x0.documentElement,
|
|
_716: (x0,x1) => x0.querySelector(x1),
|
|
_717: (x0,x1) => x0.querySelectorAll(x1),
|
|
_719: (x0,x1) => x0.createElement(x1),
|
|
_722: (x0,x1) => x0.createEvent(x1),
|
|
_723: x0 => x0.activeElement,
|
|
_726: x0 => x0.head,
|
|
_727: x0 => x0.body,
|
|
_728: (x0,x1) => { x0.title = x1 },
|
|
_732: x0 => x0.visibilityState,
|
|
_733: () => globalThis.document,
|
|
_734: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._734(f,arguments.length,x0) }),
|
|
_735: (x0,x1) => x0.dispatchEvent(x1),
|
|
_743: x0 => x0.target,
|
|
_745: x0 => x0.timeStamp,
|
|
_746: x0 => x0.type,
|
|
_748: (x0,x1,x2,x3) => x0.initEvent(x1,x2,x3),
|
|
_754: x0 => x0.baseURI,
|
|
_755: x0 => x0.firstChild,
|
|
_759: x0 => x0.parentElement,
|
|
_761: (x0,x1) => { x0.textContent = x1 },
|
|
_762: x0 => x0.parentNode,
|
|
_763: x0 => x0.nextSibling,
|
|
_764: (x0,x1) => x0.removeChild(x1),
|
|
_765: x0 => x0.isConnected,
|
|
_773: x0 => x0.clientHeight,
|
|
_774: x0 => x0.clientWidth,
|
|
_775: x0 => x0.offsetHeight,
|
|
_776: x0 => x0.offsetWidth,
|
|
_777: x0 => x0.id,
|
|
_778: (x0,x1) => { x0.id = x1 },
|
|
_781: (x0,x1) => { x0.spellcheck = x1 },
|
|
_782: x0 => x0.tagName,
|
|
_783: x0 => x0.style,
|
|
_786: (x0,x1) => x0.querySelectorAll(x1),
|
|
_787: (x0,x1,x2) => x0.setAttribute(x1,x2),
|
|
_788: (x0,x1) => { x0.tabIndex = x1 },
|
|
_789: x0 => x0.tabIndex,
|
|
_790: (x0,x1) => x0.focus(x1),
|
|
_791: x0 => x0.scrollTop,
|
|
_792: (x0,x1) => { x0.scrollTop = x1 },
|
|
_793: x0 => x0.scrollLeft,
|
|
_794: (x0,x1) => { x0.scrollLeft = x1 },
|
|
_795: x0 => x0.classList,
|
|
_797: (x0,x1) => { x0.className = x1 },
|
|
_799: (x0,x1) => x0.getElementsByClassName(x1),
|
|
_800: x0 => x0.click(),
|
|
_801: (x0,x1) => x0.attachShadow(x1),
|
|
_804: x0 => x0.computedStyleMap(),
|
|
_805: (x0,x1) => x0.get(x1),
|
|
_811: (x0,x1) => x0.getPropertyValue(x1),
|
|
_812: (x0,x1,x2,x3) => x0.setProperty(x1,x2,x3),
|
|
_813: x0 => x0.offsetLeft,
|
|
_814: x0 => x0.offsetTop,
|
|
_815: x0 => x0.offsetParent,
|
|
_817: (x0,x1) => { x0.name = x1 },
|
|
_818: x0 => x0.content,
|
|
_819: (x0,x1) => { x0.content = x1 },
|
|
_823: (x0,x1) => { x0.src = x1 },
|
|
_824: x0 => x0.naturalWidth,
|
|
_825: x0 => x0.naturalHeight,
|
|
_829: (x0,x1) => { x0.crossOrigin = x1 },
|
|
_831: (x0,x1) => { x0.decoding = x1 },
|
|
_832: x0 => x0.decode(),
|
|
_837: (x0,x1) => { x0.nonce = x1 },
|
|
_841: (x0,x1) => { x0.width = x1 },
|
|
_844: (x0,x1) => { x0.height = x1 },
|
|
_847: (x0,x1) => x0.getContext(x1),
|
|
_914: x0 => x0.width,
|
|
_915: x0 => x0.height,
|
|
_917: (x0,x1) => x0.fetch(x1),
|
|
_918: x0 => x0.status,
|
|
_920: x0 => x0.body,
|
|
_921: x0 => x0.arrayBuffer(),
|
|
_924: x0 => x0.read(),
|
|
_925: x0 => x0.value,
|
|
_926: x0 => x0.done,
|
|
_933: x0 => x0.name,
|
|
_934: x0 => x0.x,
|
|
_935: x0 => x0.y,
|
|
_938: x0 => x0.top,
|
|
_939: x0 => x0.right,
|
|
_940: x0 => x0.bottom,
|
|
_941: x0 => x0.left,
|
|
_951: x0 => x0.height,
|
|
_952: x0 => x0.width,
|
|
_953: x0 => x0.scale,
|
|
_954: (x0,x1) => { x0.value = x1 },
|
|
_957: (x0,x1) => { x0.placeholder = x1 },
|
|
_959: (x0,x1) => { x0.name = x1 },
|
|
_960: x0 => x0.selectionDirection,
|
|
_961: x0 => x0.selectionStart,
|
|
_962: x0 => x0.selectionEnd,
|
|
_965: x0 => x0.value,
|
|
_967: (x0,x1,x2) => x0.setSelectionRange(x1,x2),
|
|
_968: x0 => x0.readText(),
|
|
_969: (x0,x1) => x0.writeText(x1),
|
|
_971: x0 => x0.altKey,
|
|
_972: x0 => x0.code,
|
|
_973: x0 => x0.ctrlKey,
|
|
_974: x0 => x0.key,
|
|
_975: x0 => x0.keyCode,
|
|
_976: x0 => x0.location,
|
|
_977: x0 => x0.metaKey,
|
|
_978: x0 => x0.repeat,
|
|
_979: x0 => x0.shiftKey,
|
|
_980: x0 => x0.isComposing,
|
|
_982: x0 => x0.state,
|
|
_983: (x0,x1) => x0.go(x1),
|
|
_985: (x0,x1,x2,x3) => x0.pushState(x1,x2,x3),
|
|
_986: (x0,x1,x2,x3) => x0.replaceState(x1,x2,x3),
|
|
_987: x0 => x0.pathname,
|
|
_988: x0 => x0.search,
|
|
_989: x0 => x0.hash,
|
|
_993: x0 => x0.state,
|
|
_996: (x0,x1) => x0.createObjectURL(x1),
|
|
_998: x0 => new Blob(x0),
|
|
_1008: x0 => x0.matches,
|
|
_1009: x0 => x0.matches,
|
|
_1013: x0 => x0.relatedTarget,
|
|
_1015: x0 => x0.clientX,
|
|
_1016: x0 => x0.clientY,
|
|
_1017: x0 => x0.offsetX,
|
|
_1018: x0 => x0.offsetY,
|
|
_1021: x0 => x0.button,
|
|
_1022: x0 => x0.buttons,
|
|
_1023: x0 => x0.ctrlKey,
|
|
_1027: x0 => x0.pointerId,
|
|
_1028: x0 => x0.pointerType,
|
|
_1029: x0 => x0.pressure,
|
|
_1030: x0 => x0.tiltX,
|
|
_1031: x0 => x0.tiltY,
|
|
_1032: x0 => x0.getCoalescedEvents(),
|
|
_1035: x0 => x0.deltaX,
|
|
_1036: x0 => x0.deltaY,
|
|
_1037: x0 => x0.wheelDeltaX,
|
|
_1038: x0 => x0.wheelDeltaY,
|
|
_1039: x0 => x0.deltaMode,
|
|
_1046: x0 => x0.changedTouches,
|
|
_1049: x0 => x0.clientX,
|
|
_1050: x0 => x0.clientY,
|
|
_1053: x0 => x0.data,
|
|
_1056: (x0,x1) => { x0.disabled = x1 },
|
|
_1058: (x0,x1) => { x0.type = x1 },
|
|
_1059: (x0,x1) => { x0.max = x1 },
|
|
_1060: (x0,x1) => { x0.min = x1 },
|
|
_1061: (x0,x1) => { x0.value = x1 },
|
|
_1062: x0 => x0.value,
|
|
_1063: x0 => x0.disabled,
|
|
_1064: (x0,x1) => { x0.disabled = x1 },
|
|
_1066: (x0,x1) => { x0.placeholder = x1 },
|
|
_1068: (x0,x1) => { x0.name = x1 },
|
|
_1069: (x0,x1) => { x0.autocomplete = x1 },
|
|
_1071: x0 => x0.selectionDirection,
|
|
_1072: x0 => x0.selectionStart,
|
|
_1074: x0 => x0.selectionEnd,
|
|
_1077: (x0,x1,x2) => x0.setSelectionRange(x1,x2),
|
|
_1078: (x0,x1) => x0.add(x1),
|
|
_1081: (x0,x1) => { x0.noValidate = x1 },
|
|
_1082: (x0,x1) => { x0.method = x1 },
|
|
_1083: (x0,x1) => { x0.action = x1 },
|
|
_1089: (x0,x1) => x0.getContext(x1),
|
|
_1091: x0 => x0.convertToBlob(),
|
|
_1108: x0 => x0.orientation,
|
|
_1109: x0 => x0.width,
|
|
_1110: x0 => x0.height,
|
|
_1111: (x0,x1) => x0.lock(x1),
|
|
_1130: x0 => new ResizeObserver(x0),
|
|
_1133: (module,f) => finalizeWrapper(f, function(x0,x1) { return module.exports._1133(f,arguments.length,x0,x1) }),
|
|
_1141: x0 => x0.length,
|
|
_1142: x0 => x0.iterator,
|
|
_1143: x0 => x0.Segmenter,
|
|
_1144: x0 => x0.v8BreakIterator,
|
|
_1145: (x0,x1) => new Intl.Segmenter(x0,x1),
|
|
_1148: x0 => x0.language,
|
|
_1149: x0 => x0.script,
|
|
_1150: x0 => x0.region,
|
|
_1168: x0 => x0.done,
|
|
_1169: x0 => x0.value,
|
|
_1170: x0 => x0.index,
|
|
_1174: (x0,x1) => new Intl.v8BreakIterator(x0,x1),
|
|
_1175: (x0,x1) => x0.adoptText(x1),
|
|
_1176: x0 => x0.first(),
|
|
_1177: x0 => x0.next(),
|
|
_1178: x0 => x0.current(),
|
|
_1191: x0 => x0.hostElement,
|
|
_1192: x0 => x0.viewConstraints,
|
|
_1195: x0 => x0.maxHeight,
|
|
_1196: x0 => x0.maxWidth,
|
|
_1197: x0 => x0.minHeight,
|
|
_1198: x0 => x0.minWidth,
|
|
_1199: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1199(f,arguments.length,x0) }),
|
|
_1200: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1200(f,arguments.length,x0) }),
|
|
_1201: (x0,x1) => ({addView: x0,removeView: x1}),
|
|
_1204: x0 => x0.loader,
|
|
_1205: () => globalThis._flutter,
|
|
_1206: (x0,x1) => x0.didCreateEngineInitializer(x1),
|
|
_1207: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1207(f,arguments.length,x0) }),
|
|
_1208: (module,f) => finalizeWrapper(f, function() { return module.exports._1208(f,arguments.length) }),
|
|
_1209: (x0,x1) => ({initializeEngine: x0,autoStart: x1}),
|
|
_1212: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1212(f,arguments.length,x0) }),
|
|
_1213: x0 => ({runApp: x0}),
|
|
_1215: (x0,x1,x2) => x0.call(x1,x2),
|
|
_1216: (module,f) => finalizeWrapper(f, function(x0,x1) { return module.exports._1216(f,arguments.length,x0,x1) }),
|
|
_1217: x0 => new Promise(x0),
|
|
_1218: x0 => x0.length,
|
|
_1219: () => globalThis.window.ImageDecoder,
|
|
_1220: x0 => x0.tracks,
|
|
_1222: x0 => x0.completed,
|
|
_1224: x0 => x0.image,
|
|
_1230: x0 => x0.displayWidth,
|
|
_1231: x0 => x0.displayHeight,
|
|
_1232: x0 => x0.duration,
|
|
_1235: x0 => x0.ready,
|
|
_1236: x0 => x0.selectedTrack,
|
|
_1237: x0 => x0.repetitionCount,
|
|
_1238: x0 => x0.frameCount,
|
|
_1290: (x0,x1) => x0.createElement(x1),
|
|
_1291: (x0,x1) => x0.querySelector(x1),
|
|
_1292: (x0,x1) => x0.appendChild(x1),
|
|
_1293: x0 => ({type: x0}),
|
|
_1294: (x0,x1) => new Blob(x0,x1),
|
|
_1295: x0 => globalThis.URL.createObjectURL(x0),
|
|
_1297: (x0,x1,x2,x3) => x0.sendCommand(x1,x2,x3),
|
|
_1298: () => globalThis.PdfiumWasmCommunicator,
|
|
_1300: x0 => { globalThis.pdfiumWasmWorkerUrl = x0 },
|
|
_1301: (x0,x1) => x0.writeText(x1),
|
|
_1302: x0 => x0.preventDefault(),
|
|
_1303: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1303(f,arguments.length,x0) }),
|
|
_1304: (x0,x1,x2) => x0.addEventListener(x1,x2),
|
|
_1305: x0 => x0.createRange(),
|
|
_1306: (x0,x1) => x0.selectNode(x1),
|
|
_1307: x0 => x0.getSelection(),
|
|
_1308: x0 => x0.removeAllRanges(),
|
|
_1309: (x0,x1) => x0.addRange(x1),
|
|
_1310: (x0,x1) => x0.createElement(x1),
|
|
_1311: (x0,x1) => x0.append(x1),
|
|
_1312: (x0,x1,x2) => x0.insertRule(x1,x2),
|
|
_1313: (x0,x1) => x0.add(x1),
|
|
_1314: x0 => x0.preventDefault(),
|
|
_1315: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1315(f,arguments.length,x0) }),
|
|
_1316: (x0,x1,x2) => x0.addEventListener(x1,x2),
|
|
_1317: (x0,x1,x2,x3) => x0.addEventListener(x1,x2,x3),
|
|
_1318: (x0,x1,x2,x3) => x0.removeEventListener(x1,x2,x3),
|
|
_1325: (x0,x1,x2,x3) => x0.open(x1,x2,x3),
|
|
_1335: x0 => x0.click(),
|
|
_1336: x0 => x0.remove(),
|
|
_1339: x0 => x0.createReader(),
|
|
_1340: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1340(f,arguments.length,x0) }),
|
|
_1341: (x0,x1) => x0.readEntries(x1),
|
|
_1342: () => new Blob(),
|
|
_1343: (x0,x1,x2,x3) => x0.slice(x1,x2,x3),
|
|
_1344: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1344(f,arguments.length,x0) }),
|
|
_1345: (x0,x1) => x0.file(x1),
|
|
_1346: x0 => x0.webkitGetAsEntry(),
|
|
_1347: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1347(f,arguments.length,x0) }),
|
|
_1348: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1348(f,arguments.length,x0) }),
|
|
_1349: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1349(f,arguments.length,x0) }),
|
|
_1350: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1350(f,arguments.length,x0) }),
|
|
_1352: (x0,x1) => x0.append(x1),
|
|
_1360: (x0,x1) => x0.getItem(x1),
|
|
_1362: (x0,x1,x2) => x0.setItem(x1,x2),
|
|
_1363: (x0,x1) => x0.item(x1),
|
|
_1364: () => new FileReader(),
|
|
_1366: (x0,x1) => x0.readAsArrayBuffer(x1),
|
|
_1367: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1367(f,arguments.length,x0) }),
|
|
_1368: (x0,x1,x2) => x0.removeEventListener(x1,x2),
|
|
_1369: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1369(f,arguments.length,x0) }),
|
|
_1370: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1370(f,arguments.length,x0) }),
|
|
_1371: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1371(f,arguments.length,x0) }),
|
|
_1372: (x0,x1) => x0.removeChild(x1),
|
|
_1379: Date.now,
|
|
_1381: s => new Date(s * 1000).getTimezoneOffset() * 60,
|
|
_1382: s => {
|
|
if (!/^\s*[+-]?(?:Infinity|NaN|(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s*$/.test(s)) {
|
|
return NaN;
|
|
}
|
|
return parseFloat(s);
|
|
},
|
|
_1383: () => new Error().stack,
|
|
_1384: () => typeof dartUseDateNowForTicks !== "undefined",
|
|
_1385: () => 1000 * performance.now(),
|
|
_1386: () => Date.now(),
|
|
_1388: () => {
|
|
return typeof process != "undefined" &&
|
|
Object.prototype.toString.call(process) == "[object process]" &&
|
|
process.platform == "win32"
|
|
},
|
|
_1389: () => new WeakMap(),
|
|
_1390: (map, o) => map.get(o),
|
|
_1391: (map, o, v) => map.set(o, v),
|
|
_1392: (exn) => exn.toString(),
|
|
_1393: (exn) => exn.stack,
|
|
_1394: (exn) => {
|
|
let stackString = exn.toString();
|
|
let frames = stackString.split('\n');
|
|
let drop = 2;
|
|
if (frames[0] === 'Error') {
|
|
drop += 1;
|
|
}
|
|
return frames.slice(drop).join('\n');
|
|
},
|
|
_1395: x0 => new WeakRef(x0),
|
|
_1396: x0 => x0.deref(),
|
|
_1403: () => globalThis.WeakRef,
|
|
_1407: s => JSON.stringify(s),
|
|
_1408: s => printToConsole(s),
|
|
_1409: (o, p, r) => o.replaceAll(p, () => r),
|
|
_1411: Function.prototype.call.bind(String.prototype.toLowerCase),
|
|
_1412: s => s.toUpperCase(),
|
|
_1413: s => s.trim(),
|
|
_1414: s => s.trimLeft(),
|
|
_1415: s => s.trimRight(),
|
|
_1416: (string, times) => string.repeat(times),
|
|
_1417: Function.prototype.call.bind(String.prototype.indexOf),
|
|
_1418: (s, p, i) => s.lastIndexOf(p, i),
|
|
_1419: (string, token) => string.split(token),
|
|
_1420: Object.is,
|
|
_1424: (o, c) => o instanceof c,
|
|
_1425: o => Object.keys(o),
|
|
_1428: (o, a) => o + a,
|
|
_1455: x0 => new Array(x0),
|
|
_1457: x0 => x0.length,
|
|
_1459: (x0,x1) => x0[x1],
|
|
_1460: (x0,x1,x2) => { x0[x1] = x2 },
|
|
_1463: (x0,x1,x2) => new DataView(x0,x1,x2),
|
|
_1465: x0 => new Int8Array(x0),
|
|
_1466: (x0,x1,x2) => new Uint8Array(x0,x1,x2),
|
|
_1468: x0 => new Uint8ClampedArray(x0),
|
|
_1470: x0 => new Int16Array(x0),
|
|
_1472: x0 => new Uint16Array(x0),
|
|
_1474: x0 => new Int32Array(x0),
|
|
_1476: x0 => new Uint32Array(x0),
|
|
_1478: x0 => new Float32Array(x0),
|
|
_1480: x0 => new Float64Array(x0),
|
|
_1504: x0 => x0.random(),
|
|
_1505: (x0,x1) => x0.getRandomValues(x1),
|
|
_1506: () => globalThis.crypto,
|
|
_1507: () => globalThis.Math,
|
|
_1520: (ms, c) =>
|
|
setTimeout(() => dartInstance.exports.$invokeCallback(c),ms),
|
|
_1521: (handle) => clearTimeout(handle),
|
|
_1522: (ms, c) =>
|
|
setInterval(() => dartInstance.exports.$invokeCallback(c), ms),
|
|
_1523: (handle) => clearInterval(handle),
|
|
_1524: (c) =>
|
|
queueMicrotask(() => dartInstance.exports.$invokeCallback(c)),
|
|
_1525: () => Date.now(),
|
|
_1526: (s, m) => {
|
|
try {
|
|
return new RegExp(s, m);
|
|
} catch (e) {
|
|
return String(e);
|
|
}
|
|
},
|
|
_1527: (x0,x1) => x0.exec(x1),
|
|
_1528: (x0,x1) => x0.test(x1),
|
|
_1529: x0 => x0.pop(),
|
|
_1531: o => o === undefined,
|
|
_1533: o => typeof o === 'function' && o[jsWrappedDartFunctionSymbol] === true,
|
|
_1535: o => {
|
|
const proto = Object.getPrototypeOf(o);
|
|
return proto === Object.prototype || proto === null;
|
|
},
|
|
_1536: o => o instanceof RegExp,
|
|
_1537: (l, r) => l === r,
|
|
_1538: o => o,
|
|
_1539: o => o,
|
|
_1540: o => o,
|
|
_1541: b => !!b,
|
|
_1542: o => o.length,
|
|
_1544: (o, i) => o[i],
|
|
_1545: f => f.dartFunction,
|
|
_1546: () => ({}),
|
|
_1547: () => [],
|
|
_1549: () => globalThis,
|
|
_1550: (constructor, args) => {
|
|
const factoryFunction = constructor.bind.apply(
|
|
constructor, [null, ...args]);
|
|
return new factoryFunction();
|
|
},
|
|
_1551: (o, p) => p in o,
|
|
_1552: (o, p) => o[p],
|
|
_1553: (o, p, v) => o[p] = v,
|
|
_1554: (o, m, a) => o[m].apply(o, a),
|
|
_1556: o => String(o),
|
|
_1557: (p, s, f) => p.then(s, (e) => f(e, e === undefined)),
|
|
_1558: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1558(f,arguments.length,x0) }),
|
|
_1559: (module,f) => finalizeWrapper(f, function(x0,x1) { return module.exports._1559(f,arguments.length,x0,x1) }),
|
|
_1560: o => {
|
|
if (o === undefined) return 1;
|
|
var type = typeof o;
|
|
if (type === 'boolean') return 2;
|
|
if (type === 'number') return 3;
|
|
if (type === 'string') return 4;
|
|
if (o instanceof Array) return 5;
|
|
if (ArrayBuffer.isView(o)) {
|
|
if (o instanceof Int8Array) return 6;
|
|
if (o instanceof Uint8Array) return 7;
|
|
if (o instanceof Uint8ClampedArray) return 8;
|
|
if (o instanceof Int16Array) return 9;
|
|
if (o instanceof Uint16Array) return 10;
|
|
if (o instanceof Int32Array) return 11;
|
|
if (o instanceof Uint32Array) return 12;
|
|
if (o instanceof Float32Array) return 13;
|
|
if (o instanceof Float64Array) return 14;
|
|
if (o instanceof DataView) return 15;
|
|
}
|
|
if (o instanceof ArrayBuffer) return 16;
|
|
// Feature check for `SharedArrayBuffer` before doing a type-check.
|
|
if (globalThis.SharedArrayBuffer !== undefined &&
|
|
o instanceof SharedArrayBuffer) {
|
|
return 17;
|
|
}
|
|
if (o instanceof Promise) return 18;
|
|
return 19;
|
|
},
|
|
_1561: o => [o],
|
|
_1562: (o0, o1) => [o0, o1],
|
|
_1563: (o0, o1, o2) => [o0, o1, o2],
|
|
_1564: (o0, o1, o2, o3) => [o0, o1, o2, o3],
|
|
_1565: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
|
|
const getValue = dartInstance.exports.$wasmI8ArrayGet;
|
|
for (let i = 0; i < length; i++) {
|
|
jsArray[jsArrayOffset + i] = getValue(wasmArray, wasmArrayOffset + i);
|
|
}
|
|
},
|
|
_1566: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
|
|
const setValue = dartInstance.exports.$wasmI8ArraySet;
|
|
for (let i = 0; i < length; i++) {
|
|
setValue(wasmArray, wasmArrayOffset + i, jsArray[jsArrayOffset + i]);
|
|
}
|
|
},
|
|
_1567: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
|
|
const getValue = dartInstance.exports.$wasmI16ArrayGet;
|
|
for (let i = 0; i < length; i++) {
|
|
jsArray[jsArrayOffset + i] = getValue(wasmArray, wasmArrayOffset + i);
|
|
}
|
|
},
|
|
_1568: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
|
|
const setValue = dartInstance.exports.$wasmI16ArraySet;
|
|
for (let i = 0; i < length; i++) {
|
|
setValue(wasmArray, wasmArrayOffset + i, jsArray[jsArrayOffset + i]);
|
|
}
|
|
},
|
|
_1569: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
|
|
const getValue = dartInstance.exports.$wasmI32ArrayGet;
|
|
for (let i = 0; i < length; i++) {
|
|
jsArray[jsArrayOffset + i] = getValue(wasmArray, wasmArrayOffset + i);
|
|
}
|
|
},
|
|
_1570: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
|
|
const setValue = dartInstance.exports.$wasmI32ArraySet;
|
|
for (let i = 0; i < length; i++) {
|
|
setValue(wasmArray, wasmArrayOffset + i, jsArray[jsArrayOffset + i]);
|
|
}
|
|
},
|
|
_1571: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
|
|
const getValue = dartInstance.exports.$wasmF32ArrayGet;
|
|
for (let i = 0; i < length; i++) {
|
|
jsArray[jsArrayOffset + i] = getValue(wasmArray, wasmArrayOffset + i);
|
|
}
|
|
},
|
|
_1572: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
|
|
const setValue = dartInstance.exports.$wasmF32ArraySet;
|
|
for (let i = 0; i < length; i++) {
|
|
setValue(wasmArray, wasmArrayOffset + i, jsArray[jsArrayOffset + i]);
|
|
}
|
|
},
|
|
_1573: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
|
|
const getValue = dartInstance.exports.$wasmF64ArrayGet;
|
|
for (let i = 0; i < length; i++) {
|
|
jsArray[jsArrayOffset + i] = getValue(wasmArray, wasmArrayOffset + i);
|
|
}
|
|
},
|
|
_1574: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
|
|
const setValue = dartInstance.exports.$wasmF64ArraySet;
|
|
for (let i = 0; i < length; i++) {
|
|
setValue(wasmArray, wasmArrayOffset + i, jsArray[jsArrayOffset + i]);
|
|
}
|
|
},
|
|
_1575: x0 => new ArrayBuffer(x0),
|
|
_1576: s => {
|
|
if (/[[\]{}()*+?.\\^$|]/.test(s)) {
|
|
s = s.replace(/[[\]{}()*+?.\\^$|]/g, '\\$&');
|
|
}
|
|
return s;
|
|
},
|
|
_1578: x0 => x0.index,
|
|
_1579: x0 => x0.groups,
|
|
_1580: x0 => x0.flags,
|
|
_1581: x0 => x0.multiline,
|
|
_1582: x0 => x0.ignoreCase,
|
|
_1583: x0 => x0.unicode,
|
|
_1584: x0 => x0.dotAll,
|
|
_1585: (x0,x1) => { x0.lastIndex = x1 },
|
|
_1586: (o, p) => p in o,
|
|
_1587: (o, p) => o[p],
|
|
_1590: () => new XMLHttpRequest(),
|
|
_1591: (x0,x1,x2,x3) => x0.open(x1,x2,x3),
|
|
_1595: x0 => x0.send(),
|
|
_1597: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1597(f,arguments.length,x0) }),
|
|
_1598: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._1598(f,arguments.length,x0) }),
|
|
_1614: (x0,x1) => x0.key(x1),
|
|
_1615: o => o instanceof Array,
|
|
_1616: (a, i) => a.push(i),
|
|
_1619: (a, l) => a.length = l,
|
|
_1620: a => a.pop(),
|
|
_1621: (a, i) => a.splice(i, 1),
|
|
_1623: (a, s, e) => a.slice(s, e),
|
|
_1626: a => a.length,
|
|
_1627: (a, l) => a.length = l,
|
|
_1628: (a, i) => a[i],
|
|
_1629: (a, i, v) => a[i] = v,
|
|
_1631: o => {
|
|
if (o instanceof ArrayBuffer) return 0;
|
|
if (globalThis.SharedArrayBuffer !== undefined &&
|
|
o instanceof SharedArrayBuffer) {
|
|
return 1;
|
|
}
|
|
return 2;
|
|
},
|
|
_1632: (o, offsetInBytes, lengthInBytes) => {
|
|
var dst = new ArrayBuffer(lengthInBytes);
|
|
new Uint8Array(dst).set(new Uint8Array(o, offsetInBytes, lengthInBytes));
|
|
return new DataView(dst);
|
|
},
|
|
_1634: o => o instanceof Uint8Array,
|
|
_1635: (o, start, length) => new Uint8Array(o.buffer, o.byteOffset + start, length),
|
|
_1636: o => o instanceof Int8Array,
|
|
_1637: (o, start, length) => new Int8Array(o.buffer, o.byteOffset + start, length),
|
|
_1638: o => o instanceof Uint8ClampedArray,
|
|
_1639: (o, start, length) => new Uint8ClampedArray(o.buffer, o.byteOffset + start, length),
|
|
_1640: o => o instanceof Uint16Array,
|
|
_1641: (o, start, length) => new Uint16Array(o.buffer, o.byteOffset + start, length),
|
|
_1642: o => o instanceof Int16Array,
|
|
_1643: (o, start, length) => new Int16Array(o.buffer, o.byteOffset + start, length),
|
|
_1644: o => o instanceof Uint32Array,
|
|
_1645: (o, start, length) => new Uint32Array(o.buffer, o.byteOffset + start, length),
|
|
_1646: o => o instanceof Int32Array,
|
|
_1647: (o, start, length) => new Int32Array(o.buffer, o.byteOffset + start, length),
|
|
_1649: (o, start, length) => new BigInt64Array(o.buffer, o.byteOffset + start, length),
|
|
_1650: o => o instanceof Float32Array,
|
|
_1651: (o, start, length) => new Float32Array(o.buffer, o.byteOffset + start, length),
|
|
_1652: o => o instanceof Float64Array,
|
|
_1653: (o, start, length) => new Float64Array(o.buffer, o.byteOffset + start, length),
|
|
_1654: (t, s) => t.set(s),
|
|
_1655: l => new DataView(new ArrayBuffer(l)),
|
|
_1656: (o) => new DataView(o.buffer, o.byteOffset, o.byteLength),
|
|
_1657: o => o.byteLength,
|
|
_1658: o => o.buffer,
|
|
_1659: o => o.byteOffset,
|
|
_1660: Function.prototype.call.bind(Object.getOwnPropertyDescriptor(DataView.prototype, 'byteLength').get),
|
|
_1661: (b, o) => new DataView(b, o),
|
|
_1662: (b, o, l) => new DataView(b, o, l),
|
|
_1663: Function.prototype.call.bind(DataView.prototype.getUint8),
|
|
_1664: Function.prototype.call.bind(DataView.prototype.setUint8),
|
|
_1665: Function.prototype.call.bind(DataView.prototype.getInt8),
|
|
_1666: Function.prototype.call.bind(DataView.prototype.setInt8),
|
|
_1667: Function.prototype.call.bind(DataView.prototype.getUint16),
|
|
_1668: Function.prototype.call.bind(DataView.prototype.setUint16),
|
|
_1669: Function.prototype.call.bind(DataView.prototype.getInt16),
|
|
_1670: Function.prototype.call.bind(DataView.prototype.setInt16),
|
|
_1671: Function.prototype.call.bind(DataView.prototype.getUint32),
|
|
_1672: Function.prototype.call.bind(DataView.prototype.setUint32),
|
|
_1673: Function.prototype.call.bind(DataView.prototype.getInt32),
|
|
_1674: Function.prototype.call.bind(DataView.prototype.setInt32),
|
|
_1677: Function.prototype.call.bind(DataView.prototype.getBigInt64),
|
|
_1678: Function.prototype.call.bind(DataView.prototype.setBigInt64),
|
|
_1679: Function.prototype.call.bind(DataView.prototype.getFloat32),
|
|
_1680: Function.prototype.call.bind(DataView.prototype.setFloat32),
|
|
_1681: Function.prototype.call.bind(DataView.prototype.getFloat64),
|
|
_1682: Function.prototype.call.bind(DataView.prototype.setFloat64),
|
|
_1683: Function.prototype.call.bind(Number.prototype.toString),
|
|
_1684: Function.prototype.call.bind(BigInt.prototype.toString),
|
|
_1685: Function.prototype.call.bind(Number.prototype.toString),
|
|
_1686: (d, digits) => d.toFixed(digits),
|
|
_1709: () => globalThis.document,
|
|
_1710: () => globalThis.window,
|
|
_1715: (x0,x1) => { x0.height = x1 },
|
|
_1717: (x0,x1) => { x0.width = x1 },
|
|
_1722: x0 => x0.head,
|
|
_1723: x0 => x0.classList,
|
|
_1727: (x0,x1) => { x0.innerText = x1 },
|
|
_1728: x0 => x0.style,
|
|
_1730: x0 => x0.sheet,
|
|
_1741: x0 => x0.offsetX,
|
|
_1742: x0 => x0.offsetY,
|
|
_1743: x0 => x0.button,
|
|
_1802: (x0,x1) => { x0.responseType = x1 },
|
|
_1803: x0 => x0.response,
|
|
_1863: (x0,x1) => { x0.draggable = x1 },
|
|
_1879: x0 => x0.style,
|
|
_2132: x0 => x0.content,
|
|
_2238: (x0,x1) => { x0.download = x1 },
|
|
_2263: (x0,x1) => { x0.href = x1 },
|
|
_2808: (x0,x1) => { x0.accept = x1 },
|
|
_2822: x0 => x0.files,
|
|
_2848: (x0,x1) => { x0.multiple = x1 },
|
|
_2866: (x0,x1) => { x0.type = x1 },
|
|
_3116: (x0,x1) => { x0.src = x1 },
|
|
_3118: (x0,x1) => { x0.type = x1 },
|
|
_3122: (x0,x1) => { x0.async = x1 },
|
|
_3136: (x0,x1) => { x0.charset = x1 },
|
|
_3567: x0 => x0.items,
|
|
_3570: (x0,x1) => x0[x1],
|
|
_3574: x0 => x0.length,
|
|
_3580: x0 => x0.dataTransfer,
|
|
_3584: () => globalThis.window,
|
|
_3627: x0 => x0.location,
|
|
_3646: x0 => x0.navigator,
|
|
_3717: (x0,x1) => { x0.ondragenter = x1 },
|
|
_3719: (x0,x1) => { x0.ondragleave = x1 },
|
|
_3721: (x0,x1) => { x0.ondragover = x1 },
|
|
_3725: (x0,x1) => { x0.ondrop = x1 },
|
|
_3910: x0 => x0.localStorage,
|
|
_3918: x0 => x0.href,
|
|
_4012: x0 => x0.clipboard,
|
|
_4033: x0 => x0.userAgent,
|
|
_4034: x0 => x0.vendor,
|
|
_4241: x0 => x0.length,
|
|
_6145: x0 => x0.type,
|
|
_6247: x0 => x0.firstChild,
|
|
_6258: () => globalThis.document,
|
|
_6340: x0 => x0.body,
|
|
_6672: (x0,x1) => { x0.id = x1 },
|
|
_6699: x0 => x0.children,
|
|
_7005: x0 => x0.clientX,
|
|
_7006: x0 => x0.clientY,
|
|
_8200: x0 => x0.size,
|
|
_8201: x0 => x0.type,
|
|
_8207: x0 => x0.name,
|
|
_8208: x0 => x0.lastModified,
|
|
_8213: x0 => x0.length,
|
|
_8218: x0 => x0.result,
|
|
_11126: (x0,x1) => { x0.display = x1 },
|
|
_13033: x0 => x0.isDirectory,
|
|
_13034: x0 => x0.name,
|
|
_13035: x0 => x0.fullPath,
|
|
|
|
};
|
|
|
|
const baseImports = {
|
|
dart2wasm: dart2wasm,
|
|
Math: Math,
|
|
Date: Date,
|
|
Object: Object,
|
|
Array: Array,
|
|
Reflect: Reflect,
|
|
WebAssembly: {
|
|
JSTag: WebAssembly.JSTag,
|
|
},
|
|
"": new Proxy({}, { get(_, prop) { return prop; } }),
|
|
|
|
};
|
|
|
|
const jsStringPolyfill = {
|
|
"charCodeAt": (s, i) => s.charCodeAt(i),
|
|
"compare": (s1, s2) => {
|
|
if (s1 < s2) return -1;
|
|
if (s1 > s2) return 1;
|
|
return 0;
|
|
},
|
|
"concat": (s1, s2) => s1 + s2,
|
|
"equals": (s1, s2) => s1 === s2,
|
|
"fromCharCode": (i) => String.fromCharCode(i),
|
|
"length": (s) => s.length,
|
|
"substring": (s, a, b) => s.substring(a, b),
|
|
"fromCharCodeArray": (a, start, end) => {
|
|
if (end <= start) return '';
|
|
|
|
const read = dartInstance.exports.$wasmI16ArrayGet;
|
|
let result = '';
|
|
let index = start;
|
|
const chunkLength = Math.min(end - index, 500);
|
|
let array = new Array(chunkLength);
|
|
while (index < end) {
|
|
const newChunkLength = Math.min(end - index, 500);
|
|
for (let i = 0; i < newChunkLength; i++) {
|
|
array[i] = read(a, index++);
|
|
}
|
|
if (newChunkLength < chunkLength) {
|
|
array = array.slice(0, newChunkLength);
|
|
}
|
|
result += String.fromCharCode(...array);
|
|
}
|
|
return result;
|
|
},
|
|
"intoCharCodeArray": (s, a, start) => {
|
|
if (s === '') return 0;
|
|
|
|
const write = dartInstance.exports.$wasmI16ArraySet;
|
|
for (var i = 0; i < s.length; ++i) {
|
|
write(a, start++, s.charCodeAt(i));
|
|
}
|
|
return s.length;
|
|
},
|
|
"test": (s) => typeof s == "string",
|
|
};
|
|
|
|
|
|
|
|
|
|
dartInstance = await WebAssembly.instantiate(this.module, {
|
|
...baseImports,
|
|
...additionalImports,
|
|
|
|
"wasm:js-string": jsStringPolyfill,
|
|
});
|
|
dartInstance.exports.$setThisModule(dartInstance);
|
|
|
|
return new InstantiatedApp(this, dartInstance);
|
|
}
|
|
}
|
|
|
|
class InstantiatedApp {
|
|
constructor(compiledApp, instantiatedModule) {
|
|
this.compiledApp = compiledApp;
|
|
this.instantiatedModule = instantiatedModule;
|
|
}
|
|
|
|
// Call the main function with the given arguments.
|
|
invokeMain(...args) {
|
|
this.instantiatedModule.exports.$invokeMain(args);
|
|
}
|
|
}
|