@cratis/scene.react 0.1.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 (175) hide show
  1. package/.storybook/main.ts +31 -0
  2. package/.storybook/preview.ts +12 -0
  3. package/NavBar/NavBar.tsx +53 -0
  4. package/NavBar/extractNavigationItem.ts +40 -0
  5. package/NavBar/for_NavBar/when_rendering_navigation_contributions.tsx +62 -0
  6. package/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.ts +53 -0
  7. package/NavBar/index.ts +5 -0
  8. package/README.md +40 -0
  9. package/SceneElementView.stories.tsx +67 -0
  10. package/SceneElementView.tsx +22 -0
  11. package/core/CoreButton.tsx +17 -0
  12. package/core/CoreCard.tsx +15 -0
  13. package/core/CoreText.tsx +13 -0
  14. package/core/coreComponents.ts +18 -0
  15. package/core/corePackage.ts +36 -0
  16. package/core/index.ts +8 -0
  17. package/dist/cjs/NavBar/NavBar.js +47 -0
  18. package/dist/cjs/NavBar/NavBar.js.map +1 -0
  19. package/dist/cjs/NavBar/extractNavigationItem.js +38 -0
  20. package/dist/cjs/NavBar/extractNavigationItem.js.map +1 -0
  21. package/dist/cjs/SceneElementView.js +21 -0
  22. package/dist/cjs/SceneElementView.js.map +1 -0
  23. package/dist/cjs/core/CoreButton.js +22 -0
  24. package/dist/cjs/core/CoreButton.js.map +1 -0
  25. package/dist/cjs/core/CoreCard.js +22 -0
  26. package/dist/cjs/core/CoreCard.js.map +1 -0
  27. package/dist/cjs/core/CoreText.js +19 -0
  28. package/dist/cjs/core/CoreText.js.map +1 -0
  29. package/dist/cjs/core/coreComponents.js +20 -0
  30. package/dist/cjs/core/coreComponents.js.map +1 -0
  31. package/dist/cjs/core/corePackage.js +41 -0
  32. package/dist/cjs/core/corePackage.js.map +1 -0
  33. package/dist/cjs/index.js +38 -0
  34. package/dist/cjs/index.js.map +1 -0
  35. package/dist/cjs/package.json +3 -0
  36. package/dist/cjs/packages/ScenePackageBundle.js +76 -0
  37. package/dist/cjs/packages/ScenePackageBundle.js.map +1 -0
  38. package/dist/cjs/renderer/UnresolvedComponent.js +28 -0
  39. package/dist/cjs/renderer/UnresolvedComponent.js.map +1 -0
  40. package/dist/cjs/renderer/createReactRenderer.js +48 -0
  41. package/dist/cjs/renderer/createReactRenderer.js.map +1 -0
  42. package/dist/cjs/theme/SceneThemeProvider.js +44 -0
  43. package/dist/cjs/theme/SceneThemeProvider.js.map +1 -0
  44. package/dist/cjs/theme/themeTokens.js +52 -0
  45. package/dist/cjs/theme/themeTokens.js.map +1 -0
  46. package/dist/esm/NavBar/NavBar.d.ts +7 -0
  47. package/dist/esm/NavBar/NavBar.d.ts.map +1 -0
  48. package/dist/esm/NavBar/NavBar.js +45 -0
  49. package/dist/esm/NavBar/NavBar.js.map +1 -0
  50. package/dist/esm/NavBar/extractNavigationItem.d.ts +3 -0
  51. package/dist/esm/NavBar/extractNavigationItem.d.ts.map +1 -0
  52. package/dist/esm/NavBar/extractNavigationItem.js +36 -0
  53. package/dist/esm/NavBar/extractNavigationItem.js.map +1 -0
  54. package/dist/esm/NavBar/for_NavBar/when_rendering_navigation_contributions.d.ts +2 -0
  55. package/dist/esm/NavBar/for_NavBar/when_rendering_navigation_contributions.d.ts.map +1 -0
  56. package/dist/esm/NavBar/for_NavBar/when_rendering_navigation_contributions.js +53 -0
  57. package/dist/esm/NavBar/for_NavBar/when_rendering_navigation_contributions.js.map +1 -0
  58. package/dist/esm/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.d.ts +2 -0
  59. package/dist/esm/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.d.ts.map +1 -0
  60. package/dist/esm/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.js +45 -0
  61. package/dist/esm/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.js.map +1 -0
  62. package/dist/esm/NavBar/index.d.ts +3 -0
  63. package/dist/esm/NavBar/index.d.ts.map +1 -0
  64. package/dist/esm/NavBar/index.js +3 -0
  65. package/dist/esm/NavBar/index.js.map +1 -0
  66. package/dist/esm/SceneElementView.d.ts +10 -0
  67. package/dist/esm/SceneElementView.d.ts.map +1 -0
  68. package/dist/esm/SceneElementView.js +19 -0
  69. package/dist/esm/SceneElementView.js.map +1 -0
  70. package/dist/esm/SceneElementView.stories.d.ts +15 -0
  71. package/dist/esm/SceneElementView.stories.d.ts.map +1 -0
  72. package/dist/esm/SceneElementView.stories.js +54 -0
  73. package/dist/esm/SceneElementView.stories.js.map +1 -0
  74. package/dist/esm/core/CoreButton.d.ts +3 -0
  75. package/dist/esm/core/CoreButton.d.ts.map +1 -0
  76. package/dist/esm/core/CoreButton.js +20 -0
  77. package/dist/esm/core/CoreButton.js.map +1 -0
  78. package/dist/esm/core/CoreCard.d.ts +3 -0
  79. package/dist/esm/core/CoreCard.d.ts.map +1 -0
  80. package/dist/esm/core/CoreCard.js +20 -0
  81. package/dist/esm/core/CoreCard.js.map +1 -0
  82. package/dist/esm/core/CoreText.d.ts +3 -0
  83. package/dist/esm/core/CoreText.d.ts.map +1 -0
  84. package/dist/esm/core/CoreText.js +17 -0
  85. package/dist/esm/core/CoreText.js.map +1 -0
  86. package/dist/esm/core/coreComponents.d.ts +3 -0
  87. package/dist/esm/core/coreComponents.d.ts.map +1 -0
  88. package/dist/esm/core/coreComponents.js +18 -0
  89. package/dist/esm/core/coreComponents.js.map +1 -0
  90. package/dist/esm/core/corePackage.d.ts +5 -0
  91. package/dist/esm/core/corePackage.d.ts.map +1 -0
  92. package/dist/esm/core/corePackage.js +38 -0
  93. package/dist/esm/core/corePackage.js.map +1 -0
  94. package/dist/esm/core/index.d.ts +6 -0
  95. package/dist/esm/core/index.d.ts.map +1 -0
  96. package/dist/esm/core/index.js +6 -0
  97. package/dist/esm/core/index.js.map +1 -0
  98. package/dist/esm/for_SceneElementView/when_rendering_a_tree.d.ts +2 -0
  99. package/dist/esm/for_SceneElementView/when_rendering_a_tree.d.ts.map +1 -0
  100. package/dist/esm/for_SceneElementView/when_rendering_a_tree.js +44 -0
  101. package/dist/esm/for_SceneElementView/when_rendering_a_tree.js.map +1 -0
  102. package/dist/esm/for_applyThemeTokens/when_switching_themes.d.ts +2 -0
  103. package/dist/esm/for_applyThemeTokens/when_switching_themes.d.ts.map +1 -0
  104. package/dist/esm/for_applyThemeTokens/when_switching_themes.js +59 -0
  105. package/dist/esm/for_applyThemeTokens/when_switching_themes.js.map +1 -0
  106. package/dist/esm/for_themeTokens/when_converting_a_token_name.d.ts +2 -0
  107. package/dist/esm/for_themeTokens/when_converting_a_token_name.d.ts.map +1 -0
  108. package/dist/esm/for_themeTokens/when_converting_a_token_name.js +16 -0
  109. package/dist/esm/for_themeTokens/when_converting_a_token_name.js.map +1 -0
  110. package/dist/esm/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.d.ts +2 -0
  111. package/dist/esm/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.d.ts.map +1 -0
  112. package/dist/esm/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.js +59 -0
  113. package/dist/esm/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.js.map +1 -0
  114. package/dist/esm/for_validatePackageBundle/when_the_bundle_matches_its_manifest.d.ts +2 -0
  115. package/dist/esm/for_validatePackageBundle/when_the_bundle_matches_its_manifest.d.ts.map +1 -0
  116. package/dist/esm/for_validatePackageBundle/when_the_bundle_matches_its_manifest.js +8 -0
  117. package/dist/esm/for_validatePackageBundle/when_the_bundle_matches_its_manifest.js.map +1 -0
  118. package/dist/esm/index.d.ts +7 -0
  119. package/dist/esm/index.d.ts.map +1 -0
  120. package/dist/esm/index.js +14 -0
  121. package/dist/esm/index.js.map +1 -0
  122. package/dist/esm/package.json +3 -0
  123. package/dist/esm/packages/ScenePackageBundle.d.ts +15 -0
  124. package/dist/esm/packages/ScenePackageBundle.d.ts.map +1 -0
  125. package/dist/esm/packages/ScenePackageBundle.js +72 -0
  126. package/dist/esm/packages/ScenePackageBundle.js.map +1 -0
  127. package/dist/esm/packages/index.d.ts +2 -0
  128. package/dist/esm/packages/index.d.ts.map +1 -0
  129. package/dist/esm/packages/index.js +2 -0
  130. package/dist/esm/packages/index.js.map +1 -0
  131. package/dist/esm/renderer/ComponentRegistry.d.ts +8 -0
  132. package/dist/esm/renderer/ComponentRegistry.d.ts.map +1 -0
  133. package/dist/esm/renderer/ComponentRegistry.js +2 -0
  134. package/dist/esm/renderer/ComponentRegistry.js.map +1 -0
  135. package/dist/esm/renderer/UnresolvedComponent.d.ts +3 -0
  136. package/dist/esm/renderer/UnresolvedComponent.d.ts.map +1 -0
  137. package/dist/esm/renderer/UnresolvedComponent.js +26 -0
  138. package/dist/esm/renderer/UnresolvedComponent.js.map +1 -0
  139. package/dist/esm/renderer/createReactRenderer.d.ts +5 -0
  140. package/dist/esm/renderer/createReactRenderer.d.ts.map +1 -0
  141. package/dist/esm/renderer/createReactRenderer.js +46 -0
  142. package/dist/esm/renderer/createReactRenderer.js.map +1 -0
  143. package/dist/esm/renderer/index.d.ts +4 -0
  144. package/dist/esm/renderer/index.d.ts.map +1 -0
  145. package/dist/esm/renderer/index.js +4 -0
  146. package/dist/esm/renderer/index.js.map +1 -0
  147. package/dist/esm/theme/SceneThemeProvider.d.ts +10 -0
  148. package/dist/esm/theme/SceneThemeProvider.d.ts.map +1 -0
  149. package/dist/esm/theme/SceneThemeProvider.js +41 -0
  150. package/dist/esm/theme/SceneThemeProvider.js.map +1 -0
  151. package/dist/esm/theme/index.d.ts +3 -0
  152. package/dist/esm/theme/index.d.ts.map +1 -0
  153. package/dist/esm/theme/index.js +3 -0
  154. package/dist/esm/theme/index.js.map +1 -0
  155. package/dist/esm/theme/themeTokens.d.ts +5 -0
  156. package/dist/esm/theme/themeTokens.d.ts.map +1 -0
  157. package/dist/esm/theme/themeTokens.js +48 -0
  158. package/dist/esm/theme/themeTokens.js.map +1 -0
  159. package/dist/esm/tsconfig.tsbuildinfo +1 -0
  160. package/for_SceneElementView/when_rendering_a_tree.tsx +53 -0
  161. package/for_applyThemeTokens/when_switching_themes.ts +74 -0
  162. package/for_themeTokens/when_converting_a_token_name.ts +22 -0
  163. package/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.ts +72 -0
  164. package/for_validatePackageBundle/when_the_bundle_matches_its_manifest.ts +12 -0
  165. package/index.ts +9 -0
  166. package/package.json +60 -0
  167. package/packages/ScenePackageBundle.ts +137 -0
  168. package/packages/index.ts +4 -0
  169. package/renderer/ComponentRegistry.ts +23 -0
  170. package/renderer/UnresolvedComponent.tsx +20 -0
  171. package/renderer/createReactRenderer.tsx +35 -0
  172. package/renderer/index.ts +6 -0
  173. package/theme/SceneThemeProvider.tsx +58 -0
  174. package/theme/index.ts +5 -0
  175. package/theme/themeTokens.ts +59 -0
