@wcstack/lint 4.0.0-rc.3 → 4.0.0-rc.5

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 +207 -163
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -339,32 +339,8 @@ var LINT_HINT = " Validate statically: npx @wcstack/lint <file>.";
339
339
  function raiseError(message, subject, candidates) {
340
340
  throw new Error(`[@wcstack/state] ${message}${hooks.explain?.(message, subject, candidates) ?? ""}`);
341
341
  }
342
- var CODES = [
343
- "",
344
- "binding-syntax",
345
- "template-syntax",
346
- "binding-path-missing",
347
- "binding-type-expectation",
348
- "filter-unknown",
349
- "filter-arity",
350
- "getter-cycle",
351
- "getter-depth-exceeded",
352
- "index-arity",
353
- "index-param-range",
354
- "recursion-unsupported",
355
- "token-misconfigured",
356
- "token-undeclared",
357
- "wildcard-rank",
358
- "spread-no-bindable",
359
- "declaration-alias",
360
- "name-alias"
361
- ];
362
- var codeOf = (id) => {
363
- const c = CODES[id / 100 | 0];
364
- return c ? `[wcs/${c}] ` : "";
365
- };
366
342
  function text(id, args = []) {
367
- return hooks.render?.(id, args) ?? `${codeOf(id)}#${id}${args.map((a) => ` ${typeof a === "string" ? JSON.stringify(a) : String(a)}`).join("")}`;
343
+ return hooks.render?.(id, args) ?? `#${id}${args.map((a) => ` ${typeof a === "string" ? JSON.stringify(a) : String(a)}`).join("")}`;
368
344
  }
