@cratis/scene.blueprint.default 4.33.0 → 4.34.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 (134) hide show
  1. package/dist/cjs/index.js +53 -4
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/preview-host/ApplicationDocument.js +17 -0
  4. package/dist/cjs/preview-host/ApplicationDocument.js.map +1 -0
  5. package/dist/cjs/preview-host/ApplicationHost.js +113 -0
  6. package/dist/cjs/preview-host/ApplicationHost.js.map +1 -0
  7. package/dist/cjs/preview-host/FlowArrangementView.js +75 -0
  8. package/dist/cjs/preview-host/FlowArrangementView.js.map +1 -0
  9. package/dist/cjs/preview-host/PreviewProblem.js +32 -0
  10. package/dist/cjs/preview-host/PreviewProblem.js.map +1 -0
  11. package/dist/cjs/preview-host/PreviewProblemsView.js +51 -0
  12. package/dist/cjs/preview-host/PreviewProblemsView.js.map +1 -0
  13. package/dist/cjs/preview-host/PreviewSliceFragment.js +55 -0
  14. package/dist/cjs/preview-host/PreviewSliceFragment.js.map +1 -0
  15. package/dist/cjs/preview-host/PreviewTarget.js +17 -0
  16. package/dist/cjs/preview-host/PreviewTarget.js.map +1 -0
  17. package/dist/cjs/preview-host/PreviewTemplate.js +49 -0
  18. package/dist/cjs/preview-host/PreviewTemplate.js.map +1 -0
  19. package/dist/cjs/preview-host/PreviewToast.js +45 -0
  20. package/dist/cjs/preview-host/PreviewToast.js.map +1 -0
  21. package/dist/cjs/preview-host/ScenePreviewHost.js +290 -0
  22. package/dist/cjs/preview-host/ScenePreviewHost.js.map +1 -0
  23. package/dist/cjs/preview-host/composeApplication.js +249 -0
  24. package/dist/cjs/preview-host/composeApplication.js.map +1 -0
  25. package/dist/cjs/preview-host/defaultApplicationChrome.js +43 -0
  26. package/dist/cjs/preview-host/defaultApplicationChrome.js.map +1 -0
  27. package/dist/cjs/preview-host/diagnosePreview.js +100 -0
  28. package/dist/cjs/preview-host/diagnosePreview.js.map +1 -0
  29. package/dist/cjs/preview-host/previewProfile.js +53 -0
  30. package/dist/cjs/preview-host/previewProfile.js.map +1 -0
  31. package/dist/cjs/preview-host/previewSampleData.js +116 -0
  32. package/dist/cjs/preview-host/previewSampleData.js.map +1 -0
  33. package/dist/cjs/preview-host/resolvePreviewPlan.js +126 -0
  34. package/dist/cjs/preview-host/resolvePreviewPlan.js.map +1 -0
  35. package/dist/cjs/preview-host/useSizeClass.js +23 -0
  36. package/dist/cjs/preview-host/useSizeClass.js.map +1 -0
  37. package/dist/esm/index.d.ts +1 -0
  38. package/dist/esm/index.d.ts.map +1 -1
  39. package/dist/esm/index.js +17 -0
  40. package/dist/esm/index.js.map +1 -1
  41. package/dist/esm/preview-host/ApplicationDocument.d.ts +7 -0
  42. package/dist/esm/preview-host/ApplicationDocument.d.ts.map +1 -0
  43. package/dist/esm/preview-host/ApplicationDocument.js +15 -0
  44. package/dist/esm/preview-host/ApplicationDocument.js.map +1 -0
  45. package/dist/esm/preview-host/ApplicationHost.d.ts +21 -0
  46. package/dist/esm/preview-host/ApplicationHost.d.ts.map +1 -0
  47. package/dist/esm/preview-host/ApplicationHost.js +111 -0
  48. package/dist/esm/preview-host/ApplicationHost.js.map +1 -0
  49. package/dist/esm/preview-host/FlowArrangementView.d.ts +7 -0
  50. package/dist/esm/preview-host/FlowArrangementView.d.ts.map +1 -0
  51. package/dist/esm/preview-host/FlowArrangementView.js +73 -0
  52. package/dist/esm/preview-host/FlowArrangementView.js.map +1 -0
  53. package/dist/esm/preview-host/PreviewProblem.d.ts +26 -0
  54. package/dist/esm/preview-host/PreviewProblem.d.ts.map +1 -0
  55. package/dist/esm/preview-host/PreviewProblem.js +28 -0
  56. package/dist/esm/preview-host/PreviewProblem.js.map +1 -0
  57. package/dist/esm/preview-host/PreviewProblemsView.d.ts +7 -0
  58. package/dist/esm/preview-host/PreviewProblemsView.d.ts.map +1 -0
  59. package/dist/esm/preview-host/PreviewProblemsView.js +49 -0
  60. package/dist/esm/preview-host/PreviewProblemsView.js.map +1 -0
  61. package/dist/esm/preview-host/PreviewSliceFragment.d.ts +3 -0
  62. package/dist/esm/preview-host/PreviewSliceFragment.d.ts.map +1 -0
  63. package/dist/esm/preview-host/PreviewSliceFragment.js +53 -0
  64. package/dist/esm/preview-host/PreviewSliceFragment.js.map +1 -0
  65. package/dist/esm/preview-host/PreviewTarget.d.ts +10 -0
  66. package/dist/esm/preview-host/PreviewTarget.d.ts.map +1 -0
  67. package/dist/esm/preview-host/PreviewTarget.js +15 -0
  68. package/dist/esm/preview-host/PreviewTarget.js.map +1 -0
  69. package/dist/esm/preview-host/PreviewTemplate.d.ts +5 -0
  70. package/dist/esm/preview-host/PreviewTemplate.d.ts.map +1 -0
  71. package/dist/esm/preview-host/PreviewTemplate.js +45 -0
  72. package/dist/esm/preview-host/PreviewTemplate.js.map +1 -0
  73. package/dist/esm/preview-host/PreviewToast.d.ts +10 -0
  74. package/dist/esm/preview-host/PreviewToast.d.ts.map +1 -0
  75. package/dist/esm/preview-host/PreviewToast.js +43 -0
  76. package/dist/esm/preview-host/PreviewToast.js.map +1 -0
  77. package/dist/esm/preview-host/ScenePreviewHost.d.ts +32 -0
  78. package/dist/esm/preview-host/ScenePreviewHost.d.ts.map +1 -0
  79. package/dist/esm/preview-host/ScenePreviewHost.js +288 -0
  80. package/dist/esm/preview-host/ScenePreviewHost.js.map +1 -0
  81. package/dist/esm/preview-host/composeApplication.d.ts +34 -0
  82. package/dist/esm/preview-host/composeApplication.d.ts.map +1 -0
  83. package/dist/esm/preview-host/composeApplication.js +239 -0
  84. package/dist/esm/preview-host/composeApplication.js.map +1 -0
  85. package/dist/esm/preview-host/defaultApplicationChrome.d.ts +4 -0
  86. package/dist/esm/preview-host/defaultApplicationChrome.d.ts.map +1 -0
  87. package/dist/esm/preview-host/defaultApplicationChrome.js +41 -0
  88. package/dist/esm/preview-host/defaultApplicationChrome.js.map +1 -0
  89. package/dist/esm/preview-host/diagnosePreview.d.ts +22 -0
  90. package/dist/esm/preview-host/diagnosePreview.d.ts.map +1 -0
  91. package/dist/esm/preview-host/diagnosePreview.js +98 -0
  92. package/dist/esm/preview-host/diagnosePreview.js.map +1 -0
  93. package/dist/esm/preview-host/index.d.ts +18 -0
  94. package/dist/esm/preview-host/index.d.ts.map +1 -0
  95. package/dist/esm/preview-host/index.js +18 -0
  96. package/dist/esm/preview-host/index.js.map +1 -0
  97. package/dist/esm/preview-host/previewProfile.d.ts +6 -0
  98. package/dist/esm/preview-host/previewProfile.d.ts.map +1 -0
  99. package/dist/esm/preview-host/previewProfile.js +49 -0
  100. package/dist/esm/preview-host/previewProfile.js.map +1 -0
  101. package/dist/esm/preview-host/previewSampleData.d.ts +22 -0
  102. package/dist/esm/preview-host/previewSampleData.d.ts.map +1 -0
  103. package/dist/esm/preview-host/previewSampleData.js +113 -0
  104. package/dist/esm/preview-host/previewSampleData.js.map +1 -0
  105. package/dist/esm/preview-host/resolvePreviewPlan.d.ts +18 -0
  106. package/dist/esm/preview-host/resolvePreviewPlan.d.ts.map +1 -0
  107. package/dist/esm/preview-host/resolvePreviewPlan.js +124 -0
  108. package/dist/esm/preview-host/resolvePreviewPlan.js.map +1 -0
  109. package/dist/esm/preview-host/useSizeClass.d.ts +3 -0
  110. package/dist/esm/preview-host/useSizeClass.d.ts.map +1 -0
  111. package/dist/esm/preview-host/useSizeClass.js +21 -0
  112. package/dist/esm/preview-host/useSizeClass.js.map +1 -0
  113. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  114. package/index.ts +1 -0
  115. package/package.json +8 -8
  116. package/preview-host/ApplicationDocument.ts +31 -0
  117. package/preview-host/ApplicationHost.tsx +114 -0
  118. package/preview-host/FlowArrangementView.tsx +59 -0
  119. package/preview-host/PreviewProblem.ts +68 -0
  120. package/preview-host/PreviewProblemsView.tsx +31 -0
  121. package/preview-host/PreviewSliceFragment.ts +43 -0
  122. package/preview-host/PreviewTarget.ts +19 -0
  123. package/preview-host/PreviewTemplate.tsx +45 -0
  124. package/preview-host/PreviewToast.tsx +32 -0
  125. package/preview-host/ScenePreviewHost.tsx +250 -0
  126. package/preview-host/composeApplication.ts +273 -0
  127. package/preview-host/defaultApplicationChrome.ts +33 -0
  128. package/preview-host/diagnosePreview.ts +132 -0
  129. package/preview-host/index.ts +20 -0
  130. package/preview-host/previewProfile.ts +47 -0
  131. package/preview-host/previewSampleData.ts +144 -0
  132. package/preview-host/resolvePreviewPlan.ts +100 -0
  133. package/preview-host/useSizeClass.ts +23 -0
  134. package/shell/layout.css +22 -0
