@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Observable } from 'rxjs';
|
|
2
2
|
import type { SerialError } from '../errors/serial-error';
|
|
3
|
+
import type { SerialPayload } from '../types';
|
|
3
4
|
import type { SerialSessionState } from './serial-session-state';
|
|
4
5
|
/**
|
|
5
6
|
* v2 public API for interacting with the Web Serial API through a
|
|
@@ -83,14 +84,15 @@ export interface SerialSession {
|
|
|
83
84
|
*/
|
|
84
85
|
destroy$(): Observable<void>;
|
|
85
86
|
/**
|
|
86
|
-
* Reactive session lifecycle state.
|
|
87
|
+
* Reactive session lifecycle state as a discriminated union.
|
|
87
88
|
*
|
|
88
|
-
* Replays the current state on subscribe.
|
|
89
|
-
*
|
|
89
|
+
* Replays the current state on subscribe. Switch on `state.status` and
|
|
90
|
+
* use the per-variant fields (`portInfo`, `error`) instead of correlating
|
|
91
|
+
* separate streams.
|
|
90
92
|
*/
|
|
91
93
|
readonly state$: Observable<SerialSessionState>;
|
|
92
94
|
/**
|
|
93
|
-
* `true` when {@link state$}
|
|
95
|
+
* `true` when {@link state$} has `status: 'connected'`, `false` otherwise.
|
|
94
96
|
*
|
|
95
97
|
* Derived from `state$` with `distinctUntilChanged` so UIs can bind
|
|
96
98
|
* connect/disabled flags without reimplementing the comparison.
|
|
@@ -98,8 +100,8 @@ export interface SerialSession {
|
|
|
98
100
|
readonly isConnected$: Observable<boolean>;
|
|
99
101
|
/**
|
|
100
102
|
* The active port’s {@link SerialPort.getInfo} snapshot, or `null` when no
|
|
101
|
-
* port is open (including {@link
|
|
102
|
-
* {@link
|
|
103
|
+
* port is open (including {@link SerialSessionStatus.Idle},
|
|
104
|
+
* {@link SerialSessionStatus.Error}, and {@link SerialSessionStatus.Unsupported}).
|
|
103
105
|
*
|
|
104
106
|
* Emits the current value on subscribe. Use with {@link state$} to know when
|
|
105
107
|
* the value is valid for your UI.
|
|
@@ -233,6 +235,6 @@ export interface SerialSession {
|
|
|
233
235
|
*
|
|
234
236
|
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/203 | Issue #203}
|
|
235
237
|
*/
|
|
236
|
-
send$(data:
|
|
238
|
+
send$(data: SerialPayload): Observable<void>;
|
|
237
239
|
}
|
|
238
240
|
//# sourceMappingURL=serial-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serial-session.d.ts","sourceRoot":"","sources":["../../src/session/serial-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,kBAAkB,IAAI,OAAO,CAAC;IAE9B;;;;;;;;OAQG;IACH,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAE7B;;;;;;;;;OASG;IACH,WAAW,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAEhC;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAE7B;;;;OAIG;IACH,QAAQ,IAAI,UAAU,CAA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;OAmBG;IACH,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAEtC;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAE3C;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,cAAc,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAE5C;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAEpC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CAAC,IAAI,EAAE,aAAa,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;CAC9C"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import type { SerialError } from '../errors/serial-error';
|
|
3
|
+
import type { ReadPump } from './read-pump';
|
|
4
|
+
import { SerialSessionStatus, type SerialSessionState, type SerialSessionStatus as SerialSessionStatusType } from './serial-session-state';
|
|
5
|
+
/**
|
|
6
|
+
* Discriminated union representing the full internal runtime state of a
|
|
7
|
+
* {@link SerialSession}, including lifecycle status and any resources that
|
|
8
|
+
* are valid for that status.
|
|
9
|
+
*
|
|
10
|
+
* This is the single source of truth for session lifecycle + resources.
|
|
11
|
+
* Public consumers observe the mapped {@link SerialSessionState} via
|
|
12
|
+
* `state$`; this union is internal only.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/397 | Issue #397}
|
|
16
|
+
*/
|
|
17
|
+
export type SessionRuntime = IdleRuntime | ConnectingRuntime | ConnectedRuntime | DisconnectingRuntime | ErrorRuntime | UnsupportedRuntime | DisposedRuntime;
|
|
18
|
+
/** @internal */
|
|
19
|
+
export interface IdleRuntime {
|
|
20
|
+
readonly status: typeof SerialSessionStatus.Idle;
|
|
21
|
+
}
|
|
22
|
+
/** @internal */
|
|
23
|
+
export interface ConnectingRuntime {
|
|
24
|
+
readonly status: typeof SerialSessionStatus.Connecting;
|
|
25
|
+
readonly cancel: () => void;
|
|
26
|
+
}
|
|
27
|
+
/** @internal */
|
|
28
|
+
export interface ConnectedRuntime {
|
|
29
|
+
readonly status: typeof SerialSessionStatus.Connected;
|
|
30
|
+
readonly port: SerialPort;
|
|
31
|
+
readonly pump: ReadPump;
|
|
32
|
+
}
|
|
33
|
+
/** @internal */
|
|
34
|
+
export interface DisconnectingRuntime {
|
|
35
|
+
readonly status: typeof SerialSessionStatus.Disconnecting;
|
|
36
|
+
readonly port: SerialPort | null;
|
|
37
|
+
}
|
|
38
|
+
/** @internal */
|
|
39
|
+
export interface ErrorRuntime {
|
|
40
|
+
readonly status: typeof SerialSessionStatus.Error;
|
|
41
|
+
readonly error: SerialError;
|
|
42
|
+
}
|
|
43
|
+
/** @internal */
|
|
44
|
+
export interface UnsupportedRuntime {
|
|
45
|
+
readonly status: typeof SerialSessionStatus.Unsupported;
|
|
46
|
+
}
|
|
47
|
+
/** @internal */
|
|
48
|
+
export interface DisposedRuntime {
|
|
49
|
+
readonly status: typeof SerialSessionStatus.Disposed;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Allowed transitions for the internal SerialSession state machine.
|
|
53
|
+
*
|
|
54
|
+
* `as const satisfies` keeps literal transition targets while ensuring every
|
|
55
|
+
* {@link SerialSessionStatus} key is present. Drift from the status union
|
|
56
|
+
* becomes a compile error.
|
|
57
|
+
*
|
|
58
|
+
* @internal
|
|
59
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/398 | Issue #398}
|
|
60
|
+
*/
|
|
61
|
+
export declare const ALLOWED_TRANSITIONS: {
|
|
62
|
+
readonly idle: readonly ["connecting", "error", "disposed"];
|
|
63
|
+
readonly connecting: readonly ["connected", "error", "idle", "disposed"];
|
|
64
|
+
readonly connected: readonly ["disconnecting", "error", "disposed"];
|
|
65
|
+
readonly disconnecting: readonly ["idle", "error", "disposed"];
|
|
66
|
+
readonly error: readonly ["idle", "connecting", "disposed"];
|
|
67
|
+
readonly unsupported: readonly ["disposed"];
|
|
68
|
+
readonly disposed: readonly [];
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Valid target states when transitioning from {@link T}.
|
|
72
|
+
*
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
export type AllowedTransition<T extends SerialSessionStatusType> = (typeof ALLOWED_TRANSITIONS)[T][number];
|
|
76
|
+
/** @internal */
|
|
77
|
+
export declare function runtimeToSessionStatus(runtime: SessionRuntime): SerialSessionStatusType;
|
|
78
|
+
/**
|
|
79
|
+
* Map internal runtime to the public {@link SerialSessionState} payload.
|
|
80
|
+
*
|
|
81
|
+
* @internal
|
|
82
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/406 | Issue #406}
|
|
83
|
+
*/
|
|
84
|
+
export declare function runtimeToPublicState(runtime: SessionRuntime): SerialSessionState;
|
|
85
|
+
/** @internal */
|
|
86
|
+
export declare function isValidTransition(from: SerialSessionStatusType, to: SerialSessionStatusType): boolean;
|
|
87
|
+
/** @internal */
|
|
88
|
+
export declare function createIdleRuntime(): IdleRuntime;
|
|
89
|
+
/** @internal */
|
|
90
|
+
export declare function createConnectingRuntime(cancel: () => void): ConnectingRuntime;
|
|
91
|
+
/** @internal */
|
|
92
|
+
export declare function createConnectedRuntime(port: SerialPort, pump: ReadPump): ConnectedRuntime;
|
|
93
|
+
/** @internal */
|
|
94
|
+
export declare function createDisconnectingRuntime(port: SerialPort | null): DisconnectingRuntime;
|
|
95
|
+
/** @internal */
|
|
96
|
+
export declare function createErrorRuntime(error: SerialError): ErrorRuntime;
|
|
97
|
+
/** @internal */
|
|
98
|
+
export declare function createUnsupportedRuntime(): UnsupportedRuntime;
|
|
99
|
+
/** @internal */
|
|
100
|
+
export declare function createDisposedRuntime(): DisposedRuntime;
|
|
101
|
+
/** @internal */
|
|
102
|
+
export declare function createInitialRuntime(supported: boolean): SessionRuntime;
|
|
103
|
+
/**
|
|
104
|
+
* Extract the active port from runtime when one is held.
|
|
105
|
+
*
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
export declare function getRuntimePort(runtime: SessionRuntime): SerialPort | null;
|
|
109
|
+
/**
|
|
110
|
+
* Extract the active pump from runtime when one is held.
|
|
111
|
+
*
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
export declare function getRuntimePump(runtime: SessionRuntime): ReadPump | null;
|
|
115
|
+
/**
|
|
116
|
+
* Controller that owns the {@link SessionRuntime} discriminated union and
|
|
117
|
+
* exposes the public `state$` stream derived from the runtime.
|
|
118
|
+
*
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
121
|
+
export interface SessionRuntimeController {
|
|
122
|
+
get runtime(): SessionRuntime;
|
|
123
|
+
get status(): SerialSessionStatusType;
|
|
124
|
+
get state$(): Observable<SerialSessionState>;
|
|
125
|
+
transition(next: SessionRuntime): boolean;
|
|
126
|
+
complete(): void;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Create a controller for the internal session runtime.
|
|
130
|
+
*
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
export declare function createSessionRuntimeController(initial: SessionRuntime): SessionRuntimeController;
|
|
134
|
+
/**
|
|
135
|
+
* Exhaustiveness helper for switch statements over {@link SessionRuntime}.
|
|
136
|
+
*
|
|
137
|
+
* @internal
|
|
138
|
+
*/
|
|
139
|
+
export declare function assertNeverRuntime(value: never): never;
|
|
140
|
+
//# sourceMappingURL=session-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-runtime.d.ts","sourceRoot":"","sources":["../../src/session/session-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,UAAU,EAAE,MAAM,MAAM,CAAC;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,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G,UAAU,GAAG,IAAI,CASzE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,QAAQ,GAAG,IAAI,CAKvE;AAED;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,OAAO,IAAI,cAAc,CAAC;IAC9B,IAAI,MAAM,IAAI,uBAAuB,CAAC;IACtC,IAAI,MAAM,IAAI,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAC7C,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC;IAC1C,QAAQ,IAAI,IAAI,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,cAAc,GACtB,wBAAwB,CA2C1B;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAEtD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Observable } from 'rxjs';
|
|
2
|
+
import { type MaxChars, type MaxLines } from '../internal/branded-numbers';
|
|
2
3
|
/** @internal Folded state between {@link createTerminalBuffer} emissions. */
|
|
3
4
|
export interface TerminalBufferState {
|
|
4
5
|
completed: string;
|
|
@@ -16,8 +17,8 @@ export declare function applyTerminalChunk(state: TerminalBufferState, chunk: st
|
|
|
16
17
|
export declare function terminalDisplayText(state: TerminalBufferState): string;
|
|
17
18
|
/** Resolved limits for {@link trimTerminalState}. `0` means unlimited. */
|
|
18
19
|
export interface TerminalBufferLimits {
|
|
19
|
-
maxLines:
|
|
20
|
-
maxChars:
|
|
20
|
+
maxLines: MaxLines;
|
|
21
|
+
maxChars: MaxChars;
|
|
21
22
|
}
|
|
22
23
|
/** @internal Count newline-terminated rows in `completed`. */
|
|
23
24
|
export declare function countCompletedLines(completed: string): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-terminal-buffer.d.ts","sourceRoot":"","sources":["../../src/terminal/create-terminal-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAA0B,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"create-terminal-buffer.d.ts","sourceRoot":"","sources":["../../src/terminal/create-terminal-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAA0B,MAAM,MAAM,CAAC;AAC/D,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,QAAQ,EACd,MAAM,6BAA6B,CAAC;AAGrC,6EAA6E;AAC7E,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,MAAM,GACZ,mBAAmB,CAgBrB;AAED,gBAAgB;AAChB,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,CAEtE;AAED,0EAA0E;AAC1E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,8DAA8D;AAC9D,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAW7D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,MAAM,CAcR;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,mBAAmB,EAC1B,MAAM,EAAE,oBAAoB,GAC3B,mBAAmB,CAuBrB;AAED,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;CACpC;AAED,mFAAmF;AACnF,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,uDAAuD;AACvD,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,qBAAqB,CAIzE,CAAC;AAkBJ;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,UAAU,CAAC,MAAM,CAAC,EAC5B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,cAAc,CAahB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payload accepted by {@link SerialSession.send$}.
|
|
3
|
+
*
|
|
4
|
+
* Strings are UTF-8 encoded via a shared `TextEncoder`; `Uint8Array` values
|
|
5
|
+
* are passed through unchanged.
|
|
6
|
+
*/
|
|
7
|
+
export type SerialPayload = string | Uint8Array;
|
|
8
|
+
/**
|
|
9
|
+
* Connection parameters passed to `port.open` when opening a serial port.
|
|
10
|
+
*
|
|
11
|
+
* Derived from the W3C {@link SerialOptions} type. Excludes
|
|
12
|
+
* {@link SerialSessionOptions.filters}, which apply only to
|
|
13
|
+
* `navigator.serial.requestPort`.
|
|
14
|
+
*
|
|
15
|
+
* @see {@link SerialOptions}
|
|
16
|
+
*/
|
|
17
|
+
export type SerialConnectionOptions = Pick<SerialOptions, 'baudRate' | 'dataBits' | 'stopBits' | 'parity' | 'bufferSize' | 'flowControl'>;
|
|
18
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,aAAa,EACb,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,YAAY,GAAG,aAAa,CAC/E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gurezo/web-serial-rxjs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "RxJS-based utilities for the Web Serial API, usable from Angular, React, Svelte, and Vanilla JavaScript/TypeScript.",
|
|
5
5
|
"author": "Akihiko Kigure <akihiko.kigure@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { SerialSessionState } from './serial-session-state';
|
|
3
|
-
/**
|
|
4
|
-
* Internal state machine that backs {@link SerialSession.state$}.
|
|
5
|
-
*
|
|
6
|
-
* The machine is deliberately kept as an internal module (not exported
|
|
7
|
-
* from the package) because the public surface is only the Observable.
|
|
8
|
-
* Sub-issues of #199 (read pump / send queue / errors) drive transitions
|
|
9
|
-
* through the dedicated `to*` methods below instead of mutating a shared
|
|
10
|
-
* `BehaviorSubject` directly.
|
|
11
|
-
*
|
|
12
|
-
* Design notes:
|
|
13
|
-
*
|
|
14
|
-
* - Invalid transitions are silently rejected so that the `state$` stream
|
|
15
|
-
* never emits a state that violates the lifecycle contract. A
|
|
16
|
-
* `console.warn` is emitted in development builds to aid debugging.
|
|
17
|
-
* - `unsupported` is terminal: once entered (during construction when
|
|
18
|
-
* `navigator.serial` is missing), the machine refuses every further
|
|
19
|
-
* transition.
|
|
20
|
-
* - `state$` is derived from a {@link BehaviorSubject} so late subscribers
|
|
21
|
-
* still receive the current state on subscription.
|
|
22
|
-
*
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
export declare class SessionStateMachine {
|
|
26
|
-
private readonly subject;
|
|
27
|
-
constructor(initial?: SerialSessionState);
|
|
28
|
-
get current(): SerialSessionState;
|
|
29
|
-
get state$(): Observable<SerialSessionState>;
|
|
30
|
-
toConnecting(): boolean;
|
|
31
|
-
toConnected(): boolean;
|
|
32
|
-
toDisconnecting(): boolean;
|
|
33
|
-
toIdle(): boolean;
|
|
34
|
-
toError(): boolean;
|
|
35
|
-
toUnsupported(): boolean;
|
|
36
|
-
toDisposed(): boolean;
|
|
37
|
-
complete(): void;
|
|
38
|
-
private transition;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=session-state-machine.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-state-machine.d.ts","sourceRoot":"","sources":["../../src/session/session-state-machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,UAAU,EAAE,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAsC5D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsC;gBAElD,OAAO,GAAE,kBAA4C;IAIjE,IAAI,OAAO,IAAI,kBAAkB,CAEhC;IAED,IAAI,MAAM,IAAI,UAAU,CAAC,kBAAkB,CAAC,CAE3C;IAED,YAAY,IAAI,OAAO;IAIvB,WAAW,IAAI,OAAO;IAItB,eAAe,IAAI,OAAO;IAI1B,MAAM,IAAI,OAAO;IAIjB,OAAO,IAAI,OAAO;IAIlB,aAAa,IAAI,OAAO;IAIxB,UAAU,IAAI,OAAO;IAIrB,QAAQ,IAAI,IAAI;IAIhB,OAAO,CAAC,UAAU;CAoBnB"}
|