@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewTarget.d.ts","sourceRoot":"","sources":["../../../preview-host/PreviewTarget.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,aAAa,GACnB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAGxB,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,IAAI;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAEhF"}
@@ -0,0 +1,15 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ /**
4
+ * What a preview shows (spec PRV1/PRV3): a module - the application shell with the module's effective navigation and its
5
+ * first feature -, one of its features - the same shell with that feature - or a slice. Ids are the qualified ids of the
6
+ * application structure: `sales`, `sales.orders`, `sales.orders.PlaceOrder`. A feature may also be given relative to its module
7
+ * (`orders`).
8
+ *
9
+ * A State Change slice opens its dialog over a minimal host page; a State View slice renders its data fragment.
10
+ */ /** Whether a target names a slice. */ function isSliceTarget(target) {
11
+ return 'slice' in target;
12
+ }
13
+
14
+ export { isSliceTarget };
15
+ //# 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,5 @@
1
+ import type { ComponentRegistry, RegisteredComponentProps } from '@cratis/scene.react';
2
+ export declare const previewTemplateComponent = "Scene:template";
3
+ export declare function PreviewTemplate({ element, slots }: RegisteredComponentProps): import("react").JSX.Element;
4
+ export declare const previewComponents: ComponentRegistry;
5
+ //# sourceMappingURL=PreviewTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewTemplate.d.ts","sourceRoot":"","sources":["../../../preview-host/PreviewTemplate.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAKvF,eAAO,MAAM,wBAAwB,mBAAmB,CAAC;AAazD,wBAAgB,eAAe,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,wBAAwB,+BAe3E;AAGD,eAAO,MAAM,iBAAiB,EAAE,iBAE/B,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { evaluateFlowArrangement } from '@cratis/scene.engine';
3
+ import { FlowArrangementView } from './FlowArrangementView.js';
4
+ import { useSizeClass } from './useSizeClass.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
+ /** The name the template wrapper is registered under. */ const previewTemplateComponent = 'Scene:template';
9
+ function isFlowArrangement(arrangement) {
10
+ return !!arrangement && typeof arrangement === 'object' && 'root' in arrangement;
11
+ }
12
+ /**
13
+ * A screen's content inside the screen template it names.
14
+ *
15
+ * The template's own `arrangement flow` positions its slots - header, body, aside - exactly as the document wrote it, evaluated
16
+ * for the window's current size class. A template with no flow arrangement stacks them. It sits inside the shell's content
17
+ * slot, so the shell, not this, owns the chrome around it. Stage and the preview host render templates with this one component.
18
+ */ function PreviewTemplate({ element, slots }) {
19
+ const sizeClass = useSizeClass();
20
+ const arrangement = element.properties?.arrangement;
21
+ const nodes = {};
22
+ for (const [name, content] of Object.entries(slots)){
23
+ nodes[name] = /*#__PURE__*/ jsx("section", {
24
+ className: "scene-template-slot",
25
+ "data-slot": name,
26
+ children: content
27
+ });
28
+ }
29
+ return /*#__PURE__*/ jsx("div", {
30
+ className: "scene-template",
31
+ "data-scene-id": element.id,
32
+ children: isFlowArrangement(arrangement) ? /*#__PURE__*/ jsx(FlowArrangementView, {
33
+ node: evaluateFlowArrangement(arrangement, sizeClass),
34
+ slots: nodes
35
+ }) : Object.entries(nodes).map(([name, node])=>/*#__PURE__*/ jsx("div", {
36
+ children: node
37
+ }, name))
38
+ });
39
+ }
40
+ /** The components the preview host and the Stage add to the registry for composed screens. */ const previewComponents = {
41
+ [previewTemplateComponent]: PreviewTemplate
42
+ };
43
+
44
+ export { PreviewTemplate, previewComponents, previewTemplateComponent };
45
+ //# 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,IA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;
5
+ }
6
+ export declare function PreviewToast({ invocation, onDismiss }: {
7
+ invocation: PreviewInvocation;
8
+ onDismiss(): void;
9
+ }): import("react").JSX.Element;
10
+ //# sourceMappingURL=PreviewToast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewToast.d.ts","sourceRoot":"","sources":["../../../preview-host/PreviewToast.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAE9B,OAAO,EAAE,MAAM,CAAC;IAGhB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAMD,wBAAgB,YAAY,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE;IAAE,UAAU,EAAE,iBAAiB,CAAC;IAAC,SAAS,IAAI,IAAI,CAAA;CAAE,+BAY3G"}
@@ -0,0 +1,43 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * The toast that confirms a dry run: "Command would be sent", with the payload in an expandable detail. Nothing was sent to
7
+ * Chronicle or Arc.
8
+ */ function PreviewToast({ invocation, onDismiss }) {
9
+ return /*#__PURE__*/ jsxs("div", {
10
+ className: "scene-preview-toast",
11
+ role: "status",
12
+ "data-scene-preview-toast": true,
13
+ children: [
14
+ /*#__PURE__*/ jsx("strong", {
15
+ children: "Command would be sent"
16
+ }),
17
+ /*#__PURE__*/ jsxs("span", {
18
+ children: [
19
+ " · ",
20
+ invocation.command ?? invocation.sliceId
21
+ ]
22
+ }),
23
+ /*#__PURE__*/ jsxs("details", {
24
+ children: [
25
+ /*#__PURE__*/ jsx("summary", {
26
+ children: "Payload"
27
+ }),
28
+ /*#__PURE__*/ jsx("pre", {
29
+ children: JSON.stringify(invocation.payload, null, 2)
30
+ })
31
+ ]
32
+ }),
33
+ /*#__PURE__*/ jsx("button", {
34
+ type: "button",
35
+ onClick: onDismiss,
36
+ children: "Dismiss"
37
+ })
38
+ ]
39
+ });
40
+ }
41
+
42
+ export { PreviewToast };
43
+ //# sourceMappingURL=PreviewToast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewToast.js","sources":["../../../preview-host/PreviewToast.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\n/** What a dry run reports (PRV5). */\nexport interface PreviewInvocation {\n /** The qualified id of the slice. */\n sliceId: string;\n\n /** The command the slice accepts, when known. */\n command?: string;\n\n /** The payload that would have been sent. */\n payload: Record<string, unknown>;\n}\n\n/**\n * The toast that confirms a dry run: \"Command would be sent\", with the payload in an expandable detail. Nothing was sent to\n * Chronicle or Arc.\n */\nexport function PreviewToast({ invocation, onDismiss }: { invocation: PreviewInvocation; onDismiss(): void }) {\n return (\n <div className='scene-preview-toast' role='status' data-scene-preview-toast>\n <strong>Command would be sent</strong>\n <span> · {invocation.command ?? invocation.sliceId}</span>\n <details>\n <summary>Payload</summary>\n <pre>{JSON.stringify(invocation.payload, null, 2)}</pre>\n </details>\n <button type='button' onClick={onDismiss}>Dismiss</button>\n </div>\n );\n}\n"],"names":["PreviewToast","invocation","onDismiss","_jsxs","div","className","role","data-scene-preview-toast","_jsx","strong","span","command","sliceId","details","summary","pre","JSON","stringify","payload","button","type","onClick"],"mappings":";;AAAA;AACA;AAcA;;;AAGC,IACM,SAASA,YAAAA,CAAa,EAAEC,UAAU,EAAEC,SAAS,EAAwD,EAAA;AACxG,IAAA,qBACIC,IAAA,CAACC,KAAAA,EAAAA;QAAIC,SAAAA,EAAU,qBAAA;QAAsBC,IAAAA,EAAK,QAAA;QAASC,0BAAwB,EAAA,IAAA;;0BACvEC,GAAA,CAACC,QAAAA,EAAAA;AAAO,gBAAA,QAAA,EAAA;;0BACRN,IAAA,CAACO,MAAAA,EAAAA;;AAAK,oBAAA,KAAA;oBAAIT,UAAAA,CAAWU,OAAO,IAAIV,UAAAA,CAAWW;;;0BAC3CT,IAAA,CAACU,SAAAA,EAAAA;;kCACGL,GAAA,CAACM,SAAAA,EAAAA;AAAQ,wBAAA,QAAA,EAAA;;kCACTN,GAAA,CAACO,KAAAA,EAAAA;AAAKC,wBAAAA,QAAAA,EAAAA,IAAAA,CAAKC,SAAS,CAAChB,UAAAA,CAAWiB,OAAO,EAAE,IAAA,EAAM,CAAA;;;;0BAEnDV,GAAA,CAACW,QAAAA,EAAAA;gBAAOC,IAAAA,EAAK,QAAA;gBAASC,OAAAA,EAASnB,SAAAA;AAAW,gBAAA,QAAA,EAAA;;;;AAGtD;;"}
@@ -0,0 +1,32 @@
1
+ import { ReactNode } from 'react';
2
+ import { ApplicationStructure, NavigationModel, Theme } from '@cratis/scene.model';
3
+ import { ApplicationStructureIndex, EffectiveNavItem } from '@cratis/scene.engine';
4
+ import { ComponentRegistry, SceneHistory, SliceCommandFieldsSource, SliceInvoker } from '@cratis/scene.react';
5
+ import { ApplicationDocument } from './ApplicationDocument';
6
+ import { CompositionOptions } from './composeApplication';
7
+ import { PreviewProblem } from './PreviewProblem';
8
+ import { PreviewSampleData } from './previewSampleData';
9
+ import { PreviewTarget } from './PreviewTarget';
10
+ import { PreviewInvocation } from './PreviewToast';
11
+ export interface ScenePreviewHostProps {
12
+ document: ApplicationDocument;
13
+ structure: ApplicationStructure | ApplicationStructureIndex;
14
+ navigation?: NavigationModel;
15
+ target: PreviewTarget;
16
+ sampleData?: PreviewSampleData;
17
+ registry: ComponentRegistry;
18
+ invoker?: SliceInvoker;
19
+ onInvoked?(invocation: PreviewInvocation): void;
20
+ fieldsFor?: SliceCommandFieldsSource;
21
+ composition?: CompositionOptions;
22
+ theme?: Theme;
23
+ isVisible?(item: EffectiveNavItem): boolean;
24
+ history?: SceneHistory;
25
+ onProblems?(problems: PreviewProblem[]): void;
26
+ onSelectProblem?(problem: PreviewProblem): void;
27
+ onBreadcrumbChange?(breadcrumb: string[]): void;
28
+ onExit?(): void;
29
+ children?: ReactNode;
30
+ }
31
+ export declare function ScenePreviewHost({ document: application, structure, navigation, target, sampleData, registry, invoker, onInvoked, fieldsFor, composition, theme, isVisible, history, onProblems, onSelectProblem, onBreadcrumbChange, onExit, children, }: ScenePreviewHostProps): import("react").JSX.Element;
32
+ //# sourceMappingURL=ScenePreviewHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScenePreviewHost.d.ts","sourceRoot":"","sources":["../../../preview-host/ScenePreviewHost.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAqD,MAAM,OAAO,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAqB,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACtG,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAwB,MAAM,sBAAsB,CAAC;AACzG,OAAO,EACH,iBAAiB,EAAE,YAAY,EAAkD,wBAAwB,EAAE,YAAY,EAE1H,MAAM,qBAAqB,CAAC;AAK7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAkE,MAAM,kBAAkB,CAAC;AAElH,OAAO,EAAE,iBAAiB,EAA2B,MAAM,qBAAqB,CAAC;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAgB,MAAM,gBAAgB,CAAC;AAGjE,MAAM,WAAW,qBAAqB;IAElC,QAAQ,EAAE,mBAAmB,CAAC;IAG9B,SAAS,EAAE,oBAAoB,GAAG,yBAAyB,CAAC;IAG5D,UAAU,CAAC,EAAE,eAAe,CAAC;IAG7B,MAAM,EAAE,aAAa,CAAC;IAGtB,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAG/B,QAAQ,EAAE,iBAAiB,CAAC;IAG5B,OAAO,CAAC,EAAE,YAAY,CAAC;IAGvB,SAAS,CAAC,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAGhD,SAAS,CAAC,EAAE,wBAAwB,CAAC;IAGrC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAGjC,KAAK,CAAC,EAAE,KAAK,CAAC;IAGd,SAAS,CAAC,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAG5C,OAAO,CAAC,EAAE,YAAY,CAAC;IAGvB,UAAU,CAAC,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IAG9C,eAAe,CAAC,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAGhD,kBAAkB,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAGhD,MAAM,CAAC,IAAI,IAAI,CAAC;IAGhB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB;AAgCD,wBAAgB,gBAAgB,CAAC,EAC7B,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,UAAyB,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAgB,EAC1I,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,EAAE,QAAQ,GAC/F,EAAE,qBAAqB,+BAuGvB"}
@@ -0,0 +1,288 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { useMemo, useRef, useEffect, useState, useCallback } from 'react';
3
+ import { SliceKind } from '@cratis/scene.model';
4
+ import { ApplicationStructureIndex, resolveToolbarButton } from '@cratis/scene.engine';
5
+ import { createMemorySceneHistory, createDryRunInvoker, SliceInvokerProvider, SliceCommandFieldsProvider, SceneThemeProvider, useSceneNavigation, sliceDialogDestination } from '@cratis/scene.react';
6
+ import { ComponentName } from '../ComponentName.js';
7
+ import { externalComponent } from '../gallery/elements.js';
8
+ import { SlotName } from '../layouts/SlotName.js';
9
+ import { LayoutName } from '../layouts/LayoutName.js';
10
+ import '../layouts/shellComponents.js';
11
+ import '../layouts/appShell.js';
12
+ import '../layouts/fullPage.js';
13
+ import { previewProfile } from './previewProfile.js';
14
+ import { ApplicationHost } from './ApplicationHost.js';
15
+ import { diagnosePreview } from './diagnosePreview.js';
16
+ import { PreviewProblemSeverity, PreviewProblemCode, hasBlockingProblem } from './PreviewProblem.js';
17
+ import { PreviewProblemsView } from './PreviewProblemsView.js';
18
+ import { createPreviewSampleData } from './previewSampleData.js';
19
+ import { findSliceFragment } from './PreviewSliceFragment.js';
20
+ import { PreviewToast } from './PreviewToast.js';
21
+
22
+ const previewPageScreen = '#preview-page';
23
+ const noNavigation = {
24
+ application: {
25
+ regions: []
26
+ },
27
+ modules: []
28
+ };
29
+ /** The page a slice preview happens over when its feature has no screen of its own, or a State View's fragment is shown. */ function minimalPage(layout, content) {
30
+ return {
31
+ name: previewPageScreen,
32
+ layout,
33
+ slotContent: {
34
+ [SlotName.Content]: content
35
+ },
36
+ forms: [],
37
+ contributions: []
38
+ };
39
+ }
40
+ /**
41
+ * Renders the effective application (spec 10, PRV1-PRV9) from an in-memory document: the real shell, its navigation regions, the
42
+ * first feature of a module, a feature, or a slice - a State Change slice as its task dialog over a minimal host page, a State View
43
+ * slice as its data fragment.
44
+ *
45
+ * - **One code path**: the composition and the host are the Stage's own (`composeApplicationScreen`, `ApplicationHost`); nothing
46
+ * here draws a shell, a menu or a dialog (PRV9).
47
+ * - **Read-only**: no design affordances, no edits (PRV8) - a toolbar button without a slice shows no warning badge here; it is
48
+ * reported as a problem instead. A model that cannot render - an unknown target, a feature without a screen,
49
+ * a layout or template nobody provides - gives a {@link PreviewProblemsView} and `onProblems`, not a blank screen.
50
+ * - **Navigation** keeps to an in-memory history; a different module swaps the shell's effective navigation (PRV4).
51
+ * - **Dialogs** submit through the dry-run invoker unless one is given: validation runs, nothing is sent, a toast says so (PRV5).
52
+ * - **Data** is the active sample data pack's (PRV6); the same seed shows the same rows.
53
+ * - The strip (`Previewing`, sample data, `Exit preview · Esc`) is the host application's: this reports the breadcrumb and calls
54
+ * `onExit` on Escape.
55
+ */ function ScenePreviewHost({ document: application, structure, navigation = noNavigation, target, sampleData, registry, invoker, onInvoked, fieldsFor, composition = {}, theme, isVisible, history, onProblems, onSelectProblem, onBreadcrumbChange, onExit, children }) {
56
+ const index = useMemo(()=>structure instanceof ApplicationStructureIndex ? structure : new ApplicationStructureIndex(structure), [
57
+ structure
58
+ ]);
59
+ const compose = useMemo(()=>({
60
+ logo: navigation.application.logo,
61
+ ...composition
62
+ }), [
63
+ composition,
64
+ navigation.application.logo
65
+ ]);
66
+ const diagnosis = useMemo(()=>diagnosePreview({
67
+ document: application,
68
+ structure: index,
69
+ navigation,
70
+ target,
71
+ packs: sampleData?.packs,
72
+ composition: compose
73
+ }), [
74
+ application,
75
+ compose,
76
+ index,
77
+ navigation,
78
+ sampleData?.packs,
79
+ target
80
+ ]);
81
+ const problems = useMemo(()=>{
82
+ const found = [
83
+ ...diagnosis.problems
84
+ ];
85
+ const { plan, screen } = diagnosis;
86
+ if (plan?.kind === 'stateView' && screen && plan.slice) {
87
+ const slice = index.findSlice(plan.slice);
88
+ if (slice && findSliceFragment(screen, plan.slice, slice).length === 0) {
89
+ found.push({
90
+ code: PreviewProblemCode.SliceFragmentMissing,
91
+ severity: PreviewProblemSeverity.Warning,
92
+ message: `Nothing on the screen '${screen.name}' is bound to the State View '${plan.slice}', so its page is shown.`,
93
+ nodeId: plan.slice
94
+ });
95
+ }
96
+ }
97
+ return found;
98
+ }, [
99
+ diagnosis,
100
+ index
101
+ ]);
102
+ const key = JSON.stringify(problems);
103
+ const reported = useRef(undefined);
104
+ useEffect(()=>{
105
+ if (reported.current === key) return;
106
+ reported.current = key;
107
+ onProblems?.(problems);
108
+ }, [
109
+ key,
110
+ onProblems,
111
+ problems
112
+ ]);
113
+ const breadcrumb = diagnosis.plan?.breadcrumb;
114
+ const breadcrumbKey = breadcrumb?.join('\u0000');
115
+ useEffect(()=>{
116
+ if (breadcrumb) onBreadcrumbChange?.(breadcrumb);
117
+ // `breadcrumbKey` is the value of `breadcrumb`.
118
+ }, [
119
+ breadcrumbKey,
120
+ onBreadcrumbChange
121
+ ]);
122
+ const [memoryHistory] = useState(()=>createMemorySceneHistory());
123
+ const [toast, setToast] = useState();
124
+ const dryRun = useMemo(()=>createDryRunInvoker({
125
+ onInvoked: (invocation)=>{
126
+ setToast(invocation);
127
+ onInvoked?.(invocation);
128
+ }
129
+ }), [
130
+ onInvoked
131
+ ]);
132
+ const samples = useMemo(()=>createPreviewSampleData(application, sampleData), [
133
+ application,
134
+ sampleData
135
+ ]);
136
+ const fields = useMemo(()=>(command, slice)=>samples.commandFields(command, fieldsFor?.(command, slice) ?? []), [
137
+ fieldsFor,
138
+ samples
139
+ ]);
140
+ const page = useMemo(()=>{
141
+ const { plan, screen } = diagnosis;
142
+ if (!plan) return undefined;
143
+ if (!screen) {
144
+ // A slice whose feature has no screen of its own: a minimal host page, headed with where it is.
145
+ if (plan.slice === undefined) return undefined;
146
+ const layout = previewProfile(application.uiProfiles).layout ?? LayoutName.AppShell;
147
+ const header = externalComponent('preview-page-header', ComponentName.PageHeader, {
148
+ title: plan.breadcrumb.slice(0, -1).join(' › ') || plan.breadcrumb[0]
149
+ });
150
+ return {
151
+ screens: [
152
+ ...application.screens,
153
+ minimalPage(layout, [
154
+ header
155
+ ])
156
+ ],
157
+ initial: previewPageScreen
158
+ };
159
+ }
160
+ if (plan.kind === 'stateView' && plan.slice) {
161
+ const slice = index.findSlice(plan.slice);
162
+ const fragment = slice ? findSliceFragment(screen, plan.slice, slice) : [];
163
+ if (fragment.length > 0) return {
164
+ screens: [
165
+ ...application.screens,
166
+ minimalPage(screen.layout, fragment)
167
+ ],
168
+ initial: previewPageScreen
169
+ };
170
+ }
171
+ return {
172
+ screens: application.screens,
173
+ initial: screen.name
174
+ };
175
+ }, [
176
+ application.screens,
177
+ application.uiProfiles,
178
+ diagnosis,
179
+ index
180
+ ]);
181
+ const hostApplication = useMemo(()=>page ? {
182
+ ...application,
183
+ screens: page.screens
184
+ } : application, [
185
+ application,
186
+ page
187
+ ]);
188
+ const navigationModel = useMemo(()=>({
189
+ structure: index,
190
+ navigation,
191
+ isVisible
192
+ }), [
193
+ index,
194
+ isVisible,
195
+ navigation
196
+ ]);
197
+ const onKeyDown = useCallback((event)=>{
198
+ if (event.key === 'Escape' && !event.defaultPrevented) onExit?.();
199
+ }, [
200
+ onExit
201
+ ]);
202
+ if (hasBlockingProblem(problems) || !page) {
203
+ return /*#__PURE__*/ jsx(PreviewProblemsView, {
204
+ problems: problems.filter((problem)=>problem.severity === PreviewProblemSeverity.Error),
205
+ onSelectProblem: onSelectProblem
206
+ });
207
+ }
208
+ const body = /*#__PURE__*/ jsx(SliceInvokerProvider, {
209
+ invoker: invoker ?? dryRun,
210
+ warnEmptySlices: false,
211
+ children: /*#__PURE__*/ jsx(SliceCommandFieldsProvider, {
212
+ fieldsFor: fields,
213
+ children: /*#__PURE__*/ jsx("div", {
214
+ className: "scene-preview-host",
215
+ "data-scene-preview": diagnosis.plan?.kind,
216
+ "data-preview-breadcrumb": breadcrumb?.join(' › '),
217
+ children: /*#__PURE__*/ jsxs(ApplicationHost, {
218
+ application: hostApplication,
219
+ composition: compose,
220
+ navigationModel: navigationModel,
221
+ registry: registry,
222
+ initialScreen: page.initial,
223
+ history: history ?? memoryHistory,
224
+ resolveBinding: samples.resolveBinding,
225
+ queryResults: samples.queryResults,
226
+ children: [
227
+ diagnosis.plan?.kind === 'stateChange' && /*#__PURE__*/ jsx(OpenSliceDialog, {
228
+ index: index,
229
+ plan: diagnosis.plan
230
+ }),
231
+ /*#__PURE__*/ jsx(EscapeToExit, {
232
+ onKeyDown: onKeyDown,
233
+ enabled: onExit !== undefined
234
+ }),
235
+ toast && invoker === undefined && /*#__PURE__*/ jsx(PreviewToast, {
236
+ invocation: toast,
237
+ onDismiss: ()=>setToast(undefined)
238
+ }),
239
+ children
240
+ ]
241
+ })
242
+ })
243
+ })
244
+ });
245
+ return theme ? /*#__PURE__*/ jsx(SceneThemeProvider, {
246
+ theme: theme,
247
+ children: body
248
+ }) : body;
249
+ }
250
+ /** Opens the task dialog of a State Change slice once the page is up - the slice preview (PRV3). */ function OpenSliceDialog({ index, plan }) {
251
+ const navigation = useSceneNavigation();
252
+ const opened = useRef(false);
253
+ useEffect(()=>{
254
+ if (opened.current || plan.slice === undefined) return;
255
+ const slice = index.findSlice(plan.slice);
256
+ if (!slice || slice.kind !== SliceKind.StateChange) return;
257
+ const destination = sliceDialogDestination(resolveToolbarButton(index, {
258
+ id: plan.slice,
259
+ title: slice.name,
260
+ slice: plan.slice
261
+ }));
262
+ if (destination === undefined) return;
263
+ opened.current = true;
264
+ navigation.navigate(destination);
265
+ }, [
266
+ index,
267
+ navigation,
268
+ plan.slice
269
+ ]);
270
+ return null;
271
+ }
272
+ /** Exits the preview on Escape, unless something - an open dialog - already used the key. */ function EscapeToExit({ onKeyDown, enabled }) {
273
+ const navigation = useSceneNavigation();
274
+ const dialogOpen = navigation.currentDialog !== undefined;
275
+ useEffect(()=>{
276
+ if (!enabled || dialogOpen) return undefined;
277
+ globalThis.addEventListener('keydown', onKeyDown);
278
+ return ()=>globalThis.removeEventListener('keydown', onKeyDown);
279
+ }, [
280
+ dialogOpen,
281
+ enabled,
282
+ onKeyDown
283
+ ]);
284
+ return null;
285
+ }
286
+
287
+ export { ScenePreviewHost };
288
+ //# sourceMappingURL=ScenePreviewHost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScenePreviewHost.js","sources":["../../../preview-host/ScenePreviewHost.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, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { ApplicationStructure, NavigationModel, Screen, SliceKind, Theme } from '@cratis/scene.model';\nimport { ApplicationStructureIndex, EffectiveNavItem, resolveToolbarButton } from '@cratis/scene.engine';\nimport {\n ComponentRegistry, SceneHistory, SceneThemeProvider, SliceCommandFieldsProvider, SliceCommandFieldsSource, SliceInvoker,\n SliceInvokerProvider, createDryRunInvoker, createMemorySceneHistory, sliceDialogDestination, useSceneNavigation,\n} from '@cratis/scene.react';\nimport { ComponentName } from '../ComponentName';\nimport { externalComponent } from '../gallery/elements';\nimport { LayoutName, SlotName } from '../layouts';\nimport { previewProfile } from './previewProfile';\nimport { ApplicationDocument } from './ApplicationDocument';\nimport { ApplicationHost } from './ApplicationHost';\nimport { CompositionOptions } from './composeApplication';\nimport { diagnosePreview } from './diagnosePreview';\nimport { PreviewProblem, PreviewProblemCode, PreviewProblemSeverity, hasBlockingProblem } from './PreviewProblem';\nimport { PreviewProblemsView } from './PreviewProblemsView';\nimport { PreviewSampleData, createPreviewSampleData } from './previewSampleData';\nimport { findSliceFragment } from './PreviewSliceFragment';\nimport { PreviewTarget } from './PreviewTarget';\nimport { PreviewInvocation, PreviewToast } from './PreviewToast';\nimport { PreviewPlan } from './resolvePreviewPlan';\n\nexport interface ScenePreviewHostProps {\n /** The document to preview - the in-memory one, unsaved edits included. */\n document: ApplicationDocument;\n\n /** The modules, features and slices of the application. */\n structure: ApplicationStructure | ApplicationStructureIndex;\n\n /** The application and module navigation regions; none when absent. */\n navigation?: NavigationModel;\n\n /** What to preview: a module, a feature or a slice. */\n target: PreviewTarget;\n\n /** The sample data to preview with; none when absent. */\n sampleData?: PreviewSampleData;\n\n /** The components to draw with. */\n registry: ComponentRegistry;\n\n /** What a submitted slice dialog goes through; a dry run, which only validates and reports, when absent (PRV5). */\n invoker?: SliceInvoker;\n\n /** Called for every dry run that passes validation, with what would have been sent. */\n onInvoked?(invocation: PreviewInvocation): void;\n\n /** The fields of a command, for the slice dialogs; the preview's sample rows fill their starting values. */\n fieldsFor?: SliceCommandFieldsSource;\n\n /** What the host decides about composition, such as the packages names resolve against. */\n composition?: CompositionOptions;\n\n /** The theme to apply; Studio passes the application's selected one (PRV9). */\n theme?: Theme;\n\n /** Hides a navigation item the preview user is not allowed to see. */\n isVisible?(item: EffectiveNavItem): boolean;\n\n /** Keeps the preview's navigation; an in-memory history by default, so a preview never touches the host's address (PRV4). */\n history?: SceneHistory;\n\n /** Called with the problems found - blocking or not - whenever they change (PRV8). */\n onProblems?(problems: PreviewProblem[]): void;\n\n /** Called when the author follows a problem to its node. */\n onSelectProblem?(problem: PreviewProblem): void;\n\n /** Called with what is being previewed, `Sales`, `Orders`, ... - the strip's breadcrumb (PRV7). */\n onBreadcrumbChange?(breadcrumb: string[]): void;\n\n /** Called when Escape is pressed with no dialog open: the host exits the preview (PRV7). */\n onExit?(): void;\n\n /** Extra content inside the host, such as a design layer's strip. */\n children?: ReactNode;\n}\n\nconst previewPageScreen = '#preview-page';\nconst noNavigation: NavigationModel = { application: { regions: [] }, modules: [] };\n\n/** The page a slice preview happens over when its feature has no screen of its own, or a State View's fragment is shown. */\nfunction minimalPage(layout: string, content: Screen['slotContent'][string]): Screen {\n return {\n name: previewPageScreen,\n layout,\n slotContent: { [SlotName.Content]: content },\n forms: [],\n contributions: [],\n };\n}\n\n/**\n * Renders the effective application (spec 10, PRV1-PRV9) from an in-memory document: the real shell, its navigation regions, the\n * first feature of a module, a feature, or a slice - a State Change slice as its task dialog over a minimal host page, a State View\n * slice as its data fragment.\n *\n * - **One code path**: the composition and the host are the Stage's own (`composeApplicationScreen`, `ApplicationHost`); nothing\n * here draws a shell, a menu or a dialog (PRV9).\n * - **Read-only**: no design affordances, no edits (PRV8) - a toolbar button without a slice shows no warning badge here; it is\n * reported as a problem instead. A model that cannot render - an unknown target, a feature without a screen,\n * a layout or template nobody provides - gives a {@link PreviewProblemsView} and `onProblems`, not a blank screen.\n * - **Navigation** keeps to an in-memory history; a different module swaps the shell's effective navigation (PRV4).\n * - **Dialogs** submit through the dry-run invoker unless one is given: validation runs, nothing is sent, a toast says so (PRV5).\n * - **Data** is the active sample data pack's (PRV6); the same seed shows the same rows.\n * - The strip (`Previewing`, sample data, `Exit preview · Esc`) is the host application's: this reports the breadcrumb and calls\n * `onExit` on Escape.\n */\nexport function ScenePreviewHost({\n document: application, structure, navigation = noNavigation, target, sampleData, registry, invoker, onInvoked, fieldsFor, composition = {},\n theme, isVisible, history, onProblems, onSelectProblem, onBreadcrumbChange, onExit, children,\n}: ScenePreviewHostProps) {\n const index = useMemo(() => structure instanceof ApplicationStructureIndex ? structure : new ApplicationStructureIndex(structure), [structure]);\n const compose = useMemo<CompositionOptions>(() => ({ logo: navigation.application.logo, ...composition }), [composition, navigation.application.logo]);\n const diagnosis = useMemo(\n () => diagnosePreview({ document: application, structure: index, navigation, target, packs: sampleData?.packs, composition: compose }),\n [application, compose, index, navigation, sampleData?.packs, target]);\n\n const problems = useMemo(() => {\n const found = [...diagnosis.problems];\n const { plan, screen } = diagnosis;\n if (plan?.kind === 'stateView' && screen && plan.slice) {\n const slice = index.findSlice(plan.slice);\n if (slice && findSliceFragment(screen, plan.slice, slice).length === 0) {\n found.push({ code: PreviewProblemCode.SliceFragmentMissing, severity: PreviewProblemSeverity.Warning, message: `Nothing on the screen '${screen.name}' is bound to the State View '${plan.slice}', so its page is shown.`, nodeId: plan.slice });\n }\n }\n\n return found;\n }, [diagnosis, index]);\n\n const key = JSON.stringify(problems);\n const reported = useRef<string | undefined>(undefined);\n useEffect(() => {\n if (reported.current === key) return;\n reported.current = key;\n onProblems?.(problems);\n }, [key, onProblems, problems]);\n\n const breadcrumb = diagnosis.plan?.breadcrumb;\n const breadcrumbKey = breadcrumb?.join('\\u0000');\n useEffect(() => {\n if (breadcrumb) onBreadcrumbChange?.(breadcrumb);\n // `breadcrumbKey` is the value of `breadcrumb`.\n }, [breadcrumbKey, onBreadcrumbChange]);\n\n const [memoryHistory] = useState(() => createMemorySceneHistory());\n const [toast, setToast] = useState<PreviewInvocation>();\n const dryRun = useMemo(() => createDryRunInvoker({\n onInvoked: invocation => {\n setToast(invocation);\n onInvoked?.(invocation);\n },\n }), [onInvoked]);\n\n const samples = useMemo(() => createPreviewSampleData(application, sampleData), [application, sampleData]);\n const fields = useMemo<SliceCommandFieldsSource>(() => (command, slice) => samples.commandFields(command, fieldsFor?.(command, slice) ?? []), [fieldsFor, samples]);\n\n const page = useMemo(() => {\n const { plan, screen } = diagnosis;\n if (!plan) return undefined;\n\n if (!screen) {\n // A slice whose feature has no screen of its own: a minimal host page, headed with where it is.\n if (plan.slice === undefined) return undefined;\n const layout = previewProfile(application.uiProfiles).layout ?? LayoutName.AppShell;\n const header = externalComponent('preview-page-header', ComponentName.PageHeader, { title: plan.breadcrumb.slice(0, -1).join(' › ') || plan.breadcrumb[0] });\n return { screens: [...application.screens, minimalPage(layout, [header])], initial: previewPageScreen };\n }\n\n if (plan.kind === 'stateView' && plan.slice) {\n const slice = index.findSlice(plan.slice);\n const fragment = slice ? findSliceFragment(screen, plan.slice, slice) : [];\n if (fragment.length > 0) return { screens: [...application.screens, minimalPage(screen.layout, fragment)], initial: previewPageScreen };\n }\n\n return { screens: application.screens, initial: screen.name };\n }, [application.screens, application.uiProfiles, diagnosis, index]);\n\n const hostApplication = useMemo(() => page ? { ...application, screens: page.screens } : application, [application, page]);\n const navigationModel = useMemo(() => ({ structure: index, navigation, isVisible }), [index, isVisible, navigation]);\n\n const onKeyDown = useCallback((event: KeyboardEvent) => {\n if (event.key === 'Escape' && !event.defaultPrevented) onExit?.();\n }, [onExit]);\n\n if (hasBlockingProblem(problems) || !page) {\n return <PreviewProblemsView problems={problems.filter(problem => problem.severity === PreviewProblemSeverity.Error)} onSelectProblem={onSelectProblem} />;\n }\n\n const body = (\n <SliceInvokerProvider invoker={invoker ?? dryRun} warnEmptySlices={false}>\n <SliceCommandFieldsProvider fieldsFor={fields}>\n <div className='scene-preview-host' data-scene-preview={diagnosis.plan?.kind} data-preview-breadcrumb={breadcrumb?.join(' › ')}>\n <ApplicationHost\n application={hostApplication}\n composition={compose}\n navigationModel={navigationModel}\n registry={registry}\n initialScreen={page.initial}\n history={history ?? memoryHistory}\n resolveBinding={samples.resolveBinding}\n queryResults={samples.queryResults}>\n {diagnosis.plan?.kind === 'stateChange' && <OpenSliceDialog index={index} plan={diagnosis.plan} />}\n <EscapeToExit onKeyDown={onKeyDown} enabled={onExit !== undefined} />\n {toast && invoker === undefined && <PreviewToast invocation={toast} onDismiss={() => setToast(undefined)} />}\n {children}\n </ApplicationHost>\n </div>\n </SliceCommandFieldsProvider>\n </SliceInvokerProvider>\n );\n\n return theme ? <SceneThemeProvider theme={theme}>{body}</SceneThemeProvider> : body;\n}\n\n/** Opens the task dialog of a State Change slice once the page is up - the slice preview (PRV3). */\nfunction OpenSliceDialog({ index, plan }: { index: ApplicationStructureIndex; plan: PreviewPlan }) {\n const navigation = useSceneNavigation();\n const opened = useRef(false);\n useEffect(() => {\n if (opened.current || plan.slice === undefined) return;\n const slice = index.findSlice(plan.slice);\n if (!slice || slice.kind !== SliceKind.StateChange) return;\n\n const destination = sliceDialogDestination(resolveToolbarButton(index, { id: plan.slice, title: slice.name, slice: plan.slice }));\n if (destination === undefined) return;\n opened.current = true;\n navigation.navigate(destination);\n }, [index, navigation, plan.slice]);\n\n return null;\n}\n\n/** Exits the preview on Escape, unless something - an open dialog - already used the key. */\nfunction EscapeToExit({ onKeyDown, enabled }: { onKeyDown(event: KeyboardEvent): void; enabled: boolean }) {\n const navigation = useSceneNavigation();\n const dialogOpen = navigation.currentDialog !== undefined;\n useEffect(() => {\n if (!enabled || dialogOpen) return undefined;\n globalThis.addEventListener('keydown', onKeyDown);\n return () => globalThis.removeEventListener('keydown', onKeyDown);\n }, [dialogOpen, enabled, onKeyDown]);\n\n return null;\n}\n"],"names":["previewPageScreen","noNavigation","application","regions","modules","minimalPage","layout","content","name","slotContent","SlotName","Content","forms","contributions","ScenePreviewHost","document","structure","navigation","target","sampleData","registry","invoker","onInvoked","fieldsFor","composition","theme","isVisible","history","onProblems","onSelectProblem","onBreadcrumbChange","onExit","children","index","useMemo","ApplicationStructureIndex","compose","logo","diagnosis","diagnosePreview","packs","problems","found","plan","screen","kind","slice","findSlice","findSliceFragment","length","push","code","PreviewProblemCode","SliceFragmentMissing","severity","PreviewProblemSeverity","Warning","message","nodeId","key","JSON","stringify","reported","useRef","undefined","useEffect","current","breadcrumb","breadcrumbKey","join","memoryHistory","useState","createMemorySceneHistory","toast","setToast","dryRun","createDryRunInvoker","invocation","samples","createPreviewSampleData","fields","command","commandFields","page","previewProfile","uiProfiles","LayoutName","AppShell","header","externalComponent","ComponentName","PageHeader","title","screens","initial","fragment","hostApplication","navigationModel","onKeyDown","useCallback","event","defaultPrevented","hasBlockingProblem","_jsx","PreviewProblemsView","filter","problem","Error","body","SliceInvokerProvider","warnEmptySlices","SliceCommandFieldsProvider","div","className","data-scene-preview","data-preview-breadcrumb","_jsxs","ApplicationHost","initialScreen","resolveBinding","queryResults","OpenSliceDialog","EscapeToExit","enabled","PreviewToast","onDismiss","SceneThemeProvider","useSceneNavigation","opened","SliceKind","StateChange","destination","sliceDialogDestination","resolveToolbarButton","id","navigate","dialogOpen","currentDialog","globalThis","addEventListener","removeEventListener"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkFA,MAAMA,iBAAAA,GAAoB,eAAA;AAC1B,MAAMC,YAAAA,GAAgC;IAAEC,WAAAA,EAAa;AAAEC,QAAAA,OAAAA,EAAS;AAAG,KAAA;AAAGC,IAAAA,OAAAA,EAAS;AAAG,CAAA;AAElF,6HACA,SAASC,WAAAA,CAAYC,MAAc,EAAEC,OAAsC,EAAA;IACvE,OAAO;QACHC,IAAAA,EAAMR,iBAAAA;AACNM,QAAAA,MAAAA;QACAG,WAAAA,EAAa;YAAE,CAACC,QAAAA,CAASC,OAAO,GAAGJ;AAAQ,SAAA;AAC3CK,QAAAA,KAAAA,EAAO,EAAE;AACTC,QAAAA,aAAAA,EAAe;AACnB,KAAA;AACJ;AAEA;;;;;;;;;;;;;;;AAeC,IACM,SAASC,gBAAAA,CAAiB,EAC7BC,QAAAA,EAAUb,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BAAAA,EAAAA;IACnB,MAAMS,UAAAA,GAAavH,UAAAA,CAAWwH,aAAa,KAAKzE,SAAAA;IAChDC,SAAAA,CAAU,IAAA;QACN,IAAI,CAAC0D,OAAAA,IAAWa,UAAAA,EAAY,OAAOxE,SAAAA;QACnC0E,UAAAA,CAAWC,gBAAgB,CAAC,SAAA,EAAWzC,SAAAA,CAAAA;AACvC,QAAA,OAAO,IAAMwC,UAAAA,CAAWE,mBAAmB,CAAC,SAAA,EAAW1C,SAAAA,CAAAA;IAC3D,CAAA,EAAG;AAACsC,QAAAA,UAAAA;AAAYb,QAAAA,OAAAA;AAASzB,QAAAA;AAAU,KAAA,CAAA;IAEnC,OAAO,IAAA;AACX;;"}
@@ -0,0 +1,34 @@
1
+ import { DestinationReference, DialogTemplate, Form, Layout, SceneElement, Screen, ScreenTemplate, UiProfile, type ApplicationLogo, type EffectiveConfiguration } from '@cratis/scene.model';
2
+ import { DescriptorCatalog, PackageCatalog } from '@cratis/scene.engine';
3
+ import { ApplicationDocument } from './ApplicationDocument';
4
+ export interface CompositionOptions {
5
+ profile?: UiProfile;
6
+ catalog?: PackageCatalog;
7
+ chrome?(screen: Screen, shell: string): Record<string, SceneElement[]>;
8
+ form?(screenName: string, form: Form): SceneElement;
9
+ trailing?: SceneElement[];
10
+ decorate?(element: SceneElement): SceneElement;
11
+ blueprintTemplates?: ScreenTemplate[];
12
+ blueprintLayouts?: Layout[];
13
+ descriptors?: DescriptorCatalog;
14
+ logo?: ApplicationLogo;
15
+ }
16
+ export interface ComposedScreen {
17
+ element: SceneElement;
18
+ configuration?: EffectiveConfiguration;
19
+ templates: string[];
20
+ }
21
+ export declare function findLayout(application: ApplicationDocument, name: string, options?: CompositionOptions): Layout | undefined;
22
+ export declare function templatesOf(application: ApplicationDocument, options?: CompositionOptions): ScreenTemplate[];
23
+ export declare function templatePoolFor(application: ApplicationDocument, screen: Screen, options?: CompositionOptions): ScreenTemplate[];
24
+ export declare function templateChainOf(application: ApplicationDocument, screen: Screen, options?: CompositionOptions): ScreenTemplate[];
25
+ export declare function screenContent(application: ApplicationDocument, screen: Screen, options?: CompositionOptions): {
26
+ content: SceneElement[];
27
+ templates: string[];
28
+ slot: string;
29
+ };
30
+ export declare function composeApplicationScreen(application: ApplicationDocument, screen: Screen, options?: CompositionOptions): ComposedScreen;
31
+ export declare function composeOutletScreen(application: ApplicationDocument, screen: Screen, options?: CompositionOptions): SceneElement;
32
+ export declare function composeDialog(application: ApplicationDocument, template: DialogTemplate, options?: CompositionOptions): SceneElement;
33
+ export declare function collectDestinations(application: ApplicationDocument): DestinationReference[];
34
+ //# sourceMappingURL=composeApplication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composeApplication.d.ts","sourceRoot":"","sources":["../../../preview-host/composeApplication.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,oBAAoB,EAAE,cAAc,EAAoB,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,EACrH,KAAK,eAAe,EAAE,KAAK,sBAAsB,EACpD,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACH,iBAAiB,EAAE,cAAc,EACpC,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EAAE,mBAAmB,EAAoB,MAAM,uBAAuB,CAAC;AAM9E,MAAM,WAAW,kBAAkB;IAE/B,OAAO,CAAC,EAAE,SAAS,CAAC;IAGpB,OAAO,CAAC,EAAE,cAAc,CAAC;IAMzB,MAAM,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IAGvE,IAAI,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,YAAY,CAAC;IAGpD,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;IAG1B,QAAQ,CAAC,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CAAC;IAG/C,kBAAkB,C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