@vehicle-sil/gui-client 0.3.0 → 0.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 CHANGED
@@ -83,12 +83,12 @@ editor.setVisible(true);
83
83
 
84
84
  ### クライアント
85
85
 
86
- | 種類 | 名前 |
87
- | ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
88
- | 関数 | `createClient(options)` |
89
- | 型 | `ClientOptions`(`baseUrl`、`token`、`origin`、`http`、`socket`、`answerTimeoutMs`、`onError`) |
90
- | 型 | `GuiClient`(`connection`、`session`、`run`、`time`、`variables`、`app`、`limits`、`connect()`、`close()`、`loadApp()`、`configs()`、`config(file)`、`check()`、`describe()`、`saveConfig()`、`connections()`、`fetchSession()`、`dashboard(file)`、`scenarios(file)`、`recording()`) |
91
- | 定数 | `DEFAULT_LIMITS` |
86
+ | 種類 | 名前 |
87
+ | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
88
+ | 関数 | `createClient(options)` |
89
+ | 型 | `ClientOptions`(`baseUrl`、`token`、`origin`、`http`、`socket`、`answerTimeoutMs`、`onError`) |
90
+ | 型 | `GuiClient`(`connection`、`session`、`run`、`time`、`variables`、`app`、`limits`、`connect()`、`close()`、`loadApp()`、`configs()`、`config(file)`、`check()`、`describe()`、`saveConfig()`、`prepare()`、`connections()`、`dashboard(file)`、`scenarios(file)`、`recording()`) |
91
+ | 定数 | `DEFAULT_LIMITS` |
92
92
 
93
93
  ### 正面の口
94
94
 
@@ -106,7 +106,7 @@ editor.setVisible(true);
106
106
  | 型 | `TokenPlace` |
107
107
  | 定数 | `TOKEN_STORAGE_KEY` |
108
108
 
109
- ブラウザでは `takeToken(window)` と呼びます。URL の `#token=` を読んで URL から消し、sessionStorage に置きます。URL になければ sessionStorage に置いたものを返し、どちらにもなければ `null` を返します。
109
+ ブラウザでは `takeToken(window)` と呼びます。URL の `#token=` を読んで URL から消し、sessionStorage に置きます。URL になければ sessionStorage に置いたものを返し、どちらにもなければ `null` を返します。`--no-auth` で起動したサーバーにつなぐときは、`token` を省略するか `null` にできます(トークン認証が有効なサーバーでは、HTTP は 401 で失敗し WebSocket は `rejected` になります)。
110
110
 
111
111
  ### 接続(読むだけ)
112
112
 
@@ -118,17 +118,17 @@ editor.setVisible(true);
118
118
 
119
119
  ### セッションのコピー
120
120
 
121
- | 種類 | 名前 |
122
- | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
123
- | 型 | `ClientSession`(`session`、`currentTarget`、`currentInstance`、`ready`、`allowed`、`lastEventAt`、`notices`、`rejected`、`incompatible`、`onMessages`、`report`、`dismissNotice`) |
124
- | 型 | `Notice`、`SessionView`、`ParticipantView`、`LauncherView`、`LogLine`、`LogSource`、`TimeView`、`CommandView`、`RunOutcome`、`LauncherAnswer` |
125
- | 関数 | `runOutcome`、`phaseIndex`、`isHolding`、`launcherAnswer` |
121
+ | 種類 | 名前 |
122
+ | ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
123
+ | 型 | `ClientSession`(`session`、`currentTarget`、`currentInstance`、`ready`、`allowed`、`runtime`、`lastEventAt`、`notices`、`rejected`、`incompatible`、`onMessages`、`report`、`dismissNotice`) |
124
+ | 型 | `Notice`、`SessionView`、`ParticipantView`、`LauncherView`、`LogLine`、`LogSource`、`TimeView`、`CommandView`、`RunOutcome`、`LauncherAnswer` |
125
+ | 関数 | `runOutcome`、`phaseIndex`、`isHolding`、`launcherAnswer` |
126
126
 
