@aiquants/contact-map 0.25.0 → 0.25.2

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.md CHANGED
@@ -190,6 +190,7 @@ The function may be inline (a new identity on each render): the session keeps it
190
190
  The module-resident session reads `workerUrls.treeWorker` once per browser tab: give every contact-map view the same value on every route (or none, for the bundled Worker file). A view that asks for another URL throws an `Error` naming both, a value that is not a string (a `URL` object, `null`) throws a `TypeError`, and an empty or blank URL throws a `RangeError`; after changing the URL, reload the page.
191
191
  `ContactMapConfigProvider` checks the value's shape in every render, a server render included, like `locale` and `labels`, even while `treeWorkerFactory` is set, so a view that has not opened its tree yet still refuses it. The session itself, and with it the one-URL rule, exists only in the browser, so the rule holds per browser tab and not across a server's requests.
192
192
  `workerUrls` on `ContactMapAppView` is layered over the provider's key by key: a key the view leaves out or sets to `undefined` keeps the provider's value (`layerContactMapWorkerUrls`). `ContactMapSearchPage` layers only `indexWorker` and `levenshteinWorker` the same way and refuses a `treeWorker`, because its tree reads the provider's; set that on the provider or the view. Errors name the surface that holds the bad value (`workerUrls`, `ContactMapAppView workerUrls`, `ContactMapSearchPage workerUrls`).
193
+ The search page runs its fuzzy-search Workers (`indexWorker`, `levenshteinWorker`) under its own fixed worker id, `@aiquants/contact-map:search`, never under the engine's shared `"default"`. The engine keeps one pair of Workers per id for the page, together with the Worker URLs it resolved first under that id: every search page of a browser tab uses the URLs the first one resolved, and parts on other ids (a picker of `@aiquants/select-box`, for one) neither share those Workers nor make the search build its index again. "Reset all" keeps the id.
193
194
  Every surface reads each own property of its `workerUrls` once per render and hands down only the checked copy: `useContactMapConfig().workerUrls` is a frozen object holding all three keys (`undefined` where none is set), so a getter that returns another value after the check, or a key inherited from `Object.prototype`, never reaches a Worker.
194
195
 
195
196
  The same holds for every setting: `useContactMapConfig()` is a frozen object without a prototype that owns every setting (`undefined` where left out), inside a provider and outside one, so no setting is ever inherited, from a polluted `Object.prototype` either.
@@ -200,6 +201,7 @@ A Worker that cannot be created or fails is recreated twice, 250 ms and then 500
200
201
  ツリーは Web Worker の中で、モジュール常駐の 1 つのセッションが組み立てるので、ツリーへ戻ると直前のスナップショットがすぐに出る。設定の `treeWorkerFactory` は、Worker の作り方が決まっているバンドラー向けに Worker の生成を差し替える。呼ぶたびに新しい Worker を返すこと (フックがその Worker を所有し、外すときに止める)。フックのインスタンスごとにセッションを持つので、再マウントでスナップショットは残らない。`<Activity>` で隠したビュー (と StrictMode が繰り返す副作用) は Worker を止めるだけでツリーを画面に残し、再び表示すると、そのツリーの裏で新しい Worker に作り直す。描画のたびに別の関数になってよく (インラインの関数でよい)、セッションは Worker を持ち続けて、新しく作るときに最後の factory を呼ぶ (`workerUrls.treeWorker` は読まない)。モジュール常駐のセッションを使うなら指定せず、必要なら `workerUrls.treeWorker` で Worker のファイルを指す。
201
202
  モジュール常駐のセッションは `workerUrls.treeWorker` をブラウザのタブにつき 1 回だけ読む。全ルートの全ビューに同じ値を渡す (同梱の Worker ファイルなら全て指定しない)。別の URL を求めたビューは両方の値を挙げた `Error` を、文字列でない値 (`URL` オブジェクト、`null`) は `TypeError` を、空や空白だけの URL は `RangeError` を投げる。URL を変えたらページを再読み込みする。値の形は `ContactMapConfigProvider` が `locale` / `labels` と同じくサーバーでの描画を含むどの描画でも検査し、`treeWorkerFactory` がある間も検査するので、まだツリーを開いていないビューでも拒む。セッション自体とその 1 つの URL の規則はブラウザにだけあるので、規則はサーバーの要求をまたがず、ブラウザのタブごとに効く。`ContactMapAppView` の `workerUrls` は外側のプロバイダーの値へキーごとに重ね、ビューが省略か `undefined` にしたキーはプロバイダーの値を保つ (`layerContactMapWorkerUrls`)。
