@wcstack/lint 4.4.0 → 4.5.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 +40 -3
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -207,6 +207,11 @@ var WcsDiagnosticCode = {
207
207
  // 未知メンバーへのバインド(プロパティ / command. / eventToken. キー)。4.0 のランタイムは #38 / #1203 /
208
208
  // #1204 で拒み、root では初期化が、行では束縛が失敗する(3.x の「黙って無視」ではない)。error。
209
209
  TagMemberUnknown: "wcs/tag-member-unknown",
210
+ // `semantics: "handle"` の出力(`<wcs-camera>` の `streamReady` = 生の MediaStream)を、値としてパスに
211
+ // 束ねた。プロトコルは「値の置き場ではなく ref / callback で受ける」と定める(protocol/wc-bindable.ts)。
212
+ // ランタイムは書くので動くが、スナップショット・DevTools・SSR に載らないオブジェクトが state に入る
213
+ // (docs/seam-apps.md、state-field-report)。warning。5.0 でランタイムが拒むかは誤りの目録の議題。
214
+ HandleBoundAsValue: "wcs/handle-bound-as-value",
210
215
  // タグのメンバー名が "on" で始まる(`once` 等)のに先頭ドット無しで束縛した: ランタイムはイベント束縛にして
211
216
  // "ce" イベントを待ち、値は届かない。明示のプロパティ形 `.once:` を提案する(@wcstack/state 3.1・要件 B5 / 3.x 計画 D36)
212
217
  OnPrefixedMember: "wcs/on-prefixed-member",
@@ -3420,7 +3425,7 @@ function readBase(expr, scan, aliases, paths) {
3420
3425
  if (alias === null) return null;
3421
3426
  if (alias[1] !== "this") {
3422
3427
  const shape = aliases.get(alias[1]);
3423
- return shape === void 0 ? null : { shape, rest: alias[1].length };
3428
+ return { shape: shape ?? OPAQUE, rest: alias[1].length };
3424
3429
  }
3425
3430
  const segments = [];
3426
3431
  let i = 4;
@@ -3445,6 +3450,7 @@ function readBase(expr, scan, aliases, paths) {
3445
3450
  break;
3446
3451
  }
3447
3452
  const path = segments.join(".");
3453
+ if (path === "" && /^\s*\??\.\s*\$[$\w]*\s*\(/.test(scan.slice(4))) return { shape: OPAQUE, rest: 4 };
3448
3454
  if (path === "" || path.startsWith("$")) return null;
3449
3455
  return {
3450
3456
  shape: { isList: hasPath(paths, `${path}.*`), mirrors: [{ from: path, to: "" }], fields: [] },
@@ -3455,12 +3461,25 @@ function applyChain(expr, scan, start, initial) {
3455
3461
  let shape = initial;
3456
3462
  let i = start;
3457
3463
  while (scan.slice(i).trim() !== "") {
3464
+ if (shape.opaque && /^\s*\(/.test(scan.slice(i))) {
3465
+ const open2 = scan.indexOf("(", i);
3466
+ i = open2 + extractDelimitedContent(expr, scan, open2, "(", ")").length + 2;
3467
+ continue;
3468
+ }
3458
3469
  const call = /^\s*\??\.\s*([$\w]+)\s*\(/.exec(scan.slice(i));
3459
3470
  if (call === null) return null;
3460
3471
  const open = i + call[0].length - 1;
3461
3472
  const args = extractDelimitedContent(expr, scan, open, "(", ")");
3462
3473
  i = open + args.length + 2;
3463
3474
  const method = call[1];
3475
+ if (shape.opaque) {
3476
+ if (method === "map") {
3477
+ const mapped = mapRows(args, shape);
3478
+ if (mapped === null) return null;
3479
+ shape = mapped;
3480
+ }
3481
+ continue;
3482
+ }
3464
3483
  if (ROW_PRESERVING_METHODS.has(method)) {
3465
3484
  if (!shape.isList) return null;
3466
3485
  } else if (ROW_PICKING_METHODS.has(method)) {
@@ -3475,8 +3494,9 @@ function applyChain(expr, scan, start, initial) {
3475
3494
  return null;
3476
3495
  }
3477
3496
  }
3478
- return shape;
3497
+ return shape.opaque ? null : shape;
3479
3498
  }
3499
+ var OPAQUE = { isList: true, mirrors: [], fields: [], opaque: true };
3480
3500
  function pickRow(shape) {
3481
3501
  return {
3482
3502
  isList: false,
@@ -3487,7 +3507,7 @@ function pickRow(shape) {
3487
3507
  function mapRows(args, shape) {
3488
3508
  const [callback] = splitTopLevelElements(args);
3489
3509
  if (callback === void 0) return null;
3490
- const head = /^(?:async\s+)?(?:function\b[^(]*\(\s*([$\w]+)[^)]*\)|\(\s*([$\w]+)[^)]*\)|([$\w]+))\s*(=>)?\s*/.exec(callback);
3510
+ const head = /^(?:async\s+)?(?:function\b[^(]*\(\s*([$\w]+)?[^)]*\)|\(\s*([$\w]+)?[^)]*\)|([$\w]+))\s*(=>)?\s*/.exec(callback);
3491
3511
  if (head === null) return null;
3492
3512
  const param = head[1] ?? head[2] ?? head[3];
3493
3513
  const body = callback.slice(head[0].length);
@@ -10975,6 +10995,7 @@ var ja = {
10975
10995
  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`,
10976
10996
  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`,
10977
10997
  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`,
10998
+ handleBoundAsValue: (name, tag) => `<${tag}> \u306E "${name}" \u306F\u751F\u304D\u305F\u30EA\u30BD\u30FC\u30B9\uFF08\u30CF\u30F3\u30C9\u30EB\uFF09\u3067\u3001\u5024\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002state \u306E\u30D1\u30B9\u306B\u675F\u306D\u308B\u3068\u3001\u30B9\u30CA\u30C3\u30D7\u30B7\u30E7\u30C3\u30C8\u3084 SSR \u306B\u8F09\u3089\u306A\u3044\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u304C state \u306B\u5165\u308A\u307E\u3059 \u2014 eventToken.${name}: \u3067\u53D7\u3051\u3001\u30B3\u30DE\u30F3\u30C9\u306E\u5F15\u6570\u3068\u3057\u3066\u6B21\u306E\u8981\u7D20\u3078\u76F4\u63A5\u6E21\u3057\u3066\u304F\u3060\u3055\u3044`,
10978
10999
  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`,
10979
11000
  didYouMean: (c) => `\u3002\u3082\u3057\u304B\u3057\u3066: "${c}"`,
10980
11001
  none: () => `\u306A\u3057`,
@@ -11183,6 +11204,7 @@ var en = {
11183
11204
  nativeCommandUnknown: (method, tag, allowed) => `"${method}" is not a command of a native <${tag}> (its commands: ${allowed}; the runtime throws wcs/token-misconfigured at initialization)`,
11184
11205
  spreadNoBindable: (tag) => `'...' (spread) requires <${tag}> to expose a valid wcBindable declaration \u2014 this tag declares none, so the runtime raises an error`,
11185
11206
  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})`,
11207
+ handleBoundAsValue: (name, tag) => `"${name}" of <${tag}> is a live resource (a handle), not a value. Bound to a state path, it puts an object no snapshot or SSR can carry into the state \u2014 receive it with eventToken.${name}: and hand it to the next element as a command argument`,
11186
11208
  ariaAttrUnknown: (name) => `"${name}" is not a WAI-ARIA attribute. setAttribute writes it anyway, and assistive technology silently ignores it`,
11187
11209
  didYouMean: (c) => `. Did you mean "${c}"?`,
11188
11210
  none: () => `none`,
@@ -13299,6 +13321,9 @@ var BUILTIN_TAGS = {
13299
13321
  "start",
13300
13322
  "stop",
13301
13323
  "switchCamera"
13324
+ ],
13325
+ "handles": [
13326
+ "streamReady"
13302
13327
  ]
13303
13328
  },
13304
13329
  "wcs-recorder": {
@@ -14540,6 +14565,18 @@ function validateBindingAgainstContract(tagName, contract, parsed, property, sta
14540
14565
  });
14541
14566
  return;
14542
14567
  }
14568
+ if (contract.handles?.includes(property)) {
14569
+ diagnostics.push({
14570
+ code: WcsDiagnosticCode.HandleBoundAsValue,
14571
+ start,
14572
+ end,
14573
+ severity: "warning",
14574
+ tag: tagName,
14575
+ member: property,
14576
+ message: msgs.handleBoundAsValue(property, tagName)
14577
+ });
14578
+ return;
14579
+ }
14543
14580
  if (tagName.startsWith("wcs-") && property === "trigger" && "trigger" in contract.inputs && parsed.path) {
14544
14581
  const cand = findDataSlot(getPaths(), parsed.path);
14545
14582
  if (cand?.rawInitial === "true") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/lint",
3
- "version": "4.4.0",
3
+ "version": "4.5.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": {