camox 0.48.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 (127) 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/layoutContext.d.ts +1 -0
  6. package/dist/core/lib/contentType.js +2 -2
  7. package/dist/core/recordItem.js +3 -3
  8. package/dist/features/canvas/CamoxCanvas.js +15 -15
  9. package/dist/features/canvas/CanvasLoadingScreen.js +15 -11
  10. package/dist/features/canvas/CanvasPageFrame.js +81 -87
  11. package/dist/features/canvas/CanvasPreviewPageSlot.js +1 -1
  12. package/dist/features/canvas/DerivedPagePathInput.js +12 -12
  13. package/dist/features/canvas/canvasOverlayGeometry.js +1 -1
  14. package/dist/features/canvas/canvasStore.js +2 -2
  15. package/dist/features/canvas/sidebar/CanvasInspector.js +1 -1
  16. package/dist/features/canvas/sidebar/CuratedPageInspector.js +1 -1
  17. package/dist/features/canvas/sidebar/LayoutPageBlocks.js +23 -31
  18. package/dist/features/canvas/useCanvasCamera.js +1 -1
  19. package/dist/features/canvas/useDiscoveredPreviewPaths.js +16 -9
  20. package/dist/features/content/ContentAssets.js +84 -88
  21. package/dist/features/page/CuratedPageContent.js +1 -1
  22. package/dist/features/preview/CamoxPreview.d.ts +8 -4
  23. package/dist/features/preview/CamoxPreview.js +258 -443
  24. package/dist/features/preview/EditablePageContent.js +244 -2
  25. package/dist/features/preview/EditablePageExperience.js +19 -13
  26. package/dist/features/preview/components/AddBlockSheet.js +55 -15
  27. package/dist/features/preview/components/BlockActionsPopover.js +23 -51
  28. package/dist/features/preview/components/BlockPeek.js +66 -0
  29. package/dist/features/preview/components/BlockThumbnail.js +134 -119
  30. package/dist/features/preview/components/CanvasPreview.js +1 -1
  31. package/dist/features/preview/components/CreatePageModal.js +150 -156
  32. package/dist/features/preview/components/FieldToolbar.js +1 -1
  33. package/dist/features/preview/components/Frame.js +27 -4
  34. package/dist/features/preview/components/MobilePreviewDrawer.js +6 -9
  35. package/dist/features/preview/components/PageInfo.js +161 -126
  36. package/dist/features/preview/components/PagePicker.js +2 -2
  37. package/dist/features/preview/components/PageTree.js +174 -190
  38. package/dist/features/preview/components/PreviewPanel.js +13 -67
  39. package/dist/features/preview/components/PreviewToolbar.js +1 -1
  40. package/dist/features/preview/components/ReferenceFieldEditor.js +4 -4
  41. package/dist/features/preview/components/ReferenceListFieldEditor.js +4 -4
  42. package/dist/features/preview/components/RemovedBlockPlaceholder.js +37 -70
  43. package/dist/features/preview/components/RepeatableItemsList.js +1 -1
  44. package/dist/features/preview/components/SelectionEditor.js +248 -256
  45. package/dist/features/preview/components/StudioEditingFallback.js +22 -26
  46. package/dist/features/preview/components/useFieldWriter.js +19 -19
  47. package/dist/features/preview/components/useRecordView.js +105 -147
  48. package/dist/features/preview/components/useRepeatableItemActions.js +0 -2
  49. package/dist/features/preview/pageRecord.js +30 -24
  50. package/dist/features/preview/previewConstants.js +2 -8
  51. package/dist/features/preview/previewStore.js +2 -0
  52. package/dist/features/preview/studioNotice.js +20 -0
  53. package/dist/features/preview/usePreviewViewportActions.js +1 -1
  54. package/dist/features/provider/AuthenticatedCamoxProvider.js +47 -31
  55. package/dist/features/provider/components/CommandPalette.js +2 -5
  56. package/dist/features/provider/signInShortcut.js +1 -2
  57. package/dist/features/provider/useAdminShortcuts.js +47 -53
  58. package/dist/features/renderer/RendererApp.js +542 -0
  59. package/dist/features/renderer/RendererFrames.js +450 -0
  60. package/dist/features/renderer/definitionAnswers.js +26 -0
  61. package/dist/features/renderer/protocol.js +35 -0
  62. package/dist/features/renderer/rendererHost.js +249 -0
  63. package/dist/features/renderer/studioConnection.js +186 -0
  64. package/dist/features/routes/pageRuntime.d.ts +2 -1
  65. package/dist/features/routes/pageRuntime.js +34 -22
  66. package/dist/features/runtime/RuntimeChrome.js +2 -5
  67. package/dist/features/runtime/assetPrefix.js +14 -0
  68. package/dist/features/runtime/breadcrumbs.js +1 -1
  69. package/dist/features/runtime/editingFallback.js +4 -8
  70. package/dist/features/runtime/livePages.js +1 -1
  71. package/dist/features/runtime/pageApp.js +57 -83
  72. package/dist/features/runtime/pageClient.js +1 -1
  73. package/dist/features/runtime/pageNavigation.js +3 -2
  74. package/dist/features/runtime/publicCache.js +95 -0
  75. package/dist/features/runtime/publishingDraft.js +23 -0
  76. package/dist/features/runtime/rendererClient.d.ts +8 -0
  77. package/dist/features/runtime/rendererClient.js +77 -0
  78. package/dist/features/runtime/runtime.d.ts +22 -3
  79. package/dist/features/runtime/runtime.js +209 -96
  80. package/dist/features/runtime/runtimeRoutes.d.ts +2 -0
  81. package/dist/features/runtime/runtimeRoutes.js +2 -0
  82. package/dist/features/runtime/worker.d.ts +14 -1
  83. package/dist/features/runtime/worker.js +34 -4
  84. package/dist/features/settings/AnalyticsSettings.js +622 -0
  85. package/dist/features/settings/CamoxSettings.js +95 -0
  86. package/dist/features/settings/FaviconSettings.js +254 -0
  87. package/dist/features/settings/ProjectNameSettings.js +145 -0
  88. package/dist/features/settings/SettingsPart.js +73 -0
  89. package/dist/features/settings/SocialProfilesSettings.js +245 -0
  90. package/dist/features/settings/useProjectMutation.js +61 -0
  91. package/dist/features/studio/FollowAgentProvider.js +10 -10
  92. package/dist/features/studio/components/DraftsControl.js +136 -131
  93. package/dist/features/studio/components/LocalePicker.js +178 -174
  94. package/dist/features/studio/components/Navbar.js +107 -66
  95. package/dist/features/studio/components/ProjectMenu.js +119 -171
  96. package/dist/features/studio/components/ReviewDraftSheet.js +1151 -991
  97. package/dist/features/studio/components/ThreadMessages.js +100 -65
  98. package/dist/features/studio/components/UserButton.js +2 -2
  99. package/dist/features/studio/routes.js +3 -1
  100. package/dist/features/studio/showInCanvas.js +129 -0
  101. package/dist/features/vite/definitionsSync.js +5 -6
  102. package/dist/features/vite/hostedChecks.js +127 -0
  103. package/dist/features/vite/runtimeDev.js +58 -17
  104. package/dist/features/vite/staticAssetHeaders.js +52 -0
  105. package/dist/features/vite/vite.d.ts +1 -1
  106. package/dist/features/vite/vite.js +49 -9
  107. package/dist/hooks/use-page-destinations.js +10 -10
  108. package/dist/lib/api-client-server.d.ts +1 -1
  109. package/dist/lib/api-client.d.ts +2 -1
  110. package/dist/lib/draft-scope.d.ts +1 -0
  111. package/dist/lib/locale-path.d.ts +3 -11
  112. package/dist/lib/locale-path.js +3 -27
  113. package/dist/lib/queries.js +7 -1
  114. package/dist/lib/revisions.js +20 -0
  115. package/dist/lib/shortcuts.js +29 -0
  116. package/dist/lib/studio-definitions.js +160 -0
  117. package/dist/lib/studio-reads.d.ts +1 -0
  118. package/dist/lib/studio-reads.js +65 -21
  119. package/dist/lib/use-project-room.js +16 -10
  120. package/dist/lib/utils.js +1 -104
  121. package/dist/package.js +1 -1
  122. package/dist/studio.css +1 -1
  123. package/package.json +9 -4
  124. package/skills/camox/SKILL.md +4 -0
  125. package/skills/camox/references/artifacts.md +1 -1
  126. package/dist/features/studio/components/FaviconDialog.js +0 -318
  127. package/dist/features/studio/components/SocialProfilesDialog.js +0 -342
