@cratis/scene.react 4.23.0 → 4.25.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/core/coreComponentMetadata.ts +27 -0
- package/core/coreDescriptors.ts +6 -2
- package/dist/cjs/core/coreComponentMetadata.js +109 -0
- package/dist/cjs/core/coreComponentMetadata.js.map +1 -0
- package/dist/cjs/core/coreDescriptors.js +4 -1
- package/dist/cjs/core/coreDescriptors.js.map +1 -1
- package/dist/cjs/index.js +10 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/packages/ScenePackageBundle.js +8 -0
- package/dist/cjs/packages/ScenePackageBundle.js.map +1 -1
- package/dist/cjs/packages/describeComponents.js +64 -0
- package/dist/cjs/packages/describeComponents.js.map +1 -0
- package/dist/cjs/packages/designModes.js +145 -0
- package/dist/cjs/packages/designModes.js.map +1 -0
- package/dist/cjs/packages/validateComponentMetadata.js +25 -0
- package/dist/cjs/packages/validateComponentMetadata.js.map +1 -0
- package/dist/esm/core/coreComponentMetadata.d.ts +3 -0
- package/dist/esm/core/coreComponentMetadata.d.ts.map +1 -0
- package/dist/esm/core/coreComponentMetadata.js +107 -0
- package/dist/esm/core/coreComponentMetadata.js.map +1 -0
- package/dist/esm/core/coreDescriptors.d.ts.map +1 -1
- package/dist/esm/core/coreDescriptors.js +4 -1
- package/dist/esm/core/coreDescriptors.js.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/packages/ScenePackageBundle.d.ts.map +1 -1
- package/dist/esm/packages/ScenePackageBundle.js +9 -1
- package/dist/esm/packages/ScenePackageBundle.js.map +1 -1
- package/dist/esm/packages/describeComponents.d.ts +12 -0
- package/dist/esm/packages/describeComponents.d.ts.map +1 -0
- package/dist/esm/packages/describeComponents.js +61 -0
- package/dist/esm/packages/describeComponents.js.map +1 -0
- package/dist/esm/packages/designModes.d.ts +10 -0
- package/dist/esm/packages/designModes.d.ts.map +1 -0
- package/dist/esm/packages/designModes.js +140 -0
- package/dist/esm/packages/designModes.js.map +1 -0
- package/dist/esm/packages/index.d.ts +3 -0
- package/dist/esm/packages/index.d.ts.map +1 -1
- package/dist/esm/packages/index.js +3 -0
- package/dist/esm/packages/index.js.map +1 -1
- package/dist/esm/packages/validateComponentMetadata.d.ts +4 -0
- package/dist/esm/packages/validateComponentMetadata.d.ts.map +1 -0
- package/dist/esm/packages/validateComponentMetadata.js +23 -0
- package/dist/esm/packages/validateComponentMetadata.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/packages/ScenePackageBundle.ts +7 -1
- package/packages/describeComponents.ts +78 -0
- package/packages/designModes.ts +74 -0
- package/packages/index.ts +3 -0
- package/packages/validateComponentMetadata.ts +22 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
|
|
5
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
6
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
7
|
+
/** The rule that says an item may be changed (not inherited), interpreted by the package's design-time bundle. */ const itemEditableRule = 'item.editable';
|
|
8
|
+
/** The rule that says why an inherited item may not be changed. */ const itemInheritedReason = 'item.inherited';
|
|
9
|
+
const mutating = (action, compact)=>({
|
|
10
|
+
id: action.id,
|
|
11
|
+
icon: scene_model.componentIcon(action.icon),
|
|
12
|
+
title: action.title,
|
|
13
|
+
...compact === true ? {
|
|
14
|
+
compact: true
|
|
15
|
+
} : {},
|
|
16
|
+
availability: action.availability ?? itemEditableRule,
|
|
17
|
+
readOnlyReason: itemInheritedReason
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* The design mode of a component made of navigation items (a topbar, a sidebar, a navigation bar): add an item, and on a selected
|
|
21
|
+
* item rename it, choose its target and rendering slot, move it earlier or later, duplicate it, delete it, and - in a sidebar - add a
|
|
22
|
+
* sub-item (spec DM3). Pass the `itemsPath` of a component whose items are a `Collection` property; the target and slot buttons are
|
|
23
|
+
* left out of such a component unless `itemsPath` is absent, because only the navigation region's items have them.
|
|
24
|
+
*/ function navigationDesignMode(options = {}) {
|
|
25
|
+
const { itemsPath, sidebar = false } = options;
|
|
26
|
+
const regionItems = itemsPath === undefined;
|
|
27
|
+
return {
|
|
28
|
+
...itemsPath === undefined ? {} : {
|
|
29
|
+
itemsPath
|
|
30
|
+
},
|
|
31
|
+
addActions: [
|
|
32
|
+
{
|
|
33
|
+
id: 'addItem',
|
|
34
|
+
label: 'Add item',
|
|
35
|
+
icon: scene_model.componentIcon('plus'),
|
|
36
|
+
...itemsPath === undefined ? {} : {
|
|
37
|
+
collectionPath: itemsPath
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
itemToolbar: [
|
|
42
|
+
mutating({
|
|
43
|
+
id: 'rename',
|
|
44
|
+
icon: 'pencil',
|
|
45
|
+
title: 'Rename'
|
|
46
|
+
}, sidebar),
|
|
47
|
+
...regionItems ? [
|
|
48
|
+
mutating({
|
|
49
|
+
id: 'target',
|
|
50
|
+
icon: 'link',
|
|
51
|
+
title: 'Link target'
|
|
52
|
+
}, sidebar),
|
|
53
|
+
mutating({
|
|
54
|
+
id: 'slot',
|
|
55
|
+
icon: 'layout-panel-left',
|
|
56
|
+
title: 'Rendering slot'
|
|
57
|
+
}, sidebar)
|
|
58
|
+
] : [],
|
|
59
|
+
mutating({
|
|
60
|
+
id: 'moveEarlier',
|
|
61
|
+
icon: sidebar ? 'arrow-up' : 'arrow-left',
|
|
62
|
+
title: 'Move earlier'
|
|
63
|
+
}, sidebar),
|
|
64
|
+
mutating({
|
|
65
|
+
id: 'moveLater',
|
|
66
|
+
icon: sidebar ? 'arrow-down' : 'arrow-right',
|
|
67
|
+
title: 'Move later'
|
|
68
|
+
}, sidebar),
|
|
69
|
+
mutating({
|
|
70
|
+
id: 'duplicate',
|
|
71
|
+
icon: 'copy',
|
|
72
|
+
title: 'Duplicate'
|
|
73
|
+
}, sidebar),
|
|
74
|
+
mutating({
|
|
75
|
+
id: 'delete',
|
|
76
|
+
icon: 'trash',
|
|
77
|
+
title: 'Delete'
|
|
78
|
+
}, sidebar),
|
|
79
|
+
...sidebar ? [
|
|
80
|
+
mutating({
|
|
81
|
+
id: 'addSubItem',
|
|
82
|
+
icon: 'corner-down-right',
|
|
83
|
+
title: 'Add sub-item'
|
|
84
|
+
}, true)
|
|
85
|
+
] : []
|
|
86
|
+
]
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The design mode of a toolbar: add a button, and on a selected button rename it, choose the slice it starts, set its emphasis,
|
|
91
|
+
* move it earlier or later, duplicate it, delete it (spec DM3). The buttons are the toolbar's own items, which the host resolves.
|
|
92
|
+
*/ function toolbarDesignMode() {
|
|
93
|
+
return {
|
|
94
|
+
addActions: [
|
|
95
|
+
{
|
|
96
|
+
id: 'addButton',
|
|
97
|
+
label: 'Add button',
|
|
98
|
+
icon: scene_model.componentIcon('plus')
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
itemToolbar: [
|
|
102
|
+
mutating({
|
|
103
|
+
id: 'rename',
|
|
104
|
+
icon: 'pencil',
|
|
105
|
+
title: 'Rename'
|
|
106
|
+
}),
|
|
107
|
+
mutating({
|
|
108
|
+
id: 'slice',
|
|
109
|
+
icon: 'git-branch',
|
|
110
|
+
title: 'Choose slice'
|
|
111
|
+
}),
|
|
112
|
+
mutating({
|
|
113
|
+
id: 'emphasis',
|
|
114
|
+
icon: 'contrast',
|
|
115
|
+
title: 'Emphasis'
|
|
116
|
+
}),
|
|
117
|
+
mutating({
|
|
118
|
+
id: 'moveEarlier',
|
|
119
|
+
icon: 'arrow-left',
|
|
120
|
+
title: 'Move earlier'
|
|
121
|
+
}),
|
|
122
|
+
mutating({
|
|
123
|
+
id: 'moveLater',
|
|
124
|
+
icon: 'arrow-right',
|
|
125
|
+
title: 'Move later'
|
|
126
|
+
}),
|
|
127
|
+
mutating({
|
|
128
|
+
id: 'duplicate',
|
|
129
|
+
icon: 'copy',
|
|
130
|
+
title: 'Duplicate'
|
|
131
|
+
}),
|
|
132
|
+
mutating({
|
|
133
|
+
id: 'delete',
|
|
134
|
+
icon: 'trash',
|
|
135
|
+
title: 'Delete'
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
exports.itemEditableRule = itemEditableRule;
|
|
142
|
+
exports.itemInheritedReason = itemInheritedReason;
|
|
143
|
+
exports.navigationDesignMode = navigationDesignMode;
|
|
144
|
+
exports.toolbarDesignMode = toolbarDesignMode;
|
|
145
|
+
//# sourceMappingURL=designModes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"designModes.js","sources":["../../../packages/designModes.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ComponentDesignModeDescriptor, DesignModeItemAction, componentIcon } from '@cratis/scene.model';\n\n/** The rule that says an item may be changed (not inherited), interpreted by the package's design-time bundle. */\nexport const itemEditableRule = 'item.editable';\n\n/** The rule that says why an inherited item may not be changed. */\nexport const itemInheritedReason = 'item.inherited';\n\nconst mutating = (action: Omit<DesignModeItemAction, 'icon'> & { icon: string }, compact?: boolean): DesignModeItemAction => ({\n id: action.id,\n icon: componentIcon(action.icon),\n title: action.title,\n ...(compact === true ? { compact: true } : {}),\n availability: action.availability ?? itemEditableRule,\n readOnlyReason: itemInheritedReason,\n});\n\nexport interface NavigationDesignModeOptions {\n /** The `Collection` property that holds the items; absent when the host resolves them (a topbar's or sidebar's navigation region). */\n itemsPath?: string;\n\n /** A sidebar's items nest, and its toolbar sits below the item in a compact two-row form (spec DM3, DM4). */\n sidebar?: boolean;\n}\n\n/**\n * The design mode of a component made of navigation items (a topbar, a sidebar, a navigation bar): add an item, and on a selected\n * item rename it, choose its target and rendering slot, move it earlier or later, duplicate it, delete it, and - in a sidebar - add a\n * sub-item (spec DM3). Pass the `itemsPath` of a component whose items are a `Collection` property; the target and slot buttons are\n * left out of such a component unless `itemsPath` is absent, because only the navigation region's items have them.\n */\nexport function navigationDesignMode(options: NavigationDesignModeOptions = {}): ComponentDesignModeDescriptor {\n const { itemsPath, sidebar = false } = options;\n const regionItems = itemsPath === undefined;\n\n return {\n ...(itemsPath === undefined ? {} : { itemsPath }),\n addActions: [{ id: 'addItem', label: 'Add item', icon: componentIcon('plus'), ...(itemsPath === undefined ? {} : { collectionPath: itemsPath }) }],\n itemToolbar: [\n mutating({ id: 'rename', icon: 'pencil', title: 'Rename' }, sidebar),\n ...(regionItems ? [\n mutating({ id: 'target', icon: 'link', title: 'Link target' }, sidebar),\n mutating({ id: 'slot', icon: 'layout-panel-left', title: 'Rendering slot' }, sidebar),\n ] : []),\n mutating({ id: 'moveEarlier', icon: sidebar ? 'arrow-up' : 'arrow-left', title: 'Move earlier' }, sidebar),\n mutating({ id: 'moveLater', icon: sidebar ? 'arrow-down' : 'arrow-right', title: 'Move later' }, sidebar),\n mutating({ id: 'duplicate', icon: 'copy', title: 'Duplicate' }, sidebar),\n mutating({ id: 'delete', icon: 'trash', title: 'Delete' }, sidebar),\n ...(sidebar ? [mutating({ id: 'addSubItem', icon: 'corner-down-right', title: 'Add sub-item' }, true)] : []),\n ],\n };\n}\n\n/**\n * The design mode of a toolbar: add a button, and on a selected button rename it, choose the slice it starts, set its emphasis,\n * move it earlier or later, duplicate it, delete it (spec DM3). The buttons are the toolbar's own items, which the host resolves.\n */\nexport function toolbarDesignMode(): ComponentDesignModeDescriptor {\n return {\n addActions: [{ id: 'addButton', label: 'Add button', icon: componentIcon('plus') }],\n itemToolbar: [\n mutating({ id: 'rename', icon: 'pencil', title: 'Rename' }),\n mutating({ id: 'slice', icon: 'git-branch', title: 'Choose slice' }),\n mutating({ id: 'emphasis', icon: 'contrast', title: 'Emphasis' }),\n mutating({ id: 'moveEarlier', icon: 'arrow-left', title: 'Move earlier' }),\n mutating({ id: 'moveLater', icon: 'arrow-right', title: 'Move later' }),\n mutating({ id: 'duplicate', icon: 'copy', title: 'Duplicate' }),\n mutating({ id: 'delete', icon: 'trash', title: 'Delete' }),\n ],\n };\n}\n"],"names":["itemEditableRule","itemInheritedReason","mutating","action","compact","id","icon","componentIcon","title","availability","readOnlyReason","navigationDesignMode","options","itemsPath","sidebar","regionItems","undefined","addActions","label","collectionPath","itemToolbar","toolbarDesignMode"],"mappings":";;;;AAAA;AACA;AAIA,mHACO,MAAMA,gBAAAA,GAAmB;AAEhC,oEACO,MAAMC,mBAAAA,GAAsB;AAEnC,MAAMC,QAAAA,GAAW,CAACC,MAAAA,EAA+DC,OAAAA,IAA6C;AAC1HC,QAAAA,EAAAA,EAAIF,OAAOE,EAAE;QACbC,IAAAA,EAAMC,yBAAAA,CAAcJ,OAAOG,IAAI,CAAA;AAC/BE,QAAAA,KAAAA,EAAOL,OAAOK,KAAK;AACnB,QAAA,GAAIJ,YAAY,IAAA,GAAO;YAAEA,OAAAA,EAAS;AAAK,SAAA,GAAI,EAAE;QAC7CK,YAAAA,EAAcN,MAAAA,CAAOM,YAAY,IAAIT,gBAAAA;QACrCU,cAAAA,EAAgBT;KACpB,CAAA;AAUA;;;;;AAKC,IACM,SAASU,oBAAAA,CAAqBC,OAAAA,GAAuC,EAAE,EAAA;AAC1E,IAAA,MAAM,EAAEC,SAAS,EAAEC,OAAAA,GAAU,KAAK,EAAE,GAAGF,OAAAA;AACvC,IAAA,MAAMG,cAAcF,SAAAA,KAAcG,SAAAA;IAElC,OAAO;QACH,GAAIH,SAAAA,KAAcG,SAAAA,GAAY,EAAC,GAAI;AAAEH,YAAAA;SAAW;QAChDI,UAAAA,EAAY;AAAC,YAAA;gBAAEZ,EAAAA,EAAI,SAAA;gBAAWa,KAAAA,EAAO,UAAA;AAAYZ,gBAAAA,IAAAA,EAAMC,yBAAAA,CAAc,MAAA,CAAA;gBAAS,GAAIM,S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ageBundle.js');
|
|
5
|
+
|
|
6
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
7
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
8
|
+
/**
|
|
9
|
+
* Checks the component metadata of a bundle (rule CMP1): every component its manifest declares or its registry holds is described
|
|
10
|
+
* and declares a category, and the design-mode and editor parameters of its descriptors are sound.
|
|
11
|
+
*
|
|
12
|
+
* This is not part of `validatePackageBundle`: that gates what a host loads, and a third-party package written before components
|
|
13
|
+
* had categories must still load. A designer and the in-repo packages' own specs run this one.
|
|
14
|
+
*/ function validateComponentMetadata(bundle) {
|
|
15
|
+
const registered = new Set([
|
|
16
|
+
...bundle.manifest.components.map((name)=>ScenePackageBundle.componentRegistryKey(bundle.manifest.name, name)),
|
|
17
|
+
...Object.keys(bundle.components)
|
|
18
|
+
]);
|
|
19
|
+
return scene_engine.validateComponentDescriptors(bundle.descriptors ?? [], [
|
|
20
|
+
...registered
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.validateComponentMetadata = validateComponentMetadata;
|
|
25
|
+
//# sourceMappingURL=validateComponentMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateComponentMetadata.js","sources":["../../../packages/validateComponentMetadata.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { validateComponentDescriptors } from '@cratis/scene.engine';\nimport { SceneDiagnostic } from '@cratis/scene.model';\nimport { ScenePackageBundle, componentRegistryKey } from './ScenePackageBundle';\n\n/**\n * Checks the component metadata of a bundle (rule CMP1): every component its manifest declares or its registry holds is described\n * and declares a category, and the design-mode and editor parameters of its descriptors are sound.\n *\n * This is not part of `validatePackageBundle`: that gates what a host loads, and a third-party package written before components\n * had categories must still load. A designer and the in-repo packages' own specs run this one.\n */\nexport function validateComponentMetadata(bundle: ScenePackageBundle): SceneDiagnostic[] {\n const registered = new Set([\n ...bundle.manifest.components.map(name => componentRegistryKey(bundle.manifest.name, name)),\n ...Object.keys(bundle.components),\n ]);\n\n return validateComponentDescriptors(bundle.descriptors ?? [], [...registered]);\n}\n"],"names":["validateComponentMetadata","bundle","registered","Set","manifest","components","map","name","componentRegistryKey","Object","keys","validateComponentDescriptors","descriptors"],"mappings":";;;;;AAAA;AACA;AAMA;;;;;;IAOO,SAASA,yBAAAA,CAA0BC,MAA0B,EAAA;IAChE,MAAMC,UAAAA,GAAa,IAAIC,GAAAA,CAAI;AACpBF,QAAAA,GAAAA,MAAAA,CAAOG,QAAQ,CAACC,UAAU,CAACC,GAAG,CAACC,CAAAA,IAAAA,GAAQC,uCAAAA,CAAqBP,MAAAA,CAAOG,QAAQ,CAACG,IAAI,EAAEA,IAAAA,CAAAA,CAAAA;WAClFE,MAAAA,CAAOC,IAAI,CAACT,MAAAA,CAAOI,UAAU;AACnC,KAAA,CAAA;AAED,IAAA,OAAOM,yCAAAA,CAA6BV,MAAAA,CAAOW,WAAW,IAAI,EAAE,EAAE;AAAIV,QAAAA,GAAAA;AAAW,KAAA,CAAA;AACjF;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coreComponentMetadata.d.ts","sourceRoot":"","sources":["../../../core/coreComponentMetadata.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAmE,MAAM,aAAa,CAAC;AAGjH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAmBnE,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ComponentCategory } from '@cratis/scene.model';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '@cratis/scene.engine';
|
|
5
|
+
import '../interactions/useInteractions.js';
|
|
6
|
+
import '../interactions/NotificationHost.js';
|
|
7
|
+
import '../packages/runDesignTimeAction.js';
|
|
8
|
+
import { componentMetadata } from '../packages/describeComponents.js';
|
|
9
|
+
import { toolbarDesignMode, navigationDesignMode } from '../packages/designModes.js';
|
|
10
|
+
|
|
11
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
12
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
13
|
+
/** The category, icon, keywords and picker badge of every component of the package (CMP1), keyed by bare component name. */ const coreComponentMetadata = {
|
|
14
|
+
text: componentMetadata('Text', ComponentCategory.DataDisplay, 'type', [
|
|
15
|
+
'label',
|
|
16
|
+
'paragraph',
|
|
17
|
+
'copy'
|
|
18
|
+
]),
|
|
19
|
+
button: componentMetadata('Button', ComponentCategory.Actions, 'mouse-pointer-click', [
|
|
20
|
+
'click',
|
|
21
|
+
'submit',
|
|
22
|
+
'action'
|
|
23
|
+
], 'Bt'),
|
|
24
|
+
card: componentMetadata('Card', ComponentCategory.Layout, 'square', [
|
|
25
|
+
'panel',
|
|
26
|
+
'box',
|
|
27
|
+
'container'
|
|
28
|
+
]),
|
|
29
|
+
data: componentMetadata('Data', ComponentCategory.DataDisplay, 'database', [
|
|
30
|
+
'read model',
|
|
31
|
+
'query',
|
|
32
|
+
'source'
|
|
33
|
+
]),
|
|
34
|
+
action: componentMetadata('Command action', ComponentCategory.Actions, 'zap', [
|
|
35
|
+
'command',
|
|
36
|
+
'invoke',
|
|
37
|
+
'submit'
|
|
38
|
+
]),
|
|
39
|
+
section: componentMetadata('Section', ComponentCategory.Layout, 'layout-panel-top', [
|
|
40
|
+
'group',
|
|
41
|
+
'area',
|
|
42
|
+
'block'
|
|
43
|
+
]),
|
|
44
|
+
navigate: componentMetadata('Navigate', ComponentCategory.Navigation, 'corner-down-right', [
|
|
45
|
+
'link',
|
|
46
|
+
'go to',
|
|
47
|
+
'route'
|
|
48
|
+
]),
|
|
49
|
+
title: componentMetadata('Title', ComponentCategory.DataDisplay, 'heading', [
|
|
50
|
+
'heading',
|
|
51
|
+
'header',
|
|
52
|
+
'caption'
|
|
53
|
+
]),
|
|
54
|
+
table: componentMetadata('Table', ComponentCategory.DataDisplay, 'table', [
|
|
55
|
+
'grid',
|
|
56
|
+
'rows',
|
|
57
|
+
'list'
|
|
58
|
+
], 'Tb'),
|
|
59
|
+
column: componentMetadata('Table column', ComponentCategory.DataDisplay, 'columns-3', [
|
|
60
|
+
'heading',
|
|
61
|
+
'field'
|
|
62
|
+
]),
|
|
63
|
+
summary: componentMetadata('Summary', ComponentCategory.DataDisplay, 'list', [
|
|
64
|
+
'details',
|
|
65
|
+
'overview',
|
|
66
|
+
'facts'
|
|
67
|
+
]),
|
|
68
|
+
field: componentMetadata('Summary field', ComponentCategory.DataDisplay, 'tag', [
|
|
69
|
+
'label',
|
|
70
|
+
'value',
|
|
71
|
+
'pair'
|
|
72
|
+
]),
|
|
73
|
+
code: componentMetadata('Code', ComponentCategory.DataDisplay, 'code', [
|
|
74
|
+
'snippet',
|
|
75
|
+
'source',
|
|
76
|
+
'monospace'
|
|
77
|
+
]),
|
|
78
|
+
file: componentMetadata('File reference', ComponentCategory.DataDisplay, 'file', [
|
|
79
|
+
'include',
|
|
80
|
+
'import',
|
|
81
|
+
'screen file'
|
|
82
|
+
]),
|
|
83
|
+
navigationBar: componentMetadata('Navigation bar', ComponentCategory.Navigation, 'navigation', [
|
|
84
|
+
'menu',
|
|
85
|
+
'nav',
|
|
86
|
+
'links'
|
|
87
|
+
], undefined, navigationDesignMode({
|
|
88
|
+
itemsPath: 'items'
|
|
89
|
+
})),
|
|
90
|
+
outlet: componentMetadata('Outlet', ComponentCategory.Layout, 'panel-right', [
|
|
91
|
+
'region',
|
|
92
|
+
'slot',
|
|
93
|
+
'side panel'
|
|
94
|
+
]),
|
|
95
|
+
toolbar: componentMetadata('Toolbar', ComponentCategory.Actions, 'wrench', [
|
|
96
|
+
'actions',
|
|
97
|
+
'buttons',
|
|
98
|
+
'command bar'
|
|
99
|
+
], 'Tl', toolbarDesignMode()),
|
|
100
|
+
toolbarItem: componentMetadata('Toolbar item', ComponentCategory.Actions, 'mouse-pointer-click', [
|
|
101
|
+
'button',
|
|
102
|
+
'action'
|
|
103
|
+
])
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export { coreComponentMetadata };
|
|
107
|
+
//# sourceMappingURL=coreComponentMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coreComponentMetadata.js","sources":["../../../core/coreComponentMetadata.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ComponentCategory } from '@cratis/scene.model';\nimport { ComponentMetadata, componentMetadata as m, navigationDesignMode, toolbarDesignMode } from '../packages';\n\n/** The category, icon, keywords and picker badge of every component of the package (CMP1), keyed by bare component name. */\nexport const coreComponentMetadata: Record<string, ComponentMetadata> = {\n text: m('Text', ComponentCategory.DataDisplay, 'type', ['label', 'paragraph', 'copy']),\n button: m('Button', ComponentCategory.Actions, 'mouse-pointer-click', ['click', 'submit', 'action'], 'Bt'),\n card: m('Card', ComponentCategory.Layout, 'square', ['panel', 'box', 'container']),\n data: m('Data', ComponentCategory.DataDisplay, 'database', ['read model', 'query', 'source']),\n action: m('Command action', ComponentCategory.Actions, 'zap', ['command', 'invoke', 'submit']),\n section: m('Section', ComponentCategory.Layout, 'layout-panel-top', ['group', 'area', 'block']),\n navigate: m('Navigate', ComponentCategory.Navigation, 'corner-down-right', ['link', 'go to', 'route']),\n title: m('Title', ComponentCategory.DataDisplay, 'heading', ['heading', 'header', 'caption']),\n table: m('Table', ComponentCategory.DataDisplay, 'table', ['grid', 'rows', 'list'], 'Tb'),\n column: m('Table column', ComponentCategory.DataDisplay, 'columns-3', ['heading', 'field']),\n summary: m('Summary', ComponentCategory.DataDisplay, 'list', ['details', 'overview', 'facts']),\n field: m('Summary field', ComponentCategory.DataDisplay, 'tag', ['label', 'value', 'pair']),\n code: m('Code', ComponentCategory.DataDisplay, 'code', ['snippet', 'source', 'monospace']),\n file: m('File reference', ComponentCategory.DataDisplay, 'file', ['include', 'import', 'screen file']),\n navigationBar: m('Navigation bar', ComponentCategory.Navigation, 'navigation', ['menu', 'nav', 'links'], undefined, navigationDesignMode({ itemsPath: 'items' })),\n outlet: m('Outlet', ComponentCategory.Layout, 'panel-right', ['region', 'slot', 'side panel']),\n toolbar: m('Toolbar', ComponentCategory.Actions, 'wrench', ['actions', 'buttons', 'command bar'], 'Tl', toolbarDesignMode()),\n toolbarItem: m('Toolbar item', ComponentCategory.Actions, 'mouse-pointer-click', ['button', 'action']),\n};\n"],"names":["coreComponentMetadata","text","m","ComponentCategory","DataDisplay","button","Actions","card","Layout","data","action","section","navigate","Navigation","title","table","column","summary","field","code","file","navigationBar","undefined","navigationDesignMode","itemsPath","outlet","toolbar","toolbarDesignMode","toolbarItem"],"mappings":";;;;;;;;;;AAAA;AACA;AAKA,6HACO,MAAMA,qBAAAA,GAA2D;AACpEC,IAAAA,IAAAA,EAAMC,iBAAAA,CAAE,MAAA,EAAQC,iBAAAA,CAAkBC,WAAW,EAAE,MAAA,EAAQ;AAAC,QAAA,OAAA;AAAS,QAAA,WAAA;AAAa,QAAA;AAAO,KAAA,CAAA;AACrFC,IAAAA,MAAAA,EAAQH,iBAAAA,CAAE,QAAA,EAAUC,iBAAAA,CAAkBG,OAAO,EAAE,qBAAA,EAAuB;AAAC,QAAA,OAAA;AAAS,QAAA,QAAA;AAAU,QAAA;KAAS,EAAE,IAAA,CAAA;AACrGC,IAAAA,IAAAA,EAAML,iBAAAA,CAAE,MAAA,EAAQC,iBAAAA,CAAkBK,MAAM,EAAE,QAAA,EAAU;AAAC,QAAA,OAAA;AAAS,QAAA,KAAA;AAAO,QAAA;AAAY,KAAA,CAAA;AACjFC,IAAAA,IAAAA,EAAMP,iBAAAA,CAAE,MAAA,EAAQC,iBAAAA,CAAkBC,WAAW,EAAE,UAAA,EAAY;AAAC,QAAA,YAAA;AAAc,QAAA,OAAA;AAAS,QAAA;AAAS,KAAA,CAAA;AAC5FM,IAAAA,MAAAA,EAAQR,iBAAAA,CAAE,gB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reDescriptors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAqB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"coreDescriptors.d.ts","sourceRoot":"","sources":["../../../core/coreDescriptors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAqB,MAAM,qBAAqB,CAAC;AAiF7E,eAAO,MAAM,eAAe,EAAE,mBAAmB,EAAqE,CAAC"}
|
|
@@ -6,6 +6,8 @@ import '../interactions/useInteractions.js';
|
|
|
6
6
|
import '../interactions/NotificationHost.js';
|
|
7
7
|
import { componentRegistryKey } from '../packages/ScenePackageBundle.js';
|
|
8
8
|
import '../packages/runDesignTimeAction.js';
|
|
9
|
+
import { describeComponents } from '../packages/describeComponents.js';
|
|
10
|
+
import { coreComponentMetadata } from './coreComponentMetadata.js';
|
|
9
11
|
|
|
10
12
|
// Copyright (c) Cratis. All rights reserved.
|
|
11
13
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
@@ -16,7 +18,7 @@ const key = (name)=>componentRegistryKey('core', name);
|
|
|
16
18
|
* Only the components an author configures by hand are described: a button's label, an action's command and its
|
|
17
19
|
* argument mapping, a column's heading, and the navigation bar. The Screenplay structural components - `data`,
|
|
18
20
|
* `section`, `summary` - have nothing to edit that is not already a node in the tree.
|
|
19
|
-
*/ const
|
|
21
|
+
*/ const describedCore = [
|
|
20
22
|
{
|
|
21
23
|
component: key('button'),
|
|
22
24
|
displayName: 'Button',
|
|
@@ -177,6 +179,7 @@ const key = (name)=>componentRegistryKey('core', name);
|
|
|
177
179
|
]
|
|
178
180
|
}
|
|
179
181
|
];
|
|
182
|
+
/** The `core` package's descriptors: the hand-written ones above with every component's category, icon, keywords and design mode (CMP1). */ const coreDescriptors = describeComponents('core', describedCore, coreComponentMetadata);
|
|
180
183
|
|
|
181
184
|
export { coreDescriptors };
|
|
182
185
|
//# sourceMappingURL=coreDescriptors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreDescriptors.js","sources":["../../../core/coreDescriptors.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ComponentDescriptor, PropertyValueType } from '@cratis/scene.model';\nimport { componentRegistryKey } from '../packages';\n\nconst key = (name: string) => componentRegistryKey('core', name);\n\n/**\n * What can be edited on the `core` package's components.\n *\n * Only the components an author configures by hand are described: a button's label, an action's command and its\n * argument mapping, a column's heading, and the navigation bar. The Screenplay structural components - `data`,\n * `section`, `summary` - have nothing to edit that is not already a node in the tree.\n */\
|
|
1
|
+
{"version":3,"file":"coreDescriptors.js","sources":["../../../core/coreDescriptors.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ComponentDescriptor, PropertyValueType } from '@cratis/scene.model';\nimport { componentRegistryKey, describeComponents } from '../packages';\nimport { coreComponentMetadata } from './coreComponentMetadata';\n\nconst key = (name: string) => componentRegistryKey('core', name);\n\n/**\n * What can be edited on the `core` package's components.\n *\n * Only the components an author configures by hand are described: a button's label, an action's command and its\n * argument mapping, a column's heading, and the navigation bar. The Screenplay structural components - `data`,\n * `section`, `summary` - have nothing to edit that is not already a node in the tree.\n */\nconst describedCore: ComponentDescriptor[] = [\n {\n component: key('button'),\n displayName: 'Button',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String, default: '' },\n ],\n },\n {\n component: key('action'),\n displayName: 'Command action',\n description: 'Invokes a modeled command. The command and its argument mapping are stored on the element; the host that handles the command event reads them.',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String },\n {\n path: 'command', label: 'Command', group: 'Behavior', valueType: PropertyValueType.String,\n editorKind: 'stateChangeReference', constraints: { required: true },\n description: 'The state change this action submits.',\n },\n {\n path: 'arguments', label: 'Argument mapping', group: 'Behavior', valueType: PropertyValueType.Collection,\n description: 'Where each command argument comes from.',\n item: {\n label: 'Argument',\n properties: [\n { path: 'name', label: 'Argument', group: 'Behavior', valueType: PropertyValueType.String, constraints: { required: true } },\n { path: 'source', label: 'Source', group: 'Behavior', valueType: PropertyValueType.String, editorKind: 'bindingPath', constraints: { required: true } },\n ],\n },\n },\n ],\n },\n {\n component: key('column'),\n displayName: 'Table column',\n properties: [\n { path: 'property', label: 'Result field', group: 'Data', valueType: PropertyValueType.String, editorKind: 'resultField', constraints: { required: true } },\n { path: 'label', label: 'Heading', group: 'Content', valueType: PropertyValueType.String },\n ],\n },\n {\n component: key('outlet'),\n displayName: 'Outlet',\n description: 'A named region another screen opens into. Placing a screen here keeps this screen on the page, and the placed screen may declare outlets of its own.',\n properties: [{ path: 'name', label: 'Name', group: 'Navigation', valueType: PropertyValueType.String, constraints: { required: true } }],\n },\n {\n component: key('navigationBar'),\n displayName: 'Navigation bar',\n description: 'A list of navigation items. A template author fixes the first item (Home) and can expose the list so that screens add their own.',\n properties: [\n { path: 'title', label: 'Title', group: 'Content', valueType: PropertyValueType.String, default: 'Navigation' },\n {\n path: 'items', label: 'Items', group: 'Content', valueType: PropertyValueType.Collection, default: [],\n item: {\n label: 'Navigation item',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String, constraints: { required: true, minimumLength: 1 } },\n { path: 'icon', label: 'Icon', group: 'Content', valueType: PropertyValueType.Icon, editorKind: 'iconPicker' },\n { path: 'destination', label: 'Destination', group: 'Content', valueType: PropertyValueType.Destination, editorKind: 'screenPicker', constraints: { required: true } },\n ],\n },\n },\n ],\n },\n];\n\n/** The `core` package's descriptors: the hand-written ones above with every component's category, icon, keywords and design mode (CMP1). */\nexport const coreDescriptors: ComponentDescriptor[] = describeComponents('core', describedCore, coreComponentMetadata);"],"names":["key","name","componentRegistryKey","describedCore","component","displayName","properties","path","label","group","valueType","PropertyValueType","String","default","description","editorKind","constraints","required","Collection","item","minimumLength","Icon","Destination","coreDescriptors","describeComponents","coreComponentMetadata"],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Aa;gCAAEC,QAAAA,EAAU;AAAK;AAAE;AACxK;AACL;AACJ;AACH;AACL;AACH,CAAA;AAED,6IACO,MAAMM,kBAAyCC,kBAAAA,CAAmB,MAAA,EAAQrB,eAAesB,qBAAAA;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -54,6 +54,9 @@ export { PackageHostView } from './packages/PackageHostView.js';
|
|
|
54
54
|
export { resolveDesignTimeHost } from './packages/resolveDesignTimeHost.js';
|
|
55
55
|
export { runDesignTimeAction } from './packages/runDesignTimeAction.js';
|
|
56
56
|
export { componentRegistryKey, mergeIconAdapters, mergePackageRegistries, validatePackageBundle } from './packages/ScenePackageBundle.js';
|
|
57
|
+
export { componentMetadata, describeComponents } from './packages/describeComponents.js';
|
|
58
|
+
export { itemEditableRule, itemInheritedReason, navigationDesignMode, toolbarDesignMode } from './packages/designModes.js';
|
|
59
|
+
export { validateComponentMetadata } from './packages/validateComponentMetadata.js';
|
|
57
60
|
export { StandalonePackageHost } from './packages/StandalonePackageHost.js';
|
|
58
61
|
export { WebViewPackageHost } from './packages/WebViewPackageHost.js';
|
|
59
62
|
export { validateComponentsUiLibraryContract, validateComponentsUiLibraryMapping } from './packages/ComponentsUiLibraryContract.js';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScenePackageBundle.d.ts","sourceRoot":"","sources":["../../../packages/ScenePackageBundle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScenePackageBundle.d.ts","sourceRoot":"","sources":["../../../packages/ScenePackageBundle.ts"],"names":[],"mappings":"AAIA,OAAO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
|
|
1
|
+
import { validateComponentDescriptors } from '@cratis/scene.engine';
|
|
2
|
+
import { PackageKind, DiagnosticCode, PropertyValueType } from '@cratis/scene.model';
|
|
2
3
|
import { createIconAdapterRegistry } from '../icons/IconAdapterRegistry.js';
|
|
3
4
|
import { validateComponentsUiLibraryContract } from './ComponentsUiLibraryContract.js';
|
|
4
5
|
import { validateDesignTimeBundle } from './DesignTimeBundle.js';
|
|
@@ -139,6 +140,13 @@ function validateDescriptors(bundle) {
|
|
|
139
140
|
described.add(descriptor.component);
|
|
140
141
|
validateProperties(descriptor.component, descriptor.properties, '', problems);
|
|
141
142
|
}
|
|
143
|
+
// The category rule (CMP1) is not checked here - it gates a designer, not a host loading a package (see validateComponentMetadata) -
|
|
144
|
+
// but a design-mode descriptor or editor parameter that cannot work is as much a mistake as an enum without choices.
|
|
145
|
+
const structural = [
|
|
146
|
+
DiagnosticCode.ComponentDesignModeInvalid,
|
|
147
|
+
DiagnosticCode.PropertyEditorOptionsInvalid
|
|
148
|
+
];
|
|
149
|
+
problems.push(...validateComponentDescriptors(bundle.descriptors ?? []).filter((diagnostic)=>structural.includes(diagnostic.code)).map((diagnostic)=>diagnostic.message));
|
|
142
150
|
return problems;
|
|
143
151
|
}
|
|
144
152
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScenePackageBundle.js","sources":["../../../packages/ScenePackageBundle.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ComponentDescriptor, DialogTemplate, Layout, PackageKind, PropertyDescriptor, PropertyValueType, ScenePackage, Screen, ScreenTemplate, Theme } from '@cratis/scene.model';\nimport { IconAdapterRegistry, createIconAdapterRegistry } from '../icons/IconAdapterRegistry';\nimport { IconLibraryBundle } from '../icons/IconLibraryBundle';\nimport { ComponentRegistry } from '../renderer';\nimport { ComponentsUiLibraryContract, validateComponentsUiLibraryContract } from './ComponentsUiLibraryContract';\nimport { DesignTimeBundle, validateDesignTimeBundle } from './DesignTimeBundle';\n\n/**\n * What a package actually ships to a React renderer, as opposed to what it *declares*.\n *\n * `ScenePackage` is the declaration — a name, a kind, dependencies, and the names of what it\n * contributes. It is deliberately platform-agnostic and lives in `Scene.Model`, because Stage's build and\n * Studio's design-time queries both read it without ever loading a component. A bundle is the other half:\n * the real React components, layouts, screens and themes behind those names, which only a renderer needs.\n *\n * A package publishes exactly one bundle, as a named export following its own name —\n * `primeReactPackage`, `cratisComponentsPackage`, `corePackage`. A host loads it from the module the\n * declaration's `ScenePackage.module` names.\n */\nexport interface ScenePackageBundle {\n /**\n * The package's own declaration. Its `components`, `layouts` and `themes` name lists must agree with\n * what this bundle actually provides — {@link validatePackageBundle} is what proves they do.\n */\n manifest: ScenePackage;\n\n /**\n * The components this package provides, keyed by {@link componentRegistryKey}.\n */\n components: ComponentRegistry;\n\n /**\n * The application shells this package provides, if any. Only a blueprint has these.\n */\n layouts?: Layout[];\n\n /**\n * The screen templates this package provides — the shapes that go inside a layout, each declaring\n * which of its parent's slots it fills.\n */\n screenTemplates?: ScreenTemplate[];\n\n /**\n * The dialog templates this package provides.\n */\n dialogTemplates?: DialogTemplate[];\n\n /**\n * Sample screens this package ships — a layout package's gallery, so a preview has real content to\n * put through the real engine rather than a mockup.\n */\n screens?: Screen[];\n\n /**\n * What can be edited on this package's components - one {@link ComponentDescriptor} per component that is\n * editable at design time. They are data, so Studio reads them without rendering anything, and they travel with\n * the components they describe rather than in a registry of their own. {@link validatePackageBundle} checks\n * that every descriptor names a component the manifest declares.\n */\n descriptors?: ComponentDescriptor[];\n\n /**\n * The themes this package ships, if any.\n */\n themes?: Theme[];\n\n /**\n * The icon catalog and renderer adapter of an icon-library package. Present exactly when the\n * manifest declares an icon library.\n */\n iconLibrary?: IconLibraryBundle;\n\n /**\n * Optional web-renderer mapping to a Components UiLibrary. Scene's catalog remains independently\n * authored; hosts check the loaded export with validateComponentsUiLibraryMapping before rendering.\n */\n componentsUiLibrary?: ComponentsUiLibraryContract;\n\n /** Optional React-only design-time tooling. Runtime hosts can omit it entirely. */\n designTime?: DesignTimeBundle;\n}\n\n/**\n * The key a component is registered and looked up under: the package that provides it, then the bare name\n * a screen refers to it by.\n *\n * A screen writes a bare name (`button`) or a package-qualified one (`PrimeReact.button`);\n * `resolveComponentName` turns either into a `{ name, package }` pair, and this turns that pair into the\n * registry key. Nothing should build this string by hand — the separator is an implementation detail of\n * the registry, deliberately not the `.` used for qualification in a screen, so a package name containing\n * dots stays unambiguous.\n */\nexport function componentRegistryKey(packageName: string, componentName: string): string {\n return `${packageName}:${componentName}`;\n}\n\n/**\n * Checks that a bundle provides everything its manifest declares, and declares everything it provides, and that\n * every descriptor it ships is for a component it declares and is well formed.\n *\n * A manifest that promises a component the bundle does not register renders as `UnresolvedComponent` at\n * runtime — a blank box, far from where the mistake was made. A component registered but not declared is\n * invisible to `resolveComponentName`, so a screen can never name it. Both are silent failures, which is\n * why every package's specs run this.\n */\nexport function validatePackageBundle(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const { manifest } = bundle;\n\n for (const name of manifest.components) {\n if (!(componentRegistryKey(manifest.name, name) in bundle.components)) {\n problems.push(`declares the component '${name}' but registers no implementation for it`);\n }\n }\n\n const declared = new Set(manifest.components.map((name) => componentRegistryKey(manifest.name, name)));\n for (const key of Object.keys(bundle.components)) {\n if (!declared.has(key)) {\n problems.push(`registers '${key}', which the manifest does not declare`);\n }\n }\n\n const providedLayouts = new Set((bundle.layouts ?? []).map((layout) => layout.name));\n for (const name of manifest.layouts) {\n if (!providedLayouts.has(name)) {\n problems.push(`declares the layout '${name}' but provides no definition for it`);\n }\n }\n\n const providedScreenTemplates = new Set((bundle.screenTemplates ?? []).map((template) => template.name));\n for (const name of manifest.screenTemplates) {\n if (!providedScreenTemplates.has(name)) {\n problems.push(`declares the screen template '${name}' but provides no definition for it`);\n }\n }\n\n const providedDialogTemplates = new Set((bundle.dialogTemplates ?? []).map((template) => template.name));\n for (const name of manifest.dialogTemplates) {\n if (!providedDialogTemplates.has(name)) {\n problems.push(`declares the dialog template '${name}' but provides no definition for it`);\n }\n }\n\n const providedThemes = new Set((bundle.themes ?? []).map((theme) => theme.name));\n for (const name of manifest.themes) {\n if (!providedThemes.has(name)) {\n problems.push(`declares the theme '${name}' but provides no definition for it`);\n }\n }\n\n if (bundle.componentsUiLibrary) {\n if (manifest.kind !== PackageKind.ComponentLibrary) {\n problems.push('declares a Components UI library mapping but is not of kind ComponentLibrary');\n }\n problems.push(...validateComponentsUiLibraryContract(bundle.componentsUiLibrary));\n }\n\n problems.push(...validateIconLibrary(bundle));\n problems.push(...validateDescriptors(bundle));\n problems.push(...validateDesignTimeBundle(bundle.designTime));\n\n return problems;\n}\n\nfunction validateIconLibrary(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const { manifest, iconLibrary } = bundle;\n const declaresIconLibrary = manifest.kind === PackageKind.IconLibrary || manifest.iconLibrary !== undefined;\n\n if (manifest.kind === PackageKind.IconLibrary && !manifest.iconLibrary) {\n problems.push('is an icon library but declares no iconLibrary metadata');\n }\n\n if (manifest.kind !== PackageKind.IconLibrary && manifest.iconLibrary) {\n problems.push('declares iconLibrary metadata but is not of kind IconLibrary');\n }\n\n if (declaresIconLibrary && !iconLibrary) {\n problems.push('declares an icon library but the bundle provides no catalog or adapter for it');\n }\n\n if (!declaresIconLibrary && iconLibrary) {\n problems.push('provides an icon catalog and adapter, which the manifest does not declare');\n }\n\n if (iconLibrary) {\n if (iconLibrary.catalog.library !== manifest.name) {\n problems.push(`provides an icon catalog for '${iconLibrary.catalog.library}' instead of '${manifest.name}'`);\n }\n\n if (iconLibrary.adapter.library !== manifest.name) {\n problems.push(`provides an icon adapter for '${iconLibrary.adapter.library}' instead of '${manifest.name}'`);\n }\n\n if (manifest.iconLibrary && !manifest.iconLibrary.renderers.includes('react')) {\n problems.push(\"provides a React icon adapter but does not list 'react' among its icon renderers\");\n }\n }\n\n return problems;\n}\n\nfunction validateProperties(component: string, properties: PropertyDescriptor[], parent: string, problems: string[]): void {\n const paths = new Set<string>();\n for (const property of properties) {\n const path = `${parent}${property.path}`;\n if (paths.has(property.path)) {\n problems.push(`'${component}' describes the property '${path}' more than once`);\n }\n\n paths.add(property.path);\n\n if (property.valueType === PropertyValueType.Collection && property.item === undefined) {\n problems.push(`'${component}' describes the collection '${path}' without describing its items`);\n }\n\n if (property.valueType === PropertyValueType.Collection && property.item !== undefined) {\n validateProperties(component, property.item.properties, `${path}[].`, problems);\n }\n\n if (property.valueType === PropertyValueType.Object && property.properties !== undefined) {\n validateProperties(component, property.properties, `${path}.`, problems);\n }\n\n if (property.valueType === PropertyValueType.Enum && (property.choices ?? []).length === 0) {\n problems.push(`'${component}' describes the enum '${path}' without choices`);\n }\n }\n}\n\nfunction validateDescriptors(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const declared = new Set(bundle.manifest.components.map((name) => componentRegistryKey(bundle.manifest.name, name)));\n const described = new Set<string>();\n\n for (const descriptor of bundle.descriptors ?? []) {\n if (!declared.has(descriptor.component)) {\n problems.push(`describes '${descriptor.component}', which the manifest does not declare as a component`);\n }\n\n if (described.has(descriptor.component)) {\n problems.push(`describes '${descriptor.component}' more than once`);\n }\n\n described.add(descriptor.component);\n\n validateProperties(descriptor.component, descriptor.properties, '', problems);\n }\n\n return problems;\n}\n\n/**\n * Merges the component registries of several bundles into the single registry a renderer consumes.\n *\n * Keys carry their package name, so nothing collides and merge order does not matter — which package wins\n * a *bare* name is decided earlier, by `resolveComponentName` walking the profile's priority order.\n */\nexport function mergePackageRegistries(bundles: ScenePackageBundle[]): ComponentRegistry {\n return Object.assign({}, ...bundles.map((bundle) => bundle.components)) as ComponentRegistry;\n}\n\n/**\n * Collects the icon adapters of several bundles into the registry `SceneIcon` renders through.\n *\n * @throws Error when two bundles provide an adapter for the same library.\n */\nexport function mergeIconAdapters(bundles: ScenePackageBundle[]): IconAdapterRegistry {\n return createIconAdapterRegistry(bundles.flatMap((bundle) => (bundle.iconLibrary ? [bundle.iconLibrary.adapter] : [])));\n}\n"],"names":["componentRegistryKey","packageName","componentName","validatePackageBundle","bundle","problems","manifest","name","components","push","declared","Set","map","key","Object","keys","has","providedLayouts","layouts","layout","providedScreenTemplates","screenTemplates","template","providedDialogTemplates","dialogTemplates","providedThemes","themes","theme","componentsUiLibrary","kind","PackageKind","ComponentLibrary","validateComponentsUiLibraryContract","validateIconLibrary","validateDescriptors","validateDesignTimeBundle","designTime","iconLibrary","declaresIconLibrary","IconLibrary","undefined","catalog","library","adapter","renderers","includes","validateProperties","component","properties","parent","paths","property","path","add","valueType","PropertyValueType","Collection","item","Enum","choices","length","described","descriptor","descriptors","mergePackageRegistries","bundles","assign","mergeIconAdapters","createIconAdapterRegistry","flatMap"],"mappings":";;;;;AAAA;AACA;AAoFA;;;;;;;;;AASC,IACM,SAASA,oBAAAA,CAAqBC,WAAmB,EAAEC,aAAqB,EAAA;AAC3E,IAAA,OAAO,CAAA,EAAGD,WAAAA,CAAY,CAAC,EAAEC,aAAAA,CAAAA,CAAe;AAC5C;AAEA;;;;;;;;IASO,SAASC,qBAAAA,CAAsBC,MAA0B,EAAA;AAC5D,IAAA,MAAMC,WAAqB,EAAE;IAC7B,MAAM,EAAEC,QAAQ,EAAE,GAAGF,MAAAA;AAErB,IAAA,KAAK,MAAMG,IAAAA,IAAQD,QAAAA,CAASE,UAAU,CAAE;QACpC,IAAI,EAAER,oBAAAA,CAAqBM,QAAAA,CAASC,IAAI,EAAEA,IAAAA,CAAAA,IAASH,MAAAA,CAAOI,UAAS,CAAA,EAAI;AACnEH,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,wBAAwB,EAAEF,IAAAA,CAAK,wCAAwC,CAAC,CAAA;AAC3F,QAAA;AACJ,IAAA;AAEA,IAAA,MAAMG,QAAAA,GAAW,IAAIC,GAAAA,CAAIL,QAAAA,CAASE,UAAU,CAACI,GAAG,CAAC,CAACL,IAAAA,GAASP,oBAAAA,CAAqBM,QAAA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,WAAW,EAAEqD,UAAAA,CAAWf,SAAS,CAAC,qDAAqD,CAAC,CAAA;AAC3G,QAAA;AAEA,QAAA,IAAIc,SAAAA,CAAU7C,GAAG,CAAC8C,UAAAA,CAAWf,SAAS,CAAA,EAAG;YACrC1C,QAAAA,CAASI,IAAI,CAAC,CAAC,WAAW,EAAEqD,UAAAA,CAAWf,SAAS,CAAC,gBAAgB,CAAC,CAAA;AACtE,QAAA;QAEAc,SAAAA,CAAUR,GAAG,CAACS,UAAAA,CAAWf,SAAS,CAAA;AAElCD,QAAAA,kBAAAA,CAAmBgB,WAAWf,SAAS,EAAEe,UAAAA,CAAWd,UAAU,EAAE,EAAA,EAAI3C,QAAAA,CAAAA;AACxE,IAAA;IAEA,OAAOA,QAAAA;AACX;AAEA;;;;;IAMO,SAAS2D,sBAAAA,CAAuBC,OAA6B,EAAA;IAChE,OAAOnD,MAAAA,CAAOoD,MAAM,CAAC,EAAC,EAAA,GAAMD,OAAAA,CAAQrD,GAAG,CAAC,CAACR,MAAAA,GAAWA,MAAAA,CAAOI,UAAU,CAAA,CAAA;AACzE;AAEA;;;;IAKO,SAAS2D,iBAAAA,CAAkBF,OAA6B,EAAA;IAC3D,OAAOG,yBAAAA,CAA0BH,QAAQI,OAAO,CAAC,CAACjE,MAAAA,GAAYA,MAAAA,CAAOiC,WAAW,GAAG;YAACjC,MAAAA,CAAOiC,WAAW,CAACM;AAAQ,SAAA,GAAG,EAAE,CAAA,CAAA;AACxH;;"}
|
|
1
|
+
{"version":3,"file":"ScenePackageBundle.js","sources":["../../../packages/ScenePackageBundle.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { validateComponentDescriptors } from '@cratis/scene.engine';\nimport { ComponentDescriptor, DiagnosticCode, DialogTemplate, Layout, PackageKind, PropertyDescriptor, PropertyValueType, ScenePackage, Screen, ScreenTemplate, Theme } from '@cratis/scene.model';\nimport { IconAdapterRegistry, createIconAdapterRegistry } from '../icons/IconAdapterRegistry';\nimport { IconLibraryBundle } from '../icons/IconLibraryBundle';\nimport { ComponentRegistry } from '../renderer';\nimport { ComponentsUiLibraryContract, validateComponentsUiLibraryContract } from './ComponentsUiLibraryContract';\nimport { DesignTimeBundle, validateDesignTimeBundle } from './DesignTimeBundle';\n\n/**\n * What a package actually ships to a React renderer, as opposed to what it *declares*.\n *\n * `ScenePackage` is the declaration — a name, a kind, dependencies, and the names of what it\n * contributes. It is deliberately platform-agnostic and lives in `Scene.Model`, because Stage's build and\n * Studio's design-time queries both read it without ever loading a component. A bundle is the other half:\n * the real React components, layouts, screens and themes behind those names, which only a renderer needs.\n *\n * A package publishes exactly one bundle, as a named export following its own name —\n * `primeReactPackage`, `cratisComponentsPackage`, `corePackage`. A host loads it from the module the\n * declaration's `ScenePackage.module` names.\n */\nexport interface ScenePackageBundle {\n /**\n * The package's own declaration. Its `components`, `layouts` and `themes` name lists must agree with\n * what this bundle actually provides — {@link validatePackageBundle} is what proves they do.\n */\n manifest: ScenePackage;\n\n /**\n * The components this package provides, keyed by {@link componentRegistryKey}.\n */\n components: ComponentRegistry;\n\n /**\n * The application shells this package provides, if any. Only a blueprint has these.\n */\n layouts?: Layout[];\n\n /**\n * The screen templates this package provides — the shapes that go inside a layout, each declaring\n * which of its parent's slots it fills.\n */\n screenTemplates?: ScreenTemplate[];\n\n /**\n * The dialog templates this package provides.\n */\n dialogTemplates?: DialogTemplate[];\n\n /**\n * Sample screens this package ships — a layout package's gallery, so a preview has real content to\n * put through the real engine rather than a mockup.\n */\n screens?: Screen[];\n\n /**\n * What can be edited on this package's components - one {@link ComponentDescriptor} per component that is\n * editable at design time. They are data, so Studio reads them without rendering anything, and they travel with\n * the components they describe rather than in a registry of their own. {@link validatePackageBundle} checks\n * that every descriptor names a component the manifest declares.\n */\n descriptors?: ComponentDescriptor[];\n\n /**\n * The themes this package ships, if any.\n */\n themes?: Theme[];\n\n /**\n * The icon catalog and renderer adapter of an icon-library package. Present exactly when the\n * manifest declares an icon library.\n */\n iconLibrary?: IconLibraryBundle;\n\n /**\n * Optional web-renderer mapping to a Components UiLibrary. Scene's catalog remains independently\n * authored; hosts check the loaded export with validateComponentsUiLibraryMapping before rendering.\n */\n componentsUiLibrary?: ComponentsUiLibraryContract;\n\n /** Optional React-only design-time tooling. Runtime hosts can omit it entirely. */\n designTime?: DesignTimeBundle;\n}\n\n/**\n * The key a component is registered and looked up under: the package that provides it, then the bare name\n * a screen refers to it by.\n *\n * A screen writes a bare name (`button`) or a package-qualified one (`PrimeReact.button`);\n * `resolveComponentName` turns either into a `{ name, package }` pair, and this turns that pair into the\n * registry key. Nothing should build this string by hand — the separator is an implementation detail of\n * the registry, deliberately not the `.` used for qualification in a screen, so a package name containing\n * dots stays unambiguous.\n */\nexport function componentRegistryKey(packageName: string, componentName: string): string {\n return `${packageName}:${componentName}`;\n}\n\n/**\n * Checks that a bundle provides everything its manifest declares, and declares everything it provides, and that\n * every descriptor it ships is for a component it declares and is well formed.\n *\n * A manifest that promises a component the bundle does not register renders as `UnresolvedComponent` at\n * runtime — a blank box, far from where the mistake was made. A component registered but not declared is\n * invisible to `resolveComponentName`, so a screen can never name it. Both are silent failures, which is\n * why every package's specs run this.\n */\nexport function validatePackageBundle(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const { manifest } = bundle;\n\n for (const name of manifest.components) {\n if (!(componentRegistryKey(manifest.name, name) in bundle.components)) {\n problems.push(`declares the component '${name}' but registers no implementation for it`);\n }\n }\n\n const declared = new Set(manifest.components.map((name) => componentRegistryKey(manifest.name, name)));\n for (const key of Object.keys(bundle.components)) {\n if (!declared.has(key)) {\n problems.push(`registers '${key}', which the manifest does not declare`);\n }\n }\n\n const providedLayouts = new Set((bundle.layouts ?? []).map((layout) => layout.name));\n for (const name of manifest.layouts) {\n if (!providedLayouts.has(name)) {\n problems.push(`declares the layout '${name}' but provides no definition for it`);\n }\n }\n\n const providedScreenTemplates = new Set((bundle.screenTemplates ?? []).map((template) => template.name));\n for (const name of manifest.screenTemplates) {\n if (!providedScreenTemplates.has(name)) {\n problems.push(`declares the screen template '${name}' but provides no definition for it`);\n }\n }\n\n const providedDialogTemplates = new Set((bundle.dialogTemplates ?? []).map((template) => template.name));\n for (const name of manifest.dialogTemplates) {\n if (!providedDialogTemplates.has(name)) {\n problems.push(`declares the dialog template '${name}' but provides no definition for it`);\n }\n }\n\n const providedThemes = new Set((bundle.themes ?? []).map((theme) => theme.name));\n for (const name of manifest.themes) {\n if (!providedThemes.has(name)) {\n problems.push(`declares the theme '${name}' but provides no definition for it`);\n }\n }\n\n if (bundle.componentsUiLibrary) {\n if (manifest.kind !== PackageKind.ComponentLibrary) {\n problems.push('declares a Components UI library mapping but is not of kind ComponentLibrary');\n }\n problems.push(...validateComponentsUiLibraryContract(bundle.componentsUiLibrary));\n }\n\n problems.push(...validateIconLibrary(bundle));\n problems.push(...validateDescriptors(bundle));\n problems.push(...validateDesignTimeBundle(bundle.designTime));\n\n return problems;\n}\n\nfunction validateIconLibrary(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const { manifest, iconLibrary } = bundle;\n const declaresIconLibrary = manifest.kind === PackageKind.IconLibrary || manifest.iconLibrary !== undefined;\n\n if (manifest.kind === PackageKind.IconLibrary && !manifest.iconLibrary) {\n problems.push('is an icon library but declares no iconLibrary metadata');\n }\n\n if (manifest.kind !== PackageKind.IconLibrary && manifest.iconLibrary) {\n problems.push('declares iconLibrary metadata but is not of kind IconLibrary');\n }\n\n if (declaresIconLibrary && !iconLibrary) {\n problems.push('declares an icon library but the bundle provides no catalog or adapter for it');\n }\n\n if (!declaresIconLibrary && iconLibrary) {\n problems.push('provides an icon catalog and adapter, which the manifest does not declare');\n }\n\n if (iconLibrary) {\n if (iconLibrary.catalog.library !== manifest.name) {\n problems.push(`provides an icon catalog for '${iconLibrary.catalog.library}' instead of '${manifest.name}'`);\n }\n\n if (iconLibrary.adapter.library !== manifest.name) {\n problems.push(`provides an icon adapter for '${iconLibrary.adapter.library}' instead of '${manifest.name}'`);\n }\n\n if (manifest.iconLibrary && !manifest.iconLibrary.renderers.includes('react')) {\n problems.push(\"provides a React icon adapter but does not list 'react' among its icon renderers\");\n }\n }\n\n return problems;\n}\n\nfunction validateProperties(component: string, properties: PropertyDescriptor[], parent: string, problems: string[]): void {\n const paths = new Set<string>();\n for (const property of properties) {\n const path = `${parent}${property.path}`;\n if (paths.has(property.path)) {\n problems.push(`'${component}' describes the property '${path}' more than once`);\n }\n\n paths.add(property.path);\n\n if (property.valueType === PropertyValueType.Collection && property.item === undefined) {\n problems.push(`'${component}' describes the collection '${path}' without describing its items`);\n }\n\n if (property.valueType === PropertyValueType.Collection && property.item !== undefined) {\n validateProperties(component, property.item.properties, `${path}[].`, problems);\n }\n\n if (property.valueType === PropertyValueType.Object && property.properties !== undefined) {\n validateProperties(component, property.properties, `${path}.`, problems);\n }\n\n if (property.valueType === PropertyValueType.Enum && (property.choices ?? []).length === 0) {\n problems.push(`'${component}' describes the enum '${path}' without choices`);\n }\n }\n}\n\nfunction validateDescriptors(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const declared = new Set(bundle.manifest.components.map((name) => componentRegistryKey(bundle.manifest.name, name)));\n const described = new Set<string>();\n\n for (const descriptor of bundle.descriptors ?? []) {\n if (!declared.has(descriptor.component)) {\n problems.push(`describes '${descriptor.component}', which the manifest does not declare as a component`);\n }\n\n if (described.has(descriptor.component)) {\n problems.push(`describes '${descriptor.component}' more than once`);\n }\n\n described.add(descriptor.component);\n\n validateProperties(descriptor.component, descriptor.properties, '', problems);\n }\n\n // The category rule (CMP1) is not checked here - it gates a designer, not a host loading a package (see validateComponentMetadata) -\n // but a design-mode descriptor or editor parameter that cannot work is as much a mistake as an enum without choices.\n const structural: string[] = [DiagnosticCode.ComponentDesignModeInvalid, DiagnosticCode.PropertyEditorOptionsInvalid];\n problems.push(...validateComponentDescriptors(bundle.descriptors ?? []).filter(diagnostic => structural.includes(diagnostic.code)).map(diagnostic => diagnostic.message));\n\n return problems;\n}\n\n/**\n * Merges the component registries of several bundles into the single registry a renderer consumes.\n *\n * Keys carry their package name, so nothing collides and merge order does not matter — which package wins\n * a *bare* name is decided earlier, by `resolveComponentName` walking the profile's priority order.\n */\nexport function mergePackageRegistries(bundles: ScenePackageBundle[]): ComponentRegistry {\n return Object.assign({}, ...bundles.map((bundle) => bundle.components)) as ComponentRegistry;\n}\n\n/**\n * Collects the icon adapters of several bundles into the registry `SceneIcon` renders through.\n *\n * @throws Error when two bundles provide an adapter for the same library.\n */\nexport function mergeIconAdapters(bundles: ScenePackageBundle[]): IconAdapterRegistry {\n return createIconAdapterRegistry(bundles.flatMap((bundle) => (bundle.iconLibrary ? [bundle.iconLibrary.adapter] : [])));\n}\n"],"names":["componentRegistryKey","packageName","componentName","validatePackageBundle","bundle","problems","manifest","name","components","push","declared","Set","map","key","Object","keys","has","providedLayouts","layouts","layout","providedScreenTemplates","screenTemplates","template","providedDialogTemplates","dialogTemplates","providedThemes","themes","theme","componentsUiLibrary","kind","PackageKind","ComponentLibrary","validateComponentsUiLibraryContract","validateIconLibrary","validateDescriptors","validateDesignTimeBundle","designTime","iconLibrary","declaresIconLibrary","IconLibrary","undefined","catalog","library","adapter","renderers","includes","validateProperties","component","properties","parent","paths","property","path","add","valueType","PropertyValueType","Collection","item","Enum","choices","length","described","descriptor","descriptors","structural","DiagnosticCode","ComponentDesignModeInvalid","PropertyEditorOptionsInvalid","validateComponentDescriptors","filter","diagnostic","code","message","mergePackageRegistries","bundles","assign","mergeIconAdapters","createIconAdapterRegistry","flatMap"],"mappings":";;;;;;AAAA;AACA;AAqFA;;;;;;;;;AASC,IACM,SAASA,oBAAAA,CAAqBC,WAAmB,EAAEC,aAAqB,EAAA;AAC3E,IAAA,OAAO,CAAA,EAAGD,WAAAA,CAAY,CAAC,EAAEC,aAAAA,CAAAA,CAAe;AAC5C;AAEA;;;;;;;;IASO,SAASC,qBAAAA,CAAsBC,MAA0B,EAAA;AAC5D,IA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A,CAAWC,IAAI,CAAA,CAAA,CAAG3D,GAAG,CAAC0D,CAAAA,UAAAA,GAAcA,UAAAA,CAAWE,OAAO,CAAA,CAAA;IAEvK,OAAOnE,QAAAA;AACX;AAEA;;;;;IAMO,SAASoE,sBAAAA,CAAuBC,OAA6B,EAAA;IAChE,OAAO5D,MAAAA,CAAO6D,MAAM,CAAC,EAAC,EAAA,GAAMD,OAAAA,CAAQ9D,GAAG,CAAC,CAACR,MAAAA,GAAWA,MAAAA,CAAOI,UAAU,CAAA,CAAA;AACzE;AAEA;;;;IAKO,SAASoE,iBAAAA,CAAkBF,OAA6B,EAAA;IAC3D,OAAOG,yBAAAA,CAA0BH,QAAQI,OAAO,CAAC,CAAC1E,MAAAA,GAAYA,MAAAA,CAAOiC,WAAW,GAAG;YAACjC,MAAAA,CAAOiC,WAAW,CAACM;AAAQ,SAAA,GAAG,EAAE,CAAA,CAAA;AACxH;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentDescriptor, ComponentDesignModeDescriptor } from '@cratis/scene.model';
|
|
2
|
+
export interface ComponentMetadata {
|
|
3
|
+
displayName?: string;
|
|
4
|
+
category: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
keywords?: string[];
|
|
7
|
+
badge?: string;
|
|
8
|
+
designMode?: ComponentDesignModeDescriptor;
|
|
9
|
+
}
|
|
10
|
+
export declare function componentMetadata(displayName: string, category: string, icon: string, keywords?: string[], badge?: string, designMode?: ComponentDesignModeDescriptor): ComponentMetadata;
|
|
11
|
+
export declare function describeComponents(packageName: string, described: readonly ComponentDescriptor[], metadata: Readonly<Record<string, ComponentMetadata>>): ComponentDescriptor[];
|
|
12
|
+
//# sourceMappingURL=describeComponents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describeComponents.d.ts","sourceRoot":"","sources":["../../../packages/describeComponents.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAiB,MAAM,qBAAqB,CAAC;AAOxG,MAAM,WAAW,iBAAiB;IAE9B,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,QAAQ,EAAE,MAAM,CAAC;IAGjB,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAGpB,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,UAAU,CAAC,EAAE,6BAA6B,CAAC;CAC9C;AAGD,wBAAgB,iBAAiB,CAC7B,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAM,EAAO,EACvB,KAAK,CAAC,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,6BAA6B,GAC3C,iBAAiB,CAEnB;AAWD,wBAAgB,kBAAkB,CAC9B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,SAAS,mBAAmB,EAAE,EACzC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,GACtD,mBAAmB,EAAE,CAQvB"}
|