@gurezo/web-serial-rxjs 3.1.0 → 4.0.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 (42) hide show
  1. package/README.ja.md +4 -7
  2. package/README.md +4 -7
  3. package/dist/errors/serial-error-code.d.ts +0 -21
  4. package/dist/errors/serial-error-code.d.ts.map +1 -1
  5. package/dist/errors/serial-error-context.d.ts +1 -6
  6. package/dist/errors/serial-error-context.d.ts.map +1 -1
  7. package/dist/index.d.ts +6 -5
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.mjs +221 -427
  10. package/dist/index.mjs.map +4 -4
  11. package/dist/internal/branded-numbers.d.ts +1 -8
  12. package/dist/internal/branded-numbers.d.ts.map +1 -1
  13. package/dist/session/create-serial-session.d.ts +6 -4
  14. package/dist/session/create-serial-session.d.ts.map +1 -1
  15. package/dist/session/index.d.ts +2 -2
  16. package/dist/session/index.d.ts.map +1 -1
  17. package/dist/session/internal/error-severity.d.ts +0 -1
  18. package/dist/session/internal/error-severity.d.ts.map +1 -1
  19. package/dist/session/internal/has-web-serial-support.d.ts +6 -5
  20. package/dist/session/internal/has-web-serial-support.d.ts.map +1 -1
  21. package/dist/session/internal/line-buffer.d.ts +17 -0
  22. package/dist/session/internal/line-buffer.d.ts.map +1 -1
  23. package/dist/session/internal/port-teardown.d.ts +30 -0
  24. package/dist/session/internal/port-teardown.d.ts.map +1 -0
  25. package/dist/session/internal/receive-pipeline.d.ts +8 -5
  26. package/dist/session/internal/receive-pipeline.d.ts.map +1 -1
  27. package/dist/session/internal/session-error-reporter.d.ts +0 -1
  28. package/dist/session/internal/session-error-reporter.d.ts.map +1 -1
  29. package/dist/session/internal/session-lifecycle.d.ts +3 -5
  30. package/dist/session/internal/session-lifecycle.d.ts.map +1 -1
  31. package/dist/session/serial-session-options.d.ts +62 -94
  32. package/dist/session/serial-session-options.d.ts.map +1 -1
  33. package/dist/session/serial-session.d.ts +9 -75
  34. package/dist/session/serial-session.d.ts.map +1 -1
  35. package/dist/session/session-runtime.d.ts.map +1 -1
  36. package/dist/terminal/create-terminal-buffer.d.ts +24 -1
  37. package/dist/terminal/create-terminal-buffer.d.ts.map +1 -1
  38. package/dist/types.d.ts +5 -0
  39. package/dist/types.d.ts.map +1 -1
  40. package/package.json +2 -2
  41. package/dist/session/internal/receive-replay-buffer.d.ts +0 -38
  42. package/dist/session/internal/receive-replay-buffer.d.ts.map +0 -1
@@ -4,15 +4,10 @@ export type BaudRate = number & {
4
4
  readonly [baudRateBrand]: true;
5
5
  };
6
6
  declare const serialPortBufferSizeBrand: unique symbol;
