@cratis/scene.blueprint.default 4.32.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 (249) hide show
  1. package/ComponentName.ts +12 -0
  2. package/defaultBlueprintComponents.ts +5 -1
  3. package/dist/cjs/ComponentName.js +4 -0
  4. package/dist/cjs/ComponentName.js.map +1 -1
  5. package/dist/cjs/defaultBlueprint.js +1 -1
  6. package/dist/cjs/defaultBlueprintComponentMetadata.js +2 -2
  7. package/dist/cjs/defaultBlueprintComponents.js +10 -2
  8. package/dist/cjs/defaultBlueprintComponents.js.map +1 -1
  9. package/dist/cjs/foundation/ChartWrapper.js +520 -0
  10. package/dist/cjs/foundation/ChartWrapper.js.map +1 -0
  11. package/dist/cjs/foundation/ColumnChooser.js +156 -0
  12. package/dist/cjs/foundation/ColumnChooser.js.map +1 -0
  13. package/dist/cjs/foundation/FilterBuilder.js +307 -0
  14. package/dist/cjs/foundation/FilterBuilder.js.map +1 -0
  15. package/dist/cjs/foundation/SavedViewsMenu.js +199 -0
  16. package/dist/cjs/foundation/SavedViewsMenu.js.map +1 -0
  17. package/dist/cjs/foundation/chartGeometry.js +101 -0
  18. package/dist/cjs/foundation/chartGeometry.js.map +1 -0
  19. package/dist/cjs/foundation/columnModel.js +43 -0
  20. package/dist/cjs/foundation/columnModel.js.map +1 -0
  21. package/dist/cjs/foundation/filterModel.js +123 -0
  22. package/dist/cjs/foundation/filterModel.js.map +1 -0
  23. package/dist/cjs/foundation/foundationComponentMetadata.js +28 -0
  24. package/dist/cjs/foundation/foundationComponentMetadata.js.map +1 -1
  25. package/dist/cjs/foundation/foundationDescriptors.js +153 -0
  26. package/dist/cjs/foundation/foundationDescriptors.js.map +1 -1
  27. package/dist/cjs/foundation/foundationSamples.js +130 -0
  28. package/dist/cjs/foundation/foundationSamples.js.map +1 -1
  29. package/dist/cjs/foundation/foundationStrings.js +25 -0
  30. package/dist/cjs/foundation/foundationStrings.js.map +1 -1
  31. package/dist/cjs/foundation/useElementWidth.js +31 -0
  32. package/dist/cjs/foundation/useElementWidth.js.map +1 -0
  33. package/dist/cjs/foundation/viewModel.js +24 -0
  34. package/dist/cjs/foundation/viewModel.js.map +1 -0
  35. package/dist/cjs/index.js +91 -4
  36. package/dist/cjs/index.js.map +1 -1
  37. package/dist/cjs/preview-host/ApplicationDocument.js +17 -0
  38. package/dist/cjs/preview-host/ApplicationDocument.js.map +1 -0
  39. package/dist/cjs/preview-host/ApplicationHost.js +113 -0
  40. package/dist/cjs/preview-host/ApplicationHost.js.map +1 -0
  41. package/dist/cjs/preview-host/FlowArrangementView.js +75 -0
  42. package/dist/cjs/preview-host/FlowArrangementView.js.map +1 -0
  43. package/dist/cjs/preview-host/PreviewProblem.js +32 -0
  44. package/dist/cjs/preview-host/PreviewProblem.js.map +1 -0
  45. package/dist/cjs/preview-host/PreviewProblemsView.js +51 -0
  46. package/dist/cjs/preview-host/PreviewProblemsView.js.map +1 -0
  47. package/dist/cjs/preview-host/PreviewSliceFragment.js +55 -0
  48. package/dist/cjs/preview-host/PreviewSliceFragment.js.map +1 -0
  49. package/dist/cjs/preview-host/PreviewTarget.js +17 -0
  50. package/dist/cjs/preview-host/PreviewTarget.js.map +1 -0
  51. package/dist/cjs/preview-host/PreviewTemplate.js +49 -0
  52. package/dist/cjs/preview-host/PreviewTemplate.js.map +1 -0
  53. package/dist/cjs/preview-host/PreviewToast.js +45 -0
  54. package/dist/cjs/preview-host/PreviewToast.js.map +1 -0
  55. package/dist/cjs/preview-host/ScenePreviewHost.js +290 -0
  56. package/dist/cjs/preview-host/ScenePreviewHost.js.map +1 -0
  57. package/dist/cjs/preview-host/composeApplication.js +249 -0
  58. package/dist/cjs/preview-host/composeApplication.js.map +1 -0
  59. package/dist/cjs/preview-host/defaultApplicationChrome.js +43 -0
  60. package/dist/cjs/preview-host/defaultApplicationChrome.js.map +1 -0
  61. package/dist/cjs/preview-host/diagnosePreview.js +100 -0
  62. package/dist/cjs/preview-host/diagnosePreview.js.map +1 -0
  63. package/dist/cjs/preview-host/previewProfile.js +53 -0
  64. package/dist/cjs/preview-host/previewProfile.js.map +1 -0
  65. package/dist/cjs/preview-host/previewSampleData.js +116 -0
  66. package/dist/cjs/preview-host/previewSampleData.js.map +1 -0
  67. package/dist/cjs/preview-host/resolvePreviewPlan.js +126 -0
  68. package/dist/cjs/preview-host/resolvePreviewPlan.js.map +1 -0
  69. package/dist/cjs/preview-host/useSizeClass.js +23 -0
  70. package/dist/cjs/preview-host/useSizeClass.js.map +1 -0
  71. package/dist/esm/ComponentName.d.ts +5 -1
  72. package/dist/esm/ComponentName.d.ts.map +1 -1
  73. package/dist/esm/ComponentName.js +4 -0
  74. package/dist/esm/ComponentName.js.map +1 -1
  75. package/dist/esm/defaultBlueprint.js +1 -1
  76. package/dist/esm/defaultBlueprintComponentMetadata.js +2 -2
  77. package/dist/esm/defaultBlueprintComponents.d.ts.map +1 -1
  78. package/dist/esm/defaultBlueprintComponents.js +10 -2
  79. package/dist/esm/defaultBlueprintComponents.js.map +1 -1
  80. package/dist/esm/foundation/ChartWrapper.d.ts +5 -0
  81. package/dist/esm/foundation/ChartWrapper.d.ts.map +1 -0
  82. package/dist/esm/foundation/ChartWrapper.js +517 -0
  83. package/dist/esm/foundation/ChartWrapper.js.map +1 -0
  84. package/dist/esm/foundation/ColumnChooser.d.ts +3 -0
  85. package/dist/esm/foundation/ColumnChooser.d.ts.map +1 -0
  86. package/dist/esm/foundation/ColumnChooser.js +154 -0
  87. package/dist/esm/foundation/ColumnChooser.js.map +1 -0
  88. package/dist/esm/foundation/FilterBuilder.d.ts +3 -0
  89. package/dist/esm/foundation/FilterBuilder.d.ts.map +1 -0
  90. package/dist/esm/foundation/FilterBuilder.js +305 -0
  91. package/dist/esm/foundation/FilterBuilder.js.map +1 -0
  92. package/dist/esm/foundation/Foundation.stories.d.ts +16 -0
  93. package/dist/esm/foundation/Foundation.stories.d.ts.map +1 -1
  94. package/dist/esm/foundation/Foundation.stories.js +16 -0
  95. package/dist/esm/foundation/Foundation.stories.js.map +1 -1
  96. package/dist/esm/foundation/SavedViewsMenu.d.ts +4 -0
  97. package/dist/esm/foundation/SavedViewsMenu.d.ts.map +1 -0
  98. package/dist/esm/foundation/SavedViewsMenu.js +196 -0
  99. package/dist/esm/foundation/SavedViewsMenu.js.map +1 -0
  100. package/dist/esm/foundation/chartGeometry.d.ts +34 -0
  101. package/dist/esm/foundation/chartGeometry.d.ts.map +1 -0
  102. package/dist/esm/foundation/chartGeometry.js +93 -0
  103. package/dist/esm/foundation/chartGeometry.js.map +1 -0
  104. package/dist/esm/foundation/columnModel.d.ts +11 -0
  105. package/dist/esm/foundation/columnModel.d.ts.map +1 -0
  106. package/dist/esm/foundation/columnModel.js +38 -0
  107. package/dist/esm/foundation/columnModel.js.map +1 -0
  108. package/dist/esm/foundation/filterModel.d.ts +33 -0
  109. package/dist/esm/foundation/filterModel.d.ts.map +1 -0
  110. package/dist/esm/foundation/filterModel.js +112 -0
  111. package/dist/esm/foundation/filterModel.js.map +1 -0
  112. package/dist/esm/foundation/foundationComponentMetadata.d.ts.map +1 -1
  113. package/dist/esm/foundation/foundationComponentMetadata.js +28 -0
  114. package/dist/esm/foundation/foundationComponentMetadata.js.map +1 -1
  115. package/dist/esm/foundation/foundationDescriptors.d.ts.map +1 -1
  116. package/dist/esm/foundation/foundationDescriptors.js +154 -1
  117. package/dist/esm/foundation/foundationDescriptors.js.map +1 -1
  118. package/dist/esm/foundation/foundationSamples.d.ts.map +1 -1
  119. package/dist/esm/foundation/foundationSamples.js +130 -0
  120. package/dist/esm/foundation/foundationSamples.js.map +1 -1
  121. package/dist/esm/foundation/foundationStrings.d.ts +25 -0
  122. package/dist/esm/foundation/foundationStrings.d.ts.map +1 -1
  123. package/dist/esm/foundation/foundationStrings.js +25 -0
  124. package/dist/esm/foundation/foundationStrings.js.map +1 -1
  125. package/dist/esm/foundation/index.d.ts +9 -0
  126. package/dist/esm/foundation/index.d.ts.map +1 -1
  127. package/dist/esm/foundation/index.js +9 -0
  128. package/dist/esm/foundation/index.js.map +1 -1
  129. package/dist/esm/foundation/useElementWidth.d.ts +3 -0
  130. package/dist/esm/foundation/useElementWidth.d.ts.map +1 -0
  131. package/dist/esm/foundation/useElementWidth.js +29 -0
  132. package/dist/esm/foundation/useElementWidth.js.map +1 -0
  133. package/dist/esm/foundation/viewModel.d.ts +7 -0
  134. package/dist/esm/foundation/viewModel.d.ts.map +1 -0
  135. package/dist/esm/foundation/viewModel.js +22 -0
  136. package/dist/esm/foundation/viewModel.js.map +1 -0
  137. package/dist/esm/index.d.ts +1 -0
  138. package/dist/esm/index.d.ts.map +1 -1
  139. package/dist/esm/index.js +26 -0
  140. package/dist/esm/index.js.map +1 -1
  141. package/dist/esm/preview-host/ApplicationDocument.d.ts +7 -0
  142. package/dist/esm/preview-host/ApplicationDocument.d.ts.map +1 -0
  143. package/dist/esm/preview-host/ApplicationDocument.js +15 -0
  144. package/dist/esm/preview-host/ApplicationDocument.js.map +1 -0
  145. package/dist/esm/preview-host/ApplicationHost.d.ts +21 -0
  146. package/dist/esm/preview-host/ApplicationHost.d.ts.map +1 -0
  147. package/dist/esm/preview-host/ApplicationHost.js +111 -0
  148. package/dist/esm/preview-host/ApplicationHost.js.map +1 -0
  149. package/dist/esm/preview-host/FlowArrangementView.d.ts +7 -0
  150. package/dist/esm/preview-host/FlowArrangementView.d.ts.map +1 -0
  151. package/dist/esm/preview-host/FlowArrangementView.js +73 -0
  152. package/dist/esm/preview-host/FlowArrangementView.js.map +1 -0
  153. package/dist/esm/preview-host/PreviewProblem.d.ts +26 -0
  154. package/dist/esm/preview-host/PreviewProblem.d.ts.map +1 -0
  155. package/dist/esm/preview-host/PreviewProblem.js +28 -0
  156. package/dist/esm/preview-host/PreviewProblem.js.map +1 -0
  157. package/dist/esm/preview-host/PreviewProblemsView.d.ts +7 -0
  158. package/dist/esm/preview-host/PreviewProblemsView.d.ts.map +1 -0
  159. package/dist/esm/preview-host/PreviewProblemsView.js +49 -0
  160. package/dist/esm/preview-host/PreviewProblemsView.js.map +1 -0
  161. package/dist/esm/preview-host/PreviewSliceFragment.d.ts +3 -0
  162. package/dist/esm/preview-host/PreviewSliceFragment.d.ts.map +1 -0
  163. package/dist/esm/preview-host/PreviewSliceFragment.js +53 -0
  164. package/dist/esm/preview-host/PreviewSliceFragment.js.map +1 -0
  165. package/dist/esm/preview-host/PreviewTarget.d.ts +10 -0
  166. package/dist/esm/preview-host/PreviewTarget.d.ts.map +1 -0
  167. package/dist/esm/preview-host/PreviewTarget.js +15 -0
  168. package/dist/esm/preview-host/PreviewTarget.js.map +1 -0
  169. package/dist/esm/preview-host/PreviewTemplate.d.ts +5 -0
  170. package/dist/esm/preview-host/PreviewTemplate.d.ts.map +1 -0
  171. package/dist/esm/preview-host/PreviewTemplate.js +45 -0
  172. package/dist/esm/preview-host/PreviewTemplate.js.map +1 -0
  173. package/dist/esm/preview-host/PreviewToast.d.ts +10 -0
  174. package/dist/esm/preview-host/PreviewToast.d.ts.map +1 -0
  175. package/dist/esm/preview-host/PreviewToast.js +43 -0
  176. package/dist/esm/preview-host/PreviewToast.js.map +1 -0
  177. package/dist/esm/preview-host/ScenePreviewHost.d.ts +32 -0
  178. package/dist/esm/preview-host/ScenePreviewHost.d.ts.map +1 -0
  179. package/dist/esm/preview-host/ScenePreviewHost.js +288 -0
  180. package/dist/esm/preview-host/ScenePreviewHost.js.map +1 -0
  181. package/dist/esm/preview-host/composeApplication.d.ts +34 -0
  182. package/dist/esm/preview-host/composeApplication.d.ts.map +1 -0
  183. package/dist/esm/preview-host/composeApplication.js +239 -0
  184. package/dist/esm/preview-host/composeApplication.js.map +1 -0
  185. package/dist/esm/preview-host/defaultApplicationChrome.d.ts +4 -0
  186. package/dist/esm/preview-host/defaultApplicationChrome.d.ts.map +1 -0
  187. package/dist/esm/preview-host/defaultApplicationChrome.js +41 -0
  188. package/dist/esm/preview-host/defaultApplicationChrome.js.map +1 -0
  189. package/dist/esm/preview-host/diagnosePreview.d.ts +22 -0
  190. package/dist/esm/preview-host/diagnosePreview.d.ts.map +1 -0
  191. package/dist/esm/preview-host/diagnosePreview.js +98 -0
  192. package/dist/esm/preview-host/diagnosePreview.js.map +1 -0
  193. package/dist/esm/preview-host/index.d.ts +18 -0
  194. package/dist/esm/preview-host/index.d.ts.map +1 -0
  195. package/dist/esm/preview-host/index.js +18 -0
  196. package/dist/esm/preview-host/index.js.map +1 -0
  197. package/dist/esm/preview-host/previewProfile.d.ts +6 -0
  198. package/dist/esm/preview-host/previewProfile.d.ts.map +1 -0
  199. package/dist/esm/preview-host/previewProfile.js +49 -0
  200. package/dist/esm/preview-host/previewProfile.js.map +1 -0
  201. package/dist/esm/preview-host/previewSampleData.d.ts +22 -0
  202. package/dist/esm/preview-host/previewSampleData.d.ts.map +1 -0
  203. package/dist/esm/preview-host/previewSampleData.js +113 -0
  204. package/dist/esm/preview-host/previewSampleData.js.map +1 -0
  205. package/dist/esm/preview-host/resolvePreviewPlan.d.ts +18 -0
  206. package/dist/esm/preview-host/resolvePreviewPlan.d.ts.map +1 -0
  207. package/dist/esm/preview-host/resolvePreviewPlan.js +124 -0
  208. package/dist/esm/preview-host/resolvePreviewPlan.js.map +1 -0
  209. package/dist/esm/preview-host/useSizeClass.d.ts +3 -0
  210. package/dist/esm/preview-host/useSizeClass.d.ts.map +1 -0
  211. package/dist/esm/preview-host/useSizeClass.js +21 -0
  212. package/dist/esm/preview-host/useSizeClass.js.map +1 -0
  213. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  214. package/foundation/ChartWrapper.tsx +252 -0
  215. package/foundation/ColumnChooser.tsx +73 -0
  216. package/foundation/FilterBuilder.tsx +144 -0
  217. package/foundation/Foundation.stories.tsx +16 -0
  218. package/foundation/SavedViewsMenu.tsx +94 -0
  219. package/foundation/chartGeometry.ts +108 -0
  220. package/foundation/columnModel.ts +39 -0
  221. package/foundation/filterModel.ts +111 -0
  222. package/foundation/foundationComponentMetadata.ts +4 -0
  223. package/foundation/foundationDescriptors.ts +86 -1
  224. package/foundation/foundationSamples.ts +19 -0
  225. package/foundation/foundationStrings.ts +25 -0
  226. package/foundation/index.ts +9 -0
  227. package/foundation/useElementWidth.ts +31 -0
  228. package/foundation/viewModel.ts +21 -0
  229. package/index.ts +1 -0
  230. package/package.json +8 -8
  231. package/preview-host/ApplicationDocument.ts +31 -0
  232. package/preview-host/ApplicationHost.tsx +114 -0
  233. package/preview-host/FlowArrangementView.tsx +59 -0
  234. package/preview-host/PreviewProblem.ts +68 -0
  235. package/preview-host/PreviewProblemsView.tsx +31 -0
  236. package/preview-host/PreviewSliceFragment.ts +43 -0
  237. package/preview-host/PreviewTarget.ts +19 -0
  238. package/preview-host/PreviewTemplate.tsx +45 -0
  239. package/preview-host/PreviewToast.tsx +32 -0
  240. package/preview-host/ScenePreviewHost.tsx +250 -0
  241. package/preview-host/composeApplication.ts +273 -0
  242. package/preview-host/defaultApplicationChrome.ts +33 -0
  243. package/preview-host/diagnosePreview.ts +132 -0
  244. package/preview-host/index.ts +20 -0
  245. package/preview-host/previewProfile.ts +47 -0
  246. package/preview-host/previewSampleData.ts +144 -0
  247. package/preview-host/resolvePreviewPlan.ts +100 -0
  248. package/preview-host/useSizeClass.ts +23 -0
  249. package/shell/layout.css +307 -0
