@yume-chan/adb 0.0.16 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/CHANGELOG.json +18 -0
  2. package/CHANGELOG.md +13 -1
  3. package/LICENSE +1 -1
  4. package/esm/adb.d.ts +13 -8
  5. package/esm/adb.d.ts.map +1 -1
  6. package/esm/adb.js +63 -38
  7. package/esm/adb.js.map +1 -1
  8. package/esm/auth.d.ts +4 -4
  9. package/esm/auth.d.ts.map +1 -1
  10. package/esm/auth.js +6 -6
  11. package/esm/auth.js.map +1 -1
  12. package/esm/backend.d.ts +3 -3
  13. package/esm/backend.d.ts.map +1 -1
  14. package/esm/commands/base.d.ts +2 -2
  15. package/esm/commands/base.d.ts.map +1 -1
  16. package/esm/commands/base.js +1 -1
  17. package/esm/commands/base.js.map +1 -1
  18. package/esm/commands/framebuffer.d.ts +22 -6
  19. package/esm/commands/framebuffer.d.ts.map +1 -1
  20. package/esm/commands/framebuffer.js +33 -45
  21. package/esm/commands/framebuffer.js.map +1 -1
  22. package/esm/commands/install.d.ts +2 -2
  23. package/esm/commands/install.d.ts.map +1 -1
  24. package/esm/commands/install.js +12 -5
  25. package/esm/commands/install.js.map +1 -1
  26. package/esm/commands/power.d.ts.map +1 -1
  27. package/esm/commands/power.js +13 -9
  28. package/esm/commands/power.js.map +1 -1
  29. package/esm/commands/reverse.d.ts +5 -5
  30. package/esm/commands/reverse.d.ts.map +1 -1
  31. package/esm/commands/reverse.js +20 -18
  32. package/esm/commands/reverse.js.map +1 -1
  33. package/esm/commands/subprocess/command.d.ts +52 -0
  34. package/esm/commands/subprocess/command.d.ts.map +1 -0
  35. package/esm/commands/subprocess/command.js +81 -0
  36. package/esm/commands/subprocess/command.js.map +1 -0
  37. package/esm/commands/subprocess/index.d.ts +1 -53
  38. package/esm/commands/subprocess/index.d.ts.map +1 -1
  39. package/esm/commands/subprocess/index.js +1 -85
  40. package/esm/commands/subprocess/index.js.map +1 -1
  41. package/esm/commands/subprocess/protocols/none.d.ts +5 -5
  42. package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
  43. package/esm/commands/subprocess/protocols/none.js +5 -3
  44. package/esm/commands/subprocess/protocols/none.js.map +1 -1
  45. package/esm/commands/subprocess/protocols/shell.d.ts +4 -4
  46. package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
  47. package/esm/commands/subprocess/protocols/shell.js +28 -20
  48. package/esm/commands/subprocess/protocols/shell.js.map +1 -1
  49. package/esm/commands/subprocess/protocols/types.d.ts +7 -7
  50. package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
  51. package/esm/commands/sync/index.d.ts +1 -1
  52. package/esm/commands/sync/index.d.ts.map +1 -1
  53. package/esm/commands/sync/index.js +1 -1
  54. package/esm/commands/sync/index.js.map +1 -1
  55. package/esm/commands/sync/list.d.ts +7 -7
  56. package/esm/commands/sync/list.d.ts.map +1 -1
  57. package/esm/commands/sync/list.js +34 -50
  58. package/esm/commands/sync/list.js.map +1 -1
  59. package/esm/commands/sync/pull.d.ts +5 -4
  60. package/esm/commands/sync/pull.d.ts.map +1 -1
  61. package/esm/commands/sync/pull.js +21 -22
  62. package/esm/commands/sync/pull.js.map +1 -1
  63. package/esm/commands/sync/push.d.ts +4 -4
  64. package/esm/commands/sync/push.d.ts.map +1 -1
  65. package/esm/commands/sync/push.js +7 -11
  66. package/esm/commands/sync/push.js.map +1 -1
  67. package/esm/commands/sync/request.d.ts +4 -4
  68. package/esm/commands/sync/request.d.ts.map +1 -1
  69. package/esm/commands/sync/request.js +6 -6
  70. package/esm/commands/sync/request.js.map +1 -1
  71. package/esm/commands/sync/response.d.ts +5 -10
  72. package/esm/commands/sync/response.d.ts.map +1 -1
  73. package/esm/commands/sync/response.js +35 -26
  74. package/esm/commands/sync/response.js.map +1 -1
  75. package/esm/commands/sync/stat.d.ts +7 -7
  76. package/esm/commands/sync/stat.d.ts.map +1 -1
  77. package/esm/commands/sync/stat.js +48 -55
  78. package/esm/commands/sync/stat.js.map +1 -1
  79. package/esm/commands/sync/sync.d.ts +7 -7
  80. package/esm/commands/sync/sync.d.ts.map +1 -1
  81. package/esm/commands/sync/sync.js +25 -22
  82. package/esm/commands/sync/sync.js.map +1 -1
  83. package/esm/crypto.d.ts.map +1 -1
  84. package/esm/crypto.js +26 -16
  85. package/esm/crypto.js.map +1 -1
  86. package/esm/index.d.ts +9 -10
  87. package/esm/index.d.ts.map +1 -1
  88. package/esm/index.js +9 -10
  89. package/esm/index.js.map +1 -1
  90. package/esm/packet.d.ts +8 -8
  91. package/esm/packet.d.ts.map +1 -1
  92. package/esm/packet.js +14 -12
  93. package/esm/packet.js.map +1 -1
  94. package/esm/socket/dispatcher.d.ts +11 -6
  95. package/esm/socket/dispatcher.d.ts.map +1 -1
  96. package/esm/socket/dispatcher.js +28 -20
  97. package/esm/socket/dispatcher.js.map +1 -1
  98. package/esm/socket/index.d.ts +1 -1
  99. package/esm/socket/index.d.ts.map +1 -1
  100. package/esm/socket/index.js +1 -1
  101. package/esm/socket/index.js.map +1 -1
  102. package/esm/socket/socket.d.ts +5 -5
  103. package/esm/socket/socket.d.ts.map +1 -1
  104. package/esm/socket/socket.js +37 -17
  105. package/esm/socket/socket.js.map +1 -1
  106. package/esm/utils/auto-reset-event.d.ts +1 -1
  107. package/esm/utils/auto-reset-event.d.ts.map +1 -1
  108. package/esm/utils/auto-reset-event.js +2 -2
  109. package/esm/utils/base64.d.ts +23 -0
  110. package/esm/utils/base64.d.ts.map +1 -1
  111. package/esm/utils/base64.js +36 -29
  112. package/esm/utils/base64.js.map +1 -1
  113. package/package.json +19 -17
  114. package/src/adb.ts +140 -86
  115. package/src/auth.ts +27 -18
  116. package/src/backend.ts +7 -4
  117. package/src/commands/base.ts +3 -2
  118. package/src/commands/framebuffer.ts +48 -47
  119. package/src/commands/install.ts +20 -10
  120. package/src/commands/power.ts +14 -10
  121. package/src/commands/reverse.ts +53 -33
  122. package/src/commands/subprocess/command.ts +134 -0
  123. package/src/commands/subprocess/index.ts +1 -137
  124. package/src/commands/subprocess/protocols/none.ts +10 -6
  125. package/src/commands/subprocess/protocols/shell.ts +72 -39
  126. package/src/commands/subprocess/protocols/types.ts +12 -8
  127. package/src/commands/sync/index.ts +1 -1
  128. package/src/commands/sync/list.ts +63 -68
  129. package/src/commands/sync/pull.ts +53 -37
  130. package/src/commands/sync/push.ts +26 -15
  131. package/src/commands/sync/request.ts +20 -21
  132. package/src/commands/sync/response.ts +63 -53
  133. package/src/commands/sync/stat.ts +91 -90
  134. package/src/commands/sync/sync.ts +56 -34
  135. package/src/crypto.ts +61 -33
  136. package/src/features.ts +1 -1
  137. package/src/index.ts +9 -11
  138. package/src/packet.ts +40 -30
  139. package/src/socket/dispatcher.ts +119 -77
  140. package/src/socket/index.ts +1 -1
  141. package/src/socket/socket.ts +68 -26
  142. package/src/utils/auto-reset-event.ts +3 -3
  143. package/src/utils/base64.ts +75 -42
  144. package/tsconfig.build.json +1 -1
  145. package/tsconfig.build.tsbuildinfo +1 -1
  146. package/esm/stream/buffered.d.ts +0 -39
  147. package/esm/stream/buffered.d.ts.map +0 -1
  148. package/esm/stream/buffered.js +0 -143
  149. package/esm/stream/buffered.js.map +0 -1
  150. package/esm/stream/detect.d.ts +0 -2
  151. package/esm/stream/detect.d.ts.map +0 -1
  152. package/esm/stream/detect.js +0 -6
  153. package/esm/stream/detect.js.map +0 -1
  154. package/esm/stream/detect.native.d.ts +0 -240
  155. package/esm/stream/detect.native.d.ts.map +0 -1
  156. package/esm/stream/detect.native.js +0 -60
  157. package/esm/stream/detect.native.js.map +0 -1
  158. package/esm/stream/detect.polyfill.d.ts +0 -18
  159. package/esm/stream/detect.polyfill.d.ts.map +0 -1
  160. package/esm/stream/detect.polyfill.js +0 -4
  161. package/esm/stream/detect.polyfill.js.map +0 -1
  162. package/esm/stream/index.d.ts +0 -4
  163. package/esm/stream/index.d.ts.map +0 -1
  164. package/esm/stream/index.js +0 -4
  165. package/esm/stream/index.js.map +0 -1
  166. package/esm/stream/transform.d.ts +0 -124
  167. package/esm/stream/transform.d.ts.map +0 -1
  168. package/esm/stream/transform.js +0 -379
  169. package/esm/stream/transform.js.map +0 -1
  170. package/src/stream/buffered.ts +0 -168
  171. package/src/stream/detect.native.ts +0 -362
  172. package/src/stream/detect.polyfill.ts +0 -22
  173. package/src/stream/detect.ts +0 -7
  174. package/src/stream/index.ts +0 -3
  175. package/src/stream/transform.ts +0 -474
  176. package/tsconfig.test.json +0 -9
  177. package/web-streams-polyfill-4.0.0-beta.2.tgz +0 -0
