camox 0.51.0 → 0.52.1

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 (91) hide show
  1. package/dist/core/createApp.d.ts +1 -0
  2. package/dist/core/createApp.js +1 -0
  3. package/dist/core/editing/contentEdits.js +78 -0
  4. package/dist/core/editing/createEditableBlock.js +277 -311
  5. package/dist/core/lib/contentType.js +2 -2
  6. package/dist/core/recordItem.js +3 -3
  7. package/dist/features/canvas/CamoxCanvas.js +15 -15
  8. package/dist/features/canvas/CanvasLoadingScreen.js +15 -11
  9. package/dist/features/canvas/CanvasPageFrame.js +81 -87
  10. package/dist/features/canvas/CanvasPreviewPageSlot.js +1 -1
  11. package/dist/features/canvas/DerivedPagePathInput.js +12 -12
  12. package/dist/features/canvas/canvasOverlayGeometry.js +1 -1
  13. package/dist/features/canvas/canvasStore.js +2 -2
  14. package/dist/features/canvas/sidebar/CuratedPageInspector.js +1 -1
  15. package/dist/features/canvas/sidebar/LayoutPageBlocks.js +23 -31
  16. package/dist/features/canvas/useCanvasCamera.js +1 -1
  17. package/dist/features/canvas/useDiscoveredPreviewPaths.js +16 -9
  18. package/dist/features/page/CuratedPageContent.js +1 -1
  19. package/dist/features/preview/CamoxPreview.d.ts +8 -4
  20. package/dist/features/preview/CamoxPreview.js +257 -442
  21. package/dist/features/preview/EditablePageContent.js +244 -2
  22. package/dist/features/preview/EditablePageExperience.js +2 -4
  23. package/dist/features/preview/components/AddBlockSheet.js +55 -15
  24. package/dist/features/preview/components/BlockActionsPopover.js +12 -16
  25. package/dist/features/preview/components/BlockPeek.js +66 -0
  26. package/dist/features/preview/components/BlockThumbnail.js +134 -119
  27. package/dist/features/preview/components/CanvasPreview.js +1 -1
  28. package/dist/features/preview/components/CreatePageModal.js +150 -156
  29. package/dist/features/preview/components/Frame.js +27 -4
  30. package/dist/features/preview/components/MobilePreviewDrawer.js +1 -1
  31. package/dist/features/preview/components/PageInfo.js +161 -126
  32. package/dist/features/preview/components/PagePicker.js +2 -2
  33. package/dist/features/preview/components/PageTree.js +174 -190
  34. package/dist/features/preview/components/PreviewPanel.js +3 -3
  35. package/dist/features/preview/components/ReferenceFieldEditor.js +4 -4
  36. package/dist/features/preview/components/ReferenceListFieldEditor.js +4 -4
  37. package/dist/features/preview/components/RemovedBlockPlaceholder.js +37 -70
  38. package/dist/features/preview/components/RepeatableItemsList.js +1 -1
  39. package/dist/features/preview/components/SelectionEditor.js +248 -256
  40. package/dist/features/preview/components/StudioEditingFallback.js +22 -26
  41. package/dist/features/preview/components/useFieldWriter.js +19 -19
  42. package/dist/features/preview/components/useRecordView.js +105 -147
  43. package/dist/features/preview/components/useRepeatableItemActions.js +0 -2
  44. package/dist/features/preview/pageRecord.js +30 -24
  45. package/dist/features/preview/previewStore.js +2 -0
  46. package/dist/features/preview/studioNotice.js +20 -0
  47. package/dist/features/provider/AuthenticatedCamoxProvider.js +46 -30
  48. package/dist/features/renderer/RendererApp.js +542 -0
  49. package/dist/features/renderer/RendererFrames.js +450 -0
  50. package/dist/features/renderer/definitionAnswers.js +26 -0
  51. package/dist/features/renderer/protocol.js +35 -0
  52. package/dist/features/renderer/rendererHost.js +249 -0
  53. package/dist/features/renderer/studioConnection.js +186 -0
  54. package/dist/features/routes/pageRuntime.js +7 -2
  55. package/dist/features/runtime/RuntimeChrome.js +2 -5
  56. package/dist/features/runtime/assetPrefix.js +14 -0
  57. package/dist/features/runtime/breadcrumbs.js +1 -1
  58. package/dist/features/runtime/editingFallback.js +4 -8
  59. package/dist/features/runtime/livePages.js +1 -1
  60. package/dist/features/runtime/pageApp.js +57 -83
  61. package/dist/features/runtime/pageClient.js +1 -1
  62. package/dist/features/runtime/pageNavigation.js +3 -2
  63. package/dist/features/runtime/publicCache.js +15 -3
  64. package/dist/features/runtime/publishingDraft.js +23 -0
  65. package/dist/features/runtime/rendererClient.d.ts +8 -0
  66. package/dist/features/runtime/rendererClient.js +77 -0
  67. package/dist/features/runtime/runtime.d.ts +9 -0
  68. package/dist/features/runtime/runtime.js +36 -17
  69. package/dist/features/runtime/runtimeRoutes.d.ts +2 -0
  70. package/dist/features/runtime/runtimeRoutes.js +2 -0
  71. package/dist/features/runtime/worker.d.ts +10 -1
  72. package/dist/features/runtime/worker.js +20 -7
  73. package/dist/features/studio/FollowAgentProvider.js +10 -10
  74. package/dist/features/studio/components/ProjectMenu.js +1 -1
  75. package/dist/features/studio/components/ReviewDraftSheet.js +242 -138
  76. package/dist/features/studio/components/ThreadMessages.js +100 -65
  77. package/dist/features/studio/components/UserButton.js +1 -1
  78. package/dist/features/vite/definitionsSync.js +1 -1
  79. package/dist/features/vite/hostedChecks.js +127 -0
  80. package/dist/features/vite/runtimeDev.js +26 -0
  81. package/dist/features/vite/vite.js +33 -5
  82. package/dist/hooks/use-page-destinations.js +10 -10
  83. package/dist/lib/revisions.js +20 -0
  84. package/dist/lib/studio-definitions.js +160 -0
  85. package/dist/lib/studio-reads.js +65 -21
  86. package/dist/lib/use-project-room.js +16 -10
  87. package/dist/package.js +1 -1
  88. package/dist/studio.css +1 -1
  89. package/package.json +8 -4
  90. package/skills/camox/SKILL.md +4 -0
  91. package/skills/camox/references/artifacts.md +1 -1
