@gurezo/web-serial-rxjs 2.4.0 → 3.1.0

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 +17 -10
  2. package/README.md +21 -12
  3. package/dist/errors/serial-error-code.d.ts +81 -37
  4. package/dist/errors/serial-error-code.d.ts.map +1 -1
  5. package/dist/errors/serial-error-context.d.ts +61 -0
  6. package/dist/errors/serial-error-context.d.ts.map +1 -0
  7. package/dist/errors/serial-error.d.ts +42 -21
  8. package/dist/errors/serial-error.d.ts.map +1 -1
  9. package/dist/index.d.ts +42 -12
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.mjs +1278 -635
  12. package/dist/index.mjs.map +4 -4
  13. package/dist/internal/assert-never.d.ts +11 -0
  14. package/dist/internal/assert-never.d.ts.map +1 -0
  15. package/dist/internal/branded-numbers.d.ts +37 -0
  16. package/dist/internal/branded-numbers.d.ts.map +1 -0
  17. package/dist/internal/strip-ansi-sequences.d.ts +25 -0
  18. package/dist/internal/strip-ansi-sequences.d.ts.map +1 -0
  19. package/dist/session/create-serial-session.d.ts +6 -3
  20. package/dist/session/create-serial-session.d.ts.map +1 -1
  21. package/dist/session/index.d.ts +7 -2
  22. package/dist/session/index.d.ts.map +1 -1
  23. package/dist/session/internal/build-request-options.d.ts +7 -7
  24. package/dist/session/internal/build-request-options.d.ts.map +1 -1
  25. package/dist/session/internal/error-severity.d.ts +38 -0
  26. package/dist/session/internal/error-severity.d.ts.map +1 -0
  27. package/dist/session/internal/line-buffer.d.ts +15 -4
  28. package/dist/session/internal/line-buffer.d.ts.map +1 -1
  29. package/dist/session/internal/receive-pipeline.d.ts +34 -0
  30. package/dist/session/internal/receive-pipeline.d.ts.map +1 -0
  31. package/dist/session/internal/receive-replay-buffer.d.ts +3 -2
  32. package/dist/session/internal/receive-replay-buffer.d.ts.map +1 -1
  33. package/dist/session/internal/session-error-reporter.d.ts +32 -0
  34. package/dist/session/internal/session-error-reporter.d.ts.map +1 -0
  35. package/dist/session/internal/session-lifecycle.d.ts +44 -0
  36. package/dist/session/internal/session-lifecycle.d.ts.map +1 -0
  37. package/dist/session/internal/validate-serial-port-filters.d.ts +12 -0
  38. package/dist/session/internal/validate-serial-port-filters.d.ts.map +1 -0
  39. package/dist/session/is-connected-session-state.d.ts +11 -0
  40. package/dist/session/is-connected-session-state.d.ts.map +1 -0
  41. package/dist/session/normalize-serial-error.d.ts +1 -1
  42. package/dist/session/normalize-serial-error.d.ts.map +1 -1
  43. package/dist/session/serial-session-options.d.ts +118 -65
  44. package/dist/session/serial-session-options.d.ts.map +1 -1
  45. package/dist/session/serial-session-state.d.ts +50 -12
  46. package/dist/session/serial-session-state.d.ts.map +1 -1
  47. package/dist/session/serial-session.d.ts +52 -18
  48. package/dist/session/serial-session.d.ts.map +1 -1
  49. package/dist/session/session-runtime.d.ts +140 -0
  50. package/dist/session/session-runtime.d.ts.map +1 -0
  51. package/dist/terminal/create-terminal-buffer.d.ts +15 -3
  52. package/dist/terminal/create-terminal-buffer.d.ts.map +1 -1
  53. package/dist/types.d.ts +18 -0
  54. package/dist/types.d.ts.map +1 -0
  55. package/package.json +1 -1
  56. package/dist/session/session-state-machine.d.ts +0 -40
  57. package/dist/session/session-state-machine.d.ts.map +0 -1
