@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.
Files changed (51) hide show
  1. package/core/coreComponentMetadata.ts +27 -0
  2. package/core/coreDescriptors.ts +6 -2
  3. package/dist/cjs/core/coreComponentMetadata.js +109 -0
  4. package/dist/cjs/core/coreComponentMetadata.js.map +1 -0
  5. package/dist/cjs/core/coreDescriptors.js +4 -1
  6. package/dist/cjs/core/coreDescriptors.js.map +1 -1
  7. package/dist/cjs/index.js +10 -0
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/cjs/packages/ScenePackageBundle.js +8 -0
  10. package/dist/cjs/packages/ScenePackageBundle.js.map +1 -1
  11. package/dist/cjs/packages/describeComponents.js +64 -0
  12. package/dist/cjs/packages/describeComponents.js.map +1 -0
  13. package/dist/cjs/packages/designModes.js +145 -0
  14. package/dist/cjs/packages/designModes.js.map +1 -0
  15. package/dist/cjs/packages/validateComponentMetadata.js +25 -0
  16. package/dist/cjs/packages/validateComponentMetadata.js.map +1 -0
  17. package/dist/esm/core/coreComponentMetadata.d.ts +3 -0
  18. package/dist/esm/core/coreComponentMetadata.d.ts.map +1 -0
  19. package/dist/esm/core/coreComponentMetadata.js +107 -0
  20. package/dist/esm/core/coreComponentMetadata.js.map +1 -0
  21. package/dist/esm/core/coreDescriptors.d.ts.map +1 -1
  22. package/dist/esm/core/coreDescriptors.js +4 -1
  23. package/dist/esm/core/coreDescriptors.js.map +1 -1
  24. package/dist/esm/index.js +3 -0
  25. package/dist/esm/index.js.map +1 -1
  26. package/dist/esm/packages/ScenePackageBundle.d.ts.map +1 -1
  27. package/dist/esm/packages/ScenePackageBundle.js +9 -1
  28. package/dist/esm/packages/ScenePackageBundle.js.map +1 -1
  29. package/dist/esm/packages/describeComponents.d.ts +12 -0
  30. package/dist/esm/packages/describeComponents.d.ts.map +1 -0
  31. package/dist/esm/packages/describeComponents.js +61 -0
  32. package/dist/esm/packages/describeComponents.js.map +1 -0
  33. package/dist/esm/packages/designModes.d.ts +10 -0
  34. package/dist/esm/packages/designModes.d.ts.map +1 -0
  35. package/dist/esm/packages/designModes.js +140 -0
  36. package/dist/esm/packages/designModes.js.map +1 -0
  37. package/dist/esm/packages/index.d.ts +3 -0
  38. package/dist/esm/packages/index.d.ts.map +1 -1
  39. package/dist/esm/packages/index.js +3 -0
  40. package/dist/esm/packages/index.js.map +1 -1
  41. package/dist/esm/packages/validateComponentMetadata.d.ts +4 -0
  42. package/dist/esm/packages/validateComponentMetadata.d.ts.map +1 -0
  43. package/dist/esm/packages/validateComponentMetadata.js +23 -0
  44. package/dist/esm/packages/validateComponentMetadata.js.map +1 -0
  45. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  46. package/package.json +5 -5
  47. package/packages/ScenePackageBundle.ts +7 -1
  48. package/packages/describeComponents.ts +78 -0
  49. package/packages/designModes.ts +74 -0
  50. package/packages/index.ts +3 -0
  51. package/packages/validateComponentMetadata.ts +22 -0