@@ -0,0 +1,124 @@
1
+ import { SliceKind } from '@cratis/scene.model';
2
+ import { ApplicationStructureIndex } from '@cratis/scene.engine';
3
+ import { isSliceTarget } from './PreviewTarget.js';
4
+ import { PreviewProblemCode, PreviewProblemSeverity } from './PreviewProblem.js';
5
+
6
+ // Copyright (c) Cratis. All rights reserved.
7
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
8
+ const error = (code, message, nodeId)=>({
9
+ code,
10
+ severity: PreviewProblemSeverity.Error,
11
+ message,
12
+ ...nodeId === undefined ? {} : {
13
+ nodeId
14
+ }
15
+ });
16
+ /** The feature a qualified id names, and the display names of the features above it, outermost first. */ function featurePath(structure, qualified) {
17
+ const [moduleId, ...rest] = qualified.split('.');
18
+ let features = structure.modules.find((module)=>module.id === moduleId)?.features;
19
+ const names = [];
20
+ let found;
21
+ for (const id of rest){
22
+ found = features?.find((candidate)=>candidate.id === id);
23
+ if (!found) return undefined;
24
+ names.push(found.name);
25
+ features = found.features;
26
+ }
27
+ return found ? {
28
+ feature: found,
29
+ names
30
+ } : undefined;
31
+ }
32
+ /**
33
+ * Resolves a preview target against the application structure (PRV3): a module previews its first feature, a feature itself,
34
+ * a slice the page of the feature it belongs to with the slice itself opened (State Change) or isolated (State View).
35
+ * A target that is not in the structure resolves to a problem, not to a blank screen.
36
+ */ function resolvePreviewPlan(structure, target) {
37
+ const index = structure instanceof ApplicationStructureIndex ? structure : new ApplicationStructureIndex(structure);
38
+ if (isSliceTarget(target)) {
39
+ const slice = index.findSlice(target.slice);
40
+ if (!slice) return {
41
+ problems: [
42
+ error(PreviewProblemCode.TargetNotFound, `The slice '${target.slice}' is not in the application.`, target.slice)
43
+ ]
44
+ };
45
+ if (slice.kind === SliceKind.Automation) {
46
+ return {
47
+ problems: [
48
+ error(PreviewProblemCode.SliceNotPreviewable, `The slice '${target.slice}' is an automation: it reacts to events and has nothing to show.`, target.slice)
49
+ ]
50
+ };
51
+ }
52
+ const segments = target.slice.split('.');
53
+ const module = segments[0];
54
+ const featureId = segments.length > 2 ? segments.slice(0, -1).join('.') : undefined;
55
+ const moduleNode = index.findModule(module);
56
+ const path = featureId ? featurePath(index.structure, featureId) : undefined;
57
+ const containerFeature = featureId ?? index.firstFeatureId(module);
58
+ return {
59
+ plan: {
60
+ kind: slice.kind === SliceKind.StateChange ? 'stateChange' : 'stateView',
61
+ module,
62
+ feature: containerFeature,
63
+ slice: target.slice,
64
+ ...slice.kind === SliceKind.StateChange ? {
65
+ command: slice.command ?? slice.id
66
+ } : {},
67
+ breadcrumb: [
68
+ moduleNode?.name ?? module,
69
+ ...path?.names ?? [],
70
+ slice.name
71
+ ]
72
+ },
73
+ problems: []
74
+ };
75
+ }
76
+ const moduleNode = index.findModule(target.module);
77
+ if (!moduleNode) return {
78
+ problems: [
79
+ error(PreviewProblemCode.TargetNotFound, `The module '${target.module}' is not in the application.`, target.module)
80
+ ]
81
+ };
82
+ if (target.feature === undefined) {
83
+ const first = index.firstFeatureId(target.module);
84
+ if (first === undefined) return {
85
+ problems: [
86
+ error(PreviewProblemCode.ModuleWithoutFeatures, `The module '${moduleNode.name}' has no feature to show.`, target.module)
87
+ ]
88
+ };
89
+ return {
90
+ plan: {
91
+ kind: 'module',
92
+ module: target.module,
93
+ feature: first,
94
+ breadcrumb: [
95
+ moduleNode.name,
96
+ ...featurePath(index.structure, first)?.names ?? []
97
+ ]
98
+ },
99
+ problems: []
100
+ };
101
+ }
102
+ const qualified = target.feature.startsWith(`${target.module}.`) ? target.feature : `${target.module}.${target.feature}`;
103
+ const path = featurePath(index.structure, qualified);
104
+ if (!path) return {
105
+ problems: [
106
+ error(PreviewProblemCode.TargetNotFound, `The feature '${qualified}' is not in the application.`, qualified)
107
+ ]
108
+ };
109
+ return {
110
+ plan: {
111
+ kind: 'feature',
112
+ module: target.module,
113
+ feature: qualified,
114
+ breadcrumb: [
115
+ moduleNode.name,
116
+ ...path.names
117
+ ]
118
+ },
119
+ problems: []
120
+ };
121
+ }
122
+
123
+ export { resolvePreviewPlan };
124
+ //# sourceMappingURL=resolvePreviewPlan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolvePreviewPlan.js","sources":["../../../preview-host/resolvePreviewPlan.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 { ApplicationStructure, FeatureNode, SliceKind } from '@cratis/scene.model';\nimport { ApplicationStructureIndex } from '@cratis/scene.engine';\nimport { PreviewTarget, isSliceTarget } from './PreviewTarget';\nimport { PreviewProblem, PreviewProblemCode, PreviewProblemSeverity } from './PreviewProblem';\n\n/** What a target resolved to in the application structure. */\nexport interface PreviewPlan {\n /** `module`, `feature`, `stateChange` or `stateView`. */\n kind: 'module' | 'feature' | 'stateChange' | 'stateView';\n\n /** The module the preview is in. */\n module: string;\n\n /** The qualified id of the feature whose screen is the page: the module's first feature, the feature itself, or the slice's feature. */\n feature?: string;\n\n /** The qualified id of the slice, for a slice target. */\n slice?: string;\n\n /** The command a State Change slice accepts. */\n command?: string;\n\n /** The display names from the module down to the target - what the preview strip shows as `Sales › Orders` (PRV7). */\n breadcrumb: string[];\n}\n\nexport interface PreviewPlanResult {\n plan?: PreviewPlan;\n problems: PreviewProblem[];\n}\n\nconst error = (code: PreviewProblemCode, message: string, nodeId?: string): PreviewProblem => ({ code, severity: PreviewProblemSeverity.Error, message, ...(nodeId === undefined ? {} : { nodeId }) });\n\n/** The feature a qualified id names, and the display names of the features above it, outermost first. */\nfunction featurePath(structure: ApplicationStructure, qualified: string): { feature: FeatureNode; names: string[] } | undefined {\n const [moduleId, ...rest] = qualified.split('.');\n let features = structure.modules.find(module => module.id === moduleId)?.features;\n const names: string[] = [];\n let found: FeatureNode | undefined;\n for (const id of rest) {\n found = features?.find(candidate => candidate.id === id);\n if (!found) return undefined;\n names.push(found.name);\n features = found.features;\n }\n\n return found ? { feature: found, names } : undefined;\n}\n\n/**\n * Resolves a preview target against the application structure (PRV3): a module previews its first feature, a feature itself,\n * a slice the page of the feature it belongs to with the slice itself opened (State Change) or isolated (State View).\n * A target that is not in the structure resolves to a problem, not to a blank screen.\n */\nexport function resolvePreviewPlan(structure: ApplicationStructure | ApplicationStructureIndex, target: PreviewTarget): PreviewPlanResult {\n const index = structure instanceof ApplicationStructureIndex ? structure : new ApplicationStructureIndex(structure);\n\n if (isSliceTarget(target)) {\n const slice = index.findSlice(target.slice);\n if (!slice) return { problems: [error(PreviewProblemCode.TargetNotFound, `The slice '${target.slice}' is not in the application.`, target.slice)] };\n if (slice.kind === SliceKind.Automation) {\n return { problems: [error(PreviewProblemCode.SliceNotPreviewable, `The slice '${target.slice}' is an automation: it reacts to events and has nothing to show.`, target.slice)] };\n }\n\n const segments = target.slice.split('.');\n const module = segments[0];\n const featureId = segments.length > 2 ? segments.slice(0, -1).join('.') : undefined;\n const moduleNode = index.findModule(module);\n const path = featureId ? featurePath(index.structure, featureId) : undefined;\n const containerFeature = featureId ?? index.firstFeatureId(module);\n return {\n plan: {\n kind: slice.kind === SliceKind.StateChange ? 'stateChange' : 'stateView',\n module,\n feature: containerFeature,\n slice: target.slice,\n ...(slice.kind === SliceKind.StateChange ? { command: slice.command ?? slice.id } : {}),\n breadcrumb: [moduleNode?.name ?? module, ...(path?.names ?? []), slice.name],\n },\n problems: [],\n };\n }\n\n const moduleNode = index.findModule(target.module);\n if (!moduleNode) return { problems: [error(PreviewProblemCode.TargetNotFound, `The module '${target.module}' is not in the application.`, target.module)] };\n\n if (target.feature === undefined) {\n const first = index.firstFeatureId(target.module);\n if (first === undefined) return { problems: [error(PreviewProblemCode.ModuleWithoutFeatures, `The module '${moduleNode.name}' has no feature to show.`, target.module)] };\n return { plan: { kind: 'module', module: target.module, feature: first, breadcrumb: [moduleNode.name, ...(featurePath(index.structure, first)?.names ?? [])] }, problems: [] };\n }\n\n const qualified = target.feature.startsWith(`${target.module}.`) ? target.feature : `${target.module}.${target.feature}`;\n const path = featurePath(index.structure, qualified);\n if (!path) return { problems: [error(PreviewProblemCode.TargetNotFound, `The feature '${qualified}' is not in the application.`, qualified)] };\n return { plan: { kind: 'feature', module: target.module, feature: qualified, breadcrumb: [moduleNode.name, ...path.names] }, problems: [] };\n}\n"],"names":["error","code","message","nodeId","severity","PreviewProblemSeverity","Error","undefined","featurePath","structure","qualified","moduleId","rest","split","features","modules","find","module","id","names","found","candidate","push","name","feature","resolvePreviewPlan","target","index","ApplicationStructureIndex","isSliceTarget","slice","findSlice","problems","PreviewProblemCode","TargetNotFound","kind","SliceKind","Automation","SliceNotPreviewable","segments","featureId","length","join","moduleNode","findModule","path","containerFeature","firstFeatureId","plan","StateChange","command","breadcrumb","first","ModuleWithoutFeatures","startsWith"],"mappings":";;;;;AAA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
+ import type { SizeClass } from '@cratis/scene.model';
2
+ export declare function useSizeClass(): SizeClass;
3
+ //# sourceMappingURL=useSizeClass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSizeClass.d.ts","sourceRoot":"","sources":["../../../preview-host/useSizeClass.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAQrD,wBAAgB,YAAY,IAAI,SAAS,CAUxC"}
@@ -0,0 +1,21 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { computeSizeClass } from '@cratis/scene.engine';
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
+ * Tracks the browser window's {@link SizeClass}, recomputing whenever it resizes across a boundary the
8
+ * shared engine cares about. This is what lets a modeled `when width compact` override actually take
9
+ * effect on a narrow window instead of the arrangement engine's size-aware logic never being asked.
10
+ */ function useSizeClass() {
11
+ const [sizeClass, setSizeClass] = useState(()=>computeSizeClass(globalThis.innerWidth, globalThis.innerHeight));
12
+ useEffect(()=>{
13
+ const onResize = ()=>setSizeClass(computeSizeClass(globalThis.innerWidth, globalThis.innerHeight));
14
+ globalThis.addEventListener('resize', onResize);
15
+ return ()=>globalThis.removeEventListener('resize', onResize);
16
+ }, []);
17
+ return sizeClass;
18
+ }
19
+
20
+ export { useSizeClass };
21
+ //# sourceMappingURL=useSizeClass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSizeClass.js","sources":["../../../preview-host/useSizeClass.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 { useEffect, useState } from 'react';\nimport type { SizeClass } from '@cratis/scene.model';\nimport { computeSizeClass } from '@cratis/scene.engine';\n\n/**\n * Tracks the browser window's {@link SizeClass}, recomputing whenever it resizes across a boundary the\n * shared engine cares about. This is what lets a modeled `when width compact` override actually take\n * effect on a narrow window instead of the arrangement engine's size-aware logic never being asked.\n */\nexport function useSizeClass(): SizeClass {\n const [sizeClass, setSizeClass] = useState<SizeClass>(() => computeSizeClass(globalThis.innerWidth, globalThis.innerHeight));\n\n useEffect(() => {\n const onResize = () => setSizeClass(computeSizeClass(globalThis.innerWidth, globalThis.innerHeight));\n globalThis.addEventListener('resize', onResize);\n return () => globalThis.removeEventListener('resize', onResize);\n }, []);\n\n return sizeClass;\n}\n"],"names":["useSizeClass","sizeClass","setSizeClass","useState","computeSizeClass","globalThis","innerWidth","innerHeight","useEffect","onResize","addEventListener","removeEventListener"],"mappings":";;;AAAA;AACA;AAMA;;;;AAIC,IACM,SAASA,YAAAA,GAAAA;IACZ,MAAM,CAACC,SAAAA,EAAWC,YAAAA,CAAa,GAAGC,QAAAA,CAAoB,IAAMC,gBAAAA,CAAiBC,UAAAA,CAAWC,UAAU,EAAED,UAAAA,CAAWE,WAAW,CAAA,CAAA;IAE1HC,SAAAA,CAAU,IAAA;QACN,MAAMC,QAAAA,GAAW,IAAMP,YAAAA,CAAaE,gBAAAA,CAAiBC,WAAWC,UAAU,EAAED,WAAWE,WAAW,CAAA,CAAA;QAClGF,UAAAA,CAAWK,gBAAgB,CAAC,QAAA,EAAUD,QAAAA,CAAAA;AACtC,QAAA,OAAO,IAAMJ,UAAAA,CAAWM,mBAAmB,CAAC,QAAA,EAAUF,QAAAA,CAAAA;AAC1D,IAAA,CAAA,EAAG,EAAE,CAAA;IAEL,OAAOR,SAAAA;AACX;;"}