@wcstack/lint 4.30.0 → 4.32.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
@@ -94,9 +94,9 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
94
94
  }
95
95
  ```
96
96
 
97
- - **発見**: HTML ファイルから上へ辿って最も近い `wcstack.manifest.json` が自動で使われます — コマンドラインに渡す必要はありません。`application` artifact を含む `*.manifest.json` を引数に渡した場合は、その実行全体で発見を置き換えます。VS Code 拡張も同じファイルを発見するので IDE と CLI の結果は一致します。
97
+ - **発見**: HTML ファイルから上へ辿って最も近い `wcstack.manifest.json` が自動で使われます — コマンドラインに渡す必要はありません。`application` artifact を含む `*.manifest.json` を引数に渡した場合は、その実行全体で発見を置き換えます。そのうち 2 つが両方 `stateSchema` を宣言すると `wcs/manifest-state-collision`(error)で、どちらも使われません —— ただし 4.32 から、それぞれが違う state のファイル(`stateSource`、下)を名指すときは衝突せず、各ページには、ルートの `<wcs-state src>` が読むファイルの schema が当たります。生成した schema を持つアプリ 2 つを 1 回の実行で検査できます。VS Code 拡張も同じファイルを発見するので IDE と CLI の結果は一致します。
98
98
  - **schema を当てるページ**(4.26 から): schema を作った state のファイルを記した manifest — `wcstack.application.stateSource`、manifest からの相対で、`wcs-schema emit` が書きます — は、そのファイルを root の `<wcs-state src>` で読むページだけの契約です(同じパスの `.js` と `.ts`、`.mjs` と `.mts` は同じファイル)。state がインラインのページや別のファイルのページは、発見した manifest でも引数に渡した manifest でも、manifest が無いものとして検査します。4.25 までは、アプリの schema をその下のすべてのページに当てていたので、アプリの隣で自前のインラインの state を持つページの正しいパスが `wcs/path-nonexistent` の error になっていました。`stateSource` の無い manifest(手書き・それより前の `wcs-schema` が作ったもの)は、これまでどおりすべてのページに当てます。
99
- - **効果**: `stateSchema` を宣言すると、schema 上に確定的に存在しないバインドパスは `wcs/path-nonexistent`(**error**・exit `1`)、`for:` に非配列は `wcs/path-type-mismatch`(**error**)になります。schema が開いたままの箇所(素の `{}`)は沈黙し、インラインスクリプトのメソッド / getter / `$listKeys` は引き続き存在扱いです。`stateSchema` が無ければ従来どおりです。
99
+ - **効果**: `stateSchema` を宣言すると、schema 上に確定的に存在しないバインドパスは `wcs/path-nonexistent`(**error**・exit `1`)、`for:` に非配列は `wcs/path-type-mismatch`(**error**)になります。schema が開いたままの箇所(素の `{}`)は schema が無いときと同じに検査し(4.31 から。以前は沈黙した)、インラインスクリプトのメソッド / getter / `$listKeys` は引き続き存在扱いです。`stateSchema` が無ければ従来どおりです。
100
100
  - **契約が要るとき**: validator が全体を読めない state は、契約が無いとパスをまったく検査できません。よくあるのはトップレベルの spread です — `export default { ...defaults(), get total() { … } }` は静的には見えないキーを持ち込むので、その state のパスは検査しません。4.4 から、spread の上で 1 回だけそう言います(`wcs/path-dynamic-unknown`、info)。`stateSchema` があれば束縛を —— 4.4 から getter の中で読むパス(`wcs/read-path-missing`)も —— それで検査します。読めない `<wcs-state src>` — / から始まるパス・URL・無いファイル — の state も検査できません。4.7 から、それを属性の上で 1 回だけ言います(`wcs/state-src-unread`、info)。4.6 までは何も言いませんでした。`src` はページからの相対パスで読むので、ファイルはサーバーと同じ並びに置き、/ から始まるパスには 4.10 から `--root=<dir>` を渡してください。
101
101
  - **schema の出どころ**: 手で書く(受け付けるのは JSON-Schema サブセット `type / properties / required / items / enum / const / anyOf / $defs / $ref` のみ)か、TypeScript の state ファイル(または JSDoc で型を付けた JavaScript のファイル)から `wcs-schema`(`@wcstack/typescript`)で生成します。manifest は派生物なので、CI では `wcs-schema check` で同期を保ってください。
102
102
 
@@ -213,6 +213,16 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
213
213
 
214
214
  新しい error は `--errors-only` にも出ます。新しい warning は `--strict` で失敗します。
215
215
 
216
+ ## 生成した schema と、行の合計を持つページに言うこと
217
+
218
+ 4.31 から。外部の評価 — wcstack 4.28.0 でビルドなしの確定申告の下書きツールを 25 日で作る Advent Calendar の連載の記録から:
219
+
220
+ - **`stateSchema` を足しても検査は弱くなりません。** schema が何も言わない所 — 行に型の無い一覧(`items: {}`。空で始まる一覧に `wcs-schema` が書くもの)・`null` の型の値・`any` — のパスは、schema が無いときと同じに検査します(`wcs/binding-path-missing`、warning)。そうした一覧の下の綴り違い `.deductio` は、schema が無いと知らされ、足すと通っていました。`wcs-schema emit` も、そうした一覧を名指すようになりました。
221
+ - **`wcs/getter-untracked-read` は一覧の行も読みます。** getter が `this.incomes` を読み、行のオブジェクトから項目を読み — `this.incomes.reduce((t, row) => t + row.amount, 0)`・`this.todos.filter((t) => !t.done).length`、`filter` / `slice` / `toSorted` の後・`[...this.list]`・`for (const row of this.list)` も — その項目がパスで書かれるとき。追跡されるのは一覧だけなので、合計は行の追加と削除には付いてきて、金額を打ち替えると前の値のままです。ページの束縛が書くなら **error**(行の中の `valueAsNumber: .amount`・`checked: .done`・組み込みタグの出力)、lint が契約を持たないカスタム要素の `value:` / `checked:`(`<yen-input data-wcs="value: .amount">`)かスクリプト(`this["incomes.0.amount"] = …`・`$setAll`)が書くなら warning。その項目の書き込みが無ければ報告しません — 一覧を置き換えるページ・`#ro` の束縛・`<option data-wcs="value: .id">`。項目はパスで読んでください: `this.$getAll("incomes.*.amount", [])`。
222
+ - **無いパスにはどこでも「もしかして」。** トップレベルのキーや getter の綴り違い(`dependentsDeductio`)・オブジェクトのメンバー(`user.nmae`)にも、ランタイムと同じく近い名前を言います。これまでは行のフィールドだけでした。
223
+
224
+ 新しい warning は `--strict` で落ち、新しい error は `--errors-only` でも出ます。
225
+
216
226
  ## 生成 → 検証 → 修正ループでの利用