package/dist/cjs/index.js CHANGED
@@ -31,7 +31,7 @@ var dialogTemplates = require('./gallery/dialogTemplates.js');
31
31
  var screens = require('./gallery/screens.js');
32
32
  var dependencyComponentNames = require('./gallery/dependencyComponentNames.js');
33
33
  var componentNames = require('./gallery/componentNames.js');
34
- var previewProfile = require('./gallery/previewProfile.js');
34
+ var previewProfile$1 = require('./gallery/previewProfile.js');
35
35
  var resolveElementNames = require('./gallery/resolveElementNames.js');
36
36
  var GalleryScreenPreview = require('./gallery/GalleryScreenPreview.js');
37
37
  var TemplatePreviewState = require('./gallery/TemplatePreviewState.js');
@@ -86,6 +86,23 @@ var LayoutThemeProvider = require('./themes/LayoutThemeProvider.js');
86
86
  var defaultBlueprintComponents = require('./defaultBlueprintComponents.js');
87
87
  var defaultBlueprint = require('./defaultBlueprint.js');
88
88
  var templateProvenance = require('./templateProvenance.js');
89
+ var PreviewTarget = require('./preview-host/PreviewTarget.js');
90
+ var PreviewProblem = require('./preview-host/PreviewProblem.js');
91
+ var ApplicationDocument = require('./preview-host/ApplicationDocument.js');
92
+ var previewProfile = require('./preview-host/previewProfile.js');
93
+ var defaultApplicationChrome = require('./preview-host/defaultApplicationChrome.js');
94
+ var FlowArrangementView = require('./preview-host/FlowArrangementView.js');
95
+ var useSizeClass = require('./preview-host/useSizeClass.js');
96
+ var PreviewTemplate = require('./preview-host/PreviewTemplate.js');
97
+ var composeApplication = require('./preview-host/composeApplication.js');
98
+ var resolvePreviewPlan = require('./preview-host/resolvePreviewPlan.js');
99
+ var diagnosePreview = require('./preview-host/diagnosePreview.js');
100
+ var previewSampleData = require('./preview-host/previewSampleData.js');
101
+ var PreviewSliceFragment = require('./preview-host/PreviewSliceFragment.js');
102
+ var PreviewToast = require('./preview-host/PreviewToast.js');
103
+ var PreviewProblemsView = require('./preview-host/PreviewProblemsView.js');
104
+ var ApplicationHost = require('./preview-host/ApplicationHost.js');
105
+ var ScenePreviewHost = require('./preview-host/ScenePreviewHost.js');
89
106
 
90
107
 
91
108
 
@@ -205,9 +222,9 @@ exports.cratisComponentsNames = dependencyComponentNames.cratisComponentsNames;
205
222
  exports.primeReactComponentNames = dependencyComponentNames.primeReactComponentNames;
206
223
  exports.componentNamesIn = componentNames.componentNamesIn;
207
224
  exports.distinctComponentNames = componentNames.distinctComponentNames;
208
- exports.galleryComponentCatalog = previewProfile.galleryComponentCatalog;
209
- exports.galleryPreviewProfile = previewProfile.galleryPreviewProfile;
210
- exports.galleryProfile = previewProfile.galleryProfile;
225
+ exports.galleryComponentCatalog = previewProfile$1.galleryComponentCatalog;
226
+ exports.galleryPreviewProfile = previewProfile$1.galleryPreviewProfile;
227
+ exports.galleryProfile = previewProfile$1.galleryProfile;
211
228
  exports.resolveElementComponentNames = resolveElementNames.resolveElementComponentNames;
212
229
  exports.GalleryScreenPreview = GalleryScreenPreview.GalleryScreenPreview;
213
230
  exports.galleryPreviewRegistry = GalleryScreenPreview.galleryPreviewRegistry;
@@ -317,4 +334,36 @@ exports.defaultBlueprint = defaultBlueprint.defaultBlueprint;
317
334
  exports.defaultBlueprintManifest = defaultBlueprint.defaultBlueprintManifest;
318
335
  exports.defaultBlueprintTemplateProvenance = templateProvenance.defaultBlueprintTemplateProvenance;
319
336
  exports.sakaiCompositionProvenance = templateProvenance.sakaiCompositionProvenance;
337
+ exports.isSliceTarget = PreviewTarget.isSliceTarget;
338
+ exports.PreviewProblemCode = PreviewProblem.PreviewProblemCode;
339
+ exports.PreviewProblemSeverity = PreviewProblem.PreviewProblemSeverity;
340
+ exports.hasBlockingProblem = PreviewProblem.hasBlockingProblem;
341
+ exports.completeDocument = ApplicationDocument.completeDocument;
342
+ exports.blueprintPackageCatalog = previewProfile.blueprintPackageCatalog;
343
+ exports.previewProfile = previewProfile.previewProfile;
344
+ exports.requiredPackages = previewProfile.requiredPackages;
345
+ exports.defaultApplicationChrome = defaultApplicationChrome.defaultApplicationChrome;
346
+ exports.FlowArrangementView = FlowArrangementView.FlowArrangementView;
347
+ exports.useSizeClass = useSizeClass.useSizeClass;
348
+ exports.PreviewTemplate = PreviewTemplate.PreviewTemplate;
349
+ exports.previewComponents = PreviewTemplate.previewComponents;
350
+ exports.previewTemplateComponent = PreviewTemplate.previewTemplateComponent;
351
+ exports.collectDestinations = composeApplication.collectDestinations;
352
+ exports.composeApplicationScreen = composeApplication.composeApplicationScreen;
353
+ exports.composeDialog = composeApplication.composeDialog;
354
+ exports.composeOutletScreen = composeApplication.composeOutletScreen;
355
+ exports.findLayout = composeApplication.findLayout;
356
+ exports.screenContent = composeApplication.screenContent;
357
+ exports.templateChainOf = composeApplication.templateChainOf;
358
+ exports.templatePoolFor = composeApplication.templatePoolFor;
359
+ exports.templatesOf = composeApplication.templatesOf;
360
+ exports.resolvePreviewPlan = resolvePreviewPlan.resolvePreviewPlan;
361
+ exports.diagnosePreview = diagnosePreview.diagnosePreview;
362
+ exports.collectQueryNames = previewSampleData.collectQueryNames;
363
+ exports.createPreviewSampleData = previewSampleData.createPreviewSampleData;
364
+ exports.findSliceFragment = PreviewSliceFragment.findSliceFragment;
365
+ exports.PreviewToast = PreviewToast.PreviewToast;
366
+ exports.PreviewProblemsView = PreviewProblemsView.PreviewProblemsView;
367
+ exports.ApplicationHost = ApplicationHost.ApplicationHost;
368
+ exports.ScenePreviewHost = ScenePreviewHost.ScenePreviewHost;
320
369
  //# sourceMappingURL=index.js.map