@@ -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,33 +1,39 @@
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";
6
+ import { CamoxSettings } from "../settings/CamoxSettings.js";
7
7
  import { c } from "react/compiler-runtime";
8
8
  import { jsx } from "react/jsx-runtime";
9
9
 
10
10
  //#region src/features/preview/EditablePageExperience.tsx
11
+ /** The studio section each studio route shows. */
12
+ const STUDIO_SECTIONS = {
13
+ "studio-content": CamoxContent,
14
+ "studio-settings": CamoxSettings
15
+ };
11
16
  function EditablePageExperience(t0) {
12
- const $ = c(5);
17
+ const $ = c(6);
13
18
  const { input } = t0;
19
+ const StudioSection = input.routeKind && STUDIO_SECTIONS[input.routeKind];
14
20
  let t1;
15
- if ($[0] !== input.canvasOnly || $[1] !== input.derived || $[2] !== input.routeKind || $[3] !== input.runtimeBasePath) {
16
- t1 = /* @__PURE__ */ jsx(AuthenticatedCamoxProvider, { children: /* @__PURE__ */ jsx(CompleteBlockEditingRuntimeProvider, { children: input.routeKind ? /* @__PURE__ */ jsx(CamoxStudio, { children: input.routeKind === "studio-content" ? /* @__PURE__ */ jsx(CamoxContent, {}) : /* @__PURE__ */ jsx("div", {
21
+ if ($[0] !== StudioSection || $[1] !== input.canvasOnly || $[2] !== input.derived || $[3] !== input.routeKind || $[4] !== input.runtimeBasePath) {
22
+ t1 = /* @__PURE__ */ jsx(AuthenticatedCamoxProvider, { children: /* @__PURE__ */ jsx(CompleteBlockEditingRuntimeProvider, { children: input.routeKind ? /* @__PURE__ */ jsx(CamoxStudio, { children: StudioSection ? /* @__PURE__ */ jsx(StudioSection, {}) : /* @__PURE__ */ jsx("div", {
17
23
  className: "text-muted-foreground p-6 text-sm",
18
24
  children: "Studio page not found"
19
25
  }) }) : /* @__PURE__ */ jsx(CamoxPreview, {
20
26
  derived: input.derived,
21
27
  canvasOnly: input.canvasOnly,
22
- runtimeBasePath: input.runtimeBasePath,
23
- children: /* @__PURE__ */ jsx(PageContent, {})
28
+ runtimeBasePath: input.runtimeBasePath
24
29
  }) }) });
25
- $[0] = input.canvasOnly;
26
- $[1] = input.derived;
27
- $[2] = input.routeKind;
28
- $[3] = input.runtimeBasePath;
29
- $[4] = t1;
30
- } else t1 = $[4];
30
+ $[0] = StudioSection;
31
+ $[1] = input.canvasOnly;
32
+ $[2] = input.derived;
33
+ $[3] = input.routeKind;
34
+ $[4] = input.runtimeBasePath;
35
+ $[5] = t1;
36
+ } else t1 = $[5];
31
37
  return t1;
32
38
  }
33
39
 
@@ -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,8 +1,7 @@
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
- import { formatShortcut } from "../../../lib/utils.js";
5
3
  import { blockMutations, repeatableItemMutations } from "../../../lib/queries.js";
4
+ import { formatShortcut } from "../../../lib/shortcuts.js";
6
5
  import { isBlockSelection, previewStore, selectionForPage, selectionItemId } from "../previewStore.js";
7
6
  import { entityName } from "../entityName.js";
8
7
  import { useUpdateBlockPosition } from "./useUpdateBlockPosition.js";
@@ -139,7 +138,7 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
139
138
  children: [/* @__PURE__ */ jsxs("div", {
140
139
  className: "flex items-center gap-2",
141
140
  children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Add block below"]
142
- }), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut({ key: "o" }) })]
141
+ }), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut("O") })]
143
142
  }), /* @__PURE__ */ jsxs(CommandItem, {
144
143
  className: "justify-between",
145
144
  onSelect: () => {
@@ -149,10 +148,7 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
149
148
  children: [/* @__PURE__ */ jsxs("div", {
150
149
  className: "flex items-center gap-2",
151
150
  children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Add block above"]
152
- }), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut({
153
- key: "o",
154
- withShift: true
155
- }) })]
151
+ }), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut("Shift+O") })]
156
152
  })] }),
