@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,61 @@
|
|
|
1
|
+
import { componentIcon } from '@cratis/scene.model';
|
|
2
|
+
import { componentRegistryKey } from './ScenePackageBundle.js';
|
|
3
|
+
|
|
4
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
5
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
6
|
+
/** A `ComponentMetadata` entry in one line: what a package's metadata table is made of. */ function componentMetadata(displayName, category, icon, keywords = [], badge, designMode) {
|
|
7
|
+
return {
|
|
8
|
+
displayName,
|
|
9
|
+
category,
|
|
10
|
+
icon,
|
|
11
|
+
keywords,
|
|
12
|
+
...badge === undefined ? {} : {
|
|
13
|
+
badge
|
|
14
|
+
},
|
|
15
|
+
...designMode === undefined ? {} : {
|
|
16
|
+
designMode
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Builds the descriptors a bundle ships: the ones written by hand with the package's component metadata merged in, plus a descriptor with
|
|
22
|
+
* no editable properties for every component the metadata names that nobody described - such a component still has a name, a
|
|
23
|
+
* category and a place in a picker. A hand-written descriptor keeps everything it already says; metadata only fills in what it
|
|
24
|
+
* leaves out.
|
|
25
|
+
*
|
|
26
|
+
* The component list is the metadata table's own, so a component the table forgets has no descriptor and `validateComponentMetadata`
|
|
27
|
+
* reports it (CMP1); one the table names but the manifest does not declare is reported by `validatePackageBundle`.
|
|
28
|
+
*/ function describeComponents(packageName, described, metadata) {
|
|
29
|
+
const describedKeys = new Set(described.map((descriptor)=>descriptor.component));
|
|
30
|
+
const bare = Object.keys(metadata).map((name)=>componentRegistryKey(packageName, name)).filter((key)=>!describedKeys.has(key)).map((key)=>({
|
|
31
|
+
component: key,
|
|
32
|
+
properties: []
|
|
33
|
+
}));
|
|
34
|
+
return [
|
|
35
|
+
...described,
|
|
36
|
+
...bare
|
|
37
|
+
].map((descriptor)=>withMetadata(descriptor, metadata[descriptor.component.slice(packageName.length + 1)]));
|
|
38
|
+
}
|
|
39
|
+
function withMetadata(descriptor, metadata) {
|
|
40
|
+
if (!metadata) return descriptor;
|
|
41
|
+
return {
|
|
42
|
+
...descriptor,
|
|
43
|
+
displayName: descriptor.displayName ?? metadata.displayName ?? descriptor.component.slice(descriptor.component.indexOf(':') + 1),
|
|
44
|
+
category: descriptor.category ?? metadata.category,
|
|
45
|
+
...descriptor.icon === undefined && metadata.icon !== undefined ? {
|
|
46
|
+
icon: componentIcon(metadata.icon)
|
|
47
|
+
} : {},
|
|
48
|
+
...descriptor.keywords === undefined && metadata.keywords !== undefined ? {
|
|
49
|
+
keywords: metadata.keywords
|
|
50
|
+
} : {},
|
|
51
|
+
...descriptor.badge === undefined && metadata.badge !== undefined ? {
|
|
52
|
+
badge: metadata.badge
|
|
53
|
+
} : {},
|
|
54
|
+
...descriptor.designMode === undefined && metadata.designMode !== undefined ? {
|
|
55
|
+
designMode: metadata.designMode
|
|
56
|
+
} : {}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { componentMetadata, describeComponents };
|
|
61
|
+
//# sourceMappingURL=describeComponents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describeComponents.js","sources":["../../../packages/describeComponents.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, ComponentDesignModeDescriptor, componentIcon } from '@cratis/scene.model';\nimport { componentRegistryKey } from './ScenePackageBundle';\n\n/**\n * What a package says about one of its components for a picker, besides what can be edited: the data of CMP1 and the picker's\n * rows. Written once per package as a table keyed by the bare component name.\n */\nexport interface ComponentMetadata {\n /** The name a picker shows. Absent keeps the one the component's descriptor has, or the bare name. */\n displayName?: string;\n\n /** One of `ComponentCategory`, or a category of the package's own. */\n category: string;\n\n /** The key of the icon in the built-in icon library (`componentIcon`). */\n icon?: string;\n\n /** Words the picker's filter matches besides the name. */\n keywords?: string[];\n\n /** An explicit two-letter badge; absent means derived from the name. */\n badge?: string;\n\n /** How the component is edited directly on the design surface. */\n designMode?: ComponentDesignModeDescriptor;\n}\n\n/** A `ComponentMetadata` entry in one line: what a package's metadata table is made of. */\nexport function componentMetadata(\n displayName: string,\n category: string,\n icon: string,\n keywords: string[] = [],\n badge?: string,\n designMode?: ComponentDesignModeDescriptor\n): ComponentMetadata {\n return { displayName, category, icon, keywords, ...(badge === undefined ? {} : { badge }), ...(designMode === undefined ? {} : { designMode }) };\n}\n\n/**\n * Builds the descriptors a bundle ships: the ones written by hand with the package's component metadata merged in, plus a descriptor with\n * no editable properties for every component the metadata names that nobody described - such a component still has a name, a\n * category and a place in a picker. A hand-written descriptor keeps everything it already says; metadata only fills in what it\n * leaves out.\n *\n * The component list is the metadata table's own, so a component the table forgets has no descriptor and `validateComponentMetadata`\n * reports it (CMP1); one the table names but the manifest does not declare is reported by `validatePackageBundle`.\n */\nexport function describeComponents(\n packageName: string,\n described: readonly ComponentDescriptor[],\n metadata: Readonly<Record<string, ComponentMetadata>>\n): ComponentDescriptor[] {\n const describedKeys = new Set(described.map(descriptor => descriptor.component));\n const bare = Object.keys(metadata)\n .map(name => componentRegistryKey(packageName, name))\n .filter(key => !describedKeys.has(key))\n .map((key): ComponentDescriptor => ({ component: key, properties: [] }));\n\n return [...described, ...bare].map(descriptor => withMetadata(descriptor, metadata[descriptor.component.slice(packageName.length + 1)]));\n}\n\nfunction withMetadata(descriptor: ComponentDescriptor, metadata: ComponentMetadata | undefined): ComponentDescriptor {\n if (!metadata) return descriptor;\n\n return {\n ...descriptor,\n displayName: descriptor.displayName ?? metadata.displayName ?? descriptor.component.slice(descriptor.component.indexOf(':') + 1),\n category: descriptor.category ?? metadata.category,\n ...(descriptor.icon === undefined && metadata.icon !== undefined ? { icon: componentIcon(metadata.icon) } : {}),\n ...(descriptor.keywords === undefined && metadata.keywords !== undefined ? { keywords: metadata.keywords } : {}),\n ...(descriptor.badge === undefined && metadata.badge !== undefined ? { badge: metadata.badge } : {}),\n ...(descriptor.designMode === undefined && metadata.designMode !== undefined ? { designMode: metadata.designMode } : {}),\n };\n}\n"],"names":["componentMetadata","displayName","category","icon","keywords","badge","designMode","undefined","describeComponents","packageName","described","metadata","describedKeys","Set","map","descriptor","component","bare","Object","keys","name","componentRegistryKey","filter","key","has","properties","withMetadata","slice","length","indexOf","componentIcon"],"mappings":";;;AAAA;AACA;AA6BA,4FACO,SAASA,iBAAAA,CACZC,WAAmB,EACnBC,QAAgB,EAChBC,IAAY,EACZC,QAAAA,GAAqB,EAAE,EACvBC,KAAc,EACdC,UAA0C,EAAA;IAE1C,OAAO;AAAEL,QAAAA,WAAAA;AAAaC,QAAAA,QAAAA;AAAUC,QAAAA,IAAAA;AAAMC,QAAAA,QAAAA;QAAU,GAAIC,KAAAA,KAAUE,SAAAA,GAAY,EAAC,GAAI;AAAEF,YAAAA;SAAO;QAAG,GAAIC,UAAAA,KAAeC,SAAAA,GAAY,EAAC,GAAI;AAAED,YAAAA;;AAAc,KAAA;AACnJ;AAEA;;;;;;;;AAQC,IACM,SAASE,kBAAAA,CACZC,WAAmB,EACnBC,SAAyC,EACzCC,QAAqD,EAAA;IAErD,MAAMC,aAAAA,GAAgB,IA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M2B,aAAAA,CAAcnB,SAASR,IAAI;AAAE,SAAA,GAAI,EAAE;AAC9G,QAAA,GAAIY,WAAWX,QAAQ,KAAKG,aAAaI,QAAAA,CAASP,QAAQ,KAAKG,SAAAA,GAAY;AAAEH,YAAAA,QAAAA,EAAUO,SAASP;AAAS,SAAA,GAAI,EAAE;AAC/G,QAAA,GAAIW,WAAWV,KAAK,KAAKE,aAAaI,QAAAA,CAASN,KAAK,KAAKE,SAAAA,GAAY;AAAEF,YAAAA,KAAAA,EAAOM,SAASN;AAAM,SAAA,GAAI,EAAE;AACnG,QAAA,GAAIU,WAAWT,UAAU,KAAKC,aAAaI,QAAAA,CAASL,UAAU,KAAKC,SAAAA,GAAY;AAAED,YAAAA,UAAAA,EAAYK,SAASL;AAAW,SAAA,GAAI;AACzH,KAAA;AACJ;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ComponentDesignModeDescriptor } from '@cratis/scene.model';
|
|
2
|
+
export declare const itemEditableRule = "item.editable";
|
|
3
|
+
export declare const itemInheritedReason = "item.inherited";
|
|
4
|
+
export interface NavigationDesignModeOptions {
|
|
5
|
+
itemsPath?: string;
|
|
6
|
+
sidebar?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function navigationDesignMode(options?: NavigationDesignModeOptions): ComponentDesignModeDescriptor;
|
|
9
|
+
export declare function toolbarDesignMode(): ComponentDesignModeDescriptor;
|
|
10
|
+
//# sourceMappingURL=designModes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"designModes.d.ts","sourceRoot":"","sources":["../../../packages/designModes.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,6BAA6B,EAAuC,MAAM,qBAAqB,CAAC;AAGzG,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAGhD,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAWpD,MAAM,WAAW,2BAA2B;IAExC,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAQD,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,2BAAgC,GAAG,6BAA6B,CAoB7G;AAMD,wBAAgB,iBAAiB,IAAI,6BAA6B,CAajE"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { componentIcon } from '@cratis/scene.model';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/** The rule that says an item may be changed (not inherited), interpreted by the package's design-time bundle. */ const itemEditableRule = 'item.editable';
|
|
6
|
+
/** The rule that says why an inherited item may not be changed. */ const itemInheritedReason = 'item.inherited';
|
|
7
|
+
const mutating = (action, compact)=>({
|
|
8
|
+
id: action.id,
|
|
9
|
+
icon: componentIcon(action.icon),
|
|
10
|
+
title: action.title,
|
|
11
|
+
...compact === true ? {
|
|
12
|
+
compact: true
|
|
13
|
+
} : {},
|
|
14
|
+
availability: action.availability ?? itemEditableRule,
|
|
15
|
+
readOnlyReason: itemInheritedReason
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* The design mode of a component made of navigation items (a topbar, a sidebar, a navigation bar): add an item, and on a selected
|
|
19
|
+
* item rename it, choose its target and rendering slot, move it earlier or later, duplicate it, delete it, and - in a sidebar - add a
|
|
20
|
+
* sub-item (spec DM3). Pass the `itemsPath` of a component whose items are a `Collection` property; the target and slot buttons are
|
|
21
|
+
* left out of such a component unless `itemsPath` is absent, because only the navigation region's items have them.
|
|
22
|
+
*/ function navigationDesignMode(options = {}) {
|
|
23
|
+
const { itemsPath, sidebar = false } = options;
|
|
24
|
+
const regionItems = itemsPath === undefined;
|
|
25
|
+
return {
|
|
26
|
+
...itemsPath === undefined ? {} : {
|
|
27
|
+
itemsPath
|
|
28
|
+
},
|
|
29
|
+
addActions: [
|
|
30
|
+
{
|
|
31
|
+
id: 'addItem',
|
|
32
|
+
label: 'Add item',
|
|
33
|
+
icon: componentIcon('plus'),
|
|
34
|
+
...itemsPath === undefined ? {} : {
|
|
35
|
+
collectionPath: itemsPath
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
itemToolbar: [
|
|
40
|
+
mutating({
|
|
41
|
+
id: 'rename',
|
|
42
|
+
icon: 'pencil',
|
|
43
|
+
title: 'Rename'
|
|
44
|
+
}, sidebar),
|
|
45
|
+
...regionItems ? [
|
|
46
|
+
mutating({
|
|
47
|
+
id: 'target',
|
|
48
|
+
icon: 'link',
|
|
49
|
+
title: 'Link target'
|
|
50
|
+
}, sidebar),
|
|
51
|
+
mutating({
|
|
52
|
+
id: 'slot',
|
|
53
|
+
icon: 'layout-panel-left',
|
|
54
|
+
title: 'Rendering slot'
|
|
55
|
+
}, sidebar)
|
|
56
|
+
] : [],
|
|
57
|
+
mutating({
|
|
58
|
+
id: 'moveEarlier',
|
|
59
|
+
icon: sidebar ? 'arrow-up' : 'arrow-left',
|
|
60
|
+
title: 'Move earlier'
|
|
61
|
+
}, sidebar),
|
|
62
|
+
mutating({
|
|
63
|
+
id: 'moveLater',
|
|
64
|
+
icon: sidebar ? 'arrow-down' : 'arrow-right',
|
|
65
|
+
title: 'Move later'
|
|
66
|
+
}, sidebar),
|
|
67
|
+
mutating({
|
|
68
|
+
id: 'duplicate',
|
|
69
|
+
icon: 'copy',
|
|
70
|
+
title: 'Duplicate'
|
|
71
|
+
}, sidebar),
|
|
72
|
+
mutating({
|
|
73
|
+
id: 'delete',
|
|
74
|
+
icon: 'trash',
|
|
75
|
+
title: 'Delete'
|
|
76
|
+
}, sidebar),
|
|
77
|
+
...sidebar ? [
|
|
78
|
+
mutating({
|
|
79
|
+
id: 'addSubItem',
|
|
80
|
+
icon: 'corner-down-right',
|
|
81
|
+
title: 'Add sub-item'
|
|
82
|
+
}, true)
|
|
83
|
+
] : []
|
|
84
|
+
]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The design mode of a toolbar: add a button, and on a selected button rename it, choose the slice it starts, set its emphasis,
|
|
89
|
+
* move it earlier or later, duplicate it, delete it (spec DM3). The buttons are the toolbar's own items, which the host resolves.
|
|
90
|
+
*/ function toolbarDesignMode() {
|
|
91
|
+
return {
|
|
92
|
+
addActions: [
|
|
93
|
+
{
|
|
94
|
+
id: 'addButton',
|
|
95
|
+
label: 'Add button',
|
|
96
|
+
icon: componentIcon('plus')
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
itemToolbar: [
|
|
100
|
+
mutating({
|
|
101
|
+
id: 'rename',
|
|
102
|
+
icon: 'pencil',
|
|
103
|
+
title: 'Rename'
|
|
104
|
+
}),
|
|
105
|
+
mutating({
|
|
106
|
+
id: 'slice',
|
|
107
|
+
icon: 'git-branch',
|
|
108
|
+
title: 'Choose slice'
|
|
109
|
+
}),
|
|
110
|
+
mutating({
|
|
111
|
+
id: 'emphasis',
|
|
112
|
+
icon: 'contrast',
|
|
113
|
+
title: 'Emphasis'
|
|
114
|
+
}),
|
|
115
|
+
mutating({
|
|
116
|
+
id: 'moveEarlier',
|
|
117
|
+
icon: 'arrow-left',
|
|
118
|
+
title: 'Move earlier'
|
|
119
|
+
}),
|
|
120
|
+
mutating({
|
|
121
|
+
id: 'moveLater',
|
|
122
|
+
icon: 'arrow-right',
|
|
123
|
+
title: 'Move later'
|
|
124
|
+
}),
|
|
125
|
+
mutating({
|
|
126
|
+
id: 'duplicate',
|
|
127
|
+
icon: 'copy',
|
|
128
|
+
title: 'Duplicate'
|
|
129
|
+
}),
|
|
130
|
+
mutating({
|
|
131
|
+
id: 'delete',
|
|
132
|
+
icon: 'trash',
|
|
133
|
+
title: 'Delete'
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export { itemEditableRule, itemInheritedReason, navigationDesignMode, toolbarDesignMode };
|
|
140
|
+
//# 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,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AA;YAClEN,QAAAA,CAAS;gBAAEG,EAAAA,EAAI,UAAA;gBAAYC,IAAAA,EAAM,UAAA;gBAAYE,KAAAA,EAAO;AAAW,aAAA,CAAA;YAC/DN,QAAAA,CAAS;gBAAEG,EAAAA,EAAI,aAAA;gBAAeC,IAAAA,EAAM,YAAA;gBAAcE,KAAAA,EAAO;AAAe,aAAA,CAAA;YACxEN,QAAAA,CAAS;gBAAEG,EAAAA,EAAI,WAAA;gBAAaC,IAAAA,EAAM,aAAA;gBAAeE,KAAAA,EAAO;AAAa,aAAA,CAAA;YACrEN,QAAAA,CAAS;gBAAEG,EAAAA,EAAI,WAAA;gBAAaC,IAAAA,EAAM,MAAA;gBAAQE,KAAAA,EAAO;AAAY,aAAA,CAAA;YAC7DN,QAAAA,CAAS;gBAAEG,EAAAA,EAAI,QAAA;gBAAUC,IAAAA,EAAM,OAAA;gBAASE,KAAAA,EAAO;AAAS,aAAA;AAC3D;AACL,KAAA;AACJ;;"}
|
|
@@ -23,6 +23,9 @@ export * from './PackageHostView';
|
|
|
23
23
|
export * from './resolveDesignTimeHost';
|
|
24
24
|
export * from './runDesignTimeAction';
|
|
25
25
|
export * from './ScenePackageBundle';
|
|
26
|
+
export * from './describeComponents';
|
|
27
|
+
export * from './designModes';
|
|
28
|
+
export * from './validateComponentMetadata';
|
|
26
29
|
export * from './StandalonePackageHost';
|
|
27
30
|
export * from './WebViewPackageHost';
|
|
28
31
|
export * from './ComponentsUiLibraryContract';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/index.ts"],"names":[],"mappings":"AAGA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,c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AAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC"}
|
|
@@ -23,6 +23,9 @@ export * from './PackageHostView';
|
|
|
23
23
|
export * from './resolveDesignTimeHost';
|
|
24
24
|
export * from './runDesignTimeAction';
|
|
25
25
|
export * from './ScenePackageBundle';
|
|
26
|
+
export * from './describeComponents';
|
|
27
|
+
export * from './designModes';
|
|
28
|
+
export * from './validateComponentMetadata';
|
|
26
29
|
export * from './StandalonePackageHost';
|
|
27
30
|
export * from './WebViewPackageHost';
|
|
28
31
|
export * from './ComponentsUiLibraryContract';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/index.ts"],"names":[],"mappings":"AAGA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/index.ts"],"names":[],"mappings":"AAGA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateComponentMetadata.d.ts","sourceRoot":"","sources":["../../../packages/validateComponentMetadata.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAwB,MAAM,sBAAsB,CAAC;AAShF,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,kBAAkB,GAAG,eAAe,EAAE,CAOvF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { validateComponentDescriptors } from '@cratis/scene.engine';
|
|
2
|
+
import { componentRegistryKey } from './ScenePackageBundle.js';
|
|
3
|
+
|
|
4
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
5
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
6
|
+
/**
|
|
7
|
+
* Checks the component metadata of a bundle (rule CMP1): every component its manifest declares or its registry holds is described
|
|
8
|
+
* and declares a category, and the design-mode and editor parameters of its descriptors are sound.
|
|
9
|
+
*
|
|
10
|
+
* This is not part of `validatePackageBundle`: that gates what a host loads, and a third-party package written before components
|
|
11
|
+
* had categories must still load. A designer and the in-repo packages' own specs run this one.
|
|
12
|
+
*/ function validateComponentMetadata(bundle) {
|
|
13
|
+
const registered = new Set([
|
|
14
|
+
...bundle.manifest.components.map((name)=>componentRegistryKey(bundle.manifest.name, name)),
|
|
15
|
+
...Object.keys(bundle.components)
|
|
16
|
+
]);
|
|
17
|
+
return validateComponentDescriptors(bundle.descriptors ?? [], [
|
|
18
|
+
...registered
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { validateComponentMetadata };
|
|
23
|
+
//# 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,oBAAAA,CAAqBP,MAAAA,CAAOG,QAAQ,CAACG,IAAI,EAAEA,IAAAA,CAAAA,CAAAA;WAClFE,MAAAA,CAAOC,IAAI,CAACT,MAAAA,CAAOI,UAAU;AACnC,KAAA,CAAA;AAED,IAAA,OAAOM,4BAAAA,CAA6BV,MAAAA,CAAOW,WAAW,IAAI,EAAE,EAAE;AAAIV,QAAAA,GAAAA;AAAW,KAAA,CAAA;AACjF;;"}
|