@exhaustive-ui/mcp 22.4.0 → 22.6.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.md +13 -1
- package/data/cards/accordion.md +91 -0
- package/data/cards/animateonscroll.md +155 -0
- package/data/cards/autocomplete.md +109 -0
- package/data/cards/autofocus.md +36 -0
- package/data/cards/avatar.md +45 -0
- package/data/cards/badge.md +44 -0
- package/data/cards/blockui.md +51 -0
- package/data/cards/breadcrumb.md +56 -0
- package/data/cards/button.md +83 -0
- package/data/cards/card.md +49 -0
- package/data/cards/carousel.md +101 -0
- package/data/cards/cascadeselect.md +77 -0
- package/data/cards/chart.md +105 -0
- package/data/cards/checkbox.md +59 -0
- package/data/cards/chip.md +50 -0
- package/data/cards/classnames.md +91 -0
- package/data/cards/colorpicker.md +52 -0
- package/data/cards/confirmdialog.md +119 -0
- package/data/cards/confirmpopup.md +96 -0
- package/data/cards/contextmenu.md +60 -0
- package/data/cards/dataview.md +134 -0
- package/data/cards/datepicker.md +103 -0
- package/data/cards/dialog.md +89 -0
- package/data/cards/divider.md +55 -0
- package/data/cards/dock.md +106 -0
- package/data/cards/dragdrop.md +106 -0
- package/data/cards/drawer.md +62 -0
- package/data/cards/dynamicdialog.md +103 -0
- package/data/cards/editor.md +55 -0
- package/data/cards/fieldset.md +54 -0
- package/data/cards/fileinput.md +72 -0
- package/data/cards/fileupload.md +88 -0
- package/data/cards/floatlabel.md +41 -0
- package/data/cards/fluid.md +49 -0
- package/data/cards/focustrap.md +64 -0
- package/data/cards/galleria.md +94 -0
- package/data/cards/iconfield.md +45 -0
- package/data/cards/iftalabel.md +38 -0
- package/data/cards/image.md +58 -0
- package/data/cards/imagecompare.md +45 -0
- package/data/cards/inplace.md +56 -0
- package/data/cards/inputgroup.md +77 -0
- package/data/cards/inputmask.md +71 -0
- package/data/cards/inputnumber.md +78 -0
- package/data/cards/inputotp.md +60 -0
- package/data/cards/inputtext.md +41 -0
- package/data/cards/keyfilter.md +49 -0
- package/data/cards/knob.md +55 -0
- package/data/cards/listbox.md +105 -0
- package/data/cards/megamenu.md +96 -0
- package/data/cards/menu.md +64 -0
- package/data/cards/menubar.md +102 -0
- package/data/cards/message.md +51 -0
- package/data/cards/metergroup.md +53 -0
- package/data/cards/multiselect.md +115 -0
- package/data/cards/orderlist.md +96 -0
- package/data/cards/organizationchart.md +84 -0
- package/data/cards/overlay.md +63 -0
- package/data/cards/paginator.md +62 -0
- package/data/cards/panel.md +57 -0
- package/data/cards/panelmenu.md +94 -0
- package/data/cards/password.md +81 -0
- package/data/cards/picklist.md +106 -0
- package/data/cards/popover.md +53 -0
- package/data/cards/progressbar.md +42 -0
- package/data/cards/progressspinner.md +38 -0
- package/data/cards/radiobutton.md +52 -0
- package/data/cards/rating.md +56 -0
- package/data/cards/ripple.md +37 -0
- package/data/cards/scroller.md +32 -0
- package/data/cards/scrollpanel.md +50 -0
- package/data/cards/scrolltop.md +48 -0
- package/data/cards/select.md +108 -0
- package/data/cards/selectbutton.md +64 -0
- package/data/cards/skeleton.md +54 -0
- package/data/cards/slider.md +52 -0
- package/data/cards/speeddial.md +102 -0
- package/data/cards/splitbutton.md +96 -0
- package/data/cards/splitter.md +52 -0
- package/data/cards/stepper.md +125 -0
- package/data/cards/styleclass.md +46 -0
- package/data/cards/table.md +305 -0
- package/data/cards/tabs.md +97 -0
- package/data/cards/tag.md +41 -0
- package/data/cards/terminal.md +76 -0
- package/data/cards/textarea.md +45 -0
- package/data/cards/tieredmenu.md +121 -0
- package/data/cards/timeline.md +58 -0
- package/data/cards/toast.md +58 -0
- package/data/cards/togglebutton.md +59 -0
- package/data/cards/toggleswitch.md +52 -0
- package/data/cards/toolbar.md +74 -0
- package/data/cards/tooltip.md +43 -0
- package/data/cards/tree.md +93 -0
- package/data/cards/treeselect.md +98 -0
- package/data/cards/treetable.md +231 -0
- package/data/components/accordion.md +31 -23
- package/data/components/animateonscroll.md +18 -15
- package/data/components/autocomplete.md +162 -93
- package/data/components/autofocus.md +9 -7
- package/data/components/avatar.md +56 -43
- package/data/components/badge.md +27 -18
- package/data/components/blockui.md +15 -8
- package/data/components/breadcrumb.md +20 -14
- package/data/components/button.md +121 -94
- package/data/components/card.md +12 -10
- package/data/components/carousel.md +75 -53
- package/data/components/cascadeselect.md +271 -238
- package/data/components/chart.md +88 -74
- package/data/components/checkbox.md +107 -97
- package/data/components/chip.md +20 -16
- package/data/components/classnames.md +22 -4
- package/data/components/colorpicker.md +54 -36
- package/data/components/confirmdialog.md +146 -43
- package/data/components/confirmpopup.md +95 -22
- package/data/components/contextmenu.md +110 -39
- package/data/components/dataview.md +176 -83
- package/data/components/datepicker.md +171 -141
- package/data/components/dialog.md +80 -68
- package/data/components/divider.md +17 -12
- package/data/components/dock.md +65 -29
- package/data/components/dragdrop.md +26 -12
- package/data/components/drawer.md +67 -48
- package/data/components/dynamicdialog.md +22 -13
- package/data/components/editor.md +42 -33
- package/data/components/fieldset.md +20 -17
- package/data/components/fileinput.md +92 -35
- package/data/components/fileupload.md +101 -61
- package/data/components/floatlabel.md +20 -11
- package/data/components/fluid.md +11 -9
- package/data/components/focustrap.md +11 -7
- package/data/components/galleria.md +231 -90
- package/data/components/iconfield.md +23 -15
- package/data/components/iftalabel.md +15 -9
- package/data/components/image.md +31 -26
- package/data/components/imagecompare.md +8 -6
- package/data/components/inplace.md +27 -22
- package/data/components/inputgroup.md +53 -29
- package/data/components/inputmask.md +107 -85
- package/data/components/inputnumber.md +128 -90
- package/data/components/inputotp.md +55 -42
- package/data/components/inputtext.md +72 -50
- package/data/components/keyfilter.md +6 -3
- package/data/components/knob.md +70 -58
- package/data/components/listbox.md +171 -141
- package/data/components/llms.md +4 -0
- package/data/components/megamenu.md +24 -23
- package/data/components/menu.md +37 -34
- package/data/components/menubar.md +27 -22
- package/data/components/message.md +44 -32
- package/data/components/metergroup.md +48 -17
- package/data/components/multiselect.md +232 -168
- package/data/components/orderlist.md +55 -48
- package/data/components/organizationchart.md +182 -13
- package/data/components/overlay.md +31 -26
- package/data/components/paginator.md +49 -34
- package/data/components/panel.md +23 -19
- package/data/components/panelmenu.md +51 -25
- package/data/components/password.md +104 -91
- package/data/components/picklist.md +93 -71
- package/data/components/popover.md +68 -46
- package/data/components/progressbar.md +28 -22
- package/data/components/progressspinner.md +13 -11
- package/data/components/radiobutton.md +69 -35
- package/data/components/rating.md +48 -40
- package/data/components/ripple.md +8 -6
- package/data/components/scroller.md +29 -29
- package/data/components/scrollpanel.md +9 -7
- package/data/components/scrolltop.md +20 -18
- package/data/components/select.md +248 -169
- package/data/components/selectbutton.md +118 -56
- package/data/components/skeleton.md +22 -18
- package/data/components/slider.md +73 -49
- package/data/components/speeddial.md +77 -59
- package/data/components/splitbutton.md +354 -329
- package/data/components/splitter.md +22 -18
- package/data/components/stepper.md +38 -21
- package/data/components/styleclass.md +12 -6
- package/data/components/table.md +524 -315
- package/data/components/tabs.md +44 -26
- package/data/components/tag.md +18 -14
- package/data/components/terminal.md +38 -27
- package/data/components/textarea.md +82 -47
- package/data/components/tieredmenu.md +34 -29
- package/data/components/timeline.md +29 -28
- package/data/components/toast.md +115 -57
- package/data/components/togglebutton.md +53 -39
- package/data/components/toggleswitch.md +41 -28
- package/data/components/toolbar.md +19 -18
- package/data/components/tooltip.md +43 -32
- package/data/components/tree.md +114 -81
- package/data/components/treeselect.md +176 -174
- package/data/components/treetable.md +1250 -1045
- package/data/components.json +4134 -4088
- package/data/llms-full.txt +8979 -6437
- package/data/llms.txt +100 -96
- package/data/manifest.json +183 -15
- package/data/pages/llms.md +29 -0
- package/data/pages/tailwind.md +20 -10
- package/data/snapshot.json +2 -2
- package/dist/index.d.mts +37 -2
- package/dist/index.mjs +1395 -1079
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync, realpathSync } from "node:fs";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { readFile, readdir, stat } from "node:fs/promises";
|
|
5
|
+
import path from "node:path";
|
|
4
6
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
7
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
8
|
import { z } from "zod";
|
|
7
|
-
import { readFile } from "node:fs/promises";
|
|
8
|
-
import path from "node:path";
|
|
9
9
|
|
|
10
10
|
//#region src/config.ts
|
|
11
11
|
const DEFAULT_DOCS_URL = "https://exhaustive-ui.com";
|
|
@@ -320,7 +320,7 @@ function buildCatalog(componentsJson, manifest, options = {}) {
|
|
|
320
320
|
}));
|
|
321
321
|
const components = componentsJson.components.filter((component) => entryPoints.has(component.name) || !guideNames.has(component.name) && component.sections.some((section) => section.examples?.typescript || section.examples?.html)).map((component) => {
|
|
322
322
|
const entryPoint = entryPoints.get(component.name);
|
|
323
|
-
const declarations = entryPoint?.declarations ?? [];
|
|
323
|
+
const declarations = (entryPoint?.declarations ?? []).filter((declaration) => !declaration.internal);
|
|
324
324
|
return {
|
|
325
325
|
kind: "component",
|
|
326
326
|
name: component.name,
|
|
@@ -330,6 +330,8 @@ function buildCatalog(componentsJson, manifest, options = {}) {
|
|
|
330
330
|
publicUrl: `${site}/${component.name}`,
|
|
331
331
|
markdownUrl: `${site}/llms/components/${component.name}.md`,
|
|
332
332
|
docPath: `components/${component.name}.md`,
|
|
333
|
+
cardPath: `cards/${component.name}.md`,
|
|
334
|
+
cardUrl: `${site}/llms/cards/${component.name}.md`,
|
|
333
335
|
resourceUri: `${base}/components/${component.name}.md`,
|
|
334
336
|
apiResourceUri: `${base}/components/${component.name}/api.json`,
|
|
335
337
|
import: entryPoint?.import,
|
|
@@ -341,7 +343,7 @@ function buildCatalog(componentsJson, manifest, options = {}) {
|
|
|
341
343
|
};
|
|
342
344
|
});
|
|
343
345
|
const componentNames = new Set(components.map((component) => component.name));
|
|
344
|
-
const directives = manifest.entryPoints.flatMap((entryPoint) => (entryPoint.declarations ?? []).filter((declaration) => declaration.kind === "directive" && declaration.selector).map((declaration) => ({
|
|
346
|
+
const directives = manifest.entryPoints.flatMap((entryPoint) => (entryPoint.declarations ?? []).filter((declaration) => !declaration.internal).filter((declaration) => declaration.kind === "directive" && declaration.selector).map((declaration) => ({
|
|
345
347
|
className: declaration.className,
|
|
346
348
|
selector: declaration.selector,
|
|
347
349
|
entryPoint: entryPoint.name,
|
|
@@ -349,12 +351,37 @@ function buildCatalog(componentsJson, manifest, options = {}) {
|
|
|
349
351
|
description: declaration.description,
|
|
350
352
|
component: componentNames.has(entryPoint.name) ? entryPoint.name : void 0
|
|
351
353
|
})));
|
|
354
|
+
const parts = manifest.entryPoints.filter((entryPoint) => !componentNames.has(entryPoint.name) && !entryPoint.name.startsWith("icons/") && entryPoint.declarations?.some((declaration) => declaration.selector)).map((entryPoint) => {
|
|
355
|
+
const declarations = (entryPoint.declarations ?? []).filter((declaration) => !declaration.internal);
|
|
356
|
+
const title = declarations[0].className;
|
|
357
|
+
return {
|
|
358
|
+
kind: "component",
|
|
359
|
+
name: entryPoint.name,
|
|
360
|
+
title,
|
|
361
|
+
description: entryPoint.description ?? "",
|
|
362
|
+
route: `/${entryPoint.name}`,
|
|
363
|
+
publicUrl: `${site}/${entryPoint.name}`,
|
|
364
|
+
markdownUrl: `${site}/llms/components/${entryPoint.name}.md`,
|
|
365
|
+
docPath: `components/${entryPoint.name}.md`,
|
|
366
|
+
cardPath: `cards/${entryPoint.name}.md`,
|
|
367
|
+
cardUrl: `${site}/llms/cards/${entryPoint.name}.md`,
|
|
368
|
+
resourceUri: `${base}/components/${entryPoint.name}.md`,
|
|
369
|
+
apiResourceUri: `${base}/components/${entryPoint.name}/api.json`,
|
|
370
|
+
import: entryPoint.import,
|
|
371
|
+
modules: entryPoint.modules ?? [],
|
|
372
|
+
selectors: unique(declarations.flatMap((declaration) => splitSelectors(declaration.selector))),
|
|
373
|
+
declarations,
|
|
374
|
+
sections: [],
|
|
375
|
+
api: {}
|
|
376
|
+
};
|
|
377
|
+
});
|
|
352
378
|
return {
|
|
353
379
|
libraryVersion: manifest.version,
|
|
354
380
|
docsVersion: componentsJson.version,
|
|
355
381
|
generatedAt: componentsJson.generatedAt,
|
|
356
382
|
site,
|
|
357
383
|
components,
|
|
384
|
+
parts,
|
|
358
385
|
guides,
|
|
359
386
|
directives
|
|
360
387
|
};
|
|
@@ -530,1133 +557,1392 @@ function parseJson(text, name) {
|
|
|
530
557
|
}
|
|
531
558
|
|
|
532
559
|
//#endregion
|
|
533
|
-
//#region src/
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
async readText(docsPath) {
|
|
548
|
-
const text = this.documents.get(assertDocsPath(docsPath));
|
|
549
|
-
if (text === void 0) throw new DocsNotFoundError(docsPath);
|
|
550
|
-
return text;
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
|
-
/** The offline snapshot produced at build time by scripts/prebuild.mjs. */
|
|
554
|
-
var SnapshotSource = class {
|
|
555
|
-
directory;
|
|
556
|
-
kind = "snapshot";
|
|
557
|
-
constructor(directory) {
|
|
558
|
-
this.directory = directory;
|
|
559
|
-
}
|
|
560
|
-
async readText(docsPath) {
|
|
561
|
-
const file = path.join(this.directory, assertDocsPath(docsPath));
|
|
562
|
-
try {
|
|
563
|
-
return await readFile(file, "utf8");
|
|
564
|
-
} catch (error) {
|
|
565
|
-
if (error.code === "ENOENT") throw new DocsNotFoundError(docsPath, `Document "${docsPath}" is not in the offline snapshot`);
|
|
566
|
-
throw new DocsFetchError(docsPath, `Cannot read "${docsPath}" from the offline snapshot: ${describeError(error)}`, { cause: error });
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
/** The live docs site. A not-found path is served as the SPA shell with HTTP 200, so HTML answers are treated as misses. */
|
|
571
|
-
var RemoteSource = class {
|
|
572
|
-
options;
|
|
573
|
-
kind = "remote";
|
|
574
|
-
fetchImpl;
|
|
575
|
-
constructor(options) {
|
|
576
|
-
this.options = options;
|
|
577
|
-
this.fetchImpl = options.fetchImpl ?? globalThis.fetch;
|
|
578
|
-
}
|
|
579
|
-
urlFor(docsPath) {
|
|
580
|
-
return `${this.options.baseUrl.replace(/\/+$/, "")}/llms/${assertDocsPath(docsPath)}`;
|
|
581
|
-
}
|
|
582
|
-
async readText(docsPath) {
|
|
583
|
-
const url = this.urlFor(docsPath);
|
|
584
|
-
let response;
|
|
585
|
-
try {
|
|
586
|
-
response = await this.fetchImpl(url, {
|
|
587
|
-
signal: AbortSignal.timeout(this.options.timeoutMs),
|
|
588
|
-
headers: {
|
|
589
|
-
accept: "text/markdown, text/plain, application/json;q=0.9, */*;q=0.1",
|
|
590
|
-
"user-agent": this.options.userAgent ?? "@exhaustive-ui/mcp"
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
} catch (error) {
|
|
594
|
-
throw new DocsFetchError(docsPath, `Cannot reach ${url}: ${describeError(error)}`, { cause: error });
|
|
595
|
-
}
|
|
596
|
-
if (response.status === 404) throw new DocsNotFoundError(docsPath, `${url} answered HTTP 404`);
|
|
597
|
-
if (!response.ok) throw new DocsFetchError(docsPath, `${url} answered HTTP ${response.status}`);
|
|
598
|
-
const text = await response.text();
|
|
599
|
-
if (/text\/html/i.test(response.headers.get("content-type") ?? "") || /^\s*<(?:!doctype|html)/i.test(text)) throw new DocsNotFoundError(docsPath, `${url} is not published (the site answered with its HTML shell)`);
|
|
600
|
-
return text;
|
|
601
|
-
}
|
|
602
|
-
};
|
|
603
|
-
/** Remembers documents for a TTL, dedupes concurrent reads, and serves a stale copy when a refresh fails. */
|
|
604
|
-
var CachedSource = class {
|
|
605
|
-
inner;
|
|
606
|
-
options;
|
|
607
|
-
kind;
|
|
608
|
-
entries = /* @__PURE__ */ new Map();
|
|
609
|
-
pending = /* @__PURE__ */ new Map();
|
|
610
|
-
now;
|
|
611
|
-
hits = 0;
|
|
612
|
-
misses = 0;
|
|
613
|
-
constructor(inner, options) {
|
|
614
|
-
this.inner = inner;
|
|
615
|
-
this.options = options;
|
|
616
|
-
this.kind = inner.kind;
|
|
617
|
-
this.now = options.now ?? Date.now;
|
|
618
|
-
}
|
|
619
|
-
async readText(docsPath) {
|
|
620
|
-
const cached = this.entries.get(docsPath);
|
|
621
|
-
if (cached && cached.expiresAt > this.now()) {
|
|
622
|
-
this.hits++;
|
|
623
|
-
return cached.value;
|
|
624
|
-
}
|
|
625
|
-
const inFlight = this.pending.get(docsPath);
|
|
626
|
-
if (inFlight) return inFlight;
|
|
627
|
-
this.misses++;
|
|
628
|
-
const request = this.inner.readText(docsPath).then((value) => {
|
|
629
|
-
this.entries.set(docsPath, {
|
|
560
|
+
//#region src/template.ts
|
|
561
|
+
const TAG_PATTERN = /<([A-Za-z][\w.-]*)((?:\s+(?:[^\s<>"'=/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'<>]+))?))*)\s*\/?>/g;
|
|
562
|
+
const ATTRIBUTE_PATTERN = /([^\s"'=<>/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>]+)))?/g;
|
|
563
|
+
const IMPORT_PATTERN = /import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s*['"]([^'"]+)['"]/g;
|
|
564
|
+
/** Every opening element of the template with its attributes. */
|
|
565
|
+
function scanElements(code) {
|
|
566
|
+
const elements = [];
|
|
567
|
+
for (const match of code.matchAll(TAG_PATTERN)) {
|
|
568
|
+
const attributes = [];
|
|
569
|
+
for (const attribute of (match[2] ?? "").matchAll(ATTRIBUTE_PATTERN)) {
|
|
570
|
+
const raw = attribute[1];
|
|
571
|
+
const value = attribute[2] ?? attribute[3] ?? attribute[4];
|
|
572
|
+
attributes.push({
|
|
573
|
+
raw,
|
|
630
574
|
value,
|
|
631
|
-
|
|
575
|
+
...classifyAttribute(raw)
|
|
632
576
|
});
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
expiresAt: this.now() + this.options.ttlMs
|
|
639
|
-
});
|
|
640
|
-
return cached.value;
|
|
641
|
-
}
|
|
642
|
-
throw error;
|
|
643
|
-
}).finally(() => {
|
|
644
|
-
this.pending.delete(docsPath);
|
|
577
|
+
}
|
|
578
|
+
elements.push({
|
|
579
|
+
name: match[1],
|
|
580
|
+
attributes,
|
|
581
|
+
raw: match[0]
|
|
645
582
|
});
|
|
646
|
-
this.pending.set(docsPath, request);
|
|
647
|
-
return request;
|
|
648
|
-
}
|
|
649
|
-
invalidate() {
|
|
650
|
-
this.entries.clear();
|
|
651
583
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
584
|
+
return elements;
|
|
585
|
+
}
|
|
586
|
+
function classifyAttribute(raw) {
|
|
587
|
+
let match = /^\[\((.+)\)\]$/.exec(raw);
|
|
588
|
+
if (match) return {
|
|
589
|
+
kind: "twoWay",
|
|
590
|
+
name: match[1]
|
|
591
|
+
};
|
|
592
|
+
match = /^bindon-(.+)$/.exec(raw);
|
|
593
|
+
if (match) return {
|
|
594
|
+
kind: "twoWay",
|
|
595
|
+
name: match[1]
|
|
596
|
+
};
|
|
597
|
+
match = /^\[(.+)\]$/.exec(raw) ?? /^bind-(.+)$/.exec(raw);
|
|
598
|
+
if (match) {
|
|
599
|
+
const target = match[1];
|
|
600
|
+
return /^(?:attr|class|style)\./.test(target) ? {
|
|
601
|
+
kind: "other",
|
|
602
|
+
name: target
|
|
603
|
+
} : {
|
|
604
|
+
kind: "property",
|
|
605
|
+
name: target
|
|
658
606
|
};
|
|
659
607
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
if (primaryError !== void 0) this.lastFallbackReason = describeError(primaryError);
|
|
700
|
-
return text;
|
|
608
|
+
match = /^\((.+)\)$/.exec(raw) ?? /^on-(.+)$/.exec(raw);
|
|
609
|
+
if (match) return {
|
|
610
|
+
kind: "event",
|
|
611
|
+
name: match[1]
|
|
612
|
+
};
|
|
613
|
+
if (raw.startsWith("*")) return {
|
|
614
|
+
kind: "structural",
|
|
615
|
+
name: raw.slice(1)
|
|
616
|
+
};
|
|
617
|
+
if (raw.startsWith("let-")) return {
|
|
618
|
+
kind: "other",
|
|
619
|
+
name: raw
|
|
620
|
+
};
|
|
621
|
+
if (raw.startsWith("#") || raw.startsWith("ref-")) return {
|
|
622
|
+
kind: "reference",
|
|
623
|
+
name: raw.replace(/^#|^ref-/, "")
|
|
624
|
+
};
|
|
625
|
+
if (raw.startsWith("@") || raw.startsWith("i18n") || raw.includes(".")) return {
|
|
626
|
+
kind: "other",
|
|
627
|
+
name: raw
|
|
628
|
+
};
|
|
629
|
+
return {
|
|
630
|
+
kind: "static",
|
|
631
|
+
name: raw
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
/** ES import statements of a component source. */
|
|
635
|
+
function scanImports(code) {
|
|
636
|
+
const imports = [];
|
|
637
|
+
for (const match of code.matchAll(IMPORT_PATTERN)) {
|
|
638
|
+
const names = [
|
|
639
|
+
match[1],
|
|
640
|
+
match[3],
|
|
641
|
+
...(match[2] ?? "").split(",").map((name) => name.trim().split(/\s+as\s+/).pop() ?? "")
|
|
642
|
+
].filter((name) => !!name);
|
|
643
|
+
imports.push({
|
|
644
|
+
source: match[4],
|
|
645
|
+
names
|
|
646
|
+
});
|
|
701
647
|
}
|
|
702
|
-
|
|
703
|
-
return {
|
|
704
|
-
primary: this.primary.kind,
|
|
705
|
-
fallback: this.fallback.kind,
|
|
706
|
-
fallbackReads: this.fallbackReads,
|
|
707
|
-
lastFallbackAt: this.lastFallbackAt,
|
|
708
|
-
lastFallbackReason: this.lastFallbackReason,
|
|
709
|
-
primarySkippedUntil: this.primarySkippedUntil > this.now() ? new Date(this.primarySkippedUntil).toISOString() : void 0
|
|
710
|
-
};
|
|
711
|
-
}
|
|
712
|
-
};
|
|
713
|
-
/** The runtime source: the live site behind a TTL cache, falling back to the offline snapshot (or the snapshot alone when offline). */
|
|
714
|
-
function createDocsSource(config, fetchImpl) {
|
|
715
|
-
const snapshot = config.snapshotDir ? new SnapshotSource(config.snapshotDir) : void 0;
|
|
716
|
-
if (config.offline) {
|
|
717
|
-
if (!snapshot) throw new Error("Offline mode needs an offline snapshot directory (EXHAUSTIVE_UI_MCP_SNAPSHOT_DIR).");
|
|
718
|
-
return {
|
|
719
|
-
source: snapshot,
|
|
720
|
-
status: () => ({
|
|
721
|
-
mode: "offline",
|
|
722
|
-
docsUrl: config.docsUrl,
|
|
723
|
-
cacheTtlSeconds: 0,
|
|
724
|
-
snapshotDir: snapshot.directory
|
|
725
|
-
})
|
|
726
|
-
};
|
|
727
|
-
}
|
|
728
|
-
const remote = new CachedSource(new RemoteSource({
|
|
729
|
-
baseUrl: config.docsUrl,
|
|
730
|
-
timeoutMs: config.fetchTimeoutMs,
|
|
731
|
-
fetchImpl
|
|
732
|
-
}), { ttlMs: config.cacheTtlMs });
|
|
733
|
-
const fallback = snapshot ? new FallbackSource(remote, snapshot) : void 0;
|
|
734
|
-
return {
|
|
735
|
-
source: fallback ?? remote,
|
|
736
|
-
status: () => ({
|
|
737
|
-
mode: "remote",
|
|
738
|
-
docsUrl: config.docsUrl,
|
|
739
|
-
cacheTtlSeconds: Math.round(config.cacheTtlMs / 1e3),
|
|
740
|
-
snapshotDir: snapshot?.directory,
|
|
741
|
-
fallback: fallback?.status(),
|
|
742
|
-
cache: remote.stats()
|
|
743
|
-
})
|
|
744
|
-
};
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
//#endregion
|
|
748
|
-
//#region src/search.ts
|
|
749
|
-
const indexes = /* @__PURE__ */ new WeakMap();
|
|
750
|
-
/** Search components, guides, API members and examples of the catalog. Results are sorted by relevance. */
|
|
751
|
-
function searchCatalog(catalog, query, scope = "all") {
|
|
752
|
-
const phrase = query.trim().toLowerCase();
|
|
753
|
-
const terms = tokenize(query);
|
|
754
|
-
const entries = indexFor(catalog).filter((entry) => scope === "all" ? entry.scope === "components" || entry.scope === "guides" : entry.scope === scope);
|
|
755
|
-
const hits = [];
|
|
756
|
-
for (const entry of entries) {
|
|
757
|
-
const match = scoreEntry(entry.fields, phrase, terms);
|
|
758
|
-
if (match) hits.push({
|
|
759
|
-
...entry.result,
|
|
760
|
-
type: String(entry.result.type),
|
|
761
|
-
score: match.score,
|
|
762
|
-
matchedTerms: match.matchedTerms,
|
|
763
|
-
matches: match.matches
|
|
764
|
-
});
|
|
765
|
-
}
|
|
766
|
-
return hits.sort((a, b) => b.score - a.score || b.matchedTerms.length - a.matchedTerms.length || String(a.title ?? a.name).localeCompare(String(b.title ?? b.name)));
|
|
767
|
-
}
|
|
768
|
-
function scoreEntry(fields, phrase, terms) {
|
|
769
|
-
const matchedTerms = /* @__PURE__ */ new Set();
|
|
770
|
-
const matches = [];
|
|
771
|
-
let score = 0;
|
|
772
|
-
let phraseMatched = false;
|
|
773
|
-
for (const field of fields) {
|
|
774
|
-
if (!field.text) continue;
|
|
775
|
-
if (phrase && field.lower.includes(phrase)) {
|
|
776
|
-
phraseMatched = true;
|
|
777
|
-
score += 100 * field.weight;
|
|
778
|
-
matches.push(...snippets(field.text, phrase));
|
|
779
|
-
}
|
|
780
|
-
for (const term of terms) if (matchesTerm(term, field.lower, field.terms)) {
|
|
781
|
-
matchedTerms.add(term);
|
|
782
|
-
score += field.weight;
|
|
783
|
-
matches.push(...snippetsForTerm(field.text, term));
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
const required = terms.length <= 2 ? 1 : Math.max(2, Math.ceil(terms.length * .4));
|
|
787
|
-
if (!phraseMatched && matchedTerms.size < required) return;
|
|
788
|
-
return {
|
|
789
|
-
score,
|
|
790
|
-
matchedTerms: [...matchedTerms],
|
|
791
|
-
matches: unique(matches).slice(0, 5)
|
|
792
|
-
};
|
|
793
|
-
}
|
|
794
|
-
function indexFor(catalog) {
|
|
795
|
-
let index = indexes.get(catalog);
|
|
796
|
-
if (!index) {
|
|
797
|
-
index = buildIndex(catalog);
|
|
798
|
-
indexes.set(catalog, index);
|
|
799
|
-
}
|
|
800
|
-
return index;
|
|
801
|
-
}
|
|
802
|
-
function buildIndex(catalog) {
|
|
803
|
-
const entries = [];
|
|
804
|
-
for (const component of catalog.components) {
|
|
805
|
-
entries.push(componentEntry(component));
|
|
806
|
-
entries.push(...apiEntries(component));
|
|
807
|
-
entries.push(...exampleEntries(component));
|
|
808
|
-
}
|
|
809
|
-
for (const guide of catalog.guides) entries.push(guideEntry(guide));
|
|
810
|
-
return entries;
|
|
648
|
+
return imports;
|
|
811
649
|
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
...api.props ?? [],
|
|
816
|
-
...api.emits ?? [],
|
|
817
|
-
...api.templates ?? [],
|
|
818
|
-
...api.methods ?? [],
|
|
819
|
-
...api.pt ?? []
|
|
820
|
-
].map((member) => `${member.name} ${member.description ?? ""}`).join(" ");
|
|
821
|
-
const sectionsText = component.sections.map((section) => `${section.label} ${section.description ?? ""}`).join(" ");
|
|
822
|
-
const codeText = component.sections.map((section) => section.code ?? "").join("\n");
|
|
823
|
-
return {
|
|
824
|
-
scope: "components",
|
|
825
|
-
result: {
|
|
826
|
-
type: "component",
|
|
827
|
-
name: component.name,
|
|
828
|
-
title: component.title,
|
|
829
|
-
description: component.description,
|
|
830
|
-
selectors: component.selectors,
|
|
831
|
-
import: component.import,
|
|
832
|
-
resourceUri: component.resourceUri,
|
|
833
|
-
publicUrl: component.publicUrl,
|
|
834
|
-
nextCall: {
|
|
835
|
-
tool: "get_component",
|
|
836
|
-
arguments: { component: component.name }
|
|
837
|
-
}
|
|
838
|
-
},
|
|
839
|
-
fields: [
|
|
840
|
-
field([
|
|
841
|
-
component.name,
|
|
842
|
-
shortTitle(component.title),
|
|
843
|
-
...component.selectors,
|
|
844
|
-
component.import ?? "",
|
|
845
|
-
...component.declarations.map((declaration) => declaration.className)
|
|
846
|
-
].join(" "), 8),
|
|
847
|
-
field(component.description, 4),
|
|
848
|
-
field(sectionsText, 3),
|
|
849
|
-
field(apiText, 3),
|
|
850
|
-
field(codeText, 1)
|
|
851
|
-
]
|
|
852
|
-
};
|
|
650
|
+
/** Whether an attribute value is a template expression rather than a literal. */
|
|
651
|
+
function isInterpolated(value) {
|
|
652
|
+
return value !== void 0 && value.includes("{{");
|
|
853
653
|
}
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
type: "guide",
|
|
859
|
-
name: guide.name,
|
|
860
|
-
title: guide.title,
|
|
861
|
-
description: guide.description,
|
|
862
|
-
route: guide.route,
|
|
863
|
-
resourceUri: guide.resourceUri,
|
|
864
|
-
publicUrl: guide.publicUrl,
|
|
865
|
-
nextCall: {
|
|
866
|
-
tool: "get_guide",
|
|
867
|
-
arguments: { guide: guide.name }
|
|
868
|
-
}
|
|
869
|
-
},
|
|
870
|
-
fields: [
|
|
871
|
-
field([
|
|
872
|
-
guide.name,
|
|
873
|
-
guide.route,
|
|
874
|
-
guide.title
|
|
875
|
-
].join(" "), 8),
|
|
876
|
-
field(guide.description, 4),
|
|
877
|
-
field(guide.sections.map((section) => `${section.label} ${section.description ?? ""}`).join(" "), 3),
|
|
878
|
-
field(guide.sections.map((section) => section.code ?? "").join("\n"), 1)
|
|
879
|
-
]
|
|
880
|
-
};
|
|
654
|
+
/** The string literal a property binding assigns (`[severity]="'danger'"` -> `danger`), or undefined when it is an expression. */
|
|
655
|
+
function literalOfBinding(value) {
|
|
656
|
+
const match = value === void 0 ? null : /^\s*(?:'([^']*)'|"([^"]*)")\s*$/.exec(value);
|
|
657
|
+
return match ? match[1] ?? match[2] : void 0;
|
|
881
658
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
659
|
+
|
|
660
|
+
//#endregion
|
|
661
|
+
//#region src/v22.ts
|
|
662
|
+
/**
|
|
663
|
+
* Inputs and outputs removed or renamed in ExhaustiveUI v22, keyed by component tag (`p-` prefix,
|
|
664
|
+
* case and hyphens ignored). Mirrors the `ng update` migrations of @exhaustive-ui/core
|
|
665
|
+
* (styleclass-to-class, renamed-inputs, renamed-outputs, remove-dead-inputs, remove-dead-outputs) so that
|
|
666
|
+
* validate_usage can name the replacement instead of only reporting an unknown binding.
|
|
667
|
+
*/
|
|
668
|
+
const STYLE_CLASS_REMOVED = [
|
|
669
|
+
"accordion",
|
|
670
|
+
"autocomplete",
|
|
671
|
+
"avatar",
|
|
672
|
+
"avatargroup",
|
|
673
|
+
"badge",
|
|
674
|
+
"blockui",
|
|
675
|
+
"card",
|
|
676
|
+
"carousel",
|
|
677
|
+
"cascadeselect",
|
|
678
|
+
"checkbox",
|
|
679
|
+
"chip",
|
|
680
|
+
"colorpicker",
|
|
681
|
+
"dataview",
|
|
682
|
+
"datepicker",
|
|
683
|
+
"divider",
|
|
684
|
+
"dock",
|
|
685
|
+
"editor",
|
|
686
|
+
"iconfield",
|
|
687
|
+
"image",
|
|
688
|
+
"inplace",
|
|
689
|
+
"inputgroup",
|
|
690
|
+
"inputgroupaddon",
|
|
691
|
+
"inputicon",
|
|
692
|
+
"inputnumber",
|
|
693
|
+
"knob",
|
|
694
|
+
"listbox",
|
|
695
|
+
"megamenu",
|
|
696
|
+
"menubar",
|
|
697
|
+
"message",
|
|
698
|
+
"metergroup",
|
|
699
|
+
"multiselect",
|
|
700
|
+
"orderlist",
|
|
701
|
+
"organizationchart",
|
|
702
|
+
"paginator",
|
|
703
|
+
"panel",
|
|
704
|
+
"panelmenu",
|
|
705
|
+
"password",
|
|
706
|
+
"progressbar",
|
|
707
|
+
"progressspinner",
|
|
708
|
+
"radiobutton",
|
|
709
|
+
"scrollpanel",
|
|
710
|
+
"select",
|
|
711
|
+
"skeleton",
|
|
712
|
+
"slider",
|
|
713
|
+
"splitbutton",
|
|
714
|
+
"splitter",
|
|
715
|
+
"table",
|
|
716
|
+
"tag",
|
|
717
|
+
"terminal",
|
|
718
|
+
"timeline",
|
|
719
|
+
"toast",
|
|
720
|
+
"togglebutton",
|
|
721
|
+
"toggleswitch",
|
|
722
|
+
"toolbar",
|
|
723
|
+
"tree",
|
|
724
|
+
"treetable"
|
|
725
|
+
];
|
|
726
|
+
const RENAMED = {
|
|
727
|
+
drawer: {
|
|
728
|
+
showcloseicon: "closable",
|
|
729
|
+
ariacloselabel: "closeAriaLabel"
|
|
730
|
+
},
|
|
731
|
+
paginator: { dropdownappendto: "appendTo" },
|
|
732
|
+
dialog: { content: "headerTemplate" },
|
|
733
|
+
autocomplete: { minlength: "minQueryLength" },
|
|
734
|
+
treeselect: {
|
|
735
|
+
containerstyleclass: "class",
|
|
736
|
+
containerstyle: "style"
|
|
737
|
+
},
|
|
738
|
+
treetable: { virtualrowheight: "virtualScrollItemSize" },
|
|
739
|
+
pbutton: { ptbuttondirective: "pButtonPT" },
|
|
740
|
+
pbuttonlabel: { ptbuttonlabel: "pButtonLabelPT" },
|
|
741
|
+
pbuttonicon: { ptbuttonicon: "pButtonIconPT" },
|
|
742
|
+
pbadge: {
|
|
743
|
+
ptbadgedirective: "pBadgePT",
|
|
744
|
+
size: "badgeSize"
|
|
745
|
+
},
|
|
746
|
+
pinputtext: { ptinputtext: "pInputTextPT" },
|
|
747
|
+
ptooltip: { pttooltip: "pTooltipPT" }
|
|
748
|
+
};
|
|
749
|
+
const DEAD_INPUTS = {
|
|
750
|
+
toast: [
|
|
751
|
+
"showTransformOptions",
|
|
752
|
+
"hideTransformOptions",
|
|
753
|
+
"showTransitionOptions",
|
|
754
|
+
"hideTransitionOptions"
|
|
755
|
+
],
|
|
756
|
+
toastitem: [
|
|
757
|
+
"showTransformOptions",
|
|
758
|
+
"hideTransformOptions",
|
|
759
|
+
"showTransitionOptions",
|
|
760
|
+
"hideTransitionOptions"
|
|
761
|
+
],
|
|
762
|
+
message: ["showTransitionOptions", "hideTransitionOptions"],
|
|
763
|
+
overlay: ["showTransitionOptions", "hideTransitionOptions"],
|
|
764
|
+
colorpicker: ["showTransitionOptions", "hideTransitionOptions"],
|
|
765
|
+
overlaybadge: ["size"],
|
|
766
|
+
fieldset: ["transitionOptions"],
|
|
767
|
+
panel: ["transitionOptions"],
|
|
768
|
+
accordion: ["transitionOptions"],
|
|
769
|
+
scrolltop: ["showTransitionOptions", "hideTransitionOptions"],
|
|
770
|
+
togglebutton: ["inputId"],
|
|
771
|
+
popover: [
|
|
772
|
+
"showTransitionOptions",
|
|
773
|
+
"hideTransitionOptions",
|
|
774
|
+
"ariaCloseLabel"
|
|
775
|
+
],
|
|
776
|
+
image: [
|
|
777
|
+
"showTransitionOptions",
|
|
778
|
+
"hideTransitionOptions",
|
|
779
|
+
"modalEnterAnimation",
|
|
780
|
+
"modalLeaveAnimation"
|
|
781
|
+
],
|
|
782
|
+
drawer: ["transitionOptions"],
|
|
783
|
+
menu: ["showTransitionOptions", "hideTransitionOptions"],
|
|
784
|
+
splitbutton: [
|
|
785
|
+
"showTransitionOptions",
|
|
786
|
+
"hideTransitionOptions",
|
|
787
|
+
"plain"
|
|
788
|
+
],
|
|
789
|
+
password: ["showTransitionOptions", "hideTransitionOptions"],
|
|
790
|
+
button: ["badgeClass"],
|
|
791
|
+
contextmenusub: [
|
|
792
|
+
"autoZIndex",
|
|
793
|
+
"baseZIndex",
|
|
794
|
+
"popup"
|
|
795
|
+
],
|
|
796
|
+
tieredmenu: ["showTransitionOptions", "hideTransitionOptions"],
|
|
797
|
+
menubar: ["autoZIndex", "baseZIndex"],
|
|
798
|
+
menubarsub: [
|
|
799
|
+
"autoZIndex",
|
|
800
|
+
"baseZIndex",
|
|
801
|
+
"mobileActive",
|
|
802
|
+
"ariaLabel",
|
|
803
|
+
"ariaLabelledBy"
|
|
804
|
+
],
|
|
805
|
+
panelmenu: ["transitionOptions", "tabindex"],
|
|
806
|
+
megamenusub: ["disabled", "queryMatches"],
|
|
807
|
+
galleria: [
|
|
808
|
+
"showTransitionOptions",
|
|
809
|
+
"hideTransitionOptions",
|
|
810
|
+
"containerClass"
|
|
811
|
+
],
|
|
812
|
+
fileupload: ["removeStyleClass"],
|
|
813
|
+
cascadeselect: ["inputLabel", "emptyMessage"],
|
|
814
|
+
datepicker: ["showTransitionOptions", "hideTransitionOptions"],
|
|
815
|
+
dialog: ["transitionOptions", "rtl"],
|
|
816
|
+
confirmdialog: [
|
|
817
|
+
"closeAriaLabel",
|
|
818
|
+
"acceptAriaLabel",
|
|
819
|
+
"rejectAriaLabel",
|
|
820
|
+
"rtl",
|
|
821
|
+
"transitionOptions",
|
|
822
|
+
"focusTrap",
|
|
823
|
+
"defaultFocus"
|
|
824
|
+
],
|
|
825
|
+
treenode: [
|
|
826
|
+
"rowNode",
|
|
827
|
+
"root",
|
|
828
|
+
"firstChild",
|
|
829
|
+
"lastChild"
|
|
830
|
+
],
|
|
831
|
+
selectitem: ["visible", "itemSize"],
|
|
832
|
+
table: ["frozenColumns", "frozenWidth"],
|
|
833
|
+
autocomplete: [
|
|
834
|
+
"autoZIndex",
|
|
835
|
+
"baseZIndex",
|
|
836
|
+
"showTransitionOptions",
|
|
837
|
+
"hideTransitionOptions",
|
|
838
|
+
"autoHighlight"
|
|
839
|
+
],
|
|
840
|
+
multiselect: ["filterFields"],
|
|
841
|
+
stepper: ["transitionOptions"],
|
|
842
|
+
listbox: ["searchLocale"],
|
|
843
|
+
dataview: ["gridStyleClass", "trackBy"],
|
|
844
|
+
orderlist: ["trackBy", "header"],
|
|
845
|
+
picklist: [
|
|
846
|
+
"trackBy",
|
|
847
|
+
"sourceTrackBy",
|
|
848
|
+
"targetTrackBy"
|
|
849
|
+
],
|
|
850
|
+
toggleswitch: ["size"],
|
|
851
|
+
selectbutton: ["tabindex"],
|
|
852
|
+
confirmpopup: [
|
|
853
|
+
"showTransitionOptions",
|
|
854
|
+
"hideTransitionOptions",
|
|
855
|
+
"baseZIndex"
|
|
856
|
+
],
|
|
857
|
+
treetablesorticon: ["ariaLabelAsc", "ariaLabelDesc"]
|
|
858
|
+
};
|
|
859
|
+
const RENAMED_OUTPUTS = {
|
|
860
|
+
orderlist: { onFilterEvent: "onFilter" },
|
|
861
|
+
table: { selectAllChange: "onSelectAllChange" },
|
|
862
|
+
multiselect: {
|
|
863
|
+
onPanelShow: "onShow",
|
|
864
|
+
onPanelHide: "onHide"
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
const DEAD_OUTPUTS = {
|
|
868
|
+
overlay: ["onAnimationStart", "onAnimationDone"],
|
|
869
|
+
menubarsub: [
|
|
870
|
+
"menuFocus",
|
|
871
|
+
"menuBlur",
|
|
872
|
+
"menuKeydown"
|
|
873
|
+
]
|
|
874
|
+
};
|
|
875
|
+
function tagKey(tag) {
|
|
876
|
+
return compact(tag.replace(/^p-/i, ""));
|
|
946
877
|
}
|
|
947
|
-
function
|
|
948
|
-
return
|
|
949
|
-
scope: "examples",
|
|
950
|
-
result: {
|
|
951
|
-
type: "example",
|
|
952
|
-
component: component.name,
|
|
953
|
-
section: section.id,
|
|
954
|
-
title: section.label,
|
|
955
|
-
description: section.description,
|
|
956
|
-
codeLanguage: section.codeLanguage,
|
|
957
|
-
resourceUri: component.resourceUri,
|
|
958
|
-
nextCall: {
|
|
959
|
-
tool: "get_example",
|
|
960
|
-
arguments: {
|
|
961
|
-
component: component.name,
|
|
962
|
-
section: section.id
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
},
|
|
966
|
-
fields: [
|
|
967
|
-
field(`${component.name} ${section.label} ${section.id}`, 8),
|
|
968
|
-
field(section.description ?? "", 3),
|
|
969
|
-
field(section.code ?? "", 1)
|
|
970
|
-
]
|
|
971
|
-
}));
|
|
878
|
+
function has(list, name) {
|
|
879
|
+
return !!list?.some((entry) => entry.toLowerCase() === name.toLowerCase());
|
|
972
880
|
}
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
881
|
+
/**
|
|
882
|
+
* Replacement guidance for an input that no longer exists on `tag` (an element name, or an attribute
|
|
883
|
+
* directive selector such as `[pTooltip]`), or undefined when it was not removed in v22.
|
|
884
|
+
*/
|
|
885
|
+
function removedInputHint(tag, name) {
|
|
886
|
+
const key = tagKey(tag);
|
|
887
|
+
const lower = name.toLowerCase();
|
|
888
|
+
if (lower === "styleclass" && STYLE_CLASS_REMOVED.includes(key)) return {
|
|
889
|
+
message: "styleClass was removed in v22: use the native class attribute (ng update applies the styleclass-to-class migration).",
|
|
890
|
+
suggestion: "class"
|
|
891
|
+
};
|
|
892
|
+
const renamed = RENAMED[key]?.[lower];
|
|
893
|
+
if (renamed) return {
|
|
894
|
+
message: `${name} was renamed to ${renamed} in v22 (ng update applies the renamed-inputs migration).`,
|
|
895
|
+
suggestion: renamed
|
|
980
896
|
};
|
|
897
|
+
if (has(DEAD_INPUTS[key], name)) return { message: `${name} was removed in v22: it had no effect anymore, delete the binding (ng update applies the remove-dead-inputs migration).` };
|
|
898
|
+
}
|
|
899
|
+
/** Replacement guidance for an output that no longer exists on `tag`, or undefined when it was not removed in v22. */
|
|
900
|
+
function removedOutputHint(tag, name) {
|
|
901
|
+
const key = tagKey(tag);
|
|
902
|
+
const renamed = RENAMED_OUTPUTS[key]?.[name];
|
|
903
|
+
if (renamed) return {
|
|
904
|
+
message: `${name} was renamed to ${renamed} in v22, with the same event payload (ng update applies the renamed-outputs migration).`,
|
|
905
|
+
suggestion: renamed
|
|
906
|
+
};
|
|
907
|
+
if (!has(DEAD_OUTPUTS[key], name)) return;
|
|
908
|
+
return { message: `${name} was removed in v22: ${key === "overlay" ? "use onOverlayBeforeEnter/onOverlayAfterEnter (show) or onOverlayBeforeLeave/onOverlayAfterLeave (hide) instead" : "it never fired, bind the native focus/blur/keydown events of the element instead"} (ng update applies the remove-dead-outputs migration).` };
|
|
981
909
|
}
|
|
982
910
|
|
|
983
911
|
//#endregion
|
|
984
|
-
//#region src/
|
|
985
|
-
|
|
986
|
-
const
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
912
|
+
//#region src/validate.ts
|
|
913
|
+
/** Attributes any element may carry; never reported as unknown inputs. */
|
|
914
|
+
const GLOBAL_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
915
|
+
"id",
|
|
916
|
+
"class",
|
|
917
|
+
"style",
|
|
918
|
+
"title",
|
|
919
|
+
"hidden",
|
|
920
|
+
"tabindex",
|
|
921
|
+
"role",
|
|
922
|
+
"lang",
|
|
923
|
+
"dir",
|
|
924
|
+
"slot",
|
|
925
|
+
"part",
|
|
926
|
+
"autofocus",
|
|
927
|
+
"draggable",
|
|
928
|
+
"contenteditable",
|
|
929
|
+
"spellcheck",
|
|
930
|
+
"translate",
|
|
931
|
+
"accesskey",
|
|
932
|
+
"inert",
|
|
933
|
+
"popover",
|
|
934
|
+
"ngmodel",
|
|
935
|
+
"ngclass",
|
|
936
|
+
"ngstyle",
|
|
937
|
+
"ngmodeloptions",
|
|
938
|
+
"formcontrol",
|
|
939
|
+
"formfield",
|
|
940
|
+
"field",
|
|
941
|
+
"minlength",
|
|
942
|
+
"maxlength",
|
|
943
|
+
"email",
|
|
944
|
+
"formcontrolname",
|
|
945
|
+
"formgroup",
|
|
946
|
+
"formgroupname",
|
|
947
|
+
"formarrayname",
|
|
948
|
+
"ngmodelgroup",
|
|
949
|
+
"ngform",
|
|
950
|
+
"ngnativevalidate",
|
|
951
|
+
"ngnonbindable",
|
|
952
|
+
"ngtemplateoutlet",
|
|
953
|
+
"ngtemplateoutletcontext",
|
|
954
|
+
"ngcomponentoutlet",
|
|
955
|
+
"ngprojectas",
|
|
956
|
+
"routerlink",
|
|
957
|
+
"routerlinkactive",
|
|
958
|
+
"routerlinkactiveoptions",
|
|
959
|
+
"queryparams",
|
|
960
|
+
"cdkdrag",
|
|
961
|
+
"cdkdroplist",
|
|
962
|
+
"ptooltip"
|
|
963
|
+
]);
|
|
964
|
+
/** Attributes and properties of native elements a directive like pButton or pInputText is applied to. */
|
|
965
|
+
const NATIVE_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
966
|
+
"type",
|
|
967
|
+
"name",
|
|
968
|
+
"value",
|
|
969
|
+
"placeholder",
|
|
970
|
+
"disabled",
|
|
971
|
+
"readonly",
|
|
972
|
+
"required",
|
|
973
|
+
"checked",
|
|
974
|
+
"selected",
|
|
975
|
+
"multiple",
|
|
976
|
+
"min",
|
|
977
|
+
"max",
|
|
978
|
+
"step",
|
|
979
|
+
"minlength",
|
|
980
|
+
"maxlength",
|
|
981
|
+
"pattern",
|
|
982
|
+
"size",
|
|
983
|
+
"rows",
|
|
984
|
+
"cols",
|
|
985
|
+
"wrap",
|
|
986
|
+
"autocomplete",
|
|
987
|
+
"inputmode",
|
|
988
|
+
"enterkeyhint",
|
|
989
|
+
"src",
|
|
990
|
+
"srcset",
|
|
991
|
+
"alt",
|
|
992
|
+
"href",
|
|
993
|
+
"target",
|
|
994
|
+
"rel",
|
|
995
|
+
"download",
|
|
996
|
+
"for",
|
|
997
|
+
"form",
|
|
998
|
+
"list",
|
|
999
|
+
"label",
|
|
1000
|
+
"width",
|
|
1001
|
+
"height",
|
|
1002
|
+
"loading",
|
|
1003
|
+
"innerhtml",
|
|
1004
|
+
"innertext",
|
|
1005
|
+
"textcontent",
|
|
1006
|
+
"scrolltop",
|
|
1007
|
+
"scrollleft"
|
|
1008
|
+
]);
|
|
1009
|
+
const LEGACY_IMPORT_PATTERN = /^(?:primeng(?:\/.*)?|@primeng\/.*|@openng\/optimus-ui(?:\/.*)?|optimus-ui(?:\/.*)?)$/;
|
|
1010
|
+
const selectorIndexes = /* @__PURE__ */ new WeakMap();
|
|
1011
|
+
function selectorIndex(catalog) {
|
|
1012
|
+
let index = selectorIndexes.get(catalog);
|
|
1013
|
+
if (!index) {
|
|
1014
|
+
index = {
|
|
1015
|
+
elements: /* @__PURE__ */ new Map(),
|
|
1016
|
+
attributes: /* @__PURE__ */ new Map()
|
|
1017
|
+
};
|
|
1018
|
+
for (const component of [...catalog.components, ...catalog.parts]) for (const declaration of component.declarations) for (const selector of splitSelectors(declaration.selector)) {
|
|
1019
|
+
const attribute = attributeSelectorName(selector);
|
|
1020
|
+
if (attribute) index.attributes.set(attribute.toLowerCase(), {
|
|
1021
|
+
component,
|
|
1022
|
+
declaration
|
|
1023
|
+
});
|
|
1024
|
+
else if (/^[a-z][\w-]*$/i.test(selector)) index.elements.set(selector.toLowerCase(), {
|
|
1025
|
+
component,
|
|
1026
|
+
declaration
|
|
1000
1027
|
});
|
|
1001
1028
|
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1029
|
+
selectorIndexes.set(catalog, index);
|
|
1030
|
+
}
|
|
1031
|
+
return index;
|
|
1032
|
+
}
|
|
1033
|
+
/** Validate a template or component source against the generated API of one component. */
|
|
1034
|
+
function validateComponentUsage(catalog, component, code) {
|
|
1035
|
+
const issues = [...checkImports$1(component, code)];
|
|
1036
|
+
if (component.declarations.length === 0) {
|
|
1037
|
+
issues.push({
|
|
1038
|
+
kind: "api-unavailable",
|
|
1039
|
+
severity: "warning",
|
|
1040
|
+
name: component.name,
|
|
1041
|
+
message: `No compiled API metadata is available for ${component.title}; bindings could not be checked.`
|
|
1042
|
+
});
|
|
1043
|
+
return issues;
|
|
1044
|
+
}
|
|
1045
|
+
const index = selectorIndex(catalog);
|
|
1046
|
+
const ownSelectors = new Set(component.selectors.map((selector) => (attributeSelectorName(selector) ?? selector).toLowerCase()));
|
|
1047
|
+
const elements = scanElements(code);
|
|
1048
|
+
const usages = elements.map((element) => ({
|
|
1049
|
+
element,
|
|
1050
|
+
matches: declarationsOn(element, index)
|
|
1051
|
+
})).filter(({ matches }) => matches.some((ref) => ref.component === component));
|
|
1052
|
+
if (usages.length === 0) {
|
|
1053
|
+
issues.push(...checkSelectorMismatch(component, elements, index));
|
|
1054
|
+
if (!issues.some((issue) => issue.kind === "selector-mismatch" || issue.kind === "unknown-selector")) issues.push({
|
|
1055
|
+
kind: "selector-not-found",
|
|
1056
|
+
severity: "warning",
|
|
1057
|
+
name: component.name,
|
|
1058
|
+
message: `The code does not use ${component.title}: none of its selectors (${component.selectors.join(", ")}) appear in it.`
|
|
1059
|
+
});
|
|
1060
|
+
return issues;
|
|
1061
|
+
}
|
|
1062
|
+
for (const { element, matches } of usages) issues.push(...checkElement(component, element, matches, ownSelectors.has(element.name.toLowerCase())));
|
|
1063
|
+
return dedupe(issues);
|
|
1064
|
+
}
|
|
1065
|
+
function checkImports$1(component, code) {
|
|
1066
|
+
const issues = [];
|
|
1067
|
+
for (const statement of scanImports(code)) if (LEGACY_IMPORT_PATTERN.test(statement.source)) {
|
|
1068
|
+
const target = statement.source.split("/").slice(1).join("/");
|
|
1069
|
+
const suggestion = target && target === component.name ? component.import : target ? `@exhaustive-ui/core/${target}` : "@exhaustive-ui/core";
|
|
1070
|
+
issues.push({
|
|
1071
|
+
kind: "import-mismatch",
|
|
1072
|
+
severity: "error",
|
|
1073
|
+
name: statement.source,
|
|
1074
|
+
message: `"${statement.source}" is a PrimeNG / Optimus UI import; ExhaustiveUI components are imported from @exhaustive-ui/core.`,
|
|
1075
|
+
suggestion: suggestion ? `import { ${statement.names.join(", ") || component.modules[0] || component.declarations[0]?.className || ""} } from '${suggestion}';` : void 0
|
|
1006
1076
|
});
|
|
1007
1077
|
}
|
|
1008
|
-
return
|
|
1078
|
+
return issues;
|
|
1009
1079
|
}
|
|
1010
|
-
function
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
kind: "twoWay",
|
|
1019
|
-
name: match[1]
|
|
1020
|
-
};
|
|
1021
|
-
match = /^\[(.+)\]$/.exec(raw) ?? /^bind-(.+)$/.exec(raw);
|
|
1022
|
-
if (match) {
|
|
1023
|
-
const target = match[1];
|
|
1024
|
-
return /^(?:attr|class|style)\./.test(target) ? {
|
|
1025
|
-
kind: "other",
|
|
1026
|
-
name: target
|
|
1027
|
-
} : {
|
|
1028
|
-
kind: "property",
|
|
1029
|
-
name: target
|
|
1030
|
-
};
|
|
1080
|
+
function declarationsOn(element, index) {
|
|
1081
|
+
const refs = [];
|
|
1082
|
+
const byElement = index.elements.get(element.name.toLowerCase());
|
|
1083
|
+
if (byElement) refs.push(byElement);
|
|
1084
|
+
for (const attribute of element.attributes) {
|
|
1085
|
+
if (attribute.kind !== "static" && attribute.kind !== "property") continue;
|
|
1086
|
+
const byAttribute = index.attributes.get(attribute.name.toLowerCase());
|
|
1087
|
+
if (byAttribute && !refs.includes(byAttribute)) refs.push(byAttribute);
|
|
1031
1088
|
}
|
|
1032
|
-
|
|
1033
|
-
if (match) return {
|
|
1034
|
-
kind: "event",
|
|
1035
|
-
name: match[1]
|
|
1036
|
-
};
|
|
1037
|
-
if (raw.startsWith("*")) return {
|
|
1038
|
-
kind: "structural",
|
|
1039
|
-
name: raw.slice(1)
|
|
1040
|
-
};
|
|
1041
|
-
if (raw.startsWith("#") || raw.startsWith("ref-")) return {
|
|
1042
|
-
kind: "reference",
|
|
1043
|
-
name: raw.replace(/^#|^ref-/, "")
|
|
1044
|
-
};
|
|
1045
|
-
if (raw.startsWith("@") || raw.startsWith("i18n") || raw.includes(".")) return {
|
|
1046
|
-
kind: "other",
|
|
1047
|
-
name: raw
|
|
1048
|
-
};
|
|
1049
|
-
return {
|
|
1050
|
-
kind: "static",
|
|
1051
|
-
name: raw
|
|
1052
|
-
};
|
|
1089
|
+
return refs;
|
|
1053
1090
|
}
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
const
|
|
1057
|
-
for (const
|
|
1058
|
-
const
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1091
|
+
function checkSelectorMismatch(component, elements, index) {
|
|
1092
|
+
const issues = [];
|
|
1093
|
+
const names = /* @__PURE__ */ new Set([component.name, ...component.declarations.map((declaration) => compact(declaration.className))]);
|
|
1094
|
+
for (const element of elements) {
|
|
1095
|
+
const tag = element.name;
|
|
1096
|
+
const key = compact(tag.replace(/^p-/i, ""));
|
|
1097
|
+
const aliasTarget = COMPONENT_ALIASES[slugify(tag.replace(/^p-/i, ""))];
|
|
1098
|
+
if (/^[A-Z]/.test(tag) && names.has(compact(tag))) issues.push({
|
|
1099
|
+
kind: "selector-mismatch",
|
|
1100
|
+
severity: "error",
|
|
1101
|
+
name: tag,
|
|
1102
|
+
message: `ExhaustiveUI ${component.title} is used through its selector (${component.selectors.join(", ")}), not the PascalCase <${tag}> tag.`,
|
|
1103
|
+
suggestion: component.selectors[0]
|
|
1066
1104
|
});
|
|
1105
|
+
else if (/^p-/i.test(tag) && !index.elements.has(tag.toLowerCase())) {
|
|
1106
|
+
const renamed = aliasTarget === component.name;
|
|
1107
|
+
const related = renamed || names.has(key) || slugify(tag).startsWith(`p-${component.name}`);
|
|
1108
|
+
issues.push({
|
|
1109
|
+
kind: "unknown-selector",
|
|
1110
|
+
severity: "error",
|
|
1111
|
+
name: tag,
|
|
1112
|
+
message: renamed ? `<${tag}> is the PrimeNG name of this component; in ExhaustiveUI ${component.title} uses ${component.selectors.join(" or ")}.` : `<${tag}> is not a selector of any ExhaustiveUI component${related ? "" : ` (expected ${component.title} here)`}; use ${component.selectors.join(" or ")}.`,
|
|
1113
|
+
suggestion: component.selectors[0]
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1067
1116
|
}
|
|
1068
|
-
return
|
|
1069
|
-
}
|
|
1070
|
-
/** Whether an attribute value is a template expression rather than a literal. */
|
|
1071
|
-
function isInterpolated(value) {
|
|
1072
|
-
return value !== void 0 && value.includes("{{");
|
|
1073
|
-
}
|
|
1074
|
-
/** The string literal a property binding assigns (`[severity]="'danger'"` -> `danger`), or undefined when it is an expression. */
|
|
1075
|
-
function literalOfBinding(value) {
|
|
1076
|
-
const match = value === void 0 ? null : /^\s*(?:'([^']*)'|"([^"]*)")\s*$/.exec(value);
|
|
1077
|
-
return match ? match[1] ?? match[2] : void 0;
|
|
1117
|
+
return issues;
|
|
1078
1118
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
"
|
|
1099
|
-
"
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1119
|
+
function checkElement(component, element, matches, isOwnElement) {
|
|
1120
|
+
const issues = [];
|
|
1121
|
+
const own = matches.filter((ref) => ref.component === component).map((ref) => ref.declaration);
|
|
1122
|
+
const inputs = /* @__PURE__ */ new Map();
|
|
1123
|
+
const outputs = /* @__PURE__ */ new Set();
|
|
1124
|
+
const everyInput = /* @__PURE__ */ new Set();
|
|
1125
|
+
for (const ref of matches) {
|
|
1126
|
+
for (const selector of splitSelectors(ref.declaration.selector)) {
|
|
1127
|
+
const attribute = attributeSelectorName(selector);
|
|
1128
|
+
if (attribute) everyInput.add(attribute.toLowerCase());
|
|
1129
|
+
}
|
|
1130
|
+
for (const input of ref.declaration.inputs ?? []) {
|
|
1131
|
+
everyInput.add(input.name.toLowerCase());
|
|
1132
|
+
if (ref.component === component) inputs.set(input.name.toLowerCase(), input);
|
|
1133
|
+
}
|
|
1134
|
+
for (const output of ref.declaration.outputs ?? []) outputs.add(output.name);
|
|
1135
|
+
}
|
|
1136
|
+
const directiveAttributes = own.flatMap((declaration) => splitSelectors(declaration.selector).map(attributeSelectorName)).filter((attribute) => !!attribute && element.attributes.some((candidate) => candidate.name.toLowerCase() === attribute.toLowerCase()));
|
|
1137
|
+
const removedHint = (name) => isOwnElement ? removedInputHint(element.name, name) : directiveAttributes.map((attribute) => removedInputHint(`[${attribute}]`, name)).find(Boolean);
|
|
1138
|
+
const allowedProps = [...inputs.keys()].sort().join(", ");
|
|
1139
|
+
const allowedEvents = [...outputs].sort().join(", ");
|
|
1140
|
+
const supportsForms = own.some((declaration) => declaration.forms);
|
|
1141
|
+
const label = own[0]?.className ?? component.title;
|
|
1142
|
+
for (const attribute of element.attributes) {
|
|
1143
|
+
const lowerName = attribute.name.toLowerCase();
|
|
1144
|
+
switch (attribute.kind) {
|
|
1145
|
+
case "static":
|
|
1146
|
+
case "property": {
|
|
1147
|
+
if (everyInput.has(lowerName) && !inputs.has(lowerName)) break;
|
|
1148
|
+
const input = inputs.get(lowerName);
|
|
1149
|
+
if (!input) {
|
|
1150
|
+
const removed = removedHint(attribute.name);
|
|
1151
|
+
if (!removed && (GLOBAL_ATTRIBUTES.has(lowerName) || lowerName.startsWith("aria-") || lowerName.startsWith("data-") || lowerName.startsWith("ng") || !isOwnElement && NATIVE_ATTRIBUTES.has(lowerName))) break;
|
|
1152
|
+
issues.push({
|
|
1153
|
+
kind: "unknown-prop",
|
|
1154
|
+
severity: "error",
|
|
1155
|
+
name: attribute.name,
|
|
1156
|
+
message: `"${attribute.name}" is not an input of ${label}.${removed ? ` ${removed.message}` : ""}`,
|
|
1157
|
+
allowedProps,
|
|
1158
|
+
...removed?.suggestion ? { suggestion: removed.suggestion } : {}
|
|
1159
|
+
});
|
|
1160
|
+
break;
|
|
1161
|
+
}
|
|
1162
|
+
if (input.name !== attribute.name) {
|
|
1163
|
+
issues.push({
|
|
1164
|
+
kind: "input-case",
|
|
1165
|
+
severity: "error",
|
|
1166
|
+
name: attribute.name,
|
|
1167
|
+
message: `"${attribute.name}" is not an input of ${label}: inputs are case sensitive, write "${input.name}".`,
|
|
1168
|
+
suggestion: input.name
|
|
1169
|
+
});
|
|
1170
|
+
break;
|
|
1171
|
+
}
|
|
1172
|
+
if (input.deprecated) issues.push({
|
|
1173
|
+
kind: "deprecated-prop",
|
|
1174
|
+
severity: "warning",
|
|
1175
|
+
name: input.name,
|
|
1176
|
+
message: `Input "${input.name}" of ${label} is deprecated: ${input.deprecated}`
|
|
1177
|
+
});
|
|
1178
|
+
const literal = attribute.kind === "static" ? isInterpolated(attribute.value) ? void 0 : attribute.value : literalOfBinding(attribute.value);
|
|
1179
|
+
if (literal !== void 0 && input.values && input.values.length > 0 && !input.values.includes(literal)) issues.push({
|
|
1180
|
+
kind: "invalid-enum-value",
|
|
1181
|
+
severity: "error",
|
|
1182
|
+
name: input.name,
|
|
1183
|
+
message: `"${literal}" is not an allowed value of ${label} input "${input.name}".`,
|
|
1184
|
+
allowedValues: input.values.join(", ")
|
|
1185
|
+
});
|
|
1186
|
+
break;
|
|
1187
|
+
}
|
|
1188
|
+
case "event": {
|
|
1189
|
+
if (outputs.has(attribute.name)) break;
|
|
1190
|
+
if (inputs.get(lowerName.replace(/change$/, ""))?.twoWay && /change$/i.test(attribute.name)) break;
|
|
1191
|
+
const removed = isOwnElement ? removedOutputHint(element.name, attribute.name) : void 0;
|
|
1192
|
+
if (removed || /^on[A-Z]/.test(attribute.name)) issues.push({
|
|
1193
|
+
kind: "unknown-output",
|
|
1194
|
+
severity: "error",
|
|
1195
|
+
name: attribute.name,
|
|
1196
|
+
message: `"${attribute.name}" is not an output of ${label}.${removed ? ` ${removed.message}` : ""}`,
|
|
1197
|
+
allowedEvents,
|
|
1198
|
+
...removed?.suggestion ? { suggestion: removed.suggestion } : {}
|
|
1199
|
+
});
|
|
1200
|
+
break;
|
|
1201
|
+
}
|
|
1202
|
+
case "twoWay": {
|
|
1203
|
+
if (lowerName === "ngmodel") {
|
|
1204
|
+
if (isOwnElement && !supportsForms && !inputs.has("ngmodel")) issues.push({
|
|
1205
|
+
kind: "forms-unsupported",
|
|
1206
|
+
severity: "warning",
|
|
1207
|
+
name: "ngModel",
|
|
1208
|
+
message: `${label} does not implement ControlValueAccessor, so [(ngModel)] has no effect on it.`
|
|
1209
|
+
});
|
|
1210
|
+
break;
|
|
1211
|
+
}
|
|
1212
|
+
const input = inputs.get(lowerName);
|
|
1213
|
+
if (!input) {
|
|
1214
|
+
if (everyInput.has(lowerName) || GLOBAL_ATTRIBUTES.has(lowerName)) break;
|
|
1215
|
+
issues.push({
|
|
1216
|
+
kind: "unknown-prop",
|
|
1217
|
+
severity: "error",
|
|
1218
|
+
name: attribute.name,
|
|
1219
|
+
message: `"${attribute.name}" is not an input of ${label}, so it cannot be bound two-way.`,
|
|
1220
|
+
allowedProps
|
|
1221
|
+
});
|
|
1222
|
+
} else if (!input.twoWay && !outputs.has(`${input.name}Change`)) issues.push({
|
|
1223
|
+
kind: "two-way-binding-unsupported",
|
|
1224
|
+
severity: "error",
|
|
1225
|
+
name: input.name,
|
|
1226
|
+
message: `Input "${input.name}" of ${label} has no "${input.name}Change" output; bind it one-way with [${input.name}].`
|
|
1227
|
+
});
|
|
1228
|
+
break;
|
|
1229
|
+
}
|
|
1230
|
+
default: break;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
return issues;
|
|
1234
|
+
}
|
|
1235
|
+
function dedupe(issues) {
|
|
1236
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1237
|
+
return issues.filter((issue) => {
|
|
1238
|
+
const key = `${issue.kind}:${issue.name ?? ""}:${issue.message}`;
|
|
1239
|
+
if (seen.has(key)) return false;
|
|
1240
|
+
seen.add(key);
|
|
1241
|
+
return true;
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
function formatIssues(componentTitle, issues) {
|
|
1245
|
+
const lines = issues.map((issue) => {
|
|
1246
|
+
const extras = [
|
|
1247
|
+
issue.allowedProps ? ` Allowed inputs: ${issue.allowedProps}.` : "",
|
|
1248
|
+
issue.allowedValues ? ` Allowed values: ${issue.allowedValues}.` : "",
|
|
1249
|
+
issue.allowedEvents ? ` Allowed outputs: ${issue.allowedEvents}.` : "",
|
|
1250
|
+
issue.suggestion ? ` Suggestion: ${issue.suggestion}` : ""
|
|
1251
|
+
].join("");
|
|
1252
|
+
return `- [${issue.severity}] ${issue.kind}${issue.name ? ` ${issue.name}` : ""}: ${issue.message}${extras}`;
|
|
1253
|
+
});
|
|
1254
|
+
return [`Usage has ${issues.length} validation issue${issues.length === 1 ? "" : "s"} for ${componentTitle}.`, ...lines].join("\n");
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
//#endregion
|
|
1258
|
+
//#region src/check.ts
|
|
1259
|
+
/** Packages renamed from PrimeNG, beyond `primeng/*` itself (handled by LEGACY_IMPORT_PATTERN). */
|
|
1260
|
+
const RENAMED_PACKAGES = [
|
|
1261
|
+
[/^@primeuix\/(themes|styled|styles|utils|motion)(\/.*)?$/, (source) => source.replace(/^@primeuix\//, "@exhaustive-ui/")],
|
|
1262
|
+
[/^primeicons(\/.*)?$/, () => "@openng/icons"],
|
|
1263
|
+
[/^tailwindcss-primeui$/, () => "@exhaustive-ui/tailwindcss"],
|
|
1264
|
+
[/^primelocale(\/.*)?$/, (source) => source.replace(/^primelocale/, "@exhaustive-ui/locale")]
|
|
1145
1265
|
];
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
"
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
"showTransitionOptions",
|
|
1198
|
-
"hideTransitionOptions",
|
|
1199
|
-
"modalEnterAnimation",
|
|
1200
|
-
"modalLeaveAnimation"
|
|
1201
|
-
],
|
|
1202
|
-
drawer: ["transitionOptions"],
|
|
1203
|
-
menu: ["showTransitionOptions", "hideTransitionOptions"],
|
|
1204
|
-
splitbutton: [
|
|
1205
|
-
"showTransitionOptions",
|
|
1206
|
-
"hideTransitionOptions",
|
|
1207
|
-
"plain"
|
|
1208
|
-
],
|
|
1209
|
-
password: ["showTransitionOptions", "hideTransitionOptions"],
|
|
1210
|
-
button: ["badgeClass"],
|
|
1211
|
-
contextmenusub: [
|
|
1212
|
-
"autoZIndex",
|
|
1213
|
-
"baseZIndex",
|
|
1214
|
-
"popup"
|
|
1215
|
-
],
|
|
1216
|
-
tieredmenu: ["showTransitionOptions", "hideTransitionOptions"],
|
|
1217
|
-
menubar: ["autoZIndex", "baseZIndex"],
|
|
1218
|
-
menubarsub: [
|
|
1219
|
-
"autoZIndex",
|
|
1220
|
-
"baseZIndex",
|
|
1221
|
-
"mobileActive",
|
|
1222
|
-
"ariaLabel",
|
|
1223
|
-
"ariaLabelledBy"
|
|
1224
|
-
],
|
|
1225
|
-
panelmenu: ["transitionOptions", "tabindex"],
|
|
1226
|
-
megamenusub: ["disabled", "queryMatches"],
|
|
1227
|
-
galleria: [
|
|
1228
|
-
"showTransitionOptions",
|
|
1229
|
-
"hideTransitionOptions",
|
|
1230
|
-
"containerClass"
|
|
1231
|
-
],
|
|
1232
|
-
fileupload: ["removeStyleClass"],
|
|
1233
|
-
cascadeselect: ["inputLabel", "emptyMessage"],
|
|
1234
|
-
datepicker: ["showTransitionOptions", "hideTransitionOptions"],
|
|
1235
|
-
dialog: ["transitionOptions", "rtl"],
|
|
1236
|
-
confirmdialog: [
|
|
1237
|
-
"closeAriaLabel",
|
|
1238
|
-
"acceptAriaLabel",
|
|
1239
|
-
"rejectAriaLabel",
|
|
1240
|
-
"rtl",
|
|
1241
|
-
"transitionOptions",
|
|
1242
|
-
"focusTrap",
|
|
1243
|
-
"defaultFocus"
|
|
1244
|
-
],
|
|
1245
|
-
treenode: [
|
|
1246
|
-
"rowNode",
|
|
1247
|
-
"root",
|
|
1248
|
-
"firstChild",
|
|
1249
|
-
"lastChild"
|
|
1250
|
-
],
|
|
1251
|
-
selectitem: ["visible", "itemSize"],
|
|
1252
|
-
table: ["frozenColumns", "frozenWidth"],
|
|
1253
|
-
autocomplete: [
|
|
1254
|
-
"autoZIndex",
|
|
1255
|
-
"baseZIndex",
|
|
1256
|
-
"showTransitionOptions",
|
|
1257
|
-
"hideTransitionOptions",
|
|
1258
|
-
"autoHighlight"
|
|
1259
|
-
],
|
|
1260
|
-
multiselect: ["filterFields"],
|
|
1261
|
-
stepper: ["transitionOptions"],
|
|
1262
|
-
listbox: ["searchLocale"],
|
|
1263
|
-
dataview: ["gridStyleClass", "trackBy"],
|
|
1264
|
-
orderlist: ["trackBy", "header"],
|
|
1265
|
-
picklist: [
|
|
1266
|
-
"trackBy",
|
|
1267
|
-
"sourceTrackBy",
|
|
1268
|
-
"targetTrackBy"
|
|
1269
|
-
],
|
|
1270
|
-
toggleswitch: ["size"],
|
|
1271
|
-
selectbutton: ["tabindex"],
|
|
1272
|
-
confirmpopup: [
|
|
1273
|
-
"showTransitionOptions",
|
|
1274
|
-
"hideTransitionOptions",
|
|
1275
|
-
"baseZIndex"
|
|
1276
|
-
],
|
|
1277
|
-
treetablesorticon: ["ariaLabelAsc", "ariaLabelDesc"]
|
|
1278
|
-
};
|
|
1279
|
-
const RENAMED_OUTPUTS = {
|
|
1280
|
-
orderlist: { onFilterEvent: "onFilter" },
|
|
1281
|
-
table: { selectAllChange: "onSelectAllChange" },
|
|
1282
|
-
multiselect: {
|
|
1283
|
-
onPanelShow: "onShow",
|
|
1284
|
-
onPanelHide: "onHide"
|
|
1266
|
+
/** Components that also pick a template by the type of a node (`<ng-template #person>` for nodes of type person). */
|
|
1267
|
+
const NODE_TYPE_TEMPLATES = /* @__PURE__ */ new Set(["Tree", "OrganizationChart"]);
|
|
1268
|
+
const TAG = /<!--[\s\S]*?-->|<(\/?)([A-Za-z][\w.-]*)((?:\s+(?:[^\s<>"'=/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'<>]+))?))*)\s*(\/?)>/g;
|
|
1269
|
+
const VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
1270
|
+
"area",
|
|
1271
|
+
"base",
|
|
1272
|
+
"br",
|
|
1273
|
+
"col",
|
|
1274
|
+
"embed",
|
|
1275
|
+
"hr",
|
|
1276
|
+
"img",
|
|
1277
|
+
"input",
|
|
1278
|
+
"link",
|
|
1279
|
+
"meta",
|
|
1280
|
+
"source",
|
|
1281
|
+
"track",
|
|
1282
|
+
"wbr"
|
|
1283
|
+
]);
|
|
1284
|
+
/** The parts of a file that are Angular templates: the whole file for .html, the inline `template:` literals for .ts. */
|
|
1285
|
+
function templateRegions(file, code) {
|
|
1286
|
+
if (file.endsWith(".html")) return [{
|
|
1287
|
+
code,
|
|
1288
|
+
offset: 0
|
|
1289
|
+
}];
|
|
1290
|
+
return [...code.matchAll(/\btemplate\s*:\s*`((?:[^`\\]|\\.)*)`/g)].map((match) => ({
|
|
1291
|
+
code: match[1],
|
|
1292
|
+
offset: match.index + match[0].indexOf("`") + 1
|
|
1293
|
+
}));
|
|
1294
|
+
}
|
|
1295
|
+
const lineAt = (code, offset) => code.slice(0, offset).split("\n").length;
|
|
1296
|
+
/** `primeng/dropdown` -> `@exhaustive-ui/core/select`: the entry point of the component, renamed or not. */
|
|
1297
|
+
function coreImport(catalog, source) {
|
|
1298
|
+
const subpath = source.replace(/^(?:@primeng\/[^/]+|@openng\/optimus-ui|optimus-ui|primeng)\/?/, "");
|
|
1299
|
+
if (!subpath) return "@exhaustive-ui/core";
|
|
1300
|
+
const name = COMPONENT_ALIASES[slugify(subpath)] ?? subpath;
|
|
1301
|
+
return catalog.components.find((candidate) => candidate.name === name)?.import ?? `@exhaustive-ui/core/${subpath}`;
|
|
1302
|
+
}
|
|
1303
|
+
function checkImports(catalog, code) {
|
|
1304
|
+
const issues = [];
|
|
1305
|
+
for (const statement of scanImports(code)) {
|
|
1306
|
+
const renamed = RENAMED_PACKAGES.find(([pattern]) => pattern.test(statement.source));
|
|
1307
|
+
if (LEGACY_IMPORT_PATTERN.test(statement.source) || renamed) {
|
|
1308
|
+
const target = renamed ? renamed[1](statement.source) : coreImport(catalog, statement.source);
|
|
1309
|
+
issues.push({
|
|
1310
|
+
kind: "import-mismatch",
|
|
1311
|
+
severity: "error",
|
|
1312
|
+
name: statement.source,
|
|
1313
|
+
message: `"${statement.source}" is a PrimeNG package; ExhaustiveUI uses "${target}".`,
|
|
1314
|
+
suggestion: target
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1285
1317
|
}
|
|
1286
|
-
|
|
1287
|
-
const DEAD_OUTPUTS = {
|
|
1288
|
-
overlay: ["onAnimationStart", "onAnimationDone"],
|
|
1289
|
-
menubarsub: [
|
|
1290
|
-
"menuFocus",
|
|
1291
|
-
"menuBlur",
|
|
1292
|
-
"menuKeydown"
|
|
1293
|
-
]
|
|
1294
|
-
};
|
|
1295
|
-
function tagKey(tag) {
|
|
1296
|
-
return compact(tag.replace(/^p-/i, ""));
|
|
1318
|
+
return issues;
|
|
1297
1319
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1320
|
+
/** `<ng-template #name>` and `pTemplate="name"` placed inside a component must name one of its templates. */
|
|
1321
|
+
function checkTemplateNames(catalog, region) {
|
|
1322
|
+
const index = selectorIndex(catalog);
|
|
1323
|
+
const found = [];
|
|
1324
|
+
const stack = [];
|
|
1325
|
+
for (const match of region.code.matchAll(TAG)) {
|
|
1326
|
+
if (match[0].startsWith("<!--")) continue;
|
|
1327
|
+
const [, closing, name, , selfClosing] = match;
|
|
1328
|
+
const lower = name.toLowerCase();
|
|
1329
|
+
if (closing) {
|
|
1330
|
+
const at = stack.map((entry) => entry.name).lastIndexOf(lower);
|
|
1331
|
+
if (at >= 0) stack.length = at;
|
|
1332
|
+
continue;
|
|
1333
|
+
}
|
|
1334
|
+
const element = scanElements(match[0])[0];
|
|
1335
|
+
if (lower === "ng-template" && element) {
|
|
1336
|
+
const host = [...stack].reverse().find((entry) => entry.declaration);
|
|
1337
|
+
const reference = element.attributes.find((attribute) => attribute.kind === "reference");
|
|
1338
|
+
const legacy = element.attributes.find((attribute) => attribute.name === "pTemplate");
|
|
1339
|
+
const templateName = legacy?.value ?? reference?.name;
|
|
1340
|
+
const templates = host?.declaration?.templates ?? [];
|
|
1341
|
+
if (legacy) found.push({
|
|
1342
|
+
offset: match.index,
|
|
1343
|
+
issue: {
|
|
1344
|
+
kind: "legacy-template",
|
|
1345
|
+
severity: "warning",
|
|
1346
|
+
name: `pTemplate="${legacy.value}"`,
|
|
1347
|
+
component: host?.component?.name,
|
|
1348
|
+
message: `pTemplate is legacy: write <ng-template #${legacy.value}>.`,
|
|
1349
|
+
suggestion: `#${legacy.value}`
|
|
1350
|
+
}
|
|
1351
|
+
});
|
|
1352
|
+
const free = host?.declaration && NODE_TYPE_TEMPLATES.has(host.declaration.className);
|
|
1353
|
+
const local = !!reference && !legacy && new RegExp(`(?:\\b(?:else|then)\\s+${reference.name}\\b|="\\s*${reference.name}\\s*[";])`).test(region.code);
|
|
1354
|
+
if (host && templateName && templates.length && !free && !local && !templates.some((template) => template.name === templateName)) {
|
|
1355
|
+
const sameCase = templates.find((template) => template.name.toLowerCase() === templateName.toLowerCase());
|
|
1356
|
+
const selector = host.name;
|
|
1357
|
+
found.push({
|
|
1358
|
+
offset: match.index,
|
|
1359
|
+
issue: sameCase ? {
|
|
1360
|
+
kind: "template-name",
|
|
1361
|
+
severity: "error",
|
|
1362
|
+
name: `#${templateName}`,
|
|
1363
|
+
component: host.component?.name,
|
|
1364
|
+
message: `<${selector}> has no #${templateName} template: names are case sensitive, write #${sameCase.name}.`,
|
|
1365
|
+
suggestion: `#${sameCase.name}`
|
|
1366
|
+
} : {
|
|
1367
|
+
kind: "unknown-template",
|
|
1368
|
+
severity: "warning",
|
|
1369
|
+
name: `#${templateName}`,
|
|
1370
|
+
component: host.component?.name,
|
|
1371
|
+
message: `<${selector}> has no #${templateName} template, so it ignores this one. Its templates: ${templates.map((template) => `#${template.name}`).join(", ")}.`
|
|
1372
|
+
}
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
if (!selfClosing && !VOID_ELEMENTS.has(lower)) {
|
|
1377
|
+
const ref = element ? declarationsOn(element, index).find((candidate) => candidate.declaration.templates?.length) : void 0;
|
|
1378
|
+
stack.push({
|
|
1379
|
+
name: lower,
|
|
1380
|
+
declaration: ref?.declaration,
|
|
1381
|
+
component: ref?.component
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
return found;
|
|
1386
|
+
}
|
|
1387
|
+
/** Unknown `p-*` tags: PrimeNG names (p-dropdown, p-calendar...) and misspellings. */
|
|
1388
|
+
function checkUnknownTags(catalog, region) {
|
|
1389
|
+
const index = selectorIndex(catalog);
|
|
1390
|
+
const found = [];
|
|
1391
|
+
for (const match of region.code.matchAll(TAG)) {
|
|
1392
|
+
const name = match[2];
|
|
1393
|
+
if (!name || match[1] || !/^p-/i.test(name) || index.elements.has(name.toLowerCase())) continue;
|
|
1394
|
+
const target = COMPONENT_ALIASES[slugify(name.replace(/^p-/i, ""))];
|
|
1395
|
+
const component = target ? catalog.components.find((candidate) => candidate.name === target) : void 0;
|
|
1396
|
+
const suggestion = component?.selectors.find((selector) => /^p-/.test(selector));
|
|
1397
|
+
found.push({
|
|
1398
|
+
offset: match.index,
|
|
1399
|
+
issue: {
|
|
1400
|
+
kind: "unknown-selector",
|
|
1401
|
+
severity: "error",
|
|
1402
|
+
name: `<${name}>`,
|
|
1403
|
+
component: component?.name,
|
|
1404
|
+
message: component ? `<${name}> is the PrimeNG name of ${shortTitle(component.title)}; ExhaustiveUI uses <${suggestion}>.` : `<${name}> is not an ExhaustiveUI component.`,
|
|
1405
|
+
suggestion: suggestion ? `<${suggestion}>` : void 0
|
|
1406
|
+
}
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
return found;
|
|
1410
|
+
}
|
|
1411
|
+
/** Reported by checkSource itself, with more context than validateComponentUsage has on a single element. */
|
|
1412
|
+
const SKIPPED_KINDS = /* @__PURE__ */ new Set([
|
|
1413
|
+
"import-mismatch",
|
|
1414
|
+
"selector-not-found",
|
|
1415
|
+
"unknown-selector",
|
|
1416
|
+
"selector-mismatch"
|
|
1417
|
+
]);
|
|
1418
|
+
/** Validate one file. */
|
|
1419
|
+
function checkSource(catalog, file, code) {
|
|
1420
|
+
const issues = [];
|
|
1421
|
+
const index = selectorIndex(catalog);
|
|
1422
|
+
if (file.endsWith(".ts")) for (const issue of checkImports(catalog, code)) issues.push({
|
|
1423
|
+
...issue,
|
|
1424
|
+
file,
|
|
1425
|
+
line: lineAt(code, Math.max(code.indexOf(`'${issue.name}'`), code.indexOf(`"${issue.name}"`), 0))
|
|
1426
|
+
});
|
|
1427
|
+
for (const region of templateRegions(file, code)) {
|
|
1428
|
+
for (const { offset, issue } of [...checkUnknownTags(catalog, region), ...checkTemplateNames(catalog, region)]) issues.push({
|
|
1429
|
+
...issue,
|
|
1430
|
+
file,
|
|
1431
|
+
line: lineAt(code, region.offset + offset)
|
|
1432
|
+
});
|
|
1433
|
+
for (const match of region.code.matchAll(TAG)) {
|
|
1434
|
+
if (match[1] || match[0].startsWith("<!--")) continue;
|
|
1435
|
+
const element = scanElements(match[0])[0];
|
|
1436
|
+
if (!element) continue;
|
|
1437
|
+
for (const component of new Set(declarationsOn(element, index).map((ref) => ref.component))) for (const issue of validateComponentUsage(catalog, component, match[0])) {
|
|
1438
|
+
if (SKIPPED_KINDS.has(issue.kind)) continue;
|
|
1439
|
+
const attribute = issue.name ? element.attributes.find((candidate) => candidate.name === issue.name) : void 0;
|
|
1440
|
+
const at = attribute ? match[0].indexOf(attribute.raw) : 0;
|
|
1441
|
+
issues.push({
|
|
1442
|
+
...issue,
|
|
1443
|
+
file,
|
|
1444
|
+
component: component.name,
|
|
1445
|
+
line: lineAt(code, region.offset + match.index + Math.max(at, 0))
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1451
|
+
return issues.filter((issue) => {
|
|
1452
|
+
const key = `${issue.line}|${issue.kind}|${issue.name}|${issue.message}`;
|
|
1453
|
+
if (seen.has(key)) return false;
|
|
1454
|
+
seen.add(key);
|
|
1455
|
+
return true;
|
|
1456
|
+
}).sort((a, b) => a.line - b.line);
|
|
1457
|
+
}
|
|
1458
|
+
const SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
1459
|
+
"node_modules",
|
|
1460
|
+
"dist",
|
|
1461
|
+
"build",
|
|
1462
|
+
"coverage",
|
|
1463
|
+
"out-tsc",
|
|
1464
|
+
"tmp"
|
|
1465
|
+
]);
|
|
1466
|
+
async function collectFiles(target, files = []) {
|
|
1467
|
+
if ((await stat(target)).isFile()) {
|
|
1468
|
+
if (/\.(html|ts)$/.test(target) && !target.endsWith(".d.ts")) files.push(target);
|
|
1469
|
+
return files;
|
|
1470
|
+
}
|
|
1471
|
+
for (const entry of await readdir(target, { withFileTypes: true })) {
|
|
1472
|
+
if (entry.name.startsWith(".") || SKIPPED_DIRECTORIES.has(entry.name)) continue;
|
|
1473
|
+
await collectFiles(path.join(target, entry.name), files);
|
|
1474
|
+
}
|
|
1475
|
+
return files;
|
|
1300
1476
|
}
|
|
1301
|
-
/**
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
const
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
suggestion: "class"
|
|
1311
|
-
};
|
|
1312
|
-
const renamed = RENAMED[key]?.[lower];
|
|
1313
|
-
if (renamed) return {
|
|
1314
|
-
message: `${name} was renamed to ${renamed} in v22 (ng update applies the renamed-inputs migration).`,
|
|
1315
|
-
suggestion: renamed
|
|
1477
|
+
/** Validate every .html and .ts file under the given paths. */
|
|
1478
|
+
async function checkProject(catalog, targets) {
|
|
1479
|
+
const files = [];
|
|
1480
|
+
for (const target of targets) await collectFiles(target, files);
|
|
1481
|
+
const issues = [];
|
|
1482
|
+
for (const file of files) issues.push(...checkSource(catalog, file, await readFile(file, "utf8")));
|
|
1483
|
+
return {
|
|
1484
|
+
files: files.length,
|
|
1485
|
+
issues
|
|
1316
1486
|
};
|
|
1317
|
-
if (has(DEAD_INPUTS[key], name)) return { message: `${name} was removed in v22: it had no effect anymore, delete the binding (ng update applies the remove-dead-inputs migration).` };
|
|
1318
1487
|
}
|
|
1319
|
-
/**
|
|
1320
|
-
function
|
|
1321
|
-
const
|
|
1322
|
-
const
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
};
|
|
1327
|
-
if (!has(DEAD_OUTPUTS[key], name)) return;
|
|
1328
|
-
return { message: `${name} was removed in v22: ${key === "overlay" ? "use onOverlayBeforeEnter/onOverlayAfterEnter (show) or onOverlayBeforeLeave/onOverlayAfterLeave (hide) instead" : "it never fired, bind the native focus/blur/keydown events of the element instead"} (ng update applies the remove-dead-outputs migration).` };
|
|
1488
|
+
/** Human readable report, one issue per line, like a compiler. */
|
|
1489
|
+
function formatCheckReport(result, cwd = process.cwd()) {
|
|
1490
|
+
const errors = result.issues.filter((issue) => issue.severity === "error").length;
|
|
1491
|
+
const warnings = result.issues.length - errors;
|
|
1492
|
+
const lines = result.issues.map((issue) => `${path.relative(cwd, issue.file)}:${issue.line} ${issue.severity} ${issue.message}${issue.suggestion && !issue.message.includes(issue.suggestion) ? ` Use: ${issue.suggestion}` : ""}`);
|
|
1493
|
+
lines.push(result.issues.length ? `${errors} error${errors === 1 ? "" : "s"}, ${warnings} warning${warnings === 1 ? "" : "s"} in ${result.files} file${result.files === 1 ? "" : "s"}.` : `No ExhaustiveUI issue found in ${result.files} file${result.files === 1 ? "" : "s"}.`);
|
|
1494
|
+
return lines.join("\n");
|
|
1329
1495
|
}
|
|
1330
1496
|
|
|
1331
1497
|
//#endregion
|
|
1332
|
-
//#region src/
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
"
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
"
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
"
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
"
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
"min",
|
|
1392
|
-
"max",
|
|
1393
|
-
"step",
|
|
1394
|
-
"minlength",
|
|
1395
|
-
"maxlength",
|
|
1396
|
-
"pattern",
|
|
1397
|
-
"size",
|
|
1398
|
-
"rows",
|
|
1399
|
-
"cols",
|
|
1400
|
-
"wrap",
|
|
1401
|
-
"autocomplete",
|
|
1402
|
-
"inputmode",
|
|
1403
|
-
"enterkeyhint",
|
|
1404
|
-
"src",
|
|
1405
|
-
"srcset",
|
|
1406
|
-
"alt",
|
|
1407
|
-
"href",
|
|
1408
|
-
"target",
|
|
1409
|
-
"rel",
|
|
1410
|
-
"download",
|
|
1411
|
-
"for",
|
|
1412
|
-
"form",
|
|
1413
|
-
"list",
|
|
1414
|
-
"label",
|
|
1415
|
-
"width",
|
|
1416
|
-
"height",
|
|
1417
|
-
"loading",
|
|
1418
|
-
"innerhtml",
|
|
1419
|
-
"innertext",
|
|
1420
|
-
"textcontent",
|
|
1421
|
-
"scrolltop",
|
|
1422
|
-
"scrollleft"
|
|
1423
|
-
]);
|
|
1424
|
-
const LEGACY_IMPORT_PATTERN = /^(?:primeng(?:\/.*)?|@primeng\/.*|@openng\/optimus-ui(?:\/.*)?|optimus-ui(?:\/.*)?)$/;
|
|
1425
|
-
const selectorIndexes = /* @__PURE__ */ new WeakMap();
|
|
1426
|
-
function selectorIndex(catalog) {
|
|
1427
|
-
let index = selectorIndexes.get(catalog);
|
|
1428
|
-
if (!index) {
|
|
1429
|
-
index = {
|
|
1430
|
-
elements: /* @__PURE__ */ new Map(),
|
|
1431
|
-
attributes: /* @__PURE__ */ new Map()
|
|
1432
|
-
};
|
|
1433
|
-
for (const component of catalog.components) for (const declaration of component.declarations) for (const selector of splitSelectors(declaration.selector)) {
|
|
1434
|
-
const attribute = attributeSelectorName(selector);
|
|
1435
|
-
if (attribute) index.attributes.set(attribute.toLowerCase(), {
|
|
1436
|
-
component,
|
|
1437
|
-
declaration
|
|
1438
|
-
});
|
|
1439
|
-
else if (/^[a-z][\w-]*$/i.test(selector)) index.elements.set(selector.toLowerCase(), {
|
|
1440
|
-
component,
|
|
1441
|
-
declaration
|
|
1498
|
+
//#region src/source.ts
|
|
1499
|
+
const DOCS_PATH_PATTERN = /^(?:components\.json|manifest\.json|llms\.txt|llms-full\.txt|(?:components|pages|cards)\/[a-z0-9][a-z0-9._-]*\.md)$/;
|
|
1500
|
+
/** Reject anything that is not one of the generated docs files, so a crafted resource URI cannot read elsewhere. */
|
|
1501
|
+
function assertDocsPath(docsPath) {
|
|
1502
|
+
if (!DOCS_PATH_PATTERN.test(docsPath)) throw new DocsNotFoundError(docsPath, `"${docsPath}" is not a generated docs file`);
|
|
1503
|
+
return docsPath;
|
|
1504
|
+
}
|
|
1505
|
+
/** In-memory documents, for tests and embedding. */
|
|
1506
|
+
var MemorySource = class {
|
|
1507
|
+
documents;
|
|
1508
|
+
kind = "memory";
|
|
1509
|
+
constructor(documents = /* @__PURE__ */ new Map()) {
|
|
1510
|
+
this.documents = documents;
|
|
1511
|
+
}
|
|
1512
|
+
async readText(docsPath) {
|
|
1513
|
+
const text = this.documents.get(assertDocsPath(docsPath));
|
|
1514
|
+
if (text === void 0) throw new DocsNotFoundError(docsPath);
|
|
1515
|
+
return text;
|
|
1516
|
+
}
|
|
1517
|
+
};
|
|
1518
|
+
/** The offline snapshot produced at build time by scripts/prebuild.mjs. */
|
|
1519
|
+
var SnapshotSource = class {
|
|
1520
|
+
directory;
|
|
1521
|
+
kind = "snapshot";
|
|
1522
|
+
constructor(directory) {
|
|
1523
|
+
this.directory = directory;
|
|
1524
|
+
}
|
|
1525
|
+
async readText(docsPath) {
|
|
1526
|
+
const file = path.join(this.directory, assertDocsPath(docsPath));
|
|
1527
|
+
try {
|
|
1528
|
+
return await readFile(file, "utf8");
|
|
1529
|
+
} catch (error) {
|
|
1530
|
+
if (error.code === "ENOENT") throw new DocsNotFoundError(docsPath, `Document "${docsPath}" is not in the offline snapshot`);
|
|
1531
|
+
throw new DocsFetchError(docsPath, `Cannot read "${docsPath}" from the offline snapshot: ${describeError(error)}`, { cause: error });
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
};
|
|
1535
|
+
/** The live docs site. A not-found path is served as the SPA shell with HTTP 200, so HTML answers are treated as misses. */
|
|
1536
|
+
var RemoteSource = class {
|
|
1537
|
+
options;
|
|
1538
|
+
kind = "remote";
|
|
1539
|
+
fetchImpl;
|
|
1540
|
+
constructor(options) {
|
|
1541
|
+
this.options = options;
|
|
1542
|
+
this.fetchImpl = options.fetchImpl ?? globalThis.fetch;
|
|
1543
|
+
}
|
|
1544
|
+
urlFor(docsPath) {
|
|
1545
|
+
return `${this.options.baseUrl.replace(/\/+$/, "")}/llms/${assertDocsPath(docsPath)}`;
|
|
1546
|
+
}
|
|
1547
|
+
async readText(docsPath) {
|
|
1548
|
+
const url = this.urlFor(docsPath);
|
|
1549
|
+
let response;
|
|
1550
|
+
try {
|
|
1551
|
+
response = await this.fetchImpl(url, {
|
|
1552
|
+
signal: AbortSignal.timeout(this.options.timeoutMs),
|
|
1553
|
+
headers: {
|
|
1554
|
+
accept: "text/markdown, text/plain, application/json;q=0.9, */*;q=0.1",
|
|
1555
|
+
"user-agent": this.options.userAgent ?? "@exhaustive-ui/mcp"
|
|
1556
|
+
}
|
|
1442
1557
|
});
|
|
1558
|
+
} catch (error) {
|
|
1559
|
+
throw new DocsFetchError(docsPath, `Cannot reach ${url}: ${describeError(error)}`, { cause: error });
|
|
1443
1560
|
}
|
|
1444
|
-
|
|
1561
|
+
if (response.status === 404) throw new DocsNotFoundError(docsPath, `${url} answered HTTP 404`);
|
|
1562
|
+
if (!response.ok) throw new DocsFetchError(docsPath, `${url} answered HTTP ${response.status}`);
|
|
1563
|
+
const text = await response.text();
|
|
1564
|
+
if (/text\/html/i.test(response.headers.get("content-type") ?? "") || /^\s*<(?:!doctype|html)/i.test(text)) throw new DocsNotFoundError(docsPath, `${url} is not published (the site answered with its HTML shell)`);
|
|
1565
|
+
return text;
|
|
1445
1566
|
}
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1567
|
+
};
|
|
1568
|
+
/** Remembers documents for a TTL, dedupes concurrent reads, and serves a stale copy when a refresh fails. */
|
|
1569
|
+
var CachedSource = class {
|
|
1570
|
+
inner;
|
|
1571
|
+
options;
|
|
1572
|
+
kind;
|
|
1573
|
+
entries = /* @__PURE__ */ new Map();
|
|
1574
|
+
pending = /* @__PURE__ */ new Map();
|
|
1575
|
+
now;
|
|
1576
|
+
hits = 0;
|
|
1577
|
+
misses = 0;
|
|
1578
|
+
constructor(inner, options) {
|
|
1579
|
+
this.inner = inner;
|
|
1580
|
+
this.options = options;
|
|
1581
|
+
this.kind = inner.kind;
|
|
1582
|
+
this.now = options.now ?? Date.now;
|
|
1583
|
+
}
|
|
1584
|
+
async readText(docsPath) {
|
|
1585
|
+
const cached = this.entries.get(docsPath);
|
|
1586
|
+
if (cached && cached.expiresAt > this.now()) {
|
|
1587
|
+
this.hits++;
|
|
1588
|
+
return cached.value;
|
|
1589
|
+
}
|
|
1590
|
+
const inFlight = this.pending.get(docsPath);
|
|
1591
|
+
if (inFlight) return inFlight;
|
|
1592
|
+
this.misses++;
|
|
1593
|
+
const request = this.inner.readText(docsPath).then((value) => {
|
|
1594
|
+
this.entries.set(docsPath, {
|
|
1595
|
+
value,
|
|
1596
|
+
expiresAt: this.now() + this.options.ttlMs
|
|
1597
|
+
});
|
|
1598
|
+
return value;
|
|
1599
|
+
}).catch((error) => {
|
|
1600
|
+
if (cached) {
|
|
1601
|
+
this.entries.set(docsPath, {
|
|
1602
|
+
value: cached.value,
|
|
1603
|
+
expiresAt: this.now() + this.options.ttlMs
|
|
1604
|
+
});
|
|
1605
|
+
return cached.value;
|
|
1606
|
+
}
|
|
1607
|
+
throw error;
|
|
1608
|
+
}).finally(() => {
|
|
1609
|
+
this.pending.delete(docsPath);
|
|
1457
1610
|
});
|
|
1458
|
-
|
|
1611
|
+
this.pending.set(docsPath, request);
|
|
1612
|
+
return request;
|
|
1459
1613
|
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
const elements = scanElements(code);
|
|
1463
|
-
const usages = elements.map((element) => ({
|
|
1464
|
-
element,
|
|
1465
|
-
matches: declarationsOn(element, index)
|
|
1466
|
-
})).filter(({ matches }) => matches.some((ref) => ref.component === component));
|
|
1467
|
-
if (usages.length === 0) {
|
|
1468
|
-
issues.push(...checkSelectorMismatch(component, elements, index));
|
|
1469
|
-
if (!issues.some((issue) => issue.kind === "selector-mismatch" || issue.kind === "unknown-selector")) issues.push({
|
|
1470
|
-
kind: "selector-not-found",
|
|
1471
|
-
severity: "warning",
|
|
1472
|
-
name: component.name,
|
|
1473
|
-
message: `The code does not use ${component.title}: none of its selectors (${component.selectors.join(", ")}) appear in it.`
|
|
1474
|
-
});
|
|
1475
|
-
return issues;
|
|
1614
|
+
invalidate() {
|
|
1615
|
+
this.entries.clear();
|
|
1476
1616
|
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
const suggestion = target && target === component.name ? component.import : target ? `@exhaustive-ui/core/${target}` : "@exhaustive-ui/core";
|
|
1485
|
-
issues.push({
|
|
1486
|
-
kind: "import-mismatch",
|
|
1487
|
-
severity: "error",
|
|
1488
|
-
name: statement.source,
|
|
1489
|
-
message: `"${statement.source}" is a PrimeNG / Optimus UI import; ExhaustiveUI components are imported from @exhaustive-ui/core.`,
|
|
1490
|
-
suggestion: suggestion ? `import { ${statement.names.join(", ") || component.modules[0] || component.declarations[0]?.className || ""} } from '${suggestion}';` : void 0
|
|
1491
|
-
});
|
|
1617
|
+
stats() {
|
|
1618
|
+
return {
|
|
1619
|
+
entries: this.entries.size,
|
|
1620
|
+
hits: this.hits,
|
|
1621
|
+
misses: this.misses,
|
|
1622
|
+
ttlMs: this.options.ttlMs
|
|
1623
|
+
};
|
|
1492
1624
|
}
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1625
|
+
};
|
|
1626
|
+
const DEFAULT_FALLBACK_COOLDOWN_MS = 6e4;
|
|
1627
|
+
/** Reads from the primary source and falls back to the secondary one when the primary fails for any reason. */
|
|
1628
|
+
var FallbackSource = class {
|
|
1629
|
+
primary;
|
|
1630
|
+
fallback;
|
|
1631
|
+
kind;
|
|
1632
|
+
cooldownMs;
|
|
1633
|
+
now;
|
|
1634
|
+
fallbackReads = 0;
|
|
1635
|
+
lastFallbackAt;
|
|
1636
|
+
lastFallbackReason;
|
|
1637
|
+
primarySkippedUntil = 0;
|
|
1638
|
+
constructor(primary, fallback, options = {}) {
|
|
1639
|
+
this.primary = primary;
|
|
1640
|
+
this.fallback = fallback;
|
|
1641
|
+
this.kind = `${primary.kind}+${fallback.kind}`;
|
|
1642
|
+
this.cooldownMs = options.cooldownMs ?? 6e4;
|
|
1643
|
+
this.now = options.now ?? Date.now;
|
|
1503
1644
|
}
|
|
1504
|
-
|
|
1645
|
+
async readText(docsPath) {
|
|
1646
|
+
if (this.primarySkippedUntil > this.now()) try {
|
|
1647
|
+
return await this.readFallback(docsPath, void 0);
|
|
1648
|
+
} catch {}
|
|
1649
|
+
try {
|
|
1650
|
+
return await this.primary.readText(docsPath);
|
|
1651
|
+
} catch (primaryError) {
|
|
1652
|
+
if (primaryError instanceof DocsFetchError) this.primarySkippedUntil = this.now() + this.cooldownMs;
|
|
1653
|
+
try {
|
|
1654
|
+
return await this.readFallback(docsPath, primaryError);
|
|
1655
|
+
} catch (fallbackError) {
|
|
1656
|
+
throw primaryError instanceof DocsNotFoundError && fallbackError instanceof DocsNotFoundError ? fallbackError : primaryError;
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
async readFallback(docsPath, primaryError) {
|
|
1661
|
+
const text = await this.fallback.readText(docsPath);
|
|
1662
|
+
this.fallbackReads++;
|
|
1663
|
+
this.lastFallbackAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1664
|
+
if (primaryError !== void 0) this.lastFallbackReason = describeError(primaryError);
|
|
1665
|
+
return text;
|
|
1666
|
+
}
|
|
1667
|
+
status() {
|
|
1668
|
+
return {
|
|
1669
|
+
primary: this.primary.kind,
|
|
1670
|
+
fallback: this.fallback.kind,
|
|
1671
|
+
fallbackReads: this.fallbackReads,
|
|
1672
|
+
lastFallbackAt: this.lastFallbackAt,
|
|
1673
|
+
lastFallbackReason: this.lastFallbackReason,
|
|
1674
|
+
primarySkippedUntil: this.primarySkippedUntil > this.now() ? new Date(this.primarySkippedUntil).toISOString() : void 0
|
|
1675
|
+
};
|
|
1676
|
+
}
|
|
1677
|
+
};
|
|
1678
|
+
/** The runtime source: the live site behind a TTL cache, falling back to the offline snapshot (or the snapshot alone when offline). */
|
|
1679
|
+
function createDocsSource(config, fetchImpl) {
|
|
1680
|
+
const snapshot = config.snapshotDir ? new SnapshotSource(config.snapshotDir) : void 0;
|
|
1681
|
+
if (config.offline) {
|
|
1682
|
+
if (!snapshot) throw new Error("Offline mode needs an offline snapshot directory (EXHAUSTIVE_UI_MCP_SNAPSHOT_DIR).");
|
|
1683
|
+
return {
|
|
1684
|
+
source: snapshot,
|
|
1685
|
+
status: () => ({
|
|
1686
|
+
mode: "offline",
|
|
1687
|
+
docsUrl: config.docsUrl,
|
|
1688
|
+
cacheTtlSeconds: 0,
|
|
1689
|
+
snapshotDir: snapshot.directory
|
|
1690
|
+
})
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
const remote = new CachedSource(new RemoteSource({
|
|
1694
|
+
baseUrl: config.docsUrl,
|
|
1695
|
+
timeoutMs: config.fetchTimeoutMs,
|
|
1696
|
+
fetchImpl
|
|
1697
|
+
}), { ttlMs: config.cacheTtlMs });
|
|
1698
|
+
const fallback = snapshot ? new FallbackSource(remote, snapshot) : void 0;
|
|
1699
|
+
return {
|
|
1700
|
+
source: fallback ?? remote,
|
|
1701
|
+
status: () => ({
|
|
1702
|
+
mode: "remote",
|
|
1703
|
+
docsUrl: config.docsUrl,
|
|
1704
|
+
cacheTtlSeconds: Math.round(config.cacheTtlMs / 1e3),
|
|
1705
|
+
snapshotDir: snapshot?.directory,
|
|
1706
|
+
fallback: fallback?.status(),
|
|
1707
|
+
cache: remote.stats()
|
|
1708
|
+
})
|
|
1709
|
+
};
|
|
1505
1710
|
}
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1711
|
+
|
|
1712
|
+
//#endregion
|
|
1713
|
+
//#region src/search.ts
|
|
1714
|
+
const indexes = /* @__PURE__ */ new WeakMap();
|
|
1715
|
+
/** Search components, guides, API members and examples of the catalog. Results are sorted by relevance. */
|
|
1716
|
+
function searchCatalog(catalog, query, scope = "all") {
|
|
1717
|
+
const phrase = query.trim().toLowerCase();
|
|
1718
|
+
const terms = tokenize(query);
|
|
1719
|
+
const entries = indexFor(catalog).filter((entry) => scope === "all" ? entry.scope === "components" || entry.scope === "guides" : entry.scope === scope);
|
|
1720
|
+
const hits = [];
|
|
1721
|
+
for (const entry of entries) {
|
|
1722
|
+
const match = scoreEntry(entry.fields, phrase, terms);
|
|
1723
|
+
if (match) hits.push({
|
|
1724
|
+
...entry.result,
|
|
1725
|
+
type: String(entry.result.type),
|
|
1726
|
+
score: match.score,
|
|
1727
|
+
matchedTerms: match.matchedTerms,
|
|
1728
|
+
matches: match.matches
|
|
1519
1729
|
});
|
|
1520
|
-
else if (/^p-/i.test(tag) && !index.elements.has(tag.toLowerCase())) {
|
|
1521
|
-
const renamed = aliasTarget === component.name;
|
|
1522
|
-
const related = renamed || names.has(key) || slugify(tag).startsWith(`p-${component.name}`);
|
|
1523
|
-
issues.push({
|
|
1524
|
-
kind: "unknown-selector",
|
|
1525
|
-
severity: "error",
|
|
1526
|
-
name: tag,
|
|
1527
|
-
message: renamed ? `<${tag}> is the PrimeNG name of this component; in ExhaustiveUI ${component.title} uses ${component.selectors.join(" or ")}.` : `<${tag}> is not a selector of any ExhaustiveUI component${related ? "" : ` (expected ${component.title} here)`}; use ${component.selectors.join(" or ")}.`,
|
|
1528
|
-
suggestion: component.selectors[0]
|
|
1529
|
-
});
|
|
1530
|
-
}
|
|
1531
1730
|
}
|
|
1532
|
-
return
|
|
1731
|
+
return hits.sort((a, b) => b.score - a.score || b.matchedTerms.length - a.matchedTerms.length || String(a.title ?? a.name).localeCompare(String(b.title ?? b.name)));
|
|
1533
1732
|
}
|
|
1534
|
-
function
|
|
1535
|
-
const
|
|
1536
|
-
const
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
const
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1733
|
+
function scoreEntry(fields, phrase, terms) {
|
|
1734
|
+
const matchedTerms = /* @__PURE__ */ new Set();
|
|
1735
|
+
const matches = [];
|
|
1736
|
+
let score = 0;
|
|
1737
|
+
let phraseMatched = false;
|
|
1738
|
+
for (const field of fields) {
|
|
1739
|
+
if (!field.text) continue;
|
|
1740
|
+
if (phrase && field.lower.includes(phrase)) {
|
|
1741
|
+
phraseMatched = true;
|
|
1742
|
+
score += 100 * field.weight;
|
|
1743
|
+
matches.push(...snippets(field.text, phrase));
|
|
1544
1744
|
}
|
|
1545
|
-
for (const
|
|
1546
|
-
|
|
1547
|
-
|
|
1745
|
+
for (const term of terms) if (matchesTerm(term, field.lower, field.terms)) {
|
|
1746
|
+
matchedTerms.add(term);
|
|
1747
|
+
score += field.weight;
|
|
1748
|
+
matches.push(...snippetsForTerm(field.text, term));
|
|
1548
1749
|
}
|
|
1549
|
-
for (const output of ref.declaration.outputs ?? []) outputs.add(output.name);
|
|
1550
1750
|
}
|
|
1551
|
-
const
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1751
|
+
const required = terms.length <= 2 ? 1 : Math.max(2, Math.ceil(terms.length * .4));
|
|
1752
|
+
if (!phraseMatched && matchedTerms.size < required) return;
|
|
1753
|
+
return {
|
|
1754
|
+
score,
|
|
1755
|
+
matchedTerms: [...matchedTerms],
|
|
1756
|
+
matches: unique(matches).slice(0, 5)
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
function indexFor(catalog) {
|
|
1760
|
+
let index = indexes.get(catalog);
|
|
1761
|
+
if (!index) {
|
|
1762
|
+
index = buildIndex(catalog);
|
|
1763
|
+
indexes.set(catalog, index);
|
|
1764
|
+
}
|
|
1765
|
+
return index;
|
|
1766
|
+
}
|
|
1767
|
+
function buildIndex(catalog) {
|
|
1768
|
+
const entries = [];
|
|
1769
|
+
for (const component of catalog.components) {
|
|
1770
|
+
entries.push(componentEntry(component));
|
|
1771
|
+
entries.push(...apiEntries(component));
|
|
1772
|
+
entries.push(...exampleEntries(component));
|
|
1773
|
+
}
|
|
1774
|
+
for (const guide of catalog.guides) entries.push(guideEntry(guide));
|
|
1775
|
+
return entries;
|
|
1776
|
+
}
|
|
1777
|
+
function componentEntry(component) {
|
|
1778
|
+
const api = component.api;
|
|
1779
|
+
const apiText = [
|
|
1780
|
+
...api.props ?? [],
|
|
1781
|
+
...api.emits ?? [],
|
|
1782
|
+
...api.templates ?? [],
|
|
1783
|
+
...api.methods ?? [],
|
|
1784
|
+
...api.pt ?? []
|
|
1785
|
+
].map((member) => `${member.name} ${member.description ?? ""}`).join(" ");
|
|
1786
|
+
const sectionsText = component.sections.map((section) => `${section.label} ${section.description ?? ""}`).join(" ");
|
|
1787
|
+
const codeText = component.sections.map((section) => section.code ?? "").join("\n");
|
|
1788
|
+
return {
|
|
1789
|
+
scope: "components",
|
|
1790
|
+
result: {
|
|
1791
|
+
type: "component",
|
|
1792
|
+
name: component.name,
|
|
1793
|
+
title: component.title,
|
|
1794
|
+
description: component.description,
|
|
1795
|
+
selectors: component.selectors,
|
|
1796
|
+
import: component.import,
|
|
1797
|
+
resourceUri: component.resourceUri,
|
|
1798
|
+
publicUrl: component.publicUrl,
|
|
1799
|
+
nextCall: {
|
|
1800
|
+
tool: "get_component",
|
|
1801
|
+
arguments: { component: component.name }
|
|
1592
1802
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1803
|
+
},
|
|
1804
|
+
fields: [
|
|
1805
|
+
field([
|
|
1806
|
+
component.name,
|
|
1807
|
+
shortTitle(component.title),
|
|
1808
|
+
...component.selectors,
|
|
1809
|
+
component.import ?? "",
|
|
1810
|
+
...component.declarations.map((declaration) => declaration.className)
|
|
1811
|
+
].join(" "), 8),
|
|
1812
|
+
field(component.description, 4),
|
|
1813
|
+
field(sectionsText, 3),
|
|
1814
|
+
field(apiText, 3),
|
|
1815
|
+
field(codeText, 1)
|
|
1816
|
+
]
|
|
1817
|
+
};
|
|
1818
|
+
}
|
|
1819
|
+
function guideEntry(guide) {
|
|
1820
|
+
return {
|
|
1821
|
+
scope: "guides",
|
|
1822
|
+
result: {
|
|
1823
|
+
type: "guide",
|
|
1824
|
+
name: guide.name,
|
|
1825
|
+
title: guide.title,
|
|
1826
|
+
description: guide.description,
|
|
1827
|
+
route: guide.route,
|
|
1828
|
+
resourceUri: guide.resourceUri,
|
|
1829
|
+
publicUrl: guide.publicUrl,
|
|
1830
|
+
nextCall: {
|
|
1831
|
+
tool: "get_guide",
|
|
1832
|
+
arguments: { guide: guide.name }
|
|
1606
1833
|
}
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1834
|
+
},
|
|
1835
|
+
fields: [
|
|
1836
|
+
field([
|
|
1837
|
+
guide.name,
|
|
1838
|
+
guide.route,
|
|
1839
|
+
guide.title
|
|
1840
|
+
].join(" "), 8),
|
|
1841
|
+
field(guide.description, 4),
|
|
1842
|
+
field(guide.sections.map((section) => `${section.label} ${section.description ?? ""}`).join(" "), 3),
|
|
1843
|
+
field(guide.sections.map((section) => section.code ?? "").join("\n"), 1)
|
|
1844
|
+
]
|
|
1845
|
+
};
|
|
1846
|
+
}
|
|
1847
|
+
function apiEntries(component) {
|
|
1848
|
+
const api = component.api;
|
|
1849
|
+
return [
|
|
1850
|
+
...(api.props ?? []).map((prop) => ({
|
|
1851
|
+
member: "prop",
|
|
1852
|
+
name: prop.name,
|
|
1853
|
+
type: prop.type,
|
|
1854
|
+
description: prop.description
|
|
1855
|
+
})),
|
|
1856
|
+
...(api.emits ?? []).map((emit) => ({
|
|
1857
|
+
member: "emit",
|
|
1858
|
+
name: emit.name,
|
|
1859
|
+
type: emit.parameters?.map((parameter) => `${parameter.name}: ${parameter.type ?? "unknown"}`).join(", "),
|
|
1860
|
+
description: emit.description
|
|
1861
|
+
})),
|
|
1862
|
+
...(api.templates ?? []).map((template) => ({
|
|
1863
|
+
member: "template",
|
|
1864
|
+
name: template.name,
|
|
1865
|
+
type: template.type,
|
|
1866
|
+
description: template.description
|
|
1867
|
+
})),
|
|
1868
|
+
...(api.methods ?? []).map((method) => ({
|
|
1869
|
+
member: "method",
|
|
1870
|
+
name: method.name,
|
|
1871
|
+
type: method.returnType,
|
|
1872
|
+
description: method.description
|
|
1873
|
+
})),
|
|
1874
|
+
...(api.pt ?? []).map((pt) => ({
|
|
1875
|
+
member: "pt",
|
|
1876
|
+
name: pt.name,
|
|
1877
|
+
type: pt.type,
|
|
1878
|
+
description: pt.description
|
|
1879
|
+
})),
|
|
1880
|
+
...(api.styles ?? []).map((style) => ({
|
|
1881
|
+
member: "style",
|
|
1882
|
+
name: style.class,
|
|
1883
|
+
description: style.description
|
|
1884
|
+
})),
|
|
1885
|
+
...(api.tokens ?? []).map((token) => ({
|
|
1886
|
+
member: "token",
|
|
1887
|
+
name: token.token,
|
|
1888
|
+
type: token.variable,
|
|
1889
|
+
description: token.description
|
|
1890
|
+
}))
|
|
1891
|
+
].map((member) => ({
|
|
1892
|
+
scope: "api",
|
|
1893
|
+
result: {
|
|
1894
|
+
type: "api",
|
|
1895
|
+
component: component.name,
|
|
1896
|
+
member: member.member,
|
|
1897
|
+
name: member.name,
|
|
1898
|
+
memberType: member.type,
|
|
1899
|
+
description: member.description,
|
|
1900
|
+
apiResourceUri: component.apiResourceUri,
|
|
1901
|
+
nextCall: {
|
|
1902
|
+
tool: "get_component",
|
|
1903
|
+
arguments: {
|
|
1904
|
+
component: component.name,
|
|
1905
|
+
includeApi: true
|
|
1616
1906
|
}
|
|
1617
|
-
const input = inputs.get(lowerName);
|
|
1618
|
-
if (!input) {
|
|
1619
|
-
if (everyInput.has(lowerName) || GLOBAL_ATTRIBUTES.has(lowerName)) break;
|
|
1620
|
-
issues.push({
|
|
1621
|
-
kind: "unknown-prop",
|
|
1622
|
-
severity: "error",
|
|
1623
|
-
name: attribute.name,
|
|
1624
|
-
message: `"${attribute.name}" is not an input of ${label}, so it cannot be bound two-way.`,
|
|
1625
|
-
allowedProps
|
|
1626
|
-
});
|
|
1627
|
-
} else if (!input.twoWay && !outputs.has(`${input.name}Change`)) issues.push({
|
|
1628
|
-
kind: "two-way-binding-unsupported",
|
|
1629
|
-
severity: "error",
|
|
1630
|
-
name: input.name,
|
|
1631
|
-
message: `Input "${input.name}" of ${label} has no "${input.name}Change" output; bind it one-way with [${input.name}].`
|
|
1632
|
-
});
|
|
1633
|
-
break;
|
|
1634
1907
|
}
|
|
1635
|
-
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
return issues;
|
|
1908
|
+
},
|
|
1909
|
+
fields: [field(`${component.name} ${member.name} ${slugify(member.name).replace(/-/g, " ")}`, 8), field(`${member.type ?? ""} ${member.description ?? ""}`, 3)]
|
|
1910
|
+
}));
|
|
1639
1911
|
}
|
|
1640
|
-
function
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1912
|
+
function exampleEntries(component) {
|
|
1913
|
+
return component.sections.filter((section) => section.hasCode).map((section) => ({
|
|
1914
|
+
scope: "examples",
|
|
1915
|
+
result: {
|
|
1916
|
+
type: "example",
|
|
1917
|
+
component: component.name,
|
|
1918
|
+
section: section.id,
|
|
1919
|
+
title: section.label,
|
|
1920
|
+
description: section.description,
|
|
1921
|
+
codeLanguage: section.codeLanguage,
|
|
1922
|
+
resourceUri: component.resourceUri,
|
|
1923
|
+
nextCall: {
|
|
1924
|
+
tool: "get_example",
|
|
1925
|
+
arguments: {
|
|
1926
|
+
component: component.name,
|
|
1927
|
+
section: section.id
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
},
|
|
1931
|
+
fields: [
|
|
1932
|
+
field(`${component.name} ${section.label} ${section.id}`, 8),
|
|
1933
|
+
field(section.description ?? "", 3),
|
|
1934
|
+
field(section.code ?? "", 1)
|
|
1935
|
+
]
|
|
1936
|
+
}));
|
|
1648
1937
|
}
|
|
1649
|
-
function
|
|
1650
|
-
const
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
return `- [${issue.severity}] ${issue.kind}${issue.name ? ` ${issue.name}` : ""}: ${issue.message}${extras}`;
|
|
1658
|
-
});
|
|
1659
|
-
return [`Usage has ${issues.length} validation issue${issues.length === 1 ? "" : "s"} for ${componentTitle}.`, ...lines].join("\n");
|
|
1938
|
+
function field(text, weight) {
|
|
1939
|
+
const value = text ?? "";
|
|
1940
|
+
return {
|
|
1941
|
+
text: value,
|
|
1942
|
+
lower: value.toLowerCase(),
|
|
1943
|
+
terms: tokenize(value),
|
|
1944
|
+
weight
|
|
1945
|
+
};
|
|
1660
1946
|
}
|
|
1661
1947
|
|
|
1662
1948
|
//#endregion
|
|
@@ -1759,7 +2045,7 @@ const componentRequest = z.object({
|
|
|
1759
2045
|
sections: z.array(z.string()).optional().describe("Restrict to these section ids or labels."),
|
|
1760
2046
|
includeApi: z.boolean().default(false).describe("Include the API (inputs, outputs, templates, methods, PT keys, CSS classes, tokens) and compiled declarations."),
|
|
1761
2047
|
includeExamples: z.boolean().default(false).describe("Include the code of every example section."),
|
|
1762
|
-
detail: z.enum(["compact", "full"]).default("compact").describe("\"full\" also returns the complete Markdown document.")
|
|
2048
|
+
detail: z.enum(["compact", "full"]).default("compact").describe("\"compact\" returns the component card (import, tag, key inputs, outputs, templates with their context, one example); \"full\" also returns the complete Markdown document.")
|
|
1763
2049
|
});
|
|
1764
2050
|
const getComponentInput = {
|
|
1765
2051
|
...componentRequest.shape,
|
|
@@ -1956,8 +2242,10 @@ async function getSingleComponent(ctx, input) {
|
|
|
1956
2242
|
const sections = input.sections?.length ? input.sections.map((query) => requireSection(component.sections, query)) : component.sections;
|
|
1957
2243
|
const withCode = sections.filter((section) => section.hasCode);
|
|
1958
2244
|
const document = input.detail === "full" ? await ctx.source.readText(component.docPath) : void 0;
|
|
2245
|
+
const card = input.sections?.length ? void 0 : await readOptional(ctx, component.cardPath);
|
|
1959
2246
|
const result = {
|
|
1960
2247
|
...componentSummary(component),
|
|
2248
|
+
...card !== void 0 ? { card } : {},
|
|
1961
2249
|
route: component.route,
|
|
1962
2250
|
declarations: component.declarations.map((declaration) => ({
|
|
1963
2251
|
kind: declaration.kind,
|
|
@@ -1992,6 +2280,15 @@ async function getSingleComponent(ctx, input) {
|
|
|
1992
2280
|
})}.` : "";
|
|
1993
2281
|
return ok({ component: result }, `${component.title}: ${sections.length} section${sections.length === 1 ? "" : "s"}, ${withCode.length} with code; source ${component.resourceUri}.${next}`);
|
|
1994
2282
|
}
|
|
2283
|
+
/** A generated document that older docs deployments or snapshots may not have yet. */
|
|
2284
|
+
async function readOptional(ctx, docsPath) {
|
|
2285
|
+
try {
|
|
2286
|
+
return await ctx.source.readText(docsPath);
|
|
2287
|
+
} catch (error) {
|
|
2288
|
+
if (error instanceof DocsNotFoundError) return;
|
|
2289
|
+
throw error;
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
1995
2292
|
async function getGuideTool(ctx, input) {
|
|
1996
2293
|
const guide = findGuide(await ctx.catalog(), input.guide);
|
|
1997
2294
|
const section = input.section ? requireSection(guide.sections, input.section) : void 0;
|
|
@@ -2460,7 +2757,7 @@ function registerTools(server, ctx) {
|
|
|
2460
2757
|
}, (input) => guard(() => searchTool(ctx, input)));
|
|
2461
2758
|
server.registerTool("get_component", {
|
|
2462
2759
|
title: "Get component docs",
|
|
2463
|
-
description: "Read
|
|
2760
|
+
description: "Read an ExhaustiveUI component: its card (import, tag, key inputs, outputs, every template with the context it receives, one example), its sections and available examples, and optionally its full API, compiled declarations and full Markdown document. Start here before writing code with a component. Accepts a batch of up to 10 components.",
|
|
2464
2761
|
inputSchema: getComponentInput,
|
|
2465
2762
|
annotations: readOnly
|
|
2466
2763
|
}, (input) => guard(() => getComponentTool(ctx, input)));
|
|
@@ -2750,10 +3047,15 @@ function registerPrompts(server) {
|
|
|
2750
3047
|
const HELP = `${SERVER_NAME}: Model Context Protocol server for the ExhaustiveUI Angular component library.
|
|
2751
3048
|
|
|
2752
3049
|
Usage: exhaustive-ui-mcp [--help] [--version]
|
|
3050
|
+
exhaustive-ui-mcp check [paths...] [--json]
|
|
2753
3051
|
|
|
2754
3052
|
The server speaks MCP over stdio; register it in your MCP client, for example:
|
|
2755
3053
|
claude mcp add exhaustive-ui -- npx -y @exhaustive-ui/mcp
|
|
2756
3054
|
|
|
3055
|
+
check validates the Angular templates (.html files and inline templates of .ts files) under the given paths
|
|
3056
|
+
(default: src) against the ExhaustiveUI API: PrimeNG tags and imports, unknown inputs and outputs, removed v22
|
|
3057
|
+
inputs, template names. It exits with 1 when it finds an error. --json prints the issues as JSON.
|
|
3058
|
+
|
|
2757
3059
|
Environment variables:
|
|
2758
3060
|
EXHAUSTIVE_UI_DOCS_URL Docs site to read from (default https://exhaustive-ui.com)
|
|
2759
3061
|
EXHAUSTIVE_UI_MCP_CACHE_TTL Seconds a fetched document is reused (default 900)
|
|
@@ -2772,14 +3074,28 @@ function isCliEntrypoint() {
|
|
|
2772
3074
|
}
|
|
2773
3075
|
if (isCliEntrypoint()) {
|
|
2774
3076
|
const args = process.argv.slice(2);
|
|
2775
|
-
if (args
|
|
3077
|
+
if (args[0] === "check") runCheck(args.slice(1)).then((code) => process.exit(code), (error) => {
|
|
3078
|
+
console.error(`${SERVER_NAME} check failed:`, error instanceof Error ? error.message : error);
|
|
3079
|
+
process.exit(2);
|
|
3080
|
+
});
|
|
3081
|
+
else if (args.includes("--help") || args.includes("-h")) console.log(HELP);
|
|
2776
3082
|
else if (args.includes("--version") || args.includes("-v")) console.log(readPackageVersion());
|
|
2777
3083
|
else runExhaustiveUiMcpServer().catch((error) => {
|
|
2778
3084
|
console.error(`Failed to start ${SERVER_NAME}:`, error);
|
|
2779
3085
|
process.exit(1);
|
|
2780
3086
|
});
|
|
2781
3087
|
}
|
|
3088
|
+
async function runCheck(args) {
|
|
3089
|
+
const json = args.includes("--json");
|
|
3090
|
+
const targets = args.filter((arg) => !arg.startsWith("--"));
|
|
3091
|
+
const result = await checkProject(await createToolContext({ env: {
|
|
3092
|
+
...process.env,
|
|
3093
|
+
EXHAUSTIVE_UI_MCP_OFFLINE: "1"
|
|
3094
|
+
} }).catalog(), targets.length ? targets : ["src"]);
|
|
3095
|
+
console.log(json ? JSON.stringify(result, null, 2) : formatCheckReport(result));
|
|
3096
|
+
return result.issues.some((issue) => issue.severity === "error") ? 1 : 0;
|
|
3097
|
+
}
|
|
2782
3098
|
|
|
2783
3099
|
//#endregion
|
|
2784
|
-
export { CachedSource, CatalogLoader, DEFAULT_CACHE_TTL_SECONDS, DEFAULT_DOCS_URL, DEFAULT_FETCH_TIMEOUT_MS, FallbackSource, MemorySource, PROMPT_NAMES, RESOURCE_BASE_URI, RESOURCE_TEMPLATE_NAMES, RemoteSource, SERVER_NAME, STATIC_RESOURCE_URIS, SnapshotSource, TOOL_NAMES, buildCatalog, componentApi, createDocsSource, createExhaustiveUiMcpServer, createToolContext, findComponent, findGuide, findSection, readPackageVersion, resolveConfig, runExhaustiveUiMcpServer, searchCatalog, validateComponentUsage };
|
|
3100
|
+
export { CachedSource, CatalogLoader, DEFAULT_CACHE_TTL_SECONDS, DEFAULT_DOCS_URL, DEFAULT_FETCH_TIMEOUT_MS, FallbackSource, MemorySource, PROMPT_NAMES, RESOURCE_BASE_URI, RESOURCE_TEMPLATE_NAMES, RemoteSource, SERVER_NAME, STATIC_RESOURCE_URIS, SnapshotSource, TOOL_NAMES, buildCatalog, checkProject, checkSource, componentApi, createDocsSource, createExhaustiveUiMcpServer, createToolContext, findComponent, findGuide, findSection, formatCheckReport, readPackageVersion, resolveConfig, runExhaustiveUiMcpServer, searchCatalog, validateComponentUsage };
|
|
2785
3101
|
//# sourceMappingURL=index.mjs.map
|