157
153
  /* @__PURE__ */ jsx(CommandSeparator, {}),
158
154
  /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs(CommandItem, {
@@ -164,10 +160,7 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
164
160
  children: [/* @__PURE__ */ jsxs("div", {
165
161
  className: "flex items-center gap-2",
166
162
  children: [/* @__PURE__ */ jsx(Copy, { className: "h-4 w-4" }), "Duplicate block"]
167
- }), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut({
168
- key: "d",
169
- withMeta: true
170
- }) })]
163
+ }), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut("Mod+D") })]
171
164
  }) }),
172
165
  /* @__PURE__ */ jsx(CommandSeparator, {}),
173
166
  /* @__PURE__ */ jsxs(CommandGroup, { children: [
@@ -196,10 +189,7 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
196
189
  children: [/* @__PURE__ */ jsxs("div", {
197
190
  className: "flex items-center gap-2",
198
191
  children: [/* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }), "Delete block"]
199
- }), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut({
200
- key: "Backspace",
201
- withMeta: true
202
- }) })]
192
+ }), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut("Mod+Backspace") })]
203
193
  })
204
194
  ] })
205
195
  ] })
@@ -235,8 +225,7 @@ function isLayoutBlockId(page, blockId) {
235
225
  return (/* @__PURE__ */ new Set([...page.layout.beforeBlockIds, ...page.layout.afterBlockIds])).has(blockId);
236
226
  }
237
227
  function useBlockActionsShortcuts() {
238
- const $ = c(24);
239
- const camoxApp = useCamoxApp();
228
+ const $ = c(23);
240
229
  const page = usePreviewedPage();
241
230
  const { pageBlocks } = usePageBlocks(page);
242
231
  let t0;
@@ -279,10 +268,7 @@ function useBlockActionsShortcuts() {
279
268
  id: "delete-selected",
280
269
  label: "Delete selected",
281
270
  groupLabel: "Website",
282
- shortcut: {
283
- key: "Backspace",
284
- withMeta: true
285
- },
271
+ shortcut: "Mod+Backspace",
286
272
  checkIfAvailable: () => {
287
273
  const ctx = previewStore.getSnapshot().context;
288
274
  if (ctx.view !== "canvas") return false;
@@ -320,10 +306,7 @@ function useBlockActionsShortcuts() {
320
306
  id: "duplicate-selected",
321
307
  label: "Duplicate selected",
322
308
  groupLabel: "Website",
323
- shortcut: {
324
- key: "d",
325
- withMeta: true
326
- },
309
+ shortcut: "Mod+D",
327
310
  checkIfAvailable: () => {
328
311
  const ctx_0 = previewStore.getSnapshot().context;
329
312
  if (ctx_0.view !== "canvas") return false;
@@ -348,10 +331,7 @@ function useBlockActionsShortcuts() {
348
331
  id: "move-block-up",
349
332
  label: "Move block up",
350
333
  groupLabel: "Website",
351
- shortcut: {
352
- key: "ArrowUp",
353
- withAlt: true
354
- },
334
+ shortcut: "Alt+ArrowUp",
355
335
  checkIfAvailable: () => {
356
336
  const ctx_1 = previewStore.getSnapshot().context;
357
337
  if (ctx_1.view !== "canvas") return false;
@@ -378,10 +358,7 @@ function useBlockActionsShortcuts() {
378
358
  id: "move-block-down",
379
359
  label: "Move block down",
380
360
  groupLabel: "Website",
381
- shortcut: {
382
- key: "ArrowDown",
383
- withAlt: true
384
- },
361
+ shortcut: "Alt+ArrowDown",
385
362
  checkIfAvailable: () => {
386
363
  const ctx_2 = previewStore.getSnapshot().context;
387
364
  if (ctx_2.view !== "canvas") return false;
@@ -409,7 +386,7 @@ function useBlockActionsShortcuts() {
409
386
  id: "add-block-below",
410
387
  label: "Add block below",
411
388
  groupLabel: "Website",
412
- shortcut: { key: "o" },
389
+ shortcut: "O",
413
390
  checkIfAvailable: () => {
414
391
  const ctx_3 = previewStore.getSnapshot().context;
415
392
  if (ctx_3.view !== "canvas") return false;
@@ -430,10 +407,7 @@ function useBlockActionsShortcuts() {
430
407
  id: "add-block-above",
431
408
  label: "Add block above",
432
409
  groupLabel: "Website",
433
- shortcut: {
434
- key: "o",
435
- withShift: true
436
- },
410
+ shortcut: "Shift+O",
437
411
  checkIfAvailable: () => {
438
412
  const ctx_4 = previewStore.getSnapshot().context;
439
413
  if (ctx_4.view !== "canvas") return false;
@@ -473,29 +447,27 @@ function useBlockActionsShortcuts() {
473
447
  $[13] = t5;
474
448
  } else t5 = $[13];
475
449
  let t6;
476
- 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) {
477
451
  t6 = [
478
452
  selection,
479
453
  page,
480
454
  pageBlocks,
481
- camoxApp,
482
455
  deleteBlock,
483
456
  duplicateBlock,
484
457
  updatePosition,
485
458
  deleteRepeatableItem,
486
459
  duplicateRepeatableItem
487
460
  ];
488
- $[14] = camoxApp;
489
- $[15] = deleteBlock;
490
- $[16] = deleteRepeatableItem;
491
- $[17] = duplicateBlock;
492
- $[18] = duplicateRepeatableItem;
493
- $[19] = page;
494
- $[20] = pageBlocks;
495
- $[21] = selection;
496
- $[22] = updatePosition;
497
- $[23] = t6;
498
- } 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];
499
471
  React.useEffect(t5, t6);
500
472
  }
501
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 };