@gurezo/web-serial-rxjs 0.2.0 → 2.0.1

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 (57) hide show
  1. package/README.ja.md +21 -107
  2. package/README.md +23 -127
  3. package/dist/errors/serial-error-code.d.ts +7 -0
  4. package/dist/errors/serial-error-code.d.ts.map +1 -1
  5. package/dist/index.d.ts +31 -32
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +459 -673
  8. package/dist/index.mjs +459 -673
  9. package/dist/index.mjs.map +4 -4
  10. package/dist/session/create-serial-session.d.ts +49 -0
  11. package/dist/session/create-serial-session.d.ts.map +1 -0
  12. package/dist/session/index.d.ts +5 -0
  13. package/dist/session/index.d.ts.map +1 -0
  14. package/dist/session/internal/build-request-options.d.ts +18 -0
  15. package/dist/session/internal/build-request-options.d.ts.map +1 -0
  16. package/dist/session/internal/has-web-serial-support.d.ts +12 -0
  17. package/dist/session/internal/has-web-serial-support.d.ts.map +1 -0
  18. package/dist/session/internal/line-buffer.d.ts +14 -0
  19. package/dist/session/internal/line-buffer.d.ts.map +1 -0
  20. package/dist/session/normalize-serial-error.d.ts +55 -0
  21. package/dist/session/normalize-serial-error.d.ts.map +1 -0
  22. package/dist/session/read-pump.d.ts +74 -0
  23. package/dist/session/read-pump.d.ts.map +1 -0
  24. package/dist/session/send-queue.d.ts +58 -0
  25. package/dist/session/send-queue.d.ts.map +1 -0
  26. package/dist/session/serial-session-options.d.ts +80 -0
  27. package/dist/session/serial-session-options.d.ts.map +1 -0
  28. package/dist/session/serial-session-state.d.ts +35 -0
  29. package/dist/session/serial-session-state.d.ts.map +1 -0
  30. package/dist/session/serial-session.d.ts +143 -0
  31. package/dist/session/serial-session.d.ts.map +1 -0
  32. package/dist/session/session-state-machine.d.ts +39 -0
  33. package/dist/session/session-state-machine.d.ts.map +1 -0
  34. package/package.json +1 -5
  35. package/web-serial-rxjs-icon.png +0 -0
  36. package/dist/browser/browser-detection.d.ts +0 -104
  37. package/dist/browser/browser-detection.d.ts.map +0 -1
  38. package/dist/browser/browser-support.d.ts +0 -57
  39. package/dist/browser/browser-support.d.ts.map +0 -1
  40. package/dist/client/index.d.ts +0 -283
  41. package/dist/client/index.d.ts.map +0 -1
  42. package/dist/client/serial-client.d.ts +0 -137
  43. package/dist/client/serial-client.d.ts.map +0 -1
  44. package/dist/filters/build-request-options.d.ts +0 -42
  45. package/dist/filters/build-request-options.d.ts.map +0 -1
  46. package/dist/io/observable-to-writable.d.ts +0 -65
  47. package/dist/io/observable-to-writable.d.ts.map +0 -1
  48. package/dist/io/readable-to-observable.d.ts +0 -44
  49. package/dist/io/readable-to-observable.d.ts.map +0 -1
  50. package/dist/lib/web-serial-rxjs.d.ts +0 -7
  51. package/dist/lib/web-serial-rxjs.d.ts.map +0 -1
  52. package/dist/shell/create-shell-client.d.ts +0 -17
  53. package/dist/shell/create-shell-client.d.ts.map +0 -1
  54. package/dist/shell/index.d.ts +0 -2
  55. package/dist/shell/index.d.ts.map +0 -1
  56. package/dist/types/options.d.ts +0 -107
  57. package/dist/types/options.d.ts.map +0 -1
