@wcstack/lint 4.21.0 → 4.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ja.md CHANGED
@@ -118,6 +118,18 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
118
118
  - 配列と分からない値(`budgetErrors: {}` と `this.budgetErrors[id] = …`)への `wcs/array-index-assign` は、「配列の添字」ではなくオブジェクトのキーへの代入として言います。
119
119
  - スクリプトがその場で変えるリスト(`this.budgetRows.splice(0, n, ...rows)` — `wcs/array-mutation` が報告する)の行は、リテラルや JSDoc の型からフィールドが読めなければ検査しません。4.20 までは、そうした行のフィールドがどれも `wcs/binding-path-missing` の誤報で、本物の打ち間違いと同じ code でした。
120
120
 
121
+ ## 入力の重いフォームに言うこと
122
+
123
+ 4.23 から、継ぎ目アプリ ekiden-entry — 駅伝の申し込みウィザード。IME・オートフィル・行の中の入力・フォーム連携のカスタム要素と、入力の重いページ — から。そのページで lint は、仕込んだ誤り 21 件に何も言わず、読めない state について偽の warning を 91 件出していました:
124
+
125
+ - **値を読めないキーの下は「分からない」で、「存在しない」ではありません。** `const init = emptyEntry()` の `team: init.team`、`errs: emptyErrs()`、条件式、`[1, 2].map(…)`、`[newRunner()]` の行: そうしたキーの下のパスは検査せず、キーの上の `wcs/path-dynamic-unknown`(info)が 1 回だけそう言います — その下に束ねたパスの数(キーの `for:` の行の `.name` も数えます)と、検査させる方法(キーの JSDoc の `@type` か `stateSchema`)付きで。4.22 までは、そのパスが 1 件ずつ `wcs/binding-path-missing` の誤報で、本物の打ち間違いと同じ code でした。オブジェクトリテラルを束縛する `const` のメンバー(`team: DEFAULTS.team`。モジュールの中のものも import したものも)は読み、その下のパスを検査します。
126
+ - **`wcs/radio-name-shared`**(warning) — `for:` の行の中の、`name` をリテラルで書いた、行の値を束ねたラジオ(`<input type="radio" name="sex" data-wcs="radio: .sex">`)。どの行のラジオも同じ name になるので、ブラウザは全部の行を 1 つのグループにします: ページ全体で 1 つしか選ばれた状態にならず、表示は最初の描画から行ごとの値と食い違います。行ごとに違う name を束ねる(`attr.name: .<行のフィールド>`)か、name を外してください — `radio:` は name が無くても、同じパスに束ねたラジオを選択に合わせます。name を束ねてあるとき、行のものでないパス(`value: .id; radio: selectedId` — 行をまたぐ 1 つの選択)、行ごとに `<form>` があるときは報告しません。
127
+ - **`wcs/number-written-as-string`**(warning) — 書き戻すときに変換しない双方向の `value:` が、state が数値で持つパスを指す: `count: 0` と `<input type="number" data-wcs="value: count">`(JSDoc の `@type {number}`・`stateSchema`・行のフィールド `value: .qty` も)。要素の `value` は文字列なので、5 と入力した後の state は `"5"` で、`count + 1` は `"51"` になります。`valueAsNumber: count` か、左辺の入力フィルタ `value|number: count`(`|int`・`|float`)と書いてください。
128
+ - **`wcs/two-way-output-filter`**(warning) — 双方向の `value:` / `valueAsNumber:` の出力フィルタ(`value: code|upper`・`value: price|locale`)。打つ欄では、フィルタが 1 打鍵ごとに state の値を整形して欄へ書き直します: 入力中の欄が書き換わり(キャレットは末尾へ飛び、IME の変換は途切れます)、state が受け取るのも欄の整形済みの文字です — 出力フィルタは書き戻しで元に戻りません。整形した文字は別の要素に表示する、欄の確定で書き戻して setter で整形する(`value#onchange:`)、または一方向にしてください(`value#ro:`)。確定した値を書き戻す束縛(`#onchange`・`<select>`・スライダー)は、出力を元に戻す入力フィルタが無いときだけ報告します: `value#onchange|number: price|toFixed(2)` は報告しません。要素の書いた文字をそのまま返すフィルタ(`string`・`nullIfEmpty`・`coalesce(…)`・`defaults('')`)も報告しません。
129
+ - **`attr.*` に束ねた boolean**(`wcs/binding-type-expectation`)には、起きることを言います: ランタイムは `String(value)` — `"true"` / `"false"` — を書き、属性を外すのは `null` / `undefined` だけです。その語が属性の値であるもの — ARIA の状態(`attr.aria-invalid: flag|truthy`)・`contenteditable`・`draggable`・`spellcheck` — は、もう報告しません(`"attr.aria-invalid" には文字列型が必要です` は誤報でした)。ネイティブ要素の論理属性(`attr.disabled: flag`)には、`disabled="false"` でも無効のままであることと、代わりに束ねるプロパティ(`disabled: flag`)を言います。ほかの属性(`attr.data-open: flag`)には、文字として書かれて外れないことと、false の間は外す `|defaults(null)`・文字が意図のときの `|string` を言います。
130
+
131
+ 新しい 3 つの規則は warning です: `--strict` では失敗し、`--errors-only` には出ません。
132
+
121
133
  ## 生成 → 検証 → 修正ループでの利用
122
134
 
123
135
  安定した diagnostic code・`source:line:col` range・exit code 契約により、CI のゲートにも AI コード生成フローにもそのまま組み込めます: HTML を生成 → `npx @wcstack/lint --errors-only` → 診断を読んで修正 → exit code `0` になるまで再実行。このゲートが覆うのは `data-wcs` のページです: 出力が `not read:` や `nothing to check:` で終わるときは、そのファイルは検査されていません。
package/README.md CHANGED
@@ -118,6 +118,18 @@ Since 4.21, from the ledger-repair seam app — a maintainer fixing a household-
118
118
  - `wcs/array-index-assign` on a value not known to be an array (`budgetErrors: {}` with `this.budgetErrors[id] = …`) says it assigns an object's key, not "an array index".
119
119
  - The rows of a list the script changes in place (`this.budgetRows.splice(0, n, ...rows)`, reported as `wcs/array-mutation`) are not checked when no literal or JSDoc type gives their fields. Up to 4.20 each such row field was a false `wcs/binding-path-missing`, the same code as a real typo.
120
120
 
121
+ ## What a data-entry form is told
122
+
123
+ Since 4.23, from the ekiden-entry seam app — an entry wizard for a relay race, heavy on input: an IME, autofill, rows of inputs, form-associated custom elements. On its page the lint had said nothing about 21 mistakes made on purpose, and had given 91 false warnings about a state it could not read:
124
+
125
+ - **A key whose value the lint cannot read is unknown, not missing.** `team: init.team` beside `const init = emptyEntry()`, `errs: emptyErrs()`, a conditional, `[1, 2].map(…)`, the rows of `[newRunner()]`: the paths under such a key are not checked, and one `wcs/path-dynamic-unknown` info at the key says so — with the number of paths bound under it (a row's `.name` under the key's `for:` is one) and what has them checked: a JSDoc `@type` on the key, or a `stateSchema`. Up to 4.22 each of those paths was a false `wcs/binding-path-missing`, the same code as a real typo. A member of a `const` bound to an object literal (`team: DEFAULTS.team`, in the module or imported) is read, and the paths under it are checked.
126
+ - **`wcs/radio-name-shared`** (warning) — radios in a `for:` row with a literal `name` and a binding of the row's (`<input type="radio" name="sex" data-wcs="radio: .sex">`). Every row's radios get the same name, so the browser makes one group of all the rows: only one radio on the whole page stays checked, and the page disagrees with the rows' values from the first render. Bind a name that differs per row (`attr.name: .<a row field>`), or drop the name — `radio:` keeps the radios bound to one path in step without it. Not reported when the name is bound, when the bound path is not the row's (`value: .id; radio: selectedId` — one choice over the rows), or when each row holds its own `<form>`.
127
+ - **`wcs/number-written-as-string`** (warning) — a two-way `value:` with no conversion on the way in, bound to a path the state holds as a number: `<input type="number" data-wcs="value: count">` with `count: 0` (a JSDoc `@type {number}`, a `stateSchema` and a row field `value: .qty` count too). An element's `value` is a string, so after the user enters 5 the state has `"5"` and `count + 1` is `"51"`. Write `valueAsNumber: count`, or an input filter on the left side: `value|number: count` (`|int`, `|float`).
128
+ - **`wcs/two-way-output-filter`** (warning) — an output filter on a two-way `value:` / `valueAsNumber:` (`value: code|upper`, `value: price|locale`). In a field the user types in, the filter formats what the state holds on every keystroke: the field is rewritten while the user types — the caret jumps to the end, an IME composition is cut — and the state receives the field's formatted text, since an output filter is not undone on the way back. Show the formatted text in another element, write back when the field is committed and format in a setter (`value#onchange:`), or make the binding one-way (`value#ro:`). A binding that writes back a committed value (`#onchange`, a `<select>`, a slider) is reported only when no input filter undoes the output: `value#onchange|number: price|toFixed(2)` is not. Nor are the filters that give back what the element wrote: `string`, `nullIfEmpty`, `coalesce(…)`, `defaults('')`.
129
+ - **A boolean given to `attr.*`** (`wcs/binding-type-expectation`) is told what happens to it: the runtime writes `String(value)` — `"true"` / `"false"` — and only `null` / `undefined` remove an attribute. Where those words are the attribute's values — the ARIA states (`attr.aria-invalid: flag|truthy`), `contenteditable`, `draggable`, `spellcheck` — nothing is reported any more (it was a false warning: `"attr.aria-invalid" requires a string`). A boolean attribute of a native element (`attr.disabled: flag`) is told that `disabled="false"` still disables, with the property to bind instead (`disabled: flag`). Any other attribute (`attr.data-open: flag`) is told that it is written as the text and never removed, with `|defaults(null)` to remove it while false and `|string` where the text is meant.
130
+
131
+ The three new rules are warnings: `--strict` fails on them, `--errors-only` does not print them.
132
+
121
133
  ## Use in generate–validate–fix loops
122
134
 
123
135
  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
