on) { this._url = json.url; } get actor() { return this.actorID; } get url() { return this._url; } // Alias for source.blackbox to avoid changing protocol.js packets blackBox(range) { return this.blackbox(range); } // Alias for source.unblackbox to avoid changing protocol.js packets unblackBox() { return this.unblackbox(); } /** * Get a Front for either an ArrayBuffer or LongString * for this SourceFront's source. */ async source() { const response = await super.source(); return this._onSourceResponse(response); } _onSourceResponse(response) { const { contentType, source } = response; if (source instanceof ArrayBufferFront) { return source.slice(0, source.length).then(function (resp) { if (resp.error) { return resp; } // Keeping str as a string, ArrayBuffer/Uint8Array will not survive // setIn/mergeIn operations. const str = atob(resp.encoded); const newResponse = { source: { binary: str, toString: () => "[wasm]", }, contentType, }; return newResponse; }); } return source.substring(0, source.length).then(function (resp) { if (resp.error) { return resp; } const newResponse = { source: resp, contentType, }; return newResponse; }); } } exports.SourceFront = SourceFront; registerFront(SourceFront); PK