@wcstack/lint 4.18.0 → 4.20.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
@@ -21,10 +21,14 @@ npm i -D @wcstack/lint
21
21
  npx wcs-validate --errors-only src/**/*.html
22
22
  ```
23
23
 
24
+ 4.20 から、シェルが展開しなかったパターンは CLI が自分で展開します: 在るファイルを名指さず、`*`・`**`・`?`・`[…]`・`{a,b}` を持つ引数をファイルに当てます。当て方はシェルと同じで、`*` は 1 つのディレクトリの中だけ・`.` で始まる名前には当たらず、`**` はディレクトリをまたぎますが `node_modules` と `.` で始まるディレクトリには入りません。cmd.exe と PowerShell はパターンをそのまま渡し、npm は Windows ではパッケージの scripts を cmd.exe で走らせるので、4.19 までは npm script の `wcs-validate templates/*.html` がそこで `cannot read templates/*.html` で失敗していました。何にも当たらないパターンは error です(`no file matches <パターン>`、exit code `2`)。どのシェルでも CLI に展開させるには、パターンを引用符で囲んでください(`"src/**/*.html"`): `globstar` の無い POSIX シェルは `**` を `*` と読みます。
25
+
24
26
  `.manifest.json` で終わるファイルは sidecar manifest として、それ以外は `data-wcs` バインディングを含む HTML として検査されます。ただし framework のコンポーネントと script のファイル(`.js`・`.ts`・`.jsx`・`.tsx`・`.vue`・`.svelte`)は読みません(4.6 から。以前は HTML として読み、問題なしと報告していました)。
25
27
 
26
28
  `<wcs-state src="...">` で参照される外部 state(`.json` / `.js` / `.ts`)は HTML ファイルからの相対パスで解決され、パス検証の対象になります。URL は読み込まず、/ から始まるパスは `--root`(下記)のときだけ読み、読めないファイルはスキップされ、解決できないパスは warning のままです。なお外部 state が**解決できた**ページには通常の検証面が全て適用されるため、error severity の検出(例: 配列でない値への `for:`)が「これまでパス未解決で沈黙していたビルド」を新たに落とすことがあります。4.4 から、`.js` / `.ts` の state にはスクリプトの規則(`wcs/nested-assign`・`wcs/array-mutation`・`wcs/on-handler-this`・`wcs/updated-callback-unbound` など)もかかります: ファイルの中の指摘はそのファイルで報告し(`state.js:12:5 error wcs/nested-assign …`)、何ページから読まれても 1 回だけ数え、IDE はページの `src` の値の上に出します。4.3 までは、外部 state ではパスだけを検査していました。4.10 から、名前で書いたキー — 短縮プロパティ(`export default { lang, t }`。`examples/router-i18n` の辞書のボリューム `<wcs-state mount="i18n" src="./i18n/state.js">`)や `items: ITEMS` — は、その名前が束縛する値の形を持ちます: モジュールの `const` か、相対パスからの import(import するファイルからの相対で読み、再 export の先も辿ります)。4.17 からは名前空間の import のメンバーも同じです(`import * as M from "./lib/music.js"` の `sound: M.DEFAULT_SOUND`)。4.9 までは短縮プロパティのキーをまったく読まなかったので、`i18n.t.*` の束縛はすべて `wcs/binding-path-missing` の誤報でした。値を計算する名前(実行時にロケールの辞書を合わせた辞書)や辿れない名前(素の指定子・URL・無いファイル)のキーは、その下のパスを検査せず、ページがその下を束ねていればキーの上で 1 回だけそう言います(`wcs/path-dynamic-unknown`、info)。キーか宣言に JSDoc の `@type {typeof import("./en.js").default}` を付けると、そのファイルのリテラルで検査します。
27
29
 
30
+ 4.20 から、`{{ }}` はランタイムが束ねる場所でだけ束縛として読みます: テキストの中 — 属性の値(`aria-current="{{ x }}"`)や HTML コメントの中ではなく — で、文書の `<head>` の外(`<wcs-state>` は `<head>` を束ねません。そこの `{{ }}` やコメント束縛は `wcs/template-syntax` の warning です)。ページの state が `$behavior: { enableMustache: false }` を宣言していれば、`{{ }}` はどれも束縛として読みません — アイランドの横の CMS やサーバーのテンプレートの中括弧 — が、コメント束縛は検査します。設定は state のある場所で読みます: インライン・`json=`・`state=`・lint が読める `src=` のファイル(/ から始まるパスは `--root` のとき)。読めない state なら、`{{ }}` は従来どおり検査します。4.19 までは、そうした中括弧ごとに `wcs/binding-path-missing` の誤報と FOUC の info が出て、コメント束縛は 1 つずつ `wcs-text バインディング: …` の info を出していました(4.20 はもう出しません)。
31
+
28
32
  ```
29
33
  wcs-validate [--attr=data-wcs] [--state-tag=wcs-state] [--lang=ja|en] [--root=<dir>] [--errors-only] [--strict] <file> [<file> ...]
30
34
  ```
@@ -53,7 +57,7 @@ app.manifest.json:1:3 error wcs/manifest-broken Broken manifest JSON: ...
53
57
  |---|---|
54
58
  | `0` | error severity の診断なし(warning / info はあってもよい)。`--strict` 時は error も warning もなし |
55
59
  | `1` | error severity の診断が 1 件以上。`--strict` 時は error または warning が 1 件以上 |
56
- | `2` | usage エラー、またはファイル読み取り失敗 |
60
+ | `2` | usage エラー、またはファイル読み取り失敗。4.20 からは、何にも当たらないパターンも |
57
61
 
58
62
  件数の後に、件数が何も語らないファイルを 2 つの注が挙げます(4.6 から。`--errors-only` でも出し、exit code は変えません):
59
63
 
@@ -65,9 +69,11 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
65
69
 
66
70
  `<wcs-*>` の要素を使う framework のアプリ(React・Vue)にはどちらも無く、ページはルートの要素を持つだけで、コンポーネントは読まれません。exit code `0` は、そのようなアプリを検査したという意味ではありません。代わりに見るべきことは [framework 統合の手引き](../../docs/framework-adapter-integration.ja.md) にあります。
67
71
 
72
+ 4.20 から、束縛 — `data-wcs` 属性かコメント束縛 — があるのに `<wcs-state>` の無いファイルには、最初の束縛の上に `wcs/state-absent` の info を 1 つ出します: CMS の部分テンプレート・ファイルに分けたルートの中身・state をスクリプトで作るページには、パスを照らす state が無いので、パスは検査していません。4.19 までは、そうしたファイルは何も出さず `nothing to check:` にも載らなかったので、検査済みに見え、打ち間違い(`booking.totl`)が通っていました。state のあるページを検査するか、パスを `stateSchema`(下記)に宣言してください(宣言すれば出ません)。テキストの束縛が `{{ }}` だけのファイルは報告しません(中括弧だけでは、ほかのテンプレートエンジンのものかもしれません)。
73
+
68
74
  ## state の契約を宣言する(`stateSchema`)
69
75
 
70
- 契約が無いと、validator が解決できないパスは **warning**(`wcs/binding-path-missing`)に留まります: インラインスクリプトが静的に読めなくても `count` は実行時には存在するかもしれないからです。`[]` で始まるリストの行のフィールドは、行を足す・置き換える代入式の行リテラルから読みます。4.9 から、`map` で行を作り直す代入 — `this.rows = [...this.items].map((c) => ({ id: c.id, label: c.name }))`・`.filter(…).map((c) => { return { … }; })` — も、そうする getter と同じく読み、`{}` を種にしたキーへ代入したオブジェクトリテラルのキーも読みます(`this.fieldErrors = { date: "…" }` で `fieldErrors.date`。リテラルの中の spread は追いません)。4.17 から、`Array.from({ length: n }, (_, i) => ({ … }))`・`Array.from(source, (x) => ({ … }))` の mapper と、`[...Array(n).keys()]` に続く `map` も、getter でも代入でも同じに行の形を言います。4.16 まではその行の下の束縛がどれも `wcs/binding-path-missing` の誤報でした。4.11 から、モジュールの定数を spread する種 — `const EMPTY_DRAFT = { title: "", body: "" }` と `draft: { ...EMPTY_DRAFT }`、読めるファイルから import した定数も — は、そのリテラルのキーを持ちます(入れ子のものも。同じ名前は後に書いた方が勝ちます — オブジェクトを作るときと同じ)。リストの種の最初の行(`[{ ...ROW, id: 0 }]`)も同じです。4.17 からは、読めるファイルの名前空間の import のメンバー(`import * as M from "./lib/music.js"` の `sound: { ...M.DEFAULT_SOUND }`)も同じです。4.16 まではそのキーの下を検査しませんでした。4.10 まではそのキーの下の束縛がすべて `wcs/binding-path-missing` の誤報で、打ち間違い(`draft.titel`)も同じ警告でした。読めない spread — 呼び出し・`let`・読めない import — があれば、そのキーの下は検査せず、ページがその下を束ねていればキーの上で 1 回だけそう言います(`wcs/path-dynamic-unknown`、info)。外から届くリスト(`<wcs-fetch>` や `<wcs-storage>` が埋めるまで `null`)にはそのリテラルが無いので、プロパティの直前の JSDoc `@type` で形を宣言してください(`/** @type {{ id: number, name: string }[] | null} */ catalog: null`)。同じスクリプトの `@typedef` で行の型に名前を付け、`@type {Product[] | null}` と書いてもかまいません。本体から結果を読めない getter(`get keyRows() { return buildRows(this.sound); }`)も、getter の直前に同じように宣言します: getter は `@returns` か `@type` を結果の型として受けます(`/** @returns {{ label: string }[]} */ get keyRows() { … }`)— TypeScript と同じです。getter の `@type` は 4.17 から効きます。4.16 までは `@returns` だけが効き、getter の `@type` は何も言わずに無視されていました。HTML と同じ(または上の)ディレクトリに `application` sidecar を置くと、同じ typo が **error** になります:
76
+ 契約が無いと、validator が解決できないパスは **warning**(`wcs/binding-path-missing`)に留まります: インラインスクリプトが静的に読めなくても `count` は実行時には存在するかもしれないからです。`[]` で始まるリストの行のフィールドは、行を足す・置き換える代入式の行リテラルから読みます。4.9 から、`map` で行を作り直す代入 — `this.rows = [...this.items].map((c) => ({ id: c.id, label: c.name }))`・`.filter(…).map((c) => { return { … }; })` — も、そうする getter と同じく読み、`{}` を種にしたキーへ代入したオブジェクトリテラルのキーも読みます(`this.fieldErrors = { date: "…" }` で `fieldErrors.date`。リテラルの中の spread は追いません)。4.17 から、`Array.from({ length: n }, (_, i) => ({ … }))`・`Array.from(source, (x) => ({ … }))` の mapper と、`[...Array(n).keys()]` に続く `map` も、getter でも代入でも同じに行の形を言います。4.16 まではその行の下の束縛がどれも `wcs/binding-path-missing` の誤報でした。4.11 から、モジュールの定数を spread する種 — `const EMPTY_DRAFT = { title: "", body: "" }` と `draft: { ...EMPTY_DRAFT }`、読めるファイルから import した定数も — は、そのリテラルのキーを持ちます(入れ子のものも。同じ名前は後に書いた方が勝ちます — オブジェクトを作るときと同じ)。リストの種の最初の行(`[{ ...ROW, id: 0 }]`)も同じです。4.17 からは、読めるファイルの名前空間の import のメンバー(`import * as M from "./lib/music.js"` の `sound: { ...M.DEFAULT_SOUND }`)も同じです。4.16 まではそのキーの下を検査しませんでした。4.10 まではそのキーの下の束縛がすべて `wcs/binding-path-missing` の誤報で、打ち間違い(`draft.titel`)も同じ警告でした。読めない spread — 呼び出し・`let`・読めない import — があれば、そのキーの下は検査せず、ページがその下を束ねていればキーの上で 1 回だけそう言います(`wcs/path-dynamic-unknown`、info)。外から届くリスト(`<wcs-fetch>` や `<wcs-storage>` が埋めるまで `null`)にはそのリテラルが無いので、プロパティの直前の JSDoc `@type` で形を宣言してください(`/** @type {{ id: number, name: string }[] | null} */ catalog: null`)。同じスクリプトの `@typedef` で行の型に名前を付け、`@type {Product[] | null}` と書いてもかまいません。本体から結果を読めない getter(`get keyRows() { return buildRows(this.sound); }`)も、getter の直前に同じように宣言します: getter は `@returns` か `@type` を結果の型として受けます(`/** @returns {{ label: string }[]} */ get keyRows() { … }`)— TypeScript と同じです。getter の `@type` は 4.17 から効きます。4.16 までは `@returns` だけが効き、getter の `@type` は何も言わずに無視されていました。4.20 から、そうした型の索引シグネチャ — `Record<string, T>`・`{ [key: string]: T }`・Closure の `Object<string, T>` — は、getter の `@returns` / `@type` でもキーの `@type` でも、その下のパスを開いたままにします(`stateSchema` の開いたオブジェクトと同じ): `/** @returns {Record<string, boolean>} */ get soldOut()` と `class.full: soldOut.e12` は報告しません。4.19 まではそうした束縛のそれぞれが `wcs/binding-path-missing` の誤報でした。`Record<"open" | "closed", T>` はフィールド `open` と `closed` を持ちます。HTML と同じ(または上の)ディレクトリに `application` sidecar を置くと、同じ typo が **error** になります:
71
77
 