@@ -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,17 @@
1
+ 'use strict';
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
+ /** The document with everything a template chain needs filled in. */ function completeDocument(application) {
6
+ return {
7
+ layouts: application.layouts,
8
+ screenTemplates: application.screenTemplates,
9
+ dialogTemplates: application.dialogTemplates ?? [],
10
+ screens: application.screens,
11
+ exposures: application.exposures ?? [],
12
+ instanceContributions: application.instanceContributions ?? []
13
+ };
14
+ }
15
+
16
+ exports.completeDocument = completeDocument;
17
+ //# sourceMappingURL=ApplicationDocument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApplicationDocument.js","sources":["../../../preview-host/ApplicationDocument.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 type { SceneDocument, Theme, UiProfile } from '@cratis/scene.model';\n\n/**\n * What an application is made of: the document a designer edits - layouts, templates, screens, and what a template exposes and\n * each instance contributes - and the profile and theme the application renders with. Stage assembles it from a Screenplay\n * model, Studio from the model in memory (unsaved edits included); the composition and the hosts take nothing else.\n */\nexport type ApplicationDocument =\n & Pick<SceneDocument, 'layouts' | 'screenTemplates' | 'screens'>\n & Partial<Pick<SceneDocument, 'dialogTemplates' | 'exposures' | 'instanceContributions'>>\n & {\n /** The profiles the application declares; the first for the web is the one rendered with. */\n uiProfiles?: UiProfile[];\n\n themes?: Theme[];\n };\n\n/** The document with everything a template chain needs filled in. */\nexport function completeDocument(application: ApplicationDocument): SceneDocument {\n return {\n layouts: application.layouts,\n screenTemplates: application.screenTemplates,\n dialogTemplates: application.dialogTemplates ?? [],\n screens: application.screens,\n exposures: application.exposures ?? [],\n instanceContributions: application.instanceContributions ?? [],\n };\n}\n"],"names":["completeDocument","application","layouts","screenTemplates","dialogTemplates","screens","exposures","instanceContributions"],"mappings":";;AAAA;AACA;AAmBA,sEACO,SAASA,gBAAAA,CAAiBC,WAAgC,EAAA;IAC7D,OAAO;AACHC,QAAAA,OAAAA,EAASD,YAAYC,OAAO;AAC5BC,QAAAA,eAAAA,EAAiBF,YAAYE,eAAe;QAC5CC,eAAAA,EAAiBH,WAAAA,CAAYG,eAAe,IAAI,EAAE;AAClDC,QAAAA,OAAAA,EAASJ,YAAYI,OAAO;QAC5BC,SAAAA,EAAWL,WAAAA,CAAYK,SAAS,IAAI,EAAE;QACtCC,qBAAAA,EAAuBN,WAAAA,CAAYM,qBAAqB,IAAI;AAChE,KAAA;AACJ;;"}
@@ -0,0 +1,113 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var react = require('react');
5
+ var scene_react = require('@cratis/scene.react');
6
+ var LayoutConfigProvider = require('../configuration/LayoutConfigProvider.js');
7
+ var PreviewTemplate = require('./PreviewTemplate.js');
8
+ var composeApplication = require('./composeApplication.js');
9
+
10
+ /**
11
+ * The application as both Stage and the preview host run it: the shell composed for the screen on the page
12
+ * (`composeApplicationScreen`), nested outlets holding the screens placed in them, the navigation model in scope for the shell's
13
+ * topbar and sidebar regions, every destination the document and the navigation lead to routed, and the dialog a toolbar slice
14
+ * button or a dialog destination opened shown over it - one place for all of it (spec PRV9), so a behaviour that differs between
15
+ * the two hosts is a bug in the host, not a second implementation.
16
+ */ function ApplicationHost({ application, composition = {}, navigationModel, registry: hostRegistry, initialScreen, history, resolveBinding, queryResults, renderScreen, renderDialog, children }) {
17
+ const [memoryHistory] = react.useState(()=>scene_react.createMemorySceneHistory());
18
+ const registry = react.useMemo(()=>({
19
+ ...PreviewTemplate.previewComponents,
20
+ ...hostRegistry
21
+ }), [
22
+ hostRegistry
23
+ ]);
24
+ const hostHistory = history ?? memoryHistory;
25
+ const screens = application.screens;
26
+ const outletScreens = react.useMemo(()=>Object.fromEntries(screens.map((candidate)=>[
27
+ candidate.name,
28
+ composeApplication.composeOutletScreen(application, candidate, composition)
29
+ ])), [
30
+ application,
31
+ composition,
32
+ screens
33
+ ]);
34
+ const owners = react.useMemo(()=>scene_react.collectOutletOwners(outletScreens), [
35
+ outletScreens
36
+ ]);
37
+ const destinations = react.useMemo(()=>[
38
+ ...composeApplication.collectDestinations(application),
39
+ ...scene_react.navigationDestinations(navigationModel.structure, navigationModel.navigation, navigationModel.screenFor)
40
+ ], [
41
+ application,
42
+ navigationModel
43
+ ]);
44
+ const routes = react.useMemo(()=>scene_react.sceneRoutesFrom(screens.map((candidate)=>candidate.name), destinations), [
45
+ destinations,
46
+ screens
47
+ ]);
48
+ const bindingScope = react.useMemo(()=>({
49
+ queryResults
50
+ }), [
51
+ queryResults
52
+ ]);
53
+ const navigation = scene_react.useSceneHistoryNavigation(hostHistory, routes, initialScreen, bindingScope, owners, destinations);
54
+ const screen = screens.find((candidate)=>candidate.name === navigation.primaryScreen) ?? screens.find((candidate)=>candidate.name === initialScreen) ?? screens[0];
55
+ const composed = react.useMemo(()=>screen ? composeApplication.composeApplicationScreen(application, screen, composition) : undefined, [
56
+ application,
57
+ composition,
58
+ screen
59
+ ]);
60
+ const outletContext = react.useMemo(()=>({
61
+ screens: outletScreens,
62
+ registry
63
+ }), [
64
+ outletScreens,
65
+ registry
66
+ ]);
67
+ const dialogTemplate = navigation.currentDialog ? application.dialogTemplates?.find((candidate)=>candidate.name === navigation.currentDialog) : undefined;
68
+ const sliceDialog = !dialogTemplate && navigation.currentDialog && scene_react.sliceDialogParameters(navigation.currentDialogParameters) !== undefined;
69
+ const dialogName = scene_react.sliceDialogParameters(navigation.currentDialogParameters)?.title ?? navigation.currentDialog;
70
+ const drawn = composed ? renderScreen?.(composed.element, composed.configuration, navigation) ?? /*#__PURE__*/ jsxRuntime.jsx(scene_react.SceneElementView, {
71
+ element: composed.element,
72
+ registry: registry,
73
+ resolveBinding: resolveBinding,
74
+ queryResults: queryResults,
75
+ configuration: composed.configuration
76
+ }) : null;
77
+ return /*#__PURE__*/ jsxRuntime.jsx(scene_react.SceneNavigationProvider, {
78
+ value: navigation,
79
+ children: /*#__PURE__*/ jsxRuntime.jsx(scene_react.SceneOutletContext.Provider, {
80
+ value: outletContext,
81
+ children: /*#__PURE__*/ jsxRuntime.jsx(scene_react.SceneNavigationModelProvider, {
82
+ model: navigationModel,
83
+ children: /*#__PURE__*/ jsxRuntime.jsxs(LayoutConfigProvider.LayoutConfigProvider, {
84
+ storage: null,
85
+ children: [
86
+ /*#__PURE__*/ jsxRuntime.jsx("div", {
87
+ "data-scene-outlet": "primary",
88
+ "data-scene-url": navigation.currentUrl,
89
+ "data-scene-screen": navigation.primaryScreen,
90
+ children: drawn
91
+ }),
92
+ (dialogTemplate || sliceDialog) && /*#__PURE__*/ jsxRuntime.jsx("div", {
93
+ role: "dialog",
94
+ "aria-modal": "true",
95
+ "aria-label": dialogName,
96
+ "data-scene-dialog": navigation.currentDialog,
97
+ children: dialogTemplate ? /*#__PURE__*/ jsxRuntime.jsx(scene_react.SceneElementView, {
98
+ element: composeApplication.composeDialog(application, dialogTemplate, composition),
99
+ registry: registry,
100
+ resolveBinding: resolveBinding,
101
+ queryResults: queryResults
102
+ }) : renderDialog?.(navigation) ?? /*#__PURE__*/ jsxRuntime.jsx(scene_react.SliceDialogView, {})
103
+ }),
104
+ children
105
+ ]
106
+ })
107
+ })
108
+ })
109
+ });
110
+ }
111
+
112
+ exports.ApplicationHost = ApplicationHost;
113
+ //# sourceMappingURL=ApplicationHost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApplicationHost.js","sources":["../../../preview-host/ApplicationHost.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, useMemo, useState } from 'react';\nimport { SceneElement, type EffectiveConfiguration } from '@cratis/scene.model';\nimport { BindingResolver, BindingScope } from '@cratis/scene.engine';\nimport {\n ComponentRegistry, SceneElementView, SceneHistory, SceneNavigationContextValue, SceneNavigationModel, SceneNavigationModelProvider,\n SceneNavigationProvider, SceneOutletContext, SliceDialogView, collectOutletOwners, createMemorySceneHistory, navigationDestinations,\n sceneRoutesFrom, sliceDialogParameters, useSceneHistoryNavigation,\n} from '@cratis/scene.react';\nimport { LayoutConfigProvider } from '../configuration';\nimport { ApplicationDocument } from './ApplicationDocument';\nimport { previewComponents } from './PreviewTemplate';\nimport { CompositionOptions, collectDestinations, composeApplicationScreen, composeDialog, composeOutletScreen } from './composeApplication';\n\nexport interface ApplicationHostProps {\n /** The document the application is composed from. */\n application: ApplicationDocument;\n\n /** What the host decides about composition; Stage and the preview host differ only here. */\n composition?: CompositionOptions;\n\n /** The structure and navigation the shell's regions show and the items' destinations resolve against. */\n navigationModel: SceneNavigationModel;\n\n registry: ComponentRegistry;\n\n /** The screen shown first. */\n initialScreen: string;\n\n /** Where entries are recorded: the address bar for Stage, an in-memory history for a preview, which never touches the host's URL (PRV4). */\n history?: SceneHistory;\n\n /** What the screens' bindings resolve against. */\n resolveBinding?: BindingResolver;\n queryResults?: Record<string, unknown>;\n\n /**\n * Draws the composed screen. The default renders it with `SceneElementView`; Stage wraps it with its data and command scope.\n * @param element The composed screen.\n * @param configuration What the screen's templates were configured with.\n * @param navigation Where the user is.\n */\n renderScreen?(element: SceneElement, configuration: EffectiveConfiguration | undefined, navigation: SceneNavigationContextValue): ReactNode;\n\n /**\n * Draws what the open dialog shows when the document has no dialog template of that name - a toolbar slice button's task\n * dialog by default.\n */\n renderDialog?(navigation: SceneNavigationContextValue): ReactNode;\n\n /** Rendered inside the host's providers, after the application. */\n children?: ReactNode;\n}\n\n/**\n * The application as both Stage and the preview host run it: the shell composed for the screen on the page\n * (`composeApplicationScreen`), nested outlets holding the screens placed in them, the navigation model in scope for the shell's\n * topbar and sidebar regions, every destination the document and the navigation lead to routed, and the dialog a toolbar slice\n * button or a dialog destination opened shown over it - one place for all of it (spec PRV9), so a behaviour that differs between\n * the two hosts is a bug in the host, not a second implementation.\n */\nexport function ApplicationHost({ application, composition = {}, navigationModel, registry: hostRegistry, initialScreen, history, resolveBinding, queryResults, renderScreen, renderDialog, children }: ApplicationHostProps) {\n const [memoryHistory] = useState(() => createMemorySceneHistory());\n const registry = useMemo(() => ({ ...previewComponents, ...hostRegistry }), [hostRegistry]);\n const hostHistory = history ?? memoryHistory;\n const screens = application.screens;\n\n const outletScreens = useMemo(\n () => Object.fromEntries(screens.map(candidate => [candidate.name, composeOutletScreen(application, candidate, composition)])),\n [application, composition, screens]);\n const owners = useMemo(() => collectOutletOwners(outletScreens), [outletScreens]);\n const destinations = useMemo(\n () => [...collectDestinations(application), ...navigationDestinations(navigationModel.structure, navigationModel.navigation, navigationModel.screenFor)],\n [application, navigationModel]);\n const routes = useMemo(() => sceneRoutesFrom(screens.map(candidate => candidate.name), destinations), [destinations, screens]);\n const bindingScope = useMemo<BindingScope>(() => ({ queryResults }), [queryResults]);\n const navigation = useSceneHistoryNavigation(hostHistory, routes, initialScreen, bindingScope, owners, destinations);\n\n const screen = screens.find(candidate => candidate.name === navigation.primaryScreen) ?? screens.find(candidate => candidate.name === initialScreen) ?? screens[0];\n const composed = useMemo(() => screen ? composeApplicationScreen(application, screen, composition) : undefined, [application, composition, screen]);\n const outletContext = useMemo(() => ({ screens: outletScreens, registry }), [outletScreens, registry]);\n\n const dialogTemplate = navigation.currentDialog ? application.dialogTemplates?.find(candidate => candidate.name === navigation.currentDialog) : undefined;\n const sliceDialog = !dialogTemplate && navigation.currentDialog && sliceDialogParameters(navigation.currentDialogParameters) !== undefined;\n const dialogName = sliceDialogParameters(navigation.currentDialogParameters)?.title ?? navigation.currentDialog;\n\n const drawn = composed\n ? renderScreen?.(composed.element, composed.configuration, navigation)\n ?? <SceneElementView element={composed.element} registry={registry} resolveBinding={resolveBinding} queryResults={queryResults} configuration={composed.configuration} />\n : null;\n\n return (\n <SceneNavigationProvider value={navigation}>\n <SceneOutletContext.Provider value={outletContext}>\n <SceneNavigationModelProvider model={navigationModel}>\n {/* The shell reads its layout configuration from a provider; nothing is saved from a hosted application's own. */}\n <LayoutConfigProvider storage={null}>\n <div data-scene-outlet='primary' data-scene-url={navigation.currentUrl} data-scene-screen={navigation.primaryScreen}>{drawn}</div>\n {(dialogTemplate || sliceDialog) && (\n <div role='dialog' aria-modal='true' aria-label={dialogName} data-scene-dialog={navigation.currentDialog}>\n {dialogTemplate\n ? <SceneElementView element={composeDialog(application, dialogTemplate, composition)} registry={registry} resolveBinding={resolveBinding} queryResults={queryResults} />\n : renderDialog?.(navigation) ?? <SliceDialogView />}\n </div>\n )}\n {children}\n </LayoutConfigProvider>\n </SceneNavigationModelProvider>\n </SceneOutletContext.Provider>\n </SceneNavigationProvider>\n );\n}\n"],"names":["ApplicationHost","application","composition","navigationModel","registry","hostRegistry","initialScreen","history","resolveBinding","queryResults","renderScreen","renderDialog","children","memoryHistory","useState","createMemorySceneHistory","useMemo","previewComponents","hostHistory","screens","outletScreens","Object","fromEntries","map","candidate","name","composeOutletScreen","owners","collectOutletOwners","destinations","collectDestinations","navigationDestinations","structure","navigation","screenFor","routes","sceneRoutesFrom","bindingScope","useSceneHistoryNavigation","screen","find","primaryScreen","composed","composeApplicationScreen","undefined","outletContext","dialogTemplate","currentDialog","dialogTemplates","sliceDialog","sliceDialogParameters","currentDialogParameters","dialogName","title","drawn","element","configuration","_jsx","SceneElementView","SceneNavigationProvider","value","SceneOutletContext","Provider","SceneNavigationModelProvider","model","_jsxs","LayoutConfigProvider","storage","div","data-scene-outlet","data-scene-url","currentUrl","data-scene-screen","role","aria-modal","aria-label","data-scene-dialog","composeDialog","SliceDialogView"],"mappings":";;;;;;;;;AAwDA;;;;;;AAMC,IACM,SAASA,eAAAA,CAAgB,EAAEC,WAAW,EAAEC,WAAAA,GAAc,EAAE,EAAEC,eAAe,EAAEC,QAAAA,EAAUC,YAAY,EAAEC,aAAa,EAAEC,OAAO,EAAEC,cAAc,EAAEC,YAAY,EAAEC,YAAY,EAAEC,YAAY,EAAEC,QAAQ,EAAwB,EAAA;AACxN,IAAA,MAAM,CAACC,aAAAA,CAAc,GAAGC,cAAAA,CAAS,IAAMC,oCAAAA,EAAAA,CAAAA;IACvC,MAAMX,QAAAA,GAAWY,aAAAA,CAAQ,KAAO;AAAE,YAAA,GAAGC,iCAAiB;AAAE,YAAA,GAAGZ;AAAa,SAAA,CAAA,EAAI;AAACA,QAAAA;AAAa,KAAA,CAAA;AAC1F,IAAA,MAAMa,cAAcX,OAAAA,IAAWM,aAAAA;IAC/B,MAAMM,OAAAA,GAAUlB,YAAYkB,OAAO;IAEnC,MAAMC,aAAAA,GAAgBJ,aAAAA,CAClB,IAAMK,MAAAA,CAAOC,WAAW,CAACH,OAAAA,CAAQI,GAAG,CA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is/scene.model');
5
+ var scene_engine = require('@cratis/scene.engine');
6
+
7
+ // Copyright (c) Cratis. All rights reserved.
8
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
9
+ /**
10
+ * Renders a {@link FlowNode} tree - the same one `evaluateFlowArrangement` picks for the current size
11
+ * class - by walking it into nested flex/grid containers and dropping each named slot's real content into
12
+ * its {@link FlowSlotLeaf}. This is what turns a modeled `arrangement flow` (a layout's topbar/sidebar/
13
+ * content/footer, or a screen template's header/body/aside) into something that actually looks like more
14
+ * than one column, rather than every slot's content stacked flat regardless of what the document said.
15
+ *
16
+ * A fixed `width`/`height` on a slot is a known, documented gap in the arrangement it is fed (see
17
+ * the Screenplay converter) - only `grow` and `span` survive conversion. A slot that does not grow
18
+ * therefore sizes to its own content here, which is a reasonable rendering of "not growing" even though
19
+ * the exact pixel the author wrote is not carried this far yet.
20
+ */ function FlowArrangementView({ node, slots }) {
21
+ if (scene_engine.isFlowSlotLeaf(node)) {
22
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
23
+ children: slots[node.slotName] ?? null
24
+ });
25
+ }
26
+ if (scene_engine.isFlowGrid(node)) {
27
+ const style = {
28
+ gap: `${node.gap}px`,
29
+ gridTemplateColumns: node.columns ? `repeat(${node.columns}, 1fr)` : undefined,
30
+ gridTemplateRows: node.rows ? `repeat(${node.rows}, 1fr)` : undefined
31
+ };
32
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
33
+ className: "flow-container flow-container--grid",
34
+ style: style,
35
+ children: node.children.map((child, index)=>/*#__PURE__*/ jsxRuntime.jsx(FlowChild, {
36
+ node: child,
37
+ slots: slots
38
+ }, index))
39
+ });
40
+ }
41
+ if (scene_engine.isFlowContainer(node)) {
42
+ const direction = node.kind === scene_model.FlowContainerKind.Row ? 'row' : 'column';
43
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
44
+ className: `flow-container flow-container--${direction}`,
45
+ style: {
46
+ gap: `${node.gap}px`
47
+ },
48
+ children: node.children.map((child, index)=>/*#__PURE__*/ jsxRuntime.jsx(FlowChild, {
49
+ node: child,
50
+ slots: slots
51
+ }, index))
52
+ });
53
+ }
54
+ return null;
55
+ }
56
+ function FlowChild({ node, slots }) {
57
+ const style = node.grow ? {
58
+ flex: `${node.grow} 1 0%`,
59
+ minWidth: 0,
60
+ minHeight: 0
61
+ } : {
62
+ flex: '0 0 auto'
63
+ };
64
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
65
+ className: "flow-child",
66
+ style: style,
67
+ children: /*#__PURE__*/ jsxRuntime.jsx(FlowArrangementView, {
68
+ node: node,
69
+ slots: slots
70
+ })
71
+ });
72
+ }
73
+
74
+ exports.FlowArrangementView = FlowArrangementView;
75
+ //# sourceMappingURL=FlowArrangementView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowArrangementView.js","sources":["../../../preview-host/FlowArrangementView.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 type { CSSProperties, ReactNode } from 'react';\nimport { FlowContainerKind, type FlowNode } from '@cratis/scene.model';\nimport { isFlowContainer, isFlowGrid, isFlowSlotLeaf } from '@cratis/scene.engine';\n\n/**\n * Renders a {@link FlowNode} tree - the same one `evaluateFlowArrangement` picks for the current size\n * class - by walking it into nested flex/grid containers and dropping each named slot's real content into\n * its {@link FlowSlotLeaf}. This is what turns a modeled `arrangement flow` (a layout's topbar/sidebar/\n * content/footer, or a screen template's header/body/aside) into something that actually looks like more\n * than one column, rather than every slot's content stacked flat regardless of what the document said.\n *\n * A fixed `width`/`height` on a slot is a known, documented gap in the arrangement it is fed (see\n * the Screenplay converter) - only `grow` and `span` survive conversion. A slot that does not grow\n * therefore sizes to its own content here, which is a reasonable rendering of \"not growing\" even though\n * the exact pixel the author wrote is not carried this far yet.\n */\nexport function FlowArrangementView({ node, slots }: { node: FlowNode; slots: Record<string, ReactNode> }) {\n if (isFlowSlotLeaf(node)) {\n return <>{slots[node.slotName] ?? null}</>;\n }\n\n if (isFlowGrid(node)) {\n const style: CSSProperties = {\n gap: `${node.gap}px`,\n gridTemplateColumns: node.columns ? `repeat(${node.columns}, 1fr)` : undefined,\n gridTemplateRows: node.rows ? `repeat(${node.rows}, 1fr)` : undefined,\n };\n return (\n <div className='flow-container flow-container--grid' style={style}>\n {node.children.map((child, index) => <FlowChild key={index} node={child} slots={slots} />)}\n </div>\n );\n }\n\n if (isFlowContainer(node)) {\n const direction = node.kind === FlowContainerKind.Row ? 'row' : 'column';\n return (\n <div className={`flow-container flow-container--${direction}`} style={{ gap: `${node.gap}px` }}>\n {node.children.map((child, index) => <FlowChild key={index} node={child} slots={slots} />)}\n </div>\n );\n }\n\n return null;\n}\n\nfunction FlowChild({ node, slots }: { node: FlowNode; slots: Record<string, ReactNode> }) {\n const style: CSSProperties = node.grow\n ? { flex: `${node.grow} 1 0%`, minWidth: 0, minHeight: 0 }\n : { flex: '0 0 auto' };\n return (\n <div className='flow-child' style={style}>\n <FlowArrangementView node={node} slots={slots} />\n </div>\n );\n}\n"],"names":["FlowArrangementView","node","slots","isFlowSlotLeaf","_jsx","_Fragment","slotName","isFlowGrid","style","gap","gridTemplateColumns","columns","undefined","gridTemplateRows","rows","div","className","children","map","child","index","FlowChild","isFlowContainer","direction","kind","FlowContainerKind","Row","grow","flex","minWidth","minHeight"],"mappings":";;;;;;AAAA;AACA;AAMA;;;;;;;;;;;AAWC,IACM,SAASA,mBAAAA,CAAoB,EAAEC,IAAI,EAAEC,KAAK,EAAwD,EAAA;AACrG,IAAA,IAAIC,4BAAeF,IAAAA,CAAAA,EAAO;QACtB,qBAAOG,cAAA,CAAAC,mBAAA,EAAA;AAAGH,YAAAA,QAAAA,EAAAA,KAAK,CAACD,IAAAA,CAAKK,QAAQ,CAAC,IAAI;;AACtC,IAAA;AAEA,IAAA,IAAIC,wBAAWN,IAAAA,CAAAA,EAAO;AAClB,QAAA,MAAMO,KAAAA,GAAuB;AACzBC,YAA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BAAAA,EAAAA,KAAAA,CAAAA;;AAGjE,IAAA;IAEA,OAAO,IAAA;AACX;AAEA,SAASC,SAAAA,CAAU,EAAEpB,IAAI,EAAEC,KAAK,EAAwD,EAAA;IACpF,MAAMM,KAAAA,GAAuBP,IAAAA,CAAK0B,IAAI,GAChC;AAAEC,QAAAA,IAAAA,EAAM,CAAA,EAAG3B,IAAAA,CAAK0B,IAAI,CAAC,KAAK,CAAC;QAAEE,QAAAA,EAAU,CAAA;QAAGC,SAAAA,EAAW;KAAE,GACvD;QAAEF,IAAAA,EAAM;AAAW,KAAA;AACzB,IAAA,qBACIxB,cAAA,CAACW,KAAAA,EAAAA;QAAIC,SAAAA,EAAU,YAAA;QAAaR,KAAAA,EAAOA,KAAAA;AAC/B,QAAA,QAAA,gBAAAJ,cAAA,CAACJ,mBAAAA,EAAAA;YAAoBC,IAAAA,EAAMA,IAAAA;YAAMC,KAAAA,EAAOA;;;AAGpD;;"}
@@ -0,0 +1,32 @@
1
+ 'use strict';
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
+ /** Why a preview could not be rendered, or rendered with a caveat. */ var PreviewProblemCode = /*#__PURE__*/ function(PreviewProblemCode) {
6
+ /** The module, feature or slice the preview was asked for is not in the application structure. */ PreviewProblemCode["TargetNotFound"] = "targetNotFound";
7
+ /** The module has no feature to show. */ PreviewProblemCode["ModuleWithoutFeatures"] = "moduleWithoutFeatures";
8
+ /** The feature the preview shows has no screen in the document. */ PreviewProblemCode["ScreenMissing"] = "screenMissing";
9
+ /** The slice is neither a State Change nor a State View, so there is nothing to preview. */ PreviewProblemCode["SliceNotPreviewable"] = "sliceNotPreviewable";
10
+ /** A State View slice's data fragment was not found, so its feature's page is shown. */ PreviewProblemCode["SliceFragmentMissing"] = "sliceFragmentMissing";
11
+ /** The layout a screen names is neither in the document nor one the blueprint provides. */ PreviewProblemCode["LayoutMissing"] = "layoutMissing";
12
+ /** The screen template a screen names is neither in the document nor one the blueprint provides. */ PreviewProblemCode["TemplateMissing"] = "templateMissing";
13
+ /** A template found no single home in the layout, or nests inside itself. */ PreviewProblemCode["TemplateUnplaced"] = "templateUnplaced";
14
+ /** The application structure has a duplicate or ambiguous id. */ PreviewProblemCode["StructureInvalid"] = "structureInvalid";
15
+ /** A navigation item leads nowhere or collides with another (the engine's navigation diagnostics). */ PreviewProblemCode["NavigationInvalid"] = "navigationInvalid";
16
+ /** A toolbar button's slice does not exist, is not a State Change or is empty (the engine's toolbar diagnostics). */ PreviewProblemCode["ToolbarInvalid"] = "toolbarInvalid";
17
+ /** The profile's sample data selection names a pack or set that does not exist. */ PreviewProblemCode["SampleDataInvalid"] = "sampleDataInvalid";
18
+ return PreviewProblemCode;
19
+ }({});
20
+ /** How a problem affects the preview. */ var PreviewProblemSeverity = /*#__PURE__*/ function(PreviewProblemSeverity) {
21
+ /** The preview cannot show what was asked for; the problems are shown instead of a blank screen. */ PreviewProblemSeverity["Error"] = "error";
22
+ /** The preview renders, but something in the model will not behave as authored. */ PreviewProblemSeverity["Warning"] = "warning";
23
+ return PreviewProblemSeverity;
24
+ }({});
25
+ /** Whether any of the problems stops the preview from rendering. */ function hasBlockingProblem(problems) {
26
+ return problems.some((problem)=>problem.severity === "error");
27
+ }
28
+
29
+ exports.PreviewProblemCode = PreviewProblemCode;
30
+ exports.PreviewProblemSeverity = PreviewProblemSeverity;
31
+ exports.hasBlockingProblem = hasBlockingProblem;
32
+ //# sourceMappingURL=PreviewProblem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewProblem.js","sources":["../../../preview-host/PreviewProblem.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/** Why a preview could not be rendered, or rendered with a caveat. */\nexport enum PreviewProblemCode {\n /** The module, feature or slice the preview was asked for is not in the application structure. */\n TargetNotFound = 'targetNotFound',\n\n /** The module has no feature to show. */\n ModuleWithoutFeatures = 'moduleWithoutFeatures',\n\n /** The feature the preview shows has no screen in the document. */\n ScreenMissing = 'screenMissing',\n\n /** The slice is neither a State Change nor a State View, so there is nothing to preview. */\n SliceNotPreviewable = 'sliceNotPreviewable',\n\n /** A State View slice's data fragment was not found, so its feature's page is shown. */\n SliceFragmentMissing = 'sliceFragmentMissing',\n\n /** The layout a screen names is neither in the document nor one the blueprint provides. */\n LayoutMissing = 'layoutMissing',\n\n /** The screen template a screen names is neither in the document nor one the blueprint provides. */\n TemplateMissing = 'templateMissing',\n\n /** A template found no single home in the layout, or nests inside itself. */\n TemplateUnplaced = 'templateUnplaced',\n\n /** The application structure has a duplicate or ambiguous id. */\n StructureInvalid = 'structureInvalid',\n\n /** A navigation item leads nowhere or collides with another (the engine's navigation diagnostics). */\n NavigationInvalid = 'navigationInvalid',\n\n /** A toolbar button's slice does not exist, is not a State Change or is empty (the engine's toolbar diagnostics). */\n ToolbarInvalid = 'toolbarInvalid',\n\n /** The profile's sample data selection names a pack or set that does not exist. */\n SampleDataInvalid = 'sampleDataInvalid',\n}\n\n/** How a problem affects the preview. */\nexport enum PreviewProblemSeverity {\n /** The preview cannot show what was asked for; the problems are shown instead of a blank screen. */\n Error = 'error',\n\n /** The preview renders, but something in the model will not behave as authored. */\n Warning = 'warning',\n}\n\n/**\n * One problem the preview found (PRV8): what it is, where, and a sentence an author can act on. The node id is what a host\n * links to - a screen, a template, a navigation item, a toolbar button, a module, feature or slice.\n */\nexport interface PreviewProblem {\n code: PreviewProblemCode;\n severity: PreviewProblemSeverity;\n message: string;\n\n /** The model node the problem is about, when it has one. */\n nodeId?: string;\n}\n\n/** Whether any of the problems stops the preview from rendering. */\nexport function hasBlockingProblem(problems: PreviewProblem[]): boolean {\n return problems.some(problem => problem.severity === PreviewProblemSeverity.Error);\n}\n"],"names":["PreviewProblemCode","PreviewProblemSeverity","hasBlockingProblem","problems","some","problem","severity"],"mappings":";;AAAA;AACA;AAEA,uEACO,IAAKA,kBAAAA,iBAAAA,SAAAA,kBAAAA,EAAAA;uGACwF,kBAAA,CAAA,gBAAA,CAAA,GAAA,gBAAA;8CAGzD,kBAAA,CAAA,uBAAA,CAAA,GAAA,uBAAA;wEAG0B,kBAAA,CAAA,eAAA,CAAA,GAAA,eAAA;iGAGyB,kBAAA,CAAA,qBAAA,CAAA,GAAA,qBAAA;6FAGJ,kBAAA,CAAA,sBAAA,CAAA,GAAA,sBAAA;gGAGG,kBAAA,CAAA,eAAA,CAAA,GAAA,eAAA;yGAGS,kBAAA,CAAA,iBAAA,CAAA,GAAA,iBAAA;kFAGvB,kBAAA,CAAA,kBAAA,CAAA,GAAA,kBAAA;sEAGZ,kBAAA,CAAA,kBAAA,CAAA,GAAA,kBAAA;2GAGqC,kBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAA;0HAGe,kBAAA,CAAA,gBAAA,CAAA,GAAA,gBAAA;wFAGlC,kBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAA;AAlCzEA,IAAAA,OAAAA,kBAAAA;AAoCX,CAAA,CAAA,EAAA;AAED,0CACO,IAAKC,sBAAAA,iBAAAA,SAAAA,sBAAAA,EAAAA;yGAC0F,sBAAA,CAAA,OAAA,CAAA,GAAA,OAAA;wFAGjB,sBAAA,CAAA,SAAA,CAAA,GAAA,SAAA;AAJzEA,IAAAA,OAAAA,sBAAAA;AAMX,CAAA,CAAA,EAAA;AAeD,qEACO,SAASC,kBAAAA,CAAmBC,QAA0B,EAAA;AACzD,IAAA,OAAOA,SAASC,IAAI,CAACC,CAAAA,OAAAA,GAAWA,QAAQC,QAAQ,KAAA,OAAA,CAAA;AACpD;;;;"}
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+
5
+ // Copyright (c) Cratis. All rights reserved.
6
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
7
+ /**
8
+ * What a preview shows instead of a blank screen when the model has errors that would break rendering (PRV8): each problem
9
+ * with its code, its message and a link to the offending node.
10
+ */ function PreviewProblemsView({ problems, onSelectProblem }) {
11
+ return /*#__PURE__*/ jsxRuntime.jsxs("section", {
12
+ className: "scene-preview-problems",
13
+ role: "alert",
14
+ "data-scene-preview-problems": true,
15
+ children: [
16
+ /*#__PURE__*/ jsxRuntime.jsx("h2", {
17
+ children: "This preview cannot be shown"
18
+ }),
19
+ /*#__PURE__*/ jsxRuntime.jsx("ul", {
20
+ children: problems.map((problem, index)=>/*#__PURE__*/ jsxRuntime.jsxs("li", {
21
+ "data-severity": problem.severity,
22
+ "data-code": problem.code,
23
+ "data-node-id": problem.nodeId,
24
+ children: [
25
+ /*#__PURE__*/ jsxRuntime.jsx("code", {
26
+ children: problem.code
27
+ }),
28
+ " ",
29
+ problem.message,
30
+ problem.nodeId !== undefined && onSelectProblem && /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31
+ children: [
32
+ " ",
33
+ /*#__PURE__*/ jsxRuntime.jsxs("button", {
34
+ type: "button",
35
+ onClick: ()=>onSelectProblem(problem),
36
+ children: [
37
+ "Show ",
38
+ problem.nodeId
39
+ ]
40
+ })
41
+ ]
42
+ })
43
+ ]
44
+ }, `${problem.code}-${problem.nodeId ?? index}-${index}`))
45
+ })
46
+ ]
47
+ });
48
+ }
49
+
50
+ exports.PreviewProblemsView = PreviewProblemsView;
51
+ //# sourceMappingURL=PreviewProblemsView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewProblemsView.js","sources":["../../../preview-host/PreviewProblemsView.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 { PreviewProblem } from './PreviewProblem';\n\nexport interface PreviewProblemsViewProps {\n problems: PreviewProblem[];\n\n /** Called when the author follows a problem to the node it is about. */\n onSelectProblem?(problem: PreviewProblem): void;\n}\n\n/**\n * What a preview shows instead of a blank screen when the model has errors that would break rendering (PRV8): each problem\n * with its code, its message and a link to the offending node.\n */\nexport function PreviewProblemsView({ problems, onSelectProblem }: PreviewProblemsViewProps) {\n return (\n <section className='scene-preview-problems' role='alert' data-scene-preview-problems>\n <h2>This preview cannot be shown</h2>\n <ul>\n {problems.map((problem, index) => (\n <li key={`${problem.code}-${problem.nodeId ?? index}-${index}`} data-severity={problem.severity} data-code={problem.code} data-node-id={problem.nodeId}>\n <code>{problem.code}</code> {problem.message}\n {problem.nodeId !== undefined && onSelectProblem && <> <button type='button' onClick={() => onSelectProblem(problem)}>Show {problem.nodeId}</button></>}\n </li>\n ))}\n </ul>\n </section>\n );\n}\n"],"names":["PreviewProblemsView","problems","onSelectProblem","_jsxs","section","className","role","data-scene-preview-problems","_jsx","h2","ul","map","problem","index","li","data-severity","severity","data-code","code","data-node-id","nodeId","message","undefined","_Fragment","button","type","onClick"],"mappings":";;;;AAAA;AACA;AAWA;;;AAGC,IACM,SAASA,mBAAAA,CAAoB,EAAEC,QAAQ,EAAEC,eAAe,EAA4B,EAAA;AACvF,IAAA,qBACIC,eAAA,CAACC,SAAAA,EAAAA;QAAQC,SAAAA,EAAU,wBAAA;QAAyBC,IAAAA,EAAK,OAAA;QAAQC,6BAA2B,EAAA,IAAA;;0BAChFC,cAAA,CAACC,IAAAA,EAAAA;AAAG,gBAAA,QAAA,EAAA;;0BACJD,cAAA,CAACE,IAAAA,EAAAA;AACIT,gBAAAA,QAAAA,EAAAA,QAAAA,CAASU,GAAG,CAAC,CAACC,OAAAA,EAASC,sBACpBV,eAAA,CAACW,IAAAA,EAAAA;AAA+DC,wBAAAA,eAAAA,EAAeH,QAAQI,QAAQ;AAAEC,wBAAAA,WAAAA,EAAWL,QAAQM,IAAI;AAAEC,wBAAAA,cAAAA,EAAcP,QAAQQ,MAAM;;0CAClJZ,cAAA,CAACU,MAAAA,EAAAA;AAAMN,gCAAAA,QAAAA,EAAAA,OAAAA,CAAQM;;AAAY,4BAAA,GAAA;AAAEN,4BAAAA,OAAAA,CAAQS,OAAO;4BAC3CT,OAAAA,CAAQQ,MAAM,KAAKE,SAAAA,IAAapB,eAAAA,kBAAmBC,eAAA,CAAAoB,mBAAA,EAAA;;AAAE,oCAAA,GAAA;kDAACpB,eAAA,CAACqB,QAAAA,EAAAA;wCAAOC,IAAAA,EAAK,QAAA;AAASC,wCAAAA,OAAAA,EAAS,IAAMxB,eAAAA,CAAgBU,OAAAA,CAAAA;;AAAU,4CAAA,OAAA;AAAMA,4CAAAA,OAAAA,CAAQQ;;;;;;uBAF/H,CAAA,EAAGR,OAAAA,CAAQM,IAAI,CAAC,CAAC,EAAEN,OAAAA,CAAQQ,MAAM,IAAIP,KAAAA,CAAM,CAAC,EAAEA,KAAAA,CAAAA,CAAO,CAAA;;;;AAQlF;;"}
@@ -0,0 +1,55 @@
1
+ 'use strict';
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
+ function matches(element, names) {
6
+ const properties = element.properties;
7
+ return [
8
+ 'query',
9
+ 'readModel',
10
+ 'slice'
11
+ ].some((key)=>{
12
+ const value = properties?.[key];
13
+ return typeof value === 'string' && (names.has(value) || names.has(value.slice(value.lastIndexOf('.') + 1)));
14
+ });
15
+ }
16
+ function childrenOf(element) {
17
+ const node = element;
18
+ return [
19
+ ...Object.values(node.slots ?? {}).flat(),
20
+ ...Array.isArray(node.children) ? node.children : [],
21
+ ...node.content ? [
22
+ node.content
23
+ ] : [],
24
+ ...node.itemTemplate ? [
25
+ node.itemTemplate
26
+ ] : []
27
+ ];
28
+ }
29
+ /**
30
+ * The data fragment of a State View slice (PRV3): the outermost components of the slice's screen bound to the slice's read model
31
+ * or query - by the slice's qualified id, its id, its name or its command - each with everything inside it. Empty when the screen
32
+ * has nothing bound to it.
33
+ */ function findSliceFragment(screen, sliceId, slice) {
34
+ const names = new Set([
35
+ sliceId,
36
+ slice.id,
37
+ slice.name,
38
+ ...slice.command ? [
39
+ slice.command
40
+ ] : []
41
+ ]);
42
+ const found = [];
43
+ const visit = (element)=>{
44
+ if (element.componentName !== undefined && matches(element, names)) {
45
+ found.push(element);
46
+ return;
47
+ }
48
+ childrenOf(element).forEach(visit);
49
+ };
50
+ Object.values(screen.slotContent).flat().forEach(visit);
51
+ return found;
52
+ }
53
+
54
+ exports.findSliceFragment = findSliceFragment;
55
+ //# sourceMappingURL=PreviewSliceFragment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewSliceFragment.js","sources":["../../../preview-host/PreviewSliceFragment.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 { ExternalComponent, SceneElement, Screen, SliceNode } from '@cratis/scene.model';\n\nfunction matches(element: ExternalComponent, names: Set<string>): boolean {\n const properties = element.properties as Record<string, unknown> | undefined;\n return ['query', 'readModel', 'slice'].some(key => {\n const value = properties?.[key];\n return typeof value === 'string' && (names.has(value) || names.has(value.slice(value.lastIndexOf('.') + 1)));\n });\n}\n\nfunction childrenOf(element: SceneElement): SceneElement[] {\n const node = element as { slots?: Record<string, SceneElement[]>; children?: SceneElement[]; content?: SceneElement; itemTemplate?: SceneElement };\n return [\n ...Object.values(node.slots ?? {}).flat(),\n ...(Array.isArray(node.children) ? node.children : []),\n ...(node.content ? [node.content] : []),\n ...(node.itemTemplate ? [node.itemTemplate] : []),\n ];\n}\n\n/**\n * The data fragment of a State View slice (PRV3): the outermost components of the slice's screen bound to the slice's read model\n * or query - by the slice's qualified id, its id, its name or its command - each with everything inside it. Empty when the screen\n * has nothing bound to it.\n */\nexport function findSliceFragment(screen: Screen, sliceId: string, slice: SliceNode): SceneElement[] {\n const names = new Set([sliceId, slice.id, slice.name, ...(slice.command ? [slice.command] : [])]);\n const found: SceneElement[] = [];\n const visit = (element: SceneElement) => {\n if ((element as ExternalComponent).componentName !== undefined && matches(element as ExternalComponent, names)) {\n found.push(element);\n return;\n }\n\n childrenOf(element).forEach(visit);\n };\n\n Object.values(screen.slotContent).flat().forEach(visit);\n return found;\n}\n"],"names":["matches","element","names","properties","some","key","value","has","slice","lastIndexOf","childrenOf","node","Object","values","slots","flat","Array","isArray","children","content","itemTemplate","findSliceFragment","screen","sliceId","Set","id","name","command","found","visit","componentName","undefined","push","forEach","slotContent"],"mappings":";;AAAA;AACA;AAIA,SAASA,OAAAA,CAAQC,OAA0B,EAAEC,KAAkB,EAAA;IAC3D,MAAMC,UAAAA,GAAaF,QAAQE,UAAU;IACrC,OAAO;AAAC,QAAA,OAAA;AAAS,QAAA,WAAA;AAAa,QAAA;KAAQ,CAACC,IAAI,CAACC,CAAAA,GAAAA,GAAAA;QACxC,MAAMC,KAAAA,GAAQH,UAAAA,GAAaE,GAAAA,CAAI;AAC/B,QAAA,OAAO,OAAOC,KAAAA,KAAU,QAAA,KAAaJ,KAAAA,CAAMK,GAAG,CAACD,KAAAA,CAAAA,IAAUJ,KAAAA,CAAMK,GAAG,CAACD,MAAME,KAAK,CAACF,MAAMG,WAAW,CAAC,OAAO,CAAA,CAAA,CAAE,CAAA;AAC9G,IAAA,CAAA,CAAA;AACJ;AAEA,SAASC,WAAWT,OAAqB,EAAA;AACrC,IAAA,MAAMU,IAAAA,GAAOV,OAAAA;IACb,OAAO;AACAW,QAAAA,GAAAA,MAAAA,CAAOC,MAAM,CAACF,IAAAA,CAAKG,KAAK,IAAI,IAAIC,IAAI,EAAA;WACnCC,KAAAA,CAAMC,OAAO,CAACN,IAAAA,CAAKO,QAAQ,IAAIP,IAAAA,CAAKO,QAAQ,GAAG,EAAE;AACjDP,QAAAA,GAAAA,IAAAA,CAAKQ,OAAO,GAAG;AAACR,YAAAA,IAAAA,CAAKQ;AAAQ,SAAA,GAAG,EAAE;AAClCR,QAAAA,GAAAA,IAAAA,CAAKS,YAAY,GAAG;AAACT,YAAAA,IAAAA,CAAKS;AAAa,SAAA,GAAG;AACjD,KAAA;AACL;AAEA;;;;AAIC,IACM,SAASC,iBAAAA,CAAkBC,MAAc,EAAEC,OAAe,EAAEf,KAAgB,EAAA;IAC/E,MAAMN,KAAAA,GAAQ,IAAIsB,GAAAA,CAAI;AAACD,QAAAA,OAAAA;AAASf,QAAAA,KAAAA,CAAMiB,EAAE;AAAEjB,QAAAA,KAAAA,CAAMkB,IAAI;AAAMlB,QAAAA,GAAAA,KAAAA,CAAMmB,OAAO,GAAG;AAACnB,YAAAA,KAAAA,CAAMmB;AAAQ,SAAA,GAAG;AAAI,KAAA,CAAA;AAChG,IAAA,MAAMC,QAAwB,EAAE;AAChC,IAAA,MAAMC,QAAQ,CAAC5B,OAAAA,GAAAA;AACX,QAAA,IAAI,OAACA,CAA8B6B,aAAa,KAAKC,SAAAA,IAAa/B,OAAAA,CAAQC,SAA8BC,KAAAA,CAAAA,EAAQ;AAC5G0B,YAAAA,KAAAA,CAAMI,IAAI,CAAC/B,OAAAA,CAAAA;AACX,YAAA;AACJ,QAAA;QAEAS,UAAAA,CAAWT,OAAAA,CAAAA,CAASgC,OAAO,CAACJ,KAAAA,CAAAA;AAChC,IAAA,CAAA;IAEAjB,MAAAA,CAAOC,MAAM,CAACS,MAAAA,CAAOY,WAAW,EAAEnB,IAAI,EAAA,CAAGkB,OAAO,CAACJ,KAAAA,CAAAA;IACjD,OAAOD,KAAAA;AACX;;"}
@@ -0,0 +1,17 @@
1
+ 'use strict';
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
+ * What a preview shows (spec PRV1/PRV3): a module - the application shell with the module's effective navigation and its
7
+ * first feature -, one of its features - the same shell with that feature - or a slice. Ids are the qualified ids of the
8
+ * application structure: `sales`, `sales.orders`, `sales.orders.PlaceOrder`. A feature may also be given relative to its module
9
+ * (`orders`).
10
+ *
11
+ * A State Change slice opens its dialog over a minimal host page; a State View slice renders its data fragment.
12
+ */ /** Whether a target names a slice. */ function isSliceTarget(target) {
13
+ return 'slice' in target;
14
+ }
15
+
16
+ exports.isSliceTarget = isSliceTarget;
17
+ //# sourceMappingURL=PreviewTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewTarget.js","sources":["../../../preview-host/PreviewTarget.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 * What a preview shows (spec PRV1/PRV3): a module - the application shell with the module's effective navigation and its\n * first feature -, one of its features - the same shell with that feature - or a slice. Ids are the qualified ids of the\n * application structure: `sales`, `sales.orders`, `sales.orders.PlaceOrder`. A feature may also be given relative to its module\n * (`orders`).\n *\n * A State Change slice opens its dialog over a minimal host page; a State View slice renders its data fragment.\n */\nexport type PreviewTarget =\n | { module: string; feature?: string }\n | { slice: string };\n\n/** Whether a target names a slice. */\nexport function isSliceTarget(target: PreviewTarget): target is { slice: string } {\n return 'slice' in target;\n}\n"],"names":["isSliceTarget","target"],"mappings":";;AAAA;AACA;AAEA;;;;;;;AAOC,2CAMM,SAASA,cAAcC,MAAqB,EAAA;AAC/C,IAAA,OAAO,OAAA,IAAWA,MAAAA;AACtB;;"}
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var scene_engine = require('@cratis/scene.engine');
5
+ var FlowArrangementView = require('./FlowArrangementView.js');
6
+ var useSizeClass = require('./useSizeClass.js');
7
+
8
+ // Copyright (c) Cratis. All rights reserved.
9
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
10
+ /** The name the template wrapper is registered under. */ const previewTemplateComponent = 'Scene:template';
11
+ function isFlowArrangement(arrangement) {
12
+ return !!arrangement && typeof arrangement === 'object' && 'root' in arrangement;
13
+ }
14
+ /**
15
+ * A screen's content inside the screen template it names.
16
+ *
17
+ * The template's own `arrangement flow` positions its slots - header, body, aside - exactly as the document wrote it, evaluated
18
+ * for the window's current size class. A template with no flow arrangement stacks them. It sits inside the shell's content
19
+ * slot, so the shell, not this, owns the chrome around it. Stage and the preview host render templates with this one component.
20
+ */ function PreviewTemplate({ element, slots }) {
21
+ const sizeClass = useSizeClass.useSizeClass();
22
+ const arrangement = element.properties?.arrangement;
23
+ const nodes = {};
24
+ for (const [name, content] of Object.entries(slots)){
25
+ nodes[name] = /*#__PURE__*/ jsxRuntime.jsx("section", {
26
+ className: "scene-template-slot",
27
+ "data-slot": name,
28
+ children: content
29
+ });
30
+ }
31
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
32
+ className: "scene-template",
33
+ "data-scene-id": element.id,
34
+ children: isFlowArrangement(arrangement) ? /*#__PURE__*/ jsxRuntime.jsx(FlowArrangementView.FlowArrangementView, {
35
+ node: scene_engine.evaluateFlowArrangement(arrangement, sizeClass),
36
+ slots: nodes
37
+ }) : Object.entries(nodes).map(([name, node])=>/*#__PURE__*/ jsxRuntime.jsx("div", {
38
+ children: node
39
+ }, name))
40
+ });
41
+ }
42
+ /** The components the preview host and the Stage add to the registry for composed screens. */ const previewComponents = {
43
+ [previewTemplateComponent]: PreviewTemplate
44
+ };
45
+
46
+ exports.PreviewTemplate = PreviewTemplate;
47
+ exports.previewComponents = previewComponents;
48
+ exports.previewTemplateComponent = previewTemplateComponent;
49
+ //# sourceMappingURL=PreviewTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewTemplate.js","sources":["../../../preview-host/PreviewTemplate.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 type { ReactNode } from 'react';\nimport type { FlowArrangement } from '@cratis/scene.model';\nimport { evaluateFlowArrangement } from '@cratis/scene.engine';\nimport type { ComponentRegistry, RegisteredComponentProps } from '@cratis/scene.react';\nimport { FlowArrangementView } from './FlowArrangementView';\nimport { useSizeClass } from './useSizeClass';\n\n/** The name the template wrapper is registered under. */\nexport const previewTemplateComponent = 'Scene:template';\n\nfunction isFlowArrangement(arrangement: unknown): arrangement is FlowArrangement {\n return !!arrangement && typeof arrangement === 'object' && 'root' in arrangement;\n}\n\n/**\n * A screen's content inside the screen template it names.\n *\n * The template's own `arrangement flow` positions its slots - header, body, aside - exactly as the document wrote it, evaluated\n * for the window's current size class. A template with no flow arrangement stacks them. It sits inside the shell's content\n * slot, so the shell, not this, owns the chrome around it. Stage and the preview host render templates with this one component.\n */\nexport function PreviewTemplate({ element, slots }: RegisteredComponentProps) {\n const sizeClass = useSizeClass();\n const arrangement = (element.properties as Record<string, unknown> | undefined)?.arrangement;\n const nodes: Record<string, ReactNode> = {};\n for (const [name, content] of Object.entries(slots)) {\n nodes[name] = <section className='scene-template-slot' data-slot={name}>{content}</section>;\n }\n\n return (\n <div className='scene-template' data-scene-id={element.id}>\n {isFlowArrangement(arrangement)\n ? <FlowArrangementView node={evaluateFlowArrangement(arrangement, sizeClass)} slots={nodes} />\n : Object.entries(nodes).map(([name, node]) => <div key={name}>{node}</div>)}\n </div>\n );\n}\n\n/** The components the preview host and the Stage add to the registry for composed screens. */\nexport const previewComponents: ComponentRegistry = {\n [previewTemplateComponent]: PreviewTemplate,\n};\n"],"names":["previewTemplateComponent","isFlowArrangement","arrangement","PreviewTemplate","element","slots","sizeClass","useSizeClass","properties","nodes","name","content","Object","entries","_jsx","section","className","data-slot","div","data-scene-id","id","FlowArrangementView","node","evaluateFlowArrangement","map","previewComponents"],"mappings":";;;;;;;AAAA;AACA;AASA,0DACO,MAAMA,wBAAAA,GAA2B;AAExC,SAASC,kBAAkBC,WAAoB,EAAA;AAC3C,IAAA,OAAO,CAAC,CAACA,WAAAA,IAAe,OAAOA,WAAAA,KAAgB,YAAY,MAAA,IAAUA,WAAAA;AACzE;AAEA;;;;;;AAMC,IACM,SAASC,eAAAA,CAAgB,EAAEC,OAAO,EAAEC,KAAK,EAA4B,EAAA;AACxE,IAAA,MAAMC,SAAAA,GAAYC,yBAAAA,EAAAA;IAClB,MAAML,WAAAA,GAAeE,OAAAA,CAAQI,UAAU,EAA0CN,WAAAA;AACjF,IAAA,MAAMO,QAAmC,EAAC;IAC1C,KAAK,MAAM,CAACC,IAAAA,EAAMC,OAAAA,CAAQ,IAAIC,MAAAA,C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