127
- `ClientSession.allowed` は、GUI サーバーがいま受けるものです(`start`、`stop`、`force`。それぞれ `ok`、理由のコード `reason`、文 `message`。`rev` の大きい方が勝ちます。サーバーが言うまでは `null`)。`SessionView.launcherState` は、ランチャーの最後の `state` イベントです(実行の状態と、いま受けるもの。`rev` の大きい方が勝ちます。届くまでは `null`)。`launcherAnswer(launcherState, name)` は、1 つの操作(`write`、`pause` など)について、それが言うことを読みます: `reason`(受けるなら `null`)と `caution`。まだ言っていないランチャー(`state` がまだない、その操作の項目がない)は、受けないものとします(`unsupported`)。正面の口の `controls` と `variables.bind` は、これでランチャーを読みます。
127
+ `ClientSession.allowed` は、GUI サーバーがいま受けるものです(`start`、`stop`、`force`、`save`。それぞれ `ok`、理由のコード `reason`、文 `message`。サーバーが言うまでは `null`)。`SessionView.launcherState` は、ランチャーの最後の `state` イベントです(実行の状態と、いま受けるもの。`rev` の大きい方が勝ちます。届くまでは `null`)。`launcherAnswer(launcherState, name)` は、1 つの操作(`write`、`pause` など)について、それが言うことを読みます: `reason`(受けるなら `null`)と `caution`。まだ言っていないランチャー(`state` がまだない、その操作の項目がない)は、受けないものとします(`unsupported`)。正面の口の `controls` と `variables.bind` は、これでランチャーを読みます。
128
128
 
129
- サーバーが付ける session と変数の revision は、HTTP と WebSocket の要約の前後関係を示します。旧サーバーには番号がないため、両者の順序は最善を尽くす扱いです。revision によって replay、コマンドの応答、確定済み操作結果は捨てません。
129
+ 順序付きの通知(`session`、`event`、`allowed`、`runtime`、`variables`、`availability`、`operation`、`error`、`dropped`、`synced`)は、`(instance, run_id, stream_seq)` で順序付けられた単一の WebSocket ストリームで届きます。HTTP の変更操作(`api/run`、`api/stop-session`、`api/prepare`、`api/time`、`api/write`)は受領応答だけを返し、状態の更新は WebSocket ストリームで届きます。
130
130
 
131
- `currentTarget()` は現在の `{session, instance}` を返し、不明なら `null` を返します。`currentInstance()` は実行がなくても直近に認証したサーバーのインスタンスを返し、切断中も保持します。再接続ではサーバーが保持する履歴を先頭から再送してもらい、再起動前のカーソルを別のインスタンスに使いません。HTTP のみの利用者は、サーバー再起動後に `fetchSession()` でコピーを更新できます。
131
+ `currentTarget()` は現在の `{run_id, instance}` を返し、不明なら `null` を返します。`currentInstance()` は実行がなくても直近に認証したサーバーのインスタンスを返し、切断中も保持します。同じインスタンスと実行への再接続では `{instance, run_id, after_stream_seq}` を送ってそのカーソル以後のログイベントだけを再送してもらい、サーバーのインスタンスが変わったときは新しい `hello` から取り直します。
132
132
 
133
133
  ### 実行の操作
134
134
 
@@ -654,7 +654,7 @@ watch.close();
654
654
  - 反映されていないとわかってから送り直します。
655
655
  - 値を足し込むような(同じ書き込みを 2 回すると結果が変わる)使い方では、特に守ります。同じ値を書くだけなら、2 回書いても結果は同じです。
656
656
 
657
- **再接続**: 結果を待つ間に接続が切断されても、再接続した後の要約(`hello`、`fetchSession()`)で続きがわかります。要約には、サーバーが覚えている未確定の操作の全部と、番号が `operations_from_seq` 以上の操作の全部が入っています(サーバーが受け取るもののうち。シナリオ自身の書き込みの操作は届きません)。
657
+ **再接続**: 結果を待つ間に接続が切断されても、再接続した後の要約(`hello`)で続きがわかります。要約には、サーバーが覚えている未確定の操作の全部と、番号が `operations_from_seq` 以上の操作の全部が入っています(サーバーが受け取るもののうち。シナリオ自身の書き込みの操作は届きません)。
658
658
 