@@ -1,124 +0,0 @@
1
- import type Struct from "@yume-chan/struct";
2
- import type { StructValueType, ValueOrPromise } from "@yume-chan/struct";
3
- import { AbortSignal, ReadableStream, TransformStream, WritableStream, type QueuingStrategy, type ReadableStreamDefaultController, type ReadableWritablePair } from "./detect.js";
4
- export interface DuplexStreamFactoryOptions {
5
- /**
6
- * Callback when any `ReadableStream` is cancelled (the user doesn't need any more data),
7
- * or `WritableStream` is ended (the user won't produce any more data),
8
- * or `DuplexStreamFactory#close` is called.
9
- *
10
- * Usually you want to let the other peer know that the duplex stream should be clsoed.
11
- *
12
- * `dispose` will automatically be called after `close` completes,
13
- * but if you want to wait another peer for a close confirmation and call
14
- * `DuplexStreamFactory#dispose` yourself, you can return `false`
15
- * (or a `Promise` that resolves to `false`) to disable the automatic call.
16
- */
17
- close?: (() => ValueOrPromise<boolean | void>) | undefined;
18
- /**
19
- * Callback when any `ReadableStream` is closed (the other peer doesn't produce any more data),
20
- * or `WritableStream` is aborted (the other peer can't receive any more data),
21
- * or `DuplexStreamFactory#abort` is called.
22
- *
23
- * Usually indicates the other peer has closed the duplex stream. You can clean up
24
- * any resources you have allocated now.
25
- */
26
- dispose?: (() => void | Promise<void>) | undefined;
27
- }
28
- /**
29
- * A factory for creating a duplex stream.
30
- *
31
- * It can create multiple `ReadableStream`s and `WritableStream`s,
32
- * when any of them is closed, all other streams will be closed as well.
33
- */
34
- export declare class DuplexStreamFactory<R, W> {
35
- private readableControllers;
36
- private writers;
37
- private _writableClosed;
38
- get writableClosed(): boolean;
39
- private _closed;
40
- get closed(): Promise<void>;
41
- private options;
42
- constructor(options?: DuplexStreamFactoryOptions);
43
- wrapReadable(readable: ReadableStream<R>): WrapReadableStream<R>;
44
- createWritable(stream: WritableStream<W>): WritableStream<W>;
45
- close(): Promise<void>;
46
- dispose(): Promise<void>;
47
- }
48
- export declare class DecodeUtf8Stream extends TransformStream<Uint8Array, string> {
49
- constructor();
50
- }
51
- export declare class GatherStringStream extends WritableStream<string> {
52
- private _result;
53
- get result(): string;
54
- constructor();
55
- }
56
- export declare class StructDeserializeStream<T extends Struct<any, any, any, any>> implements ReadableWritablePair<Uint8Array, StructValueType<T>> {
57
- private _readable;
58
- get readable(): ReadableStream<Awaited<ReturnType<T["deserialize"]>>>;
59
- private _writable;
60
- get writable(): WritableStream<Uint8Array>;
61
- constructor(struct: T);
62
- }
63
- export declare class StructSerializeStream<T extends Struct<any, any, any, any>> extends TransformStream<T['TInit'], Uint8Array> {
64
- constructor(struct: T);
65
- }
66
- export declare type WrapWritableStreamStart<T> = () => ValueOrPromise<WritableStream<T>>;
67
- export interface WritableStreamWrapper<T> {
68
- start: WrapWritableStreamStart<T>;
69
- close?(): Promise<void>;
70
- }
71
- export declare class WrapWritableStream<T> extends WritableStream<T> {
72
- writable: WritableStream<T>;
73
- private writer;
74
- constructor(wrapper: WritableStream<T> | WrapWritableStreamStart<T> | WritableStreamWrapper<T>);
75
- }
76
- export declare type WrapReadableStreamStart<T> = (controller: ReadableStreamDefaultController<T>) => ValueOrPromise<ReadableStream<T>>;
77
- export interface ReadableStreamWrapper<T> {
78
- start: WrapReadableStreamStart<T>;
79
- cancel?(reason?: any): ValueOrPromise<void>;
80
- close?(): ValueOrPromise<void>;
81
- }
82
- /**
83
- * This class has multiple usages:
84
- *
85
- * 1. Get notified when the stream is cancelled or closed.
86
- * 2. Synchronously create a `ReadableStream` by asynchronously return another `ReadableStream`.
87
- * 3. Convert native `ReadableStream`s to polyfilled ones so they can `pipe` between.
88
- */
89
- export declare class WrapReadableStream<T> extends ReadableStream<T> {
90
- readable: ReadableStream<T>;
91
- private reader;
92
- constructor(wrapper: ReadableStream<T> | WrapReadableStreamStart<T> | ReadableStreamWrapper<T>);
93
- }
94
- export declare class ChunkStream extends TransformStream<Uint8Array, Uint8Array> {
95
- constructor(size: number);
96
- }
97
- export declare class SplitLineStream extends TransformStream<string, string> {
98
- constructor();
99
- }
100
- /**
101
- * Create a new `WritableStream` that, when written to, will write that chunk to
102
- * `pair.writable`, when pipe `pair.readable` to `writable`.
103
- *
104
- * It's the opposite of `ReadableStream.pipeThrough`.
105
- *
106
- * @param writable The `WritableStream` to write to.
107
- * @param pair A `TransformStream` that converts chunks.
108
- * @returns A new `WritableStream`.
109
- */
110
- export declare function pipeFrom<W, T>(writable: WritableStream<W>, pair: ReadableWritablePair<W, T>): WritableStream<T>;
111
- export declare class InspectStream<T> extends TransformStream<T, T> {
112
- constructor(callback: (value: T) => void);
113
- }
114
- export interface PushReadableStreamController<T> {
115
- abortSignal: AbortSignal;
116
- enqueue(chunk: T): Promise<void>;
117
- close(): void;
118
- error(e?: any): void;
119
- }
120
- export declare type PushReadableStreamSource<T> = (controller: PushReadableStreamController<T>) => void;
121
- export declare class PushReadableStream<T> extends ReadableStream<T> {
122
- constructor(source: PushReadableStreamSource<T>, strategy?: QueuingStrategy<T>);
123
- }
124
- //# sourceMappingURL=transform.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/stream/transform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGzE,OAAO,EAAmB,WAAW,EAAE,cAAc,EAA+B,eAAe,EAAE,cAAc,EAA+B,KAAK,eAAe,EAAE,KAAK,+BAA+B,EAAE,KA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AAC,CAAC;CA6CxF"}
@@ -1,379 +0,0 @@
1
- import { PromiseResolver } from "@yume-chan/async";
2
- import { decodeUtf8 } from "../utils/index.js";
3
- import { BufferedStream, BufferedStreamEndedError } from "./buffered.js";
4
- import { AbortController, ReadableStream, TransformStream, WritableStream } from "./detect.js";
5
- /**
6
- * A factory for creating a duplex stream.
7
- *
8
- * It can create multiple `ReadableStream`s and `WritableStream`s,
9
- * when any of them is closed, all other streams will be closed as well.
10
- */
11
- export class DuplexStreamFactory {
12
- readableControllers = [];
13
- writers = [];
14
- _writableClosed = false;
15
- get writableClosed() { return this._writableClosed; }
16
- _closed = new PromiseResolver();
17
- get closed() { return this._closed.promise; }
18
- options;
19
- constructor(options) {
20
- this.options = options ?? {};
21
- }
22
- wrapReadable(readable) {
23
- return new WrapReadableStream({
24
- start: (controller) => {
25
- this.readableControllers.push(controller);
26
- return readable;
27
- },
28
- cancel: async () => {
29
- // cancel means the local peer closes the connection first.
30
- await this.close();
31
- },
32
- close: async () => {
33
- // stream end means the remote peer closed the connection first.
34
- await this.dispose();
35
- },
36
- });
37
- }
38
- createWritable(stream) {
39
- const writer = stream.getWriter();
40
- this.writers.push(writer);
41
- // `WritableStream` has no way to tell if the remote peer has closed the connection.
42
- // So it only triggers `close`.
43
- return new WritableStream({
44
- write: async (chunk) => {
45
- await writer.ready;
46
- await writer.write(chunk);
47
- },
48
- abort: async (reason) => {
49
- await writer.abort(reason);
50
- await this.close();
51
- },
52
- close: async () => {
53
- try {
54
- await writer.close();
55
- }
56
- catch { }
57
- await this.close();
58
- },
59
- });
60
- }
61
- async close() {
62
- if (this._writableClosed) {
63
- return;
64
- }
65
- this._writableClosed = true;
66
- // Call `close` first, so it can still write data to `WritableStream`s.
67
- if (await this.options.close?.() !== false) {
68
- // `close` can return `false` to disable automatic `dispose`.
69
- await this.dispose();
70
- }
71
- for (const writer of this.writers) {
72
- try {
73
- await writer.close();
74
- }
75
- catch { }
76
- }
77
- }
78
- async dispose() {
79
- this._writableClosed = true;
80
- this._closed.resolve();
81
- for (const controller of this.readableControllers) {
82
- try {
83
- controller.close();
84
- }
85
- catch { }
86
- }
87
- await this.options.dispose?.();
88
- }
89
- }
90
- export class DecodeUtf8Stream extends TransformStream {
91
- constructor() {
92
- super({
93
- transform(chunk, controller) {
94
- controller.enqueue(decodeUtf8(chunk));
95
- },
96
- });
97
- }
98
- }
99
- export class GatherStringStream extends WritableStream {
100
- // Optimization: rope (concat strings) is faster than `[].join('')`
101
- _result = '';
102
- get result() { return this._result; }
103
- constructor() {
104
- super({
105
- write: (chunk) => {
106
- this._result += chunk;
107
- },
108
- });
109
- }
110
- }
111
- // TODO: StructTransformStream: Looking for better implementation
112
- export class StructDeserializeStream {
113
- _readable;
114
- get readable() { return this._readable; }
115
- _writable;
116
- get writable() { return this._writable; }
117
- constructor(struct) {
118
- // Convert incoming chunks to a `BufferedStream`
119
- let incomingStreamController;
120
- const incomingStream = new BufferedStream(new PushReadableStream(controller => incomingStreamController = controller));
121
- this._readable = new ReadableStream({
122
- async pull(controller) {
123
- try {
124
- const value = await struct.deserialize(incomingStream);
125
- controller.enqueue(value);
126
- }
127
- catch (e) {
128
- if (e instanceof BufferedStreamEndedError) {
129
- controller.close();
130
- return;
131
- }
132
- throw e;
133
- }
134
- }
135
- });
136
- this._writable = new WritableStream({
137
- async write(chunk) {
138
- await incomingStreamController.enqueue(chunk);
139
- },
140
- abort() {
141
- incomingStreamController.close();
142
- },
143
- close() {
144
- incomingStreamController.close();
145
- },
146
- });
147
- }
148
- }
149
- export class StructSerializeStream extends TransformStream {
150
- constructor(struct) {
151
- super({
152
- transform(chunk, controller) {
153
- controller.enqueue(struct.serialize(chunk));
154
- },
155
- });
156
- }
157
- }
158
- async function getWrappedWritableStream(wrapper) {
159
- if ('start' in wrapper) {
160
- return await wrapper.start();
161
- }
162
- else if (typeof wrapper === 'function') {
163
- return await wrapper();
164
- }
165
- else {
166
- // Can't use `wrapper instanceof WritableStream`
167
- // Because we want to be compatible with any WritableStream-like objects
168
- return wrapper;
169
- }
170
- }
171
- export class WrapWritableStream extends WritableStream {
172
- writable;
173
- writer;
174
- constructor(wrapper) {
175
- super({
176
- start: async () => {
177
- // `start` is invoked before `ReadableStream`'s constructor finish,
178
- // so using `this` synchronously causes
179
- // "Must call super constructor in derived class before accessing 'this' or returning from derived constructor".
180
- // Queue a microtask to avoid this.
181
- await Promise.resolve();
182
- this.writable = await getWrappedWritableStream(wrapper);
183
- this.writer = this.writable.getWriter();
184
- },
185
- write: async (chunk) => {
186
- // Maintain back pressure
187
- await this.writer.ready;
188
- await this.writer.write(chunk);
189
- },
190
- abort: async (reason) => {
191
- await this.writer.abort(reason);
192
- if ('close' in wrapper) {
193
- await wrapper.close?.();
194
- }
195
- },
196
- close: async () => {
197
- // Close the inner stream first.
198
- // Usually the inner stream is a logical sub-stream over the outer stream,
199
- // closing the outer stream first will make the inner stream incapable of
200
- // sending data in its `close` handler.
201
- await this.writer.close();
202
- if ('close' in wrapper) {
203
- await wrapper.close?.();
204
- }
205
- },
206
- });
207
- }
208
- }
209
- function getWrappedReadableStream(wrapper, controller) {
210
- if ('start' in wrapper) {
211
- return wrapper.start(controller);
212
- }
213
- else if (typeof wrapper === 'function') {
214
- return wrapper(controller);
215
- }
216
- else {
217
- // Can't use `wrapper instanceof ReadableStream`
218
- // Because we want to be compatible with any ReadableStream-like objects
219
- return wrapper;
220
- }
221
- }
222
- /**
223
- * This class has multiple usages:
224
- *
225
- * 1. Get notified when the stream is cancelled or closed.
226
- * 2. Synchronously create a `ReadableStream` by asynchronously return another `ReadableStream`.
227
- * 3. Convert native `ReadableStream`s to polyfilled ones so they can `pipe` between.
228
- */
229
- export class WrapReadableStream extends ReadableStream {
230
- readable;
231
- reader;
232
- constructor(wrapper) {
233
- super({
234
- start: async (controller) => {
235
- // `start` is invoked before `ReadableStream`'s constructor finish,
236
- // so using `this` synchronously causes
237
- // "Must call super constructor in derived class before accessing 'this' or returning from derived constructor".
238
- // Queue a microtask to avoid this.
239
- await Promise.resolve();
240
- this.readable = await getWrappedReadableStream(wrapper, controller);
241
- this.reader = this.readable.getReader();
242
- },
243
- cancel: async (reason) => {
244
- await this.reader.cancel(reason);
245
- if ('cancel' in wrapper) {
246
- await wrapper.cancel?.(reason);
247
- }
248
- },
249
- pull: async (controller) => {
250
- const result = await this.reader.read();
251
- if (result.done) {
252
- controller.close();
253
- if ('close' in wrapper) {
254
- await wrapper.close?.();
255
- }
256
- }
257
- else {
258
- controller.enqueue(result.value);
259
- }
260
- }
261
- });
262
- }
263
- }
264
- export class ChunkStream extends TransformStream {
265
- constructor(size) {
266
- super({
267
- transform(chunk, controller) {
268
- for (let start = 0; start < chunk.byteLength;) {
269
- const end = start + size;
270
- controller.enqueue(chunk.subarray(start, end));
271
- start = end;
272
- }
273
- }
274
- });
275
- }
276
- }
277
- function* splitLines(text) {
278
- let start = 0;
279
- while (true) {
280
- const index = text.indexOf('\n', start);
281
- if (index === -1) {
282
- return;
283
- }
284
- const line = text.substring(start, index);
285
- yield line;
286
- start = index + 1;
287
- }
288
- }
289
- export class SplitLineStream extends TransformStream {
290
- constructor() {
291
- super({
292
- transform(chunk, controller) {
293
- for (const line of splitLines(chunk)) {
294
- controller.enqueue(line);
295
- }
296
- }
297
- });
298
- }
299
- }
300
- /**
301
- * Create a new `WritableStream` that, when written to, will write that chunk to
302
- * `pair.writable`, when pipe `pair.readable` to `writable`.
303
- *
304
- * It's the opposite of `ReadableStream.pipeThrough`.
305
- *
306
- * @param writable The `WritableStream` to write to.
307
- * @param pair A `TransformStream` that converts chunks.
308
- * @returns A new `WritableStream`.
309
- */
310
- export function pipeFrom(writable, pair) {
311
- const writer = pair.writable.getWriter();
312
- const pipe = pair.readable
313
- .pipeTo(writable);
314
- return new WritableStream({
315
- async write(chunk) {
316
- await writer.ready;
317
- await writer.write(chunk);
318
- },
319
- async close() {
320
- await writer.close();
321
- await pipe;
322
- }
323
- });
324
- }
325
- export class InspectStream extends TransformStream {
326
- constructor(callback) {
327
- super({
328
- transform(chunk, controller) {
329
- callback(chunk);
330
- controller.enqueue(chunk);
331
- }
332
- });
333
- }
334
- }
335
- export class PushReadableStream extends ReadableStream {
336
- constructor(source, strategy) {
337
- let waterMarkLow;
338
- const canceled = new AbortController();
339
- super({
340
- start: (controller) => {
341
- source({
342
- abortSignal: canceled.signal,
343
- async enqueue(chunk) {
344
- if (canceled.signal.aborted) {
345
- // If the stream is already cancelled,
346
- // throw immediately.
347
- throw canceled.signal.reason ?? new Error('Aborted');
348
- }
349
- // Only when the stream is errored, `desiredSize` will be `null`.
350
- // But since `null <= 0` is `true`
351
- // (`null <= 0` is evaluated as `!(null > 0)` => `!false` => `true`),
352
- // not handling it will cause a deadlock.
353
- if ((controller.desiredSize ?? 1) <= 0) {
354
- waterMarkLow = new PromiseResolver();
355
- await waterMarkLow.promise;
356
- }
357
- // `controller.enqueue` will throw error for us
358
- // if the stream is already errored.
359
- controller.enqueue(chunk);
360
- },
361
- close() {
362
- controller.close();
363
- },
364
- error(e) {
365
- controller.error(e);
366
- },
367
- });
368
- },
369
- pull: () => {
370
- waterMarkLow?.resolve();
371
- },
372
- cancel: async (reason) => {
373
- canceled.abort(reason);
374
- waterMarkLow?.reject(reason);
375
- },
376
- }, strategy);
377
- }
378
- }
379
- //# sourceMappingURL=transform.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/stream/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,eAAe,EAAe,cAAc,EAA+B,eAAe,EAAE,cAAc,EAAsH,MAAM,aAAa,CAAC;AA4B7P;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IACpB,mBAAmB,GAAyC,EAAE,CAAC;IAC/D,OAAO,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