@@ -0,0 +1,59 @@
1
+ import { JSDOM } from 'jsdom';
2
+ import { applyThemeTokens } from '../index';
3
+ const light = {
4
+ name: 'Daylight',
5
+ compatibleWith: ['core'],
6
+ tokens: { 'primary.color': '#2563eb', 'surface.background': '#ffffff' },
7
+ };
8
+ const dark = {
9
+ name: 'Midnight',
10
+ compatibleWith: ['core'],
11
+ isDark: true,
12
+ tokens: { 'primary.color': '#60a5fa' },
13
+ };
14
+ describe('when switching themes', () => {
15
+ const dom = new JSDOM('<div id="root"></div>');
16
+ const element = dom.window.document.getElementById('root');
17
+ applyThemeTokens(element, light);
18
+ const afterLight = {
19
+ primary: element.style.getPropertyValue('--scene-primary-color'),
20
+ surface: element.style.getPropertyValue('--scene-surface-background'),
21
+ theme: element.getAttribute('data-scene-theme'),
22
+ scheme: element.getAttribute('data-scene-color-scheme'),
23
+ };
24
+ applyThemeTokens(element, dark, light);
25
+ const afterDark = {
26
+ primary: element.style.getPropertyValue('--scene-primary-color'),
27
+ surface: element.style.getPropertyValue('--scene-surface-background'),
28
+ theme: element.getAttribute('data-scene-theme'),
29
+ scheme: element.getAttribute('data-scene-color-scheme'),
30
+ };
31
+ applyThemeTokens(element, undefined, dark);
32
+ const afterClearing = {
33
+ primary: element.style.getPropertyValue('--scene-primary-color'),
34
+ theme: element.getAttribute('data-scene-theme'),
35
+ };
36
+ it('should write the first theme tokens as custom properties', () => {
37
+ afterLight.primary.should.equal('#2563eb');
38
+ afterLight.surface.should.equal('#ffffff');
39
+ });
40
+ it('should mark the element with the first theme name and scheme', () => {
41
+ afterLight.theme.should.equal('Daylight');
42
+ afterLight.scheme.should.equal('light');
43
+ });
44
+ it('should overwrite a token the next theme also defines', () => {
45
+ afterDark.primary.should.equal('#60a5fa');
46
+ });
47
+ it('should remove a token the next theme does not define, rather than leaving it stale', () => {
48
+ afterDark.surface.should.equal('');
49
+ });
50
+ it('should mark the element as dark for a dark theme', () => {
51
+ afterDark.theme.should.equal('Midnight');
52
+ afterDark.scheme.should.equal('dark');
53
+ });
54
+ it('should clear every token and marker when the theme is removed', () => {
55
+ afterClearing.primary.should.equal('');
56
+ (afterClearing.theme === null).should.be.true;
57
+ });
58
+ });
59
+ //# sourceMappingURL=when_switching_themes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when_switching_themes.js","sourceRoot":"","sources":["../../../for_applyThemeTokens/when_switching_themes.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,KAAK,GAAU;IACjB,IAAI,EAAE,UAAU;IAChB,cAAc,EAAE,CAAC,MAAM,CAAC;IACxB,MAAM,EAAE,EAAE,eAAe,EAAE,SAAS,EAAE,oBAAoB,EAAE,SAAS,EAAE;CAC1E,CAAC;AAEF,MAAM,IAAI,GAAU;IAChB,IAAI,EAAE,UAAU;IAChB,cAAc,EAAE,CAAC,MAAM,CAAC;IACxB,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,EAAE,eAAe,EAAE,SAAS,EAAE;CACzC,CAAC;AAEF,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACnC,MAAM,GAA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CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;QACpE,UAAU,CAAC,KAAM,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC3C,UAAU,CAAC,MAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC5D,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oFAAoF,EAAE,GAAG,EAAE;QAC1F,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QACxD,SAAS,CAAC,KAAM,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1C,SAAS,CAAC,MAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;QACrE,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACvC,CAAC,aAAa,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;IAClD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=when_converting_a_token_name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when_converting_a_token_name.d.ts","sourceRoot":"","sources":["../../../for_themeTokens/when_converting_a_token_name.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { themeTokenProperty } from '../index';
2
+ describe('when converting a token name', () => {
3
+ it('should prefix a single-segment name', () => {
4
+ themeTokenProperty('primary').should.equal('--scene-primary');
5
+ });
6
+ it('should join dotted segments with dashes', () => {
7
+ themeTokenProperty('primary.color').should.equal('--scene-primary-color');
8
+ });
9
+ it('should split camelCase within a segment', () => {
10
+ themeTokenProperty('surface.borderColor').should.equal('--scene-surface-border-color');
11
+ });
12
+ it('should handle a segment with a digit boundary', () => {
13
+ themeTokenProperty('surface.level2Background').should.equal('--scene-surface-level2-background');
14
+ });
15
+ });
16
+ //# sourceMappingURL=when_converting_a_token_name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when_converting_a_token_name.js","sourceRoot":"","sources":["../../../for_themeTokens/when_converting_a_token_name.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC1C,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC3C,kBAAkB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QAC/C,kBAAkB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QAC/C,kBAAkB,CAAC,qBAAqB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACrD,kBAAkB,CAAC,0BAA0B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACrG,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=when_the_bundle_and_manifest_disagree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when_the_bundle_and_manifest_disagree.d.ts","sourceRoot":"","sources":["../../../for_validatePackageBundle/when_the_bundle_and_manifest_disagree.ts"],"names":[],"mappings":""}
@@ -0,0 +1,59 @@
1
+ import { PackageKind } from '@cratis/scene.model';
2
+ import { componentRegistryKey, validatePackageBundle } from '../index';
3
+ import { CoreText } from '../core';
4
+ function manifestFor(components, layouts = [], themes = [], screenTemplates = []) {
5
+ return {
6
+ name: 'Test',
7
+ version: '1.0.0',
8
+ kind: PackageKind.ComponentLibrary,
9
+ dependencies: [],
10
+ components,
11
+ layouts,
12
+ screenTemplates,
13
+ dialogTemplates: [],
14
+ themes,
15
+ };
16
+ }
17
+ describe('when the bundle and manifest disagree', () => {
18
+ const declaredButNotRegistered = validatePackageBundle({
19
+ manifest: manifestFor(['text', 'missing']),
20
+ components: { [componentRegistryKey('Test', 'text')]: CoreText },
21
+ });
22
+ const registeredButNotDeclared = validatePackageBundle({
23
+ manifest: manifestFor([]),
24
+ components: { [componentRegistryKey('Test', 'text')]: CoreText },
25
+ });
26
+ const layoutDeclaredButNotProvided = validatePackageBundle({
27
+ manifest: manifestFor([], ['AppShell']),
28
+ components: {},
29
+ });
30
+ const screenTemplateDeclaredButNotProvided = validatePackageBundle({
31
+ manifest: manifestFor([], [], [], ['ModuleWorkspace']),
32
+ components: {},
33
+ });
34
+ const themeDeclaredButNotProvided = validatePackageBundle({
35
+ manifest: manifestFor([], [], ['Midnight']),
36
+ components: {},
37
+ });
38
+ it('should report a component the manifest declares without an implementation', () => {
39
+ declaredButNotRegistered.should.have.lengthOf(1);
40
+ declaredButNotRegistered[0].should.contain("'missing'");
41
+ });
42
+ it('should report a component registered without being declared', () => {
43
+ registeredButNotDeclared.should.have.lengthOf(1);
44
+ registeredButNotDeclared[0].should.contain('Test:text');
45
+ });
46
+ it('should report a layout the manifest declares without a definition', () => {
47
+ layoutDeclaredButNotProvided.should.have.lengthOf(1);
48
+ layoutDeclaredButNotProvided[0].should.contain("'AppShell'");
49
+ });
50
+ it('should report a screen template the manifest declares without a definition', () => {
51
+ screenTemplateDeclaredButNotProvided.should.have.lengthOf(1);
52
+ screenTemplateDeclaredButNotProvided[0].should.contain("'ModuleWorkspace'");
53
+ });
54
+ it('should report a theme the manifest declares without a definition', () => {
55
+ themeDeclaredButNotProvided.should.have.lengthOf(1);
56
+ themeDeclaredButNotProvided[0].should.contain("'Midnight'");
57
+ });
58
+ });
59
+ //# sourceMappingURL=when_the_bundle_and_manifest_disagree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when_the_bundle_and_manifest_disagree.js","sourceRoot":"","sources":["../../../for_validatePackageBundle/when_the_bundle_and_manifest_disagree.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAgB,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAsB,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,SAAS,WAAW,CAAC,UAAoB,EAAE,OAAO,GAAa,EAAE,EAAE,MAAM,GAAa,EAAE,EAAE,eAAe,GAAa,EAAE;IACpH,OAAO;QACH,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,WAAW,CAAC,gBAAgB;QAClC,YAAY,EAAE,EAAE;QAChB,UAAU;QACV,OAAO;QACP,eAAe;QACf,eAAe,EAAE,EAAE;QACnB,MAAM;KACT,CAAC;AACN,CAAC;AAED,QAAQ,CAAC,uCAAuC,EAAE,GAAG,EAAE;IACnD,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;QACnD,QAAQ,EAAE,WAAW,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAC1C,UAAU,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM,EA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AAE,GAAG,EAAE;QACzE,4BAA4B,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACrD,4BAA4B,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4EAA4E,EAAE,GAAG,EAAE;QAClF,oCAAoC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC7D,oCAAoC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QACxE,2BAA2B,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACpD,2BAA2B,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=when_the_bundle_matches_its_manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when_the_bundle_matches_its_manifest.d.ts","sourceRoot":"","sources":["../../../for_validatePackageBundle/when_the_bundle_matches_its_manifest.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { corePackage, validatePackageBundle } from '../index';
2
+ describe('when the bundle matches its manifest', () => {
3
+ const problems = validatePackageBundle(corePackage);
4
+ it('should report no problems', () => {
5
+ problems.should.be.empty;
6
+ });
7
+ });
8
+ //# sourceMappingURL=when_the_bundle_matches_its_manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when_the_bundle_matches_its_manifest.js","sourceRoot":"","sources":["../../../for_validatePackageBundle/when_the_bundle_matches_its_manifest.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAE9D,QAAQ,CAAC,sCAAsC,EAAE,GAAG,EAAE;IAClD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAEpD,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;IAC7B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from './SceneElementView';
2
+ export * from './renderer';
3
+ export * from './core';
4
+ export * from './NavBar';
5
+ export * from './packages';
6
+ export * from './theme';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,14 @@
1
+ export { SceneElementView } from './SceneElementView.js';
2
+ export { UnresolvedComponent } from './renderer/UnresolvedComponent.js';
3
+ export { createReactRenderer } from './renderer/createReactRenderer.js';
4
+ export { CoreText } from './core/CoreText.js';
5
+ export { CoreButton } from './core/CoreButton.js';
6
+ export { CoreCard } from './core/CoreCard.js';
7
+ export { coreComponents } from './core/coreComponents.js';
8
+ export { corePackage, corePackageManifest } from './core/corePackage.js';
9
+ export { NavBar } from './NavBar/NavBar.js';
10
+ export { extractNavigationItem } from './NavBar/extractNavigationItem.js';
11
+ export { componentRegistryKey, mergePackageRegistries, validatePackageBundle } from './packages/ScenePackageBundle.js';
12
+ export { applyThemeTokens, themeTokenPrefix, themeTokenProperty } from './theme/themeTokens.js';
13
+ export { SceneThemeProvider, useSceneTheme } from './theme/SceneThemeProvider.js';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,15 @@
1
+ import { DialogTemplate, Layout, ScenePackage, Screen, ScreenTemplate, Theme } from '@cratis/scene.model';
2
+ import { ComponentRegistry } from '../renderer';
3
+ export interface ScenePackageBundle {
4
+ manifest: ScenePackage;
5
+ components: ComponentRegistry;
6
+ layouts?: Layout[];
7
+ screenTemplates?: ScreenTemplate[];
8
+ dialogTemplates?: DialogTemplate[];
9
+ screens?: Screen[];
10
+ themes?: Theme[];
11
+ }
12
+ export declare function componentRegistryKey(packageName: string, componentName: string): string;
13
+ export declare function validatePackageBundle(bundle: ScenePackageBundle): string[];
14
+ export declare function mergePackageRegistries(bundles: ScenePackageBundle[]): ComponentRegistry;
15
+ //# sourceMappingURL=ScenePackageBundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScenePackageBundle.d.ts","sourceRoot":"","sources":["../../../packages/ScenePackageBundle.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC1G,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;IAKnB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;CACpB;AAYD,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAEvF;AAUD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,EAAE,CA8C1E;AAQD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,iBAAiB,CAEvF"}
@@ -0,0 +1,72 @@
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 key a component is registered and looked up under: the package that provides it, then the bare name
5
+ * a screen refers to it by.
6
+ *
7
+ * A screen writes a bare name (`button`) or a package-qualified one (`PrimeReact.button`);
8
+ * `resolveComponentName` turns either into a `{ name, package }` pair, and this turns that pair into the
9
+ * registry key. Nothing should build this string by hand — the separator is an implementation detail of
10
+ * the registry, deliberately not the `.` used for qualification in a screen, so a package name containing
11
+ * dots stays unambiguous.
12
+ */ function componentRegistryKey(packageName, componentName) {
13
+ return `${packageName}:${componentName}`;
14
+ }
15
+ /**
16
+ * Checks that a bundle provides everything its manifest declares, and declares everything it provides.
17
+ *
18
+ * A manifest that promises a component the bundle does not register renders as `UnresolvedComponent` at
19
+ * runtime — a blank box, far from where the mistake was made. A component registered but not declared is
20
+ * invisible to `resolveComponentName`, so a screen can never name it. Both are silent failures, which is
21
+ * why every package's specs run this.
22
+ */ function validatePackageBundle(bundle) {
23
+ const problems = [];
24
+ const { manifest } = bundle;
25
+ for (const name of manifest.components){
26
+ if (!(componentRegistryKey(manifest.name, name) in bundle.components)) {
27
+ problems.push(`declares the component '${name}' but registers no implementation for it`);
28
+ }
29
+ }
30
+ const declared = new Set(manifest.components.map((name)=>componentRegistryKey(manifest.name, name)));
31
+ for (const key of Object.keys(bundle.components)){
32
+ if (!declared.has(key)) {
33
+ problems.push(`registers '${key}', which the manifest does not declare`);
34
+ }
35
+ }
36
+ const providedLayouts = new Set((bundle.layouts ?? []).map((layout)=>layout.name));
37
+ for (const name of manifest.layouts){
38
+ if (!providedLayouts.has(name)) {
39
+ problems.push(`declares the layout '${name}' but provides no definition for it`);
40
+ }
41
+ }
42
+ const providedScreenTemplates = new Set((bundle.screenTemplates ?? []).map((template)=>template.name));
43
+ for (const name of manifest.screenTemplates){
44
+ if (!providedScreenTemplates.has(name)) {
45
+ problems.push(`declares the screen template '${name}' but provides no definition for it`);
46
+ }
47
+ }
48
+ const providedDialogTemplates = new Set((bundle.dialogTemplates ?? []).map((template)=>template.name));
49
+ for (const name of manifest.dialogTemplates){
50
+ if (!providedDialogTemplates.has(name)) {
51
+ problems.push(`declares the dialog template '${name}' but provides no definition for it`);
52
+ }
53
+ }
54
+ const providedThemes = new Set((bundle.themes ?? []).map((theme)=>theme.name));
55
+ for (const name of manifest.themes){
56
+ if (!providedThemes.has(name)) {
57
+ problems.push(`declares the theme '${name}' but provides no definition for it`);
58
+ }
59
+ }
60
+ return problems;
61
+ }
62
+ /**
63
+ * Merges the component registries of several bundles into the single registry a renderer consumes.
64
+ *
65
+ * Keys carry their package name, so nothing collides and merge order does not matter — which package wins
66
+ * a *bare* name is decided earlier, by `resolveComponentName` walking the profile's priority order.
67
+ */ function mergePackageRegistries(bundles) {
68
+ return Object.assign({}, ...bundles.map((bundle)=>bundle.components));
69
+ }
70
+
71
+ export { componentRegistryKey, mergePackageRegistries, validatePackageBundle };
72
+ //# sourceMappingURL=ScenePackageBundle.js.map
@@ -0,0 +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 { DialogTemplate, Layout, ScenePackage, Screen, ScreenTemplate, Theme } from '@cratis/scene.model';\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 * The themes this package ships, if any.\n */\n themes?: Theme[];\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.\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 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"],"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","mergePackageRegistries","bundles","assign"],"mappings":"AAAA;AACA;AAyDA;;;;;;;;;AASC,IACM,SAASA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CAAE;AAChC,QAAA,IAAI,CAACD,cAAAA,CAAeT,GAAG,CAACT,IAAAA,CAAAA,EAAO;AAC3BF,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,oBAAoB,EAAEF,IAAAA,CAAK,mCAAmC,CAAC,CAAA;AAClF,QAAA;AACJ,IAAA;IAEA,OAAOF,QAAAA;AACX;AAEA;;;;;IAMO,SAASuB,sBAAAA,CAAuBC,OAA6B,EAAA;IAChE,OAAOf,MAAAA,CAAOgB,MAAM,CAAC,EAAC,EAAA,GAAMD,OAAAA,CAAQjB,GAAG,CAAC,CAACR,MAAAA,GAAWA,MAAAA,CAAOI,UAAU,CAAA,CAAA;AACzE;;;;"}
@@ -0,0 +1,2 @@
1
+ export * from './ScenePackageBundle';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/index.ts"],"names":[],"mappings":"AAGA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './ScenePackageBundle';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/index.ts"],"names":[],"mappings":"AAGA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+ import { ExternalComponent } from '@cratis/scene.model';
3
+ export interface RegisteredComponentProps {
4
+ element: ExternalComponent;
5
+ slots: Record<string, ReactNode[]>;
6
+ }
7
+ export type ComponentRegistry = Record<string, ComponentType<RegisteredComponentProps>>;
8
+ //# sourceMappingURL=ComponentRegistry.d.ts.map
@@ -0,0 +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;AAKxD,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;CACtC;AAUD,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ComponentRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentRegistry.js","sourceRoot":"","sources":["../../../renderer/ComponentRegistry.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { RegisteredComponentProps } from './ComponentRegistry';
2
+ export declare function UnresolvedComponent({ element }: RegisteredComponentProps): import("react").JSX.Element;
3
+ //# sourceMappingURL=UnresolvedComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnresolvedComponent.d.ts","sourceRoot":"","sources":["../../../renderer/UnresolvedComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAO/D,wBAAgB,mBAAmB,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BASxE"}
@@ -0,0 +1,26 @@
1
+ import { jsxs } from 'react/jsx-runtime';
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
+ * The fallback rendered for an {@link ExternalComponent} whose `componentName` is not in the active
7
+ * {@link ComponentRegistry} - a visibly broken placeholder, never a silent blank, since a missing
8
+ * component is a real configuration gap the renderer should surface, not hide.
9
+ */ function UnresolvedComponent({ element }) {
10
+ return /*#__PURE__*/ jsxs("div", {
11
+ "data-scene-unresolved-component": element.componentName,
12
+ style: {
13
+ border: '1px dashed red',
14
+ color: 'red',
15
+ padding: '0.25rem 0.5rem',
16
+ fontFamily: 'monospace'
17
+ },
18
+ children: [
19
+ "Unresolved component: ",
20
+ element.componentName
21
+ ]
22
+ });
23
+ }
24
+
25
+ export { UnresolvedComponent };
26
+ //# sourceMappingURL=UnresolvedComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnresolvedComponent.js","sources":["../../../renderer/UnresolvedComponent.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 { RegisteredComponentProps } from './ComponentRegistry';\n\n/**\n * The fallback rendered for an {@link ExternalComponent} whose `componentName` is not in the active\n * {@link ComponentRegistry} - a visibly broken placeholder, never a silent blank, since a missing\n * component is a real configuration gap the renderer should surface, not hide.\n */\nexport function UnresolvedComponent({ element }: RegisteredComponentProps) {\n return (\n <div\n data-scene-unresolved-component={element.componentName}\n style={{ border: '1px dashed red', color: 'red', padding: '0.25rem 0.5rem', fontFamily: 'monospace' }}\n >\n Unresolved component: {element.componentName}\n </div>\n );\n}\n"],"names":["UnresolvedComponent","element","_jsxs","div","data-scene-unresolved-component","componentName","style","border","color","padding","fontFamily"],"mappings":";;AAAA;AACA;AAIA;;;;AAIC,IACM,SAASA,mBAAAA,CAAoB,EAAEC,OAAO,EAA4B,EAAA;AACrE,IAAA,qBACIC,IAAA,CAACC,KAAAA,EAAAA;AACGC,QAAAA,iCAAAA,EAAiCH,QAAQI,aAAa;QACtDC,KAAAA,EAAO;YAAEC,MAAAA,EAAQ,gBAAA;YAAkBC,KAAAA,EAAO,KAAA;YAAOC,OAAAA,EAAS,gBAAA;YAAkBC,UAAAA,EAAY;AAAY,SAAA;;AACvG,YAAA,wBAAA;AAC0BT,YAAAA,OAAAA,CAAQI;;;AAG3C;;;;"}
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+ import { Renderer } from '@cratis/scene.engine';
3
+ import { ComponentRegistry } from './ComponentRegistry';
4
+ export declare function createReactRenderer(registry: ComponentRegistry): Renderer<ReactNode>;
5
+ //# sourceMappingURL=createReactRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createReactRenderer.d.ts","sourceRoot":"","sources":["../../../renderer/createReactRenderer.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAiB,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AASxD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC,CAmBpF"}
@@ -0,0 +1,46 @@
1
+ import { createElement } from 'react';
2
+ import { UnresolvedComponent } from './UnresolvedComponent.js';
3
+
4
+ // Copyright (c) Cratis. All rights reserved.
5
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
6
+ /**
7
+ * Creates a {@link Renderer} that turns a Scene element tree into React elements. `Panel`, `ItemsControl`
8
+ * and `ContentControl` render as plain wrapping `div`s here - arranging them according to a layout's
9
+ * `flow`/`freeform` arrangement is Scene#4's job, layered on top of this renderer rather than folded
10
+ * into it.
11
+ */ function createReactRenderer(registry) {
12
+ return {
13
+ renderContentControl (element, content) {
14
+ return /*#__PURE__*/ createElement('div', {
15
+ key: element.id,
16
+ 'data-scene-id': element.id,
17
+ 'data-scene-kind': 'ContentControl'
18
+ }, content);
19
+ },
20
+ renderItemsControl (element, items) {
21
+ return /*#__PURE__*/ createElement('div', {
22
+ key: element.id,
23
+ 'data-scene-id': element.id,
24
+ 'data-scene-kind': 'ItemsControl'
25
+ }, items);
26
+ },
27
+ renderExternalComponent (element, slots) {
28
+ const Component = registry[element.componentName] ?? UnresolvedComponent;
29
+ return /*#__PURE__*/ createElement(Component, {
30
+ key: element.id,
31
+ element,
32
+ slots
33
+ });
34
+ },
35
+ renderPanel (element, children) {
36
+ return /*#__PURE__*/ createElement('div', {
37
+ key: element.id,
38
+ 'data-scene-id': element.id,
39
+ 'data-scene-kind': 'Panel'
40
+ }, children);
41
+ }
42
+ };
43
+ }
44
+
45
+ export { createReactRenderer };
46
+ //# sourceMappingURL=createReactRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createReactRenderer.js","sources":["../../../renderer/createReactRenderer.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, createElement } from 'react';\nimport { Renderer } from '@cratis/scene.engine';\nimport { ContentControl, ExternalComponent, ItemsControl, Panel } from '@cratis/scene.model';\nimport { ComponentRegistry } from './ComponentRegistry';\nimport { UnresolvedComponent } from './UnresolvedComponent';\n\n/**\n * Creates a {@link Renderer} that turns a Scene element tree into React elements. `Panel`, `ItemsControl`\n * and `ContentControl` render as plain wrapping `div`s here - arranging them according to a layout's\n * `flow`/`freeform` arrangement is Scene#4's job, layered on top of this renderer rather than folded\n * into it.\n */\nexport function createReactRenderer(registry: ComponentRegistry): Renderer<ReactNode> {\n return {\n renderContentControl(element: ContentControl, content: ReactNode): ReactNode {\n return createElement('div', { key: element.id, 'data-scene-id': element.id, 'data-scene-kind': 'ContentControl' }, content);\n },\n\n renderItemsControl(element: ItemsControl, items: ReactNode[]): ReactNode {\n return createElement('div', { key: element.id, 'data-scene-id': element.id, 'data-scene-kind': 'ItemsControl' }, items);\n },\n\n renderExternalComponent(element: ExternalComponent, slots: Record<string, ReactNode[]>): ReactNode {\n const Component = registry[element.componentName] ?? UnresolvedComponent;\n return createElement(Component, { key: element.id, element, slots });\n },\n\n renderPanel(element: Panel, children: ReactNode[]): ReactNode {\n return createElement('div', { key: element.id, 'data-scene-id': element.id, 'data-scene-kind': 'Panel' }, children);\n },\n };\n}\n"],"names":["createReactRenderer","registry","renderContentControl","element","content","createElement","key","id","renderItemsControl","items","renderExternalComponent","slots","Component","componentName","UnresolvedComponent","renderPanel","children"],"mappings":";;;AAAA;AACA;AAQA;;;;;IAMO,SAASA,mBAAAA,CAAoBC,QAA2B,EAAA;IAC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index.d.ts","sourceRoot":"","sources":["../../../renderer/index.ts"],"names":[],"mappings":"AAGA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './ComponentRegistry';
2
+ export * from './UnresolvedComponent';
3
+ export * from './createReactRenderer';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../renderer/index.ts"],"names":[],"mappings":"AAGA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ import { Theme } from '@cratis/scene.model';
3
+ export declare function useSceneTheme(): Theme | undefined;
4
+ export interface SceneThemePropsBase {
5
+ theme?: Theme;
6
+ children?: ReactNode;
7
+ className?: string;
8
+ }
9
+ export declare function SceneThemeProvider({ theme, children, className }: SceneThemePropsBase): import("react").JSX.Element;
10
+ //# sourceMappingURL=SceneThemeProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SceneThemeProvider.d.ts","sourceRoot":"","sources":["../../../theme/SceneThemeProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAsD,MAAM,OAAO,CAAC;AACtF,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAS5C,wBAAgB,aAAa,IAAI,KAAK,GAAG,SAAS,CAEjD;AAED,MAAM,WAAW,mBAAmB;IAIhC,KAAK,CAAC,EAAE,KAAK,CAAC;IAKd,QAAQ,CAAC,EAAE,SAAS,CAAC;IAKrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAUD,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,mBAAmB,+BAerF"}
@@ -0,0 +1,41 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useRef, useLayoutEffect, useContext, createContext } from 'react';
3
+ import { applyThemeTokens } from './themeTokens.js';
4
+
5
+ const SceneThemeContext = /*#__PURE__*/ createContext(undefined);
6
+ /**
7
+ * The theme currently applied by the nearest {@link SceneThemeProvider}, for a package component that has
8
+ * to make a decision a token cannot express - picking a light or dark logo asset, say.
9
+ */ function useSceneTheme() {
10
+ return useContext(SceneThemeContext);
11
+ }
12
+ /**
13
+ * Applies a {@link Theme}'s tokens to a wrapping element and makes the theme available to everything
14
+ * inside it.
15
+ *
16
+ * Theme switching is live re-resolution: the tokens are written onto the same element rather than
17
+ * swapping a stylesheet, so a preview changes theme without a flash and without losing any state below
18
+ * it. That is what lets Studio's gallery switch themes as fast as you can click.
19
+ */ function SceneThemeProvider({ theme, children, className }) {
20
+ const elementRef = useRef(null);
21
+ const previousRef = useRef(undefined);
22
+ useLayoutEffect(()=>{
23
+ if (!elementRef.current) return;
24
+ applyThemeTokens(elementRef.current, theme, previousRef.current);
25
+ previousRef.current = theme;
26
+ }, [
27
+ theme
28
+ ]);
29
+ return /*#__PURE__*/ jsx("div", {
30
+ ref: elementRef,
31
+ className: className,
32
+ "data-scene-theme-root": "",
33
+ children: /*#__PURE__*/ jsx(SceneThemeContext.Provider, {
34
+ value: theme,
35
+ children: children
36
+ })
37
+ });
38
+ }
39
+
40
+ export { SceneThemeProvider, useSceneTheme };
41
+ //# sourceMappingURL=SceneThemeProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SceneThemeProvider.js","sources":["../../../theme/SceneThemeProvider.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, useContext, useLayoutEffect, useRef } from 'react';\nimport { Theme } from '@cratis/scene.model';\nimport { applyThemeTokens } from './themeTokens';\n\nconst SceneThemeContext = createContext<Theme | undefined>(undefined);\n\n/**\n * The theme currently applied by the nearest {@link SceneThemeProvider}, for a package component that has\n * to make a decision a token cannot express - picking a light or dark logo asset, say.\n */\nexport function useSceneTheme(): Theme | undefined {\n return useContext(SceneThemeContext);\n}\n\nexport interface SceneThemePropsBase {\n /**\n * The theme to apply. Changing it re-resolves in place - no reload, no remount of the subtree.\n */\n theme?: Theme;\n\n /**\n * The content the theme applies to.\n */\n children?: ReactNode;\n\n /**\n * A class name for the element the tokens land on.\n */\n className?: string;\n}\n\n/**\n * Applies a {@link Theme}'s tokens to a wrapping element and makes the theme available to everything\n * inside it.\n *\n * Theme switching is live re-resolution: the tokens are written onto the same element rather than\n * swapping a stylesheet, so a preview changes theme without a flash and without losing any state below\n * it. That is what lets Studio's gallery switch themes as fast as you can click.\n */\nexport function SceneThemeProvider({ theme, children, className }: SceneThemePropsBase) {\n const elementRef = useRef<HTMLDivElement>(null);\n const previousRef = useRef<Theme | undefined>(undefined);\n\n useLayoutEffect(() => {\n if (!elementRef.current) return;\n applyThemeTokens(elementRef.current, theme, previousRef.current);\n previousRef.current = theme;\n }, [theme]);\n\n return (\n <div ref={elementRef} className={className} data-scene-theme-root=''>\n <SceneThemeContext.Provider value={theme}>{children}</SceneThemeContext.Provider>\n </div>\n );\n}\n"],"names":["SceneThemeContext","createContext","undefined","useSceneTheme","useContext","SceneThemeProvider","theme","children","className","elementRef","useRef","previousRef","useLayoutEffect","current","applyThemeTokens","_jsx","div","ref","data-scene-theme-root","Provider","value"],"mappings":";;;;AAOA,MAAMA,kCAAoBC,aAAAA,CAAiCC,SAAAA,CAAAA;AAE3D;;;AAGC,IACM,SAASC,aAAAA,GAAAA;AACZ,IAAA,OAAOC,UAAAA,CAAWJ,iBAAAA,CAAAA;AACtB;AAmBA;;;;;;;IAQO,SAASK,kBAAAA,CAAmB,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,SAAS,EAAuB,EAAA;AAClF,IAAA,MAAMC,aAAaC,MAAAA,CAAuB,IAAA,CAAA;AAC1C,IAAA,MAAMC,cAAcD,MAAAA,CAA0BR,SAAAA,CAAAA;IAE9CU,eAAAA,CAAgB,IAAA;QACZ,IAAI,CAACH,UAAAA,CAAWI,OAAO,EAAE;AACzBC,QAAAA,gBAAAA,CAAiBL,UAAAA,CAAWI,OAAO,EAAEP,KAAAA,EAAOK,YAAYE,OAAO,CAAA;AAC/DF,QAAAA,WAAAA,CAAYE,OAAO,GAAGP,KAAAA;IAC1B,CAAA,EAAG;AAACA,QAAAA;AAAM,KAAA,CAAA;AAEV,IAAA,qBACIS,GAAA,CAACC,KAAAA,EAAAA;QAAIC,GAAAA,EAAKR,UAAAA;QAAYD,SAAAA,EAAWA,SAAAA;QAAWU,uBAAAA,EAAsB,EAAA;gCAC9DH,GAAA,CAACf,kBAAkBmB,QAAQ,EAAA;YAACC,KAAAA,EAAOd,KAAAA;AAAQC,YAAAA,QAAAA,EAAAA;;;AAGvD;;;;"}
@@ -0,0 +1,3 @@
1
+ export * from './themeTokens';
2
+ export * from './SceneThemeProvider';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../theme/index.ts"],"names":[],"mappings":"AAGA,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './themeTokens';
2
+ export * from './SceneThemeProvider';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../theme/index.ts"],"names":[],"mappings":"AAGA,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Theme } from '@cratis/scene.model';
2
+ export declare const themeTokenPrefix = "--scene";
3
+ export declare function themeTokenProperty(token: string): string;
4
+ export declare function applyThemeTokens(element: HTMLElement, theme: Theme | undefined, previous?: Theme): void;
5
+ //# sourceMappingURL=themeTokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"themeTokens.d.ts","sourceRoot":"","sources":["../../../theme/themeTokens.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAQ5C,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAS1C,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMxD;AAaD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,KAAK,GAAG,IAAI,CAmBvG"}