72
78
  ```json
73
79
  {
@@ -95,9 +101,10 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
95
101
 
96
102
  ## ページの wcstack のスクリプトと lint の版
97
103
 
98
- 4.11 から、2 つの warning がページの読み込む wcstack のスクリプトを見ます。どちらも warning なので、`--strict` では落ち、`--errors-only` では落ちません。
104
+ 4.11 から、2 つの warning がページの読み込む wcstack のスクリプトを見ます。4.20 から 3 つ目が加わります。どれも warning なので、`--strict` では落ち、`--errors-only` では落ちません。
99
105
 
100
106
  - **`wcs/tag-package-missing`** — wcstack を自分で読み込むページが、あるパッケージの `wcs-*` のタグ(`<wcs-upload>` やそのヘルパー `<wcs-upload-header>`、`<wcs-state>`・`<wcs-router>` など)を書くのに、そのパッケージのスクリプトを読み込んでいない。要素は定義されず、束縛は待ち続けて何も起きず、コンソールにも何も出ません。パッケージごとに 1 回、最初のタグに、読み込む `/auto` を挙げて報告します。読み込んだと数えるのは、`<script src>`・import map の項目・インラインのスクリプトの import か文字列が `@wcstack/<pkg>`(版・CDN・ローカルのパスを問わない)か一括バンドル `wcstack`(state・router・fetch・storage・autoloader)を名指すものです。ローカルのスクリプト(`./app.js`)は、それが import する相対のモジュールとともに読み、名指すものを数えます。wcstack を自分で読み込まないページ(断片・バンドラのページ)、autoloader がいて `@components/` の import map が覆うタグ、読めないローカルのスクリプトがあるページでは報告しません。
107
+ - **`wcs/link-router-missing`**(4.20 から) — router(か一括バンドル `wcstack`)を読み込むのに `<wcs-router>` の無いページの `<wcs-link to="/…">`。リンクは接続した時点で `[@wcstack/router] wcs-link is not connected to a router.` を投げ、隠れたまま(`display: none`)になります。router の無いページ — サーバーが描き、アイランドを置いたページ — では `<a href>` と書くか、`<wcs-router>` を置いてください。ページに 1 回、最初のそうしたリンクに報告します。見るのは `wcs/tag-package-missing` と同じページ(wcstack を自分で読み込むページ)だけです: 断片 — ルートの中身・router のページが取り込むレイアウトのファイル — は wcstack のスクリプトを読み込まないので報告せず、HTML コメントの外のどこかで `wcs-router` を名指すページ(`<template>` の中の `<wcs-router>`・それを作るスクリプトも)、router が無くても描かれる URL やクエリ(`?page=2`)の `to` も報告しません。
101
108
  - **`wcs/lint-version-behind`** — ページの URL が、この lint より新しい minor を固定している: `@wcstack/state@4.11.0` を `@wcstack/lint@4.10.1` で検査する。lint が持つのは自分の版の規則なので(`@wcstack/state` と lockstep で出ます)、新しい minor で加わったものは検査されず、新しい minor の正しい書き方を error にもします(4.2.0 の lint は 4.10 の `datetime(ja-JP,short,Asia/Tokyo)` を `wcs/filter-arity` にします)。ページに 1 回、いちばん新しい固定に、`@wcstack/lint` をその版に上げるよう言います — `package.json` の lint はページが固定する版に揃えてください。版の無い URL・major だけの固定(`@4`)・lint の方が新しいときは報告しません。
102
109
 
103
110
  ## 生成 → 検証 → 修正ループでの利用
package/README.md CHANGED
@@ -21,10 +21,14 @@ npm i -D @wcstack/lint
21
21
  npx wcs-validate --errors-only src/**/*.html
22
22
  ```
23
23
 
24
+ Since 4.20, the CLI expands a pattern itself when the shell has not: an argument that names no existing file and holds `*`, `**`, `?`, `[…]` or `{a,b}` is matched against the files, as a shell does — `*` stays in one directory and skips names that start with `.`; `**` crosses directories, but not `node_modules` or one whose name starts with `.`. cmd.exe and PowerShell pass a pattern through as it is, and npm runs a package's scripts with cmd.exe on Windows, so up to 4.19 `wcs-validate templates/*.html` in an npm script failed there with `cannot read templates/*.html`. A pattern that matches no file is an error (`no file matches <pattern>`, exit code `2`). Quote the pattern (`"src/**/*.html"`) to have the CLI expand it on every shell: a POSIX shell without `globstar` reads `**` as `*`.
25
+
24
26
  Files ending in `.manifest.json` are validated as sidecar manifests; everything else is validated as HTML with `data-wcs` bindings, except a framework's components and script files (`.js`, `.ts`, `.jsx`, `.tsx`, `.vue`, `.svelte`), which are not read (since 4.6; before, they were read as HTML and reported clean).
25
27
 
26
28
  External state referenced via `<wcs-state src="...">` (`.json` / `.js` / `.ts`) is resolved relative to the HTML file and included in path validation. URLs are never read, and a path from `/` only under `--root` (below), unreadable files are skipped, and unresolved paths stay warnings. Note that once external state *does* resolve, the full validation surface applies to those pages — error-severity findings (e.g. `for:` bound to a non-array) can fail a build that was previously silent because the paths could not be checked. Since 4.4 that includes the script rules (`wcs/nested-assign`, `wcs/array-mutation`, `wcs/on-handler-this`, `wcs/updated-callback-unbound` and the rest) on a `.js` / `.ts` state: a finding in the file is reported in the file (`state.js:12:5 error wcs/nested-assign …`), once however many pages load it, and the IDE shows it on the page's `src` value. Up to 4.3 only the paths of an external state were checked. Since 4.10, a key written as a name — a shorthand (`export default { lang, t }`, the dictionary volume `<wcs-state mount="i18n" src="./i18n/state.js">` of `examples/router-i18n`) or `items: ITEMS` — has the shape of what the name is bound to: a `const` of the module, or an import from a relative path, which is read relative to the file that imports it (and the module it re-exports from) — since 4.17 a member of a namespace import too (`sound: M.DEFAULT_SOUND` with `import * as M from "./lib/music.js"`). Up to 4.9 a shorthand key was not read at all, so every `i18n.t.*` binding was a false `wcs/binding-path-missing`. A name whose value is computed (the dictionary merged from the locale catalogs at run time), or that it cannot follow (a bare specifier, a URL, a file that is not there), leaves the paths under that key unchecked, and says so once at the key when the page binds under it (`wcs/path-dynamic-unknown`, info); a JSDoc `@type {typeof import("./en.js").default}` on the key or on the declaration has them checked against that file's literal.
27
29
 
30
+ Since 4.20, `{{ }}` is read as a binding only where the runtime binds it: in text — not in an attribute value (`aria-current="{{ x }}"`) or an HTML comment — and outside the document's `<head>`, which a `<wcs-state>` does not bind (a `{{ }}` or a comment binding there is a `wcs/template-syntax` warning). When the page's state declares `$behavior: { enableMustache: false }`, no `{{ }}` is read as a binding at all — a CMS's or a server template's braces beside an island — while comment bindings are still checked. The setting is read where the state is: inline, `json=`, `state=`, or an `src=` file the lint can read (with `--root` for a path from `/`); a state it cannot read leaves `{{ }}` checked as before. Up to 4.19 each such brace pair was a false `wcs/binding-path-missing` and a FOUC info, and every comment binding printed a `wcs-text binding: …` info, which 4.20 no longer does.
31
+
28
32
  ```
29
33
  wcs-validate [--attr=data-wcs] [--state-tag=wcs-state] [--lang=ja|en] [--root=<dir>] [--errors-only] [--strict] <file> [<file> ...]
30
34
  ```
@@ -53,7 +57,7 @@ app.manifest.json:1:3 error wcs/manifest-broken Broken manifest JSON: ...
53
57
  |---|---|
54
58
  | `0` | No error-severity diagnostics (warnings/info may exist); with `--strict`, no error or warning |
55
59
  | `1` | At least one error-severity diagnostic; with `--strict`, at least one error or warning |
56
- | `2` | Usage error or unreadable file |
60
+ | `2` | Usage error or unreadable file; since 4.20, also a pattern that matches no file |
57
61
 
58
62
  After the counts, two notes name the files the counts say nothing about (since 4.6; printed with `--errors-only` too, and they do not change the exit code):
59
63
 
@@ -65,9 +69,11 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
65
69
 
66
70
  A framework app (React, Vue) that uses the `<wcs-*>` elements has neither: its page holds the root element and its components are not read. Exit code `0` does not mean such an app was checked; [the framework integration guide](../../docs/framework-adapter-integration.md) lists what to look for instead.
67
71
 