@@ -1,3 +1,245 @@
1
- import { PageContent } from "./CamoxPreview.js";
1
+ import { useViewLocale } from "../../lib/view-locale-context.js";
2
+ import { useCamoxApp } from "../provider/components/CamoxAppContext.js";
3
+ import { NormalizedDataProvider, usePageBlocks } from "../../lib/normalized-data.js";
4
+ import { reads, useRead } from "../../lib/studio-reads.js";
5
+ import { BlockErrorBoundary } from "./components/BlockErrorBoundary.js";
6
+ import { usePreviewedPage } from "./CamoxPreview.js";
7
+ import { curatedLayoutContext } from "../../core/layoutContext.js";
8
+ import { RemovedBlockPlaceholder } from "./components/RemovedBlockPlaceholder.js";
9
+ import { c } from "react/compiler-runtime";
10
+ import "react";
11
+ import { Fragment, jsx } from "react/jsx-runtime";
2
12
 
3
- export { PageContent as EditablePageContent };
13
+ //#region src/features/preview/EditablePageContent.tsx
14
+ const BlockRenderer = (t0) => {
15
+ const $ = c(28);
16
+ const { blockId, mode, showAddBlockTop, showAddBlockBottom } = t0;
17
+ let t1;
18
+ if ($[0] !== blockId) {
19
+ t1 = reads.blockBundle(blockId);
20
+ $[0] = blockId;
21
+ $[1] = t1;
22
+ } else t1 = $[1];
23
+ const data = useRead(t1);
24
+ const camoxApp = useCamoxApp();
25
+ let t2;
26
+ if ($[2] !== camoxApp || $[3] !== data.block.type) {
27
+ t2 = camoxApp.getBlockById(data.block.type);
28
+ $[2] = camoxApp;
29
+ $[3] = data.block.type;
30
+ $[4] = t2;
31
+ } else t2 = $[4];
32
+ const blockDef = t2;
33
+ if (!blockDef) {
34
+ let t3;
35
+ if ($[5] !== blockId || $[6] !== data.block.type || $[7] !== mode) {
36
+ t3 = /* @__PURE__ */ jsx(RemovedBlockPlaceholder, {
37
+ blockId,
38
+ type: data.block.type,
39
+ mode
40
+ });
41
+ $[5] = blockId;
42
+ $[6] = data.block.type;
43
+ $[7] = mode;
44
+ $[8] = t3;
45
+ } else t3 = $[8];
46
+ return t3;
47
+ }
48
+ const t3 = data.files;
49
+ const t4 = data.repeatableItems;
50
+ let t5;
51
+ if ($[9] !== data.block) {
52
+ t5 = [data.block];
53
+ $[9] = data.block;
54
+ $[10] = t5;
55
+ } else t5 = $[10];
56
+ const T0 = blockDef._internal.Component;
57
+ const t6 = data.block.id;
58
+ const t7 = data.block.type;
59
+ const t8 = data.block.content;
60
+ const t9 = data.block.settings;
61
+ const t10 = String(data.block.position);
62
+ let t11;
63
+ if ($[11] !== data.block.id || $[12] !== data.block.type || $[13] !== t10 || $[14] !== t8 || $[15] !== t9) {
64
+ t11 = {
65
+ _id: t6,
66
+ type: t7,
67
+ content: t8,
68
+ settings: t9,
69
+ position: t10
70
+ };
71
+ $[11] = data.block.id;
72
+ $[12] = data.block.type;
73
+ $[13] = t10;
74
+ $[14] = t8;
75
+ $[15] = t9;
76
+ $[16] = t11;
77
+ } else t11 = $[16];
78
+ let t12;
79
+ if ($[17] !== blockDef._internal.Component || $[18] !== mode || $[19] !== showAddBlockBottom || $[20] !== showAddBlockTop || $[21] !== t11) {
80
+ t12 = /* @__PURE__ */ jsx(T0, {
81
+ blockData: t11,
82
+ mode,
83
+ showAddBlockTop,
84
+ showAddBlockBottom
85
+ });
86
+ $[17] = blockDef._internal.Component;
87
+ $[18] = mode;
88
+ $[19] = showAddBlockBottom;
89
+ $[20] = showAddBlockTop;
90
+ $[21] = t11;
91
+ $[22] = t12;
92
+ } else t12 = $[22];
93
+ let t13;
94
+ if ($[23] !== data.files || $[24] !== data.repeatableItems || $[25] !== t12 || $[26] !== t5) {
95
+ t13 = /* @__PURE__ */ jsx(NormalizedDataProvider, {
96
+ files: t3,
97
+ repeatableItems: t4,
98
+ blocks: t5,
99
+ children: t12
100
+ });
101
+ $[23] = data.files;
102
+ $[24] = data.repeatableItems;
103
+ $[25] = t12;
104
+ $[26] = t5;
105
+ $[27] = t13;
106
+ } else t13 = $[27];
107
+ return t13;
108
+ };
109
+ const EditablePageContent = () => {
110
+ const $ = c(34);
111
+ const pageData = usePreviewedPage();
112
+ const { pageBlocks, beforeBlocks, afterBlocks, layoutFiles, layoutItems } = usePageBlocks(pageData);
113
+ const camoxApp = useCamoxApp();
114
+ const { locale } = useViewLocale();
115
+ let layout;
116
+ let layoutBlocksMap;
117
+ let t0;
118
+ if ($[0] !== afterBlocks || $[1] !== beforeBlocks || $[2] !== camoxApp || $[3] !== pageBlocks || $[4] !== pageData) {
119
+ layout = pageData.layout ? camoxApp.getLayoutById(pageData.layout.layoutId) : void 0;
120
+ let t1;
121
+ bb0: {
122
+ if (!pageData.layout) {
123
+ t1 = null;
124
+ break bb0;
125
+ }
126
+ let blocks;
127
+ if ($[8] !== afterBlocks || $[9] !== beforeBlocks) {
128
+ const allLayoutBlocks = [...beforeBlocks, ...afterBlocks];
129
+ blocks = {};
130
+ for (const block of allLayoutBlocks) blocks[block.type] = {
131
+ _id: block.id,
132
+ type: block.type,
133
+ content: block.content,
134
+ settings: block.settings,
135
+ position: String(block.position)
136
+ };
137
+ $[8] = afterBlocks;
138
+ $[9] = beforeBlocks;
139
+ $[10] = blocks;
140
+ } else blocks = $[10];
141
+ t1 = blocks;
142
+ }
143
+ layoutBlocksMap = t1;
144
+ t0 = pageBlocks.map((blockData, index) => /* @__PURE__ */ jsx(BlockErrorBoundary, {
145
+ blockId: blockData.id,
146
+ blockType: blockData.type,
147
+ children: /* @__PURE__ */ jsx(BlockRenderer, {
148
+ blockId: blockData.id,
149
+ mode: "site",
150
+ showAddBlockTop: index === 0 ? layout?._internal.blockDefinitions.some(_temp) ?? false : true,
151
+ showAddBlockBottom: true
152
+ })
153
+ }, blockData.id));
154
+ $[0] = afterBlocks;
155
+ $[1] = beforeBlocks;
156
+ $[2] = camoxApp;
157
+ $[3] = pageBlocks;
158
+ $[4] = pageData;
159
+ $[5] = layout;
160
+ $[6] = layoutBlocksMap;
161
+ $[7] = t0;
162
+ } else {
163
+ layout = $[5];
164
+ layoutBlocksMap = $[6];
165
+ t0 = $[7];
166
+ }
167
+ let t1;
168
+ if ($[11] !== t0) {
169
+ t1 = /* @__PURE__ */ jsx(Fragment, { children: t0 });
170
+ $[11] = t0;
171
+ $[12] = t1;
172
+ } else t1 = $[12];
173
+ const pageBlocksContent = t1;
174
+ if (layout && layoutBlocksMap) {
175
+ const ToReact = layout._internal.toReact;
176
+ let t2;
177
+ if ($[13] !== afterBlocks || $[14] !== beforeBlocks) {
178
+ t2 = [...beforeBlocks, ...afterBlocks];
179
+ $[13] = afterBlocks;
180
+ $[14] = beforeBlocks;
181
+ $[15] = t2;
182
+ } else t2 = $[15];
183
+ const T0 = layout._internal.Provider;
184
+ let t3;
185
+ if ($[16] !== locale || $[17] !== pageData) {
186
+ t3 = curatedLayoutContext(pageData, locale);
187
+ $[16] = locale;
188
+ $[17] = pageData;
189
+ $[18] = t3;
190
+ } else t3 = $[18];
191
+ let t4;
192
+ if ($[19] !== ToReact || $[20] !== pageBlocksContent || $[21] !== t3) {
193
+ t4 = /* @__PURE__ */ jsx(ToReact, {
194
+ ...t3,
195
+ children: pageBlocksContent
196
+ });
197
+ $[19] = ToReact;
198
+ $[20] = pageBlocksContent;
199
+ $[21] = t3;
200
+ $[22] = t4;
201
+ } else t4 = $[22];
202
+ let t5;
203
+ if ($[23] !== layout._internal.Provider || $[24] !== layoutBlocksMap || $[25] !== t4) {
204
+ t5 = /* @__PURE__ */ jsx(T0, {
205
+ layoutBlocks: layoutBlocksMap,
206
+ children: t4
207
+ });
208
+ $[23] = layout._internal.Provider;
209
+ $[24] = layoutBlocksMap;
210
+ $[25] = t4;
211
+ $[26] = t5;
212
+ } else t5 = $[26];
213
+ let t6;
214
+ if ($[27] !== layoutFiles || $[28] !== layoutItems || $[29] !== t2 || $[30] !== t5) {
215
+ t6 = /* @__PURE__ */ jsx(NormalizedDataProvider, {
216
+ files: layoutFiles,
217
+ repeatableItems: layoutItems,
218
+ blocks: t2,
219
+ children: t5
220
+ });
221
+ $[27] = layoutFiles;
222
+ $[28] = layoutItems;
223
+ $[29] = t2;
224
+ $[30] = t5;
225
+ $[31] = t6;
226
+ } else t6 = $[31];
227
+ return t6;
228
+ }
229
+ let t2;
230
+ if ($[32] !== pageBlocksContent) {
231
+ t2 = /* @__PURE__ */ jsx("main", {
232
+ className: "flex min-h-screen flex-col",
233
+ children: pageBlocksContent
234
+ });
235
+ $[32] = pageBlocksContent;
236
+ $[33] = t2;
237
+ } else t2 = $[33];
238
+ return t2;
239
+ };
240
+ function _temp(b) {
241
+ return b.slot === "before";
242
+ }
243
+
244
+ //#endregion
245
+ export { EditablePageContent };
@@ -1,8 +1,7 @@
1
- import { CamoxPreview, PageContent } from "./CamoxPreview.js";
1
+ import { CamoxPreview } from "./CamoxPreview.js";
2
2
  import { CamoxContent } from "../content/CamoxContent.js";
