camox 0.45.0 → 0.46.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 (39) hide show
  1. package/dist/core/hooks/useArtifactHost.js +2 -2
  2. package/dist/features/canvas/CamoxCanvas.js +438 -771
  3. package/dist/features/canvas/CanvasPageFrame.js +1 -3
  4. package/dist/features/canvas/CanvasPreviewPageSlot.js +26 -6
  5. package/dist/features/canvas/canvasCamera.js +3 -3
  6. package/dist/features/canvas/canvasFrameDocument.js +4 -19
  7. package/dist/features/canvas/canvasItems.js +12 -102
  8. package/dist/features/canvas/canvasStore.js +3 -92
  9. package/dist/features/canvas/sidebar/CanvasNavigator.js +81 -183
  10. package/dist/features/canvas/sidebar/CanvasSidebar.js +22 -28
  11. package/dist/features/canvas/sidebar/CuratedPageInspector.js +2 -2
  12. package/dist/features/canvas/useCanvasCamera.js +0 -20
  13. package/dist/features/canvas/useCanvasFrame.js +5 -6
  14. package/dist/features/preview/CamoxPreview.js +3 -3
  15. package/dist/features/preview/components/{AddBlockDialog.js → AddBlockSheet.js} +35 -32
  16. package/dist/features/preview/components/BlockActionsPopover.js +6 -6
  17. package/dist/features/preview/components/BlockThumbnail.js +31 -33
  18. package/dist/features/preview/components/Overlays.js +1 -1
  19. package/dist/features/preview/components/PageTree.js +1 -1
  20. package/dist/features/preview/components/PreviewPanel.js +1 -1
  21. package/dist/features/preview/previewStore.js +9 -9
  22. package/dist/features/provider/CoreCamoxProvider.js +9 -6
  23. package/dist/features/routes/pageRuntime.js +8 -8
  24. package/dist/features/runtime/runtime.d.ts +2 -7
  25. package/dist/features/runtime/runtime.js +6 -19
  26. package/dist/features/studio/FollowAgentProvider.js +11 -22
  27. package/dist/features/studio/components/FaviconDialog.js +3 -3
  28. package/dist/features/studio/followAgent.js +5 -14
  29. package/dist/features/studio/routes.js +1 -23
  30. package/dist/lib/auth.js +36 -24
  31. package/dist/lib/studio-reads.js +0 -20
  32. package/dist/package.js +1 -1
  33. package/dist/studio.css +1 -1
  34. package/package.json +4 -4
  35. package/skills/camox-expand/SKILL.md +5 -4
  36. package/dist/features/canvas/CanvasBlockFrame.js +0 -353
  37. package/dist/features/canvas/CanvasBlockHeader.js +0 -55
  38. package/dist/features/canvas/CanvasShelfMarker.js +0 -255
  39. package/dist/features/canvas/sidebar/CatalogBlockInspector.js +0 -189
@@ -7,8 +7,8 @@ import { useCamoxApp } from "../provider/components/CamoxAppContext.js";
7
7
  import { reads, useReadQuery, useStudioCache } from "../../lib/studio-reads.js";
8
8
  import { pageMutations } from "../../lib/queries.js";
9
9
  import { useLocalizedPath } from "../../lib/view-locale.js";
10
- import { canvasStore, setShelfCollapsed, useCollapsedShelves } from "./canvasStore.js";
11
- import { STUDIO_CANVAS_PATH, blockCatalogPath, matchBlockCatalogPath } from "../studio/routes.js";
10
+ import { canvasStore } from "./canvasStore.js";
11
+ import { STUDIO_CANVAS_PATH } from "../studio/routes.js";
12
12
  import { previewStore } from "../preview/previewStore.js";
13
13
  import { PREVIEW_PAGE_SLOT_ATTRIBUTE, PreviewPageFrameContext } from "../preview/previewPageFrame.js";
14
14
  import { PreviewPreparationContext } from "../preview/previewPreparation.js";
@@ -18,11 +18,8 @@ import { PageRecordContext, getPageRecord } from "../preview/pageRecord.js";
18
18
  import { CuratedBlockShortcuts } from "../preview/components/PreviewPanel.js";
19
19
  import { FollowAgentContext } from "../studio/followAgentContext.js";
20
20
  import { useCanvasFrameMode } from "./canvasFrameMode.js";
21
- import { useCanvasNearness } from "./useCanvasNearness.js";
22
- import { CanvasBlockFrame } from "./CanvasBlockFrame.js";
23
- import { CanvasBlockHeader } from "./CanvasBlockHeader.js";
24
21
  import { CANVAS_DEVICES, canvasLayoutId, canvasPageId, derivedLayoutIdOf, getCanvasPages } from "./canvasPages.js";
25
- import { CANVAS_SLOT_WIDTH, canvasBlockKey, canvasSnapTargets, getBlockCatalog, getCanvasShelves, getDefaultCollapsedShelves, isCanvasBlock, isCanvasShelfShown, positionCanvasShelves } from "./canvasItems.js";
22
+ import { CANVAS_SLOT_WIDTH, canvasSnapTargets, positionCanvasPages } from "./canvasItems.js";
26
23
  import { CanvasOverlaysShownContext } from "./CanvasOverlays.js";
27
24
  import { CanvasPageEdge } from "./CanvasPageEdge.js";
28
25
  import { CANVAS_THUMBNAIL_MAX_ZOOM, CanvasThumbnailsContext, canvasThumbnailsSupported, createCanvasThumbnails, useCanvasThumbnail } from "./canvasThumbnails.js";
@@ -31,9 +28,9 @@ import { CanvasPageHeader } from "./CanvasPageHeader.js";
31
28
  import { CanvasPreviewPageSlot } from "./CanvasPreviewPageSlot.js";
32
29
  import { CANVAS_WORLD_TRANSFORM, canvasScreenAbove, canvasScreenLength, canvasScreenX } from "./canvasScreenSpace.js";
33
30
  import { selectedCanvasPage } from "./canvasSelection.js";
34
- import { CanvasShelfMarkers } from "./CanvasShelfMarker.js";
35
31
  import { CanvasSidebar } from "./sidebar/CanvasSidebar.js";
36
32
  import { useCanvasCamera } from "./useCanvasCamera.js";
33
+ import { useCanvasNearness } from "./useCanvasNearness.js";
37
34
  import { useDiscoveredPreviewPaths } from "./useDiscoveredPreviewPaths.js";
38
35
  import { c } from "react/compiler-runtime";
39
36
  import * as React from "react";
