@cratis/scene.react 4.17.0 → 4.18.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.
@@ -105,6 +105,28 @@ function validateIconLibrary(bundle) {
105
105
  }
106
106
  return problems;
107
107
  }
108
+ function validateProperties(component, properties, parent, problems) {
109
+ const paths = new Set();
110
+ for (const property of properties){
111
+ const path = `${parent}${property.path}`;
112
+ if (paths.has(property.path)) {
113
+ problems.push(`'${component}' describes the property '${path}' more than once`);
114
+ }
115
+ paths.add(property.path);
116
+ if (property.valueType === scene_model.PropertyValueType.Collection && property.item === undefined) {
117
+ problems.push(`'${component}' describes the collection '${path}' without describing its items`);
118
+ }
119
+ if (property.valueType === scene_model.PropertyValueType.Collection && property.item !== undefined) {
120
+ validateProperties(component, property.item.properties, `${path}[].`, problems);
121
+ }
122
+ if (property.valueType === scene_model.PropertyValueType.Object && property.properties !== undefined) {
123
+ validateProperties(component, property.properties, `${path}.`, problems);
124
+ }
125
+ if (property.valueType === scene_model.PropertyValueType.Enum && (property.choices ?? []).length === 0) {
126
+ problems.push(`'${component}' describes the enum '${path}' without choices`);
127
+ }
128
+ }
129
+ }
108
130
  function validateDescriptors(bundle) {
109
131
  const problems = [];
110
132
  const declared = new Set(bundle.manifest.components.map((name)=>componentRegistryKey(bundle.manifest.name, name)));
@@ -117,19 +139,7 @@ function validateDescriptors(bundle) {
117
139
  problems.push(`describes '${descriptor.component}' more than once`);
118
140
  }
119
141
  described.add(descriptor.component);
120
- const paths = new Set();
121
- for (const property of descriptor.properties){
122
- if (paths.has(property.path)) {
123
- problems.push(`'${descriptor.component}' describes the property '${property.path}' more than once`);
124
- }
125
- paths.add(property.path);
126
- if (property.valueType === scene_model.PropertyValueType.Collection && property.item === undefined) {
127
- problems.push(`'${descriptor.component}' describes the collection '${property.path}' without describing its items`);
128
- }
129
- if (property.valueType === scene_model.PropertyValueType.Enum && (property.choices ?? []).length === 0) {
130
- problems.push(`'${descriptor.component}' describes the enum '${property.path}' without choices`);
131
- }
132
- }
142
+ validateProperties(descriptor.component, descriptor.properties, '', problems);
133
143
  }
134
144
  return problems;
135
145
  }
