@wcstack/lint 4.1.1 → 4.3.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/dist/cli.cjs +671 -160
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -122,12 +122,15 @@ var WcsDiagnosticCode = {
|
|
|
122
122
|
NestedAssign: "wcs/nested-assign",
|
|
123
123
|
// --- 意味論(構文・存在検査では捕まらない取り違え。service/semanticValidator.ts) ---
|
|
124
124
|
// `$getAll` / `$setAll` / `$resolve` の添字の本数がパスの `*` の本数と噛み合わない。
|
|
125
|
-
//
|
|
125
|
+
// ランタイムは #901 / #902 で throw する(diagnostics の後付けがあれば同じ code の文面。超過は 3.x では
|
|
126
|
+
// 黙って無視されていた)。error。
|
|
126
127
|
IndexArity: "wcs/index-arity",
|
|
127
128
|
// ワイルドカードの階数がスコープの段数を超える(`matrix.*.*` を 1 段の for で読む、
|
|
128
129
|
// `$2` を 1 段のループで読む。ランタイムの #1401)。既存の「for の外」検査の深さ方向の一般化。
|
|
129
130
|
// 4.0 は各段の `*` が**その段で囲む for のリスト**の行であることも確かめる(#1403・F32 — `for: a`
|
|
130
|
-
// の行の中の `b.*.y` は投げる)。静的側も囲む for の一覧と段ごとに比べて同じ code
|
|
131
|
+
// の行の中の `b.*.y` は投げる)。静的側も囲む for の一覧と段ごとに比べて同じ code で報告する
|
|
132
|
+
// (ランタイムの文面に code が付くのは diagnostics の後付けがあるとき)。for のスコープを組み直しきれない
|
|
133
|
+
// ので、ランタイムは初期化を失敗させるが warning のまま(vscode-wcs の README の重大度の例外)。
|
|
131
134
|
WildcardRank: "wcs/wildcard-rank",
|
|
132
135
|
// ループの添字の範囲(`$1`〜`$128`。上限は manifest の `syntax.indexParam.maxDepth`)の外。ランタイムと同じ code:
|
|
133
136
|
// for の中のマークアップの `$129`(バインディングが失敗する)と、スクリプトの `this.$0` / `this.$129` / `this.$1000`
|
|
@@ -135,7 +138,8 @@ var WcsDiagnosticCode = {
|
|
|
135
138
|
// `wcs/binding-path-missing`(ただしけっして動かないので error)。for の外の `$129` はランタイムでは #1401 なので
|
|
136
139
|
// 従来どおり「for の外のループ添字」(`wcs/template-syntax`)で報告する。
|
|
137
140
|
IndexParamRange: "wcs/index-param-range",
|
|
138
|
-
// パス getter
|
|
141
|
+
// パス getter どうしの循環参照。4.0 のランタイムは評価の時点で #701 として throw し、その getter を読む
|
|
142
|
+
// 束縛はすべて失敗する(3.x はアドレススタック上限まで再帰してから落ちた)。error。
|
|
139
143
|
GetterCycle: "wcs/getter-cycle",
|
|
140
144
|
// `$renderedCallback`(3.x の旧名 `$updatedCallback`)が、どのバインディングにも現れないパスを判定に使っている。
|
|
141
145
|
// 同コールバックは **binding 駆動**(live binding が適用された path しか報告しない)
|
|
@@ -150,8 +154,9 @@ var WcsDiagnosticCode = {
|
|
|
150
154
|
GetterUntrackedRead: "wcs/getter-untracked-read",
|
|
151
155
|
OnHandlerThis: "wcs/on-handler-this",
|
|
152
156
|
// --- <wcs-state> script: $watch declaration ---
|
|
153
|
-
//
|
|
154
|
-
//
|
|
157
|
+
// temporal の後付け(state の temporal/watch.ts)が読み込みで throw する宣言: 越境 `@` / `$` 始まり /
|
|
158
|
+
// 空キー / 明らかな非関数ハンドラ。空の段(`a..b`)はランタイムが調べず、その watch は黙って発火しない
|
|
159
|
+
// (lint だけが知らせる — docs/mistake-catalogue.md)。
|
|
155
160
|
WatchDeclarationInvalid: "wcs/watch-declaration-invalid",
|
|
156
161
|
// `$watch` のキーが状態定義に存在しない。バインディング側と違い黙って発火しない
|
|
157
162
|
// だけなので気づけない。severity は binding-path-missing に揃える(warning)。
|
|
@@ -170,8 +175,8 @@ var WcsDiagnosticCode = {
|
|
|
170
175
|
//
|
|
171
176
|
// `**` を解釈しない場所へ `**` が渡った(data-wcs / mustache / $watch キー / $listKeys
|
|
172
177
|
// キー / $resolve / $postUpdate / $dependOn(旧名 $trackDependency) / 代入)、または `$recursion` 宣言が
|
|
173
|
-
// 無いのに `**` を使った。runtime
|
|
174
|
-
//
|
|
178
|
+
// 無いのに `**` を使った。4.0 の runtime はどれも #1101 で throw する — 宣言なしの `**` getter も、
|
|
179
|
+
// アクセサを登録する時点で(3.x は黙って無視した)。error。
|
|
175
180
|
RecursionUnsupported: "wcs/recursion-unsupported",
|
|
176
181
|
// 宣言済みアンカーと合致しない `**`(綴り違い・2 つ目の `**`)、または `**` の後ろが
|
|
177
182
|
// 整形されていない(空セグメント・`**` 直後の素の `*`)。
|
|
@@ -209,7 +214,8 @@ var WcsDiagnosticCode = {
|
|
|
209
214
|
// ドットアクセスを含むチェーン代入は NestedAssign の担当(相補・二重報告なし)。
|
|
210
215
|
ArrayIndexAssign: "wcs/array-index-assign",
|
|
211
216
|
// --- built-in wcs-* tag contract (generated/builtinTags.generated.ts が正本) ---
|
|
212
|
-
// 未知メンバーへのバインド(プロパティ / command. / eventToken. キー)
|
|
217
|
+
// 未知メンバーへのバインド(プロパティ / command. / eventToken. キー)。4.0 のランタイムは #38 / #1203 /
|
|
218
|
+
// #1204 で拒み、root では初期化が、行では束縛が失敗する(3.x の「黙って無視」ではない)。error。
|
|
213
219
|
TagMemberUnknown: "wcs/tag-member-unknown",
|
|
214
220
|
// タグのメンバー名が "on" で始まる(`once` 等)のに先頭ドット無しで束縛した: ランタイムはイベント束縛にして
|
|
215
221
|
// "ce" イベントを待ち、値は届かない。明示のプロパティ形 `.once:` を提案する(@wcstack/state 3.1・要件 B5 / 3.x 計画 D36)
|
|
@@ -220,6 +226,10 @@ var WcsDiagnosticCode = {
|
|
|
220
226
|
// ランタイムは何も報告しない(root は正しい値)ので lint の code。`#direct` か `event.target.closest(...)` を
|
|
221
227
|
// 案内する。読みが実行されない分岐にあることもあるので warning。
|
|
222
228
|
DelegatedCurrentTarget: "wcs/delegated-current-target",
|
|
229
|
+
// `<form data-wcs="onsubmit: login">` の `#prevent` 忘れ(ハンドラも preventDefault を呼ばない)。ブラウザが
|
|
230
|
+
// フォームも送る — ページが読み直されるか、router があれば GET が欄(パスワードも)を URL と履歴に載せる
|
|
231
|
+
// (docs/seam-apps.md、router-auth)。warning(action 付きのフォームと、読めないハンドラでは黙る)。
|
|
232
|
+
SubmitWithoutPrevent: "wcs/submit-without-prevent",
|
|
223
233
|
// 4.0 で外れた API の旧名(`this.$trackDependency` → `$dependOn`、`$untrackDependency` → `$untracked`)。
|
|
224
234
|
// ランタイムは読んだ時点で同じ code(#1701)で throw するので error。3.x(3.2〜3.3)では「動くが 4.0 で
|
|
225
235
|
// 外れる」info だった。フィルタの旧名(`uc` など)は 4.0 のランタイムと同じく `wcs/filter-unknown` で、
|
|
@@ -267,7 +277,8 @@ var WcsDiagnosticCode = {
|
|
|
267
277
|
// (error 昇格時は packages/lint/scripts/smoke-test.mjs の対ケース更新が必須)。
|
|
268
278
|
AriaAttrUnknown: "wcs/aria-attr-unknown",
|
|
269
279
|
// --- document-level load configuration ---
|
|
270
|
-
// @wcstack/state/auto
|
|
280
|
+
// @wcstack/state/auto より後に @wcstack/devtools/auto が読まれている。info: 4.0 は後から付いた DevTools に
|
|
281
|
+
// 既存の束縛を送り直すので、欠けるのは付く前のタイムラインだけ。
|
|
271
282
|
ScriptOrder: "wcs/script-order",
|
|
272
283
|
// router/auto があるのに <base href> がない(SPA の basename 誤導出)。
|
|
273
284
|
BaseHrefMissing: "wcs/base-href-missing",
|
|
@@ -277,6 +288,13 @@ var WcsDiagnosticCode = {
|
|
|
277
288
|
RouterOutletMisplaced: "wcs/router-outlet-misplaced",
|
|
278
289
|
// @wcstack/signals と /dom エントリの同一ページ混在(リアクティブコア二重化)。
|
|
279
290
|
SignalsDualEntry: "wcs/signals-dual-entry",
|
|
291
|
+
// `<wcs-route>`(またはレイアウトのテンプレート)の直下のテキストの `{{ }}`。最初に着いたルートでしか束ねられず、
|
|
292
|
+
// 遷移で入ったルートでは書いたままの文字が出る(router の README「Where route content lives」— docs/seam-apps.md、
|
|
293
|
+
// router-admin)。warning。
|
|
294
|
+
RouteBareMustache: "wcs/route-bare-mustache",
|
|
295
|
+
// 既定の `<slot>` の無いレイアウトのテンプレートに、名前付きスロットの外の中身(入れ子のルート)を渡している。
|
|
296
|
+
// 中身は表示されない。ランタイムも同じ code で警告する(docs/seam-apps.md、router-admin)。warning。
|
|
297
|
+
LayoutSlotMissing: "wcs/layout-slot-missing",
|
|
280
298
|
// --- deprecations ---
|
|
281
299
|
// 名前付き State(`<wcs-state name>` / `path@name`)。v2 でマウント(`mount=` と接頭辞付きパス)に
|
|
282
300
|
// 置き換わる(docs/state-mount-design.md D16)。1.x では warning、v2 では parse error と同時に error。
|
|
@@ -394,7 +412,8 @@ var FORMATS_FILTER_NAMES = [
|
|
|
394
412
|
"coalesce",
|
|
395
413
|
"number",
|
|
396
414
|
"string",
|
|
397
|
-
"nullIfEmpty"
|
|
415
|
+
"nullIfEmpty",
|
|
416
|
+
"currency"
|
|
398
417
|
];
|
|
399
418
|
var definitions = /* @__PURE__ */ new Map();
|
|
400
419
|
function hasFilter(name) {
|
|
@@ -611,6 +630,8 @@ var codeOf = (id) => {
|
|
|
611
630
|
return c ? `[wcs/${c}] ` : "";
|
|
612
631
|
};
|
|
613
632
|
var MOVED = ["enableMustache", "sameValueGuard", "enableDirectionalInitialSync"];
|
|
633
|
+
var was = (v) => v == null ? String(v) : v instanceof Date ? "a Date" : Array.isArray(v) ? "an array" : typeof v === "string" ? `a string (${JSON.stringify(v.length > 32 ? v.slice(0, 32) + "\u2026" : v)})` : typeof v === "object" ? "an object" : `a ${typeof v} (${String(v)})`;
|
|
634
|
+
var NAMESPACES = ["", "", "class.", "attr.", "style."];
|
|
614
635
|
var element = (tag, at2) => `<${tag}${at2.map((a, i) => i % 2 ? `="${a}"` : ` ${a}`).join("")}>`;
|
|
615
636
|
var CSP_GUIDE = "https://github.com/wcstack/wcstack/blob/main/docs/csp.md";
|
|
616
637
|
var SENTENCES = {
|
|
@@ -662,10 +683,11 @@ var SENTENCES = {
|
|
|
662
683
|
41
|
|
663
684
|
/* RenderChain */
|
|
664
685
|
]: () => `render chain depth limit exceeded (${MAX_RENDER_CHAIN} drains that rendering itself started); bindings for this batch were not applied.`,
|
|
686
|
+
// (named as written — `textContent: iso`, `class.active: x` — when the binding has a member; else its type)
|
|
665
687
|
[
|
|
666
688
|
12
|
|
667
689
|
/* BindingFailed */
|
|
668
|
-
]: (type, p) => `binding "${type}: ${p}" failed to apply.`,
|
|
690
|
+
]: (type, p, name, kind) => `binding "${name ? (NAMESPACES[kind] ?? "") + name : type}: ${p}" failed to apply.`,
|
|
669
691
|
[
|
|
670
692
|
13
|
|
671
693
|
/* LoadFailed */
|
|
@@ -737,11 +759,19 @@ var SENTENCES = {
|
|
|
737
759
|
[
|
|
738
760
|
28
|
|
739
761
|
/* FilterValueNotNumber */
|
|
740
|
-
]: (fn) => `filter ${fn} requires a number value`,
|
|
762
|
+
]: (fn, v) => `filter ${fn} requires a number value, not ${was(v)}${typeof v === "string" ? ` \u2014 put |number before |${fn}, or convert it where it is read` : ""}`,
|
|
741
763
|
[
|
|
742
764
|
29
|
|
743
765
|
/* FilterValueNotDate */
|
|
744
|
-
]: (fn) => `filter ${fn} requires a date value`,
|
|
766
|
+
]: (fn, v) => `filter ${fn} requires a date value (a Date), not ${was(v)}${typeof v === "string" || typeof v === "number" ? " \u2014 make the Date where it is read: a getter returning new Date(\u2026)" : ""}`,
|
|
767
|
+
[
|
|
768
|
+
52
|
|
769
|
+
/* FilterStyleInvalid */
|
|
770
|
+
]: (fn, v) => `filter ${fn} takes a style of full, long, medium or short, not "${v}"`,
|
|
771
|
+
[
|
|
772
|
+
53
|
|
773
|
+
/* FilterCurrencyInvalid */
|
|
774
|
+
]: (v) => `filter currency takes an ISO 4217 currency code (JPY, USD, EUR), not "${v}"`,
|
|
745
775
|
[
|
|
746
776
|
30
|
|
747
777
|
/* FilterValueNotArray */
|
|
@@ -1606,6 +1636,61 @@ function extractAttribute(tagContent, attrName) {
|
|
|
1606
1636
|
if (!match) return null;
|
|
1607
1637
|
return match[1] ?? match[2] ?? match[3] ?? null;
|
|
1608
1638
|
}
|
|
1639
|
+
var IGNORE_VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
1640
|
+
"area",
|
|
1641
|
+
"base",
|
|
1642
|
+
"br",
|
|
1643
|
+
"col",
|
|
1644
|
+
"embed",
|
|
1645
|
+
"hr",
|
|
1646
|
+
"img",
|
|
1647
|
+
"input",
|
|
1648
|
+
"link",
|
|
1649
|
+
"meta",
|
|
1650
|
+
"param",
|
|
1651
|
+
"source",
|
|
1652
|
+
"track",
|
|
1653
|
+
"wbr"
|
|
1654
|
+
]);
|
|
1655
|
+
function findIgnoredRanges(html, bindAttribute) {
|
|
1656
|
+
const marker = asciiLowerCase(`${bindAttribute}-ignore`);
|
|
1657
|
+
const lower2 = asciiLowerCase(html);
|
|
1658
|
+
if (!lower2.includes(marker)) return [];
|
|
1659
|
+
const out = [];
|
|
1660
|
+
const stack = [];
|
|
1661
|
+
const tag = /<!--[\s\S]*?(?:-->|$)|<(\/?)([a-zA-Z][^\s/>]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;
|
|
1662
|
+
let match;
|
|
1663
|
+
while ((match = tag.exec(html)) !== null) {
|
|
1664
|
+
if (match[2] === void 0) continue;
|
|
1665
|
+
const name = asciiLowerCase(match[2]);
|
|
1666
|
+
const end = match.index + match[0].length;
|
|
1667
|
+
if (match[1] === "/") {
|
|
1668
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
1669
|
+
if (stack[i].name !== name) continue;
|
|
1670
|
+
for (const open of stack.slice(i)) if (open.start !== null) out.push([open.start, end]);
|
|
1671
|
+
stack.length = i;
|
|
1672
|
+
break;
|
|
1673
|
+
}
|
|
1674
|
+
continue;
|
|
1675
|
+
}
|
|
1676
|
+
const ignored = parseAttributeNames(match[3]).has(marker) ? match.index : null;
|
|
1677
|
+
if (IGNORE_VOID_ELEMENTS.has(name)) {
|
|
1678
|
+
if (ignored !== null) out.push([ignored, end]);
|
|
1679
|
+
continue;
|
|
1680
|
+
}
|
|
1681
|
+
if (RAW_TEXT_ELEMENTS.has(name)) {
|
|
1682
|
+
const close = name === "plaintext" ? -1 : lower2.indexOf(`</${name}`, end);
|
|
1683
|
+
const closeEnd = close === -1 ? html.length : html.indexOf(">", close) + 1 || html.length;
|
|
1684
|
+
if (ignored !== null) out.push([ignored, closeEnd]);
|
|
1685
|
+
if (close === -1) break;
|
|
1686
|
+
tag.lastIndex = closeEnd;
|
|
1687
|
+
continue;
|
|
1688
|
+
}
|
|
1689
|
+
stack.push({ name, start: ignored });
|
|
1690
|
+
}
|
|
1691
|
+
for (const open of stack) if (open.start !== null) out.push([open.start, html.length]);
|
|
1692
|
+
return out;
|
|
1693
|
+
}
|
|
1609
1694
|
|
|
1610
1695
|
// src/core/parser/quoteAware.ts
|
|
1611
1696
|
var isQuote = (c) => c === "'" || c === '"';
|
|
@@ -1681,11 +1766,17 @@ function optionsRequired(fnName) {
|
|
|
1681
1766
|
function optionMustBeNumber(fnName) {
|
|
1682
1767
|
raise2(27, [fnName]);
|
|
1683
1768
|
}
|
|
1684
|
-
function
|
|
1685
|
-
raise2(
|
|
1769
|
+
function styleInvalid(fnName, value) {
|
|
1770
|
+
raise2(52, [fnName, value]);
|
|
1771
|
+
}
|
|
1772
|
+
function currencyInvalid(value) {
|
|
1773
|
+
raise2(53, [value]);
|
|
1686
1774
|
}
|
|
1687
|
-
function
|
|
1688
|
-
raise2(
|
|
1775
|
+
function valueMustBeNumber(fnName, value) {
|
|
1776
|
+
raise2(28, [fnName, value]);
|
|
1777
|
+
}
|
|
1778
|
+
function valueMustBeDate(fnName, value) {
|
|
1779
|
+
raise2(29, [fnName, value]);
|
|
1689
1780
|
}
|
|
1690
1781
|
function valueMustBeArray(fnName) {
|
|
1691
1782
|
raise2(30, [fnName]);
|
|
@@ -1752,7 +1843,7 @@ var numeric = (name, op) => ({
|
|
|
1752
1843
|
const opt = requiredNumberOption(options, 0, name);
|
|
1753
1844
|
return (value) => {
|
|
1754
1845
|
if (typeof value !== "number") {
|
|
1755
|
-
valueMustBeNumber(name);
|
|
1846
|
+
valueMustBeNumber(name, value);
|
|
1756
1847
|
}
|
|
1757
1848
|
return op(value, opt);
|
|
1758
1849
|
};
|
|
@@ -1782,7 +1873,7 @@ var toFixed = (options) => {
|
|
|
1782
1873
|
const opt = numberOption(options?.[0] ?? "0", "toFixed");
|
|
1783
1874
|
return (value) => {
|
|
1784
1875
|
if (typeof value !== "number") {
|
|
1785
|
-
valueMustBeNumber("toFixed");
|
|
1876
|
+
valueMustBeNumber("toFixed", value);
|
|
1786
1877
|
}
|
|
1787
1878
|
return value.toFixed(opt);
|
|
1788
1879
|
};
|
|
@@ -1791,7 +1882,7 @@ var round = (options) => {
|
|
|
1791
1882
|
const optValue = Math.pow(10, numberOption(options?.[0] ?? "0", "round"));
|
|
1792
1883
|
return (value) => {
|
|
1793
1884
|
if (typeof value !== "number") {
|
|
1794
|
-
valueMustBeNumber("round");
|
|
1885
|
+
valueMustBeNumber("round", value);
|
|
1795
1886
|
}
|
|
1796
1887
|
return Math.round(value * optValue) / optValue;
|
|
1797
1888
|
};
|
|
@@ -1800,7 +1891,7 @@ var floor = (options) => {
|
|
|
1800
1891
|
const optValue = Math.pow(10, numberOption(options?.[0] ?? "0", "floor"));
|
|
1801
1892
|
return (value) => {
|
|
1802
1893
|
if (typeof value !== "number") {
|
|
1803
|
-
valueMustBeNumber("floor");
|
|
1894
|
+
valueMustBeNumber("floor", value);
|
|
1804
1895
|
}
|
|
1805
1896
|
return Math.floor(value * optValue) / optValue;
|
|
1806
1897
|
};
|
|
@@ -1809,7 +1900,7 @@ var ceil = (options) => {
|
|
|
1809
1900
|
const optValue = Math.pow(10, numberOption(options?.[0] ?? "0", "ceil"));
|
|
1810
1901
|
return (value) => {
|
|
1811
1902
|
if (typeof value !== "number") {
|
|
1812
|
-
valueMustBeNumber("ceil");
|
|
1903
|
+
valueMustBeNumber("ceil", value);
|
|
1813
1904
|
}
|
|
1814
1905
|
return Math.ceil(value * optValue) / optValue;
|
|
1815
1906
|
};
|
|
@@ -1818,7 +1909,7 @@ var percent = (options) => {
|
|
|
1818
1909
|
const opt = numberOption(options?.[0] ?? "0", "percent");
|
|
1819
1910
|
return (value) => {
|
|
1820
1911
|
if (typeof value !== "number") {
|
|
1821
|
-
valueMustBeNumber("percent");
|
|
1912
|
+
valueMustBeNumber("percent", value);
|
|
1822
1913
|
}
|
|
1823
1914
|
return `${(value * 100).toFixed(opt)}%`;
|
|
1824
1915
|
};
|
|
@@ -1845,11 +1936,29 @@ var locale = (options) => {
|
|
|
1845
1936
|
const explicit = options?.[0];
|
|
1846
1937
|
return (value) => {
|
|
1847
1938
|
if (typeof value !== "number") {
|
|
1848
|
-
valueMustBeNumber("locale");
|
|
1939
|
+
valueMustBeNumber("locale", value);
|
|
1849
1940
|
}
|
|
1850
1941
|
return value.toLocaleString(explicit ?? defaultLocale());
|
|
1851
1942
|
};
|
|
1852
1943
|
};
|
|
1944
|
+
var currency = (options) => {
|
|
1945
|
+
const code = options?.[0] ?? optionsRequired("currency");
|
|
1946
|
+
const explicit = options?.[1];
|
|
1947
|
+
const format = { style: "currency", currency: code };
|
|
1948
|
+
try {
|
|
1949
|
+
new Intl.NumberFormat("en", format);
|
|
1950
|
+
const known = Intl.supportedValuesOf?.("currency");
|
|
1951
|
+
if (known && !known.includes(code.toUpperCase())) throw 0;
|
|
1952
|
+
} catch {
|
|
1953
|
+
currencyInvalid(code);
|
|
1954
|
+
}
|
|
1955
|
+
return (value) => {
|
|
1956
|
+
if (typeof value !== "number") {
|
|
1957
|
+
valueMustBeNumber("currency", value);
|
|
1958
|
+
}
|
|
1959
|
+
return value.toLocaleString(explicit ?? defaultLocale(), format);
|
|
1960
|
+
};
|
|
1961
|
+
};
|
|
1853
1962
|
var upper = () => (value) => String(value).toUpperCase();
|
|
1854
1963
|
var lower = () => (value) => String(value).toLowerCase();
|
|
1855
1964
|
var capitalize = () => (value) => {
|
|
@@ -1906,38 +2015,48 @@ var join = (options) => {
|
|
|
1906
2015
|
return value.join(opt);
|
|
1907
2016
|
};
|
|
1908
2017
|
};
|
|
2018
|
+
var STYLES = ["full", "long", "medium", "short"];
|
|
2019
|
+
function dateOptions(options, fn) {
|
|
2020
|
+
let [loc, style] = options ?? [];
|
|
2021
|
+
if (style === void 0 && loc !== void 0 && STYLES.includes(loc)) [loc, style] = [void 0, loc];
|
|
2022
|
+
if (style !== void 0 && !STYLES.includes(style)) styleInvalid(fn, style);
|
|
2023
|
+
return [loc, style];
|
|
2024
|
+
}
|
|
1909
2025
|
var date = (options) => {
|
|
1910
|
-
const explicit = options
|
|
2026
|
+
const [explicit, style] = dateOptions(options, "date");
|
|
2027
|
+
const format = style && { dateStyle: style };
|
|
1911
2028
|
return (value) => {
|
|
1912
2029
|
if (!(value instanceof Date)) {
|
|
1913
|
-
valueMustBeDate("date");
|
|
2030
|
+
valueMustBeDate("date", value);
|
|
1914
2031
|
}
|
|
1915
|
-
return value.toLocaleDateString(explicit ?? defaultLocale());
|
|
2032
|
+
return value.toLocaleDateString(explicit ?? defaultLocale(), format);
|
|
1916
2033
|
};
|
|
1917
2034
|
};
|
|
1918
2035
|
var time = (options) => {
|
|
1919
|
-
const explicit = options
|
|
2036
|
+
const [explicit, style] = dateOptions(options, "time");
|
|
2037
|
+
const format = style && { timeStyle: style };
|
|
1920
2038
|
return (value) => {
|
|
1921
2039
|
if (!(value instanceof Date)) {
|
|
1922
|
-
valueMustBeDate("time");
|
|
2040
|
+
valueMustBeDate("time", value);
|
|
1923
2041
|
}
|
|
1924
|
-
return value.toLocaleTimeString(explicit ?? defaultLocale());
|
|
2042
|
+
return value.toLocaleTimeString(explicit ?? defaultLocale(), format);
|
|
1925
2043
|
};
|
|
1926
2044
|
};
|
|
1927
2045
|
var datetime = (options) => {
|
|
1928
|
-
const explicit = options
|
|
2046
|
+
const [explicit, style] = dateOptions(options, "datetime");
|
|
2047
|
+
const format = style && { dateStyle: style, timeStyle: style };
|
|
1929
2048
|
return (value) => {
|
|
1930
2049
|
if (!(value instanceof Date)) {
|
|
1931
|
-
valueMustBeDate("datetime");
|
|
2050
|
+
valueMustBeDate("datetime", value);
|
|
1932
2051
|
}
|
|
1933
|
-
return value.toLocaleString(explicit ?? defaultLocale());
|
|
2052
|
+
return value.toLocaleString(explicit ?? defaultLocale(), format);
|
|
1934
2053
|
};
|
|
1935
2054
|
};
|
|
1936
2055
|
var ymd = (options) => {
|
|
1937
2056
|
const opt = options?.[0] ?? "-";
|
|
1938
2057
|
return (value) => {
|
|
1939
2058
|
if (!(value instanceof Date)) {
|
|
1940
|
-
valueMustBeDate("ymd");
|
|
2059
|
+
valueMustBeDate("ymd", value);
|
|
1941
2060
|
}
|
|
1942
2061
|
const year = value.getFullYear().toString();
|
|
1943
2062
|
const month = (value.getMonth() + 1).toString().padStart(2, "0");
|
|
@@ -1949,7 +2068,7 @@ var hms = (options) => {
|
|
|
1949
2068
|
const opt = options?.[0] ?? ":";
|
|
1950
2069
|
return (value) => {
|
|
1951
2070
|
if (!(value instanceof Date)) {
|
|
1952
|
-
valueMustBeDate("hms");
|
|
2071
|
+
valueMustBeDate("hms", value);
|
|
1953
2072
|
}
|
|
1954
2073
|
const hours = value.getHours().toString().padStart(2, "0");
|
|
1955
2074
|
const minutes = value.getMinutes().toString().padStart(2, "0");
|
|
@@ -1959,7 +2078,7 @@ var hms = (options) => {
|
|
|
1959
2078
|
};
|
|
1960
2079
|
var abs = () => (value) => {
|
|
1961
2080
|
if (typeof value !== "number") {
|
|
1962
|
-
valueMustBeNumber("abs");
|
|
2081
|
+
valueMustBeNumber("abs", value);
|
|
1963
2082
|
}
|
|
1964
2083
|
return Math.abs(value);
|
|
1965
2084
|
};
|
|
@@ -1968,7 +2087,7 @@ var clamp = (options) => {
|
|
|
1968
2087
|
const max = requiredNumberOption(options, 1, "clamp");
|
|
1969
2088
|
return (value) => {
|
|
1970
2089
|
if (typeof value !== "number") {
|
|
1971
|
-
valueMustBeNumber("clamp");
|
|
2090
|
+
valueMustBeNumber("clamp", value);
|
|
1972
2091
|
}
|
|
1973
2092
|
return Math.min(Math.max(value, min), max);
|
|
1974
2093
|
};
|
|
@@ -2015,10 +2134,10 @@ var registered = {
|
|
|
2015
2134
|
ceil: { factory: ceil, arity: [0, 1] },
|
|
2016
2135
|
percent: { factory: percent, arity: [0, 1] },
|
|
2017
2136
|
unit: { factory: nullishPassthrough(unit), arity: [1, 1] },
|
|
2018
|
-
// The locale-dependent three take a locale like `locale` does (`date(ja-JP)`)
|
|
2019
|
-
date: { factory: date, arity: [0,
|
|
2020
|
-
time: { factory: time, arity: [0,
|
|
2021
|
-
datetime: { factory: datetime, arity: [0,
|
|
2137
|
+
// The locale-dependent three take a locale like `locale` does (`date(ja-JP)`), and a style (`date(ja-JP,long)`)
|
|
2138
|
+
date: { factory: date, arity: [0, 2] },
|
|
2139
|
+
time: { factory: time, arity: [0, 2] },
|
|
2140
|
+
datetime: { factory: datetime, arity: [0, 2] },
|
|
2022
2141
|
ymd: { factory: ymd, arity: [0, 1] },
|
|
2023
2142
|
hms: { factory: hms, arity: [0, 1] },
|
|
2024
2143
|
// the core set of 4.0.0-rc.3 (the core's own: eq ne not lt le gt ge falsy truthy boolean)
|
|
@@ -2045,7 +2164,9 @@ var registered = {
|
|
|
2045
2164
|
boolean: boolean2,
|
|
2046
2165
|
number: { factory: number, arity: [0, 0] },
|
|
2047
2166
|
string: { factory: string, arity: [0, 0] },
|
|
2048
|
-
nullIfEmpty: { factory: nullIfEmpty, arity: [0, 0] }
|
|
2167
|
+
nullIfEmpty: { factory: nullIfEmpty, arity: [0, 0] },
|
|
2168
|
+
// (added in 4.2: last, so the order of the others is unchanged)
|
|
2169
|
+
currency: { factory: currency, arity: [1, 2] }
|
|
2049
2170
|
};
|
|
2050
2171
|
var formatFilters = /* @__PURE__ */ Object.fromEntries(
|
|
2051
2172
|
/* @__PURE__ */ Object.entries(registered).filter(([name]) => !(name in coreFilters))
|
|
@@ -2077,10 +2198,11 @@ var builtinFilterMeta = {
|
|
|
2077
2198
|
// `not` は真偽性(truthy / falsy)の反転。`if:` が `Boolean()` で寄せるのと同じ規則で、
|
|
2078
2199
|
// `else:` はこのフィルタを足した束縛として組み立てられる(structural/createNotFilter.ts)
|
|
2079
2200
|
not: { description: "\u771F\u507D\u6027\u3092\u53CD\u8EE2\uFF08falsy \u2192 true\uFF09", hasArgs: false, resultType: "boolean", acceptTypes: "any", minArgs: 0, maxArgs: 0 },
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2201
|
+
// 比較は数値だけを受ける(filters/core.ts の `numeric` は数値以外の値で #28。3.x も同じで、"string" は誤りだった)
|
|
2202
|
+
lt: { description: "\u3088\u308A\u5C0F\u3055\u3044\u304B", hasArgs: true, resultType: "boolean", acceptTypes: ["number"], minArgs: 1, maxArgs: 1, argTypes: ["number"] },
|
|
2203
|
+
le: { description: "\u4EE5\u4E0B\u304B", hasArgs: true, resultType: "boolean", acceptTypes: ["number"], minArgs: 1, maxArgs: 1, argTypes: ["number"] },
|
|
2204
|
+
gt: { description: "\u3088\u308A\u5927\u304D\u3044\u304B", hasArgs: true, resultType: "boolean", acceptTypes: ["number"], minArgs: 1, maxArgs: 1, argTypes: ["number"] },
|
|
2205
|
+
ge: { description: "\u4EE5\u4E0A\u304B", hasArgs: true, resultType: "boolean", acceptTypes: ["number"], minArgs: 1, maxArgs: 1, argTypes: ["number"] },
|
|
2084
2206
|
// 算術
|
|
2085
2207
|
add: { description: "\u52A0\u7B97", hasArgs: true, resultType: "number", acceptTypes: ["number"], minArgs: 1, maxArgs: 1, argTypes: ["number"] },
|
|
2086
2208
|
sub: { description: "\u6E1B\u7B97", hasArgs: true, resultType: "number", acceptTypes: ["number"], minArgs: 1, maxArgs: 1, argTypes: ["number"] },
|
|
@@ -2116,10 +2238,11 @@ var builtinFilterMeta = {
|
|
|
2116
2238
|
unit: { description: "\u5358\u4F4D\uFF08\u63A5\u5C3E\u8F9E\uFF09\u3092\u4ED8\u52A0", hasArgs: true, resultType: "string", acceptTypes: ["number", "string"], minArgs: 1, maxArgs: 1, argTypes: ["string"] },
|
|
2117
2239
|
// 日付・時刻
|
|
2118
2240
|
// `locale` と同じくロケールを 1 つ受ける(`date(ja-JP)`)。実装は最初からこれを読んでいたが、
|
|
2119
|
-
// メタデータ側が maxArgs: 0 だったため lint
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2241
|
+
// メタデータ側が maxArgs: 0 だったため lint と補完が正しい書き方を誤りとして報告していた。
|
|
2242
|
+
// 4.2: 2 つ目は書式(full / long / medium / short — Intl の dateStyle / timeStyle)。書式だけなら既定のロケール
|
|
2243
|
+
date: { description: "\u30ED\u30B1\u30FC\u30EB\u5F62\u5F0F\u306E\u65E5\u4ED8 ([locale][, style]\u3002style \u306F full / long / medium / short\u3001\u65E2\u5B9A\u306E\u30ED\u30B1\u30FC\u30EB\u306F config.locale)", hasArgs: true, resultType: "string", acceptTypes: "any", minArgs: 0, maxArgs: 2, argTypes: ["string", "string"] },
|
|
2244
|
+
time: { description: "\u30ED\u30B1\u30FC\u30EB\u5F62\u5F0F\u306E\u6642\u523B ([locale][, style]\u3002style \u306F full / long / medium / short\u3001\u65E2\u5B9A\u306E\u30ED\u30B1\u30FC\u30EB\u306F config.locale)", hasArgs: true, resultType: "string", acceptTypes: "any", minArgs: 0, maxArgs: 2, argTypes: ["string", "string"] },
|
|
2245
|
+
datetime: { description: "\u30ED\u30B1\u30FC\u30EB\u5F62\u5F0F\u306E\u65E5\u6642 ([locale][, style]\u3002style \u306F full / long / medium / short\u3001\u65E2\u5B9A\u306E\u30ED\u30B1\u30FC\u30EB\u306F config.locale)", hasArgs: true, resultType: "string", acceptTypes: "any", minArgs: 0, maxArgs: 2, argTypes: ["string", "string"] },
|
|
2123
2246
|
ymd: { description: "YYYY-MM-DD \u5F62\u5F0F ([separator]\u3002\u65E2\u5B9A\u306F -)", hasArgs: true, resultType: "string", acceptTypes: "any", minArgs: 0, maxArgs: 1, argTypes: ["string"] },
|
|
2124
2247
|
hms: { description: "HH:MM:SS \u5F62\u5F0F ([separator]\u3002\u65E2\u5B9A\u306F :)", hasArgs: true, resultType: "string", acceptTypes: "any", minArgs: 0, maxArgs: 1, argTypes: ["string"] },
|
|
2125
2248
|
// 真偽値・変換
|
|
@@ -2130,7 +2253,9 @@ var builtinFilterMeta = {
|
|
|
2130
2253
|
boolean: { description: "\u30D6\u30FC\u30EB\u5024\u306B\u5909\u63DB", hasArgs: false, resultType: "boolean", acceptTypes: "any", minArgs: 0, maxArgs: 0 },
|
|
2131
2254
|
number: { description: "\u6570\u5024\u306B\u5909\u63DB", hasArgs: false, resultType: "number", acceptTypes: "any", minArgs: 0, maxArgs: 0 },
|
|
2132
2255
|
string: { description: "\u6587\u5B57\u5217\u306B\u5909\u63DB", hasArgs: false, resultType: "string", acceptTypes: "any", minArgs: 0, maxArgs: 0 },
|
|
2133
|
-
nullIfEmpty: { description: "\u7A7A\u6587\u5B57\u5217\u3092null\u306B\u5909\u63DB", hasArgs: false, resultType: "passthrough", acceptTypes: ["string"], minArgs: 0, maxArgs: 0 }
|
|
2256
|
+
nullIfEmpty: { description: "\u7A7A\u6587\u5B57\u5217\u3092null\u306B\u5909\u63DB", hasArgs: false, resultType: "passthrough", acceptTypes: ["string"], minArgs: 0, maxArgs: 0 },
|
|
2257
|
+
// 4.2(formats の最後に登録)
|
|
2258
|
+
currency: { description: "\u901A\u8CA8\u306E\u66F8\u5F0F (code[, locale]\u3002code \u306F ISO 4217 \u2014 JPY / USD / EUR\u3001\u65E2\u5B9A\u306E\u30ED\u30B1\u30FC\u30EB\u306F config.locale)", hasArgs: true, resultType: "string", acceptTypes: ["number"], minArgs: 1, maxArgs: 2, argTypes: ["string", "string"] }
|
|
2134
2259
|
};
|
|
2135
2260
|
var WCS_MANIFEST_VERSION = 2;
|
|
2136
2261
|
var builtinFilterAliases = Object.freeze({});
|
|
@@ -10516,6 +10641,193 @@ function findOwnThis(text3, kind) {
|
|
|
10516
10641
|
forEachChild(root, walk);
|
|
10517
10642
|
return found;
|
|
10518
10643
|
}
|
|
10644
|
+
var DESTRUCTIVE_ARRAY_METHODS = /* @__PURE__ */ new Set(["push", "pop", "shift", "unshift", "splice", "sort", "reverse", "fill", "copyWithin"]);
|
|
10645
|
+
function memberChain(node, source) {
|
|
10646
|
+
const segments = [];
|
|
10647
|
+
let cur = unwrapChain(node);
|
|
10648
|
+
while (cur.type === "MemberExpression") {
|
|
10649
|
+
const property = cur.property;
|
|
10650
|
+
let name = null;
|
|
10651
|
+
if (!cur.computed && property.type === "Identifier") name = property.name;
|
|
10652
|
+
else if (property.type === "Literal" && (typeof property.value === "string" || typeof property.value === "number")) name = String(property.value);
|
|
10653
|
+
segments.unshift({ name, raw: source(property), computed: cur.computed });
|
|
10654
|
+
cur = unwrapChain(cur.object);
|
|
10655
|
+
}
|
|
10656
|
+
return { base: cur, segments };
|
|
10657
|
+
}
|
|
10658
|
+
function assignTarget(root, segments) {
|
|
10659
|
+
if (segments.every((s) => s.name !== null)) {
|
|
10660
|
+
const path = segments.map((s) => s.name).join(".");
|
|
10661
|
+
return segments.length === 1 && /^[A-Za-z_$][\w$]*$/.test(path) ? `${root}.${path}` : `${root}["${path}"]`;
|
|
10662
|
+
}
|
|
10663
|
+
return `${root}[\`${segments.map((s) => s.name ?? `\${${s.raw}}`).join(".")}\`]`;
|
|
10664
|
+
}
|
|
10665
|
+
function findInPlaceChanges(text3, kind, root) {
|
|
10666
|
+
const prefix = kind === "body" ? PREFIX : VALUE_PREFIX;
|
|
10667
|
+
let program;
|
|
10668
|
+
try {
|
|
10669
|
+
program = parse3(prefix + text3 + (kind === "body" ? SUFFIX : VALUE_SUFFIX), { ecmaVersion: "latest", sourceType: "module" });
|
|
10670
|
+
} catch {
|
|
10671
|
+
return [];
|
|
10672
|
+
}
|
|
10673
|
+
const wrapper = unwrapWrapper(program);
|
|
10674
|
+
if (wrapper === null) return [];
|
|
10675
|
+
let body = wrapper.body;
|
|
10676
|
+
if (kind === "value") {
|
|
10677
|
+
const statement = wrapper.body.body.length === 1 ? wrapper.body.body[0] : null;
|
|
10678
|
+
const fn = statement?.type === "ExpressionStatement" ? statement.expression : null;
|
|
10679
|
+
if (fn === null || fn.type !== "FunctionExpression" && fn.type !== "ArrowFunctionExpression") return [];
|
|
10680
|
+
if (root === null) {
|
|
10681
|
+
const first = fn.params[0];
|
|
10682
|
+
if (first === void 0 || first.type !== "Identifier") return [];
|
|
10683
|
+
root = first.name;
|
|
10684
|
+
}
|
|
10685
|
+
body = fn.body;
|
|
10686
|
+
}
|
|
10687
|
+
if (root === null) return [];
|
|
10688
|
+
const stateRoot = root;
|
|
10689
|
+
const shift = prefix.length;
|
|
10690
|
+
const source = (n) => (prefix + text3).slice(n.start, n.end);
|
|
10691
|
+
const isRoot = (n) => stateRoot === "this" ? n.type === "ThisExpression" : n.type === "Identifier" && n.name === stateRoot;
|
|
10692
|
+
const bound = /* @__PURE__ */ new Map();
|
|
10693
|
+
const bind = (name) => {
|
|
10694
|
+
bound.set(name, (bound.get(name) ?? 0) + 1);
|
|
10695
|
+
};
|
|
10696
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
10697
|
+
const collect2 = (node) => {
|
|
10698
|
+
if (isFunctionNode(node)) {
|
|
10699
|
+
if (node.type === "FunctionDeclaration" && node.id !== null) bind(node.id.name);
|
|
10700
|
+
const names = /* @__PURE__ */ new Set();
|
|
10701
|
+
for (const param of node.params) bindingNames(param, names);
|
|
10702
|
+
names.forEach(bind);
|
|
10703
|
+
} else if (node.type === "VariableDeclarator") {
|
|
10704
|
+
const names = /* @__PURE__ */ new Set();
|
|
10705
|
+
bindingNames(node.id, names);
|
|
10706
|
+
names.forEach(bind);
|
|
10707
|
+
const init = node.init ? unwrapChain(node.init) : null;
|
|
10708
|
+
if (init !== null && node.id.type === "Identifier" && init.type === "MemberExpression") {
|
|
10709
|
+
const chain = memberChain(init, source);
|
|
10710
|
+
if (isRoot(chain.base) && chain.segments.length > 0 && !chain.segments[0].name?.startsWith("$")) {
|
|
10711
|
+
aliases.set(node.id.name, { source: source(init), segments: chain.segments });
|
|
10712
|
+
}
|
|
10713
|
+
} else if (init !== null && node.id.type === "ObjectPattern" && isRoot(init)) {
|
|
10714
|
+
for (const property of node.id.properties) {
|
|
10715
|
+
if (property.type !== "Property" || property.computed) continue;
|
|
10716
|
+
const key = property.key.type === "Identifier" ? property.key.name : property.key.type === "Literal" ? String(property.key.value) : null;
|
|
10717
|
+
const value = property.value.type === "AssignmentPattern" ? property.value.left : property.value;
|
|
10718
|
+
if (key === null || key.startsWith("$") || value.type !== "Identifier") continue;
|
|
10719
|
+
const segment = { name: key, raw: key, computed: false };
|
|
10720
|
+
aliases.set(value.name, { source: `${stateRoot}.${key}`, segments: [segment] });
|
|
10721
|
+
}
|
|
10722
|
+
}
|
|
10723
|
+
} else if (node.type === "CatchClause" && node.param) {
|
|
10724
|
+
const names = /* @__PURE__ */ new Set();
|
|
10725
|
+
bindingNames(node.param, names);
|
|
10726
|
+
names.forEach(bind);
|
|
10727
|
+
} else if (node.type === "ClassDeclaration" && node.id !== null) {
|
|
10728
|
+
bind(node.id.name);
|
|
10729
|
+
} else if (node.type === "AssignmentExpression" && node.left.type === "Identifier") {
|
|
10730
|
+
bind(node.left.name);
|
|
10731
|
+
}
|
|
10732
|
+
forEachChild(node, collect2);
|
|
10733
|
+
};
|
|
10734
|
+
collect2(body);
|
|
10735
|
+
const alias = (name) => bound.get(name) === 1 ? aliases.get(name) : void 0;
|
|
10736
|
+
const out = [];
|
|
10737
|
+
const report = (target, at2, form, directMin) => {
|
|
10738
|
+
const chain = memberChain(target, source);
|
|
10739
|
+
const base = chain.base;
|
|
10740
|
+
const range = { start: at2.start - shift, end: at2.end - shift };
|
|
10741
|
+
const pick = (segments) => form ?? (segments.length > 0 && segments.every((s) => s.computed) ? "index" : "property");
|
|
10742
|
+
if (base.type === "Identifier" && base.name !== stateRoot) {
|
|
10743
|
+
const a = alias(base.name);
|
|
10744
|
+
if (a === void 0) return;
|
|
10745
|
+
out.push({ form: pick(chain.segments), alias: base.name, source: a.source, target: assignTarget(stateRoot, a.segments), ...range });
|
|
10746
|
+
return;
|
|
10747
|
+
}
|
|
10748
|
+
if (!isRoot(base) || chain.segments.length < directMin || chain.segments[0].name?.startsWith("$")) return;
|
|
10749
|
+
out.push({ form: pick(chain.segments.slice(1)), alias: null, source: source(at2), target: assignTarget(stateRoot, chain.segments), ...range });
|
|
10750
|
+
};
|
|
10751
|
+
const direct = stateRoot === "this" ? Infinity : 2;
|
|
10752
|
+
const visitChanges = (node) => {
|
|
10753
|
+
if (node.type === "AssignmentExpression" && unwrapChain(node.left).type === "MemberExpression") {
|
|
10754
|
+
report(node.left, node.left, null, direct);
|
|
10755
|
+
} else if (node.type === "UpdateExpression" && unwrapChain(node.argument).type === "MemberExpression") {
|
|
10756
|
+
report(node.argument, node.argument, null, direct);
|
|
10757
|
+
} else if (node.type === "UnaryExpression" && node.operator === "delete" && unwrapChain(node.argument).type === "MemberExpression") {
|
|
10758
|
+
report(node.argument, node.argument, "property", direct);
|
|
10759
|
+
} else if (node.type === "CallExpression") {
|
|
10760
|
+
const callee = unwrapChain(node.callee);
|
|
10761
|
+
if (callee.type === "MemberExpression") {
|
|
10762
|
+
const method = !callee.computed && callee.property.type === "Identifier" ? callee.property.name : null;
|
|
10763
|
+
const object = unwrapChain(callee.object);
|
|
10764
|
+
if (method === "assign" && object.type === "Identifier" && object.name === "Object" && node.arguments.length > 0) {
|
|
10765
|
+
const first = node.arguments[0];
|
|
10766
|
+
if (first.type === "Identifier" || unwrapChain(first).type === "MemberExpression") report(first, node, "property", 1);
|
|
10767
|
+
} else if (method !== null && DESTRUCTIVE_ARRAY_METHODS.has(method)) {
|
|
10768
|
+
report(callee.object, node, "method", stateRoot === "this" ? Infinity : 1);
|
|
10769
|
+
}
|
|
10770
|
+
}
|
|
10771
|
+
}
|
|
10772
|
+
forEachChild(node, visitChanges);
|
|
10773
|
+
};
|
|
10774
|
+
visitChanges(body);
|
|
10775
|
+
return out;
|
|
10776
|
+
}
|
|
10777
|
+
var LOCATION_HOLDERS = /* @__PURE__ */ new Set(["window", "document", "globalThis", "self"]);
|
|
10778
|
+
var LOCATION_VARYING = /* @__PURE__ */ new Set(["pathname", "search", "hash", "href"]);
|
|
10779
|
+
function findLocationRead(body) {
|
|
10780
|
+
let program;
|
|
10781
|
+
try {
|
|
10782
|
+
program = parse3(PREFIX + body + SUFFIX, { ecmaVersion: "latest", sourceType: "module" });
|
|
10783
|
+
} catch {
|
|
10784
|
+
return null;
|
|
10785
|
+
}
|
|
10786
|
+
const wrapper = unwrapWrapper(program);
|
|
10787
|
+
if (wrapper === null) return null;
|
|
10788
|
+
const names = /* @__PURE__ */ new Set();
|
|
10789
|
+
const scan = (node) => {
|
|
10790
|
+
if (isFunctionNode(node)) for (const param of node.params) bindingNames(param, names);
|
|
10791
|
+
if (node.type === "VariableDeclarator") bindingNames(node.id, names);
|
|
10792
|
+
forEachChild(node, scan);
|
|
10793
|
+
};
|
|
10794
|
+
scan(wrapper.body);
|
|
10795
|
+
if (names.has("location")) return null;
|
|
10796
|
+
const isLocation = (node) => {
|
|
10797
|
+
const n = unwrapChain(node);
|
|
10798
|
+
if (n.type === "Identifier") return n.name === "location";
|
|
10799
|
+
return n.type === "MemberExpression" && !n.computed && n.property.type === "Identifier" && n.property.name === "location" && n.object.type === "Identifier" && LOCATION_HOLDERS.has(n.object.name);
|
|
10800
|
+
};
|
|
10801
|
+
let found = null;
|
|
10802
|
+
const at2 = (node) => {
|
|
10803
|
+
found = { start: node.start - PREFIX.length, end: node.end - PREFIX.length, text: (PREFIX + body).slice(node.start, node.end) };
|
|
10804
|
+
};
|
|
10805
|
+
const walk = (node) => {
|
|
10806
|
+
if (found !== null) return;
|
|
10807
|
+
if (node.type === "MemberExpression" && isLocation(node.object)) {
|
|
10808
|
+
const part = !node.computed && node.property.type === "Identifier" ? node.property.name : null;
|
|
10809
|
+
if (part === null || LOCATION_VARYING.has(part)) at2(node);
|
|
10810
|
+
return;
|
|
10811
|
+
}
|
|
10812
|
+
if (isLocation(node)) {
|
|
10813
|
+
at2(node);
|
|
10814
|
+
return;
|
|
10815
|
+
}
|
|
10816
|
+
if (node.type === "MemberExpression") {
|
|
10817
|
+
walk(node.object);
|
|
10818
|
+
if (node.computed) walk(node.property);
|
|
10819
|
+
return;
|
|
10820
|
+
}
|
|
10821
|
+
if (node.type === "Property") {
|
|
10822
|
+
if (node.computed) walk(node.key);
|
|
10823
|
+
walk(node.value);
|
|
10824
|
+
return;
|
|
10825
|
+
}
|
|
10826
|
+
forEachChild(node, walk);
|
|
10827
|
+
};
|
|
10828
|
+
walk(wrapper.body);
|
|
10829
|
+
return found;
|
|
10830
|
+
}
|
|
10519
10831
|
|
|
10520
10832
|
// src/core/messages.ts
|
|
10521
10833
|
function resolveLocale(locale2) {
|
|
@@ -10556,6 +10868,8 @@ var ja = {
|
|
|
10556
10868
|
getterCycle: (cycle) => `\u30D1\u30B9 getter \u304C\u5FAA\u74B0\u53C2\u7167\u3057\u3066\u3044\u307E\u3059: ${cycle}`,
|
|
10557
10869
|
updatedCallbackUnbound: (p) => `$renderedCallback \u306F binding \u99C6\u52D5\u3067\u3059\u3002"${p}" \u306F\u3053\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u3069\u306E\u30D0\u30A4\u30F3\u30C7\u30A3\u30F3\u30B0\u306B\u3082\u73FE\u308C\u306A\u3044\u305F\u3081\u3001\u3053\u306E\u5206\u5C90\u306F\u4E00\u5EA6\u3082\u5B9F\u884C\u3055\u308C\u307E\u305B\u3093\u3002\u63CF\u753B\u306B\u4F9D\u5B58\u305B\u305A\u53CD\u5FDC\u3059\u308B\u306A\u3089 $watch \u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044`,
|
|
10558
10870
|
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`,
|
|
10871
|
+
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`,
|
|
10872
|
+
submitWithoutPrevent: (h) => `onsubmit \u306B #prevent \u304C\u7121\u304F\u3001"${h}" \u3082 preventDefault \u3092\u547C\u3073\u307E\u305B\u3093\u3002\u30D6\u30E9\u30A6\u30B6\u306F\u30D5\u30A9\u30FC\u30E0\u3082\u9001\u308B\u306E\u3067\u3001\u30DA\u30FC\u30B8\u304C\u8AAD\u307F\u76F4\u3055\u308C\u308B\u304B\u3001router \u304C\u3042\u308C\u3070 GET \u304C\u6B04\u306E\u5024\uFF08\u30D1\u30B9\u30EF\u30FC\u30C9\u3082\uFF09\u3092 URL \u3068\u5C65\u6B74\u306B\u8F09\u305B\u307E\u3059\u3002onsubmit#prevent: ${h} \u3068\u66F8\u304F\u304B\u3001\u30CF\u30F3\u30C9\u30E9\u3067 event.preventDefault() \u3092\u547C\u3093\u3067\u304F\u3060\u3055\u3044`,
|
|
10559
10873
|
getterUntrackedRead: (root, sp) => `\u3053\u3053\u3067\u8FFD\u8DE1\u3055\u308C\u308B\u306E\u306F "${root}" \u3060\u3051\u3067\u3059\u3002"${sp}" \u304C\u5909\u308F\u3063\u3066\u3082\u3053\u306E getter \u306F\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF08\u30D1\u30B9\u8AAD\u307F\u53D6\u308A\u306E\u5148\u306E\u7D20\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u30A2\u30AF\u30BB\u30B9\u306F\u8FFD\u8DE1\u3055\u308C\u306A\u3044\uFF09\u3002this["${sp}"] \u3067\u8AAD\u3093\u3067\u304F\u3060\u3055\u3044`,
|
|
10560
10874
|
handlerFilterNotAllowed: (prop) => `\u30A4\u30D9\u30F3\u30C8\u30CF\u30F3\u30C9\u30E9 "${prop}" \u306B\u30D5\u30A3\u30EB\u30BF\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093`,
|
|
10561
10875
|
typeExpectation: (label, expected, resultType) => `"${label}" \u306B\u306F${JA_EXPECTED_LABEL[expected]}\u304C\u5FC5\u8981\u3067\u3059\uFF08\u73FE\u5728\u306E\u578B: ${resultType}\uFF09`,
|
|
@@ -10575,13 +10889,15 @@ var ja = {
|
|
|
10575
10889
|
watchKeyEmptySegment: (k) => `$watch \u306E\u30AD\u30FC "${k}" \u306B\u7A7A\u306E\u30D1\u30B9\u30BB\u30B0\u30E1\u30F3\u30C8\u304C\u3042\u308A\u307E\u3059`,
|
|
10576
10890
|
watchHandlerNotFunction: (k) => `$watch \u306E\u30A8\u30F3\u30C8\u30EA "${k}" \u306E\u5024\u306F\u95A2\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
10577
10891
|
watchPathMissing: (k) => `$watch \u306E\u30AD\u30FC "${k}" \u306F\u72B6\u614B\u5B9A\u7FA9\u306B\u5B58\u5728\u3057\u307E\u305B\u3093\uFF08\u4E00\u5EA6\u3082\u767A\u706B\u3057\u307E\u305B\u3093\uFF09`,
|
|
10578
|
-
scanRemoved: (mountPath) => mountPath === null ? `$scan \u306F 4.0 \u3067\u5916\u308C\u307E\u3057\u305F\
|
|
10892
|
+
scanRemoved: (mountPath) => mountPath === null ? `$scan \u306F 4.0 \u3067\u5916\u308C\u307E\u3057\u305F\uFF08diagnostics \u306E\u5F8C\u4ED8\u3051\u3092\u5165\u308C\u305F\u5165\u53E3 \u2014 /auto \u306A\u3069 \u2014 \u306F\u8AAD\u307F\u8FBC\u307F\u6642\u306B throw \u3057\u3001/core \u3060\u3051\u3067\u306F\u9ED9\u3063\u3066\u7121\u8996\u3057\u307E\u3059\uFF09\u3002\u30D1\u30B9\u306E\u5909\u5316\u3092\u7573\u3080\u306A\u3089 $watch\u3001\u30A4\u30D9\u30F3\u30C8\u3092\u7573\u3080\u306A\u3089 $on \u306E\u30CF\u30F3\u30C9\u30E9\u3067\u3001\u51FA\u529B\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u3078\u66F8\u3044\u3066\u304F\u3060\u3055\u3044` : `$scan \u306F 4.0 \u3067\u5916\u308C\u307E\u3057\u305F\u3002\u30DC\u30EA\u30E5\u30FC\u30E0\uFF08mount="${mountPath}"\uFF09\u3067\u306F\u3001\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u63A5\u304E\u6728\u3092\u62D2\u3093\u3067 console.error \u3067\u5831\u544A\u3057\u307E\u3059\uFF08\u3053\u306E state \u306F\u6728\u306B\u8F09\u308A\u307E\u305B\u3093\uFF09\u3002root \u306E state \u306E $watch \u304B $on \u306E\u30CF\u30F3\u30C9\u30E9\u3067\u7573\u3093\u3067\u304F\u3060\u3055\u3044`,
|
|
10579
10893
|
typeAnnotationIncompatible: (vt, rt) => `\u578B "${vt}" \u306F @type {${rt}} \u3068\u4E92\u63DB\u6027\u304C\u3042\u308A\u307E\u305B\u3093`,
|
|
10580
10894
|
arrayMutation: (m, alt) => `\u914D\u5217\u306E\u7834\u58CA\u7684\u30E1\u30BD\u30C3\u30C9 "${m}" \u306F\u30EA\u30A2\u30AF\u30C6\u30A3\u30D6\u66F4\u65B0\u3092\u30C8\u30EA\u30AC\u30FC\u3057\u307E\u305B\u3093\uFF08\u540C\u4E00\u53C2\u7167\u306E\u81EA\u5DF1\u518D\u4EE3\u5165\u3067\u3082\u8981\u7D20\u306E\u8FFD\u52A0\u30FB\u524A\u9664\u306F\u53CD\u6620\u3055\u308C\u307E\u305B\u3093\uFF09\u3002\u975E\u7834\u58CA\u30E1\u30BD\u30C3\u30C9\u3068\u518D\u4EE3\u5165\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: ${alt}\uFF09\u3002`,
|
|
10581
10895
|
arrayIndexAssign: (sp) => `\u914D\u5217\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u3078\u306E\u76F4\u63A5\u4EE3\u5165\u306F\u30EA\u30A2\u30AF\u30C6\u30A3\u30D6\u66F4\u65B0\u3092\u30C8\u30EA\u30AC\u30FC\u3057\u307E\u305B\u3093\u3002this["${sp}"] \u306E\u3088\u3046\u306A\u30C9\u30C3\u30C8\u30D1\u30B9\u4EE3\u5165\u3001\u307E\u305F\u306F with() \u3068\u518D\u4EE3\u5165\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,
|
|
10582
|
-
|
|
10896
|
+
inPlaceAlias: (a, src, t) => `"${a}" \u306F ${src}\uFF08state \u306E\u5024\u305D\u306E\u3082\u306E\uFF09\u3067\u3059\u3002\u305D\u308C\u3092\u901A\u3057\u305F\u5909\u66F4\u306F\u30EA\u30A2\u30AF\u30C6\u30A3\u30D6\u66F4\u65B0\u3092\u30C8\u30EA\u30AC\u30FC\u305B\u305A\u3001\u540C\u3058\u5024\u3092\u66F8\u304D\u623B\u3057\u3066\u3082\u4E00\u89A7\u306E\u884C\u306F\u8FFD\u52A0\u30FB\u524A\u9664\u30FB\u7F6E\u304D\u63DB\u3048\u3055\u308C\u307E\u305B\u3093\u3002\u65B0\u3057\u3044\u5024\u3092\u4F5C\u3063\u3066 ${t} \u306B\u4EE3\u5165\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${a}.with(i, item) / [...${a}, item] / { ...${a}, key: value }\uFF09`,
|
|
10897
|
+
inPlaceChange: (src, t) => `${src} \u306F state \u306E\u5024\u3092\u305D\u306E\u5834\u3067\u5909\u3048\u308B\u306E\u3067\u3001\u30EA\u30A2\u30AF\u30C6\u30A3\u30D6\u66F4\u65B0\u3092\u30C8\u30EA\u30AC\u30FC\u3057\u307E\u305B\u3093\u3002\u65B0\u3057\u3044\u5024\u3092\u4F5C\u3063\u3066 ${t} \u306B\u4EE3\u5165\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
10898
|
+
tagMemberUnknown: (prop, tag) => `"${prop}" \u306F <${tag}> \u306E wcBindable \u30E1\u30F3\u30D0\u30FC\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF08\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u5BA3\u8A00\u306B\u7121\u3044\u30E1\u30F3\u30D0\u30FC\u3078\u306E\u675F\u7E1B\u3092 #38 \u3067\u62D2\u307F\u3001root \u3067\u306F state \u304C\u521D\u671F\u5316\u306B\u5931\u6557\u3057\u307E\u3059\uFF09`,
|
|
10583
10899
|
nameAlias: (written, canonical) => `"${written}" \u306F 4.0 \u3067\u5916\u308C\u307E\u3057\u305F\uFF08"${canonical}" \u306E 3.x \u306E\u65E7\u540D\u3067\u3001\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u8AAD\u3093\u3060\u6642\u70B9\u3067 throw \u3057\u307E\u3059\uFF09\u3002"${canonical}" \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`,
|
|
10584
|
-
declarationAliasRead: (alias, canonical) => `"${alias}" \u306F 4.0 \u3067\u5916\u308C\u305F\u5BA3\u8A00\u30AD\u30FC\uFF08"${canonical}" \u306E 3.x \u306E\u65E7\u540D\uFF09\u306A\u306E\u3067\u3001this["${alias}"] \u306F undefined \u306B\u306A\u308A\u307E\u3059\u3002"${canonical}" \u3092\u8AAD\u3093\u3067\
|
|
10900
|
+
declarationAliasRead: (alias, canonical) => `"${alias}" \u306F 4.0 \u3067\u5916\u308C\u305F\u5BA3\u8A00\u30AD\u30FC\uFF08"${canonical}" \u306E 3.x \u306E\u65E7\u540D\uFF09\u306A\u306E\u3067\u3001this["${alias}"] \u306F undefined \u306B\u306A\u308A\u307E\u3059\u3002\u5BA3\u8A00\u306F this \u3092\u901A\u3057\u3066\u8AAD\u3081\u307E\u305B\u3093 \u2014 "${canonical}" \u3092\u8AAD\u3093\u3067\u3082 undefined \u3067\u3059${canonical === "$stream" ? "\uFF08\u30B9\u30C8\u30EA\u30FC\u30E0\u306E\u72B6\u614B\u306F $streamStatus\u30FB$streamError \u3067\u8AAD\u307F\u307E\u3059\uFF09" : ""}`,
|
|
10585
10901
|
declarationAlias: (alias, canonical) => `\u5BA3\u8A00\u30AD\u30FC "${alias}" \u306F 4.0 \u3067\u5916\u308C\u307E\u3057\u305F\uFF08"${canonical}" \u306E 3.x \u306E\u65E7\u540D\u3067\u3001\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u8AAD\u307F\u8FBC\u307F\u6642\u306B throw \u3057\u307E\u3059\uFF09\u3002"${canonical}" \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`,
|
|
10586
10902
|
declarationAliasInVolume: (alias, canonical, mountPath) => `\u5BA3\u8A00\u30AD\u30FC "${alias}" \u306F 4.0 \u3067\u5916\u308C\u307E\u3057\u305F\uFF08"${canonical}" \u306E 3.x \u306E\u65E7\u540D\uFF09\u3002\u30DC\u30EA\u30E5\u30FC\u30E0\uFF08mount="${mountPath}"\uFF09\u3067\u306F\u3001\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u63A5\u304E\u6728\u3092\u62D2\u3093\u3067 console.error \u3067\u5831\u544A\u3057\u307E\u3059\uFF08\u3053\u306E state \u306F\u6728\u306B\u8F09\u308A\u307E\u305B\u3093\uFF09\u3002"${canonical}" \u3082\u30DC\u30EA\u30E5\u30FC\u30E0\u3067\u306F\u5BA3\u8A00\u3067\u304D\u306A\u3044\u306E\u3067\u3001root \u306E state \u306B\u5BA3\u8A00\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
10587
10903
|
behaviorNotObject: (keys) => `$behavior \u306F { ${keys.map((k) => `${k}?`).join(", ")} } \u306E\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\uFF08\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u8AAD\u307F\u8FBC\u307F\u6642\u306B throw \u3057\u307E\u3059\uFF09`,
|
|
@@ -10611,22 +10927,27 @@ var ja = {
|
|
|
10611
10927
|
storagePairClobber: (path) => `<wcs-storage> \u306E value \u3092 #init=element \u306A\u3057\u3067\u30A2\u30AF\u30BB\u30B5\u30DA\u30A2 "${path}" \u306B\u675F\u306D\u3066\u3044\u307E\u3059\u3002state \u306E\u5074\u304C\u5148\u306B\u66F8\u304F\u306E\u3067\u3001\u8AAD\u307F\u8FBC\u307F\u306E\u305F\u3073\u306B getter \u306E\u6700\u521D\u306E\u5024\u304C\u4FDD\u5B58\u5024\u306E\u4E0A\u306B\u4FDD\u5B58\u3055\u308C\u3001setter \u306F\u4FDD\u5B58\u5024\u3092\u53D7\u3051\u53D6\u308C\u307E\u305B\u3093 \u2014 #init=element \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\uFF08\`value#init=element: ${path}\`\uFF09`,
|
|
10612
10928
|
inputNestedWrite: (tag, input, path, example) => `<${tag}> \u306E\u5165\u529B "${input}" \u306B "${path}" \u3092\u675F\u306D\u3066\u3044\u307E\u3059\u304C\u3001\u30DA\u30FC\u30B8\u306F\u305D\u306E\u4E0B\uFF08"${example}"\uFF09\u3078\u66F8\u304D\u8FBC\u3093\u3067\u3044\u307E\u3059\u3002\u675F\u7E1B\u306F "${path}" \u81EA\u8EAB\u3078\u306E\u4EE3\u5165\u3067\u3057\u304B\u5F53\u3066\u76F4\u3055\u308C\u306A\u3044\u306E\u3067\u3001\u4E0B\u3078\u306E\u66F8\u304D\u8FBC\u307F\u306F <${tag}> \u306B\u5C4A\u304D\u307E\u305B\u3093 \u2014 \u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u30D1\u30B9\u3067\u8AAD\u3093\u3067\u65B0\u3057\u3044\u5024\u3092\u8FD4\u3059 getter\uFF08\`this["${example}"]\`\u30FB\`$getAll\`\uFF09\u3092\u675F\u306D\u308B\u304B\u3001\u4E0B\u3078\u66F8\u304B\u305A\u306B "${path}" \u3092\u5DEE\u3057\u66FF\u3048\u3066\u304F\u3060\u3055\u3044`,
|
|
10613
10929
|
inputNestedWriteOneShot: (tag, input, path, example) => `<${tag}> \u306E\u5165\u529B "${input}" \u306B "${path}" \u3092\u675F\u306D\u3066\u3044\u307E\u3059\u304C\u3001\u30DA\u30FC\u30B8\u306F\u305D\u306E\u4E0B\uFF08"${example}"\uFF09\u3078\u66F8\u304D\u8FBC\u3093\u3067\u3044\u307E\u3059\u3002\u675F\u7E1B\u306F "${path}" \u81EA\u8EAB\u3078\u306E\u4EE3\u5165\u3067\u3057\u304B\u5F53\u3066\u76F4\u3055\u308C\u305A\u3001<${tag}> \u306F\u8981\u6C42\u306E\u305F\u3073\u306B "${input}" \u3092 null \u306B\u623B\u3059\u306E\u3067\u3001\u6B21\u306E\u8981\u6C42\u306F "${input}" \u306A\u3057\u3067\u9001\u3089\u308C\u307E\u3059 \u2014 \u8981\u6C42\u3092\u59CB\u3081\u308B\u30CF\u30F3\u30C9\u30E9\u3067\u65B0\u3057\u3044\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3092\u4F5C\u3063\u3066\u4EE3\u5165\u3057\uFF08\`this.submitBody = { \u2026 }\`\uFF09\u3001\u305D\u308C\u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044`,
|
|
10614
|
-
devtoolsAfterState: () => `@wcstack/devtools/auto \u306F @wcstack/state/auto \u3088\u308A\u5148\u306B\u8AAD\u307F\u8FBC\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u5F8C\u3060\u3068\
|
|
10930
|
+
devtoolsAfterState: () => `@wcstack/devtools/auto \u306F @wcstack/state/auto \u3088\u308A\u5148\u306B\u8AAD\u307F\u8FBC\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u5F8C\u304B\u3089\u3060\u3068\u3001DevTools \u306E\u30BF\u30A4\u30E0\u30E9\u30A4\u30F3\u306F\u4ED8\u3044\u305F\u6642\u70B9\u304B\u3089\u59CB\u307E\u308A\u307E\u3059\u3002\u65E2\u306B\u3042\u308B\u914D\u7DDA\u306F 4.0 \u304C\u9001\u308A\u76F4\u3057\u307E\u3059\uFF09`,
|
|
10615
10931
|
baseHrefMissing: () => `@wcstack/router \u3092\u4F7F\u3046 SPA \u306B\u306F <head> \u5185\u306E <base href="/"> \u304C\u5FC5\u8981\u3067\u3059\uFF08\u7121\u3044\u3068\u30C7\u30A3\u30FC\u30D7\u30EA\u30F3\u30AF\u3067 basename \u304C\u8AA4\u5C0E\u51FA\u3055\u308C\u307E\u3059\uFF09`,
|
|
10616
10932
|
routerOutletMisplaced: () => `\u3053\u306E <wcs-outlet> \u306F <wcs-router> \u306E\u76F4\u5F8C\u306B\u7121\u3044\u306E\u3067\u3001\u3069\u306E router \u3082\u4F7F\u3044\u307E\u305B\u3093\u3002router \u306F\u81EA\u5206\u306E\u76F4\u5F8C\u306E\u8981\u7D20\u3060\u3051\u3092 outlet \u3068\u3057\u3066\u4F7F\u3044\u3001\u305D\u3053\u306B <wcs-outlet> \u304C\u7121\u3051\u308C\u3070\u81EA\u524D\u306E outlet \u3092\u4F5C\u308A\u307E\u3059\u3002\u30EB\u30FC\u30C8\u306F router \u306E\u76F4\u5F8C\u306B\u63CF\u304B\u308C\u3001\u3053\u306E outlet \u306F\u7A7A\u306E\u307E\u307E\u3067\u3059 \u2014 <wcs-router> \u306E\u76F4\u5F8C\u3078\u79FB\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
10617
10933
|
signalsDualEntry: () => `@wcstack/signals \u3068 @wcstack/signals/dom \u304C\u540C\u4E00\u30DA\u30FC\u30B8\u304B\u3089 import \u3055\u308C\u3066\u3044\u307E\u3059\u3002CDN \u3067\u306F\u5404\u30A8\u30F3\u30C8\u30EA\u304C\u81EA\u5DF1\u5B8C\u7D50\u30D0\u30F3\u30C9\u30EB\u306E\u305F\u3081\u30EA\u30A2\u30AF\u30C6\u30A3\u30D6\u30B3\u30A2\u304C\u4E8C\u91CD\u5316\u3057\u3001\u5883\u754C\u3067\u53CD\u5FDC\u304C\u58CA\u308C\u307E\u3059 \u2014 \u3059\u3079\u3066 /dom \u30A8\u30F3\u30C8\u30EA\u304B\u3089 import \u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
10934
|
+
signalsImportMapBoth: () => `\u3053\u306E import map \u306F @wcstack/signals \u3068 @wcstack/signals/dom \u306E\u4E21\u65B9\u3092\u5272\u308A\u5F53\u3066\u3066\u3044\u307E\u3059\u3002CDN \u3067\u306F\u5404\u30A8\u30F3\u30C8\u30EA\u304C\u30EA\u30A2\u30AF\u30C6\u30A3\u30D6\u30B3\u30A2\u3092\u6301\u3064\u306E\u3067\u3001@wcstack/signals \u3092 import \u3059\u308B\u30E2\u30B8\u30E5\u30FC\u30EB\uFF08\u3053\u306E\u30DA\u30FC\u30B8\u306E\u3082\u306E\u3067\u3082\u3001\u8AAD\u307F\u8FBC\u3080 .js \u3067\u3082\uFF09\u304C 2 \u3064\u76EE\u306E\u30B3\u30A2\u3092\u6301\u3061\u3001\u5883\u754C\u3067\u53CD\u5FDC\u304C\u58CA\u308C\u307E\u3059\u3002@wcstack/signals/dom \u3060\u3051\u3092\u5272\u308A\u5F53\u3066\u3066\u304F\u3060\u3055\u3044\uFF08\u30B3\u30A2\u306E\u5168\u90E8\u3092 export \u3057\u307E\u3059\uFF09`,
|
|
10935
|
+
routeBareMustache: (inLayout) => inLayout ? `\u30EC\u30A4\u30A2\u30A6\u30C8\u306E\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306E\u76F4\u4E0B\u306E\u30C6\u30AD\u30B9\u30C8\u306E {{ }} \u306F\u3001\u9077\u79FB\u3067\u306F\u675F\u306D\u3089\u308C\u307E\u305B\u3093 \u2014 \u8981\u7D20\u3067\u5305\u3093\u3067\u304F\u3060\u3055\u3044\uFF08<span>{{ \u2026 }}</span>\uFF09` : `<wcs-route> \u306E\u76F4\u4E0B\u306E\u30C6\u30AD\u30B9\u30C8\u306E {{ }} \u306F\u3001\u6700\u521D\u306B\u7740\u3044\u305F\u30EB\u30FC\u30C8\u3067\u3057\u304B\u675F\u306D\u3089\u308C\u307E\u305B\u3093\u3002\u9077\u79FB\u3067\u5165\u3063\u305F\u30EB\u30FC\u30C8\u3067\u306F\u66F8\u3044\u305F\u307E\u307E\u306E\u6587\u5B57\u304C\u51FA\u307E\u3059 \u2014 \u8981\u7D20\u3067\u5305\u3093\u3067\u304F\u3060\u3055\u3044\uFF08<h1>{{ \u2026 }}</h1>\uFF09`,
|
|
10936
|
+
layoutSlotMissing: (l) => `\u30EC\u30A4\u30A2\u30A6\u30C8 "${l}" \u306E\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306B\u65E2\u5B9A\u306E <slot>\uFF08name \u306E\u7121\u3044\u3082\u306E\uFF09\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u3053\u306E <wcs-layout> \u306E\u540D\u524D\u4ED8\u304D\u30B9\u30ED\u30C3\u30C8\u306E\u5916\u306E\u4E2D\u8EAB\uFF08\u5165\u308C\u5B50\u306E\u30EB\u30FC\u30C8\u3068\u305D\u306E\u30DA\u30FC\u30B8\uFF09\u306F\u8868\u793A\u3055\u308C\u307E\u305B\u3093 \u2014 \u30DA\u30FC\u30B8\u3092\u7F6E\u304F\u5834\u6240\u306B <slot></slot> \u3092\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`,
|
|
10618
10937
|
namedStateAttrDeprecated: (name) => `name \u5C5E\u6027\u306F v2 \u3067\u64A4\u53BB\u3055\u308C\u307E\u3057\u305F\uFF081 root 1 \u30C4\u30EA\u30FC\uFF09\u3002\u30EB\u30FC\u30C8\u30C4\u30EA\u30FC\u3078\u306E\u30DE\u30A6\u30F3\u30C8 <wcs-state mount="${name}"> \u306B\u7F6E\u304D\u63DB\u3048\u3001\u30D1\u30B9\u306F "${name}.<path>" \u3067\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\uFF08docs/state-mount-design.md \xA79\uFF09`,
|
|
10619
10938
|
namedStatePathDeprecated: (name) => name === "default" ? `"@default" \u30BB\u30EC\u30AF\u30BF\u306F v2 \u3067\u64A4\u53BB\u3055\u308C\u307E\u3057\u305F\u3002"@default" \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\uFF08docs/state-mount-design.md \xA79\uFF09` : `"@name" \u30BB\u30EC\u30AF\u30BF\u306F v2 \u3067\u64A4\u53BB\u3055\u308C\u307E\u3057\u305F\uFF081 root 1 \u30C4\u30EA\u30FC\uFF09\u3002\u30DE\u30A6\u30F3\u30C8\u3057\u305F\u30C4\u30EA\u30FC\u3092 "${name}.<path>" \u3067\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\uFF08docs/state-mount-design.md \xA79\uFF09`,
|
|
10620
10939
|
mountPathInvalid: (problem, mountPath) => {
|
|
10621
10940
|
switch (problem) {
|
|
10622
10941
|
case "empty":
|
|
10623
|
-
return `"mount" \u306B\u306F\u7A7A\u3067\u306A\u3044\
|
|
10942
|
+
return `"mount" \u306B\u306F\u7A7A\u3067\u306A\u3044\u9759\u7684\u306A\u30D1\u30B9\u304C\u5FC5\u8981\u3067\u3059\uFF08\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u30DC\u30EA\u30E5\u30FC\u30E0\u3092\u62D2\u307F\u307E\u3059: has an invalid mount path\uFF09`;
|
|
10624
10943
|
case "emptySegment":
|
|
10625
|
-
return `"mount" \u30D1\u30B9 "${mountPath}" \u306B\u7A7A\u306E\
|
|
10944
|
+
return `"mount" \u30D1\u30B9 "${mountPath}" \u306B\u7A7A\u306E\u6BB5\u304C\u3042\u308A\u307E\u3059\uFF08\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u30DC\u30EA\u30E5\u30FC\u30E0\u3092\u62D2\u307F\u307E\u3059: has an invalid mount path\uFF09`;
|
|
10626
10945
|
case "wildcard":
|
|
10627
|
-
return `"mount" \u30D1\u30B9 "${mountPath}" \u306F\u9759\u7684\u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 \u2014 \
|
|
10946
|
+
return `"mount" \u30D1\u30B9 "${mountPath}" \u306F\u9759\u7684\u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 \u2014 "*" \u306F\u4F7F\u3048\u307E\u305B\u3093\uFF08\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u30DC\u30EA\u30E5\u30FC\u30E0\u3092\u62D2\u307F\u307E\u3059: has an invalid mount path\uFF09`;
|
|
10947
|
+
case "whitespace":
|
|
10948
|
+
return `"mount" \u30D1\u30B9 "${mountPath}" \u306B\u7A7A\u767D\u306F\u4F7F\u3048\u307E\u305B\u3093\uFF08\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u30DC\u30EA\u30E5\u30FC\u30E0\u3092\u62D2\u307F\u307E\u3059: has an invalid mount path\uFF09`;
|
|
10628
10949
|
default:
|
|
10629
|
-
return `"mount" \u30D1\u30B9 "${mountPath}" \u306B\u4E88\u7D04\u6587\u5B57\uFF08$, #, @\uFF09\u306F\u4F7F\u3048\u307E\u305B\u3093\
|
|
10950
|
+
return `"mount" \u30D1\u30B9 "${mountPath}" \u306B\u4E88\u7D04\u6587\u5B57\uFF08$, #, @\uFF09\u306F\u4F7F\u3048\u307E\u305B\u3093\uFF08\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u30DC\u30EA\u30E5\u30FC\u30E0\u3092\u62D2\u307F\u307E\u3059: has an invalid mount path\uFF09`;
|
|
10630
10951
|
}
|
|
10631
10952
|
},
|
|
10632
10953
|
recursionUnsupported: (p, where) => {
|
|
@@ -10648,7 +10969,7 @@ var ja = {
|
|
|
10648
10969
|
case "listKeys":
|
|
10649
10970
|
return `$listKeys \u306E\u30AD\u30FC "${p}" \u306B "**" \u306F\u4F7F\u3048\u307E\u305B\u3093\u3002\u30AD\u30FC\u4ED8\u304D\u30EA\u30B9\u30C8\u306F 1 \u672C\u306E\u5177\u4F53\u30EA\u30B9\u30C8\u30D1\u30B9\u3067\u3059 \u2014 \u6DF1\u3055\u3054\u3068\u306B\u5BA3\u8A00\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: "nodes.*.children"\uFF09`;
|
|
10650
10971
|
default:
|
|
10651
|
-
return `"${p}" \u306F "**" \u3092\u542B\u307F\u307E\u3059\u304C\u3001\u3053\u306E state \u306B\u306F $recursion \u5BA3\u8A00\u304C\u3042\u308A\u307E\u305B\u3093\u3002$recursion = { "<anchor>": "<repeat>" }\uFF08\u4F8B: { "nodes.*": "children.*" }\uFF09\u3092\u5BA3\u8A00\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u5BA3\u8A00\u304C\u7121\u3044\u3068
|
|
10972
|
+
return `"${p}" \u306F "**" \u3092\u542B\u307F\u307E\u3059\u304C\u3001\u3053\u306E state \u306B\u306F $recursion \u5BA3\u8A00\u304C\u3042\u308A\u307E\u305B\u3093\u3002$recursion = { "<anchor>": "<repeat>" }\uFF08\u4F8B: { "nodes.*": "children.*" }\uFF09\u3092\u5BA3\u8A00\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u5BA3\u8A00\u304C\u7121\u3044\u3068\u3001\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u8AAD\u307F\u8FBC\u307F\u6642\u306B #1101 \u3067 throw \u3057\u3001state \u306F\u521D\u671F\u5316\u306B\u5931\u6557\u3057\u307E\u3059\uFF09`;
|
|
10652
10973
|
}
|
|
10653
10974
|
},
|
|
10654
10975
|
recursionAnchorMismatch: (p, anchor) => `"${p}" \u306F\u5BA3\u8A00\u6E08\u307F\u306E\u518D\u5E30\u30A2\u30F3\u30AB\u30FC "${anchor}" \u3068\u5408\u81F4\u3057\u307E\u305B\u3093\uFF08\u521D\u7248\u306F state \u3054\u3068\u306B 1 \u3064\u306E\u81EA\u5DF1\u518D\u5E30\u306E\u307F\u3002"**" \u306E\u5F8C\u308D\u306F\u6574\u5F62\u3055\u308C\u305F\u63A5\u5C3E\u8F9E \u2014 2 \u3064\u76EE\u306E "**"\u30FB\u7A7A\u30BB\u30B0\u30E1\u30F3\u30C8\u30FB"**" \u76F4\u5F8C\u306E\u7D20\u306E "*" \u306F\u7F6E\u3051\u307E\u305B\u3093\uFF09`,
|
|
@@ -10748,6 +11069,8 @@ var en = {
|
|
|
10748
11069
|
getterCycle: (cycle) => `Path getters form a dependency cycle: ${cycle}`,
|
|
10749
11070
|
updatedCallbackUnbound: (p) => `$renderedCallback is binding-driven. "${p}" is not bound anywhere in this document, so this branch never runs. Use $watch to react without depending on what is rendered`,
|
|
10750
11071
|
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`,
|
|
11072
|
+
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`,
|
|
11073
|
+
submitWithoutPrevent: (h) => `onsubmit has no #prevent and "${h}" does not call preventDefault, so the browser submits the form too: the page reloads, or with the router a GET puts the fields (a password too) in the URL and the history. Write onsubmit#prevent: ${h}, or call event.preventDefault() in the handler`,
|
|
10751
11074
|
getterUntrackedRead: (root, sp) => `Only "${root}" is tracked here: the getter is not re-evaluated when "${sp}" changes (plain property access after a path read is not tracked). Read this["${sp}"] instead`,
|
|
10752
11075
|
handlerFilterNotAllowed: (prop) => `Filters cannot be applied to event handler "${prop}"`,
|
|
10753
11076
|
typeExpectation: (label, expected, resultType) => `"${label}" requires ${EN_EXPECTED_LABEL[expected]} (current type: ${resultType})`,
|
|
@@ -10767,13 +11090,15 @@ var en = {
|
|
|
10767
11090
|
watchKeyEmptySegment: (k) => `$watch key "${k}" has an empty path segment`,
|
|
10768
11091
|
watchHandlerNotFunction: (k) => `The value of $watch entry "${k}" must be a function`,
|
|
10769
11092
|
watchPathMissing: (k) => `$watch key "${k}" does not exist in the state definition (it will never fire)`,
|
|
10770
|
-
scanRemoved: (mountPath) => mountPath === null ? `$scan was removed in 4.0 (the
|
|
11093
|
+
scanRemoved: (mountPath) => mountPath === null ? `$scan was removed in 4.0 (the entries with the diagnostics add-on, such as /auto, throw at load; /core alone ignores it). Fold a path's changes in a $watch handler, or events in an $on handler, and write the output property there` : `$scan was removed in 4.0. In a volume (mount="${mountPath}") the runtime refuses to graft it and reports that with console.error (this state is not on the tree). Fold in a $watch or $on handler on the root state`,
|
|
10771
11094
|
typeAnnotationIncompatible: (vt, rt) => `Type "${vt}" is not compatible with @type {${rt}}`,
|
|
10772
11095
|
arrayMutation: (m, alt) => `Destructive array method "${m}" does not trigger a reactive update (re-assigning the same reference does not reflect added/removed elements either). Use a non-destructive method with reassignment (e.g. ${alt}).`,
|
|
10773
11096
|
arrayIndexAssign: (sp) => `Assigning directly to an array index does not trigger a reactive update. Use a dot-path assignment like this["${sp}"], or with() plus reassignment.`,
|
|
10774
|
-
|
|
11097
|
+
inPlaceAlias: (a, src, t) => `"${a}" is ${src} \u2014 the state's own value. A change through it does not trigger a reactive update, and writing the same value back does not add, remove or replace a list's rows. Build a new value and assign it to ${t} (${a}.with(i, item), [...${a}, item], { ...${a}, key: value })`,
|
|
11098
|
+
inPlaceChange: (src, t) => `${src} changes the state's value in place, which does not trigger a reactive update. Build a new value and assign it to ${t}`,
|
|
11099
|
+
tagMemberUnknown: (prop, tag) => `"${prop}" is not a wcBindable member of <${tag}> (the runtime refuses a binding to an undeclared member with #38; at the root the state fails to initialize)`,
|
|
10775
11100
|
nameAlias: (written, canonical) => `"${written}" was removed in 4.0 (the 3.x old name of "${canonical}"; the runtime throws when it is read) \u2014 write "${canonical}"`,
|
|
10776
|
-
declarationAliasRead: (alias, canonical) => `"${alias}" is a declaration key 4.0 removed (the 3.x old name of "${canonical}"), so this["${alias}"] is undefined.
|
|
11101
|
+
declarationAliasRead: (alias, canonical) => `"${alias}" is a declaration key 4.0 removed (the 3.x old name of "${canonical}"), so this["${alias}"] is undefined. A declaration cannot be read through this \u2014 reading "${canonical}" is undefined too${canonical === "$stream" ? " (read a stream's state from $streamStatus / $streamError)" : ""}`,
|
|
10777
11102
|
declarationAlias: (alias, canonical) => `The declaration key "${alias}" was removed in 4.0 (the 3.x old name of "${canonical}"; the runtime throws at load time) \u2014 write "${canonical}"`,
|
|
10778
11103
|
declarationAliasInVolume: (alias, canonical, mountPath) => `The declaration key "${alias}" was removed in 4.0 (the 3.x old name of "${canonical}"). In a volume (mount="${mountPath}") the runtime refuses to graft it and reports that with console.error (this state is not on the tree). "${canonical}" cannot be declared in a volume either \u2014 declare it on the root state`,
|
|
10779
11104
|
behaviorNotObject: (keys) => `$behavior must be an object { ${keys.map((k) => `${k}?`).join(", ")} } (the runtime throws at load time)`,
|
|
@@ -10803,22 +11128,27 @@ var en = {
|
|
|
10803
11128
|
storagePairClobber: (path) => `The <wcs-storage> value is bound to the accessor pair "${path}" without #init=element. The state's side goes first, so on every load the getter's starting value is saved over the stored one, and the setter never receives it \u2014 add #init=element (\`value#init=element: ${path}\`)`,
|
|
10804
11129
|
inputNestedWrite: (tag, input, path, example) => `"${path}" is bound to the input "${input}" of <${tag}>, but the page writes below it ("${example}"). A binding is re-applied only when "${path}" itself is assigned, so those writes never reach <${tag}> \u2014 bind a getter that reads the fields by path (\`this["${example}"]\`, \`$getAll\`) and returns a new value, or replace "${path}" instead of writing below it`,
|
|
10805
11130
|
inputNestedWriteOneShot: (tag, input, path, example) => `"${path}" is bound to the input "${input}" of <${tag}>, but the page writes below it ("${example}"). A binding is re-applied only when "${path}" itself is assigned, and <${tag}> resets "${input}" to null after every request, so the next request goes without it \u2014 build a new object in the handler that starts the request (\`this.submitBody = { \u2026 }\`) and bind that`,
|
|
10806
|
-
devtoolsAfterState: () => `Load @wcstack/devtools/auto
|
|
11131
|
+
devtoolsAfterState: () => `Load @wcstack/devtools/auto before @wcstack/state/auto (loaded later, the DevTools timeline starts when it attaches; 4.0 sends it the wiring that is there already)`,
|
|
10807
11132
|
baseHrefMissing: () => `An SPA using @wcstack/router needs <base href="/"> in <head> (without it, deep links misderive the basename)`,
|
|
10808
11133
|
routerOutletMisplaced: () => `This <wcs-outlet> is not right after a <wcs-router>, so no router uses it: a router uses only the element right after it as its outlet, and makes an outlet of its own there when that is not a <wcs-outlet>. The routes render right after the router and this outlet stays empty \u2014 move it right after the <wcs-router>`,
|
|
10809
11134
|
signalsDualEntry: () => `Both @wcstack/signals and @wcstack/signals/dom are imported on this page. On a CDN each entry is a self-contained bundle, so the reactive core is duplicated and reactivity breaks at the seam \u2014 import everything from the single /dom entry`,
|
|
11135
|
+
signalsImportMapBoth: () => `This import map maps both @wcstack/signals and @wcstack/signals/dom. On a CDN each entry carries its own reactive core, so a module that imports @wcstack/signals \u2014 this page's, or a .js file it loads \u2014 gets a second core and reactivity breaks at the seam. Map only @wcstack/signals/dom (it exports the whole core)`,
|
|
11136
|
+
routeBareMustache: (inLayout) => inLayout ? `{{ }} in text directly under a layout template is not bound on a navigation. Wrap it in an element (<span>{{ \u2026 }}</span>)` : `{{ }} in text directly under <wcs-route> is bound only on the landing route: a route entered by navigation shows it as written. Wrap it in an element (<h1>{{ \u2026 }}</h1>)`,
|
|
11137
|
+
layoutSlotMissing: (l) => `The template of layout "${l}" has no default <slot> (one without a name), so what this <wcs-layout> holds outside the named slots \u2014 the nested routes and their pages \u2014 is not shown. Put a <slot></slot> where the page goes`,
|
|
10810
11138
|
namedStateAttrDeprecated: (name) => `The "name" attribute was removed in v2 \u2014 there is a single state tree per root. Mount this state onto the tree instead: <wcs-state mount="${name}"> and read it as "${name}.<path>" (docs/state-mount-design.md \xA79)`,
|
|
10811
11139
|
namedStatePathDeprecated: (name) => name === "default" ? `The "@default" selector was removed in v2 \u2014 drop it (docs/state-mount-design.md \xA79)` : `The "@name" selector was removed in v2 \u2014 there is a single state tree. Mount the named state onto the tree (<wcs-state mount="...">) and read it as "${name}.<path>" (docs/state-mount-design.md \xA79)`,
|
|
10812
11140
|
mountPathInvalid: (problem, mountPath) => {
|
|
10813
11141
|
switch (problem) {
|
|
10814
11142
|
case "empty":
|
|
10815
|
-
return `"mount"
|
|
11143
|
+
return `"mount" needs a non-empty static path (the runtime refuses the volume: "has an invalid mount path").`;
|
|
10816
11144
|
case "emptySegment":
|
|
10817
|
-
return `"mount" path "${mountPath}" has an empty segment.`;
|
|
11145
|
+
return `"mount" path "${mountPath}" has an empty segment (the runtime refuses the volume: "has an invalid mount path").`;
|
|
10818
11146
|
case "wildcard":
|
|
10819
|
-
return `"mount" path "${mountPath}" must be static (
|
|
11147
|
+
return `"mount" path "${mountPath}" must be static \u2014 no "*" (the runtime refuses the volume: "has an invalid mount path").`;
|
|
11148
|
+
case "whitespace":
|
|
11149
|
+
return `"mount" path "${mountPath}" must not contain whitespace (the runtime refuses the volume: "has an invalid mount path").`;
|
|
10820
11150
|
default:
|
|
10821
|
-
return `"mount" path "${mountPath}" must not use reserved characters
|
|
11151
|
+
return `"mount" path "${mountPath}" must not use the reserved characters $, #, @ (the runtime refuses the volume: "has an invalid mount path").`;
|
|
10822
11152
|
}
|
|
10823
11153
|
},
|
|
10824
11154
|
recursionUnsupported: (p, where) => {
|
|
@@ -10840,7 +11170,7 @@ var en = {
|
|
|
10840
11170
|
case "listKeys":
|
|
10841
11171
|
return `$listKeys key "${p}" cannot contain "**" \u2014 a keyed list is one concrete list path. Declare the key per depth instead (for example "nodes.*.children")`;
|
|
10842
11172
|
default:
|
|
10843
|
-
return `"${p}" contains "**" but this state declares no $recursion anchor. Declare $recursion = { "<anchor>": "<repeat>" } (for example { "nodes.*": "children.*" }) \u2014 without it
|
|
11173
|
+
return `"${p}" contains "**" but this state declares no $recursion anchor. Declare $recursion = { "<anchor>": "<repeat>" } (for example { "nodes.*": "children.*" }) \u2014 without it the runtime throws #1101 at load and the state fails to initialize`;
|
|
10844
11174
|
}
|
|
10845
11175
|
},
|
|
10846
11176
|
recursionAnchorMismatch: (p, anchor) => `"${p}" does not match the declared recursion anchor "${anchor}" (this version supports exactly one self-recursive anchor per state, and "**" must be followed by a well-formed suffix: no second "**", no empty segment, no bare "*" right after "**")`,
|
|
@@ -11221,6 +11551,19 @@ var DELEGATED_EVENTS = /* @__PURE__ */ new Set([
|
|
|
11221
11551
|
var CUSTOM_ELEMENT_OWN_EVENTS = /* @__PURE__ */ new Set(["input", "change", "submit"]);
|
|
11222
11552
|
function collectCurrentTargetHandlers(elements, html, fileReader) {
|
|
11223
11553
|
const names = /* @__PURE__ */ new Set();
|
|
11554
|
+
forEachStateMethod(elements, html, fileReader, "currentTarget", (name, params, body) => {
|
|
11555
|
+
if (readsEventCurrentTarget(params, body)) names.add(name);
|
|
11556
|
+
});
|
|
11557
|
+
return names;
|
|
11558
|
+
}
|
|
11559
|
+
function collectPreventDefaultHandlers(elements, html, fileReader) {
|
|
11560
|
+
const handlers = /* @__PURE__ */ new Map();
|
|
11561
|
+
forEachStateMethod(elements, html, fileReader, null, (name, _params, body) => {
|
|
11562
|
+
handlers.set(name, /\bpreventDefault\b/.test(body));
|
|
11563
|
+
});
|
|
11564
|
+
return handlers;
|
|
11565
|
+
}
|
|
11566
|
+
function forEachStateMethod(elements, html, fileReader, spelling, fn) {
|
|
11224
11567
|
let insideTemplate = null;
|
|
11225
11568
|
for (const element2 of elements) {
|
|
11226
11569
|
if (element2.bindComponent) continue;
|
|
@@ -11230,20 +11573,19 @@ function collectCurrentTargetHandlers(elements, html, fileReader) {
|
|
|
11230
11573
|
const script = readStateScript(element2.srcAttr, fileReader);
|
|
11231
11574
|
if (script !== void 0) scripts = [script];
|
|
11232
11575
|
}
|
|
11233
|
-
scripts = scripts.filter((script) => script.includes(
|
|
11576
|
+
if (spelling !== null) scripts = scripts.filter((script) => script.includes(spelling));
|
|
11234
11577
|
if (scripts.length === 0) continue;
|
|
11235
11578
|
if ((insideTemplate ??= createTemplateTester(html))(element2.tagStart)) continue;
|
|
11236
11579
|
for (const script of scripts) {
|
|
11237
11580
|
for (const callable of analyzeCallableBodies(script)) {
|
|
11238
|
-
if (callable.kind !== "method" || !callable.body.includes(
|
|
11581
|
+
if (callable.kind !== "method" || spelling !== null && !callable.body.includes(spelling)) continue;
|
|
11239
11582
|
const head = script.slice(callable.end, callable.bodyStart - 1);
|
|
11240
11583
|
const params = /\(([^)]*)\)\s*$/.exec(head);
|
|
11241
11584
|
if (params === null) continue;
|
|
11242
|
-
|
|
11585
|
+
fn(volume === null ? callable.name : `${volume}.${callable.name}`, params[1], callable.body);
|
|
11243
11586
|
}
|
|
11244
11587
|
}
|
|
11245
11588
|
}
|
|
11246
|
-
return names;
|
|
11247
11589
|
}
|
|
11248
11590
|
function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, fileReader, applicationSchema) {
|
|
11249
11591
|
const diagnostics = [];
|
|
@@ -11251,11 +11593,6 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
|
|
|
11251
11593
|
const pathIndex = getStatePathIndex(html, stateTagName, fileReader);
|
|
11252
11594
|
const statePaths = mergeSchemaCandidates(pathIndex.paths, applicationSchema);
|
|
11253
11595
|
const attrs = findAllBindAttributes(html, attrName);
|
|
11254
|
-
let structuralTemplates = null;
|
|
11255
|
-
const getStructuralTemplates = () => {
|
|
11256
|
-
structuralTemplates ??= collectStructuralTemplates(html, attrName);
|
|
11257
|
-
return structuralTemplates;
|
|
11258
|
-
};
|
|
11259
11596
|
const outerCandidates = [];
|
|
11260
11597
|
const currentTargetCandidates = [];
|
|
11261
11598
|
let currentTargetHandlers = null;
|
|
@@ -11263,6 +11600,11 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
|
|
|
11263
11600
|
currentTargetHandlers ??= collectCurrentTargetHandlers(pathIndex.elements, html, fileReader);
|
|
11264
11601
|
return currentTargetHandlers;
|
|
11265
11602
|
};
|
|
11603
|
+
let preventDefaultHandlers = null;
|
|
11604
|
+
const getPreventDefaultHandlers = () => {
|
|
11605
|
+
preventDefaultHandlers ??= collectPreventDefaultHandlers(pathIndex.elements, html, fileReader);
|
|
11606
|
+
return preventDefaultHandlers;
|
|
11607
|
+
};
|
|
11266
11608
|
for (const attr of attrs) {
|
|
11267
11609
|
const bindings = splitBindingExpressions(attr.value);
|
|
11268
11610
|
const nonEmptyCount = bindings.filter((b) => b.trim().length > 0).length;
|
|
@@ -11324,6 +11666,15 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
|
|
|
11324
11666
|
const eventName = propNoMod.slice(2);
|
|
11325
11667
|
const handler = parsed.path.trim();
|
|
11326
11668
|
const modifiers = modifiersOf(parsed.property);
|
|
11669
|
+
if (eventName === "submit" && attr.tagName === "form" && !modifiers.includes("prevent") && getPreventDefaultHandlers().get(handler) === false && !/\saction\s*=/i.test(openTagBefore(html, attr.valueStart))) {
|
|
11670
|
+
diagnostics.push({
|
|
11671
|
+
code: WcsDiagnosticCode.SubmitWithoutPrevent,
|
|
11672
|
+
start: bindingStart + leadingSpace,
|
|
11673
|
+
end: bindingStart + leadingSpace + propNoMod.length,
|
|
11674
|
+
message: msgs.submitWithoutPrevent(handler),
|
|
11675
|
+
severity: "warning"
|
|
11676
|
+
});
|
|
11677
|
+
}
|
|
11327
11678
|
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)) {
|
|
11328
11679
|
currentTargetCandidates.push({
|
|
11329
11680
|
offset: attr.valueStart,
|
|
@@ -11401,7 +11752,8 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
|
|
|
11401
11752
|
start: pathStart,
|
|
11402
11753
|
end: pathStart + tokenPath.length,
|
|
11403
11754
|
message: msgs.commandRhsFormat(),
|
|
11404
|
-
|
|
11755
|
+
// ランタイムは束縛の計画で #1201 として throw し、root では初期化が失敗する
|
|
11756
|
+
severity: "error"
|
|
11405
11757
|
});
|
|
11406
11758
|
} else if (commandNames.size > 0 && !commandNames.has(tokenPath)) {
|
|
11407
11759
|
diagnostics.push({
|
|
@@ -11409,7 +11761,9 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
|
|
|
11409
11761
|
start: pathStart,
|
|
11410
11762
|
end: pathStart + tokenPath.length,
|
|
11411
11763
|
message: msgs.commandTokenUndeclared(tokenPath),
|
|
11412
|
-
|
|
11764
|
+
// ランタイムは取り付けで #1302 として throw し、root では初期化が失敗する
|
|
11765
|
+
// (eventToken. と `on*: $command.x` はイベントのたびに #1301 を記録するだけなので warning のまま)
|
|
11766
|
+
severity: "error"
|
|
11413
11767
|
});
|
|
11414
11768
|
}
|
|
11415
11769
|
}
|
|
@@ -11579,10 +11933,7 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
|
|
|
11579
11933
|
const typePath = candidateKeyOf(pathTrimmed, (c) => scopedPathSet.has(c));
|
|
11580
11934
|
const resultType = resolveResultType(typePath, parsed.filters, scopedPaths);
|
|
11581
11935
|
if (resultType !== null) {
|
|
11582
|
-
const typeReq = getExpectedType(
|
|
11583
|
-
parsed.property,
|
|
11584
|
-
() => isNegatedByElseChain(getStructuralTemplates(), attr.valueStart)
|
|
11585
|
-
);
|
|
11936
|
+
const typeReq = getExpectedType(parsed.property);
|
|
11586
11937
|
if (typeReq && resultType !== typeReq.expected) {
|
|
11587
11938
|
const pathOffset = binding.indexOf(parsed.path);
|
|
11588
11939
|
const pathStart = bindingStart + pathOffset;
|
|
@@ -11632,6 +11983,10 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
|
|
|
11632
11983
|
}
|
|
11633
11984
|
return diagnostics;
|
|
11634
11985
|
}
|
|
11986
|
+
function openTagBefore(html, valueStart) {
|
|
11987
|
+
const lt2 = html.lastIndexOf("<", valueStart);
|
|
11988
|
+
return lt2 === -1 ? "" : html.slice(lt2, valueStart);
|
|
11989
|
+
}
|
|
11635
11990
|
function findAllBindAttributes(html, attrName) {
|
|
11636
11991
|
const attrs = [];
|
|
11637
11992
|
const escaped = attrName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -11736,14 +12091,16 @@ function validateFilterUsage(filter, bindingStart, msgs) {
|
|
|
11736
12091
|
for (let i = 0; i < Math.min(argCount, info.argTypes.length); i++) {
|
|
11737
12092
|
const expectedArgType = info.argTypes[i];
|
|
11738
12093
|
if (expectedArgType === "any") continue;
|
|
11739
|
-
const
|
|
11740
|
-
|
|
12094
|
+
const arg = filter.args[i];
|
|
12095
|
+
const numericFails = expectedArgType === "number" && !readsAsNumber(arg);
|
|
12096
|
+
const actualArgType = inferArgType(arg);
|
|
12097
|
+
if (expectedArgType === "number" ? numericFails : actualArgType !== expectedArgType) {
|
|
11741
12098
|
diagnostics.push({
|
|
11742
12099
|
code: WcsDiagnosticCode.FilterArgType,
|
|
11743
12100
|
start: bindingStart + filter.argsOffset,
|
|
11744
12101
|
end: bindingStart + filter.argsOffset + filter.name.length,
|
|
11745
|
-
message: msgs.filterArgType(filter.name, i + 1, expectedArgType,
|
|
11746
|
-
severity: "warning"
|
|
12102
|
+
message: msgs.filterArgType(filter.name, i + 1, expectedArgType, arg, actualArgType),
|
|
12103
|
+
severity: numericFails ? "error" : "warning"
|
|
11747
12104
|
});
|
|
11748
12105
|
}
|
|
11749
12106
|
}
|
|
@@ -11808,57 +12165,11 @@ function validateSchemaPathExistence(checkPath, displayPath, scopedPaths, scoped
|
|
|
11808
12165
|
}
|
|
11809
12166
|
return null;
|
|
11810
12167
|
}
|
|
11811
|
-
function
|
|
11812
|
-
const escaped = attrName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
11813
|
-
const attrRegex = new RegExp(`${escaped}\\s*=\\s*(["'])`, "i");
|
|
11814
|
-
const tagRegex = /<template(?:\s[^>]*)?>|<\/template\s*>/gi;
|
|
11815
|
-
const templates = [];
|
|
11816
|
-
let depth = 0;
|
|
11817
|
-
let match;
|
|
11818
|
-
while ((match = tagRegex.exec(html)) !== null) {
|
|
11819
|
-
if (match[0].startsWith("</")) {
|
|
11820
|
-
depth = Math.max(0, depth - 1);
|
|
11821
|
-
continue;
|
|
11822
|
-
}
|
|
11823
|
-
const attrMatch = attrRegex.exec(match[0]);
|
|
11824
|
-
if (attrMatch) {
|
|
11825
|
-
const quote = attrMatch[1];
|
|
11826
|
-
const valueStart = match.index + attrMatch.index + attrMatch[0].length;
|
|
11827
|
-
const valueEnd = html.indexOf(quote, valueStart);
|
|
11828
|
-
if (valueEnd !== -1) {
|
|
11829
|
-
const first = splitBindingExpressions(html.slice(valueStart, valueEnd))[0] ?? "";
|
|
11830
|
-
const firstColon = indexOfOutsideQuotes2(first, ":");
|
|
11831
|
-
const prop = (firstColon === -1 ? first : first.slice(0, firstColon)).replace(/#.*$/, "").trim();
|
|
11832
|
-
const type = prop === "if" || prop === "elseif" || prop === "else" ? prop : "other";
|
|
11833
|
-
templates.push({ valueStart, depth, type });
|
|
11834
|
-
}
|
|
11835
|
-
}
|
|
11836
|
-
depth++;
|
|
11837
|
-
}
|
|
11838
|
-
return templates;
|
|
11839
|
-
}
|
|
11840
|
-
function isNegatedByElseChain(templates, valueStart) {
|
|
11841
|
-
const index = templates.findIndex((t) => t.valueStart === valueStart);
|
|
11842
|
-
if (index === -1) return false;
|
|
11843
|
-
const selfDepth = templates[index].depth;
|
|
11844
|
-
for (let i = index + 1; i < templates.length; i++) {
|
|
11845
|
-
const next = templates[i];
|
|
11846
|
-
if (next.depth > selfDepth) continue;
|
|
11847
|
-
if (next.depth < selfDepth) return false;
|
|
11848
|
-
if (next.type === "elseif" || next.type === "else") return true;
|
|
11849
|
-
if (next.type === "if") return false;
|
|
11850
|
-
}
|
|
11851
|
-
return false;
|
|
11852
|
-
}
|
|
11853
|
-
function getExpectedType(property, isNegatedIf) {
|
|
12168
|
+
function getExpectedType(property) {
|
|
11854
12169
|
const prop = property.replace(/#.*$/, "");
|
|
11855
12170
|
if (prop === "for") {
|
|
11856
12171
|
return { label: "for", expected: "array", severity: "error" };
|
|
11857
12172
|
}
|
|
11858
|
-
if (prop === "if" || prop === "elseif") {
|
|
11859
|
-
if (!isNegatedIf()) return null;
|
|
11860
|
-
return { label: prop, expected: "boolean", severity: "warning" };
|
|
11861
|
-
}
|
|
11862
12173
|
if (prop.startsWith("class.")) {
|
|
11863
12174
|
return { label: prop, expected: "boolean", severity: "warning" };
|
|
11864
12175
|
}
|
|
@@ -11914,6 +12225,10 @@ function inferArgType(arg) {
|
|
|
11914
12225
|
if (/^-?\d+(\.\d+)?$/.test(v)) return "number";
|
|
11915
12226
|
return "string";
|
|
11916
12227
|
}
|
|
12228
|
+
function readsAsNumber(arg) {
|
|
12229
|
+
const v = arg.trim().replace(/^(["'])([\s\S]*)\1$/, "$2");
|
|
12230
|
+
return v !== "" && !Number.isNaN(Number(v));
|
|
12231
|
+
}
|
|
11917
12232
|
function isLiteral(value) {
|
|
11918
12233
|
return /^-?\d/.test(value) || /^["'`]/.test(value) || value === "true" || value === "false" || value === "null";
|
|
11919
12234
|
}
|
|
@@ -13838,20 +14153,7 @@ var BUILTIN_TAGS = {
|
|
|
13838
14153
|
};
|
|
13839
14154
|
|
|
13840
14155
|
// src/service/ioNodeValidator.ts
|
|
13841
|
-
var
|
|
13842
|
-
"textContent",
|
|
13843
|
-
"innerHTML",
|
|
13844
|
-
"innerText",
|
|
13845
|
-
"hidden",
|
|
13846
|
-
"title",
|
|
13847
|
-
"id",
|
|
13848
|
-
"slot",
|
|
13849
|
-
"dir",
|
|
13850
|
-
"lang",
|
|
13851
|
-
"role",
|
|
13852
|
-
"tabIndex",
|
|
13853
|
-
"className"
|
|
13854
|
-
]);
|
|
14156
|
+
var HTML_SINK_PROPERTIES = /* @__PURE__ */ new Set(["html", "innerHTML", "outerHTML", "srcdoc"]);
|
|
13855
14157
|
var STRUCTURAL_DIRECTIVES3 = /* @__PURE__ */ new Set(["for", "if", "elseif", "else"]);
|
|
13856
14158
|
var EXPLICIT_PROPERTY_REJECTED_HEADS2 = /* @__PURE__ */ new Set([
|
|
13857
14159
|
...Object.values(getWcsManifest().syntax.bindingTypes.propNamespaces),
|
|
@@ -13953,7 +14255,7 @@ function validateBindingAgainstContract(tagName, contract, parsed, property, sta
|
|
|
13953
14255
|
code: WcsDiagnosticCode.TagMemberUnknown,
|
|
13954
14256
|
start,
|
|
13955
14257
|
end,
|
|
13956
|
-
severity: "
|
|
14258
|
+
severity: "error",
|
|
13957
14259
|
tag: tagName,
|
|
13958
14260
|
member: name,
|
|
13959
14261
|
message: msgs.tagCommandUnknown(name, tagName, contract.commands.join(", ") || msgs.none()) + suggestion(name, contract.commands, msgs)
|
|
@@ -13968,7 +14270,7 @@ function validateBindingAgainstContract(tagName, contract, parsed, property, sta
|
|
|
13968
14270
|
code: WcsDiagnosticCode.TagMemberUnknown,
|
|
13969
14271
|
start,
|
|
13970
14272
|
end,
|
|
13971
|
-
severity: "
|
|
14273
|
+
severity: "error",
|
|
13972
14274
|
tag: tagName,
|
|
13973
14275
|
member: name,
|
|
13974
14276
|
message: msgs.tagEventTokenKeyUnknown(name, tagName, contract.properties.join(", ")) + suggestion(name, contract.properties, msgs)
|
|
@@ -13976,13 +14278,13 @@ function validateBindingAgainstContract(tagName, contract, parsed, property, sta
|
|
|
13976
14278
|
}
|
|
13977
14279
|
return;
|
|
13978
14280
|
}
|
|
13979
|
-
if (!contract.properties.includes(property) && !(property in contract.inputs) && !
|
|
14281
|
+
if (!contract.properties.includes(property) && !(property in contract.inputs) && !HTML_SINK_PROPERTIES.has(property)) {
|
|
13980
14282
|
const members = [...contract.properties, ...inputNames];
|
|
13981
14283
|
diagnostics.push({
|
|
13982
14284
|
code: WcsDiagnosticCode.TagMemberUnknown,
|
|
13983
14285
|
start,
|
|
13984
14286
|
end,
|
|
13985
|
-
severity: "
|
|
14287
|
+
severity: "error",
|
|
13986
14288
|
tag: tagName,
|
|
13987
14289
|
member: property,
|
|
13988
14290
|
message: msgs.tagMemberUnknown(property, tagName) + suggestion(property, members, msgs)
|
|
@@ -14187,7 +14489,7 @@ function validateDocumentEnv(html, locale2) {
|
|
|
14187
14489
|
code: WcsDiagnosticCode.ScriptOrder,
|
|
14188
14490
|
start: later.start,
|
|
14189
14491
|
end: later.end,
|
|
14190
|
-
severity: "
|
|
14492
|
+
severity: "info",
|
|
14191
14493
|
message: msgs.devtoolsAfterState()
|
|
14192
14494
|
});
|
|
14193
14495
|
}
|
|
@@ -14224,9 +14526,63 @@ function validateDocumentEnv(html, locale2) {
|
|
|
14224
14526
|
severity: "error",
|
|
14225
14527
|
message: msgs.signalsDualEntry()
|
|
14226
14528
|
});
|
|
14529
|
+
} else {
|
|
14530
|
+
const both = findSignalsImportMapBoth(scanText);
|
|
14531
|
+
if (both) {
|
|
14532
|
+
diagnostics.push({
|
|
14533
|
+
code: WcsDiagnosticCode.SignalsDualEntry,
|
|
14534
|
+
start: both.start,
|
|
14535
|
+
end: both.end,
|
|
14536
|
+
severity: "warning",
|
|
14537
|
+
message: msgs.signalsImportMapBoth()
|
|
14538
|
+
});
|
|
14539
|
+
}
|
|
14540
|
+
}
|
|
14541
|
+
const structure = scanStructure(scanText);
|
|
14542
|
+
for (const at2 of structure.bareMustaches) {
|
|
14543
|
+
diagnostics.push({
|
|
14544
|
+
code: WcsDiagnosticCode.RouteBareMustache,
|
|
14545
|
+
start: at2.start,
|
|
14546
|
+
end: at2.end,
|
|
14547
|
+
severity: "warning",
|
|
14548
|
+
message: msgs.routeBareMustache(at2.inLayout)
|
|
14549
|
+
});
|
|
14550
|
+
}
|
|
14551
|
+
for (const layout of structure.layoutsWithoutDefaultSlot) {
|
|
14552
|
+
diagnostics.push({
|
|
14553
|
+
code: WcsDiagnosticCode.LayoutSlotMissing,
|
|
14554
|
+
start: layout.start,
|
|
14555
|
+
end: layout.end,
|
|
14556
|
+
severity: "warning",
|
|
14557
|
+
message: msgs.layoutSlotMissing(layout.id)
|
|
14558
|
+
});
|
|
14227
14559
|
}
|
|
14228
14560
|
return diagnostics;
|
|
14229
14561
|
}
|
|
14562
|
+
function findSignalsImportMapBoth(html) {
|
|
14563
|
+
const mapRegex = /<script\b((?:"[^"]*"|'[^']*'|[^>"'])*)>([\s\S]*?)<\/script\s*>/gi;
|
|
14564
|
+
let match;
|
|
14565
|
+
while ((match = mapRegex.exec(html)) !== null) {
|
|
14566
|
+
if (!/\btype\s*=\s*(["'])importmap\1/i.test(match[1])) continue;
|
|
14567
|
+
let imports;
|
|
14568
|
+
try {
|
|
14569
|
+
imports = JSON.parse(match[2]).imports;
|
|
14570
|
+
} catch {
|
|
14571
|
+
continue;
|
|
14572
|
+
}
|
|
14573
|
+
if (imports === null || typeof imports !== "object") continue;
|
|
14574
|
+
const core = imports["@wcstack/signals"];
|
|
14575
|
+
const dom = imports["@wcstack/signals/dom"] ?? imports["@wcstack/signals/"];
|
|
14576
|
+
if (typeof core !== "string" || typeof dom !== "string") continue;
|
|
14577
|
+
if (core.includes("/dist/") && dom.includes("/dist/")) continue;
|
|
14578
|
+
const key = '"@wcstack/signals"';
|
|
14579
|
+
const at2 = match[2].indexOf(key);
|
|
14580
|
+
const bodyStart = match.index + match[0].indexOf(">") + 1;
|
|
14581
|
+
const start = bodyStart + (at2 === -1 ? 0 : at2 + 1);
|
|
14582
|
+
return { start, end: start + key.length - 2 };
|
|
14583
|
+
}
|
|
14584
|
+
return null;
|
|
14585
|
+
}
|
|
14230
14586
|
var SCOPED_AUTO = /@wcstack\/([a-z0-9-]+)(?:@[^/"'\s]+)?\/(?:auto\b|dist\/(?:split\/)?auto(?:\.min)?\.js\b)/;
|
|
14231
14587
|
var BUNDLE_AUTO = /(?:^|\/)wcstack(?:@[^/"'\s]+)?\/(?:auto\b|dist\/auto\.min\.js\b)/;
|
|
14232
14588
|
var BUNDLE_PACKAGES = ["state", "router", "fetch", "storage", "autoloader"];
|
|
@@ -14305,6 +14661,88 @@ function blankHtmlComments(html) {
|
|
|
14305
14661
|
function blankJsComments(code) {
|
|
14306
14662
|
return code.replace(/\/\*[\s\S]*?\*\//g, (m) => " ".repeat(m.length)).replace(/(^|[^:])\/\/[^\n]*/g, (m, pre) => pre + " ".repeat(m.length - pre.length));
|
|
14307
14663
|
}
|
|
14664
|
+
var VOID_TAGS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr"]);
|
|
14665
|
+
var ROUTE_TAG = "wcs-route";
|
|
14666
|
+
var LAYOUT_TAG2 = "wcs-layout";
|
|
14667
|
+
function attrValue(attrs, name) {
|
|
14668
|
+
const m = new RegExp(`(?:^|\\s)${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i").exec(attrs);
|
|
14669
|
+
return m === null ? null : m[1] ?? m[2] ?? m[3] ?? "";
|
|
14670
|
+
}
|
|
14671
|
+
function scanStructure(html) {
|
|
14672
|
+
const scan = html.replace(
|
|
14673
|
+
/(<(script|style)\b[^>]*>)([\s\S]*?)(<\/\2\s*>)/gi,
|
|
14674
|
+
(_m, open, _name, body, close) => open + " ".repeat(body.length) + close
|
|
14675
|
+
);
|
|
14676
|
+
const tagRegex = /<(\/?)([a-zA-Z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)>/g;
|
|
14677
|
+
const layoutIds = /* @__PURE__ */ new Set();
|
|
14678
|
+
for (const m of scan.matchAll(/<wcs-layout\b((?:"[^"]*"|'[^']*'|[^>"'])*)>/gi)) {
|
|
14679
|
+
const id = attrValue(m[1], "layout");
|
|
14680
|
+
if (id !== null && id !== "") layoutIds.add(id);
|
|
14681
|
+
}
|
|
14682
|
+
const bareMustaches = [];
|
|
14683
|
+
const layouts = [];
|
|
14684
|
+
const templateHasDefaultSlot = /* @__PURE__ */ new Map();
|
|
14685
|
+
const stack = [];
|
|
14686
|
+
let last = 0;
|
|
14687
|
+
let match;
|
|
14688
|
+
const text3 = (from, to) => {
|
|
14689
|
+
const top = stack[stack.length - 1];
|
|
14690
|
+
if (top === void 0 || to <= from) return;
|
|
14691
|
+
const chunk = scan.slice(from, to);
|
|
14692
|
+
if (top.name === LAYOUT_TAG2 && chunk.trim() !== "") top.unslotted = true;
|
|
14693
|
+
if (top.name !== ROUTE_TAG && !top.layoutTemplate) return;
|
|
14694
|
+
for (const m of chunk.matchAll(/\{\{[\s\S]*?\}\}/g)) {
|
|
14695
|
+
bareMustaches.push({ start: from + m.index, end: from + m.index + m[0].length, inLayout: top.layoutTemplate });
|
|
14696
|
+
}
|
|
14697
|
+
};
|
|
14698
|
+
while ((match = tagRegex.exec(scan)) !== null) {
|
|
14699
|
+
text3(last, match.index);
|
|
14700
|
+
last = match.index + match[0].length;
|
|
14701
|
+
const name = match[2].toLowerCase();
|
|
14702
|
+
const nameStart = match.index + 1 + match[1].length;
|
|
14703
|
+
if (match[1] === "/") {
|
|
14704
|
+
const at2 = stack.map((e) => e.name).lastIndexOf(name);
|
|
14705
|
+
if (at2 === -1) continue;
|
|
14706
|
+
for (const closed of stack.splice(at2)) {
|
|
14707
|
+
if (closed.name === LAYOUT_TAG2 && closed.unslotted && closed.layoutId !== void 0) {
|
|
14708
|
+
layouts.push({ start: closed.nameStart, end: closed.nameEnd, id: closed.layoutId });
|
|
14709
|
+
}
|
|
14710
|
+
}
|
|
14711
|
+
continue;
|
|
14712
|
+
}
|
|
14713
|
+
const attrs = match[3];
|
|
14714
|
+
const parent = stack[stack.length - 1];
|
|
14715
|
+
if (parent?.name === LAYOUT_TAG2 && !attrValue(attrs, "slot")) parent.unslotted = true;
|
|
14716
|
+
for (const open of stack) {
|
|
14717
|
+
if (open.layoutTemplate && name === "slot" && !attrValue(attrs, "name")) templateHasDefaultSlot.set(open.layoutId, true);
|
|
14718
|
+
}
|
|
14719
|
+
if (VOID_TAGS.has(name) || /\/\s*$/.test(attrs)) continue;
|
|
14720
|
+
const id = name === "template" ? attrValue(attrs, "id") : null;
|
|
14721
|
+
const element2 = {
|
|
14722
|
+
name,
|
|
14723
|
+
layoutTemplate: id !== null && layoutIds.has(id),
|
|
14724
|
+
nameStart,
|
|
14725
|
+
nameEnd: nameStart + match[2].length
|
|
14726
|
+
};
|
|
14727
|
+
if (element2.layoutTemplate) {
|
|
14728
|
+
element2.layoutId = id;
|
|
14729
|
+
if (!templateHasDefaultSlot.has(id)) templateHasDefaultSlot.set(id, false);
|
|
14730
|
+
}
|
|
14731
|
+
if (name === LAYOUT_TAG2 && attrValue(attrs, "src") === null) {
|
|
14732
|
+
const layoutId = attrValue(attrs, "layout");
|
|
14733
|
+
if (layoutId !== null && layoutId !== "") element2.layoutId = layoutId;
|
|
14734
|
+
}
|
|
14735
|
+
stack.push(element2);
|
|
14736
|
+
}
|
|
14737
|
+
text3(last, scan.length);
|
|
14738
|
+
for (const closed of stack) {
|
|
14739
|
+
if (closed.name === LAYOUT_TAG2 && closed.unslotted && closed.layoutId !== void 0) {
|
|
14740
|
+
layouts.push({ start: closed.nameStart, end: closed.nameEnd, id: closed.layoutId });
|
|
14741
|
+
}
|
|
14742
|
+
}
|
|
14743
|
+
const layoutsWithoutDefaultSlot = layouts.filter((l) => templateHasDefaultSlot.get(l.id) === false);
|
|
14744
|
+
return { bareMustaches, layoutsWithoutDefaultSlot };
|
|
14745
|
+
}
|
|
14308
14746
|
var ROUTER_TAG2 = "wcs-router";
|
|
14309
14747
|
var OUTLET_TAG = "wcs-outlet";
|
|
14310
14748
|
function findMisplacedOutlets(html) {
|
|
@@ -14747,7 +15185,7 @@ function validateRecursiveGetters(script, offset2, spec, undeclared, msgs, out)
|
|
|
14747
15185
|
start,
|
|
14748
15186
|
end,
|
|
14749
15187
|
msgs.recursionUnsupported(span.name, "undeclared"),
|
|
14750
|
-
"
|
|
15188
|
+
"error"
|
|
14751
15189
|
);
|
|
14752
15190
|
}
|
|
14753
15191
|
continue;
|
|
@@ -15271,7 +15709,8 @@ function findMountPathProblem(mountPath) {
|
|
|
15271
15709
|
if (mountPath.length === 0) return "empty";
|
|
15272
15710
|
for (const segment of mountPath.split(".")) {
|
|
15273
15711
|
if (segment.length === 0) return "emptySegment";
|
|
15274
|
-
if (segment
|
|
15712
|
+
if (segment.includes("*")) return "wildcard";
|
|
15713
|
+
if (/\s/.test(segment)) return "whitespace";
|
|
15275
15714
|
if (segment.includes("$") || segment.includes("#") || segment.includes("@")) return "reserved";
|
|
15276
15715
|
}
|
|
15277
15716
|
return null;
|
|
@@ -15643,7 +16082,7 @@ function validateIndexArity(script, scriptStart, locale2) {
|
|
|
15643
16082
|
start: scriptStart + parsed.starts[1] + leading,
|
|
15644
16083
|
end: scriptStart + parsed.starts[1] + argText.trimEnd().length,
|
|
15645
16084
|
message: msgs.indexArity(api, path, requirement, wildcardCount, actual),
|
|
15646
|
-
severity: "
|
|
16085
|
+
severity: "error"
|
|
15647
16086
|
});
|
|
15648
16087
|
}
|
|
15649
16088
|
return out;
|
|
@@ -15699,7 +16138,7 @@ function validateGetterCycles(script, scriptStart, locale2) {
|
|
|
15699
16138
|
start: scriptStart + getter.start,
|
|
15700
16139
|
end: scriptStart + getter.end,
|
|
15701
16140
|
message: msgs.getterCycle(cycle),
|
|
15702
|
-
severity: "
|
|
16141
|
+
severity: "error"
|
|
15703
16142
|
});
|
|
15704
16143
|
}
|
|
15705
16144
|
return out;
|
|
@@ -15734,6 +16173,54 @@ function validateGetterUntrackedReads(script, scriptStart, nestedWriteRoots, loc
|
|
|
15734
16173
|
}
|
|
15735
16174
|
return out;
|
|
15736
16175
|
}
|
|
16176
|
+
function validateGetterLocationReads(script, scriptStart, locale2) {
|
|
16177
|
+
if (!script.includes("location")) return [];
|
|
16178
|
+
const msgs = getMessages(locale2);
|
|
16179
|
+
const out = [];
|
|
16180
|
+
for (const getter of analyzeCallableBodies(script)) {
|
|
16181
|
+
if (getter.kind !== "getter" || getter.accessor !== "get" || !getter.body.includes("location")) continue;
|
|
16182
|
+
const read = findLocationRead(getter.body);
|
|
16183
|
+
if (read === null) continue;
|
|
16184
|
+
out.push({
|
|
16185
|
+
code: WcsDiagnosticCode.GetterUntrackedRead,
|
|
16186
|
+
start: scriptStart + getter.bodyStart + read.start,
|
|
16187
|
+
end: scriptStart + getter.bodyStart + read.end,
|
|
16188
|
+
message: msgs.getterReadsLocation(read.text),
|
|
16189
|
+
severity: "warning"
|
|
16190
|
+
});
|
|
16191
|
+
}
|
|
16192
|
+
return out;
|
|
16193
|
+
}
|
|
16194
|
+
function onHandlerStateParam(script, handler) {
|
|
16195
|
+
if (handler.kind === "body") {
|
|
16196
|
+
const head = script.slice(Math.max(0, handler.start - 400), handler.start);
|
|
16197
|
+
return /\(\s*([A-Za-z_$][\w$]*)[^()]*\)\s*\{\s*$/.exec(head)?.[1] ?? null;
|
|
16198
|
+
}
|
|
16199
|
+
return /^\s*(?:async\s+)?(?:function\b[^(]*\(\s*([A-Za-z_$][\w$]*)|\(\s*([A-Za-z_$][\w$]*)|([A-Za-z_$][\w$]*)\s*=>)/.exec(handler.text)?.slice(1).find((name) => name !== void 0) ?? null;
|
|
16200
|
+
}
|
|
16201
|
+
function validateInPlaceChanges(script, scriptStart, locale2) {
|
|
16202
|
+
const msgs = getMessages(locale2);
|
|
16203
|
+
const out = [];
|
|
16204
|
+
const push3 = (text3, kind, textStart, root) => {
|
|
16205
|
+
for (const change of findInPlaceChanges(text3, kind, root)) {
|
|
16206
|
+
out.push({
|
|
16207
|
+
code: change.form === "method" ? WcsDiagnosticCode.ArrayMutation : change.form === "index" ? WcsDiagnosticCode.ArrayIndexAssign : WcsDiagnosticCode.NestedAssign,
|
|
16208
|
+
start: scriptStart + textStart + change.start,
|
|
16209
|
+
end: scriptStart + textStart + change.end,
|
|
16210
|
+
severity: "error",
|
|
16211
|
+
message: change.alias !== null ? msgs.inPlaceAlias(change.alias, change.source, change.target) : msgs.inPlaceChange(change.source, change.target)
|
|
16212
|
+
});
|
|
16213
|
+
}
|
|
16214
|
+
};
|
|
16215
|
+
for (const callable of analyzeCallableBodies(script)) push3(callable.body, "body", callable.bodyStart, "this");
|
|
16216
|
+
for (const handler of analyzeWatchHandlerSources(script)) push3(handler.text, handler.kind, handler.start, "this");
|
|
16217
|
+
for (const handler of analyzeOnHandlerSources(script)) {
|
|
16218
|
+
const root = handler.kind === "body" ? onHandlerStateParam(script, handler) : null;
|
|
16219
|
+
if (handler.kind === "body" && root === null) continue;
|
|
16220
|
+
push3(handler.text, handler.kind, handler.start, root);
|
|
16221
|
+
}
|
|
16222
|
+
return out;
|
|
16223
|
+
}
|
|
15737
16224
|
var NESTED_WRITE_INPUTS = {
|
|
15738
16225
|
"wcs-storage": { inputs: ["value"], exemptWhenManual: true },
|
|
15739
16226
|
"wcs-fetch": { inputs: ["body"], exemptWhenManual: false, oneShot: true }
|
|
@@ -15763,7 +16250,7 @@ function validateInputNestedWrites(html, stateTagName, bindAttrName, nestedWrite
|
|
|
15763
16250
|
code: WcsDiagnosticCode.InputNestedWrite,
|
|
15764
16251
|
start: occ.pathRange.start,
|
|
15765
16252
|
end: occ.pathRange.end,
|
|
15766
|
-
severity: "
|
|
16253
|
+
severity: "error",
|
|
15767
16254
|
tag: tag.tagName,
|
|
15768
16255
|
statePath: occ.path,
|
|
15769
16256
|
message
|
|
@@ -15845,6 +16332,26 @@ function collectNestedWriteRoots(html, stateTagName, bindAttrName, blocks) {
|
|
|
15845
16332
|
if (path !== null) addPrefixes(path, false);
|
|
15846
16333
|
}
|
|
15847
16334
|
}
|
|
16335
|
+
for (const handler of analyzeOnHandlerSources(block.content)) {
|
|
16336
|
+
const param = onHandlerStateParam(block.content, handler);
|
|
16337
|
+
if (param === null) continue;
|
|
16338
|
+
const name = param.replace(/\$/g, "\\$");
|
|
16339
|
+
const region = { start: handler.start, end: handler.start + handler.text.length };
|
|
16340
|
+
const bracket = `\\b${name}\\s*(?:\\?\\.)?\\s*\\[\\s*["']([^"']+)["']\\s*\\]`;
|
|
16341
|
+
const template = `\\b${name}\\s*(?:\\?\\.)?\\s*\\[\\s*\`([^\`]*)\`` + String.raw`\s*\]`;
|
|
16342
|
+
for (const [pattern, quote] of [[bracket, /["']/], [template, /`/]]) {
|
|
16343
|
+
for (const regex of [new RegExp(`${pattern}${ASSIGN_TAIL}`, "g"), new RegExp(`${PRE_INCDEC}${pattern}`, "g")]) {
|
|
16344
|
+
let match;
|
|
16345
|
+
const part = scan.slice(region.start, region.end);
|
|
16346
|
+
while ((match = regex.exec(part)) !== null) {
|
|
16347
|
+
const keyStart = region.start + match.index + match[0].search(quote) + 1;
|
|
16348
|
+
const raw = block.content.slice(keyStart, keyStart + match[1].length);
|
|
16349
|
+
const path = quote.source === "`" ? templateKeyPath(raw) : raw;
|
|
16350
|
+
if (path !== null) addPrefixes(path, false);
|
|
16351
|
+
}
|
|
16352
|
+
}
|
|
16353
|
+
}
|
|
16354
|
+
}
|
|
15848
16355
|
API_CALL.lastIndex = 0;
|
|
15849
16356
|
let call;
|
|
15850
16357
|
while ((call = API_CALL.exec(scan)) !== null) {
|
|
@@ -15975,7 +16482,9 @@ function validateSemantics(html, stateTagName = "wcs-state", locale2, bindAttrNa
|
|
|
15975
16482
|
out.push(...validateIndexParamReads(block.content, block.contentStart, locale2));
|
|
15976
16483
|
out.push(...validateGetterCycles(block.content, block.contentStart, locale2));
|
|
15977
16484
|
out.push(...validateGetterUntrackedReads(block.content, block.contentStart, getNestedWriteRoots, locale2));
|
|
16485
|
+
out.push(...validateGetterLocationReads(block.content, block.contentStart, locale2));
|
|
15978
16486
|
out.push(...validateOnHandlerThis(block.content, block.contentStart, locale2));
|
|
16487
|
+
out.push(...validateInPlaceChanges(block.content, block.contentStart, locale2));
|
|
15979
16488
|
}
|
|
15980
16489
|
out.push(...validateInputNestedWrites(html, stateTagName, bindAttrName, getNestedWriteRoots, locale2));
|
|
15981
16490
|
out.push(...validateUpdatedCallbackDemand(html, stateTagName, bindAttrName, locale2));
|
|
@@ -16398,7 +16907,9 @@ function validateDocument(text3, options = {}) {
|
|
|
16398
16907
|
for (const d of validateNestedAssigns(text3, stateTagName, locale2)) {
|
|
16399
16908
|
out.push({ code: WcsDiagnosticCode.NestedAssign, start: d.start, end: d.end, message: d.message, severity: d.severity });
|
|
16400
16909
|
}
|
|
16401
|
-
|
|
16910
|
+
const ignored = findIgnoredRanges(text3, bindAttribute);
|
|
16911
|
+
const kept = ignored.length === 0 ? out : out.filter((d) => !ignored.some(([start, end]) => d.start >= start && d.start < end));
|
|
16912
|
+
return sortDiagnostics(kept);
|
|
16402
16913
|
}
|
|
16403
16914
|
|
|
16404
16915
|
// src/core/sidecar/drift.ts
|