mirror of
https://github.com/denoland/deno.git
synced 2024-11-04 08:54:20 -05:00
fc4819e1e0
Refactors Event and EventTarget so that they better encapsulate their non-public data as well as are more forward compatible with things like DOM Nodes. Moves `dom_types.ts` -> `dom_types.d.ts` which was always the intention, it was a legacy of when we used to build the types from the code and the limitations of the compiler. There was a lot of cruft in `dom_types` which shouldn't have been there, and mis-alignment to the DOM standards. This generally has been eliminated, though we still have some minor differences from the DOM (like the removal of some deprecated methods/properties). Adds `DOMException`. Strictly it shouldn't inherit from `Error`, but most browsers provide a stack trace when one is thrown, so the behaviour in Deno actually better matches the browser. `Event` still doesn't log to console like it does in the browser. I wanted to get this raised and that could be an enhancement later on (it currently doesn't either).
101 lines
3.3 KiB
TypeScript
101 lines
3.3 KiB
TypeScript
// TODO reenable this code when we enable writableStreams and transport types
|
|
// // Forked from https://github.com/stardazed/sd-streams/tree/8928cf04b035fd02fb1340b7eb541c76be37e546
|
|
// // Copyright (c) 2018-Present by Arthur Langereis - @zenmumbler MIT
|
|
|
|
// /**
|
|
// * streams/writable-stream-default-controller - WritableStreamDefaultController class implementation
|
|
// * Part of Stardazed
|
|
// * (c) 2018-Present by Arthur Langereis - @zenmumbler
|
|
// * https://github.com/stardazed/sd-streams
|
|
// */
|
|
|
|
// /* eslint-disable @typescript-eslint/no-explicit-any */
|
|
// // TODO reenable this lint here
|
|
|
|
// import * as ws from "./writable-internals.ts";
|
|
// import * as shared from "./shared-internals.ts";
|
|
// import * as q from "./queue-mixin.ts";
|
|
// import { Queue } from "./queue.ts";
|
|
// import { QueuingStrategySizeCallback } from "../dom_types.d.ts";
|
|
|
|
// export class WritableStreamDefaultController<InputType>
|
|
// implements ws.WritableStreamDefaultController<InputType> {
|
|
// [ws.abortAlgorithm_]: ws.AbortAlgorithm;
|
|
// [ws.closeAlgorithm_]: ws.CloseAlgorithm;
|
|
// [ws.controlledWritableStream_]: ws.WritableStream<InputType>;
|
|
// [ws.started_]: boolean;
|
|
// [ws.strategyHWM_]: number;
|
|
// [ws.strategySizeAlgorithm_]: QueuingStrategySizeCallback<InputType>;
|
|
// [ws.writeAlgorithm_]: ws.WriteAlgorithm<InputType>;
|
|
|
|
// [q.queue_]: Queue<q.QueueElement<ws.WriteRecord<InputType> | "close">>;
|
|
// [q.queueTotalSize_]: number;
|
|
|
|
// constructor() {
|
|
// throw new TypeError();
|
|
// }
|
|
|
|
// error(e?: shared.ErrorResult): void {
|
|
// if (!ws.isWritableStreamDefaultController(this)) {
|
|
// throw new TypeError();
|
|
// }
|
|
// const state = this[ws.controlledWritableStream_][shared.state_];
|
|
// if (state !== "writable") {
|
|
// return;
|
|
// }
|
|
// ws.writableStreamDefaultControllerError(this, e);
|
|
// }
|
|
|
|
// [ws.abortSteps_](reason: shared.ErrorResult): Promise<void> {
|
|
// const result = this[ws.abortAlgorithm_](reason);
|
|
// ws.writableStreamDefaultControllerClearAlgorithms(this);
|
|
// return result;
|
|
// }
|
|
|
|
// [ws.errorSteps_](): void {
|
|
// q.resetQueue(this);
|
|
// }
|
|
// }
|
|
|
|
// export function setUpWritableStreamDefaultControllerFromUnderlyingSink<
|
|
// InputType
|
|
// >(
|
|
// stream: ws.WritableStream<InputType>,
|
|
// underlyingSink: ws.WritableStreamSink<InputType>,
|
|
// highWaterMark: number,
|
|
// sizeAlgorithm: QueuingStrategySizeCallback<InputType>
|
|
// ): void {
|
|
// // Assert: underlyingSink is not undefined.
|
|
// const controller = Object.create(
|
|
// WritableStreamDefaultController.prototype
|
|
// ) as WritableStreamDefaultController<InputType>;
|
|
|
|
// const startAlgorithm = function(): any {
|
|
// return shared.invokeOrNoop(underlyingSink, "start", [controller]);
|
|
// };
|
|
// const writeAlgorithm = shared.createAlgorithmFromUnderlyingMethod(
|
|
// underlyingSink,
|
|
// "write",
|
|
// [controller]
|
|
// );
|
|
// const closeAlgorithm = shared.createAlgorithmFromUnderlyingMethod(
|
|
// underlyingSink,
|
|
// "close",
|
|
// []
|
|
// );
|
|
// const abortAlgorithm = shared.createAlgorithmFromUnderlyingMethod(
|
|
// underlyingSink,
|
|
// "abort",
|
|
// []
|
|
// );
|
|
// ws.setUpWritableStreamDefaultController(
|
|
// stream,
|
|
// controller,
|
|
// startAlgorithm,
|
|
// writeAlgorithm,
|
|
// closeAlgorithm,
|
|
// abortAlgorithm,
|
|
// highWaterMark,
|
|
// sizeAlgorithm
|
|
// );
|
|
// }
|