(id: ImportId, path: PropertyPath, args: RpcPayload)
| 784 | } |
| 785 | |
| 786 | sendStream(id: ImportId, path: PropertyPath, args: RpcPayload) |
| 787 | : {promise: Promise<void>, size: number} { |
| 788 | if (this.abortReason) throw this.abortReason; |
| 789 | |
| 790 | let value: Array<any> = ["pipeline", id, path]; |
| 791 | let devalue = Devaluator.devaluate(args.value, undefined, this, args, this.encodingLevel); |
| 792 | |
| 793 | // HACK: Since the args is an array, devaluator will wrap in a second array. Need to unwrap. |
| 794 | // TODO: Clean this up somehow. |
| 795 | value.push((<Array<unknown>>devalue)[0]); |
| 796 | |
| 797 | let msg = ["stream", value]; |
| 798 | let size = this.send(msg); |
| 799 | if (size === undefined) { |
| 800 | size = estimateEncodedSize(msg); |
| 801 | } |
| 802 | |
| 803 | // Create the import entry in "already pulling" state (pulling=true), since stream messages |
| 804 | // are automatically pulled. Set remoteRefcount to 0 so that resolve() won't send a release |
| 805 | // message — the server implicitly releases the export after sending the resolve. Set |
| 806 | // localRefcount to 1 so that resolve() doesn't treat this as already-disposed. |
| 807 | let importId = this.imports.length; |
| 808 | let entry = new ImportTableEntry(this, importId, /*pulling=*/true); |
| 809 | entry.remoteRefcount = 0; |
| 810 | entry.localRefcount = 1; |
| 811 | this.imports.push(entry); |
| 812 | |
| 813 | // Await the resolution, then dispose the result payload and clean up the import table entry. |
| 814 | // (Normally, sendRelease() cleans up the import table, but since remoteRefcount is 0, we |
| 815 | // need to do it manually.) |
| 816 | let promise = entry.awaitResolution().then( |
| 817 | p => { p.dispose(); delete this.imports[importId]; }, |
| 818 | err => { delete this.imports[importId]; throw err; } |
| 819 | ); |
| 820 | |
| 821 | return { promise, size }; |
| 822 | } |
| 823 | |
| 824 | sendMap(id: ImportId, path: PropertyPath, captures: StubHook[], instructions: unknown[]) |
| 825 | : RpcImportHook { |
no test coverage detected