202
203
  `ContactMapSearchPage` は `indexWorker` と `levenshteinWorker` だけを同じく重ね、`treeWorker` は拒否する (ツリーはプロバイダーの値を読むので、プロバイダーかビューに設定する)。例外は誤った値を持つ設定 (`workerUrls`・`ContactMapAppView workerUrls`・`ContactMapSearchPage workerUrls`) を名指す。
204
+ 検索のページは、fuzzy-search のワーカー (`indexWorker`・`levenshteinWorker`) を、エンジンの共有の `"default"` でなく、自分の固定のワーカー ID `@aiquants/contact-map:search` で動かす。エンジンは ID ごとにワーカーの組をページの間保ち、その ID の下で最初に解決したワーカーの URL も保つので、ブラウザーのタブの検索のページはどれも最初のページが解決した URL を使い、ほかの ID の部品 (`@aiquants/select-box` の選択欄など) はそのワーカーを分け合わず、検索の索引を作り直させもしない。「すべてリセット」は ID を保つ。
203
205
  どの面も `workerUrls` の各プロパティを描画ごとに 1 回だけ読み、検査した複製だけを下へ配る。`useContactMapConfig().workerUrls` は 3 つのキーを全て持つ凍結したオブジェクト (どこにも無いキーは `undefined`) なので、検査の後で別の値を返す getter や `Object.prototype` から継承したキーが Worker に届くことは無い。
204
206
 
205
207
  これは全ての設定に当てはまる。`useContactMapConfig()` は、プロバイダーの中でも外でも、全ての設定を自身で持つ (省略したものは `undefined`) プロトタイプの無い凍結したオブジェクトなので、汚染された `Object.prototype` からも設定を継承しない。
@@ -302,16 +304,39 @@ Every control the package draws is a target of at least 44 × 44 CSS px under ev
302
304
 
303
305
  - **The search band:** the tabs of the search page (fuzzy search, settings, statistics), the AND / OR switch, the search field and its clear button, the list / tree tabs, and the tree view's controls beside them (the whole-company switch, expand all, collapse all). The row of the list / tree tabs wraps, so on a narrow screen the tree view's controls take a line of their own instead of running past the screen's edge.
304
306
  - **The settings and statistics tabs:** their buttons (reset all, reset, rebuild index) and inner tabs are 44 × 44 px, and the selects 44 px high. A slider's box is 44 px high over its width, and a press anywhere on it moves the value; the thumb keeps the browser's drawing. A checkbox keeps its drawn 12 px box, and the label row around it, 44 px high over the panel's width, is its target: a press anywhere on the row toggles it.
305
- - **Touch screens:** under a coarse pointer the text of the search field and the settings' selects is 16 px (the `body` step's 13 px under a fine pointer), so iOS Safari does not zoom the page when one of them takes the focus.
307
+ - **Touch screens:** under a coarse pointer the text of the search field and the settings' selects is 16 px (the `body` step's 13 px under a fine pointer), so iOS Safari does not zoom the page when one of them takes the focus, and the page never puts focus in the search field by itself (see Search Field Focus).
306
308
  - **Names and states:** the clear button is named by `clearSearch` while it can clear (while a search runs, its visible `searching` text names it); the list / tree buttons report the shown view with `aria-pressed`; the statistics tabs are tabs of a tab list named by `statsTabsLabel`, as the settings tabs are of one named by `settingsTabsLabel`, the shown one selected.
307
309
  - **Their own sizes:** the resize handles between the list or the tree and the detail pane keep their thin band, and the keyboard resizes the panes (`@aiquants/resize-panels`); the scroll controls of the list and the tree (`@aiquants/virtualscroll`, pointer-only) and the tree's rows (`@aiquants/directory-tree`) follow those packages.
