@gurezo/web-serial-rxjs 2.3.6 → 3.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.
- package/README.ja.md +1 -1
- package/README.md +1 -1
- package/dist/errors/serial-error-code.d.ts +92 -14
- package/dist/errors/serial-error-code.d.ts.map +1 -1
- package/dist/errors/serial-error-context.d.ts +47 -0
- package/dist/errors/serial-error-context.d.ts.map +1 -0
- package/dist/errors/serial-error.d.ts +30 -8
- package/dist/errors/serial-error.d.ts.map +1 -1
- package/dist/index.d.ts +13 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1327 -493
- package/dist/index.mjs.map +4 -4
- package/dist/internal/assert-never.d.ts +2 -0
- package/dist/internal/assert-never.d.ts.map +1 -0
- package/dist/internal/branded-numbers.d.ts +37 -0
- package/dist/internal/branded-numbers.d.ts.map +1 -0
- package/dist/internal/newline-tokenizer.d.ts +38 -0
- package/dist/internal/newline-tokenizer.d.ts.map +1 -0
- package/dist/session/create-serial-session.d.ts +7 -3
- package/dist/session/create-serial-session.d.ts.map +1 -1
- package/dist/session/index.d.ts +7 -2
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/internal/build-request-options.d.ts +7 -7
- package/dist/session/internal/build-request-options.d.ts.map +1 -1
- package/dist/session/internal/error-severity.d.ts +38 -0
- package/dist/session/internal/error-severity.d.ts.map +1 -0
- package/dist/session/internal/line-buffer.d.ts +37 -4
- package/dist/session/internal/line-buffer.d.ts.map +1 -1
- package/dist/session/internal/receive-pipeline.d.ts +34 -0
- package/dist/session/internal/receive-pipeline.d.ts.map +1 -0
- package/dist/session/internal/receive-replay-buffer.d.ts +38 -0
- package/dist/session/internal/receive-replay-buffer.d.ts.map +1 -0
- package/dist/session/internal/session-error-reporter.d.ts +32 -0
- package/dist/session/internal/session-error-reporter.d.ts.map +1 -0
- package/dist/session/internal/session-lifecycle.d.ts +44 -0
- package/dist/session/internal/session-lifecycle.d.ts.map +1 -0
- package/dist/session/internal/validate-serial-port-filters.d.ts +12 -0
- package/dist/session/internal/validate-serial-port-filters.d.ts.map +1 -0
- package/dist/session/read-pump.d.ts +9 -1
- package/dist/session/read-pump.d.ts.map +1 -1
- package/dist/session/serial-session-options.d.ts +133 -46
- package/dist/session/serial-session-options.d.ts.map +1 -1
- package/dist/session/serial-session-state.d.ts +50 -12
- package/dist/session/serial-session-state.d.ts.map +1 -1
- package/dist/session/serial-session.d.ts +44 -9
- package/dist/session/serial-session.d.ts.map +1 -1
- package/dist/session/session-runtime.d.ts +140 -0
- package/dist/session/session-runtime.d.ts.map +1 -0
- package/dist/terminal/create-terminal-buffer.d.ts +48 -1
- package/dist/terminal/create-terminal-buffer.d.ts.map +1 -1
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +2 -1
- package/dist/index.js +0 -724
- package/dist/session/session-state-machine.d.ts +0 -39
- package/dist/session/session-state-machine.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-serial-session.d.ts","sourceRoot":"","sources":["../../src/session/create-serial-session.ts"],"names":[],"mappings":"
|
|
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;AAQlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,aAAa,CA4Gf"}
|
package/dist/session/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
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 {
|
|
3
|
+
export type { SerialSessionOptions, 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 type { SerialSessionState, IdleSessionState, ConnectingSessionState, ConnectedSessionState, DisconnectingSessionState, UnsupportedSessionState, ErrorSessionState, DisposedSessionState, } from './serial-session-state';
|
|
9
|
+
export { DEFAULT_LINE_BUFFER_OPTIONS, type LineBufferOptions, } from './internal/line-buffer';
|
|
5
10
|
//# 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,
|
|
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,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,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
|
|
6
|
-
*
|
|
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
|
-
*
|
|
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":"
|
|
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,39 @@
|
|
|
1
|
+
import type { MaxChars } from '../../internal/branded-numbers';
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link createLineBuffer}.
|
|
4
|
+
*
|
|
5
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/371 | Issue #371}
|
|
6
|
+
*/
|
|
7
|
+
export interface LineBufferOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Maximum characters retained in the incomplete line tail (no line terminator yet).
|
|
10
|
+
* When exceeded, leading characters are discarded. `0` means unlimited.
|
|
11
|
+
*
|
|
12
|
+
* @default 1048576
|
|
13
|
+
*/
|
|
14
|
+
maxChars?: number;
|
|
15
|
+
}
|
|
16
|
+
/** Default limits applied when {@link LineBufferOptions} fields are omitted. */
|
|
17
|
+
export declare const DEFAULT_LINE_BUFFER_OPTIONS: Required<LineBufferOptions>;
|
|
18
|
+
/** Result of {@link createLineBuffer.feed}. */
|
|
19
|
+
export interface LineBufferFeedResult {
|
|
20
|
+
lines: string[];
|
|
21
|
+
/** `true` when leading characters were discarded due to `maxChars`. */
|
|
22
|
+
overflowed: boolean;
|
|
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
|
+
}
|
|
1
37
|
/**
|
|
2
38
|
* Streaming UTF-16 text to newline-delimited lines for {@link createSerialSession}.
|
|
3
39
|
* Supports `\r\n` and `\n` per #237; a lone `\r` that is not the last character
|
|
@@ -7,8 +43,5 @@
|
|
|
7
43
|
*
|
|
8
44
|
* @internal
|
|
9
45
|
*/
|
|
10
|
-
export declare function createLineBuffer():
|
|
11
|
-
feed(chunk: string): string[];
|
|
12
|
-
clear(): void;
|
|
13
|
-
};
|
|
46
|
+
export declare function createLineBuffer(options?: LineBufferOptions | LineBufferLimits): LineBuffer;
|
|
14
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":"
|
|
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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import type { MaxChars, ReceiveReplayBufferSize } from '../../internal/branded-numbers';
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link createReceiveReplayBuffer}.
|
|
5
|
+
*
|
|
6
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/372 | Issue #372}
|
|
7
|
+
*/
|
|
8
|
+
export interface ReceiveReplayBufferOptions {
|
|
9
|
+
/** Maximum number of chunks to retain. */
|
|
10
|
+
bufferSize: ReceiveReplayBufferSize;
|
|
11
|
+
/**
|
|
12
|
+
* Maximum total characters across retained chunks. `0` disables the limit.
|
|
13
|
+
*/
|
|
14
|
+
maxChars: MaxChars;
|
|
15
|
+
}
|
|
16
|
+
/** Result of {@link ReceiveReplayBuffer.next}. */
|
|
17
|
+
export interface ReceiveReplayBufferNextResult {
|
|
18
|
+
/** `true` when oldest chunks were discarded to satisfy limits. */
|
|
19
|
+
overflowed: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Bounded replay buffer for {@link SerialSession.receiveReplay$}.
|
|
23
|
+
* Replays retained chunks to new subscribers, then forwards live emissions.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export interface ReceiveReplayBuffer {
|
|
28
|
+
next(chunk: string): ReceiveReplayBufferNextResult;
|
|
29
|
+
asObservable(): Observable<string>;
|
|
30
|
+
complete(): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create a per-connection receive replay buffer.
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export declare function createReceiveReplayBuffer(options: ReceiveReplayBufferOptions): ReceiveReplayBuffer;
|
|
38
|
+
//# sourceMappingURL=receive-replay-buffer.d.ts.map
|
|
@@ -0,0 +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;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,CAyChC"}
|
|
@@ -19,6 +19,13 @@ export type ReadPumpChunkHandler = (text: string) => void;
|
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
21
|
export type ReadPumpErrorHandler = (error: SerialError) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Callback invoked when the read loop ends naturally (`reader.read()`
|
|
24
|
+
* resolved with `done: true`) while the pump is still active.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export type ReadPumpDoneHandler = () => void;
|
|
22
29
|
/**
|
|
23
30
|
* Options accepted by {@link createReadPump}.
|
|
24
31
|
*
|
|
@@ -27,6 +34,7 @@ export type ReadPumpErrorHandler = (error: SerialError) => void;
|
|
|
27
34
|
export interface ReadPumpOptions {
|
|
28
35
|
onChunk: ReadPumpChunkHandler;
|
|
29
36
|
onError: ReadPumpErrorHandler;
|
|
37
|
+
onDone?: ReadPumpDoneHandler;
|
|
30
38
|
}
|
|
31
39
|
/**
|
|
32
40
|
* Handle returned by {@link createReadPump}.
|
|
@@ -70,5 +78,5 @@ export interface ReadPump {
|
|
|
70
78
|
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/199 | Issue #199}
|
|
71
79
|
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/202 | Issue #202}
|
|
72
80
|
*/
|
|
73
|
-
export declare function createReadPump(port: SerialPort, { onChunk, onError }: ReadPumpOptions): ReadPump;
|
|
81
|
+
export declare function createReadPump(port: SerialPort, { onChunk, onError, onDone }: ReadPumpOptions): ReadPump;
|
|
74
82
|
//# sourceMappingURL=read-pump.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-pump.d.ts","sourceRoot":"","sources":["../../src/session/read-pump.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAE1D;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,OAAO,EAAE,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"read-pump.d.ts","sourceRoot":"","sources":["../../src/session/read-pump.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAE1D;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;OAIG;IACH,KAAK,IAAI,IAAI,CAAC;IACd;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,UAAU,EAChB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,eAAe,GAC5C,QAAQ,CAiGV"}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
+
import { type BaudRate, type MaxChars, type MaxLines, type ReceiveReplayBufferSize, type SerialPortBufferSize } from '../internal/branded-numbers';
|
|
2
|
+
import type { TerminalBufferOptions } from '../terminal/create-terminal-buffer';
|
|
3
|
+
import { type LineBufferOptions } from './internal/line-buffer';
|
|
4
|
+
/**
|
|
5
|
+
* W3C connection fields shared with {@link SerialOptions}.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
type SerialSessionConnectionFields = Pick<SerialOptions, 'baudRate' | 'dataBits' | 'stopBits' | 'parity' | 'bufferSize' | 'flowControl'>;
|
|
1
10
|
/**
|
|
2
11
|
* Options for creating a {@link SerialSession} via {@link createSerialSession}.
|
|
3
12
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
13
|
+
* Connection parameters (`baudRate`, `dataBits`, `stopBits`, `parity`,
|
|
14
|
+
* `bufferSize`, `flowControl`) are derived from the W3C {@link SerialOptions}
|
|
15
|
+
* type and passed to `port.open`. All connection fields are optional here;
|
|
16
|
+
* omitted values fall back to {@link DEFAULT_SERIAL_SESSION_OPTIONS}
|
|
17
|
+
* (`baudRate` 9600, `dataBits` 8, `stopBits` 1, `parity` `'none'`,
|
|
18
|
+
* `bufferSize` 255, `flowControl` `'none'`).
|
|
7
19
|
*
|
|
8
20
|
* @example
|
|
9
21
|
* ```typescript
|
|
@@ -17,49 +29,12 @@
|
|
|
17
29
|
* });
|
|
18
30
|
* ```
|
|
19
31
|
*
|
|
32
|
+
* @see {@link SerialOptions}
|
|
20
33
|
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/199 | Issue #199}
|
|
21
34
|
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/200 | Issue #200}
|
|
35
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/402 | Issue #402}
|
|
22
36
|
*/
|
|
23
|
-
export interface SerialSessionOptions {
|
|
24
|
-
/**
|
|
25
|
-
* Baud rate for the serial port connection (bits per second).
|
|
26
|
-
*
|
|
27
|
-
* Common values include 9600, 19200, 38400, 57600, 115200, etc.
|
|
28
|
-
* Must match the baud rate configured on the connected device.
|
|
29
|
-
*
|
|
30
|
-
* @default 9600
|
|
31
|
-
*/
|
|
32
|
-
baudRate?: number;
|
|
33
|
-
/**
|
|
34
|
-
* Number of data bits per character (7 or 8).
|
|
35
|
-
*
|
|
36
|
-
* @default 8
|
|
37
|
-
*/
|
|
38
|
-
dataBits?: 7 | 8;
|
|
39
|
-
/**
|
|
40
|
-
* Number of stop bits (1 or 2).
|
|
41
|
-
*
|
|
42
|
-
* @default 1
|
|
43
|
-
*/
|
|
44
|
-
stopBits?: 1 | 2;
|
|
45
|
-
/**
|
|
46
|
-
* Parity checking mode.
|
|
47
|
-
*
|
|
48
|
-
* @default 'none'
|
|
49
|
-
*/
|
|
50
|
-
parity?: 'none' | 'even' | 'odd';
|
|
51
|
-
/**
|
|
52
|
-
* Buffer size for the underlying read stream, in bytes.
|
|
53
|
-
*
|
|
54
|
-
* @default 255
|
|
55
|
-
*/
|
|
56
|
-
bufferSize?: number;
|
|
57
|
-
/**
|
|
58
|
-
* Flow control mode.
|
|
59
|
-
*
|
|
60
|
-
* @default 'none'
|
|
61
|
-
*/
|
|
62
|
-
flowControl?: 'none' | 'hardware';
|
|
37
|
+
export interface SerialSessionOptions extends Partial<SerialSessionConnectionFields> {
|
|
63
38
|
/**
|
|
64
39
|
* Filters for port selection when requesting a port.
|
|
65
40
|
*
|
|
@@ -76,11 +51,29 @@ export interface SerialSessionOptions {
|
|
|
76
51
|
* @default `{ enabled: false, bufferSize: 512 }` (see {@link DEFAULT_SERIAL_SESSION_OPTIONS})
|
|
77
52
|
*/
|
|
78
53
|
receiveReplay?: SerialSessionReceiveReplayOptions;
|
|
54
|
+
/**
|
|
55
|
+
* Limits for {@link SerialSession.terminalText$} display memory. Oldest
|
|
56
|
+
* completed lines and leading characters are dropped when exceeded.
|
|
57
|
+
*
|
|
58
|
+
* @default `{ maxLines: 10000, maxChars: 1048576 }` (see {@link DEFAULT_SERIAL_SESSION_OPTIONS})
|
|
59
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/370 | Issue #370}
|
|
60
|
+
*/
|
|
61
|
+
terminalBuffer?: TerminalBufferOptions;
|
|
62
|
+
/**
|
|
63
|
+
* Limits for the incomplete line tail held by {@link SerialSession.lines$}
|
|
64
|
+
* framing. When exceeded, leading characters are discarded and a non-fatal
|
|
65
|
+
* {@link SerialErrorCode.LINE_BUFFER_OVERFLOW} is emitted on {@link SerialSession.errors$}.
|
|
66
|
+
*
|
|
67
|
+
* @default `{ maxChars: 1048576 }` (see {@link DEFAULT_SERIAL_SESSION_OPTIONS})
|
|
68
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/371 | Issue #371}
|
|
69
|
+
*/
|
|
70
|
+
lineBuffer?: LineBufferOptions;
|
|
79
71
|
}
|
|
80
72
|
/**
|
|
81
73
|
* Options for {@link SerialSessionOptions.receiveReplay}.
|
|
82
74
|
*
|
|
83
75
|
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/265 | Issue #265}
|
|
76
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/372 | Issue #372}
|
|
84
77
|
*/
|
|
85
78
|
export interface SerialSessionReceiveReplayOptions {
|
|
86
79
|
/**
|
|
@@ -97,14 +90,108 @@ export interface SerialSessionReceiveReplayOptions {
|
|
|
97
90
|
* @default 512
|
|
98
91
|
*/
|
|
99
92
|
bufferSize?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Maximum total characters retained across buffered replay chunks for the
|
|
95
|
+
* active connection. When exceeded, oldest chunks are discarded. `0` means
|
|
96
|
+
* unlimited (only `bufferSize` applies).
|
|
97
|
+
*
|
|
98
|
+
* @default 0
|
|
99
|
+
*/
|
|
100
|
+
maxChars?: number;
|
|
100
101
|
}
|
|
102
|
+
/** Maximum allowed {@link SerialSessionReceiveReplayOptions.bufferSize}. */
|
|
103
|
+
export declare const MAX_RECEIVE_REPLAY_BUFFER_SIZE = 65536;
|
|
104
|
+
/** Maximum allowed {@link SerialSessionReceiveReplayOptions.maxChars}. */
|
|
105
|
+
export declare const MAX_RECEIVE_REPLAY_MAX_CHARS = 1048576;
|
|
106
|
+
/**
|
|
107
|
+
* Merge and validate {@link SerialSessionReceiveReplayOptions}.
|
|
108
|
+
*
|
|
109
|
+
* @throws {@link SerialError} with {@link SerialErrorCode.INVALID_RECEIVE_REPLAY_OPTIONS}
|
|
110
|
+
* when `bufferSize` or `maxChars` are out of range.
|
|
111
|
+
*/
|
|
112
|
+
/** Resolved receive replay options with validated branded numeric fields. */
|
|
113
|
+
export type ResolvedSerialSessionReceiveReplayOptions = {
|
|
114
|
+
enabled: boolean;
|
|
115
|
+
bufferSize: ReceiveReplayBufferSize;
|
|
116
|
+
maxChars: MaxChars;
|
|
117
|
+
};
|
|
118
|
+
export declare function resolveReceiveReplayOptions(options?: SerialSessionReceiveReplayOptions): ResolvedSerialSessionReceiveReplayOptions;
|
|
119
|
+
/**
|
|
120
|
+
* Merge and validate {@link TerminalBufferOptions}.
|
|
121
|
+
*
|
|
122
|
+
* @throws {@link SerialError} with {@link SerialErrorCode.INVALID_TERMINAL_BUFFER_OPTIONS}
|
|
123
|
+
* when `maxLines` or `maxChars` are out of range.
|
|
124
|
+
*/
|
|
125
|
+
/** Resolved terminal buffer options with validated branded numeric fields. */
|
|
126
|
+
export type ResolvedTerminalBufferOptions = {
|
|
127
|
+
maxLines: MaxLines;
|
|
128
|
+
maxChars: MaxChars;
|
|
129
|
+
};
|
|
130
|
+
export declare function resolveTerminalBufferOptions(options?: TerminalBufferOptions): ResolvedTerminalBufferOptions;
|
|
131
|
+
/**
|
|
132
|
+
* Merge and validate {@link LineBufferOptions}.
|
|
133
|
+
*
|
|
134
|
+
* @throws {@link SerialError} with {@link SerialErrorCode.INVALID_LINE_BUFFER_OPTIONS}
|
|
135
|
+
* when `maxChars` is out of range.
|
|
136
|
+
*/
|
|
137
|
+
/** Resolved line buffer options with validated branded numeric fields. */
|
|
138
|
+
export type ResolvedLineBufferOptions = {
|
|
139
|
+
maxChars: MaxChars;
|
|
140
|
+
};
|
|
141
|
+
export declare function resolveLineBufferOptions(options?: LineBufferOptions): ResolvedLineBufferOptions;
|
|
142
|
+
/**
|
|
143
|
+
* Fully resolved session options after merging {@link SerialSessionOptions}
|
|
144
|
+
* with {@link DEFAULT_SERIAL_SESSION_OPTIONS}. All invariant fields are
|
|
145
|
+
* required; `filters` remains optional.
|
|
146
|
+
*/
|
|
147
|
+
export type ResolvedSerialSessionOptions = Required<Omit<SerialSessionOptions, 'filters' | 'receiveReplay' | 'terminalBuffer' | 'lineBuffer' | 'baudRate' | 'bufferSize'>> & {
|
|
148
|
+
baudRate: BaudRate;
|
|
149
|
+
bufferSize: SerialPortBufferSize;
|
|
150
|
+
filters?: SerialPortFilter[];
|
|
151
|
+
receiveReplay: ResolvedSerialSessionReceiveReplayOptions;
|
|
152
|
+
terminalBuffer: ResolvedTerminalBufferOptions;
|
|
153
|
+
lineBuffer: ResolvedLineBufferOptions;
|
|
154
|
+
};
|
|
101
155
|
/**
|
|
102
156
|
* Default values applied to omitted {@link SerialSessionOptions} fields.
|
|
103
157
|
*
|
|
104
158
|
* @internal
|
|
105
159
|
*/
|
|
106
|
-
export declare const DEFAULT_SERIAL_SESSION_OPTIONS:
|
|
107
|
-
|
|
108
|
-
|
|
160
|
+
export declare const DEFAULT_SERIAL_SESSION_OPTIONS: {
|
|
161
|
+
baudRate: BaudRate;
|
|
162
|
+
dataBits: 8;
|
|
163
|
+
stopBits: 1;
|
|
164
|
+
parity: "none";
|
|
165
|
+
bufferSize: SerialPortBufferSize;
|
|
166
|
+
flowControl: "none";
|
|
167
|
+
receiveReplay: ResolvedSerialSessionReceiveReplayOptions;
|
|
168
|
+
terminalBuffer: ResolvedTerminalBufferOptions;
|
|
169
|
+
lineBuffer: ResolvedLineBufferOptions;
|
|
109
170
|
};
|
|
171
|
+
/** Resolved W3C connection fields for {@link ResolvedSerialSessionOptions}. */
|
|
172
|
+
export type ResolvedSerialSessionConnectionOptions = Required<Omit<SerialSessionConnectionFields, 'baudRate' | 'bufferSize'>> & {
|
|
173
|
+
baudRate: BaudRate;
|
|
174
|
+
bufferSize: SerialPortBufferSize;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Merge and validate W3C connection fields from {@link SerialSessionOptions}.
|
|
178
|
+
*
|
|
179
|
+
* @throws {@link SerialError} with {@link SerialErrorCode.INVALID_CONNECTION_OPTIONS}
|
|
180
|
+
* when `baudRate` is out of range.
|
|
181
|
+
*/
|
|
182
|
+
export declare function resolveConnectionOptions(options?: Pick<SerialSessionOptions, 'baudRate' | 'dataBits' | 'stopBits' | 'parity' | 'bufferSize' | 'flowControl'>): ResolvedSerialSessionConnectionOptions;
|
|
183
|
+
/**
|
|
184
|
+
* Merge and validate {@link SerialSessionOptions} into a fully resolved
|
|
185
|
+
* options object for internal session use.
|
|
186
|
+
*
|
|
187
|
+
* @throws {@link SerialError} when option values are out of range:
|
|
188
|
+
* {@link SerialErrorCode.INVALID_CONNECTION_OPTIONS},
|
|
189
|
+
* {@link SerialErrorCode.INVALID_FILTER_OPTIONS},
|
|
190
|
+
* {@link SerialErrorCode.INVALID_RECEIVE_REPLAY_OPTIONS},
|
|
191
|
+
* {@link SerialErrorCode.INVALID_TERMINAL_BUFFER_OPTIONS}, or
|
|
192
|
+
* {@link SerialErrorCode.INVALID_LINE_BUFFER_OPTIONS}.
|
|
193
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/403 | Issue #403}
|
|
194
|
+
*/
|
|
195
|
+
export declare function resolveSerialSessionOptions(options?: SerialSessionOptions): ResolvedSerialSessionOptions;
|
|
196
|
+
export {};
|
|
110
197
|
//# 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
|
|
1
|
+
{"version":3,"file":"serial-session-options.d.ts","sourceRoot":"","sources":["../../src/session/serial-session-options.ts"],"names":[],"mappings":"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"}
|