3
3
  import { AuthenticatedCamoxProvider } from "../provider/AuthenticatedCamoxProvider.js";
4
4
  import { CamoxStudio } from "../studio/CamoxStudio.js";
5
- import "./EditablePageContent.js";
6
5
  import { CompleteBlockEditingRuntimeProvider } from "../../core/editing/CompleteBlockEditingRuntime.js";
7
6
  import { CamoxSettings } from "../settings/CamoxSettings.js";
8
7
  import { c } from "react/compiler-runtime";
@@ -26,8 +25,7 @@ function EditablePageExperience(t0) {
26
25
  }) }) : /* @__PURE__ */ jsx(CamoxPreview, {
27
26
  derived: input.derived,
28
27
  canvasOnly: input.canvasOnly,
29
- runtimeBasePath: input.runtimeBasePath,
30
- children: /* @__PURE__ */ jsx(PageContent, {})
28
+ runtimeBasePath: input.runtimeBasePath
31
29
  }) }) });
32
30
  $[0] = StudioSection;
33
31
  $[1] = input.canvasOnly;
@@ -1,10 +1,11 @@
1
1
  import { useProjectUuid } from "../../../lib/auth.js";
2
- import { useCamoxApp } from "../../provider/components/CamoxAppContext.js";
3
2
  import { usePageBlocks } from "../../../lib/normalized-data.js";
