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

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 +132 -127
  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";
@@ -1263,26 +1277,26 @@ function findStartTagRegions(html) {
1263
1277
  let lower2 = null;
1264
1278
  let i = 0;
1265
1279
  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);
1280
+ const lt2 = html.indexOf("<", i);
1281
+ if (lt2 === -1) break;
1282
+ const next = html[lt2 + 1];
1283
+ if (html.startsWith("<!--", lt2)) {
1284
+ const close = html.indexOf("-->", lt2 + 4);
1271
1285
  i = close === -1 ? html.length : close + 3;
1272
1286
  continue;
1273
1287
  }
1274
1288
  if (next === "!" || next === "?" || next === "/") {
1275
- const close = html.indexOf(">", lt + 1);
1289
+ const close = html.indexOf(">", lt2 + 1);
1276
1290
  i = close === -1 ? html.length : close + 1;
1277
1291
  continue;
1278
1292
  }
1279
1293
  if (next === void 0 || !/[A-Za-z]/.test(next)) {
1280
- i = lt + 1;
1294
+ i = lt2 + 1;
1281
1295
  continue;
1282
1296
  }
1283
- let n = lt + 1;
1297
+ let n = lt2 + 1;
1284
1298
  while (n < html.length && /[^\s/>]/.test(html[n])) n++;
1285
- const tagName = asciiLowerCase(html.slice(lt + 1, n));
1299
+ const tagName = asciiLowerCase(html.slice(lt2 + 1, n));
1286
1300
  let j = n;
1287
1301
  let quote = null;
1288
1302
  while (j < html.length) {
@@ -1296,10 +1310,10 @@ function findStartTagRegions(html) {
1296
1310
  }
1297
1311
  j++;
1298
1312
  }
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;
1313
+ const gt2 = j < html.length ? j : html.length;
1314
+ const selfClosing = html[gt2 - 1] === "/";
1315
+ out.push({ tagName, start: n, end: selfClosing ? gt2 - 1 : gt2 });
1316
+ i = gt2 + 1;
1303
1317
  if (tagName === "script" || tagName === "style") {
1304
1318
  const close = (lower2 ??= asciiLowerCase(html)).indexOf(`</${tagName}`, i);
1305
1319
  i = close === -1 ? html.length : close;
@@ -1343,8 +1357,8 @@ function matchRawTextElement(html, lower2, pos) {
1343
1357
  return null;
1344
1358
  }
1345
1359
  function afterCloseTag(html, closeStart) {
1346
- const gt = html.indexOf(">", closeStart);
1347
- return gt === -1 ? html.length : gt + 1;
1360
+ const gt2 = html.indexOf(">", closeStart);
1361
+ return gt2 === -1 ? html.length : gt2 + 1;
1348
1362
  }
1349
1363
  function parseWcsStateElements(html, stateTagName = "wcs-state") {
1350
1364
  const elements = [];
@@ -1450,22 +1464,22 @@ function collectTemplateTags(html) {
1450
1464
  const tags = [];
1451
1465
  let pos = 0;
1452
1466
  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);
1467
+ const lt2 = html.indexOf("<", pos);
1468
+ if (lt2 === -1) break;
1469
+ if (html.startsWith("<!--", lt2)) {
1470
+ const commentEnd = html.indexOf("-->", lt2 + 4);
1457
1471
  if (commentEnd === -1) break;
1458
1472
  pos = commentEnd + 3;
1459
1473
  continue;
1460
1474
  }
1461
- const raw = matchRawTextElement(html, lower2, lt);
1475
+ const raw = matchRawTextElement(html, lower2, lt2);
1462
1476
  if (raw !== null) {
1463
1477
  pos = raw.closed ? afterCloseTag(html, raw.contentEnd) : html.length;
1464
1478
  continue;
1465
1479
  }
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;
1480
+ const tag = /^<(\/?)template(?=[\s/>])/i.exec(html.slice(lt2, lt2 + 11));
1481
+ if (tag !== null) tags.push({ at: lt2, close: tag[1] === "/" });
1482
+ pos = lt2 + 1;
1469
1483
  }
1470
1484
  return tags;
1471
1485
  }
@@ -1609,32 +1623,8 @@ var hooks2 = {};
1609
1623
  function raiseError2(message, subject, candidates) {
1610
1624
  throw new Error(`[@wcstack/state] ${message}${hooks2.explain?.(message, subject, candidates) ?? ""}`);
1611
1625
  }
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
1626
  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("")}`;
1627
+ return hooks2.render?.(id, args) ?? `#${id}${args.map((a) => ` ${typeof a === "string" ? JSON.stringify(a) : String(a)}`).join("")}`;
1638
1628
  }
