@cratis/scene.react 4.7.0 → 4.9.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 (72) hide show
  1. package/SceneElementView.tsx +10 -3
  2. package/dist/cjs/SceneElementView.js +4 -2
  3. package/dist/cjs/SceneElementView.js.map +1 -1
  4. package/dist/cjs/index.js +11 -0
  5. package/dist/cjs/index.js.map +1 -1
  6. package/dist/cjs/packages/ComponentsUiLibraryContract.js +72 -0
  7. package/dist/cjs/packages/ComponentsUiLibraryContract.js.map +1 -0
  8. package/dist/cjs/packages/DesignTimeBundle.js +17 -0
  9. package/dist/cjs/packages/DesignTimeBundle.js.map +1 -0
  10. package/dist/cjs/packages/PackageHostConfiguration.js +43 -0
  11. package/dist/cjs/packages/PackageHostConfiguration.js.map +1 -0
  12. package/dist/cjs/packages/ScenePackageBundle.js +9 -0
  13. package/dist/cjs/packages/ScenePackageBundle.js.map +1 -1
  14. package/dist/cjs/renderer/BindingOutputContext.js +74 -0
  15. package/dist/cjs/renderer/BindingOutputContext.js.map +1 -0
  16. package/dist/cjs/renderer/InteractiveComponent.js +7 -1
  17. package/dist/cjs/renderer/InteractiveComponent.js.map +1 -1
  18. package/dist/esm/SceneElementView.d.ts +2 -1
  19. package/dist/esm/SceneElementView.d.ts.map +1 -1
  20. package/dist/esm/SceneElementView.js +5 -3
  21. package/dist/esm/SceneElementView.js.map +1 -1
  22. package/dist/esm/index.js +4 -0
  23. package/dist/esm/index.js.map +1 -1
  24. package/dist/esm/packages/ComponentsUiLibraryContract.d.ts +19 -0
  25. package/dist/esm/packages/ComponentsUiLibraryContract.d.ts.map +1 -0
  26. package/dist/esm/packages/ComponentsUiLibraryContract.js +69 -0
  27. package/dist/esm/packages/ComponentsUiLibraryContract.js.map +1 -0
  28. package/dist/esm/packages/DesignTimeAction.d.ts +23 -0
  29. package/dist/esm/packages/DesignTimeAction.d.ts.map +1 -0
  30. package/dist/esm/packages/DesignTimeAction.js +2 -0
  31. package/dist/esm/packages/DesignTimeAction.js.map +1 -0
  32. package/dist/esm/packages/DesignTimeBundle.d.ts +17 -0
  33. package/dist/esm/packages/DesignTimeBundle.d.ts.map +1 -0
  34. package/dist/esm/packages/DesignTimeBundle.js +15 -0
  35. package/dist/esm/packages/DesignTimeBundle.js.map +1 -0
  36. package/dist/esm/packages/PackageHostConfiguration.d.ts +18 -0
  37. package/dist/esm/packages/PackageHostConfiguration.d.ts.map +1 -0
  38. package/dist/esm/packages/PackageHostConfiguration.js +41 -0
  39. package/dist/esm/packages/PackageHostConfiguration.js.map +1 -0
  40. package/dist/esm/packages/ScenePackageBundle.d.ts +4 -0
  41. package/dist/esm/packages/ScenePackageBundle.d.ts.map +1 -1
  42. package/dist/esm/packages/ScenePackageBundle.js +9 -0
  43. package/dist/esm/packages/ScenePackageBundle.js.map +1 -1
  44. package/dist/esm/packages/index.d.ts +4 -0
  45. package/dist/esm/packages/index.d.ts.map +1 -1
  46. package/dist/esm/packages/index.js +4 -0
  47. package/dist/esm/packages/index.js.map +1 -1
  48. package/dist/esm/renderer/BindingOutputContext.d.ts +18 -0
  49. package/dist/esm/renderer/BindingOutputContext.d.ts.map +1 -0
  50. package/dist/esm/renderer/BindingOutputContext.js +70 -0
  51. package/dist/esm/renderer/BindingOutputContext.js.map +1 -0
  52. package/dist/esm/renderer/ComponentRegistry.d.ts +2 -0
  53. package/dist/esm/renderer/ComponentRegistry.d.ts.map +1 -1
  54. package/dist/esm/renderer/InteractiveComponent.d.ts.map +1 -1
  55. package/dist/esm/renderer/InteractiveComponent.js +8 -2
  56. package/dist/esm/renderer/InteractiveComponent.js.map +1 -1
  57. package/dist/esm/renderer/index.d.ts +1 -0
  58. package/dist/esm/renderer/index.d.ts.map +1 -1
  59. package/dist/esm/renderer/index.js +1 -0
  60. package/dist/esm/renderer/index.js.map +1 -1
  61. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  62. package/package.json +5 -5
  63. package/packages/ComponentsUiLibraryContract.ts +89 -0
  64. package/packages/DesignTimeAction.ts +25 -0
  65. package/packages/DesignTimeBundle.ts +27 -0
  66. package/packages/PackageHostConfiguration.ts +56 -0
  67. package/packages/ScenePackageBundle.ts +19 -0
  68. package/packages/index.ts +4 -0
  69. package/renderer/BindingOutputContext.tsx +69 -0
  70. package/renderer/ComponentRegistry.ts +4 -0
  71. package/renderer/InteractiveComponent.tsx +5 -2
  72. package/renderer/index.ts +1 -0
package/dist/esm/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { SceneElementView } from './SceneElementView.js';
2
+ export { BindingOutputProvider, useBindingOutputScope, useBindingOutputs } from './renderer/BindingOutputContext.js';
2
3
  export { UnresolvedComponent } from './renderer/UnresolvedComponent.js';
3
4
  export { createReactRenderer } from './renderer/createReactRenderer.js';
4
5
  export { InteractiveComponent } from './renderer/InteractiveComponent.js';
@@ -16,7 +17,10 @@ export { IconAdapterRegistry, createIconAdapterRegistry } from './icons/IconAdap
16
17
  export { IconAdapterProvider, useIconAdapters } from './icons/IconAdapterContext.js';
17
18
  export { useIconGlyph } from './icons/useIconGlyph.js';
18
19
  export { SceneIcon } from './icons/SceneIcon.js';
20
+ export { validateDesignTimeBundle } from './packages/DesignTimeBundle.js';
21
+ export { resolvePackageHost } from './packages/PackageHostConfiguration.js';
19
22
  export { componentRegistryKey, mergeIconAdapters, mergePackageRegistries, validatePackageBundle } from './packages/ScenePackageBundle.js';