4
3
  import { reads, useReadQuery, useStudioCache } from "../../../lib/studio-reads.js";
5
4
  import { blockMutations } from "../../../lib/queries.js";
5
+ import { useBlockDefinitions } from "../../../lib/studio-definitions.js";
6
6
  import { useLocalePath } from "../../../lib/view-locale.js";
7
7
  import { previewStore, sameEditingOwner } from "../previewStore.js";
8
+ import { useRendererHost } from "../../renderer/RendererFrames.js";
8
9
  import { getGridNavigationIndex } from "./blockGridNavigation.js";
9
10
  import { BlockThumbnail } from "./BlockThumbnail.js";
10
11
  import { usePreviewedPage } from "../CamoxPreview.js";
@@ -103,15 +104,16 @@ const AddBlockSheet = ({ focusCreatedBlock = true }) => {
103
104
  onSettled: (_data, _error, _variables, context) => context?.edit.settle()
104
105
  });
105
106
  const { data: project } = useReadQuery(reads.project({ projectUuid }));
106
- const availableBlocks = useCamoxApp().getBlocks().filter((b) => !b._internal.layoutOnly);
107
+ const rendererHost = useRendererHost();
108
+ const availableBlocks = useBlockDefinitions().filter((block) => !block.layoutOnly);
107
109
  const page = usePreviewedPage();