7
- /** Validated W3C {@link SerialOptions} `bufferSize`. */
7
+ /** Validated W3C {@link SerialOptions} `bufferSize` (safe integer > 0). */
8
8
  export type SerialPortBufferSize = number & {
9
9
  readonly [serialPortBufferSizeBrand]: true;
10
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
11
  declare const maxCharsBrand: unique symbol;
17
12
  /** Validated character limit for buffers (`0` means unlimited). */
18
13
  export type MaxChars = number & {
@@ -27,8 +22,6 @@ export type MaxLines = number & {
27
22
  export declare function brandBaudRate(value: number): BaudRate;
28
23
  /** @internal Brand a validated serial port buffer size. */
29
24
  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
25
  /** @internal Brand a validated max character limit. */
33
26
  export declare function brandMaxChars(value: number): MaxChars;
34
27
  /** @internal Brand a validated max line limit. */
@@ -1 +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;AAC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GAAG,QAAQ,CAErD"}
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,2EAA2E;AAC3E,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG;IAC1C,QAAQ,CAAC,CAAC,yBAAyB,CAAC,EAAE,IAAI,CAAC;CAC5C,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,uDAAuD;AACvD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAErD;AAED,kDAAkD;AAClD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAErD"}
@@ -12,7 +12,6 @@ import { type SerialSessionOptions } from './serial-session-options';
12
12
  *
13
13
  * Key behaviors:
14
14
  *
15
- * - `isBrowserSupported()` returns whether `navigator.serial` is available.
16
15
  * - `state$` replays the current lifecycle state driven by the internal
17
16
  * {@link SessionRuntime} controller.
18
17
  * - `connect$()` opens a user-selected port, starts the internal read pump,
@@ -36,9 +35,12 @@ import { type SerialSessionOptions } from './serial-session-options';
36
35
  * do not mutate `state$` because a real connection loss will be
37
36
  * observed by the read pump on the next tick anyway.
38
37
  *
39
- * @param options - Session options. Only `filters` is consulted by
40
- * `connect$` today (forwarded to `navigator.serial.requestPort`); the
41
- * remaining fields are passed to `port.open` using defaults when omitted.
38
+ * @param options - Session options. W3C connection fields (`baudRate`,
39
+ * `dataBits`, …) are passed to `port.open`. `filters` is forwarded to
40
+ * `navigator.serial.requestPort`. `lineBuffer` / `terminalBuffer` configure
41
+ * {@link SerialSession.lines$} and {@link SerialSession.terminalText$}.
42
+ * Omitted fields use {@link resolveSerialSessionOptions} defaults; minimal
43
+ * callers typically only set `baudRate`.
42
44
  * @returns A {@link SerialSession} instance.
43
45
  *
44
46
  * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/199 | Issue #199}
@@ -1 +1 @@
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
+ {"version":3,"file":"create-serial-session.d.ts","sourceRoot":"","sources":["../../src/session/create-serial-session.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,0BAA0B,CAAC;AAOlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,aAAa,CAoFf"}
@@ -1,8 +1,8 @@
1
1
  export { createSerialSession } from './create-serial-session';
2
+ export { isWebSerialSupported } from './internal/has-web-serial-support';
2
3
  export type { SerialSession } from './serial-session';
3
- export type { SerialSessionOptions, SerialSessionFeatureOptions, SerialSessionReceiveReplayOptions, ResolvedSerialSessionOptions, } from './serial-session-options';
4
+ export type { SerialSessionOptions, SerialSessionFeatureOptions, ResolvedSerialSessionOptions, } from './serial-session-options';
4
5
  export { resolveSerialSessionOptions } from './serial-session-options';
5
- export { MAX_RECEIVE_REPLAY_BUFFER_SIZE, MAX_RECEIVE_REPLAY_MAX_CHARS, } from './serial-session-options';
6
6
  export type { SerialPayload, SerialConnectionOptions } from '../types';
7
7
  export { SerialSessionStatus } from './serial-session-state';
8
8
  export { isConnectedSessionState } from './is-connected-session-state';
@@ -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,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
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EACV,oBAAoB,EACpB,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,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"}
@@ -23,7 +23,6 @@ export declare const ERROR_SEVERITY: {
23
23
  readonly OPERATION_CANCELLED: "fatal";
24
24
  readonly UNKNOWN: "fatal";
25
25
  readonly LINE_BUFFER_OVERFLOW: "non-fatal";
26
- readonly RECEIVE_REPLAY_BUFFER_OVERFLOW: "non-fatal";
27
26
  readonly BROWSER_NOT_SUPPORTED: "non-fatal";
28
27
  readonly PORT_ALREADY_OPEN: "non-fatal";
29
28
  readonly PORT_NOT_OPEN: "non-fatal";
@@ -1 +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
+ {"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;;;;;;;;;;;CAW+C,CAAC;AAE3E;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,eAAe,GACpB,mBAAmB,CAKrB"}
@@ -1,12 +1,13 @@
1
1
  /**
2
- * Internal feature detection for the Web Serial API.
2
+ * Synchronous feature detection for the Web Serial API.
3
3
  *
4
- * This helper is intentionally kept package-private: the v2 public API
5
- * exposes browser support only through {@link SerialSession.isBrowserSupported}.
4
+ * Prefer this helper **before** creating a session. After a session exists,
5
+ * drive unsupported UI from `state$` with `SerialSessionStatus.Unsupported`.
6
+ * This helper is SSR-safe: it returns `false` when `navigator` is not available.
6
7
  *
7
8
  * @returns `true` when `navigator.serial` is available.
8
9
  *
9
- * @internal
10
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/490 | Issue #490}
10
11
  */
11
- export declare function hasWebSerialSupport(): boolean;
12
+ export declare function isWebSerialSupported(): boolean;
12
13
  //# sourceMappingURL=has-web-serial-support.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"has-web-serial-support.d.ts","sourceRoot":"","sources":["../../../src/session/internal/has-web-serial-support.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAO7C"}
1
+ {"version":3,"file":"has-web-serial-support.d.ts","sourceRoot":"","sources":["../../../src/session/internal/has-web-serial-support.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAO9C"}
@@ -2,12 +2,15 @@ import type { MaxChars } from '../../internal/branded-numbers';
2
2
  /**
3
3
  * Options for {@link createLineBuffer}.
4
4
  *
5
+ * Character counts use UTF-16 string length (JavaScript `.length`).
6
+ *
5
7
  * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/371 | Issue #371}
6
8
  */
7
9
  export interface LineBufferOptions {
8
10
  /**
9
11
  * Maximum characters retained in the incomplete line tail (no line terminator yet).
10
12
  * When exceeded, leading characters are discarded. `0` means unlimited.
13
+ * Must be a safe integer `>= 0` when validated.
11
14
  *
12
15
  * @default 1048576
13
16
  */
@@ -15,6 +18,20 @@ export interface LineBufferOptions {
15
18
  }
16
19
  /** Default limits applied when {@link LineBufferOptions} fields are omitted. */
17
20
  export declare const DEFAULT_LINE_BUFFER_OPTIONS: Required<LineBufferOptions>;
21
+ /** Resolved line buffer options with validated branded numeric fields. */
22
+ export type ResolvedLineBufferOptions = {
23
+ maxChars: MaxChars;
24
+ };
25
+ /**
26
+ * Merge and validate {@link LineBufferOptions}.
27
+ *
28
+ * This is the single normalization path for line buffer defaults and boundary
29
+ * checks used by {@link resolveSerialSessionOptions}.
30
+ *
31
+ * @throws {@link SerialError} with {@link SerialErrorCode.INVALID_LINE_BUFFER_OPTIONS}
32
+ * when `maxChars` is out of range.
33
+ */
34
+ export declare function resolveLineBufferOptions(options?: LineBufferOptions): ResolvedLineBufferOptions;
18
35
  /** Result of {@link createLineBuffer.feed}. */
19
36
  export interface LineBufferFeedResult {
20
37
  lines: string[];
@@ -1 +1 @@
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"}
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;AAK/D;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,gFAAgF;AAChF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,iBAAiB,CAEnE,CAAC;AAEF,0EAA0E;AAC1E,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,yBAAyB,CAwB3B;AAED,+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,CAyBZ"}
@@ -0,0 +1,30 @@
1
+ import type { ReadPump } from '../read-pump';
2
+ import type { ReceivePipeline } from './receive-pipeline';
3
+ /**
4
+ * Dependencies for {@link createPortTeardown}.
5
+ *
6
+ * @internal
7
+ */
8
+ export interface PortTeardownDeps {
9
+ receivePipeline: ReceivePipeline;
10
+ }
11
+ /**
12
+ * Port and pump teardown primitives for {@link createSerialSession}.
13
+ *
14
+ * These are extracted from the session lifecycle so that both the lifecycle
15
+ * and the error reporter can depend on them without forming a construction
16
+ * cycle: the error reporter needs `teardownPump` / `closePortSafely` for fatal
17
+ * cleanup, while the lifecycle needs the error reporter for `reportError`.
18
+ *
19
+ * @internal
20
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/476 | Issue #476}
21
+ */
22
+ export interface PortTeardown {
23
+ teardownPump: (pump: ReadPump | null) => Promise<void>;
24
+ closePortSafely: (port: SerialPort | null) => Promise<void>;
25
+ }
26
+ /**
27
+ * @internal
28
+ */
29
+ export declare function createPortTeardown(deps: PortTeardownDeps): PortTeardown;
30
+ //# sourceMappingURL=port-teardown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"port-teardown.d.ts","sourceRoot":"","sources":["../../../src/session/internal/port-teardown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,eAAe,EAAE,eAAe,CAAC;CAClC;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,YAAY;IAC3B,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;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,GAAG,YAAY,CAwBvE"}
@@ -1,6 +1,5 @@
1
1
  import { type Observable } from 'rxjs';
2
2
  import { SerialError } from '../../errors/serial-error';
3
- import type { NormalizeSerialErrorOptions } from '../normalize-serial-error';
4
3
  import type { ResolvedSerialSessionOptions } from '../serial-session-options';
5
4
  /**
6
5
  * Dependencies for {@link createReceivePipeline}.
@@ -9,7 +8,6 @@ import type { ResolvedSerialSessionOptions } from '../serial-session-options';
9
8
  */
10
9
  export interface ReceivePipelineDeps {
11
10
  resolvedOptions: ResolvedSerialSessionOptions;
12
- reportError: (error: unknown, options: NormalizeSerialErrorOptions) => SerialError;
13
11
  }
14
12
  /**
15
13
  * Receive-side stream wiring for {@link createSerialSession}.
@@ -20,9 +18,14 @@ export interface ReceivePipelineDeps {
20
18
  export interface ReceivePipeline {
21
19
  receive$: Observable<string>;
22
20
  lines$: Observable<string>;
23
- receiveReplay$: Observable<string>;
24
- clearReplay: () => void;
25
- startLiveReceiveReplay: () => void;
21
+ /**
22
+ * Buffer-overflow errors produced while decoding chunks. The factory pipes
23
+ * these into the session's single error-reporting entry point so the receive
24
+ * pipeline stays decoupled from error reporting and initialization order.
25
+ *
26
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/476 | Issue #476}
27
+ */
28
+ bufferErrors$: Observable<SerialError>;
26
29
  clearLineBuffer: () => void;
27
30
  handleChunk: (text: string) => void;
28
31
  complete: () => void;
@@ -1 +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
+ {"version":3,"file":"receive-pipeline.d.ts","sourceRoot":"","sources":["../../../src/session/internal/receive-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAW,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAE9E;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,4BAA4B,CAAC;CAC/C;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC3B;;;;;;OAMG;IACH,aAAa,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IACvC,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,CAgDjB"}
@@ -14,7 +14,6 @@ export interface SessionErrorReporterDeps {
14
14
  errorsSubject: Subject<SerialError>;
15
15
  sendQueue: SendQueue;
16
16
  isDisposed: () => boolean;
17
- updatePortInfo: (port: SerialPort | null) => void;
18
17
  teardownPump: (pump: ReadPump | null) => Promise<void>;
19
18
  closePortSafely: (port: SerialPort | null) => Promise<void>;
20
19
  }
@@ -1 +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"}
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,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,CAuDA"}
@@ -1,4 +1,4 @@
1
- import { type BehaviorSubject, Observable, type Subject } from 'rxjs';
1
+ import { Observable, type Subject } from 'rxjs';
2
2
  import { SerialError } from '../../errors/serial-error';
3
3
  import type { ReceivePipeline } from './receive-pipeline';
4
4
  import { type NormalizeSerialErrorOptions } from '../normalize-serial-error';
@@ -16,9 +16,10 @@ export interface SessionLifecycleDeps {
16
16
  resolvedOptions: ResolvedSerialSessionOptions;
17
17
  sendQueue: SendQueue;
18
18
  receivePipeline: ReceivePipeline;
19
- portInfoSubject: BehaviorSubject<SerialPortInfo | null>;
20
19
  errorsSubject: Subject<SerialError>;
21
20
  isDisposed: () => boolean;
21
+ teardownPump: (pump: ReadPump | null) => Promise<void>;
22
+ closePortSafely: (port: SerialPort | null) => Promise<void>;
22
23
  reportError: (error: unknown, options: NormalizeSerialErrorOptions) => SerialError;
23
24
  createDisposedError: () => SerialError;
24
25
  }
@@ -33,9 +34,6 @@ export interface SessionLifecycle {
33
34
  disconnect$: () => Observable<void>;
34
35
  dispose$: () => Observable<void>;
35
36
  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
37
  }
40
38
  /**
41
39
  * @internal
@@ -1 +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,mBAAm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IG;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,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IACpC,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,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,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;CACrD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,oBAAoB,GACzB,gBAAgB,CA6SlB"}
@@ -1,13 +1,29 @@
1
- import { type BaudRate, type MaxChars, type MaxLines, type ReceiveReplayBufferSize, type SerialPortBufferSize } from '../internal/branded-numbers';
1
+ import { type BaudRate, type SerialPortBufferSize } from '../internal/branded-numbers';
2
2
  import type { SerialConnectionOptions } from '../types';
3
- import type { TerminalBufferOptions } from '../terminal/create-terminal-buffer';
4
- import { type LineBufferOptions } from './internal/line-buffer';
3
+ import { type ResolvedTerminalBufferOptions, type TerminalBufferOptions } from '../terminal/create-terminal-buffer';
4
+ import { type LineBufferOptions, type ResolvedLineBufferOptions } from './internal/line-buffer';
5
+ export type { ResolvedLineBufferOptions, ResolvedTerminalBufferOptions, };
5
6
  /**
6
7
  * Library-specific options for {@link createSerialSession} that are not passed
7
8
  * to W3C `port.open`.
8
9
  *
10
+ * Responsibility split (Issue #488):
11
+ *
12
+ * - {@link SerialSessionFeatureOptions.filters} — port selection only
13
+ * (`navigator.serial.requestPort`)
14
+ * - {@link SerialSessionFeatureOptions.lineBuffer} — incomplete-line tail for
15
+ * {@link SerialSession.lines$}
16
+ * - {@link SerialSessionFeatureOptions.terminalBuffer} — display memory for
17
+ * {@link SerialSession.terminalText$}
18
+ *
19
+ * Connection parameters (`baudRate`, `dataBits`, …) live on
20
+ * {@link SerialConnectionOptions} and are composed into
21
+ * {@link SerialSessionOptions}. Minimal callers typically only set
22
+ * `baudRate`; other fields keep safe defaults.
23
+ *
9
24
  * @see {@link SerialConnectionOptions} for W3C connection parameters
10
25
  * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/441 | Issue #441}
26
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/488 | Issue #488}
11
27
  */
12
28
  export interface SerialSessionFeatureOptions {
13
29
  /**
@@ -15,29 +31,31 @@ export interface SerialSessionFeatureOptions {
15
31
  *
16
32
  * When specified, the port selection dialog will only show devices
17
33
  * matching these filters. Each filter can specify `usbVendorId` and/or
18
- * `usbProductId`.
34
+ * `usbProductId`. Not passed to `port.open`.
19
35
  */
20
36
  filters?: SerialPortFilter[];
21
- /**
22
- * Optional receive replay: retain recent decoded text **chunks** so late
23
- * subscribers to {@link SerialSession.receiveReplay$} can read buffered
24
- * data while a connection is active. Does not change {@link SerialSession.receive$}.
25
- *
26
- * @default `{ enabled: false, bufferSize: 512 }` (see {@link DEFAULT_SERIAL_SESSION_OPTIONS})
27
- */
28
- receiveReplay?: SerialSessionReceiveReplayOptions;
29
37
  /**
30
38
  * Limits for {@link SerialSession.terminalText$} display memory. Oldest
31
39
  * completed lines and leading characters are dropped when exceeded.
40
+ * Character counts use UTF-16 string length (JavaScript `.length`).
32
41
  *
33
- * @default `{ maxLines: 10000, maxChars: 1048576 }` (see {@link DEFAULT_SERIAL_SESSION_OPTIONS})
42
+ * Pass `0` for `maxLines` or `maxChars` to disable that limit (unlimited).
43
+ * Negative values, non-integers, `NaN`, and `Infinity` are rejected at
44
+ * factory time.
45
+ *
46
+ * @default `{ maxLines: 10000, maxChars: 1048576, stripAnsi: true }`
47
+ * (see {@link DEFAULT_SERIAL_SESSION_OPTIONS})
34
48
  * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/370 | Issue #370}
35
49
  */
36
50
  terminalBuffer?: TerminalBufferOptions;
37
51
  /**
38
52
  * Limits for the incomplete line tail held by {@link SerialSession.lines$}
39
53
  * framing. When exceeded, leading characters are discarded and a non-fatal
40
- * {@link SerialErrorCode.LINE_BUFFER_OVERFLOW} is emitted on {@link SerialSession.errors$}.
54
+ * {@link SerialErrorCode.LINE_BUFFER_OVERFLOW} is emitted on
55
+ * {@link SerialSession.errors$}. Character counts use UTF-16 string length.
56
+ *
57
+ * Pass `0` for `maxChars` to disable the limit (unlimited). Negative values,
58
+ * non-integers, `NaN`, and `Infinity` are rejected at factory time.
41
59
  *
42
60
  * @default `{ maxChars: 1048576 }` (see {@link DEFAULT_SERIAL_SESSION_OPTIONS})
43
61
  * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/371 | Issue #371}
@@ -49,10 +67,17 @@ export interface SerialSessionFeatureOptions {
49
67
  *
50
68
  * Composes {@link Partial}<{@link SerialConnectionOptions}> (W3C connection
51
69
  * parameters passed to `port.open`) with {@link SerialSessionFeatureOptions}
52
- * (library-specific session features). All connection fields are optional;
53
- * omitted values fall back to {@link DEFAULT_SERIAL_SESSION_OPTIONS}
54
- * (`baudRate` 9600, `dataBits` 8, `stopBits` 1, `parity` `'none'`,
55
- * `bufferSize` 255, `flowControl` `'none'`).
70
+ * (library-specific session features). All fields are optional; omitted values
71
+ * fall back to {@link DEFAULT_SERIAL_SESSION_OPTIONS}.
72
+ *
73
+ * Minimal usage typically only needs `baudRate`:
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const session = createSerialSession({ baudRate: 115200 });
78
+ * ```
79
+ *
80
+ * Full example:
56
81
  *
57
82
  * @example
58
83
  * ```typescript
@@ -66,6 +91,12 @@ export interface SerialSessionFeatureOptions {
66
91
  * });
67
92
  * ```
68
93
  *
94
+ * Boundary semantics for numeric limits:
95
+ *
96
+ * - `undefined` — apply the default from {@link DEFAULT_SERIAL_SESSION_OPTIONS}
97
+ * - `baudRate` / `bufferSize` — must be safe integers `> 0` (rejected otherwise)
98
+ * - `terminalBuffer` / `lineBuffer` limits — safe integers `>= 0`; `0` means unlimited
99
+ *
69
100
  * @see {@link SerialConnectionOptions}
70
101
  * @see {@link SerialSessionFeatureOptions}
71
102
  * @see {@link SerialOptions}
@@ -73,96 +104,29 @@ export interface SerialSessionFeatureOptions {
73
104
  * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/200 | Issue #200}
74
105
  * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/402 | Issue #402}
75
106
  * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/441 | Issue #441}
107
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/488 | Issue #488}
76
108
  */
77
109
  export interface SerialSessionOptions extends Partial<SerialConnectionOptions>, SerialSessionFeatureOptions {
78
110
  }
79
- /**
80
- * Options for {@link SerialSessionOptions.receiveReplay}.
81
- *
82
- * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/265 | Issue #265}
83
- * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/372 | Issue #372}
84
- */
85
- export interface SerialSessionReceiveReplayOptions {
86
- /**
87
- * When `true`, the session uses a replay buffer for {@link SerialSession.receiveReplay$}
88
- * for each open connection. When `false` (default), `receiveReplay$` is
89
- * the same hot stream as {@link SerialSession.receive$} (no chunk replay).
90
- */
91
- enabled?: boolean;
92
- /**
93
- * Retains the last **N** decoded text chunks (one emission per `onChunk`
94
- * from the read pump) in the replay buffer. Not the character count. Higher
95
- * `bufferSize` uses more memory.
96
- *
97
- * @default 512
98
- */
99
- bufferSize?: number;
100
- /**
101
- * Maximum total characters retained across buffered replay chunks for the
102
- * active connection. When exceeded, oldest chunks are discarded. `0` means
103
- * unlimited (only `bufferSize` applies).
104
- *
105
- * @default 0
106
- */
107
- maxChars?: number;
108
- }
109
- /** Maximum allowed {@link SerialSessionReceiveReplayOptions.bufferSize}. */
110
- export declare const MAX_RECEIVE_REPLAY_BUFFER_SIZE = 65536;
111
- /** Maximum allowed {@link SerialSessionReceiveReplayOptions.maxChars}. */
112
- export declare const MAX_RECEIVE_REPLAY_MAX_CHARS = 1048576;
113
- /**
114
- * Merge and validate {@link SerialSessionReceiveReplayOptions}.
115
- *
116
- * @throws {@link SerialError} with {@link SerialErrorCode.INVALID_RECEIVE_REPLAY_OPTIONS}
117
- * when `bufferSize` or `maxChars` are out of range.
118
- */
119
- /** Resolved receive replay options with validated branded numeric fields. */
120
- export type ResolvedSerialSessionReceiveReplayOptions = {
121
- enabled: boolean;
122
- bufferSize: ReceiveReplayBufferSize;
123
- maxChars: MaxChars;
124
- };
125
- export declare function resolveReceiveReplayOptions(options?: SerialSessionReceiveReplayOptions): ResolvedSerialSessionReceiveReplayOptions;
126
- /**
127
- * Merge and validate {@link TerminalBufferOptions}.
128
- *
129
- * @throws {@link SerialError} with {@link SerialErrorCode.INVALID_TERMINAL_BUFFER_OPTIONS}
130
- * when `maxLines` or `maxChars` are out of range.
131
- */
132
- /** Resolved terminal buffer options with validated branded numeric fields. */
133
- export type ResolvedTerminalBufferOptions = {
134
- maxLines: MaxLines;
135
- maxChars: MaxChars;
136
- stripAnsi: boolean;
137
- };
138
- export declare function resolveTerminalBufferOptions(options?: TerminalBufferOptions): ResolvedTerminalBufferOptions;
139
- /**
140
- * Merge and validate {@link LineBufferOptions}.
141
- *
142
- * @throws {@link SerialError} with {@link SerialErrorCode.INVALID_LINE_BUFFER_OPTIONS}
143
- * when `maxChars` is out of range.
144
- */
145
- /** Resolved line buffer options with validated branded numeric fields. */
146
- export type ResolvedLineBufferOptions = {
147
- maxChars: MaxChars;
148
- };
149
- export declare function resolveLineBufferOptions(options?: LineBufferOptions): ResolvedLineBufferOptions;
150
111
  /**
151
112
  * Fully resolved session options after merging {@link SerialSessionOptions}
152
113
  * with {@link DEFAULT_SERIAL_SESSION_OPTIONS}. All invariant fields are
153
114
  * required; `filters` remains optional.
154
115
  */
155
- export type ResolvedSerialSessionOptions = Required<Omit<SerialSessionOptions, 'filters' | 'receiveReplay' | 'terminalBuffer' | 'lineBuffer' | 'baudRate' | 'bufferSize'>> & {
116
+ export type ResolvedSerialSessionOptions = Required<Omit<SerialSessionOptions, 'filters' | 'terminalBuffer' | 'lineBuffer' | 'baudRate' | 'bufferSize'>> & {
156
117
  baudRate: BaudRate;
157
118
  bufferSize: SerialPortBufferSize;
158
119
  filters?: SerialPortFilter[];
159
- receiveReplay: ResolvedSerialSessionReceiveReplayOptions;
160
120
  terminalBuffer: ResolvedTerminalBufferOptions;
161
121
  lineBuffer: ResolvedLineBufferOptions;
162
122
  };
163
123
  /**
164
124
  * Default values applied to omitted {@link SerialSessionOptions} fields.
165
125
  *
126
+ * Nested buffer defaults are owned by {@link resolveTerminalBufferOptions} and
127
+ * {@link resolveLineBufferOptions}; this object is the single session-level
128
+ * snapshot used by {@link resolveSerialSessionOptions}.
129
+ *
166
130
  * @internal
167
131
  */
168
132
  export declare const DEFAULT_SERIAL_SESSION_OPTIONS: {
@@ -172,7 +136,6 @@ export declare const DEFAULT_SERIAL_SESSION_OPTIONS: {
172
136
  parity: "none";
173
137
  bufferSize: SerialPortBufferSize;
174
138
  flowControl: "none";
175
- receiveReplay: ResolvedSerialSessionReceiveReplayOptions;
176
139
  terminalBuffer: ResolvedTerminalBufferOptions;
177
140
  lineBuffer: ResolvedLineBufferOptions;
178
141
  };
@@ -185,20 +148,25 @@ export type ResolvedSerialSessionConnectionOptions = Required<Omit<SerialConnect
185
148
  * Merge and validate W3C connection fields from {@link SerialSessionOptions}.
186
149
  *
187
150
  * @throws {@link SerialError} with {@link SerialErrorCode.INVALID_CONNECTION_OPTIONS}
188
- * when `baudRate` is out of range.
151
+ * when `baudRate` or `bufferSize` are out of range.
189
152
  */
190
153
  export declare function resolveConnectionOptions(options?: Partial<SerialConnectionOptions>): ResolvedSerialSessionConnectionOptions;
191
154
  /**
192
155
  * Merge and validate {@link SerialSessionOptions} into a fully resolved
193
156
  * options object for internal session use.
194
157
  *
158
+ * Defaults and validation for nested buffers live next to their option types
159
+ * ({@link resolveTerminalBufferOptions}, {@link resolveLineBufferOptions}).
160
+ * This function is the single entry point that assembles connection + feature
161
+ * options for a session.
162
+ *
195
163
  * @throws {@link SerialError} when option values are out of range:
196
164
  * {@link SerialErrorCode.INVALID_CONNECTION_OPTIONS},
197
165
  * {@link SerialErrorCode.INVALID_FILTER_OPTIONS},
198
- * {@link SerialErrorCode.INVALID_RECEIVE_REPLAY_OPTIONS},
199
166
  * {@link SerialErrorCode.INVALID_TERMINAL_BUFFER_OPTIONS}, or
200
167
  * {@link SerialErrorCode.INVALID_LINE_BUFFER_OPTIONS}.
201
168
  * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/403 | Issue #403}
169
+ * @see {@link https://github.com/gurezo/web-serial-rxjs/issues/488 | Issue #488}
202
170
  */
203
171
  export declare function resolveSerialSessionOptions(options?: SerialSessionOptions): ResolvedSerialSessionOptions;
204
172
  //# sourceMappingURL=serial-session-options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serial-session-options.d.ts","sourceRoot":"","sources":["../../src/session/serial-session-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,uB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