haori 0.26.2 → 0.28.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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Haori.js は、HTML 属性を中心にして動的な UI を実現する軽量なライブラリです。JavaScript をほとんど書かずに、データバインディング、条件分岐、繰り返し処理、フォームの双方向バインディング、サーバー通信などを HTML 属性で宣言できます。
4
4
 
5
- バージョン: 0.26.2
5
+ バージョン: 0.28.0
6
6
 
7
7
  ---
8
8
 
@@ -30,6 +30,7 @@ Haori.js は、HTML 属性を中心にして動的な UI を実現する軽量
30
30
  - `value="true"` を付けたチェックボックスの boolean 対応(チェック時 `true`、未チェック時 `false`)
31
31
  - `type="number"` 入力の数値型対応(バインド・送信時に数値。空・数値化できない値は `null`)
32
32
  - イベント駆動アクション(`data-click-*`・`data-change-*`・`data-load-*`・`data-intersect-*`)
33
+ - 定期取得(`data-poll-*`。取得間隔・打ち切り時間・停止条件を指定)
33
34
  - サーバー通信(`data-fetch`)
34
35
  - HTML インポート(`data-import`)
35
36
  - ライフサイクルイベント(`haori:eachupdate`・`haori:bindcomplete`・`haori:show` / `haori:hide` など)
@@ -112,6 +113,7 @@ Haori.mount(document.body, {items: [{name: 'りんご'}, {name: 'みかん'}]});
112
113
  イベント駆動アクション:
113
114
 
114
115
  - `data-click-*`・`data-change-*`・`data-input-*`・`data-load-*`・`data-intersect-*` は、それぞれクリック・フォーム変更・逐次入力・要素ロード・ビューポート交差を契機に処理(fetch、bind、copy、ダイアログ操作など)を宣言します。`data-load-*` は `data-if` 要素が非表示→表示へ遷移した(`haori:show`)タイミングでも発火するため、ネイティブの `load` が発生しない `<button>` などでも利用できます。
116
+ - `data-poll-*` — タイマーで手続きを繰り返し起動します(定期取得)。別端末や別プロセスでの操作完了を待つ画面に使います。アクション語彙は `data-{event}-*` と共通(`data-poll-fetch`・`data-poll-bind`・`data-poll-bind-arg` など)。設定属性は `data-poll-interval`(取得間隔ミリ秒。既定 5000、下限 100)、`data-poll-timeout`(打ち切りミリ秒。省略時は無制限)、`data-poll-until="{{式}}"`(真になった時点で恒久停止。各リクエスト前とバインド反映後に評価)、`data-poll-error-limit`(連続失敗回数の上限。省略時は継続)、`data-poll-disabled`(真の間は抑止)、`data-poll-state`(`_poll` 状態の注入先。`running`・`paused`・`stopped`・`timedOut`・`stopReason`・`count`・`elapsedMs`)です。初回は即時実行、2回目以降は前回完了時点から計測するためリクエストは多重化せず、`data-if` で非表示の間は一時停止して再表示で再開し、DOM から外れた時点で恒久停止します。バックグラウンドタブではブラウザがタイマーを抑制するため指定間隔は保証されません(タブが表示に戻った時点で即時に取得し直します)。
115
117
  - `data-input-*` — テキスト入力1文字ごと(`input` イベント)に手続きを起動します。逐次発火するため `data-input-*` を**明示した要素のみ**が対象(オプトイン)で、`change` 同様に先祖フォームを自動検出して双方向バインディングへ反映します。検索欄の逐次絞り込みなどに使えます(例: `<input name="q" data-input-form>`)。
116
118
  - `data-on="イベント名"` + `data-on-*` — `window` / `document` へ dispatch された**任意のカスタムイベント**を契機に手続きを起動します(アクション語彙は `data-{event}-*` と共通)。ネイティブ橋の準備完了通知など、組み込みイベント以外での初期化を宣言的に書けます(例: `<body data-on="appReady" data-on-fetch="/api/init.json" data-on-bind="#app">`)。イベント名は属性値で保持(属性名の小文字化対策)、`window` キャプチャ1本で二重発火なく購読、後挿入要素も追従。組み込みイベント名(click/change/input/load)は警告し購読しません。Haori 購読開始前に発火したイベントは受け取れない点に注意。
