@kerfjs/ui 5.0.0-beta.125 → 5.0.0-beta.126
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 +5 -0
- package/ai/application-ui-diagnostic-ids-v1.json +1 -0
- package/ai/component-catalog.json +77 -6
- package/ai/component-catalog.schema.json +14 -1
- package/ai/component-composition.json +27 -6
- package/ai/component-props.json +245 -40
- package/ai/components/combobox.md +1 -1
- package/ai/components/surface-scaffold.md +19 -5
- package/ai/components/tab-bar.md +2 -0
- package/ai/components/toolbar.md +1 -0
- package/ai/public-api-signatures-v1.md +246 -295
- package/ai/skill.md +10 -4
- package/ai/view-document.schema.json +55 -2
- package/ai/webawesome-jsx-signatures-v1.md +1 -1
- package/analyzer/cli.mjs +60 -24
- package/analyzer/index.mjs +331 -58
- package/catalog-projection-cli.mjs +86 -50
- package/dist/anchored-surface.js +2 -1
- package/dist/browser/editor.js +11 -8
- package/dist/catalog-resources.d.ts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.js +6 -6
- package/dist/{chunk-VX3YF2UD.js → chunk-3K5V3ZSD.js} +3 -3
- package/dist/{chunk-VX3YF2UD.js.map → chunk-3K5V3ZSD.js.map} +1 -1
- package/dist/chunk-3SCGTP5O.js +682 -0
- package/dist/chunk-3SCGTP5O.js.map +1 -0
- package/dist/{chunk-NHQOX7T4.js → chunk-3ZKUXWAV.js} +4 -4
- package/dist/chunk-3ZKUXWAV.js.map +1 -0
- package/dist/{chunk-ADMWT7FX.js → chunk-3ZWYGGEC.js} +136 -8
- package/dist/chunk-3ZWYGGEC.js.map +1 -0
- package/dist/{chunk-KLR3DCHH.js → chunk-4L5ZIKDZ.js} +1 -1
- package/dist/chunk-4L5ZIKDZ.js.map +1 -0
- package/dist/{chunk-2E7S5C4D.js → chunk-4UWLHKNU.js} +5 -5
- package/dist/chunk-4UWLHKNU.js.map +1 -0
- package/dist/{chunk-EXGDKG7B.js → chunk-5A2DN3LR.js} +5 -5
- package/dist/chunk-5A2DN3LR.js.map +1 -0
- package/dist/{chunk-DJ65XFVN.js → chunk-63TJH2RF.js} +4 -4
- package/dist/chunk-63TJH2RF.js.map +1 -0
- package/dist/{chunk-Q2CLQ3IJ.js → chunk-6PHG2DMG.js} +1 -1
- package/dist/chunk-6PHG2DMG.js.map +1 -0
- package/dist/{chunk-SPI6VMIY.js → chunk-6T7AX365.js} +4 -4
- package/dist/chunk-6T7AX365.js.map +1 -0
- package/dist/{chunk-GVII4JSD.js → chunk-6V6UHPJD.js} +4 -4
- package/dist/chunk-6V6UHPJD.js.map +1 -0
- package/dist/{chunk-2LM3PYHA.js → chunk-C2TY5DJC.js} +11 -8
- package/dist/chunk-C2TY5DJC.js.map +1 -0
- package/dist/{chunk-3WYREXW4.js → chunk-COMEWURO.js} +8 -6
- package/dist/chunk-COMEWURO.js.map +1 -0
- package/dist/{chunk-VPDSPD76.js → chunk-DB64I3DB.js} +4 -3
- package/dist/chunk-DB64I3DB.js.map +1 -0
- package/dist/{chunk-SBCXWGNP.js → chunk-DBCDYBZP.js} +2 -2
- package/dist/{chunk-SBCXWGNP.js.map → chunk-DBCDYBZP.js.map} +1 -1
- package/dist/{chunk-CNM6ZWP2.js → chunk-DJWBXEF4.js} +4 -2
- package/dist/chunk-DJWBXEF4.js.map +1 -0
- package/dist/{chunk-SVUJIVMR.js → chunk-E2MTHHLS.js} +3 -3
- package/dist/{chunk-SVUJIVMR.js.map → chunk-E2MTHHLS.js.map} +1 -1
- package/dist/{chunk-JG4ONAOI.js → chunk-EI55KWHP.js} +2 -2
- package/dist/chunk-EI55KWHP.js.map +1 -0
- package/dist/{chunk-MVKHSAKE.js → chunk-GE2BQXB3.js} +41 -4
- package/dist/chunk-GE2BQXB3.js.map +1 -0
- package/dist/{chunk-KELWWCMX.js → chunk-I2K4OQKB.js} +4 -4
- package/dist/chunk-I2K4OQKB.js.map +1 -0
- package/dist/chunk-IFDTSVE6.js +9 -0
- package/dist/chunk-IFDTSVE6.js.map +1 -0
- package/dist/{chunk-TPLVC5BE.js → chunk-IR32NI2O.js} +336 -247
- package/dist/chunk-IR32NI2O.js.map +1 -0
- package/dist/{chunk-ZKKO4MHC.js → chunk-JYKP7TBZ.js} +4 -2
- package/dist/chunk-JYKP7TBZ.js.map +1 -0
- package/dist/{chunk-6OT7FOSA.js → chunk-K3C35KGR.js} +4 -4
- package/dist/chunk-K3C35KGR.js.map +1 -0
- package/dist/{chunk-4RECPEHI.js → chunk-KBS3GP6S.js} +4 -3
- package/dist/chunk-KBS3GP6S.js.map +1 -0
- package/dist/{chunk-YHRJNKD5.js → chunk-KS7EXW4P.js} +6 -4
- package/dist/chunk-KS7EXW4P.js.map +1 -0
- package/dist/{chunk-V6N3YLTM.js → chunk-LTOTL5AS.js} +3 -3
- package/dist/chunk-LTOTL5AS.js.map +1 -0
- package/dist/chunk-M64TAGZY.js +590 -0
- package/dist/chunk-M64TAGZY.js.map +1 -0
- package/dist/{chunk-JZZVWTUB.js → chunk-MMOQR426.js} +2 -2
- package/dist/chunk-MMOQR426.js.map +1 -0
- package/dist/{chunk-SJBMKA4X.js → chunk-OHT2AXER.js} +11 -10
- package/dist/chunk-OHT2AXER.js.map +1 -0
- package/dist/{chunk-TTFW6E6C.js → chunk-OZKBIPXU.js} +2 -2
- package/dist/chunk-OZKBIPXU.js.map +1 -0
- package/dist/{chunk-Q2SLOMN6.js → chunk-RHMY45DK.js} +4 -4
- package/dist/chunk-RHMY45DK.js.map +1 -0
- package/dist/{chunk-BZXA5SSA.js → chunk-S7QB5KMM.js} +2 -2
- package/dist/{chunk-BZXA5SSA.js.map → chunk-S7QB5KMM.js.map} +1 -1
- package/dist/{chunk-HDXUHLTQ.js → chunk-SHECA2N4.js} +8 -2
- package/dist/chunk-SHECA2N4.js.map +1 -0
- package/dist/{chunk-R6FIXYAE.js → chunk-SJEPM5ZU.js} +2 -2
- package/dist/{chunk-R6FIXYAE.js.map → chunk-SJEPM5ZU.js.map} +1 -1
- package/dist/{chunk-FJMABKKV.js → chunk-UQ4FRQ6M.js} +35 -17
- package/dist/chunk-UQ4FRQ6M.js.map +1 -0
- package/dist/{chunk-S4ZGTDSG.js → chunk-UU37OR3D.js} +2 -2
- package/dist/chunk-UU37OR3D.js.map +1 -0
- package/dist/{chunk-SWXWLSUD.js → chunk-WEQNPYVA.js} +1 -1
- package/dist/{chunk-SWXWLSUD.js.map → chunk-WEQNPYVA.js.map} +1 -1
- package/dist/{chunk-5SFHBYEY.js → chunk-WUVHP3UC.js} +97 -24
- package/dist/chunk-WUVHP3UC.js.map +1 -0
- package/dist/{chunk-3S3WXAZ5.js → chunk-X43QQWVC.js} +3 -2
- package/dist/chunk-X43QQWVC.js.map +1 -0
- package/dist/{chunk-Z3T24FX3.js → chunk-YE6KCAIN.js} +3 -2
- package/dist/chunk-YE6KCAIN.js.map +1 -0
- package/dist/{chunk-BCO673YW.js → chunk-Z3BT2SZE.js} +3 -3
- package/dist/chunk-Z3BT2SZE.js.map +1 -0
- package/dist/{chunk-KQZIC5CA.js → chunk-ZC4KSRAF.js} +7 -7
- package/dist/chunk-ZC4KSRAF.js.map +1 -0
- package/dist/collapsible-panel.d.ts +2 -2
- package/dist/collapsible-panel.js +2 -2
- package/dist/collapsible-panel.js.map +1 -1
- package/dist/column-explorer.d.ts +2 -2
- package/dist/column-explorer.js +2 -2
- package/dist/column-explorer.js.map +1 -1
- package/dist/dialog-surface-controller-BeKZ3e8Z.d.ts +251 -0
- package/dist/editor-frame.d.ts +1 -1
- package/dist/editor-frame.js +1 -1
- package/dist/editor.d.ts +38 -20
- package/dist/editor.js +10855 -6979
- package/dist/editor.js.map +1 -1
- package/dist/file-picker.js +1 -1
- package/dist/help-tags-register.js +2 -1
- package/dist/help-tags-register.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +24 -23
- package/dist/list-action-row.d.ts +1 -1
- package/dist/list-action-row.js +1 -1
- package/dist/list-detail-dialog.d.ts +7 -7
- package/dist/list-detail-dialog.js +6 -5
- package/dist/list-detail-dialog.js.map +1 -1
- package/dist/list-header.d.ts +1 -1
- package/dist/list-header.js +1 -1
- package/dist/list-item.d.ts +1 -1
- package/dist/list-item.js +1 -1
- package/dist/message-composer.js +1 -1
- package/dist/nav-stack.d.ts +6 -6
- package/dist/nav-stack.js +1 -1
- package/dist/popup-menu-register.js +1 -7
- package/dist/popup-menu-register.js.map +1 -1
- package/dist/popup-menu.d.ts +2 -2
- package/dist/popup-menu.js +1 -1
- package/dist/resizable-region.js +1 -1
- package/dist/segmented-control.d.ts +1 -1
- package/dist/segmented-control.js +1 -1
- package/dist/select-register.js +17 -23
- package/dist/select-register.js.map +1 -1
- package/dist/split-view.d.ts +6 -6
- package/dist/split-view.js +1 -1
- package/dist/styles/collapsible-panel.css +34 -25
- package/dist/styles/components/actions/popup-menu/popup-menu.css +4 -4
- package/dist/styles/components/actions/toolbar/toolbar.css +34 -1
- package/dist/styles/components/actions/toolbar-control-group/toolbar-control-group.css +1 -1
- package/dist/styles/components/forms/segmented-control/segmented-control.css +1 -1
- package/dist/styles/components/layout/collapsible-panel/collapsible-panel.css +34 -25
- package/dist/styles/components/layout/split-view/split-view.css +19 -33
- package/dist/styles/components/navigation/nav-stack/nav-stack.css +15 -19
- package/dist/styles/components/navigation/tab-navigator/tab-navigator.css +30 -29
- package/dist/styles/components/surfaces/editor-frame/editor-frame.css +2 -2
- package/dist/styles/components/surfaces/surface-scaffold/surface-scaffold.css +259 -4
- package/dist/styles/editor/editor.css +55 -0
- package/dist/styles/editor-frame.css +2 -2
- package/dist/styles/nav-stack.css +15 -19
- package/dist/styles/popup-menu.css +4 -4
- package/dist/styles/segmented-control.css +1 -1
- package/dist/styles/split-view.css +19 -33
- package/dist/styles/surface-scaffold.css +259 -4
- package/dist/styles/tab-navigator.css +30 -29
- package/dist/styles/toolbar-control-group.css +1 -1
- package/dist/styles/toolbar.css +34 -1
- package/dist/styles/webawesome.css +4 -5
- package/dist/surface-scaffold-register.js +2 -1
- package/dist/surface-scaffold-register.js.map +1 -1
- package/dist/surface-scaffold.d.ts +153 -246
- package/dist/surface-scaffold.js +3 -2
- package/dist/toolbar-control-group.d.ts +2 -2
- package/dist/toolbar-control-group.js +1 -1
- package/dist/toolbar.d.ts +6 -1
- package/dist/toolbar.js +1 -1
- package/dist/tree-list.d.ts +2 -2
- package/dist/tree-list.js +1 -1
- package/dist/wire-catalog.d.ts +1 -1
- package/dist/wire-catalog.js +3 -2
- package/dist/wire-catalog.js.map +1 -1
- package/dist/wire-checkboxes.js +2 -1
- package/dist/wire-choice-chips.js +2 -1
- package/dist/wire-color-fields.js +2 -1
- package/dist/wire-color-pickers.js +2 -1
- package/dist/wire-comboboxes.d.ts +2 -0
- package/dist/wire-comboboxes.js +2 -1
- package/dist/wire-content-items.js +2 -1
- package/dist/wire-corner-status.js +2 -1
- package/dist/wire-nav-stack.js +2 -1
- package/dist/wire-overlay-sheets.js +2 -1
- package/dist/wire-paged-views.js +2 -2
- package/dist/wire-paged-views.js.map +1 -1
- package/dist/wire-resizable-regions.js +2 -1
- package/dist/wire-scroll-dividers.js +1 -1
- package/dist/wire-search-fields.js +2 -1
- package/dist/wire-sidebar.js +2 -1
- package/dist/wire-tab-bars.d.ts +41 -2
- package/dist/wire-tab-bars.js +1 -1
- package/dist/wire-tab-navigator.js +2 -1
- package/dist/wire-tag-fields.js +2 -1
- package/dist/wire-workbench.js +2 -1
- package/dist/workbench-dialog.d.ts +7 -7
- package/dist/workbench-dialog.js +5 -4
- package/dist/workbench-dialog.js.map +1 -1
- package/dist/workbench.d.ts +1 -1
- package/dist/workbench.js +1 -1
- package/docs/accessibility.md +3 -6
- package/docs/component-contract.md +47 -7
- package/docs/component-selection.md +90 -80
- package/docs/design/templates.md +5 -4
- package/docs/editor-frame.md +1 -1
- package/docs/editor-host.md +15 -2
- package/docs/overlay-tooltip.md +1 -1
- package/docs/recipes.md +1 -1
- package/docs/surface-scaffold.md +63 -2
- package/docs/ui-analyzer.md +42 -0
- package/docs/ui-doctor.md +45 -1
- package/docs/ui-evaluator.md +35 -0
- package/docs/ux-demo.md +1 -1
- package/docs/view.md +295 -0
- package/docs/webawesome-theme.md +16 -0
- package/doctor/cli.mjs +36 -31
- package/doctor/index.mjs +349 -162
- package/evaluator/cli.mjs +36 -30
- package/llms.txt +17 -4
- package/package.json +3 -1
- package/props/cli.mjs +47 -21
- package/scripts/lib/cli-args.mjs +98 -0
- package/ux-demo/recipes/compact-toolbar.tsx +1 -1
- package/ux-demo/recipes/loading-inspector.tsx +1 -1
- package/view/catalog.mjs +229 -0
- package/view/child-kind.mjs +22 -0
- package/view/cli.mjs +142 -119
- package/view/contract.mjs +84 -11
- package/view/css-grammar.mjs +93 -0
- package/view/generate.d.mts +16 -0
- package/view/generate.mjs +122 -43
- package/view/index.d.mts +80 -14
- package/view/index.mjs +5 -9
- package/view/interpret.mjs +104 -36
- package/view/types.mjs +161 -0
- package/view/validate-move.mjs +66 -30
- package/view/validate.mjs +420 -654
- package/vite-editor.d.mts +16 -1
- package/vite-editor.mjs +74 -4
- package/dist/chunk-2E7S5C4D.js.map +0 -1
- package/dist/chunk-2LM3PYHA.js.map +0 -1
- package/dist/chunk-3S3WXAZ5.js.map +0 -1
- package/dist/chunk-3WYREXW4.js.map +0 -1
- package/dist/chunk-4RECPEHI.js.map +0 -1
- package/dist/chunk-5SFHBYEY.js.map +0 -1
- package/dist/chunk-6OT7FOSA.js.map +0 -1
- package/dist/chunk-ADMWT7FX.js.map +0 -1
- package/dist/chunk-BCO673YW.js.map +0 -1
- package/dist/chunk-CNM6ZWP2.js.map +0 -1
- package/dist/chunk-DJ65XFVN.js.map +0 -1
- package/dist/chunk-EXGDKG7B.js.map +0 -1
- package/dist/chunk-FJMABKKV.js.map +0 -1
- package/dist/chunk-GVII4JSD.js.map +0 -1
- package/dist/chunk-HDXUHLTQ.js.map +0 -1
- package/dist/chunk-JG4ONAOI.js.map +0 -1
- package/dist/chunk-JZZVWTUB.js.map +0 -1
- package/dist/chunk-KELWWCMX.js.map +0 -1
- package/dist/chunk-KLR3DCHH.js.map +0 -1
- package/dist/chunk-KQZIC5CA.js.map +0 -1
- package/dist/chunk-LD6A6PYB.js +0 -268
- package/dist/chunk-LD6A6PYB.js.map +0 -1
- package/dist/chunk-MVKHSAKE.js.map +0 -1
- package/dist/chunk-NHQOX7T4.js.map +0 -1
- package/dist/chunk-Q2CLQ3IJ.js.map +0 -1
- package/dist/chunk-Q2SLOMN6.js.map +0 -1
- package/dist/chunk-S4ZGTDSG.js.map +0 -1
- package/dist/chunk-SJBMKA4X.js.map +0 -1
- package/dist/chunk-SPI6VMIY.js.map +0 -1
- package/dist/chunk-TPLVC5BE.js.map +0 -1
- package/dist/chunk-TTFW6E6C.js.map +0 -1
- package/dist/chunk-V6N3YLTM.js.map +0 -1
- package/dist/chunk-VNT4MXR5.js +0 -548
- package/dist/chunk-VNT4MXR5.js.map +0 -1
- package/dist/chunk-VPDSPD76.js.map +0 -1
- package/dist/chunk-YHRJNKD5.js.map +0 -1
- package/dist/chunk-Z3T24FX3.js.map +0 -1
- package/dist/chunk-ZKKO4MHC.js.map +0 -1
- package/dist/{nav-stack-DwxpXxqJ.d.ts → nav-stack-vQ3ieerq.d.ts} +3 -3
package/analyzer/index.mjs
CHANGED
|
@@ -94,6 +94,10 @@ export const UI_ANALYSIS_RULES = Object.freeze({
|
|
|
94
94
|
severity: 'review',
|
|
95
95
|
title: 'Web Awesome token written without Web Awesome',
|
|
96
96
|
},
|
|
97
|
+
'KUI-L026': {
|
|
98
|
+
severity: 'review',
|
|
99
|
+
title: 'Deprecated Kerf UI prop literal',
|
|
100
|
+
},
|
|
97
101
|
});
|
|
98
102
|
|
|
99
103
|
/** Web Awesome appearance-scope classes, which need its theme to do anything. */
|
|
@@ -349,6 +353,13 @@ async function loadCatalogs(profileResult, ownership) {
|
|
|
349
353
|
componentSource,
|
|
350
354
|
styleSources: entry.styleSources ?? selected.styleSources,
|
|
351
355
|
catalogDirectory: dirname(owner),
|
|
356
|
+
deprecatedProps: selection.vocabularyAliases?.filter((alias) =>
|
|
357
|
+
(
|
|
358
|
+
entry.publicExports ??
|
|
359
|
+
selected.publicExports ??
|
|
360
|
+
[]
|
|
361
|
+
).includes(alias.component),
|
|
362
|
+
),
|
|
352
363
|
}
|
|
353
364
|
: { ...entry, componentSource, catalogDirectory: dirname(owner) },
|
|
354
365
|
);
|
|
@@ -400,6 +411,7 @@ async function loadSelectionFacts(owner, catalog) {
|
|
|
400
411
|
return facts;
|
|
401
412
|
}
|
|
402
413
|
const packageName = artifact.package ?? catalog.package;
|
|
414
|
+
facts.vocabularyAliases = artifact.propVocabulary?.aliases ?? [];
|
|
403
415
|
for (const entry of artifact.entries ?? []) {
|
|
404
416
|
const delivery = entry.delivery ?? {};
|
|
405
417
|
facts.set(`${packageName}:${entry.id}`, {
|
|
@@ -1689,6 +1701,25 @@ function inspectTsx(
|
|
|
1689
1701
|
const borrowedValues = (values, node, via) => {
|
|
1690
1702
|
for (const className of new Set(values)) borrowed(className, node, via);
|
|
1691
1703
|
};
|
|
1704
|
+
const deprecatedProp = (entry, component, prop, value, node) => {
|
|
1705
|
+
const alias = entry?.deprecatedProps?.find(
|
|
1706
|
+
(item) =>
|
|
1707
|
+
item.component === component &&
|
|
1708
|
+
item.prop === prop &&
|
|
1709
|
+
item.value === value,
|
|
1710
|
+
);
|
|
1711
|
+
if (!alias) return;
|
|
1712
|
+
diagnostics.push(
|
|
1713
|
+
diagnostic(
|
|
1714
|
+
'KUI-L026',
|
|
1715
|
+
location(file, node, source),
|
|
1716
|
+
`${component}.${prop}="${value}" is deprecated; use "${alias.replacement}". The alias remains supported for this major version.`,
|
|
1717
|
+
{ component, prop, value, replacement: alias.replacement },
|
|
1718
|
+
undefined,
|
|
1719
|
+
adoption,
|
|
1720
|
+
),
|
|
1721
|
+
);
|
|
1722
|
+
};
|
|
1692
1723
|
const templateGap = '\uE000';
|
|
1693
1724
|
const rawHtmlClasses = (value) => {
|
|
1694
1725
|
const classes = [];
|
|
@@ -1722,6 +1753,30 @@ function inspectTsx(
|
|
|
1722
1753
|
)
|
|
1723
1754
|
: undefined;
|
|
1724
1755
|
const entry = imports.get(tag) ?? namespaceEntry;
|
|
1756
|
+
if (entry) {
|
|
1757
|
+
const component =
|
|
1758
|
+
helperImports.get(tag)?.imported ?? tag.split('.').at(-1);
|
|
1759
|
+
for (const attribute of opening.attributes.properties) {
|
|
1760
|
+
if (!ts.isJsxAttribute(attribute)) continue;
|
|
1761
|
+
const value =
|
|
1762
|
+
attribute.initializer && ts.isStringLiteral(attribute.initializer)
|
|
1763
|
+
? attribute.initializer.text
|
|
1764
|
+
: attribute.initializer &&
|
|
1765
|
+
ts.isJsxExpression(attribute.initializer) &&
|
|
1766
|
+
attribute.initializer.expression &&
|
|
1767
|
+
ts.isStringLiteralLike(attribute.initializer.expression)
|
|
1768
|
+
? attribute.initializer.expression.text
|
|
1769
|
+
: undefined;
|
|
1770
|
+
if (value !== undefined)
|
|
1771
|
+
deprecatedProp(
|
|
1772
|
+
entry,
|
|
1773
|
+
component,
|
|
1774
|
+
attribute.name.getText(source),
|
|
1775
|
+
value,
|
|
1776
|
+
attribute,
|
|
1777
|
+
);
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1725
1780
|
const classAttribute = opening.attributes.properties.find(
|
|
1726
1781
|
(item) =>
|
|
1727
1782
|
ts.isJsxAttribute(item) &&
|
|
@@ -1889,6 +1944,29 @@ function inspectTsx(
|
|
|
1889
1944
|
aliasSource(namespaces.get(node.expression.expression.text)),
|
|
1890
1945
|
)
|
|
1891
1946
|
: undefined;
|
|
1947
|
+
if (
|
|
1948
|
+
entry &&
|
|
1949
|
+
node.arguments[0] &&
|
|
1950
|
+
ts.isObjectLiteralExpression(node.arguments[0])
|
|
1951
|
+
) {
|
|
1952
|
+
const component = ts.isIdentifier(node.expression)
|
|
1953
|
+
? (helperImports.get(node.expression.text)?.imported ??
|
|
1954
|
+
node.expression.text)
|
|
1955
|
+
: node.expression.name.text;
|
|
1956
|
+
for (const property of node.arguments[0].properties) {
|
|
1957
|
+
if (
|
|
1958
|
+
ts.isPropertyAssignment(property) &&
|
|
1959
|
+
ts.isStringLiteralLike(property.initializer)
|
|
1960
|
+
)
|
|
1961
|
+
deprecatedProp(
|
|
1962
|
+
entry,
|
|
1963
|
+
component,
|
|
1964
|
+
property.name.getText(source),
|
|
1965
|
+
property.initializer.text,
|
|
1966
|
+
property,
|
|
1967
|
+
);
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1892
1970
|
if (entry)
|
|
1893
1971
|
inspectCssValues(
|
|
1894
1972
|
file,
|
|
@@ -1928,25 +2006,11 @@ function inspectTsx(
|
|
|
1928
2006
|
visit(source);
|
|
1929
2007
|
}
|
|
1930
2008
|
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
knownRules = [],
|
|
1936
|
-
adoption = false,
|
|
1937
|
-
ownership = 'package',
|
|
1938
|
-
ownershipContext = 'subject',
|
|
1939
|
-
implicitComponentOwnership = false,
|
|
1940
|
-
ownershipGroups = [],
|
|
1941
|
-
profile: packageProfile = resolve(
|
|
1942
|
-
import.meta.dirname,
|
|
1943
|
-
'../ai/application-ui-profile.defaults.json',
|
|
1944
|
-
),
|
|
1945
|
-
} = {}) {
|
|
1946
|
-
const root = resolve(requestedRoot);
|
|
1947
|
-
const workspaceRoot = resolve(requestedWorkspaceRoot);
|
|
2009
|
+
// Phase 1 (file collection): the requested files plus every relative
|
|
2010
|
+
// stylesheet they import inside the project, each read once, with the
|
|
2011
|
+
// resolved style imports of every file.
|
|
2012
|
+
async function collectAnalyzedFiles(root, paths) {
|
|
1948
2013
|
const files = await collectFiles(root, paths);
|
|
1949
|
-
const diagnosticDecisions = new Map();
|
|
1950
2014
|
const contents = new Map(
|
|
1951
2015
|
await Promise.all(
|
|
1952
2016
|
files.map(async (file) => [file, await readFile(file, 'utf8')]),
|
|
@@ -1977,6 +2041,25 @@ export async function analyzeUiProject({
|
|
|
1977
2041
|
const imports = new Map(
|
|
1978
2042
|
files.map((file) => [file, relativeStyleImports(file, contents.get(file))]),
|
|
1979
2043
|
);
|
|
2044
|
+
return { files, contents, imports };
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
// Phase 2 (profile contexts): one application-UI profile plus catalog facts
|
|
2048
|
+
// per directory that holds an analyzed file, mapped back to each file. The
|
|
2049
|
+
// per-directory promise map is returned as well, because the report lists
|
|
2050
|
+
// every profile file and profile diagnostic that resolution produced.
|
|
2051
|
+
async function loadProfileContexts({
|
|
2052
|
+
files,
|
|
2053
|
+
contents,
|
|
2054
|
+
imports,
|
|
2055
|
+
root,
|
|
2056
|
+
workspaceRoot,
|
|
2057
|
+
ownership,
|
|
2058
|
+
implicitComponentOwnership,
|
|
2059
|
+
ownershipGroups,
|
|
2060
|
+
packageProfile,
|
|
2061
|
+
knownRules,
|
|
2062
|
+
}) {
|
|
1980
2063
|
const implicitEntries =
|
|
1981
2064
|
ownership === 'component' && implicitComponentOwnership
|
|
1982
2065
|
? await implicitOwnershipEntries(files, imports, root)
|
|
@@ -2060,10 +2143,15 @@ export async function analyzeUiProject({
|
|
|
2060
2143
|
),
|
|
2061
2144
|
);
|
|
2062
2145
|
if (!files.length) await loadContext(root);
|
|
2063
|
-
|
|
2064
|
-
|
|
2146
|
+
return { contexts, profileContexts };
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
// Phase 3 (package ownership): a stylesheet or source file belongs to the
|
|
2150
|
+
// package whose manifest is nearest it; entries of every other catalog
|
|
2151
|
+
// package are foreign to it. `packageOf` resolves (and caches) that package
|
|
2152
|
+
// for a directory; `foreignTo` builds a file's per-entry foreignness test.
|
|
2153
|
+
function createPackageOwnership({ root, contents, imports, ownership }) {
|
|
2065
2154
|
const packages = new Map();
|
|
2066
|
-
const compilerOptions = new Map();
|
|
2067
2155
|
const packageOf = async (directory) => {
|
|
2068
2156
|
if (!packages.has(directory))
|
|
2069
2157
|
packages.set(
|
|
@@ -2160,35 +2248,13 @@ export async function analyzeUiProject({
|
|
|
2160
2248
|
return !ownedSources?.includes(source);
|
|
2161
2249
|
};
|
|
2162
2250
|
};
|
|
2251
|
+
return { packageOf, foreignTo };
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
// Phase 4 (CSS facts): the selector and declaration facts of every analyzed
|
|
2255
|
+
// stylesheet, gathered without reporting so the source pass can consult them.
|
|
2256
|
+
async function collectStyleFacts({ files, contents, contexts, adoption }) {
|
|
2163
2257
|
const styleFacts = new Map();
|
|
2164
|
-
const recordDiagnostics = (items, context) => {
|
|
2165
|
-
for (const item of items) {
|
|
2166
|
-
const key = JSON.stringify([
|
|
2167
|
-
item.ruleId,
|
|
2168
|
-
item.location,
|
|
2169
|
-
item.message,
|
|
2170
|
-
item.evidence,
|
|
2171
|
-
item.chain,
|
|
2172
|
-
]);
|
|
2173
|
-
const decision = diagnosticDecisions.get(key) ?? {
|
|
2174
|
-
item,
|
|
2175
|
-
active: false,
|
|
2176
|
-
suppressed: false,
|
|
2177
|
-
activeConsumers: new Set(),
|
|
2178
|
-
suppressedConsumers: new Set(),
|
|
2179
|
-
};
|
|
2180
|
-
const consumer =
|
|
2181
|
-
relative(root, context.startDirectory).replaceAll('\\', '/') || '.';
|
|
2182
|
-
if (isSuppressed(item, context.profileResult.profile, workspaceRoot)) {
|
|
2183
|
-
decision.suppressed = true;
|
|
2184
|
-
decision.suppressedConsumers.add(consumer);
|
|
2185
|
-
} else {
|
|
2186
|
-
decision.active = true;
|
|
2187
|
-
decision.activeConsumers.add(consumer);
|
|
2188
|
-
}
|
|
2189
|
-
diagnosticDecisions.set(key, decision);
|
|
2190
|
-
}
|
|
2191
|
-
};
|
|
2192
2258
|
for (const file of files.filter((item) => item.endsWith('.css'))) {
|
|
2193
2259
|
const context = contexts.get(file);
|
|
2194
2260
|
const fileFacts = new Map();
|
|
@@ -2202,12 +2268,15 @@ export async function analyzeUiProject({
|
|
|
2202
2268
|
);
|
|
2203
2269
|
styleFacts.set(file, fileFacts);
|
|
2204
2270
|
}
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2271
|
+
return styleFacts;
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
// Phase 5 (co-loading): KUI-L018 accepts an on-loud from another stylesheet
|
|
2275
|
+
// the same entry loads: every stylesheet reachable from one file (a source
|
|
2276
|
+
// module's CSS imports, or a stylesheet with its @imports) is loaded together.
|
|
2277
|
+
// Returns a lookup of the on-loud declarations a stylesheet's co-loaded
|
|
2278
|
+
// siblings contribute.
|
|
2279
|
+
function coLoadedOnLoudDeclarations({ files, contents, imports, styleFacts }) {
|
|
2211
2280
|
const onLoudByStyle = new Map();
|
|
2212
2281
|
for (const style of styleFacts.keys()) {
|
|
2213
2282
|
let parsed;
|
|
@@ -2233,10 +2302,71 @@ export async function analyzeUiProject({
|
|
|
2233
2302
|
for (const sibling of loaded)
|
|
2234
2303
|
if (sibling !== style) coLoadedStyles.get(style).add(sibling);
|
|
2235
2304
|
}
|
|
2236
|
-
|
|
2305
|
+
return (style) =>
|
|
2237
2306
|
[...coLoadedStyles.get(style)]
|
|
2238
2307
|
.sort()
|
|
2239
2308
|
.flatMap((sibling) => onLoudByStyle.get(sibling) ?? []);
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
// Phase 6 (diagnostic decisions): record each diagnostic once per consumer
|
|
2312
|
+
// context as active or suppressed there, so a finding two consumers share
|
|
2313
|
+
// keeps one entry that names both.
|
|
2314
|
+
function recordDiagnosticDecisions(
|
|
2315
|
+
diagnosticDecisions,
|
|
2316
|
+
items,
|
|
2317
|
+
context,
|
|
2318
|
+
root,
|
|
2319
|
+
workspaceRoot,
|
|
2320
|
+
) {
|
|
2321
|
+
for (const item of items) {
|
|
2322
|
+
const key = JSON.stringify([
|
|
2323
|
+
item.ruleId,
|
|
2324
|
+
item.location,
|
|
2325
|
+
item.message,
|
|
2326
|
+
item.evidence,
|
|
2327
|
+
item.chain,
|
|
2328
|
+
]);
|
|
2329
|
+
const decision = diagnosticDecisions.get(key) ?? {
|
|
2330
|
+
item,
|
|
2331
|
+
active: false,
|
|
2332
|
+
suppressed: false,
|
|
2333
|
+
activeConsumers: new Set(),
|
|
2334
|
+
suppressedConsumers: new Set(),
|
|
2335
|
+
};
|
|
2336
|
+
const consumer =
|
|
2337
|
+
relative(root, context.startDirectory).replaceAll('\\', '/') || '.';
|
|
2338
|
+
if (isSuppressed(item, context.profileResult.profile, workspaceRoot)) {
|
|
2339
|
+
decision.suppressed = true;
|
|
2340
|
+
decision.suppressedConsumers.add(consumer);
|
|
2341
|
+
} else {
|
|
2342
|
+
decision.active = true;
|
|
2343
|
+
decision.activeConsumers.add(consumer);
|
|
2344
|
+
}
|
|
2345
|
+
diagnosticDecisions.set(key, decision);
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
// Phase 6 (diagnostic decisions, source pass): inspect every source module
|
|
2350
|
+
// against its own profile context, recording its diagnostics and noting
|
|
2351
|
+
// which contexts consume each stylesheet it reaches.
|
|
2352
|
+
async function inspectSourceModules({
|
|
2353
|
+
files,
|
|
2354
|
+
contents,
|
|
2355
|
+
imports,
|
|
2356
|
+
contexts,
|
|
2357
|
+
styleFacts,
|
|
2358
|
+
packageOf,
|
|
2359
|
+
foreignTo,
|
|
2360
|
+
compilerOptions,
|
|
2361
|
+
diagnosticDecisions,
|
|
2362
|
+
root,
|
|
2363
|
+
workspaceRoot,
|
|
2364
|
+
adoption,
|
|
2365
|
+
ownership,
|
|
2366
|
+
}) {
|
|
2367
|
+
const styleConsumers = new Map(
|
|
2368
|
+
[...styleFacts.keys()].map((file) => [file, new Set()]),
|
|
2369
|
+
);
|
|
2240
2370
|
for (const file of files.filter((item) =>
|
|
2241
2371
|
sourceExtensions.has(extname(item)),
|
|
2242
2372
|
)) {
|
|
@@ -2257,8 +2387,36 @@ export async function analyzeUiProject({
|
|
|
2257
2387
|
compilerOptionsFor(file, root, compilerOptions),
|
|
2258
2388
|
ownership === 'component',
|
|
2259
2389
|
);
|
|
2260
|
-
|
|
2390
|
+
recordDiagnosticDecisions(
|
|
2391
|
+
diagnosticDecisions,
|
|
2392
|
+
fileDiagnostics,
|
|
2393
|
+
context,
|
|
2394
|
+
root,
|
|
2395
|
+
workspaceRoot,
|
|
2396
|
+
);
|
|
2261
2397
|
}
|
|
2398
|
+
return styleConsumers;
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
// Phase 6 (diagnostic decisions, stylesheet pass): inspect every stylesheet
|
|
2402
|
+
// once per context that consumes it (or its own context when nothing does),
|
|
2403
|
+
// with the co-loaded on-louds, package ownership, and Web Awesome facts that
|
|
2404
|
+
// the stylesheet rules consult.
|
|
2405
|
+
async function inspectStylesheets({
|
|
2406
|
+
contents,
|
|
2407
|
+
contexts,
|
|
2408
|
+
styleConsumers,
|
|
2409
|
+
packageOf,
|
|
2410
|
+
foreignTo,
|
|
2411
|
+
siblingOnLoud,
|
|
2412
|
+
compilerOptions,
|
|
2413
|
+
diagnosticDecisions,
|
|
2414
|
+
root,
|
|
2415
|
+
workspaceRoot,
|
|
2416
|
+
adoption,
|
|
2417
|
+
ownership,
|
|
2418
|
+
ownershipContext,
|
|
2419
|
+
}) {
|
|
2262
2420
|
for (const [file, consumers] of styleConsumers) {
|
|
2263
2421
|
const applicableContexts = consumers.size
|
|
2264
2422
|
? consumers
|
|
@@ -2293,10 +2451,21 @@ export async function analyzeUiProject({
|
|
|
2293
2451
|
foundationReads: await foundationWebAwesomeReads(),
|
|
2294
2452
|
},
|
|
2295
2453
|
);
|
|
2296
|
-
|
|
2454
|
+
recordDiagnosticDecisions(
|
|
2455
|
+
diagnosticDecisions,
|
|
2456
|
+
fileDiagnostics,
|
|
2457
|
+
context,
|
|
2458
|
+
root,
|
|
2459
|
+
workspaceRoot,
|
|
2460
|
+
);
|
|
2297
2461
|
}
|
|
2298
2462
|
}
|
|
2463
|
+
}
|
|
2299
2464
|
|
|
2465
|
+
// Phase 7 (reporting): the active diagnostics in file, line, rule order —
|
|
2466
|
+
// each naming its consumers when they disagree — plus the count of findings
|
|
2467
|
+
// every consumer suppressed.
|
|
2468
|
+
function resolveDiagnosticDecisions(diagnosticDecisions) {
|
|
2300
2469
|
const active = [...diagnosticDecisions.values()]
|
|
2301
2470
|
.filter((decision) => decision.active)
|
|
2302
2471
|
.map((decision) => {
|
|
@@ -2325,6 +2494,19 @@ export async function analyzeUiProject({
|
|
|
2325
2494
|
a.location.line - b.location.line ||
|
|
2326
2495
|
a.ruleId.localeCompare(b.ruleId),
|
|
2327
2496
|
);
|
|
2497
|
+
return { active, suppressed };
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
// Phase 7 (reporting): the portable report — project-relative paths, the
|
|
2501
|
+
// profile files and profile diagnostics behind every context, the active
|
|
2502
|
+
// diagnostics, and the summary counts.
|
|
2503
|
+
async function buildAnalysisReport({
|
|
2504
|
+
root,
|
|
2505
|
+
files,
|
|
2506
|
+
profileContexts,
|
|
2507
|
+
active,
|
|
2508
|
+
suppressed,
|
|
2509
|
+
}) {
|
|
2328
2510
|
const portablePath = (file) => {
|
|
2329
2511
|
if (!file || !isAbsolute(file)) return file;
|
|
2330
2512
|
const path = relative(root, file).replaceAll('\\', '/');
|
|
@@ -2393,6 +2575,97 @@ export async function analyzeUiProject({
|
|
|
2393
2575
|
};
|
|
2394
2576
|
}
|
|
2395
2577
|
|
|
2578
|
+
export async function analyzeUiProject({
|
|
2579
|
+
root: requestedRoot = process.cwd(),
|
|
2580
|
+
workspaceRoot: requestedWorkspaceRoot = requestedRoot,
|
|
2581
|
+
paths,
|
|
2582
|
+
knownRules = [],
|
|
2583
|
+
adoption = false,
|
|
2584
|
+
ownership = 'package',
|
|
2585
|
+
ownershipContext = 'subject',
|
|
2586
|
+
implicitComponentOwnership = false,
|
|
2587
|
+
ownershipGroups = [],
|
|
2588
|
+
profile: packageProfile = resolve(
|
|
2589
|
+
import.meta.dirname,
|
|
2590
|
+
'../ai/application-ui-profile.defaults.json',
|
|
2591
|
+
),
|
|
2592
|
+
} = {}) {
|
|
2593
|
+
const root = resolve(requestedRoot);
|
|
2594
|
+
const workspaceRoot = resolve(requestedWorkspaceRoot);
|
|
2595
|
+
const { files, contents, imports } = await collectAnalyzedFiles(root, paths);
|
|
2596
|
+
const { contexts, profileContexts } = await loadProfileContexts({
|
|
2597
|
+
files,
|
|
2598
|
+
contents,
|
|
2599
|
+
imports,
|
|
2600
|
+
root,
|
|
2601
|
+
workspaceRoot,
|
|
2602
|
+
ownership,
|
|
2603
|
+
implicitComponentOwnership,
|
|
2604
|
+
ownershipGroups,
|
|
2605
|
+
packageProfile,
|
|
2606
|
+
knownRules,
|
|
2607
|
+
});
|
|
2608
|
+
const { packageOf, foreignTo } = createPackageOwnership({
|
|
2609
|
+
root,
|
|
2610
|
+
contents,
|
|
2611
|
+
imports,
|
|
2612
|
+
ownership,
|
|
2613
|
+
});
|
|
2614
|
+
const styleFacts = await collectStyleFacts({
|
|
2615
|
+
files,
|
|
2616
|
+
contents,
|
|
2617
|
+
contexts,
|
|
2618
|
+
adoption,
|
|
2619
|
+
});
|
|
2620
|
+
const siblingOnLoud = coLoadedOnLoudDeclarations({
|
|
2621
|
+
files,
|
|
2622
|
+
contents,
|
|
2623
|
+
imports,
|
|
2624
|
+
styleFacts,
|
|
2625
|
+
});
|
|
2626
|
+
const diagnosticDecisions = new Map();
|
|
2627
|
+
const compilerOptions = new Map();
|
|
2628
|
+
const styleConsumers = await inspectSourceModules({
|
|
2629
|
+
files,
|
|
2630
|
+
contents,
|
|
2631
|
+
imports,
|
|
2632
|
+
contexts,
|
|
2633
|
+
styleFacts,
|
|
2634
|
+
packageOf,
|
|
2635
|
+
foreignTo,
|
|
2636
|
+
compilerOptions,
|
|
2637
|
+
diagnosticDecisions,
|
|
2638
|
+
root,
|
|
2639
|
+
workspaceRoot,
|
|
2640
|
+
adoption,
|
|
2641
|
+
ownership,
|
|
2642
|
+
});
|
|
2643
|
+
await inspectStylesheets({
|
|
2644
|
+
contents,
|
|
2645
|
+
contexts,
|
|
2646
|
+
styleConsumers,
|
|
2647
|
+
packageOf,
|
|
2648
|
+
foreignTo,
|
|
2649
|
+
siblingOnLoud,
|
|
2650
|
+
compilerOptions,
|
|
2651
|
+
diagnosticDecisions,
|
|
2652
|
+
root,
|
|
2653
|
+
workspaceRoot,
|
|
2654
|
+
adoption,
|
|
2655
|
+
ownership,
|
|
2656
|
+
ownershipContext,
|
|
2657
|
+
});
|
|
2658
|
+
const { active, suppressed } =
|
|
2659
|
+
resolveDiagnosticDecisions(diagnosticDecisions);
|
|
2660
|
+
return buildAnalysisReport({
|
|
2661
|
+
root,
|
|
2662
|
+
files,
|
|
2663
|
+
profileContexts,
|
|
2664
|
+
active,
|
|
2665
|
+
suppressed,
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2396
2669
|
export function formatUiAnalysisText(report) {
|
|
2397
2670
|
const lines = report.profile.diagnostics.map(
|
|
2398
2671
|
(item) =>
|
|
@@ -4,43 +4,80 @@ import { readFile, writeFile } from 'node:fs/promises';
|
|
|
4
4
|
import { resolve } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
|
|
7
|
+
import {
|
|
8
|
+
CLI_USAGE_EXIT,
|
|
9
|
+
isMainModule,
|
|
10
|
+
parseCliArguments,
|
|
11
|
+
readJsonFile,
|
|
12
|
+
wantsHelp,
|
|
13
|
+
} from './scripts/lib/cli-args.mjs';
|
|
7
14
|
import { projectConsumerCatalog } from './catalog-projection.mjs';
|
|
8
15
|
|
|
9
|
-
const usage =
|
|
10
|
-
|
|
16
|
+
const usage = `Usage: kerf-catalog-demo --extension <catalog.json> --out <catalog.generated.ts> --repo-base <blob-url> (--write | --check) [options]
|
|
17
|
+
|
|
18
|
+
Options:
|
|
19
|
+
--extension <path> Consumer catalog extension JSON (required)
|
|
20
|
+
--out <path> Generated TypeScript module (required)
|
|
21
|
+
--repo-base <url> HTTP(S) blob URL for source links (required)
|
|
22
|
+
--write Write the generated module
|
|
23
|
+
--check Fail when the generated module is stale
|
|
24
|
+
--kerf-catalog <path> Kerf catalog (default: the installed one)
|
|
25
|
+
--category <name> Catalog category for consumer rows
|
|
26
|
+
--source-template <path> Component source path template ({id})
|
|
27
|
+
--demo-template <path> Demo path template ({id})
|
|
28
|
+
--documentation-template <path> Documentation path template ({id})
|
|
29
|
+
--design-template <path> Design template path template ({id})
|
|
30
|
+
-h, --help Show this help
|
|
31
|
+
|
|
32
|
+
Exit codes: 0 in sync or written, 1 stale, 2 usage or input error.`;
|
|
33
|
+
|
|
34
|
+
/** A usage or input error: reported with exit status 2, a stale module with 1. */
|
|
35
|
+
class UsageError extends Error {}
|
|
36
|
+
|
|
37
|
+
/** Reads a JSON input; a missing or malformed file is an input error (exit 2). */
|
|
38
|
+
function readInput(path, label = path) {
|
|
39
|
+
try {
|
|
40
|
+
return readJsonFile(path, label);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw new UsageError(error.message);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
11
45
|
|
|
12
46
|
function parseArgs(argv) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} else if (values.has(arg)) {
|
|
32
|
-
const value = argv[++index];
|
|
33
|
-
if (!value || value.startsWith('--'))
|
|
34
|
-
throw new Error(`${arg} needs a value`);
|
|
35
|
-
options[values.get(arg)] = value;
|
|
36
|
-
} else {
|
|
37
|
-
throw new Error(`Unknown option ${arg}`);
|
|
38
|
-
}
|
|
47
|
+
let options;
|
|
48
|
+
try {
|
|
49
|
+
({ options } = parseCliArguments(argv, {
|
|
50
|
+
values: {
|
|
51
|
+
'--extension': 'extension',
|
|
52
|
+
'--out': 'out',
|
|
53
|
+
'--repo-base': 'repoBase',
|
|
54
|
+
'--kerf-catalog': 'kerfCatalog',
|
|
55
|
+
'--category': 'category',
|
|
56
|
+
'--source-template': 'sourceTemplate',
|
|
57
|
+
'--demo-template': 'demoTemplate',
|
|
58
|
+
'--documentation-template': 'documentationTemplate',
|
|
59
|
+
'--design-template': 'designTemplate',
|
|
60
|
+
},
|
|
61
|
+
flags: { '--write': 'write', '--check': 'check' },
|
|
62
|
+
}));
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw new UsageError(error.message);
|
|
39
65
|
}
|
|
40
|
-
if (
|
|
41
|
-
throw new
|
|
66
|
+
if (options.write && options.check)
|
|
67
|
+
throw new UsageError('Choose exactly one of --write or --check');
|
|
68
|
+
options.mode = options.write ? '--write' : options.check ? '--check' : null;
|
|
69
|
+
const missing = [
|
|
70
|
+
['--extension', options.extension],
|
|
71
|
+
['--out', options.out],
|
|
72
|
+
['--repo-base', options.repoBase],
|
|
73
|
+
]
|
|
74
|
+
.filter(([, value]) => !value)
|
|
75
|
+
.map(([flag]) => flag);
|
|
76
|
+
if (!options.mode) missing.push('--write or --check');
|
|
77
|
+
if (missing.length)
|
|
78
|
+
throw new UsageError(`missing ${missing.join(', ')}\n\n${usage}`);
|
|
42
79
|
if (!/^https?:\/\//.test(options.repoBase))
|
|
43
|
-
throw new
|
|
80
|
+
throw new UsageError('--repo-base must be an HTTP(S) URL');
|
|
44
81
|
return options;
|
|
45
82
|
}
|
|
46
83
|
|
|
@@ -55,17 +92,12 @@ export function renderConsumerCatalog(rows, repoBase) {
|
|
|
55
92
|
|
|
56
93
|
export async function runCatalogProjection(argv) {
|
|
57
94
|
const options = parseArgs(argv);
|
|
58
|
-
const extension =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
? resolve(options.kerfCatalog)
|
|
65
|
-
: new URL('./ai/component-catalog.json', import.meta.url),
|
|
66
|
-
'utf8',
|
|
67
|
-
),
|
|
68
|
-
);
|
|
95
|
+
const extension = readInput(resolve(options.extension), options.extension);
|
|
96
|
+
const kerfCatalog = options.kerfCatalog
|
|
97
|
+
? readInput(resolve(options.kerfCatalog), options.kerfCatalog)
|
|
98
|
+
: readInput(
|
|
99
|
+
fileURLToPath(new URL('./ai/component-catalog.json', import.meta.url)),
|
|
100
|
+
);
|
|
69
101
|
const rows = projectConsumerCatalog(extension, kerfCatalog, options);
|
|
70
102
|
const output = renderConsumerCatalog(rows, options.repoBase);
|
|
71
103
|
const outputPath = resolve(options.out);
|
|
@@ -85,12 +117,16 @@ export async function runCatalogProjection(argv) {
|
|
|
85
117
|
}
|
|
86
118
|
}
|
|
87
119
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
process.
|
|
94
|
-
|
|
95
|
-
|
|
120
|
+
// npm runs bins through symlinks (node_modules/.bin); isMainModule compares
|
|
121
|
+
// real paths.
|
|
122
|
+
if (isMainModule(import.meta.url)) {
|
|
123
|
+
const argv = process.argv.slice(2);
|
|
124
|
+
if (wantsHelp(argv)) {
|
|
125
|
+
process.stdout.write(`${usage}\n`);
|
|
126
|
+
} else {
|
|
127
|
+
runCatalogProjection(argv).catch((error) => {
|
|
128
|
+
process.stderr.write(`kerf-catalog-demo: ${error.message}\n`);
|
|
129
|
+
process.exitCode = error instanceof UsageError ? CLI_USAGE_EXIT : 1;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
96
132
|
}
|
package/dist/anchored-surface.js
CHANGED