@@ -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, 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 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 const paths = new Set<string>();\n for (const property of descriptor.properties) {\n if (paths.has(property.path)) {\n problems.push(`'${descriptor.component}' describes the property '${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(`'${descriptor.component}' describes the collection '${property.path}' without describing its items`);\n }\n\n if (property.valueType === PropertyValueType.Enum && (property.choices ?? []).length === 0) {\n problems.push(`'${descriptor.component}' describes the enum '${property.path}' without choices`);\n }\n }\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","described","descriptor","descriptors","component","add","paths","property","properties","path","valueType","PropertyValueType","Collection","item","Enum","choices","length","mergePackageRegistries","bundles","assign","mergeIconAdapters","createIconAdapterRegistry","flatMap"],"mappings":";;;;;;;AAAA;AACA;AAoFA;;;;;;;;;AASC,IACM,SAASA,oBAAAA,CAAqBC,WAAmB,EAAEC,aAAqB,EAAA;AAC3E,IAAA,OAAO,CAAA,EAAGD,WAAAA,CAAY,CAAC,EAAEC,aAAAA,CAAAA,CAAe;AAC5C;AAEA;;;;;;;;IASO,SAASC,qBAAAA,CAAsBC,MAA0B,EAAA;AAC5D,IAAA,MAAMC,WAAqB,EAAE;IAC7B,MAAM,EAAEC,QAAQ,EAAE,GAAGF,MAAAA;AAErB,IAAA,KAAK,MAAMG,IAAAA,IAAQD,QAAAA,CAASE,UAAU,CAAE;QACpC,IAAI,EAAER,oBAAAA,CAAqBM,QAAAA,CAASC,IAAI,EAAEA,IAAAA,CAAAA,IAASH,M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BAAsB,EAAEG,QAAAA,CAASE,IAAI,CAAC,iBAAiB,CAAC,CAAA;AACnG,YAAA;AACJ,QAAA;AACJ,IAAA;IAEA,OAAOjD,QAAAA;AACX;AAEA;;;;;IAMO,SAASyD,sBAAAA,CAAuBC,OAA6B,EAAA;IAChE,OAAOjD,MAAAA,CAAOkD,MAAM,CAAC,EAAC,EAAA,GAAMD,OAAAA,CAAQnD,GAAG,CAAC,CAACR,MAAAA,GAAWA,MAAAA,CAAOI,UAAU,CAAA,CAAA;AACzE;AAEA;;;;IAKO,SAASyD,iBAAAA,CAAkBF,OAA6B,EAAA;IAC3D,OAAOG,6CAAAA,CAA0BH,QAAQI,OAAO,CAAC,CAAC/D,MAAAA,GAAYA,MAAAA,CAAOiC,WAAW,GAAG;YAACjC,MAAAA,CAAOiC,WAAW,CAACM;AAAQ,SAAA,GAAG,EAAE,CAAA,CAAA;AACxH;;;;;"}
1
+ {"version":3,"file":"ScenePackageBundle.js","sources":["../../../packages/ScenePackageBundle.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ComponentDescriptor, DialogTemplate, Layout, PackageKind, PropertyDescriptor, PropertyValueType, ScenePackage, Screen, ScreenTemplate, Theme } from '@cratis/scene.model';\nimport { IconAdapterRegistry, createIconAdapterRegistry } from '../icons/IconAdapterRegistry';\nimport { IconLibraryBundle } from '../icons/IconLibraryBundle';\nimport { ComponentRegistry } from '../renderer';\nimport { ComponentsUiLibraryContract, validateComponentsUiLibraryContract } from './ComponentsUiLibraryContract';\nimport { DesignTimeBundle, validateDesignTimeBundle } from './DesignTimeBundle';\n\n/**\n * What a package actually ships to a React renderer, as opposed to what it *declares*.\n *\n * `ScenePackage` is the declaration — a name, a kind, dependencies, and the names of what it\n * contributes. It is deliberately platform-agnostic and lives in `Scene.Model`, because Stage's build and\n * Studio's design-time queries both read it without ever loading a component. A bundle is the other half:\n * the real React components, layouts, screens and themes behind those names, which only a renderer needs.\n *\n * A package publishes exactly one bundle, as a named export following its own name —\n * `primeReactPackage`, `cratisComponentsPackage`, `corePackage`. A host loads it from the module the\n * declaration's `ScenePackage.module` names.\n */\nexport interface ScenePackageBundle {\n /**\n * The package's own declaration. Its `components`, `layouts` and `themes` name lists must agree with\n * what this bundle actually provides — {@link validatePackageBundle} is what proves they do.\n */\n manifest: ScenePackage;\n\n /**\n * The components this package provides, keyed by {@link componentRegistryKey}.\n */\n components: ComponentRegistry;\n\n /**\n * The application shells this package provides, if any. Only a blueprint has these.\n */\n layouts?: Layout[];\n\n /**\n * The screen templates this package provides — the shapes that go inside a layout, each declaring\n * which of its parent's slots it fills.\n */\n screenTemplates?: ScreenTemplate[];\n\n /**\n * The dialog templates this package provides.\n */\n dialogTemplates?: DialogTemplate[];\n\n /**\n * Sample screens this package ships — a layout package's gallery, so a preview has real content to\n * put through the real engine rather than a mockup.\n */\n screens?: Screen[];\n\n /**\n * What can be edited on this package's components - one {@link ComponentDescriptor} per component that is\n * editable at design time. They are data, so Studio reads them without rendering anything, and they travel with\n * the components they describe rather than in a registry of their own. {@link validatePackageBundle} checks\n * that every descriptor names a component the manifest declares.\n */\n descriptors?: ComponentDescriptor[];\n\n /**\n * The themes this package ships, if any.\n */\n themes?: Theme[];\n\n /**\n * The icon catalog and renderer adapter of an icon-library package. Present exactly when the\n * manifest declares an icon library.\n */\n iconLibrary?: IconLibraryBundle;\n\n /**\n * Optional web-renderer mapping to a Components UiLibrary. Scene's catalog remains independently\n * authored; hosts check the loaded export with validateComponentsUiLibraryMapping before rendering.\n */\n componentsUiLibrary?: ComponentsUiLibraryContract;\n\n /** Optional React-only design-time tooling. Runtime hosts can omit it entirely. */\n designTime?: DesignTimeBundle;\n}\n\n/**\n * The key a component is registered and looked up under: the package that provides it, then the bare name\n * a screen refers to it by.\n *\n * A screen writes a bare name (`button`) or a package-qualified one (`PrimeReact.button`);\n * `resolveComponentName` turns either into a `{ name, package }` pair, and this turns that pair into the\n * registry key. Nothing should build this string by hand — the separator is an implementation detail of\n * the registry, deliberately not the `.` used for qualification in a screen, so a package name containing\n * dots stays unambiguous.\n */\nexport function componentRegistryKey(packageName: string, componentName: string): string {\n return `${packageName}:${componentName}`;\n}\n\n/**\n * Checks that a bundle provides everything its manifest declares, and declares everything it provides, and that\n * every descriptor it ships is for a component it declares and is well formed.\n *\n * A manifest that promises a component the bundle does not register renders as `UnresolvedComponent` at\n * runtime — a blank box, far from where the mistake was made. A component registered but not declared is\n * invisible to `resolveComponentName`, so a screen can never name it. Both are silent failures, which is\n * why every package's specs run this.\n */\nexport function validatePackageBundle(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const { manifest } = bundle;\n\n for (const name of manifest.components) {\n if (!(componentRegistryKey(manifest.name, name) in bundle.components)) {\n problems.push(`declares the component '${name}' but registers no implementation for it`);\n }\n }\n\n const declared = new Set(manifest.components.map((name) => componentRegistryKey(manifest.name, name)));\n for (const key of Object.keys(bundle.components)) {\n if (!declared.has(key)) {\n problems.push(`registers '${key}', which the manifest does not declare`);\n }\n }\n\n const providedLayouts = new Set((bundle.layouts ?? []).map((layout) => layout.name));\n for (const name of manifest.layouts) {\n if (!providedLayouts.has(name)) {\n problems.push(`declares the layout '${name}' but provides no definition for it`);\n }\n }\n\n const providedScreenTemplates = new Set((bundle.screenTemplates ?? []).map((template) => template.name));\n for (const name of manifest.screenTemplates) {\n if (!providedScreenTemplates.has(name)) {\n problems.push(`declares the screen template '${name}' but provides no definition for it`);\n }\n }\n\n const providedDialogTemplates = new Set((bundle.dialogTemplates ?? []).map((template) => template.name));\n for (const name of manifest.dialogTemplates) {\n if (!providedDialogTemplates.has(name)) {\n problems.push(`declares the dialog template '${name}' but provides no definition for it`);\n }\n }\n\n const providedThemes = new Set((bundle.themes ?? []).map((theme) => theme.name));\n for (const name of manifest.themes) {\n if (!providedThemes.has(name)) {\n problems.push(`declares the theme '${name}' but provides no definition for it`);\n }\n }\n\n if (bundle.componentsUiLibrary) {\n if (manifest.kind !== PackageKind.ComponentLibrary) {\n problems.push('declares a Components UI library mapping but is not of kind ComponentLibrary');\n }\n problems.push(...validateComponentsUiLibraryContract(bundle.componentsUiLibrary));\n }\n\n problems.push(...validateIconLibrary(bundle));\n problems.push(...validateDescriptors(bundle));\n problems.push(...validateDesignTimeBundle(bundle.designTime));\n\n return problems;\n}\n\nfunction validateIconLibrary(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const { manifest, iconLibrary } = bundle;\n const declaresIconLibrary = manifest.kind === PackageKind.IconLibrary || manifest.iconLibrary !== undefined;\n\n if (manifest.kind === PackageKind.IconLibrary && !manifest.iconLibrary) {\n problems.push('is an icon library but declares no iconLibrary metadata');\n }\n\n if (manifest.kind !== PackageKind.IconLibrary && manifest.iconLibrary) {\n problems.push('declares iconLibrary metadata but is not of kind IconLibrary');\n }\n\n if (declaresIconLibrary && !iconLibrary) {\n problems.push('declares an icon library but the bundle provides no catalog or adapter for it');\n }\n\n if (!declaresIconLibrary && iconLibrary) {\n problems.push('provides an icon catalog and adapter, which the manifest does not declare');\n }\n\n if (iconLibrary) {\n if (iconLibrary.catalog.library !== manifest.name) {\n problems.push(`provides an icon catalog for '${iconLibrary.catalog.library}' instead of '${manifest.name}'`);\n }\n\n if (iconLibrary.adapter.library !== manifest.name) {\n problems.push(`provides an icon adapter for '${iconLibrary.adapter.library}' instead of '${manifest.name}'`);\n }\n\n if (manifest.iconLibrary && !manifest.iconLibrary.renderers.includes('react')) {\n problems.push(\"provides a React icon adapter but does not list 'react' among its icon renderers\");\n }\n }\n\n return problems;\n}\n\nfunction validateProperties(component: string, properties: PropertyDescriptor[], parent: string, problems: string[]): void {\n const paths = new Set<string>();\n for (const property of properties) {\n const path = `${parent}${property.path}`;\n if (paths.has(property.path)) {\n problems.push(`'${component}' describes the property '${path}' more than once`);\n }\n\n paths.add(property.path);\n\n if (property.valueType === PropertyValueType.Collection && property.item === undefined) {\n problems.push(`'${component}' describes the collection '${path}' without describing its items`);\n }\n\n if (property.valueType === PropertyValueType.Collection && property.item !== undefined) {\n validateProperties(component, property.item.properties, `${path}[].`, problems);\n }\n\n if (property.valueType === PropertyValueType.Object && property.properties !== undefined) {\n validateProperties(component, property.properties, `${path}.`, problems);\n }\n\n if (property.valueType === PropertyValueType.Enum && (property.choices ?? []).length === 0) {\n problems.push(`'${component}' describes the enum '${path}' without choices`);\n }\n }\n}\n\nfunction validateDescriptors(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const declared = new Set(bundle.manifest.components.map((name) => componentRegistryKey(bundle.manifest.name, name)));\n const described = new Set<string>();\n\n for (const descriptor of bundle.descriptors ?? []) {\n if (!declared.has(descriptor.component)) {\n problems.push(`describes '${descriptor.component}', which the manifest does not declare as a component`);\n }\n\n if (described.has(descriptor.component)) {\n problems.push(`describes '${descriptor.component}' more than once`);\n }\n\n described.add(descriptor.component);\n\n validateProperties(descriptor.component, descriptor.properties, '', problems);\n }\n\n return problems;\n}\n\n/**\n * Merges the component registries of several bundles into the single registry a renderer consumes.\n *\n * Keys carry their package name, so nothing collides and merge order does not matter — which package wins\n * a *bare* name is decided earlier, by `resolveComponentName` walking the profile's priority order.\n */\nexport function mergePackageRegistries(bundles: ScenePackageBundle[]): ComponentRegistry {\n return Object.assign({}, ...bundles.map((bundle) => bundle.components)) as ComponentRegistry;\n}\n\n/**\n * Collects the icon adapters of several bundles into the registry `SceneIcon` renders through.\n *\n * @throws Error when two bundles provide an adapter for the same library.\n */\nexport function mergeIconAdapters(bundles: ScenePackageBundle[]): IconAdapterRegistry {\n return createIconAdapterRegistry(bundles.flatMap((bundle) => (bundle.iconLibrary ? [bundle.iconLibrary.adapter] : [])));\n}\n"],"names":["componentRegistryKey","packageName","componentName","validatePackageBundle","bundle","problems","manifest","name","components","push","declared","Set","map","key","Object","keys","has","providedLayouts","layouts","layout","providedScreenTemplates","screenTemplates","template","providedDialogTemplates","dialogTemplates","providedThemes","themes","theme","componentsUiLibrary","kind","PackageKind","ComponentLibrary","validateComponentsUiLibraryContract","validateIconLibrary","validateDescriptors","validateDesignTimeBundle","designTime","iconLibrary","declaresIconLibrary","IconLibrary","undefined","catalog","library","adapter","renderers","includes","validateProperties","component","properties","parent","paths","property","path","add","valueType","PropertyValueType","Collection","item","Enum","choices","length","described","descriptor","descriptors","mergePackageRegistries","bundles","assign","mergeIconAdapters","createIconAdapterRegistry","flatMap"],"mappings":";;;;;;;AAAA;AACA;AAoFA;;;;;;;;;AASC,IACM,SAASA,oBAAAA,CAAqBC,WAAmB,EAAEC,aAAqB,EAAA;AAC3E,IAAA,OAAO,CAAA,EAAGD,WAAAA,CAAY,CAAC,EAAEC,aAAAA,CAAAA,CAAe;AAC5C;AAEA;;;;;;;;IASO,SAASC,qBAAAA,CAAsBC,MAA0B,EAAA;AAC5D,IAAA,MAAMC,WAAqB,EAAE;IAC7B,MAAM,EAAEC,QAAQ,EAAE,GAAGF,MAAAA;AAErB,IAAA,KAAK,MAAMG,IAAAA,IAAQD,QAAAA,CAASE,UAAU,CAAE;QACpC,IAAI,EAAER,oBAAAA,CAAqBM,QAAAA,CAASC,IAAI,EAAEA,IAAAA,CAAAA,IAASH,MAAAA,CAAOI,UAAS,CAAA,EAAI;AACnEH,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,wBAAwB,EAAEF,IAAAA,CAAK,wCAAwC,CAAC,CAAA;AAC3F,QAAA;AACJ,IAAA;AAEA,IAAA,MAAMG,QAAAA,GAAW,IAAIC,GAAAA,CAAIL,QAAAA,CAASE,UAAU,CAACI,GAAG,CAAC,CAACL,IAAAA,GAASP,oBAAAA,CAAqBM,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,QAAA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CAAC;AAchF,MAAM,WAAW,kBAAkB;IAK/B,QAAQ,EAAE,YAAY,CAAC;IAKvB,UAAU,EAAE,iBAAiB,CAAC;IAK9B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAMnB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IAKnC,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IAMnC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAQnB,WAAW,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAKpC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IAMjB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAMhC,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;IAGlD,UAAU,CAAC,EAAE,gBAAgB,CAAC;CACjC;AAYD,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAEvF;AAWD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAyD1E;AAgGD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,iBAAiB,CAEvF;AAOD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,mBAAmB,CAEpF"}
@@ -103,6 +103,28 @@ function validateIconLibrary(bundle) {
103
103
  }
104
104
  return problems;
105
105
  }
106
+ function validateProperties(component, properties, parent, problems) {
107
+ const paths = new Set();
108
+ for (const property of properties){
109
+ const path = `${parent}${property.path}`;
110
+ if (paths.has(property.path)) {
111
+ problems.push(`'${component}' describes the property '${path}' more than once`);
112
+ }
113
+ paths.add(property.path);
114
+ if (property.valueType === PropertyValueType.Collection && property.item === undefined) {
115
+ problems.push(`'${component}' describes the collection '${path}' without describing its items`);
116
+ }
117
+ if (property.valueType === PropertyValueType.Collection && property.item !== undefined) {
118
+ validateProperties(component, property.item.properties, `${path}[].`, problems);
119
+ }
120
+ if (property.valueType === PropertyValueType.Object && property.properties !== undefined) {
121
+ validateProperties(component, property.properties, `${path}.`, problems);
122
+ }
123
+ if (property.valueType === PropertyValueType.Enum && (property.choices ?? []).length === 0) {
124
+ problems.push(`'${component}' describes the enum '${path}' without choices`);
125
+ }
126
+ }
127
+ }
106
128
  function validateDescriptors(bundle) {
107
129
  const problems = [];
108
130
  const declared = new Set(bundle.manifest.components.map((name)=>componentRegistryKey(bundle.manifest.name, name)));
@@ -115,19 +137,7 @@ function validateDescriptors(bundle) {
115
137
  problems.push(`describes '${descriptor.component}' more than once`);
116
138
  }
117
139
  described.add(descriptor.component);
118
- const paths = new Set();
119
- for (const property of descriptor.properties){
120
- if (paths.has(property.path)) {
121
- problems.push(`'${descriptor.component}' describes the property '${property.path}' more than once`);
122
- }
123
- paths.add(property.path);
124
- if (property.valueType === PropertyValueType.Collection && property.item === undefined) {
125
- problems.push(`'${descriptor.component}' describes the collection '${property.path}' without describing its items`);
126
- }
127
- if (property.valueType === PropertyValueType.Enum && (property.choices ?? []).length === 0) {
128
- problems.push(`'${descriptor.component}' describes the enum '${property.path}' without choices`);
129
- }
130
- }
140
+ validateProperties(descriptor.component, descriptor.properties, '', problems);
131
141
  }
132
142
  return problems;
133
143
  }
@@ -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, 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 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 const paths = new Set<string>();\n for (const property of descriptor.properties) {\n if (paths.has(property.path)) {\n problems.push(`'${descriptor.component}' describes the property '${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(`'${descriptor.component}' describes the collection '${property.path}' without describing its items`);\n }\n\n if (property.valueType === PropertyValueType.Enum && (property.choices ?? []).length === 0) {\n problems.push(`'${descriptor.component}' describes the enum '${property.path}' without choices`);\n }\n }\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","described","descriptor","descriptors","component","add","paths","property","properties","path","valueType","PropertyValueType","Collection","item","Enum","choices","length","mergePackageRegistries","bundles","assign","mergeIconAdapters","createIconAdapterRegistry","flatMap"],"mappings":";;;;;AAAA;AACA;AAoFA;;;;;;;;;AASC,IACM,SAASA,oBAAAA,CAAqBC,WAAmB,EAAEC,aAAqB,EAAA;AAC3E,IAAA,OAAO,CAAA,EAAGD,WAAAA,CAAY,CAAC,EAAEC,aAAAA,CAAAA,CAAe;AAC5C;AAEA;;;;;;;;IASO,SAASC,qBAAAA,CAAsBC,MAA0B,EAAA;AAC5D,IAAA,MAAMC,WAAqB,EAAE;IAC7B,MAAM,EAAEC,QAAQ,EAAE,GAAGF,MAAAA;AAErB,IAAA,KAAK,MAAMG,IAAAA,IAAQD,QAAAA,CAASE,UAAU,CAAE;QACpC,IAAI,EAAER,oBAAAA,CAAqBM,QAAAA,CAASC,IAAI,EAAEA,IAAAA,CAAAA,IAASH,MAAAA,CAAOI,UAAS,CAAA,EAAI;AACnEH,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,wBAAwB,EAAEF,IAAAA,CAAK,wCAAwC,CAAC,CAAA;AAC3F,QAAA;AACJ,IAAA;AAEA,IAAA,MAAMG,QAAAA,GAAW,IAAIC,GAAAA,CAAIL,QAAAA,CAASE,UAAU,CAACI,GAAG,CAAC,CAACL,IAAAA,GAASP,oBAAAA,CAAqBM,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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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,MAA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