@wcstack/lint 4.22.0 → 4.24.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
@@ -118,6 +118,31 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
118
118
  - 配列と分からない値(`budgetErrors: {}` と `this.budgetErrors[id] = …`)への `wcs/array-index-assign` は、「配列の添字」ではなくオブジェクトのキーへの代入として言います。
119
119
  - スクリプトがその場で変えるリスト(`this.budgetRows.splice(0, n, ...rows)` — `wcs/array-mutation` が報告する)の行は、リテラルや JSDoc の型からフィールドが読めなければ検査しません。4.20 までは、そうした行のフィールドがどれも `wcs/binding-path-missing` の誤報で、本物の打ち間違いと同じ code でした。
120
120
 
121
+ ## 入力の重いフォームに言うこと
122
+
123
+ 4.23 から、継ぎ目アプリ ekiden-entry — 駅伝の申し込みウィザード。IME・オートフィル・行の中の入力・フォーム連携のカスタム要素と、入力の重いページ — から。そのページで lint は、仕込んだ誤り 21 件に何も言わず、読めない state について偽の warning を 91 件出していました:
124
+
125
+ - **値を読めないキーの下は「分からない」で、「存在しない」ではありません。** `const init = emptyEntry()` の `team: init.team`、`errs: emptyErrs()`、条件式、`[1, 2].map(…)`、`[newRunner()]` の行: そうしたキーの下のパスは検査せず、キーの上の `wcs/path-dynamic-unknown`(info)が 1 回だけそう言います — その下に束ねたパスの数(キーの `for:` の行の `.name` も数えます)と、検査させる方法(キーの JSDoc の `@type` か `stateSchema`)付きで。4.22 までは、そのパスが 1 件ずつ `wcs/binding-path-missing` の誤報で、本物の打ち間違いと同じ code でした。オブジェクトリテラルを束縛する `const` のメンバー(`team: DEFAULTS.team`。モジュールの中のものも import したものも)は読み、その下のパスを検査します。
126
+ - **`wcs/radio-name-shared`**(warning) — `for:` の行の中の、`name` をリテラルで書いた、行の値を束ねたラジオ(`<input type="radio" name="sex" data-wcs="radio: .sex">`)。どの行のラジオも同じ name になるので、ブラウザは全部の行を 1 つのグループにします: ページ全体で 1 つしか選ばれた状態にならず、表示は最初の描画から行ごとの値と食い違います。行ごとに違う name を束ねる(`attr.name: .<行のフィールド>`)か、name を外してください — `radio:` は name が無くても、同じパスに束ねたラジオを選択に合わせます。name を束ねてあるとき、行のものでないパス(`value: .id; radio: selectedId` — 行をまたぐ 1 つの選択)、行ごとに `<form>` があるときは報告しません。
127
+ - **`wcs/number-written-as-string`**(warning) — 書き戻すときに変換しない双方向の `value:` が、state が数値で持つパスを指す: `count: 0` と `<input type="number" data-wcs="value: count">`(JSDoc の `@type {number}`・`stateSchema`・行のフィールド `value: .qty` も)。要素の `value` は文字列なので、5 と入力した後の state は `"5"` で、`count + 1` は `"51"` になります。`valueAsNumber: count` か、左辺の入力フィルタ `value|number: count`(`|int`・`|float`)と書いてください。
128
+ - **`wcs/two-way-output-filter`**(warning) — 双方向の `value:` / `valueAsNumber:` の出力フィルタ(`value: code|upper`・`value: price|locale`)。打つ欄では、フィルタが 1 打鍵ごとに state の値を整形して欄へ書き直します: 入力中の欄が書き換わり(キャレットは末尾へ飛び、IME の変換は途切れます)、state が受け取るのも欄の整形済みの文字です — 出力フィルタは書き戻しで元に戻りません。整形した文字は別の要素に表示する、欄の確定で書き戻して setter で整形する(`value#onchange:`)、または一方向にしてください(`value#ro:`)。確定した値を書き戻す束縛(`#onchange`・`<select>`・スライダー)は、出力を元に戻す入力フィルタが無いときだけ報告します: `value#onchange|number: price|toFixed(2)` は報告しません。要素の書いた文字をそのまま返すフィルタ(`string`・`nullIfEmpty`・`coalesce(…)`・`defaults('')`)も報告しません。
129
+ - **`attr.*` に束ねた boolean**(`wcs/binding-type-expectation`)には、起きることを言います: ランタイムは `String(value)` — `"true"` / `"false"` — を書き、属性を外すのは `null` / `undefined` だけです。その語が属性の値であるもの — ARIA の状態(`attr.aria-invalid: flag|truthy`)・`contenteditable`・`draggable`・`spellcheck` — は、もう報告しません(`"attr.aria-invalid" には文字列型が必要です` は誤報でした)。ネイティブ要素の論理属性(`attr.disabled: flag`)には、`disabled="false"` でも無効のままであることと、代わりに束ねるプロパティ(`disabled: flag`)を言います。ほかの属性(`attr.data-open: flag`)には、文字として書かれて外れないことと、false の間は外す `|defaults(null)`・文字が意図のときの `|string` を言います。
130
+
131
+ 新しい 3 つの規則は warning です: `--strict` では失敗し、`--errors-only` には出ません。
132
+
133
+ ## 長いリストのページに言うこと
134
+
135
+ 4.24 から、継ぎ目アプリ town-archive — 写真 12,000 枚のアーカイブ。長いリストと無限スクロールのページ — から。そのページの誤りのうち、この lint が言わなかったもの:
136
+
137
+ - **`wcs/body-binding`**(error) — `<body>` / `<html>` に書いた `data-wcs`(`<body data-wcs="onkeydown: onKey; class.dark: dark">`)。`<wcs-state>` が束ねるのは `<body>` の中で、`<body>` と `<html>` そのものは束ねないので、そこに書いた束縛は何もしません: ハンドラは走らず、`class.` も `attr.` も書かれません。束縛を `<body>` の中の要素(包む要素・`<main>`)へ移すか、値を `$connectedCallback` や `$watch` のハンドラから書いてください(`document.documentElement.lang = …`)。
138
+ - **`wcs/link-handler`**(error) — `<wcs-link>` の束縛に書いた `on*:`(`<wcs-link data-wcs="attr.to: .href; onclick: openPhoto">`)。リンクのホストは `display: none` で、利用者がクリックするのはリンクが自分の隣に作る `<a>` なので、ハンドラは走りません。ハンドラはリンクの中の要素(子は `<a>` の中へ移ります)か、リンクを囲む要素に書いてください。ハンドラから遷移するなら、router の `navigateUrl` に書きます。
139
+ - **`wcs/root-margin-unit`**(warning) — `<wcs-intersect>` / `<wcs-infinite-scroll>` の、ブラウザが拒むリテラルの `root-margin`: `root-margin="200"`・`"0 0 900 0"`。`IntersectionObserver` が受けるのは 1〜4 個の値で、それぞれ `px` か `%` の付いた数値です — `0` にも単位が要るので、`"0 0 900px 0"` も拒まれます(`rootMargin must be specified in pixels or percent`)。そのとき `<wcs-intersect>` は何も監視せず(`observing` は `false` のまま)、`<wcs-infinite-scroll>` は次のページを読み込みません。文面は `px` を足した書き方(`root-margin="0px 0px 900px 0px"`)を言います。束ねた `rootMargin:` は検査しません。
140
+ - **`wcs/getter-untracked-read`** は、ウィンドウと文書を読む getter も報告します: `innerWidth` / `innerHeight` / `outerWidth` / `outerHeight`、`devicePixelRatio`、`scrollX` / `scrollY` / `pageXOffset` / `pageYOffset`、`matchMedia(…)` の呼び出し、`navigator.onLine`、`document.documentElement` / `document.body` / `document.scrollingElement` の `clientWidth` / `clientHeight` / `scrollTop` / `scrollLeft`、`document.visibilityState` / `document.hidden` — `window.` / `globalThis.` の有無によりません。どれも state ではないので、キャッシュされた getter は最初の値を持ち続けます(`innerWidth` から列数を決める getter は、リサイズしても変わりません)。文面は代わりに束ねるものを言います: `<wcs-resize>` の `width` / `height`、`<wcs-media-query>` の `matched`(`matchMedia`・ブレークポイント・解像度のしきい値)、`<wcs-network>` の `offline`。スクロール位置とページの可視性を出す要素は無いので、値を state に置いてイベントハンドラから書いてください。getter やモジュールが束縛する名前(`const innerWidth = …`・引数)と、state の同名のキー(`this.innerWidth`)は報告しません。
141
+ - **`wcs/delegated-current-target`** は、ハンドラに入れ子にした関数の中も読みます: `openPhoto(event) { return this.photos.find((p) => String(p.id) === event.currentTarget.closest(".card").dataset.id); }` を、ハンドラの本体での読みと同じに報告します。引数を影にする関数と、`setTimeout`・`requestAnimationFrame`・`.then(…)`・`addEventListener` に渡した関数・オブジェクトに置いた関数(`img.onload = () => …`)は報告しません: その関数は dispatch の後に走り、`currentTarget` はどちらにしても `null` です。
142
+ - **JSDoc の 1 つのブロックの `@typedef` をすべて読みます。** 4.23 までは先頭の 1 つだけを読み(1 つのコメントに `/** @typedef {…} Photo` と `@typedef {…} Area */`)、2 つ目の型のリスト(`/** @type {Area[]} */ areas: []`)は、行のフィールドごとに `wcs/binding-path-missing` の誤報になりました。
143
+
144
+ 新しい 2 つの error は `--errors-only` にも出ます。新しい warning は `--strict` で失敗します。
145
+
121
146
  ## 生成 → 検証 → 修正ループでの利用
122
147
 
123
148
  安定した diagnostic code・`source:line:col` range・exit code 契約により、CI のゲートにも AI コード生成フローにもそのまま組み込めます: HTML を生成 → `npx @wcstack/lint --errors-only` → 診断を読んで修正 → exit code `0` になるまで再実行。このゲートが覆うのは `data-wcs` のページです: 出力が `not read:` や `nothing to check:` で終わるときは、そのファイルは検査されていません。
package/README.md CHANGED
@@ -118,6 +118,31 @@ Since 4.21, from the ledger-repair seam app — a maintainer fixing a household-
118
118
  - `wcs/array-index-assign` on a value not known to be an array (`budgetErrors: {}` with `this.budgetErrors[id] = …`) says it assigns an object's key, not "an array index".
119
119
  - The rows of a list the script changes in place (`this.budgetRows.splice(0, n, ...rows)`, reported as `wcs/array-mutation`) are not checked when no literal or JSDoc type gives their fields. Up to 4.20 each such row field was a false `wcs/binding-path-missing`, the same code as a real typo.
120
120
 
121
+ ## What a data-entry form is told
122
+
123
+ Since 4.23, from the ekiden-entry seam app — an entry wizard for a relay race, heavy on input: an IME, autofill, rows of inputs, form-associated custom elements. On its page the lint had said nothing about 21 mistakes made on purpose, and had given 91 false warnings about a state it could not read:
124
+
125
+ - **A key whose value the lint cannot read is unknown, not missing.** `team: init.team` beside `const init = emptyEntry()`, `errs: emptyErrs()`, a conditional, `[1, 2].map(…)`, the rows of `[newRunner()]`: the paths under such a key are not checked, and one `wcs/path-dynamic-unknown` info at the key says so — with the number of paths bound under it (a row's `.name` under the key's `for:` is one) and what has them checked: a JSDoc `@type` on the key, or a `stateSchema`. Up to 4.22 each of those paths was a false `wcs/binding-path-missing`, the same code as a real typo. A member of a `const` bound to an object literal (`team: DEFAULTS.team`, in the module or imported) is read, and the paths under it are checked.
126
+ - **`wcs/radio-name-shared`** (warning) — radios in a `for:` row with a literal `name` and a binding of the row's (`<input type="radio" name="sex" data-wcs="radio: .sex">`). Every row's radios get the same name, so the browser makes one group of all the rows: only one radio on the whole page stays checked, and the page disagrees with the rows' values from the first render. Bind a name that differs per row (`attr.name: .<a row field>`), or drop the name — `radio:` keeps the radios bound to one path in step without it. Not reported when the name is bound, when the bound path is not the row's (`value: .id; radio: selectedId` — one choice over the rows), or when each row holds its own `<form>`.
127
+ - **`wcs/number-written-as-string`** (warning) — a two-way `value:` with no conversion on the way in, bound to a path the state holds as a number: `<input type="number" data-wcs="value: count">` with `count: 0` (a JSDoc `@type {number}`, a `stateSchema` and a row field `value: .qty` count too). An element's `value` is a string, so after the user enters 5 the state has `"5"` and `count + 1` is `"51"`. Write `valueAsNumber: count`, or an input filter on the left side: `value|number: count` (`|int`, `|float`).
128
+ - **`wcs/two-way-output-filter`** (warning) — an output filter on a two-way `value:` / `valueAsNumber:` (`value: code|upper`, `value: price|locale`). In a field the user types in, the filter formats what the state holds on every keystroke: the field is rewritten while the user types — the caret jumps to the end, an IME composition is cut — and the state receives the field's formatted text, since an output filter is not undone on the way back. Show the formatted text in another element, write back when the field is committed and format in a setter (`value#onchange:`), or make the binding one-way (`value#ro:`). A binding that writes back a committed value (`#onchange`, a `<select>`, a slider) is reported only when no input filter undoes the output: `value#onchange|number: price|toFixed(2)` is not. Nor are the filters that give back what the element wrote: `string`, `nullIfEmpty`, `coalesce(…)`, `defaults('')`.
129
+ - **A boolean given to `attr.*`** (`wcs/binding-type-expectation`) is told what happens to it: the runtime writes `String(value)` — `"true"` / `"false"` — and only `null` / `undefined` remove an attribute. Where those words are the attribute's values — the ARIA states (`attr.aria-invalid: flag|truthy`), `contenteditable`, `draggable`, `spellcheck` — nothing is reported any more (it was a false warning: `"attr.aria-invalid" requires a string`). A boolean attribute of a native element (`attr.disabled: flag`) is told that `disabled="false"` still disables, with the property to bind instead (`disabled: flag`). Any other attribute (`attr.data-open: flag`) is told that it is written as the text and never removed, with `|defaults(null)` to remove it while false and `|string` where the text is meant.
130
+
131
+ The three new rules are warnings: `--strict` fails on them, `--errors-only` does not print them.
132
+
133
+ ## What a long list's page is told
134
+
135
+ Since 4.24, from the town-archive seam app — an archive of 12,000 photos: a long list with infinite scroll. What its page got wrong and this lint did not say:
136
+
137
+ - **`wcs/body-binding`** (error) — `data-wcs` on `<body>` or `<html>` (`<body data-wcs="onkeydown: onKey; class.dark: dark">`). `<wcs-state>` binds what is inside `<body>`, not `<body>` or `<html>` themselves, so nothing written there does anything: the handler never runs, `class.` and `attr.` are never written. Move the binding to an element inside `<body>` (a wrapper, `<main>`), or write the value from `$connectedCallback` or a `$watch` handler (`document.documentElement.lang = …`).
138
+ - **`wcs/link-handler`** (error) — an `on*:` binding on a `<wcs-link>` (`<wcs-link data-wcs="attr.to: .href; onclick: openPhoto">`). The link's host is `display: none`, and what the user clicks is the `<a>` the link generates beside itself, so the handler never runs. Put it on an element inside the link (its children move into the `<a>`) or on one around it; to navigate from a handler, write the router's `navigateUrl`.
139
+ - **`wcs/root-margin-unit`** (warning) — a literal `root-margin` on `<wcs-intersect>` or `<wcs-infinite-scroll>` that the browser refuses: `root-margin="200"`, `"0 0 900 0"`. `IntersectionObserver` takes one to four values, each a number with `px` or `%` — a `0` needs its unit too, so `"0 0 900px 0"` is refused as well (`rootMargin must be specified in pixels or percent`). `<wcs-intersect>` then observes nothing (`observing` stays `false`) and `<wcs-infinite-scroll>` loads no page. The message gives the value with `px` added (`root-margin="0px 0px 900px 0px"`). A bound `rootMargin:` is not checked.
140
+ - **`wcs/getter-untracked-read`** also reports a getter that reads the window or the document: `innerWidth` / `innerHeight` / `outerWidth` / `outerHeight`, `devicePixelRatio`, `scrollX` / `scrollY` / `pageXOffset` / `pageYOffset`, a call of `matchMedia(…)`, `navigator.onLine`, the `clientWidth` / `clientHeight` / `scrollTop` / `scrollLeft` of `document.documentElement` / `document.body` / `document.scrollingElement`, `document.visibilityState` / `document.hidden` — with or without `window.` / `globalThis.`. None of them is state, so the cached getter keeps its first value (a column count computed from `innerWidth` does not change on a resize). The message names what to bind instead: `<wcs-resize>`'s `width` / `height`, `<wcs-media-query>`'s `matched` (for `matchMedia`, a breakpoint, a resolution threshold), `<wcs-network>`'s `offline`. No element gives the scroll position or the page's visibility: keep the value in state and write it from an event handler. A name the getter or the module binds (`const innerWidth = …`, a parameter) and a state key of the same name (`this.innerWidth`) are not reported.
141
+ - **`wcs/delegated-current-target`** also reads the functions nested in the handler: `openPhoto(event) { return this.photos.find((p) => String(p.id) === event.currentTarget.closest(".card").dataset.id); }` is reported like a read in the handler's own body. Not a function that shadows the parameter, nor one handed to `setTimeout`, `requestAnimationFrame`, `.then(…)` or `addEventListener`, nor one stored on an object (`img.onload = () => …`): such a function runs after the dispatch, when `currentTarget` is `null` either way.
142
+ - **Every `@typedef` of a JSDoc block is read.** Up to 4.23 only the first one of a block was (`/** @typedef {…} Photo` and `@typedef {…} Area */` in one comment), and a list typed with the second (`/** @type {Area[]} */ areas: []`) got a false `wcs/binding-path-missing` for each field of its rows.
143
+
144
+ `--errors-only` prints the two new errors; `--strict` also fails on the new warning.
145
+
121
146
  ## Use in generate–validate–fix loops
