@wcstack/lint 4.23.0 → 4.24.1
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 +13 -0
- package/README.md +13 -0
- package/dist/cli.cjs +398 -28
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -130,6 +130,19 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
|
|
|
130
130
|
|
|
131
131
|
新しい 3 つの規則は warning です: `--strict` では失敗し、`--errors-only` には出ません。
|
|
132
132
|
|
|
133
|
+
## 長いリストのページに言うこと
|
|
134
|
+
|
|
135
|
+
4.24 から、継ぎ目アプリ town-archive — 写真 12,000 枚のアーカイブ。長いリストと無限スクロールのページ — から。そのページの誤りのうち、この lint が言わなかったもの:
|
|
136
|
+
|
|
137
|
+
- **`wcs/body-binding`**(error) — `<body>` / `<html>` に書いた `data-wcs`(`<body data-wcs="onkeydown: onKey; class.dark: dark">`)。`<wcs-state>` が束ねるのは `<body>` の中で、`<body>` と `<html>` そのものは束ねないので、そこに書いた束縛は何もしません: ハンドラは走らず、`class.` も `attr.` も書かれません。束縛を `<body>` の中の要素(包む要素・`<main>`)へ移すか、値を `$connectedCallback` や `$watch` のハンドラから書いてください(`document.documentElement.lang = …`)。
|
|
138
|
+
- **`wcs/link-handler`**(error) — `<wcs-link>` の束縛に書いた `on*:`(`<wcs-link data-wcs="attr.to: .href; onclick: openPhoto">`)。リンクのホストは `display: none` で、利用者がクリックするのはリンクが自分の隣に作る `<a>` なので、ハンドラは走りません。ハンドラはリンクの中の要素(子は `<a>` の中へ移ります)か、リンクを囲む要素に書いてください。ハンドラから遷移するなら、router の `navigateUrl` に書きます。
|
|
139
|
+
- **`wcs/root-margin-unit`**(warning) — `<wcs-intersect>` / `<wcs-infinite-scroll>` の、ブラウザが拒むリテラルの `root-margin`: `root-margin="200"`・`"0 0 900 0"`。`IntersectionObserver` が受けるのは 1〜4 個の値で、それぞれ `px` か `%` の付いた数値です — `0` にも単位が要るので、`"0 0 900px 0"` も拒まれます(`rootMargin must be specified in pixels or percent`)。そのとき `<wcs-intersect>` は何も監視せず(`observing` は `false` のまま)、`<wcs-infinite-scroll>` は次のページを読み込みません。文面は `px` を足した書き方(`root-margin="0px 0px 900px 0px"`)を言います。束ねた `rootMargin:` は検査しません。
|
|
140
|
+
- **`wcs/getter-untracked-read`** は、ウィンドウと文書を読む getter も報告します: `innerWidth` / `innerHeight` / `outerWidth` / `outerHeight`、`devicePixelRatio`、`scrollX` / `scrollY` / `pageXOffset` / `pageYOffset`、`matchMedia(…)` の呼び出し、`navigator.onLine`、`document.documentElement` / `document.body` / `document.scrollingElement` の `clientWidth` / `clientHeight` / `scrollTop` / `scrollLeft`、`document.visibilityState` / `document.hidden` — `window.` / `globalThis.` の有無によりません。どれも state ではないので、キャッシュされた getter は最初の値を持ち続けます(`innerWidth` から列数を決める getter は、リサイズしても変わりません)。文面は代わりに束ねるものを言います: `<wcs-resize>` の `width` / `height`、`<wcs-media-query>` の `matched`(`matchMedia`・ブレークポイント・解像度のしきい値)、`<wcs-network>` の `offline`。スクロール位置とページの可視性を出す要素は無いので、値を state に置いてイベントハンドラから書いてください。getter やモジュールが束縛する名前(`const innerWidth = …`・引数)と、state の同名のキー(`this.innerWidth`)は報告しません。
|
|
141
|
+
- **`wcs/delegated-current-target`** は、ハンドラに入れ子にした関数の中も読みます: `openPhoto(event) { return this.photos.find((p) => String(p.id) === event.currentTarget.closest(".card").dataset.id); }` を、ハンドラの本体での読みと同じに報告します。引数を影にする関数と、`setTimeout`・`requestAnimationFrame`・`.then(…)`・`addEventListener` に渡した関数・オブジェクトに置いた関数(`img.onload = () => …`)は報告しません: その関数は dispatch の後に走り、`currentTarget` はどちらにしても `null` です。
|
|
142
|
+
- **JSDoc の 1 つのブロックの `@typedef` をすべて読みます。** 4.23 までは先頭の 1 つだけを読み(1 つのコメントに `/** @typedef {…} Photo` と `@typedef {…} Area */`)、2 つ目の型のリスト(`/** @type {Area[]} */ areas: []`)は、行のフィールドごとに `wcs/binding-path-missing` の誤報になりました。
|
|
143
|
+
|
|
144
|
+
新しい 2 つの error は `--errors-only` にも出ます。新しい warning は `--strict` で失敗します。
|
|
145
|
+
|
|
133
146
|
## 生成 → 検証 → 修正ループでの利用
|
|
134
147
|
|
|
135
148
|
安定した diagnostic code・`source:line:col` range・exit code 契約により、CI のゲートにも AI コード生成フローにもそのまま組み込めます: HTML を生成 → `npx @wcstack/lint --errors-only` → 診断を読んで修正 → exit code `0` になるまで再実行。このゲートが覆うのは `data-wcs` のページです: 出力が `not read:` や `nothing to check:` で終わるときは、そのファイルは検査されていません。
|
package/README.md
CHANGED
|
@@ -130,6 +130,19 @@ Since 4.23, from the ekiden-entry seam app — an entry wizard for a relay race,
|
|
|
130
130
|
|
|
131
131
|
The three new rules are warnings: `--strict` fails on them, `--errors-only` does not print them.
|
|
132
132
|
|
|
133
|
+
## What a long list's page is told
|
|
134
|
+
|
|
135
|
+
Since 4.24, from the town-archive seam app — an archive of 12,000 photos: a long list with infinite scroll. What its page got wrong and this lint did not say:
|
|
136
|
+
|
|
137
|
+
- **`wcs/body-binding`** (error) — `data-wcs` on `<body>` or `<html>` (`<body data-wcs="onkeydown: onKey; class.dark: dark">`). `<wcs-state>` binds what is inside `<body>`, not `<body>` or `<html>` themselves, so nothing written there does anything: the handler never runs, `class.` and `attr.` are never written. Move the binding to an element inside `<body>` (a wrapper, `<main>`), or write the value from `$connectedCallback` or a `$watch` handler (`document.documentElement.lang = …`).
|
|
138
|
+
- **`wcs/link-handler`** (error) — an `on*:` binding on a `<wcs-link>` (`<wcs-link data-wcs="attr.to: .href; onclick: openPhoto">`). The link's host is `display: none`, and what the user clicks is the `<a>` the link generates beside itself, so the handler never runs. Put it on an element inside the link (its children move into the `<a>`) or on one around it; to navigate from a handler, write the router's `navigateUrl`.
|
|
139
|
+
- **`wcs/root-margin-unit`** (warning) — a literal `root-margin` on `<wcs-intersect>` or `<wcs-infinite-scroll>` that the browser refuses: `root-margin="200"`, `"0 0 900 0"`. `IntersectionObserver` takes one to four values, each a number with `px` or `%` — a `0` needs its unit too, so `"0 0 900px 0"` is refused as well (`rootMargin must be specified in pixels or percent`). `<wcs-intersect>` then observes nothing (`observing` stays `false`) and `<wcs-infinite-scroll>` loads no page. The message gives the value with `px` added (`root-margin="0px 0px 900px 0px"`). A bound `rootMargin:` is not checked.
|
|
140
|
+
- **`wcs/getter-untracked-read`** also reports a getter that reads the window or the document: `innerWidth` / `innerHeight` / `outerWidth` / `outerHeight`, `devicePixelRatio`, `scrollX` / `scrollY` / `pageXOffset` / `pageYOffset`, a call of `matchMedia(…)`, `navigator.onLine`, the `clientWidth` / `clientHeight` / `scrollTop` / `scrollLeft` of `document.documentElement` / `document.body` / `document.scrollingElement`, `document.visibilityState` / `document.hidden` — with or without `window.` / `globalThis.`. None of them is state, so the cached getter keeps its first value (a column count computed from `innerWidth` does not change on a resize). The message names what to bind instead: `<wcs-resize>`'s `width` / `height`, `<wcs-media-query>`'s `matched` (for `matchMedia`, a breakpoint, a resolution threshold), `<wcs-network>`'s `offline`. No element gives the scroll position or the page's visibility: keep the value in state and write it from an event handler. A name the getter or the module binds (`const innerWidth = …`, a parameter) and a state key of the same name (`this.innerWidth`) are not reported.
|
|
141
|
+
- **`wcs/delegated-current-target`** also reads the functions nested in the handler: `openPhoto(event) { return this.photos.find((p) => String(p.id) === event.currentTarget.closest(".card").dataset.id); }` is reported like a read in the handler's own body. Not a function that shadows the parameter, nor one handed to `setTimeout`, `requestAnimationFrame`, `.then(…)` or `addEventListener`, nor one stored on an object (`img.onload = () => …`): such a function runs after the dispatch, when `currentTarget` is `null` either way.
|
|
142
|
+
- **Every `@typedef` of a JSDoc block is read.** Up to 4.23 only the first one of a block was (`/** @typedef {…} Photo` and `@typedef {…} Area */` in one comment), and a list typed with the second (`/** @type {Area[]} */ areas: []`) got a false `wcs/binding-path-missing` for each field of its rows.
|
|
143
|
+
|
|
144
|
+
`--errors-only` prints the two new errors; `--strict` also fails on the new warning.
|
|
145
|
+
|
|
133
146
|
## Use in generate–validate–fix loops
|
|
134
147
|
|
|
135
148
|
Stable diagnostic codes, `source:line:col` ranges, and the exit-code contract make this CLI a drop-in gate for CI and for AI code-generation flows: generate HTML → `npx @wcstack/lint --errors-only` → read the diagnostics, fix, and re-run until exit code `0`. The gate covers `data-wcs` pages: when the output ends with `not read:` or `nothing to check:`, those files were not checked.
|
package/dist/cli.cjs
CHANGED
|
@@ -290,7 +290,8 @@ var WcsDiagnosticCode = {
|
|
|
290
290
|
// の依存で足りる — 行の置換は `items` 自体を書き換え、in-place 変異は array-mutation が止める)。
|
|
291
291
|
// 読んだパスをページの束縛(組み込みタグの spread・書き戻す束縛・要素の出力)が書くなら error(その書き込みは
|
|
292
292
|
// getter に届かないと断定できる — 継ぎ目アプリ family-ledger)、スクリプトの書き込みだけなら warning(ルートも
|
|
293
|
-
// 置き換えるなら壊れない)。時刻・`location
|
|
293
|
+
// 置き換えるなら壊れない)。時刻・`location`・ウィンドウと文書の値(`innerWidth`・`scrollY`・`matchMedia(…)`・
|
|
294
|
+
// `navigator.onLine`・`document.hidden` など)を読む getter も同じ code(warning)。
|
|
294
295
|
GetterUntrackedRead: "wcs/getter-untracked-read",
|
|
295
296
|
OnHandlerThis: "wcs/on-handler-this",
|
|
296
297
|
// --- <wcs-state> script: $watch declaration ---
|
|
@@ -369,7 +370,8 @@ var WcsDiagnosticCode = {
|
|
|
369
370
|
// `currentTarget` を同期的に読む。委譲されたイベントの `currentTarget` は要素ではなく root なので、要素を
|
|
370
371
|
// 使う処理(`setPointerCapture`・`getBoundingClientRect`・`new FormData(e.currentTarget)`)が壊れる。
|
|
371
372
|
// ランタイムは何も報告しない(root は正しい値)ので lint の code。`#direct` か `event.target.closest(...)` を
|
|
372
|
-
// 案内する。読みが実行されない分岐にあることもあるので warning
|
|
373
|
+
// 案内する。読みが実行されない分岐にあることもあるので warning。本体に入れ子にした関数の中の読み
|
|
374
|
+
// (`this.items.find((x) => … event.currentTarget …)`)も拾う — 後で呼ばれる関数(`setTimeout` などに渡したもの)は除く。
|
|
373
375
|
DelegatedCurrentTarget: "wcs/delegated-current-target",
|
|
374
376
|
// `<form data-wcs="onsubmit: login">` の `#prevent` 忘れ(ハンドラも preventDefault を呼ばない)。ブラウザが
|
|
375
377
|
// フォームも送る — ページが読み直されるか、router があれば GET が欄(パスワードも)を URL と履歴に載せる
|
|
@@ -451,6 +453,22 @@ var WcsDiagnosticCode = {
|
|
|
451
453
|
// `value#onchange|number: price|toFixed(2)`)が無いときだけ報告する。要素の書いた文字をそのまま返すフィルタ
|
|
452
454
|
// (`string`・`nullIfEmpty`・`coalesce(…)`・`defaults('')`)と `#ro` では黙る。warning。
|
|
453
455
|
TwoWayOutputFilter: "wcs/two-way-output-filter",
|
|
456
|
+
// --- 束縛を書いた要素(その要素では束縛が働かない。service/bindingHostValidator.ts — 継ぎ目アプリ town-archive) ---
|
|
457
|
+
// `<body>` / `<html>` に書いた束縛の属性(`<body data-wcs="onkeydown: onKey; class.dark: dark">`)。`<wcs-state>` が束ねるのは
|
|
458
|
+
// `<body>` の中で、`<body>` と `<html>` そのものは束ねない(state の dom/mount.ts は `document.body` の子から歩く)ので、
|
|
459
|
+
// そこに書いた束縛は何もしない — イベントのハンドラは走らず、`class.` / `attr.` は書かれない。4.23 までランタイムは
|
|
460
|
+
// 何も言わない(4.24 から diagnostics の後付けが同じ code で警告する)。束縛は `<body>` の中の要素へ移すか、値を
|
|
461
|
+
// `$connectedCallback` / `$watch` から書く。error。
|
|
462
|
+
BodyBinding: "wcs/body-binding",
|
|
463
|
+
// `<wcs-link>` の束縛に書いた `on*:`(`<wcs-link data-wcs="attr.to: .href; onclick: openPhoto">`)。リンクのホストは
|
|
464
|
+
// `display: none` で、利用者がクリックするのはリンクが自分の隣に作る `<a>` なので、ハンドラは走らない。ハンドラは
|
|
465
|
+
// リンクの中の要素(子は `<a>` へ移る)か囲む要素に書き、ハンドラから遷移するなら router の `navigateUrl` に書く。error。
|
|
466
|
+
LinkHandler: "wcs/link-handler",
|
|
467
|
+
// `<wcs-intersect>` / `<wcs-infinite-scroll>` のリテラルの `root-margin` をブラウザが拒む(`root-margin="200"`・
|
|
468
|
+
// `"0 0 900 0"`): 値は 1〜4 個、それぞれ px か % の付いた数値で、0 にも単位が要る(Chromium・Firefox で確かめた —
|
|
469
|
+
// `rootMargin must be specified in pixels or percent`)。`<wcs-intersect>` は何も監視せず `observing` が false のまま、
|
|
470
|
+
// `<wcs-infinite-scroll>` は次のページを読み込まない。束ねた値(`rootMargin: …`)は検査しない。warning。
|
|
471
|
+
RootMarginUnit: "wcs/root-margin-unit",
|
|
454
472
|
// --- document-level load configuration ---
|
|
455
473
|
// @wcstack/state/auto より後に @wcstack/devtools/auto が読まれている。info: 4.0 は後から付いた DevTools に
|
|
456
474
|
// 既存の束縛を送り直すので、欠けるのは付く前のタイムラインだけ。
|
|
@@ -2583,7 +2601,7 @@ function getWcsManifest() {
|
|
|
2583
2601
|
}
|
|
2584
2602
|
|
|
2585
2603
|
// ../state/package.json
|
|
2586
|
-
var version = "4.
|
|
2604
|
+
var version = "4.24.1";
|
|
2587
2605
|
|
|
2588
2606
|
// src/service/wcsManifest.ts
|
|
2589
2607
|
var ENGINE_VERSION = version;
|
|
@@ -8651,8 +8669,10 @@ function findJsDocComments(script, scan) {
|
|
|
8651
8669
|
function readJsDocTagType(comment, tag) {
|
|
8652
8670
|
return readBracedType(comment, tag)?.type.trim() ?? null;
|
|
8653
8671
|
}
|
|
8654
|
-
function readBracedType(comment, tag) {
|
|
8655
|
-
const
|
|
8672
|
+
function readBracedType(comment, tag, from = 0) {
|
|
8673
|
+
const tagRegex = new RegExp(`@${tag}\\s*\\{`, "g");
|
|
8674
|
+
tagRegex.lastIndex = from;
|
|
8675
|
+
const tagMatch = tagRegex.exec(comment);
|
|
8656
8676
|
if (!tagMatch) return null;
|
|
8657
8677
|
const open = tagMatch.index + tagMatch[0].length - 1;
|
|
8658
8678
|
let depth = 0;
|
|
@@ -8689,11 +8709,15 @@ function jsDocCommentBefore(content, propIndex) {
|
|
|
8689
8709
|
function collectJsDocTypedefs(script, scan) {
|
|
8690
8710
|
const typedefs = /* @__PURE__ */ new Map();
|
|
8691
8711
|
for (const { text: comment } of findJsDocComments(script, scan)) {
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8712
|
+
let from = 0;
|
|
8713
|
+
for (; ; ) {
|
|
8714
|
+
const braced = readBracedType(comment, "typedef", from);
|
|
8715
|
+
if (braced === null) break;
|
|
8716
|
+
from = braced.end;
|
|
8717
|
+
const name = /^\s*([$A-Za-z_][$\w]*)/.exec(comment.slice(braced.end));
|
|
8718
|
+
const type = parseJsDocType(braced.type);
|
|
8719
|
+
if (name && type !== null) typedefs.set(name[1], type);
|
|
8720
|
+
}
|
|
8697
8721
|
}
|
|
8698
8722
|
return typedefs;
|
|
8699
8723
|
}
|
|
@@ -11730,28 +11754,35 @@ ${body}
|
|
|
11730
11754
|
const eventName = first.name;
|
|
11731
11755
|
const rebound = /* @__PURE__ */ new Set();
|
|
11732
11756
|
for (const param of fn.params.slice(1)) bindingNames(param, rebound);
|
|
11733
|
-
|
|
11734
|
-
const scanBindings = (node, nested) => {
|
|
11757
|
+
const scanBindings = (node) => {
|
|
11735
11758
|
if (isFunctionNode(node)) {
|
|
11736
11759
|
if (node.type === "FunctionDeclaration" && node.id !== null) rebound.add(node.id.name);
|
|
11737
11760
|
for (const param of node.params) bindingNames(param, rebound);
|
|
11738
|
-
|
|
11739
|
-
return;
|
|
11740
|
-
}
|
|
11741
|
-
if (node.type === "VariableDeclarator") bindingNames(node.id, rebound);
|
|
11761
|
+
} else if (node.type === "VariableDeclarator") bindingNames(node.id, rebound);
|
|
11742
11762
|
else if (node.type === "CatchClause" && node.param !== null && node.param !== void 0) bindingNames(node.param, rebound);
|
|
11743
11763
|
else if (node.type === "AssignmentExpression" && node.left.type === "Identifier") rebound.add(node.left.name);
|
|
11744
11764
|
else if (node.type === "ClassDeclaration" && node.id !== null) rebound.add(node.id.name);
|
|
11745
|
-
|
|
11746
|
-
else if (!nested && node.type === "ForOfStatement" && node.await) suspendAt = Math.min(suspendAt, node.right.end);
|
|
11747
|
-
forEachChild(node, (child) => scanBindings(child, nested));
|
|
11765
|
+
forEachChild(node, scanBindings);
|
|
11748
11766
|
};
|
|
11749
|
-
scanBindings(fn.body
|
|
11767
|
+
scanBindings(fn.body);
|
|
11750
11768
|
if (rebound.has(eventName)) return false;
|
|
11751
11769
|
let found = false;
|
|
11752
|
-
const visitReads = (node) => {
|
|
11753
|
-
if (found ||
|
|
11754
|
-
if (node
|
|
11770
|
+
const visitReads = (node, suspendAt) => {
|
|
11771
|
+
if (found || isClassNode(node) || node.start >= suspendAt) return;
|
|
11772
|
+
if (isFunctionNode(node)) {
|
|
11773
|
+
const limit = Math.min(suspendAt, firstSuspend(node.body));
|
|
11774
|
+
forEachChild(node, (child) => visitReads(child, limit));
|
|
11775
|
+
return;
|
|
11776
|
+
}
|
|
11777
|
+
if (node.type === "CallExpression" && isDeferredCall(node)) {
|
|
11778
|
+
visitReads(node.callee, suspendAt);
|
|
11779
|
+
for (const argument of node.arguments) if (!isFunctionNode(argument)) visitReads(argument, suspendAt);
|
|
11780
|
+
return;
|
|
11781
|
+
}
|
|
11782
|
+
if (node.type === "AssignmentExpression" && isFunctionNode(node.right) && unwrapChain(node.left).type === "MemberExpression") {
|
|
11783
|
+
visitReads(node.left, suspendAt);
|
|
11784
|
+
return;
|
|
11785
|
+
}
|
|
11755
11786
|
if (node.type === "MemberExpression" && node.object.type === "Identifier" && node.object.name === eventName && memberPropertyIs(node, "currentTarget")) {
|
|
11756
11787
|
found = true;
|
|
11757
11788
|
return;
|
|
@@ -11760,11 +11791,38 @@ ${body}
|
|
|
11760
11791
|
found = true;
|
|
11761
11792
|
return;
|
|
11762
11793
|
}
|
|
11763
|
-
forEachChild(node, visitReads);
|
|
11794
|
+
forEachChild(node, (child) => visitReads(child, suspendAt));
|
|
11764
11795
|
};
|
|
11765
|
-
visitReads(fn.body);
|
|
11796
|
+
visitReads(fn.body, firstSuspend(fn.body));
|
|
11766
11797
|
return found;
|
|
11767
11798
|
}
|
|
11799
|
+
var DEFERRED_CALLS = /* @__PURE__ */ new Set([
|
|
11800
|
+
"setTimeout",
|
|
11801
|
+
"setInterval",
|
|
11802
|
+
"requestAnimationFrame",
|
|
11803
|
+
"requestIdleCallback",
|
|
11804
|
+
"queueMicrotask",
|
|
11805
|
+
"then",
|
|
11806
|
+
"catch",
|
|
11807
|
+
"finally",
|
|
11808
|
+
"addEventListener"
|
|
11809
|
+
]);
|
|
11810
|
+
function isDeferredCall(node) {
|
|
11811
|
+
const callee = unwrapChain(node.callee);
|
|
11812
|
+
if (callee.type === "Identifier") return DEFERRED_CALLS.has(callee.name);
|
|
11813
|
+
return callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier" && DEFERRED_CALLS.has(callee.property.name);
|
|
11814
|
+
}
|
|
11815
|
+
function firstSuspend(body) {
|
|
11816
|
+
let at2 = Infinity;
|
|
11817
|
+
const scan = (node) => {
|
|
11818
|
+
if (isFunctionNode(node) || isClassNode(node)) return;
|
|
11819
|
+
if (node.type === "AwaitExpression") at2 = Math.min(at2, node.argument.end);
|
|
11820
|
+
else if (node.type === "ForOfStatement" && node.await) at2 = Math.min(at2, node.right.end);
|
|
11821
|
+
forEachChild(node, scan);
|
|
11822
|
+
};
|
|
11823
|
+
scan(body);
|
|
11824
|
+
return at2;
|
|
11825
|
+
}
|
|
11768
11826
|
function memberPropertyIs(node, name) {
|
|
11769
11827
|
const property = node.property;
|
|
11770
11828
|
if (!node.computed) return property.type === "Identifier" && property.name === name;
|
|
@@ -11991,12 +12049,158 @@ function findLocationRead(body) {
|
|
|
11991
12049
|
walk2(wrapper.body);
|
|
11992
12050
|
return found;
|
|
11993
12051
|
}
|
|
12052
|
+
var WINDOW_HOLDERS = /* @__PURE__ */ new Set(["window", "globalThis", "self"]);
|
|
12053
|
+
var WINDOW_VALUES = /* @__PURE__ */ new Map([
|
|
12054
|
+
["innerWidth", "size"],
|
|
12055
|
+
["innerHeight", "size"],
|
|
12056
|
+
["outerWidth", "size"],
|
|
12057
|
+
["outerHeight", "size"],
|
|
12058
|
+
["devicePixelRatio", "pixelRatio"],
|
|
12059
|
+
["scrollX", "scroll"],
|
|
12060
|
+
["scrollY", "scroll"],
|
|
12061
|
+
["pageXOffset", "scroll"],
|
|
12062
|
+
["pageYOffset", "scroll"]
|
|
12063
|
+
]);
|
|
12064
|
+
var DOCUMENT_ELEMENTS = /* @__PURE__ */ new Set(["documentElement", "body", "scrollingElement"]);
|
|
12065
|
+
var ELEMENT_VALUES = /* @__PURE__ */ new Map([
|
|
12066
|
+
["clientWidth", "size"],
|
|
12067
|
+
["clientHeight", "size"],
|
|
12068
|
+
["scrollTop", "scroll"],
|
|
12069
|
+
["scrollLeft", "scroll"]
|
|
12070
|
+
]);
|
|
12071
|
+
var DOCUMENT_VALUES = /* @__PURE__ */ new Map([["visibilityState", "visibility"], ["hidden", "visibility"]]);
|
|
12072
|
+
var AMBIENT_READ_SPELLING = /\b(?:(?:inner|outer|client)(?:Width|Height)|devicePixelRatio|scroll[XY]|page[XY]Offset|scroll(?:Top|Left)|matchMedia|onLine|visibilityState|hidden)\b/;
|
|
12073
|
+
function ambientKindOf(names2) {
|
|
12074
|
+
if (names2.length === 1) return WINDOW_VALUES.get(names2[0]) ?? null;
|
|
12075
|
+
if (names2[0] === "navigator") return names2.length === 2 && names2[1] === "onLine" ? "online" : null;
|
|
12076
|
+
if (names2[0] !== "document") return null;
|
|
12077
|
+
if (names2.length === 2) return DOCUMENT_VALUES.get(names2[1]) ?? null;
|
|
12078
|
+
return names2.length === 3 && DOCUMENT_ELEMENTS.has(names2[1]) ? ELEMENT_VALUES.get(names2[2]) ?? null : null;
|
|
12079
|
+
}
|
|
12080
|
+
function findAmbientRead(body, outer = /* @__PURE__ */ new Set()) {
|
|
12081
|
+
let program;
|
|
12082
|
+
try {
|
|
12083
|
+
program = parse3(PREFIX + body + SUFFIX, { ecmaVersion: "latest", sourceType: "module" });
|
|
12084
|
+
} catch {
|
|
12085
|
+
return null;
|
|
12086
|
+
}
|
|
12087
|
+
const wrapper = unwrapWrapper(program);
|
|
12088
|
+
if (wrapper === null) return null;
|
|
12089
|
+
const bound = new Set(outer);
|
|
12090
|
+
const scan = (node) => {
|
|
12091
|
+
if (isFunctionNode(node)) {
|
|
12092
|
+
if (node.type === "FunctionDeclaration" && node.id !== null) bound.add(node.id.name);
|
|
12093
|
+
for (const param of node.params) bindingNames(param, bound);
|
|
12094
|
+
} else if (node.type === "VariableDeclarator") bindingNames(node.id, bound);
|
|
12095
|
+
else if (node.type === "CatchClause" && node.param !== null && node.param !== void 0) bindingNames(node.param, bound);
|
|
12096
|
+
else if (node.type === "ClassDeclaration" && node.id !== null) bound.add(node.id.name);
|
|
12097
|
+
forEachChild(node, scan);
|
|
12098
|
+
};
|
|
12099
|
+
scan(wrapper.body);
|
|
12100
|
+
const globalChain = (node) => {
|
|
12101
|
+
const names2 = [];
|
|
12102
|
+
let current2 = unwrapChain(node);
|
|
12103
|
+
while (current2.type === "MemberExpression") {
|
|
12104
|
+
const property = current2.property;
|
|
12105
|
+
if (!current2.computed && property.type === "Identifier") names2.unshift(property.name);
|
|
12106
|
+
else if (current2.computed && property.type === "Literal" && typeof property.value === "string") names2.unshift(property.value);
|
|
12107
|
+
else return null;
|
|
12108
|
+
current2 = unwrapChain(current2.object);
|
|
12109
|
+
}
|
|
12110
|
+
if (current2.type !== "Identifier" || bound.has(current2.name)) return null;
|
|
12111
|
+
names2.unshift(current2.name);
|
|
12112
|
+
while (names2.length > 1 && WINDOW_HOLDERS.has(names2[0])) names2.shift();
|
|
12113
|
+
return names2;
|
|
12114
|
+
};
|
|
12115
|
+
let found = null;
|
|
12116
|
+
const source = (node) => (PREFIX + body).slice(node.start, node.end);
|
|
12117
|
+
const at2 = (node, kind, text3) => {
|
|
12118
|
+
found = { start: node.start - PREFIX.length, end: node.end - PREFIX.length, text: text3, kind };
|
|
12119
|
+
};
|
|
12120
|
+
const walk2 = (node) => {
|
|
12121
|
+
if (found !== null) return;
|
|
12122
|
+
if (node.type === "CallExpression") {
|
|
12123
|
+
const chain = globalChain(node.callee);
|
|
12124
|
+
if (chain !== null && chain.length === 1 && chain[0] === "matchMedia") {
|
|
12125
|
+
at2(node.callee, "media", `${source(node.callee)}(\u2026)`);
|
|
12126
|
+
return;
|
|
12127
|
+
}
|
|
12128
|
+
}
|
|
12129
|
+
if (node.type === "Identifier" || node.type === "MemberExpression") {
|
|
12130
|
+
const chain = globalChain(node);
|
|
12131
|
+
const kind = chain === null ? null : ambientKindOf(chain);
|
|
12132
|
+
if (kind !== null) {
|
|
12133
|
+
at2(node, kind, source(node));
|
|
12134
|
+
return;
|
|
12135
|
+
}
|
|
12136
|
+
}
|
|
12137
|
+
if (node.type === "VariableDeclarator" && node.id.type === "ObjectPattern" && node.init !== null && node.init !== void 0) {
|
|
12138
|
+
const chain = globalChain(node.init);
|
|
12139
|
+
if (chain !== null) {
|
|
12140
|
+
const prefix = chain.length === 1 && WINDOW_HOLDERS.has(chain[0]) ? [] : chain;
|
|
12141
|
+
for (const property of node.id.properties) {
|
|
12142
|
+
if (property.type !== "Property" || property.computed) continue;
|
|
12143
|
+
const key = property.key.type === "Identifier" ? property.key.name : property.key.type === "Literal" && typeof property.key.value === "string" ? property.key.value : null;
|
|
12144
|
+
const kind = key === null ? null : ambientKindOf([...prefix, key]);
|
|
12145
|
+
if (kind !== null) {
|
|
12146
|
+
at2(property.key, kind, `${source(node.init)}.${key}`);
|
|
12147
|
+
return;
|
|
12148
|
+
}
|
|
12149
|
+
}
|
|
12150
|
+
}
|
|
12151
|
+
}
|
|
12152
|
+
if (node.type === "MemberExpression") {
|
|
12153
|
+
walk2(node.object);
|
|
12154
|
+
if (node.computed) walk2(node.property);
|
|
12155
|
+
return;
|
|
12156
|
+
}
|
|
12157
|
+
if (node.type === "Property" || node.type === "MethodDefinition" || node.type === "PropertyDefinition") {
|
|
12158
|
+
if (node.computed) walk2(node.key);
|
|
12159
|
+
if (node.value !== null && node.value !== void 0) walk2(node.value);
|
|
12160
|
+
return;
|
|
12161
|
+
}
|
|
12162
|
+
if (node.type === "LabeledStatement") {
|
|
12163
|
+
walk2(node.body);
|
|
12164
|
+
return;
|
|
12165
|
+
}
|
|
12166
|
+
if (node.type === "BreakStatement" || node.type === "ContinueStatement") return;
|
|
12167
|
+
forEachChild(node, walk2);
|
|
12168
|
+
};
|
|
12169
|
+
walk2(wrapper.body);
|
|
12170
|
+
return found;
|
|
12171
|
+
}
|
|
12172
|
+
function moduleBindingNames(script) {
|
|
12173
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
12174
|
+
let program;
|
|
12175
|
+
try {
|
|
12176
|
+
program = parse3(script, { ecmaVersion: "latest", sourceType: "module", allowHashBang: true, allowAwaitOutsideFunction: true });
|
|
12177
|
+
} catch {
|
|
12178
|
+
return names2;
|
|
12179
|
+
}
|
|
12180
|
+
if (program.type !== "Program") return names2;
|
|
12181
|
+
for (const statement of program.body) {
|
|
12182
|
+
if (statement.type === "ImportDeclaration") {
|
|
12183
|
+
for (const specifier of statement.specifiers) names2.add(specifier.local.name);
|
|
12184
|
+
continue;
|
|
12185
|
+
}
|
|
12186
|
+
const declaration = statement.type === "ExportNamedDeclaration" && statement.declaration ? statement.declaration : statement;
|
|
12187
|
+
if (declaration.type === "VariableDeclaration") {
|
|
12188
|
+
for (const declarator of declaration.declarations) bindingNames(declarator.id, names2);
|
|
12189
|
+
} else if ((declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration") && declaration.id) {
|
|
12190
|
+
names2.add(declaration.id.name);
|
|
12191
|
+
}
|
|
12192
|
+
}
|
|
12193
|
+
return names2;
|
|
12194
|
+
}
|
|
11994
12195
|
|
|
11995
12196
|
// src/core/messages.ts
|
|
11996
12197
|
function resolveLocale(locale2) {
|
|
11997
12198
|
if (locale2 === void 0 || locale2 === "" || /^ja\b|^ja[-_]/i.test(locale2) || locale2.toLowerCase() === "ja") return "ja";
|
|
11998
12199
|
return "en";
|
|
11999
12200
|
}
|
|
12201
|
+
function isUnitlessZero(token) {
|
|
12202
|
+
return /^[+-]?(?:0+\.?0*|\.0+)$/.test(token);
|
|
12203
|
+
}
|
|
12000
12204
|
function shortSeed(raw) {
|
|
12001
12205
|
const flat = raw.replace(/\s+/g, " ");
|
|
12002
12206
|
return flat.length <= 32 ? flat : `${flat.slice(0, 29)}\u2026`;
|
|
@@ -12033,6 +12237,23 @@ var ja = {
|
|
|
12033
12237
|
onHandlerThis: (name) => `$on \u306E\u30CF\u30F3\u30C9\u30E9 "${name}" \u304C this \u3092\u4F7F\u3063\u3066\u3044\u307E\u3059\u3002$on \u306E\u30CF\u30F3\u30C9\u30E9\u306F state \u3092\u7B2C 1 \u5F15\u6570\u3067\u53D7\u3051\u53D6\u308A\uFF08\`${name}(state, event) { state.x = \u2026 }\`\uFF09\u3001this \u306F undefined \u306A\u306E\u3067\u3001this.\u2026 \u306F\u547C\u3070\u308C\u305F\u3068\u304D\u306B\u4F8B\u5916\u306B\u306A\u308A\u307E\u3059\u3002$watch \u3084\u30E1\u30BD\u30C3\u30C9\u3068\u9055\u3046\u70B9\u306B\u6CE8\u610F`,
|
|
12034
12238
|
getterReadsLocation: (read) => `\u3053\u306E getter \u306F ${read} \u3092\u8AAD\u3093\u3067\u3044\u307E\u3059\u304C\u3001location \u306F state \u3067\u306F\u306A\u3044\u306E\u3067\u3001\u6700\u521D\u306B\u8AAD\u3093\u3060 URL \u3092\u6301\u3061\u7D9A\u3051\u307E\u3059\uFF08\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u3067\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002URL \u306F state \u3092\u901A\u3057\u3066\u8AAD\u3093\u3067\u304F\u3060\u3055\u3044 \u2014 <wcs-router> \u306E path / searchParams \u3092\u675F\u306D\u308B`,
|
|
12035
12239
|
getterReadsClock: (read) => `\u3053\u306E getter \u306F ${read} \u3092\u8AAD\u3093\u3067\u3044\u307E\u3059\u304C\u3001\u6642\u523B\u306F state \u3067\u306F\u306A\u3044\u306E\u3067\u4F9D\u5B58\u3068\u3057\u3066\u767B\u9332\u3055\u308C\u305A\u3001getter \u306F\u30AD\u30E3\u30C3\u30B7\u30E5\u3057\u305F\u6700\u521D\u306E\u5024\u3092\u8FD4\u3057\u7D9A\u3051\u307E\u3059\uFF08\u30A4\u30D9\u30F3\u30C8\u30C8\u30FC\u30AF\u30F3\u3067\u6BCE\u30D5\u30EC\u30FC\u30E0\u300C\u63CF\u304D\u76F4\u3057\u300D\u3066\u3082\u5909\u308F\u308A\u307E\u305B\u3093\uFF09\u3002\u6642\u523B\u3092 state \u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044 \u2014 <wcs-raf> \u3084 <wcs-timer> \u304C\u66F8\u304F\u5024\u3092\u675F\u306D\u308B`,
|
|
12240
|
+
getterReadsAmbient: (read, kind) => {
|
|
12241
|
+
const head = `\u3053\u306E getter \u306F ${read} \u3092\u8AAD\u3093\u3067\u3044\u307E\u3059\u304C\u3001state \u3067\u306F\u306A\u3044\u306E\u3067\u4F9D\u5B58\u3068\u3057\u3066\u767B\u9332\u3055\u308C\u305A\u3001getter \u306F\u30AD\u30E3\u30C3\u30B7\u30E5\u3057\u305F\u6700\u521D\u306E\u5024\u3092\u8FD4\u3057\u7D9A\u3051\u307E\u3059`;
|
|
12242
|
+
switch (kind) {
|
|
12243
|
+
case "size":
|
|
12244
|
+
return `${head}\uFF08\u30EA\u30B5\u30A4\u30BA\u3057\u3066\u3082\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002\u5927\u304D\u3055\u3092 state \u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044 \u2014 <wcs-resize> \u304C\u66F8\u304F width / height \u3092\u675F\u306D\u308B\uFF08\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8\u306E\u5224\u5B9A\u306A\u3089 <wcs-media-query> \u306E matched\uFF09`;
|
|
12245
|
+
case "pixelRatio":
|
|
12246
|
+
return `${head}\uFF08\u62E1\u5927\u3057\u3066\u3082\u3001\u5225\u306E\u753B\u9762\u3078\u79FB\u3057\u3066\u3082\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002\u30DA\u30FC\u30B8\u304C\u4F7F\u3046\u89E3\u50CF\u5EA6\u306E\u3057\u304D\u3044\u5024\u3092 <wcs-media-query> \u306E matched \u3067\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08query="(min-resolution: 2dppx)"\uFF09`;
|
|
12247
|
+
case "media":
|
|
12248
|
+
return `${head}\uFF08\u30AF\u30A8\u30EA\u304C\u5408\u3046\u3088\u3046\u306B\u306A\u3063\u3066\u3082\u3001\u5408\u308F\u306A\u304F\u306A\u3063\u3066\u3082\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002<wcs-media-query> \u306E matched \u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08<wcs-media-query query="(max-width: 600px)" data-wcs="matched: narrow">\uFF09`;
|
|
12249
|
+
case "online":
|
|
12250
|
+
return `${head}\uFF08\u30AA\u30D5\u30E9\u30A4\u30F3\u306B\u306A\u3063\u3066\u3082\u3001\u623B\u3063\u3066\u3082\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002<wcs-network> \u306E offline \u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044`;
|
|
12251
|
+
case "scroll":
|
|
12252
|
+
return `${head}\uFF08\u30B9\u30AF\u30ED\u30FC\u30EB\u3057\u3066\u3082\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002\u30B9\u30AF\u30ED\u30FC\u30EB\u4F4D\u7F6E\u3092\u51FA\u3059 wcstack \u306E\u8981\u7D20\u306F\u7121\u3044\u306E\u3067\u3001\u5024\u3092 state \u306B\u7F6E\u304D\u3001\u30A4\u30D9\u30F3\u30C8\u30CF\u30F3\u30C9\u30E9\uFF08scroll \u306E\u30EA\u30B9\u30CA\u30FC\uFF09\u304B\u3089\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`;
|
|
12253
|
+
default:
|
|
12254
|
+
return `${head}\uFF08\u30DA\u30FC\u30B8\u304C\u96A0\u308C\u3066\u3082\u3001\u8868\u793A\u3055\u308C\u3066\u3082\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF09\u3002\u30DA\u30FC\u30B8\u306E\u53EF\u8996\u6027\u3092\u51FA\u3059 wcstack \u306E\u8981\u7D20\u306F\u7121\u3044\u306E\u3067\u3001\u5024\u3092 state \u306B\u7F6E\u304D\u3001\u30A4\u30D9\u30F3\u30C8\u30CF\u30F3\u30C9\u30E9\uFF08visibilitychange \u306E\u30EA\u30B9\u30CA\u30FC\uFF09\u304B\u3089\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`;
|
|
12255
|
+
}
|
|
12256
|
+
},
|
|
12036
12257
|
updatedCallbackUnknownPath: (p) => `"${p}" \u306F state \u306E\u30D1\u30B9\u3067\u306F\u306A\u3044\u306E\u3067 $renderedCallback \u306E paths \u306B\u73FE\u308C\u305A\u3001\u3053\u306E\u5206\u5C90\u306F\u4E00\u5EA6\u3082\u5B9F\u884C\u3055\u308C\u307E\u305B\u3093`,
|
|
12037
12258
|
commandTokenUnbound: (t) => `\u30B3\u30DE\u30F3\u30C9\u30C8\u30FC\u30AF\u30F3 "${t}" \u3092 emit \u3057\u3066\u3044\u307E\u3059\u304C\u3001\u3053\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u305D\u308C\u3092\u53D7\u3051\u308B command.<\u30E1\u30BD\u30C3\u30C9>: ${t} \u306E\u675F\u7E1B\u304C\u3042\u308A\u307E\u305B\u3093\u3002emit \u306F\u8AB0\u306B\u3082\u5C4A\u304D\u307E\u305B\u3093\u3002\u30E1\u30BD\u30C3\u30C9\u3092\u547C\u3076\u8981\u7D20\u306B\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08command.<\u30E1\u30BD\u30C3\u30C9>: ${t} \u2014 <\u30E1\u30BD\u30C3\u30C9> \u306F\u305D\u306E\u8981\u7D20\u306E\u30E1\u30BD\u30C3\u30C9\u306E\u540D\u524D\uFF09`,
|
|
12038
12259
|
writePathMissing: (k) => `"${k}" \u306F state \u304C\u5BA3\u8A00\u3057\u3066\u3044\u306A\u3044\u30AD\u30FC\u3067\u3059\u3002\u66F8\u304D\u8FBC\u307F\u306F\u65B0\u3057\u3044\u30AD\u30FC\u3092\u4F5C\u308B\u3060\u3051\u3067\u3001\u5BA3\u8A00\u3057\u305F\u30AD\u30FC\u306E\u675F\u7E1B\u306B\u306F\u5C4A\u304D\u307E\u305B\u3093`,
|
|
@@ -12068,6 +12289,13 @@ var ja = {
|
|
|
12068
12289
|
radioNameShared: (name, binding) => `\u884C\u3054\u3068\u306E\u30E9\u30B8\u30AA\u304C\u3059\u3079\u3066 name="${name}" \u306B\u306A\u308B\u306E\u3067\u3001\u30D6\u30E9\u30A6\u30B6\u306F\u5168\u90E8\u306E\u884C\u306E\u30E9\u30B8\u30AA\u3092 1 \u3064\u306E\u30B0\u30EB\u30FC\u30D7\u306B\u3057\u307E\u3059\u3002\u30DA\u30FC\u30B8\u5168\u4F53\u3067 1 \u3064\u3057\u304B\u9078\u3070\u308C\u305F\u72B6\u614B\u306B\u306A\u3089\u305A\u3001\u8868\u793A\u306F\u6700\u521D\u306E\u63CF\u753B\u304B\u3089\u884C\u3054\u3068\u306E\u5024\u3068\u98DF\u3044\u9055\u3044\u307E\u3059\uFF08\u4F55\u3082\u77E5\u3089\u305B\u307E\u305B\u3093\uFF09\u3002${binding === "radio" ? "\u884C\u3054\u3068\u306B\u9055\u3046 name \u3092\u675F\u306D\u308B\uFF08attr.name: .<\u884C\u3054\u3068\u306B\u9055\u3046\u30D5\u30A3\u30FC\u30EB\u30C9>\uFF09\u304B\u3001name \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\uFF08radio: \u306F name \u304C\u7121\u304F\u3066\u3082\u3001\u540C\u3058\u30D1\u30B9\u306B\u675F\u306D\u305F\u30E9\u30B8\u30AA\u3092\u9078\u629E\u306B\u5408\u308F\u305B\u307E\u3059\uFF09" : "\u884C\u3054\u3068\u306B\u9055\u3046 name \u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08attr.name: .<\u884C\u3054\u3068\u306B\u9055\u3046\u30D5\u30A3\u30FC\u30EB\u30C9>\uFF09\u3002\u884C\u3092\u307E\u305F\u3044\u3067 1 \u3064\u3092\u9078\u3070\u305B\u308B\u306A\u3089\u3001\u5168\u90E8\u3092 1 \u3064\u306E\u30D1\u30B9\u306B\u675F\u306D\u307E\u3059\uFF08value: .<\u884C\u306E id>; radio: <\u30D1\u30B9>\uFF09"}`,
|
|
12069
12290
|
numberWrittenAsString: (path, left, asNumber) => `"${path}" \u306F state \u3067\u306F\u6570\u5024\u3067\u3059\u304C\u3001value: \u304C\u66F8\u304D\u623B\u3059\u306E\u306F\u8981\u7D20\u306E\u6301\u3064\u6587\u5B57\u5217\u3067\u3059\u30025 \u3068\u5165\u529B\u3057\u305F\u5F8C\u306E state \u306F "5" \u3067\u3001"5" + 1 \u306F "51" \u306B\u306A\u308A\u307E\u3059\uFF08\u4F55\u3082\u77E5\u3089\u305B\u307E\u305B\u3093\uFF09\u3002\u66F8\u304D\u623B\u3059\u3068\u304D\u306B\u6570\u5024\u306B\u3057\u3066\u304F\u3060\u3055\u3044: ${asNumber ? `valueAsNumber: ${path}\u3001\u307E\u305F\u306F` : ""}\u5DE6\u8FBA\u306E\u5165\u529B\u30D5\u30A3\u30EB\u30BF ${left}|number: ${path}\uFF08|int\u30FB|float \u3082\uFF09`,
|
|
12070
12291
|
twoWayOutputFilter: (prop, filters, left, rhs, keystroke) => keystroke ? `${prop}: \u306F\u53CC\u65B9\u5411\u3067 1 \u6253\u9375\u3054\u3068\u306B\u66F8\u304D\u623B\u3057\u3001\u51FA\u529B\u30D5\u30A3\u30EB\u30BF "${filters}" \u306F\u305D\u306E\u305F\u3073\u306B state \u306E\u5024\u3092\u6574\u5F62\u3057\u3066\u6B04\u3078\u66F8\u304D\u76F4\u3057\u307E\u3059\u3002\u5165\u529B\u4E2D\u306E\u6B04\u304C\u66F8\u304D\u63DB\u308F\u308A\uFF08\u30AD\u30E3\u30EC\u30C3\u30C8\u306F\u672B\u5C3E\u3078\u98DB\u3073\u3001IME \u306E\u5909\u63DB\u306F\u9014\u5207\u308C\u307E\u3059\uFF09\u3001state \u304C\u53D7\u3051\u53D6\u308B\u306E\u3082\u6B04\u306E\u6574\u5F62\u6E08\u307F\u306E\u6587\u5B57\u3067\u3059\uFF08\u51FA\u529B\u30D5\u30A3\u30EB\u30BF\u306F\u66F8\u304D\u623B\u3057\u3067\u5143\u306B\u623B\u308A\u307E\u305B\u3093\uFF09\u3002\u6574\u5F62\u3057\u305F\u6587\u5B57\u306F\u5225\u306E\u8981\u7D20\u306B\u8868\u793A\u3059\u308B\u3001\u6B04\u306E\u78BA\u5B9A\u3067\u66F8\u304D\u623B\u3057\u3066 setter \u3067\u6574\u5F62\u3059\u308B\uFF08${prop}#onchange:\uFF09\u3001\u307E\u305F\u306F\u4E00\u65B9\u5411\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${prop}#ro: ${rhs}\uFF09` : `${prop}: \u306F\u53CC\u65B9\u5411\u3067\u3059\u304C\u3001\u51FA\u529B\u30D5\u30A3\u30EB\u30BF "${filters}" \u306F\u66F8\u304D\u623B\u3057\u3067\u5143\u306B\u623B\u308A\u307E\u305B\u3093\u3002\u8981\u7D20\u304C\u66F8\u304D\u623B\u3059\u306E\u306F\u8868\u793A\u3057\u3066\u3044\u308B\u6574\u5F62\u6E08\u307F\u306E\u5024\u3067\u3001\u6B21\u306F\u305D\u306E\u5024\u306B\u30D5\u30A3\u30EB\u30BF\u304C\u639B\u304B\u308A\u307E\u3059\u3002\u5DE6\u8FBA\u306E\u5165\u529B\u30D5\u30A3\u30EB\u30BF\u3067\u5143\u306B\u623B\u3059\uFF08${left}|<\u30D5\u30A3\u30EB\u30BF>: \u2026\uFF09\u3001\u6574\u5F62\u3057\u305F\u5024\u306F\u5225\u306E\u8981\u7D20\u306B\u8868\u793A\u3059\u308B\u3001\u307E\u305F\u306F\u4E00\u65B9\u5411\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${prop}#ro: ${rhs}\uFF09`,
|
|
12292
|
+
bodyBinding: (tag, attribute) => `<${tag}> \u306E ${attribute} \u306F\u675F\u7E1B\u3055\u308C\u307E\u305B\u3093\u3002<wcs-state> \u304C\u675F\u306D\u308B\u306E\u306F <body> \u306E\u4E2D\u3067\u3001<body> \u3068 <html> \u305D\u306E\u3082\u306E\u306F\u675F\u306D\u306A\u3044\u306E\u3067\u3001\u3053\u3053\u306B\u66F8\u3044\u305F\u675F\u7E1B\u306F\u4F55\u3082\u3057\u307E\u305B\u3093\uFF08\u30A4\u30D9\u30F3\u30C8\u306E\u30CF\u30F3\u30C9\u30E9\u306F\u8D70\u3089\u305A\u3001class. / attr. \u306A\u3069\u306F\u66F8\u304B\u308C\u307E\u305B\u3093\uFF09\u3002\u675F\u7E1B\u3092 <body> \u306E\u4E2D\u306E\u8981\u7D20\uFF08\u5305\u3080\u8981\u7D20\u30FB<main>\uFF09\u3078\u79FB\u3059\u304B\u3001\u5024\u3092 $connectedCallback \u3084 $watch \u306E\u30CF\u30F3\u30C9\u30E9\u304B\u3089\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF08document.documentElement.lang = \u2026\uFF09`,
|
|
12293
|
+
linkHandler: (property, handler) => `<wcs-link> \u306E "${property}:" \u306F "${handler}" \u3092\u547C\u3073\u307E\u305B\u3093\u3002<wcs-link> \u81EA\u8EAB\u306F display: none \u3067\u3001\u5229\u7528\u8005\u304C\u30AF\u30EA\u30C3\u30AF\u3059\u308B\u306E\u306F\u30EA\u30F3\u30AF\u304C\u81EA\u5206\u306E\u96A3\u306B\u4F5C\u308B <a> \u306A\u306E\u3067\u3001\u30A4\u30D9\u30F3\u30C8\u306F\u30DB\u30B9\u30C8\u306B\u5C4A\u304D\u307E\u305B\u3093\u3002\u30CF\u30F3\u30C9\u30E9\u306F\u3001\u30EA\u30F3\u30AF\u306E\u4E2D\u306E\u8981\u7D20\uFF08\u5B50\u306F <a> \u306E\u4E2D\u3078\u79FB\u308A\u307E\u3059\uFF09\u304B\u3001\u30EA\u30F3\u30AF\u3092\u56F2\u3080\u8981\u7D20\u306B\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\u3002\u30CF\u30F3\u30C9\u30E9\u304B\u3089\u9077\u79FB\u3059\u308B\u306A\u3089\u3001router \u306E navigateUrl \u306B\u66F8\u304D\u307E\u3059\uFF08<wcs-router> \u306E data-wcs="navigateUrl: \u2026"\uFF09`,
|
|
12294
|
+
rootMarginUnit: (tag, value, refused, suggested) => {
|
|
12295
|
+
const why = refused.length === 0 ? "\u5024\u306F 1\u301C4 \u500B\u3067\u3059" : `${refused.map((t) => `"${t}"`).join("\u30FB")} \u306F px \u304B % \u306E\u4ED8\u3044\u305F\u6570\u5024\u3067\u306F\u3042\u308A\u307E\u305B\u3093${refused.some(isUnitlessZero) ? "\uFF080 \u306B\u3082\u5358\u4F4D\u304C\u8981\u308A\u307E\u3059\uFF09" : ""}`;
|
|
12296
|
+
const effect = tag === "wcs-intersect" ? "\u8981\u7D20\u306F\u4F55\u3082\u76E3\u8996\u305B\u305A\u3001observing \u306F false \u306E\u307E\u307E\u3067\u3059" : "\u8981\u7D20\u306F\u4F55\u3082\u76E3\u8996\u305B\u305A\u3001\u6B21\u306E\u30DA\u30FC\u30B8\u306F\u8AAD\u307F\u8FBC\u307E\u308C\u307E\u305B\u3093";
|
|
12297
|
+
return `\u30D6\u30E9\u30A6\u30B6\u306F root-margin="${value}" \u3092\u62D2\u307F\u307E\u3059\uFF08rootMargin must be specified in pixels or percent\uFF09: ${why}\u3002\u305D\u306E\u305F\u3081${effect}\u3002${suggested === null ? "1\u301C4 \u500B\u306E\u5024\u3092\u3001\u305D\u308C\u305E\u308C px \u304B % \u306E\u4ED8\u3044\u305F\u6570\u5024\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044" : `root-margin="${suggested}" \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`}`;
|
|
12298
|
+
},
|
|
12071
12299
|
filterUnknown: (n) => `\u30D5\u30A3\u30EB\u30BF "${n}" \u306F\u7D44\u307F\u8FBC\u307F\u30D5\u30A3\u30EB\u30BF\u306B\u5B58\u5728\u3057\u307E\u305B\u3093`,
|
|
12072
12300
|
filterRemoved: (n, c) => `\u30D5\u30A3\u30EB\u30BF "${n}" \u306F 4.0 \u3067\u5916\u308C\u307E\u3057\u305F\uFF08"${c}" \u306E 3.x \u306E\u65E7\u540D\uFF09\u3002"${c}" \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`,
|
|
12073
12301
|
substrRemoved: (rewrite) => `\u30D5\u30A3\u30EB\u30BF "substr" \u306F 4.0 \u3067\u5916\u308C\u307E\u3057\u305F\u3002slice(start, start + length) \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044 \u2014 slice \u306E\u7B2C 2 \u5F15\u6570\u306F\u9577\u3055\u3067\u306F\u306A\u304F\u7D42\u308F\u308A\u306E\u4F4D\u7F6E\u3067\u3059${rewrite === null ? "" : `\uFF08\u3053\u3053\u3067\u306F ${rewrite}\uFF09`}`,
|
|
@@ -12275,6 +12503,23 @@ var en = {
|
|
|
12275
12503
|
onHandlerThis: (name) => `The $on handler "${name}" uses this. A $on handler receives the state as its first argument (\`${name}(state, event) { state.x = \u2026 }\`) and this is undefined, so this.\u2026 throws when it is called \u2014 unlike $watch handlers and methods`,
|
|
12276
12504
|
getterReadsLocation: (read) => `This getter reads ${read}, which is not state: it keeps the URL it first read (a navigation does not re-evaluate it). Read the URL through state \u2014 bind <wcs-router>'s path / searchParams`,
|
|
12277
12505
|
getterReadsClock: (read) => `This getter reads ${read}. The time is not state, so it is not a dependency: the getter is cached and keeps returning its first value (an event token "redrawing" every frame does not change it). Keep the time in state \u2014 bind the value <wcs-raf> or <wcs-timer> writes`,
|
|
12506
|
+
getterReadsAmbient: (read, kind) => {
|
|
12507
|
+
const head = `This getter reads ${read}, which is not state, so it is not a dependency: the getter is cached and keeps returning its first value`;
|
|
12508
|
+
switch (kind) {
|
|
12509
|
+
case "size":
|
|
12510
|
+
return `${head} (a resize does not re-evaluate it). Keep the size in state \u2014 bind the width / height <wcs-resize> writes (for a breakpoint, <wcs-media-query>'s matched)`;
|
|
12511
|
+
case "pixelRatio":
|
|
12512
|
+
return `${head} (a zoom or a move to another screen does not re-evaluate it). Bind <wcs-media-query>'s matched for the resolution thresholds the page uses (query="(min-resolution: 2dppx)")`;
|
|
12513
|
+
case "media":
|
|
12514
|
+
return `${head} (the query starting or ceasing to match does not re-evaluate it). Bind <wcs-media-query>'s matched instead (<wcs-media-query query="(max-width: 600px)" data-wcs="matched: narrow">)`;
|
|
12515
|
+
case "online":
|
|
12516
|
+
return `${head} (going offline or coming back does not re-evaluate it). Bind <wcs-network>'s offline instead`;
|
|
12517
|
+
case "scroll":
|
|
12518
|
+
return `${head} (scrolling does not re-evaluate it). No wcstack element gives the scroll position: keep the value in state and write it from an event handler (a scroll listener)`;
|
|
12519
|
+
default:
|
|
12520
|
+
return `${head} (the page being hidden or shown does not re-evaluate it). No wcstack element gives the page's visibility: keep the value in state and write it from an event handler (a visibilitychange listener)`;
|
|
12521
|
+
}
|
|
12522
|
+
},
|
|
12278
12523
|
updatedCallbackUnknownPath: (p) => `"${p}" is not a path of this state, so it is never in $renderedCallback's paths and this branch never runs`,
|
|
12279
12524
|
commandTokenUnbound: (t) => `The command token "${t}" is emitted, but no command.<method>: ${t} binding in this document receives it, so the emit reaches nothing. Bind it on the element whose method it should call (command.<method>: ${t}, with <method> the name of that element's method)`,
|
|
12280
12525
|
writePathMissing: (k) => `"${k}" is not a key the state declares. The write creates a new key and reaches no binding of a declared one`,
|
|
@@ -12310,6 +12555,13 @@ var en = {
|
|
|
12310
12555
|
radioNameShared: (name, binding) => `Every row's radios get name="${name}", so the browser makes one group of all the rows: only one radio on the whole page stays checked, and the page disagrees with the rows' values from the first render \u2014 nothing says so. ${binding === "radio" ? "Bind a name that differs per row (attr.name: .<a row field>), or drop the name: radio: keeps the radios bound to one path in step without it" : "Bind a name that differs per row (attr.name: .<a row field>) \u2014 or, for one choice over all the rows, bind them all to one path: value: .<the row's id>; radio: <path>"}`,
|
|
12311
12556
|
numberWrittenAsString: (path, left, asNumber) => `"${path}" is a number in the state, but value: writes back what the element holds, a string: after the user enters 5 the state has "5", and "5" + 1 is "51" \u2014 nothing says so. Convert it on the way in: ${asNumber ? `valueAsNumber: ${path}, or ` : ""}an input filter on the left side, ${left}|number: ${path} (also |int, |float)`,
|
|
12312
12557
|
twoWayOutputFilter: (prop, filters, left, rhs, keystroke) => keystroke ? `${prop}: is two-way and writes back on every keystroke, and the output filter "${filters}" formats what the state holds each time: the field is rewritten while the user types \u2014 the caret jumps to the end, an IME composition is cut \u2014 and what the state receives is the field's formatted text (an output filter is not undone on the way back). Show the formatted text in another element, write back when the field is committed and format in a setter (${prop}#onchange:), or make the binding one-way: ${prop}#ro: ${rhs}` : `${prop}: is two-way, and nothing undoes the output filter "${filters}" on the way back: the element writes back the formatted value it shows, and the filter is then applied to that. Undo it with an input filter on the left side (${left}|<filter>: \u2026), show the formatted value in another element, or make the binding one-way: ${prop}#ro: ${rhs}`,
|
|
12558
|
+
bodyBinding: (tag, attribute) => `${attribute} on <${tag}> is never bound: <wcs-state> binds what is inside <body>, not <body> or <html> themselves, so the bindings written here do nothing (an event handler never runs; class., attr. and the rest are never written). Move the binding to an element inside <body> (a wrapper, <main>), or write the value from $connectedCallback or a $watch handler (document.documentElement.lang = \u2026)`,
|
|
12559
|
+
linkHandler: (property, handler) => `"${property}:" on <wcs-link> never runs "${handler}": the <wcs-link> itself is display: none, and what the user clicks is the <a> it generates beside itself, so no event reaches the host. Put the handler on an element inside the link (its children move into the <a>) or on an element around it; to navigate from a handler, write the router's navigateUrl (data-wcs="navigateUrl: \u2026" on <wcs-router>)`,
|
|
12560
|
+
rootMarginUnit: (tag, value, refused, suggested) => {
|
|
12561
|
+
const why = refused.length === 0 ? "it takes one to four values" : `${refused.map((t) => `"${t}"`).join(", ")} ${refused.length === 1 ? "is not a number" : "are not numbers"} with px or %${refused.some(isUnitlessZero) ? " (a 0 needs its unit too)" : ""}`;
|
|
12562
|
+
const effect = tag === "wcs-intersect" ? "the element observes nothing and observing stays false" : "the element observes nothing and no page is loaded";
|
|
12563
|
+
return `The browser refuses root-margin="${value}" (rootMargin must be specified in pixels or percent): ${why}. So ${effect}. ${suggested === null ? "Write one to four values, each a number with px or %" : `Write root-margin="${suggested}"`}`;
|
|
12564
|
+
},
|
|
12313
12565
|
filterUnknown: (n) => `Filter "${n}" is not a built-in filter`,
|
|
12314
12566
|
filterRemoved: (n, c) => `Filter "${n}" was removed in 4.0 (it was the 3.x old name of "${c}") \u2014 write "${c}"`,
|
|
12315
12567
|
substrRemoved: (rewrite) => `Filter "substr" was removed in 4.0 \u2014 write slice(start, start + length): slice takes the end index, not a length${rewrite === null ? "" : ` (here: ${rewrite})`}`,
|
|
@@ -12816,6 +13068,7 @@ var DELEGATED_EVENTS = /* @__PURE__ */ new Set([
|
|
|
12816
13068
|
"pointerup"
|
|
12817
13069
|
]);
|
|
12818
13070
|
var CUSTOM_ELEMENT_OWN_EVENTS = /* @__PURE__ */ new Set(["input", "change", "submit"]);
|
|
13071
|
+
var LINK_TAG = "wcs-link";
|
|
12819
13072
|
function collectCurrentTargetHandlers(elements, html, fileReader) {
|
|
12820
13073
|
const names2 = /* @__PURE__ */ new Set();
|
|
12821
13074
|
forEachStateMethod(elements, html, fileReader, "currentTarget", (name, params, body) => {
|
|
@@ -12942,7 +13195,7 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
|
|
|
12942
13195
|
severity: "error"
|
|
12943
13196
|
});
|
|
12944
13197
|
}
|
|
12945
|
-
if (DELEGATED_EVENTS.has(eventName) && !modifiers.includes(DIRECT_MODIFIER) && attr.tagName !== void 0 && !(attr.tagName.includes("-") && CUSTOM_ELEMENT_OWN_EVENTS.has(eventName)) && /^[A-Za-z_][\w$]*(?:\.[A-Za-z_][\w$]*)*$/.test(handler) && getCurrentTargetHandlers().has(handler)) {
|
|
13198
|
+
if (DELEGATED_EVENTS.has(eventName) && !modifiers.includes(DIRECT_MODIFIER) && attr.tagName !== void 0 && attr.tagName !== LINK_TAG && !(attr.tagName.includes("-") && CUSTOM_ELEMENT_OWN_EVENTS.has(eventName)) && /^[A-Za-z_][\w$]*(?:\.[A-Za-z_][\w$]*)*$/.test(handler) && getCurrentTargetHandlers().has(handler)) {
|
|
12946
13199
|
currentTargetCandidates.push({
|
|
12947
13200
|
offset: attr.valueStart,
|
|
12948
13201
|
start: bindingStart + leadingSpace,
|
|
@@ -16435,6 +16688,101 @@ function sharedRadioName(html, attr, parsed, bindAttribute) {
|
|
|
16435
16688
|
};
|
|
16436
16689
|
}
|
|
16437
16690
|
|
|
16691
|
+
// src/service/bindingHostValidator.ts
|
|
16692
|
+
var UNBOUND_HOSTS = /* @__PURE__ */ new Set(["body", "html"]);
|
|
16693
|
+
var LINK_TAG2 = "wcs-link";
|
|
16694
|
+
function validateBindingHosts(html, bindAttribute = "data-wcs", stateTagName = "wcs-state", locale2) {
|
|
16695
|
+
const attrs = findAllBindAttributes(html, bindAttribute).filter((attr) => attr.tagName !== void 0 && (UNBOUND_HOSTS.has(attr.tagName) || attr.tagName === LINK_TAG2));
|
|
16696
|
+
if (attrs.length === 0) return [];
|
|
16697
|
+
const msgs = getMessages(locale2);
|
|
16698
|
+
const out = [];
|
|
16699
|
+
const contexts = analyzeElementContexts(html, attrs.map((attr) => attr.valueStart), bindAttribute, stateTagName);
|
|
16700
|
+
const isBound = (attr) => contexts.get(attr.valueStart)?.bound === true;
|
|
16701
|
+
let insideTemplate = null;
|
|
16702
|
+
for (const attr of attrs) {
|
|
16703
|
+
const tagName = attr.tagName;
|
|
16704
|
+
if (UNBOUND_HOSTS.has(tagName)) {
|
|
16705
|
+
if (attr.value.trim() === "" || !isBound(attr) || (insideTemplate ??= createTemplateTester(html))(attr.valueStart)) continue;
|
|
16706
|
+
out.push({
|
|
16707
|
+
code: WcsDiagnosticCode.BodyBinding,
|
|
16708
|
+
start: attributeStart(html, attr, bindAttribute),
|
|
16709
|
+
end: attr.valueStart + attr.value.length + 1,
|
|
16710
|
+
severity: "error",
|
|
16711
|
+
tag: tagName,
|
|
16712
|
+
message: msgs.bodyBinding(tagName, bindAttribute)
|
|
16713
|
+
});
|
|
16714
|
+
continue;
|
|
16715
|
+
}
|
|
16716
|
+
if (!isBound(attr)) continue;
|
|
16717
|
+
let pos = 0;
|
|
16718
|
+
for (const binding of splitBindingExpressions(attr.value)) {
|
|
16719
|
+
const bindingStart = attr.valueStart + pos;
|
|
16720
|
+
pos += binding.length + 1;
|
|
16721
|
+
const parsed = parseBindingExpression(binding);
|
|
16722
|
+
const property = parsed.property.replace(/#.*$/, "").trim();
|
|
16723
|
+
if (!/^on\w/.test(property) || parsed.path === null || parsed.path.trim() === "") continue;
|
|
16724
|
+
const start = bindingStart + (binding.length - binding.trimStart().length);
|
|
16725
|
+
out.push({
|
|
16726
|
+
code: WcsDiagnosticCode.LinkHandler,
|
|
16727
|
+
start,
|
|
16728
|
+
end: start + property.length,
|
|
16729
|
+
severity: "error",
|
|
16730
|
+
tag: LINK_TAG2,
|
|
16731
|
+
message: msgs.linkHandler(property, parsed.path.trim())
|
|
16732
|
+
});
|
|
16733
|
+
}
|
|
16734
|
+
}
|
|
16735
|
+
return out;
|
|
16736
|
+
}
|
|
16737
|
+
function attributeStart(html, attr, bindAttribute) {
|
|
16738
|
+
const from = attr.attrsStart ?? attr.valueStart;
|
|
16739
|
+
const head = html.slice(from, attr.valueStart);
|
|
16740
|
+
const escaped = bindAttribute.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
16741
|
+
const name = new RegExp(`${escaped}\\s*=\\s*["']$`, "i").exec(head);
|
|
16742
|
+
return name === null ? attr.valueStart : from + name.index;
|
|
16743
|
+
}
|
|
16744
|
+
|
|
16745
|
+
// src/service/ioAttributeValidator.ts
|
|
16746
|
+
var ROOT_MARGIN_TAGS = /* @__PURE__ */ new Set(["wcs-intersect", "wcs-infinite-scroll"]);
|
|
16747
|
+
var NUMBER = String.raw`[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?`;
|
|
16748
|
+
var ROOT_MARGIN_VALUE = new RegExp(`^${NUMBER}(?:px|%)$`, "i");
|
|
16749
|
+
var UNITLESS_NUMBER = new RegExp(`^${NUMBER}$`, "i");
|
|
16750
|
+
function checkRootMargin(value) {
|
|
16751
|
+
const values = value.split(/\s+/).filter((v) => v !== "");
|
|
16752
|
+
const refused = [...new Set(values.filter((v) => !ROOT_MARGIN_VALUE.test(v)))];
|
|
16753
|
+
if (refused.length === 0 && values.length <= 4) return null;
|
|
16754
|
+
const fixable = values.length <= 4 && refused.every((v) => UNITLESS_NUMBER.test(v));
|
|
16755
|
+
return { refused, suggested: fixable ? values.map((v) => UNITLESS_NUMBER.test(v) ? `${v}px` : v).join(" ") : null };
|
|
16756
|
+
}
|
|
16757
|
+
function validateIoAttributes(html, bindAttribute = "data-wcs", locale2) {
|
|
16758
|
+
if (!/root-margin/i.test(html)) return [];
|
|
16759
|
+
const msgs = getMessages(locale2);
|
|
16760
|
+
const out = [];
|
|
16761
|
+
for (const region of findStartTagRegions(html)) {
|
|
16762
|
+
if (!ROOT_MARGIN_TAGS.has(region.tagName)) continue;
|
|
16763
|
+
const content = html.slice(region.start, region.end);
|
|
16764
|
+
const span = extractAttributeSpan(content, "root-margin", region.start);
|
|
16765
|
+
if (span === null) continue;
|
|
16766
|
+
const value = html.slice(span.valueStart, span.valueEnd);
|
|
16767
|
+
if (value.includes("{{") || bindsRootMargin(extractAttribute(content, bindAttribute))) continue;
|
|
16768
|
+
const problem = checkRootMargin(value);
|
|
16769
|
+
if (problem === null) continue;
|
|
16770
|
+
out.push({
|
|
16771
|
+
code: WcsDiagnosticCode.RootMarginUnit,
|
|
16772
|
+
start: span.valueStart,
|
|
16773
|
+
end: span.valueEnd,
|
|
16774
|
+
severity: "warning",
|
|
16775
|
+
tag: region.tagName,
|
|
16776
|
+
message: msgs.rootMarginUnit(region.tagName, value, problem.refused, problem.suggested)
|
|
16777
|
+
});
|
|
16778
|
+
}
|
|
16779
|
+
return out;
|
|
16780
|
+
}
|
|
16781
|
+
function bindsRootMargin(bindings) {
|
|
16782
|
+
if (bindings === null) return false;
|
|
16783
|
+
return splitBindingExpressions(bindings).some((binding) => parseBindingExpression(binding).property.replace(/#.*$/, "").trim().replace(/^\./, "") === "rootMargin");
|
|
16784
|
+
}
|
|
16785
|
+
|
|
16438
16786
|
// src/service/documentEnvValidator.ts
|
|
16439
16787
|
function validateDocumentEnv(html, locale2) {
|
|
16440
16788
|
const diagnostics = [];
|
|
@@ -16775,11 +17123,11 @@ function findMisplacedOutlets(html) {
|
|
|
16775
17123
|
});
|
|
16776
17124
|
return routerWithoutOutlet ? misplaced : [];
|
|
16777
17125
|
}
|
|
16778
|
-
var
|
|
17126
|
+
var LINK_TAG3 = "wcs-link";
|
|
16779
17127
|
function findLinksIgnoringOwnQuery(html) {
|
|
16780
17128
|
const found = [];
|
|
16781
17129
|
for (const region of findStartTagRegions(html)) {
|
|
16782
|
-
if (region.tagName !==
|
|
17130
|
+
if (region.tagName !== LINK_TAG3) continue;
|
|
16783
17131
|
const content = html.slice(region.start, region.end);
|
|
16784
17132
|
const to = extractAttribute(content, "to");
|
|
16785
17133
|
const span = extractAttributeSpan(content, "query-keys", region.start);
|
|
@@ -18588,6 +18936,25 @@ function validateGetterClockReads(script, scriptStart, locale2) {
|
|
|
18588
18936
|
}
|
|
18589
18937
|
return out;
|
|
18590
18938
|
}
|
|
18939
|
+
function validateGetterAmbientReads(script, scriptStart, locale2) {
|
|
18940
|
+
if (!AMBIENT_READ_SPELLING.test(script)) return [];
|
|
18941
|
+
const msgs = getMessages(locale2);
|
|
18942
|
+
const out = [];
|
|
18943
|
+
let moduleNames = null;
|
|
18944
|
+
for (const getter of analyzeCallableBodies(script)) {
|
|
18945
|
+
if (getter.kind !== "getter" || getter.accessor !== "get" || !AMBIENT_READ_SPELLING.test(getter.body)) continue;
|
|
18946
|
+
const read = findAmbientRead(getter.body, moduleNames ??= moduleBindingNames(script));
|
|
18947
|
+
if (read === null) continue;
|
|
18948
|
+
out.push({
|
|
18949
|
+
code: WcsDiagnosticCode.GetterUntrackedRead,
|
|
18950
|
+
start: scriptStart + getter.bodyStart + read.start,
|
|
18951
|
+
end: scriptStart + getter.bodyStart + read.end,
|
|
18952
|
+
message: msgs.getterReadsAmbient(read.text, read.kind),
|
|
18953
|
+
severity: "warning"
|
|
18954
|
+
});
|
|
18955
|
+
}
|
|
18956
|
+
return out;
|
|
18957
|
+
}
|
|
18591
18958
|
function onHandlerStateParam(script, handler) {
|
|
18592
18959
|
if (handler.kind === "body") {
|
|
18593
18960
|
const head = script.slice(Math.max(0, handler.start - 400), handler.start);
|
|
@@ -18959,6 +19326,7 @@ function validateSemantics(html, stateTagName = "wcs-state", locale2, bindAttrNa
|
|
|
18959
19326
|
));
|
|
18960
19327
|
out.push(...validateGetterLocationReads(block.content, block.contentStart, locale2));
|
|
18961
19328
|
out.push(...validateGetterClockReads(block.content, block.contentStart, locale2));
|
|
19329
|
+
out.push(...validateGetterAmbientReads(block.content, block.contentStart, locale2));
|
|
18962
19330
|
out.push(...validateOnHandlerThis(block.content, block.contentStart, locale2));
|
|
18963
19331
|
out.push(...validateInPlaceChanges(block.content, block.contentStart, locale2));
|
|
18964
19332
|
}
|
|
@@ -20166,6 +20534,8 @@ function validateText(text3, options, applicationSchema) {
|
|
|
20166
20534
|
out.push(...validateAriaAttributes(text3, bindAttribute, locale2));
|
|
20167
20535
|
out.push(...validateLiveRegions(text3, bindAttribute, stateTagName, locale2));
|
|
20168
20536
|
out.push(...validateFormInputs(text3, bindAttribute, stateTagName, locale2, fileReader, applicationSchema));
|
|
20537
|
+
out.push(...validateBindingHosts(text3, bindAttribute, stateTagName, locale2));
|
|
20538
|
+
out.push(...validateIoAttributes(text3, bindAttribute, locale2));
|
|
20169
20539
|
out.push(...validateDocumentEnv(text3, locale2));
|
|
20170
20540
|
out.push(...validatePackageLoads(text3, locale2, fileReader));
|
|
20171
20541
|
out.push(...validateSemantics(text3, stateTagName, locale2, bindAttribute));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/lint",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.24.1",
|
|
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": {
|