camox 0.46.0 → 0.47.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.
- package/dist/features/canvas/canvasCamera.js +21 -6
- package/dist/features/canvas/useCanvasCamera.js +16 -11
- package/dist/features/preview/CamoxPreview.js +136 -119
- package/dist/features/preview/components/PreviewToolbar.js +74 -85
- package/dist/features/provider/CamoxProvider.js +8 -16
- package/dist/features/provider/CoreCamoxProvider.js +1 -6
- package/dist/features/provider/signInShortcut.js +60 -0
- package/dist/features/runtime/RuntimeChrome.js +1 -1
- package/dist/features/runtime/pageApp.js +11 -39
- package/dist/package.js +1 -1
- package/package.json +4 -4
- package/dist/features/provider/LocalhostPreviewProvider.js +0 -158
|
@@ -24,16 +24,31 @@ const MAX_CANVAS_ZOOM = 2;
|
|
|
24
24
|
*/
|
|
25
25
|
const MIN_CANVAS_ZOOM = .1;
|
|
26
26
|
/** Log-scale zoom per pixel of Ctrl/⌘ + wheel, including trackpad pinches. */
|
|
27
|
-
const CANVAS_WHEEL_ZOOM_RATE = .
|
|
27
|
+
const CANVAS_WHEEL_ZOOM_RATE = .012672;
|
|
28
28
|
/** Relative (log-scale) bands make the detent feel the same at every page width. */
|
|
29
|
-
const ZOOM_SNAP_CAPTURE = .
|
|
30
|
-
const ZOOM_SNAP_RELEASE = .
|
|
29
|
+
const ZOOM_SNAP_CAPTURE = .168;
|
|
30
|
+
const ZOOM_SNAP_RELEASE = .216;
|
|
31
31
|
/** Fractions of viewport width: acquire near center, then hold a wider detent. */
|
|
32
|
-
const PAN_SNAP_CAPTURE = .
|
|
33
|
-
const PAN_SNAP_RELEASE = .
|
|
32
|
+
const PAN_SNAP_CAPTURE = .144;
|
|
33
|
+
const PAN_SNAP_RELEASE = .216;
|
|
34
34
|
function isCanvasPageScale(scale, pageScale) {
|
|
35
35
|
return pageScale !== void 0 && Math.abs(Math.log(scale / pageScale)) < 1e-8;
|
|
36
36
|
}
|
|
37
|
+
/** Signed screen distance from a target's center to the viewport's center. */
|
|
38
|
+
function canvasTargetOffset(camera, viewport, target) {
|
|
39
|
+
return camera.x + (target.left + target.width / 2) * camera.scale - viewport.width / 2;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Near a target's page fit in both zoom and position, so a pan snaps onto a
|
|
43
|
+
* page without its zoom matching exactly. A held snap releases from wider bands
|
|
44
|
+
* than it captures.
|
|
45
|
+
*/
|
|
46
|
+
function isInCanvasSnapWindow(camera, viewport, target, held) {
|
|
47
|
+
const fit = fitCanvasPage(viewport, target);
|
|
48
|
+
const zoomBand = held ? ZOOM_SNAP_RELEASE : ZOOM_SNAP_CAPTURE;
|
|
49
|
+
const panBand = viewport.width * (held ? PAN_SNAP_RELEASE : PAN_SNAP_CAPTURE);
|
|
50
|
+
return Math.abs(Math.log(camera.scale / fit.scale)) <= zoomBand && Math.abs(canvasTargetOffset(camera, viewport, target)) <= panBand;
|
|
51
|
+
}
|
|
37
52
|
/** Snapped to a target: at its page fit, centered on it. */
|
|
38
53
|
function isCanvasCameraSnapped(camera, viewport, target) {
|
|
39
54
|
const fit = fitCanvasPage(viewport, target);
|
|
@@ -226,4 +241,4 @@ function canvasWheelDelta(delta, mode, viewportSize) {
|
|
|
226
241
|
}
|
|
227
242
|
|
|
228
243
|
//#endregion
|
|
229
|
-
export { CANVAS_OVERSCROLL, CANVAS_WHEEL_ZOOM_RATE, MIN_CANVAS_ZOOM, PAN_SNAP_CAPTURE, PAN_SNAP_RELEASE, ZOOM_SNAP_CAPTURE, ZOOM_SNAP_RELEASE, ZOOM_STRETCH, canvasInsets, canvasMaximumScale, canvasMinimumScale, canvasOverview, canvasVerticalRail, canvasWheelDelta, constrainCanvasCamera, findCanvasSnapTarget, fitCanvas, fitCanvasPage, isCanvasCameraSnapped, isCanvasPageScale, placeCanvasPageAnchor, snapCanvasZoom, stretchCanvasZoom, unstretchCanvasZoom, zoomCanvasAt };
|
|
244
|
+
export { CANVAS_OVERSCROLL, CANVAS_WHEEL_ZOOM_RATE, MIN_CANVAS_ZOOM, PAN_SNAP_CAPTURE, PAN_SNAP_RELEASE, ZOOM_SNAP_CAPTURE, ZOOM_SNAP_RELEASE, ZOOM_STRETCH, canvasInsets, canvasMaximumScale, canvasMinimumScale, canvasOverview, canvasTargetOffset, canvasVerticalRail, canvasWheelDelta, constrainCanvasCamera, findCanvasSnapTarget, fitCanvas, fitCanvasPage, isCanvasCameraSnapped, isCanvasPageScale, isInCanvasSnapWindow, placeCanvasPageAnchor, snapCanvasZoom, stretchCanvasZoom, unstretchCanvasZoom, zoomCanvasAt };
|
|
@@ -2,7 +2,7 @@ import { canvasStore } from "./canvasStore.js";
|
|
|
2
2
|
import { ViewportContinuityContext, captureViewportAnchor, resolveViewportAnchor } from "../preview/viewportContinuity.js";
|
|
3
3
|
import { canvasPageIframe } from "../preview/previewPageFrame.js";
|
|
4
4
|
import { canvasBlockOverlap } from "./canvasFrameDocument.js";
|
|
5
|
-
import { CANVAS_WHEEL_ZOOM_RATE,
|
|
5
|
+
import { CANVAS_WHEEL_ZOOM_RATE, ZOOM_STRETCH, canvasMaximumScale, canvasMinimumScale, canvasOverview, canvasVerticalRail, canvasWheelDelta, constrainCanvasCamera, findCanvasSnapTarget, fitCanvasPage, isCanvasCameraSnapped, isCanvasPageScale, isInCanvasSnapWindow, placeCanvasPageAnchor, snapCanvasZoom, stretchCanvasZoom, unstretchCanvasZoom, zoomCanvasAt } from "./canvasCamera.js";
|
|
6
6
|
import { revealScrollDelta } from "../preview/selectionReveal.js";
|
|
7
7
|
import { createCanvasFlight, createCanvasPan } from "./canvasFlight.js";
|
|
8
8
|
import * as React from "react";
|
|
@@ -233,16 +233,17 @@ function useCanvasCamera(workspaceKey, initialTarget, row) {
|
|
|
233
233
|
};
|
|
234
234
|
const candidate = findCanvasSnapTarget(intended, viewportSize, targets());
|
|
235
235
|
const fit = candidate && fitCanvasPage(viewportSize, candidate);
|
|
236
|
-
if (!candidate || !fit ||
|
|
237
|
-
const held =
|
|
238
|
-
|
|
239
|
-
if (Math.abs(intended.x - fit.x) > band) return intended;
|
|
236
|
+
if (!candidate || !fit || fit.scale < minimumScale) return intended;
|
|
237
|
+
const held = isCanvasCameraSnapped(base, viewportSize, candidate);
|
|
238
|
+
if (!isInCanvasSnapWindow(intended, viewportSize, candidate, held)) return intended;
|
|
240
239
|
if (selection !== candidate.key) rowRef.current?.onSnap?.();
|
|
241
240
|
select(candidate.key);
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
x: fit.x
|
|
245
|
-
|
|
241
|
+
gesture.intendedX += (candidate.left + candidate.width / 2) * (intended.scale - fit.scale);
|
|
242
|
+
return constrain({
|
|
243
|
+
x: fit.x,
|
|
244
|
+
y: rescaleY(intended, fit.scale),
|
|
245
|
+
scale: fit.scale
|
|
246
|
+
});
|
|
246
247
|
};
|
|
247
248
|
const endZoom = () => {
|
|
248
249
|
ownerWindow.clearTimeout(zoomEnd);
|
|
@@ -264,6 +265,10 @@ function useCanvasCamera(workspaceKey, initialTarget, row) {
|
|
|
264
265
|
else delete element.dataset.canvasPan;
|
|
265
266
|
};
|
|
266
267
|
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
268
|
+
const isOverview = (view) => {
|
|
269
|
+
const overview = canvasOverview(viewportSize, contentSize);
|
|
270
|
+
return Math.abs(view.scale - overview.scale) < 1e-8 && Math.abs(view.x - overview.x) < .5 && Math.abs(view.y - overview.y) < .5;
|
|
271
|
+
};
|
|
267
272
|
const remember = () => {
|
|
268
273
|
if (restoredCamera || fittingInitialPage || !viewportSize.width || !viewportSize.height) return;
|
|
269
274
|
canvasStore.send({
|
|
@@ -271,7 +276,7 @@ function useCanvasCamera(workspaceKey, initialTarget, row) {
|
|
|
271
276
|
workspaceKey,
|
|
272
277
|
view: {
|
|
273
278
|
camera,
|
|
274
|
-
fitted:
|
|
279
|
+
fitted: isOverview(camera)
|
|
275
280
|
}
|
|
276
281
|
});
|
|
277
282
|
};
|
|
@@ -516,7 +521,7 @@ function useCanvasCamera(workspaceKey, initialTarget, row) {
|
|
|
516
521
|
};
|
|
517
522
|
const nextContent = measureContent();
|
|
518
523
|
if (nextViewport.width === viewportSize.width && nextViewport.height === viewportSize.height && nextContent.width === contentSize.width && nextContent.height === contentSize.height) return;
|
|
519
|
-
const wasFitted =
|
|
524
|
+
const wasFitted = isOverview(target);
|
|
520
525
|
gesture = void 0;
|
|
521
526
|
const held = nextViewport.width !== viewportSize.width && !flight && !fittingInitialPage ? targetOf(selection) : void 0;
|
|
522
527
|
updateGeometry(nextViewport, nextContent);
|
|
@@ -17,6 +17,7 @@ import { canvasStore } from "../canvas/canvasStore.js";
|
|
|
17
17
|
import { SHOW_WHOLE_CANVAS_SHORTCUT, TOGGLE_CANVAS_SHORTCUT } from "./previewConstants.js";
|
|
18
18
|
import { CanvasSidebarSkeleton } from "../canvas/sidebar/CanvasSidebarSkeleton.js";
|
|
19
19
|
import { DerivedPageContent } from "../page/DerivedPageContent.js";
|
|
20
|
+
import { takeShowCanvasRequest } from "../provider/signInShortcut.js";
|
|
20
21
|
import { STUDIO_CANVAS_PATH } from "../studio/routes.js";
|
|
21
22
|
import { studioStore } from "../studio/studioStore.js";
|
|
22
23
|
import { previewStore, selectIsCanvasShown } from "./previewStore.js";
|
|
@@ -617,7 +618,7 @@ function usePrefetchCanvas(enabled, projectUuid) {
|
|
|
617
618
|
}
|
|
618
619
|
/** Studio chrome is shared; only curated previews require a Camox page record. */
|
|
619
620
|
const PreviewShell = (t0) => {
|
|
620
|
-
const $ = c(
|
|
621
|
+
const $ = c(53);
|
|
621
622
|
const { children, pageData, derivedLayout, pageLocation, canvasOnly, runtimeBasePath: t1 } = t0;
|
|
622
623
|
const runtimeBasePath = t1 === void 0 ? "" : t1;
|
|
623
624
|
const isAuthenticated = useIsAuthenticated();
|
|
@@ -663,26 +664,42 @@ const PreviewShell = (t0) => {
|
|
|
663
664
|
const editingOwner = t2;
|
|
664
665
|
let t3;
|
|
665
666
|
let t4;
|
|
666
|
-
if ($[4] !== isMobileStudio) {
|
|
667
|
+
if ($[4] !== isAuthenticated || $[5] !== isMobileStudio) {
|
|
667
668
|
t3 = () => {
|
|
668
|
-
if (!isMobileStudio)
|
|
669
|
-
previewStore.send({ type: "hideCanvas" });
|
|
670
|
-
previewStore.send({ type: "closeAddBlockSheet" });
|
|
669
|
+
if (isAuthenticated && takeShowCanvasRequest() && !isMobileStudio) previewStore.send({ type: "showCanvas" });
|
|
671
670
|
};
|
|
672
|
-
t4 = [isMobileStudio];
|
|
673
|
-
$[4] =
|
|
674
|
-
$[5] =
|
|
675
|
-
$[6] =
|
|
671
|
+
t4 = [isAuthenticated, isMobileStudio];
|
|
672
|
+
$[4] = isAuthenticated;
|
|
673
|
+
$[5] = isMobileStudio;
|
|
674
|
+
$[6] = t3;
|
|
675
|
+
$[7] = t4;
|
|
676
676
|
} else {
|
|
677
|
-
t3 = $[
|
|
678
|
-
t4 = $[
|
|
677
|
+
t3 = $[6];
|
|
678
|
+
t4 = $[7];
|
|
679
679
|
}
|
|
680
680
|
React.useEffect(t3, t4);
|
|
681
|
-
useCanvasOnlyLocation(!!canvasOnly && isAuthenticated, isCanvasShown, isMobileStudio, pageLocation);
|
|
682
681
|
let t5;
|
|
683
682
|
let t6;
|
|
684
|
-
if ($[
|
|
683
|
+
if ($[8] !== isMobileStudio) {
|
|
685
684
|
t5 = () => {
|
|
685
|
+
if (!isMobileStudio) return;
|
|
686
|
+
previewStore.send({ type: "hideCanvas" });
|
|
687
|
+
previewStore.send({ type: "closeAddBlockSheet" });
|
|
688
|
+
};
|
|
689
|
+
t6 = [isMobileStudio];
|
|
690
|
+
$[8] = isMobileStudio;
|
|
691
|
+
$[9] = t5;
|
|
692
|
+
$[10] = t6;
|
|
693
|
+
} else {
|
|
694
|
+
t5 = $[9];
|
|
695
|
+
t6 = $[10];
|
|
696
|
+
}
|
|
697
|
+
React.useEffect(t5, t6);
|
|
698
|
+
useCanvasOnlyLocation(!!canvasOnly && isAuthenticated, isCanvasShown, isMobileStudio, pageLocation);
|
|
699
|
+
let t7;
|
|
700
|
+
let t8;
|
|
701
|
+
if ($[11] !== isAuthenticated || $[12] !== isCanvasShown || $[13] !== isMobileStudio) {
|
|
702
|
+
t7 = () => {
|
|
686
703
|
const actions = [
|
|
687
704
|
{
|
|
688
705
|
id: "hide-canvas",
|
|
@@ -732,140 +749,140 @@ const PreviewShell = (t0) => {
|
|
|
732
749
|
});
|
|
733
750
|
};
|
|
734
751
|
};
|
|
735
|
-
|
|
752
|
+
t8 = [
|
|
736
753
|
isCanvasShown,
|
|
737
754
|
isAuthenticated,
|
|
738
755
|
isMobileStudio
|
|
739
756
|
];
|
|
740
|
-
$[
|
|
741
|
-
$[
|
|
742
|
-
$[
|
|
743
|
-
$[
|
|
744
|
-
$[
|
|
757
|
+
$[11] = isAuthenticated;
|
|
758
|
+
$[12] = isCanvasShown;
|
|
759
|
+
$[13] = isMobileStudio;
|
|
760
|
+
$[14] = t7;
|
|
761
|
+
$[15] = t8;
|
|
745
762
|
} else {
|
|
746
|
-
|
|
747
|
-
|
|
763
|
+
t7 = $[14];
|
|
764
|
+
t8 = $[15];
|
|
748
765
|
}
|
|
749
|
-
React.useEffect(
|
|
766
|
+
React.useEffect(t7, t8);
|
|
750
767
|
if (!isAuthenticated) {
|
|
751
|
-
let
|
|
752
|
-
if ($[
|
|
753
|
-
|
|
754
|
-
$[
|
|
755
|
-
$[
|
|
756
|
-
} else
|
|
757
|
-
return
|
|
768
|
+
let t9;
|
|
769
|
+
if ($[16] !== children) {
|
|
770
|
+
t9 = /* @__PURE__ */ jsx(Fragment, { children });
|
|
771
|
+
$[16] = children;
|
|
772
|
+
$[17] = t9;
|
|
773
|
+
} else t9 = $[17];
|
|
774
|
+
return t9;
|
|
758
775
|
}
|
|
759
|
-
const
|
|
760
|
-
let
|
|
761
|
-
if ($[
|
|
762
|
-
|
|
763
|
-
$[
|
|
764
|
-
$[
|
|
765
|
-
} else
|
|
766
|
-
const
|
|
767
|
-
const
|
|
768
|
-
const
|
|
769
|
-
let
|
|
770
|
-
if ($[
|
|
771
|
-
|
|
772
|
-
page:
|
|
773
|
-
layoutPage:
|
|
776
|
+
const t9 = !isCanvasShown && "bg-black";
|
|
777
|
+
let t10;
|
|
778
|
+
if ($[18] !== t9) {
|
|
779
|
+
t10 = cn("bg-background relative flex h-full min-h-0 flex-1 flex-col overflow-hidden", t9);
|
|
780
|
+
$[18] = t9;
|
|
781
|
+
$[19] = t10;
|
|
782
|
+
} else t10 = $[19];
|
|
783
|
+
const t11 = pageLocation?.pathname;
|
|
784
|
+
const t12 = !canvasOnly;
|
|
785
|
+
const t13 = !!derivedLayout;
|
|
786
|
+
let t14;
|
|
787
|
+
if ($[20] !== t12 || $[21] !== t13) {
|
|
788
|
+
t14 = /* @__PURE__ */ jsx(CanvasSidebarSkeleton, {
|
|
789
|
+
page: t12,
|
|
790
|
+
layoutPage: t13
|
|
774
791
|
});
|
|
775
|
-
$[
|
|
776
|
-
$[
|
|
777
|
-
$[
|
|
778
|
-
} else
|
|
779
|
-
const
|
|
780
|
-
const
|
|
781
|
-
const
|
|
782
|
-
const
|
|
783
|
-
let
|
|
784
|
-
if ($[
|
|
785
|
-
|
|
792
|
+
$[20] = t12;
|
|
793
|
+
$[21] = t13;
|
|
794
|
+
$[22] = t14;
|
|
795
|
+
} else t14 = $[22];
|
|
796
|
+
const t15 = !isCanvasEnabled;
|
|
797
|
+
const t16 = pageData?.page;
|
|
798
|
+
const t17 = derivedLayout?.layoutId;
|
|
799
|
+
const t18 = pageData?.projectName;
|
|
800
|
+
let t19;
|
|
801
|
+
if ($[23] !== children || $[24] !== isMobileStudio || $[25] !== pageLocation || $[26] !== t15 || $[27] !== t16 || $[28] !== t17 || $[29] !== t18) {
|
|
802
|
+
t19 = /* @__PURE__ */ jsx("div", {
|
|
786
803
|
className: "flex min-h-0 flex-1 flex-row items-stretch",
|
|
787
804
|
children: /* @__PURE__ */ jsx(PreviewPanel, {
|
|
788
|
-
active:
|
|
805
|
+
active: t15,
|
|
789
806
|
isMobileExperience: isMobileStudio,
|
|
790
|
-
page:
|
|
791
|
-
layoutId:
|
|
807
|
+
page: t16,
|
|
808
|
+
layoutId: t17,
|
|
792
809
|
pageLocation,
|
|
793
|
-
projectName:
|
|
810
|
+
projectName: t18,
|
|
794
811
|
children
|
|
795
812
|
})
|
|
796
813
|
});
|
|
797
|
-
$[
|
|
798
|
-
$[
|
|
799
|
-
$[
|
|
800
|
-
$[
|
|
801
|
-
$[
|
|
802
|
-
$[
|
|
803
|
-
$[
|
|
804
|
-
$[
|
|
805
|
-
} else
|
|
806
|
-
let
|
|
807
|
-
if ($[
|
|
808
|
-
|
|
814
|
+
$[23] = children;
|
|
815
|
+
$[24] = isMobileStudio;
|
|
816
|
+
$[25] = pageLocation;
|
|
817
|
+
$[26] = t15;
|
|
818
|
+
$[27] = t16;
|
|
819
|
+
$[28] = t17;
|
|
820
|
+
$[29] = t18;
|
|
821
|
+
$[30] = t19;
|
|
822
|
+
} else t19 = $[30];
|
|
823
|
+
let t20;
|
|
824
|
+
if ($[31] !== isCanvasEnabled || $[32] !== pathname || $[33] !== runtimeBasePath || $[34] !== t11 || $[35] !== t14 || $[36] !== t19) {
|
|
825
|
+
t20 = /* @__PURE__ */ jsx(CanvasPreview, {
|
|
809
826
|
enabled: isCanvasEnabled,
|
|
810
827
|
pathname,
|
|
811
|
-
pagePathname:
|
|
828
|
+
pagePathname: t11,
|
|
812
829
|
runtimeBasePath,
|
|
813
|
-
placeholder:
|
|
814
|
-
children:
|
|
830
|
+
placeholder: t14,
|
|
831
|
+
children: t19
|
|
815
832
|
});
|
|
816
|
-
$[
|
|
817
|
-
$[
|
|
818
|
-
$[
|
|
819
|
-
$[
|
|
820
|
-
$[
|
|
821
|
-
$[32] = t9;
|
|
822
|
-
$[33] = t18;
|
|
823
|
-
} else t18 = $[33];
|
|
824
|
-
let t19;
|
|
825
|
-
if ($[34] !== isCanvasEnabled || $[35] !== pageId) {
|
|
826
|
-
t19 = !isCanvasEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CreatePageModal, {}), pageId != null && /* @__PURE__ */ jsx(AddBlockSheet, {})] });
|
|
827
|
-
$[34] = isCanvasEnabled;
|
|
828
|
-
$[35] = pageId;
|
|
833
|
+
$[31] = isCanvasEnabled;
|
|
834
|
+
$[32] = pathname;
|
|
835
|
+
$[33] = runtimeBasePath;
|
|
836
|
+
$[34] = t11;
|
|
837
|
+
$[35] = t14;
|
|
829
838
|
$[36] = t19;
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
if ($[37] !== t18 || $[38] !== t19 || $[39] !== t8) {
|
|
833
|
-
t20 = /* @__PURE__ */ jsxs("div", {
|
|
834
|
-
className: t8,
|
|
835
|
-
children: [t18, t19]
|
|
836
|
-
});
|
|
837
|
-
$[37] = t18;
|
|
838
|
-
$[38] = t19;
|
|
839
|
-
$[39] = t8;
|
|
840
|
-
$[40] = t20;
|
|
841
|
-
} else t20 = $[40];
|
|
839
|
+
$[37] = t20;
|
|
840
|
+
} else t20 = $[37];
|
|
842
841
|
let t21;
|
|
843
|
-
if ($[
|
|
844
|
-
t21 = /* @__PURE__ */ jsx(
|
|
845
|
-
|
|
846
|
-
|
|
842
|
+
if ($[38] !== isCanvasEnabled || $[39] !== pageId) {
|
|
843
|
+
t21 = !isCanvasEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CreatePageModal, {}), pageId != null && /* @__PURE__ */ jsx(AddBlockSheet, {})] });
|
|
844
|
+
$[38] = isCanvasEnabled;
|
|
845
|
+
$[39] = pageId;
|
|
846
|
+
$[40] = t21;
|
|
847
|
+
} else t21 = $[40];
|
|
848
|
+
let t22;
|
|
849
|
+
if ($[41] !== t10 || $[42] !== t20 || $[43] !== t21) {
|
|
850
|
+
t22 = /* @__PURE__ */ jsxs("div", {
|
|
851
|
+
className: t10,
|
|
852
|
+
children: [t20, t21]
|
|
847
853
|
});
|
|
848
|
-
$[41] =
|
|
854
|
+
$[41] = t10;
|
|
849
855
|
$[42] = t20;
|
|
850
856
|
$[43] = t21;
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
if ($[44] !== projectUuid) {
|
|
854
|
-
t22 = /* @__PURE__ */ jsx(ContentCollectionItemSheet, { projectUuid });
|
|
855
|
-
$[44] = projectUuid;
|
|
856
|
-
$[45] = t22;
|
|
857
|
-
} else t22 = $[45];
|
|
857
|
+
$[44] = t22;
|
|
858
|
+
} else t22 = $[44];
|
|
858
859
|
let t23;
|
|
859
|
-
if ($[
|
|
860
|
-
t23 = /* @__PURE__ */
|
|
860
|
+
if ($[45] !== editingOwner || $[46] !== t22) {
|
|
861
|
+
t23 = /* @__PURE__ */ jsx(PreviewEditingOwnerContext, {
|
|
862
|
+
value: editingOwner,
|
|
863
|
+
children: t22
|
|
864
|
+
});
|
|
865
|
+
$[45] = editingOwner;
|
|
866
|
+
$[46] = t22;
|
|
867
|
+
$[47] = t23;
|
|
868
|
+
} else t23 = $[47];
|
|
869
|
+
let t24;
|
|
870
|
+
if ($[48] !== projectUuid) {
|
|
871
|
+
t24 = /* @__PURE__ */ jsx(ContentCollectionItemSheet, { projectUuid });
|
|
872
|
+
$[48] = projectUuid;
|
|
873
|
+
$[49] = t24;
|
|
874
|
+
} else t24 = $[49];
|
|
875
|
+
let t25;
|
|
876
|
+
if ($[50] !== t23 || $[51] !== t24) {
|
|
877
|
+
t25 = /* @__PURE__ */ jsxs(CollectionItemSheetProvider, {
|
|
861
878
|
onRouteTargetClose: _temp9,
|
|
862
|
-
children: [
|
|
879
|
+
children: [t23, t24]
|
|
863
880
|
});
|
|
864
|
-
$[
|
|
865
|
-
$[
|
|
866
|
-
$[
|
|
867
|
-
} else
|
|
868
|
-
return
|
|
881
|
+
$[50] = t23;
|
|
882
|
+
$[51] = t24;
|
|
883
|
+
$[52] = t25;
|
|
884
|
+
} else t25 = $[52];
|
|
885
|
+
return t25;
|
|
869
886
|
};
|
|
870
887
|
/** Zooms out to the whole Canvas, from anywhere in the site or the Studio. */
|
|
871
888
|
function useShowCanvasAction() {
|
|
@@ -14,130 +14,116 @@ import * as Tooltip$1 from "@camox/ui/tooltip";
|
|
|
14
14
|
import { FloatingToolbar } from "@camox/ui/floating-toolbar";
|
|
15
15
|
|
|
16
16
|
//#region src/features/preview/components/PreviewToolbar.tsx
|
|
17
|
-
const PreviewToolbar = (
|
|
18
|
-
const $ = c(
|
|
19
|
-
const { onCanvasShownChange } = t0;
|
|
17
|
+
const PreviewToolbar = () => {
|
|
18
|
+
const $ = c(21);
|
|
20
19
|
const isCanvasShown = useSelector(previewStore, selectIsCanvasShown);
|
|
21
20
|
const isToolbarHidden = useSelector(previewStore, _temp);
|
|
22
21
|
const viewportMode = useSelector(previewStore, _temp2);
|
|
23
22
|
if (isToolbarHidden) return null;
|
|
24
|
-
let
|
|
25
|
-
if ($[0] !==
|
|
26
|
-
|
|
27
|
-
if (onCanvasShownChange) {
|
|
28
|
-
onCanvasShownChange(checked);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
previewStore.send({ type: checked ? "showCanvas" : "hideCanvas" });
|
|
32
|
-
};
|
|
33
|
-
$[0] = onCanvasShownChange;
|
|
34
|
-
$[1] = t1;
|
|
35
|
-
} else t1 = $[1];
|
|
36
|
-
let t2;
|
|
37
|
-
if ($[2] !== isCanvasShown || $[3] !== t1) {
|
|
38
|
-
t2 = /* @__PURE__ */ jsx(Switch, {
|
|
23
|
+
let t0;
|
|
24
|
+
if ($[0] !== isCanvasShown) {
|
|
25
|
+
t0 = /* @__PURE__ */ jsx(Switch, {
|
|
39
26
|
id: "show-canvas",
|
|
40
27
|
checked: isCanvasShown,
|
|
41
|
-
onCheckedChange:
|
|
28
|
+
onCheckedChange: _temp3
|
|
42
29
|
});
|
|
43
|
-
$[
|
|
44
|
-
$[
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
t3 = /* @__PURE__ */ jsxs(Label, {
|
|
30
|
+
$[0] = isCanvasShown;
|
|
31
|
+
$[1] = t0;
|
|
32
|
+
} else t0 = $[1];
|
|
33
|
+
let t1;
|
|
34
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
35
|
+
t1 = /* @__PURE__ */ jsxs(Label, {
|
|
50
36
|
htmlFor: "show-canvas",
|
|
51
37
|
className: "flex items-center gap-2",
|
|
52
38
|
children: ["Show canvas ", formatShortcut(TOGGLE_CANVAS_SHORTCUT)]
|
|
53
39
|
});
|
|
54
|
-
$[
|
|
55
|
-
} else
|
|
56
|
-
let
|
|
57
|
-
if ($[
|
|
58
|
-
|
|
40
|
+
$[2] = t1;
|
|
41
|
+
} else t1 = $[2];
|
|
42
|
+
let t2;
|
|
43
|
+
if ($[3] !== t0) {
|
|
44
|
+
t2 = /* @__PURE__ */ jsxs("div", {
|
|
59
45
|
className: "flex shrink-0 items-center gap-2 px-2",
|
|
60
46
|
onPointerEnter: prefetchCanvas,
|
|
61
47
|
onFocus: prefetchCanvas,
|
|
62
|
-
children: [
|
|
48
|
+
children: [t0, t1]
|
|
63
49
|
});
|
|
64
|
-
$[
|
|
65
|
-
$[
|
|
66
|
-
} else
|
|
67
|
-
const
|
|
68
|
-
let
|
|
69
|
-
if ($[
|
|
70
|
-
|
|
71
|
-
value:
|
|
50
|
+
$[3] = t0;
|
|
51
|
+
$[4] = t2;
|
|
52
|
+
} else t2 = $[4];
|
|
53
|
+
const t3 = viewportMode === "full" ? "desktop" : viewportMode;
|
|
54
|
+
let t4;
|
|
55
|
+
if ($[5] !== t3) {
|
|
56
|
+
t4 = /* @__PURE__ */ jsx(DeviceSelector, {
|
|
57
|
+
value: t3,
|
|
72
58
|
desktopLabel: "Full view",
|
|
73
|
-
onValueChange:
|
|
59
|
+
onValueChange: _temp4
|
|
74
60
|
});
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
} else
|
|
78
|
-
let
|
|
79
|
-
if ($[
|
|
80
|
-
|
|
61
|
+
$[5] = t3;
|
|
62
|
+
$[6] = t4;
|
|
63
|
+
} else t4 = $[6];
|
|
64
|
+
let t5;
|
|
65
|
+
if ($[7] !== isCanvasShown) {
|
|
66
|
+
t5 = /* @__PURE__ */ jsx(Button, {
|
|
81
67
|
type: "button",
|
|
82
68
|
variant: "ghost",
|
|
83
69
|
size: "icon",
|
|
84
70
|
disabled: isCanvasShown,
|
|
85
|
-
onClick:
|
|
71
|
+
onClick: _temp5,
|
|
86
72
|
"aria-label": "Hide toolbar",
|
|
87
73
|
className: "text-muted-foreground"
|
|
88
74
|
});
|
|
89
|
-
$[
|
|
75
|
+
$[7] = isCanvasShown;
|
|
76
|
+
$[8] = t5;
|
|
77
|
+
} else t5 = $[8];
|
|
78
|
+
let t6;
|
|
79
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
80
|
+
t6 = /* @__PURE__ */ jsx(X, {});
|
|
81
|
+
$[9] = t6;
|
|
82
|
+
} else t6 = $[9];
|
|
83
|
+
let t7;
|
|
84
|
+
if ($[10] !== t5) {
|
|
85
|
+
t7 = /* @__PURE__ */ jsx(Tooltip$1.TooltipTrigger, {
|
|
86
|
+
render: t5,
|
|
87
|
+
children: t6
|
|
88
|
+
});
|
|
89
|
+
$[10] = t5;
|
|
90
90
|
$[11] = t7;
|
|
91
91
|
} else t7 = $[11];
|
|
92
92
|
let t8;
|
|
93
93
|
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
94
|
-
t8 = /* @__PURE__ */ jsx(
|
|
94
|
+
t8 = /* @__PURE__ */ jsx(Tooltip$1.TooltipContent, { children: "Hide toolbar" });
|
|
95
95
|
$[12] = t8;
|
|
96
96
|
} else t8 = $[12];
|
|
97
97
|
let t9;
|
|
98
98
|
if ($[13] !== t7) {
|
|
99
|
-
t9 = /* @__PURE__ */ jsx(
|
|
100
|
-
|
|
101
|
-
children: t8
|
|
99
|
+
t9 = /* @__PURE__ */ jsx("div", {
|
|
100
|
+
className: "-ml-2 flex items-center gap-2",
|
|
101
|
+
children: /* @__PURE__ */ jsxs(Tooltip$1.Tooltip, { children: [t7, t8] })
|
|
102
102
|
});
|
|
103
103
|
$[13] = t7;
|
|
104
104
|
$[14] = t9;
|
|
105
105
|
} else t9 = $[14];
|
|
106
106
|
let t10;
|
|
107
|
-
if ($[15]
|
|
108
|
-
t10 = /* @__PURE__ */
|
|
109
|
-
$[15] = t10;
|
|
110
|
-
} else t10 = $[15];
|
|
111
|
-
let t11;
|
|
112
|
-
if ($[16] !== t9) {
|
|
113
|
-
t11 = /* @__PURE__ */ jsx("div", {
|
|
114
|
-
className: "-ml-2 flex items-center gap-2",
|
|
115
|
-
children: /* @__PURE__ */ jsxs(Tooltip$1.Tooltip, { children: [t9, t10] })
|
|
116
|
-
});
|
|
117
|
-
$[16] = t9;
|
|
118
|
-
$[17] = t11;
|
|
119
|
-
} else t11 = $[17];
|
|
120
|
-
let t12;
|
|
121
|
-
if ($[18] !== t11 || $[19] !== t6) {
|
|
122
|
-
t12 = /* @__PURE__ */ jsxs("div", {
|
|
107
|
+
if ($[15] !== t4 || $[16] !== t9) {
|
|
108
|
+
t10 = /* @__PURE__ */ jsxs("div", {
|
|
123
109
|
className: "flex shrink-0 items-center gap-6 self-stretch",
|
|
124
|
-
children: [
|
|
110
|
+
children: [t4, t9]
|
|
125
111
|
});
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
128
|
-
$[
|
|
129
|
-
} else
|
|
130
|
-
let
|
|
131
|
-
if ($[
|
|
132
|
-
|
|
112
|
+
$[15] = t4;
|
|
113
|
+
$[16] = t9;
|
|
114
|
+
$[17] = t10;
|
|
115
|
+
} else t10 = $[17];
|
|
116
|
+
let t11;
|
|
117
|
+
if ($[18] !== t10 || $[19] !== t2) {
|
|
118
|
+
t11 = /* @__PURE__ */ jsxs(FloatingToolbar, {
|
|
133
119
|
className: "fixed bottom-2 w-max justify-between gap-6 transition-none",
|
|
134
|
-
children: [
|
|
120
|
+
children: [t2, t10]
|
|
135
121
|
});
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
} else
|
|
140
|
-
return
|
|
122
|
+
$[18] = t10;
|
|
123
|
+
$[19] = t2;
|
|
124
|
+
$[20] = t11;
|
|
125
|
+
} else t11 = $[20];
|
|
126
|
+
return t11;
|
|
141
127
|
};
|
|
142
128
|
function _temp(state) {
|
|
143
129
|
return state.context.isToolbarHidden;
|
|
@@ -145,13 +131,16 @@ function _temp(state) {
|
|
|
145
131
|
function _temp2(state_0) {
|
|
146
132
|
return state_0.context.viewportMode;
|
|
147
133
|
}
|
|
148
|
-
function _temp3(
|
|
134
|
+
function _temp3(checked) {
|
|
135
|
+
return previewStore.send({ type: checked ? "showCanvas" : "hideCanvas" });
|
|
136
|
+
}
|
|
137
|
+
function _temp4(device) {
|
|
149
138
|
return previewStore.send({
|
|
150
139
|
type: "setViewportMode",
|
|
151
140
|
mode: device === "desktop" ? "full" : device
|
|
152
141
|
});
|
|
153
142
|
}
|
|
154
|
-
function
|
|
143
|
+
function _temp5() {
|
|
155
144
|
return previewStore.send({ type: "hideToolbar" });
|
|
156
145
|
}
|
|
157
146
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { useSignInRedirect } from "../../lib/auth.js";
|
|
2
2
|
import { useLocation } from "../navigation/navigation.js";
|
|
3
|
+
import { useSignInShortcut } from "./signInShortcut.js";
|
|
3
4
|
import { STUDIO_BASE_PATH } from "../studio/routes.js";
|
|
4
5
|
import { AuthGate } from "../../components/AuthGate.js";
|
|
5
6
|
import { AuthenticatedCamoxProvider } from "./AuthenticatedCamoxProvider.js";
|
|
6
|
-
import { CoreCamoxProvider
|
|
7
|
-
import { LocalhostPreviewProvider } from "./LocalhostPreviewProvider.js";
|
|
7
|
+
import { CoreCamoxProvider } from "./CoreCamoxProvider.js";
|
|
8
8
|
import { c } from "react/compiler-runtime";
|
|
9
9
|
import * as React from "react";
|
|
10
10
|
import { jsx } from "react/jsx-runtime";
|
|
11
11
|
|
|
12
12
|
//#region src/features/provider/CamoxProvider.tsx
|
|
13
13
|
function UnauthenticatedExperience(t0) {
|
|
14
|
-
const $ = c(
|
|
14
|
+
const $ = c(10);
|
|
15
15
|
const { children } = t0;
|
|
16
16
|
const { pathname } = useLocation();
|
|
17
17
|
let t1;
|
|
@@ -48,25 +48,17 @@ function UnauthenticatedExperience(t0) {
|
|
|
48
48
|
t4 = $[7];
|
|
49
49
|
}
|
|
50
50
|
React.useEffect(t3, t4);
|
|
51
|
+
useSignInShortcut(!isStudio);
|
|
51
52
|
if (isStudio) return null;
|
|
52
|
-
if (isLocalhostPreview()) {
|
|
53
|
-
let t5;
|
|
54
|
-
if ($[8] !== children) {
|
|
55
|
-
t5 = /* @__PURE__ */ jsx(LocalhostPreviewProvider, { children });
|
|
56
|
-
$[8] = children;
|
|
57
|
-
$[9] = t5;
|
|
58
|
-
} else t5 = $[9];
|
|
59
|
-
return t5;
|
|
60
|
-
}
|
|
61
53
|
let t5;
|
|
62
|
-
if ($[
|
|
54
|
+
if ($[8] !== children) {
|
|
63
55
|
t5 = /* @__PURE__ */ jsx("div", {
|
|
64
56
|
className: "bg-background min-h-screen",
|
|
65
57
|
children
|
|
66
58
|
});
|
|
67
|
-
$[
|
|
68
|
-
$[
|
|
69
|
-
} else t5 = $[
|
|
59
|
+
$[8] = children;
|
|
60
|
+
$[9] = t5;
|
|
61
|
+
} else t5 = $[9];
|
|
70
62
|
return t5;
|
|
71
63
|
}
|
|
72
64
|
function CamoxProvider(props) {
|
|
@@ -9,11 +9,6 @@ import { jsx } from "react/jsx-runtime";
|
|
|
9
9
|
import { replaceEqualDeep, useQueryClient } from "@tanstack/react-query";
|
|
10
10
|
|
|
11
11
|
//#region src/features/provider/CoreCamoxProvider.tsx
|
|
12
|
-
function isLocalhostPreview() {
|
|
13
|
-
if (typeof window === "undefined") return false;
|
|
14
|
-
const { hostname } = window.location;
|
|
15
|
-
return hostname === "localhost" || hostname.endsWith(".localhost") || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "::1";
|
|
16
|
-
}
|
|
17
12
|
function CoreCamoxProvider({ apiUrl, authenticationUrl, camoxApp, children, projectUuid, initialAuthenticated = false, initialProject }) {
|
|
18
13
|
const queryClient = useQueryClient();
|
|
19
14
|
const authClient = React.useMemo(() => createCamoxAuthClient(apiUrl), [apiUrl]);
|
|
@@ -94,4 +89,4 @@ function createWindowDraftScope(queryClient) {
|
|
|
94
89
|
}
|
|
95
90
|
|
|
96
91
|
//#endregion
|
|
97
|
-
export { CoreCamoxProvider
|
|
92
|
+
export { CoreCamoxProvider };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useSignInRedirect } from "../../lib/auth.js";
|
|
2
|
+
import { TOGGLE_CANVAS_SHORTCUT } from "../preview/previewConstants.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/features/provider/signInShortcut.ts
|
|
7
|
+
/** Marks the URL a sign-in returns to, so the Studio opens on the Canvas there. */
|
|
8
|
+
const SHOW_CANVAS_PARAM = "camox-show-canvas";
|
|
9
|
+
function showCanvasCallbackHref() {
|
|
10
|
+
const url = new URL(window.location.href);
|
|
11
|
+
url.searchParams.set(SHOW_CANVAS_PARAM, "");
|
|
12
|
+
return url.href;
|
|
13
|
+
}
|
|
14
|
+
function isTyping() {
|
|
15
|
+
const element = document.activeElement;
|
|
16
|
+
return element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement || element instanceof HTMLElement && element.isContentEditable;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* While signed out, the shortcut that shows the Canvas signs in instead, then shows the Canvas
|
|
20
|
+
* on the page it was pressed on. Fields keep it, since sites often submit forms with it.
|
|
21
|
+
*/
|
|
22
|
+
function useSignInShortcut(enabled) {
|
|
23
|
+
const $ = c(4);
|
|
24
|
+
const signIn = useSignInRedirect(showCanvasCallbackHref);
|
|
25
|
+
let t0;
|
|
26
|
+
let t1;
|
|
27
|
+
if ($[0] !== enabled || $[1] !== signIn) {
|
|
28
|
+
t0 = () => {
|
|
29
|
+
if (!enabled) return;
|
|
30
|
+
const handleKeyDown = (event) => {
|
|
31
|
+
if (event.key !== TOGGLE_CANVAS_SHORTCUT.key || !(event.metaKey || event.ctrlKey)) return;
|
|
32
|
+
if (event.altKey || event.shiftKey || event.defaultPrevented || isTyping()) return;
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
signIn();
|
|
35
|
+
};
|
|
36
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
37
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
38
|
+
};
|
|
39
|
+
t1 = [enabled, signIn];
|
|
40
|
+
$[0] = enabled;
|
|
41
|
+
$[1] = signIn;
|
|
42
|
+
$[2] = t0;
|
|
43
|
+
$[3] = t1;
|
|
44
|
+
} else {
|
|
45
|
+
t0 = $[2];
|
|
46
|
+
t1 = $[3];
|
|
47
|
+
}
|
|
48
|
+
React.useEffect(t0, t1);
|
|
49
|
+
}
|
|
50
|
+
/** Whether a sign-in from the shortcut led here. Removes the mark, so it shows the Canvas once. */
|
|
51
|
+
function takeShowCanvasRequest() {
|
|
52
|
+
const url = new URL(window.location.href);
|
|
53
|
+
if (!url.searchParams.has(SHOW_CANVAS_PARAM)) return false;
|
|
54
|
+
url.searchParams.delete(SHOW_CANVAS_PARAM);
|
|
55
|
+
window.history.replaceState(window.history.state, "", url);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { takeShowCanvasRequest, useSignInShortcut };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { previewStore, selectIsCanvasShown } from "../preview/previewStore.js";
|
|
2
2
|
import { shownRecordPage } from "../preview/pageRecord.js";
|
|
3
3
|
import { Navbar } from "../studio/components/Navbar.js";
|
|
4
|
-
import { PreviewToolbar } from "../preview/components/PreviewToolbar.js";
|
|
5
4
|
import { EditingFallbackContext } from "./editingFallback.js";
|
|
5
|
+
import { PreviewToolbar } from "../preview/components/PreviewToolbar.js";
|
|
6
6
|
import { StudioEditingFallback } from "../preview/components/StudioEditingFallback.js";
|
|
7
7
|
import { ChatSidebar } from "../studio/components/ChatSidebar.js";
|
|
8
8
|
import { FollowAgentProvider } from "../studio/FollowAgentProvider.js";
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useAuthState, useSignInRedirect } from "../../lib/auth.js";
|
|
2
2
|
import { DraftScopeContext } from "../../lib/draft-scope.js";
|
|
3
3
|
import { DerivedPageContent } from "../page/DerivedPageContent.js";
|
|
4
|
+
import { useSignInShortcut } from "../provider/signInShortcut.js";
|
|
4
5
|
import { PreviewDocumentContext } from "./PreviewDocumentContext.js";
|
|
5
6
|
import { PreviewActivation } from "../preview/components/PreviewActivation.js";
|
|
6
7
|
import { Frame } from "../preview/components/Frame.js";
|
|
7
8
|
import { PreviewSignInPage } from "../provider/PreviewSignInPage.js";
|
|
8
|
-
import { CoreCamoxProvider
|
|
9
|
+
import { CoreCamoxProvider } from "../provider/CoreCamoxProvider.js";
|
|
9
10
|
import { CuratedPageContent } from "../page/CuratedPageContent.js";
|
|
10
11
|
import { EditingFallbackSlot } from "./editingFallback.js";
|
|
11
12
|
import { PageNavigationProvider } from "./pageNavigation.js";
|
|
@@ -96,7 +97,6 @@ function PageApp(t0) {
|
|
|
96
97
|
return t6;
|
|
97
98
|
}
|
|
98
99
|
const LazyEditablePageExperience = React.lazy(() => import("../preview/EditablePageExperience.js").then((module) => ({ default: module.EditablePageExperience })));
|
|
99
|
-
const LazyLocalhostPreviewProvider = React.lazy(() => import("../provider/LocalhostPreviewProvider.js").then((module) => ({ default: module.LocalhostPreviewProvider })));
|
|
100
100
|
/** Editing lists and adds any block, so it waits for every definition, not only the page's. */
|
|
101
101
|
function AllBlocks({ camoxApp, children }) {
|
|
102
102
|
React.use(camoxApp.loadAllBlocks());
|
|
@@ -116,7 +116,7 @@ var EditingActivationBoundary = class extends React.Component {
|
|
|
116
116
|
};
|
|
117
117
|
const subscribeToHydration = () => () => {};
|
|
118
118
|
function PageExperience(t0) {
|
|
119
|
-
const $ = c(
|
|
119
|
+
const $ = c(38);
|
|
120
120
|
const { camoxApp, input, queryClient, studioDocument } = t0;
|
|
121
121
|
const { isAuthenticated, isLoading } = useAuthState();
|
|
122
122
|
const hasHydrated = React.useSyncExternalStore(subscribeToHydration, _temp, _temp2);
|
|
@@ -145,6 +145,7 @@ function PageExperience(t0) {
|
|
|
145
145
|
t2 = $[5];
|
|
146
146
|
}
|
|
147
147
|
React.useEffect(t1, t2);
|
|
148
|
+
useSignInShortcut(hasHydrated && !studioOnly && !isAuthenticated && !isLoading);
|
|
148
149
|
let t3;
|
|
149
150
|
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
150
151
|
t3 = /* @__PURE__ */ jsx("div", {
|
|
@@ -248,50 +249,21 @@ function PageExperience(t0) {
|
|
|
248
249
|
return t11;
|
|
249
250
|
}
|
|
250
251
|
if (studioOnly) return null;
|
|
251
|
-
if (hasHydrated && isLocalhostPreview()) {
|
|
252
|
-
let t7;
|
|
253
|
-
if ($[35] !== readOnlyPage) {
|
|
254
|
-
t7 = /* @__PURE__ */ jsx(LazyLocalhostPreviewProvider, { children: readOnlyPage });
|
|
255
|
-
$[35] = readOnlyPage;
|
|
256
|
-
$[36] = t7;
|
|
257
|
-
} else t7 = $[36];
|
|
258
|
-
let t8;
|
|
259
|
-
if ($[37] !== camoxApp || $[38] !== t7) {
|
|
260
|
-
t8 = /* @__PURE__ */ jsx(AllBlocks, {
|
|
261
|
-
camoxApp,
|
|
262
|
-
children: t7
|
|
263
|
-
});
|
|
264
|
-
$[37] = camoxApp;
|
|
265
|
-
$[38] = t7;
|
|
266
|
-
$[39] = t8;
|
|
267
|
-
} else t8 = $[39];
|
|
268
|
-
let t9;
|
|
269
|
-
if ($[40] !== readOnlyPage || $[41] !== t8) {
|
|
270
|
-
t9 = /* @__PURE__ */ jsx(React.Suspense, {
|
|
271
|
-
fallback: readOnlyPage,
|
|
272
|
-
children: t8
|
|
273
|
-
});
|
|
274
|
-
$[40] = readOnlyPage;
|
|
275
|
-
$[41] = t8;
|
|
276
|
-
$[42] = t9;
|
|
277
|
-
} else t9 = $[42];
|
|
278
|
-
return t9;
|
|
279
|
-
}
|
|
280
252
|
if (studioDocument) {
|
|
281
253
|
let t7;
|
|
282
|
-
if ($[
|
|
254
|
+
if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
|
|
283
255
|
t7 = { height: "100vh" };
|
|
284
|
-
$[
|
|
285
|
-
} else t7 = $[
|
|
256
|
+
$[35] = t7;
|
|
257
|
+
} else t7 = $[35];
|
|
286
258
|
let t8;
|
|
287
|
-
if ($[
|
|
259
|
+
if ($[36] !== isolatedPage) {
|
|
288
260
|
t8 = /* @__PURE__ */ jsx("div", {
|
|
289
261
|
style: t7,
|
|
290
262
|
children: isolatedPage
|
|
291
263
|
});
|
|
292
|
-
$[
|
|
293
|
-
$[
|
|
294
|
-
} else t8 = $[
|
|
264
|
+
$[36] = isolatedPage;
|
|
265
|
+
$[37] = t8;
|
|
266
|
+
} else t8 = $[37];
|
|
295
267
|
return t8;
|
|
296
268
|
}
|
|
297
269
|
return readOnlyPage;
|
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "camox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"camox": "./bin/camox.mjs"
|
|
@@ -129,9 +129,9 @@
|
|
|
129
129
|
"shiki": "^4.5.0",
|
|
130
130
|
"unhead": "^3.4.3",
|
|
131
131
|
"zod": "^4.6.7",
|
|
132
|
-
"@camox/
|
|
133
|
-
"@camox/
|
|
134
|
-
"@camox/cli": "0.
|
|
132
|
+
"@camox/ui": "0.47.0",
|
|
133
|
+
"@camox/api-contract": "0.47.0",
|
|
134
|
+
"@camox/cli": "0.47.0"
|
|
135
135
|
},
|
|
136
136
|
"devDependencies": {
|
|
137
137
|
"@earendil-works/pi-ai": "1.3.0",
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { actionsStore } from "./actionsStore.js";
|
|
2
|
-
import { useSignInRedirect } from "../../lib/auth.js";
|
|
3
|
-
import { TOGGLE_CANVAS_SHORTCUT } from "../preview/previewConstants.js";
|
|
4
|
-
import { useApplyTheme } from "../studio/useTheme.js";
|
|
5
|
-
import { PreviewPanel } from "../preview/components/PreviewPanel.js";
|
|
6
|
-
import { useAdminShortcuts } from "./useAdminShortcuts.js";
|
|
7
|
-
import { PreviewToolbar } from "../preview/components/PreviewToolbar.js";
|
|
8
|
-
import { c } from "react/compiler-runtime";
|
|
9
|
-
import * as React from "react";
|
|
10
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { Toaster } from "@camox/ui/toaster";
|
|
12
|
-
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
|
|
13
|
-
import studioCssUrl from "virtual:camox-studio-css";
|
|
14
|
-
|
|
15
|
-
//#region src/features/provider/LocalhostPreviewProvider.tsx
|
|
16
|
-
function LocalhostPreviewProvider(t0) {
|
|
17
|
-
const $ = c(22);
|
|
18
|
-
const { children } = t0;
|
|
19
|
-
const signInRedirect = useSignInRedirect();
|
|
20
|
-
const { resolvedTheme } = useApplyTheme();
|
|
21
|
-
const [isSignInOpen, setIsSignInOpen] = React.useState(false);
|
|
22
|
-
useAdminShortcuts();
|
|
23
|
-
let t1;
|
|
24
|
-
let t2;
|
|
25
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
26
|
-
t1 = () => {
|
|
27
|
-
const actions = [{
|
|
28
|
-
id: "sign-in-to-edit",
|
|
29
|
-
label: "Sign in to edit",
|
|
30
|
-
aliases: ["Show canvas", "Edit mode"],
|
|
31
|
-
groupLabel: "Website",
|
|
32
|
-
checkIfAvailable: _temp,
|
|
33
|
-
execute: () => setIsSignInOpen(true),
|
|
34
|
-
shortcut: TOGGLE_CANVAS_SHORTCUT
|
|
35
|
-
}];
|
|
36
|
-
actionsStore.send({
|
|
37
|
-
type: "registerManyActions",
|
|
38
|
-
actions
|
|
39
|
-
});
|
|
40
|
-
return () => {
|
|
41
|
-
actionsStore.send({
|
|
42
|
-
type: "unregisterManyActions",
|
|
43
|
-
ids: actions.map(_temp2)
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
t2 = [];
|
|
48
|
-
$[0] = t1;
|
|
49
|
-
$[1] = t2;
|
|
50
|
-
} else {
|
|
51
|
-
t1 = $[0];
|
|
52
|
-
t2 = $[1];
|
|
53
|
-
}
|
|
54
|
-
React.useEffect(t1, t2);
|
|
55
|
-
let t3;
|
|
56
|
-
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
57
|
-
t3 = /* @__PURE__ */ jsx("link", {
|
|
58
|
-
rel: "stylesheet",
|
|
59
|
-
href: studioCssUrl,
|
|
60
|
-
"data-camox-studio": true
|
|
61
|
-
});
|
|
62
|
-
$[2] = t3;
|
|
63
|
-
} else t3 = $[2];
|
|
64
|
-
let t4;
|
|
65
|
-
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
66
|
-
t4 = { bottom: "1rem" };
|
|
67
|
-
$[3] = t4;
|
|
68
|
-
} else t4 = $[3];
|
|
69
|
-
let t5;
|
|
70
|
-
if ($[4] !== resolvedTheme) {
|
|
71
|
-
t5 = /* @__PURE__ */ jsx(Toaster, {
|
|
72
|
-
theme: resolvedTheme,
|
|
73
|
-
position: "bottom-right",
|
|
74
|
-
offset: t4
|
|
75
|
-
});
|
|
76
|
-
$[4] = resolvedTheme;
|
|
77
|
-
$[5] = t5;
|
|
78
|
-
} else t5 = $[5];
|
|
79
|
-
let t6;
|
|
80
|
-
if ($[6] !== children) {
|
|
81
|
-
t6 = /* @__PURE__ */ jsx(PreviewPanel, { children });
|
|
82
|
-
$[6] = children;
|
|
83
|
-
$[7] = t6;
|
|
84
|
-
} else t6 = $[7];
|
|
85
|
-
let t7;
|
|
86
|
-
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
87
|
-
t7 = /* @__PURE__ */ jsx(PreviewToolbar, { onCanvasShownChange: (checked) => {
|
|
88
|
-
if (checked) setIsSignInOpen(true);
|
|
89
|
-
} });
|
|
90
|
-
$[8] = t7;
|
|
91
|
-
} else t7 = $[8];
|
|
92
|
-
let t8;
|
|
93
|
-
if ($[9] !== t6) {
|
|
94
|
-
t8 = /* @__PURE__ */ jsxs("div", {
|
|
95
|
-
className: "bg-background relative flex h-screen flex-col overflow-hidden",
|
|
96
|
-
children: [t6, t7]
|
|
97
|
-
});
|
|
98
|
-
$[9] = t6;
|
|
99
|
-
$[10] = t8;
|
|
100
|
-
} else t8 = $[10];
|
|
101
|
-
let t9;
|
|
102
|
-
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
103
|
-
t9 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Sign in to edit" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "You need to sign in before you can show the canvas." })] });
|
|
104
|
-
$[11] = t9;
|
|
105
|
-
} else t9 = $[11];
|
|
106
|
-
let t10;
|
|
107
|
-
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
108
|
-
t10 = /* @__PURE__ */ jsx(AlertDialogCancel, {
|
|
109
|
-
variant: "outline",
|
|
110
|
-
size: "default",
|
|
111
|
-
children: "Cancel"
|
|
112
|
-
});
|
|
113
|
-
$[12] = t10;
|
|
114
|
-
} else t10 = $[12];
|
|
115
|
-
let t11;
|
|
116
|
-
if ($[13] !== signInRedirect) {
|
|
117
|
-
t11 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t9, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t10, /* @__PURE__ */ jsx(AlertDialogAction, {
|
|
118
|
-
onClick: signInRedirect,
|
|
119
|
-
children: "Sign in"
|
|
120
|
-
})] })] });
|
|
121
|
-
$[13] = signInRedirect;
|
|
122
|
-
$[14] = t11;
|
|
123
|
-
} else t11 = $[14];
|
|
124
|
-
let t12;
|
|
125
|
-
if ($[15] !== isSignInOpen || $[16] !== t11) {
|
|
126
|
-
t12 = /* @__PURE__ */ jsx(AlertDialog, {
|
|
127
|
-
open: isSignInOpen,
|
|
128
|
-
onOpenChange: setIsSignInOpen,
|
|
129
|
-
children: t11
|
|
130
|
-
});
|
|
131
|
-
$[15] = isSignInOpen;
|
|
132
|
-
$[16] = t11;
|
|
133
|
-
$[17] = t12;
|
|
134
|
-
} else t12 = $[17];
|
|
135
|
-
let t13;
|
|
136
|
-
if ($[18] !== t12 || $[19] !== t5 || $[20] !== t8) {
|
|
137
|
-
t13 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
138
|
-
t3,
|
|
139
|
-
t5,
|
|
140
|
-
t8,
|
|
141
|
-
t12
|
|
142
|
-
] });
|
|
143
|
-
$[18] = t12;
|
|
144
|
-
$[19] = t5;
|
|
145
|
-
$[20] = t8;
|
|
146
|
-
$[21] = t13;
|
|
147
|
-
} else t13 = $[21];
|
|
148
|
-
return t13;
|
|
149
|
-
}
|
|
150
|
-
function _temp2(action) {
|
|
151
|
-
return action.id;
|
|
152
|
-
}
|
|
153
|
-
function _temp() {
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
//#endregion
|
|
158
|
-
export { LocalhostPreviewProvider };
|