@@ -0,0 +1,27 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { ComponentCategory } from '@cratis/scene.model';
5
+ import { ComponentMetadata, componentMetadata as m, navigationDesignMode, toolbarDesignMode } from '../packages';
6
+
7
+ /** The category, icon, keywords and picker badge of every component of the package (CMP1), keyed by bare component name. */
8
+ export const coreComponentMetadata: Record<string, ComponentMetadata> = {
9
+ text: m('Text', ComponentCategory.DataDisplay, 'type', ['label', 'paragraph', 'copy']),
10
+ button: m('Button', ComponentCategory.Actions, 'mouse-pointer-click', ['click', 'submit', 'action'], 'Bt'),
11
+ card: m('Card', ComponentCategory.Layout, 'square', ['panel', 'box', 'container']),
12
+ data: m('Data', ComponentCategory.DataDisplay, 'database', ['read model', 'query', 'source']),
13
+ action: m('Command action', ComponentCategory.Actions, 'zap', ['command', 'invoke', 'submit']),
14
+ section: m('Section', ComponentCategory.Layout, 'layout-panel-top', ['group', 'area', 'block']),
15
+ navigate: m('Navigate', ComponentCategory.Navigation, 'corner-down-right', ['link', 'go to', 'route']),
16
+ title: m('Title', ComponentCategory.DataDisplay, 'heading', ['heading', 'header', 'caption']),
17
+ table: m('Table', ComponentCategory.DataDisplay, 'table', ['grid', 'rows', 'list'], 'Tb'),
18
+ column: m('Table column', ComponentCategory.DataDisplay, 'columns-3', ['heading', 'field']),
19
+ summary: m('Summary', ComponentCategory.DataDisplay, 'list', ['details', 'overview', 'facts']),
20
+ field: m('Summary field', ComponentCategory.DataDisplay, 'tag', ['label', 'value', 'pair']),
21
+ code: m('Code', ComponentCategory.DataDisplay, 'code', ['snippet', 'source', 'monospace']),
22
+ file: m('File reference', ComponentCategory.DataDisplay, 'file', ['include', 'import', 'screen file']),
23
+ navigationBar: m('Navigation bar', ComponentCategory.Navigation, 'navigation', ['menu', 'nav', 'links'], undefined, navigationDesignMode({ itemsPath: 'items' })),
24
+ outlet: m('Outlet', ComponentCategory.Layout, 'panel-right', ['region', 'slot', 'side panel']),
25
+ toolbar: m('Toolbar', ComponentCategory.Actions, 'wrench', ['actions', 'buttons', 'command bar'], 'Tl', toolbarDesignMode()),
26
+ toolbarItem: m('Toolbar item', ComponentCategory.Actions, 'mouse-pointer-click', ['button', 'action']),
27
+ };
@@ -2,7 +2,8 @@
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
 
4
4
  import { ComponentDescriptor, PropertyValueType } from '@cratis/scene.model';
5
- import { componentRegistryKey } from '../packages';
5
+ import { componentRegistryKey, describeComponents } from '../packages';
6
+ import { coreComponentMetadata } from './coreComponentMetadata';
6
7
 
7
8
  const key = (name: string) => componentRegistryKey('core', name);
8
9
 
@@ -13,7 +14,7 @@ const key = (name: string) => componentRegistryKey('core', name);
13
14
  * argument mapping, a column's heading, and the navigation bar. The Screenplay structural components - `data`,
14
15
  * `section`, `summary` - have nothing to edit that is not already a node in the tree.
15
16
  */