117
119
  - `data-click-copy-source` — `data-click-copy` のコピー元要素を明示指定します(既定は `data-click-form` のフォーム、無ければイベント発火元の binding)。
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Haori.js is a lightweight, HTML-first UI library that enables dynamic user interfaces primarily through HTML attributes. It lets you declare data bindings, conditional rendering, list rendering, form two-way binding, server fetches, and HTML imports without writing much JavaScript.
4
4
 
5
- Version: 0.26.2
5
+ Version: 0.28.0
6
6
 
7
7
  ---
8
8
 
@@ -30,6 +30,7 @@ Contents
30
30
  - Boolean checkbox support with `value="true"` (`true` when checked, `false` when unchecked)
31
31
  - `type="number"` inputs are bound and submitted as numbers (empty / non-numeric values become `null`)
32
32
  - Event-driven actions via `data-click-*`, `data-change-*`, `data-load-*`, `data-intersect-*`
33
+ - Interval polling via `data-poll-*` (interval, timeout, and stop condition)
33
34
  - Server fetches via `data-fetch`
34
35
  - HTML imports via `data-import`
35
36
  - Lifecycle events such as `haori:eachupdate`, `haori:bindcomplete`, `haori:show` / `haori:hide`
@@ -112,6 +113,7 @@ Additional binding helpers:
112
113
  Event-driven actions:
113
114
 
114
115
  - `data-click-*`, `data-change-*`, `data-input-*`, `data-load-*`, `data-intersect-*` declare actions (fetch, bind, copy, dialog control, etc.) triggered by click, form change, incremental input, element load, and viewport intersection respectively. `data-load-*` also fires when a `data-if` element transitions from hidden to shown (the `haori:show` timing), so it works on elements like `<button>` that never receive a native `load` event.
116
+ - `data-poll-*` — run a procedure repeatedly on a timer (interval polling), for screens that wait until another device or process finishes. The action vocabulary is shared with `data-{event}-*` (`data-poll-fetch`, `data-poll-bind`, `data-poll-bind-arg`, …). Configuration is `data-poll-interval` (interval in ms, default 5000, floor 100), `data-poll-timeout` (give up after ms, unlimited when omitted), `data-poll-until="{{expr}}"` (stop permanently once true; evaluated before each request and after each bind), `data-poll-error-limit` (stop after N consecutive failures; keeps going when omitted), `data-poll-disabled` (suppress while truthy) and `data-poll-state` (inject `_poll` state — `running` / `paused` / `stopped` / `timedOut` / `stopReason` / `count` / `elapsedMs`). The first request runs immediately, later intervals are measured from the previous completion (so requests never overlap), polling pauses while hidden by `data-if` and resumes when shown, and stops permanently when the element leaves the DOM. Note that browsers throttle timers in background tabs, so the configured interval is not guaranteed there (an immediate refetch is issued when the tab becomes visible again).
115
117
  - `data-input-*` — run a procedure on each keystroke (the `input` event) for text inputs. Because `input` fires incrementally, only elements that explicitly declare a `data-input-*` attribute are handled (opt-in); like `change`, it auto-detects the ancestor form and reflects the value into two-way bindings. Useful for incremental search filtering (e.g. `<input name="q" data-input-form>`).
116
118
  - `data-on="eventName"` + `data-on-*` — run a procedure when an arbitrary **custom event** dispatched on `window` / `document` fires (the action vocabulary is shared with `data-{event}-*`). Lets you declaratively initialize on events other than the built-ins, e.g. a native-bridge ready signal (`<body data-on="appReady" data-on-fetch="/api/init.json" data-on-bind="#app">`). The event name is held in the attribute value (attribute names are lowercased), a single `window` capture subscription receives both `window`- and `document`-dispatched events without double-firing, and elements inserted later are picked up too. Built-in names (click/change/input/load) are warned and not subscribed. Note: events dispatched before Haori subscribes are not received (no replay).
117
119
  - `data-click-copy-source` — explicitly set the copy source element for `data-click-copy` (defaults to the form given by `data-click-form`, otherwise the event element's binding).