@@ -0,0 +1,37 @@
1
+ declare const baudRateBrand: unique symbol;
2
+ /** Validated serial port baud rate (safe integer > 0). */
3
+ export type BaudRate = number & {
4
+ readonly [baudRateBrand]: true;
5
+ };
6
+ declare const serialPortBufferSizeBrand: unique symbol;
7
+ /** Validated W3C {@link SerialOptions} `bufferSize`. */
8
+ export type SerialPortBufferSize = number & {
9
+ readonly [serialPortBufferSizeBrand]: true;
10
+ };
11
+ declare const receiveReplayBufferSizeBrand: unique symbol;
12
+ /** Validated receive replay chunk count limit. */
13
+ export type ReceiveReplayBufferSize = number & {
14
+ readonly [receiveReplayBufferSizeBrand]: true;
15
+ };
16
+ declare const maxCharsBrand: unique symbol;
17
+ /** Validated character limit for buffers (`0` means unlimited). */
18
+ export type MaxChars = number & {
19
+ readonly [maxCharsBrand]: true;
20
+ };
21
+ declare const maxLinesBrand: unique symbol;
22
+ /** Validated line count limit for terminal display (`0` means unlimited). */
23
+ export type MaxLines = number & {
24
+ readonly [maxLinesBrand]: true;
25
+ };
26
+ /** @internal Brand a validated baud rate. */
27
+ export declare function brandBaudRate(value: number): BaudRate;
28
+ /** @internal Brand a validated serial port buffer size. */
29
+ export declare function brandSerialPortBufferSize(value: number): SerialPortBufferSize;
30
+ /** @internal Brand a validated receive replay buffer size. */
31
+ export declare function brandReceiveReplayBufferSize(value: number): ReceiveReplayBufferSize;
32
+ /** @internal Brand a validated max character limit. */
33
+ export declare function brandMaxChars(value: number): MaxChars;
34
+ /** @internal Brand a validated max line limit. */
35
+ export declare function brandMaxLines(value: number): MaxLines;
36
+ export {};
37
+ //# sourceMappingURL=branded-numbers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branded-numbers.d.ts","sourceRoot":"","sources":["../../src/internal/branded-numbers.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAC3C,0DAA0D;AAC1D,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAEnE,OAAO,CAAC,MAAM,yBAAyB,EAAE,OAAO,MAAM,CAAC;AACvD,wDAAwD;AACxD,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG;IAC1C,QAAQ,CAAC,CAAC,yBAAyB,CAAC,EAAE,IAAI,CAAC;CAC5C,CAAC;AAEF,OAAO,CAAC,MAAM,4BAA4B,EAAE,OAAO,MAAM,CAAC;AAC1D,kDAAkD;AAClD,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG;IAC7C,QAAQ,CAAC,CAAC,4BAA4B,CAAC,EAAE,IAAI,CAAC;CAC/C,CAAC;AAEF,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAC3C,mEAAmE;AACnE,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAEnE,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAC3C,6EAA6E;AAC7E,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAEnE,6CAA6C;AAC7C,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAErD;AAED,2DAA2D;AAC3D,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAE7E;AAED,8DAA8D;AAC9D,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,MAAM,GACZ,uBAAuB,CAEzB;AAED,uDAAuD;AACvD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAErD;AAED,kDAAkD;AAClD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAErD"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Stateful ANSI escape stripper for streaming text chunks.
3
+ *
4
+ * Buffers incomplete sequences that span Web Serial read boundaries so
5
+ * partial ESC bytes are not emitted as visible text.
6
+ *
7
+ * @internal
8
+ */
9
+ export interface AnsiStripper {
10
+ feed(chunk: string): string;
11
+ flush(): string;
12
+ }
13
+ /**
14
+ * Strips ANSI escape sequences from a complete string in one pass.
15
+ *
16
+ * @internal
17
+ */
18
+ export declare function stripAnsiSequences(text: string): string;
19
+ /**
20
+ * Creates a streaming ANSI escape stripper.
21
+ *
22
+ * @internal
23
+ */
24
+ export declare function createAnsiStripper(): AnsiStripper;
25
+ //# sourceMappingURL=strip-ansi-sequences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strip-ansi-sequences.d.ts","sourceRoot":"","sources":["../../src/internal/strip-ansi-sequences.ts"],"names":[],"mappings":"AA6BA;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,KAAK,IAAI,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,YAAY,CA2EjD"}
@@ -1,7 +1,7 @@
1
1
  import type { SerialSession } from './serial-session';
