@wcstack/lint 4.15.0 → 4.17.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 +2 -2
- package/README.md +2 -2
- package/dist/cli.cjs +411 -52
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -23,7 +23,7 @@ npx wcs-validate --errors-only src/**/*.html
|
|
|
23
23
|
|
|
24
24
|
`.manifest.json` で終わるファイルは sidecar manifest として、それ以外は `data-wcs` バインディングを含む HTML として検査されます。ただし framework のコンポーネントと script のファイル(`.js`・`.ts`・`.jsx`・`.tsx`・`.vue`・`.svelte`)は読みません(4.6 から。以前は HTML として読み、問題なしと報告していました)。
|
|
25
25
|
|
|
26
|
-
`<wcs-state src="...">` で参照される外部 state(`.json` / `.js` / `.ts`)は HTML ファイルからの相対パスで解決され、パス検証の対象になります。URL は読み込まず、/ から始まるパスは `--root`(下記)のときだけ読み、読めないファイルはスキップされ、解決できないパスは warning のままです。なお外部 state が**解決できた**ページには通常の検証面が全て適用されるため、error severity の検出(例: 配列でない値への `for:`)が「これまでパス未解決で沈黙していたビルド」を新たに落とすことがあります。4.4 から、`.js` / `.ts` の state にはスクリプトの規則(`wcs/nested-assign`・`wcs/array-mutation`・`wcs/on-handler-this`・`wcs/updated-callback-unbound` など)もかかります: ファイルの中の指摘はそのファイルで報告し(`state.js:12:5 error wcs/nested-assign …`)、何ページから読まれても 1 回だけ数え、IDE はページの `src` の値の上に出します。4.3 までは、外部 state ではパスだけを検査していました。4.10 から、名前で書いたキー — 短縮プロパティ(`export default { lang, t }`。`examples/router-i18n` の辞書のボリューム `<wcs-state mount="i18n" src="./i18n/state.js">`)や `items: ITEMS` — は、その名前が束縛する値の形を持ちます: モジュールの `const` か、相対パスからの import(import するファイルからの相対で読み、再 export の先も辿ります)。4.9 までは短縮プロパティのキーをまったく読まなかったので、`i18n.t.*` の束縛はすべて `wcs/binding-path-missing` の誤報でした。値を計算する名前(実行時にロケールの辞書を合わせた辞書)や辿れない名前(素の指定子・URL・無いファイル)のキーは、その下のパスを検査せず、ページがその下を束ねていればキーの上で 1 回だけそう言います(`wcs/path-dynamic-unknown`、info)。キーか宣言に JSDoc の `@type {typeof import("./en.js").default}` を付けると、そのファイルのリテラルで検査します。
|
|
26
|
+
`<wcs-state src="...">` で参照される外部 state(`.json` / `.js` / `.ts`)は HTML ファイルからの相対パスで解決され、パス検証の対象になります。URL は読み込まず、/ から始まるパスは `--root`(下記)のときだけ読み、読めないファイルはスキップされ、解決できないパスは warning のままです。なお外部 state が**解決できた**ページには通常の検証面が全て適用されるため、error severity の検出(例: 配列でない値への `for:`)が「これまでパス未解決で沈黙していたビルド」を新たに落とすことがあります。4.4 から、`.js` / `.ts` の state にはスクリプトの規則(`wcs/nested-assign`・`wcs/array-mutation`・`wcs/on-handler-this`・`wcs/updated-callback-unbound` など)もかかります: ファイルの中の指摘はそのファイルで報告し(`state.js:12:5 error wcs/nested-assign …`)、何ページから読まれても 1 回だけ数え、IDE はページの `src` の値の上に出します。4.3 までは、外部 state ではパスだけを検査していました。4.10 から、名前で書いたキー — 短縮プロパティ(`export default { lang, t }`。`examples/router-i18n` の辞書のボリューム `<wcs-state mount="i18n" src="./i18n/state.js">`)や `items: ITEMS` — は、その名前が束縛する値の形を持ちます: モジュールの `const` か、相対パスからの import(import するファイルからの相対で読み、再 export の先も辿ります)。4.17 からは名前空間の import のメンバーも同じです(`import * as M from "./lib/music.js"` の `sound: M.DEFAULT_SOUND`)。4.9 までは短縮プロパティのキーをまったく読まなかったので、`i18n.t.*` の束縛はすべて `wcs/binding-path-missing` の誤報でした。値を計算する名前(実行時にロケールの辞書を合わせた辞書)や辿れない名前(素の指定子・URL・無いファイル)のキーは、その下のパスを検査せず、ページがその下を束ねていればキーの上で 1 回だけそう言います(`wcs/path-dynamic-unknown`、info)。キーか宣言に JSDoc の `@type {typeof import("./en.js").default}` を付けると、そのファイルのリテラルで検査します。
|
|
27
27
|
|
|
28
28
|
```
|
|
29
29
|
wcs-validate [--attr=data-wcs] [--state-tag=wcs-state] [--lang=ja|en] [--root=<dir>] [--errors-only] [--strict] <file> [<file> ...]
|
|
@@ -67,7 +67,7 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
|
|
|
67
67
|
|
|
68
68
|
## state の契約を宣言する(`stateSchema`)
|
|
69
69
|
|
|
70
|
-
契約が無いと、validator が解決できないパスは **warning**(`wcs/binding-path-missing`)に留まります: インラインスクリプトが静的に読めなくても `count` は実行時には存在するかもしれないからです。`[]` で始まるリストの行のフィールドは、行を足す・置き換える代入式の行リテラルから読みます。4.9 から、`map` で行を作り直す代入 — `this.rows = [...this.items].map((c) => ({ id: c.id, label: c.name }))`・`.filter(…).map((c) => { return { … }; })` — も、そうする getter と同じく読み、`{}` を種にしたキーへ代入したオブジェクトリテラルのキーも読みます(`this.fieldErrors = { date: "…" }` で `fieldErrors.date`。リテラルの中の spread は追いません)。4.11 から、モジュールの定数を spread する種 — `const EMPTY_DRAFT = { title: "", body: "" }` と `draft: { ...EMPTY_DRAFT }`、読めるファイルから import した定数も — は、そのリテラルのキーを持ちます(入れ子のものも。同じ名前は後に書いた方が勝ちます — オブジェクトを作るときと同じ)。リストの種の最初の行(`[{ ...ROW, id: 0 }]`)も同じです。4.10 まではそのキーの下の束縛がすべて `wcs/binding-path-missing` の誤報で、打ち間違い(`draft.titel`)も同じ警告でした。読めない spread — 呼び出し・`let`・読めない import — があれば、そのキーの下は検査せず、ページがその下を束ねていればキーの上で 1 回だけそう言います(`wcs/path-dynamic-unknown`、info)。外から届くリスト(`<wcs-fetch>` や `<wcs-storage>` が埋めるまで `null`)にはそのリテラルが無いので、プロパティの直前の JSDoc `@type` で形を宣言してください(`/** @type {{ id: number, name: string }[] | null} */ catalog: null`)。同じスクリプトの `@typedef` で行の型に名前を付け、`@type {Product[] | null}`
|
|
70
|
+
契約が無いと、validator が解決できないパスは **warning**(`wcs/binding-path-missing`)に留まります: インラインスクリプトが静的に読めなくても `count` は実行時には存在するかもしれないからです。`[]` で始まるリストの行のフィールドは、行を足す・置き換える代入式の行リテラルから読みます。4.9 から、`map` で行を作り直す代入 — `this.rows = [...this.items].map((c) => ({ id: c.id, label: c.name }))`・`.filter(…).map((c) => { return { … }; })` — も、そうする getter と同じく読み、`{}` を種にしたキーへ代入したオブジェクトリテラルのキーも読みます(`this.fieldErrors = { date: "…" }` で `fieldErrors.date`。リテラルの中の spread は追いません)。4.17 から、`Array.from({ length: n }, (_, i) => ({ … }))`・`Array.from(source, (x) => ({ … }))` の mapper と、`[...Array(n).keys()]` に続く `map` も、getter でも代入でも同じに行の形を言います。4.16 まではその行の下の束縛がどれも `wcs/binding-path-missing` の誤報でした。4.11 から、モジュールの定数を spread する種 — `const EMPTY_DRAFT = { title: "", body: "" }` と `draft: { ...EMPTY_DRAFT }`、読めるファイルから import した定数も — は、そのリテラルのキーを持ちます(入れ子のものも。同じ名前は後に書いた方が勝ちます — オブジェクトを作るときと同じ)。リストの種の最初の行(`[{ ...ROW, id: 0 }]`)も同じです。4.17 からは、読めるファイルの名前空間の import のメンバー(`import * as M from "./lib/music.js"` の `sound: { ...M.DEFAULT_SOUND }`)も同じです。4.16 まではそのキーの下を検査しませんでした。4.10 まではそのキーの下の束縛がすべて `wcs/binding-path-missing` の誤報で、打ち間違い(`draft.titel`)も同じ警告でした。読めない spread — 呼び出し・`let`・読めない import — があれば、そのキーの下は検査せず、ページがその下を束ねていればキーの上で 1 回だけそう言います(`wcs/path-dynamic-unknown`、info)。外から届くリスト(`<wcs-fetch>` や `<wcs-storage>` が埋めるまで `null`)にはそのリテラルが無いので、プロパティの直前の JSDoc `@type` で形を宣言してください(`/** @type {{ id: number, name: string }[] | null} */ catalog: null`)。同じスクリプトの `@typedef` で行の型に名前を付け、`@type {Product[] | null}` と書いてもかまいません。本体から結果を読めない getter(`get keyRows() { return buildRows(this.sound); }`)も、getter の直前に同じように宣言します: getter は `@returns` か `@type` を結果の型として受けます(`/** @returns {{ label: string }[]} */ get keyRows() { … }`)— TypeScript と同じです。getter の `@type` は 4.17 から効きます。4.16 までは `@returns` だけが効き、getter の `@type` は何も言わずに無視されていました。HTML と同じ(または上の)ディレクトリに `application` sidecar を置くと、同じ typo が **error** になります:
|
|
71
71
|
|
|
72
72
|
```json
|
|
73
73
|
{
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ npx wcs-validate --errors-only src/**/*.html
|
|
|
23
23
|
|
|
24
24
|
Files ending in `.manifest.json` are validated as sidecar manifests; everything else is validated as HTML with `data-wcs` bindings, except a framework's components and script files (`.js`, `.ts`, `.jsx`, `.tsx`, `.vue`, `.svelte`), which are not read (since 4.6; before, they were read as HTML and reported clean).
|
|
25
25
|
|
|
26
|
-
External state referenced via `<wcs-state src="...">` (`.json` / `.js` / `.ts`) is resolved relative to the HTML file and included in path validation. URLs are never read, and a path from `/` only under `--root` (below), unreadable files are skipped, and unresolved paths stay warnings. Note that once external state *does* resolve, the full validation surface applies to those pages — error-severity findings (e.g. `for:` bound to a non-array) can fail a build that was previously silent because the paths could not be checked. Since 4.4 that includes the script rules (`wcs/nested-assign`, `wcs/array-mutation`, `wcs/on-handler-this`, `wcs/updated-callback-unbound` and the rest) on a `.js` / `.ts` state: a finding in the file is reported in the file (`state.js:12:5 error wcs/nested-assign …`), once however many pages load it, and the IDE shows it on the page's `src` value. Up to 4.3 only the paths of an external state were checked. Since 4.10, a key written as a name — a shorthand (`export default { lang, t }`, the dictionary volume `<wcs-state mount="i18n" src="./i18n/state.js">` of `examples/router-i18n`) or `items: ITEMS` — has the shape of what the name is bound to: a `const` of the module, or an import from a relative path, which is read relative to the file that imports it (and the module it re-exports from). Up to 4.9 a shorthand key was not read at all, so every `i18n.t.*` binding was a false `wcs/binding-path-missing`. A name whose value is computed (the dictionary merged from the locale catalogs at run time), or that it cannot follow (a bare specifier, a URL, a file that is not there), leaves the paths under that key unchecked, and says so once at the key when the page binds under it (`wcs/path-dynamic-unknown`, info); a JSDoc `@type {typeof import("./en.js").default}` on the key or on the declaration has them checked against that file's literal.
|
|
26
|
+
External state referenced via `<wcs-state src="...">` (`.json` / `.js` / `.ts`) is resolved relative to the HTML file and included in path validation. URLs are never read, and a path from `/` only under `--root` (below), unreadable files are skipped, and unresolved paths stay warnings. Note that once external state *does* resolve, the full validation surface applies to those pages — error-severity findings (e.g. `for:` bound to a non-array) can fail a build that was previously silent because the paths could not be checked. Since 4.4 that includes the script rules (`wcs/nested-assign`, `wcs/array-mutation`, `wcs/on-handler-this`, `wcs/updated-callback-unbound` and the rest) on a `.js` / `.ts` state: a finding in the file is reported in the file (`state.js:12:5 error wcs/nested-assign …`), once however many pages load it, and the IDE shows it on the page's `src` value. Up to 4.3 only the paths of an external state were checked. Since 4.10, a key written as a name — a shorthand (`export default { lang, t }`, the dictionary volume `<wcs-state mount="i18n" src="./i18n/state.js">` of `examples/router-i18n`) or `items: ITEMS` — has the shape of what the name is bound to: a `const` of the module, or an import from a relative path, which is read relative to the file that imports it (and the module it re-exports from) — since 4.17 a member of a namespace import too (`sound: M.DEFAULT_SOUND` with `import * as M from "./lib/music.js"`). Up to 4.9 a shorthand key was not read at all, so every `i18n.t.*` binding was a false `wcs/binding-path-missing`. A name whose value is computed (the dictionary merged from the locale catalogs at run time), or that it cannot follow (a bare specifier, a URL, a file that is not there), leaves the paths under that key unchecked, and says so once at the key when the page binds under it (`wcs/path-dynamic-unknown`, info); a JSDoc `@type {typeof import("./en.js").default}` on the key or on the declaration has them checked against that file's literal.
|
|
27
27
|
|
|
28
28
|
```
|
|
29
29
|
wcs-validate [--attr=data-wcs] [--state-tag=wcs-state] [--lang=ja|en] [--root=<dir>] [--errors-only] [--strict] <file> [<file> ...]
|
|
@@ -67,7 +67,7 @@ A framework app (React, Vue) that uses the `<wcs-*>` elements has neither: its p
|
|
|
67
67
|
|
|
68
68
|
## Declaring a state contract (`stateSchema`)
|
|
69
69
|
|
|
70
|
-
Without a contract, a path the validator cannot resolve is only a **warning** (`wcs/binding-path-missing`): `count` may well exist at runtime even when the inline script cannot be read statically. Note that a list starting as `[]` does not need a contract just to name its row fields — the analyzer reads them from the row literals in the assignments that add or replace rows (`this.items = this.items.concat({ id, kind: "general" })`, `.toSpliced(i, n, { … })`, `.with(i, { … })`, `[...this.items, { … }]`); only a row passed as a variable (`concat(row)`) is invisible to it. Since 4.9 it also reads an assignment that rebuilds the rows with `map` — `this.rows = [...this.items].map((c) => ({ id: c.id, label: c.name }))`, `.filter(…).map((c) => { return { … }; })` — the way it reads a getter that does, and the keys of an object literal assigned to a key seeded `{}` (`this.fieldErrors = { date: "…" }` gives `fieldErrors.date`; a spread inside the literal is not followed). Since 4.11 a seed that spreads a constant of the module — `draft: { ...EMPTY_DRAFT }` with `const EMPTY_DRAFT = { title: "", body: "" }`, or one imported from a file it reads — has that literal's keys (nested ones too; a later key of the same name wins, as when the object is built), and so does a list seed's first row (`[{ ...ROW, id: 0 }]`). Up to 4.10 every binding under such a key was a false `wcs/binding-path-missing`, and a typo (`draft.titel`) the same warning. A spread it cannot read — a call, a `let`, an import it cannot read — leaves the keys under that key unchecked, said once at the key when the page binds under it (`wcs/path-dynamic-unknown`, info). A list that arrives from outside — `null` until `<wcs-fetch>` or `<wcs-storage>` fills it — has no such literal: declare its shape with a JSDoc `@type` before the property (`/** @type {{ id: number, name: string }[] | null} */ catalog: null`), or name the row type with a `@typedef` in the same script and write `@type {Product[] | null}`. Put an `application` sidecar next to (or above) the HTML and the same typo becomes an **error**:
|
|
70
|
+
Without a contract, a path the validator cannot resolve is only a **warning** (`wcs/binding-path-missing`): `count` may well exist at runtime even when the inline script cannot be read statically. Note that a list starting as `[]` does not need a contract just to name its row fields — the analyzer reads them from the row literals in the assignments that add or replace rows (`this.items = this.items.concat({ id, kind: "general" })`, `.toSpliced(i, n, { … })`, `.with(i, { … })`, `[...this.items, { … }]`); only a row passed as a variable (`concat(row)`) is invisible to it. Since 4.9 it also reads an assignment that rebuilds the rows with `map` — `this.rows = [...this.items].map((c) => ({ id: c.id, label: c.name }))`, `.filter(…).map((c) => { return { … }; })` — the way it reads a getter that does, and the keys of an object literal assigned to a key seeded `{}` (`this.fieldErrors = { date: "…" }` gives `fieldErrors.date`; a spread inside the literal is not followed). Since 4.17 the mapper of `Array.from({ length: n }, (_, i) => ({ … }))` and `Array.from(source, (x) => ({ … }))`, and a `map` after `[...Array(n).keys()]`, give the rows the same way, in a getter and in an assignment; up to 4.16 each binding under such rows was a false `wcs/binding-path-missing`. Since 4.11 a seed that spreads a constant of the module — `draft: { ...EMPTY_DRAFT }` with `const EMPTY_DRAFT = { title: "", body: "" }`, or one imported from a file it reads — has that literal's keys (nested ones too; a later key of the same name wins, as when the object is built), and so does a list seed's first row (`[{ ...ROW, id: 0 }]`); since 4.17 so does a member of a namespace import of a file it reads (`sound: { ...M.DEFAULT_SOUND }` with `import * as M from "./lib/music.js"`), which up to 4.16 left the keys unchecked. Up to 4.10 every binding under such a key was a false `wcs/binding-path-missing`, and a typo (`draft.titel`) the same warning. A spread it cannot read — a call, a `let`, an import it cannot read — leaves the keys under that key unchecked, said once at the key when the page binds under it (`wcs/path-dynamic-unknown`, info). A list that arrives from outside — `null` until `<wcs-fetch>` or `<wcs-storage>` fills it — has no such literal: declare its shape with a JSDoc `@type` before the property (`/** @type {{ id: number, name: string }[] | null} */ catalog: null`), or name the row type with a `@typedef` in the same script and write `@type {Product[] | null}`. A getter whose result it cannot read from the body (`get keyRows() { return buildRows(this.sound); }`) is declared the same way, before the getter: a getter takes `@returns` or `@type` — `/** @returns {{ label: string }[]} */ get keyRows() { … }` — as its result type, as TypeScript does. `@type` counts on a getter since 4.17; up to 4.16 only `@returns` did, and a getter's `@type` was ignored without a word. Put an `application` sidecar next to (or above) the HTML and the same typo becomes an **error**:
|
|
71
71
|
|
|
72
72
|
```json
|
|
73
73
|
{
|
package/dist/cli.cjs
CHANGED
|
@@ -125,7 +125,7 @@ var WcsDiagnosticCode = {
|
|
|
125
125
|
ReadPathMissing: "wcs/read-path-missing",
|
|
126
126
|
NestedAssign: "wcs/nested-assign",
|
|
127
127
|
// --- 意味論(構文・存在検査では捕まらない取り違え。service/semanticValidator.ts) ---
|
|
128
|
-
// `$getAll` / `$setAll` / `$resolve` の添字の本数がパスの `*` の本数と噛み合わない。
|
|
128
|
+
// `$getAll` / `$setAll` / `$resolve` / `$update` の添字の本数がパスの `*` の本数と噛み合わない。
|
|
129
129
|
// ランタイムは #901 / #902 で throw する(diagnostics の後付けがあれば同じ code の文面。超過は 3.x では
|
|
130
130
|
// 黙って無視されていた)。error。
|
|
131
131
|
IndexArity: "wcs/index-arity",
|
|
@@ -145,6 +145,19 @@ var WcsDiagnosticCode = {
|
|
|
145
145
|
// パス getter どうしの循環参照。4.0 のランタイムは評価の時点で #701 として throw し、その getter を読む
|
|
146
146
|
// 束縛はすべて失敗する(3.x はアドレススタック上限まで再帰してから落ちた)。error。
|
|
147
147
|
GetterCycle: "wcs/getter-cycle",
|
|
148
|
+
// --- what a getter, a setter or a method writes (docs/script-write-checks.md) ---
|
|
149
|
+
// getter の評価中の書き込み(代入・複合代入・増減・`$setAll` / `$update` / 引数 3 つの `$resolve`、getter が同期に呼ぶ
|
|
150
|
+
// メソッドの書き込みも)。4.0 のランタイムは書き込みのたびに throw する(4.17 から書いたパスと getter を名指す)。
|
|
151
|
+
// 入れ子の関数の中は、評価中に走るとは限らないので見ない。error。
|
|
152
|
+
GetterWrite: "wcs/getter-write",
|
|
153
|
+
// setter が自分のパスに書く、または setter どうしが互いに書く(同期の書き込みだけ)。setter のパスはアクセサそのもの
|
|
154
|
+
// なので、書けば setter がまた呼ばれ、スタックが溢れるまで続く(4.17 から diagnostics の後付けが名指して throw する)。
|
|
155
|
+
// 自分のパスは error、2 つ以上の循環は条件で止まりうるので warning。
|
|
156
|
+
SetterCycle: "wcs/setter-cycle",
|
|
157
|
+
// setter が書くものを、同じ名前の getter が(呼ぶ getter・メソッドを通しても)一つも読まない。setter の後に getter は
|
|
158
|
+
// 元の値を返し、双方向の入力はそこへ戻る — 何も知らせない(4.17 から diagnostics の後付けが警告する)。setter・getter
|
|
159
|
+
// の読み書きを追えない(`this[key]`・`fn(this)`・知らないメソッド)なら黙る。warning。
|
|
160
|
+
SetterUnobserved: "wcs/setter-unobserved",
|
|
148
161
|
// `$renderedCallback`(3.x の旧名 `$updatedCallback`)が、どのバインディングにも現れないパスを判定に使っている。
|
|
149
162
|
// 同コールバックは **binding 駆動**(live binding が適用された path しか報告しない)
|
|
150
163
|
// なので、その分岐は一度も実行されない。表示要素が購読の実体になる事故
|
|
@@ -695,10 +708,11 @@ var SENTENCES = {
|
|
|
695
708
|
1
|
|
696
709
|
/* ScanRemoved */
|
|
697
710
|
]: () => "$scan was removed (use $watch or $on)",
|
|
711
|
+
// (no code of its own hundred: the code lint reports for the same write — a two-way binding or a script — is written here)
|
|
698
712
|
[
|
|
699
713
|
2
|
|
700
714
|
/* GetterWithoutSetter */
|
|
701
|
-
]: (p) => `"${p}" is a getter without a setter`,
|
|
715
|
+
]: (p) => `[wcs/path-readonly] "${p}" is a getter without a setter`,
|
|
702
716
|
[
|
|
703
717
|
3
|
|
704
718
|
/* NoRow */
|
|
@@ -719,10 +733,11 @@ var SENTENCES = {
|
|
|
719
733
|
7
|
|
720
734
|
/* EqIndexNoRow */
|
|
721
735
|
]: (p) => `$eqIndex("${p}") needs a list row scope.`,
|
|
736
|
+
// a write while a getter is evaluated names the getter (the core passes it, docs/script-write-checks.md); in a readonly callback, the path
|
|
722
737
|
[
|
|
723
738
|
8
|
|
724
739
|
/* Readonly */
|
|
725
|
-
]: () => "This state is readonly.",
|
|
740
|
+
]: (p, g) => g ? `[wcs/getter-write] "${p}" is written while the getter "${g}" is evaluated: a getter only reads. Write it from a method, a setter or a $watch handler.` : p ? `cannot write "${p}": this state is readonly.` : "This state is readonly.",
|
|
726
741
|
[
|
|
727
742
|
9
|
|
728
743
|
/* SetAllNeedsIndexes */
|
|
@@ -862,10 +877,11 @@ var SENTENCES = {
|
|
|
862
877
|
37
|
|
863
878
|
/* InitUnsupported */
|
|
864
879
|
]: (type, init) => `Binding type "${type}" does not support init=${init}.`,
|
|
880
|
+
// (no code of its own hundred: the code lint reports for the same binding is written here; the core passes the tag)
|
|
865
881
|
[
|
|
866
882
|
38
|
|
867
883
|
/* MemberUndeclared */
|
|
868
|
-
]: (name) => `
|
|
884
|
+
]: (name, tag) => `[wcs/tag-member-unknown] "${name}" is not a wcBindable member of <${tag}>.`,
|
|
869
885
|
[
|
|
870
886
|
39
|
|
871
887
|
/* InitIncompatible */
|
|
@@ -1121,7 +1137,11 @@ var LINT_CODES = /* @__PURE__ */ new Set([
|
|
|
1121
1137
|
"wildcard-rank",
|
|
1122
1138
|
"token-undeclared",
|
|
1123
1139
|
"binding-path-missing",
|
|
1124
|
-
"index-param-range"
|
|
1140
|
+
"index-param-range",
|
|
1141
|
+
"path-readonly",
|
|
1142
|
+
"getter-write",
|
|
1143
|
+
"setter-cycle",
|
|
1144
|
+
"tag-member-unknown"
|
|
1125
1145
|
]);
|
|
1126
1146
|
var GUIDES = [
|
|
1127
1147
|
[/no loop level in common with the context/, "; pass indexes ([] for all)."],
|
|
@@ -1132,7 +1152,9 @@ var GUIDES = [
|
|
|
1132
1152
|
[/\[wcs\/wildcard-rank\] .* ranges over the rows of/, ' A "*" in a binding is the row of the loop around it: read a row of another list in a getter, with $resolve(path, indexes).'],
|
|
1133
1153
|
[/\[wcs\/binding-type-expectation\] class\.([^ ]+)/, ' Write "class.$1: path|truthy" to toggle on truthiness.'],
|
|
1134
1154
|
[/path segments — the limit/, " Every prefix of a path is interned, so the cost grows with the square of the depth."],
|
|
1135
|
-
[/\[wcs\/
|
|
1155
|
+
[/\[wcs\/path-readonly\] "([^"]+)"/, ' Add a setter (set "$1"(v) { \u2026 }) or write what the getter reads; bind a two-way binding one way with #ro.'],
|
|
1156
|
+
[/\[wcs\/tag-member-unknown\] "([^"]+)"/, ' Bind a property or an input its static wcBindable declares; an attribute of the tag is written in the markup ($1="\u2026") or bound as attr.$1:.'],
|
|
1157
|
+
[/\[wcs\/index-arity\] \$(?:resolve|update)/, ' $resolve and $update take one index per "*"; $getAll / $setAll take at most that many (fewer expands the rest).'],
|
|
1136
1158
|
[/"([^"#]+)#[^"]*" is not a filter name: "#" cannot appear in one/, ' Modifiers belong on the left side of the binding, before the ":" \u2014 write "$1" here.']
|
|
1137
1159
|
];
|
|
1138
1160
|
var RENAMED_FILTERS = {
|
|
@@ -2403,7 +2425,7 @@ function getWcsManifest() {
|
|
|
2403
2425
|
}
|
|
2404
2426
|
|
|
2405
2427
|
// ../state/package.json
|
|
2406
|
-
var version = "4.
|
|
2428
|
+
var version = "4.17.0";
|
|
2407
2429
|
|
|
2408
2430
|
// src/service/wcsManifest.ts
|
|
2409
2431
|
var ENGINE_VERSION = version;
|
|
@@ -8398,7 +8420,7 @@ function readJsDocTypeBefore(content, propIndex) {
|
|
|
8398
8420
|
function readJsDocReturnsBefore(content, propIndex) {
|
|
8399
8421
|
const comment = jsDocCommentBefore(content, propIndex);
|
|
8400
8422
|
if (comment === void 0) return void 0;
|
|
8401
|
-
return (readBracedType(comment, "returns") ?? readBracedType(comment, "return"))?.type.trim();
|
|
8423
|
+
return (readBracedType(comment, "returns") ?? readBracedType(comment, "return") ?? readBracedType(comment, "type"))?.type.trim();
|
|
8402
8424
|
}
|
|
8403
8425
|
function jsDocCommentBefore(content, propIndex) {
|
|
8404
8426
|
let end = propIndex;
|
|
@@ -8487,17 +8509,41 @@ var ModuleScope = class _ModuleScope {
|
|
|
8487
8509
|
const program = parseModule(this.text);
|
|
8488
8510
|
return program !== null && program.type === "Program" ? program.body : [];
|
|
8489
8511
|
}
|
|
8490
|
-
/** The specifier a top-level name is imported from, if it is imported. */
|
|
8512
|
+
/** The specifier a top-level name is imported from, if it is imported (for `M.NAME`, the one `M` is). */
|
|
8491
8513
|
importOf(name) {
|
|
8514
|
+
const local = namespaceMember(name)?.namespace ?? name;
|
|
8492
8515
|
for (const statement of this.body) {
|
|
8493
8516
|
if (statement.type !== "ImportDeclaration") continue;
|
|
8494
|
-
if (statement.specifiers.some((s) => s.local.name ===
|
|
8517
|
+
if (statement.specifiers.some((s) => s.local.name === local)) return String(statement.source.value);
|
|
8495
8518
|
}
|
|
8496
8519
|
return void 0;
|
|
8497
8520
|
}
|
|
8498
|
-
/**
|
|
8521
|
+
/** Whether `text` is `M.NAME` with `M` a namespace import of the module (`import * as M from "…"`). */
|
|
8522
|
+
isNamespaceMember(text3) {
|
|
8523
|
+
const member = namespaceMember(text3);
|
|
8524
|
+
return member !== null && this.namespaceImport(member.namespace) !== void 0;
|
|
8525
|
+
}
|
|
8526
|
+
/** The specifier of a namespace import (`import * as M from "…"`) whose local name is `name`. */
|
|
8527
|
+
namespaceImport(name) {
|
|
8528
|
+
for (const statement of this.body) {
|
|
8529
|
+
if (statement.type !== "ImportDeclaration") continue;
|
|
8530
|
+
if (statement.specifiers.some((s) => s.type === "ImportNamespaceSpecifier" && s.local.name === name)) {
|
|
8531
|
+
return String(statement.source.value);
|
|
8532
|
+
}
|
|
8533
|
+
}
|
|
8534
|
+
return void 0;
|
|
8535
|
+
}
|
|
8536
|
+
/**
|
|
8537
|
+
* The value a top-level name of the module is bound to, or null when it cannot be followed. `M.NAME` with `M` a
|
|
8538
|
+
* namespace import (`import * as M from "./lib/music.js"`) is the module's export `NAME`, read as a named import is.
|
|
8539
|
+
*/
|
|
8499
8540
|
resolveName(name, hops = 0) {
|
|
8500
8541
|
if (hops > MAX_HOPS) return null;
|
|
8542
|
+
const member = namespaceMember(name);
|
|
8543
|
+
if (member !== null) {
|
|
8544
|
+
const specifier = this.namespaceImport(member.namespace);
|
|
8545
|
+
return specifier === void 0 ? null : this.module(specifier)?.resolveExport(member.name, hops + 1) ?? null;
|
|
8546
|
+
}
|
|
8501
8547
|
for (const statement of this.body) {
|
|
8502
8548
|
if (statement.type === "ImportDeclaration") {
|
|
8503
8549
|
const specifier = statement.specifiers.find((s) => s.local.name === name);
|
|
@@ -8580,6 +8626,10 @@ var ModuleScope = class _ModuleScope {
|
|
|
8580
8626
|
return scope;
|
|
8581
8627
|
}
|
|
8582
8628
|
};
|
|
8629
|
+
function namespaceMember(text3) {
|
|
8630
|
+
const m = /^([$A-Za-z_][$\w]*)\s*\.\s*([$A-Za-z_][$\w]*)$/.exec(text3.trim());
|
|
8631
|
+
return m === null ? null : { namespace: m[1], name: m[2] };
|
|
8632
|
+
}
|
|
8583
8633
|
function exportName(node) {
|
|
8584
8634
|
return node.type === "Identifier" ? node.name : String(node.value);
|
|
8585
8635
|
}
|
|
@@ -9376,7 +9426,7 @@ function readExpression(text3, scan, start) {
|
|
|
9376
9426
|
}
|
|
9377
9427
|
return text3.slice(start, i).trim();
|
|
9378
9428
|
}
|
|
9379
|
-
function expressionShape(text3, paths, aliases) {
|
|
9429
|
+
function expressionShape(text3, paths, aliases, keepOpaque = false) {
|
|
9380
9430
|
const expr = stripWrappingParens(text3.trim());
|
|
9381
9431
|
if (expr === "") return null;
|
|
9382
9432
|
const scan = maskCommentsAndStrings(expr);
|
|
@@ -9404,7 +9454,7 @@ function expressionShape(text3, paths, aliases) {
|
|
|
9404
9454
|
} else {
|
|
9405
9455
|
const spread = /^\s*\.\.\.([\s\S]+)$/.exec(inner);
|
|
9406
9456
|
if (spread === null || splitTopLevelElements(inner).length !== 1) return null;
|
|
9407
|
-
const source = expressionShape(spread[1], paths, aliases);
|
|
9457
|
+
const source = expressionShape(spread[1], paths, aliases, true);
|
|
9408
9458
|
if (source === null || !source.isList) return null;
|
|
9409
9459
|
shape = source;
|
|
9410
9460
|
}
|
|
@@ -9412,12 +9462,26 @@ function expressionShape(text3, paths, aliases) {
|
|
|
9412
9462
|
const inner = extractDelimitedContent(expr, scan, 0, "(", ")");
|
|
9413
9463
|
shape = expressionShape(inner, paths, aliases) ?? OPAQUE;
|
|
9414
9464
|
rest = inner.length + 2;
|
|
9465
|
+
} else if (/^Array\s*\.\s*from\s*\(/.test(scan)) {
|
|
9466
|
+
const open = scan.indexOf("(");
|
|
9467
|
+
const args = extractDelimitedContent(expr, scan, open, "(", ")");
|
|
9468
|
+
const from = arrayFromShape(args, paths, aliases);
|
|
9469
|
+
if (from === null) return null;
|
|
9470
|
+
shape = from;
|
|
9471
|
+
rest = open + args.length + 2;
|
|
9415
9472
|
} else {
|
|
9416
9473
|
const base = readBase(expr, scan, aliases, paths);
|
|
9417
9474
|
if (base === null) return null;
|
|
9418
9475
|
({ shape, rest } = base);
|
|
9419
9476
|
}
|
|
9420
|
-
return applyChain(expr, scan, rest, shape, paths, aliases);
|
|
9477
|
+
return applyChain(expr, scan, rest, shape, paths, aliases, keepOpaque);
|
|
9478
|
+
}
|
|
9479
|
+
function arrayFromShape(args, paths, aliases) {
|
|
9480
|
+
const [source, mapper, ...more] = splitTopLevelElements(args);
|
|
9481
|
+
if (source === void 0 || more.length > 1) return null;
|
|
9482
|
+
const sourceShape = expressionShape(source, paths, aliases, true);
|
|
9483
|
+
const rows = sourceShape !== null && sourceShape.isList ? sourceShape : OPAQUE;
|
|
9484
|
+
return mapper === void 0 ? rows : mapRows(mapper, rows, paths, aliases);
|
|
9421
9485
|
}
|
|
9422
9486
|
function readBase(expr, scan, aliases, paths) {
|
|
9423
9487
|
const alias = /^([$\w]+)/.exec(scan);
|
|
@@ -9464,7 +9528,7 @@ function readBase(expr, scan, aliases, paths) {
|
|
|
9464
9528
|
rest: i
|
|
9465
9529
|
};
|
|
9466
9530
|
}
|
|
9467
|
-
function applyChain(expr, scan, start, initial, paths, aliases) {
|
|
9531
|
+
function applyChain(expr, scan, start, initial, paths, aliases, keepOpaque = false) {
|
|
9468
9532
|
let shape = initial;
|
|
9469
9533
|
let i = start;
|
|
9470
9534
|
while (scan.slice(i).trim() !== "") {
|
|
@@ -9500,7 +9564,7 @@ function applyChain(expr, scan, start, initial, paths, aliases) {
|
|
|
9500
9564
|
return null;
|
|
9501
9565
|
}
|
|
9502
9566
|
}
|
|
9503
|
-
return shape.opaque ? null : shape;
|
|
9567
|
+
return shape.opaque && !keepOpaque ? null : shape;
|
|
9504
9568
|
}
|
|
9505
9569
|
var OPAQUE = { isList: true, mirrors: [], fields: [], opaque: true };
|
|
9506
9570
|
var EMPTY_LIST = { isList: true, mirrors: [], fields: [] };
|
|
@@ -9690,8 +9754,8 @@ function pushDataPropertyPathsAt(path, prop, paths, depth, typedefs, scope) {
|
|
|
9690
9754
|
const value = followed.value;
|
|
9691
9755
|
const shapeHint = value === null ? void 0 : inferTypeHint(value.text);
|
|
9692
9756
|
const typeHint = prop.typeHint ?? (shapeHint === "array" || shapeHint === "object" ? shapeHint : void 0);
|
|
9693
|
-
const
|
|
9694
|
-
candidate = withHint({ path, kind: "data", rawInitial: prop.value?.trim(), ...
|
|
9757
|
+
const opaque2 = (value === null || !isReadableLiteral(value.text)) && prop.declaredType === void 0 ? { opaque: { ...followed.name !== void 0 ? { name: followed.name } : {}, ...followed.from !== void 0 ? { from: followed.from } : {} } } : {};
|
|
9758
|
+
candidate = withHint({ path, kind: "data", rawInitial: prop.value?.trim(), ...opaque2 }, typeHint);
|
|
9695
9759
|
paths.push(candidate);
|
|
9696
9760
|
if (value !== null) unread = pushLiteralStructurePaths(path, { ...prop, value: value.text }, paths, depth, typedefs, value.scope);
|
|
9697
9761
|
}
|
|
@@ -9739,14 +9803,14 @@ function spreadLiteral(spread, scope) {
|
|
|
9739
9803
|
const expr = unwrapFreeze(spread.replace(/^\.\.\./, ""));
|
|
9740
9804
|
if (expr === "null" || expr === "undefined") return { text: null };
|
|
9741
9805
|
if (isObjectLiteral(expr)) return { text: expr, scope };
|
|
9742
|
-
if (
|
|
9806
|
+
if (scope === void 0 || !isFollowableName(expr, scope)) return { unread: { text: spread } };
|
|
9743
9807
|
const from = scope.importOf(expr);
|
|
9744
9808
|
const unread = { unread: { text: spread, ...from !== void 0 ? { from } : {} } };
|
|
9745
9809
|
let current2 = scope.resolveName(expr);
|
|
9746
9810
|
for (let hops = 0; current2 !== null && hops < MAX_SPREAD_HOPS; hops++) {
|
|
9747
9811
|
const inner = unwrapFreeze(current2.text);
|
|
9748
9812
|
if (isObjectLiteral(inner)) return { text: inner, scope: current2.scope };
|
|
9749
|
-
if (!
|
|
9813
|
+
if (!isFollowableName(inner, current2.scope)) return unread;
|
|
9750
9814
|
current2 = current2.scope.resolveName(inner);
|
|
9751
9815
|
}
|
|
9752
9816
|
return unread;
|
|
@@ -9778,6 +9842,9 @@ var WORD_LITERALS = /* @__PURE__ */ new Set(["true", "false", "null", "undefined
|
|
|
9778
9842
|
function isBindingName(text3) {
|
|
9779
9843
|
return /^[$A-Za-z_][$\w]*$/.test(text3) && !WORD_LITERALS.has(text3);
|
|
9780
9844
|
}
|
|
9845
|
+
function isFollowableName(text3, scope) {
|
|
9846
|
+
return isBindingName(text3) || scope.isNamespaceMember(text3);
|
|
9847
|
+
}
|
|
9781
9848
|
function unwrapFreeze(text3) {
|
|
9782
9849
|
let expr = text3.trim();
|
|
9783
9850
|
for (; ; ) {
|
|
@@ -9807,7 +9874,7 @@ function followValue(prop, scope) {
|
|
|
9807
9874
|
if (prop.value === void 0) return null;
|
|
9808
9875
|
const written = prop.value.trim();
|
|
9809
9876
|
const text3 = unwrapFreeze(written);
|
|
9810
|
-
if (!
|
|
9877
|
+
if (!isFollowableName(text3, scope)) return text3 === written ? null : { value: { text: text3, scope } };
|
|
9811
9878
|
name = text3;
|
|
9812
9879
|
from = scope.importOf(text3);
|
|
9813
9880
|
const resolved = scope.resolveName(text3);
|
|
@@ -9816,7 +9883,7 @@ function followValue(prop, scope) {
|
|
|
9816
9883
|
}
|
|
9817
9884
|
for (let hops = 0; hops < 8; hops++) {
|
|
9818
9885
|
const inner = unwrapFreeze(current2.text);
|
|
9819
|
-
if (!
|
|
9886
|
+
if (!isFollowableName(inner, current2.scope)) return { value: inner === current2.text ? current2 : { text: inner, scope: current2.scope }, name, from };
|
|
9820
9887
|
const next = current2.scope.resolveName(inner);
|
|
9821
9888
|
if (next === null) return { value: null, name, from };
|
|
9822
9889
|
current2 = next;
|
|
@@ -10838,7 +10905,9 @@ var SUFFIX = "\n})";
|
|
|
10838
10905
|
var PATH_ARG_APIS = /* @__PURE__ */ new Set(["$getAll", "$resolve", "$dependOn", "$trackDependency"]);
|
|
10839
10906
|
var TRACK_APIS = /* @__PURE__ */ new Set(["$dependOn", "$trackDependency"]);
|
|
10840
10907
|
var UNTRACK_APIS = /* @__PURE__ */ new Set(["$untracked", "$untrackDependency"]);
|
|
10841
|
-
|
|
10908
|
+
var WRITE_APIS = /* @__PURE__ */ new Set(["$setAll", "$update"]);
|
|
10909
|
+
var collecting = {};
|
|
10910
|
+
function collectGetterReads(body, options = {}) {
|
|
10842
10911
|
let program;
|
|
10843
10912
|
try {
|
|
10844
10913
|
program = parse3(PREFIX + body + SUFFIX, { ecmaVersion: "latest", sourceType: "module" });
|
|
@@ -10848,8 +10917,13 @@ function collectGetterReads(body) {
|
|
|
10848
10917
|
const fn = unwrapWrapper(program);
|
|
10849
10918
|
if (fn === null) return null;
|
|
10850
10919
|
const out = [];
|
|
10851
|
-
const root = { thisIsState: true, aliases: /* @__PURE__ */ new Set() };
|
|
10852
|
-
|
|
10920
|
+
const root = { thisIsState: true, aliases: /* @__PURE__ */ new Set(), nested: false };
|
|
10921
|
+
collecting = options;
|
|
10922
|
+
try {
|
|
10923
|
+
visit(fn.body, enterFunction(fn, root, true, false), out);
|
|
10924
|
+
} finally {
|
|
10925
|
+
collecting = {};
|
|
10926
|
+
}
|
|
10853
10927
|
return out;
|
|
10854
10928
|
}
|
|
10855
10929
|
function unwrapWrapper(program) {
|
|
@@ -10901,7 +10975,7 @@ function bindingNames(pattern, out) {
|
|
|
10901
10975
|
return;
|
|
10902
10976
|
}
|
|
10903
10977
|
}
|
|
10904
|
-
function enterFunction(fn, outer, thisIsState) {
|
|
10978
|
+
function enterFunction(fn, outer, thisIsState, nested) {
|
|
10905
10979
|
const shadowed = /* @__PURE__ */ new Set();
|
|
10906
10980
|
const aliasInits = [];
|
|
10907
10981
|
for (const param of fn.params) bindingNames(param, shadowed);
|
|
@@ -10949,11 +11023,26 @@ function enterFunction(fn, outer, thisIsState) {
|
|
|
10949
11023
|
const ok = from === null ? thisIsState : aliases.has(from);
|
|
10950
11024
|
if (!ok) aliases.delete(name);
|
|
10951
11025
|
}
|
|
10952
|
-
return { thisIsState, aliases };
|
|
11026
|
+
return { thisIsState, aliases, nested };
|
|
10953
11027
|
}
|
|
10954
11028
|
function isThisRoot(node, scope) {
|
|
10955
11029
|
return node.type === "ThisExpression" && scope.thisIsState || node.type === "Identifier" && scope.aliases.has(node.name);
|
|
10956
11030
|
}
|
|
11031
|
+
function templateKey(node) {
|
|
11032
|
+
let path = "";
|
|
11033
|
+
const lists = [];
|
|
11034
|
+
for (let k = 0; k < node.quasis.length; k++) {
|
|
11035
|
+
const quasi = node.quasis[k].value.cooked;
|
|
11036
|
+
if (quasi === null || quasi === void 0) return null;
|
|
11037
|
+
if (k > 0 && quasi !== "" && !quasi.startsWith(".")) return null;
|
|
11038
|
+
path += quasi;
|
|
11039
|
+
if (k === node.expressions.length) break;
|
|
11040
|
+
if (!path.endsWith(".")) return null;
|
|
11041
|
+
lists.push(path.slice(0, -1));
|
|
11042
|
+
path += "*";
|
|
11043
|
+
}
|
|
11044
|
+
return lists.length === 0 ? null : { path, lists };
|
|
11045
|
+
}
|
|
10957
11046
|
function literalString(node) {
|
|
10958
11047
|
if (node.type === "Literal" && typeof node.value === "string") return node.value;
|
|
10959
11048
|
if (node.type === "TemplateLiteral" && node.expressions.length === 0 && node.quasis.length === 1) {
|
|
@@ -10971,6 +11060,10 @@ function segmentOf(member) {
|
|
|
10971
11060
|
}
|
|
10972
11061
|
const text3 = literalString(property);
|
|
10973
11062
|
if (text3 !== null) return { text: text3, dynamic: null };
|
|
11063
|
+
if (collecting.templates && property.type === "TemplateLiteral") {
|
|
11064
|
+
const key = templateKey(property);
|
|
11065
|
+
if (key !== null) return { text: key.path, dynamic: property, lists: key.lists };
|
|
11066
|
+
}
|
|
10974
11067
|
return property.type === "PrivateIdentifier" ? { text: null, dynamic: null } : { text: null, dynamic: property };
|
|
10975
11068
|
}
|
|
10976
11069
|
function unwrapChain(node) {
|
|
@@ -10985,9 +11078,10 @@ function resolveChain(node) {
|
|
|
10985
11078
|
}
|
|
10986
11079
|
return { segments, base: current2 };
|
|
10987
11080
|
}
|
|
10988
|
-
function emit(out, segments, options, start, end) {
|
|
11081
|
+
function emit(out, segments, options, start, end, scope) {
|
|
10989
11082
|
if (segments.length === 0) return;
|
|
10990
11083
|
const root = segments[0].text;
|
|
11084
|
+
if (root === null && segments[0].dynamic !== null) opaque(out, options.written || options.form === "write", start, end, scope);
|
|
10991
11085
|
if (root === null || root.length === 0 || root.startsWith("$")) return;
|
|
10992
11086
|
let chain = [];
|
|
10993
11087
|
for (let i = 0; i < segments.length; i++) {
|
|
@@ -10998,25 +11092,41 @@ function emit(out, segments, options, start, end) {
|
|
|
10998
11092
|
}
|
|
10999
11093
|
chain.push(text3);
|
|
11000
11094
|
}
|
|
11095
|
+
const lists = segments[0].lists;
|
|
11001
11096
|
out.push({
|
|
11002
11097
|
path: root,
|
|
11003
11098
|
chain,
|
|
11004
11099
|
form: options.form,
|
|
11005
11100
|
callee: options.callee,
|
|
11006
11101
|
written: options.written,
|
|
11102
|
+
...lists !== void 0 ? { indexed: lists } : {},
|
|
11103
|
+
...scope.nested ? { nested: true } : {},
|
|
11104
|
+
start: start - PREFIX.length,
|
|
11105
|
+
end: end - PREFIX.length
|
|
11106
|
+
});
|
|
11107
|
+
}
|
|
11108
|
+
function opaque(out, written, start, end, scope) {
|
|
11109
|
+
if (!collecting.opaque) return;
|
|
11110
|
+
out.push({
|
|
11111
|
+
path: "",
|
|
11112
|
+
chain: null,
|
|
11113
|
+
form: "opaque",
|
|
11114
|
+
callee: false,
|
|
11115
|
+
written,
|
|
11116
|
+
...scope.nested ? { nested: true } : {},
|
|
11007
11117
|
start: start - PREFIX.length,
|
|
11008
11118
|
end: end - PREFIX.length
|
|
11009
11119
|
});
|
|
11010
11120
|
}
|
|
11011
11121
|
function visit(node, scope, out) {
|
|
11012
11122
|
if (isFunctionNode(node)) {
|
|
11013
|
-
const inner = enterFunction(node, scope, node.type === "ArrowFunctionExpression" ? scope.thisIsState : false);
|
|
11123
|
+
const inner = enterFunction(node, scope, node.type === "ArrowFunctionExpression" ? scope.thisIsState : false, true);
|
|
11014
11124
|
for (const param of node.params) if (param.type === "AssignmentPattern") visit(param.right, inner, out);
|
|
11015
11125
|
visit(node.body, inner, out);
|
|
11016
11126
|
return;
|
|
11017
11127
|
}
|
|
11018
11128
|
if (isClassNode(node)) {
|
|
11019
|
-
const inner = { thisIsState: false, aliases: scope.aliases };
|
|
11129
|
+
const inner = { thisIsState: false, aliases: scope.aliases, nested: true };
|
|
11020
11130
|
forEachChild(node, (child) => visit(child, inner, out));
|
|
11021
11131
|
return;
|
|
11022
11132
|
}
|
|
@@ -11031,10 +11141,14 @@ function visit(node, scope, out) {
|
|
|
11031
11141
|
visitCall(node, scope, out);
|
|
11032
11142
|
return;
|
|
11033
11143
|
case "AssignmentExpression":
|
|
11144
|
+
if (node.operator === "=" && node.left.type === "Identifier" && isThisRoot(node.right, scope)) return;
|
|
11034
11145
|
if (node.operator === "=") visitWriteTarget(node.left, scope, out);
|
|
11035
11146
|
else visitReadWriteTarget(node.left, scope, out);
|
|
11036
11147
|
visit(node.right, scope, out);
|
|
11037
11148
|
return;
|
|
11149
|
+
case "ThisExpression":
|
|
11150
|
+
if (scope.thisIsState) opaque(out, true, node.start, node.end, scope);
|
|
11151
|
+
return;
|
|
11038
11152
|
case "UpdateExpression":
|
|
11039
11153
|
visitReadWriteTarget(node.argument, scope, out);
|
|
11040
11154
|
return;
|
|
@@ -11048,7 +11162,7 @@ function visit(node, scope, out) {
|
|
|
11048
11162
|
function visitMember(node, scope, out, options) {
|
|
11049
11163
|
const { segments, base } = resolveChain(node);
|
|
11050
11164
|
if (isThisRoot(base, scope)) {
|
|
11051
|
-
emit(out, segments, options, node.start, node.end);
|
|
11165
|
+
emit(out, segments, options, node.start, node.end, scope);
|
|
11052
11166
|
} else {
|
|
11053
11167
|
visit(base, scope, out);
|
|
11054
11168
|
}
|
|
@@ -11062,8 +11176,9 @@ function visitCall(node, scope, out) {
|
|
|
11062
11176
|
const { segments, base } = resolveChain(callee);
|
|
11063
11177
|
if (isThisRoot(base, scope) && segments.length === 1 && segments[0].text !== null) {
|
|
11064
11178
|
const api = segments[0].text;
|
|
11065
|
-
if (UNTRACK_APIS.has(api)) return;
|
|
11066
|
-
|
|
11179
|
+
if (UNTRACK_APIS.has(api) && !collecting.untracked) return;
|
|
11180
|
+
const writes = collecting.writes === true && (WRITE_APIS.has(api) || collecting.resolveWrites === true && api === "$resolve" && node.arguments.length >= 3);
|
|
11181
|
+
if (PATH_ARG_APIS.has(api) && !writes) {
|
|
11067
11182
|
const first = node.arguments[0];
|
|
11068
11183
|
const path = first !== void 0 && first.type !== "SpreadElement" ? literalString(first) : null;
|
|
11069
11184
|
if (path !== null && path.length > 0 && !path.startsWith("$")) {
|
|
@@ -11073,10 +11188,29 @@ function visitCall(node, scope, out) {
|
|
|
11073
11188
|
form: TRACK_APIS.has(api) ? "track" : "api",
|
|
11074
11189
|
callee: false,
|
|
11075
11190
|
written: false,
|
|
11191
|
+
...scope.nested ? { nested: true } : {},
|
|
11076
11192
|
start: node.start - PREFIX.length,
|
|
11077
11193
|
end: node.end - PREFIX.length
|
|
11078
11194
|
});
|
|
11079
|
-
}
|
|
11195
|
+
} else if (path === null) opaque(out, false, node.start, node.end, scope);
|
|
11196
|
+
for (const argument of node.arguments) visit(argument, scope, out);
|
|
11197
|
+
return;
|
|
11198
|
+
}
|
|
11199
|
+
if (writes) {
|
|
11200
|
+
const first = node.arguments[0];
|
|
11201
|
+
const path = first !== void 0 && first.type !== "SpreadElement" ? literalString(first) : null;
|
|
11202
|
+
if (path !== null && path.length > 0 && !path.startsWith("$")) {
|
|
11203
|
+
out.push({
|
|
11204
|
+
path,
|
|
11205
|
+
chain: null,
|
|
11206
|
+
form: "api-write",
|
|
11207
|
+
callee: false,
|
|
11208
|
+
written: false,
|
|
11209
|
+
...scope.nested ? { nested: true } : {},
|
|
11210
|
+
start: first.start - PREFIX.length,
|
|
11211
|
+
end: first.end - PREFIX.length
|
|
11212
|
+
});
|
|
11213
|
+
} else if (path === null) opaque(out, true, node.start, node.end, scope);
|
|
11080
11214
|
for (const argument of node.arguments) visit(argument, scope, out);
|
|
11081
11215
|
return;
|
|
11082
11216
|
}
|
|
@@ -11095,6 +11229,7 @@ function visitWriteTarget(target, scope, out) {
|
|
|
11095
11229
|
}
|
|
11096
11230
|
const { segments, base } = resolveChain(unwrapped);
|
|
11097
11231
|
if (!isThisRoot(base, scope)) visit(base, scope, out);
|
|
11232
|
+
else if (collecting.writes) emit(out, segments, { form: "write", callee: false, written: false }, unwrapped.start, unwrapped.end, scope);
|
|
11098
11233
|
for (const segment of segments) {
|
|
11099
11234
|
if (segment.dynamic !== null) visit(segment.dynamic, scope, out);
|
|
11100
11235
|
}
|
|
@@ -11142,7 +11277,7 @@ function visitDestructure(pattern, prefix, scope, out) {
|
|
|
11142
11277
|
visitDestructure(value, segments, scope, out);
|
|
11143
11278
|
continue;
|
|
11144
11279
|
}
|
|
11145
|
-
emit(out, segments, { form: "destructure", callee: false, written: false }, property.start, property.end);
|
|
11280
|
+
emit(out, segments, { form: "destructure", callee: false, written: false }, property.start, property.end, scope);
|
|
11146
11281
|
}
|
|
11147
11282
|
}
|
|
11148
11283
|
function collectThisMemberRefs(body, names2) {
|
|
@@ -11525,8 +11660,14 @@ var ja = {
|
|
|
11525
11660
|
getterReadsLocation: (read) => `\u3053\u306E getter \u306F ${read} \u3092\u8AAD\u3093\u3067\u3044\u307E\u3059\u304C\u3001location \u306F state \u3067\u306F\u306A\u3044\u306E\u3067\u3001\u6700\u521D\u306B\u8AAD\u3093\u3060 URL \u3092\u6301\u3061\u7D9A\u3051\u307E\u3059\uFF08\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u3067\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002URL \u306F state \u3092\u901A\u3057\u3066\u8AAD\u3093\u3067\u304F\u3060\u3055\u3044 \u2014 <wcs-router> \u306E path / searchParams \u3092\u675F\u306D\u308B`,
|
|
11526
11661
|
getterReadsClock: (read) => `\u3053\u306E getter \u306F ${read} \u3092\u8AAD\u3093\u3067\u3044\u307E\u3059\u304C\u3001\u6642\u523B\u306F state \u3067\u306F\u306A\u3044\u306E\u3067\u4F9D\u5B58\u3068\u3057\u3066\u767B\u9332\u3055\u308C\u305A\u3001getter \u306F\u30AD\u30E3\u30C3\u30B7\u30E5\u3057\u305F\u6700\u521D\u306E\u5024\u3092\u8FD4\u3057\u7D9A\u3051\u307E\u3059\uFF08\u30A4\u30D9\u30F3\u30C8\u30C8\u30FC\u30AF\u30F3\u3067\u6BCE\u30D5\u30EC\u30FC\u30E0\u300C\u63CF\u304D\u76F4\u3057\u300D\u3066\u3082\u5909\u308F\u308A\u307E\u305B\u3093\uFF09\u3002\u6642\u523B\u3092 state \u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044 \u2014 <wcs-raf> \u3084 <wcs-timer> \u304C\u66F8\u304F\u5024\u3092\u675F\u306D\u308B`,
|
|
11527
11662
|
updatedCallbackUnknownPath: (p) => `"${p}" \u306F state \u306E\u30D1\u30B9\u3067\u306F\u306A\u3044\u306E\u3067 $renderedCallback \u306E paths \u306B\u73FE\u308C\u305A\u3001\u3053\u306E\u5206\u5C90\u306F\u4E00\u5EA6\u3082\u5B9F\u884C\u3055\u308C\u307E\u305B\u3093`,
|
|
11528
|
-
commandTokenUnbound: (t) => `\u30B3\u30DE\u30F3\u30C9\u30C8\u30FC\u30AF\u30F3 "${t}" \u3092 emit \u3057\u3066\u3044\u307E\u3059\u304C\u3001\u3053\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u305D\u308C\u3092\u53D7\u3051\u308B command.<\u30E1\u30BD\u30C3\u30C9>: ${t} \u306E\u675F\u7E1B\u304C\u3042\u308A\u307E\u305B\u3093\u3002emit \u306F\u8AB0\u306B\u3082\u5C4A\u304D\u307E\u305B\u3093\u3002\u30E1\u30BD\u30C3\u30C9\u3092\u547C\u3076\u8981\u7D20\u306B\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08command
|
|
11663
|
+
commandTokenUnbound: (t) => `\u30B3\u30DE\u30F3\u30C9\u30C8\u30FC\u30AF\u30F3 "${t}" \u3092 emit \u3057\u3066\u3044\u307E\u3059\u304C\u3001\u3053\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u305D\u308C\u3092\u53D7\u3051\u308B command.<\u30E1\u30BD\u30C3\u30C9>: ${t} \u306E\u675F\u7E1B\u304C\u3042\u308A\u307E\u305B\u3093\u3002emit \u306F\u8AB0\u306B\u3082\u5C4A\u304D\u307E\u305B\u3093\u3002\u30E1\u30BD\u30C3\u30C9\u3092\u547C\u3076\u8981\u7D20\u306B\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08command.<\u30E1\u30BD\u30C3\u30C9>: ${t} \u2014 <\u30E1\u30BD\u30C3\u30C9> \u306F\u305D\u306E\u8981\u7D20\u306E\u30E1\u30BD\u30C3\u30C9\u306E\u540D\u524D\uFF09`,
|
|
11529
11664
|
writePathMissing: (k) => `"${k}" \u306F state \u304C\u5BA3\u8A00\u3057\u3066\u3044\u306A\u3044\u30AD\u30FC\u3067\u3059\u3002\u66F8\u304D\u8FBC\u307F\u306F\u65B0\u3057\u3044\u30AD\u30FC\u3092\u4F5C\u308B\u3060\u3051\u3067\u3001\u5BA3\u8A00\u3057\u305F\u30AD\u30FC\u306E\u675F\u7E1B\u306B\u306F\u5C4A\u304D\u307E\u305B\u3093`,
|
|
11665
|
+
pathReadonlyWrite: (p) => `"${p}" \u306F setter \u306E\u7121\u3044 getter \u306A\u306E\u3067\u3001\u3053\u306E\u66F8\u304D\u8FBC\u307F\u306F\u5B9F\u884C\u306E\u305F\u3073\u306B\u4F8B\u5916\u306B\u306A\u308A\u307E\u3059\uFF08"${p}" is a getter without a setter\uFF09\u3002getter \u304C\u8AAD\u3080\u5024\u3092\u66F8\u304F setter \u3092\u8DB3\u3059\uFF08set "${p}"(v) { \u2026 }\uFF09\u304B\u3001\u305D\u306E\u5024\u3092\u76F4\u63A5\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`,
|
|
11666
|
+
getterWrite: (p, g, via) => `getter "${g}" \u306E\u8A55\u4FA1\u4E2D\u306B "${p}" \u3092\u66F8\u3044\u3066\u3044\u307E\u3059${via === void 0 ? "" : `\uFF08\u547C\u3093\u3067\u3044\u308B\u30E1\u30BD\u30C3\u30C9 "${via}" \u306E\u4E2D\uFF09`}\u3002getter \u306F\u8AAD\u3080\u3060\u3051\u3067\u3001\u66F8\u304D\u8FBC\u307F\u306F\u8A55\u4FA1\u306E\u305F\u3073\u306B\u4F8B\u5916\u306B\u306A\u308A\u307E\u3059\u3002\u30E1\u30BD\u30C3\u30C9\u30FBsetter\u30FB$watch \u306E\u30CF\u30F3\u30C9\u30E9\u304B\u3089\u66F8\u304F\u304B\u3001\u5024\u3092\u5225\u306E getter \u3067\u8A08\u7B97\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
11667
|
+
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`,
|
|
11668
|
+
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`,
|
|
11669
|
+
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`,
|
|
11670
|
+
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`,
|
|
11530
11671
|
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`,
|
|
11531
11672
|
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`,
|
|
11532
11673
|
pathDynamicUnknownValue: (path, n, name, from) => `"${path}" \u306E\u5024${name === void 0 ? "" : from === void 0 ? `\uFF08${name}\uFF09` : `\uFF08${name}\u3002"${from}" \u304B\u3089 import\uFF09`}\u306F\u9759\u7684\u306B\u8AAD\u3081\u306A\u3044\u306E\u3067\u3001\u305D\u306E\u4E0B\u306B\u675F\u306D\u305F\u30D1\u30B9\uFF08${n} \u4EF6\uFF09\u306F\u691C\u67FB\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u30AD\u30FC\u306B JSDoc \u306E @type \u2014 \u5F62\u304B\u3001\u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u30EA\u30C6\u30E9\u30EB\u3092\u6307\u3059 typeof import("./file.js").name\uFF08\u8F9E\u66F8\u306A\u3089\u5168\u90E8\u306E\u30AD\u30FC\u3092\u6301\u3064\u65E2\u5B9A\u306E\u8A00\u8A9E\u306E\u30D5\u30A1\u30A4\u30EB\uFF09\u2014 \u3092\u4ED8\u3051\u308B\u304B\u3001wcstack.manifest.json \u306E stateSchema \u306B\u5BA3\u8A00\u3059\u308B\u3068\u691C\u67FB\u3055\u308C\u307E\u3059`,
|
|
@@ -11628,6 +11769,8 @@ var ja = {
|
|
|
11628
11769
|
return `$watch \u306E\u30AD\u30FC "${p}" \u306B "**" \u306F\u4F7F\u3048\u307E\u305B\u3093\u3002\u76E3\u8996\u306F\u5177\u4F53\u30D1\u30B9\uFF08\u56FA\u5B9A\u672C\u6570\u306E "*"\uFF09\u306B\u5BFE\u3057\u3066\u306E\u307F\u6210\u7ACB\u3057\u307E\u3059`;
|
|
11629
11770
|
case "resolve":
|
|
11630
11771
|
return `$resolve("${p}") \u306B "**" \u306F\u6E21\u305B\u307E\u305B\u3093\u3002$resolve \u306F\u5C55\u958B\u5F8C\u306E\u5177\u4F53\u30D1\u30B9\u3068\u6DFB\u5B57\u30BF\u30D7\u30EB\u306E\u53B3\u5BC6\u4E00\u81F4\u3060\u3051\u3092\u53D7\u3051\u4ED8\u3051\u307E\u3059`;
|
|
11772
|
+
case "update":
|
|
11773
|
+
return `$update("${p}") \u306B "**" \u306F\u6E21\u305B\u307E\u305B\u3093\u3002$update \u306F 1 \u3064\u306E\u30A2\u30C9\u30EC\u30B9\uFF08\u5C55\u958B\u5F8C\u306E\u5177\u4F53\u30D1\u30B9\u3068\u6DFB\u5B57\u30BF\u30D7\u30EB\u306E\u53B3\u5BC6\u4E00\u81F4\uFF09\u3060\u3051\u3092\u66F8\u304D\u63DB\u3048\u307E\u3059 \u2014 \u5168\u6DF1\u3055\u3078\u306F $setAll("${p}", [], value) \u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`;
|
|
11631
11774
|
case "assignment":
|
|
11632
11775
|
return `this["${p}"] \u3078\u306E\u4EE3\u5165\u306B "**" \u306F\u4F7F\u3048\u307E\u305B\u3093\uFF08\u518D\u5E30 setter \u306F\u521D\u7248\u3067\u306F\u6301\u3066\u305A\u3001\u4EE3\u5165\u306F\u5C55\u958B\u5F8C\u306E\u5177\u4F53\u30D1\u30B9\u306B\u3057\u304B\u6210\u7ACB\u3057\u307E\u305B\u3093\uFF09\u3002$setAll("${p}", [], value) \u3067\u5168\u6DF1\u3055\u3078\u30D6\u30ED\u30FC\u30C9\u30AD\u30E3\u30B9\u30C8\u3059\u308B\u304B\u3001\u5177\u4F53\u30D1\u30B9\u3078\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`;
|
|
11633
11776
|
case "postUpdate":
|
|
@@ -11742,8 +11885,14 @@ var en = {
|
|
|
11742
11885
|
getterReadsLocation: (read) => `This getter reads ${read}, which is not state: it keeps the URL it first read (a navigation does not re-evaluate it). Read the URL through state \u2014 bind <wcs-router>'s path / searchParams`,
|
|
11743
11886
|
getterReadsClock: (read) => `This getter reads ${read}. The time is not state, so it is not a dependency: the getter is cached and keeps returning its first value (an event token "redrawing" every frame does not change it). Keep the time in state \u2014 bind the value <wcs-raf> or <wcs-timer> writes`,
|
|
11744
11887
|
updatedCallbackUnknownPath: (p) => `"${p}" is not a path of this state, so it is never in $renderedCallback's paths and this branch never runs`,
|
|
11745
|
-
commandTokenUnbound: (t) => `The command token "${t}" is emitted, but no command.<method>: ${t} binding in this document receives it, so the emit reaches nothing. Bind it on the element whose method it should call (command
|
|
11888
|
+
commandTokenUnbound: (t) => `The command token "${t}" is emitted, but no command.<method>: ${t} binding in this document receives it, so the emit reaches nothing. Bind it on the element whose method it should call (command.<method>: ${t}, with <method> the name of that element's method)`,
|
|
11746
11889
|
writePathMissing: (k) => `"${k}" is not a key the state declares. The write creates a new key and reaches no binding of a declared one`,
|
|
11890
|
+
pathReadonlyWrite: (p) => `"${p}" is a getter without a setter, so this write throws each time it runs ("${p}" is a getter without a setter). Add a setter that writes what the getter reads (set "${p}"(v) { \u2026 }), or write those values instead`,
|
|
11891
|
+
getterWrite: (p, g, via) => `The getter "${g}" writes "${p}" while it is evaluated${via === void 0 ? "" : ` (in the method "${via}" it calls)`}. A getter only reads: the write throws each time the getter is evaluated. Write it from a method, a setter or a $watch handler, or compute the value in a getter of its own`,
|
|
11892
|
+
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()})`,
|
|
11893
|
+
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`,
|
|
11894
|
+
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`,
|
|
11895
|
+
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`,
|
|
11747
11896
|
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`,
|
|
11748
11897
|
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`,
|
|
11749
11898
|
pathDynamicUnknownValue: (path, n, name, from) => `The value of "${path}"${name === void 0 ? "" : from === void 0 ? ` (${name})` : ` (${name}, imported from "${from}")`} cannot be read statically, so the ${n === 1 ? "path" : `${n} paths`} bound under it ${n === 1 ? "is" : "are"} not checked. Give the key a JSDoc @type \u2014 its shape, or typeof import("./file.js").name for a module's literal (for a dictionary, the default language's file, which has every key) \u2014 or declare it in the stateSchema of wcstack.manifest.json to have them checked`,
|
|
@@ -11845,6 +11994,8 @@ var en = {
|
|
|
11845
11994
|
return `$watch key "${p}" cannot contain "**" \u2014 watching is defined against a concrete path (a fixed number of "*")`;
|
|
11846
11995
|
case "resolve":
|
|
11847
11996
|
return `$resolve("${p}") cannot take "**" \u2014 it accepts only an expanded concrete path with an exactly matching index tuple`;
|
|
11997
|
+
case "update":
|
|
11998
|
+
return `$update("${p}") cannot take "**" \u2014 it changes one address (an expanded concrete path with an exactly matching index tuple). Write every depth with $setAll("${p}", [], value)`;
|
|
11848
11999
|
case "assignment":
|
|
11849
12000
|
return `this["${p}"] = \u2026 cannot use "**" (there are no recursive setters in this version; an assignment only resolves against an expanded concrete path). Broadcast with $setAll("${p}", [], value), or write a concrete path`;
|
|
11850
12001
|
case "postUpdate":
|
|
@@ -16428,9 +16579,10 @@ function validateScanDeclarations(html, stateTagName = "wcs-state", locale2) {
|
|
|
16428
16579
|
}
|
|
16429
16580
|
|
|
16430
16581
|
// src/service/recursionValidator.ts
|
|
16431
|
-
var RECURSION_APIS = ["getAll", "setAll", "resolve", "postUpdate", "dependOn", "trackDependency"];
|
|
16582
|
+
var RECURSION_APIS = ["getAll", "setAll", "resolve", "update", "postUpdate", "dependOn", "trackDependency"];
|
|
16432
16583
|
var UNSUPPORTED_API_SITE = {
|
|
16433
16584
|
$resolve: "resolve",
|
|
16585
|
+
$update: "update",
|
|
16434
16586
|
$postUpdate: "postUpdate",
|
|
16435
16587
|
$dependOn: "dependOn",
|
|
16436
16588
|
$trackDependency: "trackDependency"
|
|
@@ -16680,7 +16832,7 @@ function validateApiCalls(script, offset2, spec, getterSuffixes, undeclared, msg
|
|
|
16680
16832
|
const start = offset2 + parsed.starts[0] + leading;
|
|
16681
16833
|
const end = offset2 + parsed.starts[0] + pathArg.trimEnd().length;
|
|
16682
16834
|
if (!hasRecursionWildcard(path)) {
|
|
16683
|
-
const writes = api === "$setAll" || api === "$resolve" && parsed.args.length >= 3;
|
|
16835
|
+
const writes = api === "$setAll" || api === "$update" || api === "$resolve" && parsed.args.length >= 3;
|
|
16684
16836
|
if (writes && spec !== null) {
|
|
16685
16837
|
const owning = owningGetterSuffix(spec, getterSuffixes, path);
|
|
16686
16838
|
if (owning !== null) {
|
|
@@ -17431,7 +17583,7 @@ function validateNameAliases(script, scriptStart, locale2, mountPath = null) {
|
|
|
17431
17583
|
for (const span of spans) pushDeclaration(span.name, span.start, span.end, "error");
|
|
17432
17584
|
return out;
|
|
17433
17585
|
}
|
|
17434
|
-
var API_CALL = /\.\s*\$(getAll|setAll|resolve)\s*\(/g;
|
|
17586
|
+
var API_CALL = /\.\s*\$(getAll|setAll|resolve|update)\s*\(/g;
|
|
17435
17587
|
function validateIndexArity(script, scriptStart, locale2) {
|
|
17436
17588
|
const msgs = getMessages(locale2);
|
|
17437
17589
|
const out = [];
|
|
@@ -17450,7 +17602,7 @@ function validateIndexArity(script, scriptStart, locale2) {
|
|
|
17450
17602
|
const actual = literalArrayLength(parsed.args[1]);
|
|
17451
17603
|
if (actual === null) continue;
|
|
17452
17604
|
const wildcardCount = countWildcardSegments(path);
|
|
17453
|
-
const requirement = api === "$resolve" ? "exact" : "atMost";
|
|
17605
|
+
const requirement = api === "$resolve" || api === "$update" ? "exact" : "atMost";
|
|
17454
17606
|
const mismatched = requirement === "exact" ? actual !== wildcardCount : actual > wildcardCount;
|
|
17455
17607
|
if (!mismatched) continue;
|
|
17456
17608
|
const argText = parsed.args[1];
|
|
@@ -17808,7 +17960,7 @@ function collectNestedWriteRoots(html, stateTagName, bindAttrName, blocks) {
|
|
|
17808
17960
|
API_CALL.lastIndex = parsed.end;
|
|
17809
17961
|
const path = parsed.args.length > 0 ? literalString2(parsed.args[0]) : null;
|
|
17810
17962
|
if (path === null) continue;
|
|
17811
|
-
if (api === "setAll" || parsed.args.length >= 3) addPrefixes(path, false);
|
|
17963
|
+
if (api === "setAll" || api === "update" || parsed.args.length >= 3) addPrefixes(path, false);
|
|
17812
17964
|
}
|
|
17813
17965
|
}
|
|
17814
17966
|
return roots;
|
|
@@ -18127,9 +18279,9 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
|
|
|
18127
18279
|
}
|
|
18128
18280
|
const prefix = block.mountPath === null || block.mountPath === "" ? "" : `${block.mountPath}.`;
|
|
18129
18281
|
if (applicationSchema === void 0) {
|
|
18130
|
-
const
|
|
18131
|
-
const spans =
|
|
18132
|
-
for (const candidate of
|
|
18282
|
+
const opaque2 = analyzeStatePaths(block.content, moduleLocationOf(fileReader, block.modulePath)).filter((p) => p.opaque !== void 0);
|
|
18283
|
+
const spans = opaque2.length === 0 ? [] : analyzeDeclarationSpans(block.content);
|
|
18284
|
+
for (const candidate of opaque2) {
|
|
18133
18285
|
const path = prefix + candidate.path;
|
|
18134
18286
|
bound ??= buildReferenceIndex(html, { bindAttribute, stateTagName }).occurrences.filter((o) => o.kind === "path").map((o) => hasIndexSegment(o.path) ? toWildcardForm(o.path) : o.path);
|
|
18135
18287
|
const count = bound.filter((b) => b.startsWith(`${path}.`)).length;
|
|
@@ -18145,9 +18297,12 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
|
|
|
18145
18297
|
}
|
|
18146
18298
|
}
|
|
18147
18299
|
for (const callable of analyzeCallableBodies(block.content)) {
|
|
18148
|
-
for (const read of collectGetterReads(callable.body) ?? []) {
|
|
18149
|
-
|
|
18300
|
+
for (const read of collectGetterReads(callable.body, { templates: true, writes: true }) ?? []) {
|
|
18301
|
+
const write = read.written || read.form === "write" || read.form === "api-write";
|
|
18302
|
+
if (write && read.form !== "api-write" && !read.path.includes(".")) continue;
|
|
18303
|
+
if (read.path.split(".").some((s) => s === "" || s.startsWith("$")) || hasRecursionWildcard(read.path)) continue;
|
|
18150
18304
|
const path = prefix + read.path;
|
|
18305
|
+
if (read.indexed !== void 0 && !read.indexed.every((list) => isList(prefix + list, candidates, candidateSet))) continue;
|
|
18151
18306
|
if (pathExistsInCandidates(path, candidates, candidateSet)) continue;
|
|
18152
18307
|
if (applicationSchema !== void 0 ? resolveIndexedSchemaPath(applicationSchema, path).kind !== "nonexistent" : isUnresolvedPath(path, index.scopes)) continue;
|
|
18153
18308
|
const near = nearName(path, tree ??= treeOf(candidates));
|
|
@@ -18155,19 +18310,24 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
|
|
|
18155
18310
|
const said = suggestion(near.segment, near.names, msgs);
|
|
18156
18311
|
if (said === "") continue;
|
|
18157
18312
|
const at2 = block.contentStart + callable.bodyStart;
|
|
18313
|
+
const member = read.form === "member" || read.form === "write";
|
|
18158
18314
|
out.push({
|
|
18159
|
-
code: WcsDiagnosticCode.ReadPathMissing,
|
|
18315
|
+
code: write ? WcsDiagnosticCode.WritePathMissing : WcsDiagnosticCode.ReadPathMissing,
|
|
18160
18316
|
start: at2 + read.start,
|
|
18161
|
-
end:
|
|
18162
|
-
message: msgs.readPathMissing(read.path, !read.path.includes(".")) + said,
|
|
18163
|
-
// a stateSchema says the path is not there, as for a binding's `wcs/path-nonexistent`
|
|
18164
|
-
|
|
18317
|
+
end: member ? at2 + read.start + statePart(callable.body.slice(read.start, read.end)) : at2 + read.end,
|
|
18318
|
+
message: (write ? msgs.nestedWritePathMissing(read.path) : msgs.readPathMissing(read.path, !read.path.includes("."))) + said,
|
|
18319
|
+
// a stateSchema says the path is not there, as for a binding's `wcs/path-nonexistent` (a write stays a
|
|
18320
|
+
// warning, as the top-level one: a key the state adds on purpose is not a mistake)
|
|
18321
|
+
severity: !write && applicationSchema !== void 0 ? "error" : "warning"
|
|
18165
18322
|
});
|
|
18166
18323
|
}
|
|
18167
18324
|
}
|
|
18168
18325
|
}
|
|
18169
18326
|
return out;
|
|
18170
18327
|
}
|
|
18328
|
+
function isList(path, candidates, candidateSet) {
|
|
18329
|
+
return candidateSet.has(`${path}.*`) || candidates.some((c) => c.path === path && c.kind === "list");
|
|
18330
|
+
}
|
|
18171
18331
|
var THIS_PART = /^this\s*(?:\?\.\s*|\.\s*)(?:[A-Za-z_$][\w$]*)|^this\s*(?:\?\.)?\s*\[\s*(["'`])[^"'`]*\1\s*\]/;
|
|
18172
18332
|
function statePart(text3) {
|
|
18173
18333
|
return THIS_PART.exec(text3)?.[0].length ?? text3.length;
|
|
@@ -18198,6 +18358,204 @@ function nearName(path, tree) {
|
|
|
18198
18358
|
return null;
|
|
18199
18359
|
}
|
|
18200
18360
|
|
|
18361
|
+
// src/service/scriptWriteValidator.ts
|
|
18362
|
+
var OPTIONS = { writes: true, templates: true, resolveWrites: true, untracked: true, opaque: true };
|
|
18363
|
+
function isWrite(read) {
|
|
18364
|
+
return read.form === "write" || read.form === "api-write" || read.written && read.form !== "opaque";
|
|
18365
|
+
}
|
|
18366
|
+
function bodyOf(callable) {
|
|
18367
|
+
const found = collectGetterReads(callable.body, OPTIONS);
|
|
18368
|
+
if (found === null) return { callable, writes: [], reads: [], calls: [], opaque: true };
|
|
18369
|
+
const writes = [];
|
|
18370
|
+
const reads = [];
|
|
18371
|
+
const calls = [];
|
|
18372
|
+
let opaque2 = false;
|
|
18373
|
+
for (const read of found) {
|
|
18374
|
+
const at2 = { start: callable.bodyStart + read.start, end: callable.bodyStart + read.end, nested: read.nested === true };
|
|
18375
|
+
if (read.form === "opaque") {
|
|
18376
|
+
opaque2 = true;
|
|
18377
|
+
continue;
|
|
18378
|
+
}
|
|
18379
|
+
if (isWrite(read)) {
|
|
18380
|
+
const state = read.form === "api-write" || read.chain !== null && read.chain.length === 1;
|
|
18381
|
+
writes.push({ path: read.form === "api-write" ? read.path : read.chain?.join(".") ?? read.path, state, ...at2 });
|
|
18382
|
+
if (read.form === "member") reads.push({ path: read.path, ...at2 });
|
|
18383
|
+
continue;
|
|
18384
|
+
}
|
|
18385
|
+
if (read.callee && read.chain !== null && read.chain.length === 1) calls.push({ path: read.chain[0], ...at2 });
|
|
18386
|
+
reads.push({ path: read.path, ...at2 });
|
|
18387
|
+
}
|
|
18388
|
+
return { callable, writes, reads, calls, opaque: opaque2 };
|
|
18389
|
+
}
|
|
18390
|
+
function overlaps(a, b) {
|
|
18391
|
+
const x = toWildcardForm(a).split(".");
|
|
18392
|
+
const y = toWildcardForm(b).split(".");
|
|
18393
|
+
for (let i = 0; i < Math.min(x.length, y.length); i++) {
|
|
18394
|
+
if (x[i] !== y[i] && x[i] !== "*" && y[i] !== "*") return false;
|
|
18395
|
+
}
|
|
18396
|
+
return true;
|
|
18397
|
+
}
|
|
18398
|
+
function syncWrites(body, state, seen2 = /* @__PURE__ */ new Set()) {
|
|
18399
|
+
if (seen2.has(body)) return [];
|
|
18400
|
+
seen2.add(body);
|
|
18401
|
+
const out = body.writes.filter((w) => w.state === true && !w.nested);
|
|
18402
|
+
for (const call of body.calls) {
|
|
18403
|
+
const method = state.methods.get(call.path);
|
|
18404
|
+
if (!call.nested && method !== void 0) out.push(...syncWrites(method, state, seen2));
|
|
18405
|
+
}
|
|
18406
|
+
return out;
|
|
18407
|
+
}
|
|
18408
|
+
function allWrites(body, state, seen2 = /* @__PURE__ */ new Set()) {
|
|
18409
|
+
const out = /* @__PURE__ */ new Set();
|
|
18410
|
+
if (seen2.has(body)) return out;
|
|
18411
|
+
seen2.add(body);
|
|
18412
|
+
if (body.opaque) return null;
|
|
18413
|
+
for (const w of body.writes) {
|
|
18414
|
+
out.add(w.path);
|
|
18415
|
+
const setter = state.setters.get(toWildcardForm(w.path));
|
|
18416
|
+
if (setter === void 0) continue;
|
|
18417
|
+
const more = allWrites(setter, state, seen2);
|
|
18418
|
+
if (more === null) return null;
|
|
18419
|
+
for (const p of more) out.add(p);
|
|
18420
|
+
}
|
|
18421
|
+
for (const call of body.calls) {
|
|
18422
|
+
const method = state.methods.get(call.path);
|
|
18423
|
+
if (method === void 0) return null;
|
|
18424
|
+
const more = allWrites(method, state, seen2);
|
|
18425
|
+
if (more === null) return null;
|
|
18426
|
+
for (const p of more) out.add(p);
|
|
18427
|
+
}
|
|
18428
|
+
return out;
|
|
18429
|
+
}
|
|
18430
|
+
function allReads(body, state, seen2 = /* @__PURE__ */ new Set()) {
|
|
18431
|
+
const out = /* @__PURE__ */ new Set();
|
|
18432
|
+
if (seen2.has(body)) return out;
|
|
18433
|
+
seen2.add(body);
|
|
18434
|
+
if (body.opaque) return null;
|
|
18435
|
+
for (const r of body.reads) {
|
|
18436
|
+
out.add(r.path);
|
|
18437
|
+
const getter = state.getters.get(r.path);
|
|
18438
|
+
if (getter !== void 0) {
|
|
18439
|
+
const more = allReads(getter, state, seen2);
|
|
18440
|
+
if (more === null) return null;
|
|
18441
|
+
for (const p of more) out.add(p);
|
|
18442
|
+
}
|
|
18443
|
+
}
|
|
18444
|
+
for (const call of body.calls) {
|
|
18445
|
+
const method = state.methods.get(call.path);
|
|
18446
|
+
if (method === void 0) return null;
|
|
18447
|
+
const more = allReads(method, state, seen2);
|
|
18448
|
+
if (more === null) return null;
|
|
18449
|
+
for (const p of more) out.add(p);
|
|
18450
|
+
}
|
|
18451
|
+
return out;
|
|
18452
|
+
}
|
|
18453
|
+
function validateScriptWrites(html, stateTagName = "wcs-state", locale2) {
|
|
18454
|
+
const blocks = parseLoadedScriptBlocks(html, stateTagName).filter((block) => hasDefaultExportObject(block.content));
|
|
18455
|
+
if (blocks.length === 0) return [];
|
|
18456
|
+
const msgs = getMessages(locale2);
|
|
18457
|
+
const out = [];
|
|
18458
|
+
for (const block of blocks) {
|
|
18459
|
+
const getters = /* @__PURE__ */ new Map();
|
|
18460
|
+
const setters = /* @__PURE__ */ new Map();
|
|
18461
|
+
const methods = /* @__PURE__ */ new Map();
|
|
18462
|
+
for (const callable of analyzeCallableBodies(block.content)) {
|
|
18463
|
+
const body = bodyOf(callable);
|
|
18464
|
+
if (callable.kind === "method") methods.set(callable.name, body);
|
|
18465
|
+
else (callable.accessor === "set" ? setters : getters).set(callable.name, body);
|
|
18466
|
+
}
|
|
18467
|
+
const state = { getters, setters, methods };
|
|
18468
|
+
const at2 = (start, end) => ({ start: block.contentStart + start, end: block.contentStart + end });
|
|
18469
|
+
out.push(...getterWrites(state, msgs, at2));
|
|
18470
|
+
if (isReadableStateScript(block.content)) out.push(...readonlyWrites(state, msgs, at2));
|
|
18471
|
+
out.push(...setterCycles(state, msgs, at2));
|
|
18472
|
+
out.push(...unobservedSetters(state, msgs, at2));
|
|
18473
|
+
}
|
|
18474
|
+
return out;
|
|
18475
|
+
}
|
|
18476
|
+
function getterWrites(state, msgs, at2) {
|
|
18477
|
+
const out = [];
|
|
18478
|
+
for (const [name, getter] of state.getters) {
|
|
18479
|
+
for (const w of getter.writes) {
|
|
18480
|
+
if (w.state !== true || w.nested) continue;
|
|
18481
|
+
out.push({ code: WcsDiagnosticCode.GetterWrite, ...at2(w.start, w.end), message: msgs.getterWrite(w.path, name), severity: "error" });
|
|
18482
|
+
}
|
|
18483
|
+
for (const call of getter.calls) {
|
|
18484
|
+
const method = state.methods.get(call.path);
|
|
18485
|
+
if (call.nested || method === void 0) continue;
|
|
18486
|
+
const writes = syncWrites(method, state);
|
|
18487
|
+
if (writes.length === 0) continue;
|
|
18488
|
+
out.push({ code: WcsDiagnosticCode.GetterWrite, ...at2(call.start, call.end), message: msgs.getterWrite(writes[0].path, name, call.path), severity: "error" });
|
|
18489
|
+
}
|
|
18490
|
+
}
|
|
18491
|
+
return out;
|
|
18492
|
+
}
|
|
18493
|
+
function readonlyWrites(state, msgs, at2) {
|
|
18494
|
+
const readonly = new Set([...state.getters.keys()].filter((name) => !state.setters.has(name)));
|
|
18495
|
+
if (readonly.size === 0) return [];
|
|
18496
|
+
const out = [];
|
|
18497
|
+
for (const body of [...state.methods.values(), ...state.setters.values()]) {
|
|
18498
|
+
for (const w of body.writes) {
|
|
18499
|
+
const path = toWildcardForm(w.path);
|
|
18500
|
+
if (w.state !== true || hasRecursionWildcard(path) || !readonly.has(path)) continue;
|
|
18501
|
+
out.push({ code: WcsDiagnosticCode.PathReadonly, ...at2(w.start, w.end), message: msgs.pathReadonlyWrite(path), severity: "error" });
|
|
18502
|
+
}
|
|
18503
|
+
}
|
|
18504
|
+
return out;
|
|
18505
|
+
}
|
|
18506
|
+
function setterCycles(state, msgs, at2) {
|
|
18507
|
+
const out = [];
|
|
18508
|
+
const edges = /* @__PURE__ */ new Map();
|
|
18509
|
+
for (const [name, setter] of state.setters) {
|
|
18510
|
+
const targets = new Set(syncWrites(setter, state).map((w) => toWildcardForm(w.path)).filter((p) => state.setters.has(p)));
|
|
18511
|
+
if (targets.has(name)) {
|
|
18512
|
+
out.push({ code: WcsDiagnosticCode.SetterCycle, ...at2(setter.callable.start, setter.callable.end), message: msgs.setterCycleSelf(name), severity: "error" });
|
|
18513
|
+
targets.delete(name);
|
|
18514
|
+
}
|
|
18515
|
+
edges.set(name, [...targets]);
|
|
18516
|
+
}
|
|
18517
|
+
const gray = /* @__PURE__ */ new Set();
|
|
18518
|
+
const black = /* @__PURE__ */ new Set();
|
|
18519
|
+
const stack = [];
|
|
18520
|
+
const cycles = /* @__PURE__ */ new Map();
|
|
18521
|
+
const visit2 = (name) => {
|
|
18522
|
+
if (black.has(name)) return;
|
|
18523
|
+
if (gray.has(name)) {
|
|
18524
|
+
const from = stack.indexOf(name);
|
|
18525
|
+
const cycle = [...stack.slice(from), name].map((p) => `"${p}"`).join(" -> ");
|
|
18526
|
+
for (const member of stack.slice(from)) if (!cycles.has(member)) cycles.set(member, cycle);
|
|
18527
|
+
return;
|
|
18528
|
+
}
|
|
18529
|
+
gray.add(name);
|
|
18530
|
+
stack.push(name);
|
|
18531
|
+
for (const next of edges.get(name) ?? []) visit2(next);
|
|
18532
|
+
stack.pop();
|
|
18533
|
+
gray.delete(name);
|
|
18534
|
+
black.add(name);
|
|
18535
|
+
};
|
|
18536
|
+
for (const name of state.setters.keys()) visit2(name);
|
|
18537
|
+
for (const [name, cycle] of cycles) {
|
|
18538
|
+
const setter = state.setters.get(name);
|
|
18539
|
+
out.push({ code: WcsDiagnosticCode.SetterCycle, ...at2(setter.callable.start, setter.callable.end), message: msgs.setterCycle(cycle), severity: "warning" });
|
|
18540
|
+
}
|
|
18541
|
+
return out;
|
|
18542
|
+
}
|
|
18543
|
+
function unobservedSetters(state, msgs, at2) {
|
|
18544
|
+
const out = [];
|
|
18545
|
+
for (const [name, setter] of state.setters) {
|
|
18546
|
+
const getter = state.getters.get(name);
|
|
18547
|
+
if (getter === void 0) continue;
|
|
18548
|
+
const writes = allWrites(setter, state);
|
|
18549
|
+
if (writes === null || writes.size === 0 || [...writes].some((w) => toWildcardForm(w) === name)) continue;
|
|
18550
|
+
const reads = allReads(getter, state);
|
|
18551
|
+
if (reads === null || reads.size === 0) continue;
|
|
18552
|
+
if ([...writes].some((w) => [...reads].some((r) => overlaps(w, r)))) continue;
|
|
18553
|
+
const listed = [...writes].map((w) => `"${w}"`).join(", ");
|
|
18554
|
+
out.push({ code: WcsDiagnosticCode.SetterUnobserved, ...at2(setter.callable.start, setter.callable.end), message: msgs.setterUnobserved(name, listed), severity: "warning" });
|
|
18555
|
+
}
|
|
18556
|
+
return out;
|
|
18557
|
+
}
|
|
18558
|
+
|
|
18201
18559
|
// src/service/stateSourceValidator.ts
|
|
18202
18560
|
function validateStateSources(html, stateTagName = "wcs-state", locale2, fileReader) {
|
|
18203
18561
|
if (fileReader === void 0) return [];
|
|
@@ -18720,6 +19078,7 @@ function validateText(text3, options, applicationSchema) {
|
|
|
18720
19078
|
out.push(...validateSemantics(text3, stateTagName, locale2, bindAttribute));
|
|
18721
19079
|
out.push(...validateScriptStateUses(text3, stateTagName, locale2, bindAttribute));
|
|
18722
19080
|
out.push(...validateScriptReads(text3, stateTagName, locale2, fileReader, applicationSchema, bindAttribute));
|
|
19081
|
+
out.push(...validateScriptWrites(text3, stateTagName, locale2));
|
|
18723
19082
|
out.push(...validateArrayMutations(text3, stateTagName, locale2));
|
|
18724
19083
|
out.push(...validateWatchDeclarations(text3, stateTagName, locale2, fileReader));
|
|
18725
19084
|
out.push(...validateScanDeclarations(text3, stateTagName, locale2));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/lint",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.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": {
|