camox 0.51.0 → 0.52.2
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/core/createApp.d.ts +1 -0
- package/dist/core/createApp.js +1 -0
- package/dist/core/editing/contentEdits.js +78 -0
- package/dist/core/editing/createEditableBlock.js +277 -311
- package/dist/core/lib/contentType.js +2 -2
- package/dist/core/recordItem.js +3 -3
- package/dist/features/canvas/CamoxCanvas.js +15 -15
- package/dist/features/canvas/CanvasLoadingScreen.js +15 -11
- package/dist/features/canvas/CanvasPageFrame.js +81 -87
- package/dist/features/canvas/CanvasPreviewPageSlot.js +1 -1
- package/dist/features/canvas/DerivedPagePathInput.js +12 -12
- package/dist/features/canvas/canvasOverlayGeometry.js +1 -1
- package/dist/features/canvas/canvasStore.js +2 -2
- package/dist/features/canvas/sidebar/CuratedPageInspector.js +1 -1
- package/dist/features/canvas/sidebar/LayoutPageBlocks.js +23 -31
- package/dist/features/canvas/useCanvasCamera.js +1 -1
- package/dist/features/canvas/useDiscoveredPreviewPaths.js +16 -9
- package/dist/features/page/CuratedPageContent.js +1 -1
- package/dist/features/preview/CamoxPreview.d.ts +8 -4
- package/dist/features/preview/CamoxPreview.js +257 -442
- package/dist/features/preview/EditablePageContent.js +244 -2
- package/dist/features/preview/EditablePageExperience.js +2 -4
- package/dist/features/preview/components/AddBlockSheet.js +55 -15
- package/dist/features/preview/components/BlockActionsPopover.js +12 -16
- package/dist/features/preview/components/BlockPeek.js +66 -0
- package/dist/features/preview/components/BlockThumbnail.js +134 -119
- package/dist/features/preview/components/CanvasPreview.js +1 -1
- package/dist/features/preview/components/CreatePageModal.js +150 -156
- package/dist/features/preview/components/Frame.js +27 -4
- package/dist/features/preview/components/MobilePreviewDrawer.js +1 -1
- package/dist/features/preview/components/PageInfo.js +161 -126
- package/dist/features/preview/components/PagePicker.js +2 -2
- package/dist/features/preview/components/PageTree.js +174 -190
- package/dist/features/preview/components/PreviewPanel.js +3 -3
- package/dist/features/preview/components/ReferenceFieldEditor.js +4 -4
- package/dist/features/preview/components/ReferenceListFieldEditor.js +4 -4
- package/dist/features/preview/components/RemovedBlockPlaceholder.js +37 -70
- package/dist/features/preview/components/RepeatableItemsList.js +1 -1
- package/dist/features/preview/components/SelectionEditor.js +248 -256
- package/dist/features/preview/components/StudioEditingFallback.js +22 -26
- package/dist/features/preview/components/useFieldWriter.js +19 -19
- package/dist/features/preview/components/useRecordView.js +105 -147
- package/dist/features/preview/components/useRepeatableItemActions.js +0 -2
- package/dist/features/preview/pageRecord.js +30 -24
- package/dist/features/preview/previewStore.js +2 -0
- package/dist/features/preview/studioNotice.js +20 -0
- package/dist/features/provider/AuthenticatedCamoxProvider.js +46 -30
- package/dist/features/renderer/RendererApp.js +542 -0
- package/dist/features/renderer/RendererFrames.js +450 -0
- package/dist/features/renderer/definitionAnswers.js +26 -0
- package/dist/features/renderer/protocol.js +35 -0
- package/dist/features/renderer/rendererHost.js +249 -0
- package/dist/features/renderer/studioConnection.js +186 -0
- package/dist/features/routes/pageRuntime.js +7 -2
- package/dist/features/runtime/RuntimeChrome.js +2 -5
- package/dist/features/runtime/assetPrefix.js +14 -0
- package/dist/features/runtime/breadcrumbs.js +1 -1
- package/dist/features/runtime/editingFallback.js +4 -8
- package/dist/features/runtime/livePages.js +1 -1
- package/dist/features/runtime/pageApp.js +57 -83
- package/dist/features/runtime/pageClient.js +1 -1
- package/dist/features/runtime/pageNavigation.js +3 -2
- package/dist/features/runtime/publicCache.js +15 -3
- package/dist/features/runtime/publishingDraft.js +23 -0
- package/dist/features/runtime/rendererClient.d.ts +8 -0
- package/dist/features/runtime/rendererClient.js +77 -0
- package/dist/features/runtime/runtime.d.ts +9 -0
- package/dist/features/runtime/runtime.js +36 -17
- package/dist/features/runtime/runtimeRoutes.d.ts +2 -0
- package/dist/features/runtime/runtimeRoutes.js +2 -0
- package/dist/features/runtime/worker.d.ts +10 -1
- package/dist/features/runtime/worker.js +20 -7
- package/dist/features/studio/FollowAgentProvider.js +10 -10
- package/dist/features/studio/components/ProjectMenu.js +1 -1
- package/dist/features/studio/components/ReviewDraftSheet.js +242 -138
- package/dist/features/studio/components/ThreadMessages.js +100 -65
- package/dist/features/studio/components/UserButton.js +1 -1
- package/dist/features/vite/definitionsSync.js +1 -1
- package/dist/features/vite/hostedChecks.js +127 -0
- package/dist/features/vite/runtimeDev.js +26 -0
- package/dist/features/vite/vite.js +33 -5
- package/dist/hooks/use-page-destinations.js +10 -10
- package/dist/lib/revisions.js +20 -0
- package/dist/lib/studio-definitions.js +160 -0
- package/dist/lib/studio-reads.js +65 -21
- package/dist/lib/use-project-room.js +16 -10
- package/dist/package.js +1 -1
- package/dist/studio.css +1 -1
- package/package.json +8 -4
- package/skills/camox/SKILL.md +4 -0
- package/skills/camox/references/artifacts.md +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { toast } from "@camox/ui/toaster";
|
|
3
|
+
|
|
4
|
+
//#region src/features/preview/studioNotice.ts
|
|
5
|
+
/** Shows a notice in this document's toasts. */
|
|
6
|
+
function showNotice({ tone, message }) {
|
|
7
|
+
toast[tone](message);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Where the notices of a page's blocks go. The renderer frame's document shows no toasts: it
|
|
11
|
+
* hands them to the studio, which shows them.
|
|
12
|
+
*/
|
|
13
|
+
const StudioNoticeContext = React.createContext(null);
|
|
14
|
+
/** Tells the editor something, in the studio's toasts. */
|
|
15
|
+
function useStudioNotice() {
|
|
16
|
+
return React.use(StudioNoticeContext) ?? showNotice;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { StudioNoticeContext, showNotice, useStudioNotice };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AuthContext, useAuthActions } from "../../lib/auth.js";
|
|
2
2
|
import { useDraftScope } from "../../lib/draft-scope.js";
|
|
3
3
|
import { reads, useReadQuery, useStudioCache } from "../../lib/studio-reads.js";
|
|
4
|
+
import { RevisionsContext, createRevisions } from "../../lib/revisions.js";
|
|
4
5
|
import { useAdminShortcuts } from "./useAdminShortcuts.js";
|
|
5
6
|
import { useApplyTheme, useThemeActions } from "../studio/useTheme.js";
|
|
6
7
|
import { usePreviewPagesActions, useShowCanvasAction } from "../preview/CamoxPreview.js";
|
|
@@ -10,13 +11,13 @@ import { draftNoticeMessage } from "../studio/draftNotice.js";
|
|
|
10
11
|
import { CommandPalette, useCommandPaletteActions } from "./components/CommandPalette.js";
|
|
11
12
|
import { c } from "react/compiler-runtime";
|
|
12
13
|
import * as React from "react";
|
|
13
|
-
import {
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
15
|
import { Toaster, toast } from "@camox/ui/toaster";
|
|
15
16
|
import studioCssUrl from "virtual:camox-studio-css";
|
|
16
17
|
|
|
17
18
|
//#region src/features/provider/AuthenticatedCamoxProvider.tsx
|
|
18
19
|
function AuthenticatedCamoxProvider(t0) {
|
|
19
|
-
const $ = c(
|
|
20
|
+
const $ = c(18);
|
|
20
21
|
const { children } = t0;
|
|
21
22
|
useAdminShortcuts();
|
|
22
23
|
useCommandPaletteActions();
|
|
@@ -48,49 +49,64 @@ function AuthenticatedCamoxProvider(t0) {
|
|
|
48
49
|
t3 = $[4];
|
|
49
50
|
}
|
|
50
51
|
React.useEffect(t2, t3);
|
|
52
|
+
const [revisions] = React.useState(createRevisions);
|
|
51
53
|
let t4;
|
|
52
|
-
if ($[5] !== draftScope) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
if ($[5] !== draftScope || $[6] !== revisions) {
|
|
55
|
+
let t5;
|
|
56
|
+
if ($[8] !== revisions) {
|
|
57
|
+
t5 = (revision) => revisions.announce(revision);
|
|
58
|
+
$[8] = revisions;
|
|
59
|
+
$[9] = t5;
|
|
60
|
+
} else t5 = $[9];
|
|
61
|
+
t4 = {
|
|
62
|
+
onDraftEnded(ended) {
|
|
63
|
+
if (ended.draftId !== draftScope.current()) return;
|
|
64
|
+
draftScope.leave(ended, { notice: true });
|
|
65
|
+
},
|
|
66
|
+
onRevision: t5
|
|
67
|
+
};
|
|
57
68
|
$[5] = draftScope;
|
|
58
|
-
$[6] =
|
|
59
|
-
|
|
69
|
+
$[6] = revisions;
|
|
70
|
+
$[7] = t4;
|
|
71
|
+
} else t4 = $[7];
|
|
60
72
|
useProjectRoom(apiUrl, project?.id, studioCache, t4);
|
|
61
73
|
const { resolvedTheme } = useApplyTheme();
|
|
62
74
|
let t5;
|
|
63
|
-
if ($[
|
|
75
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
64
76
|
t5 = /* @__PURE__ */ jsx("link", {
|
|
65
77
|
rel: "stylesheet",
|
|
66
78
|
href: studioCssUrl,
|
|
67
79
|
"data-camox-studio": true
|
|
68
80
|
});
|
|
69
|
-
$[
|
|
70
|
-
} else t5 = $[
|
|
81
|
+
$[10] = t5;
|
|
82
|
+
} else t5 = $[10];
|
|
71
83
|
let t6;
|
|
72
|
-
if ($[
|
|
84
|
+
if ($[11] !== resolvedTheme) {
|
|
73
85
|
t6 = /* @__PURE__ */ jsx(Toaster, { theme: resolvedTheme });
|
|
74
|
-
$[
|
|
75
|
-
$[
|
|
76
|
-
} else t6 = $[
|
|
86
|
+
$[11] = resolvedTheme;
|
|
87
|
+
$[12] = t6;
|
|
88
|
+
} else t6 = $[12];
|
|
77
89
|
let t7;
|
|
78
|
-
if ($[
|
|
90
|
+
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
|
79
91
|
t7 = /* @__PURE__ */ jsx(CommandPalette, {});
|
|
80
|
-
$[
|
|
81
|
-
} else t7 = $[
|
|
92
|
+
$[13] = t7;
|
|
93
|
+
} else t7 = $[13];
|
|
82
94
|
let t8;
|
|
83
|
-
if ($[
|
|
84
|
-
t8 = /* @__PURE__ */ jsxs(
|
|
85
|
-
|
|
86
|
-
children
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
if ($[14] !== children || $[15] !== revisions || $[16] !== t6) {
|
|
96
|
+
t8 = /* @__PURE__ */ jsxs(RevisionsContext, {
|
|
97
|
+
value: revisions,
|
|
98
|
+
children: [
|
|
99
|
+
t5,
|
|
100
|
+
children,
|
|
101
|
+
t6,
|
|
102
|
+
t7
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
$[14] = children;
|
|
106
|
+
$[15] = revisions;
|
|
107
|
+
$[16] = t6;
|
|
108
|
+
$[17] = t8;
|
|
109
|
+
} else t8 = $[17];
|
|
94
110
|
return t8;
|
|
95
111
|
}
|
|
96
112
|
function _temp(notice) {
|
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
import { ViewLocaleContext } from "../../lib/view-locale-context.js";
|
|
2
|
+
import { NavigationProvider } from "../navigation/navigation.js";
|
|
3
|
+
import { reads, useRead } from "../../lib/studio-reads.js";
|
|
4
|
+
import { ArtifactStudioContext, ArtifactsRunContext } from "../../core/hooks/useArtifactHost.js";
|
|
5
|
+
import { EditableSurfaceContext } from "../../core/hooks/useIsEditable.js";
|
|
6
|
+
import { CanvasWorkspaceContext } from "../canvas/canvasZoom.js";
|
|
7
|
+
import { PreviewEditingOwnerContext } from "../preview/previewSelection.js";
|
|
8
|
+
import { StudioNoticeContext } from "../preview/studioNotice.js";
|
|
9
|
+
import { ContentEditsContext } from "../../core/editing/contentEdits.js";
|
|
10
|
+
import { PreviewDocumentContext } from "../runtime/PreviewDocumentContext.js";
|
|
11
|
+
import { FrameContext } from "../preview/components/Frame.js";
|
|
12
|
+
import { DerivedPageContent } from "../page/DerivedPageContent.js";
|
|
13
|
+
import { BlockPeek } from "../preview/components/BlockPeek.js";
|
|
14
|
+
import { EditablePageContent } from "../preview/EditablePageContent.js";
|
|
15
|
+
import { c } from "react/compiler-runtime";
|
|
16
|
+
import * as React from "react";
|
|
17
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
import { HydrationBoundary } from "@tanstack/react-query";
|
|
19
|
+
import { createPortal } from "react-dom";
|
|
20
|
+
|
|
21
|
+
//#region src/features/renderer/RendererApp.tsx
|
|
22
|
+
/**
|
|
23
|
+
* The renderer document's app: it renders the page of each frame the studio gives it into that
|
|
24
|
+
* frame's slot, with the site's code, and tells the studio how it went. It never draws any of
|
|
25
|
+
* the studio: the studio keeps its overlays, sidebars and Canvas.
|
|
26
|
+
*
|
|
27
|
+
* `codeLoaded` settles once the site's code loaded: each frame waits for it, and code that fails
|
|
28
|
+
* to load fails each frame, as a page that throws does.
|
|
29
|
+
*/
|
|
30
|
+
function RendererApp(t0) {
|
|
31
|
+
const $ = c(27);
|
|
32
|
+
const { connection, camoxApp, codeLoaded, projectUuid, runtimeBasePath } = t0;
|
|
33
|
+
const frames = React.useSyncExternalStore(connection.subscribe, connection.frames, connection.frames);
|
|
34
|
+
const thumbnails = React.useSyncExternalStore(connection.subscribe, connection.thumbnails, connection.thumbnails);
|
|
35
|
+
const t1 = connection.edit;
|
|
36
|
+
let t2;
|
|
37
|
+
if ($[0] !== connection) {
|
|
38
|
+
t2 = (notice) => connection.notify(notice);
|
|
39
|
+
$[0] = connection;
|
|
40
|
+
$[1] = t2;
|
|
41
|
+
} else t2 = $[1];
|
|
42
|
+
let t3;
|
|
43
|
+
if ($[2] !== camoxApp || $[3] !== codeLoaded || $[4] !== connection || $[5] !== frames || $[6] !== projectUuid || $[7] !== runtimeBasePath) {
|
|
44
|
+
let t4;
|
|
45
|
+
if ($[9] !== camoxApp || $[10] !== codeLoaded || $[11] !== connection || $[12] !== projectUuid || $[13] !== runtimeBasePath) {
|
|
46
|
+
t4 = (frame) => createPortal(/* @__PURE__ */ jsx(RendererFrameContent, {
|
|
47
|
+
frame,
|
|
48
|
+
connection,
|
|
49
|
+
camoxApp,
|
|
50
|
+
codeLoaded,
|
|
51
|
+
projectUuid,
|
|
52
|
+
runtimeBasePath
|
|
53
|
+
}), frame.slot, frame.frameId);
|
|
54
|
+
$[9] = camoxApp;
|
|
55
|
+
$[10] = codeLoaded;
|
|
56
|
+
$[11] = connection;
|
|
57
|
+
$[12] = projectUuid;
|
|
58
|
+
$[13] = runtimeBasePath;
|
|
59
|
+
$[14] = t4;
|
|
60
|
+
} else t4 = $[14];
|
|
61
|
+
t3 = frames.map(t4);
|
|
62
|
+
$[2] = camoxApp;
|
|
63
|
+
$[3] = codeLoaded;
|
|
64
|
+
$[4] = connection;
|
|
65
|
+
$[5] = frames;
|
|
66
|
+
$[6] = projectUuid;
|
|
67
|
+
$[7] = runtimeBasePath;
|
|
68
|
+
$[8] = t3;
|
|
69
|
+
} else t3 = $[8];
|
|
70
|
+
let t4;
|
|
71
|
+
if ($[15] !== camoxApp || $[16] !== thumbnails) {
|
|
72
|
+
let t5;
|
|
73
|
+
if ($[18] !== camoxApp) {
|
|
74
|
+
t5 = (t6) => {
|
|
75
|
+
const { thumbnailId, slot, blockType } = t6;
|
|
76
|
+
return createPortal(/* @__PURE__ */ jsx(RendererThumbnail, {
|
|
77
|
+
slot,
|
|
78
|
+
blockType,
|
|
79
|
+
camoxApp
|
|
80
|
+
}), slot, thumbnailId);
|
|
81
|
+
};
|
|
82
|
+
$[18] = camoxApp;
|
|
83
|
+
$[19] = t5;
|
|
84
|
+
} else t5 = $[19];
|
|
85
|
+
t4 = thumbnails.map(t5);
|
|
86
|
+
$[15] = camoxApp;
|
|
87
|
+
$[16] = thumbnails;
|
|
88
|
+
$[17] = t4;
|
|
89
|
+
} else t4 = $[17];
|
|
90
|
+
let t5;
|
|
91
|
+
if ($[20] !== t2 || $[21] !== t3 || $[22] !== t4) {
|
|
92
|
+
t5 = /* @__PURE__ */ jsxs(StudioNoticeContext, {
|
|
93
|
+
value: t2,
|
|
94
|
+
children: [t3, t4]
|
|
95
|
+
});
|
|
96
|
+
$[20] = t2;
|
|
97
|
+
$[21] = t3;
|
|
98
|
+
$[22] = t4;
|
|
99
|
+
$[23] = t5;
|
|
100
|
+
} else t5 = $[23];
|
|
101
|
+
let t6;
|
|
102
|
+
if ($[24] !== connection.edit || $[25] !== t5) {
|
|
103
|
+
t6 = /* @__PURE__ */ jsx(ContentEditsContext, {
|
|
104
|
+
value: t1,
|
|
105
|
+
children: t5
|
|
106
|
+
});
|
|
107
|
+
$[24] = connection.edit;
|
|
108
|
+
$[25] = t5;
|
|
109
|
+
$[26] = t6;
|
|
110
|
+
} else t6 = $[26];
|
|
111
|
+
return t6;
|
|
112
|
+
}
|
|
113
|
+
/** A block's thumbnail, rendered by the draft's code into its frame: nothing for a block it lacks. */
|
|
114
|
+
function RendererThumbnail(t0) {
|
|
115
|
+
const $ = c(9);
|
|
116
|
+
const { slot, blockType, camoxApp } = t0;
|
|
117
|
+
const frameWindow = slot.ownerDocument.defaultView;
|
|
118
|
+
const t1 = frameWindow?.frameElement ?? null;
|
|
119
|
+
let t2;
|
|
120
|
+
if ($[0] !== frameWindow || $[1] !== t1) {
|
|
121
|
+
t2 = {
|
|
122
|
+
window: frameWindow,
|
|
123
|
+
iframeElement: t1
|
|
124
|
+
};
|
|
125
|
+
$[0] = frameWindow;
|
|
126
|
+
$[1] = t1;
|
|
127
|
+
$[2] = t2;
|
|
128
|
+
} else t2 = $[2];
|
|
129
|
+
const frameContext = t2;
|
|
130
|
+
let t3;
|
|
131
|
+
if ($[3] !== blockType || $[4] !== camoxApp) {
|
|
132
|
+
t3 = /* @__PURE__ */ jsx(ThumbnailErrorBoundary, { children: /* @__PURE__ */ jsx(React.Suspense, {
|
|
133
|
+
fallback: null,
|
|
134
|
+
children: /* @__PURE__ */ jsx(ThumbnailBlock, {
|
|
135
|
+
blockType,
|
|
136
|
+
camoxApp
|
|
137
|
+
})
|
|
138
|
+
}) });
|
|
139
|
+
$[3] = blockType;
|
|
140
|
+
$[4] = camoxApp;
|
|
141
|
+
$[5] = t3;
|
|
142
|
+
} else t3 = $[5];
|
|
143
|
+
let t4;
|
|
144
|
+
if ($[6] !== frameContext || $[7] !== t3) {
|
|
145
|
+
t4 = /* @__PURE__ */ jsx(NavigationProvider, {
|
|
146
|
+
location: THUMBNAIL_LOCATION,
|
|
147
|
+
navigate: noNavigation,
|
|
148
|
+
children: /* @__PURE__ */ jsx(FrameContext.Provider, {
|
|
149
|
+
value: frameContext,
|
|
150
|
+
children: t3
|
|
151
|
+
})
|
|
152
|
+
});
|
|
153
|
+
$[6] = frameContext;
|
|
154
|
+
$[7] = t3;
|
|
155
|
+
$[8] = t4;
|
|
156
|
+
} else t4 = $[8];
|
|
157
|
+
return t4;
|
|
158
|
+
}
|
|
159
|
+
const THUMBNAIL_LOCATION = {
|
|
160
|
+
href: "",
|
|
161
|
+
pathname: "/",
|
|
162
|
+
search: "",
|
|
163
|
+
hash: ""
|
|
164
|
+
};
|
|
165
|
+
const noNavigation = () => {};
|
|
166
|
+
var ThumbnailErrorBoundary = class extends React.Component {
|
|
167
|
+
state = { failed: false };
|
|
168
|
+
static getDerivedStateFromError() {
|
|
169
|
+
return { failed: true };
|
|
170
|
+
}
|
|
171
|
+
componentDidCatch(error) {
|
|
172
|
+
console.error("Camox: a block's thumbnail failed to render.", error);
|
|
173
|
+
}
|
|
174
|
+
render() {
|
|
175
|
+
return this.state.failed ? null : this.props.children;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
function ThumbnailBlock(t0) {
|
|
179
|
+
const $ = c(2);
|
|
180
|
+
const { blockType, camoxApp } = t0;
|
|
181
|
+
const block = camoxApp.getBlockById(blockType) ?? (camoxApp.canLoadMoreBlocks() ? React.use(camoxApp.loadBlock(blockType)) : void 0);
|
|
182
|
+
let t1;
|
|
183
|
+
if ($[0] !== block) {
|
|
184
|
+
t1 = block ? /* @__PURE__ */ jsx(BlockPeek, { block }) : null;
|
|
185
|
+
$[0] = block;
|
|
186
|
+
$[1] = t1;
|
|
187
|
+
} else t1 = $[1];
|
|
188
|
+
return t1;
|
|
189
|
+
}
|
|
190
|
+
function locationOf(href) {
|
|
191
|
+
const url = new URL(href);
|
|
192
|
+
return {
|
|
193
|
+
href: url.href,
|
|
194
|
+
pathname: url.pathname,
|
|
195
|
+
search: url.search,
|
|
196
|
+
hash: url.hash
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/** One frame's page, with what the studio says of the frame around it. */
|
|
200
|
+
function RendererFrameContent(t0) {
|
|
201
|
+
const $ = c(59);
|
|
202
|
+
const { frame: t1, connection, camoxApp, codeLoaded, projectUuid, runtimeBasePath } = t0;
|
|
203
|
+
const { frameId, slot, target } = t1;
|
|
204
|
+
const frameWindow = slot.ownerDocument.defaultView;
|
|
205
|
+
const frameElement = frameWindow?.frameElement ?? null;
|
|
206
|
+
let t2;
|
|
207
|
+
if ($[0] !== target.href) {
|
|
208
|
+
t2 = locationOf(target.href);
|
|
209
|
+
$[0] = target.href;
|
|
210
|
+
$[1] = t2;
|
|
211
|
+
} else t2 = $[1];
|
|
212
|
+
const location = t2;
|
|
213
|
+
let t3;
|
|
214
|
+
if ($[2] !== connection || $[3] !== frameId) {
|
|
215
|
+
t3 = (t4) => {
|
|
216
|
+
const { to } = t4;
|
|
217
|
+
return connection.send({
|
|
218
|
+
type: "navigate",
|
|
219
|
+
frameId,
|
|
220
|
+
to
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
$[2] = connection;
|
|
224
|
+
$[3] = frameId;
|
|
225
|
+
$[4] = t3;
|
|
226
|
+
} else t3 = $[4];
|
|
227
|
+
const navigate = t3;
|
|
228
|
+
const workspaceKey = target.canvas?.workspaceKey;
|
|
229
|
+
let t4;
|
|
230
|
+
if ($[5] !== connection || $[6] !== frameId || $[7] !== workspaceKey) {
|
|
231
|
+
t4 = workspaceKey === void 0 ? null : {
|
|
232
|
+
workspaceKey,
|
|
233
|
+
mirrorCamera: _temp2,
|
|
234
|
+
reveal: (element, t5) => {
|
|
235
|
+
const immediate = t5 === void 0 ? false : t5;
|
|
236
|
+
return connection.send({
|
|
237
|
+
type: "reveal",
|
|
238
|
+
frameId,
|
|
239
|
+
element,
|
|
240
|
+
immediate
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
$[5] = connection;
|
|
245
|
+
$[6] = frameId;
|
|
246
|
+
$[7] = workspaceKey;
|
|
247
|
+
$[8] = t4;
|
|
248
|
+
} else t4 = $[8];
|
|
249
|
+
const workspace = t4;
|
|
250
|
+
let t5;
|
|
251
|
+
if ($[9] !== frameElement || $[10] !== frameWindow) {
|
|
252
|
+
t5 = {
|
|
253
|
+
window: frameWindow,
|
|
254
|
+
iframeElement: frameElement
|
|
255
|
+
};
|
|
256
|
+
$[9] = frameElement;
|
|
257
|
+
$[10] = frameWindow;
|
|
258
|
+
$[11] = t5;
|
|
259
|
+
} else t5 = $[11];
|
|
260
|
+
const frameContext = t5;
|
|
261
|
+
let t6;
|
|
262
|
+
if ($[12] !== connection || $[13] !== frameId) {
|
|
263
|
+
t6 = (message) => connection.send({
|
|
264
|
+
type: "error",
|
|
265
|
+
frameId,
|
|
266
|
+
message
|
|
267
|
+
});
|
|
268
|
+
$[12] = connection;
|
|
269
|
+
$[13] = frameId;
|
|
270
|
+
$[14] = t6;
|
|
271
|
+
} else t6 = $[14];
|
|
272
|
+
const failed = t6;
|
|
273
|
+
let t7;
|
|
274
|
+
if ($[15] !== connection || $[16] !== frameId) {
|
|
275
|
+
t7 = () => connection.send({
|
|
276
|
+
type: "rendered",
|
|
277
|
+
frameId
|
|
278
|
+
});
|
|
279
|
+
$[15] = connection;
|
|
280
|
+
$[16] = frameId;
|
|
281
|
+
$[17] = t7;
|
|
282
|
+
} else t7 = $[17];
|
|
283
|
+
const rendered = t7;
|
|
284
|
+
const t8 = target.resting ? "hidden" : "visible";
|
|
285
|
+
let t9;
|
|
286
|
+
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
|
287
|
+
t9 = /* @__PURE__ */ jsx("div", {
|
|
288
|
+
role: "status",
|
|
289
|
+
children: "Loading page…"
|
|
290
|
+
});
|
|
291
|
+
$[18] = t9;
|
|
292
|
+
} else t9 = $[18];
|
|
293
|
+
let t10;
|
|
294
|
+
if ($[19] !== camoxApp || $[20] !== codeLoaded || $[21] !== projectUuid || $[22] !== rendered || $[23] !== runtimeBasePath || $[24] !== target.derivedLayoutId || $[25] !== target.pathname) {
|
|
295
|
+
t10 = /* @__PURE__ */ jsx(React.Suspense, {
|
|
296
|
+
fallback: t9,
|
|
297
|
+
children: /* @__PURE__ */ jsx(FramePage, {
|
|
298
|
+
camoxApp,
|
|
299
|
+
codeLoaded,
|
|
300
|
+
projectUuid,
|
|
301
|
+
runtimeBasePath,
|
|
302
|
+
pathname: target.pathname,
|
|
303
|
+
derivedLayoutId: target.derivedLayoutId,
|
|
304
|
+
onRendered: rendered
|
|
305
|
+
})
|
|
306
|
+
});
|
|
307
|
+
$[19] = camoxApp;
|
|
308
|
+
$[20] = codeLoaded;
|
|
309
|
+
$[21] = projectUuid;
|
|
310
|
+
$[22] = rendered;
|
|
311
|
+
$[23] = runtimeBasePath;
|
|
312
|
+
$[24] = target.derivedLayoutId;
|
|
313
|
+
$[25] = target.pathname;
|
|
314
|
+
$[26] = t10;
|
|
315
|
+
} else t10 = $[26];
|
|
316
|
+
let t11;
|
|
317
|
+
if ($[27] !== failed || $[28] !== t10 || $[29] !== target.pathname) {
|
|
318
|
+
t11 = /* @__PURE__ */ jsx(FrameErrorBoundary, {
|
|
319
|
+
onError: failed,
|
|
320
|
+
children: t10
|
|
321
|
+
}, target.pathname);
|
|
322
|
+
$[27] = failed;
|
|
323
|
+
$[28] = t10;
|
|
324
|
+
$[29] = target.pathname;
|
|
325
|
+
$[30] = t11;
|
|
326
|
+
} else t11 = $[30];
|
|
327
|
+
let t12;
|
|
328
|
+
if ($[31] !== t11 || $[32] !== t8) {
|
|
329
|
+
t12 = /* @__PURE__ */ jsx(React.Activity, {
|
|
330
|
+
mode: t8,
|
|
331
|
+
children: t11
|
|
332
|
+
});
|
|
333
|
+
$[31] = t11;
|
|
334
|
+
$[32] = t8;
|
|
335
|
+
$[33] = t12;
|
|
336
|
+
} else t12 = $[33];
|
|
337
|
+
let t13;
|
|
338
|
+
if ($[34] !== t12 || $[35] !== target.artifactStudio) {
|
|
339
|
+
t13 = /* @__PURE__ */ jsx(ArtifactStudioContext, {
|
|
340
|
+
value: target.artifactStudio,
|
|
341
|
+
children: t12
|
|
342
|
+
});
|
|
343
|
+
$[34] = t12;
|
|
344
|
+
$[35] = target.artifactStudio;
|
|
345
|
+
$[36] = t13;
|
|
346
|
+
} else t13 = $[36];
|
|
347
|
+
let t14;
|
|
348
|
+
if ($[37] !== t13 || $[38] !== target.artifactsRun) {
|
|
349
|
+
t14 = /* @__PURE__ */ jsx(ArtifactsRunContext, {
|
|
350
|
+
value: target.artifactsRun,
|
|
351
|
+
children: t13
|
|
352
|
+
});
|
|
353
|
+
$[37] = t13;
|
|
354
|
+
$[38] = target.artifactsRun;
|
|
355
|
+
$[39] = t14;
|
|
356
|
+
} else t14 = $[39];
|
|
357
|
+
let t15;
|
|
358
|
+
if ($[40] !== t14 || $[41] !== target.editable) {
|
|
359
|
+
t15 = /* @__PURE__ */ jsx(EditableSurfaceContext, {
|
|
360
|
+
value: target.editable,
|
|
361
|
+
children: t14
|
|
362
|
+
});
|
|
363
|
+
$[40] = t14;
|
|
364
|
+
$[41] = target.editable;
|
|
365
|
+
$[42] = t15;
|
|
366
|
+
} else t15 = $[42];
|
|
367
|
+
let t16;
|
|
368
|
+
if ($[43] !== t15 || $[44] !== workspace) {
|
|
369
|
+
t16 = /* @__PURE__ */ jsx(CanvasWorkspaceContext, {
|
|
370
|
+
value: workspace,
|
|
371
|
+
children: t15
|
|
372
|
+
});
|
|
373
|
+
$[43] = t15;
|
|
374
|
+
$[44] = workspace;
|
|
375
|
+
$[45] = t16;
|
|
376
|
+
} else t16 = $[45];
|
|
377
|
+
let t17;
|
|
378
|
+
if ($[46] !== t16 || $[47] !== target.owner) {
|
|
379
|
+
t17 = /* @__PURE__ */ jsx(PreviewEditingOwnerContext, {
|
|
380
|
+
value: target.owner,
|
|
381
|
+
children: t16
|
|
382
|
+
});
|
|
383
|
+
$[46] = t16;
|
|
384
|
+
$[47] = target.owner;
|
|
385
|
+
$[48] = t17;
|
|
386
|
+
} else t17 = $[48];
|
|
387
|
+
let t18;
|
|
388
|
+
if ($[49] !== frameContext || $[50] !== t17) {
|
|
389
|
+
t18 = /* @__PURE__ */ jsx(FrameContext.Provider, {
|
|
390
|
+
value: frameContext,
|
|
391
|
+
children: t17
|
|
392
|
+
});
|
|
393
|
+
$[49] = frameContext;
|
|
394
|
+
$[50] = t17;
|
|
395
|
+
$[51] = t18;
|
|
396
|
+
} else t18 = $[51];
|
|
397
|
+
let t19;
|
|
398
|
+
if ($[52] !== location || $[53] !== navigate || $[54] !== t18) {
|
|
399
|
+
t19 = /* @__PURE__ */ jsx(NavigationProvider, {
|
|
400
|
+
location,
|
|
401
|
+
navigate,
|
|
402
|
+
children: t18
|
|
403
|
+
});
|
|
404
|
+
$[52] = location;
|
|
405
|
+
$[53] = navigate;
|
|
406
|
+
$[54] = t18;
|
|
407
|
+
$[55] = t19;
|
|
408
|
+
} else t19 = $[55];
|
|
409
|
+
const content = t19;
|
|
410
|
+
let t20;
|
|
411
|
+
if ($[56] !== content || $[57] !== target.locale) {
|
|
412
|
+
t20 = target.locale ? /* @__PURE__ */ jsx(ViewLocaleContext, {
|
|
413
|
+
value: target.locale,
|
|
414
|
+
children: content
|
|
415
|
+
}) : content;
|
|
416
|
+
$[56] = content;
|
|
417
|
+
$[57] = target.locale;
|
|
418
|
+
$[58] = t20;
|
|
419
|
+
} else t20 = $[58];
|
|
420
|
+
return t20;
|
|
421
|
+
}
|
|
422
|
+
function _temp2() {
|
|
423
|
+
return _temp;
|
|
424
|
+
}
|
|
425
|
+
function _temp() {}
|
|
426
|
+
/** The page at `pathname`, as the runtime renders it in the renderer's draft. */
|
|
427
|
+
function FramePage(t0) {
|
|
428
|
+
const $ = c(20);
|
|
429
|
+
const { camoxApp, codeLoaded, projectUuid, runtimeBasePath, pathname, derivedLayoutId, onRendered } = t0;
|
|
430
|
+
let t1;
|
|
431
|
+
if ($[0] !== derivedLayoutId || $[1] !== pathname || $[2] !== projectUuid || $[3] !== runtimeBasePath) {
|
|
432
|
+
let t2;
|
|
433
|
+
if ($[5] !== derivedLayoutId) {
|
|
434
|
+
t2 = derivedLayoutId && { derivedLayoutId };
|
|
435
|
+
$[5] = derivedLayoutId;
|
|
436
|
+
$[6] = t2;
|
|
437
|
+
} else t2 = $[6];
|
|
438
|
+
t1 = reads.canvasFrame({
|
|
439
|
+
projectUuid,
|
|
440
|
+
runtimeBasePath,
|
|
441
|
+
pathname,
|
|
442
|
+
...t2
|
|
443
|
+
});
|
|
444
|
+
$[0] = derivedLayoutId;
|
|
445
|
+
$[1] = pathname;
|
|
446
|
+
$[2] = projectUuid;
|
|
447
|
+
$[3] = runtimeBasePath;
|
|
448
|
+
$[4] = t1;
|
|
449
|
+
} else t1 = $[4];
|
|
450
|
+
const input = useRead(t1);
|
|
451
|
+
if (codeLoaded) React.use(codeLoaded);
|
|
452
|
+
const rendered = React.useEffectEvent(onRendered);
|
|
453
|
+
let t2;
|
|
454
|
+
if ($[7] !== rendered) {
|
|
455
|
+
t2 = () => rendered();
|
|
456
|
+
$[7] = rendered;
|
|
457
|
+
$[8] = t2;
|
|
458
|
+
} else t2 = $[8];
|
|
459
|
+
let t3;
|
|
460
|
+
if ($[9] !== input) {
|
|
461
|
+
t3 = [input];
|
|
462
|
+
$[9] = input;
|
|
463
|
+
$[10] = t3;
|
|
464
|
+
} else t3 = $[10];
|
|
465
|
+
React.useEffect(t2, t3);
|
|
466
|
+
const t4 = input.dehydratedState;
|
|
467
|
+
let t5;
|
|
468
|
+
if ($[11] !== camoxApp || $[12] !== input.derived) {
|
|
469
|
+
t5 = input.derived ? /* @__PURE__ */ jsx(DerivedPageContent, {
|
|
470
|
+
camoxApp,
|
|
471
|
+
derived: input.derived
|
|
472
|
+
}) : /* @__PURE__ */ jsx(EditablePageContent, {});
|
|
473
|
+
$[11] = camoxApp;
|
|
474
|
+
$[12] = input.derived;
|
|
475
|
+
$[13] = t5;
|
|
476
|
+
} else t5 = $[13];
|
|
477
|
+
let t6;
|
|
478
|
+
if ($[14] !== input.previewDocument || $[15] !== t5) {
|
|
479
|
+
t6 = /* @__PURE__ */ jsx(PreviewDocumentContext.Provider, {
|
|
480
|
+
value: input.previewDocument,
|
|
481
|
+
children: t5
|
|
482
|
+
});
|
|
483
|
+
$[14] = input.previewDocument;
|
|
484
|
+
$[15] = t5;
|
|
485
|
+
$[16] = t6;
|
|
486
|
+
} else t6 = $[16];
|
|
487
|
+
let t7;
|
|
488
|
+
if ($[17] !== t4 || $[18] !== t6) {
|
|
489
|
+
t7 = /* @__PURE__ */ jsx(HydrationBoundary, {
|
|
490
|
+
state: t4,
|
|
491
|
+
children: t6
|
|
492
|
+
});
|
|
493
|
+
$[17] = t4;
|
|
494
|
+
$[18] = t6;
|
|
495
|
+
$[19] = t7;
|
|
496
|
+
} else t7 = $[19];
|
|
497
|
+
return t7;
|
|
498
|
+
}
|
|
499
|
+
const messageOf = (error) => error instanceof Error ? error.message : String(error);
|
|
500
|
+
const ERROR_STYLE = {
|
|
501
|
+
padding: "24px",
|
|
502
|
+
fontFamily: "system-ui, sans-serif",
|
|
503
|
+
fontSize: "14px",
|
|
504
|
+
color: "#b91c1c"
|
|
505
|
+
};
|
|
506
|
+
/**
|
|
507
|
+
* Contains an error the page throws while rendering to its own frame, which says so, and tells
|
|
508
|
+
* the studio. The studio and every other frame keep working.
|
|
509
|
+
*/
|
|
510
|
+
var FrameErrorBoundary = class extends React.Component {
|
|
511
|
+
state = { error: null };
|
|
512
|
+
static getDerivedStateFromError(error) {
|
|
513
|
+
return { error: messageOf(error) };
|
|
514
|
+
}
|
|
515
|
+
componentDidCatch(error) {
|
|
516
|
+
this.props.onError(messageOf(error));
|
|
517
|
+
}
|
|
518
|
+
render() {
|
|
519
|
+
if (this.state.error === null) return this.props.children;
|
|
520
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
521
|
+
role: "alert",
|
|
522
|
+
"data-camox-renderer-error": true,
|
|
523
|
+
style: ERROR_STYLE,
|
|
524
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
525
|
+
style: {
|
|
526
|
+
margin: 0,
|
|
527
|
+
fontWeight: 600
|
|
528
|
+
},
|
|
529
|
+
children: "This page couldn’t render."
|
|
530
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
531
|
+
style: {
|
|
532
|
+
margin: "8px 0 0",
|
|
533
|
+
fontFamily: "ui-monospace, monospace"
|
|
534
|
+
},
|
|
535
|
+
children: this.state.error
|
|
536
|
+
})]
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
//#endregion
|
|
542
|
+
export { RendererApp };
|