108
110
  const { pageBlocks } = usePageBlocks(page);
109
111
  const { data: totalCounts = {} } = useReadQuery(reads.blockUsageCounts({ projectId: project?.id ?? 0 }), { enabled: !!project });
110
112
  const filteredBlocks = availableBlocks.map((block) => ({
111
113
  block,
112
- score: search.trim() ? commandFilter(block._internal.id, search.trim(), [block._internal.title, block._internal.description ?? ""]) : 1
113
- })).filter(({ score }) => score > 0).sort((a, b) => b.score - a.score || (totalCounts[b.block._internal.id] ?? 0) - (totalCounts[a.block._internal.id] ?? 0)).map(({ block }) => block);
114
- const selectedValue = filteredBlocks.some((block) => block._internal.id === highlightedValue) ? highlightedValue : filteredBlocks[0]?._internal.id ?? "";
114
+ score: search.trim() ? commandFilter(block.id, search.trim(), [block.title, block.description]) : 1
115
+ })).filter(({ score }) => score > 0).sort((a, b) => b.score - a.score || (totalCounts[b.block.id] ?? 0) - (totalCounts[a.block.id] ?? 0)).map(({ block }) => block);
116
+ const selectedValue = filteredBlocks.some((block) => block.id === highlightedValue) ? highlightedValue : filteredBlocks[0]?.id ?? "";
115
117
  const pageCounts = React.useMemo(() => {
116
118
  const counts = {};
117
119
  if (!page) return counts;
@@ -134,11 +136,15 @@ const AddBlockSheet = ({ focusCreatedBlock = true }) => {
134
136
  pageId: page.page.id
135
137
  };
136
138
  try {
137
- const bundle = block._internal.getInitialBundle();
139
+ const bundle = (rendererHost ? await initialBundleFrom(rendererHost, block.id) : null) ?? {
140
+ content: block.defaultContent,
141
+ settings: block.defaultSettings,
142
+ repeatableItems: []
143
+ };
138
144
  const { id: blockId } = await createBlock.mutateAsync({
139
145
  id: generateUuidv7(),
140
146
  pageId: page.page.id,
141
- type: block._internal.id,
147
+ type: block.id,
142
148
  content: bundle.content,
143
149
  settings: bundle.settings,
144
150
  afterPosition: sheet.afterPosition,
@@ -222,8 +228,8 @@ const AddBlockSheet = ({ focusCreatedBlock = true }) => {
222
228
  ref: gridRef,
223
229
  className: "@container p-0 [&>[cmdk-group-items]]:grid [&>[cmdk-group-items]]:grid-cols-1 [&>[cmdk-group-items]]:gap-4 @xl:[&>[cmdk-group-items]]:grid-cols-2 @3xl:[&>[cmdk-group-items]]:grid-cols-3",
224
230
  children: filteredBlocks.map((block) => /* @__PURE__ */ jsxs(CommandItem, {
225
- value: block._internal.id,
226
- keywords: [block._internal.title, block._internal.description ?? ""],
231
+ value: block.id,
232
+ keywords: [block.title, block.description],
227
233
  disabled: createBlock.isPending,
228
234
  hideCheck: true,
229
235
  onSelect: () => {
@@ -231,7 +237,8 @@ const AddBlockSheet = ({ focusCreatedBlock = true }) => {
231
237
  },
232
238
  className: "group bg-card data-[selected=true]:border-primary flex flex-col items-stretch gap-0 overflow-hidden rounded-lg border-2 p-0",
233
239
  children: [/* @__PURE__ */ jsx(BlockThumbnail, {
234
- block,
240
+ blockType: block.id,
241
+ title: block.title,
235
242
  className: "h-44"
236
243
  }), /* @__PURE__ */ jsxs("div", {
237
244
  className: "border-border flex flex-col gap-1 border-t px-3 py-2",
@@ -239,18 +246,18 @@ const AddBlockSheet = ({ focusCreatedBlock = true }) => {
239
246
  className: "flex items-center justify-between gap-2",
240
247
  children: [/* @__PURE__ */ jsx("span", {
241
248
  className: "min-w-0 leading-5 font-medium",
242
- children: block._internal.title
243
- }), block._internal.synced && /* @__PURE__ */ jsx(Badge, {
249
+ children: block.title
250
+ }), block.synced && /* @__PURE__ */ jsx(Badge, {
244
251
  variant: "secondary",
245
252
  size: "sm",
246
253
  children: "Synced"
247
254
  })]
248
255
  }), /* @__PURE__ */ jsx("span", {
249
256
  className: "text-muted-foreground text-xs leading-4",
250
- children: displayCount(block._internal.id)
257
+ children: displayCount(block.id)
251
258
  })]
252
259
  })]
253
- }, block._internal.id))
260
+ }, block.id))
254
261
  })]