217
227
 
218
228
  安定した 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
@@ -94,9 +94,9 @@ Without a contract, a path the validator cannot resolve is only a **warning** (`
94
94
  }
95
95
  ```
96
96
 
97
- - **Discovery**: the nearest `wcstack.manifest.json` walking up from the HTML file is used automatically — nothing to pass on the command line. Passing `*.manifest.json` arguments that contain an `application` artifact replaces discovery for the whole run. The VS Code extension discovers the same file, so IDE and CLI agree.
97
+ - **Discovery**: the nearest `wcstack.manifest.json` walking up from the HTML file is used automatically — nothing to pass on the command line. Passing `*.manifest.json` arguments that contain an `application` artifact replaces discovery for the whole run. Two of them that both declare a `stateSchema` are a `wcs/manifest-state-collision` error, and neither is used — except, since 4.32, when each names a different state file (`stateSource`, below): then each page gets the schema of the file its root `<wcs-state src>` loads, and two apps with a generated schema are checked in one run. The VS Code extension discovers the same file, so IDE and CLI agree.
98
98
  - **Which pages a schema is for** (since 4.26): a manifest that names the state file its schema was generated from — `wcstack.application.stateSource`, relative to the manifest, which `wcs-schema emit` writes — is the contract only of a page whose root `<wcs-state src>` loads that file (`.js` and `.ts`, `.mjs` and `.mts` of one path being one file). A page whose state is inline, or another file, is checked as if there were no manifest, whether the manifest was discovered or passed on the command line. Up to 4.25 the app's schema was applied to every page under it, so a page with its own inline state beside the app got `wcs/path-nonexistent` errors for its correct paths. A manifest without `stateSource` (hand-written, or generated by an earlier `wcs-schema`) applies to every page as before.
99
- - **Effect**: when a `stateSchema` is declared, a bound path that the schema definitely lacks is `wcs/path-nonexistent` (**error**, exit `1`); `for:` on a non-array is `wcs/path-type-mismatch` (**error**). Paths the schema leaves open (a bare `{}`) stay silent, and methods / getters / `$listKeys` from the inline script still count as existing. Without a `stateSchema`, behavior is unchanged.
99
+ - **Effect**: when a `stateSchema` is declared, a bound path that the schema definitely lacks is `wcs/path-nonexistent` (**error**, exit `1`); `for:` on a non-array is `wcs/path-type-mismatch` (**error**). Paths the schema leaves open (a bare `{}`) are checked as they are without a schema — since 4.31; they were silent — and methods / getters / `$listKeys` from the inline script still count as existing. Without a `stateSchema`, behavior is unchanged.
100
100
  - **When a contract is needed**: a state the validator cannot read in full needs one for its paths to be checked at all. A top-level spread is the common case — `export default { ...defaults(), get total() { … } }` brings in keys no static reader sees, so the validator checks no path of that state, and since 4.4 it says so once, at the spread (`wcs/path-dynamic-unknown`, info). With a `stateSchema` the bindings — and, since 4.4, the paths the getters read (`wcs/read-path-missing`) — are checked against it. A `<wcs-state src>` it cannot read — a path from `/`, a URL, a file that is not there — leaves that state unchecked as well; since 4.7 it says so once, at the attribute (`wcs/state-src-unread`, info), where up to 4.6 it said nothing. It reads a `src` relative to the page: keep the files laid out as on the server, and since 4.10 pass `--root=<dir>` for a path from `/`.
101
101
  - **Where the schema comes from**: write it by hand (only the JSON-Schema subset `type / properties / required / items / enum / const / anyOf / $defs / $ref` is accepted), or generate it from a TypeScript state file — or a JavaScript one with JSDoc types — with `wcs-schema` (`@wcstack/typescript`). The manifest is a derived artifact — keep it in sync with `wcs-schema check` in CI.
102
102
 
@@ -213,6 +213,16 @@ Since 4.30, from the street-reports seam app — a React app ported to wcstack b
213
213
 
214
214
  The new errors are printed with `--errors-only` too; the new warnings fail `--strict`.
215
215
 
216
+ ## What a page with a generated schema and a total over its rows is told
217
+
218
+ Since 4.31, from an outside evaluation — the record of a 25-day Advent Calendar series that builds a buildless tax-return draft tool on wcstack 4.28.0:
219
+
220
+ - **A `stateSchema` never weakens the check.** Where the schema says nothing — a list whose rows have no type (`items: {}`, what `wcs-schema` writes for a list that starts empty), a value typed `null`, `any` — a path is checked as it is without a schema (`wcs/binding-path-missing`, a warning). A misspelt `.deductio` under such a list was reported without the schema and passed once it was added. `wcs-schema emit` also names each such list now.
221
+ - **`wcs/getter-untracked-read` reads a list's rows too.** A getter that reads `this.incomes` and a field from its row objects — `this.incomes.reduce((t, row) => t + row.amount, 0)`, `this.todos.filter((t) => !t.done).length`, also after `filter` / `slice` / `toSorted`, on `[...this.list]`, and in `for (const row of this.list)` — when that field is written by path: only the list is tracked, so the total follows rows added and removed and keeps its value when an amount is edited. An **error** when a binding on the page writes it (`valueAsNumber: .amount` in the rows, `checked: .done`, a built-in tag's output); a warning when the write is a custom element's `value:` / `checked:` the lint has no contract for (`<yen-input data-wcs="value: .amount">`) or the script's (`this["incomes.0.amount"] = …`, `$setAll`). Not reported without such a write of that field — a page that replaces the list, a `#ro` binding, `<option data-wcs="value: .id">`. Read the field by path: `this.$getAll("incomes.*.amount", [])`.
222
+ - **A did-you-mean for any missing path.** A misspelt top-level key or getter (`dependentsDeductio`) and an object's member (`user.nmae`) name the near one, as the runtime does; only a row's field did.
223
+
224
+ The new warnings fail `--strict`; the new error shows with `--errors-only`.
225
+
216
226
  ## Use in generate–validate–fix loops
217
227
 
218
228
  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
@@ -2687,7 +2687,7 @@ function getWcsManifest() {
2687
2687
  }
2688
2688
 
