camox 0.9.0 → 0.10.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 (43) hide show
  1. package/dist/core/components/lexical/SidebarLexicalEditor.js +2 -1
  2. package/dist/core/createApp.d.ts +231 -209
  3. package/dist/core/createApp.js +17 -17
  4. package/dist/core/createBlock.d.ts +74 -72
  5. package/dist/core/createBlock.js +274 -267
  6. package/dist/core/createLayout.d.ts +100 -80
  7. package/dist/core/createLayout.js +93 -65
  8. package/dist/features/preview/CamoxPreview.js +76 -54
  9. package/dist/features/preview/components/AddBlockSheet.js +12 -12
  10. package/dist/features/preview/components/AssetFieldEditor.js +1 -1
  11. package/dist/features/preview/components/AssetLightbox.js +1 -1
  12. package/dist/features/preview/components/AssetPickerGrid.js +1 -1
  13. package/dist/features/preview/components/BlockActionsPopover.js +26 -26
  14. package/dist/features/preview/components/BlockErrorBoundary.js +59 -0
  15. package/dist/features/preview/components/{CreatePageSheet.js → CreatePageModal.js} +16 -18
  16. package/dist/features/preview/components/{EditPageSheet.js → EditPageModal.js} +32 -25
  17. package/dist/features/preview/components/Frame.js +1 -1
  18. package/dist/features/preview/components/ItemFieldsEditor.js +134 -98
  19. package/dist/features/preview/components/LinkFieldEditor.js +166 -146
  20. package/dist/features/preview/components/PageContentSheet.js +42 -37
  21. package/dist/features/preview/components/PageLocationFieldset.js +28 -26
  22. package/dist/features/preview/components/PagePicker.js +15 -8
  23. package/dist/features/preview/components/PageTree.js +337 -351
  24. package/dist/features/preview/components/PeekedBlock.js +38 -26
  25. package/dist/features/preview/components/PreviewPanel.js +16 -2
  26. package/dist/features/preview/components/PreviewSideSheet.js +26 -42
  27. package/dist/features/preview/components/RepeatableItemsList.js +7 -7
  28. package/dist/features/preview/previewStore.js +7 -7
  29. package/dist/features/provider/CamoxProvider.js +41 -9
  30. package/dist/features/routes/ogRoute.js +2 -2
  31. package/dist/features/routes/pageRoute.js +1 -1
  32. package/dist/features/studio/components/EnvironmentMenu.js +2 -2
  33. package/dist/features/studio/components/UserButton.js +49 -34
  34. package/dist/features/vite/blockBoilerplate.js +2 -1
  35. package/dist/features/vite/definitionsSync.js +53 -22
  36. package/dist/features/vite/routeGeneration.js +1 -0
  37. package/dist/features/vite/vite.js +51 -7
  38. package/dist/lib/auth.js +6 -4
  39. package/dist/lib/use-project-room.js +25 -13
  40. package/dist/studio-overlays.css +34 -0
  41. package/dist/studio.css +1 -1
  42. package/package.json +4 -4
  43. package/skills/camox-layout/SKILL.md +34 -30
@@ -5,12 +5,13 @@ import { getApiClient } from "../../lib/api-client.js";
5
5
  import { blockQueries, pageQueries, projectQueries } from "../../lib/queries.js";
6
6
  import { formatPathSegment } from "../../lib/utils.js";
7
7
  import { NormalizedDataProvider, seedBlockCaches, usePageBlocks } from "../../lib/normalized-data.js";
8
+ import { BlockErrorBoundary } from "./components/BlockErrorBoundary.js";
8
9
  import { useCamoxApp } from "../provider/components/CamoxAppContext.js";
9
10
  import { Navbar } from "../studio/components/Navbar.js";
10
11
  import { AddBlockSheet } from "./components/AddBlockSheet.js";
11
12
  import { AgentChatSheet } from "./components/AgentChatSheet.js";
12
- import { CreatePageSheet } from "./components/CreatePageSheet.js";
13
- import { EditPageSheet } from "./components/EditPageSheet.js";
13
+ import { CreatePageModal } from "./components/CreatePageModal.js";
14
+ import { EditPageModal } from "./components/EditPageModal.js";
14
15
  import { PageContentSheet } from "./components/PageContentSheet.js";
15
16
  import { PagePicker } from "./components/PagePicker.js";
16
17
  import { PageTree } from "./components/PageTree.js";