72
+ Since 4.20, a file with bindings — a `data-wcs` attribute or a comment binding — and no `<wcs-state>` gets one `wcs/state-absent` info, at its first binding: a CMS's partial template, a route's content in a file of its own, or a page whose state a script makes has no state to check the paths against, so they are not checked. Up to 4.19 such a file printed nothing and was not listed under `nothing to check:` either, so it looked checked while a typo (`booking.totl`) passed. Check the page that holds the state, or declare the paths in a `stateSchema` (below), which silences it. A file whose only text bindings are `{{ }}` is not reported (braces alone may be another template engine's).
73
+
68
74
  ## Declaring a state contract (`stateSchema`)
69
75
 
70
- Without a contract, a path the validator cannot resolve is only a **warning** (`wcs/binding-path-missing`): `count` may well exist at runtime even when the inline script cannot be read statically. Note that a list starting as `[]` does not need a contract just to name its row fields — the analyzer reads them from the row literals in the assignments that add or replace rows (`this.items = this.items.concat({ id, kind: "general" })`, `.toSpliced(i, n, { … })`, `.with(i, { … })`, `[...this.items, { … }]`); only a row passed as a variable (`concat(row)`) is invisible to it. Since 4.9 it also reads an assignment that rebuilds the rows with `map` — `this.rows = [...this.items].map((c) => ({ id: c.id, label: c.name }))`, `.filter(…).map((c) => { return { … }; })` — the way it reads a getter that does, and the keys of an object literal assigned to a key seeded `{}` (`this.fieldErrors = { date: "…" }` gives `fieldErrors.date`; a spread inside the literal is not followed). Since 4.17 the mapper of `Array.from({ length: n }, (_, i) => ({ … }))` and `Array.from(source, (x) => ({ … }))`, and a `map` after `[...Array(n).keys()]`, give the rows the same way, in a getter and in an assignment; up to 4.16 each binding under such rows was a false `wcs/binding-path-missing`. Since 4.11 a seed that spreads a constant of the module — `draft: { ...EMPTY_DRAFT }` with `const EMPTY_DRAFT = { title: "", body: "" }`, or one imported from a file it reads — has that literal's keys (nested ones too; a later key of the same name wins, as when the object is built), and so does a list seed's first row (`[{ ...ROW, id: 0 }]`); since 4.17 so does a member of a namespace import of a file it reads (`sound: { ...M.DEFAULT_SOUND }` with `import * as M from "./lib/music.js"`), which up to 4.16 left the keys unchecked. Up to 4.10 every binding under such a key was a false `wcs/binding-path-missing`, and a typo (`draft.titel`) the same warning. A spread it cannot read — a call, a `let`, an import it cannot read — leaves the keys under that key unchecked, said once at the key when the page binds under it (`wcs/path-dynamic-unknown`, info). A list that arrives from outside — `null` until `<wcs-fetch>` or `<wcs-storage>` fills it — has no such literal: declare its shape with a JSDoc `@type` before the property (`/** @type {{ id: number, name: string }[] | null} */ catalog: null`), or name the row type with a `@typedef` in the same script and write `@type {Product[] | null}`. A getter whose result it cannot read from the body (`get keyRows() { return buildRows(this.sound); }`) is declared the same way, before the getter: a getter takes `@returns` or `@type` — `/** @returns {{ label: string }[]} */ get keyRows() { … }` — as its result type, as TypeScript does. `@type` counts on a getter since 4.17; up to 4.16 only `@returns` did, and a getter's `@type` was ignored without a word. Put an `application` sidecar next to (or above) the HTML and the same typo becomes an **error**:
76
+ Without a contract, a path the validator cannot resolve is only a **warning** (`wcs/binding-path-missing`): `count` may well exist at runtime even when the inline script cannot be read statically. Note that a list starting as `[]` does not need a contract just to name its row fields — the analyzer reads them from the row literals in the assignments that add or replace rows (`this.items = this.items.concat({ id, kind: "general" })`, `.toSpliced(i, n, { … })`, `.with(i, { … })`, `[...this.items, { … }]`); only a row passed as a variable (`concat(row)`) is invisible to it. Since 4.9 it also reads an assignment that rebuilds the rows with `map` — `this.rows = [...this.items].map((c) => ({ id: c.id, label: c.name }))`, `.filter(…).map((c) => { return { … }; })` — the way it reads a getter that does, and the keys of an object literal assigned to a key seeded `{}` (`this.fieldErrors = { date: "…" }` gives `fieldErrors.date`; a spread inside the literal is not followed). Since 4.17 the mapper of `Array.from({ length: n }, (_, i) => ({ … }))` and `Array.from(source, (x) => ({ … }))`, and a `map` after `[...Array(n).keys()]`, give the rows the same way, in a getter and in an assignment; up to 4.16 each binding under such rows was a false `wcs/binding-path-missing`. Since 4.11 a seed that spreads a constant of the module — `draft: { ...EMPTY_DRAFT }` with `const EMPTY_DRAFT = { title: "", body: "" }`, or one imported from a file it reads — has that literal's keys (nested ones too; a later key of the same name wins, as when the object is built), and so does a list seed's first row (`[{ ...ROW, id: 0 }]`); since 4.17 so does a member of a namespace import of a file it reads (`sound: { ...M.DEFAULT_SOUND }` with `import * as M from "./lib/music.js"`), which up to 4.16 left the keys unchecked. Up to 4.10 every binding under such a key was a false `wcs/binding-path-missing`, and a typo (`draft.titel`) the same warning. A spread it cannot read — a call, a `let`, an import it cannot read — leaves the keys under that key unchecked, said once at the key when the page binds under it (`wcs/path-dynamic-unknown`, info). A list that arrives from outside — `null` until `<wcs-fetch>` or `<wcs-storage>` fills it — has no such literal: declare its shape with a JSDoc `@type` before the property (`/** @type {{ id: number, name: string }[] | null} */ catalog: null`), or name the row type with a `@typedef` in the same script and write `@type {Product[] | null}`. A getter whose result it cannot read from the body (`get keyRows() { return buildRows(this.sound); }`) is declared the same way, before the getter: a getter takes `@returns` or `@type` — `/** @returns {{ label: string }[]} */ get keyRows() { … }` — as its result type, as TypeScript does. `@type` counts on a getter since 4.17; up to 4.16 only `@returns` did, and a getter's `@type` was ignored without a word. Since 4.20, an index signature in such a type — `Record<string, T>`, `{ [key: string]: T }`, Closure's `Object<string, T>` — on a getter's `@returns` / `@type` or a key's `@type` leaves the paths under it open, as a `stateSchema`'s open object does: `/** @returns {Record<string, boolean>} */ get soldOut()` with `class.full: soldOut.e12` is not reported, where up to 4.19 each such binding was a false `wcs/binding-path-missing`. `Record<"open" | "closed", T>` has the fields `open` and `closed`. Put an `application` sidecar next to (or above) the HTML and the same typo becomes an **error**:
71
77
 
72
78
  ```json
73
79
  {
@@ -95,9 +101,10 @@ Without a contract, a path the validator cannot resolve is only a **warning** (`
95
101
 
96
102
  ## The page's wcstack scripts and the lint's version
97
103
 
98
- Since 4.11, two warnings look at the wcstack scripts a page loads. Both are warnings: `--strict` fails on them, `--errors-only` does not.
104
+ Since 4.11, two warnings look at the wcstack scripts a page loads, and since 4.20 a third. All are warnings: `--strict` fails on them, `--errors-only` does not.
99
105
 
100
106
  - **`wcs/tag-package-missing`** — a `wcs-*` tag of a wcstack package (`<wcs-upload>`, or its helper `<wcs-upload-header>`; `<wcs-state>`, `<wcs-router>` …) on a page that loads wcstack itself but no script of that package. The element is never defined, its bindings wait and nothing happens, and the console says nothing. Reported once per package, at its first tag, with the `/auto` to load. A script counts when a `<script src>`, an import map entry, or an import or a string in an inline script names `@wcstack/<pkg>` (any version, any CDN, a local path) or the `wcstack` bundle (state, router, fetch, storage, autoloader); a local script (`./app.js`) is read, with the relative modules it imports, for what it names. Not reported on a page that names no wcstack script itself (a fragment, a bundler's page), for a tag an `@components/` import map entry covers while the autoloader is there, or when a local script cannot be read.
107
+ - **`wcs/link-router-missing`** (since 4.20) — a `<wcs-link to="/…">` on a page that loads the router (or the `wcstack` bundle) but has no `<wcs-router>`: the link throws `[@wcstack/router] wcs-link is not connected to a router.` when it connects, and stays hidden (`display: none`). On a page without the router — a page a server renders, with islands in it — write `<a href>`, or add the `<wcs-router>`. Reported once per page, at the first such link, where `wcs/tag-package-missing` would look (a page that loads wcstack itself): a fragment — a route's content, a layout file the router page includes — loads no wcstack script and is not reported, nor is a page that names `wcs-router` anywhere outside an HTML comment (a `<wcs-router>`, in a `<template>` too, or a script that makes one), nor a `to` that is a URL or a query (`?page=2`), which renders without the router.
101
108
  - **`wcs/lint-version-behind`** — a URL on the page pins a newer minor than this lint: `@wcstack/state@4.11.0` checked with `@wcstack/lint@4.10.1`. The lint carries the rules of its own version (it is released with `@wcstack/state`, in lockstep), so it does not check what the newer minor added, and it can report the newer minor's correct syntax as an error (4.2.0's lint gives `wcs/filter-arity` for 4.10's `datetime(ja-JP,short,Asia/Tokyo)`). Said once per page, at the newest pin: upgrade `@wcstack/lint` to that version — keep the lint in `package.json` at the version the page pins. A URL without a version, a major-only pin (`@4`) and a lint newer than the page are not reported.
102
109
 
103
110
  ## Use in generate–validate–fix loops
package/dist/cli.cjs CHANGED
@@ -22,6 +22,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
22
22
  var cli_exports = {};
23
23
  __export(cli_exports, {
24
24
  createFileReader: () => createFileReader,
25
+ expandFileArgs: () => expandFileArgs,
25
26
  main: () => main,
26
27
  parseArgs: () => parseArgs,
27
28
  resolveCliLocale: () => resolveCliLocale
@@ -66,6 +67,107 @@ function createFileReader(htmlPath, read = (p) => (0, import_node_fs.readFileSyn
66
67
  };
67
68
  }
68
69
 
70
+ // src/core/cli/glob.ts
71
+ function hasGlobMagic(arg) {
72
+ return /[*?[{]/.test(arg);
73
+ }
74
+ function expandGlob(pattern, fs) {
75
+ const found = /* @__PURE__ */ new Set();
76
+ for (const alternative of expandBraces(pattern)) {
77
+ const segments = alternative.split("/");
78
+ let i = 0;
79
+ while (i < segments.length - 1 && !hasGlobMagic(segments[i])) i++;
80
+ const base = segments.slice(0, i).join("/");
81
+ walk(fs, base === "" && alternative.startsWith("/") ? "/" : base, segments.slice(i), found);
82
+ }
83
+ return [...found].sort();
84
+ }
85
+ function join(dir, name) {
86
+ if (dir === "") return name;
87
+ return dir.endsWith("/") ? dir + name : `${dir}/${name}`;
88
+ }
89
+ function walk(fs, dir, segments, found) {
90
+ const [segment, ...rest] = segments;
91
+ if (segment === "**") {
92
+ if (rest.length === 0) {
93
+ walk(fs, dir, ["**", "*"], found);
94
+ return;
95
+ }
96
+ walk(fs, dir, rest, found);
97
+ for (const entry of fs.readDir(dir === "" ? "." : dir) ?? []) {
98
+ if (!entry.dir || entry.name.startsWith(".") || entry.name === "node_modules") continue;
99
+ walk(fs, join(dir, entry.name), segments, found);
100
+ }
101
+ return;
102
+ }
103
+ const entries = fs.readDir(dir === "" ? "." : dir);
104
+ if (entries === void 0) return;
105
+ const matches = segmentMatcher(segment);
106
+ for (const entry of entries) {
107
+ if (!matches(entry.name)) continue;
108
+ if (rest.length === 0) {
109
+ if (!entry.dir) found.add(join(dir, entry.name));
110
+ } else if (entry.dir) {
111
+ walk(fs, join(dir, entry.name), rest, found);
112
+ }
113
+ }
114
+ }
115
+ function segmentMatcher(segment) {
116
+ if (!hasGlobMagic(segment)) return (name) => name === segment;
117
+ let source = "";
118
+ for (let i = 0; i < segment.length; i++) {
119
+ const ch = segment[i];
120
+ if (ch === "*") {
121
+ source += "[^/]*";
122
+ } else if (ch === "?") {
123
+ source += "[^/]";
124
+ } else if (ch === "[") {
125
+ const close = segment.indexOf("]", i + 2);
126
+ if (close === -1) {
127
+ source += "\\[";
128
+ continue;
129
+ }
130
+ let body = segment.slice(i + 1, close);
131
+ const negate = body.startsWith("!") || body.startsWith("^");
132
+ if (negate) body = body.slice(1);
133
+ source += `[${negate ? "^" : ""}${body.replace(/[\\\]]/g, "\\$&")}]`;
134
+ i = close;
135
+ } else {
136
+ source += ch.replace(/[.+^${}()|\\\]]/g, "\\$&");
137
+ }
138
+ }
139
+ const regex = new RegExp(`^${source}$`);
140
+ const dotted = segment.startsWith(".");
141
+ return (name) => (dotted || !name.startsWith(".")) && regex.test(name);
142
+ }
143
+ function expandBraces(pattern) {
144
+ const open = pattern.indexOf("{");
145
+ if (open === -1) return [pattern];
146
+ let depth = 0;
147
+ const commas = [];
148
+ for (let i = open; i < pattern.length; i++) {
149
+ const ch = pattern[i];
150
+ if (ch === "{") depth++;
151
+ else if (ch === "}") {
152
+ depth--;
153
+ if (depth === 0) {
154
+ if (commas.length === 0) return expandBraces(pattern.slice(i + 1)).map((tail2) => pattern.slice(0, i + 1) + tail2);
155
+ const head = pattern.slice(0, open);
156
+ const tail = pattern.slice(i + 1);
157
+ const bounds = [open, ...commas, i];
158
+ const out = [];
159
+ for (let k = 0; k < bounds.length - 1; k++) {
160
+ out.push(...expandBraces(head + pattern.slice(bounds[k] + 1, bounds[k + 1]) + tail));
161
+ }
162
+ return out;
163
+ }
164
+ } else if (ch === "," && depth === 1) {
165
+ commas.push(i);
166
+ }
167
+ }
168
+ return [pattern];
169
+ }
170
+
69
171
  // src/core/diagnostics.ts
70
172
  var WcsDiagnosticCode = {
71
173
  // --- sidecar manifest envelope / schema subset ---
@@ -103,6 +205,11 @@ var WcsDiagnosticCode = {
103
205
  // lint の限界の告知(作者の誤りではない): 読めない `<wcs-state src>`(/ から始まるパス・URL・無いファイル)の state は
104
206
  // パスもスクリプトの規則も検査しない — それを src の上で 1 回だけ言う。info(docs/seam-apps.md、prod-booking)。
105
207
  StateSrcUnread: "wcs/state-src-unread",
208
+ // lint の限界の告知(作者の誤りとは限らない): 束縛(`data-wcs`・コメント束縛)があるのに `<wcs-state>` の無いファイル
209
+ // (ページが取り込む CMS の部分テンプレート・ルートの中身の断片・state をスクリプトで作るページ)。束縛のパスは
210
+ // 検査していない — それをファイルに 1 回だけ、最初の束縛の上で言う。stateSchema があれば検査するので黙る。info
211
+ // (継ぎ目アプリ community-hall — 何も出ず `nothing to check:` にも載らないので、検査済みに見えた)。
212
+ StateAbsent: "wcs/state-absent",
106
213
  // --- existing binding-expression validators (retrofitted) ---
107
214
  FilterUnknown: "wcs/filter-unknown",
108
215
  FilterArity: "wcs/filter-arity",
@@ -327,6 +434,13 @@ var WcsDiagnosticCode = {
327
434
  // homeroom — 保存が「送信中 0%」で止まった)。パッケージごとに 1 回、最初のタグに。読めないローカルのスクリプトがある
328
435
  // ページ・autoloader の `@components/` が覆うタグ・wcstack を自分で読み込まないページ(断片・バンドラ)では黙る。warning。
329
436
  TagPackageMissing: "wcs/tag-package-missing",
437
+ // `<wcs-router>` の無いページの、内部のパス(`to="/…"`)へ飛ぶ `<wcs-link>`。リンクは接続で
438
+ // `[@wcstack/router] wcs-link is not connected to a router.` を投げ、ホストは `display: none` のまま `<a>` を作らない
439
+ // — リンクが消える(継ぎ目アプリ community-hall — サーバーが描くページにアイランドを置く形)。wcstack を自分で
440
+ // 読み込み、router を読み込むページだけ(断片・ルートの中身・レイアウトのファイルは黙る)。router を読み込まない
441
+ // ページは `wcs/tag-package-missing` が報告する。ページが HTML コメントの外のどこかで `wcs-router` を名指せば
442
+ // (`<template>` の中の `<wcs-router>`・それを作るスクリプトも)黙る。warning。
443
+ LinkRouterMissing: "wcs/link-router-missing",
330
444
  // ページの URL が、lint の規則の版(lint を作った @wcstack/state の版)より新しい minor の wcstack を固定している
331
445
  // (`@wcstack/state@4.11.0` と lint 4.10.1)。古い lint は新しい規則を知らず、新しい正しい書き方を error にもする
332
446
  // (homeroom — 4.2.0 の lint が 4.10 の `datetime(ja-JP,short,Asia/Tokyo)` を `wcs/filter-arity` に)。ページに 1 回、
@@ -779,10 +893,13 @@ var SENTENCES = {
779
893
  42
780
894
  /* InlineBlocked */
781
895
  ]: () => `The inline <script> of <wcs-state> was blocked by Content-Security-Policy. Inline state is evaluated through a blob: URL: give the page's nonce to the <script> that loads @wcstack/state, or allow blob: in script-src. Moving the state into an external file (src="./state.js") needs neither. See ${CSP_GUIDE}`,
896
+ // an import that does not resolve (Chromium "Failed to resolve module specifier", Firefox "… specifier …",
897
+ // WebKit "does not resolve"): the blob: URL is the base — no CSP is involved (community-hall, D6). (A browser's
898
+ // own sentence ends with a period of its own: one is enough)
782
899
  [
783
900
  43
784
901
  /* InlineFailed */
785
- ]: (detail) => `Failed to evaluate the inline <script> of <wcs-state>: ${detail}. If this page sets a Content-Security-Policy, see ${CSP_GUIDE}`,
902
+ ]: (detail) => `Failed to evaluate the inline <script> of <wcs-state>: ${String(detail).replace(/\.$/, "")}. ${/specifier|does not resolve/i.test(String(detail)) ? `An inline state is evaluated from a blob: URL, against which a relative or root-relative import ("./x.js", "/js/x.js") does not resolve: import a full URL, or a name the page's import map gives ({ "imports": { "@app/": "/js/" } }), or move the state into a file (src="./state.js").` : `If this page sets a Content-Security-Policy, see ${CSP_GUIDE}`}`,
786
903
  [
787
904
  17
788
905
  /* TokenSubscriberThrew */
@@ -1859,7 +1976,7 @@ var config = {
1859
1976
  locale: typeof document !== "undefined" ? document.documentElement?.lang || "en" : "en",
1860
1977
  enableContractAnalyzer: false
1861
1978
  };
1862
- var FEATURE_NAMES = ["formats", "diagnostics", "temporal", "list-keys", "scopes", "recursion", "ssr", "devtools", "native-commands"];
1979
+ var FEATURE_NAMES = ["formats", "diagnostics", "temporal", "list-keys", "scopes", "recursion", "ssr", "devtools", "native-commands", "release"];
1863
1980
  var NATIVE_COMMANDS = {
1864
1981
  "*": ["focus", "blur", "click", "scrollIntoView", "showPopover", "hidePopover", "togglePopover"],
1865
1982
  "dialog": ["show", "showModal", "close", "requestClose"],
@@ -2111,7 +2228,7 @@ var truncate = (options) => {
2111
2228
  return v.slice(0, maxLength) + suffix;
2112
2229
  };
2113
2230
  };
2114
- var join = (options) => {
2231
+ var join2 = (options) => {
2115
2232
  const opt = options?.[0] ?? ", ";
2116
2233
  return (value) => {
2117
2234
  if (!Array.isArray(value)) {
@@ -2220,8 +2337,9 @@ var coalesce = (options, literals) => {
2220
2337
  var nullIfEmpty = () => (value) => value === "" ? null : value;
2221
2338
  var { eq: eq2, ne: ne2, not: not2, lt, le, gt, ge, falsy: falsy2, truthy: truthy2, boolean: boolean2 } = coreFilters;
2222
2339
  var registered = {
2223
- toFixed: { factory: toFixed, arity: [0, 1] },
2224
- locale: { factory: locale, arity: [0, 1] },
2340
+ // The number display family passes an absent value through too (since 4.20 — see nullishPassthrough)
2341
+ toFixed: { factory: nullishPassthrough(toFixed), arity: [0, 1] },
2342
+ locale: { factory: nullishPassthrough(locale), arity: [0, 1] },
2225
2343
  // The `String(value)` family passes an absent value through (B8 — see nullishPassthrough)
2226
2344
  upper: { factory: nullishPassthrough(upper), arity: [0, 0] },
2227
2345
  lower: { factory: nullishPassthrough(lower), arity: [0, 0] },
@@ -2234,11 +2352,11 @@ var registered = {
2234
2352
  repeat: { factory: nullishPassthrough(repeat), arity: [1, 1] },
2235
2353
  reverse: { factory: nullishPassthrough(reverse), arity: [0, 0] },
2236
2354
  truncate: { factory: nullishPassthrough(truncate), arity: [1, 2] },
2237
- join: { factory: join, arity: [0, 1] },
2238
- round: { factory: round, arity: [0, 1] },
2239
- floor: { factory: floor, arity: [0, 1] },
2240
- ceil: { factory: ceil, arity: [0, 1] },
2241
- percent: { factory: percent, arity: [0, 1] },
2355
+ join: { factory: join2, arity: [0, 1] },
2356
+ round: { factory: nullishPassthrough(round), arity: [0, 1] },
2357
+ floor: { factory: nullishPassthrough(floor), arity: [0, 1] },
2358
+ ceil: { factory: nullishPassthrough(ceil), arity: [0, 1] },
2359
+ percent: { factory: nullishPassthrough(percent), arity: [0, 1] },
2242
2360
  unit: { factory: nullishPassthrough(unit), arity: [1, 1] },
2243
2361
  // The locale-dependent three take a locale like `locale` does (`date(ja-JP)`), a style (`date(ja-JP,long)`)
2244
2362
  // and, since 4.10, a time zone (`date(ja-JP,long,Asia/Tokyo)`)
@@ -2273,7 +2391,7 @@ var registered = {
2273
2391
  string: { factory: string, arity: [0, 0] },
2274
2392
  nullIfEmpty: { factory: nullIfEmpty, arity: [0, 0] },
2275
2393
  // (added in 4.2: last, so the order of the others is unchanged)
2276
- currency: { factory: currency, arity: [1, 2] }
2394
+ currency: { factory: nullishPassthrough(currency), arity: [1, 2] }
2277
2395
  };
2278
2396
  var formatFilters = /* @__PURE__ */ Object.fromEntries(
2279
2397
  /* @__PURE__ */ Object.entries(registered).filter(([name]) => !(name in coreFilters))
@@ -2425,7 +2543,7 @@ function getWcsManifest() {
2425
2543
  }
2426
2544
 
2427
2545
  // ../state/package.json
2428
- var version = "4.18.0";
2546
+ var version = "4.20.0";
2429
2547
 
2430
2548
  // src/service/wcsManifest.ts
2431
2549
  var ENGINE_VERSION = version;
@@ -8186,6 +8304,8 @@ function parse3(input, options) {
8186
8304
  var UNKNOWN = { kind: "unknown" };
8187
8305
  var NULL_TYPE = { kind: "name", name: "null" };
8188
8306
  var ARRAY_GENERICS = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
8307
+ var INDEX_GENERICS = /* @__PURE__ */ new Set(["Record", "Object"]);
8308
+ var SAME_SHAPE_GENERICS = /* @__PURE__ */ new Set(["Readonly", "Partial", "Required"]);
8189
8309
  var MAX_RESOLVE_DEPTH = 8;
8190
8310
  function tokenize(text3) {
8191
8311
  const tokens = [];
@@ -8327,6 +8447,10 @@ function parseJsDocType(text3) {
8327
8447
  if (isPunct(".") && tokens[pos + 1]?.t === "punct" && tokens[pos + 1].v === "<") pos++;
8328
8448
  if (isPunct("<")) {
8329
8449
  pos++;
8450
+ if (name === "Record") {
8451
+ const literal2 = parseLiteralKeyRecord();
8452
+ if (literal2 !== void 0) return literal2;
8453
+ }
8330
8454
  const args = [];
8331
8455
  for (; ; ) {
8332
8456
  const arg = parseUnion();
@@ -8335,20 +8459,47 @@ function parseJsDocType(text3) {
8335
8459
  if (!expect(",")) break;
8336
8460
  }
8337
8461
  if (!expect(">")) return null;
8338
- return ARRAY_GENERICS.has(name) && args.length === 1 ? { kind: "array", element: args[0] } : UNKNOWN;
8462
+ if (ARRAY_GENERICS.has(name) && args.length === 1) return { kind: "array", element: args[0] };
8463
+ if (INDEX_GENERICS.has(name) && args.length === 2) return { kind: "object", fields: [], index: args[1] };
8464
+ if (SAME_SHAPE_GENERICS.has(name) && args.length === 1) return args[0];
8465
+ return UNKNOWN;
8339
8466
  }
8340
8467
  return { kind: "name", name };
8341
8468
  };
8469
+ const parseLiteralKeyRecord = () => {
8470
+ const start = pos;
8471
+ const keys = [];
8472
+ expect("|");
8473
+ for (; ; ) {
8474
+ const token = peek();
8475
+ if (token === void 0 || token.t !== "string") break;
8476
+ keys.push(token.v);
8477
+ pos++;
8478
+ if (!expect("|")) break;
8479
+ }
8480
+ if (keys.length === 0 || !expect(",")) {
8481
+ pos = start;
8482
+ return void 0;
8483
+ }
8484
+ const value = parseUnion();
8485
+ if (value === null || !expect(">")) return null;
8486
+ return { kind: "object", fields: keys.map((name) => ({ name, type: value })) };
8487
+ };
8342
8488
  const parseObject = () => {
8343
8489
  pos++;
8344
8490
  const fields = [];
8491
+ let index;
8345
8492
  while (!isPunct("}")) {
8346
8493
  const key = peek();
8347
8494
  if (key === void 0) return null;
8348
8495
  if (key.t === "punct" && key.v === "[") {
8349
8496
  pos++;
8350
8497
  if (!skipUntilClose("[", "]")) return null;
8351
- if (!expect(":") || parseUnion() === null) return null;
8498
+ expect("?");
8499
+ if (!expect(":")) return null;
8500
+ const value = parseUnion();
8501
+ if (value === null) return null;
8502
+ index = index === void 0 ? value : { kind: "union", members: [index, value] };
8352
8503
  } else {
8353
8504
  if (key.t !== "name" && key.t !== "string") return null;
8354
8505
  pos++;
@@ -8360,7 +8511,7 @@ function parseJsDocType(text3) {
8360
8511
  }
8361
8512
  if (!expect(",") && !expect(";")) break;
8362
8513
  }
8363
- return expect("}") ? { kind: "object", fields } : null;
8514
+ return expect("}") ? { kind: "object", fields, ...index !== void 0 ? { index } : {} } : null;
8364
8515
  };
8365
8516
  const skipUntilClose = (open, close) => {
8366
8517
  let depth = 0;
@@ -8466,16 +8617,19 @@ function jsDocTypeHint(type, typedefs = /* @__PURE__ */ new Map()) {
8466
8617
  function jsDocShape(type, typedefs) {
8467
8618
  const elements = [];
8468
8619
  const fields = [];
8620
+ const indexes = [];
8469
8621
  for (const member of flattenJsDocType(type, typedefs)) {
8470
8622
  if (member.kind === "array") elements.push(member.element);
8471
8623
  else if (member.kind === "object") {
8472
8624
  for (const field of member.fields) {
8473
8625
  if (!fields.some((f) => f.name === field.name)) fields.push(field);
8474
8626
  }
8627
+ if (member.index !== void 0) indexes.push(member.index);
8475
8628
  }
8476
8629
  }
8477
8630
  const element2 = elements.length === 0 ? null : elements.length === 1 ? elements[0] : { kind: "union", members: elements };
8478
- return { element: element2, fields };
8631
+ if (indexes.length === 0) return { element: element2, fields };
8632
+ return { element: element2, fields, index: indexes.length === 1 ? indexes[0] : { kind: "union", members: indexes } };
8479
8633
  }
8480
8634
 
8481
8635
  // src/service/moduleValues.ts
@@ -9892,6 +10046,10 @@ function followValue(prop, scope) {
9892
10046
  }
9893
10047
  function pushDeclaredShapePaths(path, type, paths, depth, typedefs) {
9894
10048
  const shape = jsDocShape(type, typedefs);
10049
+ if (shape.index !== void 0) {
10050
+ const candidate = paths.find((p) => p.path === path);
10051
+ if (candidate !== void 0) candidate.openKeys = true;
10052
+ }
9895
10053
  if (shape.element !== null) {
9896
10054
  if (!hasPath(paths, `${path}.*`)) paths.push({ path: `${path}.*`, kind: "list" });
9897
10055
  if (!hasPath(paths, `${path}.length`)) paths.push({ path: `${path}.length`, kind: "data", typeHint: "number" });
@@ -10452,7 +10610,7 @@ function resolveStatePathIndex(elements, html, fileReader, includeRoots) {
10452
10610
  };
10453
10611
  }
10454
10612
  function opaquePathsOf(paths) {
10455
- return paths.filter((p) => p.opaque !== void 0).map((p) => p.path);
10613
+ return paths.filter((p) => p.opaque !== void 0 || p.openKeys === true).map((p) => p.path);
10456
10614
  }
10457
10615
  function moduleLocationOf(fileReader, path) {
10458
10616
  return fileReader === void 0 ? void 0 : { fileReader, path: path ?? "" };
@@ -11310,11 +11468,11 @@ function collectThisMemberRefsInValue(value, names2) {
11310
11468
  }
11311
11469
  function walkThisMembers(root, names2, offsetShift) {
11312
11470
  const out = [];
11313
- const walk = (node, thisIsState) => {
11471
+ const walk2 = (node, thisIsState) => {
11314
11472
  if (isClassNode(node)) return;
11315
11473
  if (isFunctionNode(node)) {
11316
11474
  const inner = node.type === "ArrowFunctionExpression" ? thisIsState : false;
11317
- forEachChild(node, (child) => walk(child, inner));
11475
+ forEachChild(node, (child) => walk2(child, inner));
11318
11476
  return;
11319
11477
  }
11320
11478
  if (thisIsState && node.type === "MemberExpression" && node.object.type === "ThisExpression") {
@@ -11323,9 +11481,9 @@ function walkThisMembers(root, names2, offsetShift) {
11323
11481
  out.push({ name: hit.name, start: hit.start - offsetShift, end: hit.end - offsetShift });
11324
11482
  }
11325
11483
  }
11326
- forEachChild(node, (child) => walk(child, thisIsState));
11484
+ forEachChild(node, (child) => walk2(child, thisIsState));
11327
11485
  };
11328
- walk(root, true);
11486
+ walk2(root, true);
11329
11487
  return out;
11330
11488
  }
11331
11489
  function thisMemberName(node) {
@@ -11418,16 +11576,16 @@ function findOwnThis(text3, kind) {
11418
11576
  root = statement.expression.body;
11419
11577
  }
11420
11578
  let found = null;
11421
- const walk = (node) => {
11579
+ const walk2 = (node) => {
11422
11580
  if (found !== null || isClassNode(node)) return;
11423
11581
  if (isFunctionNode(node) && node.type !== "ArrowFunctionExpression") return;
11424
11582
  if (node.type === "ThisExpression") {
11425
11583
  found = { start: node.start - prefix.length, end: node.end - prefix.length };
11426
11584
  return;
11427
11585
  }
11428
- forEachChild(node, walk);
11586
+ forEachChild(node, walk2);
11429
11587
  };
11430
- forEachChild(root, walk);
11588
+ forEachChild(root, walk2);
11431
11589
  return found;
11432
11590
  }
11433
11591
  var DESTRUCTIVE_ARRAY_METHODS = /* @__PURE__ */ new Set(["push", "pop", "shift", "unshift", "splice", "sort", "reverse", "fill", "copyWithin"]);
@@ -11591,7 +11749,7 @@ function findLocationRead(body) {
11591
11749
  const at2 = (node) => {
11592
11750
  found = { start: node.start - PREFIX.length, end: node.end - PREFIX.length, text: (PREFIX + body).slice(node.start, node.end) };
11593
11751
  };
11594
- const walk = (node) => {
11752
+ const walk2 = (node) => {
11595
11753
  if (found !== null) return;
11596
11754
  if (node.type === "MemberExpression" && isLocation(node.object)) {
11597
11755
  const part = !node.computed && node.property.type === "Identifier" ? node.property.name : null;
@@ -11603,18 +11761,18 @@ function findLocationRead(body) {
11603
11761
  return;
11604
11762
  }
11605
11763
  if (node.type === "MemberExpression") {
11606
- walk(node.object);
11607
- if (node.computed) walk(node.property);
11764
+ walk2(node.object);
11765
+ if (node.computed) walk2(node.property);
11608
11766
  return;
11609
11767
  }
11610
11768
  if (node.type === "Property") {
11611
- if (node.computed) walk(node.key);
11612
- walk(node.value);
11769
+ if (node.computed) walk2(node.key);
11770
+ walk2(node.value);
11613
11771
  return;
11614
11772
  }
11615
- forEachChild(node, walk);
11773
+ forEachChild(node, walk2);
11616
11774
  };
11617
- walk(wrapper.body);
11775
+ walk2(wrapper.body);
11618
11776
  return found;
11619
11777
  }
11620
11778
 
@@ -11670,6 +11828,7 @@ var ja = {
11670
11828
  nestedWritePathMissing: (p) => `\u30D1\u30B9 "${p}" \u306F\u72B6\u614B\u5B9A\u7FA9\u306B\u5B58\u5728\u3057\u307E\u305B\u3093\u3002\u66F8\u304D\u8FBC\u307F\u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306B\u65B0\u3057\u3044\u30AD\u30FC\u3092\u4F5C\u308B\u3060\u3051\u3067\u3001\u5BA3\u8A00\u3057\u305F\u30D1\u30B9\u306E\u675F\u7E1B\u306B\u306F\u5C4A\u304D\u307E\u305B\u3093`,
11671
11829
  readPathMissing: (p, top) => top ? `"${p}" \u306F state \u304C\u5BA3\u8A00\u3057\u3066\u3044\u306A\u3044\u30AD\u30FC\u3067\u3059\u3002\u8AAD\u3093\u3060\u6642\u70B9\u3067\u4F8B\u5916\u306B\u306A\u308A\u307E\u3059\uFF08#301\uFF09` : `\u30D1\u30B9 "${p}" \u306F\u72B6\u614B\u5B9A\u7FA9\u306B\u5B58\u5728\u3057\u307E\u305B\u3093\u3002\u8AAD\u307F\u306F undefined \u306B\u306A\u308A\u3001\u305D\u3053\u304B\u3089\u8A08\u7B97\u3057\u305F\u5024\u306F\u9ED9\u3063\u3066\u9055\u3044\u307E\u3059`,
11672
11830
  stateSrcUnread: (src) => `"${src}" \u3092\u8AAD\u3081\u306A\u3044\u306E\u3067\u3001\u3053\u306E state \u306E\u30D1\u30B9\u3082\u30B9\u30AF\u30EA\u30D7\u30C8\u306E\u898F\u5247\u3082\u691C\u67FB\u3057\u3066\u3044\u307E\u305B\u3093\u3002src \u306F\u3053\u306E\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u306E\u76F8\u5BFE\u30D1\u30B9\u3067\u8AAD\u307F\u307E\u3059\uFF08URL \u306F\u8AAD\u307E\u305A\u3001/ \u304B\u3089\u59CB\u307E\u308B\u30D1\u30B9\u306F wcs-validate --root=<\u30B5\u30A4\u30C8\u306E\u30EB\u30FC\u30C8> \u306E\u3068\u304D\u3060\u3051\u305D\u306E\u4E0B\u3067\u8AAD\u307F\u307E\u3059\uFF09\u3002\u30B5\u30FC\u30D0\u30FC\u3068\u540C\u3058\u4E26\u3073\u306B\u7F6E\u3044\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u3001\u3053\u306E\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u306E\u76F8\u5BFE\u30D1\u30B9\u3067\u6307\u3059\u304B\u3001--root \u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044`,
11831
+ stateAbsent: (tag) => `\u3053\u306E\u30D5\u30A1\u30A4\u30EB\u306B\u306F\u675F\u7E1B\u304C\u3042\u308A\u307E\u3059\u304C <${tag}> \u304C\u7121\u3044\u306E\u3067\u3001\u675F\u7E1B\u306E\u30D1\u30B9\u306F\u691C\u67FB\u3057\u3066\u3044\u307E\u305B\u3093\uFF08\u30DA\u30FC\u30B8\u304C\u53D6\u308A\u8FBC\u3080\u65AD\u7247\u3084\u3001state \u3092\u30B9\u30AF\u30EA\u30D7\u30C8\u3067\u4F5C\u308B\u30DA\u30FC\u30B8\uFF09\u3002state \u306E\u3042\u308B\u30DA\u30FC\u30B8\u3092\u691C\u67FB\u3059\u308B\u304B\u3001\u3053\u306E\u30D5\u30A1\u30A4\u30EB\u306E\u96A3\uFF08\u304B\u4E0A\uFF09\u306E wcstack.manifest.json \u306E stateSchema \u306B\u30D1\u30B9\u3092\u5BA3\u8A00\u3059\u308B\u3068\u691C\u67FB\u3055\u308C\u307E\u3059`,
11673
11832
  pathDynamicUnknownValue: (path, n, name, from) => `"${path}" \u306E\u5024${name === void 0 ? "" : from === void 0 ? `\uFF08${name}\uFF09` : `\uFF08${name}\u3002"${from}" \u304B\u3089 import\uFF09`}\u306F\u9759\u7684\u306B\u8AAD\u3081\u306A\u3044\u306E\u3067\u3001\u305D\u306E\u4E0B\u306B\u675F\u306D\u305F\u30D1\u30B9\uFF08${n} \u4EF6\uFF09\u306F\u691C\u67FB\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u30AD\u30FC\u306B JSDoc \u306E @type \u2014 \u5F62\u304B\u3001\u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u30EA\u30C6\u30E9\u30EB\u3092\u6307\u3059 typeof import("./file.js").name\uFF08\u8F9E\u66F8\u306A\u3089\u5168\u90E8\u306E\u30AD\u30FC\u3092\u6301\u3064\u65E2\u5B9A\u306E\u8A00\u8A9E\u306E\u30D5\u30A1\u30A4\u30EB\uFF09\u2014 \u3092\u4ED8\u3051\u308B\u304B\u3001wcstack.manifest.json \u306E stateSchema \u306B\u5BA3\u8A00\u3059\u308B\u3068\u691C\u67FB\u3055\u308C\u307E\u3059`,
11674
11833
  pathDynamicUnknownSpread: (sp) => `${sp} \u304C\u6301\u3061\u8FBC\u3080\u30AD\u30FC\u306F\u9759\u7684\u306B\u8AAD\u3081\u306A\u3044\u306E\u3067\u3001\u3053\u306E state \u306E\u30D1\u30B9\u306F\u691C\u67FB\u3057\u3066\u3044\u307E\u305B\u3093\uFF08\u675F\u7E1B\u30FBgetter \u306E\u4E2D\u306E\u8AAD\u307F\u30FB$watch \u306E\u30AD\u30FC\uFF09\u3002\u30AD\u30FC\u3092 wcstack.manifest.json \u306E stateSchema \u306B\u5BA3\u8A00\u3059\u308B\u3068\u691C\u67FB\u3055\u308C\u307E\u3059\u3002npx wcs-schema\uFF08@wcstack/typescript\uFF09\u304C state \u306E\u578B\uFF08JSDoc\u30FBTypeScript\uFF09\u304B\u3089\u4F5C\u308C\u307E\u3059`,
11675
11834
  pathDynamicUnknownObjectSpread: (path, n, sp, from) => `${sp}${from === void 0 ? "" : `\uFF08"${from}" \u304B\u3089 import\uFF09`}\u304C "${path}" \u306B\u6301\u3061\u8FBC\u3080\u30AD\u30FC\u306F\u9759\u7684\u306B\u8AAD\u3081\u306A\u3044\u306E\u3067\u3001\u305D\u306E\u4E0B\u306B\u675F\u306D\u305F\u30D1\u30B9\uFF08${n} \u4EF6\uFF09\u306F\u691C\u67FB\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u30EA\u30C6\u30E9\u30EB\u3092\u675F\u7E1B\u3059\u308B\u30E2\u30B8\u30E5\u30FC\u30EB\u306E const \u3092 spread \u3059\u308B\u304B\u3001\u30AD\u30FC\u306B\u5F62\u3092\u8868\u3059 JSDoc \u306E @type \u3092\u4ED8\u3051\u308B\u304B\u3001wcstack.manifest.json \u306E stateSchema \u306B\u5BA3\u8A00\u3059\u308B\u3068\u691C\u67FB\u3055\u308C\u307E\u3059`,
@@ -11686,8 +11845,9 @@ var ja = {
11686
11845
  filterMaxArgs: (n, max, c) => `\u30D5\u30A3\u30EB\u30BF "${n}" \u306E\u5F15\u6570\u306F\u6700\u5927 ${max} \u500B\u3067\u3059\uFF08${c} \u500B\u6307\u5B9A\uFF09`,
11687
11846
  filterArgType: (n, i, exp, arg, act) => `\u30D5\u30A3\u30EB\u30BF "${n}" \u306E\u7B2C${i}\u5F15\u6570\u306F ${exp} \u578B\u304C\u5FC5\u8981\u3067\u3059\uFF08"${arg}" \u306F ${act} \u578B\uFF09`,
11688
11847
  filterInputType: (n, accepts, cur) => `\u30D5\u30A3\u30EB\u30BF "${n}" \u306F ${accepts} \u578B\u306E\u5165\u529B\u304C\u5FC5\u8981\u3067\u3059\uFF08\u73FE\u5728\u306E\u578B: ${cur}\uFF09`,
11689
- wcsTextInfo: (e) => `wcs-text \u30D0\u30A4\u30F3\u30C7\u30A3\u30F3\u30B0: ${e}`,
11690
11848
  moustacheFouc: (e) => `<template> \u5916\u306E {{ }} \u69CB\u6587\u306F FOUC\uFF08\u521D\u671F\u8868\u793A\u6642\u306B\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u6587\u5B57\u5217\u304C\u898B\u3048\u308B\uFF09\u306E\u539F\u56E0\u306B\u306A\u308A\u307E\u3059\u3002<!--@@:${e}--> \u307E\u305F\u306F\u30B3\u30E1\u30F3\u30C8\u69CB\u6587\u306E\u4F7F\u7528\u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,
11849
+ moustacheFoucTextParent: (e, tag) => `<template> \u5916\u306E {{ }} \u69CB\u6587\u306F FOUC\uFF08\u521D\u671F\u8868\u793A\u6642\u306B\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u6587\u5B57\u5217\u304C\u898B\u3048\u308B\uFF09\u306E\u539F\u56E0\u306B\u306A\u308A\u307E\u3059\u3002<${tag}> \u306E\u4E2D\u306E\u30B3\u30E1\u30F3\u30C8\u69CB\u6587\u306F\u675F\u7E1B\u306B\u306A\u308A\u307E\u305B\u3093 \u2014 \u8981\u7D20\u306B\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08<${tag} data-wcs="${tag === "textarea" ? "value" : "textContent"}: ${e}">\uFF09\u3002`,
11850
+ textBindingInHead: (w) => `${w} \u306F\u6587\u66F8\u306E <head> \u306E\u4E2D\u306B\u3042\u308A\u307E\u3059\u304C\u3001<wcs-state> \u304C\u675F\u306D\u308B\u306E\u306F <body> \u3068\u30B7\u30E3\u30C9\u30A6\u30EB\u30FC\u30C8\u3060\u3051\u306A\u306E\u3067\u3001\u66F8\u3044\u305F\u307E\u307E\u306E\u6587\u5B57\u304C\u51FA\u307E\u3059\u3002\u30BF\u30A4\u30C8\u30EB\u306F state \u306E\u30B9\u30AF\u30EA\u30D7\u30C8\u304B\u3089 document.title \u306B\u66F8\u304F\uFF08$connectedCallback \u3068 $watch \u306E\u30CF\u30F3\u30C9\u30E9\uFF09\u304B\u3001\u30EB\u30FC\u30C8\u306E <wcs-head> \u306E <title> \u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044`,
11691
11851
  nestedAssign: (sp) => `\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3\u3078\u306E\u4EE3\u5165\u306F\u30EA\u30A2\u30AF\u30C6\u30A3\u30D6\u66F4\u65B0\u3092\u30C8\u30EA\u30AC\u30FC\u3057\u307E\u305B\u3093\u3002this["${sp}"] \u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,
11692
11852
  watchNotObject: () => `$watch \u306F\u300C\u30D1\u30B9 \u2192 \u30CF\u30F3\u30C9\u30E9\u95A2\u6570\u300D\u306E\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\uFF08\u3053\u306E\u5F62\u306F\u30E9\u30F3\u30BF\u30A4\u30E0\u304C\u8AAD\u307F\u8FBC\u307F\u6642\u306B throw \u3057\u307E\u3059\uFF09`,
11693
11853
  watchKeyCrossState: (k) => `$watch \u306E\u30AD\u30FC "${k}" \u306F\u4ED6\u306E state \u3092\u6307\u3057\u3066\u3044\u307E\u3059\u3002@ \u4ED8\u304D\u306E\u8D8A\u5883 watch \u306F\u4F7F\u3048\u307E\u305B\u3093\uFF08\u81EA state \u306E\u30D1\u30B9\u306E\u307F\uFF09`,
@@ -11742,6 +11902,7 @@ var ja = {
11742
11902
  signalsDualEntry: () => `@wcstack/signals \u3068 @wcstack/signals/dom \u304C\u540C\u4E00\u30DA\u30FC\u30B8\u304B\u3089 import \u3055\u308C\u3066\u3044\u307E\u3059\u3002CDN \u3067\u306F\u5404\u30A8\u30F3\u30C8\u30EA\u304C\u81EA\u5DF1\u5B8C\u7D50\u30D0\u30F3\u30C9\u30EB\u306E\u305F\u3081\u30EA\u30A2\u30AF\u30C6\u30A3\u30D6\u30B3\u30A2\u304C\u4E8C\u91CD\u5316\u3057\u3001\u5883\u754C\u3067\u53CD\u5FDC\u304C\u58CA\u308C\u307E\u3059 \u2014 \u3059\u3079\u3066 /dom \u30A8\u30F3\u30C8\u30EA\u304B\u3089 import \u3057\u3066\u304F\u3060\u3055\u3044`,
11743
11903
  signalsImportMapBoth: () => `\u3053\u306E import map \u306F @wcstack/signals \u3068 @wcstack/signals/dom \u306E\u4E21\u65B9\u3092\u5272\u308A\u5F53\u3066\u3066\u3044\u307E\u3059\u3002CDN \u3067\u306F\u5404\u30A8\u30F3\u30C8\u30EA\u304C\u30EA\u30A2\u30AF\u30C6\u30A3\u30D6\u30B3\u30A2\u3092\u6301\u3064\u306E\u3067\u3001@wcstack/signals \u3092 import \u3059\u308B\u30E2\u30B8\u30E5\u30FC\u30EB\uFF08\u3053\u306E\u30DA\u30FC\u30B8\u306E\u3082\u306E\u3067\u3082\u3001\u8AAD\u307F\u8FBC\u3080 .js \u3067\u3082\uFF09\u304C 2 \u3064\u76EE\u306E\u30B3\u30A2\u3092\u6301\u3061\u3001\u5883\u754C\u3067\u53CD\u5FDC\u304C\u58CA\u308C\u307E\u3059\u3002@wcstack/signals/dom \u3060\u3051\u3092\u5272\u308A\u5F53\u3066\u3066\u304F\u3060\u3055\u3044\uFF08\u30B3\u30A2\u306E\u5168\u90E8\u3092 export \u3057\u307E\u3059\uFF09`,
11744
11904
  tagPackageMissing: (tags, pkg, url) => `${tags.map((t) => `<${t}>`).join("\u30FB")} \u306F ${pkg} \u306E\u30BF\u30B0\u3067\u3059\u304C\u3001\u3053\u306E\u30DA\u30FC\u30B8\u306F ${pkg} \u306E\u30B9\u30AF\u30EA\u30D7\u30C8\u3092\u8AAD\u307F\u8FBC\u3093\u3067\u3044\u307E\u305B\u3093\u3002\u8981\u7D20\u306F\u5B9A\u7FA9\u3055\u308C\u306A\u3044\u306E\u3067\u3001\u305D\u306E\u675F\u7E1B\u306F\u5F85\u3061\u7D9A\u3051\u3066\u4F55\u3082\u8D77\u304D\u305A\u3001\u30B3\u30F3\u30BD\u30FC\u30EB\u306B\u3082\u4F55\u3082\u51FA\u307E\u305B\u3093 \u2014 <script type="module" src="${url}"></script> \u3067\u8AAD\u307F\u8FBC\u3093\u3067\u304F\u3060\u3055\u3044`,
11905
+ linkRouterMissing: (to, n) => `\u3053\u306E\u30DA\u30FC\u30B8\u306B\u306F <wcs-router> \u304C\u7121\u3044\u306E\u3067\u3001\u3053\u306E <wcs-link to="${to}">${n > 1 ? `\uFF08\u3068\u30DA\u30FC\u30B8\u306E\u307B\u304B\u306E ${n - 1} \u500B\uFF09` : ""}\u306F\u63A5\u7D9A\u3057\u305F\u6642\u70B9\u3067 "[@wcstack/router] wcs-link is not connected to a router." \u3092\u6295\u3052\u3001\u30EA\u30F3\u30AF\u306F\u96A0\u308C\u307E\u3059\uFF08display: none\uFF09\u3002router \u306E\u7121\u3044\u30DA\u30FC\u30B8\u3067\u306F <a href="${to}"> \u3068\u66F8\u304F\u304B\u3001<wcs-router> \u3092\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044`,
11745
11906
  lintVersionBehind: (spec, version3, minor, lint) => `\u3053\u306E\u30DA\u30FC\u30B8\u306F ${spec} \u3092\u56FA\u5B9A\u3057\u3066\u3044\u307E\u3059\u304C\u3001\u3053\u306E lint \u306E\u898F\u5247\uFF08@wcstack ${lint}\uFF09\u3088\u308A\u65B0\u3057\u3044 minor \u3067\u3059\u3002${minor} \u3067\u52A0\u308F\u3063\u305F\u898F\u5247\u306F\u691C\u67FB\u3055\u308C\u305A\u3001${minor} \u306E\u6B63\u3057\u3044\u66F8\u304D\u65B9\u304C error \u306B\u306A\u308B\u3053\u3068\u3082\u3042\u308A\u307E\u3059 \u2014 @wcstack/lint \u3092 ${version3} \u306B\u4E0A\u3052\u3066\u304F\u3060\u3055\u3044\uFF08npm i -D @wcstack/lint@${version3}\u3002VS Code \u306E\u62E1\u5F35\u306F ${minor} \u306B\u5BFE\u5FDC\u3059\u308B\u7248\u3078\uFF09`,
11746
11907
  routeBareMustache: (inLayout) => inLayout ? `\u30EC\u30A4\u30A2\u30A6\u30C8\u306E\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306E\u76F4\u4E0B\u306E\u30C6\u30AD\u30B9\u30C8\u306E {{ }} \u306F\u3001\u9077\u79FB\u3067\u306F\u675F\u306D\u3089\u308C\u307E\u305B\u3093 \u2014 \u8981\u7D20\u3067\u5305\u3093\u3067\u304F\u3060\u3055\u3044\uFF08<span>{{ \u2026 }}</span>\uFF09` : `<wcs-route> \u306E\u76F4\u4E0B\u306E\u30C6\u30AD\u30B9\u30C8\u306E {{ }} \u306F\u3001\u6700\u521D\u306B\u7740\u3044\u305F\u30EB\u30FC\u30C8\u3067\u3057\u304B\u675F\u306D\u3089\u308C\u307E\u305B\u3093\u3002\u9077\u79FB\u3067\u5165\u3063\u305F\u30EB\u30FC\u30C8\u3067\u306F\u66F8\u3044\u305F\u307E\u307E\u306E\u6587\u5B57\u304C\u51FA\u307E\u3059 \u2014 \u8981\u7D20\u3067\u5305\u3093\u3067\u304F\u3060\u3055\u3044\uFF08<h1>{{ \u2026 }}</h1>\uFF09`,
11747
11908
  layoutSlotMissing: (l) => `\u30EC\u30A4\u30A2\u30A6\u30C8 "${l}" \u306E\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306B\u65E2\u5B9A\u306E <slot>\uFF08name \u306E\u7121\u3044\u3082\u306E\uFF09\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u3053\u306E <wcs-layout> \u306E\u540D\u524D\u4ED8\u304D\u30B9\u30ED\u30C3\u30C8\u306E\u5916\u306E\u4E2D\u8EAB\uFF08\u5165\u308C\u5B50\u306E\u30EB\u30FC\u30C8\u3068\u305D\u306E\u30DA\u30FC\u30B8\uFF09\u306F\u8868\u793A\u3055\u308C\u307E\u305B\u3093 \u2014 \u30DA\u30FC\u30B8\u3092\u7F6E\u304F\u5834\u6240\u306B <slot></slot> \u3092\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`,
@@ -11895,6 +12056,7 @@ var en = {
11895
12056
  nestedWritePathMissing: (p) => `Path "${p}" does not exist in the state definition. The write creates a new key in the object and reaches no binding of a declared path`,
11896
12057
  readPathMissing: (p, top) => top ? `"${p}" is not a key the state declares. Reading it throws (#301)` : `Path "${p}" does not exist in the state definition. The read gives undefined, and what is computed from it is wrong without a word`,
11897
12058
  stateSrcUnread: (src) => `"${src}" cannot be read, so this state's paths and script rules are not checked. A src is read relative to this file (a URL is not read, and a path from / only under wcs-validate --root=<the site's root>): point it at the file laid out as on the server, relative to this file, or pass --root`,
12059
+ stateAbsent: (tag) => `This file has bindings but no <${tag}>, so the paths they bind are not checked (a fragment a page includes, or a page whose state is made by script). Check the page that holds the state, or declare the paths in the stateSchema of a wcstack.manifest.json next to (or above) this file to have them checked`,
11898
12060
  pathDynamicUnknownValue: (path, n, name, from) => `The value of "${path}"${name === void 0 ? "" : from === void 0 ? ` (${name})` : ` (${name}, imported from "${from}")`} cannot be read statically, so the ${n === 1 ? "path" : `${n} paths`} bound under it ${n === 1 ? "is" : "are"} not checked. Give the key a JSDoc @type \u2014 its shape, or typeof import("./file.js").name for a module's literal (for a dictionary, the default language's file, which has every key) \u2014 or declare it in the stateSchema of wcstack.manifest.json to have them checked`,
11899
12061
  pathDynamicUnknownSpread: (sp) => `The keys ${sp} brings in cannot be read statically, so this state's paths are not checked (bindings, reads in getters, $watch keys). Declare the keys in the stateSchema of wcstack.manifest.json to have them checked; npx wcs-schema (@wcstack/typescript) derives it from the state's types (JSDoc or TypeScript)`,
11900
12062
  pathDynamicUnknownObjectSpread: (path, n, sp, from) => `The keys ${sp}${from === void 0 ? "" : ` (imported from "${from}")`} brings into "${path}" cannot be read statically, so the ${n === 1 ? "path" : `${n} paths`} bound under it ${n === 1 ? "is" : "are"} not checked. Spread a const of the module bound to an object literal, give the key a JSDoc @type with its shape, or declare it in the stateSchema of wcstack.manifest.json to have them checked`,
@@ -11911,8 +12073,9 @@ var en = {
11911
12073
  filterMaxArgs: (n, max, c) => `Filter "${n}" accepts at most ${max} argument(s) (${c} given)`,
11912
12074
  filterArgType: (n, i, exp, arg, act) => `Argument ${i} of filter "${n}" must be of type ${exp} ("${arg}" is ${act})`,
11913
12075
  filterInputType: (n, accepts, cur) => `Filter "${n}" requires input of type ${accepts} (current type: ${cur})`,
11914
- wcsTextInfo: (e) => `wcs-text binding: ${e}`,
11915
12076
  moustacheFouc: (e) => `{{ }} outside a <template> causes FOUC (the raw template string is visible before binding). Consider the comment syntax <!--@@:${e}--> instead.`,
12077
+ moustacheFoucTextParent: (e, tag) => `{{ }} outside a <template> causes FOUC (the raw template string is visible before binding). A comment binding is not bound inside <${tag}>: bind the element instead (<${tag} data-wcs="${tag === "textarea" ? "value" : "textContent"}: ${e}">).`,
12078
+ textBindingInHead: (w) => `${w} is in the document's <head>, and a <wcs-state> binds only the <body> and shadow roots, so it stays as written. Write document.title from the state's script ($connectedCallback and a $watch handler), or put the <title> in a route's <wcs-head>`,
11916
12079
  nestedAssign: (sp) => `Assigning to a nested property does not trigger a reactive update. Use this["${sp}"] instead.`,
11917
12080
  watchNotObject: () => `$watch must be an object mapping state paths to handler functions (the runtime throws on this shape at load time)`,
11918
12081
  watchKeyCrossState: (k) => `$watch key "${k}" targets another state. Cross-state watching with @ is not supported (own paths only)`,
@@ -11967,6 +12130,7 @@ var en = {
11967
12130
  signalsDualEntry: () => `Both @wcstack/signals and @wcstack/signals/dom are imported on this page. On a CDN each entry is a self-contained bundle, so the reactive core is duplicated and reactivity breaks at the seam \u2014 import everything from the single /dom entry`,
11968
12131
  signalsImportMapBoth: () => `This import map maps both @wcstack/signals and @wcstack/signals/dom. On a CDN each entry carries its own reactive core, so a module that imports @wcstack/signals \u2014 this page's, or a .js file it loads \u2014 gets a second core and reactivity breaks at the seam. Map only @wcstack/signals/dom (it exports the whole core)`,
11969
12132
  tagPackageMissing: (tags, pkg, url) => `${tags.map((t) => `<${t}>`).join(", ")} ${tags.length === 1 ? "is a tag" : "are tags"} of ${pkg}, and this page loads no script of ${pkg}: the element is never defined, so its bindings wait and nothing happens, without a word in the console. Load it with <script type="module" src="${url}"></script>`,
12133
+ linkRouterMissing: (to, n) => `This page has no <wcs-router>, so this <wcs-link to="${to}">${n > 1 ? ` (and the ${n - 1} other${n > 2 ? "s" : ""} on the page)` : ""} throws "[@wcstack/router] wcs-link is not connected to a router." when it connects, and the link is hidden (display: none). On a page without the router write <a href="${to}">, or add the <wcs-router>`,
11970
12134
  lintVersionBehind: (spec, version3, minor, lint) => `This page pins ${spec}, a newer minor than the rules of this lint (@wcstack ${lint}): what ${minor} added is not checked, and correct ${minor} syntax can be reported as an error. Upgrade @wcstack/lint to ${version3} (npm i -D @wcstack/lint@${version3}; the VS Code extension to its release for ${minor})`,
11971
12135
  routeBareMustache: (inLayout) => inLayout ? `{{ }} in text directly under a layout template is not bound on a navigation. Wrap it in an element (<span>{{ \u2026 }}</span>)` : `{{ }} in text directly under <wcs-route> is bound only on the landing route: a route entered by navigation shows it as written. Wrap it in an element (<h1>{{ \u2026 }}</h1>)`,
11972
12136
  layoutSlotMissing: (l) => `The template of layout "${l}" has no default <slot> (one without a name), so what this <wcs-layout> holds outside the named slots \u2014 the nested routes and their pages \u2014 is not shown. Put a <slot></slot> where the page goes`,
@@ -13332,21 +13496,24 @@ var COMMENT_BINDING = /<!--\s*@@\s*(?:wcs-text)?\s*:\s*((?:(?!-->)[\s\S])+?)\s*-
13332
13496
  var RAW_TEXT_TAGS = ["script", "style"];
13333
13497
  var TEXT_ONLY_COMMENT_PARENTS = ["textarea", "title"];
13334
13498
  function findAllMustacheSyntax(html) {
13335
- return collect(html, MUSTACHE, "mustache", RAW_TEXT_TAGS);
13499
+ return collect(html, maskMarkup(html), MUSTACHE, "mustache", RAW_TEXT_TAGS);
13336
13500
  }
13337
13501
  function findAllCommentBindings(html) {
13338
- return collect(html, COMMENT_BINDING, "comment", [...RAW_TEXT_TAGS, ...TEXT_ONLY_COMMENT_PARENTS]);
13502
+ return collect(html, html, COMMENT_BINDING, "comment", [...RAW_TEXT_TAGS, ...TEXT_ONLY_COMMENT_PARENTS]);
13339
13503
  }
13340
- function collect(html, regex, kind, skipInside) {
13504
+ function collect(html, scan, regex, kind, skipInside) {
13341
13505
  const results = [];
13342
13506
  const skip = rangeTester(html, skipInside);
13343
13507
  const inTemplate = templateTester(html);
13508
+ const inHead = documentHeadTester(html);
13509
+ const textParent = kind === "mustache" ? rangeTester(html, TEXT_ONLY_COMMENT_PARENTS) : null;
13344
13510
  regex.lastIndex = 0;
13345
13511
  let match;
13346
- while ((match = regex.exec(html)) !== null) {
13347
- if (skip(match.index)) continue;
13512
+ while ((match = regex.exec(scan)) !== null) {
13513
+ if (skip(match.index) !== null) continue;
13348
13514
  const expr = match[1];
13349
13515
  const exprStart = match.indices[1][0];
13516
+ const parent = textParent?.(match.index) ?? null;
13350
13517
  results.push({
13351
13518
  kind,
13352
13519
  expression: expr,
@@ -13354,11 +13521,84 @@ function collect(html, regex, kind, skipInside) {
13354
13521
  exprEnd: exprStart + expr.length,
13355
13522
  matchStart: match.index,
13356
13523
  matchEnd: match.index + match[0].length,
13357
- insideTemplate: inTemplate(match.index)
13524
+ insideTemplate: inTemplate(match.index),
13525
+ inDocumentHead: inHead(match.index),
13526
+ ...parent !== null ? { textParent: parent } : {}
13358
13527
  });
13359
13528
  }
13360
13529
  return results;
13361
13530
  }
13531
+ function maskMarkup(html) {
13532
+ if (!html.includes("{{")) return html;
13533
+ const lower2 = asciiLowerCase(html);
13534
+ const chunks = [];
13535
+ let last = 0;
13536
+ const mask = (from, to) => {
13537
+ if (to <= from) return;
13538
+ chunks.push(html.slice(last, from), "<", "x".repeat(to - from - 1));
13539
+ last = to;
13540
+ };
13541
+ let i = 0;
13542
+ while (i < html.length) {
13543
+ const lt2 = html.indexOf("<", i);
13544
+ if (lt2 === -1) break;
13545
+ if (html.startsWith("<!--", lt2)) {
13546
+ const close = html.indexOf("-->", lt2 + 4);
13547
+ i = close === -1 ? html.length : close + 3;
13548
+ mask(lt2, i);
13549
+ continue;
13550
+ }
13551
+ const next = html[lt2 + 1];
13552
+ if (next === "!" || next === "?" || next === "/") {
13553
+ const close = html.indexOf(">", lt2 + 1);
13554
+ i = close === -1 ? html.length : close + 1;
13555
+ mask(lt2, i);
13556
+ continue;
13557
+ }
13558
+ if (next === void 0 || !/[A-Za-z]/.test(next)) {
13559
+ i = lt2 + 1;
13560
+ continue;
13561
+ }
13562
+ let n = lt2 + 1;
13563
+ while (n < html.length && /[^\s/>]/.test(html[n])) n++;
13564
+ const tagName = lower2.slice(lt2 + 1, n);
13565
+ let j = n;
13566
+ let quote = null;
13567
+ while (j < html.length) {
13568
+ const c = html[j];
13569
+ if (quote !== null) {
13570
+ if (c === quote) quote = null;
13571
+ } else if (c === '"' || c === "'") {
13572
+ quote = c;
13573
+ } else if (c === ">") {
13574
+ break;
13575
+ }
13576
+ j++;
13577
+ }
13578
+ i = j < html.length ? j + 1 : html.length;
13579
+ mask(lt2, i);
13580
+ const raw = RAW_TEXT_TAGS.includes(tagName);
13581
+ if (raw || TEXT_ONLY_COMMENT_PARENTS.includes(tagName)) {
13582
+ const close = lower2.indexOf(`</${tagName}`, i);
13583
+ const contentEnd = close === -1 ? html.length : close;
13584
+ if (raw) mask(i, contentEnd);
13585
+ i = contentEnd;
13586
+ }
13587
+ }
13588
+ chunks.push(html.slice(last));
13589
+ return chunks.join("");
13590
+ }
13591
+ function documentHeadTester(html) {
13592
+ if (!/<head[\s>]/i.test(html)) return () => false;
13593
+ const regions = findStartTagRegions(html);
13594
+ const head = regions.find((r) => r.tagName === "head");
13595
+ if (head === void 0) return () => false;
13596
+ const close = asciiLowerCase(html).indexOf("</head", head.end);
13597
+ const body = regions.find((r) => r.tagName === "body" && r.start > head.end);
13598
+ const ends = [close, body === void 0 ? -1 : body.start].filter((at2) => at2 !== -1);
13599
+ const end = ends.length === 0 ? html.length : Math.min(...ends);
13600
+ return (offset2) => offset2 > head.end && offset2 < end;
13601
+ }
13362
13602
  function rangeTester(html, tags) {
13363
13603
  const ranges = [];
13364
13604
  const lower2 = asciiLowerCase(html);
@@ -13366,15 +13606,16 @@ function rangeTester(html, tags) {
13366
13606
  let match;
13367
13607
  while ((match = open.exec(html)) !== null) {
13368
13608
  const start = match.index + match[0].length;
13369
- const close = lower2.indexOf(`</${match[1].toLowerCase()}`, start);
13609
+ const tag = match[1].toLowerCase();
13610
+ const close = lower2.indexOf(`</${tag}`, start);
13370
13611
  const end = close === -1 ? html.length : close;
13371
- ranges.push({ start, end });
13612
+ ranges.push({ start, end, tag });
13372
13613
  open.lastIndex = end;
13373
13614
  }
13374
13615
  let i = 0;
13375
13616
  return (offset2) => {
13376
13617
  while (i < ranges.length && ranges[i].end <= offset2) i++;
13377
- return i < ranges.length && ranges[i].start <= offset2;
13618
+ return i < ranges.length && ranges[i].start <= offset2 ? ranges[i].tag : null;
13378
13619
  };
13379
13620
  }
13380
13621
  function templateTester(html) {
@@ -13424,21 +13665,22 @@ function validateTemplateSyntax(html, stateTagName, bindAttrName = "data-wcs", l
13424
13665
  const mustaches = findAllMustacheSyntax(html);
13425
13666
  const comments = findAllCommentBindings(html);
13426
13667
  for (const item of [...mustaches, ...comments]) {
13427
- if (item.kind === "comment") {
13668
+ if (item.inDocumentHead && !item.insideTemplate) {
13428
13669
  diagnostics.push({
13429
13670
  code: WcsDiagnosticCode.TemplateSyntax,
13430
13671
  start: item.matchStart,
13431
13672
  end: item.matchEnd,
13432
- message: msgs.wcsTextInfo(item.expression),
13433
- severity: "info"
13673
+ message: msgs.textBindingInHead(item.kind === "mustache" ? `{{ ${item.expression} }}` : `<!--@@: ${item.expression}-->`),
13674
+ severity: "warning"
13434
13675
  });
13676
+ continue;
13435
13677
  }
13436
13678
  if (item.kind === "mustache" && !item.insideTemplate) {
13437
13679
  diagnostics.push({
13438
13680
  code: WcsDiagnosticCode.TemplateSyntax,
13439
13681
  start: item.matchStart,
13440
13682
  end: item.matchEnd,
13441
- message: msgs.moustacheFouc(item.expression),
13683
+ message: item.textParent !== void 0 ? msgs.moustacheFoucTextParent(item.expression, item.textParent) : msgs.moustacheFouc(item.expression),
13442
13684
  severity: "info"
13443
13685
  });
13444
13686
  }
@@ -13692,6 +13934,7 @@ function validateBindingSyntax(html, bindAttrName = "data-wcs", locale2) {
13692
13934
  }
13693
13935
  }
13694
13936
  for (const item of [...findAllMustacheSyntax(html), ...findAllCommentBindings(html)]) {
13937
+ if (item.inDocumentHead && !item.insideTemplate) continue;
13695
13938
  const detail = bindingSyntaxDetail(parseEmbeddedTextWithPositions(item.expression).error);
13696
13939
  if (detail === null) continue;
13697
13940
  diagnostics.push({
@@ -16111,6 +16354,31 @@ function validatePackageLoads(html, locale2, fileReader) {
16111
16354
  message: msgs.tagPackageMissing(at2.tags, `@wcstack/${pkg}`, `https://esm.run/@wcstack/${pkg}${version3 === null ? "" : `@${version3}`}/auto`)
16112
16355
  });
16113
16356
  }
16357
+ const linkDefined = loads.pkgs.has("router") || defined.has("router") || autoloader && components.some((k) => coversTag(k, "wcs-link"));
16358
+ if (linkDefined) {
16359
+ const links = findLinksWithoutRouter(scan);
16360
+ if (links.length > 0) {
16361
+ out.push({
16362
+ code: WcsDiagnosticCode.LinkRouterMissing,
16363
+ start: links[0].start,
16364
+ end: links[0].end,
16365
+ severity: "warning",
16366
+ tag: "wcs-link",
16367
+ message: msgs.linkRouterMissing(links[0].to, links.length)
16368
+ });
16369
+ }
16370
+ }
16371
+ return out;
16372
+ }
16373
+ function findLinksWithoutRouter(scan) {
16374
+ if (/\bwcs-router\b/i.test(scan)) return [];
16375
+ const out = [];
16376
+ for (const region of findStartTagRegions(scan)) {
16377
+ if (region.tagName !== "wcs-link") continue;
16378
+ const to = extractAttribute(scan.slice(region.start, region.end), "to");
16379
+ if (to === null || !to.startsWith("/")) continue;
16380
+ out.push({ to, start: region.start - "wcs-link".length, end: region.start });
16381
+ }
16114
16382
  return out;
16115
16383
  }
16116
16384
  function comparePins(a, b) {
@@ -17220,6 +17488,7 @@ function validateNamedState(html, attrName, stateTagName = "wcs-state", locale2)
17220
17488
  }
17221
17489
  }
17222
17490
  for (const item of [...findAllMustacheSyntax(html), ...findAllCommentBindings(html)]) {
17491
+ if (item.inDocumentHead && !item.insideTemplate) continue;
17223
17492
  const selector = findStateSelector(item.expression, true);
17224
17493
  if (selector !== null) {
17225
17494
  diagnostics.push({
@@ -18576,6 +18845,71 @@ function validateStateSources(html, stateTagName = "wcs-state", locale2, fileRea
18576
18845
  }
18577
18846
  return out;
18578
18847
  }
18848
+ function validateStateAbsent(html, bindAttribute = "data-wcs", stateTagName = "wcs-state", locale2, applicationSchema) {
18849
+ if (applicationSchema !== void 0) return [];
18850
+ if (!html.includes(bindAttribute) && !html.includes("@@")) return [];
18851
+ if (parseWcsStateElements(html, stateTagName).length > 0) return [];
18852
+ const ignored = findIgnoredRanges(html, bindAttribute);
18853
+ const bindings = [
18854
+ ...findAllBindAttributes(html, bindAttribute).filter((attr) => attr.value.trim() !== "").map((attr) => ({ start: attr.valueStart, end: attr.valueStart + attr.value.length })),
18855
+ ...findAllCommentBindings(html).map((m) => ({ start: m.exprStart, end: m.exprEnd }))
18856
+ ].filter((b) => !ignored.some(([start, end]) => b.start >= start && b.start < end));
18857
+ if (bindings.length === 0) return [];
18858
+ const first = bindings.reduce((a, b) => b.start < a.start ? b : a);
18859
+ return [{
18860
+ code: WcsDiagnosticCode.StateAbsent,
18861
+ start: first.start,
18862
+ end: first.end,
18863
+ message: getMessages(locale2).stateAbsent(stateTagName),
18864
+ severity: "info"
18865
+ }];
18866
+ }
18867
+
18868
+ // src/service/stateBehavior.ts
18869
+ var BEHAVIOR_KEY2 = "$behavior";
18870
+ var MUSTACHE_KEY = "enableMustache";
18871
+ function isMustacheDisabled(html, stateTagName = "wcs-state", fileReader) {
18872
+ if (!html.includes(MUSTACHE_KEY) && (fileReader === void 0 || !html.includes("src"))) return false;
18873
+ const elements = parseWcsStateElements(html, stateTagName);
18874
+ if (elements.length === 0) return false;
18875
+ const insideTemplate = createTemplateTester(html);
18876
+ const root = elements.find((e) => e.mountPath === null && !e.bindComponent && !insideTemplate(e.tagStart));
18877
+ if (root === void 0) return false;
18878
+ if (root.stateAttr !== void 0) {
18879
+ const json = findScriptJsonById(html, root.stateAttr);
18880
+ return json !== null && jsonDisablesMustache(json);
18881
+ }
18882
+ if (root.srcAttr !== void 0) {
18883
+ if (fileReader === void 0) return false;
18884
+ if (root.srcAttr.endsWith(".json")) {
18885
+ const json = fileReader(root.srcAttr);
18886
+ return json !== void 0 && jsonDisablesMustache(json);
18887
+ }
18888
+ const script = readStateScript(root.srcAttr, fileReader);
18889
+ return script !== void 0 && scriptDisablesMustache(script);
18890
+ }
18891
+ if (root.jsonAttr !== void 0) return jsonDisablesMustache(root.jsonAttr);
18892
+ const block = root.scriptBlocks[0];
18893
+ return block !== void 0 && scriptDisablesMustache(block.content);
18894
+ }
18895
+ function jsonDisablesMustache(text3) {
18896
+ try {
18897
+ const data2 = JSON.parse(text3);
18898
+ const behavior = data2?.[BEHAVIOR_KEY2];
18899
+ return typeof behavior === "object" && behavior !== null && behavior[MUSTACHE_KEY] === false;
18900
+ } catch {
18901
+ return false;
18902
+ }
18903
+ }
18904
+ function scriptDisablesMustache(script) {
18905
+ if (!script.includes(MUSTACHE_KEY)) return false;
18906
+ const decl = findTopLevelDeclaration(script, BEHAVIOR_KEY2);
18907
+ if (decl === null || decl.kind !== "data") return false;
18908
+ return analyzeDeclarationEntries(script, BEHAVIOR_KEY2).some((entry) => entry.name === MUSTACHE_KEY && entry.kind === "data" && entry.value !== void 0 && stripComments(entry.value) === "false");
18909
+ }
18910
+ function stripComments(value) {
18911
+ return value.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g, "").trim();
18912
+ }
18579
18913
 
18580
18914
  // src/core/sidecar/jsonSource.ts
18581
18915
  var JsonReader = class {
@@ -19026,7 +19360,11 @@ function validateDocument(text3, options = {}) {
19026
19360
  const stateTagName = options.stateTagName ?? "wcs-state";
19027
19361
  const fileReader = options.fileReader;
19028
19362
  const applicationSchema = options.applicationSchema ?? (fileReader !== void 0 ? discoverApplicationManifest(fileReader)?.schema : void 0);
19029
- const found = [...validateText(text3, options, applicationSchema), ...validateStateSources(text3, stateTagName, options.locale, fileReader)];
19363
+ const found = [
19364
+ ...validateText(text3, options, applicationSchema),
19365
+ ...validateStateSources(text3, stateTagName, options.locale, fileReader),
19366
+ ...validateStateAbsent(text3, options.bindAttribute ?? "data-wcs", stateTagName, options.locale, applicationSchema)
19367
+ ];
19030
19368
  const page = fileReader === void 0 ? null : inlineExternalStates(text3, stateTagName, fileReader);
19031
19369
  if (page === null) return sortDiagnostics(found);
19032
19370
  const key = (d) => [d.code, d.start, d.end, d.message, d.origin?.path, d.origin?.start].join("\0");
@@ -19093,7 +19431,10 @@ function validateText(text3, options, applicationSchema) {
19093
19431
  for (const d of validateNestedAssigns(text3, stateTagName, locale2)) {
19094
19432
  out.push({ code: WcsDiagnosticCode.NestedAssign, start: d.start, end: d.end, message: d.message, severity: d.severity });
19095
19433
  }
19096
- const ignored = findIgnoredRanges(text3, bindAttribute);
19434
+ const ignored = [
19435
+ ...findIgnoredRanges(text3, bindAttribute),
19436
+ ...text3.includes("{{") && isMustacheDisabled(text3, stateTagName, fileReader) ? findAllMustacheSyntax(text3).map((m) => [m.matchStart, m.matchEnd]) : []
19437
+ ];
19097
19438
  const kept = ignored.length === 0 ? out : out.filter((d) => !ignored.some(([start, end]) => d.start >= start && d.start < end));
19098
19439
  return sortDiagnostics(kept);
19099
19440
  }
@@ -19364,13 +19705,54 @@ function resolveCliLocale(explicit, env = process.env) {
19364
19705
  return "en";
19365
19706
  }
19366
19707
  }
19708
+ var nodeGlobFs = {
19709
+ readDir(path) {
19710
+ try {
19711
+ return (0, import_node_fs2.readdirSync)(path, { withFileTypes: true }).map((entry) => ({ name: entry.name, dir: entry.isDirectory() }));
19712
+ } catch {
19713
+ return void 0;
19714
+ }
19715
+ }
19716
+ };
19717
+ function isFile(path) {
19718
+ try {
19719
+ return (0, import_node_fs2.statSync)(path).isFile();
19720
+ } catch {
19721
+ return false;
19722
+ }
19723
+ }
19724
+ function expandFileArgs(args, fs = nodeGlobFs, exists = isFile, windows = process.platform === "win32") {
19725
+ const files = [];
19726
+ const seen2 = /* @__PURE__ */ new Set();
19727
+ const add = (path) => {
19728
+ if (seen2.has(path)) return;
19729
+ seen2.add(path);
19730
+ files.push(path);
19731
+ };
19732
+ for (const arg of args) {
19733
+ if (!hasGlobMagic(arg) || exists(arg)) {
19734
+ add(arg);
19735
+ continue;
19736
+ }
19737
+ const matches = expandGlob(windows ? arg.replace(/\\/g, "/") : arg, fs);
19738
+ if (matches.length === 0) return { files, unmatched: arg };
19739
+ for (const match of matches) add(match);
19740
+ }
19741
+ return { files };
19742
+ }
19367
19743
  function main(argv) {
19368
- const { options, files, root } = parseArgs(argv);
19744
+ const { options, files: args, root } = parseArgs(argv);
19369
19745
  const locale2 = resolveCliLocale(options.locale);
19370
- if (files.length === 0) {
19746
+ if (args.length === 0) {
19371
19747
  process.stderr.write("usage: wcs-validate [--attr=data-wcs] [--state-tag=wcs-state] [--lang=ja|en] [--root=<dir>] [--errors-only] [--strict] <file> [<file> ...]\n");
19372
19748
  return 2;
19373
19749
  }
19750
+ const { files, unmatched } = expandFileArgs(args);
19751
+ if (unmatched !== void 0) {
19752
+ process.stderr.write(`no file matches ${unmatched}
19753
+ `);
19754
+ return 2;
19755
+ }
19374
19756
  const inputs = [];
19375
19757
  for (const path of files) {
19376
19758
  let text3;
@@ -19408,6 +19790,7 @@ if (typeof require !== "undefined" && typeof module !== "undefined" && require.m
19408
19790
  // Annotate the CommonJS export names for ESM import in node:
19409
19791
  0 && (module.exports = {
19410
19792
  createFileReader,
19793
+ expandFileArgs,
19411
19794
  main,
19412
19795
  parseArgs,
19413
19796
  resolveCliLocale
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/lint",
3
- "version": "4.18.0",
3
+ "version": "4.20.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": {