122
147
 
123
148
  Stable diagnostic codes, `source:line:col` ranges, and the exit-code contract make this CLI a drop-in gate for CI and for AI code-generation flows: generate HTML → `npx @wcstack/lint --errors-only` → read the diagnostics, fix, and re-run until exit code `0`. The gate covers `data-wcs` pages: when the output ends with `not read:` or `nothing to check:`, those files were not checked.
package/dist/cli.cjs CHANGED
@@ -290,7 +290,8 @@ var WcsDiagnosticCode = {
290
290
  // の依存で足りる — 行の置換は `items` 自体を書き換え、in-place 変異は array-mutation が止める)。
291
291
  // 読んだパスをページの束縛(組み込みタグの spread・書き戻す束縛・要素の出力)が書くなら error(その書き込みは
292
292
  // getter に届かないと断定できる — 継ぎ目アプリ family-ledger)、スクリプトの書き込みだけなら warning(ルートも
293
- // 置き換えるなら壊れない)。時刻・`location` を読む getter も同じ code(warning)。
293
+ // 置き換えるなら壊れない)。時刻・`location`・ウィンドウと文書の値(`innerWidth`・`scrollY`・`matchMedia(…)`・
294
+ // `navigator.onLine`・`document.hidden` など)を読む getter も同じ code(warning)。
294
295
  GetterUntrackedRead: "wcs/getter-untracked-read",
295
296
  OnHandlerThis: "wcs/on-handler-this",
296
297
  // --- <wcs-state> script: $watch declaration ---
@@ -369,7 +370,8 @@ var WcsDiagnosticCode = {
369
370
  // `currentTarget` を同期的に読む。委譲されたイベントの `currentTarget` は要素ではなく root なので、要素を
370
371
  // 使う処理(`setPointerCapture`・`getBoundingClientRect`・`new FormData(e.currentTarget)`)が壊れる。
371
372
  // ランタイムは何も報告しない(root は正しい値)ので lint の code。`#direct` か `event.target.closest(...)` を
372
- // 案内する。読みが実行されない分岐にあることもあるので warning。
373
+ // 案内する。読みが実行されない分岐にあることもあるので warning。本体に入れ子にした関数の中の読み
374
+ // (`this.items.find((x) => … event.currentTarget …)`)も拾う — 後で呼ばれる関数(`setTimeout` などに渡したもの)は除く。
373
375
  DelegatedCurrentTarget: "wcs/delegated-current-target",
374
376
  // `<form data-wcs="onsubmit: login">` の `#prevent` 忘れ(ハンドラも preventDefault を呼ばない)。ブラウザが
375
377
  // フォームも送る — ページが読み直されるか、router があれば GET が欄(パスワードも)を URL と履歴に載せる
@@ -432,6 +434,41 @@ var WcsDiagnosticCode = {
432
434
  // 置き、文と一緒に挿入される。スクリーンリーダーは読み上げない(読み上げるのは、ページにある間に文が変わったとき)。
433
435
  // 挿入で読み上げられる `role="alert"` は対象外。継ぎ目アプリ city-library(view transition ありの Chromium で 0/10)。warning。
434
436
  LiveRegionInserted: "wcs/live-region-inserted",
437
+ // --- フォームの入力(要素の束縛が、利用者の入力に対して何をするか。service/formInputValidator.ts) ---
438
+ // `for:` の行の中の、`name` をリテラルで書いたラジオ(`<input type="radio" name="sex" data-wcs="radio: .sex">`)。
439
+ // どの行のラジオも同じ name になるので、ブラウザは全部の行を 1 つのグループにする: ページ全体で 1 つしか選ばれた
440
+ // 状態にならず、表示は最初の描画から行ごとの値と食い違う。ランタイムは何も言わない(ブラウザの規則 — 継ぎ目アプリ
441
+ // ekiden-entry)。name を束ねてあるとき(`attr.name:`)・行のものでないパス(`radio: selectedId` — 行をまたぐ 1 つの
442
+ // グループが意図)・行ごとに `<form>` があるときは黙る。warning。
443
+ RadioNameShared: "wcs/radio-name-shared",
444
+ // 書き戻すときに変換しない双方向の `value:` が、state が数値で持つパス(種・JSDoc の `@type`・stateSchema)を指す。
445
+ // 要素の `value` は文字列なので、5 と入力した後の state は `"5"` で、`count + 1` は `"51"` になる。ランタイムは何も
446
+ // 言わない(ekiden-entry — 弁当 1 個と 2 個が 12 個になった)。数値にする入力フィルタ(`value|number:`)・
447
+ // `valueAsNumber:`・`#ro`・アクセサペア(setter が変換しうる)では黙る。warning。
448
+ NumberWrittenAsString: "wcs/number-written-as-string",
449
+ // 双方向の `value:` / `valueAsNumber:` に付けた出力フィルタ(`value: code|upper`・`value: price|locale`)。フィルタは
450
+ // 要素が書き戻すたび(既定では 1 打鍵ごと)に state の値を整形して欄へ書き直す: キャレットは末尾へ飛び、IME の変換は
451
+ // 途切れ、state が受け取るのは整形済みの文字(出力フィルタは書き戻しで元に戻らない)。確定した値を書き戻す束縛
452
+ // (`#onchange`・スライダー・`<select>`)は入力中に書き換わらないので、入力フィルタ(作者が用意した戻り道 —
453
+ // `value#onchange|number: price|toFixed(2)`)が無いときだけ報告する。要素の書いた文字をそのまま返すフィルタ
454
+ // (`string`・`nullIfEmpty`・`coalesce(…)`・`defaults('')`)と `#ro` では黙る。warning。
455
+ TwoWayOutputFilter: "wcs/two-way-output-filter",
456
+ // --- 束縛を書いた要素(その要素では束縛が働かない。service/bindingHostValidator.ts — 継ぎ目アプリ town-archive) ---
457
+ // `<body>` / `<html>` に書いた束縛の属性(`<body data-wcs="onkeydown: onKey; class.dark: dark">`)。`<wcs-state>` が束ねるのは
458
+ // `<body>` の中で、`<body>` と `<html>` そのものは束ねない(state の dom/mount.ts は `document.body` の子から歩く)ので、
459
+ // そこに書いた束縛は何もしない — イベントのハンドラは走らず、`class.` / `attr.` は書かれない。4.23 までランタイムは
460
+ // 何も言わない(4.24 から diagnostics の後付けが同じ code で警告する)。束縛は `<body>` の中の要素へ移すか、値を
461
+ // `$connectedCallback` / `$watch` から書く。error。
462
+ BodyBinding: "wcs/body-binding",
463
+ // `<wcs-link>` の束縛に書いた `on*:`(`<wcs-link data-wcs="attr.to: .href; onclick: openPhoto">`)。リンクのホストは
464
+ // `display: none` で、利用者がクリックするのはリンクが自分の隣に作る `<a>` なので、ハンドラは走らない。ハンドラは
465
+ // リンクの中の要素(子は `<a>` へ移る)か囲む要素に書き、ハンドラから遷移するなら router の `navigateUrl` に書く。error。
466
+ LinkHandler: "wcs/link-handler",
467
+ // `<wcs-intersect>` / `<wcs-infinite-scroll>` のリテラルの `root-margin` をブラウザが拒む(`root-margin="200"`・
468
+ // `"0 0 900 0"`): 値は 1〜4 個、それぞれ px か % の付いた数値で、0 にも単位が要る(Chromium・Firefox で確かめた —
469
+ // `rootMargin must be specified in pixels or percent`)。`<wcs-intersect>` は何も監視せず `observing` が false のまま、
470
+ // `<wcs-infinite-scroll>` は次のページを読み込まない。束ねた値(`rootMargin: …`)は検査しない。warning。
471
+ RootMarginUnit: "wcs/root-margin-unit",
435
472
  // --- document-level load configuration ---
436
473
  // @wcstack/state/auto より後に @wcstack/devtools/auto が読まれている。info: 4.0 は後から付いた DevTools に
437
474
  // 既存の束縛を送り直すので、欠けるのは付く前のタイムラインだけ。
@@ -1997,7 +2034,7 @@ var config = {
1997
2034
  locale: typeof document !== "undefined" ? document.documentElement?.lang || "en" : "en",
1998
2035
  enableContractAnalyzer: false
1999
2036
  };
2000
- var FEATURE_NAMES = ["formats", "diagnostics", "temporal", "list-keys", "scopes", "recursion", "ssr", "devtools", "native-commands", "release"];
2037
+ var FEATURE_NAMES = ["formats", "diagnostics", "temporal", "list-keys", "scopes", "recursion", "ssr", "devtools", "native-commands", "release", "forms"];
2001
2038
  var NATIVE_COMMANDS = {
2002
2039
  "*": ["focus", "blur", "click", "scrollIntoView", "showPopover", "hidePopover", "togglePopover"],
2003
2040
  "dialog": ["show", "showModal", "close", "requestClose"],
@@ -2564,7 +2601,7 @@ function getWcsManifest() {
2564
2601
  }
2565
2602
 
2566
2603
  // ../state/package.json
2567
- var version = "4.22.0";
2604
+ var version = "4.24.0";
2568
2605
 
2569
2606
  // src/service/wcsManifest.ts
2570
2607
  var ENGINE_VERSION = version;
@@ -8632,8 +8669,10 @@ function findJsDocComments(script, scan) {
8632
8669
  function readJsDocTagType(comment, tag) {
8633
8670
  return readBracedType(comment, tag)?.type.trim() ?? null;
8634
8671
  }
8635
- function readBracedType(comment, tag) {
8636
- const tagMatch = new RegExp(`@${tag}\\s*\\{`).exec(comment);
8672
+ function readBracedType(comment, tag, from = 0) {
8673
+ const tagRegex = new RegExp(`@${tag}\\s*\\{`, "g");
8674
+ tagRegex.lastIndex = from;
8675
+ const tagMatch = tagRegex.exec(comment);
8637
8676
  if (!tagMatch) return null;
8638
8677
  const open = tagMatch.index + tagMatch[0].length - 1;
8639
8678
  let depth = 0;
@@ -8670,11 +8709,15 @@ function jsDocCommentBefore(content, propIndex) {
8670
8709
  function collectJsDocTypedefs(script, scan) {
8671
8710
  const typedefs = /* @__PURE__ */ new Map();
8672
8711
  for (const { text: comment } of findJsDocComments(script, scan)) {
8673
- const braced = readBracedType(comment, "typedef");
8674
- if (braced === null) continue;
8675
- const name = /^\s*([$A-Za-z_][$\w]*)/.exec(comment.slice(braced.end));
8676
- const type = parseJsDocType(braced.type);
8677
- if (name && type !== null) typedefs.set(name[1], type);
8712
+ let from = 0;
8713
+ for (; ; ) {
8714
+ const braced = readBracedType(comment, "typedef", from);
8715
+ if (braced === null) break;
8716
+ from = braced.end;
8717
+ const name = /^\s*([$A-Za-z_][$\w]*)/.exec(comment.slice(braced.end));
8718
+ const type = parseJsDocType(braced.type);
8719
+ if (name && type !== null) typedefs.set(name[1], type);
8720
+ }
8678
8721
  }
8679
8722
  return typedefs;
8680
8723
  }
@@ -10017,7 +10060,8 @@ function pushDataPropertyPathsAt(path, prop, paths, depth, typedefs, scope) {
10017
10060
  let candidate;
10018
10061
  let unread = null;
10019
10062
  if (followed === null) {
10020
- candidate = { path, kind: "data", typeHint: prop.typeHint, rawInitial: prop.value?.trim() };
10063
+ const opaque2 = prop.value !== void 0 && prop.declaredType === void 0 && isUnreadExpression(prop.value) ? { opaque: unreadExpression(prop.value, scope) } : {};
10064
+ candidate = { path, kind: "data", typeHint: prop.typeHint, rawInitial: prop.value?.trim(), ...opaque2 };
10021
10065
  paths.push(candidate);
10022
10066
  unread = pushLiteralStructurePaths(path, prop, paths, depth, typedefs, scope);
10023
10067
  } else {
@@ -10131,6 +10175,45 @@ function isReadableLiteral(text3) {
10131
10175
  const v = text3.trim();
10132
10176
  return /^[[{"'`]/.test(v) || /^-?\.?\d/.test(v) || WORD_LITERALS.has(v) || /^(?:async\s+)?function\b/.test(v) || /^(?:async\s*)?(?:\([^()]*\)|[$\w]+)\s*=>/.test(v);
10133
10177
  }
10178
+ function isUnreadExpression(value) {
10179
+ const v = value.trim();
10180
+ if (!isReadableLiteral(v)) return true;
10181
+ const open = v[0];
10182
+ if (open !== "[" && open !== "{") return false;
10183
+ const scan = maskCommentsAndStrings(v);
10184
+ const inner = extractDelimitedContent(v, scan, 0, open, open === "[" ? "]" : "}");
10185
+ const rest = scan.slice(inner.length + 2).replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g, " ").trimStart();
10186
+ return /^(?:\?\.|\.|\[|\()/.test(rest);
10187
+ }
10188
+ var MAX_UNREAD_TEXT = 40;
10189
+ function unreadExpression(value, scope) {
10190
+ const flat = value.trim().replace(/^(?:\/\*[\s\S]*?\*\/\s*|\/\/[^\n]*\n\s*)+/, "").replace(/\s+/g, " ");
10191
+ const name = flat.length <= MAX_UNREAD_TEXT ? flat : `${flat.slice(0, MAX_UNREAD_TEXT - 1)}\u2026`;
10192
+ const root = /^(?:\.\.\.|(?:new|await)\s+)*([$A-Za-z_][$\w]*)/.exec(flat)?.[1];
10193
+ const from = root === void 0 || scope === void 0 ? void 0 : scope.importOf(root);
10194
+ return { name, ...from !== void 0 ? { from } : {} };
10195
+ }
10196
+ function firstArrayElement(value) {
10197
+ const trimmed = value.trim();
10198
+ const scan = maskCommentsAndStrings(trimmed).replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g, (c) => " ".repeat(c.length));
10199
+ const element2 = (end) => {
10200
+ const from = 1 + (scan.slice(1, end).length - scan.slice(1, end).trimStart().length);
10201
+ return scan.slice(from, end).trim() === "" ? null : trimmed.slice(from, end).trim();
10202
+ };
10203
+ let depth = 0;
10204
+ for (let i = 1; i < scan.length; i++) {
10205
+ const ch = scan[i];
10206
+ if (ch === "{" || ch === "[" || ch === "(") {
10207
+ depth++;
10208
+ } else if (ch === "}" || ch === "]" || ch === ")") {
10209
+ if (depth === 0) return element2(i);
10210
+ depth--;
10211
+ } else if (ch === "," && depth === 0) {
10212
+ return element2(i);
10213
+ }
10214
+ }
10215
+ return null;
10216
+ }
10134
10217
  function followValue(prop, scope) {
10135
10218
  const type = parseTypeImport(prop.jsdocText);
10136
10219
  let current2;
@@ -10144,12 +10227,20 @@ function followValue(prop, scope) {
10144
10227
  if (prop.value === void 0) return null;
10145
10228
  const written = prop.value.trim();
10146
10229
  const text3 = unwrapFreeze(written);
10147
- if (!isFollowableName(text3, scope)) return text3 === written ? null : { value: { text: text3, scope } };
10148
- name = text3;
10149
- from = scope.importOf(text3);
10150
- const resolved = scope.resolveName(text3);
10151
- if (resolved === null) return { value: null, name, from };
10152
- current2 = resolved;
10230
+ if (!isFollowableName(text3, scope)) {
10231
+ const member = followMember(text3, scope);
10232
+ if (member === void 0) return text3 === written ? null : { value: { text: text3, scope } };
10233
+ name = text3;
10234
+ from = member.from;
10235
+ if (member.value === null) return { value: null, name, from };
10236
+ current2 = member.value;
10237
+ } else {
10238
+ name = text3;
10239
+ from = scope.importOf(text3);
10240
+ const resolved = scope.resolveName(text3);
10241
+ if (resolved === null) return { value: null, name, from };
10242
+ current2 = resolved;
10243
+ }
10153
10244
  }
10154
10245
  for (let hops = 0; hops < 8; hops++) {
10155
10246
  const inner = unwrapFreeze(current2.text);
@@ -10160,6 +10251,38 @@ function followValue(prop, scope) {
10160
10251
  }
10161
10252
  return { value: null, name, from };
10162
10253
  }
10254
+ function followMember(text3, scope) {
10255
+ const m = /^([$A-Za-z_][$\w]*)((?:\s*\.\s*[$A-Za-z_][$\w]*)+)$/.exec(text3);
10256
+ if (m === null || WORD_LITERALS.has(m[1])) return void 0;
10257
+ const root = m[1];
10258
+ let keys = m[2].split(".").map((key) => key.trim()).filter((key) => key !== "");
10259
+ let current2;
10260
+ if (scope.isNamespaceMember(`${root}.${keys[0]}`)) {
10261
+ current2 = scope.resolveName(`${root}.${keys[0]}`);
10262
+ keys = keys.slice(1);
10263
+ } else {
10264
+ current2 = scope.resolveName(root);
10265
+ if (current2 === null) return void 0;
10266
+ }
10267
+ const from = scope.importOf(root);
10268
+ const unread = { value: null, ...from !== void 0 ? { from } : {} };
10269
+ for (const key of keys) {
10270
+ let literal2 = current2;
10271
+ for (let hops = 0; literal2 !== null && hops < MAX_SPREAD_HOPS; hops++) {
10272
+ const inner = unwrapFreeze(literal2.text);
10273
+ if (isObjectLiteral(inner)) {
10274
+ literal2 = { text: inner, scope: literal2.scope };
10275
+ break;
10276
+ }
10277
+ literal2 = isFollowableName(inner, literal2.scope) ? literal2.scope.resolveName(inner) : null;
10278
+ }
10279
+ if (literal2 === null || !isObjectLiteral(literal2.text)) return unread;
10280
+ const found = objectLiteralKeys(extractObjectContent(literal2.text), literal2.scope, true).keys.find((k) => k.prop.name === key);
10281
+ if (found === void 0 || found.prop.value === void 0) return unread;
10282
+ current2 = { text: found.prop.value, scope: found.scope ?? literal2.scope };
10283
+ }
10284
+ return { value: current2, ...from !== void 0 ? { from } : {} };
10285
+ }
10163
10286
  function pushDeclaredShapePaths(path, type, paths, depth, typedefs) {
10164
10287
  const shape = jsDocShape(type, typedefs);
10165
10288
  if (shape.index !== void 0) {
@@ -10187,7 +10310,11 @@ function pushLiteralStructurePaths(path, prop, paths, depth, typedefs, scope) {
10187
10310
  paths.push({ path: `${path}.length`, kind: "data", typeHint: "number" });
10188
10311
  if (depth >= MAX_OBJECT_NEST_DEPTH) return null;
10189
10312
  const first = firstRowObjectContent(prop.value);
10190
- if (first === null) return null;
10313
+ if (first === null) {
10314
+ const element2 = prop.declaredType === void 0 ? firstArrayElement(prop.value) : null;
10315
+ if (element2 !== null && !isReadableLiteral(element2)) row.opaque = unreadExpression(element2, scope);
10316
+ return null;
10317
+ }
10191
10318
  const { keys, unread } = objectLiteralKeys(first, scope, false);
10192
10319
  for (const key of keys) {
10193
10320
  pushDataPropertyPathsAt(`${path}.*.${key.prop.name}`, key.prop, paths, depth + 1, typedefs, key.scope);
@@ -11627,28 +11754,35 @@ ${body}
11627
11754
  const eventName = first.name;
11628
11755
  const rebound = /* @__PURE__ */ new Set();
11629
11756
  for (const param of fn.params.slice(1)) bindingNames(param, rebound);
11630
- let suspendAt = Infinity;
11631
- const scanBindings = (node, nested) => {
11757
+ const scanBindings = (node) => {
11632
11758
  if (isFunctionNode(node)) {
11633
11759
  if (node.type === "FunctionDeclaration" && node.id !== null) rebound.add(node.id.name);
11634
11760
  for (const param of node.params) bindingNames(param, rebound);
11635
- scanBindings(node.body, true);
11636
- return;
11637
- }
11638
- if (node.type === "VariableDeclarator") bindingNames(node.id, rebound);
11761
+ } else if (node.type === "VariableDeclarator") bindingNames(node.id, rebound);
11639
11762
  else if (node.type === "CatchClause" && node.param !== null && node.param !== void 0) bindingNames(node.param, rebound);
11640
11763
  else if (node.type === "AssignmentExpression" && node.left.type === "Identifier") rebound.add(node.left.name);
11641
11764
  else if (node.type === "ClassDeclaration" && node.id !== null) rebound.add(node.id.name);
11642
- if (!nested && node.type === "AwaitExpression") suspendAt = Math.min(suspendAt, node.argument.end);
11643
- else if (!nested && node.type === "ForOfStatement" && node.await) suspendAt = Math.min(suspendAt, node.right.end);
11644
- forEachChild(node, (child) => scanBindings(child, nested));
11765
+ forEachChild(node, scanBindings);
11645
11766
  };
11646
- scanBindings(fn.body, false);
11767
+ scanBindings(fn.body);
11647
11768
  if (rebound.has(eventName)) return false;
11648
11769
  let found = false;
11649
- const visitReads = (node) => {
11650
- if (found || isFunctionNode(node) || isClassNode(node)) return;
11651
- if (node.start >= suspendAt) return;
11770
+ const visitReads = (node, suspendAt) => {
11771
+ if (found || isClassNode(node) || node.start >= suspendAt) return;
11772
+ if (isFunctionNode(node)) {
11773
+ const limit = Math.min(suspendAt, firstSuspend(node.body));
11774
+ forEachChild(node, (child) => visitReads(child, limit));
11775
+ return;
11776
+ }
11777
+ if (node.type === "CallExpression" && isDeferredCall(node)) {
11778
+ visitReads(node.callee, suspendAt);
11779
+ for (const argument of node.arguments) if (!isFunctionNode(argument)) visitReads(argument, suspendAt);
11780
+ return;
11781
+ }
11782
+ if (node.type === "AssignmentExpression" && isFunctionNode(node.right) && unwrapChain(node.left).type === "MemberExpression") {
11783
+ visitReads(node.left, suspendAt);
11784
+ return;
11785
+ }
11652
11786
  if (node.type === "MemberExpression" && node.object.type === "Identifier" && node.object.name === eventName && memberPropertyIs(node, "currentTarget")) {
11653
11787
  found = true;
11654
11788
  return;
@@ -11657,11 +11791,38 @@ ${body}
11657
11791
  found = true;
11658
11792
  return;
11659
11793
  }
11660
- forEachChild(node, visitReads);
11794
+ forEachChild(node, (child) => visitReads(child, suspendAt));
11661
11795
  };
11662
- visitReads(fn.body);
11796
+ visitReads(fn.body, firstSuspend(fn.body));
11663
11797
  return found;
11664
11798
  }
11799
+ var DEFERRED_CALLS = /* @__PURE__ */ new Set([
11800
+ "setTimeout",
11801
+ "setInterval",
11802
+ "requestAnimationFrame",
11803
+ "requestIdleCallback",
11804
+ "queueMicrotask",
11805
+ "then",
11806
+ "catch",
11807
+ "finally",
11808
+ "addEventListener"
11809
+ ]);
11810
+ function isDeferredCall(node) {
11811
+ const callee = unwrapChain(node.callee);
11812
+ if (callee.type === "Identifier") return DEFERRED_CALLS.has(callee.name);
11813
+ return callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier" && DEFERRED_CALLS.has(callee.property.name);
11814
+ }
11815
+ function firstSuspend(body) {
11816
+ let at2 = Infinity;
11817
+ const scan = (node) => {
11818
+ if (isFunctionNode(node) || isClassNode(node)) return;
11819
+ if (node.type === "AwaitExpression") at2 = Math.min(at2, node.argument.end);
11820
+ else if (node.type === "ForOfStatement" && node.await) at2 = Math.min(at2, node.right.end);
11821
+ forEachChild(node, scan);
11822
+ };
11823
+ scan(body);
11824
+ return at2;
11825
+ }
11665
11826
  function memberPropertyIs(node, name) {
11666
11827
  const property = node.property;
11667
11828
  if (!node.computed) return property.type === "Identifier" && property.name === name;
@@ -11888,12 +12049,158 @@ function findLocationRead(body) {
11888
12049
  walk2(wrapper.body);
11889
12050
  return found;
11890
12051
  }
12052
+ var WINDOW_HOLDERS = /* @__PURE__ */ new Set(["window", "globalThis", "self"]);
12053
+ var WINDOW_VALUES = /* @__PURE__ */ new Map([
12054
+ ["innerWidth", "size"],
12055
+ ["innerHeight", "size"],
12056
+ ["outerWidth", "size"],
12057
+ ["outerHeight", "size"],
12058
+ ["devicePixelRatio", "pixelRatio"],
12059
+ ["scrollX", "scroll"],
12060
+ ["scrollY", "scroll"],
12061
+ ["pageXOffset", "scroll"],
12062
+ ["pageYOffset", "scroll"]
12063
+ ]);
12064
+ var DOCUMENT_ELEMENTS = /* @__PURE__ */ new Set(["documentElement", "body", "scrollingElement"]);
12065
+ var ELEMENT_VALUES = /* @__PURE__ */ new Map([
12066
+ ["clientWidth", "size"],
12067
+ ["clientHeight", "size"],
12068
+ ["scrollTop", "scroll"],
12069
+ ["scrollLeft", "scroll"]
12070
+ ]);
12071
+ var DOCUMENT_VALUES = /* @__PURE__ */ new Map([["visibilityState", "visibility"], ["hidden", "visibility"]]);
12072
+ var AMBIENT_READ_SPELLING = /\b(?:(?:inner|outer|client)(?:Width|Height)|devicePixelRatio|scroll[XY]|page[XY]Offset|scroll(?:Top|Left)|matchMedia|onLine|visibilityState|hidden)\b/;
12073
+ function ambientKindOf(names2) {
12074
+ if (names2.length === 1) return WINDOW_VALUES.get(names2[0]) ?? null;
12075
+ if (names2[0] === "navigator") return names2.length === 2 && names2[1] === "onLine" ? "online" : null;
12076
+ if (names2[0] !== "document") return null;
12077
+ if (names2.length === 2) return DOCUMENT_VALUES.get(names2[1]) ?? null;
12078
+ return names2.length === 3 && DOCUMENT_ELEMENTS.has(names2[1]) ? ELEMENT_VALUES.get(names2[2]) ?? null : null;
12079
+ }
12080
+ function findAmbientRead(body, outer = /* @__PURE__ */ new Set()) {
12081
+ let program;
12082
+ try {
12083
+ program = parse3(PREFIX + body + SUFFIX, { ecmaVersion: "latest", sourceType: "module" });
12084
+ } catch {
12085
+ return null;
12086
+ }
12087
+ const wrapper = unwrapWrapper(program);
12088
+ if (wrapper === null) return null;
12089
+ const bound = new Set(outer);
12090
+ const scan = (node) => {
12091
+ if (isFunctionNode(node)) {
12092
+ if (node.type === "FunctionDeclaration" && node.id !== null) bound.add(node.id.name);
12093
+ for (const param of node.params) bindingNames(param, bound);
12094
+ } else if (node.type === "VariableDeclarator") bindingNames(node.id, bound);
12095
+ else if (node.type === "CatchClause" && node.param !== null && node.param !== void 0) bindingNames(node.param, bound);
12096
+ else if (node.type === "ClassDeclaration" && node.id !== null) bound.add(node.id.name);
12097
+ forEachChild(node, scan);
12098
+ };
12099
+ scan(wrapper.body);
12100
+ const globalChain = (node) => {
12101
+ const names2 = [];
12102
+ let current2 = unwrapChain(node);
12103
+ while (current2.type === "MemberExpression") {
12104
+ const property = current2.property;
12105
+ if (!current2.computed && property.type === "Identifier") names2.unshift(property.name);
12106
+ else if (current2.computed && property.type === "Literal" && typeof property.value === "string") names2.unshift(property.value);
12107
+ else return null;
12108
+ current2 = unwrapChain(current2.object);
12109
+ }
12110
+ if (current2.type !== "Identifier" || bound.has(current2.name)) return null;
12111
+ names2.unshift(current2.name);
12112
+ while (names2.length > 1 && WINDOW_HOLDERS.has(names2[0])) names2.shift();
12113
+ return names2;
12114
+ };
12115
+ let found = null;
12116
+ const source = (node) => (PREFIX + body).slice(node.start, node.end);
12117
+ const at2 = (node, kind, text3) => {
12118
+ found = { start: node.start - PREFIX.length, end: node.end - PREFIX.length, text: text3, kind };
12119
+ };
12120
+ const walk2 = (node) => {
12121
+ if (found !== null) return;
12122
+ if (node.type === "CallExpression") {
12123
+ const chain = globalChain(node.callee);
12124
+ if (chain !== null && chain.length === 1 && chain[0] === "matchMedia") {
12125
+ at2(node.callee, "media", `${source(node.callee)}(\u2026)`);
12126
+ return;
12127
+ }
12128
+ }
12129
+ if (node.type === "Identifier" || node.type === "MemberExpression") {
12130
+ const chain = globalChain(node);
12131
+ const kind = chain === null ? null : ambientKindOf(chain);
12132
+ if (kind !== null) {
12133
+ at2(node, kind, source(node));
12134
+ return;
12135
+ }
12136
+ }
12137
+ if (node.type === "VariableDeclarator" && node.id.type === "ObjectPattern" && node.init !== null && node.init !== void 0) {
12138
+ const chain = globalChain(node.init);
12139
+ if (chain !== null) {
12140
+ const prefix = chain.length === 1 && WINDOW_HOLDERS.has(chain[0]) ? [] : chain;
12141
+ for (const property of node.id.properties) {
12142
+ if (property.type !== "Property" || property.computed) continue;
12143
+ const key = property.key.type === "Identifier" ? property.key.name : property.key.type === "Literal" && typeof property.key.value === "string" ? property.key.value : null;
12144
+ const kind = key === null ? null : ambientKindOf([...prefix, key]);
12145
+ if (kind !== null) {
12146
+ at2(property.key, kind, `${source(node.init)}.${key}`);
12147
+ return;
12148
+ }
12149
+ }
12150
+ }
12151
+ }
12152
+ if (node.type === "MemberExpression") {
12153
+ walk2(node.object);
12154
+ if (node.computed) walk2(node.property);
12155
+ return;
12156
+ }
12157
+ if (node.type === "Property" || node.type === "MethodDefinition" || node.type === "PropertyDefinition") {
12158
+ if (node.computed) walk2(node.key);
12159
+ if (node.value !== null && node.value !== void 0) walk2(node.value);
12160
+ return;
12161
+ }
12162
+ if (node.type === "LabeledStatement") {
12163
+ walk2(node.body);
12164
+ return;
12165
+ }
12166
+ if (node.type === "BreakStatement" || node.type === "ContinueStatement") return;
12167
+ forEachChild(node, walk2);
12168
+ };
12169
+ walk2(wrapper.body);
12170
+ return found;
12171
+ }
12172
+ function moduleBindingNames(script) {
12173
+ const names2 = /* @__PURE__ */ new Set();
12174
+ let program;
12175
+ try {
12176
+ program = parse3(script, { ecmaVersion: "latest", sourceType: "module", allowHashBang: true, allowAwaitOutsideFunction: true });
12177
+ } catch {
12178
+ return names2;
12179
+ }
12180
+ if (program.type !== "Program") return names2;
12181
+ for (const statement of program.body) {
12182
+ if (statement.type === "ImportDeclaration") {
12183
+ for (const specifier of statement.specifiers) names2.add(specifier.local.name);
12184
+ continue;
12185
+ }
12186
+ const declaration = statement.type === "ExportNamedDeclaration" && statement.declaration ? statement.declaration : statement;
12187
+ if (declaration.type === "VariableDeclaration") {
12188
+ for (const declarator of declaration.declarations) bindingNames(declarator.id, names2);
12189
+ } else if ((declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration") && declaration.id) {
12190
+ names2.add(declaration.id.name);
12191
+ }
12192
+ }
12193
+ return names2;
12194
+ }
11891
12195
 
11892
12196
  // src/core/messages.ts
11893
12197
  function resolveLocale(locale2) {
11894
12198
  if (locale2 === void 0 || locale2 === "" || /^ja\b|^ja[-_]/i.test(locale2) || locale2.toLowerCase() === "ja") return "ja";
11895
12199
  return "en";
11896
12200
  }
12201
+ function isUnitlessZero(token) {
12202
+ return /^[+-]?(?:0+\.?0*|\.0+)$/.test(token);
12203
+ }
11897
12204
  function shortSeed(raw) {
11898
12205
  const flat = raw.replace(/\s+/g, " ");
11899
12206
  return flat.length <= 32 ? flat : `${flat.slice(0, 29)}\u2026`;
@@ -11930,6 +12237,23 @@ var ja = {
11930
12237
  onHandlerThis: (name) => `$on \u306E\u30CF\u30F3\u30C9\u30E9 "${name}" \u304C this \u3092\u4F7F\u3063\u3066\u3044\u307E\u3059\u3002$on \u306E\u30CF\u30F3\u30C9\u30E9\u306F state \u3092\u7B2C 1 \u5F15\u6570\u3067\u53D7\u3051\u53D6\u308A\uFF08\`${name}(state, event) { state.x = \u2026 }\`\uFF09\u3001this \u306F undefined \u306A\u306E\u3067\u3001this.\u2026 \u306F\u547C\u3070\u308C\u305F\u3068\u304D\u306B\u4F8B\u5916\u306B\u306A\u308A\u307E\u3059\u3002$watch \u3084\u30E1\u30BD\u30C3\u30C9\u3068\u9055\u3046\u70B9\u306B\u6CE8\u610F`,
11931
12238
  getterReadsLocation: (read) => `\u3053\u306E getter \u306F ${read} \u3092\u8AAD\u3093\u3067\u3044\u307E\u3059\u304C\u3001location \u306F state \u3067\u306F\u306A\u3044\u306E\u3067\u3001\u6700\u521D\u306B\u8AAD\u3093\u3060 URL \u3092\u6301\u3061\u7D9A\u3051\u307E\u3059\uFF08\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u3067\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002URL \u306F state \u3092\u901A\u3057\u3066\u8AAD\u3093\u3067\u304F\u3060\u3055\u3044 \u2014 <wcs-router> \u306E path / searchParams \u3092\u675F\u306D\u308B`,
11932
12239
  getterReadsClock: (read) => `\u3053\u306E getter \u306F ${read} \u3092\u8AAD\u3093\u3067\u3044\u307E\u3059\u304C\u3001\u6642\u523B\u306F state \u3067\u306F\u306A\u3044\u306E\u3067\u4F9D\u5B58\u3068\u3057\u3066\u767B\u9332\u3055\u308C\u305A\u3001getter \u306F\u30AD\u30E3\u30C3\u30B7\u30E5\u3057\u305F\u6700\u521D\u306E\u5024\u3092\u8FD4\u3057\u7D9A\u3051\u307E\u3059\uFF08\u30A4\u30D9\u30F3\u30C8\u30C8\u30FC\u30AF\u30F3\u3067\u6BCE\u30D5\u30EC\u30FC\u30E0\u300C\u63CF\u304D\u76F4\u3057\u300D\u3066\u3082\u5909\u308F\u308A\u307E\u305B\u3093\uFF09\u3002\u6642\u523B\u3092 state \u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044 \u2014 <wcs-raf> \u3084 <wcs-timer> \u304C\u66F8\u304F\u5024\u3092\u675F\u306D\u308B`,
12240
+ getterReadsAmbient: (read, kind) => {
12241
+ const head = `\u3053\u306E getter \u306F ${read} \u3092\u8AAD\u3093\u3067\u3044\u307E\u3059\u304C\u3001state \u3067\u306F\u306A\u3044\u306E\u3067\u4F9D\u5B58\u3068\u3057\u3066\u767B\u9332\u3055\u308C\u305A\u3001getter \u306F\u30AD\u30E3\u30C3\u30B7\u30E5\u3057\u305F\u6700\u521D\u306E\u5024\u3092\u8FD4\u3057\u7D9A\u3051\u307E\u3059`;
12242
+ switch (kind) {
12243
+ case "size":
12244
+ return `${head}\uFF08\u30EA\u30B5\u30A4\u30BA\u3057\u3066\u3082\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002\u5927\u304D\u3055\u3092 state \u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044 \u2014 <wcs-resize> \u304C\u66F8\u304F width / height \u3092\u675F\u306D\u308B\uFF08\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8\u306E\u5224\u5B9A\u306A\u3089 <wcs-media-query> \u306E matched\uFF09`;
12245
+ case "pixelRatio":
12246
+ return `${head}\uFF08\u62E1\u5927\u3057\u3066\u3082\u3001\u5225\u306E\u753B\u9762\u3078\u79FB\u3057\u3066\u3082\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002\u30DA\u30FC\u30B8\u304C\u4F7F\u3046\u89E3\u50CF\u5EA6\u306E\u3057\u304D\u3044\u5024\u3092 <wcs-media-query> \u306E matched \u3067\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08query="(min-resolution: 2dppx)"\uFF09`;
12247
+ case "media":
12248
+ return `${head}\uFF08\u30AF\u30A8\u30EA\u304C\u5408\u3046\u3088\u3046\u306B\u306A\u3063\u3066\u3082\u3001\u5408\u308F\u306A\u304F\u306A\u3063\u3066\u3082\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002<wcs-media-query> \u306E matched \u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08<wcs-media-query query="(max-width: 600px)" data-wcs="matched: narrow">\uFF09`;
12249
+ case "online":
12250
+ return `${head}\uFF08\u30AA\u30D5\u30E9\u30A4\u30F3\u306B\u306A\u3063\u3066\u3082\u3001\u623B\u3063\u3066\u3082\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002<wcs-network> \u306E offline \u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044`;
12251
+ case "scroll":
12252
+ return `${head}\uFF08\u30B9\u30AF\u30ED\u30FC\u30EB\u3057\u3066\u3082\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002\u30B9\u30AF\u30ED\u30FC\u30EB\u4F4D\u7F6E\u3092\u51FA\u3059 wcstack \u306E\u8981\u7D20\u306F\u7121\u3044\u306E\u3067\u3001\u5024\u3092 state \u306B\u7F6E\u304D\u3001\u30A4\u30D9\u30F3\u30C8\u30CF\u30F3\u30C9\u30E9\uFF08scroll \u306E\u30EA\u30B9\u30CA\u30FC\uFF09\u304B\u3089\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`;
12253
+ default:
12254
+ return `${head}\uFF08\u30DA\u30FC\u30B8\u304C\u96A0\u308C\u3066\u3082\u3001\u8868\u793A\u3055\u308C\u3066\u3082\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002\u30DA\u30FC\u30B8\u306E\u53EF\u8996\u6027\u3092\u51FA\u3059 wcstack \u306E\u8981\u7D20\u306F\u7121\u3044\u306E\u3067\u3001\u5024\u3092 state \u306B\u7F6E\u304D\u3001\u30A4\u30D9\u30F3\u30C8\u30CF\u30F3\u30C9\u30E9\uFF08visibilitychange \u306E\u30EA\u30B9\u30CA\u30FC\uFF09\u304B\u3089\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`;
12255
+ }
12256
+ },
11933
12257
  updatedCallbackUnknownPath: (p) => `"${p}" \u306F state \u306E\u30D1\u30B9\u3067\u306F\u306A\u3044\u306E\u3067 $renderedCallback \u306E paths \u306B\u73FE\u308C\u305A\u3001\u3053\u306E\u5206\u5C90\u306F\u4E00\u5EA6\u3082\u5B9F\u884C\u3055\u308C\u307E\u305B\u3093`,
11934
12258
  commandTokenUnbound: (t) => `\u30B3\u30DE\u30F3\u30C9\u30C8\u30FC\u30AF\u30F3 "${t}" \u3092 emit \u3057\u3066\u3044\u307E\u3059\u304C\u3001\u3053\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u305D\u308C\u3092\u53D7\u3051\u308B command.<\u30E1\u30BD\u30C3\u30C9>: ${t} \u306E\u675F\u7E1B\u304C\u3042\u308A\u307E\u305B\u3093\u3002emit \u306F\u8AB0\u306B\u3082\u5C4A\u304D\u307E\u305B\u3093\u3002\u30E1\u30BD\u30C3\u30C9\u3092\u547C\u3076\u8981\u7D20\u306B\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08command.<\u30E1\u30BD\u30C3\u30C9>: ${t} \u2014 <\u30E1\u30BD\u30C3\u30C9> \u306F\u305D\u306E\u8981\u7D20\u306E\u30E1\u30BD\u30C3\u30C9\u306E\u540D\u524D\uFF09`,
11935
12259
  writePathMissing: (k) => `"${k}" \u306F state \u304C\u5BA3\u8A00\u3057\u3066\u3044\u306A\u3044\u30AD\u30FC\u3067\u3059\u3002\u66F8\u304D\u8FBC\u307F\u306F\u65B0\u3057\u3044\u30AD\u30FC\u3092\u4F5C\u308B\u3060\u3051\u3067\u3001\u5BA3\u8A00\u3057\u305F\u30AD\u30FC\u306E\u675F\u7E1B\u306B\u306F\u5C4A\u304D\u307E\u305B\u3093`,
@@ -11960,6 +12284,18 @@ var ja = {
11960
12284
  getterUntrackedReadBound: (root, sp, binding, tag, written) => `\u3053\u3053\u3067\u8FFD\u8DE1\u3055\u308C\u308B\u306E\u306F "${root}" \u3060\u3051\u3067\u3059\u304C\u3001<${tag}> \u306E\u675F\u7E1B "${binding}" \u306F "${written}" \u3092\u30D1\u30B9\u3067\u66F8\u304D\u307E\u3059\u3002\u305D\u306E\u66F8\u304D\u8FBC\u307F\u306F\u3053\u306E getter \u306B\u5C4A\u304B\u305A\u3001getter \u306F\u524D\u306B\u8A08\u7B97\u3057\u305F\u5024\u3092\u8FD4\u3057\u7D9A\u3051\u307E\u3059\uFF08\u30D1\u30B9\u8AAD\u307F\u53D6\u308A\u306E\u5148\u306E\u7D20\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u30A2\u30AF\u30BB\u30B9\u306F\u8FFD\u8DE1\u3055\u308C\u306A\u3044\uFF09\u3002this["${sp}"] \u3067\u8AAD\u3093\u3067\u304F\u3060\u3055\u3044`,
11961
12285
  handlerFilterNotAllowed: (prop) => `\u30A4\u30D9\u30F3\u30C8\u30CF\u30F3\u30C9\u30E9 "${prop}" \u306B\u30D5\u30A3\u30EB\u30BF\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093`,
11962
12286
  typeExpectation: (label, expected, resultType) => `"${label}" \u306B\u306F${JA_EXPECTED_LABEL[expected]}\u304C\u5FC5\u8981\u3067\u3059\uFF08\u73FE\u5728\u306E\u578B: ${resultType}\uFF09`,
12287
+ attrBooleanPresence: (a, p, rhs) => `"attr.${a}" \u306B boolean \u3092\u675F\u306D\u3066\u3044\u307E\u3059\u3002attr.* \u306F String(value) \u3092\u66F8\u304F\u306E\u3067\u3001false \u306E\u3068\u304D ${a}="false" \u306B\u306A\u308A\u307E\u3059\u3002\u8AD6\u7406\u5C5E\u6027\u306F\u5024\u306B\u95A2\u4FC2\u306A\u304F\u3001\u5728\u308B\u3060\u3051\u3067\u52B9\u304D\u307E\u3059: ${a}="false" \u3067\u3082 ${a} \u306E\u307E\u307E\u3067\u3059\uFF08\u5C5E\u6027\u3092\u5916\u3059\u306E\u306F null / undefined \u3060\u3051\uFF09\u3002\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044: ${p}: ${rhs}`,
12288
+ attrBooleanText: (a, rhs) => `"attr.${a}" \u306B boolean \u3092\u675F\u306D\u3066\u3044\u307E\u3059\u3002attr.* \u306F String(value) \u3092\u66F8\u304F\u306E\u3067\u3001\u5C5E\u6027\u306F "true" \u304B "false" \u306B\u306A\u308A\u3001\u5916\u308C\u308B\u3053\u3068\u306F\u3042\u308A\u307E\u305B\u3093\uFF08\u5916\u3059\u306E\u306F null / undefined \u3060\u3051\uFF09\u3002\u5C5E\u6027\u306E\u6709\u7121\u3092\u898B\u308B\u5074\uFF08CSS \u306E [${a}]\u30FBhasAttribute()\uFF09\u306B\u306F\u3001\u3069\u3061\u3089\u3067\u3082\u5728\u308A\u307E\u3059\u3002false \u306E\u9593\u306F\u5916\u3059\u306A\u3089 attr.${a}: ${rhs}|defaults(null)\u3001\u6587\u5B57\u306E "true" / "false" \u304C\u610F\u56F3\u306A\u3089 attr.${a}: ${rhs}|string \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`,
12289
+ radioNameShared: (name, binding) => `\u884C\u3054\u3068\u306E\u30E9\u30B8\u30AA\u304C\u3059\u3079\u3066 name="${name}" \u306B\u306A\u308B\u306E\u3067\u3001\u30D6\u30E9\u30A6\u30B6\u306F\u5168\u90E8\u306E\u884C\u306E\u30E9\u30B8\u30AA\u3092 1 \u3064\u306E\u30B0\u30EB\u30FC\u30D7\u306B\u3057\u307E\u3059\u3002\u30DA\u30FC\u30B8\u5168\u4F53\u3067 1 \u3064\u3057\u304B\u9078\u3070\u308C\u305F\u72B6\u614B\u306B\u306A\u3089\u305A\u3001\u8868\u793A\u306F\u6700\u521D\u306E\u63CF\u753B\u304B\u3089\u884C\u3054\u3068\u306E\u5024\u3068\u98DF\u3044\u9055\u3044\u307E\u3059\uFF08\u4F55\u3082\u77E5\u3089\u305B\u307E\u305B\u3093\uFF09\u3002${binding === "radio" ? "\u884C\u3054\u3068\u306B\u9055\u3046 name \u3092\u675F\u306D\u308B\uFF08attr.name: .<\u884C\u3054\u3068\u306B\u9055\u3046\u30D5\u30A3\u30FC\u30EB\u30C9>\uFF09\u304B\u3001name \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\uFF08radio: \u306F name \u304C\u7121\u304F\u3066\u3082\u3001\u540C\u3058\u30D1\u30B9\u306B\u675F\u306D\u305F\u30E9\u30B8\u30AA\u3092\u9078\u629E\u306B\u5408\u308F\u305B\u307E\u3059\uFF09" : "\u884C\u3054\u3068\u306B\u9055\u3046 name \u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08attr.name: .<\u884C\u3054\u3068\u306B\u9055\u3046\u30D5\u30A3\u30FC\u30EB\u30C9>\uFF09\u3002\u884C\u3092\u307E\u305F\u3044\u3067 1 \u3064\u3092\u9078\u3070\u305B\u308B\u306A\u3089\u3001\u5168\u90E8\u3092 1 \u3064\u306E\u30D1\u30B9\u306B\u675F\u306D\u307E\u3059\uFF08value: .<\u884C\u306E id>; radio: <\u30D1\u30B9>\uFF09"}`,
12290
+ numberWrittenAsString: (path, left, asNumber) => `"${path}" \u306F state \u3067\u306F\u6570\u5024\u3067\u3059\u304C\u3001value: \u304C\u66F8\u304D\u623B\u3059\u306E\u306F\u8981\u7D20\u306E\u6301\u3064\u6587\u5B57\u5217\u3067\u3059\u30025 \u3068\u5165\u529B\u3057\u305F\u5F8C\u306E state \u306F "5" \u3067\u3001"5" + 1 \u306F "51" \u306B\u306A\u308A\u307E\u3059\uFF08\u4F55\u3082\u77E5\u3089\u305B\u307E\u305B\u3093\uFF09\u3002\u66F8\u304D\u623B\u3059\u3068\u304D\u306B\u6570\u5024\u306B\u3057\u3066\u304F\u3060\u3055\u3044: ${asNumber ? `valueAsNumber: ${path}\u3001\u307E\u305F\u306F` : ""}\u5DE6\u8FBA\u306E\u5165\u529B\u30D5\u30A3\u30EB\u30BF ${left}|number: ${path}\uFF08|int\u30FB|float \u3082\uFF09`,
12291
+ twoWayOutputFilter: (prop, filters, left, rhs, keystroke) => keystroke ? `${prop}: \u306F\u53CC\u65B9\u5411\u3067 1 \u6253\u9375\u3054\u3068\u306B\u66F8\u304D\u623B\u3057\u3001\u51FA\u529B\u30D5\u30A3\u30EB\u30BF "${filters}" \u306F\u305D\u306E\u305F\u3073\u306B state \u306E\u5024\u3092\u6574\u5F62\u3057\u3066\u6B04\u3078\u66F8\u304D\u76F4\u3057\u307E\u3059\u3002\u5165\u529B\u4E2D\u306E\u6B04\u304C\u66F8\u304D\u63DB\u308F\u308A\uFF08\u30AD\u30E3\u30EC\u30C3\u30C8\u306F\u672B\u5C3E\u3078\u98DB\u3073\u3001IME \u306E\u5909\u63DB\u306F\u9014\u5207\u308C\u307E\u3059\uFF09\u3001state \u304C\u53D7\u3051\u53D6\u308B\u306E\u3082\u6B04\u306E\u6574\u5F62\u6E08\u307F\u306E\u6587\u5B57\u3067\u3059\uFF08\u51FA\u529B\u30D5\u30A3\u30EB\u30BF\u306F\u66F8\u304D\u623B\u3057\u3067\u5143\u306B\u623B\u308A\u307E\u305B\u3093\uFF09\u3002\u6574\u5F62\u3057\u305F\u6587\u5B57\u306F\u5225\u306E\u8981\u7D20\u306B\u8868\u793A\u3059\u308B\u3001\u6B04\u306E\u78BA\u5B9A\u3067\u66F8\u304D\u623B\u3057\u3066 setter \u3067\u6574\u5F62\u3059\u308B\uFF08${prop}#onchange:\uFF09\u3001\u307E\u305F\u306F\u4E00\u65B9\u5411\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${prop}#ro: ${rhs}\uFF09` : `${prop}: \u306F\u53CC\u65B9\u5411\u3067\u3059\u304C\u3001\u51FA\u529B\u30D5\u30A3\u30EB\u30BF "${filters}" \u306F\u66F8\u304D\u623B\u3057\u3067\u5143\u306B\u623B\u308A\u307E\u305B\u3093\u3002\u8981\u7D20\u304C\u66F8\u304D\u623B\u3059\u306E\u306F\u8868\u793A\u3057\u3066\u3044\u308B\u6574\u5F62\u6E08\u307F\u306E\u5024\u3067\u3001\u6B21\u306F\u305D\u306E\u5024\u306B\u30D5\u30A3\u30EB\u30BF\u304C\u639B\u304B\u308A\u307E\u3059\u3002\u5DE6\u8FBA\u306E\u5165\u529B\u30D5\u30A3\u30EB\u30BF\u3067\u5143\u306B\u623B\u3059\uFF08${left}|<\u30D5\u30A3\u30EB\u30BF>: \u2026\uFF09\u3001\u6574\u5F62\u3057\u305F\u5024\u306F\u5225\u306E\u8981\u7D20\u306B\u8868\u793A\u3059\u308B\u3001\u307E\u305F\u306F\u4E00\u65B9\u5411\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${prop}#ro: ${rhs}\uFF09`,
12292
+ bodyBinding: (tag, attribute) => `<${tag}> \u306E ${attribute} \u306F\u675F\u7E1B\u3055\u308C\u307E\u305B\u3093\u3002<wcs-state> \u304C\u675F\u306D\u308B\u306E\u306F <body> \u306E\u4E2D\u3067\u3001<body> \u3068 <html> \u305D\u306E\u3082\u306E\u306F\u675F\u306D\u306A\u3044\u306E\u3067\u3001\u3053\u3053\u306B\u66F8\u3044\u305F\u675F\u7E1B\u306F\u4F55\u3082\u3057\u307E\u305B\u3093\uFF08\u30A4\u30D9\u30F3\u30C8\u306E\u30CF\u30F3\u30C9\u30E9\u306F\u8D70\u3089\u305A\u3001class. / attr. \u306A\u3069\u306F\u66F8\u304B\u308C\u307E\u305B\u3093\uFF09\u3002\u675F\u7E1B\u3092 <body> \u306E\u4E2D\u306E\u8981\u7D20\uFF08\u5305\u3080\u8981\u7D20\u30FB<main>\uFF09\u3078\u79FB\u3059\u304B\u3001\u5024\u3092 $connectedCallback \u3084 $watch \u306E\u30CF\u30F3\u30C9\u30E9\u304B\u3089\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF08document.documentElement.lang = \u2026\uFF09`,
12293
+ linkHandler: (property, handler) => `<wcs-link> \u306E "${property}:" \u306F "${handler}" \u3092\u547C\u3073\u307E\u305B\u3093\u3002<wcs-link> \u81EA\u8EAB\u306F display: none \u3067\u3001\u5229\u7528\u8005\u304C\u30AF\u30EA\u30C3\u30AF\u3059\u308B\u306E\u306F\u30EA\u30F3\u30AF\u304C\u81EA\u5206\u306E\u96A3\u306B\u4F5C\u308B <a> \u306A\u306E\u3067\u3001\u30A4\u30D9\u30F3\u30C8\u306F\u30DB\u30B9\u30C8\u306B\u5C4A\u304D\u307E\u305B\u3093\u3002\u30CF\u30F3\u30C9\u30E9\u306F\u3001\u30EA\u30F3\u30AF\u306E\u4E2D\u306E\u8981\u7D20\uFF08\u5B50\u306F <a> \u306E\u4E2D\u3078\u79FB\u308A\u307E\u3059\uFF09\u304B\u3001\u30EA\u30F3\u30AF\u3092\u56F2\u3080\u8981\u7D20\u306B\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\u3002\u30CF\u30F3\u30C9\u30E9\u304B\u3089\u9077\u79FB\u3059\u308B\u306A\u3089\u3001router \u306E navigateUrl \u306B\u66F8\u304D\u307E\u3059\uFF08<wcs-router> \u306E data-wcs="navigateUrl: \u2026"\uFF09`,
12294
+ rootMarginUnit: (tag, value, refused, suggested) => {
12295
+ const why = refused.length === 0 ? "\u5024\u306F 1\u301C4 \u500B\u3067\u3059" : `${refused.map((t) => `"${t}"`).join("\u30FB")} \u306F px \u304B % \u306E\u4ED8\u3044\u305F\u6570\u5024\u3067\u306F\u3042\u308A\u307E\u305B\u3093${refused.some(isUnitlessZero) ? "\uFF080 \u306B\u3082\u5358\u4F4D\u304C\u8981\u308A\u307E\u3059\uFF09" : ""}`;
12296
+ const effect = tag === "wcs-intersect" ? "\u8981\u7D20\u306F\u4F55\u3082\u76E3\u8996\u305B\u305A\u3001observing \u306F false \u306E\u307E\u307E\u3067\u3059" : "\u8981\u7D20\u306F\u4F55\u3082\u76E3\u8996\u305B\u305A\u3001\u6B21\u306E\u30DA\u30FC\u30B8\u306F\u8AAD\u307F\u8FBC\u307E\u308C\u307E\u305B\u3093";
12297
+ return `\u30D6\u30E9\u30A6\u30B6\u306F root-margin="${value}" \u3092\u62D2\u307F\u307E\u3059\uFF08rootMargin must be specified in pixels or percent\uFF09: ${why}\u3002\u305D\u306E\u305F\u3081${effect}\u3002${suggested === null ? "1\u301C4 \u500B\u306E\u5024\u3092\u3001\u305D\u308C\u305E\u308C px \u304B % \u306E\u4ED8\u3044\u305F\u6570\u5024\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044" : `root-margin="${suggested}" \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`}`;
12298
+ },
11963
12299
  filterUnknown: (n) => `\u30D5\u30A3\u30EB\u30BF "${n}" \u306F\u7D44\u307F\u8FBC\u307F\u30D5\u30A3\u30EB\u30BF\u306B\u5B58\u5728\u3057\u307E\u305B\u3093`,
11964
12300
  filterRemoved: (n, c) => `\u30D5\u30A3\u30EB\u30BF "${n}" \u306F 4.0 \u3067\u5916\u308C\u307E\u3057\u305F\uFF08"${c}" \u306E 3.x \u306E\u65E7\u540D\uFF09\u3002"${c}" \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`,
11965
12301
  substrRemoved: (rewrite) => `\u30D5\u30A3\u30EB\u30BF "substr" \u306F 4.0 \u3067\u5916\u308C\u307E\u3057\u305F\u3002slice(start, start + length) \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044 \u2014 slice \u306E\u7B2C 2 \u5F15\u6570\u306F\u9577\u3055\u3067\u306F\u306A\u304F\u7D42\u308F\u308A\u306E\u4F4D\u7F6E\u3067\u3059${rewrite === null ? "" : `\uFF08\u3053\u3053\u3067\u306F ${rewrite}\uFF09`}`,
@@ -12167,6 +12503,23 @@ var en = {
12167
12503
  onHandlerThis: (name) => `The $on handler "${name}" uses this. A $on handler receives the state as its first argument (\`${name}(state, event) { state.x = \u2026 }\`) and this is undefined, so this.\u2026 throws when it is called \u2014 unlike $watch handlers and methods`,
12168
12504
  getterReadsLocation: (read) => `This getter reads ${read}, which is not state: it keeps the URL it first read (a navigation does not re-evaluate it). Read the URL through state \u2014 bind <wcs-router>'s path / searchParams`,
12169
12505
  getterReadsClock: (read) => `This getter reads ${read}. The time is not state, so it is not a dependency: the getter is cached and keeps returning its first value (an event token "redrawing" every frame does not change it). Keep the time in state \u2014 bind the value <wcs-raf> or <wcs-timer> writes`,
12506
+ getterReadsAmbient: (read, kind) => {
12507
+ const head = `This getter reads ${read}, which is not state, so it is not a dependency: the getter is cached and keeps returning its first value`;
12508
+ switch (kind) {
12509
+ case "size":
12510
+ return `${head} (a resize does not re-evaluate it). Keep the size in state \u2014 bind the width / height <wcs-resize> writes (for a breakpoint, <wcs-media-query>'s matched)`;
12511
+ case "pixelRatio":
12512
+ return `${head} (a zoom or a move to another screen does not re-evaluate it). Bind <wcs-media-query>'s matched for the resolution thresholds the page uses (query="(min-resolution: 2dppx)")`;
12513
+ case "media":
12514
+ return `${head} (the query starting or ceasing to match does not re-evaluate it). Bind <wcs-media-query>'s matched instead (<wcs-media-query query="(max-width: 600px)" data-wcs="matched: narrow">)`;
12515
+ case "online":
12516
+ return `${head} (going offline or coming back does not re-evaluate it). Bind <wcs-network>'s offline instead`;
12517
+ case "scroll":
12518
+ return `${head} (scrolling does not re-evaluate it). No wcstack element gives the scroll position: keep the value in state and write it from an event handler (a scroll listener)`;
12519
+ default:
12520
+ return `${head} (the page being hidden or shown does not re-evaluate it). No wcstack element gives the page's visibility: keep the value in state and write it from an event handler (a visibilitychange listener)`;
12521
+ }
12522
+ },
12170
12523
  updatedCallbackUnknownPath: (p) => `"${p}" is not a path of this state, so it is never in $renderedCallback's paths and this branch never runs`,
12171
12524
  commandTokenUnbound: (t) => `The command token "${t}" is emitted, but no command.<method>: ${t} binding in this document receives it, so the emit reaches nothing. Bind it on the element whose method it should call (command.<method>: ${t}, with <method> the name of that element's method)`,
12172
12525
  writePathMissing: (k) => `"${k}" is not a key the state declares. The write creates a new key and reaches no binding of a declared one`,
@@ -12197,6 +12550,18 @@ var en = {
12197
12550
  getterUntrackedReadBound: (root, sp, binding, tag, written) => `Only "${root}" is tracked here, but the binding "${binding}" on <${tag}> writes "${written}" by path: that write never reaches this getter, which keeps returning the value it last computed (plain property access after a path read is not tracked). Read this["${sp}"] instead`,
12198
12551
  handlerFilterNotAllowed: (prop) => `Filters cannot be applied to event handler "${prop}"`,
12199
12552
  typeExpectation: (label, expected, resultType) => `"${label}" requires ${EN_EXPECTED_LABEL[expected]} (current type: ${resultType})`,
12553
+ attrBooleanPresence: (a, p, rhs) => `"attr.${a}" is given a boolean. attr.* writes String(value), so false is written as ${a}="false" \u2014 and a boolean attribute is on whenever it is present, whatever its value: ${a}="false" still means ${a} (only null / undefined remove an attribute). Bind the property instead: ${p}: ${rhs}`,
12554
+ attrBooleanText: (a, rhs) => `"attr.${a}" is given a boolean. attr.* writes String(value), so the attribute is "true" or "false" and is never removed (only null / undefined remove it): whatever tests its presence \u2014 [${a}] in CSS, hasAttribute() \u2014 finds it either way. To remove it while false, write attr.${a}: ${rhs}|defaults(null); if the text "true" / "false" is what is meant, say so: attr.${a}: ${rhs}|string`,
12555
+ radioNameShared: (name, binding) => `Every row's radios get name="${name}", so the browser makes one group of all the rows: only one radio on the whole page stays checked, and the page disagrees with the rows' values from the first render \u2014 nothing says so. ${binding === "radio" ? "Bind a name that differs per row (attr.name: .<a row field>), or drop the name: radio: keeps the radios bound to one path in step without it" : "Bind a name that differs per row (attr.name: .<a row field>) \u2014 or, for one choice over all the rows, bind them all to one path: value: .<the row's id>; radio: <path>"}`,
12556
+ numberWrittenAsString: (path, left, asNumber) => `"${path}" is a number in the state, but value: writes back what the element holds, a string: after the user enters 5 the state has "5", and "5" + 1 is "51" \u2014 nothing says so. Convert it on the way in: ${asNumber ? `valueAsNumber: ${path}, or ` : ""}an input filter on the left side, ${left}|number: ${path} (also |int, |float)`,
12557
+ twoWayOutputFilter: (prop, filters, left, rhs, keystroke) => keystroke ? `${prop}: is two-way and writes back on every keystroke, and the output filter "${filters}" formats what the state holds each time: the field is rewritten while the user types \u2014 the caret jumps to the end, an IME composition is cut \u2014 and what the state receives is the field's formatted text (an output filter is not undone on the way back). Show the formatted text in another element, write back when the field is committed and format in a setter (${prop}#onchange:), or make the binding one-way: ${prop}#ro: ${rhs}` : `${prop}: is two-way, and nothing undoes the output filter "${filters}" on the way back: the element writes back the formatted value it shows, and the filter is then applied to that. Undo it with an input filter on the left side (${left}|<filter>: \u2026), show the formatted value in another element, or make the binding one-way: ${prop}#ro: ${rhs}`,
12558
+ bodyBinding: (tag, attribute) => `${attribute} on <${tag}> is never bound: <wcs-state> binds what is inside <body>, not <body> or <html> themselves, so the bindings written here do nothing (an event handler never runs; class., attr. and the rest are never written). Move the binding to an element inside <body> (a wrapper, <main>), or write the value from $connectedCallback or a $watch handler (document.documentElement.lang = \u2026)`,
12559
+ linkHandler: (property, handler) => `"${property}:" on <wcs-link> never runs "${handler}": the <wcs-link> itself is display: none, and what the user clicks is the <a> it generates beside itself, so no event reaches the host. Put the handler on an element inside the link (its children move into the <a>) or on an element around it; to navigate from a handler, write the router's navigateUrl (data-wcs="navigateUrl: \u2026" on <wcs-router>)`,
12560
+ rootMarginUnit: (tag, value, refused, suggested) => {
12561
+ const why = refused.length === 0 ? "it takes one to four values" : `${refused.map((t) => `"${t}"`).join(", ")} ${refused.length === 1 ? "is not a number" : "are not numbers"} with px or %${refused.some(isUnitlessZero) ? " (a 0 needs its unit too)" : ""}`;
12562
+ const effect = tag === "wcs-intersect" ? "the element observes nothing and observing stays false" : "the element observes nothing and no page is loaded";
12563
+ return `The browser refuses root-margin="${value}" (rootMargin must be specified in pixels or percent): ${why}. So ${effect}. ${suggested === null ? "Write one to four values, each a number with px or %" : `Write root-margin="${suggested}"`}`;
12564
+ },
12200
12565
  filterUnknown: (n) => `Filter "${n}" is not a built-in filter`,
12201
12566
  filterRemoved: (n, c) => `Filter "${n}" was removed in 4.0 (it was the 3.x old name of "${c}") \u2014 write "${c}"`,
12202
12567
  substrRemoved: (rewrite) => `Filter "substr" was removed in 4.0 \u2014 write slice(start, start + length): slice takes the end index, not a length${rewrite === null ? "" : ` (here: ${rewrite})`}`,
@@ -12614,6 +12979,63 @@ function removedFilterMessage(name, args, msgs) {
12614
12979
  return canonical === null ? null : msgs.filterRemoved(name, canonical);
12615
12980
  }
12616
12981
 
12982
+ // src/service/attributeValues.ts
12983
+ var ARIA_TRUE_FALSE = /* @__PURE__ */ new Set([
12984
+ "aria-atomic",
12985
+ "aria-busy",
12986
+ "aria-checked",
12987
+ "aria-current",
12988
+ "aria-disabled",
12989
+ "aria-expanded",
12990
+ "aria-grabbed",
12991
+ "aria-haspopup",
12992
+ "aria-hidden",
12993
+ "aria-invalid",
12994
+ "aria-modal",
12995
+ "aria-multiline",
12996
+ "aria-multiselectable",
12997
+ "aria-pressed",
12998
+ "aria-readonly",
12999
+ "aria-required",
13000
+ "aria-selected"
13001
+ ]);
13002
+ var ENUMERATED_TRUE_FALSE = /* @__PURE__ */ new Set(["contenteditable", "draggable", "spellcheck", "writingsuggestions"]);
13003
+ var BOOLEAN_ATTRIBUTE_PROPERTY = {
13004
+ allowfullscreen: "allowFullscreen",
13005
+ async: "async",
13006
+ autofocus: "autofocus",
13007
+ autoplay: "autoplay",
13008
+ checked: "checked",
13009
+ controls: "controls",
13010
+ default: "default",
13011
+ defer: "defer",
13012
+ disabled: "disabled",
13013
+ formnovalidate: "formNoValidate",
13014
+ hidden: "hidden",
13015
+ inert: "inert",
13016
+ ismap: "isMap",
13017
+ loop: "loop",
13018
+ multiple: "multiple",
13019
+ muted: "muted",
13020
+ nomodule: "noModule",
13021
+ novalidate: "noValidate",
13022
+ open: "open",
13023
+ playsinline: "playsInline",
13024
+ readonly: "readOnly",
13025
+ required: "required",
13026
+ reversed: "reversed",
13027
+ selected: "selected"
13028
+ };
13029
+ function booleanAttributeText(name, tag) {
13030
+ const attribute = name.toLowerCase();
13031
+ if (ARIA_TRUE_FALSE.has(attribute) || ENUMERATED_TRUE_FALSE.has(attribute)) return { kind: "value" };
13032
+ const native = tag !== void 0 && !tag.includes("-");
13033
+ if (native && Object.hasOwn(BOOLEAN_ATTRIBUTE_PROPERTY, attribute)) {
13034
+ return { kind: "presence", property: BOOLEAN_ATTRIBUTE_PROPERTY[attribute] };
13035
+ }
13036
+ return { kind: "text" };
13037
+ }
13038
+
12617
13039
  // src/service/bindingValidator.ts
12618
13040
  var filterMap = new Map(BUILTIN_FILTERS.map((f) => [f.name, f]));
12619
13041
  var DIRECT_MODIFIER = "direct";
@@ -12646,6 +13068,7 @@ var DELEGATED_EVENTS = /* @__PURE__ */ new Set([
12646
13068
  "pointerup"
12647
13069
  ]);
12648
13070
  var CUSTOM_ELEMENT_OWN_EVENTS = /* @__PURE__ */ new Set(["input", "change", "submit"]);
13071
+ var LINK_TAG = "wcs-link";
12649
13072
  function collectCurrentTargetHandlers(elements, html, fileReader) {
12650
13073
  const names2 = /* @__PURE__ */ new Set();
12651
13074
  forEachStateMethod(elements, html, fileReader, "currentTarget", (name, params, body) => {
@@ -12772,7 +13195,7 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
12772
13195
  severity: "error"
12773
13196
  });
12774
13197
  }
12775
- if (DELEGATED_EVENTS.has(eventName) && !modifiers.includes(DIRECT_MODIFIER) && attr.tagName !== void 0 && !(attr.tagName.includes("-") && CUSTOM_ELEMENT_OWN_EVENTS.has(eventName)) && /^[A-Za-z_][\w$]*(?:\.[A-Za-z_][\w$]*)*$/.test(handler) && getCurrentTargetHandlers().has(handler)) {
13198
+ if (DELEGATED_EVENTS.has(eventName) && !modifiers.includes(DIRECT_MODIFIER) && attr.tagName !== void 0 && attr.tagName !== LINK_TAG && !(attr.tagName.includes("-") && CUSTOM_ELEMENT_OWN_EVENTS.has(eventName)) && /^[A-Za-z_][\w$]*(?:\.[A-Za-z_][\w$]*)*$/.test(handler) && getCurrentTargetHandlers().has(handler)) {
12776
13199
  currentTargetCandidates.push({
12777
13200
  offset: attr.valueStart,
12778
13201
  start: bindingStart + leadingSpace,
@@ -13044,7 +13467,19 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
13044
13467
  const resultType = resolveResultType(typePath, parsed.filters, scopedPaths);
13045
13468
  if (resultType !== null) {
13046
13469
  const typeReq = getExpectedType(parsed.property);
13047
- if (typeReq && resultType !== typeReq.expected) {
13470
+ const attrBoolean = typeReq !== null && propNoMod.startsWith("attr.") && isBooleanType(resultType) ? booleanAttrMessage(propNoMod.slice("attr.".length), attr.tagName, binding, parsed, msgs) : void 0;
13471
+ if (attrBoolean !== void 0) {
13472
+ if (attrBoolean !== null) {
13473
+ const pathStart = bindingStart + binding.indexOf(parsed.path);
13474
+ diagnostics.push({
13475
+ code: WcsDiagnosticCode.BindingTypeExpectation,
13476
+ start: pathStart,
13477
+ end: pathStart + pathTrimmed.length,
13478
+ message: attrBoolean,
13479
+ severity: "warning"
13480
+ });
13481
+ }
13482
+ } else if (typeReq && resultType !== typeReq.expected) {
13048
13483
  const pathOffset = binding.indexOf(parsed.path);
13049
13484
  const pathStart = bindingStart + pathOffset;
13050
13485
  const schemaDefinite = typeReq.expected === "array" && parsed.filters.length === 0 && applicationSchema !== void 0 && scopedPaths.some((p) => p.path === typePath && p.fromSchema === true);
@@ -13125,7 +13560,14 @@ function findAllBindAttributes(html, attrName) {
13125
13560
  const valueEnd = html.indexOf(quote, valueStart);
13126
13561
  if (valueEnd === -1 || valueEnd > tag.end) continue;
13127
13562
  const inputType = tag.tagName === "input" ? extractAttribute(attrsText, "type") ?? void 0 : void 0;
13128
- attrs.push({ value: html.slice(valueStart, valueEnd), valueStart, tagName: tag.tagName, ...inputType !== void 0 ? { inputType } : {} });
13563
+ attrs.push({
13564
+ value: html.slice(valueStart, valueEnd),
13565
+ valueStart,
13566
+ tagName: tag.tagName,
13567
+ ...inputType !== void 0 ? { inputType } : {},
13568
+ attrsStart: tag.start,
13569
+ attrsEnd: tag.end
13570
+ });
13129
13571
  regex.lastIndex = valueEnd - tag.start;
13130
13572
  }
13131
13573
  }
@@ -13306,6 +13748,18 @@ function getExpectedType(property) {
13306
13748
  }
13307
13749
  return null;
13308
13750
  }
13751
+ function isBooleanType(type) {
13752
+ const parts = type.split("|");
13753
+ return parts.includes("boolean") && parts.every((part) => part === "boolean" || part === "null");
13754
+ }
13755
+ function booleanAttrMessage(name, tag, binding, parsed, msgs) {
13756
+ const last = parsed.filters[parsed.filters.length - 1];
13757
+ if (last !== void 0 && last.name === "defaults" && last.args.length === 1 && last.args[0] === "null") return null;
13758
+ const written = booleanAttributeText(name, tag);
13759
+ if (written.kind === "value") return null;
13760
+ const rhs = binding.slice(indexOfOutsideQuotes2(binding, ":") + 1).trim();
13761
+ return written.kind === "presence" ? msgs.attrBooleanPresence(name, written.property, rhs) : msgs.attrBooleanText(name, rhs);
13762
+ }
13309
13763
  function validateFilterChainTypes(path, filters, statePaths, bindingStart, msgs) {
13310
13764
  const diagnostics = [];
13311
13765
  const pathInfo = statePaths.find((p) => p.path === path);
@@ -16053,6 +16507,282 @@ function closingTagStart(html, from, name) {
16053
16507
  return html.length;
16054
16508
  }
16055
16509
 
16510
+ // src/service/formInputValidator.ts
16511
+ var filterMap2 = new Map(BUILTIN_FILTERS.map((f) => [f.name, f]));
16512
+ var NOT_ENTERED = /* @__PURE__ */ new Set(["checkbox", "radio", "hidden", "button", "submit", "reset", "image", "file"]);
16513
+ var NOT_TYPED = /* @__PURE__ */ new Set(["range", "color", "date", "datetime-local", "month", "week", "time"]);
16514
+ var AS_NUMBER = /* @__PURE__ */ new Set(["number", "range", "date", "datetime-local", "month", "week", "time"]);
16515
+ function validateFormInputs(html, bindAttribute = "data-wcs", stateTagName = "wcs-state", locale2, fileReader, applicationSchema) {
16516
+ const attrs = findAllBindAttributes(html, bindAttribute).filter((attr) => attr.tagName === "input" || attr.tagName === "textarea" || attr.tagName === "select");
16517
+ if (attrs.length === 0) return [];
16518
+ const msgs = getMessages(locale2);
16519
+ const out = [];
16520
+ let types2 = null;
16521
+ const getTypes = () => {
16522
+ if (types2 === null) {
16523
+ const index = getStatePathIndex(html, stateTagName, fileReader);
16524
+ const candidates = mergeSchemaCandidates(index.paths, applicationSchema);
16525
+ const set = new Set(candidates.map((p) => p.path));
16526
+ types2 = {
16527
+ candidates,
16528
+ has: (path) => set.has(path),
16529
+ computed: new Set(index.paths.filter((p) => p.kind === "computed").map((p) => p.path))
16530
+ };
16531
+ }
16532
+ return types2;
16533
+ };
16534
+ const saidRadio = /* @__PURE__ */ new Set();
16535
+ for (const attr of attrs) {
16536
+ const bindings = splitBindingExpressions(attr.value);
16537
+ const parsed = bindings.map(parseBindingExpression);
16538
+ const type = (attr.inputType ?? "text").toLowerCase();
16539
+ if (attr.tagName === "input" && type === "radio") {
16540
+ const shared = sharedRadioName(html, attr, parsed, bindAttribute);
16541
+ if (shared !== null && !saidRadio.has(shared.key)) {
16542
+ saidRadio.add(shared.key);
16543
+ out.push({
16544
+ code: WcsDiagnosticCode.RadioNameShared,
16545
+ start: shared.start,
16546
+ end: shared.end,
16547
+ message: msgs.radioNameShared(shared.name, shared.binding),
16548
+ severity: "warning"
16549
+ });
16550
+ }
16551
+ continue;
16552
+ }
16553
+ if (attr.tagName === "input" && NOT_ENTERED.has(type)) continue;
16554
+ const typed = attr.tagName === "textarea" || attr.tagName === "input" && !NOT_TYPED.has(type);
16555
+ let pos = 0;
16556
+ for (let i = 0; i < bindings.length; i++) {
16557
+ const binding = bindings[i];
16558
+ const bindingStart = attr.valueStart + pos;
16559
+ pos += binding.length + 1;
16560
+ const p = parsed[i];
16561
+ if (p.path === null) continue;
16562
+ const name = propertyName(p.property);
16563
+ if (name !== "value" && name !== "valueAsNumber") continue;
16564
+ if (!writesBack(attr, name, p.property)) continue;
16565
+ const path = p.path.trim();
16566
+ const colon = indexOfOutsideQuotes2(binding, ":");
16567
+ const left = binding.slice(0, colon).trim();
16568
+ const rhs = binding.slice(colon + 1).trim();
16569
+ const harmful = p.filters.find((filter) => !givesBackWhatWasWritten(filter, p));
16570
+ const keystroke = typed && writeBackEvent(p.property) === "input";
16571
+ if (harmful !== void 0 && (keystroke || p.inputFilters.length === 0)) {
16572
+ if (p.filters.some((filter) => !filterMap2.has(filter.name))) continue;
16573
+ out.push({
16574
+ code: WcsDiagnosticCode.TwoWayOutputFilter,
16575
+ start: bindingStart + harmful.offset,
16576
+ end: bindingStart + harmful.offset + harmful.name.length,
16577
+ message: msgs.twoWayOutputFilter(name, `|${binding.slice(p.filters[0].offset).trim()}`, left, rhs, keystroke),
16578
+ severity: "warning"
16579
+ });
16580
+ continue;
16581
+ }
16582
+ if (name !== "value" || inputGivesNumber(p) !== false) continue;
16583
+ const statePath = expandRowPath(path, html, attr.valueStart, bindAttribute);
16584
+ if (statePath === null) continue;
16585
+ const t = getTypes();
16586
+ const key = candidateKeyOf(statePath, t.has);
16587
+ const candidate = t.candidates.find((c) => c.path === key);
16588
+ if (candidate === void 0 || candidate.kind !== "data" || t.computed.has(key) || !isNumberType(candidate.typeHint)) continue;
16589
+ const pathStart = bindingStart + binding.indexOf(p.path, colon + 1);
16590
+ out.push({
16591
+ code: WcsDiagnosticCode.NumberWrittenAsString,
16592
+ start: pathStart,
16593
+ end: pathStart + path.length,
16594
+ message: msgs.numberWrittenAsString(path, left, attr.tagName === "input" && AS_NUMBER.has(type)) + (path.startsWith(".") ? msgs.expansionSuffix(statePath) : ""),
16595
+ severity: "warning",
16596
+ statePath
16597
+ });
16598
+ }
16599
+ }
16600
+ return out;
16601
+ }
16602
+ function propertyName(property) {
16603
+ const name = property.replace(/#.*$/, "").trim();
16604
+ return name.startsWith(".") ? name.slice(1) : name;
16605
+ }
16606
+ function writeBackEvent(property) {
16607
+ const hash = property.indexOf("#");
16608
+ if (hash === -1) return "input";
16609
+ const named = property.slice(hash + 1).split(",").map((m) => m.trim()).find((m) => /^on\w+$/.test(m));
16610
+ return named === void 0 ? "input" : named.slice(2);
16611
+ }
16612
+ function isNumberType(typeHint) {
16613
+ if (typeHint === void 0) return false;
16614
+ const parts = typeHint.split("|");
16615
+ return parts.includes("number") && parts.every((part) => part === "number" || part === "null");
16616
+ }
16617
+ function inputGivesNumber(p) {
16618
+ let current2 = "string";
16619
+ for (const filter of p.inputFilters) {
16620
+ const info = filterMap2.get(filter.name);
16621
+ if (info === void 0) return null;
16622
+ if (info.resultType !== "passthrough") current2 = info.resultType;
16623
+ }
16624
+ return current2 === "number";
16625
+ }
16626
+ function isEmptyArgument(args) {
16627
+ return args.length === 1 && (args[0] === "" || args[0] === "''" || args[0] === '""');
16628
+ }
16629
+ function givesBackWhatWasWritten(filter, p) {
16630
+ switch (filter.name) {
16631
+ case "string":
16632
+ case "nullIfEmpty":
16633
+ return true;
16634
+ case "coalesce":
16635
+ return isEmptyArgument(filter.args) || !p.inputFilters.some((input) => input.name === "nullIfEmpty");
16636
+ case "defaults":
16637
+ return isEmptyArgument(filter.args);
16638
+ default:
16639
+ return false;
16640
+ }
16641
+ }
16642
+ function expandRowPath(path, html, offset2, bindAttribute) {
16643
+ if (!path.startsWith(".")) return path;
16644
+ if (getRowShorthandForPath(html, offset2, bindAttribute) === null) return null;
16645
+ const list = getResolvedForListPath(html, offset2, bindAttribute);
16646
+ if (list === null || list.startsWith(".")) return null;
16647
+ return path === "." ? `${list}.*` : `${list}.*.${path.slice(1)}`;
16648
+ }
16649
+ function writtenAttributes(html, from, to) {
16650
+ const out = [];
16651
+ const attribute = /([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>`=]+)))?/g;
16652
+ const text3 = html.slice(from, to);
16653
+ let match;
16654
+ while ((match = attribute.exec(text3)) !== null) {
16655
+ out.push({
16656
+ name: match[1].toLowerCase(),
16657
+ value: match[2] ?? match[3] ?? match[4] ?? null,
16658
+ start: from + match.index,
16659
+ end: from + match.index + match[0].length
16660
+ });
16661
+ }
16662
+ return out;
16663
+ }
16664
+ function sharedRadioName(html, attr, parsed, bindAttribute) {
16665
+ if (attr.attrsStart === void 0 || attr.attrsEnd === void 0) return null;
16666
+ const names2 = parsed.map((p) => propertyName(p.property));
16667
+ if (names2.includes("attr.name") || names2.includes("name")) return null;
16668
+ const at2 = names2.findIndex((name) => name === "radio" || name === "checked");
16669
+ if (at2 === -1) return null;
16670
+ const path = parsed[at2].path?.trim() ?? "";
16671
+ const wildcards = countWildcardSegments(path);
16672
+ if (!path.startsWith(".") && wildcards === 0) return null;
16673
+ const literal2 = writtenAttributes(html, attr.attrsStart, attr.attrsEnd).find((a) => a.name === "name");
16674
+ if (literal2 === void 0 || literal2.value === null || literal2.value.trim() === "") return null;
16675
+ const fors = getEnclosingFors(html, attr.valueStart, bindAttribute);
16676
+ if (fors.length === 0) return null;
16677
+ const level = path.startsWith(".") || wildcards > fors.length ? fors.length - 1 : wildcards - 1;
16678
+ const loop = fors[level];
16679
+ const row = html.slice(loop.anchor, attr.attrsStart).toLowerCase();
16680
+ const form = row.lastIndexOf("<form");
16681
+ if (form !== -1 && /^<form[\s>]/.test(row.slice(form)) && row.indexOf("</form", form) === -1) return null;
16682
+ return {
16683
+ name: literal2.value,
16684
+ binding: names2[at2],
16685
+ start: literal2.start,
16686
+ end: literal2.end,
16687
+ key: `${loop.anchor}\0${literal2.value}`
16688
+ };
16689
+ }
16690
+
16691
+ // src/service/bindingHostValidator.ts
16692
+ var UNBOUND_HOSTS = /* @__PURE__ */ new Set(["body", "html"]);
16693
+ var LINK_TAG2 = "wcs-link";
16694
+ function validateBindingHosts(html, bindAttribute = "data-wcs", stateTagName = "wcs-state", locale2) {
16695
+ const attrs = findAllBindAttributes(html, bindAttribute).filter((attr) => attr.tagName !== void 0 && (UNBOUND_HOSTS.has(attr.tagName) || attr.tagName === LINK_TAG2));
16696
+ if (attrs.length === 0) return [];
16697
+ const msgs = getMessages(locale2);
16698
+ const out = [];
16699
+ const contexts = analyzeElementContexts(html, attrs.map((attr) => attr.valueStart), bindAttribute, stateTagName);
16700
+ const isBound = (attr) => contexts.get(attr.valueStart)?.bound === true;
16701
+ let insideTemplate = null;
16702
+ for (const attr of attrs) {
16703
+ const tagName = attr.tagName;
16704
+ if (UNBOUND_HOSTS.has(tagName)) {
16705
+ if (attr.value.trim() === "" || !isBound(attr) || (insideTemplate ??= createTemplateTester(html))(attr.valueStart)) continue;
16706
+ out.push({
16707
+ code: WcsDiagnosticCode.BodyBinding,
16708
+ start: attributeStart(html, attr, bindAttribute),
16709
+ end: attr.valueStart + attr.value.length + 1,
16710
+ severity: "error",
16711
+ tag: tagName,
16712
+ message: msgs.bodyBinding(tagName, bindAttribute)
16713
+ });
16714
+ continue;
16715
+ }
16716
+ if (!isBound(attr)) continue;
16717
+ let pos = 0;
16718
+ for (const binding of splitBindingExpressions(attr.value)) {
16719
+ const bindingStart = attr.valueStart + pos;
16720
+ pos += binding.length + 1;
16721
+ const parsed = parseBindingExpression(binding);
16722
+ const property = parsed.property.replace(/#.*$/, "").trim();
16723
+ if (!/^on\w/.test(property) || parsed.path === null || parsed.path.trim() === "") continue;
16724
+ const start = bindingStart + (binding.length - binding.trimStart().length);
16725
+ out.push({
16726
+ code: WcsDiagnosticCode.LinkHandler,
16727
+ start,
16728
+ end: start + property.length,
16729
+ severity: "error",
16730
+ tag: LINK_TAG2,
16731
+ message: msgs.linkHandler(property, parsed.path.trim())
16732
+ });
16733
+ }
16734
+ }
16735
+ return out;
16736
+ }
16737
+ function attributeStart(html, attr, bindAttribute) {
16738
+ const from = attr.attrsStart ?? attr.valueStart;
16739
+ const head = html.slice(from, attr.valueStart);
16740
+ const escaped = bindAttribute.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16741
+ const name = new RegExp(`${escaped}\\s*=\\s*["']$`, "i").exec(head);
16742
+ return name === null ? attr.valueStart : from + name.index;
16743
+ }
16744
+
16745
+ // src/service/ioAttributeValidator.ts
16746
+ var ROOT_MARGIN_TAGS = /* @__PURE__ */ new Set(["wcs-intersect", "wcs-infinite-scroll"]);
16747
+ var NUMBER = String.raw`[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?`;
16748
+ var ROOT_MARGIN_VALUE = new RegExp(`^${NUMBER}(?:px|%)$`, "i");
16749
+ var UNITLESS_NUMBER = new RegExp(`^${NUMBER}$`, "i");
16750
+ function checkRootMargin(value) {
16751
+ const values = value.split(/\s+/).filter((v) => v !== "");
16752
+ const refused = [...new Set(values.filter((v) => !ROOT_MARGIN_VALUE.test(v)))];
16753
+ if (refused.length === 0 && values.length <= 4) return null;
16754
+ const fixable = values.length <= 4 && refused.every((v) => UNITLESS_NUMBER.test(v));
16755
+ return { refused, suggested: fixable ? values.map((v) => UNITLESS_NUMBER.test(v) ? `${v}px` : v).join(" ") : null };
16756
+ }
16757
+ function validateIoAttributes(html, bindAttribute = "data-wcs", locale2) {
16758
+ if (!/root-margin/i.test(html)) return [];
16759
+ const msgs = getMessages(locale2);
16760
+ const out = [];
16761
+ for (const region of findStartTagRegions(html)) {
16762
+ if (!ROOT_MARGIN_TAGS.has(region.tagName)) continue;
16763
+ const content = html.slice(region.start, region.end);
16764
+ const span = extractAttributeSpan(content, "root-margin", region.start);
16765
+ if (span === null) continue;
16766
+ const value = html.slice(span.valueStart, span.valueEnd);
16767
+ if (value.includes("{{") || bindsRootMargin(extractAttribute(content, bindAttribute))) continue;
16768
+ const problem = checkRootMargin(value);
16769
+ if (problem === null) continue;
16770
+ out.push({
16771
+ code: WcsDiagnosticCode.RootMarginUnit,
16772
+ start: span.valueStart,
16773
+ end: span.valueEnd,
16774
+ severity: "warning",
16775
+ tag: region.tagName,
16776
+ message: msgs.rootMarginUnit(region.tagName, value, problem.refused, problem.suggested)
16777
+ });
16778
+ }
16779
+ return out;
16780
+ }
16781
+ function bindsRootMargin(bindings) {
16782
+ if (bindings === null) return false;
16783
+ return splitBindingExpressions(bindings).some((binding) => parseBindingExpression(binding).property.replace(/#.*$/, "").trim().replace(/^\./, "") === "rootMargin");
16784
+ }
16785
+
16056
16786
  // src/service/documentEnvValidator.ts
16057
16787
  function validateDocumentEnv(html, locale2) {
16058
16788
  const diagnostics = [];
@@ -16393,11 +17123,11 @@ function findMisplacedOutlets(html) {
16393
17123
  });
16394
17124
  return routerWithoutOutlet ? misplaced : [];
16395
17125
  }
16396
- var LINK_TAG = "wcs-link";
17126
+ var LINK_TAG3 = "wcs-link";
16397
17127
  function findLinksIgnoringOwnQuery(html) {
16398
17128
  const found = [];
16399
17129
  for (const region of findStartTagRegions(html)) {
16400
- if (region.tagName !== LINK_TAG) continue;
17130
+ if (region.tagName !== LINK_TAG3) continue;
16401
17131
  const content = html.slice(region.start, region.end);
16402
17132
  const to = extractAttribute(content, "to");
16403
17133
  const span = extractAttributeSpan(content, "query-keys", region.start);
@@ -18206,6 +18936,25 @@ function validateGetterClockReads(script, scriptStart, locale2) {
18206
18936
  }
18207
18937
  return out;
18208
18938
  }
18939
+ function validateGetterAmbientReads(script, scriptStart, locale2) {
18940
+ if (!AMBIENT_READ_SPELLING.test(script)) return [];
18941
+ const msgs = getMessages(locale2);
18942
+ const out = [];
18943
+ let moduleNames = null;
18944
+ for (const getter of analyzeCallableBodies(script)) {
18945
+ if (getter.kind !== "getter" || getter.accessor !== "get" || !AMBIENT_READ_SPELLING.test(getter.body)) continue;
18946
+ const read = findAmbientRead(getter.body, moduleNames ??= moduleBindingNames(script));
18947
+ if (read === null) continue;
18948
+ out.push({
18949
+ code: WcsDiagnosticCode.GetterUntrackedRead,
18950
+ start: scriptStart + getter.bodyStart + read.start,
18951
+ end: scriptStart + getter.bodyStart + read.end,
18952
+ message: msgs.getterReadsAmbient(read.text, read.kind),
18953
+ severity: "warning"
18954
+ });
18955
+ }
18956
+ return out;
18957
+ }
18209
18958
  function onHandlerStateParam(script, handler) {
18210
18959
  if (handler.kind === "body") {
18211
18960
  const head = script.slice(Math.max(0, handler.start - 400), handler.start);
@@ -18577,6 +19326,7 @@ function validateSemantics(html, stateTagName = "wcs-state", locale2, bindAttrNa
18577
19326
  ));
18578
19327
  out.push(...validateGetterLocationReads(block.content, block.contentStart, locale2));
18579
19328
  out.push(...validateGetterClockReads(block.content, block.contentStart, locale2));
19329
+ out.push(...validateGetterAmbientReads(block.content, block.contentStart, locale2));
18580
19330
  out.push(...validateOnHandlerThis(block.content, block.contentStart, locale2));
18581
19331
  out.push(...validateInPlaceChanges(block.content, block.contentStart, locale2));
18582
19332
  }
@@ -18748,8 +19498,8 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
18748
19498
  const spans = opaque2.length === 0 ? [] : analyzeDeclarationSpans(block.content);
18749
19499
  for (const candidate of opaque2) {
18750
19500
  const path = prefix + candidate.path;
18751
- bound ??= buildReferenceIndex(html, { bindAttribute, stateTagName }).occurrences.filter((o) => o.kind === "path").map((o) => hasIndexSegment(o.path) ? toWildcardForm(o.path) : o.path);
18752
- const count = bound.filter((b) => b.startsWith(`${path}.`)).length;
19501
+ bound ??= buildReferenceIndex(html, { bindAttribute, stateTagName }).occurrences.filter((o) => o.kind === "path").map((o) => rowPathOf(o.path, html, o.pathRange.start, bindAttribute)).map((path2) => hasIndexSegment(path2) ? toWildcardForm(path2) : path2);
19502
+ const count = bound.filter((b) => b.startsWith(`${path}.`) && !pathExistsInCandidates(b, candidates, candidateSet)).length;
18753
19503
  const span = spans.find((s) => candidate.path === s.name || candidate.path.startsWith(`${s.name}.`));
18754
19504
  if (count === 0 || span === void 0) continue;
18755
19505
  out.push({
@@ -18796,6 +19546,12 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
18796
19546
  }
18797
19547
  return out;
18798
19548
  }
19549
+ function rowPathOf(path, html, offset2, bindAttribute) {
19550
+ if (!path.startsWith(".")) return path;
19551
+ const list = getResolvedForListPath(html, offset2, bindAttribute);
19552
+ if (list === null || list.startsWith(".")) return path;
19553
+ return path === "." ? `${list}.*` : `${list}.*.${path.slice(1)}`;
19554
+ }
18799
19555
  function isList(path, candidates, candidateSet) {
18800
19556
  return candidateSet.has(`${path}.*`) || candidates.some((c) => c.path === path && c.kind === "list");
18801
19557
  }
@@ -19159,7 +19915,7 @@ function findTopLevelReads(source) {
19159
19915
  }
19160
19916
  function readOf(node, assigned, source) {
19161
19917
  const object = node.object;
19162
- const prop = propertyName(node);
19918
+ const prop = propertyName2(node);
19163
19919
  if (isGlobal(object, STORAGES)) {
19164
19920
  if (assigned || prop !== null && STORAGE_WRITES.has(prop)) return null;
19165
19921
  return { start: node.start, end: node.end, text: source.slice(node.start, node.end) };
@@ -19175,7 +19931,7 @@ function isGlobal(node, names2) {
19175
19931
  const object = node.object;
19176
19932
  return object.type === "Identifier" && GLOBALS.has(object.name) && node.property.type === "Identifier" && names2.has(node.property.name);
19177
19933
  }
19178
- function propertyName(node) {
19934
+ function propertyName2(node) {
19179
19935
  if (!node.computed) return node.property.type === "Identifier" ? node.property.name : null;
19180
19936
  return node.property.type === "Literal" && typeof node.property.value === "string" ? node.property.value : null;
19181
19937
  }
@@ -19777,6 +20533,9 @@ function validateText(text3, options, applicationSchema) {
19777
20533
  out.push(...validateIoNodes(text3, bindAttribute, stateTagName, locale2, fileReader));
19778
20534
  out.push(...validateAriaAttributes(text3, bindAttribute, locale2));
19779
20535
  out.push(...validateLiveRegions(text3, bindAttribute, stateTagName, locale2));
20536
+ out.push(...validateFormInputs(text3, bindAttribute, stateTagName, locale2, fileReader, applicationSchema));
20537
+ out.push(...validateBindingHosts(text3, bindAttribute, stateTagName, locale2));
20538
+ out.push(...validateIoAttributes(text3, bindAttribute, locale2));
19780
20539
  out.push(...validateDocumentEnv(text3, locale2));
19781
20540
  out.push(...validatePackageLoads(text3, locale2, fileReader));
19782
20541
  out.push(...validateSemantics(text3, stateTagName, locale2, bindAttribute));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/lint",
3
- "version": "4.22.0",
3
+ "version": "4.24.0",
4
4
  "description": "Static-contract validator CLI (wcs-validate) for wcstack data-wcs bindings and wcstack.manifest.json sidecars. Thin npm wrapper around the wcstack-intellisense validator core.",
5
5
  "type": "module",
6
6
  "bin": {