Compare commits
6 Commits
c69420ae90
...
68283d14e5
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | 68283d14e5 | |
Derrick Hammer | 23a55f772b | |
Derrick Hammer | 53dd352c95 | |
Derrick Hammer | 2aa53faf00 | |
Derrick Hammer | 68fec66069 | |
Derrick Hammer | 0c320f992b |
|
@ -82,6 +82,7 @@ export default class Go {
|
|||
private exited = false;
|
||||
private _resolveCallbackPromise?: () => void;
|
||||
importObject: ImportObject;
|
||||
private _pendingEvent?: any;
|
||||
|
||||
constructor() {
|
||||
this._callbackTimeouts = new Map();
|
||||
|
@ -437,6 +438,16 @@ export default class Go {
|
|||
}
|
||||
this._inst.exports.resume();
|
||||
}
|
||||
_makeFuncWrapper(id) {
|
||||
const go = this;
|
||||
return function () {
|
||||
const event = { id: id, this: this, args: arguments };
|
||||
go._pendingEvent = event;
|
||||
go._resume();
|
||||
// @ts-ignore
|
||||
return event.result;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
|
|
|
@ -89,7 +89,7 @@ func start() int {
|
|||
return callbackId
|
||||
}
|
||||
|
||||
// exit write
|
||||
//export exit
|
||||
func exit() {
|
||||
exitChan <- true
|
||||
}
|
||||
|
|
|
@ -12,6 +12,13 @@ export async function getVerifiableStream(
|
|||
const reader = new VariableChunkStream(data);
|
||||
let bytesToRead;
|
||||
|
||||
if (root instanceof ArrayBuffer) {
|
||||
root = new Uint8Array(root);
|
||||
}
|
||||
if (proof instanceof ArrayBuffer) {
|
||||
proof = new Uint8Array(proof);
|
||||
}
|
||||
|
||||
const getNextBytes = async () => {
|
||||
bytesToRead = getWasmProperty(wasmId, "write_promise");
|
||||
bytesToRead = await bytesToRead;
|
||||
|
@ -67,9 +74,9 @@ export async function getVerifiableStream(
|
|||
|
||||
const result = getWasmProperty(wasmId, "result");
|
||||
|
||||
const wasmDone = result === undefined;
|
||||
const wasmDone = result !== undefined;
|
||||
|
||||
if (result === undefined) {
|
||||
if (!wasmDone) {
|
||||
await getNextBytes();
|
||||
}
|
||||
|
||||
|
@ -84,6 +91,8 @@ export async function getVerifiableStream(
|
|||
done(controller);
|
||||
}
|
||||
}
|
||||
|
||||
controller.enqueue(chunk.value);
|
||||
},
|
||||
async cancel(reason: any) {
|
||||
await reader.cancel(reason);
|
||||
|
|
Loading…
Reference in New Issue