1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
const imports = {
object_store: {
process: ObjectStore.processWasm,
},
console: {
log(buffer, length) {
console.log(ObjectStore.decodeString(buffer, length))
},
warn(buffer, length) {
console.warn(ObjectStore.decodeString(buffer, length))
},
err(buffer, length) {
console.error(ObjectStore.decodeString(buffer, length))
},
debug(buffer, length) {
console.debug(ObjectStore.decodeString(buffer, length))
},
}
}
const wasm_ready = WebAssembly.instantiateStreaming(fetch("index.wasm"), imports).then(
({ instance, module }) => {
const view = new DataView(instance.exports.memory.buffer);
const type_names = [ 'Call', 'Value', 'Ptr' ];
const size_of = {};
for (const type of type_names) {
size_of[type] = view.getUint16(instance.exports[`type::size::${type}`], true);
}
wasm = {
exports: instance.exports,
memory: instance.exports.memory,
size_of: size_of,
}
},
);
|