@wcstack/lint 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +3 -2
- package/README.md +3 -2
- package/dist/cli.cjs +716 -155
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -56,31 +56,6 @@ function createFileReader(htmlPath, read = (p) => (0, import_node_fs.readFileSyn
|
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
// src/core/offsetToPosition.ts
|
|
60
|
-
function createPositionMapper(text3) {
|
|
61
|
-
const lineStarts = [0];
|
|
62
|
-
for (let i = 0; i < text3.length; i++) {
|
|
63
|
-
const c = text3.charCodeAt(i);
|
|
64
|
-
if (c === 10) {
|
|
65
|
-
lineStarts.push(i + 1);
|
|
66
|
-
} else if (c === 13) {
|
|
67
|
-
if (text3.charCodeAt(i + 1) === 10) i++;
|
|
68
|
-
lineStarts.push(i + 1);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return (offset2) => {
|
|
72
|
-
const clamped = Math.max(0, Math.min(offset2, text3.length));
|
|
73
|
-
let lo = 0;
|
|
74
|
-
let hi = lineStarts.length - 1;
|
|
75
|
-
while (lo < hi) {
|
|
76
|
-
const mid = lo + hi + 1 >> 1;
|
|
77
|
-
if (lineStarts[mid] <= clamped) lo = mid;
|
|
78
|
-
else hi = mid - 1;
|
|
79
|
-
}
|
|
80
|
-
return { line: lo + 1, column: clamped - lineStarts[lo] + 1 };
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
59
|
// src/core/diagnostics.ts
|
|
85
60
|
var WcsDiagnosticCode = {
|
|
86
61
|
// --- sidecar manifest envelope / schema subset ---
|
|
@@ -107,8 +82,12 @@ var WcsDiagnosticCode = {
|
|
|
107
82
|
// --- path / type resolution against a stateSchema ---
|
|
108
83
|
PathNonexistent: "wcs/path-nonexistent",
|
|
109
84
|
PathTypeMismatch: "wcs/path-type-mismatch",
|
|
85
|
+
// 書き戻す束縛(`value:` / `checked:` / `radio:` / `checkbox:`、`#ro` なし)が、setter の無い getter を指す。ランタイムは
|
|
86
|
+
// 入力のたびに `"<path>" is a getter without a setter` を投げる(code なし — 7GUIs の評価の Temperature)。error。
|
|
110
87
|
PathReadonly: "wcs/path-readonly",
|
|
111
88
|
PathReservedName: "wcs/path-reserved-name",
|
|
89
|
+
// lint の限界の告知(作者の誤りではない): `export default { … }` のトップレベルの spread が持ち込むキーは読めないので、
|
|
90
|
+
// stateSchema の無い state のパスは検査しない — それを spread の上で 1 回だけ言う。info。
|
|
112
91
|
PathDynamicUnknown: "wcs/path-dynamic-unknown",
|
|
113
92
|
// --- existing binding-expression validators (retrofitted) ---
|
|
114
93
|
FilterUnknown: "wcs/filter-unknown",
|
|
@@ -119,6 +98,17 @@ var WcsDiagnosticCode = {
|
|
|
119
98
|
BindingTypeExpectation: "wcs/binding-type-expectation",
|
|
120
99
|
TokenUndeclared: "wcs/token-undeclared",
|
|
121
100
|
TokenMisconfigured: "wcs/token-misconfigured",
|
|
101
|
+
// 宣言したコマンドトークンを emit する(スクリプトの `.emit()`・マークアップの `on*: $command.x`)のに、どの
|
|
102
|
+
// `command.<method>:` 束縛にも結ばれていない。emit は誰にも届かず、ランタイムは何も言わない(7GUIs の評価)。warning
|
|
103
|
+
// (ページの外 — 別ファイルのルートのテンプレート — で束ねる形は見えない)。
|
|
104
|
+
CommandTokenUnbound: "wcs/command-token-unbound",
|
|
105
|
+
// state が宣言していないトップレベルのキーへの書き込み(`this.selectedID = …` と `selectedId`)。新しいキーができる
|
|
106
|
+
// だけで、宣言したキーの束縛は変わらない。ランタイムは何も言わない。近い名前(打ち間違い)があるときだけ、warning。
|
|
107
|
+
WritePathMissing: "wcs/write-path-missing",
|
|
108
|
+
// getter・メソッドの中で読む state のパス(`this["items.*.amout"]`・`$getAll("items.*.amout")`・`this.totl`)が宣言に無い。
|
|
109
|
+
// 入れ子のパスの読みは undefined になり、そこから計算した金額が黙って違う(確定申告の下書きツールの評価)。トップレベルの
|
|
110
|
+
// キーは読んだ時点で throw する。近い名前(打ち間違い)があるときだけ、warning。ランタイムの diagnostics も同じ code。
|
|
111
|
+
ReadPathMissing: "wcs/read-path-missing",
|
|
122
112
|
NestedAssign: "wcs/nested-assign",
|
|
123
113
|
// --- 意味論(構文・存在検査では捕まらない取り違え。service/semanticValidator.ts) ---
|
|
124
114
|
// `$getAll` / `$setAll` / `$resolve` の添字の本数がパスの `*` の本数と噛み合わない。
|
|
@@ -326,6 +316,31 @@ function sortDiagnostics(diagnostics) {
|
|
|
326
316
|
return [...diagnostics].sort((a, b) => a.start - b.start || severityRank[a.severity] - severityRank[b.severity] || (a.code < b.code ? -1 : a.code > b.code ? 1 : 0));
|
|
327
317
|
}
|
|
328
318
|
|
|
319
|
+
// src/core/offsetToPosition.ts
|
|
320
|
+
function createPositionMapper(text3) {
|
|
321
|
+
const lineStarts = [0];
|
|
322
|
+
for (let i = 0; i < text3.length; i++) {
|
|
323
|
+
const c = text3.charCodeAt(i);
|
|
324
|
+
if (c === 10) {
|
|
325
|
+
lineStarts.push(i + 1);
|
|
326
|
+
} else if (c === 13) {
|
|
327
|
+
if (text3.charCodeAt(i + 1) === 10) i++;
|
|
328
|
+
lineStarts.push(i + 1);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return (offset2) => {
|
|
332
|
+
const clamped = Math.max(0, Math.min(offset2, text3.length));
|
|
333
|
+
let lo = 0;
|
|
334
|
+
let hi = lineStarts.length - 1;
|
|
335
|
+
while (lo < hi) {
|
|
336
|
+
const mid = lo + hi + 1 >> 1;
|
|
337
|
+
if (lineStarts[mid] <= clamped) lo = mid;
|
|
338
|
+
else hi = mid - 1;
|
|
339
|
+
}
|
|
340
|
+
return { line: lo + 1, column: clamped - lineStarts[lo] + 1 };
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
329
344
|
// ../state/dist/parser.esm.js
|
|
330
345
|
var hooks = {};
|
|
331
346
|
function editDistance(a, b, max) {
|
|
@@ -585,8 +600,8 @@ function checkPathLikeGetPathInfo(path) {
|
|
|
585
600
|
function recursionUnsupported(path) {
|
|
586
601
|
raise(1101, [path]);
|
|
587
602
|
}
|
|
588
|
-
function parseStatePart(
|
|
589
|
-
const [stateAndPath, filters] = splitFilters(
|
|
603
|
+
function parseStatePart(statePart2) {
|
|
604
|
+
const [stateAndPath, filters] = splitFilters(statePart2, "output", cacheFilterInfos);
|
|
590
605
|
if (stateAndPath.includes("@")) {
|
|
591
606
|
raise(32, [stateAndPath]);
|
|
592
607
|
}
|
|
@@ -595,7 +610,7 @@ function parseStatePart(statePart) {
|
|
|
595
610
|
const body = isLoopRelative ? statePathName.slice(DELIMITER.length) : statePathName;
|
|
596
611
|
const hasEmptySegment = body.length > 0 && body.split(DELIMITER).some((segment) => segment.length === 0);
|
|
597
612
|
if (hasEmptySegment || !isLoopRelative && body.length === 0) {
|
|
598
|
-
raise(119, [
|
|
613
|
+
raise(119, [statePart2]);
|
|
599
614
|
}
|
|
600
615
|
checkPathLikeGetPathInfo(statePathName);
|
|
601
616
|
return {
|
|
@@ -1157,7 +1172,7 @@ function parseBindTextsForElement(bindText) {
|
|
|
1157
1172
|
raise(101, [bindText2]);
|
|
1158
1173
|
}
|
|
1159
1174
|
const propPart = bindText2.slice(0, separatorIndex).trim();
|
|
1160
|
-
const
|
|
1175
|
+
const statePart2 = bindText2.slice(separatorIndex + 1).trim();
|
|
1161
1176
|
const keyword = propPart.split(MODIFIER_SEPARATOR)[0].split(FILTER_SEPARATOR)[0].trim();
|
|
1162
1177
|
if (KEYWORDS_WITHOUT_MODIFIERS.has(keyword)) {
|
|
1163
1178
|
if (keyword !== propPart) {
|
|
@@ -1165,20 +1180,20 @@ function parseBindTextsForElement(bindText) {
|
|
|
1165
1180
|
}
|
|
1166
1181
|
let stateResult2;
|
|
1167
1182
|
if (keyword === ELSE_KEYWORD) {
|
|
1168
|
-
if (
|
|
1183
|
+
if (statePart2.length > 0) {
|
|
1169
1184
|
raise(103, [bindText2]);
|
|
1170
1185
|
}
|
|
1171
1186
|
stateResult2 = { statePathName: "#else", outFilters: [] };
|
|
1172
1187
|
} else if (keyword === SPREAD_PROP) {
|
|
1173
|
-
if (
|
|
1188
|
+
if (statePart2.length === 0) {
|
|
1174
1189
|
raise(104, [bindText2]);
|
|
1175
1190
|
}
|
|
1176
|
-
stateResult2 = parseStatePart(
|
|
1191
|
+
stateResult2 = parseStatePart(statePart2);
|
|
1177
1192
|
if (stateResult2.outFilters.length > 0) {
|
|
1178
1193
|
raise(105, [bindText2]);
|
|
1179
1194
|
}
|
|
1180
1195
|
} else {
|
|
1181
|
-
stateResult2 = parseStatePart(
|
|
1196
|
+
stateResult2 = parseStatePart(statePart2);
|
|
1182
1197
|
if (keyword === "for" && stateResult2.outFilters.length > 0) {
|
|
1183
1198
|
raise(121, [bindText2]);
|
|
1184
1199
|
}
|
|
@@ -1195,7 +1210,7 @@ function parseBindTextsForElement(bindText) {
|
|
|
1195
1210
|
if (keyword === CLASS_NAMESPACE || keyword === ATTR_NAMESPACE) {
|
|
1196
1211
|
raise(122, [bindText2, keyword]);
|
|
1197
1212
|
}
|
|
1198
|
-
const stateResult = parseStatePart(
|
|
1213
|
+
const stateResult = parseStatePart(statePart2);
|
|
1199
1214
|
const propResult = parsePropPart(propPart);
|
|
1200
1215
|
const [head] = propResult.propSegments;
|
|
1201
1216
|
if (head === "" && propResult.propSegments.length > 1) {
|
|
@@ -1441,6 +1456,9 @@ function parseWcsStateElements(html, stateTagName = "wcs-state") {
|
|
|
1441
1456
|
const jsonAttr = extractAttribute(wcsMatch.tagContent, "json") ?? void 0;
|
|
1442
1457
|
const stateAttr = extractAttribute(wcsMatch.tagContent, "state") ?? void 0;
|
|
1443
1458
|
const srcAttr = extractAttribute(wcsMatch.tagContent, "src") ?? void 0;
|
|
1459
|
+
const contentAt = pos + 1 + stateTagName.length;
|
|
1460
|
+
const srcSpan = extractAttributeSpan(wcsMatch.tagContent, "src", contentAt);
|
|
1461
|
+
const jsonSpan = extractAttributeSpan(wcsMatch.tagContent, "json", contentAt);
|
|
1444
1462
|
const tagStart = pos;
|
|
1445
1463
|
const tagEnd = wcsMatch.end;
|
|
1446
1464
|
pos = wcsMatch.end;
|
|
@@ -1484,7 +1502,18 @@ function parseWcsStateElements(html, stateTagName = "wcs-state") {
|
|
|
1484
1502
|
wcsEnd = wcsCloseIdx === -1 ? len : wcsCloseIdx;
|
|
1485
1503
|
}
|
|
1486
1504
|
}
|
|
1487
|
-
elements.push({
|
|
1505
|
+
elements.push({
|
|
1506
|
+
mountPath,
|
|
1507
|
+
bindComponent,
|
|
1508
|
+
jsonAttr,
|
|
1509
|
+
stateAttr,
|
|
1510
|
+
srcAttr,
|
|
1511
|
+
scriptBlocks,
|
|
1512
|
+
tagStart,
|
|
1513
|
+
tagEnd,
|
|
1514
|
+
...srcSpan !== null ? { srcSpan } : {},
|
|
1515
|
+
...jsonSpan !== null ? { jsonSpan } : {}
|
|
1516
|
+
});
|
|
1488
1517
|
pos = wcsEnd;
|
|
1489
1518
|
if (wcsCloseIdx !== -1) pos = afterCloseTag(html, wcsCloseIdx);
|
|
1490
1519
|
}
|
|
@@ -1619,13 +1648,13 @@ function findCloseTag(html, startPos, tagName, lower2 = asciiLowerCase(html)) {
|
|
|
1619
1648
|
return -1;
|
|
1620
1649
|
}
|
|
1621
1650
|
function parseAttributeNames(tagContent) {
|
|
1622
|
-
const
|
|
1651
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
1623
1652
|
const attribute = /([^\s"'<>/=]+)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'<>`=]+))?/g;
|
|
1624
1653
|
let match;
|
|
1625
1654
|
while ((match = attribute.exec(tagContent)) !== null) {
|
|
1626
|
-
|
|
1655
|
+
names2.add(match[1].toLowerCase());
|
|
1627
1656
|
}
|
|
1628
|
-
return
|
|
1657
|
+
return names2;
|
|
1629
1658
|
}
|
|
1630
1659
|
function extractAttribute(tagContent, attrName) {
|
|
1631
1660
|
const regex = new RegExp(
|
|
@@ -1636,6 +1665,16 @@ function extractAttribute(tagContent, attrName) {
|
|
|
1636
1665
|
if (!match) return null;
|
|
1637
1666
|
return match[1] ?? match[2] ?? match[3] ?? null;
|
|
1638
1667
|
}
|
|
1668
|
+
function extractAttributeSpan(tagContent, attrName, at2) {
|
|
1669
|
+
const regex = new RegExp(`(^|\\s)${attrName}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|(\\S+))`, "i");
|
|
1670
|
+
const match = regex.exec(tagContent);
|
|
1671
|
+
if (match === null) return null;
|
|
1672
|
+
const start = at2 + match.index + match[1].length;
|
|
1673
|
+
const end = at2 + match.index + match[0].length;
|
|
1674
|
+
const value = match[2] ?? match[3] ?? match[4] ?? "";
|
|
1675
|
+
const valueEnd = match[4] === void 0 ? end - 1 : end;
|
|
1676
|
+
return { start, end, valueStart: valueEnd - value.length, valueEnd };
|
|
1677
|
+
}
|
|
1639
1678
|
var IGNORE_VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
1640
1679
|
"area",
|
|
1641
1680
|
"base",
|
|
@@ -2990,17 +3029,25 @@ function hasDefaultExportObject(scriptContent) {
|
|
|
2990
3029
|
return locateDefaultExportObject(scriptContent) !== null;
|
|
2991
3030
|
}
|
|
2992
3031
|
function hasTopLevelSpread(scriptContent) {
|
|
3032
|
+
return findTopLevelSpread(scriptContent) !== null;
|
|
3033
|
+
}
|
|
3034
|
+
function findTopLevelSpread(scriptContent) {
|
|
2993
3035
|
const root = locateDefaultExportObject(scriptContent);
|
|
2994
|
-
if (!root) return
|
|
3036
|
+
if (!root) return null;
|
|
2995
3037
|
const scan = maskCommentsAndStrings(root.content);
|
|
2996
3038
|
let depth = 0;
|
|
3039
|
+
let start = -1;
|
|
2997
3040
|
for (let i = 0; i < scan.length; i++) {
|
|
2998
3041
|
const ch = scan[i];
|
|
2999
3042
|
if (ch === "(" || ch === "[" || ch === "{") depth++;
|
|
3000
3043
|
else if (ch === ")" || ch === "]" || ch === "}") depth--;
|
|
3001
|
-
else if (depth === 0 && ch === "." && scan.startsWith("...", i))
|
|
3044
|
+
else if (depth === 0 && start < 0 && ch === "." && scan.startsWith("...", i)) start = i;
|
|
3045
|
+
else if (depth === 0 && start >= 0 && ch === ",") return spreadRange(root.start, scan, start, i);
|
|
3002
3046
|
}
|
|
3003
|
-
return
|
|
3047
|
+
return start < 0 ? null : spreadRange(root.start, scan, start, scan.length);
|
|
3048
|
+
}
|
|
3049
|
+
function spreadRange(base, scan, start, stop) {
|
|
3050
|
+
return { start: base + start, end: base + start + scan.slice(start, stop).trimEnd().length };
|
|
3004
3051
|
}
|
|
3005
3052
|
function analyzeObjectEntries(scriptContent, key, allowEmptyKeys = false) {
|
|
3006
3053
|
const root = locateDefaultExportObject(scriptContent);
|
|
@@ -3954,9 +4001,9 @@ function derefSchemaNodes(node, defs) {
|
|
|
3954
4001
|
}
|
|
3955
4002
|
return out;
|
|
3956
4003
|
}
|
|
3957
|
-
function schemaTypeHint(
|
|
4004
|
+
function schemaTypeHint(nodes2) {
|
|
3958
4005
|
const hints = /* @__PURE__ */ new Set();
|
|
3959
|
-
for (const n of
|
|
4006
|
+
for (const n of nodes2) {
|
|
3960
4007
|
const types2 = typeof n.type === "string" ? [n.type] : Array.isArray(n.type) ? n.type : [];
|
|
3961
4008
|
if (types2.length > 0) {
|
|
3962
4009
|
for (const t of types2) {
|
|
@@ -3995,10 +4042,10 @@ function collectSchemaObjectPaths(node, prefix, paths, defs, depth) {
|
|
|
3995
4042
|
}
|
|
3996
4043
|
}
|
|
3997
4044
|
function pushSchemaValuePaths(path, node, paths, defs, depth) {
|
|
3998
|
-
const
|
|
3999
|
-
const typeHint = schemaTypeHint(
|
|
4045
|
+
const nodes2 = derefSchemaNodes(node, defs);
|
|
4046
|
+
const typeHint = schemaTypeHint(nodes2);
|
|
4000
4047
|
paths.push(withHint({ path, kind: "data", fromSchema: true }, typeHint));
|
|
4001
|
-
const items =
|
|
4048
|
+
const items = nodes2.map((n) => n.items).find((i) => i !== void 0 && i !== null && typeof i === "object");
|
|
4002
4049
|
const isArray2 = items !== void 0 || (typeHint?.split("|").includes("array") ?? false);
|
|
4003
4050
|
if (isArray2) {
|
|
4004
4051
|
const itemNodes = items !== void 0 ? derefSchemaNodes(items, defs) : [];
|
|
@@ -4015,7 +4062,7 @@ function pushSchemaValuePaths(path, node, paths, defs, depth) {
|
|
|
4015
4062
|
}
|
|
4016
4063
|
return;
|
|
4017
4064
|
}
|
|
4018
|
-
if (
|
|
4065
|
+
if (nodes2.some((n) => n.properties !== void 0)) {
|
|
4019
4066
|
collectSchemaObjectPaths(node, path, paths, defs, depth + 1);
|
|
4020
4067
|
}
|
|
4021
4068
|
}
|
|
@@ -4114,9 +4161,12 @@ function fromJson(text3) {
|
|
|
4114
4161
|
const paths = analyzeJsonPaths(text3);
|
|
4115
4162
|
return { paths, readable: paths.length > 0 || isJsonObject(text3) };
|
|
4116
4163
|
}
|
|
4164
|
+
function scriptReadable(script, paths) {
|
|
4165
|
+
return !hasTopLevelSpread(script) && (paths.length > 0 || hasDefaultExportObject(script));
|
|
4166
|
+
}
|
|
4117
4167
|
function fromScript(script) {
|
|
4118
4168
|
const paths = analyzeStatePaths(script);
|
|
4119
|
-
return { paths, readable:
|
|
4169
|
+
return { paths, readable: scriptReadable(script, paths) };
|
|
4120
4170
|
}
|
|
4121
4171
|
function resolveElementPathsRaw(element2, html, fileReader) {
|
|
4122
4172
|
let readable = false;
|
|
@@ -4139,19 +4189,23 @@ function resolveElementPathsRaw(element2, html, fileReader) {
|
|
|
4139
4189
|
readable ||= resolved.readable;
|
|
4140
4190
|
}
|
|
4141
4191
|
if (element2.scriptBlocks.length > 0) {
|
|
4142
|
-
const
|
|
4192
|
+
const blocks = element2.scriptBlocks.map((block) => ({ script: block.content, paths: analyzeStatePaths(block.content) }));
|
|
4143
4193
|
return {
|
|
4144
|
-
paths,
|
|
4145
|
-
readable:
|
|
4194
|
+
paths: blocks.flatMap((block) => block.paths),
|
|
4195
|
+
readable: readable || blocks.some((block) => scriptReadable(block.script, block.paths))
|
|
4146
4196
|
};
|
|
4147
4197
|
}
|
|
4148
4198
|
return readable ? { paths: [], readable } : UNREADABLE;
|
|
4149
4199
|
}
|
|
4150
4200
|
function readStateScript(srcPath, fileReader) {
|
|
4151
|
-
|
|
4152
|
-
|
|
4201
|
+
return readStateScriptFile(srcPath, fileReader)?.text;
|
|
4202
|
+
}
|
|
4203
|
+
function readStateScriptFile(srcPath, fileReader) {
|
|
4204
|
+
const paths = srcPath.endsWith(".js") ? [srcPath.replace(/\.js$/, ".ts"), srcPath] : srcPath.endsWith(".ts") ? [srcPath] : [];
|
|
4205
|
+
for (const path of paths) {
|
|
4206
|
+
const text3 = fileReader(path);
|
|
4207
|
+
if (text3) return { path, text: text3 };
|
|
4153
4208
|
}
|
|
4154
|
-
if (srcPath.endsWith(".ts")) return fileReader(srcPath) || void 0;
|
|
4155
4209
|
return void 0;
|
|
4156
4210
|
}
|
|
4157
4211
|
function resolveSrcAttribute(srcPath, fileReader) {
|
|
@@ -4184,10 +4238,6 @@ function isInsideForTemplate(html, offset2, bindAttrName = "data-wcs") {
|
|
|
4184
4238
|
}
|
|
4185
4239
|
return false;
|
|
4186
4240
|
}
|
|
4187
|
-
function getInnermostForPath(html, offset2, bindAttrName = "data-wcs") {
|
|
4188
|
-
const chain = getEnclosingForPaths(html, offset2, bindAttrName);
|
|
4189
|
-
return chain.length === 0 ? null : chain[chain.length - 1];
|
|
4190
|
-
}
|
|
4191
4241
|
var BINDING_SYNTAX_MARKER = `[${WcsDiagnosticCode.BindingSyntax}]`;
|
|
4192
4242
|
function isForBindingRefused(bindText) {
|
|
4193
4243
|
try {
|
|
@@ -4433,10 +4483,10 @@ function analyzeElementContexts(html, offsets, bindAttrName = "data-wcs", stateT
|
|
|
4433
4483
|
}
|
|
4434
4484
|
const match3 = bindAttr.exec(attrs);
|
|
4435
4485
|
const value = match3 === null ? null : match3[1] ?? match3[2] ?? match3[3];
|
|
4436
|
-
const
|
|
4437
|
-
const structural = name === "template" &&
|
|
4486
|
+
const names2 = value === null ? [] : propertyNamesOf(value);
|
|
4487
|
+
const structural = name === "template" && names2.length === 1 && STRUCTURAL_DIRECTIVES2.has(names2[0]) && !value.slice(0, Math.max(0, indexOfOutsideQuotes2(value, ":"))).includes("#");
|
|
4438
4488
|
const plainTemplate = name === "template" && !structural;
|
|
4439
|
-
const blocks = plainTemplate && stack.some((e) => e.name === "template") || name !== "template" &&
|
|
4489
|
+
const blocks = plainTemplate && stack.some((e) => e.name === "template") || name !== "template" && names2.some((n) => CONTENT_PROPERTIES.has(n));
|
|
4440
4490
|
const scope = plainTemplate ? { hasOwnState: false, id: extractAttribute(attrs, "id"), underRouter: stack.some((e) => e.name === ROUTER_TAG) } : null;
|
|
4441
4491
|
stack.push({ name, structural, scope, blocks });
|
|
4442
4492
|
}
|
|
@@ -5893,7 +5943,7 @@ pp$8.parseClassElement = function(constructorAllowsSuper) {
|
|
|
5893
5943
|
}
|
|
5894
5944
|
var ecmaVersion = this.options.ecmaVersion;
|
|
5895
5945
|
var node = this.startNode();
|
|
5896
|
-
var
|
|
5946
|
+
var keyName2 = "";
|
|
5897
5947
|
var isGenerator = false;
|
|
5898
5948
|
var isAsync = false;
|
|
5899
5949
|
var kind = "method";
|
|
@@ -5906,34 +5956,34 @@ pp$8.parseClassElement = function(constructorAllowsSuper) {
|
|
|
5906
5956
|
if (this.isClassElementNameStart() || this.type === types$1.star) {
|
|
5907
5957
|
isStatic = true;
|
|
5908
5958
|
} else {
|
|
5909
|
-
|
|
5959
|
+
keyName2 = "static";
|
|
5910
5960
|
}
|
|
5911
5961
|
}
|
|
5912
5962
|
node.static = isStatic;
|
|
5913
|
-
if (!
|
|
5963
|
+
if (!keyName2 && ecmaVersion >= 8 && this.eatContextual("async")) {
|
|
5914
5964
|
if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) {
|
|
5915
5965
|
isAsync = true;
|
|
5916
5966
|
} else {
|
|
5917
|
-
|
|
5967
|
+
keyName2 = "async";
|
|
5918
5968
|
}
|
|
5919
5969
|
}
|
|
5920
|
-
if (!
|
|
5970
|
+
if (!keyName2 && (ecmaVersion >= 9 || !isAsync) && this.eat(types$1.star)) {
|
|
5921
5971
|
isGenerator = true;
|
|
5922
5972
|
}
|
|
5923
|
-
if (!
|
|
5973
|
+
if (!keyName2 && !isAsync && !isGenerator) {
|
|
5924
5974
|
var lastValue = this.value;
|
|
5925
5975
|
if (this.eatContextual("get") || this.eatContextual("set")) {
|
|
5926
5976
|
if (this.isClassElementNameStart()) {
|
|
5927
5977
|
kind = lastValue;
|
|
5928
5978
|
} else {
|
|
5929
|
-
|
|
5979
|
+
keyName2 = lastValue;
|
|
5930
5980
|
}
|
|
5931
5981
|
}
|
|
5932
5982
|
}
|
|
5933
|
-
if (
|
|
5983
|
+
if (keyName2) {
|
|
5934
5984
|
node.computed = false;
|
|
5935
5985
|
node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc);
|
|
5936
|
-
node.key.name =
|
|
5986
|
+
node.key.name = keyName2;
|
|
5937
5987
|
this.finishNode(node.key, "Identifier");
|
|
5938
5988
|
} else {
|
|
5939
5989
|
this.parseClassElementName(node);
|
|
@@ -6234,7 +6284,7 @@ pp$8.parseExportSpecifier = function(exports$1) {
|
|
|
6234
6284
|
return this.finishNode(node, "ExportSpecifier");
|
|
6235
6285
|
};
|
|
6236
6286
|
pp$8.parseExportSpecifiers = function(exports$1) {
|
|
6237
|
-
var
|
|
6287
|
+
var nodes2 = [], first = true;
|
|
6238
6288
|
this.expect(types$1.braceL);
|
|
6239
6289
|
while (!this.eat(types$1.braceR)) {
|
|
6240
6290
|
if (!first) {
|
|
@@ -6245,9 +6295,9 @@ pp$8.parseExportSpecifiers = function(exports$1) {
|
|
|
6245
6295
|
} else {
|
|
6246
6296
|
first = false;
|
|
6247
6297
|
}
|
|
6248
|
-
|
|
6298
|
+
nodes2.push(this.parseExportSpecifier(exports$1));
|
|
6249
6299
|
}
|
|
6250
|
-
return
|
|
6300
|
+
return nodes2;
|
|
6251
6301
|
};
|
|
6252
6302
|
pp$8.parseImport = function(node) {
|
|
6253
6303
|
this.next();
|
|
@@ -6292,16 +6342,16 @@ pp$8.parseImportNamespaceSpecifier = function() {
|
|
|
6292
6342
|
return this.finishNode(node, "ImportNamespaceSpecifier");
|
|
6293
6343
|
};
|
|
6294
6344
|
pp$8.parseImportSpecifiers = function() {
|
|
6295
|
-
var
|
|
6345
|
+
var nodes2 = [], first = true;
|
|
6296
6346
|
if (this.type === types$1.name) {
|
|
6297
|
-
|
|
6347
|
+
nodes2.push(this.parseImportDefaultSpecifier());
|
|
6298
6348
|
if (!this.eat(types$1.comma)) {
|
|
6299
|
-
return
|
|
6349
|
+
return nodes2;
|
|
6300
6350
|
}
|
|
6301
6351
|
}
|
|
6302
6352
|
if (this.type === types$1.star) {
|
|
6303
|
-
|
|
6304
|
-
return
|
|
6353
|
+
nodes2.push(this.parseImportNamespaceSpecifier());
|
|
6354
|
+
return nodes2;
|
|
6305
6355
|
}
|
|
6306
6356
|
this.expect(types$1.braceL);
|
|
6307
6357
|
while (!this.eat(types$1.braceR)) {
|
|
@@ -6313,14 +6363,14 @@ pp$8.parseImportSpecifiers = function() {
|
|
|
6313
6363
|
} else {
|
|
6314
6364
|
first = false;
|
|
6315
6365
|
}
|
|
6316
|
-
|
|
6366
|
+
nodes2.push(this.parseImportSpecifier());
|
|
6317
6367
|
}
|
|
6318
|
-
return
|
|
6368
|
+
return nodes2;
|
|
6319
6369
|
};
|
|
6320
6370
|
pp$8.parseWithClause = function() {
|
|
6321
|
-
var
|
|
6371
|
+
var nodes2 = [];
|
|
6322
6372
|
if (!this.eat(types$1._with)) {
|
|
6323
|
-
return
|
|
6373
|
+
return nodes2;
|
|
6324
6374
|
}
|
|
6325
6375
|
this.expect(types$1.braceL);
|
|
6326
6376
|
var attributeKeys = {};
|
|
@@ -6335,14 +6385,14 @@ pp$8.parseWithClause = function() {
|
|
|
6335
6385
|
first = false;
|
|
6336
6386
|
}
|
|
6337
6387
|
var attr = this.parseImportAttribute();
|
|
6338
|
-
var
|
|
6339
|
-
if (hasOwn(attributeKeys,
|
|
6340
|
-
this.raiseRecoverable(attr.key.start, "Duplicate attribute key '" +
|
|
6388
|
+
var keyName2 = attr.key.type === "Identifier" ? attr.key.name : attr.key.value;
|
|
6389
|
+
if (hasOwn(attributeKeys, keyName2)) {
|
|
6390
|
+
this.raiseRecoverable(attr.key.start, "Duplicate attribute key '" + keyName2 + "'");
|
|
6341
6391
|
}
|
|
6342
|
-
attributeKeys[
|
|
6343
|
-
|
|
6392
|
+
attributeKeys[keyName2] = true;
|
|
6393
|
+
nodes2.push(attr);
|
|
6344
6394
|
}
|
|
6345
|
-
return
|
|
6395
|
+
return nodes2;
|
|
6346
6396
|
};
|
|
6347
6397
|
pp$8.parseImportAttribute = function() {
|
|
6348
6398
|
var node = this.startNode();
|
|
@@ -10491,7 +10541,7 @@ function visitDestructure(pattern, prefix, scope, out) {
|
|
|
10491
10541
|
emit(out, segments, { form: "destructure", callee: false, written: false }, property.start, property.end);
|
|
10492
10542
|
}
|
|
10493
10543
|
}
|
|
10494
|
-
function collectThisMemberRefs(body,
|
|
10544
|
+
function collectThisMemberRefs(body, names2) {
|
|
10495
10545
|
let program;
|
|
10496
10546
|
try {
|
|
10497
10547
|
program = parse3(PREFIX + body + SUFFIX, { ecmaVersion: "latest", sourceType: "module" });
|
|
@@ -10500,11 +10550,11 @@ function collectThisMemberRefs(body, names) {
|
|
|
10500
10550
|
}
|
|
10501
10551
|
const fn = unwrapWrapper(program);
|
|
10502
10552
|
if (fn === null) return null;
|
|
10503
|
-
return walkThisMembers(fn.body,
|
|
10553
|
+
return walkThisMembers(fn.body, names2, PREFIX.length);
|
|
10504
10554
|
}
|
|
10505
10555
|
var VALUE_PREFIX = "(async function* () {\n(";
|
|
10506
10556
|
var VALUE_SUFFIX = ")\n})";
|
|
10507
|
-
function collectThisMemberRefsInValue(value,
|
|
10557
|
+
function collectThisMemberRefsInValue(value, names2) {
|
|
10508
10558
|
let program;
|
|
10509
10559
|
try {
|
|
10510
10560
|
program = parse3(VALUE_PREFIX + value + VALUE_SUFFIX, { ecmaVersion: "latest", sourceType: "module" });
|
|
@@ -10517,9 +10567,9 @@ function collectThisMemberRefsInValue(value, names) {
|
|
|
10517
10567
|
if (statement.type !== "ExpressionStatement") return null;
|
|
10518
10568
|
const expression = statement.expression;
|
|
10519
10569
|
if (expression.type !== "FunctionExpression") return [];
|
|
10520
|
-
return walkThisMembers(expression.body,
|
|
10570
|
+
return walkThisMembers(expression.body, names2, VALUE_PREFIX.length);
|
|
10521
10571
|
}
|
|
10522
|
-
function walkThisMembers(root,
|
|
10572
|
+
function walkThisMembers(root, names2, offsetShift) {
|
|
10523
10573
|
const out = [];
|
|
10524
10574
|
const walk = (node, thisIsState) => {
|
|
10525
10575
|
if (isClassNode(node)) return;
|
|
@@ -10530,7 +10580,7 @@ function walkThisMembers(root, names, offsetShift) {
|
|
|
10530
10580
|
}
|
|
10531
10581
|
if (thisIsState && node.type === "MemberExpression" && node.object.type === "ThisExpression") {
|
|
10532
10582
|
const hit = thisMemberName(node);
|
|
10533
|
-
if (hit !== null &&
|
|
10583
|
+
if (hit !== null && names2.has(hit.name)) {
|
|
10534
10584
|
out.push({ name: hit.name, start: hit.start - offsetShift, end: hit.end - offsetShift });
|
|
10535
10585
|
}
|
|
10536
10586
|
}
|
|
@@ -10697,13 +10747,13 @@ function findInPlaceChanges(text3, kind, root) {
|
|
|
10697
10747
|
const collect2 = (node) => {
|
|
10698
10748
|
if (isFunctionNode(node)) {
|
|
10699
10749
|
if (node.type === "FunctionDeclaration" && node.id !== null) bind(node.id.name);
|
|
10700
|
-
const
|
|
10701
|
-
for (const param of node.params) bindingNames(param,
|
|
10702
|
-
|
|
10750
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
10751
|
+
for (const param of node.params) bindingNames(param, names2);
|
|
10752
|
+
names2.forEach(bind);
|
|
10703
10753
|
} else if (node.type === "VariableDeclarator") {
|
|
10704
|
-
const
|
|
10705
|
-
bindingNames(node.id,
|
|
10706
|
-
|
|
10754
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
10755
|
+
bindingNames(node.id, names2);
|
|
10756
|
+
names2.forEach(bind);
|
|
10707
10757
|
const init = node.init ? unwrapChain(node.init) : null;
|
|
10708
10758
|
if (init !== null && node.id.type === "Identifier" && init.type === "MemberExpression") {
|
|
10709
10759
|
const chain = memberChain(init, source);
|
|
@@ -10721,9 +10771,9 @@ function findInPlaceChanges(text3, kind, root) {
|
|
|
10721
10771
|
}
|
|
10722
10772
|
}
|
|
10723
10773
|
} else if (node.type === "CatchClause" && node.param) {
|
|
10724
|
-
const
|
|
10725
|
-
bindingNames(node.param,
|
|
10726
|
-
|
|
10774
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
10775
|
+
bindingNames(node.param, names2);
|
|
10776
|
+
names2.forEach(bind);
|
|
10727
10777
|
} else if (node.type === "ClassDeclaration" && node.id !== null) {
|
|
10728
10778
|
bind(node.id.name);
|
|
10729
10779
|
} else if (node.type === "AssignmentExpression" && node.left.type === "Identifier") {
|
|
@@ -10785,14 +10835,14 @@ function findLocationRead(body) {
|
|
|
10785
10835
|
}
|
|
10786
10836
|
const wrapper = unwrapWrapper(program);
|
|
10787
10837
|
if (wrapper === null) return null;
|
|
10788
|
-
const
|
|
10838
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
10789
10839
|
const scan = (node) => {
|
|
10790
|
-
if (isFunctionNode(node)) for (const param of node.params) bindingNames(param,
|
|
10791
|
-
if (node.type === "VariableDeclarator") bindingNames(node.id,
|
|
10840
|
+
if (isFunctionNode(node)) for (const param of node.params) bindingNames(param, names2);
|
|
10841
|
+
if (node.type === "VariableDeclarator") bindingNames(node.id, names2);
|
|
10792
10842
|
forEachChild(node, scan);
|
|
10793
10843
|
};
|
|
10794
10844
|
scan(wrapper.body);
|
|
10795
|
-
if (
|
|
10845
|
+
if (names2.has("location")) return null;
|
|
10796
10846
|
const isLocation = (node) => {
|
|
10797
10847
|
const n = unwrapChain(node);
|
|
10798
10848
|
if (n.type === "Identifier") return n.name === "location";
|
|
@@ -10869,6 +10919,13 @@ var ja = {
|
|
|
10869
10919
|
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`,
|
|
10870
10920
|
onHandlerThis: (name) => `$on \u306E\u30CF\u30F3\u30C9\u30E9 "${name}" \u304C this \u3092\u4F7F\u3063\u3066\u3044\u307E\u3059\u3002$on \u306E\u30CF\u30F3\u30C9\u30E9\u306F state \u3092\u7B2C 1 \u5F15\u6570\u3067\u53D7\u3051\u53D6\u308A\uFF08\`${name}(state, event) { state.x = \u2026 }\`\uFF09\u3001this \u306F undefined \u306A\u306E\u3067\u3001this.\u2026 \u306F\u547C\u3070\u308C\u305F\u3068\u304D\u306B\u4F8B\u5916\u306B\u306A\u308A\u307E\u3059\u3002$watch \u3084\u30E1\u30BD\u30C3\u30C9\u3068\u9055\u3046\u70B9\u306B\u6CE8\u610F`,
|
|
10871
10921
|
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`,
|
|
10922
|
+
getterReadsClock: (read) => `\u3053\u306E getter \u306F ${read} \u3092\u8AAD\u3093\u3067\u3044\u307E\u3059\u304C\u3001\u6642\u523B\u306F state \u3067\u306F\u306A\u3044\u306E\u3067\u4F9D\u5B58\u3068\u3057\u3066\u767B\u9332\u3055\u308C\u305A\u3001getter \u306F\u30AD\u30E3\u30C3\u30B7\u30E5\u3057\u305F\u6700\u521D\u306E\u5024\u3092\u8FD4\u3057\u7D9A\u3051\u307E\u3059\uFF08\u30A4\u30D9\u30F3\u30C8\u30C8\u30FC\u30AF\u30F3\u3067\u6BCE\u30D5\u30EC\u30FC\u30E0\u300C\u63CF\u304D\u76F4\u3057\u300D\u3066\u3082\u5909\u308F\u308A\u307E\u305B\u3093\uFF09\u3002\u6642\u523B\u3092 state \u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044 \u2014 <wcs-raf> \u3084 <wcs-timer> \u304C\u66F8\u304F\u5024\u3092\u675F\u306D\u308B`,
|
|
10923
|
+
updatedCallbackUnknownPath: (p) => `"${p}" \u306F state \u306E\u30D1\u30B9\u3067\u306F\u306A\u3044\u306E\u3067 $renderedCallback \u306E paths \u306B\u73FE\u308C\u305A\u3001\u3053\u306E\u5206\u5C90\u306F\u4E00\u5EA6\u3082\u5B9F\u884C\u3055\u308C\u307E\u305B\u3093`,
|
|
10924
|
+
commandTokenUnbound: (t) => `\u30B3\u30DE\u30F3\u30C9\u30C8\u30FC\u30AF\u30F3 "${t}" \u3092 emit \u3057\u3066\u3044\u307E\u3059\u304C\u3001\u3053\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u305D\u308C\u3092\u53D7\u3051\u308B command.<\u30E1\u30BD\u30C3\u30C9>: ${t} \u306E\u675F\u7E1B\u304C\u3042\u308A\u307E\u305B\u3093\u3002emit \u306F\u8AB0\u306B\u3082\u5C4A\u304D\u307E\u305B\u3093\u3002\u30E1\u30BD\u30C3\u30C9\u3092\u547C\u3076\u8981\u7D20\u306B\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08command.focus: ${t}\uFF09`,
|
|
10925
|
+
writePathMissing: (k) => `"${k}" \u306F state \u304C\u5BA3\u8A00\u3057\u3066\u3044\u306A\u3044\u30AD\u30FC\u3067\u3059\u3002\u66F8\u304D\u8FBC\u307F\u306F\u65B0\u3057\u3044\u30AD\u30FC\u3092\u4F5C\u308B\u3060\u3051\u3067\u3001\u5BA3\u8A00\u3057\u305F\u30AD\u30FC\u306E\u675F\u7E1B\u306B\u306F\u5C4A\u304D\u307E\u305B\u3093`,
|
|
10926
|
+
readPathMissing: (p, top) => top ? `"${p}" \u306F state \u304C\u5BA3\u8A00\u3057\u3066\u3044\u306A\u3044\u30AD\u30FC\u3067\u3059\u3002\u8AAD\u3093\u3060\u6642\u70B9\u3067\u4F8B\u5916\u306B\u306A\u308A\u307E\u3059\uFF08#301\uFF09` : `\u30D1\u30B9 "${p}" \u306F\u72B6\u614B\u5B9A\u7FA9\u306B\u5B58\u5728\u3057\u307E\u305B\u3093\u3002\u8AAD\u307F\u306F undefined \u306B\u306A\u308A\u3001\u305D\u3053\u304B\u3089\u8A08\u7B97\u3057\u305F\u5024\u306F\u9ED9\u3063\u3066\u9055\u3044\u307E\u3059`,
|
|
10927
|
+
pathDynamicUnknownSpread: (sp) => `${sp} \u304C\u6301\u3061\u8FBC\u3080\u30AD\u30FC\u306F\u9759\u7684\u306B\u8AAD\u3081\u306A\u3044\u306E\u3067\u3001\u3053\u306E state \u306E\u30D1\u30B9\u306F\u691C\u67FB\u3057\u3066\u3044\u307E\u305B\u3093\uFF08\u675F\u7E1B\u30FBgetter \u306E\u4E2D\u306E\u8AAD\u307F\u30FB$watch \u306E\u30AD\u30FC\uFF09\u3002\u30AD\u30FC\u3092 wcstack.manifest.json \u306E stateSchema \u306B\u5BA3\u8A00\u3059\u308B\u3068\u691C\u67FB\u3055\u308C\u307E\u3059\u3002npx wcs-schema\uFF08@wcstack/typescript\uFF09\u304C state \u306E\u578B\uFF08JSDoc\u30FBTypeScript\uFF09\u304B\u3089\u4F5C\u308C\u307E\u3059`,
|
|
10928
|
+
pathReadonlyTwoWay: (p, prop) => `"${p}" \u306F setter \u306E\u7121\u3044 getter \u3067\u3059\u304C\u3001${prop}: \u306F\u8AAD\u8005\u306E\u5165\u529B\u3092\u66F8\u304D\u623B\u3059\u306E\u3067\u3001\u5165\u529B\u306E\u305F\u3073\u306B\u66F8\u304D\u8FBC\u307F\u304C\u5931\u6557\u3057\u307E\u3059\uFF08"${p}" is a getter without a setter\uFF09\u3002setter \u3092\u8DB3\u3059\uFF08set "${p}"(v) { \u2026 }\uFF09\u304B\u3001#ro \u3067\u4E00\u65B9\u5411\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${prop}#ro: ${p}\uFF09`,
|
|
10872
10929
|
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`,
|
|
10873
10930
|
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`,
|
|
10874
10931
|
handlerFilterNotAllowed: (prop) => `\u30A4\u30D9\u30F3\u30C8\u30CF\u30F3\u30C9\u30E9 "${prop}" \u306B\u30D5\u30A3\u30EB\u30BF\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093`,
|
|
@@ -10905,7 +10962,7 @@ var ja = {
|
|
|
10905
10962
|
behaviorValueType: (key, type) => `$behavior \u306E "${key}" \u306F ${type === "boolean" ? "true \u304B false" : type} \u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\uFF08\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u8AAD\u307F\u8FBC\u307F\u6642\u306B throw \u3057\u307E\u3059\uFF09`,
|
|
10906
10963
|
configInVolume: (key, mountPath) => `${key} \u306F\u30DC\u30EA\u30E5\u30FC\u30E0\uFF08mount="${mountPath}"\uFF09\u3067\u306F\u5BA3\u8A00\u3067\u304D\u307E\u305B\u3093\uFF08\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u63A5\u304E\u6728\u3092\u62D2\u307F\u3001console.error \u3067\u5831\u544A\u3057\u307E\u3059 \u2014 \u3053\u306E state \u306F\u6728\u306B\u8F09\u308A\u307E\u305B\u3093\uFF09\u3002root \u306E state \u306B\u5BA3\u8A00\u3057\u3066\u304F\u3060\u3055\u3044 \u2014 \u30DC\u30EA\u30E5\u30FC\u30E0\u306F root \u306E\u30A8\u30F3\u30B8\u30F3\u306B\u63A5\u304E\u6728\u3055\u308C\u307E\u3059`,
|
|
10907
10964
|
featuresNotArray: () => `$features \u306F\u5F8C\u4ED8\u3051\u306E\u540D\u524D\u306E\u914D\u5217\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\uFF08\u4F8B: ["temporal", "formats"]\u3002\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u8AAD\u307F\u8FBC\u307F\u6642\u306B throw \u3057\u307E\u3059\uFF09`,
|
|
10908
|
-
featureUnknown: (name,
|
|
10965
|
+
featureUnknown: (name, names2, suggestion2) => `"${name}" \u306F\u5F8C\u4ED8\u3051\u306E\u540D\u524D\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF08${names2.join("\u30FB")}\uFF09${suggestion2}`,
|
|
10909
10966
|
volumeDeclarationRejected: (key, mountPath) => `${key} \u306F\u30DC\u30EA\u30E5\u30FC\u30E0\uFF08mount="${mountPath}"\uFF09\u3067\u306F\u5B9F\u884C\u3055\u308C\u307E\u305B\u3093\u3002\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u63A5\u304E\u6728\u3092\u62D2\u3093\u3067 console.error \u3067\u5831\u544A\u3057\u307E\u3059\uFF08\u3053\u306E state \u306F\u6728\u306B\u8F09\u308A\u307E\u305B\u3093\uFF09\u3002root \u306E state \u306B\u5BA3\u8A00\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
10910
10967
|
volumeDeclarationNotRun: (key, mountPath) => `${key} \u306F\u30DC\u30EA\u30E5\u30FC\u30E0\uFF08mount="${mountPath}"\uFF09\u3067\u306F\u5B9F\u884C\u3055\u308C\u307E\u305B\u3093\uFF08\u30E9\u30F3\u30BF\u30A4\u30E0\u306F console.warn \u3067\u77E5\u3089\u305B\u3001\u3053\u306E\u5BA3\u8A00\u3092\u7121\u8996\u3057\u307E\u3059 \u2014 root \u306E state \u306E\u3082\u306E\u3067\u3059\uFF09\u3002root \u306E state \u306B\u5BA3\u8A00\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
10911
10968
|
secondRoot: () => '\u540C\u3058 root \u306B 2 \u3064\u76EE\u306E <wcs-state> \u304C\u3042\u308A\u307E\u3059\u3002state \u306E\u6728\u306F root \u3054\u3068\u306B 1 \u3064\u3067\u3059\uFF08\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u5F8C\u304B\u3089\u8AAD\u307F\u8FBC\u3093\u3060\u65B9\u3092\u62D2\u3093\u3067 console.error \u3067\u5831\u544A\u3057\u307E\u3059\uFF09\u3002\u90E8\u5206\u6728\u306F <wcs-state mount="path"> \u3067\u63A5\u304E\u6728\u3057\u3066\u304F\u3060\u3055\u3044',
|
|
@@ -11070,6 +11127,13 @@ var en = {
|
|
|
11070
11127
|
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`,
|
|
11071
11128
|
onHandlerThis: (name) => `The $on handler "${name}" uses this. A $on handler receives the state as its first argument (\`${name}(state, event) { state.x = \u2026 }\`) and this is undefined, so this.\u2026 throws when it is called \u2014 unlike $watch handlers and methods`,
|
|
11072
11129
|
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`,
|
|
11130
|
+
getterReadsClock: (read) => `This getter reads ${read}. The time is not state, so it is not a dependency: the getter is cached and keeps returning its first value (an event token "redrawing" every frame does not change it). Keep the time in state \u2014 bind the value <wcs-raf> or <wcs-timer> writes`,
|
|
11131
|
+
updatedCallbackUnknownPath: (p) => `"${p}" is not a path of this state, so it is never in $renderedCallback's paths and this branch never runs`,
|
|
11132
|
+
commandTokenUnbound: (t) => `The command token "${t}" is emitted, but no command.<method>: ${t} binding in this document receives it, so the emit reaches nothing. Bind it on the element whose method it should call (command.focus: ${t})`,
|
|
11133
|
+
writePathMissing: (k) => `"${k}" is not a key the state declares. The write creates a new key and reaches no binding of a declared one`,
|
|
11134
|
+
readPathMissing: (p, top) => top ? `"${p}" is not a key the state declares. Reading it throws (#301)` : `Path "${p}" does not exist in the state definition. The read gives undefined, and what is computed from it is wrong without a word`,
|
|
11135
|
+
pathDynamicUnknownSpread: (sp) => `The keys ${sp} brings in cannot be read statically, so this state's paths are not checked (bindings, reads in getters, $watch keys). Declare the keys in the stateSchema of wcstack.manifest.json to have them checked; npx wcs-schema (@wcstack/typescript) derives it from the state's types (JSDoc or TypeScript)`,
|
|
11136
|
+
pathReadonlyTwoWay: (p, prop) => `"${p}" is a getter without a setter, and ${prop}: writes back what the reader enters, so every edit fails ("${p}" is a getter without a setter). Add a setter (set "${p}"(v) { \u2026 }), or bind it one way with #ro (${prop}#ro: ${p})`,
|
|
11073
11137
|
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`,
|
|
11074
11138
|
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`,
|
|
11075
11139
|
handlerFilterNotAllowed: (prop) => `Filters cannot be applied to event handler "${prop}"`,
|
|
@@ -11106,7 +11170,7 @@ var en = {
|
|
|
11106
11170
|
behaviorValueType: (key, type) => `$behavior "${key}" must be ${type === "boolean" ? "true or false" : type} (the runtime throws at load time)`,
|
|
11107
11171
|
configInVolume: (key, mountPath) => `${key} cannot be declared in a volume (mount="${mountPath}"): the runtime refuses to graft the volume and reports that with console.error (this state is not on the tree). Declare it on the root state \u2014 a volume is grafted onto the root's engine`,
|
|
11108
11172
|
featuresNotArray: () => `$features must be an array of add-on names (for example ["temporal", "formats"]; the runtime throws at load time)`,
|
|
11109
|
-
featureUnknown: (name,
|
|
11173
|
+
featureUnknown: (name, names2, suggestion2) => `"${name}" is not an add-on (${names2.join(", ")})${suggestion2}`,
|
|
11110
11174
|
volumeDeclarationRejected: (key, mountPath) => `${key} is not run in a volume (mount="${mountPath}"): the runtime refuses to graft the volume and reports that with console.error (this state is not on the tree). Declare it on the root state`,
|
|
11111
11175
|
volumeDeclarationNotRun: (key, mountPath) => `${key} is not run in a volume (mount="${mountPath}"): the runtime says so with console.warn and ignores this declaration \u2014 it belongs to the root state. Declare it there`,
|
|
11112
11176
|
secondRoot: () => 'A second <wcs-state> on the same root: there is one state tree per root (the runtime refuses the one that loads second and reports it with console.error). Graft a subtree with <wcs-state mount="path">',
|
|
@@ -11421,8 +11485,8 @@ function derefUnion(node, rootDefs) {
|
|
|
11421
11485
|
}
|
|
11422
11486
|
return { kind: "ok", nodes: out };
|
|
11423
11487
|
}
|
|
11424
|
-
function firstDefined(
|
|
11425
|
-
for (const n of
|
|
11488
|
+
function firstDefined(nodes2, pick) {
|
|
11489
|
+
for (const n of nodes2) {
|
|
11426
11490
|
const v = pick(n);
|
|
11427
11491
|
if (v !== void 0) return v;
|
|
11428
11492
|
}
|
|
@@ -11550,11 +11614,11 @@ var DELEGATED_EVENTS = /* @__PURE__ */ new Set([
|
|
|
11550
11614
|
]);
|
|
11551
11615
|
var CUSTOM_ELEMENT_OWN_EVENTS = /* @__PURE__ */ new Set(["input", "change", "submit"]);
|
|
11552
11616
|
function collectCurrentTargetHandlers(elements, html, fileReader) {
|
|
11553
|
-
const
|
|
11617
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
11554
11618
|
forEachStateMethod(elements, html, fileReader, "currentTarget", (name, params, body) => {
|
|
11555
|
-
if (readsEventCurrentTarget(params, body))
|
|
11619
|
+
if (readsEventCurrentTarget(params, body)) names2.add(name);
|
|
11556
11620
|
});
|
|
11557
|
-
return
|
|
11621
|
+
return names2;
|
|
11558
11622
|
}
|
|
11559
11623
|
function collectPreventDefaultHandlers(elements, html, fileReader) {
|
|
11560
11624
|
const handlers = /* @__PURE__ */ new Map();
|
|
@@ -11801,6 +11865,18 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
|
|
|
11801
11865
|
message: `${verdict.message}${pathTrimmed.startsWith(".") ? msgs.expansionSuffix(checkPath) : ""}`,
|
|
11802
11866
|
severity: verdict.severity
|
|
11803
11867
|
});
|
|
11868
|
+
} else if (writesBack(attr, propNoMod, parsed.property)) {
|
|
11869
|
+
const target = scopedPaths.find((p) => p.path === checkPath);
|
|
11870
|
+
if (target !== void 0 && target.kind === "computed" && target.settable !== true) {
|
|
11871
|
+
const pathStart = bindingStart + binding.indexOf(parsed.path);
|
|
11872
|
+
diagnostics.push({
|
|
11873
|
+
code: WcsDiagnosticCode.PathReadonly,
|
|
11874
|
+
start: pathStart,
|
|
11875
|
+
end: pathStart + pathTrimmed.length,
|
|
11876
|
+
message: msgs.pathReadonlyTwoWay(checkPath, propNoMod),
|
|
11877
|
+
severity: "error"
|
|
11878
|
+
});
|
|
11879
|
+
}
|
|
11804
11880
|
}
|
|
11805
11881
|
}
|
|
11806
11882
|
}
|
|
@@ -11987,6 +12063,19 @@ function openTagBefore(html, valueStart) {
|
|
|
11987
12063
|
const lt2 = html.lastIndexOf("<", valueStart);
|
|
11988
12064
|
return lt2 === -1 ? "" : html.slice(lt2, valueStart);
|
|
11989
12065
|
}
|
|
12066
|
+
function writesBack(attr, prop, written) {
|
|
12067
|
+
if (written.split("#").slice(1).some((modifier) => modifier.trim() === "ro")) return false;
|
|
12068
|
+
if (prop === "radio" || prop === "checkbox") return true;
|
|
12069
|
+
const tag = attr.tagName;
|
|
12070
|
+
if (tag === void 0 || tag.includes("-")) return false;
|
|
12071
|
+
if (tag === "input") {
|
|
12072
|
+
const type = (attr.inputType || "text").toLowerCase();
|
|
12073
|
+
if (type === "button") return false;
|
|
12074
|
+
if ((type === "radio" || type === "checkbox") && prop === "checked") return true;
|
|
12075
|
+
return prop === "value" || prop === "valueAsNumber" || prop === "valueAsDate";
|
|
12076
|
+
}
|
|
12077
|
+
return (tag === "select" || tag === "textarea") && prop === "value";
|
|
12078
|
+
}
|
|
11990
12079
|
function findAllBindAttributes(html, attrName) {
|
|
11991
12080
|
const attrs = [];
|
|
11992
12081
|
const escaped = attrName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -12000,7 +12089,8 @@ function findAllBindAttributes(html, attrName) {
|
|
|
12000
12089
|
const valueStart = tag.start + match.index + match[0].length;
|
|
12001
12090
|
const valueEnd = html.indexOf(quote, valueStart);
|
|
12002
12091
|
if (valueEnd === -1 || valueEnd > tag.end) continue;
|
|
12003
|
-
|
|
12092
|
+
const inputType = tag.tagName === "input" ? extractAttribute(attrsText, "type") ?? void 0 : void 0;
|
|
12093
|
+
attrs.push({ value: html.slice(valueStart, valueEnd), valueStart, tagName: tag.tagName, ...inputType !== void 0 ? { inputType } : {} });
|
|
12004
12094
|
regex.lastIndex = valueEnd - tag.start;
|
|
12005
12095
|
}
|
|
12006
12096
|
}
|
|
@@ -14152,6 +14242,162 @@ var BUILTIN_TAGS = {
|
|
|
14152
14242
|
}
|
|
14153
14243
|
};
|
|
14154
14244
|
|
|
14245
|
+
// src/service/pageElements.ts
|
|
14246
|
+
var MAX_FILES = 32;
|
|
14247
|
+
var JS_TYPES = /* @__PURE__ */ new Set(["", "module", "text/javascript", "application/javascript", "text/ecmascript"]);
|
|
14248
|
+
function pageScripts(html) {
|
|
14249
|
+
const inline = [];
|
|
14250
|
+
const srcs = [];
|
|
14251
|
+
const re = /<script\b((?:"[^"]*"|'[^']*'|[^>"'])*)>([\s\S]*?)<\/script\s*>/gi;
|
|
14252
|
+
const text3 = html.replace(/<!--[\s\S]*?-->/g, (c) => " ".repeat(c.length));
|
|
14253
|
+
let m;
|
|
14254
|
+
while ((m = re.exec(text3)) !== null) {
|
|
14255
|
+
const attrs = m[1];
|
|
14256
|
+
const type = (extractAttribute(attrs, "type") ?? "").trim().toLowerCase();
|
|
14257
|
+
if (!JS_TYPES.has(type)) continue;
|
|
14258
|
+
const src = extractAttribute(attrs, "src");
|
|
14259
|
+
if (src !== null) srcs.push(src);
|
|
14260
|
+
else if (m[2].trim() !== "") inline.push(m[2]);
|
|
14261
|
+
}
|
|
14262
|
+
return { inline, srcs };
|
|
14263
|
+
}
|
|
14264
|
+
function joinRelative(from, spec) {
|
|
14265
|
+
if (!spec.startsWith("./") && !spec.startsWith("../")) return null;
|
|
14266
|
+
const dir = from.includes("/") ? from.slice(0, from.lastIndexOf("/") + 1) : "";
|
|
14267
|
+
const out = [];
|
|
14268
|
+
for (const seg of `${dir}${spec}`.split("/")) {
|
|
14269
|
+
if (seg === "" || seg === ".") continue;
|
|
14270
|
+
if (seg === ".." && out.length > 0 && out[out.length - 1] !== "..") out.pop();
|
|
14271
|
+
else out.push(seg);
|
|
14272
|
+
}
|
|
14273
|
+
return `./${out.join("/")}`;
|
|
14274
|
+
}
|
|
14275
|
+
function parseScript(source) {
|
|
14276
|
+
for (const sourceType of ["module", "script"]) {
|
|
14277
|
+
try {
|
|
14278
|
+
return parse3(source, { ecmaVersion: "latest", sourceType, allowHashBang: true });
|
|
14279
|
+
} catch {
|
|
14280
|
+
}
|
|
14281
|
+
}
|
|
14282
|
+
return null;
|
|
14283
|
+
}
|
|
14284
|
+
function* nodes(node) {
|
|
14285
|
+
yield node;
|
|
14286
|
+
for (const value of Object.values(node)) {
|
|
14287
|
+
if (Array.isArray(value)) {
|
|
14288
|
+
for (const v of value) if (v !== null && typeof v === "object" && typeof v.type === "string") yield* nodes(v);
|
|
14289
|
+
} else if (value !== null && typeof value === "object" && typeof value.type === "string") {
|
|
14290
|
+
yield* nodes(value);
|
|
14291
|
+
}
|
|
14292
|
+
}
|
|
14293
|
+
}
|
|
14294
|
+
var keyName = (key, computed) => computed ? null : key.type === "Identifier" ? key.name : key.type === "Literal" && typeof key.value === "string" ? key.value : null;
|
|
14295
|
+
function names(obj, key) {
|
|
14296
|
+
const prop = obj.properties.find((p) => p.type === "Property" && keyName(p.key, p.computed) === key);
|
|
14297
|
+
if (prop === void 0 || prop.type !== "Property") return void 0;
|
|
14298
|
+
if (prop.value.type !== "ArrayExpression") return null;
|
|
14299
|
+
const out = [];
|
|
14300
|
+
for (const el of prop.value.elements) {
|
|
14301
|
+
if (el === null || el.type !== "ObjectExpression" || el.properties.some((p) => p.type !== "Property")) return null;
|
|
14302
|
+
const name = el.properties.find((p) => p.type === "Property" && keyName(p.key, p.computed) === "name");
|
|
14303
|
+
if (name === void 0 || name.type !== "Property" || name.value.type !== "Literal" || typeof name.value.value !== "string") return null;
|
|
14304
|
+
out.push(name.value.value);
|
|
14305
|
+
}
|
|
14306
|
+
return out;
|
|
14307
|
+
}
|
|
14308
|
+
function contractOf(value) {
|
|
14309
|
+
if (value.type !== "ObjectExpression" || value.properties.some((p) => p.type !== "Property")) return "unknown";
|
|
14310
|
+
const properties = names(value, "properties");
|
|
14311
|
+
const inputs = names(value, "inputs");
|
|
14312
|
+
const commands = names(value, "commands");
|
|
14313
|
+
if (properties === null || inputs === null || commands === null) return "unknown";
|
|
14314
|
+
return {
|
|
14315
|
+
properties: properties ?? [],
|
|
14316
|
+
inputs: Object.fromEntries((inputs ?? []).map((n) => [n, null])),
|
|
14317
|
+
commands: commands ?? []
|
|
14318
|
+
};
|
|
14319
|
+
}
|
|
14320
|
+
function declaredBy(cls) {
|
|
14321
|
+
let declared = "none";
|
|
14322
|
+
for (const member of cls.body.body) {
|
|
14323
|
+
if (member.type !== "PropertyDefinition" && member.type !== "MethodDefinition" || !member.static) continue;
|
|
14324
|
+
if (keyName(member.key, member.computed) !== "wcBindable") continue;
|
|
14325
|
+
if (member.type === "PropertyDefinition") {
|
|
14326
|
+
declared = member.value === null || member.value === void 0 ? "unknown" : contractOf(member.value);
|
|
14327
|
+
} else {
|
|
14328
|
+
const body = member.kind === "get" ? member.value.body.body : [];
|
|
14329
|
+
const ret = body.length === 1 && body[0].type === "ReturnStatement" ? body[0].argument : null;
|
|
14330
|
+
declared = ret === null || ret === void 0 ? "unknown" : contractOf(ret);
|
|
14331
|
+
}
|
|
14332
|
+
}
|
|
14333
|
+
const sup = cls.superClass;
|
|
14334
|
+
return { declared, superName: sup !== null && sup !== void 0 && sup.type === "Identifier" ? sup.name : null };
|
|
14335
|
+
}
|
|
14336
|
+
function isDefine(callee) {
|
|
14337
|
+
if (callee.type !== "MemberExpression" || keyName(callee.property, callee.computed) !== "define") return false;
|
|
14338
|
+
const o = callee.object;
|
|
14339
|
+
return o.type === "Identifier" && o.name === "customElements" || o.type === "MemberExpression" && keyName(o.property, o.computed) === "customElements";
|
|
14340
|
+
}
|
|
14341
|
+
function collectPageElementContracts(html, fileReader) {
|
|
14342
|
+
const { inline, srcs } = pageScripts(html);
|
|
14343
|
+
const programs = [];
|
|
14344
|
+
const read = /* @__PURE__ */ new Set();
|
|
14345
|
+
const queue = srcs.map((spec) => ({ from: "", spec: spec.startsWith(".") ? spec : `./${spec}` }));
|
|
14346
|
+
const visit2 = (program, from) => {
|
|
14347
|
+
programs.push(program);
|
|
14348
|
+
for (const n of nodes(program)) {
|
|
14349
|
+
const source = n.type === "ImportDeclaration" || n.type === "ExportAllDeclaration" || n.type === "ExportNamedDeclaration" ? n.source : n.type === "ImportExpression" ? n.source : null;
|
|
14350
|
+
if (source !== null && source !== void 0 && source.type === "Literal" && typeof source.value === "string") queue.push({ from, spec: source.value });
|
|
14351
|
+
}
|
|
14352
|
+
};
|
|
14353
|
+
for (const source of inline) {
|
|
14354
|
+
const program = parseScript(source);
|
|
14355
|
+
if (program !== null) visit2(program, "");
|
|
14356
|
+
}
|
|
14357
|
+
while (queue.length > 0 && fileReader !== void 0 && read.size < MAX_FILES) {
|
|
14358
|
+
const { from, spec } = queue.shift();
|
|
14359
|
+
const path = joinRelative(from, spec);
|
|
14360
|
+
if (path === null || read.has(path) || !/\.m?js$/.test(path)) continue;
|
|
14361
|
+
read.add(path);
|
|
14362
|
+
const text3 = fileReader(path);
|
|
14363
|
+
const program = text3 === void 0 ? null : parseScript(text3);
|
|
14364
|
+
if (program !== null) visit2(program, path);
|
|
14365
|
+
}
|
|
14366
|
+
const classes = /* @__PURE__ */ new Map();
|
|
14367
|
+
const defines = [];
|
|
14368
|
+
for (const program of programs) {
|
|
14369
|
+
for (const n of nodes(program)) {
|
|
14370
|
+
if (n.type === "ClassDeclaration" && n.id !== null && !classes.has(n.id.name)) classes.set(n.id.name, declaredBy(n));
|
|
14371
|
+
else if (n.type === "VariableDeclarator" && n.id.type === "Identifier" && n.init?.type === "ClassExpression" && !classes.has(n.id.name)) {
|
|
14372
|
+
classes.set(n.id.name, declaredBy(n.init));
|
|
14373
|
+
} else if (n.type === "CallExpression" && isDefine(n.callee) && n.arguments.length >= 2) {
|
|
14374
|
+
const [tag, cls] = n.arguments;
|
|
14375
|
+
if (tag.type !== "Literal" || typeof tag.value !== "string") continue;
|
|
14376
|
+
if (cls.type === "ClassExpression") defines.push({ tag: tag.value, info: declaredBy(cls) });
|
|
14377
|
+
else if (cls.type === "Identifier") defines.push({ tag: tag.value, info: cls.name });
|
|
14378
|
+
}
|
|
14379
|
+
}
|
|
14380
|
+
}
|
|
14381
|
+
const resolve2 = (info, depth) => {
|
|
14382
|
+
if (info.declared === "unknown") return null;
|
|
14383
|
+
if (info.declared !== "none") return info.declared;
|
|
14384
|
+
const sup = info.superName === null ? void 0 : classes.get(info.superName);
|
|
14385
|
+
return sup === void 0 || depth > 16 ? null : resolve2(sup, depth + 1);
|
|
14386
|
+
};
|
|
14387
|
+
const out = /* @__PURE__ */ new Map();
|
|
14388
|
+
for (const { tag, info } of defines) {
|
|
14389
|
+
const name = tag.toLowerCase();
|
|
14390
|
+
if (name.startsWith("wcs-") || out.has(name)) continue;
|
|
14391
|
+
const cls = typeof info === "string" ? classes.get(info) : info;
|
|
14392
|
+
const contract = cls === void 0 ? null : resolve2(cls, 0);
|
|
14393
|
+
if (contract !== null) out.set(name, contract);
|
|
14394
|
+
}
|
|
14395
|
+
return out;
|
|
14396
|
+
}
|
|
14397
|
+
function mayDefineElements(html) {
|
|
14398
|
+
return /customElements|<script\b[^>]*\bsrc\s*=/i.test(html);
|
|
14399
|
+
}
|
|
14400
|
+
|
|
14155
14401
|
// src/service/ioNodeValidator.ts
|
|
14156
14402
|
var HTML_SINK_PROPERTIES = /* @__PURE__ */ new Set(["html", "innerHTML", "outerHTML", "srcdoc"]);
|
|
14157
14403
|
var STRUCTURAL_DIRECTIVES3 = /* @__PURE__ */ new Set(["for", "if", "elseif", "else"]);
|
|
@@ -14166,7 +14412,6 @@ function validateIoNodes(html, bindAttribute = "data-wcs", stateTagName = "wcs-s
|
|
|
14166
14412
|
const diagnostics = [];
|
|
14167
14413
|
const msgs = getMessages(locale2);
|
|
14168
14414
|
const occurrences = findBuiltinTagOccurrences(html);
|
|
14169
|
-
if (occurrences.length === 0) return diagnostics;
|
|
14170
14415
|
let statePaths = null;
|
|
14171
14416
|
const getPaths = () => statePaths ??= getStatePathsFromHtml(html, stateTagName, fileReader);
|
|
14172
14417
|
for (const occ of occurrences) {
|
|
@@ -14194,32 +14439,35 @@ function validateIoNodes(html, bindAttribute = "data-wcs", stateTagName = "wcs-s
|
|
|
14194
14439
|
}
|
|
14195
14440
|
if (contract.properties.length === 0 && contract.commands.length === 0 && Object.keys(contract.inputs).length === 0) continue;
|
|
14196
14441
|
const hasManual = hasBooleanAttribute(occ.attrsText, "manual");
|
|
14197
|
-
|
|
14198
|
-
|
|
14199
|
-
|
|
14200
|
-
|
|
14201
|
-
|
|
14202
|
-
|
|
14203
|
-
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
const
|
|
14207
|
-
|
|
14208
|
-
occ.tagName,
|
|
14209
|
-
contract,
|
|
14210
|
-
parsed,
|
|
14211
|
-
property,
|
|
14212
|
-
start,
|
|
14213
|
-
end,
|
|
14214
|
-
hasManual,
|
|
14215
|
-
getPaths,
|
|
14216
|
-
diagnostics,
|
|
14217
|
-
msgs
|
|
14218
|
-
);
|
|
14442
|
+
checkBindings(occ.tagName, contract, bindAttr.value, valueStart, hasManual, getPaths, diagnostics, msgs);
|
|
14443
|
+
}
|
|
14444
|
+
if (mayDefineElements(html)) {
|
|
14445
|
+
const own2 = findPageTagOccurrences(html, bindAttribute);
|
|
14446
|
+
const contracts = own2.length > 0 ? collectPageElementContracts(html, fileReader) : null;
|
|
14447
|
+
for (const occ of own2) {
|
|
14448
|
+
const contract = contracts.get(occ.tagName);
|
|
14449
|
+
if (contract === void 0) continue;
|
|
14450
|
+
if (contract.properties.length === 0 && contract.commands.length === 0 && Object.keys(contract.inputs).length === 0) continue;
|
|
14451
|
+
const bindAttr = extractAttributeValue(occ.attrsText, bindAttribute);
|
|
14452
|
+
checkBindings(occ.tagName, contract, bindAttr.value, occ.attrsStart + bindAttr.valueOffsetInAttrs, false, getPaths, diagnostics, msgs);
|
|
14219
14453
|
}
|
|
14220
14454
|
}
|
|
14221
14455
|
return diagnostics;
|
|
14222
14456
|
}
|
|
14457
|
+
function checkBindings(tagName, contract, value, valueStart, hasManual, getPaths, diagnostics, msgs) {
|
|
14458
|
+
let exprOffset = 0;
|
|
14459
|
+
for (const expr of splitBindingExpressions(value)) {
|
|
14460
|
+
const exprStart = valueStart + exprOffset;
|
|
14461
|
+
exprOffset += expr.length + 1;
|
|
14462
|
+
const parsed = parseBindingExpression(expr);
|
|
14463
|
+
const property = parsed.property;
|
|
14464
|
+
if (!property) continue;
|
|
14465
|
+
const propIndex = expr.indexOf(property);
|
|
14466
|
+
const start = propIndex === -1 ? exprStart : exprStart + propIndex;
|
|
14467
|
+
const end = propIndex === -1 ? exprStart + expr.length : start + property.length;
|
|
14468
|
+
validateBindingAgainstContract(tagName, contract, parsed, property, start, end, hasManual, getPaths, diagnostics, msgs);
|
|
14469
|
+
}
|
|
14470
|
+
}
|
|
14223
14471
|
function validateBindingAgainstContract(tagName, contract, parsed, property, start, end, hasManual, getPaths, diagnostics, msgs) {
|
|
14224
14472
|
const hashIndex = property.indexOf("#");
|
|
14225
14473
|
const modifiers = hashIndex === -1 ? "" : property.slice(hashIndex + 1);
|
|
@@ -14278,6 +14526,7 @@ function validateBindingAgainstContract(tagName, contract, parsed, property, sta
|
|
|
14278
14526
|
}
|
|
14279
14527
|
return;
|
|
14280
14528
|
}
|
|
14529
|
+
if (!tagName.startsWith("wcs-") && property.includes(".")) return;
|
|
14281
14530
|
if (!contract.properties.includes(property) && !(property in contract.inputs) && !HTML_SINK_PROPERTIES.has(property)) {
|
|
14282
14531
|
const members = [...contract.properties, ...inputNames];
|
|
14283
14532
|
diagnostics.push({
|
|
@@ -14291,7 +14540,7 @@ function validateBindingAgainstContract(tagName, contract, parsed, property, sta
|
|
|
14291
14540
|
});
|
|
14292
14541
|
return;
|
|
14293
14542
|
}
|
|
14294
|
-
if (property === "trigger" && "trigger" in contract.inputs && parsed.path) {
|
|
14543
|
+
if (tagName.startsWith("wcs-") && property === "trigger" && "trigger" in contract.inputs && parsed.path) {
|
|
14295
14544
|
const cand = findDataSlot(getPaths(), parsed.path);
|
|
14296
14545
|
if (cand?.rawInitial === "true") {
|
|
14297
14546
|
diagnostics.push({
|
|
@@ -14368,6 +14617,17 @@ function findBuiltinTagOccurrences(html) {
|
|
|
14368
14617
|
}
|
|
14369
14618
|
return out;
|
|
14370
14619
|
}
|
|
14620
|
+
function findPageTagOccurrences(html, bindAttribute) {
|
|
14621
|
+
const out = [];
|
|
14622
|
+
for (const region of findStartTagRegions(html)) {
|
|
14623
|
+
const tagName = region.tagName;
|
|
14624
|
+
if (!tagName.includes("-") || tagName.startsWith("wcs-")) continue;
|
|
14625
|
+
const attrsText = html.slice(region.start, region.end);
|
|
14626
|
+
if (extractAttributeValue(attrsText, bindAttribute) === null) continue;
|
|
14627
|
+
out.push({ tagName, tagStart: region.start - tagName.length - 1, attrsText, attrsStart: region.start });
|
|
14628
|
+
}
|
|
14629
|
+
return out;
|
|
14630
|
+
}
|
|
14371
14631
|
function extractAttributeValue(attrsText, attrName) {
|
|
14372
14632
|
const escaped = attrName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
14373
14633
|
const regex = new RegExp(`(?:^|\\s)${escaped}\\s*=\\s*(["'])`, "i");
|
|
@@ -14813,7 +15073,7 @@ function validateWatchDeclarations(html, stateTagName = "wcs-state", locale2, fi
|
|
|
14813
15073
|
const scopes = {
|
|
14814
15074
|
mounts: volumes?.scopes.mounts ?? [],
|
|
14815
15075
|
unresolvedMounts: volumes?.scopes.unresolvedMounts ?? NO_MOUNTS,
|
|
14816
|
-
rootUnresolved:
|
|
15076
|
+
rootUnresolved: !scriptReadable(block.content, own2)
|
|
14817
15077
|
};
|
|
14818
15078
|
for (const entry of entries) {
|
|
14819
15079
|
const diagnostic = validateEntry(entry, pathSet, paths, scopes, msgs);
|
|
@@ -14834,10 +15094,10 @@ var NO_MOUNTS = /* @__PURE__ */ new Set();
|
|
|
14834
15094
|
function assignVolumes(elements, html) {
|
|
14835
15095
|
const chainOf = createTemplateChain(html);
|
|
14836
15096
|
const innermost = (chain) => chain.length > 0 ? chain[chain.length - 1] : -1;
|
|
14837
|
-
const
|
|
15097
|
+
const treeOf2 = (root) => innermost(chainOf(root.tagStart));
|
|
14838
15098
|
const rootTrees = /* @__PURE__ */ new Set();
|
|
14839
15099
|
for (const element2 of elements) {
|
|
14840
|
-
if (element2.mountPath === null && !element2.bindComponent) rootTrees.add(
|
|
15100
|
+
if (element2.mountPath === null && !element2.bindComponent) rootTrees.add(treeOf2(element2));
|
|
14841
15101
|
}
|
|
14842
15102
|
const volumes = /* @__PURE__ */ new Map();
|
|
14843
15103
|
for (const element2 of elements) {
|
|
@@ -14854,7 +15114,7 @@ function assignVolumes(elements, html) {
|
|
|
14854
15114
|
if (list === void 0) volumes.set(tree, [element2]);
|
|
14855
15115
|
else list.push(element2);
|
|
14856
15116
|
}
|
|
14857
|
-
return { treeOf, volumes };
|
|
15117
|
+
return { treeOf: treeOf2, volumes };
|
|
14858
15118
|
}
|
|
14859
15119
|
function validateEntry(entry, pathSet, paths, scopes, msgs) {
|
|
14860
15120
|
const { key } = entry;
|
|
@@ -15842,8 +16102,8 @@ function validateVolumeBlock2(block, mountPath, msgs, out) {
|
|
|
15842
16102
|
}
|
|
15843
16103
|
function validateBindComponentSource(html, tagStart, tagEnd, hasInlineScript, msgs, out) {
|
|
15844
16104
|
const tag = html.slice(tagStart, tagEnd);
|
|
15845
|
-
const
|
|
15846
|
-
const sources = BIND_COMPONENT_SOURCE_ATTRIBUTES.filter((name) =>
|
|
16105
|
+
const names2 = parseAttributeNames(tag);
|
|
16106
|
+
const sources = BIND_COMPONENT_SOURCE_ATTRIBUTES.filter((name) => names2.has(name));
|
|
15847
16107
|
if (hasInlineScript) sources.push('<script type="module">');
|
|
15848
16108
|
if (sources.length === 0) return;
|
|
15849
16109
|
const prop = /\sbind-component\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>`=]+))/i.exec(tag);
|
|
@@ -15971,7 +16231,7 @@ var OLD_DECLARATION_KEY = /(^|[{,;\s])(\$streams|\$updatedCallback)(?=\s*(?:[:(]
|
|
|
15971
16231
|
function collectDeclarationAliasReads(script) {
|
|
15972
16232
|
return collectStateThisReads(script, OLD_DECLARATION_MEMBER_NAMES);
|
|
15973
16233
|
}
|
|
15974
|
-
function collectStateThisReads(script,
|
|
16234
|
+
function collectStateThisReads(script, names2) {
|
|
15975
16235
|
if (!hasDefaultExportObject(script)) return null;
|
|
15976
16236
|
const out = [];
|
|
15977
16237
|
const take = (refs, base) => {
|
|
@@ -15980,10 +16240,10 @@ function collectStateThisReads(script, names) {
|
|
|
15980
16240
|
return true;
|
|
15981
16241
|
};
|
|
15982
16242
|
for (const callable of analyzeCallableBodies(script)) {
|
|
15983
|
-
if (!take(collectThisMemberRefs(callable.body,
|
|
16243
|
+
if (!take(collectThisMemberRefs(callable.body, names2), callable.bodyStart)) return null;
|
|
15984
16244
|
}
|
|
15985
16245
|
for (const handler of analyzeWatchHandlerSources(script)) {
|
|
15986
|
-
const refs = handler.kind === "body" ? collectThisMemberRefs(handler.text,
|
|
16246
|
+
const refs = handler.kind === "body" ? collectThisMemberRefs(handler.text, names2) : collectThisMemberRefsInValue(handler.text, names2);
|
|
15987
16247
|
if (!take(refs, handler.start)) return null;
|
|
15988
16248
|
}
|
|
15989
16249
|
out.sort((a, b) => a.start - b.start);
|
|
@@ -16191,6 +16451,26 @@ function validateGetterLocationReads(script, scriptStart, locale2) {
|
|
|
16191
16451
|
}
|
|
16192
16452
|
return out;
|
|
16193
16453
|
}
|
|
16454
|
+
var CLOCK_READ = /\bDate\s*\.\s*now\s*\(|\bnew\s+Date\s*\(\s*\)|\bperformance\s*\.\s*now\s*\(/;
|
|
16455
|
+
function validateGetterClockReads(script, scriptStart, locale2) {
|
|
16456
|
+
if (!/Date|performance/.test(script)) return [];
|
|
16457
|
+
const msgs = getMessages(locale2);
|
|
16458
|
+
const out = [];
|
|
16459
|
+
for (const getter of analyzeCallableBodies(script)) {
|
|
16460
|
+
if (getter.kind !== "getter" || getter.accessor !== "get") continue;
|
|
16461
|
+
const read = CLOCK_READ.exec(maskCommentsAndStrings(getter.body));
|
|
16462
|
+
if (read === null) continue;
|
|
16463
|
+
const text3 = read[0].startsWith("new") ? "new Date()" : read[0].startsWith("performance") ? "performance.now()" : "Date.now()";
|
|
16464
|
+
out.push({
|
|
16465
|
+
code: WcsDiagnosticCode.GetterUntrackedRead,
|
|
16466
|
+
start: scriptStart + getter.bodyStart + read.index,
|
|
16467
|
+
end: scriptStart + getter.bodyStart + read.index + read[0].length,
|
|
16468
|
+
message: msgs.getterReadsClock(text3),
|
|
16469
|
+
severity: "warning"
|
|
16470
|
+
});
|
|
16471
|
+
}
|
|
16472
|
+
return out;
|
|
16473
|
+
}
|
|
16194
16474
|
function onHandlerStateParam(script, handler) {
|
|
16195
16475
|
if (handler.kind === "body") {
|
|
16196
16476
|
const head = script.slice(Math.max(0, handler.start - 400), handler.start);
|
|
@@ -16388,15 +16668,22 @@ function validateUpdatedCallbackDemand(html, stateTagName, bindAttrName, locale2
|
|
|
16388
16668
|
const reported = /* @__PURE__ */ new Set();
|
|
16389
16669
|
while ((match = PATH_TEST_LITERAL.exec(body)) !== null) {
|
|
16390
16670
|
const path = match[2];
|
|
16391
|
-
if (path.length === 0 ||
|
|
16392
|
-
|
|
16671
|
+
if (path.length === 0 || bound.has(path) || reported.has(path)) continue;
|
|
16672
|
+
let message;
|
|
16673
|
+
if (declared.has(path)) {
|
|
16674
|
+
message = msgs.updatedCallbackUnbound(path);
|
|
16675
|
+
} else {
|
|
16676
|
+
const near = suggestion(path, [...declared, ...bound], msgs);
|
|
16677
|
+
if (near === "") continue;
|
|
16678
|
+
message = msgs.updatedCallbackUnknownPath(path) + near;
|
|
16679
|
+
}
|
|
16393
16680
|
reported.add(path);
|
|
16394
16681
|
const quoteAt = match.index + match[0].length - path.length - 1;
|
|
16395
16682
|
out.push({
|
|
16396
16683
|
code: WcsDiagnosticCode.UpdatedCallbackUnbound,
|
|
16397
16684
|
start: block.contentStart + callback.bodyStart + quoteAt,
|
|
16398
16685
|
end: block.contentStart + callback.bodyStart + quoteAt + path.length,
|
|
16399
|
-
message
|
|
16686
|
+
message,
|
|
16400
16687
|
severity: "warning"
|
|
16401
16688
|
});
|
|
16402
16689
|
}
|
|
@@ -16409,8 +16696,8 @@ function collectBoundPaths(html, stateTagName, bindAttrName) {
|
|
|
16409
16696
|
for (const occurrence of index.occurrences) {
|
|
16410
16697
|
bound.add(occurrence.path);
|
|
16411
16698
|
if (!occurrence.path.startsWith(".")) continue;
|
|
16412
|
-
const forPath =
|
|
16413
|
-
if (forPath === null
|
|
16699
|
+
const forPath = getResolvedForListPath(html, occurrence.pathRange.start, bindAttrName);
|
|
16700
|
+
if (forPath === null) continue;
|
|
16414
16701
|
bound.add(
|
|
16415
16702
|
occurrence.path === "." ? `${forPath}.*` : `${forPath}.*.${occurrence.path.slice(1)}`
|
|
16416
16703
|
);
|
|
@@ -16483,6 +16770,7 @@ function validateSemantics(html, stateTagName = "wcs-state", locale2, bindAttrNa
|
|
|
16483
16770
|
out.push(...validateGetterCycles(block.content, block.contentStart, locale2));
|
|
16484
16771
|
out.push(...validateGetterUntrackedReads(block.content, block.contentStart, getNestedWriteRoots, locale2));
|
|
16485
16772
|
out.push(...validateGetterLocationReads(block.content, block.contentStart, locale2));
|
|
16773
|
+
out.push(...validateGetterClockReads(block.content, block.contentStart, locale2));
|
|
16486
16774
|
out.push(...validateOnHandlerThis(block.content, block.contentStart, locale2));
|
|
16487
16775
|
out.push(...validateInPlaceChanges(block.content, block.contentStart, locale2));
|
|
16488
16776
|
}
|
|
@@ -16491,6 +16779,169 @@ function validateSemantics(html, stateTagName = "wcs-state", locale2, bindAttrNa
|
|
|
16491
16779
|
return out;
|
|
16492
16780
|
}
|
|
16493
16781
|
|
|
16782
|
+
// src/service/scriptStateUseValidator.ts
|
|
16783
|
+
var COMMAND_USE = /\.\s*\$command\s*\.\s*([A-Za-z_$][\w$]*)/dg;
|
|
16784
|
+
var EMIT_AFTER = /^\s*\.\s*emit\s*\(/;
|
|
16785
|
+
var THIS_WRITE = /\bthis\s*\.\s*([A-Za-z_][\w$]*)\s*(?:=(?![=>])|[-+*/%&|^]=|\*\*=|<<=|>>>?=|&&=|\|\|=|\?\?=|\+\+|--)/dg;
|
|
16786
|
+
var PRE_THIS_WRITE = /(?:\+\+|--)\s*this\s*\.\s*([A-Za-z_][\w$]*)/dg;
|
|
16787
|
+
function validateScriptStateUses(html, stateTagName = "wcs-state", locale2, bindAttrName = "data-wcs") {
|
|
16788
|
+
const blocks = parseLoadedScriptBlocks(html, stateTagName).filter((block) => isReadableStateScript(block.content));
|
|
16789
|
+
if (blocks.length === 0) return [];
|
|
16790
|
+
const msgs = getMessages(locale2);
|
|
16791
|
+
const out = [];
|
|
16792
|
+
let receivers = null;
|
|
16793
|
+
let markupEmits = null;
|
|
16794
|
+
const bindings = () => {
|
|
16795
|
+
if (receivers !== null) return;
|
|
16796
|
+
receivers = /* @__PURE__ */ new Set();
|
|
16797
|
+
markupEmits = /* @__PURE__ */ new Map();
|
|
16798
|
+
for (const o of buildReferenceIndex(html, { bindAttribute: bindAttrName, stateTagName }).occurrences) {
|
|
16799
|
+
if (!o.path.startsWith("$command.")) continue;
|
|
16800
|
+
const name = o.path.slice("$command.".length);
|
|
16801
|
+
const prop = o.propName ?? "";
|
|
16802
|
+
if (prop.startsWith("command.")) receivers.add(name);
|
|
16803
|
+
else if (prop.startsWith("on") && !markupEmits.has(name)) markupEmits.set(name, o.pathRange);
|
|
16804
|
+
}
|
|
16805
|
+
};
|
|
16806
|
+
for (const block of blocks) {
|
|
16807
|
+
const paths = analyzeStatePaths(block.content);
|
|
16808
|
+
const masked = maskCommentsAndStrings(block.content);
|
|
16809
|
+
const declared = paths.filter((p) => p.kind === "command").map((p) => p.path.slice("$command.".length));
|
|
16810
|
+
if (block.mountPath === null && declared.length > 0) {
|
|
16811
|
+
const emitted = /* @__PURE__ */ new Map();
|
|
16812
|
+
COMMAND_USE.lastIndex = 0;
|
|
16813
|
+
let match;
|
|
16814
|
+
while ((match = COMMAND_USE.exec(masked)) !== null) {
|
|
16815
|
+
const name = match[1];
|
|
16816
|
+
const [start, end] = match.indices[1];
|
|
16817
|
+
if (!declared.includes(name)) {
|
|
16818
|
+
out.push({
|
|
16819
|
+
code: WcsDiagnosticCode.TokenUndeclared,
|
|
16820
|
+
start: block.contentStart + start,
|
|
16821
|
+
end: block.contentStart + end,
|
|
16822
|
+
// `$command` holds the declared tokens only: `.emit()` on what it lacks is a TypeError
|
|
16823
|
+
message: msgs.commandTokenUndeclared(`$command.${name}`) + suggestion(name, declared, msgs),
|
|
16824
|
+
severity: "error"
|
|
16825
|
+
});
|
|
16826
|
+
} else if (!emitted.has(name) && EMIT_AFTER.test(masked.slice(match.index + match[0].length))) {
|
|
16827
|
+
emitted.set(name, { start: block.contentStart + start, end: block.contentStart + end });
|
|
16828
|
+
}
|
|
16829
|
+
}
|
|
16830
|
+
bindings();
|
|
16831
|
+
for (const name of declared) {
|
|
16832
|
+
if (receivers.has(name)) continue;
|
|
16833
|
+
const at2 = emitted.get(name) ?? markupEmits.get(name);
|
|
16834
|
+
if (at2 === void 0) continue;
|
|
16835
|
+
out.push({
|
|
16836
|
+
code: WcsDiagnosticCode.CommandTokenUnbound,
|
|
16837
|
+
start: at2.start,
|
|
16838
|
+
end: at2.end,
|
|
16839
|
+
message: msgs.commandTokenUnbound(`$command.${name}`),
|
|
16840
|
+
severity: "warning"
|
|
16841
|
+
});
|
|
16842
|
+
}
|
|
16843
|
+
}
|
|
16844
|
+
const keys = [...new Set(paths.map((p) => p.path.split(".")[0]).filter((key) => key !== "" && !key.startsWith("$")))];
|
|
16845
|
+
const reported = /* @__PURE__ */ new Set();
|
|
16846
|
+
for (const pattern of [THIS_WRITE, PRE_THIS_WRITE]) {
|
|
16847
|
+
pattern.lastIndex = 0;
|
|
16848
|
+
let match;
|
|
16849
|
+
while ((match = pattern.exec(masked)) !== null) {
|
|
16850
|
+
const key = match[1];
|
|
16851
|
+
if (keys.includes(key) || reported.has(key)) continue;
|
|
16852
|
+
const near = suggestion(key, keys, msgs);
|
|
16853
|
+
if (near === "") continue;
|
|
16854
|
+
reported.add(key);
|
|
16855
|
+
const [start, end] = match.indices[1];
|
|
16856
|
+
out.push({
|
|
16857
|
+
code: WcsDiagnosticCode.WritePathMissing,
|
|
16858
|
+
start: block.contentStart + start,
|
|
16859
|
+
end: block.contentStart + end,
|
|
16860
|
+
message: msgs.writePathMissing(key) + near,
|
|
16861
|
+
severity: "warning"
|
|
16862
|
+
});
|
|
16863
|
+
}
|
|
16864
|
+
}
|
|
16865
|
+
}
|
|
16866
|
+
return out;
|
|
16867
|
+
}
|
|
16868
|
+
|
|
16869
|
+
// src/service/scriptReadValidator.ts
|
|
16870
|
+
function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileReader, applicationSchema) {
|
|
16871
|
+
const blocks = parseLoadedScriptBlocks(html, stateTagName);
|
|
16872
|
+
if (blocks.length === 0) return [];
|
|
16873
|
+
const msgs = getMessages(locale2);
|
|
16874
|
+
const index = getStatePathIndex(html, stateTagName, fileReader);
|
|
16875
|
+
const candidates = mergeSchemaCandidates(index.paths, applicationSchema);
|
|
16876
|
+
const candidateSet = new Set(candidates.map((p) => p.path));
|
|
16877
|
+
let tree = null;
|
|
16878
|
+
const out = [];
|
|
16879
|
+
for (const block of blocks) {
|
|
16880
|
+
const spread = applicationSchema === void 0 ? findTopLevelSpread(block.content) : null;
|
|
16881
|
+
if (spread !== null) {
|
|
16882
|
+
out.push({
|
|
16883
|
+
code: WcsDiagnosticCode.PathDynamicUnknown,
|
|
16884
|
+
start: block.contentStart + spread.start,
|
|
16885
|
+
end: block.contentStart + spread.end,
|
|
16886
|
+
message: msgs.pathDynamicUnknownSpread(block.content.slice(spread.start, spread.end)),
|
|
16887
|
+
severity: "info"
|
|
16888
|
+
});
|
|
16889
|
+
}
|
|
16890
|
+
const prefix = block.mountPath === null || block.mountPath === "" ? "" : `${block.mountPath}.`;
|
|
16891
|
+
for (const callable of analyzeCallableBodies(block.content)) {
|
|
16892
|
+
for (const read of collectGetterReads(callable.body) ?? []) {
|
|
16893
|
+
if (read.written || read.path.split(".").some((s) => s === "" || s.startsWith("$")) || hasRecursionWildcard(read.path)) continue;
|
|
16894
|
+
const path = prefix + read.path;
|
|
16895
|
+
if (pathExistsInCandidates(path, candidates, candidateSet)) continue;
|
|
16896
|
+
if (applicationSchema !== void 0 ? resolveIndexedSchemaPath(applicationSchema, path).kind !== "nonexistent" : isUnresolvedPath(path, index.scopes)) continue;
|
|
16897
|
+
const near = nearName(path, tree ??= treeOf(candidates));
|
|
16898
|
+
if (near === null) continue;
|
|
16899
|
+
const said = suggestion(near.segment, near.names, msgs);
|
|
16900
|
+
if (said === "") continue;
|
|
16901
|
+
const at2 = block.contentStart + callable.bodyStart;
|
|
16902
|
+
out.push({
|
|
16903
|
+
code: WcsDiagnosticCode.ReadPathMissing,
|
|
16904
|
+
start: at2 + read.start,
|
|
16905
|
+
end: read.form === "member" ? at2 + read.start + statePart(callable.body.slice(read.start, read.end)) : at2 + read.end,
|
|
16906
|
+
message: msgs.readPathMissing(read.path, !read.path.includes(".")) + said,
|
|
16907
|
+
// a stateSchema says the path is not there, as for a binding's `wcs/path-nonexistent`
|
|
16908
|
+
severity: applicationSchema !== void 0 ? "error" : "warning"
|
|
16909
|
+
});
|
|
16910
|
+
}
|
|
16911
|
+
}
|
|
16912
|
+
}
|
|
16913
|
+
return out;
|
|
16914
|
+
}
|
|
16915
|
+
var THIS_PART = /^this\s*(?:\?\.\s*|\.\s*)(?:[A-Za-z_$][\w$]*)|^this\s*(?:\?\.)?\s*\[\s*(["'`])[^"'`]*\1\s*\]/;
|
|
16916
|
+
function statePart(text3) {
|
|
16917
|
+
return THIS_PART.exec(text3)?.[0].length ?? text3.length;
|
|
16918
|
+
}
|
|
16919
|
+
function treeOf(candidates) {
|
|
16920
|
+
const tree = /* @__PURE__ */ new Map();
|
|
16921
|
+
for (const c of candidates) {
|
|
16922
|
+
let parent = "";
|
|
16923
|
+
for (const segment of c.path.split(".")) {
|
|
16924
|
+
let names2 = tree.get(parent);
|
|
16925
|
+
if (names2 === void 0) tree.set(parent, names2 = /* @__PURE__ */ new Set());
|
|
16926
|
+
names2.add(segment);
|
|
16927
|
+
parent = parent === "" ? segment : `${parent}.${segment}`;
|
|
16928
|
+
}
|
|
16929
|
+
}
|
|
16930
|
+
return tree;
|
|
16931
|
+
}
|
|
16932
|
+
function nearName(path, tree) {
|
|
16933
|
+
let parent = "";
|
|
16934
|
+
for (const segment of (hasIndexSegment(path) ? toWildcardForm(path) : path).split(".")) {
|
|
16935
|
+
const names2 = tree.get(parent);
|
|
16936
|
+
if (names2?.has(segment)) {
|
|
16937
|
+
parent = parent === "" ? segment : `${parent}.${segment}`;
|
|
16938
|
+
continue;
|
|
16939
|
+
}
|
|
16940
|
+
return { segment, names: [...names2 ?? []].filter((name) => name !== "*" && !name.startsWith("$")) };
|
|
16941
|
+
}
|
|
16942
|
+
return null;
|
|
16943
|
+
}
|
|
16944
|
+
|
|
16494
16945
|
// src/core/sidecar/jsonSource.ts
|
|
16495
16946
|
var JsonReader = class {
|
|
16496
16947
|
constructor(text3) {
|
|
@@ -16878,13 +17329,104 @@ function joinRelativeSource(htmlSource, relativePath) {
|
|
|
16878
17329
|
return dirSegments.join("/");
|
|
16879
17330
|
}
|
|
16880
17331
|
|
|
17332
|
+
// src/core/externalState.ts
|
|
17333
|
+
var OPEN = '<script type="module">';
|
|
17334
|
+
var CLOSE = "</script>";
|
|
17335
|
+
function inlineExternalStates(html, stateTagName, fileReader) {
|
|
17336
|
+
let text3 = "";
|
|
17337
|
+
let from = 0;
|
|
17338
|
+
let shift = 0;
|
|
17339
|
+
const states = [];
|
|
17340
|
+
for (const element2 of parseWcsStateElements(html, stateTagName)) {
|
|
17341
|
+
const src = element2.srcSpan;
|
|
17342
|
+
if (src === void 0 || element2.srcAttr === void 0 || element2.stateAttr !== void 0 || element2.bindComponent) continue;
|
|
17343
|
+
const file = readStateScriptFile(element2.srcAttr, fileReader);
|
|
17344
|
+
if (file === void 0) continue;
|
|
17345
|
+
const blanks = [src];
|
|
17346
|
+
if (element2.jsonSpan !== void 0) blanks.push(element2.jsonSpan);
|
|
17347
|
+
blanks.sort((a, b) => a.start - b.start);
|
|
17348
|
+
for (const span of blanks) {
|
|
17349
|
+
text3 += html.slice(from, span.start) + " ".repeat(span.end - span.start);
|
|
17350
|
+
from = span.end;
|
|
17351
|
+
}
|
|
17352
|
+
text3 += html.slice(from, element2.tagEnd);
|
|
17353
|
+
from = element2.tagEnd;
|
|
17354
|
+
const content = file.text.replace(/<\/(script)/gi, "<\\$1");
|
|
17355
|
+
const at2 = element2.tagEnd + shift;
|
|
17356
|
+
const length = OPEN.length + content.length + CLOSE.length;
|
|
17357
|
+
text3 += OPEN + content + CLOSE;
|
|
17358
|
+
states.push({
|
|
17359
|
+
path: file.path,
|
|
17360
|
+
text: file.text,
|
|
17361
|
+
at: at2,
|
|
17362
|
+
contentAt: at2 + OPEN.length,
|
|
17363
|
+
length,
|
|
17364
|
+
valueStart: src.valueStart,
|
|
17365
|
+
valueEnd: src.valueEnd,
|
|
17366
|
+
position: createPositionMapper(file.text)
|
|
17367
|
+
});
|
|
17368
|
+
shift += length;
|
|
17369
|
+
}
|
|
17370
|
+
if (states.length === 0) return null;
|
|
17371
|
+
return { text: text3 + html.slice(from), states };
|
|
17372
|
+
}
|
|
17373
|
+
function locateInlined(page, offset2) {
|
|
17374
|
+
let shift = 0;
|
|
17375
|
+
for (const state of page.states) {
|
|
17376
|
+
if (offset2 < state.at) break;
|
|
17377
|
+
if (offset2 < state.at + state.length) {
|
|
17378
|
+
return { state, offset: Math.min(Math.max(offset2 - state.contentAt, 0), state.text.length) };
|
|
17379
|
+
}
|
|
17380
|
+
shift += state.length;
|
|
17381
|
+
}
|
|
17382
|
+
return { offset: offset2 - shift };
|
|
17383
|
+
}
|
|
17384
|
+
|
|
16881
17385
|
// src/core/validateDocument.ts
|
|
16882
17386
|
function validateDocument(text3, options = {}) {
|
|
17387
|
+
const stateTagName = options.stateTagName ?? "wcs-state";
|
|
17388
|
+
const fileReader = options.fileReader;
|
|
17389
|
+
const applicationSchema = options.applicationSchema ?? (fileReader !== void 0 ? discoverApplicationManifest(fileReader)?.schema : void 0);
|
|
17390
|
+
const found = validateText(text3, options, applicationSchema);
|
|
17391
|
+
const page = fileReader === void 0 ? null : inlineExternalStates(text3, stateTagName, fileReader);
|
|
17392
|
+
if (page === null) return found;
|
|
17393
|
+
const key = (d) => [d.code, d.start, d.end, d.message, d.origin?.path, d.origin?.start].join("\0");
|
|
17394
|
+
const seen2 = new Set(found.map(key));
|
|
17395
|
+
const out = [...found];
|
|
17396
|
+
for (const d of validateText(page.text, options, applicationSchema)) {
|
|
17397
|
+
const start = locateInlined(page, d.start);
|
|
17398
|
+
const end = locateInlined(page, d.end);
|
|
17399
|
+
let mapped;
|
|
17400
|
+
if (start.state !== void 0) {
|
|
17401
|
+
const state = start.state;
|
|
17402
|
+
const fileEnd = end.state === state ? Math.max(end.offset, start.offset) : start.offset;
|
|
17403
|
+
mapped = {
|
|
17404
|
+
...d,
|
|
17405
|
+
start: state.valueStart,
|
|
17406
|
+
end: state.valueEnd,
|
|
17407
|
+
origin: {
|
|
17408
|
+
path: state.path,
|
|
17409
|
+
start: start.offset,
|
|
17410
|
+
end: fileEnd,
|
|
17411
|
+
startPosition: state.position(start.offset),
|
|
17412
|
+
endPosition: state.position(fileEnd)
|
|
17413
|
+
}
|
|
17414
|
+
};
|
|
17415
|
+
} else {
|
|
17416
|
+
mapped = { ...d, start: start.offset, end: end.state === void 0 ? Math.max(end.offset, start.offset) : start.offset };
|
|
17417
|
+
}
|
|
17418
|
+
const k = key(mapped);
|
|
17419
|
+
if (seen2.has(k)) continue;
|
|
17420
|
+
seen2.add(k);
|
|
17421
|
+
out.push(mapped);
|
|
17422
|
+
}
|
|
17423
|
+
return sortDiagnostics(out);
|
|
17424
|
+
}
|
|
17425
|
+
function validateText(text3, options, applicationSchema) {
|
|
16883
17426
|
const bindAttribute = options.bindAttribute ?? "data-wcs";
|
|
16884
17427
|
const stateTagName = options.stateTagName ?? "wcs-state";
|
|
16885
17428
|
const locale2 = options.locale;
|
|
16886
17429
|
const fileReader = options.fileReader;
|
|
16887
|
-
const applicationSchema = options.applicationSchema ?? (fileReader !== void 0 ? discoverApplicationManifest(fileReader)?.schema : void 0);
|
|
16888
17430
|
const out = [];
|
|
16889
17431
|
out.push(...validateBindings(text3, bindAttribute, stateTagName, locale2, fileReader, applicationSchema));
|
|
16890
17432
|
out.push(...validateTemplateSyntax(text3, stateTagName, bindAttribute, locale2, fileReader, applicationSchema));
|
|
@@ -16893,6 +17435,8 @@ function validateDocument(text3, options = {}) {
|
|
|
16893
17435
|
out.push(...validateAriaAttributes(text3, bindAttribute, locale2));
|
|
16894
17436
|
out.push(...validateDocumentEnv(text3, locale2));
|
|
16895
17437
|
out.push(...validateSemantics(text3, stateTagName, locale2, bindAttribute));
|
|
17438
|
+
out.push(...validateScriptStateUses(text3, stateTagName, locale2, bindAttribute));
|
|
17439
|
+
out.push(...validateScriptReads(text3, stateTagName, locale2, fileReader, applicationSchema));
|
|
16896
17440
|
out.push(...validateArrayMutations(text3, stateTagName, locale2));
|
|
16897
17441
|
out.push(...validateWatchDeclarations(text3, stateTagName, locale2, fileReader));
|
|
16898
17442
|
out.push(...validateScanDeclarations(text3, stateTagName, locale2));
|
|
@@ -17064,6 +17608,7 @@ function runValidation(inputs, options = {}) {
|
|
|
17064
17608
|
explicitSchema = result.resolvedSchema;
|
|
17065
17609
|
}
|
|
17066
17610
|
}
|
|
17611
|
+
const inFiles = /* @__PURE__ */ new Map();
|
|
17067
17612
|
for (const input of inputs) {
|
|
17068
17613
|
if (input.kind !== "html") continue;
|
|
17069
17614
|
let applicationSchema = explicitSchema;
|
|
@@ -17083,8 +17628,24 @@ function runValidation(inputs, options = {}) {
|
|
|
17083
17628
|
...input.fileReader !== void 0 ? { fileReader: input.fileReader } : {},
|
|
17084
17629
|
...applicationSchema !== void 0 ? { applicationSchema } : {}
|
|
17085
17630
|
};
|
|
17086
|
-
|
|
17631
|
+
const own2 = [];
|
|
17632
|
+
for (const d of validateDocument(input.text, docOptions)) {
|
|
17633
|
+
if (d.origin === void 0) {
|
|
17634
|
+
own2.push(d);
|
|
17635
|
+
continue;
|
|
17636
|
+
}
|
|
17637
|
+
const source = joinRelativeSource(input.source, d.origin.path);
|
|
17638
|
+
if (!textBySource.has(source)) textBySource.set(source, input.fileReader?.(d.origin.path) ?? "");
|
|
17639
|
+
let list = inFiles.get(source);
|
|
17640
|
+
if (list === void 0) inFiles.set(source, list = []);
|
|
17641
|
+
const { origin, ...rest } = d;
|
|
17642
|
+
if (!list.some((x) => x.code === d.code && x.start === origin.start && x.end === origin.end && x.message === d.message)) {
|
|
17643
|
+
list.push({ ...rest, start: origin.start, end: origin.end });
|
|
17644
|
+
}
|
|
17645
|
+
}
|
|
17646
|
+
diagnosticsBySource.set(input.source, own2);
|
|
17087
17647
|
}
|
|
17648
|
+
for (const [source, list] of inFiles) diagnosticsBySource.set(source, sortDiagnostics(list));
|
|
17088
17649
|
const lines = [];
|
|
17089
17650
|
let errorCount = 0;
|
|
17090
17651
|
let warningCount = 0;
|