@wcstack/lint 4.1.1 → 4.2.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.
Files changed (2) hide show
  1. package/dist/cli.cjs +541 -42
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -220,6 +220,10 @@ var WcsDiagnosticCode = {
220
220
  // ランタイムは何も報告しない(root は正しい値)ので lint の code。`#direct` か `event.target.closest(...)` を
221
221
  // 案内する。読みが実行されない分岐にあることもあるので warning。
222
222
  DelegatedCurrentTarget: "wcs/delegated-current-target",
223
+ // `<form data-wcs="onsubmit: login">` の `#prevent` 忘れ(ハンドラも preventDefault を呼ばない)。ブラウザが
224
+ // フォームも送る — ページが読み直されるか、router があれば GET が欄(パスワードも)を URL と履歴に載せる
225
+ // (docs/seam-apps.md、router-auth)。warning(action 付きのフォームと、読めないハンドラでは黙る)。
226
+ SubmitWithoutPrevent: "wcs/submit-without-prevent",
223
227
  // 4.0 で外れた API の旧名(`this.$trackDependency` → `$dependOn`、`$untrackDependency` → `$untracked`)。
224
228
  // ランタイムは読んだ時点で同じ code(#1701)で throw するので error。3.x(3.2〜3.3)では「動くが 4.0 で
225
229
  // 外れる」info だった。フィルタの旧名(`uc` など)は 4.0 のランタイムと同じく `wcs/filter-unknown` で、
@@ -277,6 +281,13 @@ var WcsDiagnosticCode = {
277
281
  RouterOutletMisplaced: "wcs/router-outlet-misplaced",
278
282
  // @wcstack/signals と /dom エントリの同一ページ混在(リアクティブコア二重化)。
279
283
  SignalsDualEntry: "wcs/signals-dual-entry",
284
+ // `<wcs-route>`(またはレイアウトのテンプレート)の直下のテキストの `{{ }}`。最初に着いたルートでしか束ねられず、
285
+ // 遷移で入ったルートでは書いたままの文字が出る(router の README「Where route content lives」— docs/seam-apps.md、
286
+ // router-admin)。warning。
287
+ RouteBareMustache: "wcs/route-bare-mustache",
288
+ // 既定の `<slot>` の無いレイアウトのテンプレートに、名前付きスロットの外の中身(入れ子のルート)を渡している。
289
+ // 中身は表示されない。ランタイムも同じ code で警告する(docs/seam-apps.md、router-admin)。warning。
290
+ LayoutSlotMissing: "wcs/layout-slot-missing",
280
291
  // --- deprecations ---
281
292
  // 名前付き State(`<wcs-state name>` / `path@name`)。v2 でマウント(`mount=` と接頭辞付きパス)に
282
293
  // 置き換わる(docs/state-mount-design.md D16)。1.x では warning、v2 では parse error と同時に error。
@@ -394,7 +405,8 @@ var FORMATS_FILTER_NAMES = [
394
405
  "coalesce",
395
406
  "number",
396
407
  "string",
397
- "nullIfEmpty"
408
+ "nullIfEmpty",
409
+ "currency"
398
410
  ];
399
411
  var definitions = /* @__PURE__ */ new Map();
400
412
  function hasFilter(name) {
@@ -611,6 +623,8 @@ var codeOf = (id) => {
611
623
  return c ? `[wcs/${c}] ` : "";
612
624
  };
613
625
  var MOVED = ["enableMustache", "sameValueGuard", "enableDirectionalInitialSync"];
626
+ 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)})`;
627
+ var NAMESPACES = ["", "", "class.", "attr.", "style."];
614
628
  var element = (tag, at2) => `<${tag}${at2.map((a, i) => i % 2 ? `="${a}"` : ` ${a}`).join("")}>`;
615
629
  var CSP_GUIDE = "https://github.com/wcstack/wcstack/blob/main/docs/csp.md";
616
630
  var SENTENCES = {
@@ -662,10 +676,11 @@ var SENTENCES = {
662
676
  41
663
677
  /* RenderChain */
664
678
  ]: () => `render chain depth limit exceeded (${MAX_RENDER_CHAIN} drains that rendering itself started); bindings for this batch were not applied.`,
679
+ // (named as written — `textContent: iso`, `class.active: x` — when the binding has a member; else its type)
665
680
  [
666
681
  12
667
682
  /* BindingFailed */
668
- ]: (type, p) => `binding "${type}: ${p}" failed to apply.`,
683
+ ]: (type, p, name, kind) => `binding "${name ? (NAMESPACES[kind] ?? "") + name : type}: ${p}" failed to apply.`,
669
684
  [
670
685
  13
671
686
  /* LoadFailed */
@@ -737,11 +752,19 @@ var SENTENCES = {
737
752
  [
738
753
  28
739
754
  /* FilterValueNotNumber */
740
- ]: (fn) => `filter ${fn} requires a number value`,
755
+ ]: (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
756
  [
742
757
  29
743
758
  /* FilterValueNotDate */
744
- ]: (fn) => `filter ${fn} requires a date value`,
759
+ ]: (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)" : ""}`,
760
+ [
761
+ 52
762
+ /* FilterStyleInvalid */
763
+ ]: (fn, v) => `filter ${fn} takes a style of full, long, medium or short, not "${v}"`,
764
+ [
765
+ 53
766
+ /* FilterCurrencyInvalid */
767
+ ]: (v) => `filter currency takes an ISO 4217 currency code (JPY, USD, EUR), not "${v}"`,
745
768
  [
746
769
  30
747
770
  /* FilterValueNotArray */
@@ -1681,11 +1704,17 @@ function optionsRequired(fnName) {
1681
1704
  function optionMustBeNumber(fnName) {
1682
1705
  raise2(27, [fnName]);
1683
1706
  }
1684
- function valueMustBeNumber(fnName) {
1685
- raise2(28, [fnName]);
1707
+ function styleInvalid(fnName, value) {
1708
+ raise2(52, [fnName, value]);
1709
+ }
1710
+ function currencyInvalid(value) {
1711
+ raise2(53, [value]);
1686
1712
  }
1687
- function valueMustBeDate(fnName) {
1688
- raise2(29, [fnName]);
1713
+ function valueMustBeNumber(fnName, value) {
1714
+ raise2(28, [fnName, value]);
1715
+ }
1716
+ function valueMustBeDate(fnName, value) {
1717
+ raise2(29, [fnName, value]);
1689
1718
  }
1690
1719
  function valueMustBeArray(fnName) {
1691
1720
  raise2(30, [fnName]);
@@ -1752,7 +1781,7 @@ var numeric = (name, op) => ({
1752
1781
  const opt = requiredNumberOption(options, 0, name);
1753
1782
  return (value) => {
1754
1783
  if (typeof value !== "number") {
1755
- valueMustBeNumber(name);
1784
+ valueMustBeNumber(name, value);
1756
1785
  }
1757
1786
  return op(value, opt);
1758
1787
  };
@@ -1782,7 +1811,7 @@ var toFixed = (options) => {
1782
1811
  const opt = numberOption(options?.[0] ?? "0", "toFixed");
1783
1812
  return (value) => {
1784
1813
  if (typeof value !== "number") {
1785
- valueMustBeNumber("toFixed");
1814
+ valueMustBeNumber("toFixed", value);
1786
1815
  }
1787
1816
  return value.toFixed(opt);
1788
1817
  };
@@ -1791,7 +1820,7 @@ var round = (options) => {
1791
1820
  const optValue = Math.pow(10, numberOption(options?.[0] ?? "0", "round"));
1792
1821
  return (value) => {
1793
1822
  if (typeof value !== "number") {
1794
- valueMustBeNumber("round");
1823
+ valueMustBeNumber("round", value);
1795
1824
  }
1796
1825
  return Math.round(value * optValue) / optValue;
1797
1826
  };
@@ -1800,7 +1829,7 @@ var floor = (options) => {
1800
1829
  const optValue = Math.pow(10, numberOption(options?.[0] ?? "0", "floor"));
1801
1830
  return (value) => {
1802
1831
  if (typeof value !== "number") {
1803
- valueMustBeNumber("floor");
1832
+ valueMustBeNumber("floor", value);
1804
1833
  }
1805
1834
  return Math.floor(value * optValue) / optValue;
1806
1835
  };
@@ -1809,7 +1838,7 @@ var ceil = (options) => {
1809
1838
  const optValue = Math.pow(10, numberOption(options?.[0] ?? "0", "ceil"));
1810
1839
  return (value) => {
1811
1840
  if (typeof value !== "number") {
1812
- valueMustBeNumber("ceil");
1841
+ valueMustBeNumber("ceil", value);
1813
1842
  }
1814
1843
  return Math.ceil(value * optValue) / optValue;
1815
1844
  };
@@ -1818,7 +1847,7 @@ var percent = (options) => {
1818
1847
  const opt = numberOption(options?.[0] ?? "0", "percent");
1819
1848
  return (value) => {
1820
1849
  if (typeof value !== "number") {
1821
- valueMustBeNumber("percent");
1850
+ valueMustBeNumber("percent", value);
1822
1851
  }
1823
1852
  return `${(value * 100).toFixed(opt)}%`;
1824
1853
  };
@@ -1845,11 +1874,29 @@ var locale = (options) => {
1845
1874
  const explicit = options?.[0];
1846
1875
  return (value) => {
1847
1876
  if (typeof value !== "number") {
1848
- valueMustBeNumber("locale");
1877
+ valueMustBeNumber("locale", value);
1849
1878
  }
1850
1879
  return value.toLocaleString(explicit ?? defaultLocale());
1851
1880
  };
1852
1881
  };
1882
+ var currency = (options) => {
1883
+ const code = options?.[0] ?? optionsRequired("currency");
1884
+ const explicit = options?.[1];
1885
+ const format = { style: "currency", currency: code };
1886
+ try {
1887
+ new Intl.NumberFormat("en", format);
1888
+ const known = Intl.supportedValuesOf?.("currency");
1889
+ if (known && !known.includes(code.toUpperCase())) throw 0;
1890
+ } catch {
1891
+ currencyInvalid(code);
1892
+ }
1893
+ return (value) => {
1894
+ if (typeof value !== "number") {
1895
+ valueMustBeNumber("currency", value);
1896
+ }
1897
+ return value.toLocaleString(explicit ?? defaultLocale(), format);
1898
+ };
1899
+ };
1853
1900
  var upper = () => (value) => String(value).toUpperCase();
1854
1901
  var lower = () => (value) => String(value).toLowerCase();
1855
1902
  var capitalize = () => (value) => {
@@ -1906,38 +1953,48 @@ var join = (options) => {
1906
1953
  return value.join(opt);
1907
1954
  };
1908
1955
  };
1956
+ var STYLES = ["full", "long", "medium", "short"];
1957
+ function dateOptions(options, fn) {
1958
+ let [loc, style] = options ?? [];
1959
+ if (style === void 0 && loc !== void 0 && STYLES.includes(loc)) [loc, style] = [void 0, loc];
1960
+ if (style !== void 0 && !STYLES.includes(style)) styleInvalid(fn, style);
1961
+ return [loc, style];
1962
+ }
1909
1963
  var date = (options) => {
1910
- const explicit = options?.[0];
1964
+ const [explicit, style] = dateOptions(options, "date");
1965
+ const format = style && { dateStyle: style };
1911
1966
  return (value) => {
1912
1967
  if (!(value instanceof Date)) {
1913
- valueMustBeDate("date");
1968
+ valueMustBeDate("date", value);
1914
1969
  }
1915
- return value.toLocaleDateString(explicit ?? defaultLocale());
1970
+ return value.toLocaleDateString(explicit ?? defaultLocale(), format);
1916
1971
  };
1917
1972
  };
1918
1973
  var time = (options) => {
1919
- const explicit = options?.[0];
1974
+ const [explicit, style] = dateOptions(options, "time");
1975
+ const format = style && { timeStyle: style };
1920
1976
  return (value) => {
1921
1977
  if (!(value instanceof Date)) {
1922
- valueMustBeDate("time");
1978
+ valueMustBeDate("time", value);
1923
1979
  }
1924
- return value.toLocaleTimeString(explicit ?? defaultLocale());
1980
+ return value.toLocaleTimeString(explicit ?? defaultLocale(), format);
1925
1981
  };
1926
1982
  };
1927
1983
  var datetime = (options) => {
1928
- const explicit = options?.[0];
1984
+ const [explicit, style] = dateOptions(options, "datetime");
1985
+ const format = style && { dateStyle: style, timeStyle: style };
1929
1986
  return (value) => {
1930
1987
  if (!(value instanceof Date)) {
1931
- valueMustBeDate("datetime");
1988
+ valueMustBeDate("datetime", value);
1932
1989
  }
1933
- return value.toLocaleString(explicit ?? defaultLocale());
1990
+ return value.toLocaleString(explicit ?? defaultLocale(), format);
1934
1991
  };
1935
1992
  };
1936
1993
  var ymd = (options) => {
1937
1994
  const opt = options?.[0] ?? "-";
1938
1995
  return (value) => {
1939
1996
  if (!(value instanceof Date)) {
1940
- valueMustBeDate("ymd");
1997
+ valueMustBeDate("ymd", value);
1941
1998
  }
1942
1999
  const year = value.getFullYear().toString();
1943
2000
  const month = (value.getMonth() + 1).toString().padStart(2, "0");
@@ -1949,7 +2006,7 @@ var hms = (options) => {
1949
2006
  const opt = options?.[0] ?? ":";
1950
2007
  return (value) => {
1951
2008
  if (!(value instanceof Date)) {
1952
- valueMustBeDate("hms");
2009
+ valueMustBeDate("hms", value);
1953
2010
  }
1954
2011
  const hours = value.getHours().toString().padStart(2, "0");
1955
2012
  const minutes = value.getMinutes().toString().padStart(2, "0");
@@ -1959,7 +2016,7 @@ var hms = (options) => {
1959
2016
  };
1960
2017
  var abs = () => (value) => {
1961
2018
  if (typeof value !== "number") {
1962
- valueMustBeNumber("abs");
2019
+ valueMustBeNumber("abs", value);
1963
2020
  }
1964
2021
  return Math.abs(value);
1965
2022
  };
@@ -1968,7 +2025,7 @@ var clamp = (options) => {
1968
2025
  const max = requiredNumberOption(options, 1, "clamp");
1969
2026
  return (value) => {
1970
2027
  if (typeof value !== "number") {
1971
- valueMustBeNumber("clamp");
2028
+ valueMustBeNumber("clamp", value);
1972
2029
  }
1973
2030
  return Math.min(Math.max(value, min), max);
1974
2031
  };
@@ -2015,10 +2072,10 @@ var registered = {
2015
2072
  ceil: { factory: ceil, arity: [0, 1] },
2016
2073
  percent: { factory: percent, arity: [0, 1] },
2017
2074
  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, 1] },
2020
- time: { factory: time, arity: [0, 1] },
2021
- datetime: { factory: datetime, arity: [0, 1] },
2075
+ // The locale-dependent three take a locale like `locale` does (`date(ja-JP)`), and a style (`date(ja-JP,long)`)
2076
+ date: { factory: date, arity: [0, 2] },
2077
+ time: { factory: time, arity: [0, 2] },
2078
+ datetime: { factory: datetime, arity: [0, 2] },
2022
2079
  ymd: { factory: ymd, arity: [0, 1] },
2023
2080
  hms: { factory: hms, arity: [0, 1] },
2024
2081
  // 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 +2102,9 @@ var registered = {
2045
2102
  boolean: boolean2,
2046
2103
  number: { factory: number, arity: [0, 0] },
2047
2104
  string: { factory: string, arity: [0, 0] },
2048
- nullIfEmpty: { factory: nullIfEmpty, arity: [0, 0] }
2105
+ nullIfEmpty: { factory: nullIfEmpty, arity: [0, 0] },
2106
+ // (added in 4.2: last, so the order of the others is unchanged)
2107
+ currency: { factory: currency, arity: [1, 2] }
2049
2108
  };
2050
2109
  var formatFilters = /* @__PURE__ */ Object.fromEntries(
2051
2110
  /* @__PURE__ */ Object.entries(registered).filter(([name]) => !(name in coreFilters))
@@ -2116,10 +2175,11 @@ var builtinFilterMeta = {
2116
2175
  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
2176
  // 日付・時刻
2118
2177
  // `locale` と同じくロケールを 1 つ受ける(`date(ja-JP)`)。実装は最初からこれを読んでいたが、
2119
- // メタデータ側が maxArgs: 0 だったため lint と補完が正しい書き方を誤りとして報告していた
2120
- date: { description: "\u30ED\u30B1\u30FC\u30EB\u5F62\u5F0F\u306E\u65E5\u4ED8 ([locale]\u3002\u65E2\u5B9A\u306F config.locale)", hasArgs: true, resultType: "string", acceptTypes: "any", minArgs: 0, maxArgs: 1, argTypes: ["string"] },
2121
- time: { description: "\u30ED\u30B1\u30FC\u30EB\u5F62\u5F0F\u306E\u6642\u523B ([locale]\u3002\u65E2\u5B9A\u306F config.locale)", hasArgs: true, resultType: "string", acceptTypes: "any", minArgs: 0, maxArgs: 1, argTypes: ["string"] },
2122
- datetime: { description: "\u30ED\u30B1\u30FC\u30EB\u5F62\u5F0F\u306E\u65E5\u6642 ([locale]\u3002\u65E2\u5B9A\u306F config.locale)", hasArgs: true, resultType: "string", acceptTypes: "any", minArgs: 0, maxArgs: 1, argTypes: ["string"] },
2178
+ // メタデータ側が maxArgs: 0 だったため lint と補完が正しい書き方を誤りとして報告していた。
2179
+ // 4.2: 2 つ目は書式(full / long / medium / short — Intl の dateStyle / timeStyle)。書式だけなら既定のロケール
2180
+ 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"] },
2181
+ 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"] },
2182
+ 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
2183
  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
2184
  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
2185
  // 真偽値・変換
@@ -2130,7 +2190,9 @@ var builtinFilterMeta = {
2130
2190
  boolean: { description: "\u30D6\u30FC\u30EB\u5024\u306B\u5909\u63DB", hasArgs: false, resultType: "boolean", acceptTypes: "any", minArgs: 0, maxArgs: 0 },
2131
2191
  number: { description: "\u6570\u5024\u306B\u5909\u63DB", hasArgs: false, resultType: "number", acceptTypes: "any", minArgs: 0, maxArgs: 0 },
2132
2192
  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 }
2193
+ nullIfEmpty: { description: "\u7A7A\u6587\u5B57\u5217\u3092null\u306B\u5909\u63DB", hasArgs: false, resultType: "passthrough", acceptTypes: ["string"], minArgs: 0, maxArgs: 0 },
2194
+ // 4.2(formats の最後に登録)
2195
+ 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
2196
  };
2135
2197
  var WCS_MANIFEST_VERSION = 2;
2136
2198
  var builtinFilterAliases = Object.freeze({});
@@ -10516,6 +10578,193 @@ function findOwnThis(text3, kind) {
10516
10578
  forEachChild(root, walk);
10517
10579
  return found;
10518
10580
  }
10581
+ var DESTRUCTIVE_ARRAY_METHODS = /* @__PURE__ */ new Set(["push", "pop", "shift", "unshift", "splice", "sort", "reverse", "fill", "copyWithin"]);
10582
+ function memberChain(node, source) {
10583
+ const segments = [];
10584
+ let cur = unwrapChain(node);
10585
+ while (cur.type === "MemberExpression") {
10586
+ const property = cur.property;
10587
+ let name = null;
10588
+ if (!cur.computed && property.type === "Identifier") name = property.name;
10589
+ else if (property.type === "Literal" && (typeof property.value === "string" || typeof property.value === "number")) name = String(property.value);
10590
+ segments.unshift({ name, raw: source(property), computed: cur.computed });
10591
+ cur = unwrapChain(cur.object);
10592
+ }
10593
+ return { base: cur, segments };
10594
+ }
10595
+ function assignTarget(root, segments) {
10596
+ if (segments.every((s) => s.name !== null)) {
10597
+ const path = segments.map((s) => s.name).join(".");
10598
+ return segments.length === 1 && /^[A-Za-z_$][\w$]*$/.test(path) ? `${root}.${path}` : `${root}["${path}"]`;
10599
+ }
10600
+ return `${root}[\`${segments.map((s) => s.name ?? `\${${s.raw}}`).join(".")}\`]`;
10601
+ }
10602
+ function findInPlaceChanges(text3, kind, root) {
10603
+ const prefix = kind === "body" ? PREFIX : VALUE_PREFIX;
10604
+ let program;
10605
+ try {
10606
+ program = parse3(prefix + text3 + (kind === "body" ? SUFFIX : VALUE_SUFFIX), { ecmaVersion: "latest", sourceType: "module" });
10607
+ } catch {
10608
+ return [];
10609
+ }
10610
+ const wrapper = unwrapWrapper(program);
10611
+ if (wrapper === null) return [];
10612
+ let body = wrapper.body;
10613
+ if (kind === "value") {
10614
+ const statement = wrapper.body.body.length === 1 ? wrapper.body.body[0] : null;
10615
+ const fn = statement?.type === "ExpressionStatement" ? statement.expression : null;
10616
+ if (fn === null || fn.type !== "FunctionExpression" && fn.type !== "ArrowFunctionExpression") return [];
10617
+ if (root === null) {
10618
+ const first = fn.params[0];
10619
+ if (first === void 0 || first.type !== "Identifier") return [];
10620
+ root = first.name;
10621
+ }
10622
+ body = fn.body;
10623
+ }
10624
+ if (root === null) return [];
10625
+ const stateRoot = root;
10626
+ const shift = prefix.length;
10627
+ const source = (n) => (prefix + text3).slice(n.start, n.end);
10628
+ const isRoot = (n) => stateRoot === "this" ? n.type === "ThisExpression" : n.type === "Identifier" && n.name === stateRoot;
10629
+ const bound = /* @__PURE__ */ new Map();
10630
+ const bind = (name) => {
10631
+ bound.set(name, (bound.get(name) ?? 0) + 1);
10632
+ };
10633
+ const aliases = /* @__PURE__ */ new Map();
10634
+ const collect2 = (node) => {
10635
+ if (isFunctionNode(node)) {
10636
+ if (node.type === "FunctionDeclaration" && node.id !== null) bind(node.id.name);
10637
+ const names = /* @__PURE__ */ new Set();
10638
+ for (const param of node.params) bindingNames(param, names);
10639
+ names.forEach(bind);
10640
+ } else if (node.type === "VariableDeclarator") {
10641
+ const names = /* @__PURE__ */ new Set();
10642
+ bindingNames(node.id, names);
10643
+ names.forEach(bind);
10644
+ const init = node.init ? unwrapChain(node.init) : null;
10645
+ if (init !== null && node.id.type === "Identifier" && init.type === "MemberExpression") {
10646
+ const chain = memberChain(init, source);
10647
+ if (isRoot(chain.base) && chain.segments.length > 0 && !chain.segments[0].name?.startsWith("$")) {
10648
+ aliases.set(node.id.name, { source: source(init), segments: chain.segments });
10649
+ }
10650
+ } else if (init !== null && node.id.type === "ObjectPattern" && isRoot(init)) {
10651
+ for (const property of node.id.properties) {
10652
+ if (property.type !== "Property" || property.computed) continue;
10653
+ const key = property.key.type === "Identifier" ? property.key.name : property.key.type === "Literal" ? String(property.key.value) : null;
10654
+ const value = property.value.type === "AssignmentPattern" ? property.value.left : property.value;
10655
+ if (key === null || key.startsWith("$") || value.type !== "Identifier") continue;
10656
+ const segment = { name: key, raw: key, computed: false };
10657
+ aliases.set(value.name, { source: `${stateRoot}.${key}`, segments: [segment] });
10658
+ }
10659
+ }
10660
+ } else if (node.type === "CatchClause" && node.param) {
10661
+ const names = /* @__PURE__ */ new Set();
10662
+ bindingNames(node.param, names);
10663
+ names.forEach(bind);
10664
+ } else if (node.type === "ClassDeclaration" && node.id !== null) {
10665
+ bind(node.id.name);
10666
+ } else if (node.type === "AssignmentExpression" && node.left.type === "Identifier") {
10667
+ bind(node.left.name);
10668
+ }
10669
+ forEachChild(node, collect2);
10670
+ };
10671
+ collect2(body);
10672
+ const alias = (name) => bound.get(name) === 1 ? aliases.get(name) : void 0;
10673
+ const out = [];
10674
+ const report = (target, at2, form, directMin) => {
10675
+ const chain = memberChain(target, source);
10676
+ const base = chain.base;
10677
+ const range = { start: at2.start - shift, end: at2.end - shift };
10678
+ const pick = (segments) => form ?? (segments.length > 0 && segments.every((s) => s.computed) ? "index" : "property");
10679
+ if (base.type === "Identifier" && base.name !== stateRoot) {
10680
+ const a = alias(base.name);
10681
+ if (a === void 0) return;
10682
+ out.push({ form: pick(chain.segments), alias: base.name, source: a.source, target: assignTarget(stateRoot, a.segments), ...range });
10683
+ return;
10684
+ }
10685
+ if (!isRoot(base) || chain.segments.length < directMin || chain.segments[0].name?.startsWith("$")) return;
10686
+ out.push({ form: pick(chain.segments.slice(1)), alias: null, source: source(at2), target: assignTarget(stateRoot, chain.segments), ...range });
10687
+ };
10688
+ const direct = stateRoot === "this" ? Infinity : 2;
10689
+ const visitChanges = (node) => {
10690
+ if (node.type === "AssignmentExpression" && unwrapChain(node.left).type === "MemberExpression") {
10691
+ report(node.left, node.left, null, direct);
10692
+ } else if (node.type === "UpdateExpression" && unwrapChain(node.argument).type === "MemberExpression") {
10693
+ report(node.argument, node.argument, null, direct);
10694
+ } else if (node.type === "UnaryExpression" && node.operator === "delete" && unwrapChain(node.argument).type === "MemberExpression") {
10695
+ report(node.argument, node.argument, "property", direct);
10696
+ } else if (node.type === "CallExpression") {
10697
+ const callee = unwrapChain(node.callee);
10698
+ if (callee.type === "MemberExpression") {
10699
+ const method = !callee.computed && callee.property.type === "Identifier" ? callee.property.name : null;
10700
+ const object = unwrapChain(callee.object);
10701
+ if (method === "assign" && object.type === "Identifier" && object.name === "Object" && node.arguments.length > 0) {
10702
+ const first = node.arguments[0];
10703
+ if (first.type === "Identifier" || unwrapChain(first).type === "MemberExpression") report(first, node, "property", 1);
10704
+ } else if (method !== null && DESTRUCTIVE_ARRAY_METHODS.has(method)) {
10705
+ report(callee.object, node, "method", stateRoot === "this" ? Infinity : 1);
10706
+ }
10707
+ }
10708
+ }
10709
+ forEachChild(node, visitChanges);
10710
+ };
10711
+ visitChanges(body);
10712
+ return out;
10713
+ }
10714
+ var LOCATION_HOLDERS = /* @__PURE__ */ new Set(["window", "document", "globalThis", "self"]);
10715
+ var LOCATION_VARYING = /* @__PURE__ */ new Set(["pathname", "search", "hash", "href"]);
10716
+ function findLocationRead(body) {
10717
+ let program;
10718
+ try {
10719
+ program = parse3(PREFIX + body + SUFFIX, { ecmaVersion: "latest", sourceType: "module" });
10720
+ } catch {
10721
+ return null;
10722
+ }
10723
+ const wrapper = unwrapWrapper(program);
10724
+ if (wrapper === null) return null;
10725
+ const names = /* @__PURE__ */ new Set();
10726
+ const scan = (node) => {
10727
+ if (isFunctionNode(node)) for (const param of node.params) bindingNames(param, names);
10728
+ if (node.type === "VariableDeclarator") bindingNames(node.id, names);
10729
+ forEachChild(node, scan);
10730
+ };
10731
+ scan(wrapper.body);
10732
+ if (names.has("location")) return null;
10733
+ const isLocation = (node) => {
10734
+ const n = unwrapChain(node);
10735
+ if (n.type === "Identifier") return n.name === "location";
10736
+ return n.type === "MemberExpression" && !n.computed && n.property.type === "Identifier" && n.property.name === "location" && n.object.type === "Identifier" && LOCATION_HOLDERS.has(n.object.name);
10737
+ };
10738
+ let found = null;
10739
+ const at2 = (node) => {
10740
+ found = { start: node.start - PREFIX.length, end: node.end - PREFIX.length, text: (PREFIX + body).slice(node.start, node.end) };
10741
+ };
10742
+ const walk = (node) => {
10743
+ if (found !== null) return;
10744
+ if (node.type === "MemberExpression" && isLocation(node.object)) {
10745
+ const part = !node.computed && node.property.type === "Identifier" ? node.property.name : null;
10746
+ if (part === null || LOCATION_VARYING.has(part)) at2(node);
10747
+ return;
10748
+ }
10749
+ if (isLocation(node)) {
10750
+ at2(node);
10751
+ return;
10752
+ }
10753
+ if (node.type === "MemberExpression") {
10754
+ walk(node.object);
10755
+ if (node.computed) walk(node.property);
10756
+ return;
10757
+ }
10758
+ if (node.type === "Property") {
10759
+ if (node.computed) walk(node.key);
10760
+ walk(node.value);
10761
+ return;
10762
+ }
10763
+ forEachChild(node, walk);
10764
+ };
10765
+ walk(wrapper.body);
10766
+ return found;
10767
+ }
10519
10768
 
10520
10769
  // src/core/messages.ts
10521
10770
  function resolveLocale(locale2) {
@@ -10556,6 +10805,8 @@ var ja = {
10556
10805
  getterCycle: (cycle) => `\u30D1\u30B9 getter \u304C\u5FAA\u74B0\u53C2\u7167\u3057\u3066\u3044\u307E\u3059: ${cycle}`,
10557
10806
  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
10807
  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`,
10808
+ 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`,
10809
+ 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
10810
  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
10811
  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
10812
  typeExpectation: (label, expected, resultType) => `"${label}" \u306B\u306F${JA_EXPECTED_LABEL[expected]}\u304C\u5FC5\u8981\u3067\u3059\uFF08\u73FE\u5728\u306E\u578B: ${resultType}\uFF09`,
@@ -10579,6 +10830,8 @@ var ja = {
10579
10830
  typeAnnotationIncompatible: (vt, rt) => `\u578B "${vt}" \u306F @type {${rt}} \u3068\u4E92\u63DB\u6027\u304C\u3042\u308A\u307E\u305B\u3093`,
10580
10831
  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
10832
  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`,
10833
+ 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`,
10834
+ 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`,
10582
10835
  tagMemberUnknown: (prop, tag) => `"${prop}" \u306F <${tag}> \u306E wcBindable \u30E1\u30F3\u30D0\u30FC\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF08\u672A\u77E5\u30E1\u30F3\u30D0\u30FC\u3078\u306E\u30D0\u30A4\u30F3\u30C9\u306F\u9ED9\u3063\u3066\u7121\u8996\u3055\u308C\u307E\u3059\uFF09`,
10583
10836
  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
10837
  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\u304F\u3060\u3055\u3044`,
@@ -10615,6 +10868,9 @@ var ja = {
10615
10868
  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
10869
  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
10870
  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`,
10871
+ 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`,
10872
+ 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`,
10873
+ 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
10874
  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
10875
  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
10876
  mountPathInvalid: (problem, mountPath) => {
@@ -10748,6 +11004,8 @@ var en = {
10748
11004
  getterCycle: (cycle) => `Path getters form a dependency cycle: ${cycle}`,
10749
11005
  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
11006
  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`,
11007
+ 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`,
11008
+ 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
11009
  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
11010
  handlerFilterNotAllowed: (prop) => `Filters cannot be applied to event handler "${prop}"`,
10753
11011
  typeExpectation: (label, expected, resultType) => `"${label}" requires ${EN_EXPECTED_LABEL[expected]} (current type: ${resultType})`,
@@ -10771,6 +11029,8 @@ var en = {
10771
11029
  typeAnnotationIncompatible: (vt, rt) => `Type "${vt}" is not compatible with @type {${rt}}`,
10772
11030
  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
11031
  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.`,
11032
+ 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 })`,
11033
+ 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}`,
10774
11034
  tagMemberUnknown: (prop, tag) => `"${prop}" is not a wcBindable member of <${tag}> (bindings to unknown members are silently ignored)`,
10775
11035
  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
11036
  declarationAliasRead: (alias, canonical) => `"${alias}" is a declaration key 4.0 removed (the 3.x old name of "${canonical}"), so this["${alias}"] is undefined. Read "${canonical}" instead`,
@@ -10807,6 +11067,9 @@ var en = {
10807
11067
  baseHrefMissing: () => `An SPA using @wcstack/router needs <base href="/"> in <head> (without it, deep links misderive the basename)`,
10808
11068
  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
11069
  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`,
11070
+ 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)`,
11071
+ 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>)`,
11072
+ 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
11073
  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
11074
  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
11075
  mountPathInvalid: (problem, mountPath) => {
@@ -11221,6 +11484,19 @@ var DELEGATED_EVENTS = /* @__PURE__ */ new Set([
11221
11484
  var CUSTOM_ELEMENT_OWN_EVENTS = /* @__PURE__ */ new Set(["input", "change", "submit"]);
11222
11485
  function collectCurrentTargetHandlers(elements, html, fileReader) {
11223
11486
  const names = /* @__PURE__ */ new Set();
11487
+ forEachStateMethod(elements, html, fileReader, "currentTarget", (name, params, body) => {
11488
+ if (readsEventCurrentTarget(params, body)) names.add(name);
11489
+ });
11490
+ return names;
11491
+ }
11492
+ function collectPreventDefaultHandlers(elements, html, fileReader) {
11493
+ const handlers = /* @__PURE__ */ new Map();
11494
+ forEachStateMethod(elements, html, fileReader, null, (name, _params, body) => {
11495
+ handlers.set(name, /\bpreventDefault\b/.test(body));
11496
+ });
11497
+ return handlers;
11498
+ }
11499
+ function forEachStateMethod(elements, html, fileReader, spelling, fn) {
11224
11500
  let insideTemplate = null;
11225
11501
  for (const element2 of elements) {
11226
11502
  if (element2.bindComponent) continue;
@@ -11230,20 +11506,19 @@ function collectCurrentTargetHandlers(elements, html, fileReader) {
11230
11506
  const script = readStateScript(element2.srcAttr, fileReader);
11231
11507
  if (script !== void 0) scripts = [script];
11232
11508
  }
11233
- scripts = scripts.filter((script) => script.includes("currentTarget"));
11509
+ if (spelling !== null) scripts = scripts.filter((script) => script.includes(spelling));
11234
11510
  if (scripts.length === 0) continue;
11235
11511
  if ((insideTemplate ??= createTemplateTester(html))(element2.tagStart)) continue;
11236
11512
  for (const script of scripts) {
11237
11513
  for (const callable of analyzeCallableBodies(script)) {
11238
- if (callable.kind !== "method" || !callable.body.includes("currentTarget")) continue;
11514
+ if (callable.kind !== "method" || spelling !== null && !callable.body.includes(spelling)) continue;
11239
11515
  const head = script.slice(callable.end, callable.bodyStart - 1);
11240
11516
  const params = /\(([^)]*)\)\s*$/.exec(head);
11241
11517
  if (params === null) continue;
11242
- if (readsEventCurrentTarget(params[1], callable.body)) names.add(volume === null ? callable.name : `${volume}.${callable.name}`);
11518
+ fn(volume === null ? callable.name : `${volume}.${callable.name}`, params[1], callable.body);
11243
11519
  }
11244
11520
  }
11245
11521
  }
11246
- return names;
11247
11522
  }
11248
11523
  function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, fileReader, applicationSchema) {
11249
11524
  const diagnostics = [];
@@ -11263,6 +11538,11 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
11263
11538
  currentTargetHandlers ??= collectCurrentTargetHandlers(pathIndex.elements, html, fileReader);
11264
11539
  return currentTargetHandlers;
11265
11540
  };
11541
+ let preventDefaultHandlers = null;
11542
+ const getPreventDefaultHandlers = () => {
11543
+ preventDefaultHandlers ??= collectPreventDefaultHandlers(pathIndex.elements, html, fileReader);
11544
+ return preventDefaultHandlers;
11545
+ };
11266
11546
  for (const attr of attrs) {
11267
11547
  const bindings = splitBindingExpressions(attr.value);
11268
11548
  const nonEmptyCount = bindings.filter((b) => b.trim().length > 0).length;
@@ -11324,6 +11604,15 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
11324
11604
  const eventName = propNoMod.slice(2);
11325
11605
  const handler = parsed.path.trim();
11326
11606
  const modifiers = modifiersOf(parsed.property);
11607
+ if (eventName === "submit" && attr.tagName === "form" && !modifiers.includes("prevent") && getPreventDefaultHandlers().get(handler) === false && !/\saction\s*=/i.test(openTagBefore(html, attr.valueStart))) {
11608
+ diagnostics.push({
11609
+ code: WcsDiagnosticCode.SubmitWithoutPrevent,
11610
+ start: bindingStart + leadingSpace,
11611
+ end: bindingStart + leadingSpace + propNoMod.length,
11612
+ message: msgs.submitWithoutPrevent(handler),
11613
+ severity: "warning"
11614
+ });
11615
+ }
11327
11616
  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
11617
  currentTargetCandidates.push({
11329
11618
  offset: attr.valueStart,
@@ -11632,6 +11921,10 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
11632
11921
  }
11633
11922
  return diagnostics;
11634
11923
  }
11924
+ function openTagBefore(html, valueStart) {
11925
+ const lt2 = html.lastIndexOf("<", valueStart);
11926
+ return lt2 === -1 ? "" : html.slice(lt2, valueStart);
11927
+ }
11635
11928
  function findAllBindAttributes(html, attrName) {
11636
11929
  const attrs = [];
11637
11930
  const escaped = attrName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -14224,9 +14517,63 @@ function validateDocumentEnv(html, locale2) {
14224
14517
  severity: "error",
14225
14518
  message: msgs.signalsDualEntry()
14226
14519
  });
14520
+ } else {
14521
+ const both = findSignalsImportMapBoth(scanText);
14522
+ if (both) {
14523
+ diagnostics.push({
14524
+ code: WcsDiagnosticCode.SignalsDualEntry,
14525
+ start: both.start,
14526
+ end: both.end,
14527
+ severity: "warning",
14528
+ message: msgs.signalsImportMapBoth()
14529
+ });
14530
+ }
14531
+ }
14532
+ const structure = scanStructure(scanText);
14533
+ for (const at2 of structure.bareMustaches) {
14534
+ diagnostics.push({
14535
+ code: WcsDiagnosticCode.RouteBareMustache,
14536
+ start: at2.start,
14537
+ end: at2.end,
14538
+ severity: "warning",
14539
+ message: msgs.routeBareMustache(at2.inLayout)
14540
+ });
14541
+ }
14542
+ for (const layout of structure.layoutsWithoutDefaultSlot) {
14543
+ diagnostics.push({
14544
+ code: WcsDiagnosticCode.LayoutSlotMissing,
14545
+ start: layout.start,
14546
+ end: layout.end,
14547
+ severity: "warning",
14548
+ message: msgs.layoutSlotMissing(layout.id)
14549
+ });
14227
14550
  }
14228
14551
  return diagnostics;
14229
14552
  }
14553
+ function findSignalsImportMapBoth(html) {
14554
+ const mapRegex = /<script\b((?:"[^"]*"|'[^']*'|[^>"'])*)>([\s\S]*?)<\/script\s*>/gi;
14555
+ let match;
14556
+ while ((match = mapRegex.exec(html)) !== null) {
14557
+ if (!/\btype\s*=\s*(["'])importmap\1/i.test(match[1])) continue;
14558
+ let imports;
14559
+ try {
14560
+ imports = JSON.parse(match[2]).imports;
14561
+ } catch {
14562
+ continue;
14563
+ }
14564
+ if (imports === null || typeof imports !== "object") continue;
14565
+ const core = imports["@wcstack/signals"];
14566
+ const dom = imports["@wcstack/signals/dom"] ?? imports["@wcstack/signals/"];
14567
+ if (typeof core !== "string" || typeof dom !== "string") continue;
14568
+ if (core.includes("/dist/") && dom.includes("/dist/")) continue;
14569
+ const key = '"@wcstack/signals"';
14570
+ const at2 = match[2].indexOf(key);
14571
+ const bodyStart = match.index + match[0].indexOf(">") + 1;
14572
+ const start = bodyStart + (at2 === -1 ? 0 : at2 + 1);
14573
+ return { start, end: start + key.length - 2 };
14574
+ }
14575
+ return null;
14576
+ }
14230
14577
  var SCOPED_AUTO = /@wcstack\/([a-z0-9-]+)(?:@[^/"'\s]+)?\/(?:auto\b|dist\/(?:split\/)?auto(?:\.min)?\.js\b)/;
14231
14578
  var BUNDLE_AUTO = /(?:^|\/)wcstack(?:@[^/"'\s]+)?\/(?:auto\b|dist\/auto\.min\.js\b)/;
14232
14579
  var BUNDLE_PACKAGES = ["state", "router", "fetch", "storage", "autoloader"];
@@ -14305,6 +14652,88 @@ function blankHtmlComments(html) {
14305
14652
  function blankJsComments(code) {
14306
14653
  return code.replace(/\/\*[\s\S]*?\*\//g, (m) => " ".repeat(m.length)).replace(/(^|[^:])\/\/[^\n]*/g, (m, pre) => pre + " ".repeat(m.length - pre.length));
14307
14654
  }
14655
+ var VOID_TAGS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr"]);
14656
+ var ROUTE_TAG = "wcs-route";
14657
+ var LAYOUT_TAG2 = "wcs-layout";
14658
+ function attrValue(attrs, name) {
14659
+ const m = new RegExp(`(?:^|\\s)${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i").exec(attrs);
14660
+ return m === null ? null : m[1] ?? m[2] ?? m[3] ?? "";
14661
+ }
14662
+ function scanStructure(html) {
14663
+ const scan = html.replace(
14664
+ /(<(script|style)\b[^>]*>)([\s\S]*?)(<\/\2\s*>)/gi,
14665
+ (_m, open, _name, body, close) => open + " ".repeat(body.length) + close
14666
+ );
14667
+ const tagRegex = /<(\/?)([a-zA-Z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)>/g;
14668
+ const layoutIds = /* @__PURE__ */ new Set();
14669
+ for (const m of scan.matchAll(/<wcs-layout\b((?:"[^"]*"|'[^']*'|[^>"'])*)>/gi)) {
14670
+ const id = attrValue(m[1], "layout");
14671
+ if (id !== null && id !== "") layoutIds.add(id);
14672
+ }
14673
+ const bareMustaches = [];
14674
+ const layouts = [];
14675
+ const templateHasDefaultSlot = /* @__PURE__ */ new Map();
14676
+ const stack = [];
14677
+ let last = 0;
14678
+ let match;
14679
+ const text3 = (from, to) => {
14680
+ const top = stack[stack.length - 1];
14681
+ if (top === void 0 || to <= from) return;
14682
+ const chunk = scan.slice(from, to);
14683
+ if (top.name === LAYOUT_TAG2 && chunk.trim() !== "") top.unslotted = true;
14684
+ if (top.name !== ROUTE_TAG && !top.layoutTemplate) return;
14685
+ for (const m of chunk.matchAll(/\{\{[\s\S]*?\}\}/g)) {
14686
+ bareMustaches.push({ start: from + m.index, end: from + m.index + m[0].length, inLayout: top.layoutTemplate });
14687
+ }
14688
+ };
14689
+ while ((match = tagRegex.exec(scan)) !== null) {
14690
+ text3(last, match.index);
14691
+ last = match.index + match[0].length;
14692
+ const name = match[2].toLowerCase();
14693
+ const nameStart = match.index + 1 + match[1].length;
14694
+ if (match[1] === "/") {
14695
+ const at2 = stack.map((e) => e.name).lastIndexOf(name);
14696
+ if (at2 === -1) continue;
14697
+ for (const closed of stack.splice(at2)) {
14698
+ if (closed.name === LAYOUT_TAG2 && closed.unslotted && closed.layoutId !== void 0) {
14699
+ layouts.push({ start: closed.nameStart, end: closed.nameEnd, id: closed.layoutId });
14700
+ }
14701
+ }
14702
+ continue;
14703
+ }
14704
+ const attrs = match[3];
14705
+ const parent = stack[stack.length - 1];
14706
+ if (parent?.name === LAYOUT_TAG2 && !attrValue(attrs, "slot")) parent.unslotted = true;
14707
+ for (const open of stack) {
14708
+ if (open.layoutTemplate && name === "slot" && !attrValue(attrs, "name")) templateHasDefaultSlot.set(open.layoutId, true);
14709
+ }
14710
+ if (VOID_TAGS.has(name) || /\/\s*$/.test(attrs)) continue;
14711
+ const id = name === "template" ? attrValue(attrs, "id") : null;
14712
+ const element2 = {
14713
+ name,
14714
+ layoutTemplate: id !== null && layoutIds.has(id),
14715
+ nameStart,
14716
+ nameEnd: nameStart + match[2].length
14717
+ };
14718
+ if (element2.layoutTemplate) {
14719
+ element2.layoutId = id;
14720
+ if (!templateHasDefaultSlot.has(id)) templateHasDefaultSlot.set(id, false);
14721
+ }
14722
+ if (name === LAYOUT_TAG2 && attrValue(attrs, "src") === null) {
14723
+ const layoutId = attrValue(attrs, "layout");
14724
+ if (layoutId !== null && layoutId !== "") element2.layoutId = layoutId;
14725
+ }
14726
+ stack.push(element2);
14727
+ }
14728
+ text3(last, scan.length);
14729
+ for (const closed of stack) {
14730
+ if (closed.name === LAYOUT_TAG2 && closed.unslotted && closed.layoutId !== void 0) {
14731
+ layouts.push({ start: closed.nameStart, end: closed.nameEnd, id: closed.layoutId });
14732
+ }
14733
+ }
14734
+ const layoutsWithoutDefaultSlot = layouts.filter((l) => templateHasDefaultSlot.get(l.id) === false);
14735
+ return { bareMustaches, layoutsWithoutDefaultSlot };
14736
+ }
14308
14737
  var ROUTER_TAG2 = "wcs-router";
14309
14738
  var OUTLET_TAG = "wcs-outlet";
14310
14739
  function findMisplacedOutlets(html) {
@@ -15734,6 +16163,54 @@ function validateGetterUntrackedReads(script, scriptStart, nestedWriteRoots, loc
15734
16163
  }
15735
16164
  return out;
15736
16165
  }
16166
+ function validateGetterLocationReads(script, scriptStart, locale2) {
16167
+ if (!script.includes("location")) return [];
16168
+ const msgs = getMessages(locale2);
16169
+ const out = [];
16170
+ for (const getter of analyzeCallableBodies(script)) {
16171
+ if (getter.kind !== "getter" || getter.accessor !== "get" || !getter.body.includes("location")) continue;
16172
+ const read = findLocationRead(getter.body);
16173
+ if (read === null) continue;
16174
+ out.push({
16175
+ code: WcsDiagnosticCode.GetterUntrackedRead,
16176
+ start: scriptStart + getter.bodyStart + read.start,
16177
+ end: scriptStart + getter.bodyStart + read.end,
16178
+ message: msgs.getterReadsLocation(read.text),
16179
+ severity: "warning"
16180
+ });
16181
+ }
16182
+ return out;
16183
+ }
16184
+ function onHandlerStateParam(script, handler) {
16185
+ if (handler.kind === "body") {
16186
+ const head = script.slice(Math.max(0, handler.start - 400), handler.start);
16187
+ return /\(\s*([A-Za-z_$][\w$]*)[^()]*\)\s*\{\s*$/.exec(head)?.[1] ?? null;
16188
+ }
16189
+ 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;
16190
+ }
16191
+ function validateInPlaceChanges(script, scriptStart, locale2) {
16192
+ const msgs = getMessages(locale2);
16193
+ const out = [];
16194
+ const push3 = (text3, kind, textStart, root) => {
16195
+ for (const change of findInPlaceChanges(text3, kind, root)) {
16196
+ out.push({
16197
+ code: change.form === "method" ? WcsDiagnosticCode.ArrayMutation : change.form === "index" ? WcsDiagnosticCode.ArrayIndexAssign : WcsDiagnosticCode.NestedAssign,
16198
+ start: scriptStart + textStart + change.start,
16199
+ end: scriptStart + textStart + change.end,
16200
+ severity: "error",
16201
+ message: change.alias !== null ? msgs.inPlaceAlias(change.alias, change.source, change.target) : msgs.inPlaceChange(change.source, change.target)
16202
+ });
16203
+ }
16204
+ };
16205
+ for (const callable of analyzeCallableBodies(script)) push3(callable.body, "body", callable.bodyStart, "this");
16206
+ for (const handler of analyzeWatchHandlerSources(script)) push3(handler.text, handler.kind, handler.start, "this");
16207
+ for (const handler of analyzeOnHandlerSources(script)) {
16208
+ const root = handler.kind === "body" ? onHandlerStateParam(script, handler) : null;
16209
+ if (handler.kind === "body" && root === null) continue;
16210
+ push3(handler.text, handler.kind, handler.start, root);
16211
+ }
16212
+ return out;
16213
+ }
15737
16214
  var NESTED_WRITE_INPUTS = {
15738
16215
  "wcs-storage": { inputs: ["value"], exemptWhenManual: true },
15739
16216
  "wcs-fetch": { inputs: ["body"], exemptWhenManual: false, oneShot: true }
@@ -15845,6 +16322,26 @@ function collectNestedWriteRoots(html, stateTagName, bindAttrName, blocks) {
15845
16322
  if (path !== null) addPrefixes(path, false);
15846
16323
  }
15847
16324
  }
16325
+ for (const handler of analyzeOnHandlerSources(block.content)) {
16326
+ const param = onHandlerStateParam(block.content, handler);
16327
+ if (param === null) continue;
16328
+ const name = param.replace(/\$/g, "\\$");
16329
+ const region = { start: handler.start, end: handler.start + handler.text.length };
16330
+ const bracket = `\\b${name}\\s*(?:\\?\\.)?\\s*\\[\\s*["']([^"']+)["']\\s*\\]`;
16331
+ const template = `\\b${name}\\s*(?:\\?\\.)?\\s*\\[\\s*\`([^\`]*)\`` + String.raw`\s*\]`;
16332
+ for (const [pattern, quote] of [[bracket, /["']/], [template, /`/]]) {
16333
+ for (const regex of [new RegExp(`${pattern}${ASSIGN_TAIL}`, "g"), new RegExp(`${PRE_INCDEC}${pattern}`, "g")]) {
16334
+ let match;
16335
+ const part = scan.slice(region.start, region.end);
16336
+ while ((match = regex.exec(part)) !== null) {
16337
+ const keyStart = region.start + match.index + match[0].search(quote) + 1;
16338
+ const raw = block.content.slice(keyStart, keyStart + match[1].length);
16339
+ const path = quote.source === "`" ? templateKeyPath(raw) : raw;
16340
+ if (path !== null) addPrefixes(path, false);
16341
+ }
16342
+ }
16343
+ }
16344
+ }
15848
16345
  API_CALL.lastIndex = 0;
15849
16346
  let call;
15850
16347
  while ((call = API_CALL.exec(scan)) !== null) {
@@ -15975,7 +16472,9 @@ function validateSemantics(html, stateTagName = "wcs-state", locale2, bindAttrNa
15975
16472
  out.push(...validateIndexParamReads(block.content, block.contentStart, locale2));
15976
16473
  out.push(...validateGetterCycles(block.content, block.contentStart, locale2));
15977
16474
  out.push(...validateGetterUntrackedReads(block.content, block.contentStart, getNestedWriteRoots, locale2));
16475
+ out.push(...validateGetterLocationReads(block.content, block.contentStart, locale2));
15978
16476
  out.push(...validateOnHandlerThis(block.content, block.contentStart, locale2));
16477
+ out.push(...validateInPlaceChanges(block.content, block.contentStart, locale2));
15979
16478
  }
15980
16479
  out.push(...validateInputNestedWrites(html, stateTagName, bindAttrName, getNestedWriteRoots, locale2));
15981
16480
  out.push(...validateUpdatedCallbackDemand(html, stateTagName, bindAttrName, locale2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/lint",
3
- "version": "4.1.1",
3
+ "version": "4.2.0",
4
4
  "description": "Static-contract validator CLI (wcs-validate) for wcstack data-wcs bindings and wcstack.manifest.json sidecars. Thin npm wrapper around the wcstack-intellisense validator core.",
5
5
  "type": "module",
6
6
  "bin": {