@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/scene.react",
3
- "version": "4.17.0",
3
+ "version": "4.18.0",
4
4
  "description": "The React renderer implementing Scene.Engine's Renderer contract against real React/DOM.",
5
5
  "keywords": [
6
6
  "cratis",
@@ -51,12 +51,12 @@
51
51
  "build-storybook": "storybook build"
52
52
  },
53
53
  "dependencies": {
54
- "@cratis/scene.engine": "4.17.0",
55
- "@cratis/scene.model": "4.17.0"
54
+ "@cratis/scene.engine": "4.18.0",
55
+ "@cratis/scene.model": "4.18.0"
56
56
  },
57
57
  "devDependencies": {
58
- "@cratis/scene.engine": "4.17.0",
59
- "@cratis/scene.model": "4.17.0",
58
+ "@cratis/scene.engine": "4.18.0",
59
+ "@cratis/scene.model": "4.18.0",
60
60
  "@storybook/addon-links": "^10.6.1",
61
61
  "@storybook/react": "^10.6.1",
62
62
  "@storybook/react-vite": "^10.6.1",
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Cratis. All rights reserved.
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
 
4
- import { ComponentDescriptor, DialogTemplate, Layout, PackageKind, PropertyValueType, ScenePackage, Screen, ScreenTemplate, Theme } from '@cratis/scene.model';
4
+ import { ComponentDescriptor, DialogTemplate, Layout, PackageKind, PropertyDescriptor, PropertyValueType, ScenePackage, Screen, ScreenTemplate, Theme } from '@cratis/scene.model';
5
5
  import { IconAdapterRegistry, createIconAdapterRegistry } from '../icons/IconAdapterRegistry';
6
6
  import { IconLibraryBundle } from '../icons/IconLibraryBundle';
7
7
  import { ComponentRegistry } from '../renderer';
@@ -203,6 +203,34 @@ function validateIconLibrary(bundle: ScenePackageBundle): string[] {
203
203
  return problems;
204
204
  }
205
205
 
206
+ function validateProperties(component: string, properties: PropertyDescriptor[], parent: string, problems: string[]): void {
207
+ const paths = new Set<string>();
208
+ for (const property of properties) {
209
+ const path = `${parent}${property.path}`;
210
+ if (paths.has(property.path)) {
211
+ problems.push(`'${component}' describes the property '${path}' more than once`);
212
+ }
213
+
214
+ paths.add(property.path);
215
+
216
+ if (property.valueType === PropertyValueType.Collection && property.item === undefined) {
217
+ problems.push(`'${component}' describes the collection '${path}' without describing its items`);
218
+ }
219
+
220
+ if (property.valueType === PropertyValueType.Collection && property.item !== undefined) {
221
+ validateProperties(component, property.item.properties, `${path}[].`, problems);
222
+ }
223
+
224
+ if (property.valueType === PropertyValueType.Object && property.properties !== undefined) {
225
+ validateProperties(component, property.properties, `${path}.`, problems);
226
+ }
227
+
228
+ if (property.valueType === PropertyValueType.Enum && (property.choices ?? []).length === 0) {
229
+ problems.push(`'${component}' describes the enum '${path}' without choices`);
230
+ }
231
+ }
232
+ }
233
+
206
234
  function validateDescriptors(bundle: ScenePackageBundle): string[] {
207
235
  const problems: string[] = [];
208
236
  const declared = new Set(bundle.manifest.components.map((name) => componentRegistryKey(bundle.manifest.name, name)));
@@ -219,22 +247,7 @@ function validateDescriptors(bundle: ScenePackageBundle): string[] {
219
247
 
220
248
  described.add(descriptor.component);
221
249
 
222
- const paths = new Set<string>();
223
- for (const property of descriptor.properties) {
224
- if (paths.has(property.path)) {
225
- problems.push(`'${descriptor.component}' describes the property '${property.path}' more than once`);
226
- }
227
-
228
- paths.add(property.path);
229
-
230
- if (property.valueType === PropertyValueType.Collection && property.item === undefined) {
231
- problems.push(`'${descriptor.component}' describes the collection '${property.path}' without describing its items`);
232
- }
233
-
234
- if (property.valueType === PropertyValueType.Enum && (property.choices ?? []).length === 0) {
235
- problems.push(`'${descriptor.component}' describes the enum '${property.path}' without choices`);
236
- }
237
- }
250
+ validateProperties(descriptor.component, descriptor.properties, '', problems);
238
251
  }
239
252
 
240
253
  return problems;