23
+ export { validateComponentsUiLibraryContract, validateComponentsUiLibraryMapping } from './packages/ComponentsUiLibraryContract.js';
20
24
  export { applyThemeTokens, themeTokenPrefix, themeTokenProperty } from './theme/themeTokens.js';
21
25
  export { SceneThemeProvider, useSceneTheme } from './theme/SceneThemeProvider.js';
22
26
  export { InteractionScope, attachmentFor, useInteractionScope } from './interactions/InteractionScope.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,19 @@
1
+ export interface ComponentsUiLibraryContract {
2
+ module: string;
3
+ exportName: string;
4
+ id: string;
5
+ abi: number;
6
+ profile: string;
7
+ requiredSlots: readonly string[];
8
+ requiredCapabilities?: readonly string[];
9
+ }
10
+ export interface ComponentsUiLibraryManifest {
11
+ readonly id: string;
12
+ readonly abi: number;
13
+ readonly profile: string;
14
+ readonly slots: object;
15
+ readonly capabilities: readonly string[];
16
+ }
17
+ export declare function validateComponentsUiLibraryContract(contract: ComponentsUiLibraryContract): string[];
18
+ export declare function validateComponentsUiLibraryMapping(contract: ComponentsUiLibraryContract, library: ComponentsUiLibraryManifest): string[];
19
+ //# sourceMappingURL=ComponentsUiLibraryContract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentsUiLibraryContract.d.ts","sourceRoot":"","sources":["../../../packages/ComponentsUiLibraryContract.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,2BAA2B;IAExC,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,EAAE,MAAM,CAAC;IAEnB,EAAE,EAAE,MAAM,CAAC;IAEX,GAAG,EAAE,MAAM,CAAC;IAEZ,OAAO,EAAE,MAAM,CAAC;IAEhB,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAEjC,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C;AAOD,MAAM,WAAW,2BAA2B;IACxC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C;AAGD,wBAAgB,mCAAmC,CAAC,QAAQ,EAAE,2BAA2B,GAAG,MAAM,EAAE,CAoBnG;AAOD,wBAAgB,kCAAkC,CAC9C,QAAQ,EAAE,2BAA2B,EACrC,OAAO,EAAE,2BAA2B,GACrC,MAAM,EAAE,CAmBV"}
@@ -0,0 +1,69 @@
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
+ * The web-only mapping between an independently authored Scene catalog and a Components renderer.
5
+ * Primitive slot identities are not Scene component names: composites such as DataTable remain
6
+ * library-independent. This contract belongs to the React bundle, never the platform-neutral model.
7
+ */ /** Checks a mapping before loading executable frontend code. */ function validateComponentsUiLibraryContract(contract) {
8
+ const problems = [];
9
+ for (const field of [
10
+ 'module',
11
+ 'exportName',
12
+ 'id',
13
+ 'profile'
14
+ ]){
15
+ if (contract[field].trim().length === 0) problems.push(`Components UI library mapping has an empty '${field}'`);
16
+ }
17
+ if (!Number.isInteger(contract.abi) || contract.abi < 1) {
18
+ problems.push('Components UI library mapping requires a positive integer ABI major');
19
+ }
20
+ for (const [field, values] of [
21
+ [
22
+ 'requiredSlots',
23
+ contract.requiredSlots
24
+ ],
25
+ [
26
+ 'requiredCapabilities',
27
+ contract.requiredCapabilities ?? []
28
+ ]
29
+ ]){
30
+ const seen = new Set();
31
+ for (const value of values){
32
+ if (value.trim().length === 0) problems.push(`Components UI library mapping has an empty '${field}' entry`);
33
+ if (seen.has(value)) problems.push(`Components UI library mapping repeats '${value}' in '${field}'`);
34
+ seen.add(value);
35
+ }
36
+ }
37
+ return problems;
38
+ }
39
+ /**
40
+ * Proves that an allowlisted module export satisfies its Scene mapping. Hosts must reject problems,
41
+ * rather than silently falling back to a different library. Additional slots are permitted: a
42
+ * renderer can support more than the bounded profile this integration consumes.
43
+ */ function validateComponentsUiLibraryMapping(contract, library) {
44
+ const problems = validateComponentsUiLibraryContract(contract);
45
+ for (const field of [
46
+ 'id',
47
+ 'abi',
48
+ 'profile'
49
+ ]){
50
+ if (library[field] !== contract[field]) {
51
+ problems.push(`Components UI library '${contract.id}' requires ${field} '${contract[field]}' but the loaded library supplies '${library[field]}'`);
52
+ }
53
+ }
54
+ const slots = new Map(Object.entries(library.slots));
55
+ for (const slot of contract.requiredSlots){
56
+ if (!slots.has(slot) || slots.get(slot) === undefined || slots.get(slot) === null) {
57
+ problems.push(`Components UI library '${contract.id}' provides no implementation for required slot '${slot}'`);
58
+ }
59
+ }
60
+ for (const capability of contract.requiredCapabilities ?? []){
61
+ if (!library.capabilities.includes(capability)) {
62
+ problems.push(`Components UI library '${contract.id}' does not support required capability '${capability}'`);
63
+ }
64
+ }
65
+ return problems;
66
+ }
67
+
68
+ export { validateComponentsUiLibraryContract, validateComponentsUiLibraryMapping };
69
+ //# sourceMappingURL=ComponentsUiLibraryContract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentsUiLibraryContract.js","sources":["../../../packages/ComponentsUiLibraryContract.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\n/**\n * The web-only mapping between an independently authored Scene catalog and a Components renderer.\n * Primitive slot identities are not Scene component names: composites such as DataTable remain\n * library-independent. This contract belongs to the React bundle, never the platform-neutral model.\n */\nexport interface ComponentsUiLibraryContract {\n /** The npm module the host loads through its explicit package allowlist. */\n module: string;\n /** The named export supplying the Components UiLibrary. */\n exportName: string;\n /** The expected runtime library identity. */\n id: string;\n /** The Components renderer ABI major required by this mapping. */\n abi: number;\n /** The renderer profile promised by the library. */\n profile: string;\n /** Primitive or presentation slots the Scene integration requires. */\n requiredSlots: readonly string[];\n /** Capabilities required by the integration, not inferred from library identity. */\n requiredCapabilities?: readonly string[];\n}\n\n/**\n * The structural part of Components' UiLibrary needed to check a mapping. The actual library may\n * also contain providers and executable slot declarations; Scene does not load or reinterpret them.\n * Keeping this structural avoids a Components ABI dependency in Scene.Model or Scene.Engine.\n */\nexport interface ComponentsUiLibraryManifest {\n readonly id: string;\n readonly abi: number;\n readonly profile: string;\n readonly slots: object;\n readonly capabilities: readonly string[];\n}\n\n/** Checks a mapping before loading executable frontend code. */\nexport function validateComponentsUiLibraryContract(contract: ComponentsUiLibraryContract): string[] {\n const problems: string[] = [];\n for (const field of ['module', 'exportName', 'id', 'profile'] as const) {\n if (contract[field].trim().length === 0) problems.push(`Components UI library mapping has an empty '${field}'`);\n }\n if (!Number.isInteger(contract.abi) || contract.abi < 1) {\n problems.push('Components UI library mapping requires a positive integer ABI major');\n }\n for (const [field, values] of [\n ['requiredSlots', contract.requiredSlots],\n ['requiredCapabilities', contract.requiredCapabilities ?? []],\n ] as const) {\n const seen = new Set<string>();\n for (const value of values) {\n if (value.trim().length === 0) problems.push(`Components UI library mapping has an empty '${field}' entry`);\n if (seen.has(value)) problems.push(`Components UI library mapping repeats '${value}' in '${field}'`);\n seen.add(value);\n }\n }\n return problems;\n}\n\n/**\n * Proves that an allowlisted module export satisfies its Scene mapping. Hosts must reject problems,\n * rather than silently falling back to a different library. Additional slots are permitted: a\n * renderer can support more than the bounded profile this integration consumes.\n */\nexport function validateComponentsUiLibraryMapping(\n contract: ComponentsUiLibraryContract,\n library: ComponentsUiLibraryManifest,\n): string[] {\n const problems = validateComponentsUiLibraryContract(contract);\n for (const field of ['id', 'abi', 'profile'] as const) {\n if (library[field] !== contract[field]) {\n problems.push(`Components UI library '${contract.id}' requires ${field} '${contract[field]}' but the loaded library supplies '${library[field]}'`);\n }\n }\n const slots = new Map(Object.entries(library.slots));\n for (const slot of contract.requiredSlots) {\n if (!slots.has(slot) || slots.get(slot) === undefined || slots.get(slot) === null) {\n problems.push(`Components UI library '${contract.id}' provides no implementation for required slot '${slot}'`);\n }\n }\n for (const capability of contract.requiredCapabilities ?? []) {\n if (!library.capabilities.includes(capability)) {\n problems.push(`Components UI library '${contract.id}' does not support required capability '${capability}'`);\n }\n }\n return problems;\n}\n"],"names":["validateComponentsUiLibraryContract","contract","problems","field","trim","length","push","Number","isInteger","abi","values","requiredSlots","requiredCapabilities","seen","Set","value","has","add","validateComponentsUiLibraryMapping","library","id","slots","Map","Object","entries","slot","get","undefined","capability","capabilities","includes"],"mappings":"AAAA;AACA;AAEA;;;;AAIC,qEAgCM,SAASA,oCAAoCC,QAAqC,EAAA;AACrF,IAAA,MAAMC,WAAqB,EAAE;AAC7B,IAAA,KAAK,MAAMC,KAAAA,IAAS;AAAC,QAAA,QAAA;AAAU,QAAA,YAAA;AAAc,QAAA,IAAA;AAAM,QAAA;KAAU,CAAW;AACpE,QAAA,IAAIF,QAAQ,CAACE,KAAAA,CAAM,CAACC,IAAI,GAAGC,MAAM,KAAK,CAAA,EAAGH,QAAAA,CAASI,IAAI,CAAC,CAAC,4CAA4C,EAAEH,KAAAA,CAAM,CAAC,CAAC,CAAA;AAClH,IAAA;IACA,IAAI,CAACI,MAAAA,CAAOC,SAAS,CAACP,QAAAA,CAASQ,GAAG,CAAA,IAAKR,QAAAA,CAASQ,GAAG,GAAG,CAAA,EAAG;AACrDP,QAAAA,QAAAA,CAASI,IAAI,CAAC,qEAAA,CAAA;AAClB,IAAA;AACA,IAAA,KAAK,MAAM,CAACH,KAAAA,EAAOO,MAAAA,CAAO,IAAI;AAC1B,QAAA;AAAC,YAAA,eAAA;AAAiBT,YAAAA,QAAAA,CAASU;AAAc,SAAA;AACzC,QAAA;AAAC,YAAA,sBAAA;YAAwBV,QAAAA,CAASW,oBAAoB,IAAI;AAAG;KAChE,CAAW;AACR,QAAA,MAAMC,OAAO,IAAIC,GAAAA,EAAAA;QACjB,KAAK,MAAMC,SAASL,MAAAA,CAAQ;AACxB,YAAA,IAAIK,KAAAA,CAAMX,IAAI,EAAA,CAAGC,MAAM,KAAK,CAAA,EAAGH,QAAAA,CAASI,IAAI,CAAC,CAAC,4CAA4C,EAAEH,KAAAA,CAAM,OAAO,CAAC,CAAA;AAC1G,YAAA,IAAIU,IAAAA,CAAKG,GAAG,CAACD,KAAAA,CAAAA,EAAQb,SAASI,IAAI,CAAC,CAAC,uCAAuC,EAAES,KAAAA,CA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AASW,oBAAoB,IAAI,EAAE,CAAE;AAC1D,QAAA,IAAI,CAACO,OAAAA,CAAQU,YAAY,CAACC,QAAQ,CAACF,UAAAA,CAAAA,EAAa;AAC5C1B,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,uBAAuB,EAAEL,QAAAA,CAASmB,EAAE,CAAC,wCAAwC,EAAEQ,UAAAA,CAAW,CAAC,CAAC,CAAA;AAC/G,QAAA;AACJ,IAAA;IACA,OAAO1B,QAAAA;AACX;;"}
@@ -0,0 +1,23 @@
1
+ import { ComponentDescriptor, DesignTimeActionDescriptor, ExternalComponent, SceneEdit } from '@cratis/scene.model';
2
+ export interface DesignTimeActionContext {
3
+ element: ExternalComponent;
4
+ descriptor: ComponentDescriptor;
5
+ commandMetadata?: {
6
+ properties: {
7
+ name: string;
8
+ type: string;
9
+ label?: string;
10
+ }[];
11
+ };
12
+ }
13
+ export interface DesignTimeActionResult {
14
+ edits: SceneEdit[];
15
+ diagnostics: string[];
16
+ }
17
+ export interface DesignTimeAction {
18
+ descriptor: DesignTimeActionDescriptor;
19
+ isVisible(context: DesignTimeActionContext): boolean;
20
+ isEnabled(context: DesignTimeActionContext): boolean;
21
+ execute(context: DesignTimeActionContext): DesignTimeActionResult;
22
+ }
23
+ //# sourceMappingURL=DesignTimeAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DesignTimeAction.d.ts","sourceRoot":"","sources":["../../../packages/DesignTimeAction.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEpH,MAAM,WAAW,uBAAuB;IACpC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,UAAU,EAAE,mBAAmB,CAAC;IAChC,eAAe,CAAC,EAAE;QAAE,UAAU,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAAE,CAAC;CACtF;AAED,MAAM,WAAW,sBAAsB;IACnC,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB;AAKD,MAAM,WAAW,gBAAgB;IAC7B,UAAU,EAAE,0BAA0B,CAAC;IACvC,SAAS,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC;IACrD,SAAS,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC;IACrD,OAAO,CAAC,OAAO,EAAE,uBAAuB,GAAG,sBAAsB,CAAC;CACrE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=DesignTimeAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DesignTimeAction.js","sourceRoot":"","sources":["../../../packages/DesignTimeAction.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+ import { DesignTimeAction } from './DesignTimeAction';
3
+ export interface DesignTimeBundle {
4
+ previews?: Record<string, ComponentType<{
5
+ children?: ReactNode;
6
+ }>>;
7
+ designers?: Record<string, ComponentType<{
8
+ children?: ReactNode;
9
+ }>>;
10
+ propertyEditors?: Record<string, ComponentType<Record<string, unknown>>>;
11
+ propertyDisplays?: Record<string, ComponentType<{
12
+ value: unknown;
13
+ }>>;
14
+ actions?: Record<string, DesignTimeAction>;
15
+ }
16
+ export declare function validateDesignTimeBundle(bundle: DesignTimeBundle | undefined): string[];
17
+ //# sourceMappingURL=DesignTimeBundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DesignTimeBundle.d.ts","sourceRoot":"","sources":["../../../packages/DesignTimeBundle.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAKtD,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC,CAAC;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC,CAAC;IACpE,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACzE,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC,CAAC;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC9C;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,GAAG,MAAM,EAAE,CASvF"}
@@ -0,0 +1,15 @@
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
+ function validateDesignTimeBundle(bundle) {
4
+ if (!bundle) return [];
5
+ const problems = [];
6
+ for (const [name, action] of Object.entries(bundle.actions ?? {})){
7
+ if (action.descriptor.id !== name) {
8
+ problems.push(`registers design-time action '${name}' with descriptor id '${action.descriptor.id}'`);
9
+ }
10
+ }
11
+ return problems;
12
+ }
13
+
14
+ export { validateDesignTimeBundle };
15
+ //# sourceMappingURL=DesignTimeBundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DesignTimeBundle.js","sources":["../../../packages/DesignTimeBundle.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 { ComponentType, ReactNode } from 'react';\nimport { DesignTimeAction } from './DesignTimeAction';\n\n/**\n * Optional React-only design-time surface a package may publish beside its runtime bundle.\n */\nexport interface DesignTimeBundle {\n previews?: Record<string, ComponentType<{ children?: ReactNode }>>;\n designers?: Record<string, ComponentType<{ children?: ReactNode }>>;\n propertyEditors?: Record<string, ComponentType<Record<string, unknown>>>;\n propertyDisplays?: Record<string, ComponentType<{ value: unknown }>>;\n actions?: Record<string, DesignTimeAction>;\n}\n\nexport function validateDesignTimeBundle(bundle: DesignTimeBundle | undefined): string[] {\n if (!bundle) return [];\n const problems: string[] = [];\n for (const [name, action] of Object.entries(bundle.actions ?? {})) {\n if (action.descriptor.id !== name) {\n problems.push(`registers design-time action '${name}' with descriptor id '${action.descriptor.id}'`);\n }\n }\n return problems;\n}\n"],"names":["validateDesignTimeBundle","bundle","problems","name","action","Object","entries","actions","descriptor","id","push"],"mappings":"AAAA;AACA;AAgBO,SAASA,yBAAyBC,MAAoC,EAAA;IACzE,IAAI,CAACA,MAAAA,EAAQ,OAAO,EAAE;AACtB,IAAA,MAAMC,WAAqB,EAAE;AAC7B,IAAA,KAAK,MAAM,CAACC,IAAAA,EAAMC,MAAAA,CAAO,IAAIC,MAAAA,CAAOC,OAAO,CAACL,MAAAA,CAAOM,OAAO,IAAI,EAAC,CAAA,CAAI;AAC/D,QAAA,IAAIH,MAAAA,CAAOI,UAAU,CAACC,EAAE,KAAKN,IAAAA,EAAM;AAC/BD,YAAAA,QAAAA,CAASQ,IAAI,CAAC,CAAC,8BAA8B,EAAEP,IAAAA,CAAK,sBAAsB,EAAEC,MAAAA,CAAOI,UAAU,CAACC,EAAE,CAAC,CAAC,CAAC,CAAA;AACvG,QAAA;AACJ,IAAA;IACA,OAAOP,QAAAA;AACX;;"}
@@ -0,0 +1,18 @@
1
+ import { UiProfile } from '@cratis/scene.model';
2
+ import { ScenePackageBundle, mergePackageRegistries } from './ScenePackageBundle';
3
+ export interface PackageHostPolicy {
4
+ allowExecutableImports: boolean;
5
+ allowNetworkAssets: boolean;
6
+ }
7
+ export interface PackageHostConfiguration {
8
+ bundles: ScenePackageBundle[];
9
+ profile: UiProfile;
10
+ policy: PackageHostPolicy;
11
+ }
12
+ export interface ResolvedPackageHost {
13
+ bundles: ScenePackageBundle[];
14
+ components: ReturnType<typeof mergePackageRegistries>;
15
+ diagnostics: string[];
16
+ }
17
+ export declare function resolvePackageHost(configuration: PackageHostConfiguration): ResolvedPackageHost;
18
+ //# sourceMappingURL=PackageHostConfiguration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageHostConfiguration.d.ts","sourceRoot":"","sources":["../../../packages/PackageHostConfiguration.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAElF,MAAM,WAAW,iBAAiB;IAC9B,sBAAsB,EAAE,OAAO,CAAC;IAChC,kBAAkB,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;IACtD,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB;AAKD,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,wBAAwB,GAAG,mBAAmB,CA6B/F"}
@@ -0,0 +1,41 @@
1
+ import { mergePackageRegistries } from './ScenePackageBundle.js';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * Resolves the approved package set a standalone or embedded React host uses.
7
+ */ function resolvePackageHost(configuration) {
8
+ const diagnostics = [];
9
+ const byName = new Map(configuration.bundles.map((bundle)=>[
10
+ bundle.manifest.name,
11
+ bundle
12
+ ]));
13
+ const bundles = [];
14
+ const runtimeSingletons = new Map();
15
+ for (const packageName of configuration.profile.packages){
16
+ const bundle = byName.get(packageName);
17
+ if (!bundle) {
18
+ diagnostics.push(`UI profile asks for '${packageName}' but the host did not approve a bundle for it`);
19
+ continue;
20
+ }
21
+ if (!configuration.policy.allowNetworkAssets && (bundle.manifest.assets ?? []).some((asset)=>/^https?:\/\//.test(asset))) {
22
+ diagnostics.push(`Package '${packageName}' declares network assets, but host policy forbids them`);
23
+ }
24
+ for (const dependency of bundle.manifest.runtimeSingletons ?? []){
25
+ const owner = runtimeSingletons.get(dependency);
26
+ if (owner && owner !== packageName) {
27
+ diagnostics.push(`Runtime singleton '${dependency}' is provided by both '${owner}' and '${packageName}'`);
28
+ }
29
+ runtimeSingletons.set(dependency, packageName);
30
+ }
31
+ bundles.push(bundle);
32
+ }
33
+ return {
34
+ bundles,
35
+ components: mergePackageRegistries(bundles),
36
+ diagnostics
37
+ };
38
+ }
39
+
40
+ export { resolvePackageHost };
41
+ //# sourceMappingURL=PackageHostConfiguration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageHostConfiguration.js","sources":["../../../packages/PackageHostConfiguration.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 { UiProfile } from '@cratis/scene.model';\nimport { ScenePackageBundle, mergePackageRegistries } from './ScenePackageBundle';\n\nexport interface PackageHostPolicy {\n allowExecutableImports: boolean;\n allowNetworkAssets: boolean;\n}\n\nexport interface PackageHostConfiguration {\n bundles: ScenePackageBundle[];\n profile: UiProfile;\n policy: PackageHostPolicy;\n}\n\nexport interface ResolvedPackageHost {\n bundles: ScenePackageBundle[];\n components: ReturnType<typeof mergePackageRegistries>;\n diagnostics: string[];\n}\n\n/**\n * Resolves the approved package set a standalone or embedded React host uses.\n */\nexport function resolvePackageHost(configuration: PackageHostConfiguration): ResolvedPackageHost {\n const diagnostics: string[] = [];\n const byName = new Map(configuration.bundles.map(bundle => [bundle.manifest.name, bundle]));\n const bundles: ScenePackageBundle[] = [];\n const runtimeSingletons = new Map<string, string>();\n\n for (const packageName of configuration.profile.packages) {\n const bundle = byName.get(packageName);\n if (!bundle) {\n diagnostics.push(`UI profile asks for '${packageName}' but the host did not approve a bundle for it`);\n continue;\n }\n\n if (!configuration.policy.allowNetworkAssets && (bundle.manifest.assets ?? []).some(asset => /^https?:\\/\\//.test(asset))) {\n diagnostics.push(`Package '${packageName}' declares network assets, but host policy forbids them`);\n }\n\n for (const dependency of bundle.manifest.runtimeSingletons ?? []) {\n const owner = runtimeSingletons.get(dependency);\n if (owner && owner !== packageName) {\n diagnostics.push(`Runtime singleton '${dependency}' is provided by both '${owner}' and '${packageName}'`);\n }\n runtimeSingletons.set(dependency, packageName);\n }\n\n bundles.push(bundle);\n }\n\n return { bundles, components: mergePackageRegistries(bundles), diagnostics };\n}\n"],"names":["resolvePackageHost","configuration","diagnostics","byName","Map","bundles","map","bundle","manifest","name","runtimeSingletons","packageName","profile","packages","get","push","policy","allowNetworkAssets","assets","some","asset","test","dependency","owner","set","components","mergePackageRegistries"],"mappings":";;AAAA;AACA;AAsBA;;IAGO,SAASA,kBAAAA,CAAmBC,aAAuC,EAAA;AACtE,IAAA,MAAMC,cAAwB,EAAE;IAChC,MAAMC,MAAAA,GAAS,IAAIC,GAAAA,CAAIH,aAAAA,CAAcI,OAAO,CAACC,GAAG,CAACC,CAAAA,MAAAA,GAAU;YAACA,MAAAA,CAAOC,QAAQ,CAACC,IAAI;AAAEF,YAAAA;AAAO,SAAA,CAAA,CAAA;AACzF,IAAA,MAAMF,UAAgC,EAAE;AACxC,IAAA,MAAMK,oBAAoB,IAAIN,GAAAA,EAAAA;AAE9B,IAAA,KAAK,MAAMO,WAAAA,IAAeV,aAAAA,CAAcW,OAAO,CAACC,QAAQ,CAAE;QACtD,MAAMN,MAAAA,GAASJ,MAAAA,CAAOW,GAAG,CAACH,WAAAA,CAAAA;AAC1B,QAAA,IAAI,CAACJ,MAAAA,EAAQ;AACTL,YAAAA,WAAAA,CAAYa,IAAI,CAAC,CAAC,qBAAqB,EAAEJ,WAAAA,CAAY,8CAA8C,CAAC,CAAA;AACpG,YAAA;AACJ,QAAA;QAEA,IAAI,CAACV,cAAce,MAAM,CAACC,kBAAkB,IAAKV,CAAAA,MAAAA,CAAOC,QAAQ,CAACU,MAAM,IAAI,EAAE,EAAEC,IAAI,CAACC,CAAAA,KAAAA,GAAS,cAAA,CAAeC,IAAI,CAACD,KAAAA,CAAAA,CAAAA,EAAS;AACtHlB,YAAAA,WAAAA,CAAYa,IAAI,CAAC,CAAC,SAAS,EAAEJ,WAAAA,CAAY,uDAAuD,CAAC,CAAA;AACrG,QAAA;QAEA,KAAK,MAAMW,cAAcf,MAAAA,CAAOC,QAAQ,CAACE,iBAAiB,IAAI,EAAE,CAAE;YAC9D,MAAMa,KAAAA,GAAQb,iBAAAA,CAAkBI,GAAG,CAACQ,UAAAA,CAAAA;YACpC,IAAIC,KAAAA,IAASA,UAAUZ,WAAAA,EAAa;AAChCT,gBAAAA,WAAAA,CAAYa,IAAI,CAAC,CAAC,mBAAmB,EAAEO,UAAAA,CAAW,uBAAuB,EAAEC,KAAAA,CAAM,OAAO,EAAEZ,WAAAA,CAAY,CAAC,CAAC,CAAA;AAC5G,YAAA;YACAD,iBAAAA,CAAkBc,GAAG,CAACF,UAAAA,EAAYX,WAAAA,CAAAA;AACtC,QAAA;AAEAN,QAAAA,OAAAA,CAAQU,IAAI,CAACR,MAAAA,CAAAA;AACjB,IAAA;IAEA,OAAO;AAAEF,QAAAA,OAAAA;AAASoB,QAAAA,UAAAA,EAAYC,sBAAAA,CAAuBrB,OAAAA,CAAAA;AAAUH,QAAAA;AAAY,KAAA;AAC/E;;"}
@@ -2,6 +2,8 @@ import { ComponentDescriptor, DialogTemplate, Layout, ScenePackage, Screen, Scre
2
2
  import { IconAdapterRegistry } from '../icons/IconAdapterRegistry';
3
3
  import { IconLibraryBundle } from '../icons/IconLibraryBundle';
4
4
  import { ComponentRegistry } from '../renderer';
5
+ import { ComponentsUiLibraryContract } from './ComponentsUiLibraryContract';
6
+ import { DesignTimeBundle } from './DesignTimeBundle';
5
7
  export interface ScenePackageBundle {
6
8
  manifest: ScenePackage;
7
9
  components: ComponentRegistry;
@@ -12,6 +14,8 @@ export interface ScenePackageBundle {
12
14
  descriptors?: ComponentDescriptor[];
13
15
  themes?: Theme[];
14
16
  iconLibrary?: IconLibraryBundle;
17
+ componentsUiLibrary?: ComponentsUiLibraryContract;
18
+ designTime?: DesignTimeBundle;
15
19
  }
16
20
  export declare function componentRegistryKey(packageName: string, componentName: string): string;
17
21
  export declare function validatePackageBundle(bundle: ScenePackageBundle): string[];
@@ -1 +1 @@
1
- {"version":3,"file":"ScenePackageBundle.d.ts","sourceRoot":"","sources":["../../../packages/ScenePackageBundle.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,EAAkC,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC/J,OAAO,EAAE,mBAAmB,EAA6B,MAAM,8BAA8B,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAchD,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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AAE,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;AAmFD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,iBAAiB,CAEvF;AAOD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,mBAAmB,CAEpF"}
@@ -1,5 +1,7 @@
1
1
  import { PackageKind, PropertyValueType } from '@cratis/scene.model';
2
2
  import { createIconAdapterRegistry } from '../icons/IconAdapterRegistry.js';
3
+ import { validateComponentsUiLibraryContract } from './ComponentsUiLibraryContract.js';
4
+ import { validateDesignTimeBundle } from './DesignTimeBundle.js';
3
5
 
4
6
  // Copyright (c) Cratis. All rights reserved.
5
7
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
@@ -61,8 +63,15 @@ import { createIconAdapterRegistry } from '../icons/IconAdapterRegistry.js';
61
63
  problems.push(`declares the theme '${name}' but provides no definition for it`);
62
64
  }
63
65
  }
66
+ if (bundle.componentsUiLibrary) {
67
+ if (manifest.kind !== PackageKind.ComponentLibrary) {
68
+ problems.push('declares a Components UI library mapping but is not of kind ComponentLibrary');
69
+ }
70
+ problems.push(...validateComponentsUiLibraryContract(bundle.componentsUiLibrary));
71
+ }
64
72
  problems.push(...validateIconLibrary(bundle));
65
73
  problems.push(...validateDescriptors(bundle));
74
+ problems.push(...validateDesignTimeBundle(bundle.designTime));
66
75
  return problems;
67
76
  }
68
77
  function validateIconLibrary(bundle) {
@@ -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';\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/**\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 problems.push(...validateIconLibrary(bundle));\n problems.push(...validateDescriptors(bundle));\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","validateIconLibrary","validateDescriptors","iconLibrary","declaresIconLibrary","kind","PackageKind","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;AAyEA;;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UAAAA,CAAWE,SAAS,CAAC,sBAAsB,EAAEG,QAAAA,CAASE,IAAI,CAAC,iBAAiB,CAAC,CAAA;AACnG,YAAA;AACJ,QAAA;AACJ,IAAA;IAEA,OAAO5C,QAAAA;AACX;AAEA;;;;;IAMO,SAASoD,sBAAAA,CAAuBC,OAA6B,EAAA;IAChE,OAAO5C,MAAAA,CAAO6C,MAAM,CAAC,EAAC,EAAA,GAAMD,OAAAA,CAAQ9C,GAAG,CAAC,CAACR,MAAAA,GAAWA,MAAAA,CAAOI,UAAU,CAAA,CAAA;AACzE;AAEA;;;;IAKO,SAASoD,iBAAAA,CAAkBF,OAA6B,EAAA;IAC3D,OAAOG,yBAAAA,CAA0BH,QAAQI,OAAO,CAAC,CAAC1D,MAAAA,GAAYA,MAAAA,CAAO0B,WAAW,GAAG;YAAC1B,MAAAA,CAAO0B,WAAW,CAACQ;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, 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","flat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AS,KAAKC,iBAAAA,CAAkBC,UAAU,IAAIL,QAAAA,CAASM,IAAI,KAAKlB,SAAAA,EAAW;AACpFnC,gBAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,CAAC,EAAEsC,UAAAA,CAAWE,SAAS,CAAC,4BAA4B,EAAEG,QAAAA,CAASE,IAAI,CAAC,8BAA8B,CAAC,CAAA;AACtH,YAAA;AAEA,YAAA,IAAIF,SAASG,SAAS,KAAKC,iBAAAA,CAAkBG,IAAI,IAAI,CAACP,QAAAA,CAASQ,OAAO,IAAI,EAAC,EAAGC,MAAM,KAAK,CAAA,EAAG;AACxFxD,gBAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,CAAC,EAAEsC,UAAAA,CAAWE,SAAS,CAAC,sBAAsB,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,yBAAAA,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,2 +1,6 @@
1
+ export * from './DesignTimeAction';
2
+ export * from './DesignTimeBundle';
3
+ export * from './PackageHostConfiguration';
1
4
  export * from './ScenePackageBundle';
5
+ export * from './ComponentsUiLibraryContract';
2
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/index.ts"],"names":[],"mappings":"AAGA,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/index.ts"],"names":[],"mappings":"AAGA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC"}
@@ -1,2 +1,6 @@
1
+ export * from './DesignTimeAction';
2
+ export * from './DesignTimeBundle';
3
+ export * from './PackageHostConfiguration';
1
4
  export * from './ScenePackageBundle';
5
+ export * from './ComponentsUiLibraryContract';
2
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/index.ts"],"names":[],"mappings":"AAGA,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/index.ts"],"names":[],"mappings":"AAGA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { ReactNode } from 'react';
2
+ export interface ComponentBindingOutputs {
3
+ setOutput(property: string, value: unknown): void;
4
+ clearOutput(property: string): void;
5
+ clearAll(): void;
6
+ }
7
+ export interface BindingOutputProviderValue {
8
+ outputs: Record<string, Record<string, unknown>>;
9
+ outputFor(elementId: string): ComponentBindingOutputs;
10
+ }
11
+ export interface BindingOutputProviderProps {
12
+ children: ReactNode;
13
+ onOutputsChanged?: (outputs: Record<string, Record<string, unknown>>) => void;
14
+ }
15
+ export declare function BindingOutputProvider({ children, onOutputsChanged }: BindingOutputProviderProps): import("react").JSX.Element;
16
+ export declare function useBindingOutputs(elementId: string): ComponentBindingOutputs;
17
+ export declare function useBindingOutputScope(): Record<string, Record<string, unknown>>;
18
+ //# sourceMappingURL=BindingOutputContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BindingOutputContext.d.ts","sourceRoot":"","sources":["../../../renderer/BindingOutputContext.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAwE,MAAM,OAAO,CAAC;AAExG,MAAM,WAAW,uBAAuB;IACpC,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAClD,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,IAAI,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,0BAA0B;IACvC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjD,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB,CAAC;CACzD;AAUD,MAAM,WAAW,0BAA0B;IACvC,QAAQ,EAAE,SAAS,CAAC;IACpB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC;CACjF;AAKD,wBAAgB,qBAAqB,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,EAAE,0BAA0B,+BA2B/F;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB,CAG5E;AAED,wBAAgB,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAE/E"}
@@ -0,0 +1,70 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useState, useEffect, useCallback, useMemo, useContext, createContext } from 'react';
3
+
4
+ const emptyOutputs = {
5
+ setOutput: ()=>undefined,
6
+ clearOutput: ()=>undefined,
7
+ clearAll: ()=>undefined
8
+ };
9
+ const Context = /*#__PURE__*/ createContext(undefined);
10
+ /**
11
+ * Tracks component output properties for typed component-property bindings and clears them with component lifecycle.
12
+ */ function BindingOutputProvider({ children, onOutputsChanged }) {
13
+ const [outputs, setOutputs] = useState({});
14
+ useEffect(()=>{
15
+ onOutputsChanged?.(outputs);
16
+ }, [
17
+ onOutputsChanged,
18
+ outputs
19
+ ]);
20
+ const outputFor = useCallback((elementId)=>({
21
+ setOutput: (property, propertyValue)=>setOutputs((current)=>({
22
+ ...current,
23
+ [elementId]: {
24
+ ...current[elementId] ?? {},
25
+ [property]: propertyValue
26
+ }
27
+ })),
28
+ clearOutput: (property)=>setOutputs((current)=>{
29
+ const elementOutputs = {
30
+ ...current[elementId] ?? {}
31
+ };
32
+ delete elementOutputs[property];
33
+ return {
34
+ ...current,
35
+ [elementId]: elementOutputs
36
+ };
37
+ }),
38
+ clearAll: ()=>setOutputs((current)=>{
39
+ const next = {
40
+ ...current
41
+ };
42
+ delete next[elementId];
43
+ return next;
44
+ })
45
+ }), []);
46
+ const value = useMemo(()=>({
47
+ outputs,
48
+ outputFor
49
+ }), [
50
+ outputs,
51
+ outputFor
52
+ ]);
53
+ return /*#__PURE__*/ jsx(Context.Provider, {
54
+ value: value,
55
+ children: children
56
+ });
57
+ }
58
+ function useBindingOutputs(elementId) {
59
+ const outputFor = useContext(Context)?.outputFor;
60
+ return useMemo(()=>outputFor?.(elementId) ?? emptyOutputs, [
61
+ outputFor,
62
+ elementId
63
+ ]);
64
+ }
65
+ function useBindingOutputScope() {
66
+ return useContext(Context)?.outputs ?? {};
67
+ }
68
+
69
+ export { BindingOutputProvider, useBindingOutputScope, useBindingOutputs };
70
+ //# sourceMappingURL=BindingOutputContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BindingOutputContext.js","sources":["../../../renderer/BindingOutputContext.tsx"],"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 { ReactNode, createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\n\nexport interface ComponentBindingOutputs {\n setOutput(property: string, value: unknown): void;\n clearOutput(property: string): void;\n clearAll(): void;\n}\n\nexport interface BindingOutputProviderValue {\n outputs: Record<string, Record<string, unknown>>;\n outputFor(elementId: string): ComponentBindingOutputs;\n}\n\nconst emptyOutputs: ComponentBindingOutputs = {\n setOutput: () => undefined,\n clearOutput: () => undefined,\n clearAll: () => undefined,\n};\n\nconst Context = createContext<BindingOutputProviderValue | undefined>(undefined);\n\nexport interface BindingOutputProviderProps {\n children: ReactNode;\n onOutputsChanged?: (outputs: Record<string, Record<string, unknown>>) => void;\n}\n\n/**\n * Tracks component output properties for typed component-property bindings and clears them with component lifecycle.\n */\nexport function BindingOutputProvider({ children, onOutputsChanged }: BindingOutputProviderProps) {\n const [outputs, setOutputs] = useState<Record<string, Record<string, unknown>>>({});\n\n useEffect(() => {\n onOutputsChanged?.(outputs);\n }, [onOutputsChanged, outputs]);\n\n const outputFor = useCallback((elementId: string): ComponentBindingOutputs => ({\n setOutput: (property: string, propertyValue: unknown) => setOutputs(current => ({\n ...current,\n [elementId]: { ...(current[elementId] ?? {}), [property]: propertyValue },\n })),\n clearOutput: (property: string) => setOutputs(current => {\n const elementOutputs = { ...(current[elementId] ?? {}) };\n delete elementOutputs[property];\n return { ...current, [elementId]: elementOutputs };\n }),\n clearAll: () => setOutputs(current => {\n const next = { ...current };\n delete next[elementId];\n return next;\n }),\n }), []);\n\n const value = useMemo<BindingOutputProviderValue>(() => ({ outputs, outputFor }), [outputs, outputFor]);\n\n return <Context.Provider value={value}>{children}</Context.Provider>;\n}\n\nexport function useBindingOutputs(elementId: string): ComponentBindingOutputs {\n const outputFor = useContext(Context)?.outputFor;\n return useMemo(() => outputFor?.(elementId) ?? emptyOutputs, [outputFor, elementId]);\n}\n\nexport function useBindingOutputScope(): Record<string, Record<string, unknown>> {\n return useContext(Context)?.outputs ?? {};\n}\n"],"names":["emptyOutputs","setOutput","undefined","clearOutput","clearAll","Context","createContext","BindingOutputProvider","children","onOutputsChanged","outputs","setOutputs","useState","useEffect","outputFor","useCallback","elementId","property","propertyValue","current","elementOutputs","next","value","useMemo","_jsx","Provider","useBindingOutputs","useContext","useBindingOutputScope"],"mappings":";;;AAgBA,MAAMA,YAAAA,GAAwC;AAC1CC,IAAAA,SAAAA,EAAW,IAAMC,SAAAA;AACjBC,IAAAA,WAAAA,EAAa,IAAMD,SAAAA;AACnBE,IAAAA,QAAAA,EAAU,IAAMF;AACpB,CAAA;AAEA,MAAMG,wBAAUC,aAAAA,CAAsDJ,SAAAA,CAAAA;AAOtE;;AAEC,IACM,SAASK,qBAAAA,CAAsB,EAAEC,QAAQ,EAAEC,gBAAgB,EAA8B,EAAA;AAC5F,IAAA,MAAM,CAACC,OAAAA,EAASC,UAAAA,CAAW,GAAGC,SAAkD,EAAC,CAAA;IAEjFC,SAAAA,CAAU,IAAA;QACNJ,gBAAAA,GAAmBC,OAAAA,CAAAA;IACvB,CAAA,EAAG;AAACD,QAAAA,gBAAAA;AAAkBC,QAAAA;AAAQ,KAAA,CAAA;AAE9B,IAAA,MAAMI,SAAAA,GAAYC,WAAAA,CAAY,CAACC,SAAAA,IAAgD;AAC3Ef,YAAAA,SAAAA,EAAW,CAACgB,QAAAA,EAAkBC,aAAAA,GAA2BP,UAAAA,CAAWQ,CAAAA,WAAY;AAC5E,wBAAA,GAAGA,OAAO;AACV,wBAAA,CAACH,YAAY;AAAE,4BAAA,GAAIG,OAAO,CAACH,SAAAA,CAAU,IAAI,EAAE;AAAG,4BAAA,CAACC,WAAWC;AAAc;qBAC5E,CAAA,CAAA;YACAf,WAAAA,EAAa,CAACc,QAAAA,GAAqBN,UAAAA,CAAWQ,CAAAA,OAAAA,GAAAA;AAC1C,oBAAA,MAAMC,cAAAA,GAAiB;AAAE,wBAAA,GAAID,OAAO,CAACH,SAAAA,CAAU,IAAI;AAAI,qBAAA;oBACvD,OAAOI,cAAc,CAACH,QAAAA,CAAS;oBAC/B,OAAO;AAAE,wBAAA,GAAGE,OAAO;AAAE,wBAAA,CAACH,YAAYI;AAAe,qBAAA;AACrD,gBAAA,CAAA,CAAA;YACAhB,QAAAA,EAAU,IAAMO,WAAWQ,CAAAA,OAAAA,GAAAA;AACvB,oBAAA,MAAME,IAAAA,GAAO;AAAE,wBAAA,GAAGF;AAAQ,qBAAA;oBAC1B,OAAOE,IAAI,CAACL,SAAAA,CAAU;oBACtB,OAAOK,IAAAA;AACX,gBAAA,CAAA;AACJ,SAAA,GAAI,EAAE,CAAA;IAEN,MAAMC,KAAAA,GAAQC,OAAAA,CAAoC,KAAO;AAAEb,YAAAA,OAAAA;AAASI,YAAAA;AAAU,SAAA,CAAA,EAAI;AAACJ,QAAAA,OAAAA;AAASI,QAAAA;AAAU,KAAA,CAAA;IAEtG,qBAAOU,GAAA,CAACnB,QAAQoB,QAAQ,EAAA;QAACH,KAAAA,EAAOA,KAAAA;AAAQd,QAAAA,QAAAA,EAAAA;;AAC5C;AAEO,SAASkB,kBAAkBV,SAAiB,EAAA;IAC/C,MAAMF,SAAAA,GAAYa,WAAWtB,OAAAA,CAAAA,EAAUS,SAAAA;AACvC,IAAA,OAAOS,OAAAA,CAAQ,IAAMT,SAAAA,GAAYE,SAAAA,CAAAA,IAAchB,YAAAA,EAAc;AAACc,QAAAA,SAAAA;AAAWE,QAAAA;AAAU,KAAA,CAAA;AACvF;AAEO,SAASY,qBAAAA,GAAAA;IACZ,OAAOD,UAAAA,CAAWtB,OAAAA,CAAAA,EAAUK,OAAAA,IAAW,EAAC;AAC5C;;"}
@@ -1,10 +1,12 @@
1
1
  import { ComponentType, ReactNode } from 'react';
2
2
  import { ExternalComponent } from '@cratis/scene.model';
3
3
  import { InteractionHandlers } from '../interactions';
4
+ import { ComponentBindingOutputs } from './BindingOutputContext';
4
5
  export interface RegisteredComponentProps {
5
6
  element: ExternalComponent;
6
7
  slots: Record<string, ReactNode[]>;
7
8
  interactions?: InteractionHandlers;
9
+ bindingOutputs?: ComponentBindingOutputs;
8
10
  }
9
11
  export type ComponentRegistry = Record<string, ComponentType<RegisteredComponentProps>>;
10
12
  //# sourceMappingURL=ComponentRegistry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ComponentRegistry.d.ts","sourceRoot":"","sources":["../../../renderer/ComponentRegistry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAKtD,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAUnC,YAAY,CAAC,EAAE,mBAAmB,CAAC;CACtC;AAUD,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"ComponentRegistry.d.ts","sourceRoot":"","sources":["../../../renderer/ComponentRegistry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAKjE,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAUnC,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAGnC,cAAc,CAAC,EAAE,uBAAuB,CAAC;CAC5C;AAUD,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"InteractiveComponent.d.ts","sourceRoot":"","sources":["../../../renderer/InteractiveComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAiB,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,WAAW,yBAAyB;IACtC,SAAS,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;IACnD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;CACtC;AASD,wBAAgB,oBAAoB,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,yBAAyB,+GAG5F"}
1
+ {"version":3,"file":"InteractiveComponent.d.ts","sourceRoot":"","sources":["../../../renderer/InteractiveComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,SAAS,EAA4B,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,WAAW,yBAAyB;IACtC,SAAS,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;IACnD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;CACtC;AASD,wBAAgB,oBAAoB,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,yBAAyB,+GAK5F"}