1639
1629
  function raise2(id, args, subject, candidates) {
1640
1630
  raiseError2(text2(id, args), subject, candidates);
@@ -1738,42 +1728,6 @@ var numeric = (name, op) => ({
1738
1728
  var truthy = () => (value) => !!value;
1739
1729
  var falsy = () => (value) => !value;
1740
1730
  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
1731
  var coreFilters = {
1778
1732
  eq: { factory: eq, arity: [1, 1] },
1779
1733
  ne: { factory: ne, arity: [1, 1] },
@@ -1782,23 +1736,9 @@ var coreFilters = {
1782
1736
  le: numeric("le", (value, opt) => value <= opt),
1783
1737
  gt: numeric("gt", (value, opt) => value > opt),
1784
1738
  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
1739
  falsy: { factory: falsy, arity: [0, 0] },
1795
1740
  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] }
1741
+ boolean: { factory: boolean, arity: [0, 0] }
1802
1742
  };
1803
1743
  var nullishPassthrough = (factory) => (options) => {
1804
1744
  const filterFn = factory(options);
@@ -1983,7 +1923,44 @@ var hms = (options) => {
1983
1923
  return `${hours}${opt}${minutes}${opt}${seconds}`;
1984
1924
  };
1985
1925
  };
1986
- var formatFilters = {
1926
+ var abs = () => (value) => {
1927
+ if (typeof value !== "number") {
1928
+ valueMustBeNumber("abs");
1929
+ }
1930
+ return Math.abs(value);
1931
+ };
1932
+ var clamp = (options) => {
1933
+ const min = requiredNumberOption(options, 0, "clamp");
1934
+ const max = requiredNumberOption(options, 1, "clamp");
1935
+ return (value) => {
1936
+ if (typeof value !== "number") {
1937
+ valueMustBeNumber("clamp");
1938
+ }
1939
+ return Math.min(Math.max(value, min), max);
1940
+ };
1941
+ };
1942
+ var number = () => (value) => Number(value);
1943
+ var string = () => (value) => String(value);
1944
+ var int = () => (value) => parseInt(String(value), 10);
1945
+ var float = () => (value) => parseFloat(String(value));
1946
+ var defaults = (options, literals) => {
1947
+ const opt = options?.[0] ?? optionsRequired("defaults");
1948
+ const fallback = firstLiteral(opt, literals);
1949
+ return (value) => {
1950
+ if (!value) {
1951
+ return fallback;
1952
+ }
1953
+ return value;
1954
+ };
1955
+ };
1956
+ var coalesce = (options, literals) => {
1957
+ const opt = options?.[0] ?? optionsRequired("coalesce");
1958
+ const fallback = firstLiteral(opt, literals);
1959
+ return (value) => value ?? fallback;
1960
+ };
1961
+ var nullIfEmpty = () => (value) => value === "" ? null : value;
1962
+ var { eq: eq2, ne: ne2, not: not2, lt, le, gt, ge, falsy: falsy2, truthy: truthy2, boolean: boolean2 } = coreFilters;
1963
+ var registered = {
1987
1964
  toFixed: { factory: toFixed, arity: [0, 1] },
1988
1965
  locale: { factory: locale, arity: [0, 1] },
1989
1966
  // The `String(value)` family passes an absent value through (B8 — see nullishPassthrough)
@@ -2009,8 +1986,36 @@ var formatFilters = {
2009
1986
  time: { factory: time, arity: [0, 1] },
2010
1987
  datetime: { factory: datetime, arity: [0, 1] },
2011
1988
  ymd: { factory: ymd, arity: [0, 1] },
2012
- hms: { factory: hms, arity: [0, 1] }
1989
+ hms: { factory: hms, arity: [0, 1] },
1990
+ // the core set of 4.0.0-rc.3 (the core's own: eq ne not lt le gt ge falsy truthy boolean)
1991
+ eq: eq2,
1992
+ ne: ne2,
1993
+ not: not2,
1994
+ lt,
1995
+ le,
1996
+ gt,
1997
+ ge,
1998
+ add: numeric("add", (value, opt) => value + opt),
1999
+ sub: numeric("sub", (value, opt) => value - opt),
2000
+ mul: numeric("mul", (value, opt) => value * opt),
2001
+ div: numeric("div", (value, opt) => value / opt),
2002
+ mod: numeric("mod", (value, opt) => value % opt),
2003
+ abs: { factory: abs, arity: [0, 0] },
2004
+ clamp: { factory: clamp, arity: [2, 2] },
2005
+ int: { factory: int, arity: [0, 0] },
2006
+ float: { factory: float, arity: [0, 0] },
2007
+ falsy: falsy2,
2008
+ truthy: truthy2,
2009
+ defaults: { factory: defaults, arity: [1, 1] },
2010
+ coalesce: { factory: coalesce, arity: [1, 1] },
2011
+ boolean: boolean2,
2012
+ number: { factory: number, arity: [0, 0] },
2013
+ string: { factory: string, arity: [0, 0] },
2014
+ nullIfEmpty: { factory: nullIfEmpty, arity: [0, 0] }
2013
2015
  };
2016
+ var formatFilters = /* @__PURE__ */ Object.fromEntries(
2017
+ /* @__PURE__ */ Object.entries(registered).filter(([name]) => !(name in coreFilters))
2018
+ );
2014
2019
  var STRUCTURAL_BINDING_TYPE_SET2 = /* @__PURE__ */ new Set([
2015
2020
  "if",
2016
2021
  "elseif",
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.4",
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": {