255
262
  })]
256
263
  }),
@@ -269,6 +276,39 @@ const AddBlockSheet = ({ focusCreatedBlock = true }) => {
269
276
  })
270
277
  });
271
278
  };
279
+ /**
280
+ * How long adding a block waits for the renderer frame to give the block's initial content
281
+ * before it uses the synced defaults. A tuning value.
282
+ */
283
+ const INITIAL_BUNDLE_WAIT_MS = 3e3;
284
+ /**
285
+ * The initial content a `blockType` block's code builds, asked of the renderer frame. Null,
286
+ * for the synced defaults, when the renderer runs another SDK version, which answers nothing,
287
+ * or hasn't answered within `INITIAL_BUNDLE_WAIT_MS`, as when it never connects.
288
+ */
289
+ function initialBundleFrom(host, blockType) {
290
+ return new Promise((resolve, reject) => {
291
+ const settle = (bundle) => {
292
+ clearTimeout(timeout);
293
+ stopWatching();
294
+ resolve(bundle);
295
+ };
296
+ const timeout = setTimeout(() => settle(null), INITIAL_BUNDLE_WAIT_MS);
297
+ const watch = () => {
298
+ if (host.status() === "updating") settle(null);
299
+ };
300
+ const stopWatching = host.subscribeStatus(watch);
301
+ watch();
302
+ host.ask({
303
+ type: "initialBundle",
304
+ blockType
305
+ }).then(settle, (error) => {
306
+ clearTimeout(timeout);
307
+ stopWatching();
308
+ reject(error);
309
+ });
310
+ });
311
+ }
272
312
 
