(function() {
var elem = document.querySelector('#output');
window.mergedLibrary = {};
window.wasmExports = {
__wbindgen_start: () => {},
__wbg_wasmbindgentestcontext_free: () => {},
__wbg_interval_free: () => {}
};
window.cachedTextEncoder = { encodeInto: () => {} };
window.cachedTextDecoder = { decode: () => {} };
window.Module = {};
window.addToLibrary = function(obj) {
Object.assign(window.mergedLibrary, obj);
};
var DECORATORS = ['__deps', '__postset', '__export', '__force'];
function isDecorator(key) {
return DECORATORS.some(function(d) { return key.endsWith(d); });
}
setTimeout(function() {
try {
if (typeof window.mergedLibrary.$initBindgen !== 'function') {
throw new Error("$initBindgen not found in the merged library.");
}
window.mergedLibrary.$initBindgen();
window.exportedSymbols = new Set();
for (const key of Object.keys(window.mergedLibrary)) {
if (!key.startsWith('$') || isDecorator(key)) continue;
if (window.mergedLibrary[key + '__export'] === true) {
window.exportedSymbols.add(key.slice(1));
}
}
for (const name of window.exportedSymbols) {
window.Module[name] = window.mergedLibrary['$' + name];
}
} catch (e) {
elem.textContent += 'test setup failed: ' + e;
return;
}
function testInitBindgenForced() {
if (window.mergedLibrary.$initBindgen__force !== true) {
return { status: false, e: 'test result: $initBindgen is not __force: true' };
}
const deps = window.mergedLibrary.$initBindgen__deps || [];
const required = ['$addOnInit', '$CLOSURE_DTORS', '$WASM_VECTOR_LEN'];
for (const value of required) {
if (!deps.includes(value)) {
return { status: false, e: `test result: ${value} not found in $initBindgen__deps` };
}
}
return { status: true, e: 'test result: ok' };
}
function testModuleExports() {
if (typeof Module.hello !== 'function') {
return { status: false, e: 'test result: hello() is not found in Module' };
}
if (typeof Module.Interval !== 'function') {
return { status: false, e: 'test result: Interval is not found in Module' };
}
for (const name of ['hello', 'Interval']) {
if (!window.exportedSymbols.has(name)) {
return { status: false, e: `test result: ${name} does not carry __export: true` };
}
if (window.mergedLibrary['$' + name + '__force'] !== true) {
return { status: false, e: `test result: ${name} does not carry __force: true` };
}
}
const keys = Object.keys(window.mergedLibrary);
const testNames = ['clearInterval', 'setInterval', 'log'];
for (const name of testNames) {
const regex = new RegExp(`^__wbg_${name}`);
const res = keys.find(key => regex.test(key));
if (!res) {
return { status: false, e: `test result: ${name} not found in mergedLibrary` };
}
}
return { status: true, e: 'test result: ok' };
}
const tests = [testInitBindgenForced(), testModuleExports()];
for (const res of tests) {
if (!res.status) {
elem.textContent += res.e;
return;
}
}
elem.textContent +='test result: ok';
}, 50);
})();