@kerfjs/ui 5.0.0-beta.125 → 5.0.0-beta.127
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 +265 -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 +251 -298
- 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 +12 -7
- 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-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-NR3ZO4LK.js → chunk-7U65KLDL.js} +1 -1
- package/dist/chunk-7U65KLDL.js.map +1 -0
- package/dist/chunk-BMOZSNDU.js +133 -0
- package/dist/chunk-BMOZSNDU.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-GHV36C6I.js +94 -0
- package/dist/chunk-GHV36C6I.js.map +1 -0
- package/dist/{chunk-BCO673YW.js → chunk-GQUDCWOD.js} +10 -4
- package/dist/chunk-GQUDCWOD.js.map +1 -0
- package/dist/chunk-HD7ZLISK.js +808 -0
- package/dist/chunk-HD7ZLISK.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-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 +3 -3
- package/dist/column-explorer.js +16 -138
- 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 +11651 -7052
- 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 +10 -3
- package/dist/styles/components/surfaces/surface-scaffold/surface-scaffold.css +291 -4
- package/dist/styles/editor/editor.css +78 -0
- package/dist/styles/editor-frame.css +10 -3
- 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 +291 -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 +155 -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 +4 -4
- package/dist/tree-list.js +2 -2
- package/dist/{tree-rows-eHnnGLGM.d.ts → tree-rows-Bms5QJvG.d.ts} +3 -0
- 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-column-explorer.js +1 -92
- package/dist/wire-column-explorer.js.map +1 -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 +314 -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 +6 -2
- package/props/cli.mjs +47 -21
- package/scripts/lib/cli-args.mjs +98 -0
- package/ux-demo/recipes/app-shell.tsx +48 -141
- package/ux-demo/recipes/collapsible-sidebar.tsx +43 -169
- package/ux-demo/recipes/compact-toolbar.tsx +22 -114
- package/ux-demo/recipes/composer-form.tsx +14 -104
- package/ux-demo/recipes/list-detail-dialog.tsx +38 -84
- package/ux-demo/recipes/list-workspace-states.tsx +29 -152
- package/ux-demo/recipes/loading-inspector.tsx +30 -174
- package/ux-demo/recipes/media-detail.tsx +29 -146
- package/ux-demo/recipes/navigation-sidebar.tsx +24 -113
- package/ux-demo/recipes/navigation-stack.tsx +7 -43
- package/ux-demo/recipes/workspace-header.tsx +2 -66
- 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 +155 -56
- 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-NR3ZO4LK.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/view/catalog.mjs
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// The catalog side of @kerfjs/ui/view: indexes component-props and
|
|
2
|
+
// composition documents (createViewCatalog), resolves prop types, and maps
|
|
3
|
+
// field zones (a content field inside a prop value) to the prop path they
|
|
4
|
+
// fill. Shared by the validator, the generator, and the interpreter.
|
|
5
|
+
|
|
6
|
+
export const isObject = (value) =>
|
|
7
|
+
value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
8
|
+
export const keyOf = (type) => type.split('#')[0];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Indexes component-props and composition documents for validation. Each
|
|
12
|
+
* component keeps the `definitions` table of the document that declared it,
|
|
13
|
+
* so two packages' same-named types never collide.
|
|
14
|
+
*/
|
|
15
|
+
export function createViewCatalog({ props = [], composition = [] }) {
|
|
16
|
+
const components = new Map();
|
|
17
|
+
for (const document of props) {
|
|
18
|
+
for (const component of document.components ?? []) {
|
|
19
|
+
components.set(component.key, {
|
|
20
|
+
component,
|
|
21
|
+
definitions: document.definitions ?? {},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const entries = new Map();
|
|
26
|
+
// A config type another component renders as an entry (KF-THTR71), keyed
|
|
27
|
+
// `package:TypeName` since type names are only unique within a package.
|
|
28
|
+
const configParents = new Map();
|
|
29
|
+
for (const document of composition) {
|
|
30
|
+
for (const entry of document.entries ?? []) {
|
|
31
|
+
entries.set(entry.key, entry);
|
|
32
|
+
for (const name of entry.configTypes ?? [])
|
|
33
|
+
configParents.set(
|
|
34
|
+
`${keyOf(entry.key).split(':')[0]}:${name}`,
|
|
35
|
+
entry.key,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return { components, entries, configParents };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function resolveType(type, definitions) {
|
|
43
|
+
let current = type;
|
|
44
|
+
for (let hops = 0; current?.kind === 'ref' && hops < 32; hops += 1) {
|
|
45
|
+
current = definitions[current.ref];
|
|
46
|
+
}
|
|
47
|
+
return current ?? { kind: 'unknown' };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const propsOf = (type, definitions) =>
|
|
51
|
+
resolveType(type, definitions).props;
|
|
52
|
+
|
|
53
|
+
/** A type, or each member of a union of it (unions of unions flattened). */
|
|
54
|
+
function membersOf(type, definitions) {
|
|
55
|
+
const resolved = resolveType(type, definitions);
|
|
56
|
+
return resolved.kind === 'union'
|
|
57
|
+
? resolved.members.flatMap((member) => membersOf(member, definitions))
|
|
58
|
+
: [resolved];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const INDEX = /^\d+$/;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A zone key that names a content field inside a prop value (KF-PD6QC5:
|
|
65
|
+
* field zones): the prop, then field names and list indexes, dot-separated
|
|
66
|
+
* (`leftRail.content`, `mainToolbar.title`, `views.0.content`). Walks the
|
|
67
|
+
* prop's type through refs, union members, objects (never a field the type
|
|
68
|
+
* forbids), and lists, and ends at rendered content. Returns the prop, the
|
|
69
|
+
* path inside its value, and whether the field takes text; undefined for any
|
|
70
|
+
* other key.
|
|
71
|
+
*/
|
|
72
|
+
export function fieldZoneOf(component, definitions, key) {
|
|
73
|
+
const walked = walkField(component, definitions, key);
|
|
74
|
+
if (!walked) return undefined;
|
|
75
|
+
const content = walked.types
|
|
76
|
+
.flatMap((type) => membersOf(type, definitions))
|
|
77
|
+
.find((type) => type.kind === 'content');
|
|
78
|
+
return content
|
|
79
|
+
? {
|
|
80
|
+
prop: walked.name,
|
|
81
|
+
path: walked.path.map((step) =>
|
|
82
|
+
INDEX.test(step) ? Number(step) : step,
|
|
83
|
+
),
|
|
84
|
+
text: content.acceptsText === true,
|
|
85
|
+
}
|
|
86
|
+
: undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The types a field zone key reaches in a component's prop value, with the
|
|
91
|
+
* named types (`ref`s) of the value that holds that field: a NavStack view's
|
|
92
|
+
* `views.0.toolbar.leading` is held by a `NavStackViewToolbar`.
|
|
93
|
+
*/
|
|
94
|
+
function walkField(component, definitions, key) {
|
|
95
|
+
if (typeof key !== 'string' || !key.includes('.')) return undefined;
|
|
96
|
+
const [name, ...path] = key.split('.');
|
|
97
|
+
const prop = component.props.find((item) => item.name === name);
|
|
98
|
+
if (!prop || prop.slot || prop.zone) return undefined;
|
|
99
|
+
let types = [prop.type];
|
|
100
|
+
let holders = [];
|
|
101
|
+
for (const step of path) {
|
|
102
|
+
holders = types.flatMap((type) => (type.kind === 'ref' ? [type.ref] : []));
|
|
103
|
+
const next = [];
|
|
104
|
+
for (const type of types.flatMap((item) => membersOf(item, definitions))) {
|
|
105
|
+
if (INDEX.test(step)) {
|
|
106
|
+
if (type.kind === 'array') next.push(type.items);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const field =
|
|
110
|
+
type.kind === 'object'
|
|
111
|
+
? type.props?.find((item) => item.name === step)
|
|
112
|
+
: undefined;
|
|
113
|
+
if (field && resolveType(field.type, definitions).kind !== 'never')
|
|
114
|
+
next.push(field.type);
|
|
115
|
+
}
|
|
116
|
+
if (!next.length) return undefined;
|
|
117
|
+
types = next;
|
|
118
|
+
}
|
|
119
|
+
return { name, path, types, holders };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The component a field zone's children are placed in (KF-THTR71): a
|
|
124
|
+
* content field inside a value another component renders, such as a
|
|
125
|
+
* NavStack view's toolbar config, which renders as a Toolbar. A config type
|
|
126
|
+
* may name one field (`ListDetailDialogList.toolbar`) when only that field
|
|
127
|
+
* renders in the component. Undefined when neither the field nor its holder
|
|
128
|
+
* is cataloged.
|
|
129
|
+
*/
|
|
130
|
+
export function fieldParent(ctx, node, component, definitions, key) {
|
|
131
|
+
const pkg = keyOf(node.type).split(':')[0];
|
|
132
|
+
const walked = walkField(component, definitions, key);
|
|
133
|
+
const field = walked?.path.at(-1);
|
|
134
|
+
for (const holder of walked?.holders ?? []) {
|
|
135
|
+
// KF-WBH5P2: one field of a holder that renders only that field in
|
|
136
|
+
// another component (`ListDetailDialogList.toolbar` in a Toolbar)
|
|
137
|
+
// names it alone; the whole holder's mapping is the fallback.
|
|
138
|
+
const parent =
|
|
139
|
+
ctx.catalog.configParents?.get(`${pkg}:${holder}.${field}`) ??
|
|
140
|
+
ctx.catalog.configParents?.get(`${pkg}:${holder}`);
|
|
141
|
+
if (parent) return parent;
|
|
142
|
+
}
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Where a field zone's children go in a prop value while it is checked,
|
|
148
|
+
* interpreted, or generated: a placeholder no document can spell, so it
|
|
149
|
+
* never reads as a literal of the document's own.
|
|
150
|
+
*/
|
|
151
|
+
export class ZoneFill {
|
|
152
|
+
constructor(key, children) {
|
|
153
|
+
this.key = key;
|
|
154
|
+
this.children = children;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* A prop value as a problem quotes it: JSON, with each field zone written as
|
|
160
|
+
* `<zone key>` rather than its nodes (KF-20GMVX), so the message stays short
|
|
161
|
+
* and does not change when something inside the zone does.
|
|
162
|
+
*/
|
|
163
|
+
export function quoteValue(value) {
|
|
164
|
+
return JSON.stringify(value, (_key, item) =>
|
|
165
|
+
item instanceof ZoneFill ? `<zone ${item.key}>` : item,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** `value` with `fill` at `path`, copying each object and list on the way. */
|
|
170
|
+
function withAt(value, path, fill) {
|
|
171
|
+
if (!path.length) return fill;
|
|
172
|
+
const [step, ...rest] = path;
|
|
173
|
+
if (typeof step === 'number') {
|
|
174
|
+
const list = Array.isArray(value) ? [...value] : [];
|
|
175
|
+
list[step] = withAt(list[step], rest, fill);
|
|
176
|
+
return list;
|
|
177
|
+
}
|
|
178
|
+
const object = isObject(value) ? { ...value } : {};
|
|
179
|
+
object[step] = withAt(object[step], rest, fill);
|
|
180
|
+
return object;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Whether a value is a binding (`$param`, `$bind`, …) rather than a literal. */
|
|
184
|
+
export const isBinding = (value) =>
|
|
185
|
+
isObject(value) && Object.keys(value).some((key) => key.startsWith('$'));
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* `props` with each filled field zone's placeholder (a `ZoneFill`) at its
|
|
189
|
+
* path, so the zone fills that content field (KF-PD6QC5). A prop held by a
|
|
190
|
+
* binding is left alone; validation reports the clash.
|
|
191
|
+
*/
|
|
192
|
+
export function withFieldZones(props, zones, component, definitions) {
|
|
193
|
+
let merged = props;
|
|
194
|
+
for (const key of Object.keys(zones)) {
|
|
195
|
+
const field = fieldZoneOf(component, definitions, key);
|
|
196
|
+
if (!field || !zones[key].length || isBinding(merged[field.prop])) continue;
|
|
197
|
+
merged = {
|
|
198
|
+
...merged,
|
|
199
|
+
[field.prop]: withAt(
|
|
200
|
+
merged[field.prop],
|
|
201
|
+
field.path,
|
|
202
|
+
new ZoneFill(key, zones[key]),
|
|
203
|
+
),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
return merged;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* How a component carries application `data-*` attributes (the node marker
|
|
211
|
+
* and a row key): its `rootAttributes` prop, a Web Awesome element's own
|
|
212
|
+
* attributes, or nothing. A generated `dataChannel` field wins when present.
|
|
213
|
+
*/
|
|
214
|
+
export function channelOf(component) {
|
|
215
|
+
if (component.dataChannel) return component.dataChannel;
|
|
216
|
+
if (component.source === 'webawesome') return 'attributes';
|
|
217
|
+
return component.props.some((prop) => prop.name === 'rootAttributes')
|
|
218
|
+
? 'rootAttributes'
|
|
219
|
+
: 'none';
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** The prop a zone key fills: the composition zone's binding or the prop itself. */
|
|
223
|
+
export function zonePropOf(catalog, component, key) {
|
|
224
|
+
const entry = component.key.includes('#')
|
|
225
|
+
? undefined
|
|
226
|
+
: catalog.entries.get(component.key);
|
|
227
|
+
const zone = entry?.zones?.find((item) => item.id === key && item.jsx?.prop);
|
|
228
|
+
return zone ? zone.jsx.prop : key;
|
|
229
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// childKind: the one place that tells a view child's kind apart (KF-TZKGBZ:
|
|
2
|
+
// one shared child-kind dispatch). A child is an `$each` list, an `$if`
|
|
3
|
+
// branch, a `$slot` placement, a composed `#view` node, or a component node;
|
|
4
|
+
// every walker switches on this instead of repeating the `in` checks, so a
|
|
5
|
+
// new control-flow kind has one place to be added.
|
|
6
|
+
|
|
7
|
+
/** The kind of a view child: `each`, `if`, `slot`, `view`, or `node`. */
|
|
8
|
+
export function childKind(child) {
|
|
9
|
+
if ('$each' in child) return 'each';
|
|
10
|
+
if ('$if' in child) return 'if';
|
|
11
|
+
if ('$slot' in child) return 'slot';
|
|
12
|
+
return child.type === '#view' ? 'view' : 'node';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The child with its kind, as a value TypeScript narrows on: switching on
|
|
17
|
+
* `classifyChild(child).kind` makes `.child` the `$each`, `$if`, `$slot`, or
|
|
18
|
+
* node shape in each case.
|
|
19
|
+
*/
|
|
20
|
+
export function classifyChild(child) {
|
|
21
|
+
return { kind: childKind(child), child };
|
|
22
|
+
}
|
package/view/cli.mjs
CHANGED
|
@@ -2,15 +2,23 @@
|
|
|
2
2
|
// kerf-ui-view: generate, check, and diff read-only view modules from Kerf UI
|
|
3
3
|
// view documents (docs/26-ui-editor.md §6). An authoring step, like a
|
|
4
4
|
// formatter — never part of a consumer's build.
|
|
5
|
-
import { existsSync, readFileSync,
|
|
5
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
6
6
|
import { createRequire } from 'node:module';
|
|
7
7
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
8
8
|
import process from 'node:process';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
10
|
|
|
11
|
+
import {
|
|
12
|
+
CLI_USAGE_EXIT,
|
|
13
|
+
isMainModule,
|
|
14
|
+
parseCliArguments,
|
|
15
|
+
readJsonFile,
|
|
16
|
+
wantsHelp,
|
|
17
|
+
} from '../scripts/lib/cli-args.mjs';
|
|
11
18
|
import { contractOf, diffContracts } from './contract.mjs';
|
|
12
19
|
import { generateView, readViewHeader, viewModulePath } from './generate.mjs';
|
|
13
|
-
import { createViewCatalog
|
|
20
|
+
import { createViewCatalog } from './catalog.mjs';
|
|
21
|
+
import { validateView } from './validate.mjs';
|
|
14
22
|
|
|
15
23
|
const USAGE = `Usage: kerf-ui-view <command> <document.kui.json...> [options]
|
|
16
24
|
|
|
@@ -28,47 +36,49 @@ Options:
|
|
|
28
36
|
--props <file> an extra component-props.json (repeatable)
|
|
29
37
|
--no-profile skip catalogs .kerf-ui-profile.json declares
|
|
30
38
|
--composition <file> an extra component-composition.json (repeatable)
|
|
39
|
+
-h, --help show this help
|
|
40
|
+
|
|
41
|
+
Exit codes: 0 success, 1 invalid, stale, or hand-edited output, 2 usage or
|
|
42
|
+
input error.
|
|
31
43
|
`;
|
|
32
44
|
|
|
33
45
|
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
34
|
-
|
|
46
|
+
// Every read names its file on failure (missing, unreadable, invalid JSON).
|
|
47
|
+
const readJson = (path) => readJsonFile(path);
|
|
35
48
|
|
|
36
49
|
/** Parses argv into `{ command, documents, options }`, or throws a usage error. */
|
|
37
50
|
export function parseArguments(argv) {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (argument === '--target') {
|
|
55
|
-
options.target = next();
|
|
56
|
-
if (!['ts', 'js'].includes(options.target))
|
|
57
|
-
throw new Error('--target is ts or js');
|
|
58
|
-
} else if (argument === '--declarations-only')
|
|
59
|
-
options.declarationsOnly = true;
|
|
60
|
-
else if (argument === '--props') options.props.push(next());
|
|
61
|
-
else if (argument === '--composition') options.composition.push(next());
|
|
62
|
-
else if (argument === '--no-profile') options.profile = false;
|
|
63
|
-
else if (argument.startsWith('--'))
|
|
64
|
-
throw new Error(`unknown option ${argument}`);
|
|
65
|
-
else documents.push(argument);
|
|
66
|
-
}
|
|
51
|
+
const { options, positionals } = parseCliArguments(argv, {
|
|
52
|
+
values: {
|
|
53
|
+
'--target': 'target',
|
|
54
|
+
'--props': 'props',
|
|
55
|
+
'--composition': 'composition',
|
|
56
|
+
},
|
|
57
|
+
repeatable: ['--props', '--composition'],
|
|
58
|
+
flags: {
|
|
59
|
+
'--declarations-only': 'declarationsOnly',
|
|
60
|
+
'--no-profile': 'noProfile',
|
|
61
|
+
},
|
|
62
|
+
positionals: true,
|
|
63
|
+
});
|
|
64
|
+
const [command, ...documents] = positionals;
|
|
65
|
+
const target = options.target ?? 'ts';
|
|
66
|
+
if (!['ts', 'js'].includes(target)) throw new Error('--target is ts or js');
|
|
67
67
|
if (!['generate', 'check', 'diff'].includes(command))
|
|
68
68
|
throw new Error(`unknown command ${command ?? '(none)'}`);
|
|
69
69
|
if (documents.length === 0)
|
|
70
70
|
throw new Error('name at least one .kui.json document');
|
|
71
|
-
return {
|
|
71
|
+
return {
|
|
72
|
+
command,
|
|
73
|
+
documents,
|
|
74
|
+
options: {
|
|
75
|
+
target,
|
|
76
|
+
declarationsOnly: options.declarationsOnly === true,
|
|
77
|
+
props: options.props,
|
|
78
|
+
composition: options.composition,
|
|
79
|
+
profile: options.noProfile !== true,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
72
82
|
}
|
|
73
83
|
|
|
74
84
|
const require = createRequire(import.meta.url);
|
|
@@ -146,14 +156,19 @@ function loadCatalog(options, documentPath) {
|
|
|
146
156
|
});
|
|
147
157
|
}
|
|
148
158
|
|
|
149
|
-
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Loads composed documents: `path` is where a `#view`'s `src` points relative
|
|
161
|
+
* to the top document's folder, since each `src` resolves from the document
|
|
162
|
+
* that contains it, as each generated module imports its own children.
|
|
163
|
+
*/
|
|
164
|
+
const viewResolver = (documentPath) => (src, path) => {
|
|
165
|
+
const file = resolve(dirname(documentPath), path);
|
|
166
|
+
return existsSync(file) ? readJson(file) : undefined;
|
|
153
167
|
};
|
|
154
168
|
|
|
155
169
|
/** Runs one command; returns `{ code, output }` instead of exiting, for tests. */
|
|
156
170
|
export function run(argv) {
|
|
171
|
+
if (wantsHelp(argv)) return { code: 0, output: USAGE };
|
|
157
172
|
let parsed;
|
|
158
173
|
try {
|
|
159
174
|
parsed = parseArguments(argv);
|
|
@@ -163,99 +178,107 @@ export function run(argv) {
|
|
|
163
178
|
const { command, documents, options } = parsed;
|
|
164
179
|
const lines = [];
|
|
165
180
|
let failed = false;
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
181
|
+
try {
|
|
182
|
+
for (const documentPath of documents) {
|
|
183
|
+
const catalog = loadCatalog(options, documentPath);
|
|
184
|
+
const document = readJson(documentPath);
|
|
185
|
+
const resolveView = viewResolver(documentPath);
|
|
186
|
+
const validation = validateView(document, catalog, { resolveView });
|
|
187
|
+
if (!validation.valid) {
|
|
188
|
+
failed = true;
|
|
189
|
+
for (const item of validation.diagnostics) {
|
|
190
|
+
lines.push(
|
|
191
|
+
`${documentPath}: ${item.code} ${item.path}: ${item.message}`,
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
// Hints are advice: printed, never a failure.
|
|
197
|
+
for (const item of validation.hints)
|
|
174
198
|
lines.push(
|
|
175
|
-
`${documentPath}: ${item.code} ${item.path}: ${item.message}`,
|
|
199
|
+
`${documentPath}: hint ${item.code} ${item.path}: ${item.message}`,
|
|
176
200
|
);
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
importFrom: dirname(resolve(documentPath)),
|
|
192
|
-
});
|
|
193
|
-
const outputs = [[modulePath, generated.code]];
|
|
194
|
-
if (generated.declarations)
|
|
195
|
-
outputs.push([
|
|
196
|
-
modulePath.replace(/\.js$/, '.d.ts'),
|
|
197
|
-
generated.declarations,
|
|
198
|
-
]);
|
|
201
|
+
const modulePath = viewModulePath(documentPath, options.target);
|
|
202
|
+
const generated = generateView(document, catalog, {
|
|
203
|
+
source: basename(documentPath),
|
|
204
|
+
resolveView,
|
|
205
|
+
target: options.target,
|
|
206
|
+
declarationsOnly: options.declarationsOnly,
|
|
207
|
+
importFrom: dirname(resolve(documentPath)),
|
|
208
|
+
});
|
|
209
|
+
const outputs = [[modulePath, generated.code]];
|
|
210
|
+
if (generated.declarations)
|
|
211
|
+
outputs.push([
|
|
212
|
+
modulePath.replace(/\.js$/, '.d.ts'),
|
|
213
|
+
generated.declarations,
|
|
214
|
+
]);
|
|
199
215
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
`${modulePath}: ${changes.length ? `${changes.length} contract change(s)` : 'contract unchanged'}`,
|
|
222
|
-
);
|
|
223
|
-
for (const change of changes) {
|
|
216
|
+
if (command === 'generate') {
|
|
217
|
+
for (const [path, code] of outputs) writeFileSync(path, code);
|
|
218
|
+
lines.push(`${modulePath}: ${generated.digest}`);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
const current = existsSync(modulePath)
|
|
222
|
+
? readFileSync(modulePath, 'utf8')
|
|
223
|
+
: undefined;
|
|
224
|
+
const header =
|
|
225
|
+
current === undefined ? undefined : readViewHeader(current);
|
|
226
|
+
if (command === 'diff') {
|
|
227
|
+
const before = header?.contract ?? {
|
|
228
|
+
inputs: {},
|
|
229
|
+
actions: {},
|
|
230
|
+
slots: {},
|
|
231
|
+
refs: {},
|
|
232
|
+
};
|
|
233
|
+
const changes = diffContracts(
|
|
234
|
+
before,
|
|
235
|
+
contractOf(document, catalog, { resolveView }),
|
|
236
|
+
);
|
|
224
237
|
lines.push(
|
|
225
|
-
|
|
238
|
+
`${modulePath}: ${changes.length ? `${changes.length} contract change(s)` : 'contract unchanged'}`,
|
|
226
239
|
);
|
|
240
|
+
for (const change of changes) {
|
|
241
|
+
lines.push(
|
|
242
|
+
` ${change.breaking ? 'BREAKING' : 'compatible'} ${change.member} ${JSON.stringify(change.name)} ${change.change} (${change.detail})`,
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
for (const [path, code] of outputs) {
|
|
248
|
+
const existing =
|
|
249
|
+
path === modulePath
|
|
250
|
+
? current
|
|
251
|
+
: existsSync(path)
|
|
252
|
+
? readFileSync(path, 'utf8')
|
|
253
|
+
: undefined;
|
|
254
|
+
const existingHeader =
|
|
255
|
+
path === modulePath ? header : existing && readViewHeader(existing);
|
|
256
|
+
if (existing === undefined) {
|
|
257
|
+
failed = true;
|
|
258
|
+
lines.push(`${path}: missing; run kerf-ui-view generate`);
|
|
259
|
+
} else if (!existingHeader?.intact) {
|
|
260
|
+
failed = true;
|
|
261
|
+
lines.push(
|
|
262
|
+
`${path}: edited by hand; regenerate it instead of editing`,
|
|
263
|
+
);
|
|
264
|
+
} else if (existing !== code) {
|
|
265
|
+
failed = true;
|
|
266
|
+
lines.push(`${path}: stale; run kerf-ui-view generate`);
|
|
267
|
+
} else lines.push(`${path}: up to date`);
|
|
227
268
|
}
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
for (const [path, code] of outputs) {
|
|
231
|
-
const existing =
|
|
232
|
-
path === modulePath
|
|
233
|
-
? current
|
|
234
|
-
: existsSync(path)
|
|
235
|
-
? readFileSync(path, 'utf8')
|
|
236
|
-
: undefined;
|
|
237
|
-
const existingHeader =
|
|
238
|
-
path === modulePath ? header : existing && readViewHeader(existing);
|
|
239
|
-
if (existing === undefined) {
|
|
240
|
-
failed = true;
|
|
241
|
-
lines.push(`${path}: missing; run kerf-ui-view generate`);
|
|
242
|
-
} else if (!existingHeader?.intact) {
|
|
243
|
-
failed = true;
|
|
244
|
-
lines.push(`${path}: edited by hand; regenerate it instead of editing`);
|
|
245
|
-
} else if (existing !== code) {
|
|
246
|
-
failed = true;
|
|
247
|
-
lines.push(`${path}: stale; run kerf-ui-view generate`);
|
|
248
|
-
} else lines.push(`${path}: up to date`);
|
|
249
269
|
}
|
|
270
|
+
} catch (error) {
|
|
271
|
+
// An unreadable or malformed input file, or a failed write: report it as
|
|
272
|
+
// `kerf-ui-view: <path>: <reason>` instead of a stack trace.
|
|
273
|
+
lines.push(`kerf-ui-view: ${error.message}`);
|
|
274
|
+
return { code: CLI_USAGE_EXIT, output: `${lines.join('\n')}\n` };
|
|
250
275
|
}
|
|
251
276
|
return { code: failed ? 1 : 0, output: `${lines.join('\n')}\n` };
|
|
252
277
|
}
|
|
253
278
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
realpathSync(resolve(process.argv[1])) === fileURLToPath(import.meta.url)
|
|
258
|
-
) {
|
|
279
|
+
// npm runs bins through symlinks (node_modules/.bin); isMainModule compares
|
|
280
|
+
// real paths.
|
|
281
|
+
if (isMainModule(import.meta.url)) {
|
|
259
282
|
const result = run(process.argv.slice(2));
|
|
260
283
|
(result.code === 0 ? process.stdout : process.stderr).write(result.output);
|
|
261
284
|
process.exitCode = result.code;
|