2
2
  import { type SerialSessionOptions } from './serial-session-options';
3
3
  /**
4
- * Create a v2 {@link SerialSession}.
4
+ * Create a {@link SerialSession}.
5
5
  *
6
6
  * This release wires the internal read pump (#202) and the internal send
7
7
  * queue (#203) into the session so that `connect$`, `disconnect$`,
@@ -13,8 +13,8 @@ import { type SerialSessionOptions } from './serial-session-options';
13
13
  * Key behaviors:
14
14
  *
15
15
  * - `isBrowserSupported()` returns whether `navigator.serial` is available.
16
- * - `state$` replays the current lifecycle state driven by
17
- * {@link SessionStateMachine}.
16
+ * - `state$` replays the current lifecycle state driven by the internal
17
+ * {@link SessionRuntime} controller.
18
18
  * - `connect$()` opens a user-selected port, starts the internal read pump,
19
19
  * and transitions `idle -> connecting -> connected`.
20
20
  * - `disconnect$()` stops the read pump, closes the port, and transitions
@@ -45,6 +45,9 @@ import { type SerialSessionOptions } from './serial-session-options';
45
45
  * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/202 | Issue #202}
46
46
  * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/203 | Issue #203}
47
47
  * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/204 | Issue #204}
48
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/397 | Issue #397}
49
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/399 | Issue #399}
50
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/401 | Issue #401}
48
51
  */
49
52
  export declare function createSerialSession(options?: SerialSessionOptions): SerialSession;
50
53
  //# sourceMappingURL=create-serial-session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-serial-session.d.ts","sourceRoot":"","sources":["../../src/session/create-serial-session.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,0BAA0B,CAAC;AAgBlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,aAAa,CAugBf"}
