@gurezo/web-serial-rxjs 0.2.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.ja.md +21 -107
  2. package/README.md +23 -127
  3. package/dist/errors/serial-error-code.d.ts +7 -0
  4. package/dist/errors/serial-error-code.d.ts.map +1 -1
  5. package/dist/index.d.ts +31 -32
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +459 -673
  8. package/dist/index.mjs +459 -673
  9. package/dist/index.mjs.map +4 -4
  10. package/dist/session/create-serial-session.d.ts +49 -0
  11. package/dist/session/create-serial-session.d.ts.map +1 -0
  12. package/dist/session/index.d.ts +5 -0
  13. package/dist/session/index.d.ts.map +1 -0
  14. package/dist/session/internal/build-request-options.d.ts +18 -0
  15. package/dist/session/internal/build-request-options.d.ts.map +1 -0
  16. package/dist/session/internal/has-web-serial-support.d.ts +12 -0
  17. package/dist/session/internal/has-web-serial-support.d.ts.map +1 -0
  18. package/dist/session/internal/line-buffer.d.ts +14 -0
  19. package/dist/session/internal/line-buffer.d.ts.map +1 -0
  20. package/dist/session/normalize-serial-error.d.ts +55 -0
  21. package/dist/session/normalize-serial-error.d.ts.map +1 -0
  22. package/dist/session/read-pump.d.ts +74 -0
  23. package/dist/session/read-pump.d.ts.map +1 -0
  24. package/dist/session/send-queue.d.ts +58 -0
  25. package/dist/session/send-queue.d.ts.map +1 -0
  26. package/dist/session/serial-session-options.d.ts +80 -0
  27. package/dist/session/serial-session-options.d.ts.map +1 -0
  28. package/dist/session/serial-session-state.d.ts +35 -0
  29. package/dist/session/serial-session-state.d.ts.map +1 -0
  30. package/dist/session/serial-session.d.ts +143 -0
  31. package/dist/session/serial-session.d.ts.map +1 -0
  32. package/dist/session/session-state-machine.d.ts +39 -0
  33. package/dist/session/session-state-machine.d.ts.map +1 -0
  34. package/package.json +1 -5
  35. package/web-serial-rxjs-icon.png +0 -0
  36. package/dist/browser/browser-detection.d.ts +0 -104
  37. package/dist/browser/browser-detection.d.ts.map +0 -1
  38. package/dist/browser/browser-support.d.ts +0 -57
  39. package/dist/browser/browser-support.d.ts.map +0 -1
  40. package/dist/client/index.d.ts +0 -283
  41. package/dist/client/index.d.ts.map +0 -1
  42. package/dist/client/serial-client.d.ts +0 -137
  43. package/dist/client/serial-client.d.ts.map +0 -1
  44. package/dist/filters/build-request-options.d.ts +0 -42
  45. package/dist/filters/build-request-options.d.ts.map +0 -1
  46. package/dist/io/observable-to-writable.d.ts +0 -65
  47. package/dist/io/observable-to-writable.d.ts.map +0 -1
  48. package/dist/io/readable-to-observable.d.ts +0 -44
  49. package/dist/io/readable-to-observable.d.ts.map +0 -1
  50. package/dist/lib/web-serial-rxjs.d.ts +0 -7
  51. package/dist/lib/web-serial-rxjs.d.ts.map +0 -1
  52. package/dist/shell/create-shell-client.d.ts +0 -17
  53. package/dist/shell/create-shell-client.d.ts.map +0 -1
  54. package/dist/shell/index.d.ts +0 -2
  55. package/dist/shell/index.d.ts.map +0 -1
  56. package/dist/types/options.d.ts +0 -107
  57. package/dist/types/options.d.ts.map +0 -1
package/README.ja.md CHANGED
@@ -1,58 +1,15 @@
1
- # web-serial-rxjs
1
+ # @gurezo/web-serial-rxjs
2
2
 