16
- export const coreDescriptors: ComponentDescriptor[] = [
17
+ const describedCore: ComponentDescriptor[] = [
17
18
  {
18
19
  component: key('button'),
19
20
  displayName: 'Button',
@@ -79,3 +80,6 @@ export const coreDescriptors: ComponentDescriptor[] = [
79
80
  ],
80
81
  },
81
82
  ];
83
+
84
+ /** The `core` package's descriptors: the hand-written ones above with every component's category, icon, keywords and design mode (CMP1). */
85
+ export const coreDescriptors: ComponentDescriptor[] = describeComponents('core', describedCore, coreComponentMetadata);
@@ -0,0 +1,109 @@
1
+ 'use strict';
2
+
3
+ var scene_model = require('@cratis/scene.model');
4
+ require('react/jsx-runtime');
5
+ require('react');
6
+ require('@cratis/scene.engine');
7
+ require('../interactions/useInteractions.js');
8
+ require('../interactions/NotificationHost.js');
9
+ require('../packages/runDesignTimeAction.js');
10
+ var describeComponents = require('../packages/describeComponents.js');
11
+ var designModes = require('../packages/designModes.js');
12
+
13
+ // Copyright (c) Cratis. All rights reserved.
14
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
15
+ /** The category, icon, keywords and picker badge of every component of the package (CMP1), keyed by bare component name. */ const coreComponentMetadata = {
16
+ text: describeComponents.componentMetadata('Text', scene_model.ComponentCategory.DataDisplay, 'type', [
17
+ 'label',
18
+ 'paragraph',
19
+ 'copy'
20
+ ]),
21
+ button: describeComponents.componentMetadata('Button', scene_model.ComponentCategory.Actions, 'mouse-pointer-click', [
22
+ 'click',
23
+ 'submit',
24
+ 'action'
25
+ ], 'Bt'),
26
+ card: describeComponents.componentMetadata('Card', scene_model.ComponentCategory.Layout, 'square', [
27
+ 'panel',
28
+ 'box',
29
+ 'container'
30
+ ]),
31
+ data: describeComponents.componentMetadata('Data', scene_model.ComponentCategory.DataDisplay, 'database', [
32
+ 'read model',
33
+ 'query',
34
+ 'source'
35
+ ]),
36
+ action: describeComponents.componentMetadata('Command action', scene_model.ComponentCategory.Actions, 'zap', [
37
+ 'command',
38
+ 'invoke',
39
+ 'submit'
40
+ ]),
41
+ section: describeComponents.componentMetadata('Section', scene_model.ComponentCategory.Layout, 'layout-panel-top', [
42
+ 'group',
43
+ 'area',
44
+ 'block'
45
+ ]),
46
+ navigate: describeComponents.componentMetadata('Navigate', scene_model.ComponentCategory.Navigation, 'corner-down-right', [
47
+ 'link',
48
+ 'go to',
49
+ 'route'
50
+ ]),
51
+ title: describeComponents.componentMetadata('Title', scene_model.ComponentCategory.DataDisplay, 'heading', [
52
+ 'heading',
53
+ 'header',
54
+ 'caption'
55
+ ]),
56
+ table: describeComponents.componentMetadata('Table', scene_model.ComponentCategory.DataDisplay, 'table', [
57
+ 'grid',
58
+ 'rows',
59
+ 'list'
60
+ ], 'Tb'),
61
+ column: describeComponents.componentMetadata('Table column', scene_model.ComponentCategory.DataDisplay, 'columns-3', [
62
+ 'heading',
63
+ 'field'
64
+ ]),
65
+ summary: describeComponents.componentMetadata('Summary', scene_model.ComponentCategory.DataDisplay, 'list', [
66
+ 'details',
67
+ 'overview',
68
+ 'facts'
69
+ ]),
70
+ field: describeComponents.componentMetadata('Summary field', scene_model.ComponentCategory.DataDisplay, 'tag', [
71
+ 'label',
72
+ 'value',
73
+ 'pair'
74
+ ]),
75
+ code: describeComponents.componentMetadata('Code', scene_model.ComponentCategory.DataDisplay, 'code', [
76
+ 'snippet',
77
+ 'source',
78
+ 'monospace'
79
+ ]),
80
+ file: describeComponents.componentMetadata('File reference', scene_model.ComponentCategory.DataDisplay, 'file', [
81
+ 'include',
82
+ 'import',
83
+ 'screen file'
84
+ ]),
85
+ navigationBar: describeComponents.componentMetadata('Navigation bar', scene_model.ComponentCategory.Navigation, 'navigation', [
86
+ 'menu',
87
+ 'nav',
88
+ 'links'
89
+ ], undefined, designModes.navigationDesignMode({
90
+ itemsPath: 'items'
91
+ })),
92
+ outlet: describeComponents.componentMetadata('Outlet', scene_model.ComponentCategory.Layout, 'panel-right', [
93
+ 'region',
94
+ 'slot',
95
+ 'side panel'
96
+ ]),
97
+ toolbar: describeComponents.componentMetadata('Toolbar', scene_model.ComponentCategory.Actions, 'wrench', [
98
+ 'actions',
99
+ 'buttons',
100
+ 'command bar'
101
+ ], 'Tl', designModes.toolbarDesignMode()),
102
+ toolbarItem: describeComponents.componentMetadata('Toolbar item', scene_model.ComponentCategory.Actions, 'mouse-pointer-click', [
103
+ 'button',
104
+ 'action'
105
+ ])
106
+ };
107
+
108
+ exports.coreComponentMetadata = coreComponentMetadata;
109
+ //# 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,oCAAAA,CAAE,MAAA,EAAQC,6BAAAA,CAAkBC,WAAW,EAAE,MAAA,EAAQ;AAAC,QAAA,OAAA;AAAS,QAAA,WAAA;AAAa,QAAA;AAAO,KAAA,CAAA;AACrFC,IAAAA,MAAAA,EAAQH,oCAAAA,CAAE,QAAA,EAAUC,6BAAAA,CAAkBG,OAAO,EAAE,qBAAA,EAAuB;AAAC,QAAA,OAAA;AAAS,QAAA,QAAA;AAAU,QAAA;KAAS,EAAE,IAAA,CAAA;AACrGC,IAAAA,IAAAA,EAAML,oCAAAA,CAAE,MAAA,EAAQC,6BAAAA,CAAkBK,MAAM,EAAE,QAAA,EAAU;AAAC,QAAA,OAAA;AAAS,QAAA,KAAA;AAAO,QAAA;AAAY,KAAA,CAAA;AACjFC,IAAAA,IAAAA,EAAMP,oCAAAA,CAAE,MAAA,EAAQC,6BAAAA,CAAkBC,WAAW,EAAE,UAAA,EAAY;AAAC,QA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AS,KAAA;AACzG;;"}
@@ -8,6 +8,8 @@ require('../interactions/useInteractions.js');
8
8
  require('../interactions/NotificationHost.js');
9
9
  var ScenePackageBundle = require('../packages/ScenePackageBundle.js');
10
10
  require('../packages/runDesignTimeAction.js');
11
+ var describeComponents = require('../packages/describeComponents.js');
12
+ var coreComponentMetadata = require('./coreComponentMetadata.js');
11
13
 
12
14
  // Copyright (c) Cratis. All rights reserved.
13
15
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
@@ -18,7 +20,7 @@ const key = (name)=>ScenePackageBundle.componentRegistryKey('core', name);
18
20
  * Only the components an author configures by hand are described: a button's label, an action's command and its
19
21
  * argument mapping, a column's heading, and the navigation bar. The Screenplay structural components - `data`,
20
22
  * `section`, `summary` - have nothing to edit that is not already a node in the tree.
21
- */ const coreDescriptors = [
23
+ */ const describedCore = [
22
24
  {
23
25
  component: key('button'),
24
26
  displayName: 'Button',
@@ -179,6 +181,7 @@ const key = (name)=>ScenePackageBundle.componentRegistryKey('core', name);
179
181
  ]
180
182
  }
181
183
  ];
184
+ /** The `core` package's descriptors: the hand-written ones above with every component's category, icon, keywords and design mode (CMP1). */ const coreDescriptors = describeComponents.describeComponents('core', describedCore, coreComponentMetadata.coreComponentMetadata);
182
185
 
183
186
  exports.coreDescriptors = coreDescriptors;
184
187
  //# 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 */\nexport const coreDescriptors: 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"],"names":["key","name","componentRegistryKey","coreDescriptors","component","displayName","properties","path","label","group","valueType","PropertyValueType","String","default","description","editorKind","constraints","required","Collection","item","minimumLength","Icon","Destination"],"mappings":";;;;;;;;;;;AAAA;AACA;AAKA,MAAMA,GAAAA,GAAM,CAACC,IAAAA,GAAiBC,uCAAAA,CAAqB,MAAA,EAAQD,IAAAA,CAAAA;AAE3D;;;;;;UAOaE,eAAAA,GAAyC;AAClD,IAAA;AACIC,QAAAA,SAAAA,EAAWJ,GAAAA,CAAI,QAAA,CAAA;QACfK,WAAAA,EAAa,QAAA;QACbC,UAAAA,EAAY;AACR,YAAA;gBAAEC,IAAAA,EAAM,OAAA;gBAASC,KAAAA,EAAO,OAAA;gBAASC,KAAAA,EAAO,SAAA;AAAWC,gBAAAA,SAAAA,EAAWC,8BAAkBC,MAAM;gBAAEC,OAAAA,EAAS;AAAG;AACvG;AACL,KAAA;AACA,IAAA;AACIT,QAAAA,SAAAA,EAAWJ,GAAAA,CAAI,QAAA,CAAA;QACfK,WAAAA,EAAa,gBAAA;QACbS,WAAAA,EAAa,gJAAA;QACbR,UAAAA,EAAY;AACR,YAAA;gBAAEC,IAAAA,EAAM,OAAA;gBAASC,KAAAA,EAAO,OAAA;gBAASC,KAAAA,EAAO,SAAA;AAAWC,gBAAAA,SAAAA,EAAWC,8BAAkBC;AAAO,aAAA;AACvF,YAAA;gBACIL,IAAAA,EAAM,SAAA;gBAAWC,KAAAA,EAAO,SAAA;gBAAWC,KAAAA,EAAO,UAAA;AAAYC,gBAAAA,SAAAA,EAAWC,8BAAkBC,MAAM;gBACzFG,UAAAA,EAAY,sBAAA;gBAAwBC,WAAAA,EAAa;oBAAEC,QAAAA,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AAA,EAAO,SAAA;AAAWC,4BAAAA,SAAAA,EAAWC,8BAAkBU,IAAI;4BAAEN,UAAAA,EAAY;AAAa,yBAAA;AAC7G,wBAAA;4BAAER,IAAAA,EAAM,aAAA;4BAAeC,KAAAA,EAAO,aAAA;4BAAeC,KAAAA,EAAO,SAAA;AAAWC,4BAAAA,SAAAA,EAAWC,8BAAkBW,WAAW;4BAAEP,UAAAA,EAAY,cAAA;4BAAgBC,WAAAA,EAAa;gCAAEC,QAAAA,EAAU;AAAK;AAAE;AACxK;AACL;AACJ;AACH;AACL;;;"}
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"],"mappings":";;;;;;;;;;;;;AAAA;AACA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K;AAAE;AACxK;AACL;AACJ;AACH;AACL;AACH,CAAA;AAED,6IACO,MAAMM,kBAAyCC,qCAAAA,CAAmB,MAAA,EAAQrB,eAAesB,2CAAAA;;"}
package/dist/cjs/index.js CHANGED
@@ -56,6 +56,9 @@ var PackageHostView = require('./packages/PackageHostView.js');
56
56
  var resolveDesignTimeHost = require('./packages/resolveDesignTimeHost.js');
57
57
  var runDesignTimeAction = require('./packages/runDesignTimeAction.js');
58
58
  var ScenePackageBundle = require('./packages/ScenePackageBundle.js');
59
+ var describeComponents = require('./packages/describeComponents.js');
60
+ var designModes = require('./packages/designModes.js');
61
+ var validateComponentMetadata = require('./packages/validateComponentMetadata.js');
59
62
  var StandalonePackageHost = require('./packages/StandalonePackageHost.js');
60
63
  var WebViewPackageHost = require('./packages/WebViewPackageHost.js');
61
64
  var ComponentsUiLibraryContract = require('./packages/ComponentsUiLibraryContract.js');
@@ -158,6 +161,13 @@ exports.componentRegistryKey = ScenePackageBundle.componentRegistryKey;
158
161
  exports.mergeIconAdapters = ScenePackageBundle.mergeIconAdapters;
159
162
  exports.mergePackageRegistries = ScenePackageBundle.mergePackageRegistries;
160
163
  exports.validatePackageBundle = ScenePackageBundle.validatePackageBundle;
164
+ exports.componentMetadata = describeComponents.componentMetadata;
165
+ exports.describeComponents = describeComponents.describeComponents;
166
+ exports.itemEditableRule = designModes.itemEditableRule;
167
+ exports.itemInheritedReason = designModes.itemInheritedReason;
168
+ exports.navigationDesignMode = designModes.navigationDesignMode;
169
+ exports.toolbarDesignMode = designModes.toolbarDesignMode;
170
+ exports.validateComponentMetadata = validateComponentMetadata.validateComponentMetadata;
161
171
  exports.StandalonePackageHost = StandalonePackageHost.StandalonePackageHost;
162
172
  exports.WebViewPackageHost = WebViewPackageHost.WebViewPackageHost;
163
173
  exports.validateComponentsUiLibraryContract = ComponentsUiLibraryContract.validateComponentsUiLibraryContract;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var scene_engine = require('@cratis/scene.engine');
3
4
  var scene_model = require('@cratis/scene.model');
4
5
  var IconAdapterRegistry = require('../icons/IconAdapterRegistry.js');
5
6
  var ComponentsUiLibraryContract = require('./ComponentsUiLibraryContract.js');
@@ -141,6 +142,13 @@ function validateDescriptors(bundle) {
141
142
  described.add(descriptor.component);
142
143
  validateProperties(descriptor.component, descriptor.properties, '', problems);
143
144
  }
145
+ // The category rule (CMP1) is not checked here - it gates a designer, not a host loading a package (see validateComponentMetadata) -
146
+ // but a design-mode descriptor or editor parameter that cannot work is as much a mistake as an enum without choices.
147
+ const structural = [
148
+ scene_model.DiagnosticCode.ComponentDesignModeInvalid,
149
+ scene_model.DiagnosticCode.PropertyEditorOptionsInvalid
150
+ ];
151
+ problems.push(...scene_engine.validateComponentDescriptors(bundle.descriptors ?? []).filter((diagnostic)=>structural.includes(diagnostic.code)).map((diagnostic)=>diagnostic.message));
144
152
  return problems;
145
153
  }