273
313
  //#endregion
274
- export { AddBlockSheet };
314
+ export { AddBlockSheet, INITIAL_BUNDLE_WAIT_MS };
@@ -1,5 +1,4 @@
1
1
  import { actionsStore } from "../../provider/actionsStore.js";
2
- import { useCamoxApp } from "../../provider/components/CamoxAppContext.js";
3
2
  import { usePageBlocks } from "../../../lib/normalized-data.js";
4
3
  import { blockMutations, repeatableItemMutations } from "../../../lib/queries.js";
5
4
  import { formatShortcut } from "../../../lib/shortcuts.js";
@@ -226,8 +225,7 @@ function isLayoutBlockId(page, blockId) {
226
225
  return (/* @__PURE__ */ new Set([...page.layout.beforeBlockIds, ...page.layout.afterBlockIds])).has(blockId);
227
226
  }
228
227
  function useBlockActionsShortcuts() {
229
- const $ = c(24);
230
- const camoxApp = useCamoxApp();
228
+ const $ = c(23);
231
229
  const page = usePreviewedPage();
232
230
  const { pageBlocks } = usePageBlocks(page);
233
231
  let t0;
@@ -449,29 +447,27 @@ function useBlockActionsShortcuts() {
449
447
  $[13] = t5;
450
448
  } else t5 = $[13];
451
449
  let t6;
452
- if ($[14] !== camoxApp || $[15] !== deleteBlock || $[16] !== deleteRepeatableItem || $[17] !== duplicateBlock || $[18] !== duplicateRepeatableItem || $[19] !== page || $[20] !== pageBlocks || $[21] !== selection || $[22] !== updatePosition) {
450
+ if ($[14] !== deleteBlock || $[15] !== deleteRepeatableItem || $[16] !== duplicateBlock || $[17] !== duplicateRepeatableItem || $[18] !== page || $[19] !== pageBlocks || $[20] !== selection || $[21] !== updatePosition) {
453
451
  t6 = [
454
452
  selection,
455
453
  page,
456
454
  pageBlocks,
457
- camoxApp,
458
455
  deleteBlock,
459
456
  duplicateBlock,
460
457
  updatePosition,
461
458
  deleteRepeatableItem,
462
459
  duplicateRepeatableItem
463
460
  ];
464
- $[14] = camoxApp;
465
- $[15] = deleteBlock;
466
- $[16] = deleteRepeatableItem;
467
- $[17] = duplicateBlock;
468
- $[18] = duplicateRepeatableItem;
469
- $[19] = page;
470
- $[20] = pageBlocks;
471
- $[21] = selection;
472
- $[22] = updatePosition;
473
- $[23] = t6;
474
- } else t6 = $[23];
461
+ $[14] = deleteBlock;
462
+ $[15] = deleteRepeatableItem;
463
+ $[16] = duplicateBlock;
464
+ $[17] = duplicateRepeatableItem;
465
+ $[18] = page;
466
+ $[19] = pageBlocks;
467
+ $[20] = selection;
468
+ $[21] = updatePosition;
469
+ $[22] = t6;
470
+ } else t6 = $[22];
475
471
  React.useEffect(t5, t6);
476
472
  }