3
- <p align="center">
4
- <img src="https://raw.githubusercontent.com/gurezo/web-serial-rxjs/main/assets/icon/web-serial-rxjs-icon.png" alt="web-serial-rxjs プロジェクトアイコン" width="512" />
5
- </p>
6
-
7
- Web Serial API を RxJS ベースのリアクティブなラッパーで提供する TypeScript ライブラリです。Web アプリケーションでシリアルポート通信を簡単に実現できます。
8
-
9
- ## 目次
10
-
11
- - [機能](#機能)
12
- - [対応フレームワーク](#対応フレームワーク)
13
- - [ブラウザサポート](#ブラウザサポート)
14
- - [インストール](#インストール)
15
- - [ドキュメント](#ドキュメント)
16
- - [サンプル](#サンプル)
17
- - [プロジェクトアイコンについて](#プロジェクトアイコンについて)
18
- - [開発とリリース戦略](#開発とリリース戦略)
19
- - [貢献](#貢献)
20
- - [ライセンス](#ライセンス)
21
- - [リンク](#リンク)
22
-
23
- ## 機能
24
-
25
- - **RxJS ベースのリアクティブ API**: RxJS Observables を活用したリアクティブなシリアルポート通信
26
- - **テキスト向け API**: `getReadStreamAsText()` と `writeText()` で手動のエンコード/デコードを不要化
27
- - **シェルユーティリティ層**: `createShellClient()` でコマンド実行とプロンプト待ちのワークフローを簡潔化
28
- - **TypeScript サポート**: 完全な TypeScript 型定義を含む
29
- - **ブラウザ検出**: ブラウザサポートの検出とエラーハンドリング機能を内蔵
30
- - **エラーハンドリング**: カスタムエラークラスとエラーコードによる包括的なエラーハンドリング
31
- - **フレームワーク非依存**: 任意の JavaScript/TypeScript フレームワークまたはバニラ JavaScript で使用可能
32
-
33
- ## 対応フレームワーク
34
-
35
- このライブラリはフレームワーク非依存で、以下の環境で利用できます。
36
-
37
- - Angular
38
- - React
39
- - Svelte
40
- - Vanilla JavaScript / TypeScript
3
+ Web Serial API を最小限の Session 指向 RxJS 表面でラップする TypeScript ライブラリです。v2 では単一の `SerialSession` を公開し、`state$` / `isConnected$` / `receive$` / `lines$` / `errors$` を購読するだけで UI を駆動できます。read loop や送信キューの自前実装は不要です。
41
4
 
42
5
  ## ブラウザサポート
43
6
 
44
- Web Serial API は現在、Chromium ベースのブラウザでのみサポートされています:
7
+ Web Serial API は **Chromium 系**のブラウザ(**Chrome** 89+、**Edge** 89+、**Opera** 75+)でのみ利用できます。
45
8
 
46
- - **Chrome** 89+
47
- - **Edge** 89+
48
- - **Opera** 75+
49
-
50
- このライブラリには、使用前に Web Serial API のサポートを確認するためのブラウザ検出ユーティリティが含まれています。
9
+ `connect$` の前の feature detection には `SerialSession.isBrowserSupported()`(同期的に `boolean`)を使います。
51
10
 
52
11
  ## インストール
53
12
 
54
- npm または pnpm を使用してパッケージをインストールします:
55
-
56
13
  ```bash
57
14
  npm install @gurezo/web-serial-rxjs
58
15
  # または
@@ -61,7 +18,7 @@ pnpm add @gurezo/web-serial-rxjs
61
18
 
62
19
  ### ピア依存関係
63
20
 
64
- このライブラリは RxJS をピア依存関係として必要とします:
21
+ **RxJS** `^7.8.0` をピア依存関係として必要とします。
65
22
 
66
23
  ```bash
67
24
  npm install rxjs
@@ -69,71 +26,28 @@ npm install rxjs
69
26
  pnpm add rxjs
70
27
  ```
71
28
 
72
- **最小要件バージョン**: RxJS ^7.8.0
73
-
74
- ## ドキュメント
75
-
76
- - **[クイックスタート](docs/QUICK_START.ja.md)** - 基本的な例と使用方法で始める
77
- - **[API リファレンス](docs/API_REFERENCE.ja.md)** - 詳細な説明を含む完全な API ドキュメント
78
- - **[高度な使用方法](docs/ADVANCED_USAGE.ja.md)** - 高度なパターン、ストリーム処理、エラー回復
79
-
80
- ## サンプル
81
-
82
- 以下の環境向けのサンプルを用意しています。
29
+ ## 次に読むもの
83
30
 
84
- - **[Angular](https://github.com/gurezo/web-serial-rxjs/tree/main/apps/example-angular)** - Service を使用した Angular の例
85
- - **[React](https://github.com/gurezo/web-serial-rxjs/tree/main/apps/example-react)** - カスタムフック(`useSerialClient`)を使用した React の例
86
- - **[Svelte](https://github.com/gurezo/web-serial-rxjs/tree/main/apps/example-svelte)** - Svelte Store を使用した Svelte の例
87
- - **[Vanilla JavaScript](https://github.com/gurezo/web-serial-rxjs/tree/main/apps/example-vanilla-js)** - バニラ JavaScript での基本的な使用方法
88
- - **[Vanilla TypeScript](https://github.com/gurezo/web-serial-rxjs/tree/main/apps/example-vanilla-ts)** - RxJS を使用した TypeScript の例
89
- - **[Vue](https://github.com/gurezo/web-serial-rxjs/tree/main/apps/example-vue)** - Composition API を使用した Vue 3 の例
31
+ - **v2 の全体像**(機能一覧、`SerialSession` 早見表、`SerialSessionState`、最小サンプル): [SerialSession(v2)の概要](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/OVERVIEW.ja.md)([English](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/OVERVIEW.md))
32
+ - 最短でポートを開く手順: [クイックスタート](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/QUICK_START.ja.md)
90
33
 
91
- 各例には、セットアップと使用方法の説明を含む README が含まれています。
92
-
93
- ## プロジェクトアイコンについて
94
-
95
- このプロジェクトのアイコンには、[RxJS](https://rxjs.dev/) のロゴから着想を得たデザインに、
96
- Web Serial を表すシリアルコネクタのモチーフを組み合わせたものを使用しています。
97
-
98
- このアイコンは、本ライブラリが Web Serial API を RxJS ベースで扱うための
99
- ライブラリであることを示す目的でのみ使用しています。
100
-
101
- 本プロジェクトは **[ReactiveX](http://reactivex.io/) / [RxJS](https://rxjs.dev/) 公式とは関係のない独立したオープンソースプロジェクト** であり、
102
- 公式な提携・承認・スポンサー関係はありません。
103
-
104
- ## 開発とリリース戦略
105
-
106
- このプロジェクトは**trunk-based開発**アプローチに従います:
107
-
108
- - **`main`ブランチ**: 常にリリース可能な状態
109
- - **短命ブランチ**: `feature/*`, `fix/*`, `docs/*` はプルリクエスト用
110
- - **リリース**: ブランチではなくGitタグ(例: `v1.0.0`)で管理
111
- - **バージョン保守**: 複数のメジャーバージョンを保守する必要がある場合のみ `release/v*` ブランチを追加
112
-
113
- 詳細な貢献ガイドラインについては、[CONTRIBUTING.ja.md](https://github.com/gurezo/web-serial-rxjs/blob/main/CONTRIBUTING.ja.md) を参照してください。
114
-
115
- 詳細なリリース手順については、[RELEASING.ja.md](https://github.com/gurezo/web-serial-rxjs/blob/main/RELEASING.ja.md) を参照してください。
116
-
117
- ## 貢献
118
-
119
- 貢献を歓迎します!詳細については、[貢献ガイド](https://github.com/gurezo/web-serial-rxjs/blob/main/CONTRIBUTING.ja.md)を参照してください:
120
-
121
- - 開発環境のセットアップ
122
- - コードスタイルガイドライン
123
- - コミットメッセージの規約
124
- - プルリクエストのプロセス
125
- - リリースプロセス
126
-
127
- 英語版の貢献ガイドは [CONTRIBUTING.md](https://github.com/gurezo/web-serial-rxjs/blob/main/CONTRIBUTING.md) を参照してください。
34
+ ## ドキュメント
128
35
 
129
- リリース手順については、[RELEASING.ja.md](https://github.com/gurezo/web-serial-rxjs/blob/main/RELEASING.ja.md)(または英語版は [RELEASING.md](https://github.com/gurezo/web-serial-rxjs/blob/main/RELEASING.md))を参照してください。
36
+ | ドキュメント | 用途 |
37
+ | --- | --- |
38
+ | [全体像](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/OVERVIEW.ja.md) | 機能と v2 `SerialSession` / `SerialSessionState` の対応表 |
39
+ | [クイックスタート](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/QUICK_START.ja.md) | ポートを開いて購読までを最短で |
40
+ | [高度な使用方法](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/ADVANCED_USAGE.ja.md) | 行フレーミング、擬似リクエスト/レス、リカバリ |
41
+ | [API リファレンス](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/API_REFERENCE.ja.md) | オプション、`SerialError`、型の詳細 |
42
+ | [v1 → v2 マイグレーション](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/MIGRATION_V2.ja.md) | 廃止された v1 API の置き換え |
43
+ | **リポジトリ [README](https://github.com/gurezo/web-serial-rxjs/blob/main/README.ja.md)** | モノレポ構成、**`apps/` のサンプル**、貢献、MCP、プロジェクトアイコン |
130
44
 
131
45
  ## ライセンス
132
46
 
133
- このプロジェクトは MIT ライセンスの下で公開されています。詳細は [LICENSE](https://github.com/gurezo/web-serial-rxjs/blob/main/LICENSE) ファイルを参照してください。
47
+ MIT。詳細はリポジトリの [LICENSE](https://github.com/gurezo/web-serial-rxjs/blob/main/LICENSE) を参照してください。
134
48
 
135
49
  ## リンク
136
50
 
137
- - **GitHub リポジトリ**: [https://github.com/gurezo/web-serial-rxjs](https://github.com/gurezo/web-serial-rxjs)
138
- - **イシュー**: [https://github.com/gurezo/web-serial-rxjs/issues](https://github.com/gurezo/web-serial-rxjs/issues)
139
- - **Web Serial API 仕様**: [https://wicg.github.io/serial/](https://wicg.github.io/serial/)
51
+ - **リポジトリ**: [github.com/gurezo/web-serial-rxjs](https://github.com/gurezo/web-serial-rxjs)
52
+ - **イシュー**: [github.com/gurezo/web-serial-rxjs/issues](https://github.com/gurezo/web-serial-rxjs/issues)
53
+ - **Web Serial API 仕様**: [wicg.github.io/serial](https://wicg.github.io/serial/)
package/README.md CHANGED
@@ -1,68 +1,24 @@
1
- # web-serial-rxjs
1
+ # @gurezo/web-serial-rxjs
2
2
 
3
- <p align="center">
4
- <img src="https://raw.githubusercontent.com/gurezo/web-serial-rxjs/main/assets/icon/web-serial-rxjs-icon.png" alt="web-serial-rxjs project icon" width="512" />
5
- </p>
3
+ A TypeScript library that wraps the Web Serial API with a minimal, session-oriented RxJS surface. The v2 API exposes a single `SerialSession` so applications can drive their UI from `state$` + `isConnected$` + `receive$` + `lines$` + `errors$`, without rebuilding read loops or send queues themselves.
6
4
 
7
- A TypeScript library that provides a reactive RxJS-based wrapper for the Web Serial API, enabling easy serial port communication in web applications.
5
+ ## Browser support
8
6
 
9
- ## Table of Contents
7
+ The Web Serial API is only available in **Chromium-based** browsers: **Chrome** 89+, **Edge** 89+, **Opera** 75+.
10
8
 
11
- - [Features](#features)
12
- - [Framework Support](#framework-support)
13
- - [Browser Support](#browser-support)
14
- - [Installation](#installation)
15
- - [Documentation](#documentation)
16
- - [Examples](#examples)
17
- - [Project Icon](#project-icon)
18
- - [AI Assistant (MCP)](#ai-assistant-mcp)
19
- - [Development and Release Strategy](#development-and-release-strategy)
20
- - [Contributing](#contributing)
21
- - [License](#license)
22
- - [Links](#links)
23
-
24
- ## Features
25
-
26
- - **RxJS-based reactive API**: Leverage the power of RxJS Observables for reactive serial port communication
27
- - **Text-friendly API**: Use `getReadStreamAsText()` and `writeText()` without manual encoding/decoding
28
- - **Shell utility layer**: Execute command/prompt workflows with `createShellClient()`
29
- - **TypeScript support**: Full TypeScript type definitions included
30
- - **Browser detection**: Built-in browser support detection and error handling
31
- - **Error handling**: Comprehensive error handling with custom error classes and error codes
32
- - **Framework agnostic**: Works with any JavaScript/TypeScript framework or vanilla JavaScript
33
-
34
- ## Framework Support
35
-
36
- This library is framework-agnostic and can be used with:
37
-
38
- - Angular
39
- - React
40
- - Svelte
41
- - Vanilla JavaScript / TypeScript
42
-
43
- ## Browser Support
44
-
45
- The Web Serial API is currently only supported in Chromium-based browsers:
46
-
47
- - **Chrome** 89+
48
- - **Edge** 89+
49
- - **Opera** 75+
50
-
51
- The library includes built-in browser detection utilities to check for Web Serial API support before attempting to use it.
9
+ `SerialSession.isBrowserSupported()` returns a synchronous `boolean` for feature detection before `connect$`.
52
10
 
53
11
  ## Installation
54
12
 
55
- Install the package using npm or pnpm:
56
-
57
13
  ```bash
58
14
  npm install @gurezo/web-serial-rxjs
59
15
  # or
60
16
  pnpm add @gurezo/web-serial-rxjs
61
17
  ```
62
18
 
63
- ### Peer Dependencies
19
+ ### Peer dependency
64
20
 
65
- This library requires RxJS as a peer dependency:
21
+ This library requires **RxJS** `^7.8.0` as a peer dependency:
66
22
 
67
23
  ```bash
68
24
  npm install rxjs
@@ -70,88 +26,28 @@ npm install rxjs
70
26
  pnpm add rxjs
71
27
  ```
72
28
 
73
- **Minimum required version**: RxJS ^7.8.0
74
-
75
- ## Documentation
76
-
77
- - **[Quick Start](docs/QUICK_START.md)** - Get started with basic examples and usage patterns
78
- - **[API Reference](docs/API_REFERENCE.md)** - Complete API documentation with detailed descriptions
79
- - **[Advanced Usage](docs/ADVANCED_USAGE.md)** - Advanced patterns, stream processing, and error recovery
80
-
81
- ## Examples
82
-
83
- Examples are available for the following environments:
84
-
85
- - **[Angular](https://github.com/gurezo/web-serial-rxjs/tree/main/apps/example-angular)** - Angular example using a Service
86
- - **[React](https://github.com/gurezo/web-serial-rxjs/tree/main/apps/example-react)** - React example with custom hook (`useSerialClient`)
87
- - **[Svelte](https://github.com/gurezo/web-serial-rxjs/tree/main/apps/example-svelte)** - Svelte example using Svelte Store
88
- - **[Vanilla JavaScript](https://github.com/gurezo/web-serial-rxjs/tree/main/apps/example-vanilla-js)** - Basic usage with vanilla JavaScript
89
- - **[Vanilla TypeScript](https://github.com/gurezo/web-serial-rxjs/tree/main/apps/example-vanilla-ts)** - TypeScript example with RxJS
90
- - **[Vue](https://github.com/gurezo/web-serial-rxjs/tree/main/apps/example-vue)** - Vue 3 example using Composition API
91
-
92
- Each example includes a README with setup and usage instructions.
93
-
94
- ## Project Icon
29
+ ## Where to go next
95
30
 
96
- The project icon includes a modified design inspired by the [RxJS](https://rxjs.dev/) logo,
97
- combined with a serial connector motif to represent Web Serial communication.
31
+ - Full **v2 API map** (features, `SerialSession` table, `SerialSessionState`, minimal example): [SerialSession (v2) overview](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/OVERVIEW.md) ([日本語](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/OVERVIEW.ja.md))
32
+ - Shortest path to an open port: [Quick Start](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/QUICK_START.md)
98
33
 
99
- The icon is used only to indicate that this library provides
100
- RxJS-based abstractions for the Web Serial API.
101
-
102
- This project is an independent open source project and is **not affiliated with,
103
- endorsed by, or sponsored by the [ReactiveX](http://reactivex.io/) or [RxJS](https://rxjs.dev/) project**.
104
-
105
- ## AI Assistant (MCP)
106
-
107
- This project includes [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server configuration for AI-assisted development. The following MCP servers are available:
108
-
109
- | Server | Purpose |
110
- | --------------- | -------------------------------------------------------------------------------------- |
111
- | **nx-mcp** | Nx workspace analysis, project graph, CI monitoring, and documentation |
112
- | **angular-cli** | Angular CLI tools for example-angular (code generation, documentation, best practices) |
113
- | **svelte** | Svelte/SvelteKit documentation and code analysis for example-svelte |
114
-
115
- **Configuration files:**
116
-
117
- - `.mcp.json` - Standard MCP configuration (Cursor, VS Code, Claude, etc.)
118
- - `.cursor/mcp.json` - Cursor-specific configuration
119
-
120
- To use MCP servers in Cursor, the configuration is automatically loaded from `.cursor/mcp.json`. For VS Code, add the MCP extension and configure it to use `.mcp.json`, or add the server definitions to your MCP settings.
121
-
122
- ## Development and Release Strategy
123
-
124
- This project follows a **trunk-based development** approach:
125
-
126
- - **`main` branch**: Always in a release-ready state
127
- - **Short-lived branches**: `feature/*`, `fix/*`, `docs/*` for pull requests
128
- - **Releases**: Managed via Git tags (e.g., `v1.0.0`), not branches
129
- - **Version maintenance**: `release/v*` branches are added only when needed for maintaining multiple major versions
130
-
131
- For detailed contribution guidelines, see [CONTRIBUTING.md](https://github.com/gurezo/web-serial-rxjs/blob/main/CONTRIBUTING.md).
132
-
133
- For detailed release instructions, see [RELEASING.md](https://github.com/gurezo/web-serial-rxjs/blob/main/RELEASING.md).
134
-
135
- ## Contributing
136
-
137
- We welcome contributions! Please see our [Contributing Guide](https://github.com/gurezo/web-serial-rxjs/blob/main/CONTRIBUTING.md) for details on:
138
-
139
- - Development setup
140
- - Code style guidelines
141
- - Commit message conventions
142
- - Pull request process
143
- - Release process
144
-
145
- For Japanese contributors, please see [CONTRIBUTING.ja.md](https://github.com/gurezo/web-serial-rxjs/blob/main/CONTRIBUTING.ja.md).
34
+ ## Documentation
146
35
 
147
- For release instructions, see [RELEASING.md](https://github.com/gurezo/web-serial-rxjs/blob/main/RELEASING.md) (or [RELEASING.ja.md](https://github.com/gurezo/web-serial-rxjs/blob/main/RELEASING.ja.md) for Japanese).
36
+ | Doc | Use it for |
37
+ | --- | --- |
38
+ | [Overview](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/OVERVIEW.md) | Features and the v2 `SerialSession` / `SerialSessionState` map |
39
+ | [Quick Start](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/QUICK_START.md) | Open a port and wire subscriptions end-to-end |
40
+ | [Advanced Usage](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/ADVANCED_USAGE.md) | Line framing, request/response-style flows, recovery |
41
+ | [API Reference](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/API_REFERENCE.md) | `SerialSessionOptions`, `SerialError`, and formal details |
42
+ | [v1 → v2 migration](https://github.com/gurezo/web-serial-rxjs/blob/main/packages/web-serial-rxjs/docs/MIGRATION_V2.md) | Replacing the removed v1 `SerialClient` / `ShellClient` API |
43
+ | [Repository README](https://github.com/gurezo/web-serial-rxjs/blob/main/README.md) | Monorepo layout, **examples** under `apps/`, contributing, MCP, and project icon |
148
44
 
149
45
  ## License
150
46
 
151
- This project is licensed under the MIT License - see the [LICENSE](https://github.com/gurezo/web-serial-rxjs/blob/main/LICENSE) file for details.
47
+ MIT see the [LICENSE](https://github.com/gurezo/web-serial-rxjs/blob/main/LICENSE) file in the repository.
152
48
 
153
49
  ## Links
154
50
 
155
- - **GitHub Repository**: [https://github.com/gurezo/web-serial-rxjs](https://github.com/gurezo/web-serial-rxjs)
156
- - **Issues**: [https://github.com/gurezo/web-serial-rxjs/issues](https://github.com/gurezo/web-serial-rxjs/issues)
157
- - **Web Serial API Specification**: [https://wicg.github.io/serial/](https://wicg.github.io/serial/)
51
+ - **Repository**: [github.com/gurezo/web-serial-rxjs](https://github.com/gurezo/web-serial-rxjs)
52
+ - **Issues**: [github.com/gurezo/web-serial-rxjs/issues](https://github.com/gurezo/web-serial-rxjs/issues)
53
+ - **Web Serial API (spec)**: [wicg.github.io/serial](https://wicg.github.io/serial/)
@@ -119,6 +119,13 @@ export declare enum SerialErrorCode {
119
119
  * to inform the user that the operation was cancelled.
120
120
  */
121
121
  OPERATION_CANCELLED = "OPERATION_CANCELLED",
122
+ /**
123
+ * Operation timed out before completion.
124
+ *
125
+ * This error occurs when an operation waits for a condition (for example, prompt
126
+ * detection) and the timeout period elapses first.
127
+ */
128
+ OPERATION_TIMEOUT = "OPERATION_TIMEOUT",
122
129
  /**
123
130
  * Unknown error occurred.
124
131
  *
@@ -1 +1 @@
1
- {"version":3,"file":"serial-error-code.d.ts","sourceRoot":"","sources":["../../src/errors/serial-error-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,oBAAY,eAAe;IACzB;;;;;;;;OAQG;IACH,qBAAqB,0BAA0B;IAE/C;;;;;;;;OAQG;IACH,kBAAkB,uBAAuB;IAEzC;;;;;;;OAOG;IACH,gBAAgB,qBAAqB;IAErC;;;;;;;OAOG;IACH,iBAAiB,sBAAsB;IAEvC;;;;;;;OAOG;IACH,aAAa,kBAAkB;IAE/B;;;;;;;OAOG;IACH,WAAW,gBAAgB;IAE3B;;;;;;;OAOG;IACH,YAAY,iBAAiB;IAE7B;;;;;;;;OAQG;IACH,eAAe,oBAAoB;IAEnC;;;;;;;OAOG;IACH,sBAAsB,2BAA2B;IAEjD;;;;;;;;OAQG;IACH,mBAAmB,wBAAwB;IAE3C;;;;;;;OAOG;IACH,OAAO,YAAY;CACpB"}
1
+ {"version":3,"file":"serial-error-code.d.ts","sourceRoot":"","sources":["../../src/errors/serial-error-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,oBAAY,eAAe;IACzB;;;;;;;;OAQG;IACH,qBAAqB,0BAA0B;IAE/C;;;;;;;;OAQG;IACH,kBAAkB,uBAAuB;IAEzC;;;;;;;OAOG;IACH,gBAAgB,qBAAqB;IAErC;;;;;;;OAOG;IACH,iBAAiB,sBAAsB;IAEvC;;;;;;;OAOG;IACH,aAAa,kBAAkB;IAE/B;;;;;;;OAOG;IACH,WAAW,gBAAgB;IAE3B;;;;;;;OAOG;IACH,YAAY,iBAAiB;IAE7B;;;;;;;;OAQG;IACH,eAAe,oBAAoB;IAEnC;;;;;;;OAOG;IACH,sBAAsB,2BAA2B;IAEjD;;;;;;;;OAQG;IACH,mBAAmB,wBAAwB;IAE3C;;;;;OAKG;IACH,iBAAiB,sBAAsB;IAEvC;;;;;;;OAOG;IACH,OAAO,YAAY;CACpB"}
package/dist/index.d.ts CHANGED
@@ -3,54 +3,53 @@
3
3
  *
4
4
  * # web-serial-rxjs
5
5
  *
6
- * A TypeScript library that provides a reactive RxJS-based wrapper for the Web Serial API,
7
- * enabling easy serial port communication in web applications.
6
+ * A TypeScript library that wraps the Web Serial API with a minimal,
7
+ * RxJS-based session surface.
8
8
  *
9
- * ## Features
9
+ * ## Public API (v2)
10
10
  *
11
- * - **RxJS-based reactive API**: Leverage the power of RxJS Observables for reactive serial port communication
12
- * - **TypeScript support**: Full TypeScript type definitions included
13
- * - **Browser detection**: Built-in browser support detection and error handling
14
- * - **Error handling**: Comprehensive error handling with custom error classes and error codes
15
- * - **Framework agnostic**: Works with any JavaScript/TypeScript framework or vanilla JavaScript
11
+ * The v2 public API intentionally exposes a single, session-oriented surface
12
+ * so that apps (Angular, Vue, React, Svelte, vanilla JS/TS) can drive their
13
+ * UI entirely from `state$` + `isConnected$` + `receive$` + `lines$` + `errors$` without rebuilding any
14
+ * state, read loops, or write queues themselves.
15
+ *
16
+ * - {@link createSerialSession} - factory for a {@link SerialSession}
17
+ * - {@link SerialSession} - the runtime interface
18
+ * - {@link SerialSessionOptions} - connection options
19
+ * - {@link SerialSessionState} - `state$` payload values (const + type)
20
+ * - {@link SerialError} / {@link SerialErrorCode} - unified error surface
16
21
  *
17
22
  * ## Browser Support
18
23
  *
19
- * The Web Serial API is currently only supported in Chromium-based browsers:
24
+ * The Web Serial API is only available in Chromium-based browsers:
25
+ *
20
26
  * - Chrome 89+
21
27
  * - Edge 89+
22
28
  * - Opera 75+
23
29
  *
30
+ * Use {@link SerialSession.isBrowserSupported} for a synchronous feature
31
+ * check before calling {@link SerialSession.connect$}.
32
+ *
24
33
  * @example
25
34
  * ```typescript
26
- * import { createSerialClient, isBrowserSupported } from '@gurezo/web-serial-rxjs';
35
+ * import { createSerialSession } from '@gurezo/web-serial-rxjs';
27
36
  *
28
- * // Check browser support
29
- * if (!isBrowserSupported()) {
30
- * console.error('Web Serial API is not supported in this browser');
31
- * return;
32
- * }
37
+ * const session = createSerialSession({ baudRate: 115200 });
33
38
  *
34
- * // Create a serial client
35
- * const client = createSerialClient({ baudRate: 9600 });
39
+ * if (!session.isBrowserSupported()) {
40
+ * console.error('Web Serial API is not supported in this browser');
41
+ * } else {
42
+ * session.state$.subscribe((state) => console.log('state:', state));
43
+ * session.receive$.subscribe((chunk) => console.log('rx:', chunk));
44
+ * session.errors$.subscribe((error) => console.error('err:', error));
36
45
  *
37
- * // Connect to a serial port
38
- * client.connect().subscribe({
39
- * next: () => console.log('Connected!'),
40
- * error: (error) => console.error('Connection error:', error),
41
- * });
46
+ * session.connect$().subscribe();
47
+ * session.send$('hello\r\n').subscribe();
48
+ * }
42
49
  * ```
43
50
  */
44
- export { createSerialClient } from './client';
45
- export { createShellClient } from './shell';
46
- export type { SerialClient } from './client';
47
- export type { ShellClient, ShellClientOptions, ShellExecResult } from './shell';
51
+ export { createSerialSession, SerialSessionState } from './session';
52
+ export type { SerialSession, SerialSessionOptions } from './session';
48
53
  export { SerialError } from './errors/serial-error';
49
54
  export { SerialErrorCode } from './errors/serial-error-code';
50
- export type { SerialClientOptions } from './types/options';
51
- export { BrowserType, detectBrowserType, hasWebSerialSupport, isChromiumBased, } from './browser/browser-detection';
52
- export { checkBrowserSupport, isBrowserSupported, } from './browser/browser-support';
53
- export { observableToWritable, subscribeToWritable, } from './io/observable-to-writable';
54
- export { readableToObservable } from './io/readable-to-observable';
55
- export { buildRequestOptions } from './filters/build-request-options';
56
55
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAGhF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG3D,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,GAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAGnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpE,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC"}