659
659
  | 自分の操作 | ライブラリの扱い |
660
660
  | ---------------------------------------------------- | ----------------------------------------------------------- |
package/README.md CHANGED
@@ -83,12 +83,12 @@ The names that `src/index.ts` exports, by group. Parentheses list the members of
83
83
 
84
84
  ### Client
85
85
 
86
- | Kind | Name |
87
- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
88
- | Function | `createClient(options)` |
89
- | Type | `ClientOptions` (`baseUrl`, `token`, `origin`, `http`, `socket`, `answerTimeoutMs`, `onError`) |
90
- | Type | `GuiClient` (`connection`, `session`, `run`, `time`, `variables`, `app`, `limits`, `connect()`, `close()`, `loadApp()`, `configs()`, `config(file)`, `check()`, `describe()`, `saveConfig()`, `connections()`, `fetchSession()`, `dashboard(file)`, `scenarios(file)`, `recording()`) |
91
- | Constant | `DEFAULT_LIMITS` |
86
+ | Kind | Name |
87
+ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
88
+ | Function | `createClient(options)` |
89
+ | Type | `ClientOptions` (`baseUrl`, `token`, `origin`, `http`, `socket`, `answerTimeoutMs`, `onError`) |
90
+ | Type | `GuiClient` (`connection`, `session`, `run`, `time`, `variables`, `app`, `limits`, `connect()`, `close()`, `loadApp()`, `configs()`, `config(file)`, `check()`, `describe()`, `saveConfig()`, `prepare()`, `connections()`, `dashboard(file)`, `scenarios(file)`, `recording()`) |
91
+ | Constant | `DEFAULT_LIMITS` |
92
92
 
93
93
  ### Front door
94
94
 
@@ -106,7 +106,7 @@ The names that `src/index.ts` exports, by group. Parentheses list the members of
106
106
  | Type | `TokenPlace` |
107
107
  | Constant | `TOKEN_STORAGE_KEY` |
108
108
 
109
- In the browser, call `takeToken(window)`. It reads `#token=` from the URL, removes it from the URL and stores it in sessionStorage. If the URL has no token, it returns the one in sessionStorage; if neither has one, it returns `null`.
109
+ In the browser, call `takeToken(window)`. It reads `#token=` from the URL, removes it from the URL and stores it in sessionStorage. If the URL has no token, it returns the one in sessionStorage; if neither has one, it returns `null`. When connecting to a server started with `--no-auth`, `token` may be omitted or `null` (against a server with token authentication enabled, HTTP requests reject with 401 and WebSocket sets `rejected`).
110
110
 
111
111
  ### Connection (read-only)
112
112
 
@@ -118,17 +118,17 @@ In the browser, call `takeToken(window)`. It reads `#token=` from the URL, remov
118
118
 
119
119
  ### Session copy
120
120
 
121
- | Kind | Name |
122
- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
123
- | Type | `ClientSession` (`session`, `currentTarget`, `currentInstance`, `ready`, `allowed`, `lastEventAt`, `notices`, `rejected`, `incompatible`, `onMessages`, `report`, `dismissNotice`) |
124
- | Type | `Notice`, `SessionView`, `ParticipantView`, `LauncherView`, `LogLine`, `LogSource`, `TimeView`, `CommandView`, `RunOutcome`, `LauncherAnswer` |
125
- | Function | `runOutcome`, `phaseIndex`, `isHolding`, `launcherAnswer` |
121
+ | Kind | Name |
122
+ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
123
+ | Type | `ClientSession` (`session`, `currentTarget`, `currentInstance`, `ready`, `allowed`, `runtime`, `lastEventAt`, `notices`, `rejected`, `incompatible`, `onMessages`, `report`, `dismissNotice`) |
124
+ | Type | `Notice`, `SessionView`, `ParticipantView`, `LauncherView`, `LogLine`, `LogSource`, `TimeView`, `CommandView`, `RunOutcome`, `LauncherAnswer` |
125
+ | Function | `runOutcome`, `phaseIndex`, `isHolding`, `launcherAnswer` |
126
126
 
