@wcstack/lint 4.19.0 → 4.21.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 +21 -3
- package/README.md +21 -3
- package/dist/cli.cjs +724 -122
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -22,6 +22,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
var cli_exports = {};
|
|
23
23
|
__export(cli_exports, {
|
|
24
24
|
createFileReader: () => createFileReader,
|
|
25
|
+
expandFileArgs: () => expandFileArgs,
|
|
25
26
|
main: () => main,
|
|
26
27
|
parseArgs: () => parseArgs,
|
|
27
28
|
resolveCliLocale: () => resolveCliLocale
|
|
@@ -66,6 +67,107 @@ function createFileReader(htmlPath, read = (p) => (0, import_node_fs.readFileSyn
|
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
// src/core/cli/glob.ts
|
|
71
|
+
function hasGlobMagic(arg) {
|
|
72
|
+
return /[*?[{]/.test(arg);
|
|
73
|
+
}
|
|
74
|
+
function expandGlob(pattern, fs) {
|
|
75
|
+
const found = /* @__PURE__ */ new Set();
|
|
76
|
+
for (const alternative of expandBraces(pattern)) {
|
|
77
|
+
const segments = alternative.split("/");
|
|
78
|
+
let i = 0;
|
|
79
|
+
while (i < segments.length - 1 && !hasGlobMagic(segments[i])) i++;
|
|
80
|
+
const base = segments.slice(0, i).join("/");
|
|
81
|
+
walk(fs, base === "" && alternative.startsWith("/") ? "/" : base, segments.slice(i), found);
|
|
82
|
+
}
|
|
83
|
+
return [...found].sort();
|
|
84
|
+
}
|
|
85
|
+
function join(dir, name) {
|
|
86
|
+
if (dir === "") return name;
|
|
87
|
+
return dir.endsWith("/") ? dir + name : `${dir}/${name}`;
|
|
88
|
+
}
|
|
89
|
+
function walk(fs, dir, segments, found) {
|
|
90
|
+
const [segment, ...rest] = segments;
|
|
91
|
+
if (segment === "**") {
|
|
92
|
+
if (rest.length === 0) {
|
|
93
|
+
walk(fs, dir, ["**", "*"], found);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
walk(fs, dir, rest, found);
|
|
97
|
+
for (const entry of fs.readDir(dir === "" ? "." : dir) ?? []) {
|
|
98
|
+
if (!entry.dir || entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
99
|
+
walk(fs, join(dir, entry.name), segments, found);
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const entries = fs.readDir(dir === "" ? "." : dir);
|
|
104
|
+
if (entries === void 0) return;
|
|
105
|
+
const matches = segmentMatcher(segment);
|
|
106
|
+
for (const entry of entries) {
|
|
107
|
+
if (!matches(entry.name)) continue;
|
|
108
|
+
if (rest.length === 0) {
|
|
109
|
+
if (!entry.dir) found.add(join(dir, entry.name));
|
|
110
|
+
} else if (entry.dir) {
|
|
111
|
+
walk(fs, join(dir, entry.name), rest, found);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function segmentMatcher(segment) {
|
|
116
|
+
if (!hasGlobMagic(segment)) return (name) => name === segment;
|
|
117
|
+
let source = "";
|
|
118
|
+
for (let i = 0; i < segment.length; i++) {
|
|
119
|
+
const ch = segment[i];
|
|
120
|
+
if (ch === "*") {
|
|
121
|
+
source += "[^/]*";
|
|
122
|
+
} else if (ch === "?") {
|
|
123
|
+
source += "[^/]";
|
|
124
|
+
} else if (ch === "[") {
|
|
125
|
+
const close = segment.indexOf("]", i + 2);
|
|
126
|
+
if (close === -1) {
|
|
127
|
+
source += "\\[";
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
let body = segment.slice(i + 1, close);
|
|
131
|
+
const negate = body.startsWith("!") || body.startsWith("^");
|
|
132
|
+
if (negate) body = body.slice(1);
|
|
133
|
+
source += `[${negate ? "^" : ""}${body.replace(/[\\\]]/g, "\\$&")}]`;
|
|
134
|
+
i = close;
|
|
135
|
+
} else {
|
|
136
|
+
source += ch.replace(/[.+^${}()|\\\]]/g, "\\$&");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const regex = new RegExp(`^${source}$`);
|
|
140
|
+
const dotted = segment.startsWith(".");
|
|
141
|
+
return (name) => (dotted || !name.startsWith(".")) && regex.test(name);
|
|
142
|
+
}
|
|
143
|
+
function expandBraces(pattern) {
|
|
144
|
+
const open = pattern.indexOf("{");
|
|
145
|
+
if (open === -1) return [pattern];
|
|
146
|
+
let depth = 0;
|
|
147
|
+
const commas = [];
|
|
148
|
+
for (let i = open; i < pattern.length; i++) {
|
|
149
|
+
const ch = pattern[i];
|
|
150
|
+
if (ch === "{") depth++;
|
|
151
|
+
else if (ch === "}") {
|
|
152
|
+
depth--;
|
|
153
|
+
if (depth === 0) {
|
|
154
|
+
if (commas.length === 0) return expandBraces(pattern.slice(i + 1)).map((tail2) => pattern.slice(0, i + 1) + tail2);
|
|
155
|
+
const head = pattern.slice(0, open);
|
|
156
|
+
const tail = pattern.slice(i + 1);
|
|
157
|
+
const bounds = [open, ...commas, i];
|
|
158
|
+
const out = [];
|
|
159
|
+
for (let k = 0; k < bounds.length - 1; k++) {
|
|
160
|
+
out.push(...expandBraces(head + pattern.slice(bounds[k] + 1, bounds[k + 1]) + tail));
|
|
161
|
+
}
|
|
162
|
+
return out;
|
|
163
|
+
}
|
|
164
|
+
} else if (ch === "," && depth === 1) {
|
|
165
|
+
commas.push(i);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return [pattern];
|
|
169
|
+
}
|
|
170
|
+
|
|
69
171
|
// src/core/diagnostics.ts
|
|
70
172
|
var WcsDiagnosticCode = {
|
|
71
173
|
// --- sidecar manifest envelope / schema subset ---
|
|
@@ -103,6 +205,11 @@ var WcsDiagnosticCode = {
|
|
|
103
205
|
// lint の限界の告知(作者の誤りではない): 読めない `<wcs-state src>`(/ から始まるパス・URL・無いファイル)の state は
|
|
104
206
|
// パスもスクリプトの規則も検査しない — それを src の上で 1 回だけ言う。info(docs/seam-apps.md、prod-booking)。
|
|
105
207
|
StateSrcUnread: "wcs/state-src-unread",
|
|
208
|
+
// lint の限界の告知(作者の誤りとは限らない): 束縛(`data-wcs`・コメント束縛)があるのに `<wcs-state>` の無いファイル
|
|
209
|
+
// (ページが取り込む CMS の部分テンプレート・ルートの中身の断片・state をスクリプトで作るページ)。束縛のパスは
|
|
210
|
+
// 検査していない — それをファイルに 1 回だけ、最初の束縛の上で言う。stateSchema があれば検査するので黙る。info
|
|
211
|
+
// (継ぎ目アプリ community-hall — 何も出ず `nothing to check:` にも載らないので、検査済みに見えた)。
|
|
212
|
+
StateAbsent: "wcs/state-absent",
|
|
106
213
|
// --- existing binding-expression validators (retrofitted) ---
|
|
107
214
|
FilterUnknown: "wcs/filter-unknown",
|
|
108
215
|
FilterArity: "wcs/filter-arity",
|
|
@@ -116,6 +223,11 @@ var WcsDiagnosticCode = {
|
|
|
116
223
|
// `command.<method>:` 束縛にも結ばれていない。emit は誰にも届かず、ランタイムは何も言わない(7GUIs の評価)。warning
|
|
117
224
|
// (ページの外 — 別ファイルのルートのテンプレート — で束ねる形は見えない)。
|
|
118
225
|
CommandTokenUnbound: "wcs/command-token-unbound",
|
|
226
|
+
// `$eventTokens` に宣言したのに、ドキュメントのどの `eventToken.<member>: <name>` 束縛も出さないトークン(command-token-unbound
|
|
227
|
+
// の逆)。どの要素も発火させないので `$on` のハンドラは走らず、ランタイムは何も言わない(継ぎ目アプリ ledger-repair — 束縛と
|
|
228
|
+
// ハンドラを外して `deleteFetch.status` を見た)。warning。ファイルから読むレイアウト(`<wcs-layout src>`)や、state の
|
|
229
|
+
// モジュールのほかに `eventToken.` の束縛を書くスクリプトがあるページは、見えない束縛が出しうるので黙る。root の state だけ。
|
|
230
|
+
EventTokenUnbound: "wcs/event-token-unbound",
|
|
119
231
|
// state が宣言していないトップレベルのキーへの書き込み(`this.selectedID = …` と `selectedId`)。新しいキーができる
|
|
120
232
|
// だけで、宣言したキーの束縛は変わらない。ランタイムは何も言わない。近い名前(打ち間違い)があるときだけ、warning。
|
|
121
233
|
WritePathMissing: "wcs/write-path-missing",
|
|
@@ -253,8 +365,15 @@ var WcsDiagnosticCode = {
|
|
|
253
365
|
DelegatedCurrentTarget: "wcs/delegated-current-target",
|
|
254
366
|
// `<form data-wcs="onsubmit: login">` の `#prevent` 忘れ(ハンドラも preventDefault を呼ばない)。ブラウザが
|
|
255
367
|
// フォームも送る — ページが読み直されるか、router があれば GET が欄(パスワードも)を URL と履歴に載せる
|
|
256
|
-
// (docs/seam-apps.md、router-auth)。
|
|
368
|
+
// (docs/seam-apps.md、router-auth)。error(4.21 から — 4.20 までは warning で、`--errors-only` に隠れた: 継ぎ目アプリ
|
|
369
|
+
// ledger-repair)。action 付きのフォームと、読めないハンドラでは黙る。
|
|
257
370
|
SubmitWithoutPrevent: "wcs/submit-without-prevent",
|
|
371
|
+
// `localStorage` / `sessionStorage` / `document.cookie` を、1 回しか評価されないモジュールのトップレベル(関数の外)で読む。
|
|
372
|
+
// `<wcs-guard-handler>` のモジュールは 1 回だけ評価され、export した関数が遷移のたびに走る(router の README)ので、ガードは
|
|
373
|
+
// 読み込みの時点のセッションで決め続ける — ログインしても守られたページはすべて /login へ戻され、何も言わない(継ぎ目アプリ
|
|
374
|
+
// ledger-repair)。ガードは error、`<wcs-state>` のモジュール(インライン・`src=`)は warning(state は読み込みの時点の値を
|
|
375
|
+
// 持ち続ける — 意図した種もありうる)。関数の中(export した関数・そこから呼ぶ補助関数・getter・メソッド)の読みは黙る。
|
|
376
|
+
SessionReadAtModuleTop: "wcs/session-read-at-module-top",
|
|
258
377
|
// 4.0 で外れた API の旧名(`this.$trackDependency` → `$dependOn`、`$untrackDependency` → `$untracked`)。
|
|
259
378
|
// ランタイムは読んだ時点で同じ code(#1701)で throw するので error。3.x(3.2〜3.3)では「動くが 4.0 で
|
|
260
379
|
// 外れる」info だった。フィルタの旧名(`uc` など)は 4.0 のランタイムと同じく `wcs/filter-unknown` で、
|
|
@@ -325,8 +444,16 @@ var WcsDiagnosticCode = {
|
|
|
325
444
|
// wcstack を自分で読み込むページが、あるパッケージのタグ(`<wcs-upload>`・`<wcs-upload-header>`)を書くのに、その
|
|
326
445
|
// パッケージのスクリプトを読み込んでいない。要素は定義されず、束縛は待ち続け、コンソールにも何も出ない(継ぎ目アプリ
|
|
327
446
|
// homeroom — 保存が「送信中 0%」で止まった)。パッケージごとに 1 回、最初のタグに。読めないローカルのスクリプトがある
|
|
328
|
-
// ページ・autoloader の `@components/` が覆うタグ・wcstack を自分で読み込まないページ(断片・バンドラ)では黙る。
|
|
447
|
+
// ページ・autoloader の `@components/` が覆うタグ・wcstack を自分で読み込まないページ(断片・バンドラ)では黙る。error
|
|
448
|
+
// (4.21 から — 4.20 までは warning で、`--errors-only` に隠れた: 継ぎ目アプリ ledger-repair)。
|
|
329
449
|
TagPackageMissing: "wcs/tag-package-missing",
|
|
450
|
+
// `<wcs-router>` の無いページの、内部のパス(`to="/…"`)へ飛ぶ `<wcs-link>`。リンクは接続で
|
|
451
|
+
// `[@wcstack/router] wcs-link is not connected to a router.` を投げ、ホストは `display: none` のまま `<a>` を作らない
|
|
452
|
+
// — リンクが消える(継ぎ目アプリ community-hall — サーバーが描くページにアイランドを置く形)。wcstack を自分で
|
|
453
|
+
// 読み込み、router を読み込むページだけ(断片・ルートの中身・レイアウトのファイルは黙る)。router を読み込まない
|
|
454
|
+
// ページは `wcs/tag-package-missing` が報告する。ページが HTML コメントの外のどこかで `wcs-router` を名指せば
|
|
455
|
+
// (`<template>` の中の `<wcs-router>`・それを作るスクリプトも)黙る。warning。
|
|
456
|
+
LinkRouterMissing: "wcs/link-router-missing",
|
|
330
457
|
// ページの URL が、lint の規則の版(lint を作った @wcstack/state の版)より新しい minor の wcstack を固定している
|
|
331
458
|
// (`@wcstack/state@4.11.0` と lint 4.10.1)。古い lint は新しい規則を知らず、新しい正しい書き方を error にもする
|
|
332
459
|
// (homeroom — 4.2.0 の lint が 4.10 の `datetime(ja-JP,short,Asia/Tokyo)` を `wcs/filter-arity` に)。ページに 1 回、
|
|
@@ -779,10 +906,13 @@ var SENTENCES = {
|
|
|
779
906
|
42
|
|
780
907
|
/* InlineBlocked */
|
|
781
908
|
]: () => `The inline <script> of <wcs-state> was blocked by Content-Security-Policy. Inline state is evaluated through a blob: URL: give the page's nonce to the <script> that loads @wcstack/state, or allow blob: in script-src. Moving the state into an external file (src="./state.js") needs neither. See ${CSP_GUIDE}`,
|
|
909
|
+
// an import that does not resolve (Chromium "Failed to resolve module specifier", Firefox "… specifier …",
|
|
910
|
+
// WebKit "does not resolve"): the blob: URL is the base — no CSP is involved (community-hall, D6). (A browser's
|
|
911
|
+
// own sentence ends with a period of its own: one is enough)
|
|
782
912
|
[
|
|
783
913
|
43
|
|
784
914
|
/* InlineFailed */
|
|
785
|
-
]: (detail) => `Failed to evaluate the inline <script> of <wcs-state>: ${detail}. If this page sets a Content-Security-Policy, see ${CSP_GUIDE}`,
|
|
915
|
+
]: (detail) => `Failed to evaluate the inline <script> of <wcs-state>: ${String(detail).replace(/\.$/, "")}. ${/specifier|does not resolve/i.test(String(detail)) ? `An inline state is evaluated from a blob: URL, against which a relative or root-relative import ("./x.js", "/js/x.js") does not resolve: import a full URL, or a name the page's import map gives ({ "imports": { "@app/": "/js/" } }), or move the state into a file (src="./state.js").` : `If this page sets a Content-Security-Policy, see ${CSP_GUIDE}`}`,
|
|
786
916
|
[
|
|
787
917
|
17
|
|
788
918
|
/* TokenSubscriberThrew */
|
|
@@ -1859,7 +1989,7 @@ var config = {
|
|
|
1859
1989
|
locale: typeof document !== "undefined" ? document.documentElement?.lang || "en" : "en",
|
|
1860
1990
|
enableContractAnalyzer: false
|
|
1861
1991
|
};
|
|
1862
|
-
var FEATURE_NAMES = ["formats", "diagnostics", "temporal", "list-keys", "scopes", "recursion", "ssr", "devtools", "native-commands"];
|
|
1992
|
+
var FEATURE_NAMES = ["formats", "diagnostics", "temporal", "list-keys", "scopes", "recursion", "ssr", "devtools", "native-commands", "release"];
|
|
1863
1993
|
var NATIVE_COMMANDS = {
|
|
1864
1994
|
"*": ["focus", "blur", "click", "scrollIntoView", "showPopover", "hidePopover", "togglePopover"],
|
|
1865
1995
|
"dialog": ["show", "showModal", "close", "requestClose"],
|
|
@@ -2111,7 +2241,7 @@ var truncate = (options) => {
|
|
|
2111
2241
|
return v.slice(0, maxLength) + suffix;
|
|
2112
2242
|
};
|
|
2113
2243
|
};
|
|
2114
|
-
var
|
|
2244
|
+
var join2 = (options) => {
|
|
2115
2245
|
const opt = options?.[0] ?? ", ";
|
|
2116
2246
|
return (value) => {
|
|
2117
2247
|
if (!Array.isArray(value)) {
|
|
@@ -2220,8 +2350,9 @@ var coalesce = (options, literals) => {
|
|
|
2220
2350
|
var nullIfEmpty = () => (value) => value === "" ? null : value;
|
|
2221
2351
|
var { eq: eq2, ne: ne2, not: not2, lt, le, gt, ge, falsy: falsy2, truthy: truthy2, boolean: boolean2 } = coreFilters;
|
|
2222
2352
|
var registered = {
|
|
2223
|
-
|
|
2224
|
-
|
|
2353
|
+
// The number display family passes an absent value through too (since 4.20 — see nullishPassthrough)
|
|
2354
|
+
toFixed: { factory: nullishPassthrough(toFixed), arity: [0, 1] },
|
|
2355
|
+
locale: { factory: nullishPassthrough(locale), arity: [0, 1] },
|
|
2225
2356
|
// The `String(value)` family passes an absent value through (B8 — see nullishPassthrough)
|
|
2226
2357
|
upper: { factory: nullishPassthrough(upper), arity: [0, 0] },
|
|
2227
2358
|
lower: { factory: nullishPassthrough(lower), arity: [0, 0] },
|
|
@@ -2234,11 +2365,11 @@ var registered = {
|
|
|
2234
2365
|
repeat: { factory: nullishPassthrough(repeat), arity: [1, 1] },
|
|
2235
2366
|
reverse: { factory: nullishPassthrough(reverse), arity: [0, 0] },
|
|
2236
2367
|
truncate: { factory: nullishPassthrough(truncate), arity: [1, 2] },
|
|
2237
|
-
join: { factory:
|
|
2238
|
-
round: { factory: round, arity: [0, 1] },
|
|
2239
|
-
floor: { factory: floor, arity: [0, 1] },
|
|
2240
|
-
ceil: { factory: ceil, arity: [0, 1] },
|
|
2241
|
-
percent: { factory: percent, arity: [0, 1] },
|
|
2368
|
+
join: { factory: join2, arity: [0, 1] },
|
|
2369
|
+
round: { factory: nullishPassthrough(round), arity: [0, 1] },
|
|
2370
|
+
floor: { factory: nullishPassthrough(floor), arity: [0, 1] },
|
|
2371
|
+
ceil: { factory: nullishPassthrough(ceil), arity: [0, 1] },
|
|
2372
|
+
percent: { factory: nullishPassthrough(percent), arity: [0, 1] },
|
|
2242
2373
|
unit: { factory: nullishPassthrough(unit), arity: [1, 1] },
|
|
2243
2374
|
// The locale-dependent three take a locale like `locale` does (`date(ja-JP)`), a style (`date(ja-JP,long)`)
|
|
2244
2375
|
// and, since 4.10, a time zone (`date(ja-JP,long,Asia/Tokyo)`)
|
|
@@ -2273,7 +2404,7 @@ var registered = {
|
|
|
2273
2404
|
string: { factory: string, arity: [0, 0] },
|
|
2274
2405
|
nullIfEmpty: { factory: nullIfEmpty, arity: [0, 0] },
|
|
2275
2406
|
// (added in 4.2: last, so the order of the others is unchanged)
|
|
2276
|
-
currency: { factory: currency, arity: [1, 2] }
|
|
2407
|
+
currency: { factory: nullishPassthrough(currency), arity: [1, 2] }
|
|
2277
2408
|
};
|
|
2278
2409
|
var formatFilters = /* @__PURE__ */ Object.fromEntries(
|
|
2279
2410
|
/* @__PURE__ */ Object.entries(registered).filter(([name]) => !(name in coreFilters))
|
|
@@ -2425,7 +2556,7 @@ function getWcsManifest() {
|
|
|
2425
2556
|
}
|
|
2426
2557
|
|
|
2427
2558
|
// ../state/package.json
|
|
2428
|
-
var version = "4.
|
|
2559
|
+
var version = "4.21.0";
|
|
2429
2560
|
|
|
2430
2561
|
// src/service/wcsManifest.ts
|
|
2431
2562
|
var ENGINE_VERSION = version;
|
|
@@ -2450,7 +2581,72 @@ var STRUCTURAL_DIRECTIVES = [...STRUCTURAL_BINDING_TYPE_SET2].map((name) => ({
|
|
|
2450
2581
|
...STRUCTURAL_DIRECTIVE_INFO[name]
|
|
2451
2582
|
}));
|
|
2452
2583
|
|
|
2584
|
+
// src/service/indexPath.ts
|
|
2585
|
+
var INDEX_SEGMENT = /^\d/;
|
|
2586
|
+
function isIndexSegment(segment) {
|
|
2587
|
+
return INDEX_SEGMENT.test(segment);
|
|
2588
|
+
}
|
|
2589
|
+
function hasIndexSegment(path) {
|
|
2590
|
+
return path.split(".").some((segment) => INDEX_SEGMENT.test(segment));
|
|
2591
|
+
}
|
|
2592
|
+
function toWildcardForm(path) {
|
|
2593
|
+
if (!hasIndexSegment(path)) return path;
|
|
2594
|
+
return path.split(".").map((segment) => INDEX_SEGMENT.test(segment) ? "*" : segment).join(".");
|
|
2595
|
+
}
|
|
2596
|
+
function candidateKeyOf(path, has) {
|
|
2597
|
+
return has(path) ? path : toWildcardForm(path);
|
|
2598
|
+
}
|
|
2599
|
+
var UNSAFE_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype"]);
|
|
2600
|
+
function hasUnsafeSegment(path) {
|
|
2601
|
+
return path.split(".").some((segment) => UNSAFE_SEGMENTS.has(segment));
|
|
2602
|
+
}
|
|
2603
|
+
var { maxDepth } = getWcsManifest().syntax.indexParam;
|
|
2604
|
+
var MAX_INDEX_PARAM3 = maxDepth;
|
|
2605
|
+
var INDEX_PARAM = new RegExp(`^\\$[1-9]\\d{0,${String(maxDepth).length - 1}}$`);
|
|
2606
|
+
function classifyIndexParam(path) {
|
|
2607
|
+
if (!/^\$\d+$/.test(path)) return null;
|
|
2608
|
+
if (!INDEX_PARAM.test(path)) return { kind: "notIndex" };
|
|
2609
|
+
const n = Number(path.slice(1));
|
|
2610
|
+
return n <= MAX_INDEX_PARAM3 ? { kind: "index", n } : { kind: "range", n };
|
|
2611
|
+
}
|
|
2612
|
+
function isOutOfRangeIndexRead(name) {
|
|
2613
|
+
if (name.length < 2 || name.charCodeAt(0) !== 36) return false;
|
|
2614
|
+
const c = name.charCodeAt(1);
|
|
2615
|
+
if (c < 48 || c > 57) return false;
|
|
2616
|
+
return !INDEX_PARAM.test(name) || Number(name.slice(1)) > MAX_INDEX_PARAM3;
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2453
2619
|
// src/service/suggestion.ts
|
|
2620
|
+
function pathTree(candidates) {
|
|
2621
|
+
const tree = /* @__PURE__ */ new Map();
|
|
2622
|
+
for (const c of candidates) {
|
|
2623
|
+
let parent = "";
|
|
2624
|
+
for (const segment of c.path.split(".")) {
|
|
2625
|
+
let names2 = tree.get(parent);
|
|
2626
|
+
if (names2 === void 0) tree.set(parent, names2 = /* @__PURE__ */ new Set());
|
|
2627
|
+
names2.add(segment);
|
|
2628
|
+
parent = parent === "" ? segment : `${parent}.${segment}`;
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
return tree;
|
|
2632
|
+
}
|
|
2633
|
+
function missingSegment(path, tree) {
|
|
2634
|
+
let parent = "";
|
|
2635
|
+
for (const segment of (hasIndexSegment(path) ? toWildcardForm(path) : path).split(".")) {
|
|
2636
|
+
const names2 = tree.get(parent);
|
|
2637
|
+
if (names2?.has(segment)) {
|
|
2638
|
+
parent = parent === "" ? segment : `${parent}.${segment}`;
|
|
2639
|
+
continue;
|
|
2640
|
+
}
|
|
2641
|
+
return { segment, parent, names: [...names2 ?? []].filter((name) => name !== "*" && !name.startsWith("$")) };
|
|
2642
|
+
}
|
|
2643
|
+
return null;
|
|
2644
|
+
}
|
|
2645
|
+
function rowFieldSuggestion(path, candidates, msgs) {
|
|
2646
|
+
const missing = missingSegment(path, pathTree(candidates));
|
|
2647
|
+
if (missing === null || !missing.parent.split(".").includes("*")) return "";
|
|
2648
|
+
return suggestion(missing.segment, missing.names, msgs);
|
|
2649
|
+
}
|
|
2454
2650
|
function suggestion(input, candidates, msgs) {
|
|
2455
2651
|
let best = null;
|
|
2456
2652
|
let bestDistance = 3;
|
|
@@ -8186,6 +8382,8 @@ function parse3(input, options) {
|
|
|
8186
8382
|
var UNKNOWN = { kind: "unknown" };
|
|
8187
8383
|
var NULL_TYPE = { kind: "name", name: "null" };
|
|
8188
8384
|
var ARRAY_GENERICS = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
8385
|
+
var INDEX_GENERICS = /* @__PURE__ */ new Set(["Record", "Object"]);
|
|
8386
|
+
var SAME_SHAPE_GENERICS = /* @__PURE__ */ new Set(["Readonly", "Partial", "Required"]);
|
|
8189
8387
|
var MAX_RESOLVE_DEPTH = 8;
|
|
8190
8388
|
function tokenize(text3) {
|
|
8191
8389
|
const tokens = [];
|
|
@@ -8327,6 +8525,10 @@ function parseJsDocType(text3) {
|
|
|
8327
8525
|
if (isPunct(".") && tokens[pos + 1]?.t === "punct" && tokens[pos + 1].v === "<") pos++;
|
|
8328
8526
|
if (isPunct("<")) {
|
|
8329
8527
|
pos++;
|
|
8528
|
+
if (name === "Record") {
|
|
8529
|
+
const literal2 = parseLiteralKeyRecord();
|
|
8530
|
+
if (literal2 !== void 0) return literal2;
|
|
8531
|
+
}
|
|
8330
8532
|
const args = [];
|
|
8331
8533
|
for (; ; ) {
|
|
8332
8534
|
const arg = parseUnion();
|
|
@@ -8335,20 +8537,47 @@ function parseJsDocType(text3) {
|
|
|
8335
8537
|
if (!expect(",")) break;
|
|
8336
8538
|
}
|
|
8337
8539
|
if (!expect(">")) return null;
|
|
8338
|
-
|
|
8540
|
+
if (ARRAY_GENERICS.has(name) && args.length === 1) return { kind: "array", element: args[0] };
|
|
8541
|
+
if (INDEX_GENERICS.has(name) && args.length === 2) return { kind: "object", fields: [], index: args[1] };
|
|
8542
|
+
if (SAME_SHAPE_GENERICS.has(name) && args.length === 1) return args[0];
|
|
8543
|
+
return UNKNOWN;
|
|
8339
8544
|
}
|
|
8340
8545
|
return { kind: "name", name };
|
|
8341
8546
|
};
|
|
8547
|
+
const parseLiteralKeyRecord = () => {
|
|
8548
|
+
const start = pos;
|
|
8549
|
+
const keys = [];
|
|
8550
|
+
expect("|");
|
|
8551
|
+
for (; ; ) {
|
|
8552
|
+
const token = peek();
|
|
8553
|
+
if (token === void 0 || token.t !== "string") break;
|
|
8554
|
+
keys.push(token.v);
|
|
8555
|
+
pos++;
|
|
8556
|
+
if (!expect("|")) break;
|
|
8557
|
+
}
|
|
8558
|
+
if (keys.length === 0 || !expect(",")) {
|
|
8559
|
+
pos = start;
|
|
8560
|
+
return void 0;
|
|
8561
|
+
}
|
|
8562
|
+
const value = parseUnion();
|
|
8563
|
+
if (value === null || !expect(">")) return null;
|
|
8564
|
+
return { kind: "object", fields: keys.map((name) => ({ name, type: value })) };
|
|
8565
|
+
};
|
|
8342
8566
|
const parseObject = () => {
|
|
8343
8567
|
pos++;
|
|
8344
8568
|
const fields = [];
|
|
8569
|
+
let index;
|
|
8345
8570
|
while (!isPunct("}")) {
|
|
8346
8571
|
const key = peek();
|
|
8347
8572
|
if (key === void 0) return null;
|
|
8348
8573
|
if (key.t === "punct" && key.v === "[") {
|
|
8349
8574
|
pos++;
|
|
8350
8575
|
if (!skipUntilClose("[", "]")) return null;
|
|
8351
|
-
|
|
8576
|
+
expect("?");
|
|
8577
|
+
if (!expect(":")) return null;
|
|
8578
|
+
const value = parseUnion();
|
|
8579
|
+
if (value === null) return null;
|
|
8580
|
+
index = index === void 0 ? value : { kind: "union", members: [index, value] };
|
|
8352
8581
|
} else {
|
|
8353
8582
|
if (key.t !== "name" && key.t !== "string") return null;
|
|
8354
8583
|
pos++;
|
|
@@ -8360,7 +8589,7 @@ function parseJsDocType(text3) {
|
|
|
8360
8589
|
}
|
|
8361
8590
|
if (!expect(",") && !expect(";")) break;
|
|
8362
8591
|
}
|
|
8363
|
-
return expect("}") ? { kind: "object", fields } : null;
|
|
8592
|
+
return expect("}") ? { kind: "object", fields, ...index !== void 0 ? { index } : {} } : null;
|
|
8364
8593
|
};
|
|
8365
8594
|
const skipUntilClose = (open, close) => {
|
|
8366
8595
|
let depth = 0;
|
|
@@ -8466,16 +8695,19 @@ function jsDocTypeHint(type, typedefs = /* @__PURE__ */ new Map()) {
|
|
|
8466
8695
|
function jsDocShape(type, typedefs) {
|
|
8467
8696
|
const elements = [];
|
|
8468
8697
|
const fields = [];
|
|
8698
|
+
const indexes = [];
|
|
8469
8699
|
for (const member of flattenJsDocType(type, typedefs)) {
|
|
8470
8700
|
if (member.kind === "array") elements.push(member.element);
|
|
8471
8701
|
else if (member.kind === "object") {
|
|
8472
8702
|
for (const field of member.fields) {
|
|
8473
8703
|
if (!fields.some((f) => f.name === field.name)) fields.push(field);
|
|
8474
8704
|
}
|
|
8705
|
+
if (member.index !== void 0) indexes.push(member.index);
|
|
8475
8706
|
}
|
|
8476
8707
|
}
|
|
8477
8708
|
const element2 = elements.length === 0 ? null : elements.length === 1 ? elements[0] : { kind: "union", members: elements };
|
|
8478
|
-
return { element: element2, fields };
|
|
8709
|
+
if (indexes.length === 0) return { element: element2, fields };
|
|
8710
|
+
return { element: element2, fields, index: indexes.length === 1 ? indexes[0] : { kind: "union", members: indexes } };
|
|
8479
8711
|
}
|
|
8480
8712
|
|
|
8481
8713
|
// src/service/moduleValues.ts
|
|
@@ -8873,8 +9105,30 @@ function analyzeStatePaths(scriptContent, location) {
|
|
|
8873
9105
|
}
|
|
8874
9106
|
collectRowShapesFromAssignments(scriptContent, paths);
|
|
8875
9107
|
collectGetterResultShapes(scriptContent, root.start, topLevelProps, effectiveDescriptors, paths);
|
|
9108
|
+
markRowsChangedInPlace(scriptContent, paths);
|
|
8876
9109
|
return paths;
|
|
8877
9110
|
}
|
|
9111
|
+
var ROWS_IN_PLACE_CALL = /\bthis\s*(?:\?\.|\.)\s*([\w$]+)\s*\??\.\s*(?:push|unshift|splice|fill)\s*\(|\bthis\s*(?:\?\.)?\s*\[\s*(["'])([^"']*)\2\s*\]\s*\??\.\s*(?:push|unshift|splice|fill)\s*\(/dg;
|
|
9112
|
+
var ROWS_IN_PLACE_ASSIGN = /\bthis\s*(?:\?\.|\.)\s*([\w$]+)\s*(?:\?\.)?\s*\[(?!\s*["'])[^[\]]+\]\s*=(?!=)/dg;
|
|
9113
|
+
function markRowsChangedInPlace(scriptContent, paths) {
|
|
9114
|
+
if (!/\b(?:push|unshift|splice|fill)\s*\(|\]\s*=(?!=)/.test(scriptContent)) return;
|
|
9115
|
+
const masked = maskCommentsAndStrings(scriptContent);
|
|
9116
|
+
const changed = /* @__PURE__ */ new Set();
|
|
9117
|
+
ROWS_IN_PLACE_CALL.lastIndex = 0;
|
|
9118
|
+
let m;
|
|
9119
|
+
while ((m = ROWS_IN_PLACE_CALL.exec(masked)) !== null) {
|
|
9120
|
+
if (m[1] !== void 0) changed.add(m[1]);
|
|
9121
|
+
else if (m.indices?.[3] !== void 0) changed.add(scriptContent.slice(m.indices[3][0], m.indices[3][1]));
|
|
9122
|
+
}
|
|
9123
|
+
ROWS_IN_PLACE_ASSIGN.lastIndex = 0;
|
|
9124
|
+
while ((m = ROWS_IN_PLACE_ASSIGN.exec(masked)) !== null) changed.add(m[1]);
|
|
9125
|
+
for (const list of changed) {
|
|
9126
|
+
const rows = paths.find((p) => p.path === `${list}.*` && p.kind === "list");
|
|
9127
|
+
if (rows === void 0 || rows.openKeys === true) continue;
|
|
9128
|
+
const fields = paths.some((p) => p.path.startsWith(`${list}.*.`) && (p.kind === "data" || p.kind === "list"));
|
|
9129
|
+
if (!fields) rows.openKeys = true;
|
|
9130
|
+
}
|
|
9131
|
+
}
|
|
8878
9132
|
function specFromRecursionValue(prop) {
|
|
8879
9133
|
if (!prop || prop.kind !== "data" || !prop.value || !isObjectLiteral(prop.value)) return null;
|
|
8880
9134
|
const entries = parseTopLevelProperties(extractObjectContent(prop.value)).filter((e) => e.kind === "data");
|
|
@@ -9892,6 +10146,10 @@ function followValue(prop, scope) {
|
|
|
9892
10146
|
}
|
|
9893
10147
|
function pushDeclaredShapePaths(path, type, paths, depth, typedefs) {
|
|
9894
10148
|
const shape = jsDocShape(type, typedefs);
|
|
10149
|
+
if (shape.index !== void 0) {
|
|
10150
|
+
const candidate = paths.find((p) => p.path === path);
|
|
10151
|
+
if (candidate !== void 0) candidate.openKeys = true;
|
|
10152
|
+
}
|
|
9895
10153
|
if (shape.element !== null) {
|
|
9896
10154
|
if (!hasPath(paths, `${path}.*`)) paths.push({ path: `${path}.*`, kind: "list" });
|
|
9897
10155
|
if (!hasPath(paths, `${path}.length`)) paths.push({ path: `${path}.length`, kind: "data", typeHint: "number" });
|
|
@@ -10362,41 +10620,6 @@ function withHint(candidate, typeHint) {
|
|
|
10362
10620
|
return typeHint === void 0 ? candidate : { ...candidate, typeHint };
|
|
10363
10621
|
}
|
|
10364
10622
|
|
|
10365
|
-
// src/service/indexPath.ts
|
|
10366
|
-
var INDEX_SEGMENT = /^\d/;
|
|
10367
|
-
function isIndexSegment(segment) {
|
|
10368
|
-
return INDEX_SEGMENT.test(segment);
|
|
10369
|
-
}
|
|
10370
|
-
function hasIndexSegment(path) {
|
|
10371
|
-
return path.split(".").some((segment) => INDEX_SEGMENT.test(segment));
|
|
10372
|
-
}
|
|
10373
|
-
function toWildcardForm(path) {
|
|
10374
|
-
if (!hasIndexSegment(path)) return path;
|
|
10375
|
-
return path.split(".").map((segment) => INDEX_SEGMENT.test(segment) ? "*" : segment).join(".");
|
|
10376
|
-
}
|
|
10377
|
-
function candidateKeyOf(path, has) {
|
|
10378
|
-
return has(path) ? path : toWildcardForm(path);
|
|
10379
|
-
}
|
|
10380
|
-
var UNSAFE_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype"]);
|
|
10381
|
-
function hasUnsafeSegment(path) {
|
|
10382
|
-
return path.split(".").some((segment) => UNSAFE_SEGMENTS.has(segment));
|
|
10383
|
-
}
|
|
10384
|
-
var { maxDepth } = getWcsManifest().syntax.indexParam;
|
|
10385
|
-
var MAX_INDEX_PARAM3 = maxDepth;
|
|
10386
|
-
var INDEX_PARAM = new RegExp(`^\\$[1-9]\\d{0,${String(maxDepth).length - 1}}$`);
|
|
10387
|
-
function classifyIndexParam(path) {
|
|
10388
|
-
if (!/^\$\d+$/.test(path)) return null;
|
|
10389
|
-
if (!INDEX_PARAM.test(path)) return { kind: "notIndex" };
|
|
10390
|
-
const n = Number(path.slice(1));
|
|
10391
|
-
return n <= MAX_INDEX_PARAM3 ? { kind: "index", n } : { kind: "range", n };
|
|
10392
|
-
}
|
|
10393
|
-
function isOutOfRangeIndexRead(name) {
|
|
10394
|
-
if (name.length < 2 || name.charCodeAt(0) !== 36) return false;
|
|
10395
|
-
const c = name.charCodeAt(1);
|
|
10396
|
-
if (c < 48 || c > 57) return false;
|
|
10397
|
-
return !INDEX_PARAM.test(name) || Number(name.slice(1)) > MAX_INDEX_PARAM3;
|
|
10398
|
-
}
|
|
10399
|
-
|
|
10400
10623
|
// src/service/statePathResolver.ts
|
|
10401
10624
|
function isUnresolvedPath(path, scopes) {
|
|
10402
10625
|
if (scopes.opaquePaths.length > 0) {
|
|
@@ -10452,7 +10675,7 @@ function resolveStatePathIndex(elements, html, fileReader, includeRoots) {
|
|
|
10452
10675
|
};
|
|
10453
10676
|
}
|
|
10454
10677
|
function opaquePathsOf(paths) {
|
|
10455
|
-
return paths.filter((p) => p.opaque !== void 0).map((p) => p.path);
|
|
10678
|
+
return paths.filter((p) => p.opaque !== void 0 || p.openKeys === true).map((p) => p.path);
|
|
10456
10679
|
}
|
|
10457
10680
|
function moduleLocationOf(fileReader, path) {
|
|
10458
10681
|
return fileReader === void 0 ? void 0 : { fileReader, path: path ?? "" };
|
|
@@ -11310,11 +11533,11 @@ function collectThisMemberRefsInValue(value, names2) {
|
|
|
11310
11533
|
}
|
|
11311
11534
|
function walkThisMembers(root, names2, offsetShift) {
|
|
11312
11535
|
const out = [];
|
|
11313
|
-
const
|
|
11536
|
+
const walk2 = (node, thisIsState) => {
|
|
11314
11537
|
if (isClassNode(node)) return;
|
|
11315
11538
|
if (isFunctionNode(node)) {
|
|
11316
11539
|
const inner = node.type === "ArrowFunctionExpression" ? thisIsState : false;
|
|
11317
|
-
forEachChild(node, (child) =>
|
|
11540
|
+
forEachChild(node, (child) => walk2(child, inner));
|
|
11318
11541
|
return;
|
|
11319
11542
|
}
|
|
11320
11543
|
if (thisIsState && node.type === "MemberExpression" && node.object.type === "ThisExpression") {
|
|
@@ -11323,9 +11546,9 @@ function walkThisMembers(root, names2, offsetShift) {
|
|
|
11323
11546
|
out.push({ name: hit.name, start: hit.start - offsetShift, end: hit.end - offsetShift });
|
|
11324
11547
|
}
|
|
11325
11548
|
}
|
|
11326
|
-
forEachChild(node, (child) =>
|
|
11549
|
+
forEachChild(node, (child) => walk2(child, thisIsState));
|
|
11327
11550
|
};
|
|
11328
|
-
|
|
11551
|
+
walk2(root, true);
|
|
11329
11552
|
return out;
|
|
11330
11553
|
}
|
|
11331
11554
|
function thisMemberName(node) {
|
|
@@ -11418,16 +11641,16 @@ function findOwnThis(text3, kind) {
|
|
|
11418
11641
|
root = statement.expression.body;
|
|
11419
11642
|
}
|
|
11420
11643
|
let found = null;
|
|
11421
|
-
const
|
|
11644
|
+
const walk2 = (node) => {
|
|
11422
11645
|
if (found !== null || isClassNode(node)) return;
|
|
11423
11646
|
if (isFunctionNode(node) && node.type !== "ArrowFunctionExpression") return;
|
|
11424
11647
|
if (node.type === "ThisExpression") {
|
|
11425
11648
|
found = { start: node.start - prefix.length, end: node.end - prefix.length };
|
|
11426
11649
|
return;
|
|
11427
11650
|
}
|
|
11428
|
-
forEachChild(node,
|
|
11651
|
+
forEachChild(node, walk2);
|
|
11429
11652
|
};
|
|
11430
|
-
forEachChild(root,
|
|
11653
|
+
forEachChild(root, walk2);
|
|
11431
11654
|
return found;
|
|
11432
11655
|
}
|
|
11433
11656
|
var DESTRUCTIVE_ARRAY_METHODS = /* @__PURE__ */ new Set(["push", "pop", "shift", "unshift", "splice", "sort", "reverse", "fill", "copyWithin"]);
|
|
@@ -11591,7 +11814,7 @@ function findLocationRead(body) {
|
|
|
11591
11814
|
const at2 = (node) => {
|
|
11592
11815
|
found = { start: node.start - PREFIX.length, end: node.end - PREFIX.length, text: (PREFIX + body).slice(node.start, node.end) };
|
|
11593
11816
|
};
|
|
11594
|
-
const
|
|
11817
|
+
const walk2 = (node) => {
|
|
11595
11818
|
if (found !== null) return;
|
|
11596
11819
|
if (node.type === "MemberExpression" && isLocation(node.object)) {
|
|
11597
11820
|
const part = !node.computed && node.property.type === "Identifier" ? node.property.name : null;
|
|
@@ -11603,18 +11826,18 @@ function findLocationRead(body) {
|
|
|
11603
11826
|
return;
|
|
11604
11827
|
}
|
|
11605
11828
|
if (node.type === "MemberExpression") {
|
|
11606
|
-
|
|
11607
|
-
if (node.computed)
|
|
11829
|
+
walk2(node.object);
|
|
11830
|
+
if (node.computed) walk2(node.property);
|
|
11608
11831
|
return;
|
|
11609
11832
|
}
|
|
11610
11833
|
if (node.type === "Property") {
|
|
11611
|
-
if (node.computed)
|
|
11612
|
-
|
|
11834
|
+
if (node.computed) walk2(node.key);
|
|
11835
|
+
walk2(node.value);
|
|
11613
11836
|
return;
|
|
11614
11837
|
}
|
|
11615
|
-
forEachChild(node,
|
|
11838
|
+
forEachChild(node, walk2);
|
|
11616
11839
|
};
|
|
11617
|
-
|
|
11840
|
+
walk2(wrapper.body);
|
|
11618
11841
|
return found;
|
|
11619
11842
|
}
|
|
11620
11843
|
|
|
@@ -11670,11 +11893,16 @@ var ja = {
|
|
|
11670
11893
|
nestedWritePathMissing: (p) => `\u30D1\u30B9 "${p}" \u306F\u72B6\u614B\u5B9A\u7FA9\u306B\u5B58\u5728\u3057\u307E\u305B\u3093\u3002\u66F8\u304D\u8FBC\u307F\u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306B\u65B0\u3057\u3044\u30AD\u30FC\u3092\u4F5C\u308B\u3060\u3051\u3067\u3001\u5BA3\u8A00\u3057\u305F\u30D1\u30B9\u306E\u675F\u7E1B\u306B\u306F\u5C4A\u304D\u307E\u305B\u3093`,
|
|
11671
11894
|
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`,
|
|
11672
11895
|
stateSrcUnread: (src) => `"${src}" \u3092\u8AAD\u3081\u306A\u3044\u306E\u3067\u3001\u3053\u306E state \u306E\u30D1\u30B9\u3082\u30B9\u30AF\u30EA\u30D7\u30C8\u306E\u898F\u5247\u3082\u691C\u67FB\u3057\u3066\u3044\u307E\u305B\u3093\u3002src \u306F\u3053\u306E\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u306E\u76F8\u5BFE\u30D1\u30B9\u3067\u8AAD\u307F\u307E\u3059\uFF08URL \u306F\u8AAD\u307E\u305A\u3001/ \u304B\u3089\u59CB\u307E\u308B\u30D1\u30B9\u306F wcs-validate --root=<\u30B5\u30A4\u30C8\u306E\u30EB\u30FC\u30C8> \u306E\u3068\u304D\u3060\u3051\u305D\u306E\u4E0B\u3067\u8AAD\u307F\u307E\u3059\uFF09\u3002\u30B5\u30FC\u30D0\u30FC\u3068\u540C\u3058\u4E26\u3073\u306B\u7F6E\u3044\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u3001\u3053\u306E\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u306E\u76F8\u5BFE\u30D1\u30B9\u3067\u6307\u3059\u304B\u3001--root \u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
11896
|
+
stateAbsent: (tag) => `\u3053\u306E\u30D5\u30A1\u30A4\u30EB\u306B\u306F\u675F\u7E1B\u304C\u3042\u308A\u307E\u3059\u304C <${tag}> \u304C\u7121\u3044\u306E\u3067\u3001\u675F\u7E1B\u306E\u30D1\u30B9\u306F\u691C\u67FB\u3057\u3066\u3044\u307E\u305B\u3093\uFF08\u30DA\u30FC\u30B8\u304C\u53D6\u308A\u8FBC\u3080\u65AD\u7247\u3084\u3001state \u3092\u30B9\u30AF\u30EA\u30D7\u30C8\u3067\u4F5C\u308B\u30DA\u30FC\u30B8\uFF09\u3002state \u306E\u3042\u308B\u30DA\u30FC\u30B8\u3092\u691C\u67FB\u3059\u308B\u304B\u3001\u3053\u306E\u30D5\u30A1\u30A4\u30EB\u306E\u96A3\uFF08\u304B\u4E0A\uFF09\u306E wcstack.manifest.json \u306E stateSchema \u306B\u30D1\u30B9\u3092\u5BA3\u8A00\u3059\u308B\u3068\u691C\u67FB\u3055\u308C\u307E\u3059`,
|
|
11673
11897
|
pathDynamicUnknownValue: (path, n, name, from) => `"${path}" \u306E\u5024${name === void 0 ? "" : from === void 0 ? `\uFF08${name}\uFF09` : `\uFF08${name}\u3002"${from}" \u304B\u3089 import\uFF09`}\u306F\u9759\u7684\u306B\u8AAD\u3081\u306A\u3044\u306E\u3067\u3001\u305D\u306E\u4E0B\u306B\u675F\u306D\u305F\u30D1\u30B9\uFF08${n} \u4EF6\uFF09\u306F\u691C\u67FB\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u30AD\u30FC\u306B JSDoc \u306E @type \u2014 \u5F62\u304B\u3001\u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u30EA\u30C6\u30E9\u30EB\u3092\u6307\u3059 typeof import("./file.js").name\uFF08\u8F9E\u66F8\u306A\u3089\u5168\u90E8\u306E\u30AD\u30FC\u3092\u6301\u3064\u65E2\u5B9A\u306E\u8A00\u8A9E\u306E\u30D5\u30A1\u30A4\u30EB\uFF09\u2014 \u3092\u4ED8\u3051\u308B\u304B\u3001wcstack.manifest.json \u306E stateSchema \u306B\u5BA3\u8A00\u3059\u308B\u3068\u691C\u67FB\u3055\u308C\u307E\u3059`,
|
|
11674
11898
|
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`,
|
|
11675
11899
|
pathDynamicUnknownObjectSpread: (path, n, sp, from) => `${sp}${from === void 0 ? "" : `\uFF08"${from}" \u304B\u3089 import\uFF09`}\u304C "${path}" \u306B\u6301\u3061\u8FBC\u3080\u30AD\u30FC\u306F\u9759\u7684\u306B\u8AAD\u3081\u306A\u3044\u306E\u3067\u3001\u305D\u306E\u4E0B\u306B\u675F\u306D\u305F\u30D1\u30B9\uFF08${n} \u4EF6\uFF09\u306F\u691C\u67FB\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u30EA\u30C6\u30E9\u30EB\u3092\u675F\u7E1B\u3059\u308B\u30E2\u30B8\u30E5\u30FC\u30EB\u306E const \u3092 spread \u3059\u308B\u304B\u3001\u30AD\u30FC\u306B\u5F62\u3092\u8868\u3059 JSDoc \u306E @type \u3092\u4ED8\u3051\u308B\u304B\u3001wcstack.manifest.json \u306E stateSchema \u306B\u5BA3\u8A00\u3059\u308B\u3068\u691C\u67FB\u3055\u308C\u307E\u3059`,
|
|
11676
11900
|
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`,
|
|
11677
11901
|
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`,
|
|
11902
|
+
guardReadsAtModuleTop: (r) => `\u30AC\u30FC\u30C9\u306E\u30E2\u30B8\u30E5\u30FC\u30EB\u304C\u3001export \u3059\u308B\u95A2\u6570\u306E\u5916\uFF08\u30C8\u30C3\u30D7\u30EC\u30D9\u30EB\uFF09\u3067 ${r} \u3092\u8AAD\u3093\u3067\u3044\u307E\u3059\u3002\u30E2\u30B8\u30E5\u30FC\u30EB\u306F\u30DA\u30FC\u30B8\u306E\u8AAD\u307F\u8FBC\u307F\u3067 1 \u56DE\u3060\u3051\u8A55\u4FA1\u3055\u308C\u308B\u306E\u3067\u3001\u30AC\u30FC\u30C9\u306F\u305D\u306E\u3068\u304D\u8AAD\u3093\u3060\u5024\u3092\u6301\u3061\u7D9A\u3051\u3001\u9077\u79FB\u306E\u305F\u3073\u306B\u305D\u306E\u5024\u3067\u6C7A\u3081\u307E\u3059\uFF08\u30ED\u30B0\u30A4\u30F3\u3057\u305F\u5F8C\u3082\u30BB\u30C3\u30B7\u30E7\u30F3\u304C\u7121\u3044\u307E\u307E\uFF09\u3002\u9077\u79FB\u306E\u305F\u3073\u306B\u8D70\u308B\u3001export \u3057\u305F\u95A2\u6570\u306E\u4E2D\u3067\u8AAD\u3093\u3067\u304F\u3060\u3055\u3044`,
|
|
11903
|
+
stateReadsAtModuleTop: (r) => `state \u306E\u30E2\u30B8\u30E5\u30FC\u30EB\u304C\u30C8\u30C3\u30D7\u30EC\u30D9\u30EB\u3067 ${r} \u3092\u8AAD\u3093\u3067\u3044\u307E\u3059\u3002\u30E2\u30B8\u30E5\u30FC\u30EB\u306F <wcs-state> \u3054\u3068\u306B 1 \u56DE\u3060\u3051\u8A55\u4FA1\u3055\u308C\u308B\u306E\u3067\u3001state \u306F\u30DA\u30FC\u30B8\u306E\u8AAD\u307F\u8FBC\u307F\u306E\u6642\u70B9\u306E\u5024\u3092\u6301\u3061\u7D9A\u3051\u307E\u3059\uFF08\u5F8C\u3067\u5909\u308F\u308B\u30C8\u30FC\u30AF\u30F3\u3084\u30BB\u30C3\u30B7\u30E7\u30F3\u306F\u898B\u3048\u307E\u305B\u3093\uFF09\u3002\u5024\u3092 state \u306B\u7F6E\u304F\uFF08<wcs-storage> \u306B\u675F\u306D\u308B\uFF09\u304B\u3001\u4F7F\u3046\u30E1\u30BD\u30C3\u30C9\u306E\u4E2D\u3067\u8AAD\u3093\u3067\u304F\u3060\u3055\u3044`,
|
|
11904
|
+
eventTokenUnbound: (t, handler) => `\u30A4\u30D9\u30F3\u30C8\u30C8\u30FC\u30AF\u30F3 "${t}" \u3092 $eventTokens \u306B\u5BA3\u8A00\u3057\u3066\u3044\u307E\u3059\u304C\u3001\u3053\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u305D\u308C\u3092\u51FA\u3059 eventToken.<\u30E1\u30F3\u30D0\u30FC>: ${t} \u306E\u675F\u7E1B\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u3069\u306E\u8981\u7D20\u3082\u767A\u706B\u3055\u305B\u306A\u3044\u306E\u3067\u3001${handler ? "$on \u306E\u30CF\u30F3\u30C9\u30E9\u306F\u4E00\u5EA6\u3082\u8D70\u308A\u307E\u305B\u3093" : "\u3053\u306E\u30C8\u30FC\u30AF\u30F3\u306F\u4E00\u5EA6\u3082\u767A\u706B\u3057\u307E\u305B\u3093"}\u3002\u767A\u706B\u3055\u305B\u308B\u8981\u7D20\u306B\u675F\u306D\u308B\uFF08eventToken.<\u30E1\u30F3\u30D0\u30FC>: ${t} \u2014 <\u30E1\u30F3\u30D0\u30FC> \u306F\u305D\u306E\u8981\u7D20\u306E wcBindable \u306E\u30D7\u30ED\u30D1\u30C6\u30A3\uFF09\u304B\u3001$eventTokens \u304B\u3089\u5916\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
11905
|
+
objectKeyAssign: (t, acc, sp) => `"${t}" \u306E\u30AD\u30FC\u306B\u305D\u306E\u5834\u3067\u4EE3\u5165\u3057\u3066\u3044\u307E\u3059\u3002state \u306F\u3053\u306E\u66F8\u304D\u8FBC\u307F\u3092\u898B\u306A\u3044\u306E\u3067\u3001\u305D\u308C\u3092\u8AAD\u3080\u675F\u7E1B\u30FBgetter\u30FB$watch \u306F\u5909\u308F\u3089\u305A\u3001\u4F55\u3082\u63CF\u304D\u76F4\u3055\u308C\u307E\u305B\u3093\u3002\u65B0\u3057\u3044\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3092\u4EE3\u5165\u3059\u308B\uFF08${acc} = { ...${acc}, [key]: value }\uFF09\u304B\u3001\u30C9\u30C3\u30C8\u30D1\u30B9\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF08this["${sp}"] = \u2026\uFF09`,
|
|
11678
11906
|
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`,
|
|
11679
11907
|
getterUntrackedReadBound: (root, sp, binding, tag, written) => `\u3053\u3053\u3067\u8FFD\u8DE1\u3055\u308C\u308B\u306E\u306F "${root}" \u3060\u3051\u3067\u3059\u304C\u3001<${tag}> \u306E\u675F\u7E1B "${binding}" \u306F "${written}" \u3092\u30D1\u30B9\u3067\u66F8\u304D\u307E\u3059\u3002\u305D\u306E\u66F8\u304D\u8FBC\u307F\u306F\u3053\u306E getter \u306B\u5C4A\u304B\u305A\u3001getter \u306F\u524D\u306B\u8A08\u7B97\u3057\u305F\u5024\u3092\u8FD4\u3057\u7D9A\u3051\u307E\u3059\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`,
|
|
11680
11908
|
handlerFilterNotAllowed: (prop) => `\u30A4\u30D9\u30F3\u30C8\u30CF\u30F3\u30C9\u30E9 "${prop}" \u306B\u30D5\u30A3\u30EB\u30BF\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093`,
|
|
@@ -11686,8 +11914,9 @@ var ja = {
|
|
|
11686
11914
|
filterMaxArgs: (n, max, c) => `\u30D5\u30A3\u30EB\u30BF "${n}" \u306E\u5F15\u6570\u306F\u6700\u5927 ${max} \u500B\u3067\u3059\uFF08${c} \u500B\u6307\u5B9A\uFF09`,
|
|
11687
11915
|
filterArgType: (n, i, exp, arg, act) => `\u30D5\u30A3\u30EB\u30BF "${n}" \u306E\u7B2C${i}\u5F15\u6570\u306F ${exp} \u578B\u304C\u5FC5\u8981\u3067\u3059\uFF08"${arg}" \u306F ${act} \u578B\uFF09`,
|
|
11688
11916
|
filterInputType: (n, accepts, cur) => `\u30D5\u30A3\u30EB\u30BF "${n}" \u306F ${accepts} \u578B\u306E\u5165\u529B\u304C\u5FC5\u8981\u3067\u3059\uFF08\u73FE\u5728\u306E\u578B: ${cur}\uFF09`,
|
|
11689
|
-
wcsTextInfo: (e) => `wcs-text \u30D0\u30A4\u30F3\u30C7\u30A3\u30F3\u30B0: ${e}`,
|
|
11690
11917
|
moustacheFouc: (e) => `<template> \u5916\u306E {{ }} \u69CB\u6587\u306F FOUC\uFF08\u521D\u671F\u8868\u793A\u6642\u306B\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u6587\u5B57\u5217\u304C\u898B\u3048\u308B\uFF09\u306E\u539F\u56E0\u306B\u306A\u308A\u307E\u3059\u3002<!--@@:${e}--> \u307E\u305F\u306F\u30B3\u30E1\u30F3\u30C8\u69CB\u6587\u306E\u4F7F\u7528\u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,
|
|
11918
|
+
moustacheFoucTextParent: (e, tag) => `<template> \u5916\u306E {{ }} \u69CB\u6587\u306F FOUC\uFF08\u521D\u671F\u8868\u793A\u6642\u306B\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u6587\u5B57\u5217\u304C\u898B\u3048\u308B\uFF09\u306E\u539F\u56E0\u306B\u306A\u308A\u307E\u3059\u3002<${tag}> \u306E\u4E2D\u306E\u30B3\u30E1\u30F3\u30C8\u69CB\u6587\u306F\u675F\u7E1B\u306B\u306A\u308A\u307E\u305B\u3093 \u2014 \u8981\u7D20\u306B\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08<${tag} data-wcs="${tag === "textarea" ? "value" : "textContent"}: ${e}">\uFF09\u3002`,
|
|
11919
|
+
textBindingInHead: (w) => `${w} \u306F\u6587\u66F8\u306E <head> \u306E\u4E2D\u306B\u3042\u308A\u307E\u3059\u304C\u3001<wcs-state> \u304C\u675F\u306D\u308B\u306E\u306F <body> \u3068\u30B7\u30E3\u30C9\u30A6\u30EB\u30FC\u30C8\u3060\u3051\u306A\u306E\u3067\u3001\u66F8\u3044\u305F\u307E\u307E\u306E\u6587\u5B57\u304C\u51FA\u307E\u3059\u3002\u30BF\u30A4\u30C8\u30EB\u306F state \u306E\u30B9\u30AF\u30EA\u30D7\u30C8\u304B\u3089 document.title \u306B\u66F8\u304F\uFF08$connectedCallback \u3068 $watch \u306E\u30CF\u30F3\u30C9\u30E9\uFF09\u304B\u3001\u30EB\u30FC\u30C8\u306E <wcs-head> \u306E <title> \u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044`,
|
|
11691
11920
|
nestedAssign: (sp) => `\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3\u3078\u306E\u4EE3\u5165\u306F\u30EA\u30A2\u30AF\u30C6\u30A3\u30D6\u66F4\u65B0\u3092\u30C8\u30EA\u30AC\u30FC\u3057\u307E\u305B\u3093\u3002this["${sp}"] \u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,
|
|
11692
11921
|
watchNotObject: () => `$watch \u306F\u300C\u30D1\u30B9 \u2192 \u30CF\u30F3\u30C9\u30E9\u95A2\u6570\u300D\u306E\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\uFF08\u3053\u306E\u5F62\u306F\u30E9\u30F3\u30BF\u30A4\u30E0\u304C\u8AAD\u307F\u8FBC\u307F\u6642\u306B throw \u3057\u307E\u3059\uFF09`,
|
|
11693
11922
|
watchKeyCrossState: (k) => `$watch \u306E\u30AD\u30FC "${k}" \u306F\u4ED6\u306E state \u3092\u6307\u3057\u3066\u3044\u307E\u3059\u3002@ \u4ED8\u304D\u306E\u8D8A\u5883 watch \u306F\u4F7F\u3048\u307E\u305B\u3093\uFF08\u81EA state \u306E\u30D1\u30B9\u306E\u307F\uFF09`,
|
|
@@ -11742,6 +11971,7 @@ var ja = {
|
|
|
11742
11971
|
signalsDualEntry: () => `@wcstack/signals \u3068 @wcstack/signals/dom \u304C\u540C\u4E00\u30DA\u30FC\u30B8\u304B\u3089 import \u3055\u308C\u3066\u3044\u307E\u3059\u3002CDN \u3067\u306F\u5404\u30A8\u30F3\u30C8\u30EA\u304C\u81EA\u5DF1\u5B8C\u7D50\u30D0\u30F3\u30C9\u30EB\u306E\u305F\u3081\u30EA\u30A2\u30AF\u30C6\u30A3\u30D6\u30B3\u30A2\u304C\u4E8C\u91CD\u5316\u3057\u3001\u5883\u754C\u3067\u53CD\u5FDC\u304C\u58CA\u308C\u307E\u3059 \u2014 \u3059\u3079\u3066 /dom \u30A8\u30F3\u30C8\u30EA\u304B\u3089 import \u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
11743
11972
|
signalsImportMapBoth: () => `\u3053\u306E import map \u306F @wcstack/signals \u3068 @wcstack/signals/dom \u306E\u4E21\u65B9\u3092\u5272\u308A\u5F53\u3066\u3066\u3044\u307E\u3059\u3002CDN \u3067\u306F\u5404\u30A8\u30F3\u30C8\u30EA\u304C\u30EA\u30A2\u30AF\u30C6\u30A3\u30D6\u30B3\u30A2\u3092\u6301\u3064\u306E\u3067\u3001@wcstack/signals \u3092 import \u3059\u308B\u30E2\u30B8\u30E5\u30FC\u30EB\uFF08\u3053\u306E\u30DA\u30FC\u30B8\u306E\u3082\u306E\u3067\u3082\u3001\u8AAD\u307F\u8FBC\u3080 .js \u3067\u3082\uFF09\u304C 2 \u3064\u76EE\u306E\u30B3\u30A2\u3092\u6301\u3061\u3001\u5883\u754C\u3067\u53CD\u5FDC\u304C\u58CA\u308C\u307E\u3059\u3002@wcstack/signals/dom \u3060\u3051\u3092\u5272\u308A\u5F53\u3066\u3066\u304F\u3060\u3055\u3044\uFF08\u30B3\u30A2\u306E\u5168\u90E8\u3092 export \u3057\u307E\u3059\uFF09`,
|
|
11744
11973
|
tagPackageMissing: (tags, pkg, url) => `${tags.map((t) => `<${t}>`).join("\u30FB")} \u306F ${pkg} \u306E\u30BF\u30B0\u3067\u3059\u304C\u3001\u3053\u306E\u30DA\u30FC\u30B8\u306F ${pkg} \u306E\u30B9\u30AF\u30EA\u30D7\u30C8\u3092\u8AAD\u307F\u8FBC\u3093\u3067\u3044\u307E\u305B\u3093\u3002\u8981\u7D20\u306F\u5B9A\u7FA9\u3055\u308C\u306A\u3044\u306E\u3067\u3001\u305D\u306E\u675F\u7E1B\u306F\u5F85\u3061\u7D9A\u3051\u3066\u4F55\u3082\u8D77\u304D\u305A\u3001\u30B3\u30F3\u30BD\u30FC\u30EB\u306B\u3082\u4F55\u3082\u51FA\u307E\u305B\u3093 \u2014 <script type="module" src="${url}"></script> \u3067\u8AAD\u307F\u8FBC\u3093\u3067\u304F\u3060\u3055\u3044`,
|
|
11974
|
+
linkRouterMissing: (to, n) => `\u3053\u306E\u30DA\u30FC\u30B8\u306B\u306F <wcs-router> \u304C\u7121\u3044\u306E\u3067\u3001\u3053\u306E <wcs-link to="${to}">${n > 1 ? `\uFF08\u3068\u30DA\u30FC\u30B8\u306E\u307B\u304B\u306E ${n - 1} \u500B\uFF09` : ""}\u306F\u63A5\u7D9A\u3057\u305F\u6642\u70B9\u3067 "[@wcstack/router] wcs-link is not connected to a router." \u3092\u6295\u3052\u3001\u30EA\u30F3\u30AF\u306F\u96A0\u308C\u307E\u3059\uFF08display: none\uFF09\u3002router \u306E\u7121\u3044\u30DA\u30FC\u30B8\u3067\u306F <a href="${to}"> \u3068\u66F8\u304F\u304B\u3001<wcs-router> \u3092\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044`,
|
|
11745
11975
|
lintVersionBehind: (spec, version3, minor, lint) => `\u3053\u306E\u30DA\u30FC\u30B8\u306F ${spec} \u3092\u56FA\u5B9A\u3057\u3066\u3044\u307E\u3059\u304C\u3001\u3053\u306E lint \u306E\u898F\u5247\uFF08@wcstack ${lint}\uFF09\u3088\u308A\u65B0\u3057\u3044 minor \u3067\u3059\u3002${minor} \u3067\u52A0\u308F\u3063\u305F\u898F\u5247\u306F\u691C\u67FB\u3055\u308C\u305A\u3001${minor} \u306E\u6B63\u3057\u3044\u66F8\u304D\u65B9\u304C error \u306B\u306A\u308B\u3053\u3068\u3082\u3042\u308A\u307E\u3059 \u2014 @wcstack/lint \u3092 ${version3} \u306B\u4E0A\u3052\u3066\u304F\u3060\u3055\u3044\uFF08npm i -D @wcstack/lint@${version3}\u3002VS Code \u306E\u62E1\u5F35\u306F ${minor} \u306B\u5BFE\u5FDC\u3059\u308B\u7248\u3078\uFF09`,
|
|
11746
11976
|
routeBareMustache: (inLayout) => inLayout ? `\u30EC\u30A4\u30A2\u30A6\u30C8\u306E\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306E\u76F4\u4E0B\u306E\u30C6\u30AD\u30B9\u30C8\u306E {{ }} \u306F\u3001\u9077\u79FB\u3067\u306F\u675F\u306D\u3089\u308C\u307E\u305B\u3093 \u2014 \u8981\u7D20\u3067\u5305\u3093\u3067\u304F\u3060\u3055\u3044\uFF08<span>{{ \u2026 }}</span>\uFF09` : `<wcs-route> \u306E\u76F4\u4E0B\u306E\u30C6\u30AD\u30B9\u30C8\u306E {{ }} \u306F\u3001\u6700\u521D\u306B\u7740\u3044\u305F\u30EB\u30FC\u30C8\u3067\u3057\u304B\u675F\u306D\u3089\u308C\u307E\u305B\u3093\u3002\u9077\u79FB\u3067\u5165\u3063\u305F\u30EB\u30FC\u30C8\u3067\u306F\u66F8\u3044\u305F\u307E\u307E\u306E\u6587\u5B57\u304C\u51FA\u307E\u3059 \u2014 \u8981\u7D20\u3067\u5305\u3093\u3067\u304F\u3060\u3055\u3044\uFF08<h1>{{ \u2026 }}</h1>\uFF09`,
|
|
11747
11977
|
layoutSlotMissing: (l) => `\u30EC\u30A4\u30A2\u30A6\u30C8 "${l}" \u306E\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306B\u65E2\u5B9A\u306E <slot>\uFF08name \u306E\u7121\u3044\u3082\u306E\uFF09\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u3053\u306E <wcs-layout> \u306E\u540D\u524D\u4ED8\u304D\u30B9\u30ED\u30C3\u30C8\u306E\u5916\u306E\u4E2D\u8EAB\uFF08\u5165\u308C\u5B50\u306E\u30EB\u30FC\u30C8\u3068\u305D\u306E\u30DA\u30FC\u30B8\uFF09\u306F\u8868\u793A\u3055\u308C\u307E\u305B\u3093 \u2014 \u30DA\u30FC\u30B8\u3092\u7F6E\u304F\u5834\u6240\u306B <slot></slot> \u3092\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`,
|
|
@@ -11895,11 +12125,16 @@ var en = {
|
|
|
11895
12125
|
nestedWritePathMissing: (p) => `Path "${p}" does not exist in the state definition. The write creates a new key in the object and reaches no binding of a declared path`,
|
|
11896
12126
|
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`,
|
|
11897
12127
|
stateSrcUnread: (src) => `"${src}" cannot be read, so this state's paths and script rules are not checked. A src is read relative to this file (a URL is not read, and a path from / only under wcs-validate --root=<the site's root>): point it at the file laid out as on the server, relative to this file, or pass --root`,
|
|
12128
|
+
stateAbsent: (tag) => `This file has bindings but no <${tag}>, so the paths they bind are not checked (a fragment a page includes, or a page whose state is made by script). Check the page that holds the state, or declare the paths in the stateSchema of a wcstack.manifest.json next to (or above) this file to have them checked`,
|
|
11898
12129
|
pathDynamicUnknownValue: (path, n, name, from) => `The value of "${path}"${name === void 0 ? "" : from === void 0 ? ` (${name})` : ` (${name}, imported from "${from}")`} cannot be read statically, so the ${n === 1 ? "path" : `${n} paths`} bound under it ${n === 1 ? "is" : "are"} not checked. Give the key a JSDoc @type \u2014 its shape, or typeof import("./file.js").name for a module's literal (for a dictionary, the default language's file, which has every key) \u2014 or declare it in the stateSchema of wcstack.manifest.json to have them checked`,
|
|
11899
12130
|
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)`,
|
|
11900
12131
|
pathDynamicUnknownObjectSpread: (path, n, sp, from) => `The keys ${sp}${from === void 0 ? "" : ` (imported from "${from}")`} brings into "${path}" cannot be read statically, so the ${n === 1 ? "path" : `${n} paths`} bound under it ${n === 1 ? "is" : "are"} not checked. Spread a const of the module bound to an object literal, give the key a JSDoc @type with its shape, or declare it in the stateSchema of wcstack.manifest.json to have them checked`,
|
|
11901
12132
|
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})`,
|
|
11902
12133
|
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`,
|
|
12134
|
+
guardReadsAtModuleTop: (r) => `The guard's module reads ${r} at its top level, outside the function it exports. The module is evaluated once, when the page loads, so the guard keeps the value it read then and decides every navigation with it (after a login, the session is still not there). Read it inside the exported function, which runs on every navigation`,
|
|
12135
|
+
stateReadsAtModuleTop: (r) => `The state's module reads ${r} at its top level. The module is evaluated once per <wcs-state>, so the state keeps the value it read when the page loaded (a token or a session that changes later is not seen). Keep the value in state (bind it with <wcs-storage>), or read it inside the method that uses it`,
|
|
12136
|
+
eventTokenUnbound: (t, handler) => `The event token "${t}" is declared in $eventTokens, but no eventToken.<member>: ${t} binding in this document emits it: no element fires it, so ${handler ? "its $on handler never runs" : "it never fires"}. Bind it on the element whose event should fire it (eventToken.<member>: ${t}, with <member> a wcBindable property of that element), or remove it from $eventTokens`,
|
|
12137
|
+
objectKeyAssign: (t, acc, sp) => `This assigns a key of "${t}" in place. The state does not see the write, so no binding, getter or $watch that reads it changes, and nothing is rendered again. Assign a new object (${acc} = { ...${acc}, [key]: value }), or write the dot path this["${sp}"] = \u2026`,
|
|
11903
12138
|
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`,
|
|
11904
12139
|
getterUntrackedReadBound: (root, sp, binding, tag, written) => `Only "${root}" is tracked here, but the binding "${binding}" on <${tag}> writes "${written}" by path: that write never reaches this getter, which keeps returning the value it last computed (plain property access after a path read is not tracked). Read this["${sp}"] instead`,
|
|
11905
12140
|
handlerFilterNotAllowed: (prop) => `Filters cannot be applied to event handler "${prop}"`,
|
|
@@ -11911,8 +12146,9 @@ var en = {
|
|
|
11911
12146
|
filterMaxArgs: (n, max, c) => `Filter "${n}" accepts at most ${max} argument(s) (${c} given)`,
|
|
11912
12147
|
filterArgType: (n, i, exp, arg, act) => `Argument ${i} of filter "${n}" must be of type ${exp} ("${arg}" is ${act})`,
|
|
11913
12148
|
filterInputType: (n, accepts, cur) => `Filter "${n}" requires input of type ${accepts} (current type: ${cur})`,
|
|
11914
|
-
wcsTextInfo: (e) => `wcs-text binding: ${e}`,
|
|
11915
12149
|
moustacheFouc: (e) => `{{ }} outside a <template> causes FOUC (the raw template string is visible before binding). Consider the comment syntax <!--@@:${e}--> instead.`,
|
|
12150
|
+
moustacheFoucTextParent: (e, tag) => `{{ }} outside a <template> causes FOUC (the raw template string is visible before binding). A comment binding is not bound inside <${tag}>: bind the element instead (<${tag} data-wcs="${tag === "textarea" ? "value" : "textContent"}: ${e}">).`,
|
|
12151
|
+
textBindingInHead: (w) => `${w} is in the document's <head>, and a <wcs-state> binds only the <body> and shadow roots, so it stays as written. Write document.title from the state's script ($connectedCallback and a $watch handler), or put the <title> in a route's <wcs-head>`,
|
|
11916
12152
|
nestedAssign: (sp) => `Assigning to a nested property does not trigger a reactive update. Use this["${sp}"] instead.`,
|
|
11917
12153
|
watchNotObject: () => `$watch must be an object mapping state paths to handler functions (the runtime throws on this shape at load time)`,
|
|
11918
12154
|
watchKeyCrossState: (k) => `$watch key "${k}" targets another state. Cross-state watching with @ is not supported (own paths only)`,
|
|
@@ -11967,6 +12203,7 @@ var en = {
|
|
|
11967
12203
|
signalsDualEntry: () => `Both @wcstack/signals and @wcstack/signals/dom are imported on this page. On a CDN each entry is a self-contained bundle, so the reactive core is duplicated and reactivity breaks at the seam \u2014 import everything from the single /dom entry`,
|
|
11968
12204
|
signalsImportMapBoth: () => `This import map maps both @wcstack/signals and @wcstack/signals/dom. On a CDN each entry carries its own reactive core, so a module that imports @wcstack/signals \u2014 this page's, or a .js file it loads \u2014 gets a second core and reactivity breaks at the seam. Map only @wcstack/signals/dom (it exports the whole core)`,
|
|
11969
12205
|
tagPackageMissing: (tags, pkg, url) => `${tags.map((t) => `<${t}>`).join(", ")} ${tags.length === 1 ? "is a tag" : "are tags"} of ${pkg}, and this page loads no script of ${pkg}: the element is never defined, so its bindings wait and nothing happens, without a word in the console. Load it with <script type="module" src="${url}"></script>`,
|
|
12206
|
+
linkRouterMissing: (to, n) => `This page has no <wcs-router>, so this <wcs-link to="${to}">${n > 1 ? ` (and the ${n - 1} other${n > 2 ? "s" : ""} on the page)` : ""} throws "[@wcstack/router] wcs-link is not connected to a router." when it connects, and the link is hidden (display: none). On a page without the router write <a href="${to}">, or add the <wcs-router>`,
|
|
11970
12207
|
lintVersionBehind: (spec, version3, minor, lint) => `This page pins ${spec}, a newer minor than the rules of this lint (@wcstack ${lint}): what ${minor} added is not checked, and correct ${minor} syntax can be reported as an error. Upgrade @wcstack/lint to ${version3} (npm i -D @wcstack/lint@${version3}; the VS Code extension to its release for ${minor})`,
|
|
11971
12208
|
routeBareMustache: (inLayout) => inLayout ? `{{ }} in text directly under a layout template is not bound on a navigation. Wrap it in an element (<span>{{ \u2026 }}</span>)` : `{{ }} in text directly under <wcs-route> is bound only on the landing route: a route entered by navigation shows it as written. Wrap it in an element (<h1>{{ \u2026 }}</h1>)`,
|
|
11972
12209
|
layoutSlotMissing: (l) => `The template of layout "${l}" has no default <slot> (one without a name), so what this <wcs-layout> holds outside the named slots \u2014 the nested routes and their pages \u2014 is not shown. Put a <slot></slot> where the page goes`,
|
|
@@ -12474,7 +12711,7 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
|
|
|
12474
12711
|
start: bindingStart + leadingSpace,
|
|
12475
12712
|
end: bindingStart + leadingSpace + propNoMod.length,
|
|
12476
12713
|
message: msgs.submitWithoutPrevent(handler),
|
|
12477
|
-
severity: "
|
|
12714
|
+
severity: "error"
|
|
12478
12715
|
});
|
|
12479
12716
|
}
|
|
12480
12717
|
if (DELEGATED_EVENTS.has(eventName) && !modifiers.includes(DIRECT_MODIFIER) && attr.tagName !== void 0 && !(attr.tagName.includes("-") && CUSTOM_ELEMENT_OWN_EVENTS.has(eventName)) && /^[A-Za-z_][\w$]*(?:\.[A-Za-z_][\w$]*)*$/.test(handler) && getCurrentTargetHandlers().has(handler)) {
|
|
@@ -12596,11 +12833,12 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
|
|
|
12596
12833
|
if (verdict) {
|
|
12597
12834
|
const pathOffset = binding.indexOf(parsed.path);
|
|
12598
12835
|
const pathStart = bindingStart + pathOffset;
|
|
12836
|
+
const near = verdict.code === WcsDiagnosticCode.BindingPathMissing || verdict.code === WcsDiagnosticCode.PathNonexistent ? rowFieldSuggestion(checkPath, scopedPaths, msgs) : "";
|
|
12599
12837
|
diagnostics.push({
|
|
12600
12838
|
code: verdict.code,
|
|
12601
12839
|
start: pathStart,
|
|
12602
12840
|
end: pathStart + pathTrimmed.length,
|
|
12603
|
-
message: `${verdict.message}${pathTrimmed.startsWith(".") ? msgs.expansionSuffix(checkPath) : ""}`,
|
|
12841
|
+
message: `${verdict.message}${pathTrimmed.startsWith(".") ? msgs.expansionSuffix(checkPath) : ""}${near}`,
|
|
12604
12842
|
severity: verdict.severity
|
|
12605
12843
|
});
|
|
12606
12844
|
} else if (writesBack(attr, propNoMod, parsed.property)) {
|
|
@@ -13307,6 +13545,7 @@ function findDestructiveCalls(script, baseOffset, msgs, out) {
|
|
|
13307
13545
|
}
|
|
13308
13546
|
}
|
|
13309
13547
|
function findIndexAssigns(script, baseOffset, msgs, out) {
|
|
13548
|
+
let paths = null;
|
|
13310
13549
|
for (const pattern of [DOT_INDEX_ASSIGN, BRACKET_INDEX_ASSIGN, PRE_DOT_INDEX, PRE_BRACKET_INDEX]) {
|
|
13311
13550
|
for (const match of execAllMasked(pattern, script)) {
|
|
13312
13551
|
const [root, chain] = match.groups;
|
|
@@ -13314,17 +13553,30 @@ function findIndexAssigns(script, baseOffset, msgs, out) {
|
|
|
13314
13553
|
if (isApiRoot(root)) continue;
|
|
13315
13554
|
const suggestedPath = root + chainToDotted(chain);
|
|
13316
13555
|
const start = baseOffset + match.index;
|
|
13556
|
+
const last = LAST_SUB.exec(chain);
|
|
13557
|
+
const target = root + chainToDotted(last === null ? chain : chain.slice(0, last.index));
|
|
13558
|
+
const numeric2 = last !== null && /^\s*\d+\s*$/.test(last[1]);
|
|
13559
|
+
const kind = containerKind(target, paths ??= analyzeStatePaths(script));
|
|
13317
13560
|
out.push({
|
|
13318
13561
|
code: WcsDiagnosticCode.ArrayIndexAssign,
|
|
13319
13562
|
start,
|
|
13320
13563
|
end: start + match.length,
|
|
13321
|
-
message: msgs.arrayIndexAssign(suggestedPath),
|
|
13564
|
+
message: kind === "array" || kind === "unknown" && numeric2 ? msgs.arrayIndexAssign(suggestedPath) : msgs.objectKeyAssign(target, toAccessor(target), suggestedPath),
|
|
13322
13565
|
severity: "error",
|
|
13323
13566
|
statePath: suggestedPath
|
|
13324
13567
|
});
|
|
13325
13568
|
}
|
|
13326
13569
|
}
|
|
13327
13570
|
}
|
|
13571
|
+
var LAST_SUB = /(?:\?\.)?\s*\[([^[\]]+)\]\s*$/;
|
|
13572
|
+
function containerKind(target, paths) {
|
|
13573
|
+
const path = target.split(".").map((s) => /^<.*>$/.test(s) || /^\d+$/.test(s) ? "*" : s).join(".");
|
|
13574
|
+
if (paths.some((p) => p.path === `${path}.*`)) return "array";
|
|
13575
|
+
const hints = (paths.find((p) => p.path === path)?.typeHint ?? "").split("|");
|
|
13576
|
+
if (hints.includes("array")) return "array";
|
|
13577
|
+
if (hints.includes("object") || paths.some((p) => p.path.startsWith(`${path}.`))) return "object";
|
|
13578
|
+
return "unknown";
|
|
13579
|
+
}
|
|
13328
13580
|
|
|
13329
13581
|
// src/service/templateSyntax.ts
|
|
13330
13582
|
var MUSTACHE = /\{\{\s*((?:(?!<[A-Za-z/!?])[\s\S])+?)\s*\}\}/dg;
|
|
@@ -13332,21 +13584,24 @@ var COMMENT_BINDING = /<!--\s*@@\s*(?:wcs-text)?\s*:\s*((?:(?!-->)[\s\S])+?)\s*-
|
|
|
13332
13584
|
var RAW_TEXT_TAGS = ["script", "style"];
|
|
13333
13585
|
var TEXT_ONLY_COMMENT_PARENTS = ["textarea", "title"];
|
|
13334
13586
|
function findAllMustacheSyntax(html) {
|
|
13335
|
-
return collect(html, MUSTACHE, "mustache", RAW_TEXT_TAGS);
|
|
13587
|
+
return collect(html, maskMarkup(html), MUSTACHE, "mustache", RAW_TEXT_TAGS);
|
|
13336
13588
|
}
|
|
13337
13589
|
function findAllCommentBindings(html) {
|
|
13338
|
-
return collect(html, COMMENT_BINDING, "comment", [...RAW_TEXT_TAGS, ...TEXT_ONLY_COMMENT_PARENTS]);
|
|
13590
|
+
return collect(html, html, COMMENT_BINDING, "comment", [...RAW_TEXT_TAGS, ...TEXT_ONLY_COMMENT_PARENTS]);
|
|
13339
13591
|
}
|
|
13340
|
-
function collect(html, regex, kind, skipInside) {
|
|
13592
|
+
function collect(html, scan, regex, kind, skipInside) {
|
|
13341
13593
|
const results = [];
|
|
13342
13594
|
const skip = rangeTester(html, skipInside);
|
|
13343
13595
|
const inTemplate = templateTester(html);
|
|
13596
|
+
const inHead = documentHeadTester(html);
|
|
13597
|
+
const textParent = kind === "mustache" ? rangeTester(html, TEXT_ONLY_COMMENT_PARENTS) : null;
|
|
13344
13598
|
regex.lastIndex = 0;
|
|
13345
13599
|
let match;
|
|
13346
|
-
while ((match = regex.exec(
|
|
13347
|
-
if (skip(match.index)) continue;
|
|
13600
|
+
while ((match = regex.exec(scan)) !== null) {
|
|
13601
|
+
if (skip(match.index) !== null) continue;
|
|
13348
13602
|
const expr = match[1];
|
|
13349
13603
|
const exprStart = match.indices[1][0];
|
|
13604
|
+
const parent = textParent?.(match.index) ?? null;
|
|
13350
13605
|
results.push({
|
|
13351
13606
|
kind,
|
|
13352
13607
|
expression: expr,
|
|
@@ -13354,11 +13609,84 @@ function collect(html, regex, kind, skipInside) {
|
|
|
13354
13609
|
exprEnd: exprStart + expr.length,
|
|
13355
13610
|
matchStart: match.index,
|
|
13356
13611
|
matchEnd: match.index + match[0].length,
|
|
13357
|
-
insideTemplate: inTemplate(match.index)
|
|
13612
|
+
insideTemplate: inTemplate(match.index),
|
|
13613
|
+
inDocumentHead: inHead(match.index),
|
|
13614
|
+
...parent !== null ? { textParent: parent } : {}
|
|
13358
13615
|
});
|
|
13359
13616
|
}
|
|
13360
13617
|
return results;
|
|
13361
13618
|
}
|
|
13619
|
+
function maskMarkup(html) {
|
|
13620
|
+
if (!html.includes("{{")) return html;
|
|
13621
|
+
const lower2 = asciiLowerCase(html);
|
|
13622
|
+
const chunks = [];
|
|
13623
|
+
let last = 0;
|
|
13624
|
+
const mask = (from, to) => {
|
|
13625
|
+
if (to <= from) return;
|
|
13626
|
+
chunks.push(html.slice(last, from), "<", "x".repeat(to - from - 1));
|
|
13627
|
+
last = to;
|
|
13628
|
+
};
|
|
13629
|
+
let i = 0;
|
|
13630
|
+
while (i < html.length) {
|
|
13631
|
+
const lt2 = html.indexOf("<", i);
|
|
13632
|
+
if (lt2 === -1) break;
|
|
13633
|
+
if (html.startsWith("<!--", lt2)) {
|
|
13634
|
+
const close = html.indexOf("-->", lt2 + 4);
|
|
13635
|
+
i = close === -1 ? html.length : close + 3;
|
|
13636
|
+
mask(lt2, i);
|
|
13637
|
+
continue;
|
|
13638
|
+
}
|
|
13639
|
+
const next = html[lt2 + 1];
|
|
13640
|
+
if (next === "!" || next === "?" || next === "/") {
|
|
13641
|
+
const close = html.indexOf(">", lt2 + 1);
|
|
13642
|
+
i = close === -1 ? html.length : close + 1;
|
|
13643
|
+
mask(lt2, i);
|
|
13644
|
+
continue;
|
|
13645
|
+
}
|
|
13646
|
+
if (next === void 0 || !/[A-Za-z]/.test(next)) {
|
|
13647
|
+
i = lt2 + 1;
|
|
13648
|
+
continue;
|
|
13649
|
+
}
|
|
13650
|
+
let n = lt2 + 1;
|
|
13651
|
+
while (n < html.length && /[^\s/>]/.test(html[n])) n++;
|
|
13652
|
+
const tagName = lower2.slice(lt2 + 1, n);
|
|
13653
|
+
let j = n;
|
|
13654
|
+
let quote = null;
|
|
13655
|
+
while (j < html.length) {
|
|
13656
|
+
const c = html[j];
|
|
13657
|
+
if (quote !== null) {
|
|
13658
|
+
if (c === quote) quote = null;
|
|
13659
|
+
} else if (c === '"' || c === "'") {
|
|
13660
|
+
quote = c;
|
|
13661
|
+
} else if (c === ">") {
|
|
13662
|
+
break;
|
|
13663
|
+
}
|
|
13664
|
+
j++;
|
|
13665
|
+
}
|
|
13666
|
+
i = j < html.length ? j + 1 : html.length;
|
|
13667
|
+
mask(lt2, i);
|
|
13668
|
+
const raw = RAW_TEXT_TAGS.includes(tagName);
|
|
13669
|
+
if (raw || TEXT_ONLY_COMMENT_PARENTS.includes(tagName)) {
|
|
13670
|
+
const close = lower2.indexOf(`</${tagName}`, i);
|
|
13671
|
+
const contentEnd = close === -1 ? html.length : close;
|
|
13672
|
+
if (raw) mask(i, contentEnd);
|
|
13673
|
+
i = contentEnd;
|
|
13674
|
+
}
|
|
13675
|
+
}
|
|
13676
|
+
chunks.push(html.slice(last));
|
|
13677
|
+
return chunks.join("");
|
|
13678
|
+
}
|
|
13679
|
+
function documentHeadTester(html) {
|
|
13680
|
+
if (!/<head[\s>]/i.test(html)) return () => false;
|
|
13681
|
+
const regions = findStartTagRegions(html);
|
|
13682
|
+
const head = regions.find((r) => r.tagName === "head");
|
|
13683
|
+
if (head === void 0) return () => false;
|
|
13684
|
+
const close = asciiLowerCase(html).indexOf("</head", head.end);
|
|
13685
|
+
const body = regions.find((r) => r.tagName === "body" && r.start > head.end);
|
|
13686
|
+
const ends = [close, body === void 0 ? -1 : body.start].filter((at2) => at2 !== -1);
|
|
13687
|
+
const end = ends.length === 0 ? html.length : Math.min(...ends);
|
|
13688
|
+
return (offset2) => offset2 > head.end && offset2 < end;
|
|
13689
|
+
}
|
|
13362
13690
|
function rangeTester(html, tags) {
|
|
13363
13691
|
const ranges = [];
|
|
13364
13692
|
const lower2 = asciiLowerCase(html);
|
|
@@ -13366,15 +13694,16 @@ function rangeTester(html, tags) {
|
|
|
13366
13694
|
let match;
|
|
13367
13695
|
while ((match = open.exec(html)) !== null) {
|
|
13368
13696
|
const start = match.index + match[0].length;
|
|
13369
|
-
const
|
|
13697
|
+
const tag = match[1].toLowerCase();
|
|
13698
|
+
const close = lower2.indexOf(`</${tag}`, start);
|
|
13370
13699
|
const end = close === -1 ? html.length : close;
|
|
13371
|
-
ranges.push({ start, end });
|
|
13700
|
+
ranges.push({ start, end, tag });
|
|
13372
13701
|
open.lastIndex = end;
|
|
13373
13702
|
}
|
|
13374
13703
|
let i = 0;
|
|
13375
13704
|
return (offset2) => {
|
|
13376
13705
|
while (i < ranges.length && ranges[i].end <= offset2) i++;
|
|
13377
|
-
return i < ranges.length && ranges[i].start <= offset2;
|
|
13706
|
+
return i < ranges.length && ranges[i].start <= offset2 ? ranges[i].tag : null;
|
|
13378
13707
|
};
|
|
13379
13708
|
}
|
|
13380
13709
|
function templateTester(html) {
|
|
@@ -13421,24 +13750,26 @@ function validateTemplateSyntax(html, stateTagName, bindAttrName = "data-wcs", l
|
|
|
13421
13750
|
const defaultPaths = allPaths;
|
|
13422
13751
|
const pathSet = new Set(defaultPaths.map((p) => p.path));
|
|
13423
13752
|
const filterNameSet = new Set(BUILTIN_FILTERS.map((f) => f.name));
|
|
13753
|
+
const nearRowField = (code, path) => code === WcsDiagnosticCode.BindingPathMissing || code === WcsDiagnosticCode.PathNonexistent ? rowFieldSuggestion(path, defaultPaths, msgs) : "";
|
|
13424
13754
|
const mustaches = findAllMustacheSyntax(html);
|
|
13425
13755
|
const comments = findAllCommentBindings(html);
|
|
13426
13756
|
for (const item of [...mustaches, ...comments]) {
|
|
13427
|
-
if (item.
|
|
13757
|
+
if (item.inDocumentHead && !item.insideTemplate) {
|
|
13428
13758
|
diagnostics.push({
|
|
13429
13759
|
code: WcsDiagnosticCode.TemplateSyntax,
|
|
13430
13760
|
start: item.matchStart,
|
|
13431
13761
|
end: item.matchEnd,
|
|
13432
|
-
message: msgs.
|
|
13433
|
-
severity: "
|
|
13762
|
+
message: msgs.textBindingInHead(item.kind === "mustache" ? `{{ ${item.expression} }}` : `<!--@@: ${item.expression}-->`),
|
|
13763
|
+
severity: "warning"
|
|
13434
13764
|
});
|
|
13765
|
+
continue;
|
|
13435
13766
|
}
|
|
13436
13767
|
if (item.kind === "mustache" && !item.insideTemplate) {
|
|
13437
13768
|
diagnostics.push({
|
|
13438
13769
|
code: WcsDiagnosticCode.TemplateSyntax,
|
|
13439
13770
|
start: item.matchStart,
|
|
13440
13771
|
end: item.matchEnd,
|
|
13441
|
-
message: msgs.moustacheFouc(item.expression),
|
|
13772
|
+
message: item.textParent !== void 0 ? msgs.moustacheFoucTextParent(item.expression, item.textParent) : msgs.moustacheFouc(item.expression),
|
|
13442
13773
|
severity: "info"
|
|
13443
13774
|
});
|
|
13444
13775
|
}
|
|
@@ -13532,7 +13863,7 @@ function validateTemplateSyntax(html, stateTagName, bindAttrName = "data-wcs", l
|
|
|
13532
13863
|
code: verdict.code,
|
|
13533
13864
|
start: item.exprStart,
|
|
13534
13865
|
end: item.exprStart + pathPart.length,
|
|
13535
|
-
message: verdict.message + msgs.expansionSuffix(expandedPath),
|
|
13866
|
+
message: verdict.message + msgs.expansionSuffix(expandedPath) + nearRowField(verdict.code, expandedPath),
|
|
13536
13867
|
severity: verdict.severity
|
|
13537
13868
|
});
|
|
13538
13869
|
}
|
|
@@ -13544,7 +13875,7 @@ function validateTemplateSyntax(html, stateTagName, bindAttrName = "data-wcs", l
|
|
|
13544
13875
|
code: verdict.code,
|
|
13545
13876
|
start: item.exprStart,
|
|
13546
13877
|
end: item.exprStart + pathPart.length,
|
|
13547
|
-
message: verdict.message,
|
|
13878
|
+
message: verdict.message + nearRowField(verdict.code, pathPart),
|
|
13548
13879
|
severity: verdict.severity
|
|
13549
13880
|
});
|
|
13550
13881
|
}
|
|
@@ -13692,6 +14023,7 @@ function validateBindingSyntax(html, bindAttrName = "data-wcs", locale2) {
|
|
|
13692
14023
|
}
|
|
13693
14024
|
}
|
|
13694
14025
|
for (const item of [...findAllMustacheSyntax(html), ...findAllCommentBindings(html)]) {
|
|
14026
|
+
if (item.inDocumentHead && !item.insideTemplate) continue;
|
|
13695
14027
|
const detail = bindingSyntaxDetail(parseEmbeddedTextWithPositions(item.expression).error);
|
|
13696
14028
|
if (detail === null) continue;
|
|
13697
14029
|
diagnostics.push({
|
|
@@ -16106,11 +16438,36 @@ function validatePackageLoads(html, locale2, fileReader) {
|
|
|
16106
16438
|
code: WcsDiagnosticCode.TagPackageMissing,
|
|
16107
16439
|
start: at2.start,
|
|
16108
16440
|
end: at2.end,
|
|
16109
|
-
severity: "
|
|
16441
|
+
severity: "error",
|
|
16110
16442
|
tag: at2.tags[0],
|
|
16111
16443
|
message: msgs.tagPackageMissing(at2.tags, `@wcstack/${pkg}`, `https://esm.run/@wcstack/${pkg}${version3 === null ? "" : `@${version3}`}/auto`)
|
|
16112
16444
|
});
|
|
16113
16445
|
}
|
|
16446
|
+
const linkDefined = loads.pkgs.has("router") || defined.has("router") || autoloader && components.some((k) => coversTag(k, "wcs-link"));
|
|
16447
|
+
if (linkDefined) {
|
|
16448
|
+
const links = findLinksWithoutRouter(scan);
|
|
16449
|
+
if (links.length > 0) {
|
|
16450
|
+
out.push({
|
|
16451
|
+
code: WcsDiagnosticCode.LinkRouterMissing,
|
|
16452
|
+
start: links[0].start,
|
|
16453
|
+
end: links[0].end,
|
|
16454
|
+
severity: "warning",
|
|
16455
|
+
tag: "wcs-link",
|
|
16456
|
+
message: msgs.linkRouterMissing(links[0].to, links.length)
|
|
16457
|
+
});
|
|
16458
|
+
}
|
|
16459
|
+
}
|
|
16460
|
+
return out;
|
|
16461
|
+
}
|
|
16462
|
+
function findLinksWithoutRouter(scan) {
|
|
16463
|
+
if (/\bwcs-router\b/i.test(scan)) return [];
|
|
16464
|
+
const out = [];
|
|
16465
|
+
for (const region of findStartTagRegions(scan)) {
|
|
16466
|
+
if (region.tagName !== "wcs-link") continue;
|
|
16467
|
+
const to = extractAttribute(scan.slice(region.start, region.end), "to");
|
|
16468
|
+
if (to === null || !to.startsWith("/")) continue;
|
|
16469
|
+
out.push({ to, start: region.start - "wcs-link".length, end: region.start });
|
|
16470
|
+
}
|
|
16114
16471
|
return out;
|
|
16115
16472
|
}
|
|
16116
16473
|
function comparePins(a, b) {
|
|
@@ -16363,10 +16720,10 @@ var NO_MOUNTS = /* @__PURE__ */ new Set();
|
|
|
16363
16720
|
function assignVolumes(elements, html) {
|
|
16364
16721
|
const chainOf = createTemplateChain(html);
|
|
16365
16722
|
const innermost = (chain) => chain.length > 0 ? chain[chain.length - 1] : -1;
|
|
16366
|
-
const
|
|
16723
|
+
const treeOf = (root) => innermost(chainOf(root.tagStart));
|
|
16367
16724
|
const rootTrees = /* @__PURE__ */ new Set();
|
|
16368
16725
|
for (const element2 of elements) {
|
|
16369
|
-
if (element2.mountPath === null && !element2.bindComponent) rootTrees.add(
|
|
16726
|
+
if (element2.mountPath === null && !element2.bindComponent) rootTrees.add(treeOf(element2));
|
|
16370
16727
|
}
|
|
16371
16728
|
const volumes = /* @__PURE__ */ new Map();
|
|
16372
16729
|
for (const element2 of elements) {
|
|
@@ -16383,7 +16740,7 @@ function assignVolumes(elements, html) {
|
|
|
16383
16740
|
if (list === void 0) volumes.set(tree, [element2]);
|
|
16384
16741
|
else list.push(element2);
|
|
16385
16742
|
}
|
|
16386
|
-
return { treeOf
|
|
16743
|
+
return { treeOf, volumes };
|
|
16387
16744
|
}
|
|
16388
16745
|
function validateEntry(entry, pathSet, paths, scopes, msgs) {
|
|
16389
16746
|
const { key } = entry;
|
|
@@ -17220,6 +17577,7 @@ function validateNamedState(html, attrName, stateTagName = "wcs-state", locale2)
|
|
|
17220
17577
|
}
|
|
17221
17578
|
}
|
|
17222
17579
|
for (const item of [...findAllMustacheSyntax(html), ...findAllCommentBindings(html)]) {
|
|
17580
|
+
if (item.inDocumentHead && !item.insideTemplate) continue;
|
|
17223
17581
|
const selector = findStateSelector(item.expression, true);
|
|
17224
17582
|
if (selector !== null) {
|
|
17225
17583
|
diagnostics.push({
|
|
@@ -18178,13 +18536,17 @@ function validateScriptStateUses(html, stateTagName = "wcs-state", locale2, bind
|
|
|
18178
18536
|
if (blocks.length === 0) return [];
|
|
18179
18537
|
const msgs = getMessages(locale2);
|
|
18180
18538
|
const out = [];
|
|
18539
|
+
let hidden = null;
|
|
18181
18540
|
let receivers = null;
|
|
18182
18541
|
let markupEmits = null;
|
|
18542
|
+
let eventEmits = null;
|
|
18183
18543
|
const bindings = () => {
|
|
18184
18544
|
if (receivers !== null) return;
|
|
18185
18545
|
receivers = /* @__PURE__ */ new Set();
|
|
18186
18546
|
markupEmits = /* @__PURE__ */ new Map();
|
|
18547
|
+
eventEmits = /* @__PURE__ */ new Set();
|
|
18187
18548
|
for (const o of buildReferenceIndex(html, { bindAttribute: bindAttrName, stateTagName }).occurrences) {
|
|
18549
|
+
if (o.kind === "eventToken") eventEmits.add(o.path);
|
|
18188
18550
|
if (!o.path.startsWith("$command.")) continue;
|
|
18189
18551
|
const name = o.path.slice("$command.".length);
|
|
18190
18552
|
const prop = o.propName ?? "";
|
|
@@ -18230,6 +18592,23 @@ function validateScriptStateUses(html, stateTagName = "wcs-state", locale2, bind
|
|
|
18230
18592
|
});
|
|
18231
18593
|
}
|
|
18232
18594
|
}
|
|
18595
|
+
const events = paths.filter((p) => p.kind === "eventToken").map((p) => p.path);
|
|
18596
|
+
if (block.mountPath === null && events.length > 0) {
|
|
18597
|
+
bindings();
|
|
18598
|
+
const unbound = events.filter((name) => !eventEmits.has(name));
|
|
18599
|
+
if (unbound.length > 0 && !(hidden ??= hidesEmitters(html, blocks))) {
|
|
18600
|
+
const handlers = new Set(analyzeOnHandlerSources(block.content).map((h) => h.name));
|
|
18601
|
+
for (const at2 of declaredNames(block.content, unbound)) {
|
|
18602
|
+
out.push({
|
|
18603
|
+
code: WcsDiagnosticCode.EventTokenUnbound,
|
|
18604
|
+
start: block.contentStart + at2.start,
|
|
18605
|
+
end: block.contentStart + at2.end,
|
|
18606
|
+
message: msgs.eventTokenUnbound(at2.name, handlers.has(at2.name)),
|
|
18607
|
+
severity: "warning"
|
|
18608
|
+
});
|
|
18609
|
+
}
|
|
18610
|
+
}
|
|
18611
|
+
}
|
|
18233
18612
|
const keys = [...new Set(paths.map((p) => p.path.split(".")[0]).filter((key) => key !== "" && !key.startsWith("$")))];
|
|
18234
18613
|
const reported = /* @__PURE__ */ new Set();
|
|
18235
18614
|
for (const pattern of [THIS_WRITE, PRE_THIS_WRITE]) {
|
|
@@ -18254,6 +18633,33 @@ function validateScriptStateUses(html, stateTagName = "wcs-state", locale2, bind
|
|
|
18254
18633
|
}
|
|
18255
18634
|
return out;
|
|
18256
18635
|
}
|
|
18636
|
+
function declaredNames(script, names2) {
|
|
18637
|
+
const decl = findTopLevelDeclaration(script, "$eventTokens");
|
|
18638
|
+
if (decl === null || decl.value === void 0 || decl.valueStart === void 0 || literalKind(decl.value) !== "array") return [];
|
|
18639
|
+
const out = [];
|
|
18640
|
+
for (const element2 of arrayElements(blankComments(decl.value))) {
|
|
18641
|
+
if (literalKind(element2.text) !== "string") continue;
|
|
18642
|
+
const name = element2.text.slice(1, -1);
|
|
18643
|
+
if (!names2.includes(name) || out.some((o) => o.name === name)) continue;
|
|
18644
|
+
const start = decl.valueStart + element2.start + 1;
|
|
18645
|
+
out.push({ name, start, end: start + name.length });
|
|
18646
|
+
}
|
|
18647
|
+
return out;
|
|
18648
|
+
}
|
|
18649
|
+
var LAYOUT_SRC = /<wcs-layout\b(?:"[^"]*"|'[^']*'|[^>"'])*?\ssrc\s*=/i;
|
|
18650
|
+
var SCRIPT = /(<script\b(?:"[^"]*"|'[^']*'|[^>"'])*>)([\s\S]*?)<\/script\s*>/gi;
|
|
18651
|
+
function hidesEmitters(html, blocks) {
|
|
18652
|
+
const text3 = html.replace(/<!--[\s\S]*?-->/g, (c) => " ".repeat(c.length));
|
|
18653
|
+
if (LAYOUT_SRC.test(text3)) return true;
|
|
18654
|
+
SCRIPT.lastIndex = 0;
|
|
18655
|
+
let m;
|
|
18656
|
+
while ((m = SCRIPT.exec(text3)) !== null) {
|
|
18657
|
+
const contentStart = m.index + m[1].length;
|
|
18658
|
+
if (blocks.some((b) => b.contentStart === contentStart)) continue;
|
|
18659
|
+
if (m[2].includes("eventToken.")) return true;
|
|
18660
|
+
}
|
|
18661
|
+
return false;
|
|
18662
|
+
}
|
|
18257
18663
|
|
|
18258
18664
|
// src/service/scriptReadValidator.ts
|
|
18259
18665
|
function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileReader, applicationSchema, bindAttribute = "data-wcs") {
|
|
@@ -18305,7 +18711,7 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
|
|
|
18305
18711
|
if (read.indexed !== void 0 && !read.indexed.every((list) => isList(prefix + list, candidates, candidateSet))) continue;
|
|
18306
18712
|
if (pathExistsInCandidates(path, candidates, candidateSet)) continue;
|
|
18307
18713
|
if (applicationSchema !== void 0 ? resolveIndexedSchemaPath(applicationSchema, path).kind !== "nonexistent" : isUnresolvedPath(path, index.scopes)) continue;
|
|
18308
|
-
const near =
|
|
18714
|
+
const near = missingSegment(path, tree ??= pathTree(candidates));
|
|
18309
18715
|
if (near === null) continue;
|
|
18310
18716
|
const said = suggestion(near.segment, near.names, msgs);
|
|
18311
18717
|
if (said === "") continue;
|
|
@@ -18332,31 +18738,6 @@ var THIS_PART = /^this\s*(?:\?\.\s*|\.\s*)(?:[A-Za-z_$][\w$]*)|^this\s*(?:\?\.)?
|
|
|
18332
18738
|
function statePart(text3) {
|
|
18333
18739
|
return THIS_PART.exec(text3)?.[0].length ?? text3.length;
|
|
18334
18740
|
}
|
|
18335
|
-
function treeOf(candidates) {
|
|
18336
|
-
const tree = /* @__PURE__ */ new Map();
|
|
18337
|
-
for (const c of candidates) {
|
|
18338
|
-
let parent = "";
|
|
18339
|
-
for (const segment of c.path.split(".")) {
|
|
18340
|
-
let names2 = tree.get(parent);
|
|
18341
|
-
if (names2 === void 0) tree.set(parent, names2 = /* @__PURE__ */ new Set());
|
|
18342
|
-
names2.add(segment);
|
|
18343
|
-
parent = parent === "" ? segment : `${parent}.${segment}`;
|
|
18344
|
-
}
|
|
18345
|
-
}
|
|
18346
|
-
return tree;
|
|
18347
|
-
}
|
|
18348
|
-
function nearName(path, tree) {
|
|
18349
|
-
let parent = "";
|
|
18350
|
-
for (const segment of (hasIndexSegment(path) ? toWildcardForm(path) : path).split(".")) {
|
|
18351
|
-
const names2 = tree.get(parent);
|
|
18352
|
-
if (names2?.has(segment)) {
|
|
18353
|
-
parent = parent === "" ? segment : `${parent}.${segment}`;
|
|
18354
|
-
continue;
|
|
18355
|
-
}
|
|
18356
|
-
return { segment, names: [...names2 ?? []].filter((name) => name !== "*" && !name.startsWith("$")) };
|
|
18357
|
-
}
|
|
18358
|
-
return null;
|
|
18359
|
-
}
|
|
18360
18741
|
|
|
18361
18742
|
// src/service/scriptWriteValidator.ts
|
|
18362
18743
|
var OPTIONS = { writes: true, templates: true, resolveWrites: true, untracked: true, opaque: true };
|
|
@@ -18556,6 +18937,112 @@ function unobservedSetters(state, msgs, at2) {
|
|
|
18556
18937
|
return out;
|
|
18557
18938
|
}
|
|
18558
18939
|
|
|
18940
|
+
// src/service/moduleTopReadValidator.ts
|
|
18941
|
+
var GUARD_TAG = "wcs-guard-handler";
|
|
18942
|
+
var STORAGES = /* @__PURE__ */ new Set(["localStorage", "sessionStorage"]);
|
|
18943
|
+
var GLOBALS = /* @__PURE__ */ new Set(["window", "globalThis", "self"]);
|
|
18944
|
+
var STORAGE_WRITES = /* @__PURE__ */ new Set(["setItem", "removeItem", "clear"]);
|
|
18945
|
+
function validateModuleTopReads(html, stateTagName = "wcs-state", locale2) {
|
|
18946
|
+
const msgs = getMessages(locale2);
|
|
18947
|
+
const out = [];
|
|
18948
|
+
const check = (blocks, guard) => {
|
|
18949
|
+
for (const block of blocks) {
|
|
18950
|
+
for (const read of findTopLevelReads(block.content)) {
|
|
18951
|
+
out.push({
|
|
18952
|
+
code: WcsDiagnosticCode.SessionReadAtModuleTop,
|
|
18953
|
+
start: block.contentStart + read.start,
|
|
18954
|
+
end: block.contentStart + read.end,
|
|
18955
|
+
message: guard ? msgs.guardReadsAtModuleTop(read.text) : msgs.stateReadsAtModuleTop(read.text),
|
|
18956
|
+
severity: guard ? "error" : "warning"
|
|
18957
|
+
});
|
|
18958
|
+
}
|
|
18959
|
+
}
|
|
18960
|
+
};
|
|
18961
|
+
if (html.includes(GUARD_TAG)) check(parseWcsScriptBlocks(html, GUARD_TAG), true);
|
|
18962
|
+
check(parseLoadedScriptBlocks(html, stateTagName), false);
|
|
18963
|
+
return out;
|
|
18964
|
+
}
|
|
18965
|
+
function findTopLevelReads(source) {
|
|
18966
|
+
if (!/localStorage|sessionStorage|cookie/.test(source)) return [];
|
|
18967
|
+
let program;
|
|
18968
|
+
try {
|
|
18969
|
+
program = parse3(source, { ecmaVersion: "latest", sourceType: "module", allowHashBang: true });
|
|
18970
|
+
} catch {
|
|
18971
|
+
return [];
|
|
18972
|
+
}
|
|
18973
|
+
const out = [];
|
|
18974
|
+
const visit2 = (node, assigned) => {
|
|
18975
|
+
switch (node.type) {
|
|
18976
|
+
// run when called (a getter, a setter and a method are function expressions under their property)
|
|
18977
|
+
case "FunctionDeclaration":
|
|
18978
|
+
case "FunctionExpression":
|
|
18979
|
+
case "ArrowFunctionExpression":
|
|
18980
|
+
case "ClassDeclaration":
|
|
18981
|
+
case "ClassExpression":
|
|
18982
|
+
return;
|
|
18983
|
+
case "AssignmentExpression":
|
|
18984
|
+
visit2(node.left, node.operator === "=");
|
|
18985
|
+
visit2(node.right, false);
|
|
18986
|
+
return;
|
|
18987
|
+
case "CallExpression": {
|
|
18988
|
+
const callee = node.callee;
|
|
18989
|
+
if (callee.type === "FunctionExpression" || callee.type === "ArrowFunctionExpression") {
|
|
18990
|
+
visit2(callee.body, false);
|
|
18991
|
+
for (const arg of node.arguments) visit2(arg, false);
|
|
18992
|
+
return;
|
|
18993
|
+
}
|
|
18994
|
+
break;
|
|
18995
|
+
}
|
|
18996
|
+
case "MemberExpression": {
|
|
18997
|
+
const read = readOf(node, assigned, source);
|
|
18998
|
+
if (read !== null) {
|
|
18999
|
+
out.push(read);
|
|
19000
|
+
return;
|
|
19001
|
+
}
|
|
19002
|
+
break;
|
|
19003
|
+
}
|
|
19004
|
+
default:
|
|
19005
|
+
break;
|
|
19006
|
+
}
|
|
19007
|
+
for (const child of children(node)) visit2(child, false);
|
|
19008
|
+
};
|
|
19009
|
+
visit2(program, false);
|
|
19010
|
+
return out;
|
|
19011
|
+
}
|
|
19012
|
+
function readOf(node, assigned, source) {
|
|
19013
|
+
const object = node.object;
|
|
19014
|
+
const prop = propertyName(node);
|
|
19015
|
+
if (isGlobal(object, STORAGES)) {
|
|
19016
|
+
if (assigned || prop !== null && STORAGE_WRITES.has(prop)) return null;
|
|
19017
|
+
return { start: node.start, end: node.end, text: source.slice(node.start, node.end) };
|
|
19018
|
+
}
|
|
19019
|
+
if (prop === "cookie" && !assigned && isGlobal(object, /* @__PURE__ */ new Set(["document"]))) {
|
|
19020
|
+
return { start: node.start, end: node.end, text: source.slice(node.start, node.end) };
|
|
19021
|
+
}
|
|
19022
|
+
return null;
|
|
19023
|
+
}
|
|
19024
|
+
function isGlobal(node, names2) {
|
|
19025
|
+
if (node.type === "Identifier") return names2.has(node.name);
|
|
19026
|
+
if (node.type !== "MemberExpression" || node.computed) return false;
|
|
19027
|
+
const object = node.object;
|
|
19028
|
+
return object.type === "Identifier" && GLOBALS.has(object.name) && node.property.type === "Identifier" && names2.has(node.property.name);
|
|
19029
|
+
}
|
|
19030
|
+
function propertyName(node) {
|
|
19031
|
+
if (!node.computed) return node.property.type === "Identifier" ? node.property.name : null;
|
|
19032
|
+
return node.property.type === "Literal" && typeof node.property.value === "string" ? node.property.value : null;
|
|
19033
|
+
}
|
|
19034
|
+
function children(node) {
|
|
19035
|
+
const out = [];
|
|
19036
|
+
for (const value of Object.values(node)) {
|
|
19037
|
+
if (Array.isArray(value)) {
|
|
19038
|
+
for (const v of value) if (v !== null && typeof v === "object" && typeof v.type === "string") out.push(v);
|
|
19039
|
+
} else if (value !== null && typeof value === "object" && typeof value.type === "string") {
|
|
19040
|
+
out.push(value);
|
|
19041
|
+
}
|
|
19042
|
+
}
|
|
19043
|
+
return out;
|
|
19044
|
+
}
|
|
19045
|
+
|
|
18559
19046
|
// src/service/stateSourceValidator.ts
|
|
18560
19047
|
function validateStateSources(html, stateTagName = "wcs-state", locale2, fileReader) {
|
|
18561
19048
|
if (fileReader === void 0) return [];
|
|
@@ -18576,6 +19063,71 @@ function validateStateSources(html, stateTagName = "wcs-state", locale2, fileRea
|
|
|
18576
19063
|
}
|
|
18577
19064
|
return out;
|
|
18578
19065
|
}
|
|
19066
|
+
function validateStateAbsent(html, bindAttribute = "data-wcs", stateTagName = "wcs-state", locale2, applicationSchema) {
|
|
19067
|
+
if (applicationSchema !== void 0) return [];
|
|
19068
|
+
if (!html.includes(bindAttribute) && !html.includes("@@")) return [];
|
|
19069
|
+
if (parseWcsStateElements(html, stateTagName).length > 0) return [];
|
|
19070
|
+
const ignored = findIgnoredRanges(html, bindAttribute);
|
|
19071
|
+
const bindings = [
|
|
19072
|
+
...findAllBindAttributes(html, bindAttribute).filter((attr) => attr.value.trim() !== "").map((attr) => ({ start: attr.valueStart, end: attr.valueStart + attr.value.length })),
|
|
19073
|
+
...findAllCommentBindings(html).map((m) => ({ start: m.exprStart, end: m.exprEnd }))
|
|
19074
|
+
].filter((b) => !ignored.some(([start, end]) => b.start >= start && b.start < end));
|
|
19075
|
+
if (bindings.length === 0) return [];
|
|
19076
|
+
const first = bindings.reduce((a, b) => b.start < a.start ? b : a);
|
|
19077
|
+
return [{
|
|
19078
|
+
code: WcsDiagnosticCode.StateAbsent,
|
|
19079
|
+
start: first.start,
|
|
19080
|
+
end: first.end,
|
|
19081
|
+
message: getMessages(locale2).stateAbsent(stateTagName),
|
|
19082
|
+
severity: "info"
|
|
19083
|
+
}];
|
|
19084
|
+
}
|
|
19085
|
+
|
|
19086
|
+
// src/service/stateBehavior.ts
|
|
19087
|
+
var BEHAVIOR_KEY2 = "$behavior";
|
|
19088
|
+
var MUSTACHE_KEY = "enableMustache";
|
|
19089
|
+
function isMustacheDisabled(html, stateTagName = "wcs-state", fileReader) {
|
|
19090
|
+
if (!html.includes(MUSTACHE_KEY) && (fileReader === void 0 || !html.includes("src"))) return false;
|
|
19091
|
+
const elements = parseWcsStateElements(html, stateTagName);
|
|
19092
|
+
if (elements.length === 0) return false;
|
|
19093
|
+
const insideTemplate = createTemplateTester(html);
|
|
19094
|
+
const root = elements.find((e) => e.mountPath === null && !e.bindComponent && !insideTemplate(e.tagStart));
|
|
19095
|
+
if (root === void 0) return false;
|
|
19096
|
+
if (root.stateAttr !== void 0) {
|
|
19097
|
+
const json = findScriptJsonById(html, root.stateAttr);
|
|
19098
|
+
return json !== null && jsonDisablesMustache(json);
|
|
19099
|
+
}
|
|
19100
|
+
if (root.srcAttr !== void 0) {
|
|
19101
|
+
if (fileReader === void 0) return false;
|
|
19102
|
+
if (root.srcAttr.endsWith(".json")) {
|
|
19103
|
+
const json = fileReader(root.srcAttr);
|
|
19104
|
+
return json !== void 0 && jsonDisablesMustache(json);
|
|
19105
|
+
}
|
|
19106
|
+
const script = readStateScript(root.srcAttr, fileReader);
|
|
19107
|
+
return script !== void 0 && scriptDisablesMustache(script);
|
|
19108
|
+
}
|
|
19109
|
+
if (root.jsonAttr !== void 0) return jsonDisablesMustache(root.jsonAttr);
|
|
19110
|
+
const block = root.scriptBlocks[0];
|
|
19111
|
+
return block !== void 0 && scriptDisablesMustache(block.content);
|
|
19112
|
+
}
|
|
19113
|
+
function jsonDisablesMustache(text3) {
|
|
19114
|
+
try {
|
|
19115
|
+
const data2 = JSON.parse(text3);
|
|
19116
|
+
const behavior = data2?.[BEHAVIOR_KEY2];
|
|
19117
|
+
return typeof behavior === "object" && behavior !== null && behavior[MUSTACHE_KEY] === false;
|
|
19118
|
+
} catch {
|
|
19119
|
+
return false;
|
|
19120
|
+
}
|
|
19121
|
+
}
|
|
19122
|
+
function scriptDisablesMustache(script) {
|
|
19123
|
+
if (!script.includes(MUSTACHE_KEY)) return false;
|
|
19124
|
+
const decl = findTopLevelDeclaration(script, BEHAVIOR_KEY2);
|
|
19125
|
+
if (decl === null || decl.kind !== "data") return false;
|
|
19126
|
+
return analyzeDeclarationEntries(script, BEHAVIOR_KEY2).some((entry) => entry.name === MUSTACHE_KEY && entry.kind === "data" && entry.value !== void 0 && stripComments(entry.value) === "false");
|
|
19127
|
+
}
|
|
19128
|
+
function stripComments(value) {
|
|
19129
|
+
return value.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g, "").trim();
|
|
19130
|
+
}
|
|
18579
19131
|
|
|
18580
19132
|
// src/core/sidecar/jsonSource.ts
|
|
18581
19133
|
var JsonReader = class {
|
|
@@ -19026,7 +19578,11 @@ function validateDocument(text3, options = {}) {
|
|
|
19026
19578
|
const stateTagName = options.stateTagName ?? "wcs-state";
|
|
19027
19579
|
const fileReader = options.fileReader;
|
|
19028
19580
|
const applicationSchema = options.applicationSchema ?? (fileReader !== void 0 ? discoverApplicationManifest(fileReader)?.schema : void 0);
|
|
19029
|
-
const found = [
|
|
19581
|
+
const found = [
|
|
19582
|
+
...validateText(text3, options, applicationSchema),
|
|
19583
|
+
...validateStateSources(text3, stateTagName, options.locale, fileReader),
|
|
19584
|
+
...validateStateAbsent(text3, options.bindAttribute ?? "data-wcs", stateTagName, options.locale, applicationSchema)
|
|
19585
|
+
];
|
|
19030
19586
|
const page = fileReader === void 0 ? null : inlineExternalStates(text3, stateTagName, fileReader);
|
|
19031
19587
|
if (page === null) return sortDiagnostics(found);
|
|
19032
19588
|
const key = (d) => [d.code, d.start, d.end, d.message, d.origin?.path, d.origin?.start].join("\0");
|
|
@@ -19080,6 +19636,7 @@ function validateText(text3, options, applicationSchema) {
|
|
|
19080
19636
|
out.push(...validateScriptReads(text3, stateTagName, locale2, fileReader, applicationSchema, bindAttribute));
|
|
19081
19637
|
out.push(...validateScriptWrites(text3, stateTagName, locale2));
|
|
19082
19638
|
out.push(...validateArrayMutations(text3, stateTagName, locale2));
|
|
19639
|
+
out.push(...validateModuleTopReads(text3, stateTagName, locale2));
|
|
19083
19640
|
out.push(...validateWatchDeclarations(text3, stateTagName, locale2, fileReader));
|
|
19084
19641
|
out.push(...validateScanDeclarations(text3, stateTagName, locale2));
|
|
19085
19642
|
out.push(...validateRecursion(text3, stateTagName, locale2));
|
|
@@ -19093,7 +19650,10 @@ function validateText(text3, options, applicationSchema) {
|
|
|
19093
19650
|
for (const d of validateNestedAssigns(text3, stateTagName, locale2)) {
|
|
19094
19651
|
out.push({ code: WcsDiagnosticCode.NestedAssign, start: d.start, end: d.end, message: d.message, severity: d.severity });
|
|
19095
19652
|
}
|
|
19096
|
-
const ignored =
|
|
19653
|
+
const ignored = [
|
|
19654
|
+
...findIgnoredRanges(text3, bindAttribute),
|
|
19655
|
+
...text3.includes("{{") && isMustacheDisabled(text3, stateTagName, fileReader) ? findAllMustacheSyntax(text3).map((m) => [m.matchStart, m.matchEnd]) : []
|
|
19656
|
+
];
|
|
19097
19657
|
const kept = ignored.length === 0 ? out : out.filter((d) => !ignored.some(([start, end]) => d.start >= start && d.start < end));
|
|
19098
19658
|
return sortDiagnostics(kept);
|
|
19099
19659
|
}
|
|
@@ -19364,13 +19924,54 @@ function resolveCliLocale(explicit, env = process.env) {
|
|
|
19364
19924
|
return "en";
|
|
19365
19925
|
}
|
|
19366
19926
|
}
|
|
19927
|
+
var nodeGlobFs = {
|
|
19928
|
+
readDir(path) {
|
|
19929
|
+
try {
|
|
19930
|
+
return (0, import_node_fs2.readdirSync)(path, { withFileTypes: true }).map((entry) => ({ name: entry.name, dir: entry.isDirectory() }));
|
|
19931
|
+
} catch {
|
|
19932
|
+
return void 0;
|
|
19933
|
+
}
|
|
19934
|
+
}
|
|
19935
|
+
};
|
|
19936
|
+
function isFile(path) {
|
|
19937
|
+
try {
|
|
19938
|
+
return (0, import_node_fs2.statSync)(path).isFile();
|
|
19939
|
+
} catch {
|
|
19940
|
+
return false;
|
|
19941
|
+
}
|
|
19942
|
+
}
|
|
19943
|
+
function expandFileArgs(args, fs = nodeGlobFs, exists = isFile, windows = process.platform === "win32") {
|
|
19944
|
+
const files = [];
|
|
19945
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
19946
|
+
const add = (path) => {
|
|
19947
|
+
if (seen2.has(path)) return;
|
|
19948
|
+
seen2.add(path);
|
|
19949
|
+
files.push(path);
|
|
19950
|
+
};
|
|
19951
|
+
for (const arg of args) {
|
|
19952
|
+
if (!hasGlobMagic(arg) || exists(arg)) {
|
|
19953
|
+
add(arg);
|
|
19954
|
+
continue;
|
|
19955
|
+
}
|
|
19956
|
+
const matches = expandGlob(windows ? arg.replace(/\\/g, "/") : arg, fs);
|
|
19957
|
+
if (matches.length === 0) return { files, unmatched: arg };
|
|
19958
|
+
for (const match of matches) add(match);
|
|
19959
|
+
}
|
|
19960
|
+
return { files };
|
|
19961
|
+
}
|
|
19367
19962
|
function main(argv) {
|
|
19368
|
-
const { options, files, root } = parseArgs(argv);
|
|
19963
|
+
const { options, files: args, root } = parseArgs(argv);
|
|
19369
19964
|
const locale2 = resolveCliLocale(options.locale);
|
|
19370
|
-
if (
|
|
19965
|
+
if (args.length === 0) {
|
|
19371
19966
|
process.stderr.write("usage: wcs-validate [--attr=data-wcs] [--state-tag=wcs-state] [--lang=ja|en] [--root=<dir>] [--errors-only] [--strict] <file> [<file> ...]\n");
|
|
19372
19967
|
return 2;
|
|
19373
19968
|
}
|
|
19969
|
+
const { files, unmatched } = expandFileArgs(args);
|
|
19970
|
+
if (unmatched !== void 0) {
|
|
19971
|
+
process.stderr.write(`no file matches ${unmatched}
|
|
19972
|
+
`);
|
|
19973
|
+
return 2;
|
|
19974
|
+
}
|
|
19374
19975
|
const inputs = [];
|
|
19375
19976
|
for (const path of files) {
|
|
19376
19977
|
let text3;
|
|
@@ -19408,6 +20009,7 @@ if (typeof require !== "undefined" && typeof module !== "undefined" && require.m
|
|
|
19408
20009
|
// Annotate the CommonJS export names for ESM import in node:
|
|
19409
20010
|
0 && (module.exports = {
|
|
19410
20011
|
createFileReader,
|
|
20012
|
+
expandFileArgs,
|
|
19411
20013
|
main,
|
|
19412
20014
|
parseArgs,
|
|
19413
20015
|
resolveCliLocale
|