308
310
 
309
311
  - **検索の帯**: 検索ページのタブ (あいまい検索・検索設定・検索統計)・AND / OR の切り替え・検索欄とクリアのボタン・一覧 / ツリーのタブ・その横のツリーのビューの操作部品 (会社全体の表示の切り替え・全展開・全折りたたみ)。一覧 / ツリーのタブの行は折り返すので、狭い画面ではツリーのビューの操作部品は画面の端からはみ出さずに次の行へ移る。
310
312
  - **検索設定と検索統計のタブ**: ボタン (すべてリセット・リセット・インデックス再構築) と内側のタブは 44 × 44 px、セレクトは高さ 44 px。スライダーは幅いっぱいで高さ 44 px の箱を持ち、箱のどこを押しても値が動く (つまみの描き方はブラウザーのまま)。チェックボックスは描く箱を 12 px のまま保ち、それを囲むパネルの幅いっぱいで高さ 44 px のラベルの行が的になる (行のどこを押しても切り替わる)。
311
- - **タッチの画面**: 粗いポインターでは検索欄と設定のセレクトの文字を 16 px にし (細かいポインターでは `body` の段の 13 px)、フォーカスを受けても iOS の Safari が画面を拡大しない。
313
+ - **タッチの画面**: 粗いポインターでは検索欄と設定のセレクトの文字を 16 px にし (細かいポインターでは `body` の段の 13 px)、フォーカスを受けても iOS の Safari が画面を拡大しない。ページは検索欄へ自分でフォーカスを置かない (検索欄の焦点の節を参照)。
312
314
  - **名前と状態**: クリアのボタンは消せる間 `clearSearch` を名前に持つ (検索中は見えている `searching` の文字が名前)。一覧 / ツリーのボタンは見せているビューを `aria-pressed` で示す。検索統計の内側のタブは `statsTabsLabel` を名前に持つタブの並びのタブで (検索設定のタブが `settingsTabsLabel` の並びのタブであるのと同じ)、見せているものが選ばれている。
313
315
  - **自分の大きさを保つもの**: 一覧やツリーと詳細のペインの間のサイズ変更ハンドルは細い帯のままで、ペインの幅はキーボードでも変えられる (`@aiquants/resize-panels`)。一覧とツリーのスクロールの操作部品 (`@aiquants/virtualscroll`。ポインター専用) とツリーの行 (`@aiquants/directory-tree`) はそれぞれのパッケージに従う。
314
316
 
317
+ ## Search Field Focus / 検索欄の焦点
318
+
319
+ Under a fine pointer (a mouse: the `(pointer: coarse)` media query does not match), the search page puts focus in its search field by itself, so the user can type at once:
320
+
321
+ - when the page is ready: its search tab is shown, the route is idle and no transition is pending, and the focus is on a page tab, on the body or on the field already;
322
+ - when its search tab is shown again;
323
+ - after the clear button and after the AND / OR switch;
324
+ - when the page is shown again (`visibilitychange` to `visible`, and `pageshow`);
325
+ - when the stream failure notice leaves holding focus (see Stream Status).
326
+
327
+ On a touch screen (a coarse primary pointer, the condition of the field's 16 px text) it does none of these, because a focused field brings up the on-screen keyboard (and a host may hide what it draws along the screen's bottom edge while a text field holds the focus): the user taps the field to type, and the leaving failure notice hands focus to the selected page tab instead.
328
+ The pointer is read at each of these moments, so a mouse attached or detached counts from then on. Without `matchMedia` (a DOM outside a browser) the pointer counts as fine. On a touch screen a focus the user puts somewhere, the field included, stays there.
329
+
330
+ 細かいポインター (マウス。`(pointer: coarse)` のメディアクエリが当たらない) では、検索のページは検索欄へ自分でフォーカスを置き、利用者がすぐに打てるようにする。
331
+
332
+ - ページの読み込みが済んだ時: 検索のタブを見せ、ルートの移動が `idle` で待ちの遷移が無く、フォーカスがページのタブか body か検索欄にある時。
333
+ - 検索のタブを再び見せた時。
334
+ - クリアのボタンと AND / OR の切り替えの後。
335
+ - ページが再び見えた時 (`visible` への `visibilitychange` と `pageshow`)。
336
+ - ストリームの失敗の知らせがフォーカスを持ったまま外れた時 (ストリームの状態の表示の節を参照)。
337
+
338
+ 触る画面 (粗い主なポインター。検索欄の 16 px の文字と同じ条件) ではどれもしない。欄のフォーカスは画面のキーボードを呼ぶ (ホストは、文字の欄がフォーカスを持つ間、画面の下の端に沿って描く物を隠すことがある) ためで、利用者は欄を押して打ち、外れる失敗の知らせは代わりに選ばれたページのタブへフォーカスを渡す。ポインターはこれらの時ごとに読むので、マウスを繋いだか外した後はその時から効く。`matchMedia` の無い DOM (ブラウザーの外のもの) では、ポインターは細かいと数える。触る画面では、利用者が置いたフォーカス (検索欄も) はそのまま残る。
339
+
315
340
  ## Text Size / 文字の大きさ
