@gurezo/web-serial-rxjs 2.4.0 → 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/dist/errors/serial-error-code.d.ts +53 -18
- 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 +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1065 -594
- 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/session/create-serial-session.d.ts +5 -2
- package/dist/session/create-serial-session.d.ts.map +1 -1
- package/dist/session/index.d.ts +6 -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 +15 -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 +3 -2
- package/dist/session/internal/receive-replay-buffer.d.ts.map +1 -1
- 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/serial-session-options.d.ts +95 -49
- package/dist/session/serial-session-options.d.ts.map +1 -1
- package/dist/session/serial-session-state.d.ts +49 -12
- package/dist/session/serial-session-state.d.ts.map +1 -1
- package/dist/session/serial-session.d.ts +9 -7
- 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 +3 -2
- 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 +1 -1
- package/dist/session/session-state-machine.d.ts +0 -40
- package/dist/session/session-state-machine.d.ts.map +0 -1
|
@@ -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
|
|
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":"
|
|
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,6 +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';
|
|
5
9
|
export { DEFAULT_LINE_BUFFER_OPTIONS, type LineBufferOptions, } from './internal/line-buffer';
|
|
6
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,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":"
|
|
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:
|
|
10
|
+
bufferSize: ReceiveReplayBufferSize;
|
|
10
11
|
/**
|
|
11
12
|
* Maximum total characters across retained chunks. `0` disables the limit.
|
|
12
13
|
*/
|
|
13
|
-
maxChars:
|
|
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;
|
|
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"}
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
+
import { type BaudRate, type MaxChars, type MaxLines, type ReceiveReplayBufferSize, type SerialPortBufferSize } from '../internal/branded-numbers';
|
|
1
2
|
import type { TerminalBufferOptions } from '../terminal/create-terminal-buffer';
|
|
2
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'>;
|
|
3
10
|
/**
|
|
4
11
|
* Options for creating a {@link SerialSession} via {@link createSerialSession}.
|
|
5
12
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
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'`).
|
|
9
19
|
*
|
|
10
20
|
* @example
|
|
11
21
|
* ```typescript
|
|
@@ -19,49 +29,12 @@ import { type LineBufferOptions } from './internal/line-buffer';
|
|
|
19
29
|
* });
|
|
20
30
|
* ```
|
|
21
31
|
*
|
|
32
|
+
* @see {@link SerialOptions}
|
|
22
33
|
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/199 | Issue #199}
|
|
23
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}
|
|
24
36
|
*/
|
|
25
|
-
export interface SerialSessionOptions {
|
|
26
|
-
/**
|
|
27
|
-
* Baud rate for the serial port connection (bits per second).
|
|
28
|
-
*
|
|
29
|
-
* Common values include 9600, 19200, 38400, 57600, 115200, etc.
|
|
30
|
-
* Must match the baud rate configured on the connected device.
|
|
31
|
-
*
|
|
32
|
-
* @default 9600
|
|
33
|
-
*/
|
|
34
|
-
baudRate?: number;
|
|
35
|
-
/**
|
|
36
|
-
* Number of data bits per character (7 or 8).
|
|
37
|
-
*
|
|
38
|
-
* @default 8
|
|
39
|
-
*/
|
|
40
|
-
dataBits?: 7 | 8;
|
|
41
|
-
/**
|
|
42
|
-
* Number of stop bits (1 or 2).
|
|
43
|
-
*
|
|
44
|
-
* @default 1
|
|
45
|
-
*/
|
|
46
|
-
stopBits?: 1 | 2;
|
|
47
|
-
/**
|
|
48
|
-
* Parity checking mode.
|
|
49
|
-
*
|
|
50
|
-
* @default 'none'
|
|
51
|
-
*/
|
|
52
|
-
parity?: 'none' | 'even' | 'odd';
|
|
53
|
-
/**
|
|
54
|
-
* Buffer size for the underlying read stream, in bytes.
|
|
55
|
-
*
|
|
56
|
-
* @default 255
|
|
57
|
-
*/
|
|
58
|
-
bufferSize?: number;
|
|
59
|
-
/**
|
|
60
|
-
* Flow control mode.
|
|
61
|
-
*
|
|
62
|
-
* @default 'none'
|
|
63
|
-
*/
|
|
64
|
-
flowControl?: 'none' | 'hardware';
|
|
37
|
+
export interface SerialSessionOptions extends Partial<SerialSessionConnectionFields> {
|
|
65
38
|
/**
|
|
66
39
|
* Filters for port selection when requesting a port.
|
|
67
40
|
*
|
|
@@ -136,16 +109,89 @@ export declare const MAX_RECEIVE_REPLAY_MAX_CHARS = 1048576;
|
|
|
136
109
|
* @throws {@link SerialError} with {@link SerialErrorCode.INVALID_RECEIVE_REPLAY_OPTIONS}
|
|
137
110
|
* when `bufferSize` or `maxChars` are out of range.
|
|
138
111
|
*/
|
|
139
|
-
|
|
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
|
+
};
|
|
140
155
|
/**
|
|
141
156
|
* Default values applied to omitted {@link SerialSessionOptions} fields.
|
|
142
157
|
*
|
|
143
158
|
* @internal
|
|
144
159
|
*/
|
|
145
|
-
export declare const DEFAULT_SERIAL_SESSION_OPTIONS:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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;
|
|
170
|
+
};
|
|
171
|
+
/** Resolved W3C connection fields for {@link ResolvedSerialSessionOptions}. */
|
|
172
|
+
export type ResolvedSerialSessionConnectionOptions = Required<Omit<SerialSessionConnectionFields, 'baudRate' | 'bufferSize'>> & {
|
|
173
|
+
baudRate: BaudRate;
|
|
174
|
+
bufferSize: SerialPortBufferSize;
|
|
150
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 {};
|
|
151
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,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"serial-session-options.d.ts","sourceRoot":"","sources":["../../src/session/serial-session-options.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import type { SerialError } from '../errors/serial-error';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Canonical status literals for a {@link SerialSession} lifecycle.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* consumers used for UI switches; the {@link SerialSessionState} const
|
|
7
|
-
* object is the canonical source of those literals so call sites can
|
|
8
|
-
* avoid string typos and get IDE completion.
|
|
5
|
+
* Use these constants when comparing {@link SerialSessionState.status}
|
|
6
|
+
* so call sites avoid string typos and get IDE completion.
|
|
9
7
|
*
|
|
10
8
|
* Lifecycle transitions:
|
|
11
9
|
*
|
|
@@ -14,12 +12,12 @@
|
|
|
14
12
|
* \-> error
|
|
15
13
|
* (any) -> unsupported (when Web Serial API is unavailable)
|
|
16
14
|
* (any) -> error (when an unrecoverable failure occurs)
|
|
15
|
+
* (any) -> disposed (when dispose$ completes)
|
|
17
16
|
* ```
|
|
18
17
|
*
|
|
19
|
-
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/
|
|
20
|
-
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/200 | Issue #200}
|
|
18
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/406 | Issue #406}
|
|
21
19
|
*/
|
|
22
|
-
export declare const
|
|
20
|
+
export declare const SerialSessionStatus: {
|
|
23
21
|
readonly Idle: "idle";
|
|
24
22
|
readonly Connecting: "connecting";
|
|
25
23
|
readonly Connected: "connected";
|
|
@@ -29,8 +27,47 @@ export declare const SerialSessionState: {
|
|
|
29
27
|
readonly Disposed: "disposed";
|
|
30
28
|
};
|
|
31
29
|
/**
|
|
32
|
-
* String union of allowed {@link
|
|
33
|
-
* (same set as the values on the {@link
|
|
30
|
+
* String union of allowed {@link SerialSessionStatus} runtime values
|
|
31
|
+
* (same set as the values on the {@link SerialSessionStatus} object).
|
|
34
32
|
*/
|
|
35
|
-
export type
|
|
33
|
+
export type SerialSessionStatus = (typeof SerialSessionStatus)[keyof typeof SerialSessionStatus];
|
|
34
|
+
/** @see {@link SerialSessionState} */
|
|
35
|
+
export interface IdleSessionState {
|
|
36
|
+
readonly status: typeof SerialSessionStatus.Idle;
|
|
37
|
+
}
|
|
38
|
+
/** @see {@link SerialSessionState} */
|
|
39
|
+
export interface ConnectingSessionState {
|
|
40
|
+
readonly status: typeof SerialSessionStatus.Connecting;
|
|
41
|
+
}
|
|
42
|
+
/** @see {@link SerialSessionState} */
|
|
43
|
+
export interface ConnectedSessionState {
|
|
44
|
+
readonly status: typeof SerialSessionStatus.Connected;
|
|
45
|
+
readonly portInfo: SerialPortInfo;
|
|
46
|
+
}
|
|
47
|
+
/** @see {@link SerialSessionState} */
|
|
48
|
+
export interface DisconnectingSessionState {
|
|
49
|
+
readonly status: typeof SerialSessionStatus.Disconnecting;
|
|
50
|
+
}
|
|
51
|
+
/** @see {@link SerialSessionState} */
|
|
52
|
+
export interface UnsupportedSessionState {
|
|
53
|
+
readonly status: typeof SerialSessionStatus.Unsupported;
|
|
54
|
+
}
|
|
55
|
+
/** @see {@link SerialSessionState} */
|
|
56
|
+
export interface ErrorSessionState {
|
|
57
|
+
readonly status: typeof SerialSessionStatus.Error;
|
|
58
|
+
readonly error: SerialError;
|
|
59
|
+
}
|
|
60
|
+
/** @see {@link SerialSessionState} */
|
|
61
|
+
export interface DisposedSessionState {
|
|
62
|
+
readonly status: typeof SerialSessionStatus.Disposed;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Discriminated union emitted by {@link SerialSession.state$}.
|
|
66
|
+
*
|
|
67
|
+
* Each variant carries the lifecycle `status` plus optional detail fields
|
|
68
|
+
* (`portInfo` when connected, `error` when in a fatal error state).
|
|
69
|
+
*
|
|
70
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/406 | Issue #406}
|
|
71
|
+
*/
|
|
72
|
+
export type SerialSessionState = IdleSessionState | ConnectingSessionState | ConnectedSessionState | DisconnectingSessionState | UnsupportedSessionState | ErrorSessionState | DisposedSessionState;
|
|
36
73
|
//# sourceMappingURL=serial-session-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serial-session-state.d.ts","sourceRoot":"","sources":["../../src/session/serial-session-state.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"serial-session-state.d.ts","sourceRoot":"","sources":["../../src/session/serial-session-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;CAQtB,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAC7B,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEjE,sCAAsC;AACtC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,OAAO,mBAAmB,CAAC,IAAI,CAAC;CAClD;AAED,sCAAsC;AACtC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,MAAM,EAAE,OAAO,mBAAmB,CAAC,UAAU,CAAC;CACxD;AAED,sCAAsC;AACtC,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,OAAO,mBAAmB,CAAC,SAAS,CAAC;IACtD,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;CACnC;AAED,sCAAsC;AACtC,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,OAAO,mBAAmB,CAAC,aAAa,CAAC;CAC3D;AAED,sCAAsC;AACtC,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM,EAAE,OAAO,mBAAmB,CAAC,WAAW,CAAC;CACzD;AAED,sCAAsC;AACtC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,OAAO,mBAAmB,CAAC,KAAK,CAAC;IAClD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAED,sCAAsC;AACtC,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,OAAO,mBAAmB,CAAC,QAAQ,CAAC;CACtD;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,sBAAsB,GACtB,qBAAqB,GACrB,yBAAyB,GACzB,uBAAuB,GACvB,iBAAiB,GACjB,oBAAoB,CAAC"}
|