@gurezo/web-serial-rxjs 2.3.5 → 2.4.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 +43 -0
- package/dist/errors/serial-error-code.d.ts.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +447 -84
- package/dist/index.mjs.map +4 -4
- 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 +2 -1
- package/dist/session/create-serial-session.d.ts.map +1 -1
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/internal/line-buffer.d.ts +24 -2
- package/dist/session/internal/line-buffer.d.ts.map +1 -1
- package/dist/session/internal/receive-replay-buffer.d.ts +37 -0
- package/dist/session/internal/receive-replay-buffer.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 +42 -1
- package/dist/session/serial-session-options.d.ts.map +1 -1
- package/dist/session/serial-session-state.d.ts +1 -0
- package/dist/session/serial-session-state.d.ts.map +1 -1
- package/dist/session/serial-session.d.ts +35 -2
- package/dist/session/serial-session.d.ts.map +1 -1
- package/dist/session/session-state-machine.d.ts +1 -0
- package/dist/session/session-state-machine.d.ts.map +1 -1
- package/dist/terminal/create-terminal-buffer.d.ts +47 -1
- package/dist/terminal/create-terminal-buffer.d.ts.map +1 -1
- package/package.json +2 -1
- package/dist/index.js +0 -724
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { TerminalBufferOptions } from '../terminal/create-terminal-buffer';
|
|
2
|
+
import { type LineBufferOptions } from './internal/line-buffer';
|
|
1
3
|
/**
|
|
2
4
|
* Options for creating a {@link SerialSession} via {@link createSerialSession}.
|
|
3
5
|
*
|
|
@@ -76,11 +78,29 @@ export interface SerialSessionOptions {
|
|
|
76
78
|
* @default `{ enabled: false, bufferSize: 512 }` (see {@link DEFAULT_SERIAL_SESSION_OPTIONS})
|
|
77
79
|
*/
|
|
78
80
|
receiveReplay?: SerialSessionReceiveReplayOptions;
|
|
81
|
+
/**
|
|
82
|
+
* Limits for {@link SerialSession.terminalText$} display memory. Oldest
|
|
83
|
+
* completed lines and leading characters are dropped when exceeded.
|
|
84
|
+
*
|
|
85
|
+
* @default `{ maxLines: 10000, maxChars: 1048576 }` (see {@link DEFAULT_SERIAL_SESSION_OPTIONS})
|
|
86
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/370 | Issue #370}
|
|
87
|
+
*/
|
|
88
|
+
terminalBuffer?: TerminalBufferOptions;
|
|
89
|
+
/**
|
|
90
|
+
* Limits for the incomplete line tail held by {@link SerialSession.lines$}
|
|
91
|
+
* framing. When exceeded, leading characters are discarded and a non-fatal
|
|
92
|
+
* {@link SerialErrorCode.LINE_BUFFER_OVERFLOW} is emitted on {@link SerialSession.errors$}.
|
|
93
|
+
*
|
|
94
|
+
* @default `{ maxChars: 1048576 }` (see {@link DEFAULT_SERIAL_SESSION_OPTIONS})
|
|
95
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/371 | Issue #371}
|
|
96
|
+
*/
|
|
97
|
+
lineBuffer?: LineBufferOptions;
|
|
79
98
|
}
|
|
80
99
|
/**
|
|
81
100
|
* Options for {@link SerialSessionOptions.receiveReplay}.
|
|
82
101
|
*
|
|
83
102
|
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/265 | Issue #265}
|
|
103
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/372 | Issue #372}
|
|
84
104
|
*/
|
|
85
105
|
export interface SerialSessionReceiveReplayOptions {
|
|
86
106
|
/**
|
|
@@ -97,14 +117,35 @@ export interface SerialSessionReceiveReplayOptions {
|
|
|
97
117
|
* @default 512
|
|
98
118
|
*/
|
|
99
119
|
bufferSize?: number;
|
|
120
|
+
/**
|
|
121
|
+
* Maximum total characters retained across buffered replay chunks for the
|
|
122
|
+
* active connection. When exceeded, oldest chunks are discarded. `0` means
|
|
123
|
+
* unlimited (only `bufferSize` applies).
|
|
124
|
+
*
|
|
125
|
+
* @default 0
|
|
126
|
+
*/
|
|
127
|
+
maxChars?: number;
|
|
100
128
|
}
|
|
129
|
+
/** Maximum allowed {@link SerialSessionReceiveReplayOptions.bufferSize}. */
|
|
130
|
+
export declare const MAX_RECEIVE_REPLAY_BUFFER_SIZE = 65536;
|
|
131
|
+
/** Maximum allowed {@link SerialSessionReceiveReplayOptions.maxChars}. */
|
|
132
|
+
export declare const MAX_RECEIVE_REPLAY_MAX_CHARS = 1048576;
|
|
133
|
+
/**
|
|
134
|
+
* Merge and validate {@link SerialSessionReceiveReplayOptions}.
|
|
135
|
+
*
|
|
136
|
+
* @throws {@link SerialError} with {@link SerialErrorCode.INVALID_RECEIVE_REPLAY_OPTIONS}
|
|
137
|
+
* when `bufferSize` or `maxChars` are out of range.
|
|
138
|
+
*/
|
|
139
|
+
export declare function resolveReceiveReplayOptions(options?: SerialSessionReceiveReplayOptions): Required<SerialSessionReceiveReplayOptions>;
|
|
101
140
|
/**
|
|
102
141
|
* Default values applied to omitted {@link SerialSessionOptions} fields.
|
|
103
142
|
*
|
|
104
143
|
* @internal
|
|
105
144
|
*/
|
|
106
|
-
export declare const DEFAULT_SERIAL_SESSION_OPTIONS: Required<Omit<SerialSessionOptions, 'filters' | 'receiveReplay'>> & {
|
|
145
|
+
export declare const DEFAULT_SERIAL_SESSION_OPTIONS: Required<Omit<SerialSessionOptions, 'filters' | 'receiveReplay' | 'terminalBuffer' | 'lineBuffer'>> & {
|
|
107
146
|
filters?: SerialPortFilter[];
|
|
108
147
|
receiveReplay: Required<SerialSessionReceiveReplayOptions>;
|
|
148
|
+
terminalBuffer: Required<TerminalBufferOptions>;
|
|
149
|
+
lineBuffer: Required<LineBufferOptions>;
|
|
109
150
|
};
|
|
110
151
|
//# 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;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAEjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAEjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;IAEjC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAElC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAE7B;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"serial-session-options.d.ts","sourceRoot":"","sources":["../../src/session/serial-session-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAIhF,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAEjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAEjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,G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disconnecting";
|
|
27
27
|
readonly Unsupported: "unsupported";
|
|
28
28
|
readonly Error: "error";
|
|
29
|
+
readonly Disposed: "disposed";
|
|
29
30
|
};
|
|
30
31
|
/**
|
|
31
32
|
* String union of allowed {@link SerialSessionState} runtime values
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serial-session-state.d.ts","sourceRoot":"","sources":["../../src/session/serial-session-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"serial-session-state.d.ts","sourceRoot":"","sources":["../../src/session/serial-session-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;CAQrB,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -51,11 +51,37 @@ export interface SerialSession {
|
|
|
51
51
|
/**
|
|
52
52
|
* Close the active serial port and stop the internal read pump.
|
|
53
53
|
*
|
|
54
|
-
* Safe to call when already disconnected
|
|
54
|
+
* Safe to call when already disconnected or while a disconnect is already
|
|
55
|
+
* in progress. When called during `'connecting'`, cancels the in-flight
|
|
56
|
+
* `connect$()` (closes any opened port) and returns the session to
|
|
57
|
+
* `'idle'` without reaching `'connected'`.
|
|
55
58
|
*
|
|
56
59
|
* @returns An Observable that completes when the port is fully closed.
|
|
57
60
|
*/
|
|
58
61
|
disconnect$(): Observable<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Permanently tear down the session and complete all observables.
|
|
64
|
+
*
|
|
65
|
+
* Unlike {@link disconnect$}, which returns the session to `'idle'` for
|
|
66
|
+
* reuse, `dispose$` closes any active connection, releases internal
|
|
67
|
+
* resources, emits `'disposed'` on {@link state$}, and completes every
|
|
68
|
+
* session stream. After disposal, {@link connect$} and {@link send$}
|
|
69
|
+
* fail with {@link SerialErrorCode.SESSION_DISPOSED}; create a new
|
|
70
|
+
* session instead of reusing this instance.
|
|
71
|
+
*
|
|
72
|
+
* Safe to call multiple times; subsequent calls complete immediately.
|
|
73
|
+
*
|
|
74
|
+
* @returns An Observable that completes when disposal has finished.
|
|
75
|
+
*
|
|
76
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/373 | Issue #373}
|
|
77
|
+
*/
|
|
78
|
+
dispose$(): Observable<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Alias for {@link dispose$}.
|
|
81
|
+
*
|
|
82
|
+
* @returns An Observable that completes when disposal has finished.
|
|
83
|
+
*/
|
|
84
|
+
destroy$(): Observable<void>;
|
|
59
85
|
/**
|
|
60
86
|
* Reactive session lifecycle state.
|
|
61
87
|
*
|
|
@@ -142,6 +168,8 @@ export interface SerialSession {
|
|
|
142
168
|
* This stream collapses carriage-return redraws (`\r`) and keeps normal
|
|
143
169
|
* newline behavior (`\n`, `\r\n`) so apps can bind terminal-like output
|
|
144
170
|
* directly without wrapping {@link createTerminalBuffer} in every consumer.
|
|
171
|
+
* By default, retains at most 10,000 completed lines and 1,048,576
|
|
172
|
+
* characters; configure via {@link SerialSessionOptions.terminalBuffer}.
|
|
145
173
|
*
|
|
146
174
|
* Equivalent behavior:
|
|
147
175
|
*
|
|
@@ -170,11 +198,16 @@ export interface SerialSession {
|
|
|
170
198
|
* rendering terminal text, prefer {@link terminalText$}.
|
|
171
199
|
*
|
|
172
200
|
* A trailing fragment without a line terminator is buffered until a later
|
|
173
|
-
* chunk completes a line, or discarded on disconnect.
|
|
201
|
+
* chunk completes a line, or discarded on disconnect. The incomplete tail is
|
|
202
|
+
* bounded by {@link SerialSessionOptions.lineBuffer} `maxChars` (default
|
|
203
|
+
* 1,048,576); when exceeded, leading characters are discarded and a
|
|
204
|
+
* non-fatal {@link SerialErrorCode.LINE_BUFFER_OVERFLOW} is emitted on
|
|
205
|
+
* {@link errors$}. Pass `{ maxChars: 0 }` for unlimited growth. It is **not**
|
|
174
206
|
* subscription-lazy: the same framing runs whenever the read pump is active,
|
|
175
207
|
* independent of subscribers.
|
|
176
208
|
*
|
|
177
209
|
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/273 | Issue #273}
|
|
210
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/371 | Issue #371}
|
|
178
211
|
*/
|
|
179
212
|
readonly lines$: Observable<string>;
|
|
180
213
|
/**
|
|
@@ -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
|
|
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;I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session/session-state-machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,UAAU,EAAE,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;
|
|
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"}
|
|
@@ -14,6 +14,27 @@ export interface TerminalBufferState {
|
|
|
14
14
|
export declare function applyTerminalChunk(state: TerminalBufferState, chunk: string): TerminalBufferState;
|
|
15
15
|
/** @internal */
|
|
16
16
|
export declare function terminalDisplayText(state: TerminalBufferState): string;
|
|
17
|
+
/** Resolved limits for {@link trimTerminalState}. `0` means unlimited. */
|
|
18
|
+
export interface TerminalBufferLimits {
|
|
19
|
+
maxLines: number;
|
|
20
|
+
maxChars: number;
|
|
21
|
+
}
|
|
22
|
+
/** @internal Count newline-terminated rows in `completed`. */
|
|
23
|
+
export declare function countCompletedLines(completed: string): number;
|
|
24
|
+
/**
|
|
25
|
+
* Drops oldest completed lines when `maxLines` is exceeded.
|
|
26
|
+
*
|
|
27
|
+
* @internal Exported for unit tests.
|
|
28
|
+
*/
|
|
29
|
+
export declare function trimCompletedByMaxLines(completed: string, maxLines: number): string;
|
|
30
|
+
/**
|
|
31
|
+
* Trims {@link TerminalBufferState} to respect memory limits. Oldest
|
|
32
|
+
* `completed` content is removed first; `currentLine` is trimmed only when
|
|
33
|
+
* the display text still exceeds `maxChars` after `completed` is empty.
|
|
34
|
+
*
|
|
35
|
+
* @internal Exported for unit tests.
|
|
36
|
+
*/
|
|
37
|
+
export declare function trimTerminalState(state: TerminalBufferState, limits: TerminalBufferLimits): TerminalBufferState;
|
|
17
38
|
export interface TerminalBuffer {
|
|
18
39
|
/**
|
|
19
40
|
* Cumulative text suitable for terminal-style display: completed lines plus
|
|
@@ -21,10 +42,35 @@ export interface TerminalBuffer {
|
|
|
21
42
|
*/
|
|
22
43
|
readonly text$: Observable<string>;
|
|
23
44
|
}
|
|
45
|
+
/** Options for {@link createTerminalBuffer} memory limits. `0` means unlimited. */
|
|
46
|
+
export interface TerminalBufferOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Maximum number of completed lines to retain in the display buffer.
|
|
49
|
+
*
|
|
50
|
+
* @default 10000
|
|
51
|
+
*/
|
|
52
|
+
maxLines?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Maximum total characters in the cumulative display text
|
|
55
|
+
* (`completed` + `currentLine`). Oldest content is dropped first.
|
|
56
|
+
*
|
|
57
|
+
* @default 1048576
|
|
58
|
+
*/
|
|
59
|
+
maxChars?: number;
|
|
60
|
+
}
|
|
61
|
+
/** Default limits applied when options are omitted. */
|
|
62
|
+
export declare const DEFAULT_TERMINAL_BUFFER_OPTIONS: Required<TerminalBufferOptions>;
|
|
24
63
|
/**
|
|
25
64
|
* Builds a terminal-oriented text stream from {@link SerialSession.receive$} (or any
|
|
26
65
|
* `Observable<string>` of decoded chunks). Uses internal buffering so callers need not
|
|
27
66
|
* implement carriage-return collapse themselves.
|
|
67
|
+
*
|
|
68
|
+
* By default, retains at most {@link DEFAULT_TERMINAL_BUFFER_OPTIONS.maxLines}
|
|
69
|
+
* completed lines and {@link DEFAULT_TERMINAL_BUFFER_OPTIONS.maxChars} characters
|
|
70
|
+
* so long-running sessions do not grow memory without bound. Pass `0` for either
|
|
71
|
+
* limit to disable that constraint.
|
|
72
|
+
*
|
|
73
|
+
* @see {@link https://github.com/gurezo/web-serial-rxjs/issues/370 | Issue #370}
|
|
28
74
|
*/
|
|
29
|
-
export declare function createTerminalBuffer(receive$: Observable<string
|
|
75
|
+
export declare function createTerminalBuffer(receive$: Observable<string>, options?: TerminalBufferOptions): TerminalBuffer;
|
|
30
76
|
//# sourceMappingURL=create-terminal-buffer.d.ts.map
|
|
@@ -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;AAG/D,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,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;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;AAgBJ;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,UAAU,CAAC,MAAM,CAAC,EAC5B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,cAAc,CAahB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gurezo/web-serial-rxjs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.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",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"build:bundle": "node esbuild.config.mjs",
|
|
27
27
|
"build:copy-files": "cp ../../LICENSE . 2>/dev/null || true",
|
|
28
28
|
"build:cleanup": "rm -rf dist/packages dist/package.json 2>/dev/null || true",
|
|
29
|
+
"verify:dist": "node scripts/verify-dist.mjs",
|
|
29
30
|
"clean": "rm -rf dist",
|
|
30
31
|
"prepublishOnly": "pnpm run build"
|
|
31
32
|
},
|