127
- `ClientSession.allowed` is what the GUI server accepts now (`start`, `stop` and `force`, each with `ok`, a `reason` code and a `message`; the larger `rev` wins; `null` until the server says). `SessionView.launcherState` is the launcher's last `state` event (where the run stands and what it accepts; the larger `rev` wins; `null` until one arrives). `launcherAnswer(launcherState, name)` reads what it says of one operation (`write`, `pause`, ...): `reason` (`null` when the launcher accepts it) and `caution`. A launcher that has not said (no `state` yet, or no entry for the operation) does not accept it (`unsupported`). The front door's `controls` and `variables.bind` read the launcher with it.
127
+ `ClientSession.allowed` is what the GUI server accepts now (`start`, `stop`, `force` and `save`, each with `ok`, a `reason` code and a `message`; `null` until the server says). `SessionView.launcherState` is the launcher's last `state` event (where the run stands and what it accepts; the larger `rev` wins; `null` until one arrives). `launcherAnswer(launcherState, name)` reads what it says of one operation (`write`, `pause`, ...): `reason` (`null` when the launcher accepts it) and `caution`. A launcher that has not said (no `state` yet, or no entry for the operation) does not accept it (`unsupported`). The front door's `controls` and `variables.bind` read the launcher with it.
128
128
 
129
- Server-provided session and variable revisions order snapshots across HTTP and WebSocket; older servers omit them, so cross-transport ordering is best effort. Revisions do not suppress replay, command answers, or terminal operation results.
129
+ Ordered notifications (`session`, `event`, `allowed`, `runtime`, `variables`, `availability`, `operation`, `error`, `dropped`, `synced`) arrive over the single WebSocket stream ordered by `(instance, run_id, stream_seq)`. HTTP mutation endpoints (`api/run`, `api/stop-session`, `api/prepare`, `api/time`, `api/write`) return lightweight acknowledgements while state updates arrive on the WebSocket stream.
130
130
 
131
- The `currentTarget()` method returns the current `{session, instance}` pair, or `null` when it is unknown. `currentInstance()` returns the last authenticated server instance even if no run exists, and retains it while disconnected. On reconnect the client requests the retained replay from the beginning, so a restarted server cannot apply a cursor from another instance. An HTTP-only client can refresh its copy with `fetchSession()` after a server restart.
131
+ The `currentTarget()` method returns the current `{run_id, instance}` pair, or `null` when it is unknown. `currentInstance()` returns the last authenticated server instance even if no run exists, and retains it while disconnected. On reconnect to the same instance and run, the client sends `{instance, run_id, after_stream_seq}` so the server resends only log events after that cursor; when the server instance changes, it starts fresh from the new `hello`.
132
132
 
133
133
  ### Run control
134
134
 
@@ -652,7 +652,7 @@ The `kind` of a `WriteError`:
652
652
  - Resend only once you know that the write was not applied.
653
653
  - This matters most for writes that add to a value (writing twice gives a different result). Writing the same value twice gives the same result.
654
654
 
655
- **Reconnection**: if the connection drops while you wait for a result, the summary after reconnecting (`hello`, `fetchSession()`) tells how it went on. The summary holds every open operation the server keeps, and every operation whose number is `operations_from_seq` or higher (of those the server receives: the operations of a scenario's own writes never come).
655
+ **Reconnection**: if the connection drops while you wait for a result, the summary after reconnecting (`hello`) tells how it went on. The summary holds every open operation the server keeps, and every operation whose number is `operations_from_seq` or higher (of those the server receives: the operations of a scenario's own writes never come).
656
656
 
657
657
  | Your operation | What the library does |
658
658
  | ------------------------------------------------------------------ | --------------------------------------------------------------------------- |