146
154
  /**
@@ -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,oBAA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AAG,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,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,QAAAA,CAASC,IAAI,EAAEA,IAAAA,CAAAA,CAAAA,CAAAA;AAC/F,IAAA,KAAK,MAAMM,GAAAA,IAAOC,MAAAA,CAAOC,IAAI,CAACX,MAAAA,CAAOI,UAAU,CAAA,CAAG;AAC9C,QAAA,IAAI,CAACE,QAAAA,CAASM,GAAG,CAACH,GAAAA,CAAAA,EAAM;AACpBR,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,WAAW,EAAEI,GAAAA,CAAI,sCAAsC,CAAC,CAAA;AAC3E,QAAA;AACJ,IAAA;AAEA,IAAA,MAAMI,kBAAkB,IAAIN,GAAAA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,EAAEe,UAAAA,CAAWd,UAAU,EAAE,EAAA,EAAI3C,QAAAA,CAAAA;AACxE,IAAA;;;AAIA,IAAA,MAAM2D,UAAAA,GAAuB;AAACC,QAAAA,0BAAAA,CAAeC,0BAA0B;AAAED,QAAAA,0BAAAA,CAAeE;AAA6B,KAAA;IACrH9D,QAAAA,CAASI,IAAI,IAAI2D,yCAAAA,CAA6BhE,MAAAA,CAAO2D,WAAW,IAAI,EAAE,CAAA,CAAEM,MAAM,CAACC,CAAAA,aAAcN,UAAAA,CAAWnB,QAAQ,CAACyB,UAAAA,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,6CAAAA,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,64 @@
1
+ 'use strict';
2
+
3
+ var scene_model = require('@cratis/scene.model');
4
+ var ScenePackageBundle = require('./ScenePackageBundle.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
+ /** A `ComponentMetadata` entry in one line: what a package's metadata table is made of. */ function componentMetadata(displayName, category, icon, keywords = [], badge, designMode) {
9
+ return {
10
+ displayName,
11
+ category,
12
+ icon,
13
+ keywords,
14
+ ...badge === undefined ? {} : {
15
+ badge
16
+ },
17
+ ...designMode === undefined ? {} : {
18
+ designMode
19
+ }
20
+ };
21
+ }
22
+ /**
23
+ * Builds the descriptors a bundle ships: the ones written by hand with the package's component metadata merged in, plus a descriptor with
24
+ * no editable properties for every component the metadata names that nobody described - such a component still has a name, a
25
+ * category and a place in a picker. A hand-written descriptor keeps everything it already says; metadata only fills in what it
26
+ * leaves out.
27
+ *
28
+ * The component list is the metadata table's own, so a component the table forgets has no descriptor and `validateComponentMetadata`
29
+ * reports it (CMP1); one the table names but the manifest does not declare is reported by `validatePackageBundle`.
30
+ */ function describeComponents(packageName, described, metadata) {
31
+ const describedKeys = new Set(described.map((descriptor)=>descriptor.component));
32
+ const bare = Object.keys(metadata).map((name)=>ScenePackageBundle.componentRegistryKey(packageName, name)).filter((key)=>!describedKeys.has(key)).map((key)=>({
33
+ component: key,
34
+ properties: []
35
+ }));
36
+ return [
37
+ ...described,
38
+ ...bare
39
+ ].map((descriptor)=>withMetadata(descriptor, metadata[descriptor.component.slice(packageName.length + 1)]));
40
+ }
41
+ function withMetadata(descriptor, metadata) {
42
+ if (!metadata) return descriptor;
43
+ return {
44
+ ...descriptor,
45
+ displayName: descriptor.displayName ?? metadata.displayName ?? descriptor.component.slice(descriptor.component.indexOf(':') + 1),
46
+ category: descriptor.category ?? metadata.category,
47
+ ...descriptor.icon === undefined && metadata.icon !== undefined ? {
48
+ icon: scene_model.componentIcon(metadata.icon)
49
+ } : {},
50
+ ...descriptor.keywords === undefined && metadata.keywords !== undefined ? {
51
+ keywords: metadata.keywords
52
+ } : {},
53
+ ...descriptor.badge === undefined && metadata.badge !== undefined ? {
54
+ badge: metadata.badge
55
+ } : {},
56
+ ...descriptor.designMode === undefined && metadata.designMode !== undefined ? {
57
+ designMode: metadata.designMode
58
+ } : {}
59
+ };
60
+ }
61
+
62
+ exports.componentMetadata = componentMetadata;
63
+ exports.describeComponents = describeComponents;
64
+ //# 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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