@@ -270,6 +270,14 @@ var WcsDiagnosticCode = {
270
270
  // 元の値を返し、双方向の入力はそこへ戻る — 何も知らせない(4.17 から diagnostics の後付けが警告する)。setter・getter
271
271
  // の読み書きを追えない(`this[key]`・`fn(this)`・知らないメソッド)なら黙る。warning。
272
272
  SetterUnobserved: "wcs/setter-unobserved",
273
+ // 1 つのアクセサを複数のパスに宣言するキー(`get "users.*.full,employees.*.full"()`、4.22)の書き方の誤り:
274
+ // カンマの前後の空白・空の項目・再帰のキー(`**`)。ランタイムはカンマで分けた間をそのままパスにするので、
275
+ // 空白入りのパスは誰も読まないパスになる(diagnostics の後付けは同じコードで初期化を失敗させる)。error。
276
+ AccessorListSyntax: "wcs/accessor-list-syntax",
277
+ // 複数のリストに宣言したアクセサの本体が、そのうち 1 つのリストの行を絶対パス(`this["users.*.first"]`)で
278
+ // 読み書きしている。ほかのリストの行ではそのパスに行が無く、読みは undefined、書きは例外になる。本体は
279
+ // 行からの相対パス(`this[".first"]`)で書く(diagnostics の後付けは同じコードで警告する)。error。
280
+ AccessorListPath: "wcs/accessor-list-path",
273
281
  // `$renderedCallback`(3.x の旧名 `$updatedCallback`)が、どのバインディングにも現れないパスを判定に使っている。
274
282
  // 同コールバックは **binding 駆動**(live binding が適用された path しか報告しない)
275
283
  // なので、その分岐は一度も実行されない。表示要素が購読の実体になる事故
@@ -424,6 +432,25 @@ var WcsDiagnosticCode = {
424
432
  // 置き、文と一緒に挿入される。スクリーンリーダーは読み上げない(読み上げるのは、ページにある間に文が変わったとき)。
425
433
  // 挿入で読み上げられる `role="alert"` は対象外。継ぎ目アプリ city-library(view transition ありの Chromium で 0/10)。warning。
426
434
  LiveRegionInserted: "wcs/live-region-inserted",
435
+ // --- フォームの入力(要素の束縛が、利用者の入力に対して何をするか。service/formInputValidator.ts) ---
436
+ // `for:` の行の中の、`name` をリテラルで書いたラジオ(`<input type="radio" name="sex" data-wcs="radio: .sex">`)。
437
+ // どの行のラジオも同じ name になるので、ブラウザは全部の行を 1 つのグループにする: ページ全体で 1 つしか選ばれた
438
+ // 状態にならず、表示は最初の描画から行ごとの値と食い違う。ランタイムは何も言わない(ブラウザの規則 — 継ぎ目アプリ
439
+ // ekiden-entry)。name を束ねてあるとき(`attr.name:`)・行のものでないパス(`radio: selectedId` — 行をまたぐ 1 つの
440
+ // グループが意図)・行ごとに `<form>` があるときは黙る。warning。
441
+ RadioNameShared: "wcs/radio-name-shared",
442
+ // 書き戻すときに変換しない双方向の `value:` が、state が数値で持つパス(種・JSDoc の `@type`・stateSchema)を指す。
443
+ // 要素の `value` は文字列なので、5 と入力した後の state は `"5"` で、`count + 1` は `"51"` になる。ランタイムは何も
444
+ // 言わない(ekiden-entry — 弁当 1 個と 2 個が 12 個になった)。数値にする入力フィルタ(`value|number:`)・
445
+ // `valueAsNumber:`・`#ro`・アクセサペア(setter が変換しうる)では黙る。warning。
446
+ NumberWrittenAsString: "wcs/number-written-as-string",
447
+ // 双方向の `value:` / `valueAsNumber:` に付けた出力フィルタ(`value: code|upper`・`value: price|locale`)。フィルタは
448
+ // 要素が書き戻すたび(既定では 1 打鍵ごと)に state の値を整形して欄へ書き直す: キャレットは末尾へ飛び、IME の変換は
449
+ // 途切れ、state が受け取るのは整形済みの文字(出力フィルタは書き戻しで元に戻らない)。確定した値を書き戻す束縛
450
+ // (`#onchange`・スライダー・`<select>`)は入力中に書き換わらないので、入力フィルタ(作者が用意した戻り道 —
451
+ // `value#onchange|number: price|toFixed(2)`)が無いときだけ報告する。要素の書いた文字をそのまま返すフィルタ
452
+ // (`string`・`nullIfEmpty`・`coalesce(…)`・`defaults('')`)と `#ro` では黙る。warning。
453
+ TwoWayOutputFilter: "wcs/two-way-output-filter",
427
454
  // --- document-level load configuration ---
428
455
  // @wcstack/state/auto より後に @wcstack/devtools/auto が読まれている。info: 4.0 は後から付いた DevTools に
429
456
  // 既存の束縛を送り直すので、欠けるのは付く前のタイムラインだけ。
@@ -1236,7 +1263,7 @@ var SENTENCES = {
1236
1263
  [
1237
1264
  1402
1238
1265
  /* WildcardRelative */
1239
- ]: (p) => `"${p}" is relative: it needs an enclosing "for" template`,
1266
+ ]: (p) => `"${p}" is relative: it needs an enclosing "for" template (in script, a row: a row accessor, or a method called from a row)`,
1240
1267
  [
1241
1268
  1403
1242
1269
  /* WildcardOtherList */
@@ -1989,7 +2016,7 @@ var config = {
1989
2016
  locale: typeof document !== "undefined" ? document.documentElement?.lang || "en" : "en",
1990
2017
  enableContractAnalyzer: false
1991
2018
  };
1992
- var FEATURE_NAMES = ["formats", "diagnostics", "temporal", "list-keys", "scopes", "recursion", "ssr", "devtools", "native-commands", "release"];
2019
+ var FEATURE_NAMES = ["formats", "diagnostics", "temporal", "list-keys", "scopes", "recursion", "ssr", "devtools", "native-commands", "release", "forms"];
1993
2020
  var NATIVE_COMMANDS = {
1994
2021
  "*": ["focus", "blur", "click", "scrollIntoView", "showPopover", "hidePopover", "togglePopover"],
1995
2022
  "dialog": ["show", "showModal", "close", "requestClose"],
@@ -2556,7 +2583,7 @@ function getWcsManifest() {
2556
2583
  }
2557
2584
 
2558
2585
  // ../state/package.json
2559
- var version = "4.21.0";
2586
+ var version = "4.23.0";
2560
2587
 
2561
2588
  // src/service/wcsManifest.ts
2562
2589
  var ENGINE_VERSION = version;
@@ -9298,6 +9325,13 @@ function analyzeDeclarationSpans(scriptContent) {
9298
9325
  }
9299
9326
  return out;
9300
9327
  }
9328
+ function accessorRow(callable) {
9329
+ if (callable.kind !== "getter") return null;
9330
+ const segments = callable.name.split(".");
9331
+ let last = -1;
9332
+ for (let i = 0; i < segments.length; i++) if (segments[i] === "*" || segments[i] === "**") last = i;
9333
+ return last < 0 ? null : segments.slice(0, last + 1).join(".");
9334
+ }
9301
9335
  function analyzeCallableBodies(scriptContent) {
9302
9336
  const root = locateDefaultExportObject(scriptContent);
9303
9337
  if (!root) return [];
@@ -9312,7 +9346,8 @@ function analyzeCallableBodies(scriptContent) {
9312
9346
  end: root.start + prop.nameEnd,
9313
9347
  body: prop.value ?? "",
9314
9348
  bodyStart: root.start + (prop.valueStart ?? 0),
9315
- accessor: prop.accessor
9349
+ accessor: prop.accessor,
9350
+ ...prop.listed !== void 0 ? { listed: { ...prop.listed, start: root.start + prop.listed.start, end: root.start + prop.listed.end } } : {}
9316
9351
  });
9317
9352
  }
9318
9353
  return out;
@@ -10001,7 +10036,8 @@ function pushDataPropertyPathsAt(path, prop, paths, depth, typedefs, scope) {
10001
10036
  let candidate;
10002
10037
  let unread = null;
10003
10038
  if (followed === null) {
10004
- candidate = { path, kind: "data", typeHint: prop.typeHint, rawInitial: prop.value?.trim() };
10039
+ const opaque2 = prop.value !== void 0 && prop.declaredType === void 0 && isUnreadExpression(prop.value) ? { opaque: unreadExpression(prop.value, scope) } : {};
10040
+ candidate = { path, kind: "data", typeHint: prop.typeHint, rawInitial: prop.value?.trim(), ...opaque2 };
10005
10041
  paths.push(candidate);
10006
10042
  unread = pushLiteralStructurePaths(path, prop, paths, depth, typedefs, scope);
10007
10043
  } else {
@@ -10115,6 +10151,45 @@ function isReadableLiteral(text3) {
10115
10151
  const v = text3.trim();
10116
10152
  return /^[[{"'`]/.test(v) || /^-?\.?\d/.test(v) || WORD_LITERALS.has(v) || /^(?:async\s+)?function\b/.test(v) || /^(?:async\s*)?(?:\([^()]*\)|[$\w]+)\s*=>/.test(v);
10117
10153
  }
10154
+ function isUnreadExpression(value) {
10155
+ const v = value.trim();
10156
+ if (!isReadableLiteral(v)) return true;
10157
+ const open = v[0];
10158
+ if (open !== "[" && open !== "{") return false;
10159
+ const scan = maskCommentsAndStrings(v);
10160
+ const inner = extractDelimitedContent(v, scan, 0, open, open === "[" ? "]" : "}");
10161
+ const rest = scan.slice(inner.length + 2).replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g, " ").trimStart();
10162
+ return /^(?:\?\.|\.|\[|\()/.test(rest);
10163
+ }
10164
+ var MAX_UNREAD_TEXT = 40;
10165
+ function unreadExpression(value, scope) {
10166
+ const flat = value.trim().replace(/^(?:\/\*[\s\S]*?\*\/\s*|\/\/[^\n]*\n\s*)+/, "").replace(/\s+/g, " ");
10167
+ const name = flat.length <= MAX_UNREAD_TEXT ? flat : `${flat.slice(0, MAX_UNREAD_TEXT - 1)}\u2026`;
10168
+ const root = /^(?:\.\.\.|(?:new|await)\s+)*([$A-Za-z_][$\w]*)/.exec(flat)?.[1];
10169
+ const from = root === void 0 || scope === void 0 ? void 0 : scope.importOf(root);
10170
+ return { name, ...from !== void 0 ? { from } : {} };
10171
+ }
10172
+ function firstArrayElement(value) {
10173
+ const trimmed = value.trim();
10174
+ const scan = maskCommentsAndStrings(trimmed).replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g, (c) => " ".repeat(c.length));
10175
+ const element2 = (end) => {
10176
+ const from = 1 + (scan.slice(1, end).length - scan.slice(1, end).trimStart().length);
10177
+ return scan.slice(from, end).trim() === "" ? null : trimmed.slice(from, end).trim();
10178
+ };
10179
+ let depth = 0;
10180
+ for (let i = 1; i < scan.length; i++) {
10181
+ const ch = scan[i];
10182
+ if (ch === "{" || ch === "[" || ch === "(") {
10183
+ depth++;
10184
+ } else if (ch === "}" || ch === "]" || ch === ")") {
10185
+ if (depth === 0) return element2(i);
10186
+ depth--;
10187
+ } else if (ch === "," && depth === 0) {
10188
+ return element2(i);
10189
+ }
10190
+ }
10191
+ return null;
10192
+ }
10118
10193
  function followValue(prop, scope) {
10119
10194
  const type = parseTypeImport(prop.jsdocText);
10120
10195
  let current2;
@@ -10128,12 +10203,20 @@ function followValue(prop, scope) {
10128
10203
  if (prop.value === void 0) return null;
10129
10204
  const written = prop.value.trim();
10130
10205
  const text3 = unwrapFreeze(written);
10131
- if (!isFollowableName(text3, scope)) return text3 === written ? null : { value: { text: text3, scope } };
10132
- name = text3;
10133
- from = scope.importOf(text3);
10134
- const resolved = scope.resolveName(text3);
10135
- if (resolved === null) return { value: null, name, from };
10136
- current2 = resolved;
10206
+ if (!isFollowableName(text3, scope)) {
10207
+ const member = followMember(text3, scope);
10208
+ if (member === void 0) return text3 === written ? null : { value: { text: text3, scope } };
10209
+ name = text3;
10210
+ from = member.from;
10211
+ if (member.value === null) return { value: null, name, from };
10212
+ current2 = member.value;
10213
+ } else {
10214
+ name = text3;
10215
+ from = scope.importOf(text3);
10216
+ const resolved = scope.resolveName(text3);
10217
+ if (resolved === null) return { value: null, name, from };
10218
+ current2 = resolved;
10219
+ }
10137
10220
  }
10138
10221
  for (let hops = 0; hops < 8; hops++) {
10139
10222
  const inner = unwrapFreeze(current2.text);
@@ -10144,6 +10227,38 @@ function followValue(prop, scope) {
10144
10227
  }
10145
10228
  return { value: null, name, from };
10146
10229
  }
10230
+ function followMember(text3, scope) {
10231
+ const m = /^([$A-Za-z_][$\w]*)((?:\s*\.\s*[$A-Za-z_][$\w]*)+)$/.exec(text3);
10232
+ if (m === null || WORD_LITERALS.has(m[1])) return void 0;
10233
+ const root = m[1];
10234
+ let keys = m[2].split(".").map((key) => key.trim()).filter((key) => key !== "");
10235
+ let current2;
10236
+ if (scope.isNamespaceMember(`${root}.${keys[0]}`)) {
10237
+ current2 = scope.resolveName(`${root}.${keys[0]}`);
10238
+ keys = keys.slice(1);
10239
+ } else {
10240
+ current2 = scope.resolveName(root);
10241
+ if (current2 === null) return void 0;
10242
+ }
10243
+ const from = scope.importOf(root);
10244
+ const unread = { value: null, ...from !== void 0 ? { from } : {} };
10245
+ for (const key of keys) {
10246
+ let literal2 = current2;
10247
+ for (let hops = 0; literal2 !== null && hops < MAX_SPREAD_HOPS; hops++) {
10248
+ const inner = unwrapFreeze(literal2.text);
10249
+ if (isObjectLiteral(inner)) {
10250
+ literal2 = { text: inner, scope: literal2.scope };
10251
+ break;
10252
+ }
10253
+ literal2 = isFollowableName(inner, literal2.scope) ? literal2.scope.resolveName(inner) : null;
10254
+ }
10255
+ if (literal2 === null || !isObjectLiteral(literal2.text)) return unread;
10256
+ const found = objectLiteralKeys(extractObjectContent(literal2.text), literal2.scope, true).keys.find((k) => k.prop.name === key);
10257
+ if (found === void 0 || found.prop.value === void 0) return unread;
10258
+ current2 = { text: found.prop.value, scope: found.scope ?? literal2.scope };
10259
+ }
10260
+ return { value: current2, ...from !== void 0 ? { from } : {} };
10261
+ }
10147
10262
  function pushDeclaredShapePaths(path, type, paths, depth, typedefs) {
10148
10263
  const shape = jsDocShape(type, typedefs);
10149
10264
  if (shape.index !== void 0) {
@@ -10171,7 +10286,11 @@ function pushLiteralStructurePaths(path, prop, paths, depth, typedefs, scope) {
10171
10286
  paths.push({ path: `${path}.length`, kind: "data", typeHint: "number" });
10172
10287
  if (depth >= MAX_OBJECT_NEST_DEPTH) return null;
10173
10288
  const first = firstRowObjectContent(prop.value);
10174
- if (first === null) return null;
10289
+ if (first === null) {
10290
+ const element2 = prop.declaredType === void 0 ? firstArrayElement(prop.value) : null;
10291
+ if (element2 !== null && !isReadableLiteral(element2)) row.opaque = unreadExpression(element2, scope);
10292
+ return null;
10293
+ }
10175
10294
  const { keys, unread } = objectLiteralKeys(first, scope, false);
10176
10295
  for (const key of keys) {
10177
10296
  pushDataPropertyPathsAt(`${path}.*.${key.prop.name}`, key.prop, paths, depth + 1, typedefs, key.scope);
@@ -10236,6 +10355,19 @@ function inferJsonTypeHint(value) {
10236
10355
  if (typeof value === "object") return "object";
10237
10356
  return void 0;
10238
10357
  }
10358
+ function listedPaths(key, keyStart) {
10359
+ const out = [];
10360
+ let at2 = 0;
10361
+ for (const part of key.split(",")) {
10362
+ const name = part.trim();
10363
+ if (name !== "") {
10364
+ const start = keyStart + at2 + (part.length - part.trimStart().length);
10365
+ out.push({ name, start, end: start + name.length });
10366
+ }
10367
+ at2 += part.length + 1;
10368
+ }
10369
+ return out;
10370
+ }
10239
10371
  function locateDefaultExportObject(script) {
10240
10372
  const scan = maskCommentsAndStrings(script);
10241
10373
  const match = scan.match(/export\s+default\s+(?:defineState\s*\(\s*)?(\{)/);
@@ -10312,16 +10444,20 @@ function parseTopLevelProperties(objectContent, allowEmptyDataKeys = false) {
10312
10444
  const accessor = match[0].startsWith("set") ? "set" : "get";
10313
10445
  const returnsText = accessor === "get" ? readJsDocReturnsBefore(objectContent, match.index) : void 0;
10314
10446
  const declaredType = returnsText === void 0 ? null : parseJsDocType(returnsText);
10315
- props.push({
10316
- name: accessorName,
10447
+ const entry = {
10317
10448
  kind: "getter",
10318
10449
  accessor,
10319
10450
  value: body,
10320
10451
  valueStart: bodyStart,
10321
- nameStart: nameSpan[0],
10322
- nameEnd: nameSpan[1],
10323
10452
  ...declaredType !== null ? { declaredType } : {}
10324
- });
10453
+ };
10454
+ const paths = accessorName.includes(",") ? listedPaths(accessorName, nameSpan[0]) : [];
10455
+ if (paths.length > 0) {
10456
+ const listed = { paths: paths.map((p) => p.name), key: accessorName, start: nameSpan[0], end: nameSpan[1] };
10457
+ for (const p of paths) props.push({ name: p.name, ...entry, nameStart: p.start, nameEnd: p.end, listed });
10458
+ continue;
10459
+ }
10460
+ props.push({ name: accessorName, ...entry, nameStart: nameSpan[0], nameEnd: nameSpan[1] });
10325
10461
  continue;
10326
10462
  }
10327
10463
  const methodName = nameAt(4) ?? nameAt(5) ?? nameAt(6);
@@ -11147,7 +11283,20 @@ function collectGetterReads(body, options = {}) {
11147
11283
  } finally {
11148
11284
  collecting = {};
11149
11285
  }
11150
- return out;
11286
+ const row = options.row;
11287
+ return row == null ? out : out.map((read) => atRow(read, row));
11288
+ }
11289
+ var underRow = (path, row) => path === "." ? row : row + path;
11290
+ var ROW_APIS = /* @__PURE__ */ new Set(["$getAll", "$dependOn"]);
11291
+ function atRow(read, row) {
11292
+ if (!read.path.startsWith(".") || read.api !== void 0 && !ROW_APIS.has(read.api)) return read;
11293
+ return {
11294
+ ...read,
11295
+ path: underRow(read.path, row),
11296
+ chain: read.chain === null ? null : [underRow(read.chain[0], row), ...read.chain.slice(1)],
11297
+ ...read.indexed !== void 0 ? { indexed: read.indexed.map((list) => underRow(list, row)) } : {},
11298
+ relative: read.path
11299
+ };
11151
11300
  }
11152
11301
  function unwrapWrapper(program) {
11153
11302
  if (program.type !== "Program" || program.body.length !== 1) return null;
@@ -11411,6 +11560,7 @@ function visitCall(node, scope, out) {
11411
11560
  form: TRACK_APIS.has(api) ? "track" : "api",
11412
11561
  callee: false,
11413
11562
  written: false,
11563
+ api,
11414
11564
  ...scope.nested ? { nested: true } : {},
11415
11565
  start: node.start - PREFIX.length,
11416
11566
  end: node.end - PREFIX.length
@@ -11429,6 +11579,7 @@ function visitCall(node, scope, out) {
11429
11579
  form: "api-write",
11430
11580
  callee: false,
11431
11581
  written: false,
11582
+ api,
11432
11583
  ...scope.nested ? { nested: true } : {},
11433
11584
  start: first.start - PREFIX.length,
11434
11585
  end: first.end - PREFIX.length
@@ -11890,6 +12041,11 @@ var ja = {
11890
12041
  setterCycleSelf: (p) => `"${p}" \u306E setter \u304C\u81EA\u5206\u306E\u30D1\u30B9 "${p}" \u306B\u66F8\u3044\u3066\u3044\u307E\u3059\u3002setter \u306E\u30D1\u30B9\u306F\u30A2\u30AF\u30BB\u30B5\u305D\u306E\u3082\u306E\u306A\u306E\u3067\u3001\u66F8\u3051\u3070 setter \u304C\u307E\u305F\u547C\u3070\u308C\u3001\u30B9\u30BF\u30C3\u30AF\u304C\u6EA2\u308C\u308B\u307E\u3067\u7D9A\u304D\u307E\u3059\u3002\u5024\u306F getter \u304C\u8AAD\u3080\u30C7\u30FC\u30BF\u306E\u30D1\u30B9\uFF08_${p.split(".").pop()} \u306A\u3069\uFF09\u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044`,
11891
12042
  setterCycle: (cycle) => `setter \u304C\u4E92\u3044\u306B\u66F8\u304D\u5408\u3063\u3066\u3044\u307E\u3059: ${cycle}\u3002\u6761\u4EF6\u3067\u6B62\u307E\u3089\u306A\u3051\u308C\u3070\u3001\u4E92\u3044\u3092\u547C\u3073\u7D9A\u3051\u3066\u30B9\u30BF\u30C3\u30AF\u304C\u6EA2\u308C\u307E\u3059\u3002\u5024\u306F getter \u304C\u8AAD\u3080\u30C7\u30FC\u30BF\u306E\u30D1\u30B9\u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044`,
11892
12043
  setterUnobserved: (p, w) => `"${p}" \u306E setter \u306F ${w} \u3092\u66F8\u304D\u307E\u3059\u304C\u3001getter "${p}" \u306F\u305D\u306E\u3069\u308C\u3082\u8AAD\u307F\u307E\u305B\u3093\u3002\u66F8\u3044\u305F\u5F8C\u3082 getter \u306F\u5143\u306E\u5024\u3092\u8FD4\u3057\u3001"${p}" \u306B\u675F\u306D\u305F\u53CC\u65B9\u5411\u306E\u5165\u529B\u306F\u305D\u3053\u3078\u623B\u308A\u307E\u3059\u3002getter \u304C\u8AAD\u3080\u5024\u3092\u66F8\u304F\u304B\u3001setter \u304C\u66F8\u304F\u5024\u3092 getter \u3067\u8AAD\u3093\u3067\u304F\u3060\u3055\u3044`,
12044
+ relativePathOf: (r, a) => `\uFF08\u30A2\u30AF\u30BB\u30B5 "${a}" \u306E\u4E2D\u306E "${r}"\uFF09`,
12045
+ relativeNoRow: (r, a) => `"${r}" \u306F\u884C\u304B\u3089\u306E\u76F8\u5BFE\u30D1\u30B9\u3067\u3059\u304C\u3001\u30A2\u30AF\u30BB\u30B5 "${a}" \u306F\u30EA\u30B9\u30C8\u306E\u884C\u306E\u3082\u306E\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF08\u30AD\u30FC\u306B "*" \u304C\u3042\u308A\u307E\u305B\u3093\uFF09\u3002\u884C\u304C\u7121\u3044\u306E\u3067\u3001\u8A55\u4FA1\u306E\u305F\u3073\u306B\u4F8B\u5916\u306B\u306A\u308A\u307E\u3059\uFF08#1402\uFF09\u3002\u30D5\u30EB\u30D1\u30B9\u3067\u66F8\u304F\u304B\u3001\u884C\u306E\u30A2\u30AF\u30BB\u30B5\uFF08get "<\u30EA\u30B9\u30C8>.*.<\u540D\u524D>"()\uFF09\u306B\u3057\u3066\u304F\u3060\u3055\u3044`,
12046
+ relativeApiPath: (r, api) => `"${r}" \u306F\u884C\u304B\u3089\u306E\u76F8\u5BFE\u30D1\u30B9\u3067\u3059\u304C\u3001${api} \u306F\u884C\u3092\u6DFB\u5B57\u306E\u5F15\u6570\u3067\u53D7\u3051\u53D6\u308A\u3001\u547C\u3070\u308C\u305F\u884C\u304B\u3089\u306F\u53D6\u308A\u307E\u305B\u3093\u3002\u76F8\u5BFE\u30D1\u30B9\u306F\u3053\u3053\u3067\u306F\u5C55\u958B\u3055\u308C\u305A\u3001\u547C\u3073\u51FA\u3057\u306F\u4F8B\u5916\u306B\u306A\u308A\u307E\u3059\u3002\u30D5\u30EB\u30D1\u30B9\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF08"<\u30EA\u30B9\u30C8>.*${r === "." ? "" : r}"\uFF09`,
12047
+ accessorListSyntax: (k, why) => `\u30A2\u30AF\u30BB\u30B5\u306E\u30AD\u30FC "${k}" \u306F\u8907\u6570\u306E\u30D1\u30B9\u306E\u4E26\u3073\u3067\u3059\u304C\u3001${why === "space" ? "\u30AB\u30F3\u30DE\u306E\u524D\u5F8C\u306B\u7A7A\u767D\u304C\u3042\u308A\u307E\u3059" : why === "empty" ? "\u7A7A\u306E\u9805\u76EE\u304C\u3042\u308A\u307E\u3059" : '\u518D\u5E30\u306E\u30D1\u30B9\uFF08"**"\uFF09\u306F\u4E26\u3079\u3089\u308C\u307E\u305B\u3093'}\u3002\u30D1\u30B9\u306F\u30AB\u30F3\u30DE\u3060\u3051\u3067\u533A\u5207\u308A\u307E\u3059\uFF08get "users.*.fullname,employees.*.fullname"()\uFF09${why === "recursive" ? "" : "\u3002\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u30AB\u30F3\u30DE\u306E\u9593\u3092\u305D\u306E\u307E\u307E\u30D1\u30B9\u306B\u3059\u308B\u306E\u3067\u3001\u3053\u306E\u307E\u307E\u3067\u306F\u8AB0\u3082\u8AAD\u307E\u306A\u3044\u30D1\u30B9\u304C\u5BA3\u8A00\u3055\u308C\u307E\u3059"}`,
12048
+ accessorListPath: (p, list, other, rel) => `"${p}" \u306F "${list}" \u306E\u884C\u306E\u30D1\u30B9\u3067\u3059\u304C\u3001\u3053\u306E\u30A2\u30AF\u30BB\u30B5\u306F "${other}" \u306B\u3082\u5BA3\u8A00\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u305D\u3061\u3089\u306E\u884C\u3067\u306F\u3053\u306E\u30D1\u30B9\u306B\u884C\u304C\u7121\u304F\u3001\u8AAD\u307F\u306F undefined\u3001\u66F8\u304D\u306F\u4F8B\u5916\u306B\u306A\u308A\u307E\u3059\u3002\u884C\u304B\u3089\u306E\u76F8\u5BFE\u30D1\u30B9\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044: this["${rel}"]`,
11893
12049
  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`,
11894
12050
  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`,
11895
12051
  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`,
@@ -11907,6 +12063,11 @@ var ja = {
11907
12063
  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`,
11908
12064
  handlerFilterNotAllowed: (prop) => `\u30A4\u30D9\u30F3\u30C8\u30CF\u30F3\u30C9\u30E9 "${prop}" \u306B\u30D5\u30A3\u30EB\u30BF\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093`,
11909
12065
  typeExpectation: (label, expected, resultType) => `"${label}" \u306B\u306F${JA_EXPECTED_LABEL[expected]}\u304C\u5FC5\u8981\u3067\u3059\uFF08\u73FE\u5728\u306E\u578B: ${resultType}\uFF09`,
12066
+ 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}`,
12067
+ attrBooleanText: (a, rhs) => `"attr.${a}" \u306B boolean \u3092\u675F\u306D\u3066\u3044\u307E\u3059\u3002attr.* \u306F String(value) \u3092\u66F8\u304F\u306E\u3067\u3001\u5C5E\u6027\u306F "true" \u304B "false" \u306B\u306A\u308A\u3001\u5916\u308C\u308B\u3053\u3068\u306F\u3042\u308A\u307E\u305B\u3093\uFF08\u5916\u3059\u306E\u306F null / undefined \u3060\u3051\uFF09\u3002\u5C5E\u6027\u306E\u6709\u7121\u3092\u898B\u308B\u5074\uFF08CSS \u306E [${a}]\u30FBhasAttribute()\uFF09\u306B\u306F\u3001\u3069\u3061\u3089\u3067\u3082\u5728\u308A\u307E\u3059\u3002false \u306E\u9593\u306F\u5916\u3059\u306A\u3089 attr.${a}: ${rhs}|defaults(null)\u3001\u6587\u5B57\u306E "true" / "false" \u304C\u610F\u56F3\u306A\u3089 attr.${a}: ${rhs}|string \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`,
12068
+ radioNameShared: (name, binding) => `\u884C\u3054\u3068\u306E\u30E9\u30B8\u30AA\u304C\u3059\u3079\u3066 name="${name}" \u306B\u306A\u308B\u306E\u3067\u3001\u30D6\u30E9\u30A6\u30B6\u306F\u5168\u90E8\u306E\u884C\u306E\u30E9\u30B8\u30AA\u3092 1 \u3064\u306E\u30B0\u30EB\u30FC\u30D7\u306B\u3057\u307E\u3059\u3002\u30DA\u30FC\u30B8\u5168\u4F53\u3067 1 \u3064\u3057\u304B\u9078\u3070\u308C\u305F\u72B6\u614B\u306B\u306A\u3089\u305A\u3001\u8868\u793A\u306F\u6700\u521D\u306E\u63CF\u753B\u304B\u3089\u884C\u3054\u3068\u306E\u5024\u3068\u98DF\u3044\u9055\u3044\u307E\u3059\uFF08\u4F55\u3082\u77E5\u3089\u305B\u307E\u305B\u3093\uFF09\u3002${binding === "radio" ? "\u884C\u3054\u3068\u306B\u9055\u3046 name \u3092\u675F\u306D\u308B\uFF08attr.name: .<\u884C\u3054\u3068\u306B\u9055\u3046\u30D5\u30A3\u30FC\u30EB\u30C9>\uFF09\u304B\u3001name \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\uFF08radio: \u306F name \u304C\u7121\u304F\u3066\u3082\u3001\u540C\u3058\u30D1\u30B9\u306B\u675F\u306D\u305F\u30E9\u30B8\u30AA\u3092\u9078\u629E\u306B\u5408\u308F\u305B\u307E\u3059\uFF09" : "\u884C\u3054\u3068\u306B\u9055\u3046 name \u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08attr.name: .<\u884C\u3054\u3068\u306B\u9055\u3046\u30D5\u30A3\u30FC\u30EB\u30C9>\uFF09\u3002\u884C\u3092\u307E\u305F\u3044\u3067 1 \u3064\u3092\u9078\u3070\u305B\u308B\u306A\u3089\u3001\u5168\u90E8\u3092 1 \u3064\u306E\u30D1\u30B9\u306B\u675F\u306D\u307E\u3059\uFF08value: .<\u884C\u306E id>; radio: <\u30D1\u30B9>\uFF09"}`,
12069
+ numberWrittenAsString: (path, left, asNumber) => `"${path}" \u306F state \u3067\u306F\u6570\u5024\u3067\u3059\u304C\u3001value: \u304C\u66F8\u304D\u623B\u3059\u306E\u306F\u8981\u7D20\u306E\u6301\u3064\u6587\u5B57\u5217\u3067\u3059\u30025 \u3068\u5165\u529B\u3057\u305F\u5F8C\u306E state \u306F "5" \u3067\u3001"5" + 1 \u306F "51" \u306B\u306A\u308A\u307E\u3059\uFF08\u4F55\u3082\u77E5\u3089\u305B\u307E\u305B\u3093\uFF09\u3002\u66F8\u304D\u623B\u3059\u3068\u304D\u306B\u6570\u5024\u306B\u3057\u3066\u304F\u3060\u3055\u3044: ${asNumber ? `valueAsNumber: ${path}\u3001\u307E\u305F\u306F` : ""}\u5DE6\u8FBA\u306E\u5165\u529B\u30D5\u30A3\u30EB\u30BF ${left}|number: ${path}\uFF08|int\u30FB|float \u3082\uFF09`,
12070
+ twoWayOutputFilter: (prop, filters, left, rhs, keystroke) => keystroke ? `${prop}: \u306F\u53CC\u65B9\u5411\u3067 1 \u6253\u9375\u3054\u3068\u306B\u66F8\u304D\u623B\u3057\u3001\u51FA\u529B\u30D5\u30A3\u30EB\u30BF "${filters}" \u306F\u305D\u306E\u305F\u3073\u306B state \u306E\u5024\u3092\u6574\u5F62\u3057\u3066\u6B04\u3078\u66F8\u304D\u76F4\u3057\u307E\u3059\u3002\u5165\u529B\u4E2D\u306E\u6B04\u304C\u66F8\u304D\u63DB\u308F\u308A\uFF08\u30AD\u30E3\u30EC\u30C3\u30C8\u306F\u672B\u5C3E\u3078\u98DB\u3073\u3001IME \u306E\u5909\u63DB\u306F\u9014\u5207\u308C\u307E\u3059\uFF09\u3001state \u304C\u53D7\u3051\u53D6\u308B\u306E\u3082\u6B04\u306E\u6574\u5F62\u6E08\u307F\u306E\u6587\u5B57\u3067\u3059\uFF08\u51FA\u529B\u30D5\u30A3\u30EB\u30BF\u306F\u66F8\u304D\u623B\u3057\u3067\u5143\u306B\u623B\u308A\u307E\u305B\u3093\uFF09\u3002\u6574\u5F62\u3057\u305F\u6587\u5B57\u306F\u5225\u306E\u8981\u7D20\u306B\u8868\u793A\u3059\u308B\u3001\u6B04\u306E\u78BA\u5B9A\u3067\u66F8\u304D\u623B\u3057\u3066 setter \u3067\u6574\u5F62\u3059\u308B\uFF08${prop}#onchange:\uFF09\u3001\u307E\u305F\u306F\u4E00\u65B9\u5411\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${prop}#ro: ${rhs}\uFF09` : `${prop}: \u306F\u53CC\u65B9\u5411\u3067\u3059\u304C\u3001\u51FA\u529B\u30D5\u30A3\u30EB\u30BF "${filters}" \u306F\u66F8\u304D\u623B\u3057\u3067\u5143\u306B\u623B\u308A\u307E\u305B\u3093\u3002\u8981\u7D20\u304C\u66F8\u304D\u623B\u3059\u306E\u306F\u8868\u793A\u3057\u3066\u3044\u308B\u6574\u5F62\u6E08\u307F\u306E\u5024\u3067\u3001\u6B21\u306F\u305D\u306E\u5024\u306B\u30D5\u30A3\u30EB\u30BF\u304C\u639B\u304B\u308A\u307E\u3059\u3002\u5DE6\u8FBA\u306E\u5165\u529B\u30D5\u30A3\u30EB\u30BF\u3067\u5143\u306B\u623B\u3059\uFF08${left}|<\u30D5\u30A3\u30EB\u30BF>: \u2026\uFF09\u3001\u6574\u5F62\u3057\u305F\u5024\u306F\u5225\u306E\u8981\u7D20\u306B\u8868\u793A\u3059\u308B\u3001\u307E\u305F\u306F\u4E00\u65B9\u5411\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${prop}#ro: ${rhs}\uFF09`,
11910
12071
  filterUnknown: (n) => `\u30D5\u30A3\u30EB\u30BF "${n}" \u306F\u7D44\u307F\u8FBC\u307F\u30D5\u30A3\u30EB\u30BF\u306B\u5B58\u5728\u3057\u307E\u305B\u3093`,
11911
12072
  filterRemoved: (n, c) => `\u30D5\u30A3\u30EB\u30BF "${n}" \u306F 4.0 \u3067\u5916\u308C\u307E\u3057\u305F\uFF08"${c}" \u306E 3.x \u306E\u65E7\u540D\uFF09\u3002"${c}" \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`,
11912
12073
  substrRemoved: (rewrite) => `\u30D5\u30A3\u30EB\u30BF "substr" \u306F 4.0 \u3067\u5916\u308C\u307E\u3057\u305F\u3002slice(start, start + length) \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044 \u2014 slice \u306E\u7B2C 2 \u5F15\u6570\u306F\u9577\u3055\u3067\u306F\u306A\u304F\u7D42\u308F\u308A\u306E\u4F4D\u7F6E\u3067\u3059${rewrite === null ? "" : `\uFF08\u3053\u3053\u3067\u306F ${rewrite}\uFF09`}`,
@@ -12122,6 +12283,11 @@ var en = {
12122
12283
  setterCycleSelf: (p) => `The setter of "${p}" writes its own path "${p}". A setter's path is the accessor itself: writing it calls the setter again, until the stack overflows. Store the value under a data path the getter reads (such as _${p.split(".").pop()})`,
12123
12284
  setterCycle: (cycle) => `Setters write each other: ${cycle}. Unless a condition stops them, they call each other until the stack overflows. Store the values under data paths the getters read`,
12124
12285
  setterUnobserved: (p, w) => `The setter of "${p}" writes ${w}, none of which the getter "${p}" reads. After a write the getter returns its old value, and a two-way input bound to "${p}" goes back to it. Write what the getter reads, or read what the setter writes in the getter`,
12286
+ relativePathOf: (r, a) => ` ("${r}" in the accessor "${a}")`,
12287
+ relativeNoRow: (r, a) => `"${r}" is relative to a row, but the accessor "${a}" is not one of a list's rows (its key has no "*"). With no row it throws each time it is evaluated (#1402). Write the full path, or make it a row accessor (get "<list>.*.<name>"())`,
12288
+ relativeApiPath: (r, api) => `"${r}" is relative to a row, but ${api} takes its rows from its indexes argument, not from the row it is called at. A relative path is not expanded there, and the call throws. Write the full path ("<list>.*${r === "." ? "" : r}")`,
12289
+ accessorListSyntax: (k, why) => `The accessor key "${k}" lists several paths, but ${why === "space" ? "has a space beside a comma" : why === "empty" ? "has an empty entry" : 'a recursive path ("**") cannot be listed'}. Separate the paths with "," alone (get "users.*.fullname,employees.*.fullname"())${why === "recursive" ? "" : ": the runtime takes what is between the commas as it is, so this declares a path nothing reads"}`,
12290
+ accessorListPath: (p, list, other, rel) => `"${p}" is a path of the rows of "${list}", and this accessor is also declared for "${other}": at its rows that path has no row, so a read gives undefined and a write throws. Write it relative to the row: this["${rel}"]`,
12125
12291
  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`,
12126
12292
  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`,
12127
12293
  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`,
@@ -12139,6 +12305,11 @@ var en = {
12139
12305
  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`,
12140
12306
  handlerFilterNotAllowed: (prop) => `Filters cannot be applied to event handler "${prop}"`,
12141
12307
  typeExpectation: (label, expected, resultType) => `"${label}" requires ${EN_EXPECTED_LABEL[expected]} (current type: ${resultType})`,
12308
+ 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}`,
12309
+ attrBooleanText: (a, rhs) => `"attr.${a}" is given a boolean. attr.* writes String(value), so the attribute is "true" or "false" and is never removed (only null / undefined remove it): whatever tests its presence \u2014 [${a}] in CSS, hasAttribute() \u2014 finds it either way. To remove it while false, write attr.${a}: ${rhs}|defaults(null); if the text "true" / "false" is what is meant, say so: attr.${a}: ${rhs}|string`,
12310
+ radioNameShared: (name, binding) => `Every row's radios get name="${name}", so the browser makes one group of all the rows: only one radio on the whole page stays checked, and the page disagrees with the rows' values from the first render \u2014 nothing says so. ${binding === "radio" ? "Bind a name that differs per row (attr.name: .<a row field>), or drop the name: radio: keeps the radios bound to one path in step without it" : "Bind a name that differs per row (attr.name: .<a row field>) \u2014 or, for one choice over all the rows, bind them all to one path: value: .<the row's id>; radio: <path>"}`,
12311
+ numberWrittenAsString: (path, left, asNumber) => `"${path}" is a number in the state, but value: writes back what the element holds, a string: after the user enters 5 the state has "5", and "5" + 1 is "51" \u2014 nothing says so. Convert it on the way in: ${asNumber ? `valueAsNumber: ${path}, or ` : ""}an input filter on the left side, ${left}|number: ${path} (also |int, |float)`,
12312
+ twoWayOutputFilter: (prop, filters, left, rhs, keystroke) => keystroke ? `${prop}: is two-way and writes back on every keystroke, and the output filter "${filters}" formats what the state holds each time: the field is rewritten while the user types \u2014 the caret jumps to the end, an IME composition is cut \u2014 and what the state receives is the field's formatted text (an output filter is not undone on the way back). Show the formatted text in another element, write back when the field is committed and format in a setter (${prop}#onchange:), or make the binding one-way: ${prop}#ro: ${rhs}` : `${prop}: is two-way, and nothing undoes the output filter "${filters}" on the way back: the element writes back the formatted value it shows, and the filter is then applied to that. Undo it with an input filter on the left side (${left}|<filter>: \u2026), show the formatted value in another element, or make the binding one-way: ${prop}#ro: ${rhs}`,
12142
12313
  filterUnknown: (n) => `Filter "${n}" is not a built-in filter`,
12143
12314
  filterRemoved: (n, c) => `Filter "${n}" was removed in 4.0 (it was the 3.x old name of "${c}") \u2014 write "${c}"`,
12144
12315
  substrRemoved: (rewrite) => `Filter "substr" was removed in 4.0 \u2014 write slice(start, start + length): slice takes the end index, not a length${rewrite === null ? "" : ` (here: ${rewrite})`}`,
@@ -12556,6 +12727,63 @@ function removedFilterMessage(name, args, msgs) {
12556
12727
  return canonical === null ? null : msgs.filterRemoved(name, canonical);
12557
12728
  }
12558
12729
 
12730
+ // src/service/attributeValues.ts
12731
+ var ARIA_TRUE_FALSE = /* @__PURE__ */ new Set([
12732
+ "aria-atomic",
12733
+ "aria-busy",
12734
+ "aria-checked",
12735
+ "aria-current",
12736
+ "aria-disabled",
12737
+ "aria-expanded",
12738
+ "aria-grabbed",
12739
+ "aria-haspopup",
12740
+ "aria-hidden",
12741
+ "aria-invalid",
12742
+ "aria-modal",
12743
+ "aria-multiline",
12744
+ "aria-multiselectable",
12745
+ "aria-pressed",
12746
+ "aria-readonly",
12747
+ "aria-required",
12748
+ "aria-selected"
12749
+ ]);
12750
+ var ENUMERATED_TRUE_FALSE = /* @__PURE__ */ new Set(["contenteditable", "draggable", "spellcheck", "writingsuggestions"]);
12751
+ var BOOLEAN_ATTRIBUTE_PROPERTY = {
12752
+ allowfullscreen: "allowFullscreen",
12753
+ async: "async",
12754
+ autofocus: "autofocus",
12755
+ autoplay: "autoplay",
12756
+ checked: "checked",
12757
+ controls: "controls",
12758
+ default: "default",
12759
+ defer: "defer",
12760
+ disabled: "disabled",
12761
+ formnovalidate: "formNoValidate",
12762
+ hidden: "hidden",
12763
+ inert: "inert",
12764
+ ismap: "isMap",
12765
+ loop: "loop",
12766
+ multiple: "multiple",
12767
+ muted: "muted",
12768
+ nomodule: "noModule",
12769
+ novalidate: "noValidate",
12770
+ open: "open",
12771
+ playsinline: "playsInline",
12772
+ readonly: "readOnly",
12773
+ required: "required",
12774
+ reversed: "reversed",
12775
+ selected: "selected"
12776
+ };
12777
+ function booleanAttributeText(name, tag) {
12778
+ const attribute = name.toLowerCase();
12779
+ if (ARIA_TRUE_FALSE.has(attribute) || ENUMERATED_TRUE_FALSE.has(attribute)) return { kind: "value" };
12780
+ const native = tag !== void 0 && !tag.includes("-");
12781
+ if (native && Object.hasOwn(BOOLEAN_ATTRIBUTE_PROPERTY, attribute)) {
12782
+ return { kind: "presence", property: BOOLEAN_ATTRIBUTE_PROPERTY[attribute] };
12783
+ }
12784
+ return { kind: "text" };
12785
+ }
12786
+
12559
12787
  // src/service/bindingValidator.ts
12560
12788
  var filterMap = new Map(BUILTIN_FILTERS.map((f) => [f.name, f]));
12561
12789
  var DIRECT_MODIFIER = "direct";
@@ -12986,7 +13214,19 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
12986
13214
  const resultType = resolveResultType(typePath, parsed.filters, scopedPaths);
12987
13215
  if (resultType !== null) {
12988
13216
  const typeReq = getExpectedType(parsed.property);
12989
- if (typeReq && resultType !== typeReq.expected) {
13217
+ const attrBoolean = typeReq !== null && propNoMod.startsWith("attr.") && isBooleanType(resultType) ? booleanAttrMessage(propNoMod.slice("attr.".length), attr.tagName, binding, parsed, msgs) : void 0;
13218
+ if (attrBoolean !== void 0) {
13219
+ if (attrBoolean !== null) {
13220
+ const pathStart = bindingStart + binding.indexOf(parsed.path);
13221
+ diagnostics.push({
13222
+ code: WcsDiagnosticCode.BindingTypeExpectation,
13223
+ start: pathStart,
13224
+ end: pathStart + pathTrimmed.length,
13225
+ message: attrBoolean,
13226
+ severity: "warning"
13227
+ });
13228
+ }
13229
+ } else if (typeReq && resultType !== typeReq.expected) {
12990
13230
  const pathOffset = binding.indexOf(parsed.path);
12991
13231
  const pathStart = bindingStart + pathOffset;
12992
13232
  const schemaDefinite = typeReq.expected === "array" && parsed.filters.length === 0 && applicationSchema !== void 0 && scopedPaths.some((p) => p.path === typePath && p.fromSchema === true);
@@ -13067,7 +13307,14 @@ function findAllBindAttributes(html, attrName) {
13067
13307
  const valueEnd = html.indexOf(quote, valueStart);
13068
13308
  if (valueEnd === -1 || valueEnd > tag.end) continue;
13069
13309
  const inputType = tag.tagName === "input" ? extractAttribute(attrsText, "type") ?? void 0 : void 0;
13070
- attrs.push({ value: html.slice(valueStart, valueEnd), valueStart, tagName: tag.tagName, ...inputType !== void 0 ? { inputType } : {} });
13310
+ attrs.push({
13311
+ value: html.slice(valueStart, valueEnd),
13312
+ valueStart,
13313
+ tagName: tag.tagName,
13314
+ ...inputType !== void 0 ? { inputType } : {},
13315
+ attrsStart: tag.start,
13316
+ attrsEnd: tag.end
13317
+ });
13071
13318
  regex.lastIndex = valueEnd - tag.start;
13072
13319
  }
13073
13320
  }
@@ -13248,6 +13495,18 @@ function getExpectedType(property) {
13248
13495
  }
13249
13496
  return null;
13250
13497
  }
13498
+ function isBooleanType(type) {
13499
+ const parts = type.split("|");
13500
+ return parts.includes("boolean") && parts.every((part) => part === "boolean" || part === "null");
13501
+ }
13502
+ function booleanAttrMessage(name, tag, binding, parsed, msgs) {
13503
+ const last = parsed.filters[parsed.filters.length - 1];
13504
+ if (last !== void 0 && last.name === "defaults" && last.args.length === 1 && last.args[0] === "null") return null;
13505
+ const written = booleanAttributeText(name, tag);
13506
+ if (written.kind === "value") return null;
13507
+ const rhs = binding.slice(indexOfOutsideQuotes2(binding, ":") + 1).trim();
13508
+ return written.kind === "presence" ? msgs.attrBooleanPresence(name, written.property, rhs) : msgs.attrBooleanText(name, rhs);
13509
+ }
13251
13510
  function validateFilterChainTypes(path, filters, statePaths, bindingStart, msgs) {
13252
13511
  const diagnostics = [];
13253
13512
  const pathInfo = statePaths.find((p) => p.path === path);
@@ -15911,7 +16170,7 @@ function collectGetterReadsByName(html, stateTagName) {
15911
16170
  const prefix = block.mountPath === null || block.mountPath === "" ? "" : `${block.mountPath}.`;
15912
16171
  for (const callable of analyzeCallableBodies(block.content)) {
15913
16172
  if (callable.kind !== "getter" || callable.accessor === "set") continue;
15914
- const reads = collectGetterReads(callable.body) ?? [];
16173
+ const reads = collectGetterReads(callable.body, { row: accessorRow(callable) }) ?? [];
15915
16174
  out.set(prefix + callable.name, reads.map((r) => prefix + r.path));
15916
16175
  }
15917
16176
  }
@@ -15995,6 +16254,187 @@ function closingTagStart(html, from, name) {
15995
16254
  return html.length;
15996
16255
  }
15997
16256
 
16257
+ // src/service/formInputValidator.ts
16258
+ var filterMap2 = new Map(BUILTIN_FILTERS.map((f) => [f.name, f]));
16259
+ var NOT_ENTERED = /* @__PURE__ */ new Set(["checkbox", "radio", "hidden", "button", "submit", "reset", "image", "file"]);
16260
+ var NOT_TYPED = /* @__PURE__ */ new Set(["range", "color", "date", "datetime-local", "month", "week", "time"]);
16261
+ var AS_NUMBER = /* @__PURE__ */ new Set(["number", "range", "date", "datetime-local", "month", "week", "time"]);
16262
+ function validateFormInputs(html, bindAttribute = "data-wcs", stateTagName = "wcs-state", locale2, fileReader, applicationSchema) {
16263
+ const attrs = findAllBindAttributes(html, bindAttribute).filter((attr) => attr.tagName === "input" || attr.tagName === "textarea" || attr.tagName === "select");
16264
+ if (attrs.length === 0) return [];
16265
+ const msgs = getMessages(locale2);
16266
+ const out = [];
16267
+ let types2 = null;
16268
+ const getTypes = () => {
16269
+ if (types2 === null) {
16270
+ const index = getStatePathIndex(html, stateTagName, fileReader);
16271
+ const candidates = mergeSchemaCandidates(index.paths, applicationSchema);
16272
+ const set = new Set(candidates.map((p) => p.path));
16273
+ types2 = {
16274
+ candidates,
16275
+ has: (path) => set.has(path),
16276
+ computed: new Set(index.paths.filter((p) => p.kind === "computed").map((p) => p.path))
16277
+ };
16278
+ }
16279
+ return types2;
16280
+ };
16281
+ const saidRadio = /* @__PURE__ */ new Set();
16282
+ for (const attr of attrs) {
16283
+ const bindings = splitBindingExpressions(attr.value);
16284
+ const parsed = bindings.map(parseBindingExpression);
16285
+ const type = (attr.inputType ?? "text").toLowerCase();
16286
+ if (attr.tagName === "input" && type === "radio") {
16287
+ const shared = sharedRadioName(html, attr, parsed, bindAttribute);
16288
+ if (shared !== null && !saidRadio.has(shared.key)) {
16289
+ saidRadio.add(shared.key);
16290
+ out.push({
16291
+ code: WcsDiagnosticCode.RadioNameShared,
16292
+ start: shared.start,
16293
+ end: shared.end,
16294
+ message: msgs.radioNameShared(shared.name, shared.binding),
16295
+ severity: "warning"
16296
+ });
16297
+ }
16298
+ continue;
16299
+ }
16300
+ if (attr.tagName === "input" && NOT_ENTERED.has(type)) continue;
16301
+ const typed = attr.tagName === "textarea" || attr.tagName === "input" && !NOT_TYPED.has(type);
16302
+ let pos = 0;
16303
+ for (let i = 0; i < bindings.length; i++) {
16304
+ const binding = bindings[i];
16305
+ const bindingStart = attr.valueStart + pos;
16306
+ pos += binding.length + 1;
16307
+ const p = parsed[i];
16308
+ if (p.path === null) continue;
16309
+ const name = propertyName(p.property);
16310
+ if (name !== "value" && name !== "valueAsNumber") continue;
16311
+ if (!writesBack(attr, name, p.property)) continue;
16312
+ const path = p.path.trim();
16313
+ const colon = indexOfOutsideQuotes2(binding, ":");
16314
+ const left = binding.slice(0, colon).trim();
16315
+ const rhs = binding.slice(colon + 1).trim();
16316
+ const harmful = p.filters.find((filter) => !givesBackWhatWasWritten(filter, p));
16317
+ const keystroke = typed && writeBackEvent(p.property) === "input";
16318
+ if (harmful !== void 0 && (keystroke || p.inputFilters.length === 0)) {
16319
+ if (p.filters.some((filter) => !filterMap2.has(filter.name))) continue;
16320
+ out.push({
16321
+ code: WcsDiagnosticCode.TwoWayOutputFilter,
16322
+ start: bindingStart + harmful.offset,
16323
+ end: bindingStart + harmful.offset + harmful.name.length,
16324
+ message: msgs.twoWayOutputFilter(name, `|${binding.slice(p.filters[0].offset).trim()}`, left, rhs, keystroke),
16325
+ severity: "warning"
16326
+ });
16327
+ continue;
16328
+ }
16329
+ if (name !== "value" || inputGivesNumber(p) !== false) continue;
16330
+ const statePath = expandRowPath(path, html, attr.valueStart, bindAttribute);
16331
+ if (statePath === null) continue;
16332
+ const t = getTypes();
16333
+ const key = candidateKeyOf(statePath, t.has);
16334
+ const candidate = t.candidates.find((c) => c.path === key);
16335
+ if (candidate === void 0 || candidate.kind !== "data" || t.computed.has(key) || !isNumberType(candidate.typeHint)) continue;
16336
+ const pathStart = bindingStart + binding.indexOf(p.path, colon + 1);
16337
+ out.push({
16338
+ code: WcsDiagnosticCode.NumberWrittenAsString,
16339
+ start: pathStart,
16340
+ end: pathStart + path.length,
16341
+ message: msgs.numberWrittenAsString(path, left, attr.tagName === "input" && AS_NUMBER.has(type)) + (path.startsWith(".") ? msgs.expansionSuffix(statePath) : ""),
16342
+ severity: "warning",
16343
+ statePath
16344
+ });
16345
+ }
16346
+ }
16347
+ return out;
16348
+ }
16349
+ function propertyName(property) {
16350
+ const name = property.replace(/#.*$/, "").trim();
16351
+ return name.startsWith(".") ? name.slice(1) : name;
16352
+ }
16353
+ function writeBackEvent(property) {
16354
+ const hash = property.indexOf("#");
16355
+ if (hash === -1) return "input";
16356
+ const named = property.slice(hash + 1).split(",").map((m) => m.trim()).find((m) => /^on\w+$/.test(m));
16357
+ return named === void 0 ? "input" : named.slice(2);
16358
+ }
16359
+ function isNumberType(typeHint) {
16360
+ if (typeHint === void 0) return false;
16361
+ const parts = typeHint.split("|");
16362
+ return parts.includes("number") && parts.every((part) => part === "number" || part === "null");
16363
+ }
16364
+ function inputGivesNumber(p) {
16365
+ let current2 = "string";
16366
+ for (const filter of p.inputFilters) {
16367
+ const info = filterMap2.get(filter.name);
16368
+ if (info === void 0) return null;
16369
+ if (info.resultType !== "passthrough") current2 = info.resultType;
16370
+ }
16371
+ return current2 === "number";
16372
+ }
16373
+ function isEmptyArgument(args) {
16374
+ return args.length === 1 && (args[0] === "" || args[0] === "''" || args[0] === '""');
16375
+ }
16376
+ function givesBackWhatWasWritten(filter, p) {
16377
+ switch (filter.name) {
16378
+ case "string":
16379
+ case "nullIfEmpty":
16380
+ return true;
16381
+ case "coalesce":
16382
+ return isEmptyArgument(filter.args) || !p.inputFilters.some((input) => input.name === "nullIfEmpty");
16383
+ case "defaults":
16384
+ return isEmptyArgument(filter.args);
16385
+ default:
16386
+ return false;
16387
+ }
16388
+ }
16389
+ function expandRowPath(path, html, offset2, bindAttribute) {
16390
+ if (!path.startsWith(".")) return path;
16391
+ if (getRowShorthandForPath(html, offset2, bindAttribute) === null) return null;
16392
+ const list = getResolvedForListPath(html, offset2, bindAttribute);
16393
+ if (list === null || list.startsWith(".")) return null;
16394
+ return path === "." ? `${list}.*` : `${list}.*.${path.slice(1)}`;
16395
+ }
16396
+ function writtenAttributes(html, from, to) {
16397
+ const out = [];
16398
+ const attribute = /([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>`=]+)))?/g;
16399
+ const text3 = html.slice(from, to);
16400
+ let match;
16401
+ while ((match = attribute.exec(text3)) !== null) {
16402
+ out.push({
16403
+ name: match[1].toLowerCase(),
16404
+ value: match[2] ?? match[3] ?? match[4] ?? null,
16405
+ start: from + match.index,
16406
+ end: from + match.index + match[0].length
16407
+ });
16408
+ }
16409
+ return out;
16410
+ }
16411
+ function sharedRadioName(html, attr, parsed, bindAttribute) {
16412
+ if (attr.attrsStart === void 0 || attr.attrsEnd === void 0) return null;
16413
+ const names2 = parsed.map((p) => propertyName(p.property));
16414
+ if (names2.includes("attr.name") || names2.includes("name")) return null;
16415
+ const at2 = names2.findIndex((name) => name === "radio" || name === "checked");
16416
+ if (at2 === -1) return null;
16417
+ const path = parsed[at2].path?.trim() ?? "";
16418
+ const wildcards = countWildcardSegments(path);
16419
+ if (!path.startsWith(".") && wildcards === 0) return null;
16420
+ const literal2 = writtenAttributes(html, attr.attrsStart, attr.attrsEnd).find((a) => a.name === "name");
16421
+ if (literal2 === void 0 || literal2.value === null || literal2.value.trim() === "") return null;
16422
+ const fors = getEnclosingFors(html, attr.valueStart, bindAttribute);
16423
+ if (fors.length === 0) return null;
16424
+ const level = path.startsWith(".") || wildcards > fors.length ? fors.length - 1 : wildcards - 1;
16425
+ const loop = fors[level];
16426
+ const row = html.slice(loop.anchor, attr.attrsStart).toLowerCase();
16427
+ const form = row.lastIndexOf("<form");
16428
+ if (form !== -1 && /^<form[\s>]/.test(row.slice(form)) && row.indexOf("</form", form) === -1) return null;
16429
+ return {
16430
+ name: literal2.value,
16431
+ binding: names2[at2],
16432
+ start: literal2.start,
16433
+ end: literal2.end,
16434
+ key: `${loop.anchor}\0${literal2.value}`
16435
+ };
16436
+ }
16437
+
15998
16438
  // src/service/documentEnvValidator.ts
15999
16439
  function validateDocumentEnv(html, locale2) {
16000
16440
  const diagnostics = [];
@@ -17956,6 +18396,7 @@ function validateIndexArity(script, scriptStart, locale2) {
17956
18396
  if (parsed.args.length < 2) continue;
17957
18397
  const path = literalString2(parsed.args[0]);
17958
18398
  if (path === null) continue;
18399
+ if (path.startsWith(".")) continue;
17959
18400
  if (hasRecursionWildcard(path)) continue;
17960
18401
  const actual = literalArrayLength(parsed.args[1]);
17961
18402
  if (actual === null) continue;
@@ -17984,7 +18425,7 @@ function validateGetterCycles(script, scriptStart, locale2) {
17984
18425
  for (const getter of getters) {
17985
18426
  if (getter.accessor === "set") continue;
17986
18427
  const targets = /* @__PURE__ */ new Set();
17987
- for (const read of collectGetterReads(getter.body) ?? []) {
18428
+ for (const read of collectGetterReads(getter.body, { row: accessorRow(getter) }) ?? []) {
17988
18429
  if (declared.has(read.path)) targets.add(read.path);
17989
18430
  }
17990
18431
  edges.set(getter.name, [...targets]);
@@ -18689,8 +19130,8 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
18689
19130
  const spans = opaque2.length === 0 ? [] : analyzeDeclarationSpans(block.content);
18690
19131
  for (const candidate of opaque2) {
18691
19132
  const path = prefix + candidate.path;
18692
- bound ??= buildReferenceIndex(html, { bindAttribute, stateTagName }).occurrences.filter((o) => o.kind === "path").map((o) => hasIndexSegment(o.path) ? toWildcardForm(o.path) : o.path);
18693
- const count = bound.filter((b) => b.startsWith(`${path}.`)).length;
19133
+ bound ??= buildReferenceIndex(html, { bindAttribute, stateTagName }).occurrences.filter((o) => o.kind === "path").map((o) => rowPathOf(o.path, html, o.pathRange.start, bindAttribute)).map((path2) => hasIndexSegment(path2) ? toWildcardForm(path2) : path2);
19134
+ const count = bound.filter((b) => b.startsWith(`${path}.`) && !pathExistsInCandidates(b, candidates, candidateSet)).length;
18694
19135
  const span = spans.find((s) => candidate.path === s.name || candidate.path.startsWith(`${s.name}.`));
18695
19136
  if (count === 0 || span === void 0) continue;
18696
19137
  out.push({
@@ -18702,8 +19143,9 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
18702
19143
  });
18703
19144
  }
18704
19145
  }
19146
+ const saidInListed = /* @__PURE__ */ new Set();
18705
19147
  for (const callable of analyzeCallableBodies(block.content)) {
18706
- for (const read of collectGetterReads(callable.body, { templates: true, writes: true }) ?? []) {
19148
+ for (const read of collectGetterReads(callable.body, { templates: true, writes: true, row: accessorRow(callable) }) ?? []) {
18707
19149
  const write = read.written || read.form === "write" || read.form === "api-write";
18708
19150
  if (write && read.form !== "api-write" && !read.path.includes(".")) continue;
18709
19151
  if (read.path.split(".").some((s) => s === "" || s.startsWith("$")) || hasRecursionWildcard(read.path)) continue;
@@ -18716,12 +19158,17 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
18716
19158
  const said = suggestion(near.segment, near.names, msgs);
18717
19159
  if (said === "") continue;
18718
19160
  const at2 = block.contentStart + callable.bodyStart;
19161
+ if (callable.listed !== void 0) {
19162
+ const place = `${write}:${at2 + read.start}`;
19163
+ if (saidInListed.has(place)) continue;
19164
+ saidInListed.add(place);
19165
+ }
18719
19166
  const member = read.form === "member" || read.form === "write";
18720
19167
  out.push({
18721
19168
  code: write ? WcsDiagnosticCode.WritePathMissing : WcsDiagnosticCode.ReadPathMissing,
18722
19169
  start: at2 + read.start,
18723
19170
  end: member ? at2 + read.start + statePart(callable.body.slice(read.start, read.end)) : at2 + read.end,
18724
- message: (write ? msgs.nestedWritePathMissing(read.path) : msgs.readPathMissing(read.path, !read.path.includes("."))) + said,
19171
+ message: (write ? msgs.nestedWritePathMissing(read.path) : msgs.readPathMissing(read.path, !read.path.includes("."))) + (read.relative === void 0 ? "" : msgs.relativePathOf(read.relative, callable.name)) + said,
18725
19172
  // a stateSchema says the path is not there, as for a binding's `wcs/path-nonexistent` (a write stays a
18726
19173
  // warning, as the top-level one: a key the state adds on purpose is not a mistake)
18727
19174
  severity: !write && applicationSchema !== void 0 ? "error" : "warning"
@@ -18731,6 +19178,12 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
18731
19178
  }
18732
19179
  return out;
18733
19180
  }
19181
+ function rowPathOf(path, html, offset2, bindAttribute) {
19182
+ if (!path.startsWith(".")) return path;
19183
+ const list = getResolvedForListPath(html, offset2, bindAttribute);
19184
+ if (list === null || list.startsWith(".")) return path;
19185
+ return path === "." ? `${list}.*` : `${list}.*.${path.slice(1)}`;
19186
+ }
18734
19187
  function isList(path, candidates, candidateSet) {
18735
19188
  return candidateSet.has(`${path}.*`) || candidates.some((c) => c.path === path && c.kind === "list");
18736
19189
  }
@@ -18745,7 +19198,7 @@ function isWrite(read) {
18745
19198
  return read.form === "write" || read.form === "api-write" || read.written && read.form !== "opaque";
18746
19199
  }
18747
19200
  function bodyOf(callable) {
18748
- const found = collectGetterReads(callable.body, OPTIONS);
19201
+ const found = collectGetterReads(callable.body, { ...OPTIONS, row: accessorRow(callable) });
18749
19202
  if (found === null) return { callable, writes: [], reads: [], calls: [], opaque: true };
18750
19203
  const writes = [];
18751
19204
  const reads = [];
@@ -18753,7 +19206,7 @@ function bodyOf(callable) {
18753
19206
  let opaque2 = false;
18754
19207
  for (const read of found) {
18755
19208
  const at2 = { start: callable.bodyStart + read.start, end: callable.bodyStart + read.end, nested: read.nested === true };
18756
- if (read.form === "opaque") {
19209
+ if (read.form === "opaque" || read.path.startsWith(".")) {
18757
19210
  opaque2 = true;
18758
19211
  continue;
18759
19212
  }
@@ -18857,6 +19310,8 @@ function validateScriptWrites(html, stateTagName = "wcs-state", locale2) {
18857
19310
  function getterWrites(state, msgs, at2) {
18858
19311
  const out = [];
18859
19312
  for (const [name, getter] of state.getters) {
19313
+ const listed = getter.callable.listed;
19314
+ if (listed !== void 0 && listed.paths[0] !== name) continue;
18860
19315
  for (const w of getter.writes) {
18861
19316
  if (w.state !== true || w.nested) continue;
18862
19317
  out.push({ code: WcsDiagnosticCode.GetterWrite, ...at2(w.start, w.end), message: msgs.getterWrite(w.path, name), severity: "error" });
@@ -18876,9 +19331,12 @@ function readonlyWrites(state, msgs, at2) {
18876
19331
  if (readonly.size === 0) return [];
18877
19332
  const out = [];
18878
19333
  for (const body of [...state.methods.values(), ...state.setters.values()]) {
19334
+ const listed = body.callable.listed;
19335
+ const again = listed !== void 0 && listed.paths[0] !== body.callable.name;
18879
19336
  for (const w of body.writes) {
18880
19337
  const path = toWildcardForm(w.path);
18881
19338
  if (w.state !== true || hasRecursionWildcard(path) || !readonly.has(path)) continue;
19339
+ if (again && out.some((d) => d.start === at2(w.start, w.end).start)) continue;
18882
19340
  out.push({ code: WcsDiagnosticCode.PathReadonly, ...at2(w.start, w.end), message: msgs.pathReadonlyWrite(path), severity: "error" });
18883
19341
  }
18884
19342
  }
@@ -18937,6 +19395,84 @@ function unobservedSetters(state, msgs, at2) {
18937
19395
  return out;
18938
19396
  }
18939
19397
 
19398
+ // src/service/accessorListValidator.ts
19399
+ var OPTIONS2 = { templates: true, writes: true, resolveWrites: true, untracked: true };
19400
+ var INDEXED_APIS = /* @__PURE__ */ new Set(["$resolve", "$setAll", "$update"]);
19401
+ function rowOfPath(path) {
19402
+ const at2 = path.lastIndexOf("*");
19403
+ return at2 < 0 ? null : path.slice(0, at2 + 1);
19404
+ }
19405
+ function hasRow(row, needed) {
19406
+ return row !== null && (row === needed || row.startsWith(`${needed}.`));
19407
+ }
19408
+ function validateAccessorLists(html, stateTagName = "wcs-state", locale2) {
19409
+ const blocks = parseLoadedScriptBlocks(html, stateTagName).filter((block) => hasDefaultExportObject(block.content));
19410
+ if (blocks.length === 0) return [];
19411
+ const msgs = getMessages(locale2);
19412
+ const out = [];
19413
+ for (const block of blocks) {
19414
+ const at2 = (start, end) => ({ start: block.contentStart + start, end: block.contentStart + end });
19415
+ const keys = /* @__PURE__ */ new Set();
19416
+ for (const callable of analyzeCallableBodies(block.content)) {
19417
+ const listed = callable.listed;
19418
+ if (listed !== void 0 && !keys.has(listed.start)) {
19419
+ keys.add(listed.start);
19420
+ const why = listSyntax(listed.key, listed.paths);
19421
+ if (why !== null) {
19422
+ out.push({
19423
+ code: WcsDiagnosticCode.AccessorListSyntax,
19424
+ ...at2(listed.start, listed.end),
19425
+ message: msgs.accessorListSyntax(listed.key, why),
19426
+ severity: "error"
19427
+ });
19428
+ }
19429
+ }
19430
+ if (listed !== void 0 && listed.paths[0] !== callable.name) continue;
19431
+ const reads = collectGetterReads(callable.body, OPTIONS2);
19432
+ if (reads === null) continue;
19433
+ const rows = (listed?.paths ?? [callable.name]).map((name) => accessorRow({ name, kind: callable.kind }));
19434
+ for (const read of reads) {
19435
+ if (read.form === "opaque") continue;
19436
+ const place = at2(callable.bodyStart + read.start, callable.bodyStart + read.end);
19437
+ if (read.path.startsWith(".") && read.api !== void 0 && INDEXED_APIS.has(read.api)) {
19438
+ out.push({ code: WcsDiagnosticCode.WildcardRank, ...place, message: msgs.relativeApiPath(read.path, read.api), severity: "error" });
19439
+ continue;
19440
+ }
19441
+ if (callable.kind !== "getter" || read.nested === true) continue;
19442
+ if (read.path.startsWith(".")) {
19443
+ if (rows.every((row) => row === null)) {
19444
+ out.push({ code: WcsDiagnosticCode.WildcardRank, ...place, message: msgs.relativeNoRow(read.path, describe(callable)), severity: "error" });
19445
+ }
19446
+ continue;
19447
+ }
19448
+ if (listed === void 0 || read.form === "api" || read.form === "api-write" || read.form === "track") continue;
19449
+ if (hasRecursionWildcard(read.path)) continue;
19450
+ const needed = rowOfPath(read.path);
19451
+ if (needed === null) continue;
19452
+ const home = rows.findIndex((row) => hasRow(row, needed));
19453
+ const away = rows.findIndex((row) => !hasRow(row, needed));
19454
+ if (home < 0 || away < 0) continue;
19455
+ const rest = read.path.slice(rows[home].length);
19456
+ out.push({
19457
+ code: WcsDiagnosticCode.AccessorListPath,
19458
+ ...place,
19459
+ message: msgs.accessorListPath(read.path, needed.slice(0, -2), listed.paths[away], rest === "" ? "." : rest),
19460
+ severity: "error"
19461
+ });
19462
+ }
19463
+ }
19464
+ }
19465
+ return out;
19466
+ }
19467
+ function listSyntax(key, paths) {
19468
+ if (/\s/.test(key)) return "space";
19469
+ if (key.split(",").some((part) => part === "")) return "empty";
19470
+ return paths.some(hasRecursionWildcard) ? "recursive" : null;
19471
+ }
19472
+ function describe(callable) {
19473
+ return callable.listed?.key ?? callable.name;
19474
+ }
19475
+
18940
19476
  // src/service/moduleTopReadValidator.ts
18941
19477
  var GUARD_TAG = "wcs-guard-handler";
18942
19478
  var STORAGES = /* @__PURE__ */ new Set(["localStorage", "sessionStorage"]);
@@ -19011,7 +19547,7 @@ function findTopLevelReads(source) {
19011
19547
  }
19012
19548
  function readOf(node, assigned, source) {
19013
19549
  const object = node.object;
19014
- const prop = propertyName(node);
19550
+ const prop = propertyName2(node);
19015
19551
  if (isGlobal(object, STORAGES)) {
19016
19552
  if (assigned || prop !== null && STORAGE_WRITES.has(prop)) return null;
19017
19553
  return { start: node.start, end: node.end, text: source.slice(node.start, node.end) };
@@ -19027,7 +19563,7 @@ function isGlobal(node, names2) {
19027
19563
  const object = node.object;
19028
19564
  return object.type === "Identifier" && GLOBALS.has(object.name) && node.property.type === "Identifier" && names2.has(node.property.name);
19029
19565
  }
19030
- function propertyName(node) {
19566
+ function propertyName2(node) {
19031
19567
  if (!node.computed) return node.property.type === "Identifier" ? node.property.name : null;
19032
19568
  return node.property.type === "Literal" && typeof node.property.value === "string" ? node.property.value : null;
19033
19569
  }
@@ -19629,12 +20165,14 @@ function validateText(text3, options, applicationSchema) {
19629
20165
  out.push(...validateIoNodes(text3, bindAttribute, stateTagName, locale2, fileReader));
19630
20166
  out.push(...validateAriaAttributes(text3, bindAttribute, locale2));
19631
20167
  out.push(...validateLiveRegions(text3, bindAttribute, stateTagName, locale2));
20168
+ out.push(...validateFormInputs(text3, bindAttribute, stateTagName, locale2, fileReader, applicationSchema));
19632
20169
  out.push(...validateDocumentEnv(text3, locale2));
19633
20170
  out.push(...validatePackageLoads(text3, locale2, fileReader));
19634
20171
  out.push(...validateSemantics(text3, stateTagName, locale2, bindAttribute));
19635
20172
  out.push(...validateScriptStateUses(text3, stateTagName, locale2, bindAttribute));
19636
20173
  out.push(...validateScriptReads(text3, stateTagName, locale2, fileReader, applicationSchema, bindAttribute));
19637
20174
  out.push(...validateScriptWrites(text3, stateTagName, locale2));
20175
+ out.push(...validateAccessorLists(text3, stateTagName, locale2));
19638
20176
  out.push(...validateArrayMutations(text3, stateTagName, locale2));
19639
20177
  out.push(...validateModuleTopReads(text3, stateTagName, locale2));
19640
20178
  out.push(...validateWatchDeclarations(text3, stateTagName, locale2, fileReader));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/lint",
3
- "version": "4.21.0",
3
+ "version": "4.23.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": {