477
473
  function _temp14(a) {
@@ -0,0 +1,66 @@
1
+ import { NormalizedDataProvider } from "../../../lib/normalized-data.js";
2
+ import { c } from "react/compiler-runtime";
3
+ import * as React from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+
6
+ //#region src/features/preview/components/BlockPeek.tsx
7
+ /**
8
+ * A block rendered by its code from its peek bundle: what its thumbnail shows. It catches no
9
+ * error: a broken block shows no thumbnail, which is for the thumbnail to do.
10
+ */
11
+ const BlockPeek = (t0) => {
12
+ const $ = c(13);
13
+ const { block } = t0;
14
+ let t1;
15
+ if ($[0] !== block._internal) {
16
+ t1 = block._internal.getPeekBundle();
17
+ $[0] = block._internal;
18
+ $[1] = t1;
19
+ } else t1 = $[1];
20
+ const bundle = t1;
21
+ const t2 = bundle.block.content;
22
+ const t3 = bundle.block.settings;
23
+ let t4;
24
+ if ($[2] !== block._internal.id || $[3] !== t2 || $[4] !== t3) {
25
+ t4 = {
26
+ _id: "thumbnail",
27
+ type: block._internal.id,
28
+ content: t2,
29
+ settings: t3,
30
+ position: ""
31
+ };
32
+ $[2] = block._internal.id;
33
+ $[3] = t2;
34
+ $[4] = t3;
35
+ $[5] = t4;
36
+ } else t4 = $[5];
37
+ let t5;
38
+ if ($[6] !== block._internal.Component || $[7] !== t4) {
39
+ t5 = /* @__PURE__ */ jsx(block._internal.Component, {
40
+ blockData: t4,
41
+ mode: "peek"
42
+ });
43
+ $[6] = block._internal.Component;
44
+ $[7] = t4;
45
+ $[8] = t5;
46
+ } else t5 = $[8];
47
+ let t6;
48
+ if ($[9] !== bundle.files || $[10] !== bundle.repeatableItems || $[11] !== t5) {
49
+ t6 = /* @__PURE__ */ jsx(React.Suspense, {
50
+ fallback: null,
51
+ children: /* @__PURE__ */ jsx(NormalizedDataProvider, {
52
+ files: bundle.files,
53
+ repeatableItems: bundle.repeatableItems,
54
+ children: t5
55
+ })
56
+ });
57
+ $[9] = bundle.files;
58
+ $[10] = bundle.repeatableItems;
59
+ $[11] = t5;
60
+ $[12] = t6;
61
+ } else t6 = $[12];
62
+ return t6;
63
+ };
64
+
65
+ //#endregion
66
+ export { BlockPeek };