1
+ {"version":3,"file":"create-serial-session.d.ts","sourceRoot":"","sources":["../../src/session/create-serial-session.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,0BAA0B,CAAC;AAOlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,aAAa,CAyGf"}
@@ -1,6 +1,11 @@
1
1
  export { createSerialSession } from './create-serial-session';
2
2
  export type { SerialSession } from './serial-session';
3
- export type { SerialSessionOptions, SerialSessionReceiveReplayOptions, } from './serial-session-options';
4
- export { SerialSessionState } from './serial-session-state';
3
+ export type { SerialSessionOptions, SerialSessionFeatureOptions, SerialSessionReceiveReplayOptions, ResolvedSerialSessionOptions, } from './serial-session-options';
4
+ export { resolveSerialSessionOptions } from './serial-session-options';
5
+ export { MAX_RECEIVE_REPLAY_BUFFER_SIZE, MAX_RECEIVE_REPLAY_MAX_CHARS, } from './serial-session-options';
6
+ export type { SerialPayload, SerialConnectionOptions } from '../types';
7
+ export { SerialSessionStatus } from './serial-session-state';
8
+ export { isConnectedSessionState } from './is-connected-session-state';
9
+ export type { SerialSessionState, IdleSessionState, ConnectingSessionState, ConnectedSessionState, DisconnectingSessionState, UnsupportedSessionState, ErrorSessionState, DisposedSessionState, } from './serial-session-state';
5
10
  export { DEFAULT_LINE_BUFFER_OPTIONS, type LineBufferOptions, } from './internal/line-buffer';
6
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EACV,oBAAoB,EACpB,iCAAiC,GAClC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACL,2BAA2B,EAC3B,KAAK,iBAAiB,GACvB,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EACV,oBAAoB,EACpB,2BAA2B,EAC3B,iCAAiC,EACjC,4BAA4B,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,2BAA2B,EAC3B,KAAK,iBAAiB,GACvB,MAAM,wBAAwB,CAAC"}
@@ -1,16 +1,16 @@
1
1
  import type { SerialSessionOptions } from '../serial-session-options';
2
2
  /**
3
- * Build {@link SerialPortRequestOptions} from {@link SerialSessionOptions}.
3
+ * Build {@link SerialPortRequestOptions} from resolved {@link SerialSessionOptions}.
4
4
  *
5
- * Converts the `filters` field of {@link SerialSessionOptions} into the
6
- * shape expected by `navigator.serial.requestPort` and validates USB
7
- * vendor / product identifiers. Returns `undefined` when no filters are
5
+ * Converts the `filters` field into the shape expected by
6
+ * `navigator.serial.requestPort`. Returns `undefined` when no filters are
8
7
  * supplied so the browser shows all available ports.
9
8
  *
10
- * @param options - The session options supplied by the caller.
9
+ * Filter validation is performed earlier by
10
+ * {@link resolveSerialSessionOptions} at factory time.
11
+ *
12
+ * @param options - Resolved session options (filters already validated).
11
13
  * @returns The request options, or `undefined` when no filters are set.
12
- * @throws {@link SerialError} with {@link SerialErrorCode.INVALID_FILTER_OPTIONS}
13
- * when a filter is empty or contains out-of-range IDs.
14
14
  *
15
15
  * @internal
16
16
  */
@@ -1 +1 @@
1
- {"version":3,"file":"build-request-options.d.ts","sourceRoot":"","sources":["../../../src/session/internal/build-request-options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,wBAAwB,GAAG,SAAS,CA2CtC"}
1
+ {"version":3,"file":"build-request-options.d.ts","sourceRoot":"","sources":["../../../src/session/internal/build-request-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,wBAAwB,GAAG,SAAS,CAQtC"}
@@ -0,0 +1,38 @@
1
+ import { SerialErrorCode } from '../../errors/serial-error-code';
2
+ /**
3
+ * Internal error classification used by the single `reportError` entry
4
+ * point. `'fatal'` errors drive `state$` into `'error'` and tear down
5
+ * the live session (pump stop + port close); `'non-fatal'` errors are
6
+ * only multiplexed on `errors$` without mutating session state.
7
+ *
8
+ * @internal
9
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/399 | Issue #399}
10
+ */
11
+ export type ReportErrorSeverity = 'fatal' | 'non-fatal';
12
+ /**
13
+ * Maps each {@link SerialErrorCode} that can surface through session
14
+ * `reportError` to its severity. Unmapped codes fall back to `'fatal'`
15
+ * in {@link resolveErrorSeverity}.
16
+ *
17
+ * @internal
18
+ */
19
+ export declare const ERROR_SEVERITY: {
20
+ readonly READ_FAILED: "fatal";
21
+ readonly CONNECTION_LOST: "fatal";
22
+ readonly PORT_OPEN_FAILED: "fatal";
23
+ readonly OPERATION_CANCELLED: "fatal";
24
+ readonly UNKNOWN: "fatal";
25
+ readonly LINE_BUFFER_OVERFLOW: "non-fatal";
26
+ readonly RECEIVE_REPLAY_BUFFER_OVERFLOW: "non-fatal";
27
+ readonly BROWSER_NOT_SUPPORTED: "non-fatal";
28
+ readonly PORT_ALREADY_OPEN: "non-fatal";
29
+ readonly PORT_NOT_OPEN: "non-fatal";
30
+ readonly WRITE_FAILED: "non-fatal";
31
+ };
32
+ /**
33
+ * Resolve the reporting severity for a normalised {@link SerialErrorCode}.
34
+ *
35
+ * @internal
36
+ */
37
+ export declare function resolveErrorSeverity(code: SerialErrorCode): ReportErrorSeverity;
38
+ //# sourceMappingURL=error-severity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-severity.d.ts","sourceRoot":"","sources":["../../../src/session/internal/error-severity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,WAAW,CAAC;AAExD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;CAY+C,CAAC;AAE3E;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,eAAe,GACpB,mBAAmB,CAKrB"}
@@ -1,3 +1,4 @@
1
+ import type { MaxChars } from '../../internal/branded-numbers';
1
2
  /**
2
3
  * Options for {@link createLineBuffer}.
3
4
  *
@@ -20,6 +21,19 @@ export interface LineBufferFeedResult {
20
21
  /** `true` when leading characters were discarded due to `maxChars`. */
21
22
  overflowed: boolean;
22
23
  }
24
+ /**
25
+ * Handle returned by {@link createLineBuffer}.
26
+ *
27
+ * @internal
28
+ */
29
+ export interface LineBuffer {
30
+ feed(chunk: string): LineBufferFeedResult;
31
+ clear(): void;
32
+ }
33
+ /** @internal Resolved limits for {@link createLineBuffer}. */
34
+ export interface LineBufferLimits {
35
+ maxChars: MaxChars;
36
+ }
23
37
  /**
24
38
  * Streaming UTF-16 text to newline-delimited lines for {@link createSerialSession}.
25
39
  * Supports `\r\n` and `\n` per #237; a lone `\r` that is not the last character
@@ -29,8 +43,5 @@ export interface LineBufferFeedResult {
29
43
  *
30
44
  * @internal
31
45
  */
32
- export declare function createLineBuffer(options?: LineBufferOptions): {
33
- feed(chunk: string): LineBufferFeedResult;
34
- clear(): void;
35
- };
46
+ export declare function createLineBuffer(options?: LineBufferOptions | LineBufferLimits): LineBuffer;
36
47
  //# sourceMappingURL=line-buffer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"line-buffer.d.ts","sourceRoot":"","sources":["../../../src/session/internal/line-buffer.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,gFAAgF;AAChF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,iBAAiB,CAEnE,CAAC;AAEF,+CAA+C;AAC/C,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,uEAAuE;IACvE,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG;IAC7D,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAAC;IAC1C,KAAK,IAAI,IAAI,CAAC;CACf,CA4BA"}
1
+ {"version":3,"file":"line-buffer.d.ts","sourceRoot":"","sources":["../../../src/session/internal/line-buffer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAG/D;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,gFAAgF;AAChF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,iBAAiB,CAEnE,CAAC;AAEF,+CAA+C;AAC/C,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,uEAAuE;IACvE,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAAC;IAC1C,KAAK,IAAI,IAAI,CAAC;CACf;AAED,8DAA8D;AAC9D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,CAAC,EAAE,iBAAiB,GAAG,gBAAgB,GAC7C,UAAU,CA6BZ"}
@@ -0,0 +1,34 @@
1
+ import { type Observable } from 'rxjs';
2
+ import { SerialError } from '../../errors/serial-error';
3
+ import type { NormalizeSerialErrorOptions } from '../normalize-serial-error';
4
+ import type { ResolvedSerialSessionOptions } from '../serial-session-options';
5
+ /**
6
+ * Dependencies for {@link createReceivePipeline}.
7
+ *
8
+ * @internal
9
+ */
10
+ export interface ReceivePipelineDeps {
11
+ resolvedOptions: ResolvedSerialSessionOptions;
12
+ reportError: (error: unknown, options: NormalizeSerialErrorOptions) => SerialError;
13
+ }
14
+ /**
15
+ * Receive-side stream wiring for {@link createSerialSession}.
16
+ *
17
+ * @internal
18
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/401 | Issue #401}
19
+ */
20
+ export interface ReceivePipeline {
21
+ receive$: Observable<string>;
22
+ lines$: Observable<string>;
23
+ receiveReplay$: Observable<string>;
24
+ clearReplay: () => void;
25
+ startLiveReceiveReplay: () => void;
26
+ clearLineBuffer: () => void;
27
+ handleChunk: (text: string) => void;
28
+ complete: () => void;
29
+ }
30
+ /**
31
+ * @internal
32
+ */
33
+ export declare function createReceivePipeline(deps: ReceivePipelineDeps): ReceivePipeline;
34
+ //# sourceMappingURL=receive-pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receive-pipeline.d.ts","sourceRoot":"","sources":["../../../src/session/internal/receive-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EAIhB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAOxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAE9E;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,4BAA4B,CAAC;IAC9C,WAAW,EAAE,CACX,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,2BAA2B,KACjC,WAAW,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC3B,cAAc,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,sBAAsB,EAAE,MAAM,IAAI,CAAC;IACnC,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,mBAAmB,GACxB,eAAe,CAuGjB"}
@@ -1,4 +1,5 @@
1
1
  import { Observable } from 'rxjs';
2
+ import type { MaxChars, ReceiveReplayBufferSize } from '../../internal/branded-numbers';
2
3
  /**
3
4
  * Options for {@link createReceiveReplayBuffer}.
4
5
  *
@@ -6,11 +7,11 @@ import { Observable } from 'rxjs';
6
7
  */
7
8
  export interface ReceiveReplayBufferOptions {
8
9
  /** Maximum number of chunks to retain. */
9
- bufferSize: number;
10
+ bufferSize: ReceiveReplayBufferSize;
10
11
  /**
11
12
  * Maximum total characters across retained chunks. `0` disables the limit.
12
13
  */
13
- maxChars: number;
14
+ maxChars: MaxChars;
14
15
  }
15
16
  /** Result of {@link ReceiveReplayBuffer.next}. */
16
17
  export interface ReceiveReplayBufferNextResult {
@@ -1 +1 @@
1
- {"version":3,"file":"receive-replay-buffer.d.ts","sourceRoot":"","sources":["../../../src/session/internal/receive-replay-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAW,MAAM,MAAM,CAAC;AAE3C;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,kDAAkD;AAClD,MAAM,WAAW,6BAA6B;IAC5C,kEAAkE;IAClE,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,6BAA6B,CAAC;IACnD,YAAY,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,QAAQ,IAAI,IAAI,CAAC;CAClB;AAMD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,0BAA0B,GAClC,mBAAmB,CAyDrB"}
1
+ {"version":3,"file":"receive-replay-buffer.d.ts","sourceRoot":"","sources":["../../../src/session/internal/receive-replay-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAW,MAAM,MAAM,CAAC;AAC3C,OAAO,KAAK,EACV,QAAQ,EACR,uBAAuB,EACxB,MAAM,gCAAgC,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC,0CAA0C;IAC1C,UAAU,EAAE,uBAAuB,CAAC;IACpC;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,kDAAkD;AAClD,MAAM,WAAW,6BAA6B;IAC5C,kEAAkE;IAClE,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,6BAA6B,CAAC;IACnD,YAAY,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,QAAQ,IAAI,IAAI,CAAC;CAClB;AAMD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,0BAA0B,GAClC,mBAAmB,CAyDrB"}
@@ -0,0 +1,32 @@
1
+ import type { Subject } from 'rxjs';
2
+ import { SerialError } from '../../errors/serial-error';
3
+ import { type NormalizeSerialErrorOptions } from '../normalize-serial-error';
4
+ import type { ReadPump } from '../read-pump';
5
+ import type { SendQueue } from '../send-queue';
6
+ import { type SessionRuntimeController } from '../session-runtime';
7
+ /**
8
+ * Dependencies for {@link createSessionErrorReporter}.
9
+ *
10
+ * @internal
11
+ */
12
+ export interface SessionErrorReporterDeps {
13
+ controller: SessionRuntimeController;
14
+ errorsSubject: Subject<SerialError>;
15
+ sendQueue: SendQueue;
16
+ isDisposed: () => boolean;
17
+ updatePortInfo: (port: SerialPort | null) => void;
18
+ teardownPump: (pump: ReadPump | null) => Promise<void>;
19
+ closePortSafely: (port: SerialPort | null) => Promise<void>;
20
+ }
21
+ /**
22
+ * Centralised error reporting for {@link createSerialSession}.
23
+ *
24
+ * @internal
25
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/204 | Issue #204}
26
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/401 | Issue #401}
27
+ */
28
+ export declare function createSessionErrorReporter(deps: SessionErrorReporterDeps): {
29
+ reportError: (error: unknown, options: NormalizeSerialErrorOptions) => SerialError;
30
+ createDisposedError: () => SerialError;
31
+ };
32
+ //# sourceMappingURL=session-error-reporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-error-reporter.d.ts","sourceRoot":"","sources":["../../../src/session/internal/session-error-reporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAIL,KAAK,wBAAwB,EAC9B,MAAM,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,wBAAwB,CAAC;IACrC,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IACpC,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,cAAc,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,KAAK,IAAI,CAAC;IAClD,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,eAAe,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,wBAAwB,GAAG;IAC1E,WAAW,EAAE,CACX,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,2BAA2B,KACjC,WAAW,CAAC;IACjB,mBAAmB,EAAE,MAAM,WAAW,CAAC;CACxC,CAyDA"}
@@ -0,0 +1,44 @@
1
+ import { type BehaviorSubject, Observable, type Subject } from 'rxjs';
2
+ import { SerialError } from '../../errors/serial-error';
3
+ import type { ReceivePipeline } from './receive-pipeline';
4
+ import { type NormalizeSerialErrorOptions } from '../normalize-serial-error';
5
+ import { type ReadPump } from '../read-pump';
6
+ import type { SendQueue } from '../send-queue';
7
+ import type { ResolvedSerialSessionOptions } from '../serial-session-options';
8
+ import { type SessionRuntimeController } from '../session-runtime';
9
+ /**
10
+ * Dependencies for {@link createSessionLifecycle}.
11
+ *
12
+ * @internal
13
+ */
14
+ export interface SessionLifecycleDeps {
15
+ controller: SessionRuntimeController;
16
+ resolvedOptions: ResolvedSerialSessionOptions;
17
+ sendQueue: SendQueue;
18
+ receivePipeline: ReceivePipeline;
19
+ portInfoSubject: BehaviorSubject<SerialPortInfo | null>;
20
+ errorsSubject: Subject<SerialError>;
21
+ isDisposed: () => boolean;
22
+ reportError: (error: unknown, options: NormalizeSerialErrorOptions) => SerialError;
23
+ createDisposedError: () => SerialError;
24
+ }
25
+ /**
26
+ * Port and pump lifecycle operations for {@link createSerialSession}.
27
+ *
28
+ * @internal
29
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/401 | Issue #401}
30
+ */
31
+ export interface SessionLifecycle {
32
+ connect$: () => Observable<void>;
33
+ disconnect$: () => Observable<void>;
34
+ dispose$: () => Observable<void>;
35
+ writeToPort: (payload: Uint8Array) => Promise<void>;
36
+ teardownPump: (pump: ReadPump | null) => Promise<void>;
37
+ closePortSafely: (port: SerialPort | null) => Promise<void>;
38
+ updatePortInfo: (port: SerialPort | null) => void;
39
+ }
40
+ /**
41
+ * @internal
42
+ */
43
+ export declare function createSessionLifecycle(deps: SessionLifecycleDeps): SessionLifecycle;
44
+ //# sourceMappingURL=session-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/session/internal/session-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAIxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAE9E,OAAO,EASL,KAAK,wBAAwB,EAC9B,MAAM,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,wBAAwB,CAAC;IACrC,eAAe,EAAE,4BAA4B,CAAC;IAC9C,SAAS,EAAE,SAAS,CAAC;IACrB,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,EAAE,eAAe,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACxD,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IACpC,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,WAAW,EAAE,CACX,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,2BAA2B,KACjC,WAAW,CAAC;IACjB,mBAAmB,EAAE,MAAM,WAAW,CAAC;CACxC;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;IACjC,WAAW,EAAE,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;IACpC,QAAQ,EAAE,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;IACjC,WAAW,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,eAAe,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,cAAc,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,KAAK,IAAI,CAAC;CACnD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,oBAAoB,GACzB,gBAAgB,CAgVlB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Validate {@link SerialPortFilter} entries for session creation.
3
+ *
4
+ * @param filters - Optional filters from {@link SerialSessionOptions}.
5
+ * @returns The same filters reference when valid, or `undefined` when omitted/empty.
6
+ * @throws {@link SerialError} with {@link SerialErrorCode.INVALID_FILTER_OPTIONS}
7
+ * when a filter is empty or contains out-of-range IDs.
8
+ *
9
+ * @internal
10
+ */
11
+ export declare function validateSerialPortFilters(filters?: SerialPortFilter[]): SerialPortFilter[] | undefined;
12
+ //# sourceMappingURL=validate-serial-port-filters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-serial-port-filters.d.ts","sourceRoot":"","sources":["../../../src/session/internal/validate-serial-port-filters.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,CAAC,EAAE,gBAAgB,EAAE,GAC3B,gBAAgB,EAAE,GAAG,SAAS,CAkEhC"}
@@ -0,0 +1,11 @@
1
+ import { type ConnectedSessionState, type SerialSessionState } from './serial-session-state';
2
+ /**
3
+ * Type predicate for {@link ConnectedSessionState}.
4
+ *
5
+ * Use with RxJS `filter()` to preserve discriminated union narrowing in
6
+ * pipelines so `portInfo` and other connected-only fields stay typed.
7
+ *
8
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/436 | Issue #436}
9
+ */
10
+ export declare function isConnectedSessionState(state: SerialSessionState): state is ConnectedSessionState;
11
+ //# sourceMappingURL=is-connected-session-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-connected-session-state.d.ts","sourceRoot":"","sources":["../../src/session/is-connected-session-state.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EAExB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,kBAAkB,GACxB,KAAK,IAAI,qBAAqB,CAEhC"}
@@ -45,7 +45,7 @@ export interface NormalizeSerialErrorOptions {
45
45
  * control-flow event, not a hard failure.
46
46
  * 3. Any other value is wrapped as a {@link SerialError} with
47
47
  * {@link NormalizeSerialErrorOptions.fallbackCode}, preserving the
48
- * original error as `originalError` for debugging.
48
+ * underlying failure on {@link SerialError.context | context.cause}.
49
49
  *
50
50
  * @internal
51
51
  * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/199 | Issue #199}
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-serial-error.d.ts","sourceRoot":"","sources":["../../src/session/normalize-serial-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAW9D;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;;;;OAQG;IACH,YAAY,EAAE,eAAe,CAAC;IAC9B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,2BAA2B,GACnC,WAAW,CAqBb"}
1
+ {"version":3,"file":"normalize-serial-error.d.ts","sourceRoot":"","sources":["../../src/session/normalize-serial-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAW9D;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;;;;OAQG;IACH,YAAY,EAAE,eAAe,CAAC;IAC9B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,2BAA2B,GACnC,WAAW,CAuBb"}