mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -05:00
feat(ext/web): WritableStreamDefaultController.signal (#12654)
This commit is contained in:
parent
8e010b6844
commit
c91da1222b
3 changed files with 22 additions and 35 deletions
|
@ -9,7 +9,8 @@
|
|||
|
||||
((window) => {
|
||||
const webidl = window.__bootstrap.webidl;
|
||||
// TODO(lucacasonato): get AbortSignal from __bootstrap.
|
||||
const { add, remove, signalAbort, newSignal } =
|
||||
window.__bootstrap.abortSignal;
|
||||
const {
|
||||
ArrayBuffer,
|
||||
ArrayBufferIsView,
|
||||
|
@ -286,6 +287,7 @@
|
|||
const _readRequests = Symbol("[[readRequests]]");
|
||||
const _readIntoRequests = Symbol("[[readIntoRequests]]");
|
||||
const _readyPromise = Symbol("[[readyPromise]]");
|
||||
const _signal = Symbol("[[signal]]");
|
||||
const _started = Symbol("[[started]]");
|
||||
const _state = Symbol("[[state]]");
|
||||
const _storedError = Symbol("[[storedError]]");
|
||||
|
@ -1902,8 +1904,7 @@
|
|||
abortAlgorithm();
|
||||
return promise.promise;
|
||||
}
|
||||
// TODO(lucacasonato): use the internal API to listen for abort.
|
||||
signal.addEventListener("abort", abortAlgorithm);
|
||||
signal[add](abortAlgorithm);
|
||||
}
|
||||
|
||||
function pipeLoop() {
|
||||
|
@ -2107,8 +2108,7 @@
|
|||
readableStreamReaderGenericRelease(reader);
|
||||
|
||||
if (signal !== undefined) {
|
||||
// TODO(lucacasonato): use the internal API to remove the listener.
|
||||
signal.removeEventListener("abort", abortAlgorithm);
|
||||
signal[remove](abortAlgorithm);
|
||||
}
|
||||
if (isError) {
|
||||
promise.reject(error);
|
||||
|
@ -2985,6 +2985,7 @@
|
|||
controller[_stream] = stream;
|
||||
stream[_controller] = controller;
|
||||
resetQueue(controller);
|
||||
controller[_signal] = newSignal();
|
||||
controller[_started] = false;
|
||||
controller[_strategySizeAlgorithm] = sizeAlgorithm;
|
||||
controller[_strategyHWM] = highWaterMark;
|
||||
|
@ -3342,6 +3343,10 @@
|
|||
if (state === "closed" || state === "errored") {
|
||||
return resolvePromiseWith(undefined);
|
||||
}
|
||||
stream[_controller][_signal][signalAbort]();
|
||||
if (state === "closed" || state === "errored") {
|
||||
return resolvePromiseWith(undefined);
|
||||
}
|
||||
if (stream[_pendingAbortRequest] !== undefined) {
|
||||
return stream[_pendingAbortRequest].deferred.promise;
|
||||
}
|
||||
|
@ -5421,6 +5426,13 @@
|
|||
[_stream];
|
||||
/** @type {(chunk: W, controller: this) => Promise<void>} */
|
||||
[_writeAlgorithm];
|
||||
/** @type {AbortSignal} */
|
||||
[_signal];
|
||||
|
||||
get signal() {
|
||||
webidl.assertBranded(this, WritableStreamDefaultController);
|
||||
return this[_signal];
|
||||
}
|
||||
|
||||
constructor() {
|
||||
webidl.illegalConstructor();
|
||||
|
|
1
ext/web/lib.deno_web.d.ts
vendored
1
ext/web/lib.deno_web.d.ts
vendored
|
@ -635,6 +635,7 @@ declare var WritableStream: {
|
|||
* sink is given a corresponding WritableStreamDefaultController instance to
|
||||
* manipulate. */
|
||||
interface WritableStreamDefaultController {
|
||||
signal: AbortSignal;
|
||||
error(error?: any): void;
|
||||
}
|
||||
|
||||
|
|
|
@ -6056,18 +6056,8 @@
|
|||
"window-worker-timeOrigin.window.html": false
|
||||
},
|
||||
"streams": {
|
||||
"idlharness.any.html": [
|
||||
"WritableStreamDefaultController interface: attribute abortReason",
|
||||
"WritableStreamDefaultController interface: attribute signal",
|
||||
"WritableStreamDefaultController interface: self.writableStreamDefaultController must inherit property \"abortReason\" with the proper type",
|
||||
"WritableStreamDefaultController interface: self.writableStreamDefaultController must inherit property \"signal\" with the proper type"
|
||||
],
|
||||
"idlharness.any.worker.html": [
|
||||
"WritableStreamDefaultController interface: attribute abortReason",
|
||||
"WritableStreamDefaultController interface: attribute signal",
|
||||
"WritableStreamDefaultController interface: self.writableStreamDefaultController must inherit property \"abortReason\" with the proper type",
|
||||
"WritableStreamDefaultController interface: self.writableStreamDefaultController must inherit property \"signal\" with the proper type"
|
||||
],
|
||||
"idlharness.any.html": true,
|
||||
"idlharness.any.worker.html": true,
|
||||
"piping": {
|
||||
"abort.any.html": true,
|
||||
"abort.any.worker.html": true,
|
||||
|
@ -6169,24 +6159,8 @@
|
|||
"terminate.any.worker.html": true
|
||||
},
|
||||
"writable-streams": {
|
||||
"aborting.any.html": [
|
||||
"WritableStreamDefaultController.signal",
|
||||
"the abort signal is signalled synchronously - write",
|
||||
"the abort signal is signalled synchronously - close",
|
||||
"the abort signal is not signalled on error",
|
||||
"the abort signal is not signalled on write failure",
|
||||
"the abort signal is not signalled on close failure",
|
||||
"recursive abort() call"
|
||||
],
|
||||
"aborting.any.worker.html": [
|
||||
"WritableStreamDefaultController.signal",
|
||||
"the abort signal is signalled synchronously - write",
|
||||
"the abort signal is signalled synchronously - close",
|
||||
"the abort signal is not signalled on error",
|
||||
"the abort signal is not signalled on write failure",
|
||||
"the abort signal is not signalled on close failure",
|
||||
"recursive abort() call"
|
||||
],
|
||||
"aborting.any.html": true,
|
||||
"aborting.any.worker.html": true,
|
||||
"bad-strategies.any.html": true,
|
||||
"bad-strategies.any.worker.html": true,
|
||||
"bad-underlying-sinks.any.html": true,
|
||||
|
|
Loading…
Reference in a new issue