@@ -98,15 +95,11 @@ var CanvasFrameBoundary = class extends React.Component {
98
95
  if (!this.state.error) return this.props.children;
99
96
  return /* @__PURE__ */ jsxs(CanvasMessage, { children: [/* @__PURE__ */ jsx(PreparationFailure, {
100
97
  error: this.state.error,
101
- selected: this.props.selected ?? false
98
+ selected: this.props.selected
102
99
  }), /* @__PURE__ */ jsxs("div", {
103
100
  role: "alert",
104
101
  children: [
105
- /* @__PURE__ */ jsxs("p", { children: [
106
- "This ",
107
- this.props.subject,
108
- " could not be rendered."
109
- ] }),
102
+ /* @__PURE__ */ jsx("p", { children: "This page could not be rendered." }),
110
103
  /* @__PURE__ */ jsx("p", {
111
104
  className: "mt-2",
112
105
  children: this.state.error.message
@@ -562,84 +555,10 @@ function createCanvasHover() {
562
555
  on: { set: (context, event) => context.pageKey === event.pageKey ? context : { pageKey: event.pageKey } }
563
556
  });
564
557
  }
565
- /** A Block Catalog block's area in the Canvas row, with its frame. */
566
- function CanvasBlockItem(t0) {
567
- const $ = c(24);
568
- const { itemKey, block, projectId, runtimeBasePath, viewport, framed, selected, selectBlock } = t0;
569
- let t1;
570
- if ($[0] !== viewport.width) {
571
- t1 = { width: viewport.width };
572
- $[0] = viewport.width;
573
- $[1] = t1;
574
- } else t1 = $[1];
575
- let t2;
576
- if ($[2] !== block || $[3] !== selectBlock) {
577
- t2 = () => selectBlock(block);
578
- $[2] = block;
579
- $[3] = selectBlock;
580
- $[4] = t2;
581
- } else t2 = $[4];
582
- let t3;
583
- if ($[5] !== block || $[6] !== projectId || $[7] !== runtimeBasePath || $[8] !== selected || $[9] !== t2 || $[10] !== viewport.height || $[11] !== viewport.width) {
584
- t3 = /* @__PURE__ */ jsx(CanvasFrameBoundary, {
585
- subject: "block",
586
- children: /* @__PURE__ */ jsx(CanvasBlockFrame, {
587
- block,
588
- projectId,
589
- runtimeBasePath,
590
- width: viewport.width,
591
- viewportHeight: viewport.height,
592
- selected,
593
- onSelect: t2
594
- })
595
- });
596
- $[5] = block;
597
- $[6] = projectId;
598
- $[7] = runtimeBasePath;
599
- $[8] = selected;
600
- $[9] = t2;
601
- $[10] = viewport.height;
602
- $[11] = viewport.width;
603
- $[12] = t3;
604
- } else t3 = $[12];
605
- let t4;
606
- if ($[13] !== framed) {
607
- t4 = /* @__PURE__ */ jsx(CanvasPageEdge, { shaded: framed });
608
- $[13] = framed;
609
- $[14] = t4;
610
- } else t4 = $[14];
611
- let t5;
612
- if ($[15] !== block._internal.id || $[16] !== t1 || $[17] !== t3 || $[18] !== t4) {
613
- t5 = /* @__PURE__ */ jsxs("div", {
614
- "data-canvas-block": block._internal.id,
615
- className: "bg-background relative shrink-0 shadow-xl ring-1 ring-black/10",
616
- style: t1,
617
- children: [t3, t4]
618
- });
619
- $[15] = block._internal.id;
620
- $[16] = t1;
621
- $[17] = t3;
622
- $[18] = t4;
623
- $[19] = t5;
624
- } else t5 = $[19];
625
- let t6;
626
- if ($[20] !== framed || $[21] !== itemKey || $[22] !== t5) {
627
- t6 = /* @__PURE__ */ jsx(CanvasSlot, {
628
- itemKey,
629
- framed,
630
- children: t5
631
- });
632
- $[20] = framed;
633
- $[21] = itemKey;
634
- $[22] = t5;
635
- $[23] = t6;
636
- } else t6 = $[23];
637
- return t6;
638
- }
639
558
  /** A Page's area in the Canvas row, with its frame. */
640
559
  function CanvasPageItem(t0) {
641
- const $ = c(40);
642
- const { page, pathname, selected, previewed, collapsed, framed, viewport, runtimeBasePath, onActivate, selectPage, hover } = t0;
560
+ const $ = c(39);
561
+ const { page, pathname, selected, previewed, framed, viewport, runtimeBasePath, onActivate, selectPage, hover } = t0;
643
562
  let t1;
644
563
  if ($[0] !== page.key) {
645
564
  t1 = (state) => state.context.pageKey === page.key;
@@ -677,7 +596,7 @@ function CanvasPageItem(t0) {
677
596
  $[10] = t4;
678
597
  } else t4 = $[10];
679
598
  let t5;
680
- if ($[11] !== collapsed || $[12] !== framed || $[13] !== hovered || $[14] !== onPageActivate || $[15] !== page || $[16] !== pathname || $[17] !== previewed || $[18] !== runtimeBasePath || $[19] !== selectPage || $[20] !== selected || $[21] !== viewport) {
599
+ if ($[11] !== framed || $[12] !== hovered || $[13] !== onPageActivate || $[14] !== page || $[15] !== pathname || $[16] !== previewed || $[17] !== runtimeBasePath || $[18] !== selectPage || $[19] !== selected || $[20] !== viewport) {
681
600
  t5 = previewed ? /* @__PURE__ */ jsx(CanvasPreviewPageSlot, {
682
601
  pageId: canvasPageId(page),
683
602
  layoutId: canvasLayoutId(page),
@@ -685,7 +604,6 @@ function CanvasPageItem(t0) {
685
604
  viewportHeight: viewport.height,
686
605
  selected,
687
606
  hovered,
688
- hidden: collapsed,
689
607
  shaded: framed,
690
608
  onActivate: onPageActivate
691
609
  }) : pathname ? /* @__PURE__ */ jsx(CanvasPagePreview, {
@@ -699,39 +617,37 @@ function CanvasPageItem(t0) {
699
617
  onActivate: onPageActivate,
700
618
  onSelect: () => selectPage(pathname)
701
619
  }) : /* @__PURE__ */ jsx(CanvasMessage, { children: "Choose a page path above to preview this layout." });
702
- $[11] = collapsed;
703
- $[12] = framed;
704
- $[13] = hovered;
705
- $[14] = onPageActivate;
706
- $[15] = page;
707
- $[16] = pathname;
708
- $[17] = previewed;
709
- $[18] = runtimeBasePath;
710
- $[19] = selectPage;
711
- $[20] = selected;
712
- $[21] = viewport;
713
- $[22] = t5;
714
- } else t5 = $[22];
620
+ $[11] = framed;
621
+ $[12] = hovered;
622
+ $[13] = onPageActivate;
623
+ $[14] = page;
624
+ $[15] = pathname;
625
+ $[16] = previewed;
626
+ $[17] = runtimeBasePath;
627
+ $[18] = selectPage;
628
+ $[19] = selected;
629
+ $[20] = viewport;
630
+ $[21] = t5;
631
+ } else t5 = $[21];
715
632
  let t6;
716
- if ($[23] !== pathname || $[24] !== selected || $[25] !== t5) {
633
+ if ($[22] !== pathname || $[23] !== selected || $[24] !== t5) {
717
634
  t6 = /* @__PURE__ */ jsx(CanvasFrameBoundary, {
718
- subject: "page",
719
635
  selected,
720
636
  children: t5
721
637
  }, pathname);
722
- $[23] = pathname;
723
- $[24] = selected;
724
- $[25] = t5;
725
- $[26] = t6;
726
- } else t6 = $[26];
638
+ $[22] = pathname;
639
+ $[23] = selected;
640
+ $[24] = t5;
641
+ $[25] = t6;
642
+ } else t6 = $[25];
727
643
  let t7;
728
- if ($[27] !== framed) {
644
+ if ($[26] !== framed) {
729
645
  t7 = /* @__PURE__ */ jsx(CanvasPageEdge, { shaded: framed });
730
- $[27] = framed;
731
- $[28] = t7;
732
- } else t7 = $[28];
646
+ $[26] = framed;
647
+ $[27] = t7;
648
+ } else t7 = $[27];
733
649
  let t8;
734
- if ($[29] !== page.key || $[30] !== pathname || $[31] !== t3 || $[32] !== t4 || $[33] !== t6 || $[34] !== t7) {
650
+ if ($[28] !== page.key || $[29] !== pathname || $[30] !== t3 || $[31] !== t4 || $[32] !== t6 || $[33] !== t7) {
735
651
  t8 = /* @__PURE__ */ jsxs("div", {
736
652
  "data-canvas-page": page.key,
737
653
  "data-canvas-pathname": pathname,
@@ -740,57 +656,28 @@ function CanvasPageItem(t0) {
740
656
  style: t4,
741
657
  children: [t6, t7]
742
658
  });
743
- $[29] = page.key;
744
- $[30] = pathname;
745
- $[31] = t3;
746
- $[32] = t4;
747
- $[33] = t6;
748
- $[34] = t7;
749
- $[35] = t8;
750
- } else t8 = $[35];
659
+ $[28] = page.key;
660
+ $[29] = pathname;
661
+ $[30] = t3;
662
+ $[31] = t4;
663
+ $[32] = t6;
664
+ $[33] = t7;
665
+ $[34] = t8;
666
+ } else t8 = $[34];
751
667
  let t9;
752
- if ($[36] !== framed || $[37] !== page.key || $[38] !== t8) {
668
+ if ($[35] !== framed || $[36] !== page.key || $[37] !== t8) {
753
669
  t9 = /* @__PURE__ */ jsx(CanvasSlot, {
754
670
  itemKey: page.key,
755
671
  framed,
756
672
  children: t8
757
673
  });
758
- $[36] = framed;
759
- $[37] = page.key;
760
- $[38] = t8;
761
- $[39] = t9;
762
- } else t9 = $[39];
674
+ $[35] = framed;
675
+ $[36] = page.key;
676
+ $[37] = t8;
677
+ $[38] = t9;
678
+ } else t9 = $[38];
763
679
  return t9;
764
680
  }
765
- /** A block header with the number of Pages placing the block. */
766
- function CanvasBlockUsageHeader(t0) {
767
- const $ = c(7);
768
- const { projectId, block, onSelect } = t0;
769
- let t1;
770
- if ($[0] !== block._internal.id || $[1] !== projectId) {
771
- t1 = reads.pagesUsingBlock({
772
- projectId,
773
- type: block._internal.id
774
- });
775
- $[0] = block._internal.id;
776
- $[1] = projectId;
777
- $[2] = t1;
778
- } else t1 = $[2];
779
- const t2 = useReadQuery(t1).data?.length;
780
- let t3;
781
- if ($[3] !== block || $[4] !== onSelect || $[5] !== t2) {
782
- t3 = /* @__PURE__ */ jsx(CanvasBlockHeader, {
783
- block,
784
- pageCount: t2,
785
- onSelect
786
- });
787
- $[3] = block;
788
- $[4] = onSelect;
789
- $[5] = t2;
790
- $[6] = t3;
791
- } else t3 = $[6];
792
- return t3;
793
- }
794
681
  /** Gives a Page a new nickname, keeping its path. */
795
682
  function useRenamePage() {
796
683
  const $ = c(4);
@@ -888,8 +775,8 @@ function useWorkspaceThumbnails(workspaceKey) {
888
775
  return thumbnails;
889
776
  }
890
777
  function CanvasWorkspace(t0) {
891
- const $ = c(89);
892
- const { ref, projectId, pages, blocks, selectedPage, selectedBlock, previewedPage, intendedItemKey, runtimeBasePath, viewport, onActivate, onSelectionIntent } = t0;
778
+ const $ = c(44);
779
+ const { ref, pages, selectedPage, previewedPage, intendedPageKey, runtimeBasePath, viewport, onActivate, onSelectionIntent } = t0;
893
780
  const { apiUrl, projectUuid } = useAuthContext();
894
781
  const renamePage = useRenamePage();
895
782
  const location = useLocation();
@@ -915,515 +802,292 @@ function CanvasWorkspace(t0) {
915
802
  $[3] = onSelectionIntent;
916
803
  $[4] = t1;
917
804
  } else t1 = $[4];
918
- const goToItem = t1;
805
+ const goTo = t1;
919
806
  let t2;
920
- if ($[5] !== follow || $[6] !== goToItem) {
807
+ if ($[5] !== follow || $[6] !== goTo) {
921
808
  t2 = (pathname_0) => {
922
809
  follow?.takeOver();
923
- goToItem(pathname_0);
810
+ goTo(pathname_0);
924
811
  };
925
812
  $[5] = follow;
926
- $[6] = goToItem;
813
+ $[6] = goTo;
927
814
  $[7] = t2;
928
815
  } else t2 = $[7];
929
816
  const selectPage = t2;
817
+ const latestSelectPage = React.useRef(selectPage);
930
818
  let t3;
931
- if ($[8] !== localized || $[9] !== selectPage) {
932
- t3 = (block) => selectPage(localized(blockCatalogPath(block._internal.id)));
933
- $[8] = localized;
934
- $[9] = selectPage;
935
- $[10] = t3;
936
- } else t3 = $[10];
937
- const selectBlock = t3;
938
- let t4;
939
- if ($[11] !== selectBlock || $[12] !== selectPage) {
940
- t4 = {
941
- selectPage,
942
- selectBlock
943
- };
944
- $[11] = selectBlock;
945
- $[12] = selectPage;
946
- $[13] = t4;
947
- } else t4 = $[13];
948
- const latestSelect = React.useRef(t4);
949
- let t5;
950
- if ($[14] !== selectBlock || $[15] !== selectPage) {
951
- t5 = () => {
952
- latestSelect.current = {
953
- selectPage,
954
- selectBlock
955
- };
819
+ if ($[8] !== selectPage) {
820
+ t3 = () => {
821
+ latestSelectPage.current = selectPage;
956
822
  };
957
- $[14] = selectBlock;
958
- $[15] = selectPage;
959
- $[16] = t5;
960
- } else t5 = $[16];
961
- React.useLayoutEffect(t5);
962
- let t6;
963
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
964
- t6 = (pathname_1) => latestSelect.current.selectPage(pathname_1);
965
- $[17] = t6;
966
- } else t6 = $[17];
967
- const selectFramePage = t6;
968
- let t7;
969
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
970
- t7 = (block_0) => latestSelect.current.selectBlock(block_0);
971
- $[18] = t7;
972
- } else t7 = $[18];
973
- const selectFrameBlock = t7;
974
- let t8;
975
- if ($[19] !== apiUrl || $[20] !== projectUuid || $[21] !== runtimeBasePath) {
976
- t8 = JSON.stringify([
823
+ $[8] = selectPage;
824
+ $[9] = t3;
825
+ } else t3 = $[9];
826
+ React.useLayoutEffect(t3);
827
+ const selectFramePage = (pathname_1) => latestSelectPage.current(pathname_1);
828
+ let t4;
829
+ if ($[10] !== apiUrl || $[11] !== projectUuid || $[12] !== runtimeBasePath) {
830
+ t4 = JSON.stringify([
977
831
  apiUrl,
978
832
  projectUuid,
979
833
  runtimeBasePath
980
834
  ]);
981
- $[19] = apiUrl;
982
- $[20] = projectUuid;
983
- $[21] = runtimeBasePath;
984
- $[22] = t8;
985
- } else t8 = $[22];
986
- const workspaceKey = t8;
987
- let t9;
988
- if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
989
- t9 = {};
990
- $[23] = t9;
991
- } else t9 = $[23];
992
- const [previewPathnames, setPreviewPathnames] = React.useState(t9);
993
- const shelves = getCanvasShelves(pages, blocks);
994
- let t10;
995
- if ($[24] !== selectedBlock || $[25] !== selectedPage?.key) {
996
- t10 = selectedPage?.key ?? (selectedBlock && canvasBlockKey(selectedBlock._internal.id));
997
- $[24] = selectedBlock;
998
- $[25] = selectedPage?.key;
999
- $[26] = t10;
1000
- } else t10 = $[26];
1001
- const selectedItemKey = t10;
1002
- const collapsedShelves = useCollapsedShelves(workspaceKey, getDefaultCollapsedShelves(shelves), shelves.find((shelf) => shelf.items.some((t11) => {
1003
- const { key } = t11;
1004
- return key === selectedItemKey;
1005
- }))?.key);
1006
- let t12;
1007
- if ($[27] !== collapsedShelves || $[28] !== workspaceKey) {
1008
- t12 = (shelfKey) => setShelfCollapsed(workspaceKey, shelfKey, !collapsedShelves.has(shelfKey));
1009
- $[27] = collapsedShelves;
1010
- $[28] = workspaceKey;
1011
- $[29] = t12;
1012
- } else t12 = $[29];
1013
- const toggleShelf = t12;
1014
- const { items, markers, width } = positionCanvasShelves(shelves, collapsedShelves);
1015
- const positions = new Map(items.map(_temp3));
1016
- const blocksByKey = new Map(items.filter(isCanvasBlock).map(_temp4));
1017
- const pageSlots = new Map(pages.map((page) => [page.key, {
1018
- page,
1019
- left: positions.get(page.key),
1020
- pathname: page.key === selectedPage?.key ? selectedPath : previewedPath && page.key === previewedPage?.key ? previewedPath : previewPathnames[page.key] ?? page.pathname
1021
- }]));
1022
- const selectedKey = selectedItemKey && positions.has(selectedItemKey) ? selectedItemKey : null;
1023
- const hiddenSelectedShelf = shelves.find((shelf_0) => collapsedShelves.has(shelf_0.key) && shelf_0.items.some((t13) => {
1024
- const { key: key_0 } = t13;
1025
- return key_0 === selectedItemKey;
1026
- }))?.key;
835
+ $[10] = apiUrl;
836
+ $[11] = projectUuid;
837
+ $[12] = runtimeBasePath;
838
+ $[13] = t4;
839
+ } else t4 = $[13];
840
+ const workspaceKey = t4;
841
+ let t5;
842
+ if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
843
+ t5 = {};
844
+ $[14] = t5;
845
+ } else t5 = $[14];
846
+ const [previewPathnames, setPreviewPathnames] = React.useState(t5);
847
+ const { items, width } = positionCanvasPages(pages);
848
+ let t6;
849
+ if ($[15] !== previewPathnames || $[16] !== previewedPage?.key || $[17] !== previewedPath || $[18] !== selectedPage?.key || $[19] !== selectedPath) {
850
+ t6 = (t7) => {
851
+ const { key, page, left } = t7;
852
+ return [key, {
853
+ page,
854
+ left,
855
+ pathname: key === selectedPage?.key ? selectedPath : previewedPath && key === previewedPage?.key ? previewedPath : previewPathnames[key] ?? page.pathname
856
+ }];
857
+ };
858
+ $[15] = previewPathnames;
859
+ $[16] = previewedPage?.key;
860
+ $[17] = previewedPath;
861
+ $[18] = selectedPage?.key;
862
+ $[19] = selectedPath;
863
+ $[20] = t6;
864
+ } else t6 = $[20];
865
+ const pageSlots = new Map(items.map(t6));
1027
866
  const framed = viewport.width < CANVAS_SLOT_WIDTH;
1028
867
  const snapTargets = canvasSnapTargets(items);
1029
868
  const snapRingRef = React.useRef(null);
1030
869
  const snapFlash = React.useRef(null);
1031
- let t14;
1032
- if ($[30] !== selectedKey) {
1033
- t14 = (t15) => {
1034
- const { key: key_1 } = t15;
1035
- return key_1 === selectedKey;
870
+ let t7;
871
+ if ($[21] !== selectedPage?.key) {
872
+ t7 = (t8) => {
873
+ const { key: key_0 } = t8;
874
+ return key_0 === selectedPage?.key;
1036
875
  };
1037
- $[30] = selectedKey;
1038
- $[31] = t14;
1039
- } else t14 = $[31];
1040
- let t15;
1041
- if ($[32] !== goToItem || $[33] !== localized) {
1042
- t15 = () => goToItem(localized(STUDIO_CANVAS_PATH));
1043
- $[32] = goToItem;
1044
- $[33] = localized;
1045
- $[34] = t15;
1046
- } else t15 = $[34];
1047
- let t16;
1048
- if ($[35] !== follow) {
1049
- t16 = () => follow?.takeOver();
1050
- $[35] = follow;
1051
- $[36] = t16;
1052
- } else t16 = $[36];
1053
- const { viewportRef, contentRef, flyTo, mirrorCamera, keepInView, reveal, fitAll } = useCanvasCamera(workspaceKey, snapTargets.find(t14), {
876
+ $[21] = selectedPage?.key;
877
+ $[22] = t7;
878
+ } else t7 = $[22];
879
+ let t8;
880
+ if ($[23] !== goTo || $[24] !== localized) {
881
+ t8 = () => goTo(localized(STUDIO_CANVAS_PATH));
882
+ $[23] = goTo;
883
+ $[24] = localized;
884
+ $[25] = t8;
885
+ } else t8 = $[25];
886
+ let t9;
887
+ if ($[26] !== follow) {
888
+ t9 = () => follow?.takeOver();
889
+ $[26] = follow;
890
+ $[27] = t9;
891
+ } else t9 = $[27];
892
+ const { viewportRef, contentRef, flyTo, mirrorCamera, reveal, fitAll } = useCanvasCamera(workspaceKey, snapTargets.find(t7), {
1054
893
  targets: snapTargets,
1055
894
  width,
1056
- onSelect: (key_2) => {
1057
- const block_1 = blocksByKey.get(key_2);
1058
- if (block_1) return selectBlock(block_1);
1059
- const pathname_2 = pageSlots.get(key_2)?.pathname;
895
+ onSelect: (key_1) => {
896
+ const pathname_2 = pageSlots.get(key_1)?.pathname;
1060
897
  if (pathname_2) selectPage(pathname_2);
1061
898
  },
1062
- selected: intendedItemKey && positions.has(intendedItemKey) ? intendedItemKey : null,
1063
- onDeselect: t15,
899
+ selected: intendedPageKey && pageSlots.has(intendedPageKey) ? intendedPageKey : null,
900
+ onDeselect: t8,
1064
901
  onSnap: () => {
1065
902
  snapFlash.current = snapRingRef.current?.animate(SNAP_FLASH_KEYFRAMES, SNAP_FLASH_TIMING) ?? null;
1066
903
  },
1067
904
  onSnapStretched: () => snapFlash.current?.cancel(),
1068
- onEditorMove: t16
905
+ onEditorMove: t9
1069
906
  });
1070
- let t17;
1071
- if ($[37] !== mirrorCamera || $[38] !== reveal || $[39] !== workspaceKey) {
1072
- t17 = {
907
+ let t10;
908
+ if ($[28] !== mirrorCamera || $[29] !== reveal || $[30] !== workspaceKey) {
909
+ t10 = {
1073
910
  workspaceKey,
1074
911
  mirrorCamera,
1075
912
  reveal
1076
913
  };
1077
- $[37] = mirrorCamera;
1078
- $[38] = reveal;
1079
- $[39] = workspaceKey;
1080
- $[40] = t17;
1081
- } else t17 = $[40];
1082
- const workspace = t17;
914
+ $[28] = mirrorCamera;
915
+ $[29] = reveal;
916
+ $[30] = workspaceKey;
917
+ $[31] = t10;
918
+ } else t10 = $[31];
919
+ const workspace = t10;
1083
920
  const thumbnails = useWorkspaceThumbnails(workspaceKey);
1084
- const collapsingShelf = React.useRef(null);
1085
- React.useLayoutEffect(() => {
1086
- const marker = markers.find((t18) => {
1087
- const { key: key_3 } = t18;
1088
- return key_3 === collapsingShelf.current;
1089
- });
1090
- collapsingShelf.current = null;
1091
- if (marker) keepInView(marker.start, 12);
1092
- });
1093
921
  const instructionsId = React.useId();
1094
- const previousPath = React.useRef(selectedPath);
1095
- React.useEffect(() => {
1096
- if (previousPath.current === selectedPath) return;
1097
- if (location.source !== "canvas" && hiddenSelectedShelf) {
1098
- setShelfCollapsed(workspaceKey, hiddenSelectedShelf, false);
1099
- return;
1100
- }
1101
- if (location.source !== "canvas" && !selectedKey) return;
1102
- previousPath.current = selectedPath;
1103
- }, [
1104
- selectedPath,
1105
- location.source,
1106
- selectedKey,
1107
- hiddenSelectedShelf,
1108
- workspaceKey
1109
- ]);
1110
- const [pendingFlight, setPendingFlight] = React.useState(null);
1111
- const pendingFlightPlaced = !!pendingFlight && positions.has(pendingFlight);
1112
- let t19;
1113
- let t20;
1114
- if ($[41] !== flyTo || $[42] !== pendingFlight || $[43] !== pendingFlightPlaced) {
1115
- t19 = () => {
1116
- if (!pendingFlight || !pendingFlightPlaced) return;
1117
- setPendingFlight(null);
1118
- flyTo(pendingFlight);
1119
- };
1120
- t20 = [
1121
- pendingFlight,
1122
- pendingFlightPlaced,
1123
- flyTo
1124
- ];
1125
- $[41] = flyTo;
1126
- $[42] = pendingFlight;
1127
- $[43] = pendingFlightPlaced;
1128
- $[44] = t19;
1129
- $[45] = t20;
1130
- } else {
1131
- t19 = $[44];
1132
- t20 = $[45];
1133
- }
1134
- React.useEffect(t19, t20);
1135
- let t21;
1136
- let t22;
1137
- if ($[46] !== fitAll) {
1138
- t21 = () => {
922
+ let t11;
923
+ let t12;
924
+ if ($[32] !== fitAll) {
925
+ t11 = () => {
1139
926
  let answered = canvasStore.getSnapshot().context.overviewRequests;
1140
- const subscription = canvasStore.subscribe((t23) => {
1141
- const { context } = t23;
927
+ const subscription = canvasStore.subscribe((t13) => {
928
+ const { context } = t13;
1142
929
  if (context.overviewRequests === answered) return;
1143
930
  answered = context.overviewRequests;
1144
931
  fitAll();
1145
932
  });
1146
933
  return () => subscription.unsubscribe();
1147
934
  };
1148
- t22 = [fitAll];
1149
- $[46] = fitAll;
1150
- $[47] = t21;
1151
- $[48] = t22;
935
+ t12 = [fitAll];
936
+ $[32] = fitAll;
937
+ $[33] = t11;
938
+ $[34] = t12;
1152
939
  } else {
1153
- t21 = $[47];
1154
- t22 = $[48];
940
+ t11 = $[33];
941
+ t12 = $[34];
1155
942
  }
1156
- React.useEffect(t21, t22);
943
+ React.useEffect(t11, t12);
1157
944
  React.useImperativeHandle(ref, () => ({
1158
- showItem(key_4) {
1159
- const shelf_1 = shelves.find((candidate) => candidate.items.some((item_1) => item_1.key === key_4));
1160
- const item_2 = shelf_1?.items.find((candidate_0) => candidate_0.key === key_4);
1161
- if (!shelf_1 || !item_2) return;
1162
- const pathname_3 = item_2.kind === "block" ? localized(blockCatalogPath(item_2.block._internal.id)) : pageSlots.get(key_4)?.pathname;
1163
- if (pathname_3 && pathname_3 !== selectedPath) {
1164
- navigate({ to: `${pathname_3}${location.search}${location.hash}` });
945
+ showPage(key_2) {
946
+ const slot = pageSlots.get(key_2);
947
+ if (!slot) return;
948
+ if (slot.pathname && slot.pathname !== selectedPath) {
949
+ navigate({ to: `${slot.pathname}${location.search}${location.hash}` });
1165
950
  return;
1166
951
  }
1167
- if (collapsedShelves.has(shelf_1.key)) toggleShelf(shelf_1.key);
1168
- setPendingFlight(key_4);
952
+ flyTo(key_2);
1169
953
  },
1170
954
  showWholeCanvas() {
1171
955
  selectPage(localized(STUDIO_CANVAS_PATH));
1172
956
  fitAll();
1173
957
  }
1174
958
  }));
1175
- const t23 = "region";
1176
- const t24 = "Page canvas";
1177
- const t25 = 0;
1178
- const t26 = true;
1179
- const t27 = "bg-muted relative min-h-0 min-w-0 flex-1 touch-none overflow-clip outline-none *:*:[--canvas-x:initial] *:*:[--canvas-y:initial] data-[canvas-pan]:cursor-grab data-[canvas-pan]:**:cursor-[inherit]! data-[canvas-pan=dragging]:cursor-grabbing data-[canvas-pan]:[&_iframe]:pointer-events-none";
1180
- let t28;
1181
- if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
1182
- t28 = {
959
+ let t13;
960
+ if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
961
+ t13 = {
1183
962
  userSelect: "none",
1184
963
  overscrollBehavior: "none"
1185
964
  };
1186
- $[49] = t28;
1187
- } else t28 = $[49];
1188
- const t29 = !!intendedItemKey;
1189
- let t30;
1190
- if ($[50] === Symbol.for("react.memo_cache_sentinel")) {
1191
- t30 = {
1192
- gap: 480,
965
+ $[35] = t13;
966
+ } else t13 = $[35];
967
+ let t14;
968
+ if ($[36] === Symbol.for("react.memo_cache_sentinel")) {
969
+ t14 = {
970
+ gap: 240,
1193
971
  transform: CANVAS_WORLD_TRANSFORM,
1194
972
  transformOrigin: "0 0"
1195
973
  };
1196
- $[50] = t30;
1197
- } else t30 = $[50];
1198
- const t31 = shelves.map((shelf_2) => {
1199
- if (!isCanvasShelfShown(shelf_2)) return null;
1200
- const collapsed = collapsedShelves.has(shelf_2.key) || shelf_2.items.length === 0;
1201
- return /* @__PURE__ */ jsx("div", {
1202
- "data-canvas-shelf": shelf_2.key,
1203
- inert: collapsed,
1204
- className: `flex shrink-0 items-start ${collapsed ? "invisible w-0" : ""}`,
1205
- style: { gap: 240 },
1206
- children: (collapsed && shelf_2.unmountedWhenCollapsed ? [] : shelf_2.items).map((item_3) => {
1207
- if (item_3.kind === "block") return /* @__PURE__ */ jsx(CanvasBlockItem, {
1208
- itemKey: item_3.key,
1209
- block: item_3.block,
1210
- projectId,
1211
- runtimeBasePath,
1212
- viewport,
1213
- framed,
1214
- selected: item_3.block._internal.id === selectedBlock?._internal.id,
1215
- selectBlock: selectFrameBlock
1216
- }, item_3.key);
1217
- const slot = pageSlots.get(item_3.key);
1218
- if (!slot) return null;
1219
- const { page: page_0, pathname: pathname_4 } = slot;
1220
- return /* @__PURE__ */ jsx(CanvasPageItem, {
1221
- page: page_0,
1222
- pathname: pathname_4,
1223
- selected: page_0.key === selectedPage?.key,
1224
- hover,
1225
- previewed: !!previewPageFrame && page_0.key === previewedPage?.key && pathname_4 === previewedPath,
1226
- collapsed,
1227
- framed,
1228
- viewport,
1229
- runtimeBasePath,
1230
- onActivate,
1231
- selectPage: selectFramePage
1232
- }, page_0.key);
1233
- })
1234
- }, shelf_2.key);
1235
- });
1236
- let t32;
1237
- if ($[51] !== contentRef || $[52] !== t31) {
1238
- t32 = /* @__PURE__ */ jsx("div", {
1239
- ref: contentRef,
1240
- "data-canvas-items": true,
1241
- className: "absolute top-0 left-0 flex w-max items-start in-data-[canvas-promoted]:will-change-transform",
1242
- style: t30,
1243
- children: t31
1244
- });
1245
- $[51] = contentRef;
1246
- $[52] = t31;
1247
- $[53] = t32;
1248
- } else t32 = $[53];
1249
- let t33;
1250
- if ($[54] !== t29 || $[55] !== t32) {
1251
- t33 = /* @__PURE__ */ jsx(CanvasOverlaysShownContext, {
1252
- value: t29,
1253
- children: t32
1254
- });
1255
- $[54] = t29;
1256
- $[55] = t32;
1257
- $[56] = t33;
1258
- } else t33 = $[56];
1259
- let t34;
1260
- if ($[57] !== t33 || $[58] !== thumbnails) {
1261
- t34 = /* @__PURE__ */ jsx(CanvasThumbnailsContext, {
1262
- value: thumbnails,
1263
- children: t33
1264
- });
1265
- $[57] = t33;
1266
- $[58] = thumbnails;
1267
- $[59] = t34;
1268
- } else t34 = $[59];
1269
- let t35;
1270
- if ($[60] !== t34 || $[61] !== workspace) {
1271
- t35 = /* @__PURE__ */ jsx(CanvasWorkspaceContext, {
1272
- value: workspace,
1273
- children: t34
1274
- });
1275
- $[60] = t34;
1276
- $[61] = workspace;
1277
- $[62] = t35;
1278
- } else t35 = $[62];
1279
- let t36;
1280
- if ($[63] !== toggleShelf) {
1281
- t36 = (marker_0) => {
1282
- if (!marker_0.collapsed) collapsingShelf.current = marker_0.key;
1283
- toggleShelf(marker_0.key);
1284
- };
1285
- $[63] = toggleShelf;
1286
- $[64] = t36;
1287
- } else t36 = $[64];
1288
- let t37;
1289
- if ($[65] !== markers || $[66] !== t36) {
1290
- t37 = /* @__PURE__ */ jsx(CanvasShelfMarkers, {
1291
- markers,
1292
- onToggle: t36
1293
- });
1294
- $[65] = markers;
1295
- $[66] = t36;
1296
- $[67] = t37;
1297
- } else t37 = $[67];
1298
- const t39 = [...pageSlots.values()].map((t38) => {
1299
- const { page: page_1, pathname: pathname_5, left } = t38;
1300
- return left === void 0 ? null : /* @__PURE__ */ jsx(CanvasHeaderSlot, {
1301
- itemKey: page_1.key,
1302
- left,
1303
- children: /* @__PURE__ */ jsx(CanvasPageHeader, {
1304
- page: page_1,
1305
- pathname: pathname_5,
1306
- onRename: page_1.kind === "curated" ? (nickname) => renamePage(page_1.pageId, nickname) : void 0,
1307
- selected: page_1.key === selectedPage?.key,
1308
- onHoverChange: (hovered) => hover.send({
1309
- type: "set",
1310
- pageKey: hovered ? page_1.key : null
1311
- }),
1312
- onSelect: () => {
1313
- if (!pathname_5) return;
1314
- selectPage(pathname_5);
1315
- },
1316
- onChange: (path) => {
1317
- const inLocale = localized(path);
1318
- setPreviewPathnames((current) => ({
1319
- ...current,
1320
- [page_1.key]: inLocale
1321
- }));
1322
- selectPage(inLocale);
1323
- }
1324
- })
1325
- }, page_1.key);
1326
- });
1327
- let t40;
1328
- if ($[68] !== projectId || $[69] !== selectBlock) {
1329
- t40 = (t41) => {
1330
- const { key: key_5, left: left_0, block: block_2 } = t41;
1331
- return /* @__PURE__ */ jsx(CanvasHeaderSlot, {
1332
- itemKey: key_5,
1333
- left: left_0,
1334
- children: /* @__PURE__ */ jsx(CanvasBlockUsageHeader, {
1335
- projectId,
1336
- block: block_2,
1337
- onSelect: () => selectBlock(block_2)
1338
- })
1339
- }, key_5);
1340
- };
1341
- $[68] = projectId;
1342
- $[69] = selectBlock;
1343
- $[70] = t40;
1344
- } else t40 = $[70];
1345
- const t41 = items.filter(isCanvasBlock).map(t40);
1346
- let t42;
1347
- if ($[71] !== pages.length) {
1348
- t42 = !pages.length && /* @__PURE__ */ jsx(CanvasMessage, { children: "No pages to preview yet." });
1349
- $[71] = pages.length;
1350
- $[72] = t42;
1351
- } else t42 = $[72];
1352
- let t43;
1353
- if ($[73] !== instructionsId) {
1354
- t43 = /* @__PURE__ */ jsx("p", {
974
+ $[36] = t14;
975
+ } else t14 = $[36];
976
+ let t17;
977
+ if ($[37] !== pages.length) {
978
+ t17 = !pages.length && /* @__PURE__ */ jsx(CanvasMessage, { children: "No pages to preview yet." });
979
+ $[37] = pages.length;
980
+ $[38] = t17;
981
+ } else t17 = $[38];
982
+ let t18;
983
+ if ($[39] !== instructionsId) {
984
+ t18 = /* @__PURE__ */ jsx("p", {
1355
985
  id: instructionsId,
1356
986
  className: "sr-only",
1357
987
  children: "Scroll, or hold Space and drag, to pan. Pinch or Ctrl/⌘ + scroll to zoom. Click a page to edit it. Focus the canvas and use plus or minus to zoom, arrow keys to pan, 0 for 100%, or Home / Shift+1 to fit all pages."
1358
988
  });
1359
- $[73] = instructionsId;
1360
- $[74] = t43;
1361
- } else t43 = $[74];
1362
- let t44;
1363
- if ($[75] === Symbol.for("react.memo_cache_sentinel")) {
1364
- t44 = { zIndex: 2 };
1365
- $[75] = t44;
1366
- } else t44 = $[75];
1367
- let t45;
1368
- if ($[76] !== snapRingRef) {
1369
- t45 = /* @__PURE__ */ jsx("div", {
989
+ $[39] = instructionsId;
990
+ $[40] = t18;
991
+ } else t18 = $[40];
992
+ let t19;
993
+ if ($[41] === Symbol.for("react.memo_cache_sentinel")) {
994
+ t19 = { zIndex: 2 };
995
+ $[41] = t19;
996
+ } else t19 = $[41];
997
+ let t20;
998
+ if ($[42] !== snapRingRef) {
999
+ t20 = /* @__PURE__ */ jsx("div", {
1370
1000
  ref: snapRingRef,
1371
1001
  "aria-hidden": true,
1372
1002
  "data-canvas-snap-ring": true,
1373
1003
  className: "ring-primary pointer-events-none absolute inset-0 opacity-0 ring-3 ring-inset",
1374
- style: t44
1375
- });
1376
- $[76] = snapRingRef;
1377
- $[77] = t45;
1378
- } else t45 = $[77];
1379
- let t46;
1380
- if ($[78] !== instructionsId || $[79] !== t28 || $[80] !== t35 || $[81] !== t37 || $[82] !== t39 || $[83] !== t41 || $[84] !== t42 || $[85] !== t43 || $[86] !== t45 || $[87] !== viewportRef) {
1381
- t46 = /* @__PURE__ */ jsxs("div", {
1382
- ref: viewportRef,
1383
- role: t23,
1384
- "aria-label": t24,
1385
- "aria-describedby": instructionsId,
1386
- tabIndex: t25,
1387
- "data-camox-canvas": t26,
1388
- className: t27,
1389
- style: t28,
1390
- children: [
1391
- t35,
1392
- t37,
1393
- t39,
1394
- t41,
1395
- t42,
1396
- t43,
1397
- t45
1398
- ]
1004
+ style: t19
1399
1005
  });
1400
- $[78] = instructionsId;
1401
- $[79] = t28;
1402
- $[80] = t35;
1403
- $[81] = t37;
1404
- $[82] = t39;
1405
- $[83] = t41;
1406
- $[84] = t42;
1407
- $[85] = t43;
1408
- $[86] = t45;
1409
- $[87] = viewportRef;
1410
- $[88] = t46;
1411
- } else t46 = $[88];
1412
- return t46;
1413
- }
1414
- function _temp4(item_0) {
1415
- return [item_0.key, item_0.block];
1416
- }
1417
- function _temp3(item) {
1418
- return [item.key, item.left];
1006
+ $[42] = snapRingRef;
1007
+ $[43] = t20;
1008
+ } else t20 = $[43];
1009
+ return /* @__PURE__ */ jsxs("div", {
1010
+ ref: viewportRef,
1011
+ role: "region",
1012
+ "aria-label": "Page canvas",
1013
+ "aria-describedby": instructionsId,
1014
+ tabIndex: 0,
1015
+ "data-camox-canvas": true,
1016
+ className: "bg-muted relative min-h-0 min-w-0 flex-1 touch-none overflow-clip outline-none *:*:[--canvas-x:initial] *:*:[--canvas-y:initial] data-[canvas-pan]:cursor-grab data-[canvas-pan]:**:cursor-[inherit]! data-[canvas-pan=dragging]:cursor-grabbing data-[canvas-pan]:[&_iframe]:pointer-events-none",
1017
+ style: t13,
1018
+ children: [
1019
+ /* @__PURE__ */ jsx(CanvasWorkspaceContext, {
1020
+ value: workspace,
1021
+ children: /* @__PURE__ */ jsx(CanvasThumbnailsContext, {
1022
+ value: thumbnails,
1023
+ children: /* @__PURE__ */ jsx(CanvasOverlaysShownContext, {
1024
+ value: !!intendedPageKey,
1025
+ children: /* @__PURE__ */ jsx("div", {
1026
+ ref: contentRef,
1027
+ "data-canvas-items": true,
1028
+ className: "absolute top-0 left-0 flex w-max items-start in-data-[canvas-promoted]:will-change-transform",
1029
+ style: t14,
1030
+ children: [...pageSlots.values()].map((t15) => {
1031
+ const { page: page_0, pathname: pathname_3 } = t15;
1032
+ return /* @__PURE__ */ jsx(CanvasPageItem, {
1033
+ page: page_0,
1034
+ pathname: pathname_3,
1035
+ selected: page_0.key === selectedPage?.key,
1036
+ hover,
1037
+ previewed: !!previewPageFrame && page_0.key === previewedPage?.key && pathname_3 === previewedPath,
1038
+ framed,
1039
+ viewport,
1040
+ runtimeBasePath,
1041
+ onActivate,
1042
+ selectPage: selectFramePage
1043
+ }, page_0.key);
1044
+ })
1045
+ })
1046
+ })
1047
+ })
1048
+ }),
1049
+ [...pageSlots.values()].map((t16) => {
1050
+ const { page: page_1, pathname: pathname_4, left: left_0 } = t16;
1051
+ return /* @__PURE__ */ jsx(CanvasHeaderSlot, {
1052
+ itemKey: page_1.key,
1053
+ left: left_0,
1054
+ children: /* @__PURE__ */ jsx(CanvasPageHeader, {
1055
+ page: page_1,
1056
+ pathname: pathname_4,
1057
+ onRename: page_1.kind === "curated" ? (nickname) => renamePage(page_1.pageId, nickname) : void 0,
1058
+ selected: page_1.key === selectedPage?.key,
1059
+ onHoverChange: (hovered) => hover.send({
1060
+ type: "set",
1061
+ pageKey: hovered ? page_1.key : null
1062
+ }),
1063
+ onSelect: () => {
1064
+ if (!pathname_4) return;
1065
+ selectPage(pathname_4);
1066
+ },
1067
+ onChange: (path) => {
1068
+ const inLocale = localized(path);
1069
+ setPreviewPathnames((current) => ({
1070
+ ...current,
1071
+ [page_1.key]: inLocale
1072
+ }));
1073
+ selectPage(inLocale);
1074
+ }
1075
+ })
1076
+ }, page_1.key);
1077
+ }),
1078
+ t17,
1079
+ t18,
1080
+ t20
1081
+ ]
1082
+ });
1419
1083
  }
1420
1084
  function CamoxCanvas(t0) {
1421
- const $ = c(60);
1085
+ const $ = c(68);
1422
1086
  const { runtimeBasePath } = t0;
1423
1087
  const app = useCamoxApp();
1424
1088
  const renamePage = useRenamePage();
1425
1089
  const location = useLocation();
1426
- const viewportMode = useSelector(previewStore, _temp5);
1090
+ const viewportMode = useSelector(previewStore, _temp3);
1427
1091
  const viewport = CANVAS_DEVICES[viewportMode === "full" ? "desktop" : viewportMode];
1428
1092
  const [activeFrame, setActiveFrame] = React.useState(null);
1429
1093
  const selectedPath = location.pathname;
@@ -1453,7 +1117,7 @@ function CamoxCanvas(t0) {
1453
1117
  t3 = [];
1454
1118
  $[4] = t3;
1455
1119
  } else t3 = $[4];
1456
- React.useEffect(_temp7, t3);
1120
+ React.useEffect(_temp5, t3);
1457
1121
  const projectUuid = useProjectUuid();
1458
1122
  let t4;
1459
1123
  if ($[5] !== projectUuid) {
@@ -1479,74 +1143,92 @@ function CamoxCanvas(t0) {
1479
1143
  const discoveredPaths = useDiscoveredPreviewPaths(runtimeBasePath);
1480
1144
  const viewLocale = useViewLocale();
1481
1145
  const canvasPages = pages.data ? getCanvasPages(pages.data, app.getLayouts(), discoveredPaths, viewLocale.locale) : [];
1482
- const selectionAt = (runtimePath) => {
1483
- const pathname = parseLocalePath(runtimePath, viewLocale.locales).path;
1484
- if (pathname === "/camox/canvas") return {};
1485
- const blockId = matchBlockCatalogPath(pathname);
1486
- if (!blockId) return { page: selectedCanvasPage(canvasPages, app.getLayouts(), runtimePath, viewLocale.locales) };
1487
- const block = app.getBlockById(blockId);
1488
- return { block: block && !block._internal.layoutOnly ? block : void 0 };
1489
- };
1490
- const { page: selectedPage, block: selectedBlock } = selectionAt(location.pathname);
1146
+ let t8;
1147
+ if ($[11] !== viewLocale.locales) {
1148
+ t8 = (runtimePath) => parseLocalePath(runtimePath, viewLocale.locales).path === STUDIO_CANVAS_PATH;
1149
+ $[11] = viewLocale.locales;
1150
+ $[12] = t8;
1151
+ } else t8 = $[12];
1152
+ const isCanvasPath = t8;
1153
+ const pageAt = (runtimePath_0) => isCanvasPath(runtimePath_0) ? void 0 : selectedCanvasPage(canvasPages, app.getLayouts(), runtimePath_0, viewLocale.locales);
1154
+ const selectedPage = pageAt(location.pathname);
1491
1155
  const previewedPath = React.use(PreviewPageFrameContext)?.pathname;
1492
- const previewedPage = previewedPath ? selectionAt(previewedPath).page : void 0;
1156
+ const previewedPage = previewedPath ? pageAt(previewedPath) : void 0;
1493
1157
  const [intent, setIntent] = React.useState(null);
1494
1158
  if (intent && intent.from !== location.pathname) setIntent(null);
1495
1159
  const intended = intent?.from === location.pathname ? intent.to : location;
1496
- const intendedSelection = selectionAt(intended.pathname);
1160
+ const intendedPage = pageAt(intended.pathname);
1497
1161
  const navigate = useNavigate();
1498
1162
  const workspace = React.useRef(null);
1499
- let t8;
1500
- if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
1501
- t8 = { enabled: false };
1502
- $[11] = t8;
1503
- } else t8 = $[11];
1163
+ let t9;
1164
+ if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
1165
+ t9 = { enabled: false };
1166
+ $[13] = t9;
1167
+ } else t9 = $[13];
1504
1168
  const { data: intendedFrameInput } = useReadQuery(reads.canvasFrame({
1505
1169
  projectUuid,
1506
1170
  runtimeBasePath,
1507
1171
  pathname: intended.pathname,
1508
- derivedLayoutId: derivedLayoutIdOf(intendedSelection.page)
1509
- }), t8);
1510
- const recordResult = derivedLayoutIdOf(intendedSelection.page) ? intendedFrameInput?.derived?.result : void 0;
1511
- let t9;
1512
- if ($[12] !== recordResult) {
1513
- t9 = getPageRecord(recordResult);
1514
- $[12] = recordResult;
1515
- $[13] = t9;
1516
- } else t9 = $[13];
1517
- const pageRecord = t9;
1172
+ derivedLayoutId: derivedLayoutIdOf(intendedPage)
1173
+ }), t9);
1174
+ const recordResult = derivedLayoutIdOf(intendedPage) ? intendedFrameInput?.derived?.result : void 0;
1175
+ let t10;
1176
+ if ($[14] !== recordResult) {
1177
+ t10 = getPageRecord(recordResult);
1178
+ $[14] = recordResult;
1179
+ $[15] = t10;
1180
+ } else t10 = $[15];
1181
+ const pageRecord = t10;
1518
1182
  usePreparationFailure((!project.isFetching ? project.error : null) ?? (!pages.isFetching ? pages.error : null));
1519
1183
  const preparation = React.useContext(PreviewPreparationContext);
1520
- React.useEffect(() => {
1521
- if (project.isPending || pages.isPending || project.error || pages.error) return;
1522
- if (selectedBlock || parseLocalePath(location.pathname, viewLocale.locales).path === "/camox/canvas") {
1523
- preparation?.ready();
1524
- return;
1525
- }
1526
- if (selectedPage) return;
1527
- preparation?.fail(/* @__PURE__ */ new Error(`No canvas page matches ${location.pathname}.`));
1528
- }, [
1529
- project.isPending,
1530
- pages.isPending,
1531
- project.error,
1532
- pages.error,
1533
- selectedPage,
1534
- selectedBlock,
1535
- location.pathname,
1536
- viewLocale.locales,
1537
- preparation
1538
- ]);
1184
+ let t11;
1185
+ let t12;
1186
+ if ($[16] !== location.pathname || $[17] !== pages.error || $[18] !== pages.isPending || $[19] !== preparation || $[20] !== project.error || $[21] !== project.isPending || $[22] !== selectedPage || $[23] !== viewLocale.locales) {
1187
+ t11 = () => {
1188
+ if (project.isPending || pages.isPending || project.error || pages.error) return;
1189
+ if (parseLocalePath(location.pathname, viewLocale.locales).path === "/camox/canvas") {
1190
+ preparation?.ready();
1191
+ return;
1192
+ }
1193
+ if (selectedPage) return;
1194
+ preparation?.fail(/* @__PURE__ */ new Error(`No canvas page matches ${location.pathname}.`));
1195
+ };
1196
+ t12 = [
1197
+ project.isPending,
1198
+ pages.isPending,
1199
+ project.error,
1200
+ pages.error,
1201
+ selectedPage,
1202
+ location.pathname,
1203
+ viewLocale.locales,
1204
+ preparation
1205
+ ];
1206
+ $[16] = location.pathname;
1207
+ $[17] = pages.error;
1208
+ $[18] = pages.isPending;
1209
+ $[19] = preparation;
1210
+ $[20] = project.error;
1211
+ $[21] = project.isPending;
1212
+ $[22] = selectedPage;
1213
+ $[23] = viewLocale.locales;
1214
+ $[24] = t11;
1215
+ $[25] = t12;
1216
+ } else {
1217
+ t11 = $[24];
1218
+ t12 = $[25];
1219
+ }
1220
+ React.useEffect(t11, t12);
1539
1221
  if (project.error || pages.error) {
1540
- let t10;
1541
- if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
1542
- t10 = /* @__PURE__ */ jsx("p", { children: "Could not load the site’s pages." });
1543
- $[14] = t10;
1544
- } else t10 = $[14];
1545
- let t11;
1546
- if ($[15] !== pages || $[16] !== project) {
1547
- t11 = /* @__PURE__ */ jsx(CanvasMessage, { children: /* @__PURE__ */ jsxs("div", {
1222
+ let t13;
1223
+ if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
1224
+ t13 = /* @__PURE__ */ jsx("p", { children: "Could not load the site’s pages." });
1225
+ $[26] = t13;
1226
+ } else t13 = $[26];
1227
+ let t14;
1228
+ if ($[27] !== pages || $[28] !== project) {
1229
+ t14 = /* @__PURE__ */ jsx(CanvasMessage, { children: /* @__PURE__ */ jsxs("div", {
1548
1230
  role: "alert",
1549
- children: [t10, /* @__PURE__ */ jsx("button", {
1231
+ children: [t13, /* @__PURE__ */ jsx("button", {
1550
1232
  className: "mt-4 underline",
1551
1233
  onClick: () => {
1552
1234
  if (project.error) project.refetch();
@@ -1555,178 +1237,163 @@ function CamoxCanvas(t0) {
1555
1237
  children: "Try again"
1556
1238
  })]
1557
1239
  }) });
1558
- $[15] = pages;
1559
- $[16] = project;
1560
- $[17] = t11;
1561
- } else t11 = $[17];
1562
- return t11;
1240
+ $[27] = pages;
1241
+ $[28] = project;
1242
+ $[29] = t14;
1243
+ } else t14 = $[29];
1244
+ return t14;
1563
1245
  }
1564
1246
  if (project.isPending || pages.isPending) {
1565
- let t10;
1566
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
1567
- t10 = /* @__PURE__ */ jsx(CanvasMessage, { children: /* @__PURE__ */ jsx("span", {
1247
+ let t13;
1248
+ if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
1249
+ t13 = /* @__PURE__ */ jsx(CanvasMessage, { children: /* @__PURE__ */ jsx("span", {
1568
1250
  role: "status",
1569
1251
  children: "Loading canvas…"
1570
1252
  }) });
1571
- $[18] = t10;
1572
- } else t10 = $[18];
1573
- return t10;
1253
+ $[30] = t13;
1254
+ } else t13 = $[30];
1255
+ return t13;
1574
1256
  }
1575
1257
  const editingOwner = activeFrame?.pathname === intended.pathname ? activeFrame.owner : null;
1576
- const blockCatalog = getBlockCatalog(app.getBlocks());
1577
- const intendedItemKey = intendedSelection.page?.key ?? (intendedSelection.block && canvasBlockKey(intendedSelection.block._internal.id));
1578
- const t10 = "flex min-h-0 flex-1 overflow-hidden";
1579
- const t11 = selectedPage?.kind === "curated" && /* @__PURE__ */ jsx(CuratedBlockShortcuts, {});
1580
- const T0 = NavigationProvider;
1581
- const T1 = PageRecordContext;
1582
- const T2 = CanvasSidebar;
1583
- const t12 = intendedSelection.page;
1584
- const t13 = intendedSelection.block && {
1585
- block: intendedSelection.block,
1586
- projectId: project.data.id
1587
- };
1588
- const t14 = getCanvasShelves(canvasPages, blockCatalog);
1258
+ let t13;
1259
+ if ($[31] !== selectedPage?.kind) {
1260
+ t13 = selectedPage?.kind === "curated" && /* @__PURE__ */ jsx(CuratedBlockShortcuts, {});
1261
+ $[31] = selectedPage?.kind;
1262
+ $[32] = t13;
1263
+ } else t13 = $[32];
1264
+ const t14 = intendedPage?.key;
1589
1265
  let t15;
1590
- if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
1591
- t15 = (key) => workspace.current?.showItem(key);
1592
- $[19] = t15;
1593
- } else t15 = $[19];
1266
+ if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
1267
+ t15 = (key) => workspace.current?.showPage(key);
1268
+ $[33] = t15;
1269
+ } else t15 = $[33];
1594
1270
  let t16;
1595
- if ($[20] !== intendedItemKey || $[21] !== t14) {
1271
+ if ($[34] !== canvasPages || $[35] !== t14) {
1596
1272
  t16 = {
1597
- shelves: t14,
1598
- selectedKey: intendedItemKey,
1599
- onShowItem: t15
1273
+ pages: canvasPages,
1274
+ selectedKey: t14,
1275
+ onShowPage: t15
1600
1276
  };
1601
- $[20] = intendedItemKey;
1602
- $[21] = t14;
1603
- $[22] = t16;
1604
- } else t16 = $[22];
1277
+ $[34] = canvasPages;
1278
+ $[35] = t14;
1279
+ $[36] = t16;
1280
+ } else t16 = $[36];
1605
1281
  let t17;
1606
- if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
1282
+ if ($[37] === Symbol.for("react.memo_cache_sentinel")) {
1607
1283
  t17 = () => workspace.current?.showWholeCanvas();
1608
- $[23] = t17;
1609
- } else t17 = $[23];
1284
+ $[37] = t17;
1285
+ } else t17 = $[37];
1610
1286
  let t18;
1611
- if ($[24] !== T2 || $[25] !== editingOwner || $[26] !== intendedSelection || $[27] !== pageRecord || $[28] !== renamePage || $[29] !== t13 || $[30] !== t16) {
1612
- t18 = /* @__PURE__ */ jsx(T2, {
1613
- page: t12,
1614
- catalog: t13,
1287
+ if ($[38] !== editingOwner || $[39] !== intendedPage || $[40] !== pageRecord || $[41] !== renamePage || $[42] !== t16) {
1288
+ t18 = /* @__PURE__ */ jsx(CanvasSidebar, {
1289
+ page: intendedPage,
1615
1290
  navigator: t16,
1616
1291
  onShowWholeCanvas: t17,
1617
1292
  onRenamePage: renamePage,
1618
1293
  owner: editingOwner,
1619
1294
  pageRecord
1620
1295
  });
1621
- $[24] = T2;
1622
- $[25] = editingOwner;
1623
- $[26] = intendedSelection;
1624
- $[27] = pageRecord;
1625
- $[28] = renamePage;
1626
- $[29] = t13;
1627
- $[30] = t16;
1628
- $[31] = t18;
1629
- } else t18 = $[31];
1296
+ $[38] = editingOwner;
1297
+ $[39] = intendedPage;
1298
+ $[40] = pageRecord;
1299
+ $[41] = renamePage;
1300
+ $[42] = t16;
1301
+ $[43] = t18;
1302
+ } else t18 = $[43];
1630
1303
  let t19;
1631
- if ($[32] !== T1 || $[33] !== recordResult || $[34] !== t18) {
1632
- t19 = /* @__PURE__ */ jsx(T1, {
1304
+ if ($[44] !== recordResult || $[45] !== t18) {
1305
+ t19 = /* @__PURE__ */ jsx(PageRecordContext, {
1633
1306
  value: recordResult,
1634
1307
  children: t18
1635
1308
  });
1636
- $[32] = T1;
1637
- $[33] = recordResult;
1638
- $[34] = t18;
1639
- $[35] = t19;
1640
- } else t19 = $[35];
1309
+ $[44] = recordResult;
1310
+ $[45] = t18;
1311
+ $[46] = t19;
1312
+ } else t19 = $[46];
1641
1313
  let t20;
1642
- if ($[36] !== T0 || $[37] !== intended || $[38] !== navigate || $[39] !== t19) {
1643
- t20 = /* @__PURE__ */ jsx(T0, {
1314
+ if ($[47] !== intended || $[48] !== navigate || $[49] !== t19) {
1315
+ t20 = /* @__PURE__ */ jsx(NavigationProvider, {
1644
1316
  location: intended,
1645
1317
  navigate,
1646
1318
  children: t19
1647
1319
  });
1648
- $[36] = T0;
1649
- $[37] = intended;
1650
- $[38] = navigate;
1651
- $[39] = t19;
1652
- $[40] = t20;
1653
- } else t20 = $[40];
1654
- let t21;
1655
- if ($[41] === Symbol.for("react.memo_cache_sentinel")) {
1656
- t21 = (pathname_0, owner, release) => setActiveFrame({
1657
- pathname: pathname_0,
1320
+ $[47] = intended;
1321
+ $[48] = navigate;
1322
+ $[49] = t19;
1323
+ $[50] = t20;
1324
+ } else t20 = $[50];
1325
+ const t21 = intendedPage?.key;
1326
+ let t22;
1327
+ if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
1328
+ t22 = (pathname, owner, release) => setActiveFrame({
1329
+ pathname,
1658
1330
  owner,
1659
1331
  release
1660
1332
  });
1661
- $[41] = t21;
1662
- } else t21 = $[41];
1663
- let t22;
1664
- if ($[42] !== location || $[43] !== setIntent) {
1665
- t22 = (pathname_1) => setIntent({
1333
+ $[51] = t22;
1334
+ } else t22 = $[51];
1335
+ let t23;
1336
+ if ($[52] !== location || $[53] !== setIntent) {
1337
+ t23 = (pathname_0) => setIntent({
1666
1338
  from: location.pathname,
1667
1339
  to: {
1668
1340
  ...location,
1669
- pathname: pathname_1,
1670
- href: new URL(`${pathname_1}${location.search}${location.hash}`, window.location.href).href
1341
+ pathname: pathname_0,
1342
+ href: new URL(`${pathname_0}${location.search}${location.hash}`, window.location.href).href
1671
1343
  }
1672
1344
  });
1673
- $[42] = location;
1674
- $[43] = setIntent;
1675
- $[44] = t22;
1676
- } else t22 = $[44];
1677
- let t23;
1678
- if ($[45] !== blockCatalog || $[46] !== canvasPages || $[47] !== intendedItemKey || $[48] !== previewedPage || $[49] !== project.data.id || $[50] !== runtimeBasePath || $[51] !== selectedBlock || $[52] !== selectedPage || $[53] !== t22 || $[54] !== viewport) {
1679
- t23 = /* @__PURE__ */ jsx(CanvasWorkspace, {
1345
+ $[52] = location;
1346
+ $[53] = setIntent;
1347
+ $[54] = t23;
1348
+ } else t23 = $[54];
1349
+ let t24;
1350
+ if ($[55] !== canvasPages || $[56] !== previewedPage || $[57] !== project.data.id || $[58] !== runtimeBasePath || $[59] !== selectedPage || $[60] !== t21 || $[61] !== t23 || $[62] !== viewport) {
1351
+ t24 = /* @__PURE__ */ jsx(CanvasWorkspace, {
1680
1352
  ref: workspace,
1681
- projectId: project.data.id,
1682
1353
  pages: canvasPages,
1683
- blocks: blockCatalog,
1684
1354
  selectedPage,
1685
- selectedBlock,
1686
1355
  previewedPage,
1687
- intendedItemKey,
1356
+ intendedPageKey: t21,
1688
1357
  runtimeBasePath,
1689
1358
  viewport,
1690
- onActivate: t21,
1691
- onSelectionIntent: t22
1359
+ onActivate: t22,
1360
+ onSelectionIntent: t23
1692
1361
  }, project.data.id);
1693
- $[45] = blockCatalog;
1694
- $[46] = canvasPages;
1695
- $[47] = intendedItemKey;
1696
- $[48] = previewedPage;
1697
- $[49] = project.data.id;
1698
- $[50] = runtimeBasePath;
1699
- $[51] = selectedBlock;
1700
- $[52] = selectedPage;
1701
- $[53] = t22;
1702
- $[54] = viewport;
1703
- $[55] = t23;
1704
- } else t23 = $[55];
1705
- let t24;
1706
- if ($[56] !== t11 || $[57] !== t20 || $[58] !== t23) {
1707
- t24 = /* @__PURE__ */ jsxs("div", {
1708
- className: t10,
1362
+ $[55] = canvasPages;
1363
+ $[56] = previewedPage;
1364
+ $[57] = project.data.id;
1365
+ $[58] = runtimeBasePath;
1366
+ $[59] = selectedPage;
1367
+ $[60] = t21;
1368
+ $[61] = t23;
1369
+ $[62] = viewport;
1370
+ $[63] = t24;
1371
+ } else t24 = $[63];
1372
+ let t25;
1373
+ if ($[64] !== t13 || $[65] !== t20 || $[66] !== t24) {
1374
+ t25 = /* @__PURE__ */ jsxs("div", {
1375
+ className: "flex min-h-0 flex-1 overflow-hidden",
1709
1376
  children: [
1710
- t11,
1377
+ t13,
1711
1378
  t20,
1712
- t23
1379
+ t24
1713
1380
  ]
1714
1381
  });
1715
- $[56] = t11;
1716
- $[57] = t20;
1717
- $[58] = t23;
1718
- $[59] = t24;
1719
- } else t24 = $[59];
1720
- return t24;
1382
+ $[64] = t13;
1383
+ $[65] = t20;
1384
+ $[66] = t24;
1385
+ $[67] = t25;
1386
+ } else t25 = $[67];
1387
+ return t25;
1721
1388
  }
1722
- function _temp7() {
1389
+ function _temp5() {
1723
1390
  previewStore.send({ type: "clearSelection" });
1724
- return _temp6;
1391
+ return _temp4;
1725
1392
  }
1726
- function _temp6() {
1393
+ function _temp4() {
1727
1394
  previewStore.send({ type: "clearSelection" });
1728
1395
  }
1729
- function _temp5(state) {
1396
+ function _temp3(state) {
1730
1397
  return state.context.viewportMode;
1731
1398
  }
1732
1399