@@ -1,283 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { SerialClientOptions } from '../types/options';
3
- /**
4
- * SerialClient interface for interacting with serial ports using RxJS Observables.
5
- *
6
- * This interface provides a reactive API for serial port communication, allowing you to
7
- * connect to serial devices, read and write data using RxJS Observables.
8
- *
9
- * @example
10
- * ```typescript
11
- * const client = createSerialClient({ baudRate: 9600 });
12
- *
13
- * // Connect to a port
14
- * client.connect().subscribe({
15
- * next: () => {
16
- * console.log('Connected!');
17
- *
18
- * // Read data
19
- * client.getReadStream().subscribe({
20
- * next: (data) => console.log('Received:', data),
21
- * });
22
- *
23
- * // Write data
24
- * const encoder = new TextEncoder();
25
- * client.write(encoder.encode('Hello')).subscribe();
26
- * },
27
- * error: (error) => console.error('Connection error:', error),
28
- * });
29
- * ```
30
- */
31
- export interface SerialClient {
32
- /**
33
- * Request a serial port from the user.
34
- *
35
- * This method opens the browser's port selection dialog and returns an Observable
36
- * that emits the selected SerialPort when the user chooses a port.
37
- *
38
- * @returns An Observable that emits the selected {@link SerialPort} when the user selects a port
39
- * @throws {@link SerialError} with code {@link SerialErrorCode.OPERATION_CANCELLED} if the user cancels the selection
40
- * @throws {@link SerialError} with code {@link SerialErrorCode.PORT_NOT_AVAILABLE} if the port request fails
41
- * @throws {@link SerialError} with code {@link SerialErrorCode.BROWSER_NOT_SUPPORTED} if the browser doesn't support Web Serial API
42
- *
43
- * @example
44
- * ```typescript
45
- * client.requestPort().subscribe({
46
- * next: (port) => console.log('Selected port:', port),
47
- * error: (error) => console.error('Port selection failed:', error),
48
- * });
49
- * ```
50
- */
51
- requestPort(): Observable<SerialPort>;
52
- /**
53
- * Get available serial ports that have been previously granted access.
54
- *
55
- * This method returns an Observable that emits an array of SerialPort instances
56
- * that the user has previously granted access to in this browser session.
57
- *
58
- * @returns An Observable that emits an array of available {@link SerialPort} instances
59
- * @throws {@link SerialError} with code {@link SerialErrorCode.PORT_NOT_AVAILABLE} if getting ports fails
60
- * @throws {@link SerialError} with code {@link SerialErrorCode.BROWSER_NOT_SUPPORTED} if the browser doesn't support Web Serial API
61
- *
62
- * @example
63
- * ```typescript
64
- * client.getPorts().subscribe({
65
- * next: (ports) => {
66
- * console.log(`Found ${ports.length} available ports`);
67
- * if (ports.length > 0) {
68
- * client.connect(ports[0]).subscribe();
69
- * }
70
- * },
71
- * });
72
- * ```
73
- */
74
- getPorts(): Observable<SerialPort[]>;
75
- /**
76
- * Connect to a serial port.
77
- *
78
- * Opens the specified port (or requests one if not provided) and configures it
79
- * with the options passed to {@link createSerialClient}. The port must be connected
80
- * before reading or writing data.
81
- *
82
- * @param port - Optional {@link SerialPort} to connect to. If not provided, will call {@link requestPort} to prompt the user.
83
- * @returns An Observable that completes when the port is successfully opened
84
- * @throws {@link SerialError} with code {@link SerialErrorCode.PORT_ALREADY_OPEN} if a port is already open
85
- * @throws {@link SerialError} with code {@link SerialErrorCode.PORT_OPEN_FAILED} if opening the port fails
86
- * @throws {@link SerialError} with code {@link SerialErrorCode.OPERATION_CANCELLED} if the user cancels port selection
87
- * @throws {@link SerialError} with code {@link SerialErrorCode.BROWSER_NOT_SUPPORTED} if the browser doesn't support Web Serial API
88
- *
89
- * @example
90
- * ```typescript
91
- * // Connect by requesting a port
92
- * client.connect().subscribe({
93
- * next: () => console.log('Connected!'),
94
- * error: (error) => console.error('Connection failed:', error),
95
- * });
96
- *
97
- * // Connect to a specific port
98
- * client.getPorts().subscribe({
99
- * next: (ports) => {
100
- * if (ports.length > 0) {
101
- * client.connect(ports[0]).subscribe();
102
- * }
103
- * },
104
- * });
105
- * ```
106
- */
107
- connect(port?: SerialPort): Observable<void>;
108
- /**
109
- * Disconnect from the serial port.
110
- *
111
- * Closes the currently open port and stops all active read/write streams.
112
- * This method is safe to call even if no port is currently open.
113
- *
114
- * @returns An Observable that completes when the port is successfully closed
115
- * @throws {@link SerialError} with code {@link SerialErrorCode.CONNECTION_LOST} if closing the port fails
116
- *
117
- * @example
118
- * ```typescript
119
- * client.disconnect().subscribe({
120
- * next: () => console.log('Disconnected'),
121
- * error: (error) => console.error('Disconnect failed:', error),
122
- * });
123
- * ```
124
- */
125
- disconnect(): Observable<void>;
126
- /**
127
- * Get an Observable that emits data read from the serial port.
128
- *
129
- * Returns an Observable stream that emits Uint8Array chunks as data is received
130
- * from the serial port. The stream will continue until the port is disconnected
131
- * or an error occurs.
132
- *
133
- * @returns An Observable that emits Uint8Array chunks containing data read from the serial port
134
- * @throws {@link SerialError} with code {@link SerialErrorCode.PORT_NOT_OPEN} if the port is not open
135
- *
136
- * @example
137
- * ```typescript
138
- * client.getReadStream().subscribe({
139
- * next: (data) => {
140
- * const text = new TextDecoder().decode(data);
141
- * console.log('Received:', text);
142
- * },
143
- * error: (error) => console.error('Read error:', error),
144
- * });
145
- * ```
146
- */
147
- getReadStream(): Observable<Uint8Array>;
148
- /**
149
- * Get an Observable that emits text read from the serial port.
150
- *
151
- * This is a convenience API on top of {@link getReadStream} that decodes bytes
152
- * with TextDecoder and emits text chunks.
153
- *
154
- * @returns An Observable that emits decoded text chunks
155
- * @throws {@link SerialError} with code {@link SerialErrorCode.PORT_NOT_OPEN} if the port is not open
156
- */
157
- getReadStreamAsText(): Observable<string>;
158
- /**
159
- * Write data to the serial port from an Observable.
160
- *
161
- * Writes data from an Observable stream to the serial port. The Observable should
162
- * emit Uint8Array chunks that will be written sequentially to the port. If a previous
163
- * write stream is active, it will be cancelled before starting the new one.
164
- *
165
- * @param data$ - Observable that emits Uint8Array chunks to write to the serial port
166
- * @returns An Observable that completes when all data has been written and the stream completes
167
- * @throws {@link SerialError} with code {@link SerialErrorCode.PORT_NOT_OPEN} if the port is not open
168
- * @throws {@link SerialError} with code {@link SerialErrorCode.WRITE_FAILED} if writing fails
169
- *
170
- * @example
171
- * ```typescript
172
- * const data$ = from([
173
- * new TextEncoder().encode('Hello'),
174
- * new TextEncoder().encode('World'),
175
- * ]);
176
- *
177
- * client.writeStream(data$).subscribe({
178
- * next: () => console.log('Writing...'),
179
- * complete: () => console.log('All data written'),
180
- * error: (error) => console.error('Write error:', error),
181
- * });
182
- * ```
183
- */
184
- writeStream(data$: Observable<Uint8Array>): Observable<void>;
185
- /**
186
- * Write a single chunk of data to the serial port.
187
- *
188
- * Writes a single Uint8Array chunk to the serial port. For writing multiple chunks,
189
- * consider using {@link writeStream} with an Observable instead.
190
- *
191
- * @param data - Uint8Array data to write to the serial port
192
- * @returns An Observable that completes when the data has been written
193
- * @throws {@link SerialError} with code {@link SerialErrorCode.PORT_NOT_OPEN} if the port is not open
194
- * @throws {@link SerialError} with code {@link SerialErrorCode.WRITE_FAILED} if writing fails
195
- *
196
- * @example
197
- * ```typescript
198
- * const encoder = new TextEncoder();
199
- * const data = encoder.encode('Hello, Serial!');
200
- *
201
- * client.write(data).subscribe({
202
- * next: () => console.log('Data written'),
203
- * error: (error) => console.error('Write error:', error),
204
- * });
205
- * ```
206
- */
207
- write(data: Uint8Array): Observable<void>;
208
- /**
209
- * Write text data to the serial port.
210
- *
211
- * This is a convenience API on top of {@link write} that encodes text with TextEncoder.
212
- *
213
- * @param data - Text data to write to the serial port
214
- * @returns An Observable that completes when the data has been written
215
- * @throws {@link SerialError} with code {@link SerialErrorCode.PORT_NOT_OPEN} if the port is not open
216
- * @throws {@link SerialError} with code {@link SerialErrorCode.WRITE_FAILED} if writing fails
217
- */
218
- writeText(data: string): Observable<void>;
219
- /**
220
- * Check if the port is currently open and connected.
221
- *
222
- * @returns `true` if a port is currently open, `false` otherwise
223
- */
224
- readonly connected: boolean;
225
- /**
226
- * Reactive connection state stream.
227
- *
228
- * Emits `true` when connected and `false` when disconnected.
229
- */
230
- readonly connected$: Observable<boolean>;
231
- /**
232
- * Reactive connection event stream.
233
- *
234
- * Emits `'connected'` on successful connection and `'disconnected'` on disconnection.
235
- */
236
- readonly connectionEvents$: Observable<'connected' | 'disconnected'>;
237
- /**
238
- * Get the current SerialPort instance.
239
- *
240
- * Returns the currently connected SerialPort instance, or `null` if no port is open.
241
- * This allows direct access to the underlying Web Serial API SerialPort object if needed.
242
- *
243
- * @returns The current {@link SerialPort} instance, or `null` if no port is open
244
- */
245
- readonly currentPort: SerialPort | null;
246
- }
247
- /**
248
- * Create a new SerialClient instance for interacting with serial ports.
249
- *
250
- * This is the main entry point for creating a serial client. The client provides
251
- * a reactive RxJS-based API for connecting to serial ports and reading/writing data.
252
- *
253
- * @param options - Optional configuration options for the serial port connection.
254
- * If not provided, default values will be used (9600 baud, 8 data bits, etc.)
255
- * @returns A new {@link SerialClient} instance
256
- * @throws {@link SerialError} with code {@link SerialErrorCode.BROWSER_NOT_SUPPORTED} if the browser doesn't support Web Serial API
257
- *
258
- * @example
259
- * ```typescript
260
- * // Create a client with default settings (9600 baud)
261
- * const client = createSerialClient();
262
- *
263
- * // Create a client with custom settings
264
- * const client = createSerialClient({
265
- * baudRate: 115200,
266
- * dataBits: 8,
267
- * stopBits: 1,
268
- * parity: 'none',
269
- * filters: [{ usbVendorId: 0x1234 }],
270
- * });
271
- *
272
- * // Check browser support before creating a client
273
- * import { isBrowserSupported } from '@gurezo/web-serial-rxjs';
274
- *
275
- * if (!isBrowserSupported()) {
276
- * console.error('Web Serial API is not supported');
277
- * } else {
278
- * const client = createSerialClient();
279
- * }
280
- * ```
281
- */
282
- export declare function createSerialClient(options?: SerialClientOptions): SerialClient;
283
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC;IAEtC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,QAAQ,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC;IAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,OAAO,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAE7C;;;;;;;;;;;;;;;;OAgBG;IACH,UAAU,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAE/B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,aAAa,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC;IAExC;;;;;;;;OAQG;IACH,mBAAmB,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IAE1C;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAE7D;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAE1C;;;;;;;;;OASG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAE1C;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAEzC;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,WAAW,GAAG,cAAc,CAAC,CAAC;IAErE;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,EAAE,UAAU,GAAG,IAAI,CAAC;CACzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,CAAC,EAAE,mBAAmB,GAC5B,YAAY,CAEd"}
@@ -1,137 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { SerialClientOptions } from '../types/options';
3
- /**
4
- * Internal implementation of SerialClient interface.
5
- *
6
- * This class implements the {@link SerialClient} interface and provides the actual
7
- * functionality for serial port communication. Users should not instantiate this class
8
- * directly; instead, use {@link createSerialClient} to create a SerialClient instance.
9
- *
10
- * @internal
11
- */
12
- export declare class SerialClientImpl {
13
- /** @internal */
14
- private port;
15
- /** @internal */
16
- private isOpen;
17
- /** @internal */
18
- private readSubscription;
19
- /** @internal */
20
- private writeSubscription;
21
- /** @internal */
22
- private sharedReadStream$;
23
- /** @internal */
24
- private textEncoder;
25
- /** @internal */
26
- private textDecoder;
27
- /** @internal */
28
- private readonly connectedState$;
29
- /** @internal */
30
- private readonly connectionEventsSubject$;
31
- /** @internal */
32
- private readonly options;
33
- /**
34
- * Creates a new SerialClientImpl instance.
35
- *
36
- * @param options - Optional configuration options for the serial port connection
37
- * @throws {@link SerialError} with code {@link SerialErrorCode.BROWSER_NOT_SUPPORTED} if the browser doesn't support Web Serial API
38
- * @internal
39
- */
40
- constructor(options?: SerialClientOptions);
41
- /**
42
- * Request a serial port from the user.
43
- *
44
- * @returns Observable that emits the selected SerialPort
45
- * @internal
46
- */
47
- requestPort(): Observable<SerialPort>;
48
- /**
49
- * Get available serial ports.
50
- *
51
- * @returns Observable that emits an array of available SerialPorts
52
- * @internal
53
- */
54
- getPorts(): Observable<SerialPort[]>;
55
- /**
56
- * Connect to a serial port.
57
- *
58
- * @param port - Optional SerialPort to connect to. If not provided, will request one.
59
- * @returns Observable that completes when the port is opened
60
- * @internal
61
- */
62
- connect(port?: SerialPort): Observable<void>;
63
- /**
64
- * Disconnect from the serial port.
65
- *
66
- * @returns Observable that completes when the port is closed
67
- * @internal
68
- */
69
- disconnect(): Observable<void>;
70
- /**
71
- * Get an Observable that emits data read from the serial port.
72
- *
73
- * @returns Observable that emits Uint8Array chunks
74
- * @internal
75
- */
76
- getReadStream(): Observable<Uint8Array>;
77
- /**
78
- * Get an Observable that emits decoded text from the serial port.
79
- *
80
- * @returns Observable that emits text chunks
81
- * @internal
82
- */
83
- getReadStreamAsText(): Observable<string>;
84
- /**
85
- * Write data to the serial port from an Observable.
86
- *
87
- * @param data$ - Observable that emits Uint8Array chunks to write
88
- * @returns Observable that completes when writing is finished
89
- * @internal
90
- */
91
- writeStream(data$: Observable<Uint8Array>): Observable<void>;
92
- /**
93
- * Write a single chunk of data to the serial port.
94
- *
95
- * @param data - Data to write
96
- * @returns Observable that completes when the data is written
97
- * @internal
98
- */
99
- write(data: Uint8Array): Observable<void>;
100
- /**
101
- * Write text data to the serial port.
102
- *
103
- * @param data - Text data to write
104
- * @returns Observable that completes when the data is written
105
- * @internal
106
- */
107
- writeText(data: string): Observable<void>;
108
- /**
109
- * Check if the port is currently open.
110
- *
111
- * @returns `true` if a port is currently open, `false` otherwise
112
- * @internal
113
- */
114
- get connected(): boolean;
115
- /**
116
- * Get an Observable that emits connection state changes.
117
- *
118
- * @returns Observable that emits `true` when connected and `false` when disconnected
119
- * @internal
120
- */
121
- get connected$(): Observable<boolean>;
122
- /**
123
- * Get an Observable that emits connection lifecycle events.
124
- *
125
- * @returns Observable that emits 'connected' or 'disconnected'
126
- * @internal
127
- */
128
- get connectionEvents$(): Observable<'connected' | 'disconnected'>;
129
- /**
130
- * Get the current SerialPort instance.
131
- *
132
- * @returns The current SerialPort instance, or `null` if no port is open
133
- * @internal
134
- */
135
- get currentPort(): SerialPort | null;
136
- }
137
- //# sourceMappingURL=serial-client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serial-client.d.ts","sourceRoot":"","sources":["../../src/client/serial-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAMX,MAAM,MAAM,CAAC;AAMd,OAAO,EAEL,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;GAQG;AACH,qBAAa,gBAAgB;IAC3B,gBAAgB;IAChB,OAAO,CAAC,IAAI,CAA2B;IACvC,gBAAgB;IAChB,OAAO,CAAC,MAAM,CAAS;IACvB,gBAAgB;IAChB,OAAO,CAAC,gBAAgB,CAA4C;IACpE,gBAAgB;IAChB,OAAO,CAAC,iBAAiB,CAA4C;IACrE,gBAAgB;IAChB,OAAO,CAAC,iBAAiB,CAAuC;IAChE,gBAAgB;IAChB,OAAO,CAAC,WAAW,CAAqB;IACxC,gBAAgB;IAChB,OAAO,CAAC,WAAW,CAAqB;IACxC,gBAAgB;IAChB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuC;IACvE,gBAAgB;IAChB,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAErC;IACJ,gBAAgB;IAChB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAEtB;IAEF;;;;;;OAMG;gBACS,OAAO,CAAC,EAAE,mBAAmB;IASzC;;;;;OAKG;IACH,WAAW,IAAI,UAAU,CAAC,UAAU,CAAC;IAuBrC;;;;;OAKG;IACH,QAAQ,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;IAcpC;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC;IA2D5C;;;;;OAKG;IACH,UAAU,IAAI,UAAU,CAAC,IAAI,CAAC;IA2C9B;;;;;OAKG;IACH,aAAa,IAAI,UAAU,CAAC,UAAU,CAAC;IAqBvC;;;;;OAKG;IACH,mBAAmB,IAAI,UAAU,CAAC,MAAM,CAAC;IAMzC;;;;;;OAMG;IACH,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC;IAuD5D;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC;IA0BzC;;;;;;OAMG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC;IAIzC;;;;;OAKG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;;;;OAKG;IACH,IAAI,UAAU,IAAI,UAAU,CAAC,OAAO,CAAC,CAEpC;IAED;;;;;OAKG;IACH,IAAI,iBAAiB,IAAI,UAAU,CAAC,WAAW,GAAG,cAAc,CAAC,CAEhE;IAED;;;;;OAKG;IACH,IAAI,WAAW,IAAI,UAAU,GAAG,IAAI,CAEnC;CACF"}
@@ -1,42 +0,0 @@
1
- import { SerialClientOptions } from '../types/options';
2
- /**
3
- * Build SerialPortRequestOptions from SerialClientOptions.
4
- *
5
- * This utility function converts filter options from {@link SerialClientOptions} into
6
- * the format expected by the Web Serial API's `navigator.serial.requestPort()` method.
7
- * It validates the filter options to ensure they are valid before returning them.
8
- *
9
- * If no filters are provided in the options, this function returns `undefined`, which
10
- * allows the port selection dialog to show all available ports.
11
- *
12
- * @param options - Optional SerialClientOptions containing filter configuration
13
- * @returns SerialPortRequestOptions object with validated filters, or `undefined` if no filters are provided
14
- * @throws {@link SerialError} with code {@link SerialErrorCode.INVALID_FILTER_OPTIONS} if filter validation fails
15
- *
16
- * @example
17
- * ```typescript
18
- * // With filters
19
- * const options = {
20
- * baudRate: 9600,
21
- * filters: [
22
- * { usbVendorId: 0x1234 },
23
- * { usbVendorId: 0x5678, usbProductId: 0x9abc },
24
- * ],
25
- * };
26
- * const requestOptions = buildRequestOptions(options);
27
- * // Returns: { filters: [...] }
28
- *
29
- * // Without filters
30
- * const requestOptions = buildRequestOptions({ baudRate: 9600 });
31
- * // Returns: undefined
32
- *
33
- * // Invalid filter (will throw)
34
- * try {
35
- * buildRequestOptions({ filters: [{ usbVendorId: -1 }] });
36
- * } catch (error) {
37
- * // SerialError with code INVALID_FILTER_OPTIONS
38
- * }
39
- * ```
40
- */
41
- export declare function buildRequestOptions(options?: SerialClientOptions): SerialPortRequestOptions | undefined;
42
- //# sourceMappingURL=build-request-options.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-request-options.d.ts","sourceRoot":"","sources":["../../src/filters/build-request-options.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,CAAC,EAAE,mBAAmB,GAC5B,wBAAwB,GAAG,SAAS,CA4CtC"}
@@ -1,65 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- /**
3
- * Convert an RxJS Observable to a WritableStream.
4
- *
5
- * This utility function converts an RxJS Observable into a Web Streams API WritableStream.
6
- * Values emitted by the Observable will be written to the returned WritableStream. The stream
7
- * will close when the Observable completes or abort if the Observable errors.
8
- *
9
- * Note: This function creates a new WritableStream. For directly subscribing to an Observable
10
- * and writing to an existing WritableStream, use {@link subscribeToWritable} instead.
11
- *
12
- * @param observable - The Observable to convert to a WritableStream
13
- * @returns A WritableStream that writes Uint8Array chunks emitted by the Observable
14
- *
15
- * @example
16
- * ```typescript
17
- * const data$ = from([
18
- * new TextEncoder().encode('Hello'),
19
- * new TextEncoder().encode('World'),
20
- * ]);
21
- *
22
- * const writableStream = observableToWritable(data$);
23
- * // Use the writable stream with other Web Streams APIs
24
- * ```
25
- */
26
- export declare function observableToWritable(observable: Observable<Uint8Array>): WritableStream<Uint8Array>;
27
- /**
28
- * Subscribe to an Observable and write its values to a WritableStream.
29
- *
30
- * This utility function subscribes to an RxJS Observable and writes all emitted values
31
- * to the provided WritableStream. This is commonly used to write Observable data to a
32
- * serial port's writable stream.
33
- *
34
- * The function returns a subscription object that can be used to unsubscribe and clean up.
35
- * When unsubscribed, the writer lock will be released properly.
36
- *
37
- * @param observable - The Observable to subscribe to and read data from
38
- * @param stream - The WritableStream to write data to
39
- * @returns A subscription object with an `unsubscribe` method for cleanup
40
- * @throws {@link SerialError} with code {@link SerialErrorCode.WRITE_FAILED} if writing to the stream fails
41
- *
42
- * @example
43
- * ```typescript
44
- * const data$ = from([
45
- * new TextEncoder().encode('Hello'),
46
- * new TextEncoder().encode('World'),
47
- * ]);
48
- *
49
- * const subscription = subscribeToWritable(data$, port.writable);
50
- *
51
- * // Later, to cancel and clean up:
52
- * subscription.unsubscribe();
53
- *
54
- * // Use with RxJS operators
55
- * const processedData$ = of('Hello, Serial!').pipe(
56
- * map((text) => new TextEncoder().encode(text))
57
- * );
58
- *
59
- * subscribeToWritable(processedData$, port.writable);
60
- * ```
61
- */
62
- export declare function subscribeToWritable(observable: Observable<Uint8Array>, stream: WritableStream<Uint8Array>): {
63
- unsubscribe: () => void;
64
- };
65
- //# sourceMappingURL=observable-to-writable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"observable-to-writable.d.ts","sourceRoot":"","sources":["../../src/io/observable-to-writable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGlC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,GACjC,cAAc,CAAC,UAAU,CAAC,CAqE5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,EAClC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GACjC;IAAE,WAAW,EAAE,MAAM,IAAI,CAAA;CAAE,CAiD7B"}
@@ -1,44 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- /**
3
- * Convert a ReadableStream to an RxJS Observable.
4
- *
5
- * This utility function converts a Web Streams API ReadableStream into an RxJS Observable,
6
- * allowing you to use RxJS operators with stream data. The Observable will emit Uint8Array
7
- * chunks as they are read from the stream, complete when the stream ends, or error if
8
- * the stream encounters an error.
9
- *
10
- * The returned Observable handles stream cleanup automatically - if you unsubscribe before
11
- * the stream completes, the reader lock will be released properly.
12
- *
13
- * @param stream - The ReadableStream to convert to an Observable
14
- * @returns An Observable that emits Uint8Array chunks from the stream
15
- * @throws {@link SerialError} with code {@link SerialErrorCode.READ_FAILED} if reading from the stream fails
16
- *
17
- * @example
18
- * ```typescript
19
- * // Convert a serial port's readable stream to an Observable
20
- * const readable$ = readableToObservable(port.readable);
21
- *
22
- * readable$.subscribe({
23
- * next: (chunk) => {
24
- * console.log('Received chunk:', chunk);
25
- * },
26
- * complete: () => {
27
- * console.log('Stream completed');
28
- * },
29
- * error: (error) => {
30
- * console.error('Stream error:', error);
31
- * },
32
- * });
33
- *
34
- * // Use with RxJS operators
35
- * readableToObservable(port.readable)
36
- * .pipe(
37
- * map((chunk) => new TextDecoder().decode(chunk)),
38
- * filter((text) => text.includes('OK'))
39
- * )
40
- * .subscribe((text) => console.log('Filtered text:', text));
41
- * ```
42
- */
43
- export declare function readableToObservable(stream: ReadableStream<Uint8Array>): Observable<Uint8Array>;
44
- //# sourceMappingURL=readable-to-observable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"readable-to-observable.d.ts","sourceRoot":"","sources":["../../src/io/readable-to-observable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GACjC,UAAU,CAAC,UAAU,CAAC,CAoDxB"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Utility function that returns the library name.
3
- *
4
- * @returns The library name as a string: 'web-serial-rxjs'
5
- */
6
- export declare function webSerialRxjs(): string;
7
- //# sourceMappingURL=web-serial-rxjs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-serial-rxjs.d.ts","sourceRoot":"","sources":["../../src/lib/web-serial-rxjs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
@@ -1,17 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import type { SerialClient } from '../client';
3
- export interface ShellClientOptions {
4
- prompt: string | RegExp;
5
- timeout?: number;
6
- retry?: number;
7
- lineEnding?: string;
8
- }
9
- export interface ShellExecResult {
10
- stdout: string;
11
- }
12
- export interface ShellClient {
13
- exec$(command: string): Observable<ShellExecResult>;
14
- readUntilPrompt$(): Observable<string>;
15
- }
16
- export declare function createShellClient(client: SerialClient, options: ShellClientOptions): ShellClient;
17
- //# sourceMappingURL=create-shell-client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-shell-client.d.ts","sourceRoot":"","sources":["../../src/shell/create-shell-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAMX,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IACpD,gBAAgB,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;CACxC;AAyLD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,kBAAkB,GAC1B,WAAW,CAEb"}
@@ -1,2 +0,0 @@
1
- export { createShellClient, type ShellClient, type ShellClientOptions, type ShellExecResult, } from './create-shell-client';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAC"}