369
345
  function raise(id, args, subject, candidates) {
370
346
  raiseError(text(id, args), subject, candidates);
@@ -392,7 +368,21 @@ var FORMATS_FILTER_NAMES = [
392
368
  "time",
393
369
  "datetime",
394
370
  "ymd",
395
- "hms"
371
+ "hms",
372
+ "add",
373
+ "sub",
374
+ "mul",
375
+ "div",
376
+ "mod",
377
+ "abs",
378
+ "clamp",
379
+ "int",
380
+ "float",
381
+ "defaults",
382
+ "coalesce",
383
+ "number",
384
+ "string",
385
+ "nullIfEmpty"
396
386
  ];
397
387
  var definitions = /* @__PURE__ */ new Map();
398
388
  function hasFilter(name) {
@@ -584,6 +574,30 @@ function parseStatePart(statePart) {
584
574
  }
585
575
  var MAX_DRAIN_PASSES = 32;
586
576
  var MAX_RENDER_CHAIN = 100;
577
+ var CODES = [
578
+ "",
579
+ "binding-syntax",
580
+ "template-syntax",
581
+ "binding-path-missing",
582
+ "binding-type-expectation",
583
+ "filter-unknown",
584
+ "filter-arity",
585
+ "getter-cycle",
586
+ "getter-depth-exceeded",
587
+ "index-arity",
588
+ "index-param-range",
589
+ "recursion-unsupported",
590
+ "token-misconfigured",
591
+ "token-undeclared",
592
+ "wildcard-rank",
593
+ "spread-no-bindable",
594
+ "declaration-alias",
595
+ "name-alias"
596
+ ];
597
+ var codeOf = (id) => {
598
+ const c = CODES[id / 100 | 0];
599
+ return c ? `[wcs/${c}] ` : "";
600
+ };
587
601
  var MOVED = ["enableMustache", "sameValueGuard", "enableDirectionalInitialSync"];
588
602
  var element = (tag, at2) => `<${tag}${at2.map((a, i) => i % 2 ? `="${a}"` : ` ${a}`).join("")}>`;
589
603
  var CSP_GUIDE = "https://github.com/wcstack/wcstack/blob/main/docs/csp.md";
@@ -936,10 +950,11 @@ var SENTENCES = {
936
950
  1201
937
951
  /* CommandRightSide */
938
952
  ]: (prop, p) => `"${prop}: ${p}": the right-hand side must be $command.<name>`,
953
+ // a native element's command (no hyphen: never a custom element) is the native-commands add-on's
939
954
  [
940
955
  1202
941
956
  /* NoBindable */
942
- ]: (tag, what) => `<${tag}> declares no static wcBindable (${what}).`,
957
+ ]: (tag, what) => `<${tag}> declares no static wcBindable (${what}).${!tag.includes("-") && what.startsWith("command.") ? " A native element's command needs the add-on @wcstack/state/features/native-commands." : ""}`,
943
958
  [
944
959
  1203
945
960
  /* NoCommand */
@@ -948,6 +963,10 @@ var SENTENCES = {
948
963
  1204
949
964
  /* NoProperty */
950
965
  ]: (tag, prop) => `<${tag}> declares no property "${prop}".`,
966
+ [
967
+ 1205
968
+ /* NativeNoCommand */
969
+ ]: (tag, method, allowed) => `<${tag}> has no command "${method}" (a native <${tag}>'s commands: ${allowed}).`,
951
970
  [
952
971
  1301
953
972
  /* EventTokenUndeclared */
@@ -1263,26 +1282,26 @@ function findStartTagRegions(html) {
1263
1282
  let lower2 = null;
1264
1283
  let i = 0;
1265
1284
  while (i < html.length) {
1266
- const lt = html.indexOf("<", i);
1267
- if (lt === -1) break;
1268
- const next = html[lt + 1];
1269
- if (html.startsWith("<!--", lt)) {
1270
- const close = html.indexOf("-->", lt + 4);
1285
+ const lt2 = html.indexOf("<", i);
1286
+ if (lt2 === -1) break;
1287
+ const next = html[lt2 + 1];
1288
+ if (html.startsWith("<!--", lt2)) {
1289
+ const close = html.indexOf("-->", lt2 + 4);
1271
1290
  i = close === -1 ? html.length : close + 3;
1272
1291
  continue;
1273
1292
  }
1274
1293
  if (next === "!" || next === "?" || next === "/") {
1275
- const close = html.indexOf(">", lt + 1);
1294
+ const close = html.indexOf(">", lt2 + 1);
1276
1295
  i = close === -1 ? html.length : close + 1;
1277
1296
  continue;
1278
1297
  }
1279
1298
  if (next === void 0 || !/[A-Za-z]/.test(next)) {
1280
- i = lt + 1;
1299
+ i = lt2 + 1;
1281
1300
  continue;
1282
1301
  }
1283
- let n = lt + 1;
1302
+ let n = lt2 + 1;
1284
1303
  while (n < html.length && /[^\s/>]/.test(html[n])) n++;
1285
- const tagName = asciiLowerCase(html.slice(lt + 1, n));
1304
+ const tagName = asciiLowerCase(html.slice(lt2 + 1, n));
1286
1305
  let j = n;
1287
1306
  let quote = null;
1288
1307
  while (j < html.length) {
@@ -1296,10 +1315,10 @@ function findStartTagRegions(html) {
1296
1315
  }
1297
1316
  j++;
1298
1317
  }
1299
- const gt = j < html.length ? j : html.length;
1300
- const selfClosing = html[gt - 1] === "/";
1301
- out.push({ tagName, start: n, end: selfClosing ? gt - 1 : gt });
1302
- i = gt + 1;
1318
+ const gt2 = j < html.length ? j : html.length;
1319
+ const selfClosing = html[gt2 - 1] === "/";
1320
+ out.push({ tagName, start: n, end: selfClosing ? gt2 - 1 : gt2 });
1321
+ i = gt2 + 1;
1303
1322
  if (tagName === "script" || tagName === "style") {
1304
1323
  const close = (lower2 ??= asciiLowerCase(html)).indexOf(`</${tagName}`, i);
1305
1324
  i = close === -1 ? html.length : close;
@@ -1343,8 +1362,8 @@ function matchRawTextElement(html, lower2, pos) {
1343
1362
  return null;
1344
1363
  }
1345
1364
  function afterCloseTag(html, closeStart) {
1346
- const gt = html.indexOf(">", closeStart);
1347
- return gt === -1 ? html.length : gt + 1;
1365
+ const gt2 = html.indexOf(">", closeStart);
1366
+ return gt2 === -1 ? html.length : gt2 + 1;
1348
1367
  }
1349
1368
  function parseWcsStateElements(html, stateTagName = "wcs-state") {
1350
1369
  const elements = [];
@@ -1450,22 +1469,22 @@ function collectTemplateTags(html) {
1450
1469
  const tags = [];
1451
1470
  let pos = 0;
1452
1471
  while (pos < html.length) {
1453
- const lt = html.indexOf("<", pos);
1454
- if (lt === -1) break;
1455
- if (html.startsWith("<!--", lt)) {
1456
- const commentEnd = html.indexOf("-->", lt + 4);
1472
+ const lt2 = html.indexOf("<", pos);
1473
+ if (lt2 === -1) break;
1474
+ if (html.startsWith("<!--", lt2)) {
1475
+ const commentEnd = html.indexOf("-->", lt2 + 4);
1457
1476
  if (commentEnd === -1) break;
1458
1477
  pos = commentEnd + 3;
1459
1478
  continue;
1460
1479
  }
1461
- const raw = matchRawTextElement(html, lower2, lt);
1480
+ const raw = matchRawTextElement(html, lower2, lt2);
1462
1481
  if (raw !== null) {
1463
1482
  pos = raw.closed ? afterCloseTag(html, raw.contentEnd) : html.length;
1464
1483
  continue;
1465
1484
  }
1466
- const tag = /^<(\/?)template(?=[\s/>])/i.exec(html.slice(lt, lt + 11));
1467
- if (tag !== null) tags.push({ at: lt, close: tag[1] === "/" });
1468
- pos = lt + 1;
1485
+ const tag = /^<(\/?)template(?=[\s/>])/i.exec(html.slice(lt2, lt2 + 11));
1486
+ if (tag !== null) tags.push({ at: lt2, close: tag[1] === "/" });
1487
+ pos = lt2 + 1;
1469
1488
  }
1470
1489
  return tags;
1471
1490
  }
@@ -1609,32 +1628,8 @@ var hooks2 = {};
1609
1628
  function raiseError2(message, subject, candidates) {
1610
1629
  throw new Error(`[@wcstack/state] ${message}${hooks2.explain?.(message, subject, candidates) ?? ""}`);
1611
1630
  }
1612
- var CODES2 = [
1613
- "",
1614
- "binding-syntax",
1615
- "template-syntax",
1616
- "binding-path-missing",
1617
- "binding-type-expectation",
1618
- "filter-unknown",
1619
- "filter-arity",
1620
- "getter-cycle",
1621
- "getter-depth-exceeded",
1622
- "index-arity",
1623
- "index-param-range",
1624
- "recursion-unsupported",
1625
- "token-misconfigured",
1626
- "token-undeclared",
1627
- "wildcard-rank",
1628
- "spread-no-bindable",
1629
- "declaration-alias",
1630
- "name-alias"
1631
- ];
1632
- var codeOf2 = (id) => {
1633
- const c = CODES2[id / 100 | 0];
1634
- return c ? `[wcs/${c}] ` : "";
1635
- };
1636
1631
  function text2(id, args = []) {
1637
- return hooks2.render?.(id, args) ?? `${codeOf2(id)}#${id}${args.map((a) => ` ${typeof a === "string" ? JSON.stringify(a) : String(a)}`).join("")}`;
1632
+ return hooks2.render?.(id, args) ?? `#${id}${args.map((a) => ` ${typeof a === "string" ? JSON.stringify(a) : String(a)}`).join("")}`;
1638
1633
  }
1639
1634
  function raise2(id, args, subject, candidates) {
1640
1635
  raiseError2(text2(id, args), subject, candidates);
@@ -1649,7 +1644,17 @@ var config = {
1649
1644
  locale: typeof document !== "undefined" ? document.documentElement?.lang || "en" : "en",
1650
1645
  enableContractAnalyzer: false
1651
1646
  };
1652
- var FEATURE_NAMES = ["formats", "diagnostics", "temporal", "list-keys", "scopes", "recursion", "ssr", "devtools"];
1647
+ var FEATURE_NAMES = ["formats", "diagnostics", "temporal", "list-keys", "scopes", "recursion", "ssr", "devtools", "native-commands"];
1648
+ var NATIVE_COMMANDS = {
1649
+ "*": ["focus", "blur", "click", "scrollIntoView", "showPopover", "hidePopover", "togglePopover"],
1650
+ "dialog": ["show", "showModal", "close", "requestClose"],
1651
+ "form": ["requestSubmit", "checkValidity", "reportValidity"],
1652
+ "input": ["select", "setSelectionRange", "showPicker", "setCustomValidity", "checkValidity", "reportValidity"],
1653
+ "textarea": ["select", "setSelectionRange", "setCustomValidity", "checkValidity", "reportValidity"],
1654
+ "select": ["showPicker", "setCustomValidity", "checkValidity", "reportValidity"],
1655
+ "audio": ["play", "pause", "load"],
1656
+ "video": ["play", "pause", "load"]
1657
+ };
1653
1658
  var WILDCARD2 = "*";
1654
1659
  function optionsRequired(fnName) {
1655
1660
  raise2(26, [fnName]);
@@ -1738,42 +1743,6 @@ var numeric = (name, op) => ({
1738
1743
  var truthy = () => (value) => !!value;
1739
1744
  var falsy = () => (value) => !value;
1740
1745
  var boolean = () => (value) => Boolean(value);
1741
- var abs = () => (value) => {
1742
- if (typeof value !== "number") {
1743
- valueMustBeNumber("abs");
1744
- }
1745
- return Math.abs(value);
1746
- };
1747
- var clamp = (options) => {
1748
- const min = requiredNumberOption(options, 0, "clamp");
1749
- const max = requiredNumberOption(options, 1, "clamp");
1750
- return (value) => {
1751
- if (typeof value !== "number") {
1752
- valueMustBeNumber("clamp");
1753
- }
1754
- return Math.min(Math.max(value, min), max);
1755
- };
1756
- };
1757
- var number = () => (value) => Number(value);
1758
- var string = () => (value) => String(value);
1759
- var int = () => (value) => parseInt(String(value), 10);
1760
- var float = () => (value) => parseFloat(String(value));
1761
- var defaults = (options, literals) => {
1762
- const opt = options?.[0] ?? optionsRequired("defaults");
1763
- const fallback = firstLiteral(opt, literals);
1764
- return (value) => {
1765
- if (!value) {
1766
- return fallback;
1767
- }
1768
- return value;
1769
- };
1770
- };
1771
- var coalesce = (options, literals) => {
1772
- const opt = options?.[0] ?? optionsRequired("coalesce");
1773
- const fallback = firstLiteral(opt, literals);
1774
- return (value) => value ?? fallback;
1775
- };
1776
- var nullIfEmpty = () => (value) => value === "" ? null : value;
1777
1746
  var coreFilters = {
1778
1747
  eq: { factory: eq, arity: [1, 1] },
1779
1748
  ne: { factory: ne, arity: [1, 1] },
@@ -1782,23 +1751,9 @@ var coreFilters = {
1782
1751
  le: numeric("le", (value, opt) => value <= opt),
1783
1752
  gt: numeric("gt", (value, opt) => value > opt),
1784
1753
  ge: numeric("ge", (value, opt) => value >= opt),
1785
- add: numeric("add", (value, opt) => value + opt),
1786
- sub: numeric("sub", (value, opt) => value - opt),
1787
- mul: numeric("mul", (value, opt) => value * opt),
1788
- div: numeric("div", (value, opt) => value / opt),
1789
- mod: numeric("mod", (value, opt) => value % opt),
1790
- abs: { factory: abs, arity: [0, 0] },
1791
- clamp: { factory: clamp, arity: [2, 2] },
1792
- int: { factory: int, arity: [0, 0] },
1793
- float: { factory: float, arity: [0, 0] },
1794
1754
  falsy: { factory: falsy, arity: [0, 0] },
1795
1755
  truthy: { factory: truthy, arity: [0, 0] },
1796
- defaults: { factory: defaults, arity: [1, 1] },
1797
- coalesce: { factory: coalesce, arity: [1, 1] },
1798
- boolean: { factory: boolean, arity: [0, 0] },
1799
- number: { factory: number, arity: [0, 0] },
1800
- string: { factory: string, arity: [0, 0] },
1801
- nullIfEmpty: { factory: nullIfEmpty, arity: [0, 0] }
1756
+ boolean: { factory: boolean, arity: [0, 0] }
1802
1757
  };
1803
1758
  var nullishPassthrough = (factory) => (options) => {
1804
1759
  const filterFn = factory(options);
@@ -1983,7 +1938,44 @@ var hms = (options) => {
1983
1938
  return `${hours}${opt}${minutes}${opt}${seconds}`;
1984
1939
  };
1985
1940
  };
1986
- var formatFilters = {
1941
+ var abs = () => (value) => {
1942
+ if (typeof value !== "number") {
1943
+ valueMustBeNumber("abs");
1944
+ }
1945
+ return Math.abs(value);
1946
+ };
1947
+ var clamp = (options) => {
1948
+ const min = requiredNumberOption(options, 0, "clamp");
1949
+ const max = requiredNumberOption(options, 1, "clamp");
1950
+ return (value) => {
1951
+ if (typeof value !== "number") {
1952
+ valueMustBeNumber("clamp");
1953
+ }
1954
+ return Math.min(Math.max(value, min), max);
1955
+ };
1956
+ };
1957
+ var number = () => (value) => Number(value);
1958
+ var string = () => (value) => String(value);
1959
+ var int = () => (value) => parseInt(String(value), 10);
1960
+ var float = () => (value) => parseFloat(String(value));
1961
+ var defaults = (options, literals) => {
1962
+ const opt = options?.[0] ?? optionsRequired("defaults");
1963
+ const fallback = firstLiteral(opt, literals);
1964
+ return (value) => {
1965
+ if (!value) {
1966
+ return fallback;
1967
+ }
1968
+ return value;
1969
+ };
1970
+ };
1971
+ var coalesce = (options, literals) => {
1972
+ const opt = options?.[0] ?? optionsRequired("coalesce");
1973
+ const fallback = firstLiteral(opt, literals);
1974
+ return (value) => value ?? fallback;
1975
+ };
1976
+ var nullIfEmpty = () => (value) => value === "" ? null : value;
1977
+ var { eq: eq2, ne: ne2, not: not2, lt, le, gt, ge, falsy: falsy2, truthy: truthy2, boolean: boolean2 } = coreFilters;
1978
+ var registered = {
1987
1979
  toFixed: { factory: toFixed, arity: [0, 1] },
1988
1980
  locale: { factory: locale, arity: [0, 1] },
1989
1981
  // The `String(value)` family passes an absent value through (B8 — see nullishPassthrough)
@@ -2009,8 +2001,36 @@ var formatFilters = {
2009
2001
  time: { factory: time, arity: [0, 1] },
2010
2002
  datetime: { factory: datetime, arity: [0, 1] },
2011
2003
  ymd: { factory: ymd, arity: [0, 1] },
2012
- hms: { factory: hms, arity: [0, 1] }
2004
+ hms: { factory: hms, arity: [0, 1] },
2005
+ // the core set of 4.0.0-rc.3 (the core's own: eq ne not lt le gt ge falsy truthy boolean)
2006
+ eq: eq2,
2007
+ ne: ne2,
2008
+ not: not2,
2009
+ lt,
2010
+ le,
2011
+ gt,
2012
+ ge,
2013
+ add: numeric("add", (value, opt) => value + opt),
2014
+ sub: numeric("sub", (value, opt) => value - opt),
2015
+ mul: numeric("mul", (value, opt) => value * opt),
2016
+ div: numeric("div", (value, opt) => value / opt),
2017
+ mod: numeric("mod", (value, opt) => value % opt),
2018
+ abs: { factory: abs, arity: [0, 0] },
2019
+ clamp: { factory: clamp, arity: [2, 2] },
2020
+ int: { factory: int, arity: [0, 0] },
2021
+ float: { factory: float, arity: [0, 0] },
2022
+ falsy: falsy2,
2023
+ truthy: truthy2,
2024
+ defaults: { factory: defaults, arity: [1, 1] },
2025
+ coalesce: { factory: coalesce, arity: [1, 1] },
2026
+ boolean: boolean2,
2027
+ number: { factory: number, arity: [0, 0] },
2028
+ string: { factory: string, arity: [0, 0] },
2029
+ nullIfEmpty: { factory: nullIfEmpty, arity: [0, 0] }
2013
2030
  };
2031
+ var formatFilters = /* @__PURE__ */ Object.fromEntries(
2032
+ /* @__PURE__ */ Object.entries(registered).filter(([name]) => !(name in coreFilters))
2033
+ );
2014
2034
  var STRUCTURAL_BINDING_TYPE_SET2 = /* @__PURE__ */ new Set([
2015
2035
  "if",
2016
2036
  "elseif",
@@ -2146,10 +2166,18 @@ function getWcsManifest() {
2146
2166
  ],
2147
2167
  // every option is a boolean, true when left out (engine.ts `loadTarget`: `typeof … === "boolean"`, `?? true`)
2148
2168
  behaviorOptions: Object.fromEntries(BEHAVIOR_OPTION_KEYS.map((key) => [key, { type: "boolean", default: true }])),
2149
- features: [...FEATURE_NAMES]
2169
+ features: [...FEATURE_NAMES],
2170
+ nativeCommands: Object.fromEntries(Object.entries(NATIVE_COMMANDS).map(([tag, methods]) => [tag, [...methods]]))
2150
2171
  };
2151
2172
  }
2152
2173
 
2174
+ // src/service/wcsManifest.ts
2175
+ var NATIVE_COMMANDS2 = getWcsManifest().nativeCommands ?? null;
2176
+ function nativeCommandsOf(tag) {
2177
+ if (NATIVE_COMMANDS2 === null) return null;
2178
+ return [...NATIVE_COMMANDS2["*"] ?? [], ...Object.hasOwn(NATIVE_COMMANDS2, tag) ? NATIVE_COMMANDS2[tag] : []];
2179
+ }
2180
+
2153
2181
  // src/service/completionData.ts
2154
2182
  var BUILTIN_FILTERS = Object.entries(builtinFilterMeta).map(
2155
2183
  ([name, meta]) => ({ name, ...meta })
@@ -2165,6 +2193,41 @@ var STRUCTURAL_DIRECTIVES = [...STRUCTURAL_BINDING_TYPE_SET2].map((name) => ({
2165
2193
  ...STRUCTURAL_DIRECTIVE_INFO[name]
2166
2194
  }));
2167
2195
 
2196
+ // src/service/suggestion.ts
2197
+ function suggestion(input, candidates, msgs) {
2198
+ let best = null;
2199
+ let bestDistance = 3;
2200
+ for (const c of candidates) {
2201
+ const d = editDistance2(input.toLowerCase(), c.toLowerCase(), bestDistance);
2202
+ if (d < bestDistance) {
2203
+ best = c;
2204
+ bestDistance = d;
2205
+ }
2206
+ }
2207
+ return best !== null ? msgs.didYouMean(best) : "";
2208
+ }
2209
+ function editDistance2(a, b, bound) {
2210
+ if (Math.abs(a.length - b.length) >= bound) return bound;
2211
+ const prev = new Array(b.length + 1);
2212
+ const curr = new Array(b.length + 1);
2213
+ for (let j = 0; j <= b.length; j++) prev[j] = j;
2214
+ for (let i = 1; i <= a.length; i++) {
2215
+ curr[0] = i;
2216
+ let rowMin = curr[0];
2217
+ for (let j = 1; j <= b.length; j++) {
2218
+ curr[j] = Math.min(
2219
+ prev[j] + 1,
2220
+ curr[j - 1] + 1,
2221
+ prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1)
2222
+ );
2223
+ if (curr[j] < rowMin) rowMin = curr[j];
2224
+ }
2225
+ if (rowMin >= bound) return bound;
2226
+ for (let j = 0; j <= b.length; j++) prev[j] = curr[j];
2227
+ }
2228
+ return Math.min(prev[b.length], bound);
2229
+ }
2230
+
2168
2231
  // src/service/recursionPaths.ts
2169
2232
  var RECURSION_WILDCARD2 = "**";
2170
2233
  var RECURSION_KEY = "$recursion";
@@ -9892,6 +9955,7 @@ var ja = {
9892
9955
  featuresAttrNotRoot: () => `features \u5C5E\u6027\u3092\u8AAD\u3080\u306E\u306F\u6587\u66F8\u306E root \u306E <wcs-state>\uFF08mount \u3068 bind-component \u3092\u6301\u305F\u306A\u3044\u6700\u521D\u306E\u3082\u306E\uFF09\u3060\u3051\u3067\u3059\u3002\u3053\u306E\u8981\u7D20\u306E features \u306F\u7121\u8996\u3055\u308C\u307E\u3059 \u2014 root \u306E <wcs-state> \u306B\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`,
9893
9956
  onPrefixedMember: (member, tag, modifiers) => `"${member}" \u306F <${tag}> \u306E\u30E1\u30F3\u30D0\u30FC\u3067\u3059\u304C\u3001"on" \u3067\u59CB\u307E\u308B\u540D\u524D\u306F\u30A4\u30D9\u30F3\u30C8\u675F\u7E1B\u306B\u306A\u308A\uFF08"${member.slice(2)}" \u30A4\u30D9\u30F3\u30C8\u3092\u5F85\u3064\uFF09\u3001\u5024\u306F\u5C4A\u304D\u307E\u305B\u3093\u3002\u30D7\u30ED\u30D1\u30C6\u30A3\u3068\u3057\u3066\u675F\u7E1B\u3059\u308B\u306B\u306F ".${member}${modifiers ? `#${modifiers}` : ""}:" \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF08@wcstack/state 3.1\uFF09`,
9894
9957
  tagCommandUnknown: (name, tag, declared) => `"${name}" \u306F <${tag}> \u306E command \u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF08\u5BA3\u8A00\u6E08\u307F: ${declared}\uFF09`,
9958
+ nativeCommandUnknown: (method, tag, allowed) => `"${method}" \u306F\u30CD\u30A4\u30C6\u30A3\u30D6\u306E <${tag}> \u306B command \u3067\u547C\u3079\u308B\u30E1\u30BD\u30C3\u30C9\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF08\u547C\u3079\u308B\u306E\u306F ${allowed}\u3002\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u521D\u671F\u5316\u3067 wcs/token-misconfigured \u3092\u6295\u3052\u307E\u3059\uFF09`,
9895
9959
  spreadNoBindable: (tag) => `'...'\uFF08spread\uFF09\u306F <${tag}> \u306B\u6709\u52B9\u306A wcBindable \u5BA3\u8A00\u304C\u5FC5\u8981\u3067\u3059 \u2014 \u3053\u306E\u30BF\u30B0\u306F\u5BA3\u8A00\u3092\u6301\u305F\u306A\u3044\u305F\u3081\u3001\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u30A8\u30E9\u30FC\u3092\u9001\u51FA\u3057\u307E\u3059`,
9896
9960
  tagEventTokenKeyUnknown: (name, tag, declared) => `eventToken \u306E\u30AD\u30FC "${name}" \u306F <${tag}> \u306E wcBindable \u30D7\u30ED\u30D1\u30C6\u30A3\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u751F DOM \u30A4\u30D9\u30F3\u30C8\u540D\u306F\u767A\u706B\u3057\u307E\u305B\u3093 \u2014 \u30D7\u30ED\u30D1\u30C6\u30A3\u540D\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u5BA3\u8A00\u6E08\u307F: ${declared}\uFF09`,
9897
9961
  ariaAttrUnknown: (name) => `"${name}" \u306F WAI-ARIA \u306E\u5C5E\u6027\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002setAttribute \u306F\u305D\u306E\u307E\u307E\u66F8\u304D\u8FBC\u307F\u307E\u3059\u304C\u3001\u652F\u63F4\u6280\u8853\u306B\u306F\u9ED9\u3063\u3066\u7121\u8996\u3055\u308C\u307E\u3059`,
@@ -10077,6 +10141,7 @@ var en = {
10077
10141
  featuresAttrNotRoot: () => `The features attribute is read only on the document's root <wcs-state> (the first one without mount and bind-component); it is ignored here \u2014 put it on the root <wcs-state>`,
10078
10142
  onPrefixedMember: (member, tag, modifiers) => `"${member}" is a member of <${tag}>, but a name starting with "on" makes an event binding (it listens for a "${member.slice(2)}" event) and the value never arrives. Write ".${member}${modifiers ? `#${modifiers}` : ""}:" to bind the property (@wcstack/state 3.1)`,
10079
10143
  tagCommandUnknown: (name, tag, declared) => `"${name}" is not a command of <${tag}> (declared: ${declared})`,
10144
+ nativeCommandUnknown: (method, tag, allowed) => `"${method}" is not a command of a native <${tag}> (its commands: ${allowed}; the runtime throws wcs/token-misconfigured at initialization)`,
10080
10145
  spreadNoBindable: (tag) => `'...' (spread) requires <${tag}> to expose a valid wcBindable declaration \u2014 this tag declares none, so the runtime raises an error`,
10081
10146
  tagEventTokenKeyUnknown: (name, tag, declared) => `eventToken key "${name}" is not a wcBindable property of <${tag}>. Raw DOM event names never fire \u2014 use the property name (declared: ${declared})`,
10082
10147
  ariaAttrUnknown: (name) => `"${name}" is not a WAI-ARIA attribute. setAttribute writes it anyway, and assistive technology silently ignores it`,
@@ -10659,6 +10724,18 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
10659
10724
  scopedPaths.filter((p) => p.kind === "command").map((p) => p.path)
10660
10725
  );
10661
10726
  if (propNoMod.startsWith("command.")) {
10727
+ const allowed = attr.tagName !== void 0 && !attr.tagName.includes("-") ? nativeCommandsOf(attr.tagName) : null;
10728
+ const method = propNoMod.slice("command.".length);
10729
+ if (allowed !== null && !allowed.includes(method)) {
10730
+ const methodStart = bindingStart + binding.indexOf("command.") + "command.".length;
10731
+ diagnostics.push({
10732
+ code: WcsDiagnosticCode.TokenMisconfigured,
10733
+ start: methodStart,
10734
+ end: methodStart + method.length,
10735
+ message: msgs.nativeCommandUnknown(method, attr.tagName, allowed.join(", ")) + suggestion(method, allowed, msgs),
10736
+ severity: "error"
10737
+ });
10738
+ }
10662
10739
  const tokenPath = parsed.path?.trim() ?? "";
10663
10740
  if (tokenPath) {
10664
10741
  const pathOffset = binding.indexOf(parsed.path);
@@ -13269,39 +13346,6 @@ function normalizeSeed(raw) {
13269
13346
  const compact = raw.replace(/\s+/g, "");
13270
13347
  return compact === "" ? raw : compact;
13271
13348
  }
13272
- function suggestion(input, candidates, msgs) {
13273
- let best = null;
13274
- let bestDistance = 3;
13275
- for (const c of candidates) {
13276
- const d = editDistance2(input.toLowerCase(), c.toLowerCase(), bestDistance);
13277
- if (d < bestDistance) {
13278
- best = c;
13279
- bestDistance = d;
13280
- }
13281
- }
13282
- return best !== null ? msgs.didYouMean(best) : "";
13283
- }
13284
- function editDistance2(a, b, bound) {
13285
- if (Math.abs(a.length - b.length) >= bound) return bound;
13286
- const prev = new Array(b.length + 1);
13287
- const curr = new Array(b.length + 1);
13288
- for (let j = 0; j <= b.length; j++) prev[j] = j;
13289
- for (let i = 1; i <= a.length; i++) {
13290
- curr[0] = i;
13291
- let rowMin = curr[0];
13292
- for (let j = 1; j <= b.length; j++) {
13293
- curr[j] = Math.min(
13294
- prev[j] + 1,
13295
- curr[j - 1] + 1,
13296
- prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1)
13297
- );
13298
- if (curr[j] < rowMin) rowMin = curr[j];
13299
- }
13300
- if (rowMin >= bound) return bound;
13301
- for (let j = 0; j <= b.length; j++) prev[j] = curr[j];
13302
- }
13303
- return Math.min(prev[b.length], bound);
13304
- }
13305
13349
  function findBuiltinTagOccurrences(html) {
13306
13350
  const out = [];
13307
13351
  const regex = /<(wcs-[a-z0-9-]+)((?:"[^"]*"|'[^']*'|[^>"'])*)>/gi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/lint",
3
- "version": "4.0.0-rc.3",
3
+ "version": "4.0.0-rc.5",
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": {