316
341
 
317
342
  The primary text of every control and list row the package draws (a button's, a tab's or a link's name, the value of the search field and the selects, a field's visible name (the label of a select or a slider), a checkbox's label row) is at least console-ui's `body` step, 13 px on a 20 px line,
@@ -348,7 +373,7 @@ The steps read these host CSS variables, each the step's value while the host le
348
373
  While the phase is `failed`, a band shows the message (`streamLoadFailed` with the received count) and a retry button (`streamRetry`) that calls the stream's `retryNow()`. The band is a group named by the message, which also describes the button; it is not a live region (the announcer tells the change). The message carries the client's English error text as its tooltip (`title`), supplementary detail drawn by the browser.
349
374
  While the phase is `unauthenticated` (a 401) or `forbidden` (a 403), a slot in the same place holds the node of the host's access failure presenter instead, and the notice draws no band and words nothing itself (see Access Failures).
350
375
  The band and the slot overlap neither the header nor the page: they push the page down by their height and 8 px, and a one-line band is 52 px tall (1 + 3 + 44 + 3 + 1), on the 4 px lattice. Its text is the rose tone's on the tone's tint (7.21:1 in the light scheme, 11.09:1 in the dark one); the button is a 44 × 44 px target on the surface (its text 7.92:1 and 12.59:1), outlined by the control outline (4.34:1 and 5.97:1 on the band) and ringed by the package's focus ring (6.22:1 and 9.42:1 on the band).
351
- When the band or the slot leaves while it holds focus (the retry pressed, or another call of the stream's `retryNow()`, which a component mounting `useContactMapStream` makes for a stream that failed or was refused), focus goes to the search page beside it instead of falling to the body: to the search field, or to the selected page tab while the page shows its settings or its statistics (the field is then not rendered).
376
+ When the band or the slot leaves while it holds focus (the retry pressed, or another call of the stream's `retryNow()`, which a component mounting `useContactMapStream` makes for a stream that failed or was refused), focus goes to the search page beside it instead of falling to the body: to the search field, or to the selected page tab while the page shows its settings or its statistics (the field is then not rendered) and on a touch screen (see Search Field Focus).
352
377
  The same holds when one of them replaces the other (`failed` and an access failure, or one kind and the other) while it holds focus. Focus put elsewhere by then stays where it is.
353
378
  - **The announcer** (`ContactMapStreamAnnouncer`): one per view, outside the header and the notice, a visually hidden box of one polite status region (`role="status"`) and one assertive alert region (`role="alert"`), both mounted empty.
354
379
  It announces only the phase changes after mount, each with the text of the phase it entered, written once as it enters it: `retrying` as a status (`annotationReconnecting`), `failed` as an alert (`streamLoadFailed`), and the other phases empty both regions, the access failures (`unauthenticated`, `forbidden`) included: the presenter's node speaks for itself, so the failure is not read twice. A change of the received count within a phase is not announced, and neither is the phase at mount (the annotation and the notice show it). They are the package's only live regions.
@@ -358,7 +383,7 @@ The steps read these host CSS variables, each the step's value while the host le
358
383
  局面が `failed` の間は、帯に文 (受信済みの件数を持つ `streamLoadFailed`) と、ストリームの `retryNow()` を呼ぶ再試行のボタン (`streamRetry`) を見せる。帯は文を名前に持つグループで、文はボタンの説明でもある。読み上げの領域ではない (移り変わりは読み上げの部品が知らせる)。文はクライアントの英語のエラー文をツールチップ (`title`) に持つ (ブラウザーが描く補足)。
359
384
  局面が `unauthenticated` (401) か `forbidden` (403) の間は、同じ所の置き場がホストのアクセスの失敗の示し手の node を持ち、知らせは帯を描かず、自分では何も書かない (アクセスの失敗の節を参照)。
360
385
  帯と置き場は見出しにもページにも重ならない: ページを自分の高さと 8 px だけ下へ押し、1 行の帯は高さ 52 px (1 + 3 + 44 + 3 + 1) で 4 px の格子に乗る。文字は rose の色調の淡い面の上の色調の文字 (明るい配色で 7.21:1、暗い配色で 11.09:1)。ボタンは面の上の 44 × 44 px の的 (文字は 7.92:1 と 12.59:1) で、操作部品の輪郭 (帯の上で 4.34:1 と 5.97:1) とパッケージのフォーカスの輪 (帯の上で 6.22:1 と 9.42:1) を持つ。
361
- 帯か置き場がフォーカスを持ったまま外れると (再試行の押下か、ストリームの `retryNow()` のほかの呼び出し。`useContactMapStream` をマウントする部品は失敗した・断られたストリームを再試行する)、フォーカスは body へ落とさず傍らの検索のページへ渡す: 検索欄へ、ページが検索設定か検索統計を見せる間は (検索欄が描かれない) 選ばれたページのタブへ。フォーカスを持ったまま一方が他方に替わるとき (`failed` とアクセスの失敗、または 2 つの種類どうし) も同じ。それまでに別の所へ置かれたフォーカスはそのまま。
386
+ 帯か置き場がフォーカスを持ったまま外れると (再試行の押下か、ストリームの `retryNow()` のほかの呼び出し。`useContactMapStream` をマウントする部品は失敗した・断られたストリームを再試行する)、フォーカスは body へ落とさず傍らの検索のページへ渡す: 検索欄へ、ページが検索設定か検索統計を見せる間 (検索欄が描かれない) と触る画面では (検索欄の焦点の節を参照) 選ばれたページのタブへ。フォーカスを持ったまま一方が他方に替わるとき (`failed` とアクセスの失敗、または 2 つの種類どうし) も同じ。それまでに別の所へ置かれたフォーカスはそのまま。
362
387
  - **読み上げの部品** (`ContactMapStreamAnnouncer`): ビューに 1 つ、見出しと知らせの外に置く。画面に出さない箱に控えめな状態の領域 (`role="status"`) と割り込む警告の領域 (`role="alert"`) を 1 つずつ持ち、どちらも空のままマウントする。知らせるのはマウントの後の局面の移り変わりだけで、入った局面の文字を入ったときに 1 度だけ書く: `retrying` は状態 (`annotationReconnecting`)、`failed` は警告 (`streamLoadFailed`)、ほかの局面は両方の領域を空にする。アクセスの失敗 (`unauthenticated`・`forbidden`) も空にする (示し手の node が自ら読み上げるので、同じ失敗を 2 度読ませない)。局面の中での受信済みの件数の増減は知らせず、マウントの時点の局面も知らせない (注記と知らせが見せている)。パッケージの読み上げの領域はこの 2 つだけ。
363
388
 
364
389
  A host that composes the page itself (`ContactMapSearchPage` under its own header) places the same parts: the announcer outside its header and the notice right after it, with the outlet context's `streamAccessFailureNumber`, the stream's `retryNow` and its access failure presenter.