2689
2689
  // ../state/package.json
2690
- var version = "4.30.0";
2690
+ var version = "4.32.0";
2691
2691
 
2692
2692
  // src/service/wcsManifest.ts
2693
2693
  var ENGINE_VERSION = version;
@@ -2773,9 +2773,9 @@ function missingSegment(path, tree) {
2773
2773
  }
2774
2774
  return null;
2775
2775
  }
2776
- function rowFieldSuggestion(path, candidates, msgs) {
2776
+ function pathSuggestion(path, candidates, msgs) {
2777
2777
  const missing = missingSegment(path, pathTree(candidates));
2778
- if (missing === null || !missing.parent.split(".").includes("*")) return "";
2778
+ if (missing === null) return "";
2779
2779
  return suggestion(missing.segment, missing.names, msgs);
2780
2780
  }
2781
2781
  function suggestion(input, candidates, msgs) {
@@ -13461,6 +13461,7 @@ var ja = {
13461
13461
  objectKeyAssign: (t, acc, sp) => `"${t}" \u306E\u30AD\u30FC\u306B\u305D\u306E\u5834\u3067\u4EE3\u5165\u3057\u3066\u3044\u307E\u3059\u3002state \u306F\u3053\u306E\u66F8\u304D\u8FBC\u307F\u3092\u898B\u306A\u3044\u306E\u3067\u3001\u305D\u308C\u3092\u8AAD\u3080\u675F\u7E1B\u30FBgetter\u30FB$watch \u306F\u5909\u308F\u3089\u305A\u3001\u4F55\u3082\u63CF\u304D\u76F4\u3055\u308C\u307E\u305B\u3093\u3002\u65B0\u3057\u3044\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3092\u4EE3\u5165\u3059\u308B\uFF08${acc} = { ...${acc}, [key]: value }\uFF09\u304B\u3001\u30C9\u30C3\u30C8\u30D1\u30B9\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF08this["${sp}"] = \u2026\uFF09`,
13462
13462
  getterUntrackedRead: (root, sp) => `\u3053\u3053\u3067\u8FFD\u8DE1\u3055\u308C\u308B\u306E\u306F "${root}" \u3060\u3051\u3067\u3059\u3002"${sp}" \u304C\u5909\u308F\u3063\u3066\u3082\u3053\u306E getter \u306F\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\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`,
13463
13463
  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`,
13464
+ getterRowFieldRead: (list, fieldPath, written, binding, tag) => `\u3053\u306E getter \u306F\u4E00\u89A7 "${list}" \u3092\u8AAD\u307F\u3001\u884C\u306E\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u304B\u3089\u9805\u76EE\u3092\u8AAD\u3093\u3067\u3044\u307E\u3059\u3002\u8FFD\u8DE1\u3055\u308C\u308B\u306E\u306F "${list}" \u3060\u3051\u3067\u3001${binding !== null ? `<${tag}> \u306E\u675F\u7E1B "${binding}" \u306F` : "\u30DA\u30FC\u30B8\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\u3001\u884C\u306E\u8FFD\u52A0\u3068\u524A\u9664\u3067\u306F\u6B63\u3057\u304F\u898B\u3048\u3066\u3082\u3001\u884C\u306E\u5024\u3092\u5909\u3048\u308B\u3068\u524D\u306B\u8A08\u7B97\u3057\u305F\u5024\u306E\u307E\u307E\u3067\u3059\u3002\u884C\u306E\u9805\u76EE\u306F\u30D1\u30B9\u3067\u8AAD\u3093\u3067\u304F\u3060\u3055\u3044: this.$getAll("${fieldPath}", [])`,
13464
13465
  handlerFilterNotAllowed: (prop) => `\u30A4\u30D9\u30F3\u30C8\u30CF\u30F3\u30C9\u30E9 "${prop}" \u306B\u30D5\u30A3\u30EB\u30BF\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093`,
13465
13466
  typeExpectation: (label, expected, resultType) => `"${label}" \u306B\u306F${JA_EXPECTED_LABEL[expected]}\u304C\u5FC5\u8981\u3067\u3059\uFF08\u73FE\u5728\u306E\u578B: ${resultType}\uFF09`,
13466
13467
  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}`,
@@ -13761,6 +13762,7 @@ var en = {
13761
13762
  objectKeyAssign: (t, acc, sp) => `This assigns a key of "${t}" in place. The state does not see the write, so no binding, getter or $watch that reads it changes, and nothing is rendered again. Assign a new object (${acc} = { ...${acc}, [key]: value }), or write the dot path this["${sp}"] = \u2026`,
13762
13763
  getterUntrackedRead: (root, sp) => `Only "${root}" is tracked here: the getter is not re-evaluated when "${sp}" changes (plain property access after a path read is not tracked). Read this["${sp}"] instead`,
13763
13764
  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`,
13765
+ getterRowFieldRead: (list, fieldPath, written, binding, tag) => `This getter reads the list "${list}" and a field from its row objects. Only "${list}" is tracked, and ${binding !== null ? `the binding "${binding}" on <${tag}>` : "the page"} writes "${written}" by path: that write never reaches this getter, which looks right when rows are added or removed and keeps its last value when a row's value changes. Read the rows' fields by path: this.$getAll("${fieldPath}", [])`,
13764
13766
  handlerFilterNotAllowed: (prop) => `Filters cannot be applied to event handler "${prop}"`,
13765
13767
  typeExpectation: (label, expected, resultType) => `"${label}" requires ${EN_EXPECTED_LABEL[expected]} (current type: ${resultType})`,
13766
13768
  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}`,
@@ -16130,6 +16132,122 @@ function findLocationRead(body) {
16130
16132
  walk2(wrapper.body);
16131
16133
  return found;
16132
16134
  }
16135
+ var ROW_CALLBACKS = /* @__PURE__ */ new Map([
16136
+ ["reduce", [1]],
16137
+ ["reduceRight", [1]],
16138
+ ["map", [0]],
16139
+ ["flatMap", [0]],
16140
+ ["filter", [0]],
16141
+ ["find", [0]],
16142
+ ["findIndex", [0]],
16143
+ ["findLast", [0]],
16144
+ ["findLastIndex", [0]],
16145
+ ["some", [0]],
16146
+ ["every", [0]],
16147
+ ["forEach", [0]],
16148
+ ["sort", [0, 1]],
16149
+ ["toSorted", [0, 1]]
16150
+ ]);
16151
+ var ROW_PRESERVING = /* @__PURE__ */ new Set(["filter", "slice", "sort", "toSorted", "reverse", "toReversed", "toSpliced", "concat"]);
16152
+ function findRowFieldReads(body) {
16153
+ let program;
16154
+ try {
16155
+ program = parseErasingTypes(PREFIX + body + SUFFIX, { ecmaVersion: "latest", sourceType: "module" });
16156
+ } catch {
16157
+ return null;
16158
+ }
16159
+ const wrapper = unwrapWrapper(program);
16160
+ if (wrapper === null) return null;
16161
+ const out = [];
16162
+ const listOf = (node) => {
16163
+ const n = unwrapChain(node);
16164
+ if (n.type === "MemberExpression" && n.object.type === "ThisExpression") {
16165
+ const key = !n.computed && n.property.type === "Identifier" ? n.property.name : literalString2(n.property);
16166
+ return key !== null && key !== "" && !key.startsWith("$") ? key : null;
16167
+ }
16168
+ if (n.type === "CallExpression") {
16169
+ const callee = unwrapChain(n.callee);
16170
+ if (callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier" && ROW_PRESERVING.has(callee.property.name)) return listOf(callee.object);
16171
+ }
16172
+ if (n.type === "ArrayExpression" && n.elements.length === 1 && n.elements[0]?.type === "SpreadElement") {
16173
+ return listOf(n.elements[0].argument);
16174
+ }
16175
+ return null;
16176
+ };
16177
+ const readsOf = (list, name, node) => {
16178
+ const walk3 = (n) => {
16179
+ if (isFunctionNode(n)) {
16180
+ const bound = /* @__PURE__ */ new Set();
16181
+ for (const param of n.params) bindingNames(param, bound);
16182
+ if (bound.has(name)) return;
16183
+ }
16184
+ if (n.type === "AssignmentExpression" || n.type === "UpdateExpression") {
16185
+ const target = n.type === "AssignmentExpression" ? n.left : n.argument;
16186
+ if (unwrapChain(target).type === "MemberExpression") {
16187
+ if (n.type === "AssignmentExpression") walk3(n.right);
16188
+ return;
16189
+ }
16190
+ }
16191
+ if (n.type === "MemberExpression" || n.type === "ChainExpression" || n.type === "CallExpression") {
16192
+ const call = n.type === "CallExpression" ? n : null;
16193
+ const { segments, base } = resolveChain(call !== null ? call.callee : n);
16194
+ if (base.type === "Identifier" && base.name === name && segments.length > 0) {
16195
+ const fields = [];
16196
+ for (const segment of segments) {
16197
+ if (segment.text === null || segment.dynamic !== null) break;
16198
+ fields.push(segment.text);
16199
+ }
16200
+ if (call !== null && fields.length === segments.length) fields.pop();
16201
+ if (fields.length > 0) out.push({ list, fields, start: n.start - PREFIX.length, end: n.end - PREFIX.length });
16202
+ if (call !== null) for (const arg of call.arguments) walk3(arg);
16203
+ return;
16204
+ }
16205
+ }
16206
+ forEachChild(n, walk3);
16207
+ };
16208
+ walk3(node);
16209
+ };
16210
+ const rowParam = (list, param, body2) => {
16211
+ if (param === void 0) return;
16212
+ const p = param.type === "AssignmentPattern" ? param.left : param;
16213
+ if (p.type === "Identifier") {
16214
+ readsOf(list, p.name, body2);
16215
+ return;
16216
+ }
16217
+ if (p.type !== "ObjectPattern") return;
16218
+ for (const property of p.properties) {
16219
+ if (property.type !== "Property") continue;
16220
+ const key = !property.computed && property.key.type === "Identifier" ? property.key.name : literalString2(property.key);
16221
+ if (key !== null) out.push({ list, fields: [key], start: property.key.start - PREFIX.length, end: property.key.end - PREFIX.length });
16222
+ }
16223
+ };
16224
+ const walk2 = (node, thisIsState) => {
16225
+ if (isFunctionNode(node) && node.type !== "ArrowFunctionExpression") {
16226
+ forEachChild(node, (child) => walk2(child, false));
16227
+ return;
16228
+ }
16229
+ if (isClassNode(node)) return;
16230
+ if (thisIsState && node.type === "CallExpression") {
16231
+ const callee = unwrapChain(node.callee);
16232
+ const method = callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier" ? callee.property.name : null;
16233
+ const rows = method === null ? void 0 : ROW_CALLBACKS.get(method);
16234
+ const list = rows === void 0 ? null : listOf(callee.object);
16235
+ const callback = node.arguments[0];
16236
+ if (list !== null && callback !== void 0 && isFunctionNode(callback)) {
16237
+ for (const index of rows) rowParam(list, callback.params[index], callback.body);
16238
+ }
16239
+ }
16240
+ if (thisIsState && node.type === "ForOfStatement") {
16241
+ const list = listOf(node.right);
16242
+ const left = node.left;
16243
+ const param = left.type === "VariableDeclaration" ? left.declarations[0]?.id : left;
16244
+ if (list !== null) rowParam(list, param, node.body);
16245
+ }
16246
+ forEachChild(node, (child) => walk2(child, thisIsState));
16247
+ };
16248
+ walk2(wrapper.body, true);
16249
+ return out;
16250
+ }
16133
16251
  var WINDOW_HOLDERS = /* @__PURE__ */ new Set(["window", "globalThis", "self"]);
16134
16252
  var WINDOW_VALUES = /* @__PURE__ */ new Map([
16135
16253
  ["innerWidth", "size"],
@@ -16990,11 +17108,11 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
16990
17108
  code: WcsDiagnosticCode.RecursionUnsupported,
16991
17109
  message: msgs.recursionUnsupported(checkPath, "binding"),
16992
17110
  severity: "error"
16993
- } : schema !== void 0 && !(unresolved && propNoMod.startsWith("on")) ? validateSchemaPathExistence(checkPath, pathTrimmed, scopedPaths, scopedPathSet, commandNames, schema, msgs) : unresolved ? null : toMissingVerdict(validatePathExistence(checkPath, pathTrimmed, scopedPaths, scopedPathSet, commandNames, msgs));
17111
+ } : schema !== void 0 && !(unresolved && propNoMod.startsWith("on")) ? validateSchemaPathExistence(checkPath, pathTrimmed, scopedPaths, scopedPathSet, commandNames, schema, msgs, unresolved) : unresolved ? null : toMissingVerdict(validatePathExistence(checkPath, pathTrimmed, scopedPaths, scopedPathSet, commandNames, msgs));
16994
17112
  if (verdict) {
16995
17113
  const pathOffset = binding.indexOf(parsed.path);
16996
17114
  const pathStart = bindingStart + pathOffset;
16997
- const near = verdict.code === WcsDiagnosticCode.BindingPathMissing || verdict.code === WcsDiagnosticCode.PathNonexistent ? rowFieldSuggestion(checkPath, scopedPaths, msgs) : "";
17115
+ const near = verdict.code === WcsDiagnosticCode.BindingPathMissing || verdict.code === WcsDiagnosticCode.PathNonexistent ? pathSuggestion(checkPath, scopedPaths, msgs) : "";
16998
17116
  diagnostics.push({
16999
17117
  code: verdict.code,
17000
17118
  start: pathStart,
@@ -17445,7 +17563,7 @@ function matchesRecursionCandidates(scopedPaths, checkPath, scopedPathSet) {
17445
17563
  function toMissingVerdict(message) {
17446
17564
  return message ? { code: WcsDiagnosticCode.BindingPathMissing, message, severity: "warning" } : null;
17447
17565
  }
17448
- function validateSchemaPathExistence(checkPath, displayPath, scopedPaths, scopedPathSet, commandNames, schema, msgs) {
17566
+ function validateSchemaPathExistence(checkPath, displayPath, scopedPaths, scopedPathSet, commandNames, schema, msgs, unresolved) {
17449
17567
  if (checkPath.startsWith("$")) {
17450
17568
  return toMissingVerdict(validatePathExistence(checkPath, displayPath, scopedPaths, scopedPathSet, commandNames, msgs));
17451
17569
  }
@@ -17454,6 +17572,9 @@ function validateSchemaPathExistence(checkPath, displayPath, scopedPaths, scoped
17454
17572
  if (resolution.kind === "nonexistent") {
17455
17573
  return { code: WcsDiagnosticCode.PathNonexistent, message: msgs.pathNonexistent(displayPath), severity: "error" };
17456
17574
  }
17575
+ if (resolution.kind === "unknown" && !unresolved) {
17576
+ return toMissingVerdict(validatePathExistence(checkPath, displayPath, scopedPaths, scopedPathSet, commandNames, msgs));
17577
+ }
17457
17578
  return null;
17458
17579
  }
17459
17580
  function getExpectedType(property) {
@@ -17866,7 +17987,10 @@ function validateTemplateSyntax(html, stateTagName, bindAttrName = "data-wcs", l
17866
17987
  if (isValidTemplatePath(path, pathSet2, scoped)) return null;
17867
17988
  if (defaultSchema !== void 0 && !path.startsWith("$")) {
17868
17989
  const resolution = resolveIndexedSchemaPath(defaultSchema, path);
17869
- return resolution.kind === "nonexistent" ? { code: WcsDiagnosticCode.PathNonexistent, severity: "error", message: msgs.pathNonexistent(displayPath) } : null;
17990
+ if (resolution.kind === "nonexistent") {
17991
+ return { code: WcsDiagnosticCode.PathNonexistent, severity: "error", message: msgs.pathNonexistent(displayPath) };
17992
+ }
17993
+ if (resolution.kind !== "unknown") return null;
17870
17994
  }
17871
17995
  if (isUnresolvedPath(path, pathIndex.scopes)) return null;
17872
17996
  return { code: WcsDiagnosticCode.BindingPathMissing, severity: "warning", message: msgs.pathMissing(displayPath) };
@@ -17875,7 +17999,7 @@ function validateTemplateSyntax(html, stateTagName, bindAttrName = "data-wcs", l
17875
17999
  const defaultPaths = allPaths;
17876
18000
  const pathSet = new Set(defaultPaths.map((p) => p.path));
17877
18001
  const filterNameSet = new Set(BUILTIN_FILTERS.map((f) => f.name));
17878
- const nearRowField = (code, path) => code === WcsDiagnosticCode.BindingPathMissing || code === WcsDiagnosticCode.PathNonexistent ? rowFieldSuggestion(path, defaultPaths, msgs) : "";
18002
+ const nearName = (code, path) => code === WcsDiagnosticCode.BindingPathMissing || code === WcsDiagnosticCode.PathNonexistent ? pathSuggestion(path, defaultPaths, msgs) : "";
17879
18003
  const mustaches = findAllMustacheSyntax(html);
17880
18004
  const comments = findAllCommentBindings(html);
17881
18005
  for (const item of [...mustaches, ...comments]) {
@@ -17988,7 +18112,7 @@ function validateTemplateSyntax(html, stateTagName, bindAttrName = "data-wcs", l
17988
18112
  code: verdict.code,
17989
18113
  start: item.exprStart,
17990
18114
  end: item.exprStart + pathPart.length,
17991
- message: verdict.message + msgs.expansionSuffix(expandedPath) + nearRowField(verdict.code, expandedPath),
18115
+ message: verdict.message + msgs.expansionSuffix(expandedPath) + nearName(verdict.code, expandedPath),
17992
18116
  severity: verdict.severity
17993
18117
  });
17994
18118
  }
@@ -18000,7 +18124,7 @@ function validateTemplateSyntax(html, stateTagName, bindAttrName = "data-wcs", l
18000
18124
  code: verdict.code,
18001
18125
  start: item.exprStart,
18002
18126
  end: item.exprStart + pathPart.length,
18003
- message: verdict.message + nearRowField(verdict.code, pathPart),
18127
+ message: verdict.message + nearName(verdict.code, pathPart),
18004
18128
  severity: verdict.severity
18005
18129
  });
18006
18130
  }
@@ -19349,7 +19473,7 @@ function validateGetterUntrackedReads(script, scriptStart, mountPath, nestedWrit
19349
19473
  const segments = read.callee ? read.chain.slice(0, -1) : read.chain;
19350
19474
  if (segments.length < 2 || !objectRoots.has(segments[0])) continue;
19351
19475
  const prefix = mountPath === null ? [] : mountPath.split(".");
19352
- const write = boundWriteOf([...prefix, ...segments], prefix.length + read.path.split(".").length, bindingWrites());
19476
+ const write = boundWriteOf([...prefix, ...segments], prefix.length + read.path.split(".").length, bindingWrites().filter((w) => w.certain));
19353
19477
  if (write === void 0 && !nestedWriteRoots().has([...prefix, segments[0]].join("."))) continue;
19354
19478
  const sp = segments.join(".");
19355
19479
  out.push({
@@ -19363,6 +19487,45 @@ function validateGetterUntrackedReads(script, scriptStart, mountPath, nestedWrit
19363
19487
  }
19364
19488
  return out;
19365
19489
  }
19490
+ function validateGetterRowFieldReads(script, scriptStart, mountPath, writtenPaths, bindingWrites, locale2) {
19491
+ const getters = analyzeCallableBodies(script).filter((entry) => entry.kind === "getter" && entry.accessor === "get");
19492
+ const msgs = getMessages(locale2);
19493
+ const prefix = mountPath === null ? [] : mountPath.split(".");
19494
+ const out = [];
19495
+ for (const getter of getters) {
19496
+ if (!/\bthis\b/.test(getter.body)) continue;
19497
+ const told = /* @__PURE__ */ new Set();
19498
+ for (const read of findRowFieldReads(getter.body) ?? []) {
19499
+ const list = [...prefix, ...read.list.split(".")];
19500
+ const segments = [...list, "*", ...read.fields];
19501
+ const writes = bindingWrites();
19502
+ const bound = boundWriteOf(segments, list.length, writes.filter((w) => w.certain));
19503
+ const soft = bound === void 0 ? boundWriteOf(segments, list.length, writes.filter((w) => !w.certain)) : void 0;
19504
+ const written = bound?.path ?? soft?.path ?? writtenUnderRows(segments, list.length, writtenPaths());
19505
+ const fieldPath = `${read.list}.*.${read.fields.join(".")}`;
19506
+ if (written === void 0 || told.has(fieldPath)) continue;
19507
+ told.add(fieldPath);
19508
+ out.push({
19509
+ code: WcsDiagnosticCode.GetterUntrackedRead,
19510
+ start: scriptStart + getter.bodyStart + read.start,
19511
+ end: scriptStart + getter.bodyStart + read.end,
19512
+ message: msgs.getterRowFieldRead(read.list, fieldPath, written, (bound ?? soft)?.binding ?? null, (bound ?? soft)?.tag ?? null),
19513
+ severity: bound === void 0 ? "warning" : "error"
19514
+ });
19515
+ }
19516
+ }
19517
+ return out;
19518
+ }
19519
+ function writtenUnderRows(segments, tracked, written) {
19520
+ return written.find(({ path, inclusive, script }) => {
19521
+ if (!script || inclusive) return false;
19522
+ const w = path.split(".").map((s) => /^\d+$/.test(s) ? "*" : s);
19523
+ if (w.length <= tracked) return false;
19524
+ const common = Math.min(w.length, segments.length);
19525
+ for (let i = 0; i < common; i++) if (w[i] !== segments[i]) return false;
19526
+ return true;
19527
+ })?.path;
19528
+ }
19366
19529
  function boundWriteOf(segments, tracked, writes) {
19367
19530
  return writes.find((write) => {
19368
19531
  const written = write.path.split(".");
@@ -19389,8 +19552,8 @@ function collectBindingWrites(html, bindAttrName) {
19389
19552
  if (list === null) return;
19390
19553
  path = path === "." ? `${list}.*` : `${list}.*.${path.slice(1)}`;
19391
19554
  }
19392
- const write = (written) => {
19393
- out.push({ path: written, binding: binding.exprText, tag });
19555
+ const write = (written, certain = true) => {
19556
+ out.push({ path: written, binding: binding.exprText, tag, certain });
19394
19557
  };
19395
19558
  if (parsed.bindingType === "spread") {
19396
19559
  if (outputs === null) return;
@@ -19403,6 +19566,8 @@ function collectBindingWrites(html, bindAttrName) {
19403
19566
  write(path);
19404
19567
  } else if (parsed.bindingType === "prop" && (writesBack(attr, parsed.propName, parsed.propName) || outputs?.includes(parsed.propName) === true)) {
19405
19568
  write(path);
19569
+ } else if (parsed.bindingType === "prop" && contract === void 0 && tag.includes("-") && TWO_WAY_PROPS.has(parsed.propName)) {
19570
+ write(path, false);
19406
19571
  }
19407
19572
  });
19408
19573
  }
@@ -19545,9 +19710,11 @@ function templateKeyPath(raw) {
19545
19710
  const path = raw.replace(/\$\{[^{}]*\}/g, "*");
19546
19711
  return TEMPLATE_KEY_PATH.test(path) ? path : null;
19547
19712
  }
19548
- function collectNestedWriteRoots(html, stateTagName, bindAttrName, blocks) {
19713
+ function collectNestedWriteRoots(html, stateTagName, bindAttrName, blocks, written = []) {
19549
19714
  const roots = /* @__PURE__ */ new Map();
19715
+ let script = false;
19550
19716
  const addPrefixes = (path, inclusive) => {
19717
+ written.push({ path, inclusive, script });
19551
19718
  const segments = path.split(".");
19552
19719
  const last = inclusive ? segments.length : segments.length - 1;
19553
19720
  const example = inclusive ? `${path}.*` : path;
@@ -19587,6 +19754,7 @@ function collectNestedWriteRoots(html, stateTagName, bindAttrName, blocks) {
19587
19754
  const tag = tags.find((t) => t.start <= at2 && at2 <= t.end);
19588
19755
  if (tag?.contract?.hasWcBindable && tag.contract.properties.includes(occ.propName)) addPrefixes(path, false);
19589
19756
  }
19757
+ script = true;
19590
19758
  for (const block of blocks) {
19591
19759
  if (block.mountPath !== null) addPrefixes(block.mountPath, true);
19592
19760
  const scan = maskCommentsAndStrings(block.content);
@@ -19818,8 +19986,15 @@ function validateOnHandlerThis(script, scriptStart, locale2) {
19818
19986
  function validateSemantics(html, stateTagName = "wcs-state", locale2, bindAttrName = "data-wcs") {
19819
19987
  const out = [];
19820
19988
  const blocks = parseLoadedScriptBlocks(html, stateTagName);
19821
- let nestedWriteRoots = null;
19822
- const getNestedWriteRoots = () => nestedWriteRoots ??= collectNestedWriteRoots(html, stateTagName, bindAttrName, blocks);
19989
+ let nestedWrites = null;
19990
+ const getNestedWrites = () => {
19991
+ if (nestedWrites === null) {
19992
+ const paths = [];
19993
+ nestedWrites = { roots: collectNestedWriteRoots(html, stateTagName, bindAttrName, blocks, paths), paths };
19994
+ }
19995
+ return nestedWrites;
19996
+ };
19997
+ const getNestedWriteRoots = () => getNestedWrites().roots;
19823
19998
  let bindingWrites = null;
19824
19999
  const getBindingWrites = () => bindingWrites ??= collectBindingWrites(html, bindAttrName);
19825
20000
  for (const block of blocks) {
@@ -19835,6 +20010,14 @@ function validateSemantics(html, stateTagName = "wcs-state", locale2, bindAttrNa
19835
20010
  getBindingWrites,
19836
20011
  locale2
19837
20012
  ));
20013
+ out.push(...validateGetterRowFieldReads(
20014
+ block.content,
20015
+ block.contentStart,
20016
+ block.mountPath,
20017
+ () => getNestedWrites().paths,
20018
+ getBindingWrites,
20019
+ locale2
20020
+ ));
19838
20021
  out.push(...validateGetterLocationReads(block.content, block.contentStart, locale2));
19839
20022
  out.push(...validateGetterClockReads(block.content, block.contentStart, locale2));
19840
20023
  out.push(...validateGetterAmbientReads(block.content, block.contentStart, locale2));
@@ -22620,6 +22803,30 @@ function parseJsonWithSpans(text3) {
22620
22803
  }
22621
22804
  }
22622
22805
 
22806
+ // src/core/sidecar/statePaths.ts
22807
+ function segmentsOf(path) {
22808
+ const norm = path.replace(/\\/g, "/");
22809
+ const absolute = norm.startsWith("/") || /^[A-Za-z]:\//.test(norm);
22810
+ const segments = [];
22811
+ for (const segment of norm.split("/")) {
22812
+ if (segment === "" || segment === ".") continue;
22813
+ if (segment === ".." && segments.length > 0 && segments[segments.length - 1] !== "..") segments.pop();
22814
+ else segments.push(/^[A-Za-z]:$/.test(segment) ? segment.toUpperCase() : segment);
22815
+ }
22816
+ return { absolute, segments };
22817
+ }
22818
+ function sameStateFile(a, b) {
22819
+ const canonical = (p) => p.replace(/\.ts$/, ".js").replace(/\.mts$/, ".mjs");
22820
+ return canonical(a) === canonical(b);
22821
+ }
22822
+ function differentStateFiles(manifestA, stateSourceA, manifestB, stateSourceB) {
22823
+ const a = segmentsOf(manifestA);
22824
+ const b = segmentsOf(manifestB);
22825
+ if (a.absolute !== b.absolute) return false;
22826
+ const file = (manifest2, stateSource) => segmentsOf([...manifest2.slice(0, -1), stateSource].join("/")).segments.join("/");
22827
+ return !sameStateFile(file(a.segments, stateSourceA), file(b.segments, stateSourceB));
22828
+ }
22829
+
22623
22830
  // src/core/sidecar/types.ts
22624
22831
  var SUPPORTED_SCHEMA_VERSION = 2;
22625
22832
  var SUPPORTED_NAMESPACE_VERSION = 2;
@@ -22712,9 +22919,8 @@ function resolvePackageContracts(loaded) {
22712
22919
  const collided = /* @__PURE__ */ new Set();
22713
22920
  const firstSource = /* @__PURE__ */ new Map();
22714
22921
  const filterOwner = /* @__PURE__ */ new Map();
22715
- let schemaOwner;
22716
- let schemaWinner;
22717
- let schemaStateSource;
22922
+ const schemaEntries = [];
22923
+ let schemaCollided = false;
22718
22924
  let hasApplicationArtifact = false;
22719
22925
  for (const lm of loaded) {
22720
22926
  if (lm.manifest === null) continue;
@@ -22773,16 +22979,21 @@ function resolvePackageContracts(loaded) {
22773
22979
  if (lm.manifest.kind === "application" && application?.stateSchema !== void 0) {
22774
22980
  const schema = application.stateSchema;
22775
22981
  if (schema !== null && typeof schema === "object" && !Array.isArray(schema)) {
22776
- if (schemaOwner === void 0) {
22777
- schemaOwner = lm.artifact.source;
22778
- schemaWinner = schema;
22779
- schemaStateSource = application.stateSource;
22982
+ const stateSource = typeof application.stateSource === "string" && application.stateSource.trim() !== "" ? application.stateSource.trim() : void 0;
22983
+ const entry = {
22984
+ schema,
22985
+ source: lm.artifact.source,
22986
+ ...stateSource !== void 0 ? { stateSource } : {}
22987
+ };
22988
+ const other = schemaEntries.find((e) => !(e.stateSource !== void 0 && entry.stateSource !== void 0 && differentStateFiles(e.source, e.stateSource, entry.source, entry.stateSource)));
22989
+ if (other === void 0) {
22990
+ schemaEntries.push(entry);
22780
22991
  } else {
22781
- schemaWinner = void 0;
22992
+ schemaCollided = true;
22782
22993
  ctxFor(lm).add(
22783
22994
  WcsDiagnosticCode.ManifestStateCollision,
22784
22995
  pointer("manifestExtensions", "wcstack.application", "stateSchema"),
22785
- `Multiple application artifacts declare a stateSchema (also in "${schemaOwner}"); neither is used.`,
22996
+ `Multiple application artifacts declare a stateSchema (also in "${other.source}"); neither is used.`,
22786
22997
  "error",
22787
22998
  void 0,
22788
22999
  true
@@ -22796,12 +23007,14 @@ function resolvePackageContracts(loaded) {
22796
23007
  const kept = diags.filter((d) => !(d.code === WcsDiagnosticCode.ManifestOverride && d.tag !== void 0 && collided.has(d.tag)));
22797
23008
  if (kept.length > 0) diagnosticsBySource.set(source, kept);
22798
23009
  }
22799
- const stateSource = schemaWinner !== void 0 && typeof schemaStateSource === "string" && schemaStateSource.trim() !== "" ? schemaStateSource.trim() : void 0;
23010
+ const schemas = schemaCollided ? [] : schemaEntries;
23011
+ const single = schemas.length === 1 ? schemas[0] : void 0;
22800
23012
  return {
22801
23013
  tags: winners,
22802
- applicationSchema: schemaWinner,
22803
- ...schemaWinner !== void 0 ? { applicationSchemaSource: schemaOwner } : {},
22804
- ...stateSource !== void 0 ? { applicationStateSource: stateSource } : {},
23014
+ applicationSchema: single?.schema,
23015
+ ...single !== void 0 ? { applicationSchemaSource: single.source } : {},
23016
+ ...single?.stateSource !== void 0 ? { applicationStateSource: single.stateSource } : {},
23017
+ applicationSchemas: schemas,
22805
23018
  hasApplicationArtifact,
22806
23019
  diagnosticsBySource
22807
23020
  };
@@ -22843,17 +23056,6 @@ function applicationStateSourceOf(loaded) {
22843
23056
  const stateSource = manifest2.manifestExtensions?.["wcstack.application"]?.stateSource;
22844
23057
  return typeof stateSource === "string" && stateSource.trim() !== "" ? stateSource.trim() : void 0;
22845
23058
  }
22846
- function segmentsOf(path) {
22847
- const norm = path.replace(/\\/g, "/");
22848
- const absolute = norm.startsWith("/") || /^[A-Za-z]:\//.test(norm);
22849
- const segments = [];
22850
- for (const segment of norm.split("/")) {
22851
- if (segment === "" || segment === ".") continue;
22852
- if (segment === ".." && segments.length > 0 && segments[segments.length - 1] !== "..") segments.pop();
22853
- else segments.push(/^[A-Za-z]:$/.test(segment) ? segment.toUpperCase() : segment);
22854
- }
22855
- return { absolute, segments };
22856
- }
22857
23059
  function stateSourceFromPage(pageSource, manifestSource, stateSource) {
22858
23060
  const page = segmentsOf(pageSource);
22859
23061
  const manifest2 = segmentsOf(manifestSource);
@@ -22864,10 +23066,6 @@ function stateSourceFromPage(pageSource, manifestSource, stateSource) {
22864
23066
  while (common < dir.length && common < target.length && dir[common] === target[common] && dir[common] !== "..") common++;
22865
23067
  return [...dir.slice(common).map(() => ".."), ...target.slice(common)].join("/");
22866
23068
  }
22867
- function sameStateFile(a, b) {
22868
- const canonical = (p) => p.replace(/\.ts$/, ".js").replace(/\.mts$/, ".mjs");
22869
- return canonical(a) === canonical(b);
22870
- }
22871
23069
  function schemaAppliesToPage(html, stateTagName, stateSource, fileReader) {
22872
23070
  const roots = parseWcsStateElements(html, stateTagName).filter((e) => e.mountPath === null && !e.bindComponent && e.srcAttr !== void 0);
22873
23071
  if (roots.length === 0) return false;
@@ -23467,6 +23665,7 @@ function validateManifestSet(input) {
23467
23665
  resolvedSchema: resolved.applicationSchema,
23468
23666
  ...resolved.applicationSchemaSource !== void 0 ? { resolvedSchemaSource: resolved.applicationSchemaSource } : {},
23469
23667
  ...resolved.applicationStateSource !== void 0 ? { resolvedStateSource: resolved.applicationStateSource } : {},
23668
+ resolvedSchemas: resolved.applicationSchemas,
23470
23669
  hasApplicationArtifact: resolved.hasApplicationArtifact
23471
23670
  };
23472
23671
  }
@@ -23483,12 +23682,27 @@ function hasAnythingToCheck(text3, bindAttribute, stateTagName) {
23483
23682
  return text3.includes(bindAttribute) || /<wcs-/i.test(text3) || text3.includes(`<${stateTagName}`) || /@wcstack\/|\bwcstack(?:@[\w.-]+)?\/auto\b/.test(text3);
23484
23683
  }
23485
23684
  var severityLabel = { error: "error", warning: "warning", info: "info" };
23685
+ function explicitSchemaFor(input, schemas, stateTagName) {
23686
+ if (schemas.length === 1) {
23687
+ const [only] = schemas;
23688
+ return {
23689
+ schema: only.schema,
23690
+ stateSource: only.stateSource === void 0 ? void 0 : stateSourceFromPage(input.source, only.source, only.stateSource)
23691
+ };
23692
+ }
23693
+ for (const entry of schemas) {
23694
+ const stateSource = stateSourceFromPage(input.source, entry.source, entry.stateSource);
23695
+ if (stateSource !== void 0 && schemaAppliesToPage(input.text, stateTagName, stateSource, input.fileReader)) {
23696
+ return { schema: entry.schema, stateSource };
23697
+ }
23698
+ }
23699
+ return void 0;
23700
+ }
23486
23701
  function runValidation(inputs, options = {}) {
23487
23702
  const diagnosticsBySource = /* @__PURE__ */ new Map();
23488
23703
  const textBySource = new Map(inputs.map((i) => [i.source, i.text]));
23489
23704
  const manifestInputs = inputs.filter((i) => i.kind === "manifest");
23490
- let explicitSchema;
23491
- let explicitStateSource;
23705
+ let explicitSchemas = [];
23492
23706
  let haveExplicitApplication = false;
23493
23707
  if (manifestInputs.length > 0) {
23494
23708
  const result = validateManifestSet({
@@ -23500,10 +23714,7 @@ function runValidation(inputs, options = {}) {
23500
23714
  }
23501
23715
  if (result.hasApplicationArtifact) {
23502
23716
  haveExplicitApplication = true;
23503
- explicitSchema = result.resolvedSchema;
23504
- if (result.resolvedSchemaSource !== void 0 && result.resolvedStateSource !== void 0) {
23505
- explicitStateSource = { manifest: result.resolvedSchemaSource, stateSource: result.resolvedStateSource };
23506
- }
23717
+ explicitSchemas = result.resolvedSchemas;
23507
23718
  }
23508
23719
  }
23509
23720
  const inFiles = /* @__PURE__ */ new Map();
@@ -23513,8 +23724,9 @@ function runValidation(inputs, options = {}) {
23513
23724
  if (!hasAnythingToCheck(input.text, options.bindAttribute ?? "data-wcs", options.stateTagName ?? "wcs-state")) {
23514
23725
  nothingToCheck.push(input.source);
23515
23726
  }
23516
- let applicationSchema = explicitSchema;
23517
- let applicationStateSource = explicitStateSource === void 0 ? void 0 : stateSourceFromPage(input.source, explicitStateSource.manifest, explicitStateSource.stateSource);
23727
+ const explicit = explicitSchemaFor(input, explicitSchemas, options.stateTagName ?? "wcs-state");
23728
+ let applicationSchema = explicit?.schema;
23729
+ let applicationStateSource = explicit?.stateSource;
23518
23730
  if (!haveExplicitApplication && input.fileReader !== void 0) {
23519
23731
  const discovered = discoverApplicationManifest(input.fileReader);
23520
23732
  applicationSchema = discovered?.schema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/lint",
3
- "version": "4.30.0",
3
+ "version": "4.32.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": {