@@ -147,7 +148,7 @@ function usePreviewedPage() {
147
148
  $[20] = t9;
148
149
  } else t9 = $[20];
149
150
  const { data: peekedPage } = useQuery(t9);
150
- return peekedPage ?? currentPage;
151
+ return peekedPagePathname ? peekedPage ?? currentPage : currentPage;
151
152
  }
152
153
  function _temp(state) {
153
154
  return state.context.peekedPagePathname;
@@ -174,14 +175,14 @@ const BlockRenderer = (t0) => {
174
175
  if (!blockDef) return null;
175
176
  const t3 = data.files;
176
177
  const t4 = data.repeatableItems;
177
- const T0 = blockDef.Component;
178
- const t5 = String(data.block.id);
178
+ const T0 = blockDef._internal.Component;
179
+ const t5 = data.block.id;
179
180
  const t6 = data.block.type;
180
181
  const t7 = data.block.content;
181
182
  const t8 = data.block.settings;
182
183
  const t9 = String(data.block.position);
183
184
  let t10;
184
- if ($[5] !== data.block.type || $[6] !== t5 || $[7] !== t7 || $[8] !== t8 || $[9] !== t9) {
185
+ if ($[5] !== data.block.id || $[6] !== data.block.type || $[7] !== t7 || $[8] !== t8 || $[9] !== t9) {
185
186
  t10 = {
186
187
  _id: t5,
187
188
  type: t6,
@@ -189,22 +190,22 @@ const BlockRenderer = (t0) => {
189
190
  settings: t8,
190
191
  position: t9
191
192
  };
192
- $[5] = data.block.type;
193
- $[6] = t5;
193
+ $[5] = data.block.id;
194
+ $[6] = data.block.type;
194
195
  $[7] = t7;
195
196
  $[8] = t8;
196
197
  $[9] = t9;
197
198
  $[10] = t10;
198
199
  } else t10 = $[10];
199
200
  let t11;
200
- if ($[11] !== blockDef.Component || $[12] !== mode || $[13] !== showAddBlockBottom || $[14] !== showAddBlockTop || $[15] !== t10) {
201
+ if ($[11] !== blockDef._internal.Component || $[12] !== mode || $[13] !== showAddBlockBottom || $[14] !== showAddBlockTop || $[15] !== t10) {
201
202
  t11 = /* @__PURE__ */ jsx(T0, {
202
203
  blockData: t10,
203
204
  mode,
204
205
  showAddBlockTop,
205
206
  showAddBlockBottom
206
207
  });
207
- $[11] = blockDef.Component;
208
+ $[11] = blockDef._internal.Component;
208
209
  $[12] = mode;
209
210
  $[13] = showAddBlockBottom;
210
211
  $[14] = showAddBlockTop;
@@ -249,7 +250,7 @@ const PageContent = () => {
249
250
  const allLayoutBlocks = [...beforeBlocks, ...afterBlocks];
250
251
  const blocks = {};
251
252
  for (const block_0 of allLayoutBlocks) blocks[block_0.type] = {
252
- _id: String(block_0.id),
253
+ _id: block_0.id,
253
254
  type: block_0.type,
254
255
  content: block_0.content,
255
256
  settings: block_0.settings,
@@ -263,20 +264,24 @@ const PageContent = () => {
263
264
  ]);
264
265
  const pageBlocksContent = /* @__PURE__ */ jsxs(Fragment, { children: [
265
266
  peekedBlockIndex === 0 && pageBlocks.length > 0 && /* @__PURE__ */ jsx(PeekedBlock, { onExitComplete }),
266
- pageBlocks.map((blockData, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsx(BlockRenderer, {
267
+ pageBlocks.map((blockData, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsx(BlockErrorBoundary, {
267
268
  blockId: blockData.id,
268
- mode: "site",
269
- showAddBlockTop: index === 0 ? layout?.blockDefinitions.some((b) => b.placement === "before") ?? false : true,
270
- showAddBlockBottom: true
269
+ blockType: blockData.type,
270
+ children: /* @__PURE__ */ jsx(BlockRenderer, {
271
+ blockId: blockData.id,
272
+ mode: "site",
273
+ showAddBlockTop: index === 0 ? layout?._internal.blockDefinitions.some((b) => b.placement === "before") ?? false : true,
274
+ showAddBlockBottom: true
275
+ })
271
276
  }), index === peekedBlockIndex - 1 && /* @__PURE__ */ jsx(PeekedBlock, { onExitComplete })] }, blockData.id)),
272
277
  pageBlocks.length === 0 && /* @__PURE__ */ jsx(PeekedBlock, { onExitComplete })
273
278
  ] });
274
279
  if (layout && layoutBlocksMap) {
275
- const LayoutComponent = layout.component;
280
+ const LayoutComponent = layout._internal.component;
276
281
  return /* @__PURE__ */ jsx(NormalizedDataProvider, {
277
282
  files: layoutFiles,
278
283
  repeatableItems: layoutItems,
279
- children: /* @__PURE__ */ jsx(layout.Provider, {
284
+ children: /* @__PURE__ */ jsx(layout._internal.Provider, {
280
285
  layoutBlocks: layoutBlocksMap,
281
286
  children: /* @__PURE__ */ jsx(LayoutComponent, { children: pageBlocksContent })
282
287
  })
@@ -298,27 +303,38 @@ const CamoxPreview = (t0) => {
298
303
  let t2;
299
304
  if ($[0] !== isAuthenticated || $[1] !== isPresentationMode) {
300
305
  t1 = () => {
301
- const actions = [{
302
- id: "enter-presentation-mode",
303
- label: "Enter presentation mode",
304
- groupLabel: "Preview",
305
- checkIfAvailable: () => isAuthenticated && !isPresentationMode,
306
- execute: _temp4,
307
- shortcut: {
308
- key: "Enter",
309
- withMeta: true
310
- }
311
- }, {
312
- id: "exit-presentation-mode",
313
- label: "Exit presentation mode",
314
- groupLabel: "Preview",
315
- checkIfAvailable: () => isAuthenticated && isPresentationMode,
316
- execute: _temp5,
317
- shortcut: {
318
- key: "Escape",
319
- withMeta: true
306
+ const actions = [
307
+ {
308
+ id: "enter-presentation-mode",
309
+ label: "Enter presentation mode",
310
+ groupLabel: "Preview",
311
+ checkIfAvailable: () => isAuthenticated && !isPresentationMode,
312
+ execute: _temp4,
313
+ shortcut: {
314
+ key: "Enter",
315
+ withMeta: true
316
+ }
317
+ },
318
+ {
319
+ id: "exit-presentation-mode",
320
+ label: "Exit presentation mode",
321
+ groupLabel: "Preview",
322
+ checkIfAvailable: () => isAuthenticated && isPresentationMode,
323
+ execute: _temp5,
324
+ shortcut: {
325
+ key: "Escape",
326
+ withMeta: true
327
+ }
328
+ },
329
+ {
330
+ id: "clear-selection",
331
+ label: "Clear selection",
332
+ groupLabel: "Preview",
333
+ checkIfAvailable: _temp6,
334
+ execute: _temp7,
335
+ shortcut: { key: "Escape" }
320
336
  }
321
- }];
337
+ ];
322
338
  actionsStore.send({
323
339
  type: "registerManyActions",
324
340
  actions
@@ -326,7 +342,7 @@ const CamoxPreview = (t0) => {
326
342
  return () => {
327
343
  actionsStore.send({
328
344
  type: "unregisterManyActions",
329
- ids: actions.map(_temp6)
345
+ ids: actions.map(_temp8)
330
346
  });
331
347
  };
332
348
  };
@@ -378,7 +394,7 @@ const CamoxPreview = (t0) => {
378
394
  variant: "outline",
379
395
  size: "icon",
380
396
  onClick: () => previewStore.send({
381
- type: "openEditPageSheet",
397
+ type: "openEditPageModal",
382
398
  pageId: pageData.page.id
383
399
  })
384
400
  }),
@@ -429,8 +445,8 @@ const CamoxPreview = (t0) => {
429
445
  t8 = /* @__PURE__ */ jsx(PageContentSheet, {});
430
446
  t9 = /* @__PURE__ */ jsx(AddBlockSheet, {});
431
447
  t10 = /* @__PURE__ */ jsx(AgentChatSheet, {});
432
- t11 = /* @__PURE__ */ jsx(CreatePageSheet, {});
433
- t12 = /* @__PURE__ */ jsx(EditPageSheet, {});
448
+ t11 = /* @__PURE__ */ jsx(CreatePageModal, {});
449
+ t12 = /* @__PURE__ */ jsx(EditPageModal, {});
434
450
  $[21] = t10;
435
451
  $[22] = t11;
436
452
  $[23] = t12;
@@ -502,8 +518,8 @@ function usePreviewPagesActions() {
502
518
  id: "create-page",
503
519
  label: "Create page",
504
520
  groupLabel: "Preview",
505
- checkIfAvailable: _temp7,
506
- execute: _temp8
521
+ checkIfAvailable: _temp9,
522
+ execute: _temp0
507
523
  },
508
524
  {
509
525
  id: "edit-current-page",
@@ -513,7 +529,7 @@ function usePreviewPagesActions() {
513
529
  execute: () => {
514
530
  if (!currentPage) return;
515
531
  previewStore.send({
516
- type: "openEditPageSheet",
532
+ type: "openEditPageModal",
517
533
  pageId: currentPage.id
518
534
  });
519
535
  }
@@ -524,14 +540,14 @@ function usePreviewPagesActions() {
524
540
  groupLabel: "Preview",
525
541
  checkIfAvailable: () => !!pages,
526
542
  hasChildren: true,
527
- execute: _temp9
543
+ execute: _temp1
528
544
  },
529
545
  ...pages ? pages.map((page) => ({
530
546
  id: `go-to-page-${page.id}`,
531
547
  parentActionId: "go-to-page",
532
548
  label: `Go to "${page.metaTitle ?? formatPathSegment(page.pathSegment)}"`,
533
549
  groupLabel: "Preview",
534
- checkIfAvailable: _temp0,
550
+ checkIfAvailable: _temp10,
535
551
  execute: () => navigate({ to: page.fullPath })
536
552
  })) : []
537
553
  ];
@@ -542,7 +558,7 @@ function usePreviewPagesActions() {
542
558
  return () => {
543
559
  actionsStore.send({
544
560
  type: "unregisterManyActions",
545
- ids: actions.map(_temp1)
561
+ ids: actions.map(_temp11)
546
562
  });
547
563
  };
548
564
  };
@@ -562,17 +578,17 @@ function usePreviewPagesActions() {
562
578
  }
563
579
  React.useEffect(t4, t5);
564
580
  }
565
- function _temp1(a) {
581
+ function _temp11(a) {
566
582
  return a.id;
567
583
  }
568
- function _temp0() {
584
+ function _temp10() {
569
585
  return true;
570
586
  }
571
- function _temp9() {}
572
- function _temp8() {
573
- return previewStore.send({ type: "openCreatePageSheet" });
587
+ function _temp1() {}
588
+ function _temp0() {
589
+ return previewStore.send({ type: "openCreatePageModal" });
574
590
  }
575
- function _temp7() {
591
+ function _temp9() {
576
592
  return true;
577
593
  }
578
594
  function _temp2(state) {
@@ -587,7 +603,13 @@ function _temp4() {
587
603
  function _temp5() {
588
604
  return previewStore.send({ type: "exitPresentationMode" });
589
605
  }
590
- function _temp6(a) {
606
+ function _temp6() {
607
+ return true;
608
+ }
609
+ function _temp7() {
610
+ console.log("clear selection");
611
+ }
612
+ function _temp8(a) {
591
613
  return a.id;
592
614
  }
593
615
 
@@ -166,10 +166,10 @@ const AddBlockSheet = () => {
166
166
  t9 = async (block_0) => {
167
167
  if (!page) return;
168
168
  const afterPosition_0 = peekedBlockPosition === "" ? "" : peekedBlockPosition ?? pageBlocks_0[pageBlocks_0.length - 1]?.position;
169
- const bundle = block_0.getInitialBundle();
169
+ const bundle = block_0._internal.getInitialBundle();
170
170
  const { id: blockId } = await createBlock.mutateAsync({
171
171
  pageId: page.page.id,
172
- type: block_0.id,
172
+ type: block_0._internal.id,
173
173
  content: bundle.content,
174
174
  settings: bundle.settings,
175
175
  afterPosition: afterPosition_0,
@@ -177,11 +177,11 @@ const AddBlockSheet = () => {
177
177
  });
178
178
  trackClientEvent("block_added", {
179
179
  projectId: page.page.projectId,
180
- blockType: block_0.id
180
+ blockType: block_0._internal.id
181
181
  });
182
182
  previewStore.send({
183
183
  type: "focusCreatedBlock",
184
- blockId: String(blockId)
184
+ blockId
185
185
  });
186
186
  previewStore.send({ type: "exitPeekedBlock" });
187
187
  };
@@ -209,7 +209,7 @@ const AddBlockSheet = () => {
209
209
  const handlePreviewBlock = t10;
210
210
  const handleValueChange = (value) => {
211
211
  setHighlightedValue(value);
212
- const block_2 = availableBlocks.find((b_2) => b_2.title === value);
212
+ const block_2 = availableBlocks.find((b_2) => b_2._internal.title === value);
213
213
  if (block_2) handlePreviewBlock(block_2);
214
214
  else previewStore.send({ type: "clearPeekedBlock" });
215
215
  };
@@ -274,30 +274,30 @@ const AddBlockSheet = () => {
274
274
  const T3 = CommandGroup;
275
275
  let t22;
276
276
  if ($[33] !== totalCounts) {
277
- t22 = (a, b_3) => (totalCounts[b_3.id] ?? 0) - (totalCounts[a.id] ?? 0);
277
+ t22 = (a, b_3) => (totalCounts[b_3._internal.id] ?? 0) - (totalCounts[a._internal.id] ?? 0);
278
278
  $[33] = totalCounts;
279
279
  $[34] = t22;
280
280
  } else t22 = $[34];
281
281
  let t23;
282
282
  if ($[35] !== displayCount || $[36] !== handleAddBlock) {
283
283
  t23 = (block_3) => /* @__PURE__ */ jsxs(CommandItem, {
284
- value: block_3.title,
284
+ value: block_3._internal.title,
285
285
  onSelect: () => {
286
286
  handleAddBlock(block_3);
287
287
  },
288
288
  className: "group flex items-center justify-between gap-2",
289
- children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", { children: block_3.title }), /* @__PURE__ */ jsx("span", {
289
+ children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", { children: block_3._internal.title }), /* @__PURE__ */ jsx("span", {
290
290
  className: "text-muted-foreground block",
291
- children: displayCount(block_3.id)
291
+ children: displayCount(block_3._internal.id)
292
292
  })] }), /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
293
293
  className: "hidden group-focus-within:flex group-hover:flex",
294
294
  children: /* @__PURE__ */ jsx(InfoIcon, {})
295
295
  }), /* @__PURE__ */ jsx(TooltipContent, {
296
296
  className: "max-w-[300px]",
297
297
  side: "right",
298
- children: block_3.description
298
+ children: block_3._internal.description
299
299
  })] })]
300
- }, block_3.id);
300
+ }, block_3._internal.id);
301
301
  $[35] = displayCount;
302
302
  $[36] = handleAddBlock;
303
303
  $[37] = t23;
@@ -365,7 +365,7 @@ function _temp2(b) {
365
365
  return b != null;
366
366
  }
367
367
  function _temp3(b_1) {
368
- return !b_1.layoutOnly;
368
+ return !b_1._internal.layoutOnly;
369
369
  }
370
370
  function _temp4(state_0) {
371
371
  return state_0.context.isAddBlockSheetOpen;
@@ -194,7 +194,7 @@ const SingleAssetFieldEditor = (t0) => {
194
194
  children: [
195
195
  /* @__PURE__ */ jsxs("button", {
196
196
  type: "button",
197
- className: "flex min-w-0 flex-1 cursor-zoom-in items-center gap-2",
197
+ className: "flex min-w-0 flex-1 cursor-zoom-in items-center gap-2 rounded-sm p-1 focus-visible:outline-2",
198
198
  onClick: () => setLightboxOpen(true),
199
199
  children: [isImage ? /* @__PURE__ */ jsx("div", {
200
200
  className: "border-border h-10 w-10 shrink-0 overflow-hidden rounded border",
@@ -12,9 +12,9 @@ import { jsx, jsxs } from "react/jsx-runtime";
12
12
  import { Button } from "@camox/ui/button";
13
13
  import { Tooltip, TooltipContent, TooltipTrigger } from "@camox/ui/tooltip";
14
14
  import { Check, Download, FileIcon, Link, Loader2, Trash2, X } from "lucide-react";
15
+ import { Dialog, DialogContent, DialogTitle } from "@camox/ui/dialog";
15
16
  import { Switch } from "@camox/ui/switch";
16
17
  import { ButtonGroup } from "@camox/ui/button-group";
17
- import { Dialog, DialogContent, DialogTitle } from "@camox/ui/dialog";
18
18
 
19
19
  //#region src/features/preview/components/AssetLightbox.tsx
20
20
  function MetadataRow(t0) {
@@ -132,7 +132,7 @@ const AssetPickerGrid = (t0) => {
132
132
  let t12;
133
133
  if ($[23] !== t10 || $[24] !== t11) {
134
134
  t12 = /* @__PURE__ */ jsxs("div", {
135
- className: "bg-background sticky top-0 z-10 flex items-center gap-2 px-4 py-4",
135
+ className: "sticky top-0 z-10 flex items-center gap-2 px-4 py-4",
136
136
  children: [t10, t11]
137
137
  });
138
138
  $[23] = t10;
@@ -57,7 +57,7 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
57
57
  };
58
58
  const handleAddBlockAbove = (block_2) => {
59
59
  if (!page) return;
60
- const blockIndex = pageBlocks.findIndex((b) => String(b.id) === String(block_2.id));
60
+ const blockIndex = pageBlocks.findIndex((b) => b.id === block_2.id);
61
61
  const afterPosition = blockIndex > 0 ? pageBlocks[blockIndex - 1].position : "";
62
62
  previewStore.send({
63
63
  type: "openAddBlockSheet",
@@ -72,12 +72,12 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
72
72
  };
73
73
  const getBlocksAbove = (block_4) => {
74
74
  if (!page) return [];
75
- const blockIndex_0 = pageBlocks.findIndex((b_0) => String(b_0.id) === String(block_4.id));
75
+ const blockIndex_0 = pageBlocks.findIndex((b_0) => b_0.id === block_4.id);
76
76
  return pageBlocks.slice(0, blockIndex_0);
77
77
  };
78
78
  const getBlocksBelow = (block_5) => {
79
79
  if (!page) return [];
80
- const blockIndex_1 = pageBlocks.findIndex((b_1) => String(b_1.id) === String(block_5.id));
80
+ const blockIndex_1 = pageBlocks.findIndex((b_1) => b_1.id === block_5.id);
81
81
  return pageBlocks.slice(blockIndex_1 + 1);
82
82
  };
83
83
  const handleDeleteBlocksAbove = async (block_6) => {
@@ -116,7 +116,7 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
116
116
  onSelect: () => {
117
117
  previewStore.send({
118
118
  type: "openBlockContentSheet",
119
- blockId: String(block.id)
119
+ blockId: block.id
120
120
  });
121
121
  onOpenChange(false);
122
122
  },
@@ -129,13 +129,13 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
129
129
  }) })]
130
130
  }), !isLayoutBlock && (() => {
131
131
  const blockDef = camoxApp.getBlockById(block.type);
132
- if (!(blockDef?.settingsSchema?.properties && Object.keys(blockDef.settingsSchema.properties).length > 0)) return null;
132
+ if (!(blockDef?._internal.settingsSchema?.properties && Object.keys(blockDef._internal.settingsSchema.properties).length > 0)) return null;
133
133
  return /* @__PURE__ */ jsx(CommandItem, {
134
134
  className: "justify-between",
135
135
  onSelect: () => {
136
136
  previewStore.send({
137
137
  type: "openBlockContentSheet",
138
- blockId: String(block.id)
138
+ blockId: block.id
139
139
  });
140
140
  onOpenChange(false);
141
141
  },
@@ -270,7 +270,7 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
270
270
  };
271
271
  function isLayoutBlockId(page, blockId) {
272
272
  if (!page?.layout) return false;
273
- return new Set([...page.layout.beforeBlockIds, ...page.layout.afterBlockIds]).has(Number(blockId));
273
+ return new Set([...page.layout.beforeBlockIds, ...page.layout.afterBlockIds]).has(blockId);
274
274
  }
275
275
  function useBlockActionsShortcuts() {
276
276
  const $ = c(17);
@@ -322,13 +322,13 @@ function useBlockActionsShortcuts() {
322
322
  if (!sel) return false;
323
323
  if (isLayoutBlockId(page, sel.blockId)) return false;
324
324
  const itemId = selectionItemId(sel);
325
- if (itemId) {
325
+ if (itemId != null) {
326
326
  if (!page) return false;
327
- const block = pageBlocks.find((b) => String(b.id) === sel.blockId);
327
+ const block = pageBlocks.find((b) => b.id === sel.blockId);
328
328
  if (!block) return false;
329
329
  for (const [, value] of Object.entries(block.content)) {
330
330
  if (!Array.isArray(value)) continue;
331
- if (value.some((i) => i?._itemId != null && String(i._itemId) === itemId)) return value.length > 1;
331
+ if (value.some((i) => i?._itemId === itemId)) return value.length > 1;
332
332
  }
333
333
  return false;
334
334
  }
@@ -338,13 +338,13 @@ function useBlockActionsShortcuts() {
338
338
  const sel_0 = previewStore.getSnapshot().context.selection;
339
339
  if (!sel_0) return;
340
340
  const itemId_0 = selectionItemId(sel_0);
341
- if (itemId_0) {
342
- deleteRepeatableItem.mutateAsync({ id: Number(itemId_0) }).then(_temp2, _temp3);
341
+ if (itemId_0 != null) {
342
+ deleteRepeatableItem.mutateAsync({ id: itemId_0 }).then(_temp2, _temp3);
343
343
  previewStore.send({ type: "selectParent" });
344
344
  return;
345
345
  }
346
- const block_0 = pageBlocks.find((b_0) => String(b_0.id) === sel_0.blockId);
347
- deleteBlockMutation.mutateAsync({ id: Number(sel_0.blockId) }).then(() => toast.success(`Deleted "${block_0?.summary || block_0?.type}" block`), _temp4);
346
+ const block_0 = pageBlocks.find((b_0) => b_0.id === sel_0.blockId);
347
+ deleteBlockMutation.mutateAsync({ id: sel_0.blockId }).then(() => toast.success(`Deleted "${block_0?.summary || block_0?.type}" block`), _temp4);
348
348
  previewStore.send({ type: "clearSelection" });
349
349
  }
350
350
  },
@@ -368,12 +368,12 @@ function useBlockActionsShortcuts() {
368
368
  const sel_2 = previewStore.getSnapshot().context.selection;
369
369
  if (!sel_2) return;
370
370
  const itemId_1 = selectionItemId(sel_2);
371
- if (itemId_1) {
372
- duplicateRepeatableItem.mutateAsync({ id: Number(itemId_1) }).then(_temp5, _temp6);
371
+ if (itemId_1 != null) {
372
+ duplicateRepeatableItem.mutateAsync({ id: itemId_1 }).then(_temp5, _temp6);
373
373
  return;
374
374
  }
375
- const block_1 = pageBlocks.find((b_1) => String(b_1.id) === sel_2.blockId);
376
- duplicateBlockMutation.mutateAsync({ id: Number(sel_2.blockId) }).then(() => toast.success(`Duplicated "${block_1?.summary}" block`), _temp7);
375
+ const block_1 = pageBlocks.find((b_1) => b_1.id === sel_2.blockId);
376
+ duplicateBlockMutation.mutateAsync({ id: sel_2.blockId }).then(() => toast.success(`Duplicated "${block_1?.summary}" block`), _temp7);
377
377
  }
378
378
  },
379
379
  {
@@ -390,17 +390,17 @@ function useBlockActionsShortcuts() {
390
390
  const sel_3 = ctx_1.selection;
391
391
  if (!sel_3 || !page) return false;
392
392
  if (isLayoutBlockId(page, sel_3.blockId)) return false;
393
- return pageBlocks.findIndex((b_2) => String(b_2.id) === sel_3.blockId) > 0;
393
+ return pageBlocks.findIndex((b_2) => b_2.id === sel_3.blockId) > 0;
394
394
  },
395
395
  execute: () => {
396
396
  const sel_4 = previewStore.getSnapshot().context.selection;
397
397
  if (!sel_4 || !page) return;
398
- const index_0 = pageBlocks.findIndex((b_3) => String(b_3.id) === sel_4.blockId);
398
+ const index_0 = pageBlocks.findIndex((b_3) => b_3.id === sel_4.blockId);
399
399
  if (index_0 <= 0) return;
400
400
  const afterPosition = index_0 > 1 ? pageBlocks[index_0 - 2].position : void 0;
401
401
  const beforePosition = pageBlocks[index_0 - 1].position;
402
402
  updatePositionMutation.mutateAsync({
403
- id: Number(sel_4.blockId),
403
+ id: sel_4.blockId,
404
404
  afterPosition,
405
405
  beforePosition
406
406
  }).then(_temp8, _temp9);
@@ -420,18 +420,18 @@ function useBlockActionsShortcuts() {
420
420
  const sel_5 = ctx_2.selection;
421
421
  if (!sel_5 || !page) return false;
422
422
  if (isLayoutBlockId(page, sel_5.blockId)) return false;
423
- const index_1 = pageBlocks.findIndex((b_4) => String(b_4.id) === sel_5.blockId);
423
+ const index_1 = pageBlocks.findIndex((b_4) => b_4.id === sel_5.blockId);
424
424
  return index_1 !== -1 && index_1 < pageBlocks.length - 1;
425
425
  },
426
426
  execute: () => {
427
427
  const sel_6 = previewStore.getSnapshot().context.selection;
428
428
  if (!sel_6 || !page) return;
429
- const index_2 = pageBlocks.findIndex((b_5) => String(b_5.id) === sel_6.blockId);
429
+ const index_2 = pageBlocks.findIndex((b_5) => b_5.id === sel_6.blockId);
430
430
  if (index_2 === -1 || index_2 >= pageBlocks.length - 1) return;
431
431
  const afterPosition_0 = pageBlocks[index_2 + 1].position;
432
432
  const beforePosition_0 = index_2 + 2 < pageBlocks.length ? pageBlocks[index_2 + 2].position : void 0;
433
433
  updatePositionMutation.mutateAsync({
434
- id: Number(sel_6.blockId),
434
+ id: sel_6.blockId,
435
435
  afterPosition: afterPosition_0,
436
436
  beforePosition: beforePosition_0
437
437
  }).then(_temp0, _temp1);
@@ -446,7 +446,7 @@ function useBlockActionsShortcuts() {
446
446
  execute: () => {
447
447
  const sel_7 = previewStore.getSnapshot().context.selection;
448
448
  if (!sel_7 || !page) return;
449
- const block_2 = pageBlocks.find((b_6) => String(b_6.id) === sel_7.blockId);
449
+ const block_2 = pageBlocks.find((b_6) => b_6.id === sel_7.blockId);
450
450
  if (!block_2) return;
451
451
  previewStore.send({
452
452
  type: "openAddBlockSheet",
@@ -466,7 +466,7 @@ function useBlockActionsShortcuts() {
466
466
  execute: () => {
467
467
  const sel_8 = previewStore.getSnapshot().context.selection;
468
468
  if (!sel_8 || !page) return;
469
- const blockIndex = pageBlocks.findIndex((b_7) => String(b_7.id) === sel_8.blockId);
469
+ const blockIndex = pageBlocks.findIndex((b_7) => b_7.id === sel_8.blockId);
470
470
  if (blockIndex === -1) return;
471
471
  const afterPosition_1 = blockIndex > 0 ? pageBlocks[blockIndex - 1].position : "";
472
472
  previewStore.send({
@@ -0,0 +1,59 @@
1
+ import { useIsAuthenticated } from "../../../lib/auth.js";
2
+ import { c } from "react/compiler-runtime";
3
+ import * as React from "react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+
6
+ //#region src/features/preview/components/BlockErrorBoundary.tsx
7
+ var BlockErrorBoundaryInner = class extends React.Component {
8
+ state = { error: null };
9
+ static getDerivedStateFromError(error) {
10
+ return { error };
11
+ }
12
+ componentDidCatch(error, info) {
13
+ console.error(`[camox] Block "${this.props.blockType}" (id=${this.props.blockId}) crashed:`, error, info.componentStack);
14
+ }
15
+ render() {
16
+ if (this.state.error) {
17
+ if (!this.props.isAuthenticated) return null;
18
+ return /* @__PURE__ */ jsxs("div", {
19
+ className: "camox-block-error",
20
+ "data-camox-block-id": this.props.blockId,
21
+ children: [/* @__PURE__ */ jsxs("p", {
22
+ className: "camox-block-error-title",
23
+ children: [
24
+ "Block “",
25
+ this.props.blockType,
26
+ "” failed to render"
27
+ ]
28
+ }), /* @__PURE__ */ jsx("pre", {
29
+ className: "camox-block-error-message",
30
+ children: this.state.error.message
31
+ })]
32
+ });
33
+ }
34
+ return this.props.children;
35
+ }
36
+ };
37
+ const BlockErrorBoundary = (t0) => {
38
+ const $ = c(5);
39
+ const { blockId, blockType, children } = t0;
40
+ const isAuthenticated = useIsAuthenticated();
41
+ let t1;
42
+ if ($[0] !== blockId || $[1] !== blockType || $[2] !== children || $[3] !== isAuthenticated) {
43
+ t1 = /* @__PURE__ */ jsx(BlockErrorBoundaryInner, {
44
+ blockId,
45
+ blockType,
46
+ isAuthenticated,
47
+ children
48
+ });
49
+ $[0] = blockId;
50
+ $[1] = blockType;
51
+ $[2] = children;
52
+ $[3] = isAuthenticated;
53
+ $[4] = t1;
54
+ } else t1 = $[4];
55
+ return t1;
56
+ };
57
+
58
+ //#endregion
59
+ export { BlockErrorBoundary };