1 | declare module 'stream/web' {
|
2 |
|
3 |
|
4 | interface ReadableWritablePair<R = any, W = any> {
|
5 | readable: ReadableStream<R>;
|
6 | |
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | writable: WritableStream<W>;
|
16 | }
|
17 | interface StreamPipeOptions {
|
18 | preventAbort?: boolean;
|
19 | preventCancel?: boolean;
|
20 | |
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | preventClose?: boolean;
|
62 | signal?: AbortSignal;
|
63 | }
|
64 | interface ReadableStreamGenericReader {
|
65 | readonly closed: Promise<undefined>;
|
66 | cancel(reason?: any): Promise<void>;
|
67 | }
|
68 | interface ReadableStreamDefaultReadValueResult<T> {
|
69 | done: false;
|
70 | value: T;
|
71 | }
|
72 | interface ReadableStreamDefaultReadDoneResult {
|
73 | done: true;
|
74 | value?: undefined;
|
75 | }
|
76 | type ReadableStreamController<T> = ReadableStreamDefaultController<T>;
|
77 | type ReadableStreamDefaultReadResult<T> = ReadableStreamDefaultReadValueResult<T> | ReadableStreamDefaultReadDoneResult;
|
78 | interface ReadableByteStreamControllerCallback {
|
79 | (controller: ReadableByteStreamController): void | PromiseLike<void>;
|
80 | }
|
81 | interface UnderlyingSinkAbortCallback {
|
82 | (reason?: any): void | PromiseLike<void>;
|
83 | }
|
84 | interface UnderlyingSinkCloseCallback {
|
85 | (): void | PromiseLike<void>;
|
86 | }
|
87 | interface UnderlyingSinkStartCallback {
|
88 | (controller: WritableStreamDefaultController): any;
|
89 | }
|
90 | interface UnderlyingSinkWriteCallback<W> {
|
91 | (chunk: W, controller: WritableStreamDefaultController): void | PromiseLike<void>;
|
92 | }
|
93 | interface UnderlyingSourceCancelCallback {
|
94 | (reason?: any): void | PromiseLike<void>;
|
95 | }
|
96 | interface UnderlyingSourcePullCallback<R> {
|
97 | (controller: ReadableStreamController<R>): void | PromiseLike<void>;
|
98 | }
|
99 | interface UnderlyingSourceStartCallback<R> {
|
100 | (controller: ReadableStreamController<R>): any;
|
101 | }
|
102 | interface TransformerFlushCallback<O> {
|
103 | (controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
|
104 | }
|
105 | interface TransformerStartCallback<O> {
|
106 | (controller: TransformStreamDefaultController<O>): any;
|
107 | }
|
108 | interface TransformerTransformCallback<I, O> {
|
109 | (chunk: I, controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
|
110 | }
|
111 | interface UnderlyingByteSource {
|
112 | autoAllocateChunkSize?: number;
|
113 | cancel?: ReadableStreamErrorCallback;
|
114 | pull?: ReadableByteStreamControllerCallback;
|
115 | start?: ReadableByteStreamControllerCallback;
|
116 | type: 'bytes';
|
117 | }
|
118 | interface UnderlyingSource<R = any> {
|
119 | cancel?: UnderlyingSourceCancelCallback;
|
120 | pull?: UnderlyingSourcePullCallback<R>;
|
121 | start?: UnderlyingSourceStartCallback<R>;
|
122 | type?: undefined;
|
123 | }
|
124 | interface UnderlyingSink<W = any> {
|
125 | abort?: UnderlyingSinkAbortCallback;
|
126 | close?: UnderlyingSinkCloseCallback;
|
127 | start?: UnderlyingSinkStartCallback;
|
128 | type?: undefined;
|
129 | write?: UnderlyingSinkWriteCallback<W>;
|
130 | }
|
131 | interface ReadableStreamErrorCallback {
|
132 | (reason: any): void | PromiseLike<void>;
|
133 | }
|
134 |
|
135 | interface ReadableStream<R = any> {
|
136 | readonly locked: boolean;
|
137 | cancel(reason?: any): Promise<void>;
|
138 | getReader(): ReadableStreamDefaultReader<R>;
|
139 | pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
|
140 | pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
|
141 | tee(): [ReadableStream<R>, ReadableStream<R>];
|
142 | values(options?: { preventCancel?: boolean }): AsyncIterableIterator<R>;
|
143 | [Symbol.asyncIterator](): AsyncIterableIterator<R>;
|
144 | }
|
145 | const ReadableStream: {
|
146 | prototype: ReadableStream;
|
147 | new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
|
148 | new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
|
149 | };
|
150 | interface ReadableStreamDefaultReader<R = any> extends ReadableStreamGenericReader {
|
151 | read(): Promise<ReadableStreamDefaultReadResult<R>>;
|
152 | releaseLock(): void;
|
153 | }
|
154 | const ReadableStreamDefaultReader: {
|
155 | prototype: ReadableStreamDefaultReader;
|
156 | new <R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
|
157 | };
|
158 | const ReadableStreamBYOBReader: any;
|
159 | const ReadableStreamBYOBRequest: any;
|
160 | interface ReadableByteStreamController {
|
161 | readonly byobRequest: undefined;
|
162 | readonly desiredSize: number | null;
|
163 | close(): void;
|
164 | enqueue(chunk: ArrayBufferView): void;
|
165 | error(error?: any): void;
|
166 | }
|
167 | const ReadableByteStreamController: {
|
168 | prototype: ReadableByteStreamController;
|
169 | new (): ReadableByteStreamController;
|
170 | };
|
171 | interface ReadableStreamDefaultController<R = any> {
|
172 | readonly desiredSize: number | null;
|
173 | close(): void;
|
174 | enqueue(chunk?: R): void;
|
175 | error(e?: any): void;
|
176 | }
|
177 | const ReadableStreamDefaultController: {
|
178 | prototype: ReadableStreamDefaultController;
|
179 | new (): ReadableStreamDefaultController;
|
180 | };
|
181 | interface Transformer<I = any, O = any> {
|
182 | flush?: TransformerFlushCallback<O>;
|
183 | readableType?: undefined;
|
184 | start?: TransformerStartCallback<O>;
|
185 | transform?: TransformerTransformCallback<I, O>;
|
186 | writableType?: undefined;
|
187 | }
|
188 | interface TransformStream<I = any, O = any> {
|
189 | readonly readable: ReadableStream<O>;
|
190 | readonly writable: WritableStream<I>;
|
191 | }
|
192 | const TransformStream: {
|
193 | prototype: TransformStream;
|
194 | new <I = any, O = any>(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>): TransformStream<I, O>;
|
195 | };
|
196 | interface TransformStreamDefaultController<O = any> {
|
197 | readonly desiredSize: number | null;
|
198 | enqueue(chunk?: O): void;
|
199 | error(reason?: any): void;
|
200 | terminate(): void;
|
201 | }
|
202 | const TransformStreamDefaultController: {
|
203 | prototype: TransformStreamDefaultController;
|
204 | new (): TransformStreamDefaultController;
|
205 | };
|
206 | |
207 |
|
208 |
|
209 |
|
210 |
|
211 | interface WritableStream<W = any> {
|
212 | readonly locked: boolean;
|
213 | abort(reason?: any): Promise<void>;
|
214 | close(): Promise<void>;
|
215 | getWriter(): WritableStreamDefaultWriter<W>;
|
216 | }
|
217 | const WritableStream: {
|
218 | prototype: WritableStream;
|
219 | new <W = any>(underlyingSink?: UnderlyingSink<W>, strategy?: QueuingStrategy<W>): WritableStream<W>;
|
220 | };
|
221 | |
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 | interface WritableStreamDefaultWriter<W = any> {
|
228 | readonly closed: Promise<undefined>;
|
229 | readonly desiredSize: number | null;
|
230 | readonly ready: Promise<undefined>;
|
231 | abort(reason?: any): Promise<void>;
|
232 | close(): Promise<void>;
|
233 | releaseLock(): void;
|
234 | write(chunk?: W): Promise<void>;
|
235 | }
|
236 | const WritableStreamDefaultWriter: {
|
237 | prototype: WritableStreamDefaultWriter;
|
238 | new <W = any>(stream: WritableStream<W>): WritableStreamDefaultWriter<W>;
|
239 | };
|
240 | |
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 | interface WritableStreamDefaultController {
|
247 | error(e?: any): void;
|
248 | }
|
249 | const WritableStreamDefaultController: {
|
250 | prototype: WritableStreamDefaultController;
|
251 | new (): WritableStreamDefaultController;
|
252 | };
|
253 | interface QueuingStrategy<T = any> {
|
254 | highWaterMark?: number;
|
255 | size?: QueuingStrategySize<T>;
|
256 | }
|
257 | interface QueuingStrategySize<T = any> {
|
258 | (chunk?: T): number;
|
259 | }
|
260 | interface QueuingStrategyInit {
|
261 | |
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 | highWaterMark: number;
|
271 | }
|
272 | |
273 |
|
274 |
|
275 |
|
276 | interface ByteLengthQueuingStrategy extends QueuingStrategy<ArrayBufferView> {
|
277 | readonly highWaterMark: number;
|
278 | readonly size: QueuingStrategySize<ArrayBufferView>;
|
279 | }
|
280 | const ByteLengthQueuingStrategy: {
|
281 | prototype: ByteLengthQueuingStrategy;
|
282 | new (init: QueuingStrategyInit): ByteLengthQueuingStrategy;
|
283 | };
|
284 | |
285 |
|
286 |
|
287 |
|
288 | interface CountQueuingStrategy extends QueuingStrategy {
|
289 | readonly highWaterMark: number;
|
290 | readonly size: QueuingStrategySize;
|
291 | }
|
292 | const CountQueuingStrategy: {
|
293 | prototype: CountQueuingStrategy;
|
294 | new (init: QueuingStrategyInit): CountQueuingStrategy;
|
295 | };
|
296 | interface TextEncoderStream {
|
297 |
|
298 | readonly encoding: 'utf-8';
|
299 | readonly readable: ReadableStream<Uint8Array>;
|
300 | readonly writable: WritableStream<string>;
|
301 | readonly [Symbol.toStringTag]: string;
|
302 | }
|
303 | const TextEncoderStream: {
|
304 | prototype: TextEncoderStream;
|
305 | new (): TextEncoderStream;
|
306 | };
|
307 | interface TextDecoderOptions {
|
308 | fatal?: boolean;
|
309 | ignoreBOM?: boolean;
|
310 | }
|
311 | type BufferSource = ArrayBufferView | ArrayBuffer;
|
312 | interface TextDecoderStream {
|
313 |
|
314 | readonly encoding: string;
|
315 |
|
316 | readonly fatal: boolean;
|
317 |
|
318 | readonly ignoreBOM: boolean;
|
319 | readonly readable: ReadableStream<string>;
|
320 | readonly writable: WritableStream<BufferSource>;
|
321 | readonly [Symbol.toStringTag]: string;
|
322 | }
|
323 | const TextDecoderStream: {
|
324 | prototype: TextDecoderStream;
|
325 | new (label?: string, options?: TextDecoderOptions): TextDecoderStream;
|
326 | };
|
327 | }
|
328 | declare module 'node:stream/web' {
|
329 | export * from 'stream/web';
|
330 | }
|