camox 0.34.0 → 0.35.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 (73) hide show
  1. package/dist/core/components/lexical/InlineLexicalEditor.js +1 -1
  2. package/dist/core/components/lexical/SidebarLexicalEditor.js +7 -7
  3. package/dist/core/components/lexical/TextLinkPopover.js +4 -4
  4. package/dist/core/createApp.d.ts +2 -1
  5. package/dist/core/createBlock.d.ts +5 -1451
  6. package/dist/core/createBlock.js +449 -1602
  7. package/dist/core/editing/BlockEditingRuntime.js +36 -0
  8. package/dist/core/editing/CompleteBlockEditingRuntime.js +76 -0
  9. package/dist/core/editing/createEditableBlock.d.ts +1455 -0
  10. package/dist/core/editing/createEditableBlock.js +1751 -0
  11. package/dist/core/lib/lexicalState.js +1 -1
  12. package/dist/features/agent-chat/components/AgentChatSidebar.js +1 -1
  13. package/dist/features/content/components/AssetCard.js +1 -1
  14. package/dist/features/page/PublishedPageContent.js +236 -0
  15. package/dist/features/page/PublishedPageExperience.js +23 -0
  16. package/dist/features/preview/CamoxPreview.d.ts +1 -0
  17. package/dist/features/preview/CamoxPreview.js +4 -4
  18. package/dist/features/preview/EditablePageContent.js +3 -0
  19. package/dist/features/preview/EditablePageExperience.js +24 -0
  20. package/dist/features/preview/components/AddBlockSidebar.js +3 -3
  21. package/dist/features/preview/components/AssetFieldEditor.js +1 -1
  22. package/dist/features/preview/components/AssetLightbox.js +46 -110
  23. package/dist/features/preview/components/BlockActionsPopover.js +6 -6
  24. package/dist/features/preview/components/CreatePageModal.js +4 -4
  25. package/dist/features/preview/components/DebouncedFieldEditor.js +2 -2
  26. package/dist/features/preview/components/DraftSwitchDialog.js +1 -1
  27. package/dist/features/preview/components/FieldToolbar.js +3 -3
  28. package/dist/features/preview/components/Frame.js +1 -1
  29. package/dist/features/preview/components/ItemFieldsEditor.js +3 -3
  30. package/dist/features/preview/components/LeftSidebar.js +1 -1
  31. package/dist/features/preview/components/LinkFieldEditor.js +3 -3
  32. package/dist/features/preview/components/Metadata.js +87 -0
  33. package/dist/features/preview/components/MultipleAssetFieldEditor.js +1 -1
  34. package/dist/features/preview/components/OverlayTracker.js +3 -3
  35. package/dist/features/preview/components/Overlays.js +3 -3
  36. package/dist/features/preview/components/PageEditorSidebar.js +5 -5
  37. package/dist/features/preview/components/PageInfoSidebar.js +157 -73
  38. package/dist/features/preview/components/PageLocationFieldset.js +1 -1
  39. package/dist/features/preview/components/PageNavigatorSidebar.js +4 -4
  40. package/dist/features/preview/components/PageNicknameField.js +2 -2
  41. package/dist/features/preview/components/PagePicker.js +3 -3
  42. package/dist/features/preview/components/PageTree.js +3 -3
  43. package/dist/features/preview/components/PeekedBlock.js +2 -2
  44. package/dist/features/preview/components/PreviewPanel.js +2 -2
  45. package/dist/features/preview/components/PreviewToolbar.js +2 -2
  46. package/dist/features/preview/components/PublishDialog.js +2 -2
  47. package/dist/features/preview/components/RepeatableItemsList.js +1 -1
  48. package/dist/features/preview/components/RightSidebar.js +1 -1
  49. package/dist/features/preview/components/useRepeatableItemActions.js +1 -1
  50. package/dist/features/preview/components/useUpdateBlockPosition.js +1 -1
  51. package/dist/features/provider/AuthenticatedCamoxProvider.js +63 -0
  52. package/dist/features/provider/CamoxProvider.d.ts +5 -12
  53. package/dist/features/provider/CamoxProvider.js +80 -338
  54. package/dist/features/provider/CoreCamoxProvider.js +37 -0
  55. package/dist/features/provider/LocalhostPreviewProvider.js +159 -0
  56. package/dist/features/provider/components/CommandPalette.js +1 -1
  57. package/dist/features/provider/useAdminShortcuts.js +1 -1
  58. package/dist/features/runtime/hydrationData.js +9 -0
  59. package/dist/features/runtime/pageApp.js +148 -35
  60. package/dist/features/runtime/pageClient.d.ts +1 -2
  61. package/dist/features/runtime/pageClient.js +3 -20
  62. package/dist/features/runtime/runtime.d.ts +1 -0
  63. package/dist/features/runtime/studioApp.js +76 -8
  64. package/dist/features/runtime/studioClient.d.ts +6 -0
  65. package/dist/features/runtime/studioClient.js +20 -0
  66. package/dist/features/studio/CamoxStudio.js +1 -1
  67. package/dist/features/studio/components/EnvironmentMenu.js +2 -2
  68. package/dist/features/studio/useTheme.js +1 -22
  69. package/dist/features/vite/runtimeDev.js +24 -3
  70. package/dist/features/vite/vite.js +7 -1
  71. package/dist/lib/normalized-data.js +6 -6
  72. package/dist/lib/view-queries.js +28 -0
  73. package/package.json +9 -4
@@ -1,27 +1,36 @@
1
- import { CamoxPreview, PageContent } from "../preview/CamoxPreview.js";
2
- import { CamoxProvider } from "../provider/CamoxProvider.js";
1
+ import { useAuthState } from "../../lib/auth.js";
2
+ import { CoreCamoxProvider, isLocalhostPreview } from "../provider/CoreCamoxProvider.js";
3
+ import { PublishedPageExperience } from "../page/PublishedPageExperience.js";
3
4
  import { PageNavigationProvider } from "./pageNavigation.js";
4
5
  import { c } from "react/compiler-runtime";
5
6
  import { HydrationBoundary, QueryClientProvider } from "@tanstack/react-query";
7
+ import * as React from "react";
6
8
  import { jsx } from "react/jsx-runtime";
7
9
 
8
10
  //#region src/features/runtime/pageApp.tsx
9
11
  function PageApp(t0) {
10
- const $ = c(18);
11
- if ($[0] !== "557a21bc6b4aed13935ede3368115a90db9c6fcffe823bb869ddbaeb394cf48e") {
12
- for (let $i = 0; $i < 18; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
13
- $[0] = "557a21bc6b4aed13935ede3368115a90db9c6fcffe823bb869ddbaeb394cf48e";
12
+ const $ = c(22);
13
+ if ($[0] !== "41b609b6b6e9223ab6f76c85adfea25789d9d089bc02ca12ea1dd789dd8294d1") {
14
+ for (let $i = 0; $i < 22; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
15
+ $[0] = "41b609b6b6e9223ab6f76c85adfea25789d9d089bc02ca12ea1dd789dd8294d1";
14
16
  }
15
17
  const { camoxApp, input, queryClient } = t0;
16
18
  const t1 = input.dehydratedState;
17
19
  let t2;
18
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
19
- t2 = /* @__PURE__ */ jsx(CamoxPreview, { children: /* @__PURE__ */ jsx(PageContent, {}) });
20
- $[1] = t2;
21
- } else t2 = $[1];
20
+ if ($[1] !== camoxApp || $[2] !== input || $[3] !== queryClient) {
21
+ t2 = /* @__PURE__ */ jsx(PageExperience, {
22
+ camoxApp,
23
+ input,
24
+ queryClient
25
+ });
26
+ $[1] = camoxApp;
27
+ $[2] = input;
28
+ $[3] = queryClient;
29
+ $[4] = t2;
30
+ } else t2 = $[4];
22
31
  let t3;
23
- if ($[2] !== camoxApp || $[3] !== input.apiUrl || $[4] !== input.authenticationUrl || $[5] !== input.environmentName || $[6] !== input.projectSlug) {
24
- t3 = /* @__PURE__ */ jsx(CamoxProvider, {
32
+ if ($[5] !== camoxApp || $[6] !== input.apiUrl || $[7] !== input.authenticationUrl || $[8] !== input.environmentName || $[9] !== input.projectSlug || $[10] !== t2) {
33
+ t3 = /* @__PURE__ */ jsx(CoreCamoxProvider, {
25
34
  camoxApp,
26
35
  authenticationUrl: input.authenticationUrl,
27
36
  apiUrl: input.apiUrl,
@@ -29,47 +38,151 @@ function PageApp(t0) {
29
38
  environmentName: input.environmentName,
30
39
  children: t2
31
40
  });
32
- $[2] = camoxApp;
33
- $[3] = input.apiUrl;
34
- $[4] = input.authenticationUrl;
35
- $[5] = input.environmentName;
36
- $[6] = input.projectSlug;
37
- $[7] = t3;
38
- } else t3 = $[7];
41
+ $[5] = camoxApp;
42
+ $[6] = input.apiUrl;
43
+ $[7] = input.authenticationUrl;
44
+ $[8] = input.environmentName;
45
+ $[9] = input.projectSlug;
46
+ $[10] = t2;
47
+ $[11] = t3;
48
+ } else t3 = $[11];
39
49
  let t4;
40
- if ($[8] !== input || $[9] !== queryClient || $[10] !== t3) {
50
+ if ($[12] !== input || $[13] !== queryClient || $[14] !== t3) {
41
51
  t4 = /* @__PURE__ */ jsx(PageNavigationProvider, {
42
52
  initialInput: input,
43
53
  queryClient,
44
54
  children: t3
45
55
  });
46
- $[8] = input;
47
- $[9] = queryClient;
48
- $[10] = t3;
49
- $[11] = t4;
50
- } else t4 = $[11];
56
+ $[12] = input;
57
+ $[13] = queryClient;
58
+ $[14] = t3;
59
+ $[15] = t4;
60
+ } else t4 = $[15];
51
61
  let t5;
52
- if ($[12] !== t1 || $[13] !== t4) {
62
+ if ($[16] !== t1 || $[17] !== t4) {
53
63
  t5 = /* @__PURE__ */ jsx(HydrationBoundary, {
54
64
  state: t1,
55
65
  children: t4
56
66
  });
57
- $[12] = t1;
58
- $[13] = t4;
59
- $[14] = t5;
60
- } else t5 = $[14];
67
+ $[16] = t1;
68
+ $[17] = t4;
69
+ $[18] = t5;
70
+ } else t5 = $[18];
61
71
  let t6;
62
- if ($[15] !== queryClient || $[16] !== t5) {
72
+ if ($[19] !== queryClient || $[20] !== t5) {
63
73
  t6 = /* @__PURE__ */ jsx(QueryClientProvider, {
64
74
  client: queryClient,
65
75
  children: t5
66
76
  });
67
- $[15] = queryClient;
68
- $[16] = t5;
69
- $[17] = t6;
70
- } else t6 = $[17];
77
+ $[19] = queryClient;
78
+ $[20] = t5;
79
+ $[21] = t6;
80
+ } else t6 = $[21];
71
81
  return t6;
72
82
  }
83
+ const LazyEditablePageExperience = React.lazy(() => import("../preview/EditablePageExperience.js").then((module) => ({ default: module.EditablePageExperience })));
84
+ const LazyLocalhostPreviewProvider = React.lazy(() => import("../provider/LocalhostPreviewProvider.js").then((module) => ({ default: module.LocalhostPreviewProvider })));
85
+ var EditingActivationBoundary = class extends React.Component {
86
+ state = { failed: false };
87
+ static getDerivedStateFromError() {
88
+ return { failed: true };
89
+ }
90
+ componentDidCatch(error) {
91
+ console.error("Camox editing runtime failed to load; keeping the published page visible.", error);
92
+ }
93
+ render() {
94
+ if (this.state.failed) return this.props.fallback;
95
+ return this.props.children;
96
+ }
97
+ };
98
+ function PageExperience(t0) {
99
+ const $ = c(21);
100
+ if ($[0] !== "41b609b6b6e9223ab6f76c85adfea25789d9d089bc02ca12ea1dd789dd8294d1") {
101
+ for (let $i = 0; $i < 21; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
102
+ $[0] = "41b609b6b6e9223ab6f76c85adfea25789d9d089bc02ca12ea1dd789dd8294d1";
103
+ }
104
+ const { camoxApp, input, queryClient } = t0;
105
+ const { isAuthenticated } = useAuthState();
106
+ const [hasOtt] = React.useState(_temp);
107
+ const local = isLocalhostPreview();
108
+ const shouldActivateEditing = isAuthenticated || input.source === "draft" || hasOtt;
109
+ let t1;
110
+ if ($[1] !== input.source) {
111
+ t1 = /* @__PURE__ */ jsx(PublishedPageExperience, { source: input.source });
112
+ $[1] = input.source;
113
+ $[2] = t1;
114
+ } else t1 = $[2];
115
+ const published = t1;
116
+ if (shouldActivateEditing) {
117
+ let t2;
118
+ if ($[3] !== camoxApp || $[4] !== input || $[5] !== queryClient) {
119
+ t2 = /* @__PURE__ */ jsx(LazyEditablePageExperience, {
120
+ camoxApp,
121
+ input,
122
+ queryClient
123
+ });
124
+ $[3] = camoxApp;
125
+ $[4] = input;
126
+ $[5] = queryClient;
127
+ $[6] = t2;
128
+ } else t2 = $[6];
129
+ let t3;
130
+ if ($[7] !== published || $[8] !== t2) {
131
+ t3 = /* @__PURE__ */ jsx(React.Suspense, {
132
+ fallback: published,
133
+ children: t2
134
+ });
135
+ $[7] = published;
136
+ $[8] = t2;
137
+ $[9] = t3;
138
+ } else t3 = $[9];
139
+ let t4;
140
+ if ($[10] !== published || $[11] !== t3) {
141
+ t4 = /* @__PURE__ */ jsx(EditingActivationBoundary, {
142
+ fallback: published,
143
+ children: t3
144
+ });
145
+ $[10] = published;
146
+ $[11] = t3;
147
+ $[12] = t4;
148
+ } else t4 = $[12];
149
+ return t4;
150
+ }
151
+ if (local) {
152
+ let t2;
153
+ if ($[13] !== published) {
154
+ t2 = /* @__PURE__ */ jsx(LazyLocalhostPreviewProvider, { children: published });
155
+ $[13] = published;
156
+ $[14] = t2;
157
+ } else t2 = $[14];
158
+ let t3;
159
+ if ($[15] !== published || $[16] !== t2) {
160
+ t3 = /* @__PURE__ */ jsx(React.Suspense, {
161
+ fallback: published,
162
+ children: t2
163
+ });
164
+ $[15] = published;
165
+ $[16] = t2;
166
+ $[17] = t3;
167
+ } else t3 = $[17];
168
+ let t4;
169
+ if ($[18] !== published || $[19] !== t3) {
170
+ t4 = /* @__PURE__ */ jsx(EditingActivationBoundary, {
171
+ fallback: published,
172
+ children: t3
173
+ });
174
+ $[18] = published;
175
+ $[19] = t3;
176
+ $[20] = t4;
177
+ } else t4 = $[20];
178
+ return t4;
179
+ }
180
+ return published;
181
+ }
182
+ function _temp() {
183
+ if (typeof window === "undefined") return false;
184
+ return new URL(window.location.href).searchParams.has("ott");
185
+ }
73
186
 
74
187
  //#endregion
75
188
  export { PageApp };
@@ -2,6 +2,5 @@ import { CamoxApp } from "../../core/createApp.js";
2
2
 
3
3
  //#region src/features/runtime/pageClient.d.ts
4
4
  declare function hydratePageWithApp(camoxApp: CamoxApp): void;
5
- declare function hydrateRuntimeWithApp(camoxApp: CamoxApp): void;
6
5
  //#endregion
7
- export { hydratePageWithApp, hydrateRuntimeWithApp };
6
+ export { hydratePageWithApp };
@@ -1,37 +1,20 @@
1
1
  import { PageApp } from "./pageApp.js";
2
- import { StudioApp } from "./studioApp.js";
2
+ import { readHydrationData } from "./hydrationData.js";
3
3
  import { QueryClient } from "@tanstack/react-query";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  import { hydrateRoot } from "react-dom/client";
6
6
 
7
7
  //#region src/features/runtime/pageClient.tsx
8
- function readHydrationData() {
9
- const script = document.getElementById("__CAMOX_DATA__");
10
- if (!script?.textContent) throw new Error("Camox runtime hydration data was not found.");
11
- return JSON.parse(script.textContent);
12
- }
13
8
  function hydratePageWithApp(camoxApp) {
14
- hydrateRuntimeWithApp(camoxApp);
15
- }
16
- function hydrateRuntimeWithApp(camoxApp) {
17
9
  const root = document.getElementById("root");
18
10
  if (!root) throw new Error("Camox runtime root element was not found.");
19
11
  const queryClient = new QueryClient();
20
- const input = readHydrationData();
21
- if (input.runtimeKind === "studio") {
22
- hydrateRoot(root, /* @__PURE__ */ jsx(StudioApp, {
23
- camoxApp,
24
- input,
25
- queryClient
26
- }));
27
- return;
28
- }
29
12
  hydrateRoot(root, /* @__PURE__ */ jsx(PageApp, {
30
13
  camoxApp,
31
- input,
14
+ input: readHydrationData(),
32
15
  queryClient
33
16
  }));
34
17
  }
35
18
 
36
19
  //#endregion
37
- export { hydratePageWithApp, hydrateRuntimeWithApp };
20
+ export { hydratePageWithApp };
@@ -19,6 +19,7 @@ interface PageRenderInput {
19
19
  pathname: string;
20
20
  projectSlug: string;
21
21
  runtimeBasePath: string;
22
+ source: "live" | "draft";
22
23
  }
23
24
  //#endregion
24
25
  export { PageRenderInput };
@@ -1,18 +1,23 @@
1
+ import { useSignInRedirect } from "../../lib/auth.js";
1
2
  import { STUDIO_CONTENT_PATH } from "../studio/routes.js";
2
3
  import { CamoxContent } from "../content/CamoxContent.js";
3
- import { CamoxProvider } from "../provider/CamoxProvider.js";
4
+ import { AuthGate } from "../../components/AuthGate.js";
5
+ import { AuthenticatedCamoxProvider } from "../provider/AuthenticatedCamoxProvider.js";
6
+ import { CoreCamoxProvider } from "../provider/CoreCamoxProvider.js";
4
7
  import { CamoxStudio } from "../studio/CamoxStudio.js";
8
+ import { CompleteBlockEditingRuntimeProvider } from "../../core/editing/CompleteBlockEditingRuntime.js";
5
9
  import { StudioNavigationProvider } from "./studioNavigation.js";
6
10
  import { c } from "react/compiler-runtime";
7
11
  import { HydrationBoundary, QueryClientProvider } from "@tanstack/react-query";
8
- import { jsx } from "react/jsx-runtime";
12
+ import * as React from "react";
13
+ import { Fragment, jsx } from "react/jsx-runtime";
9
14
 
10
15
  //#region src/features/runtime/studioApp.tsx
11
16
  function StudioRouteContent(t0) {
12
17
  const $ = c(4);
13
- if ($[0] !== "4c7f5ba34e144c65d886d3b5a39ff5adc9765123d3c37bd6491f55534f919b1f") {
18
+ if ($[0] !== "4c9c648e70d7360e13c0b3d8d0f0633d0ab4263e359229c8802810bae1f42f17") {
14
19
  for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
15
- $[0] = "4c7f5ba34e144c65d886d3b5a39ff5adc9765123d3c37bd6491f55534f919b1f";
20
+ $[0] = "4c9c648e70d7360e13c0b3d8d0f0633d0ab4263e359229c8802810bae1f42f17";
16
21
  }
17
22
  const { input } = t0;
18
23
  if (input.pathname === STUDIO_CONTENT_PATH) {
@@ -44,23 +49,86 @@ function StudioRouteContent(t0) {
44
49
  } else t1 = $[3];
45
50
  return t1;
46
51
  }
52
+ function StudioAuthentication(t0) {
53
+ const $ = c(6);
54
+ if ($[0] !== "4c9c648e70d7360e13c0b3d8d0f0633d0ab4263e359229c8802810bae1f42f17") {
55
+ for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
56
+ $[0] = "4c9c648e70d7360e13c0b3d8d0f0633d0ab4263e359229c8802810bae1f42f17";
57
+ }
58
+ const { children } = t0;
59
+ const signInRedirect = useSignInRedirect(_temp);
60
+ let t1;
61
+ let t2;
62
+ if ($[1] !== signInRedirect) {
63
+ t1 = () => signInRedirect();
64
+ t2 = [signInRedirect];
65
+ $[1] = signInRedirect;
66
+ $[2] = t1;
67
+ $[3] = t2;
68
+ } else {
69
+ t1 = $[2];
70
+ t2 = $[3];
71
+ }
72
+ React.useEffect(t1, t2);
73
+ let t3;
74
+ if ($[4] !== children) {
75
+ t3 = /* @__PURE__ */ jsx(Fragment, { children });
76
+ $[4] = children;
77
+ $[5] = t3;
78
+ } else t3 = $[5];
79
+ return t3;
80
+ }
81
+ function _temp() {
82
+ if (typeof window === "undefined") return;
83
+ return new URL("/", window.location.href).href;
84
+ }
85
+ function StudioAccessGate(t0) {
86
+ const $ = c(6);
87
+ if ($[0] !== "4c9c648e70d7360e13c0b3d8d0f0633d0ab4263e359229c8802810bae1f42f17") {
88
+ for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
89
+ $[0] = "4c9c648e70d7360e13c0b3d8d0f0633d0ab4263e359229c8802810bae1f42f17";
90
+ }
91
+ const { children } = t0;
92
+ let t1;
93
+ if ($[1] !== children) {
94
+ t1 = /* @__PURE__ */ jsx(AuthenticatedCamoxProvider, { children });
95
+ $[1] = children;
96
+ $[2] = t1;
97
+ } else t1 = $[2];
98
+ let t2;
99
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
100
+ t2 = /* @__PURE__ */ jsx(StudioAuthentication, { children: null });
101
+ $[3] = t2;
102
+ } else t2 = $[3];
103
+ let t3;
104
+ if ($[4] !== t1) {
105
+ t3 = /* @__PURE__ */ jsx(AuthGate, {
106
+ authenticated: t1,
107
+ loading: null,
108
+ unauthenticated: t2
109
+ });
110
+ $[4] = t1;
111
+ $[5] = t3;
112
+ } else t3 = $[5];
113
+ return t3;
114
+ }
47
115
  function StudioApp(t0) {
48
116
  const $ = c(21);
49
- if ($[0] !== "4c7f5ba34e144c65d886d3b5a39ff5adc9765123d3c37bd6491f55534f919b1f") {
117
+ if ($[0] !== "4c9c648e70d7360e13c0b3d8d0f0633d0ab4263e359229c8802810bae1f42f17") {
50
118
  for (let $i = 0; $i < 21; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
51
- $[0] = "4c7f5ba34e144c65d886d3b5a39ff5adc9765123d3c37bd6491f55534f919b1f";
119
+ $[0] = "4c9c648e70d7360e13c0b3d8d0f0633d0ab4263e359229c8802810bae1f42f17";
52
120
  }
53
121
  const { camoxApp, input, queryClient } = t0;
54
122
  const t1 = input.dehydratedState;
55
123
  let t2;
56
124
  if ($[1] !== input) {
57
- t2 = /* @__PURE__ */ jsx(CamoxStudio, { children: /* @__PURE__ */ jsx(StudioRouteContent, { input }) });
125
+ t2 = /* @__PURE__ */ jsx(StudioAccessGate, { children: /* @__PURE__ */ jsx(CompleteBlockEditingRuntimeProvider, { children: /* @__PURE__ */ jsx(CamoxStudio, { children: /* @__PURE__ */ jsx(StudioRouteContent, { input }) }) }) });
58
126
  $[1] = input;
59
127
  $[2] = t2;
60
128
  } else t2 = $[2];
61
129
  let t3;
62
130
  if ($[3] !== camoxApp || $[4] !== input.apiUrl || $[5] !== input.authenticationUrl || $[6] !== input.environmentName || $[7] !== input.projectSlug || $[8] !== t2) {
63
- t3 = /* @__PURE__ */ jsx(CamoxProvider, {
131
+ t3 = /* @__PURE__ */ jsx(CoreCamoxProvider, {
64
132
  camoxApp,
65
133
  authenticationUrl: input.authenticationUrl,
66
134
  apiUrl: input.apiUrl,
@@ -0,0 +1,6 @@
1
+ import { CamoxApp } from "../../core/createApp.js";
2
+
3
+ //#region src/features/runtime/studioClient.d.ts
4
+ declare function hydrateStudioWithApp(camoxApp: CamoxApp): void;
5
+ //#endregion
6
+ export { hydrateStudioWithApp };
@@ -0,0 +1,20 @@
1
+ import { readHydrationData } from "./hydrationData.js";
2
+ import { StudioApp } from "./studioApp.js";
3
+ import { QueryClient } from "@tanstack/react-query";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { hydrateRoot } from "react-dom/client";
6
+
7
+ //#region src/features/runtime/studioClient.tsx
8
+ function hydrateStudioWithApp(camoxApp) {
9
+ const root = document.getElementById("root");
10
+ if (!root) throw new Error("Camox runtime root element was not found.");
11
+ const queryClient = new QueryClient();
12
+ hydrateRoot(root, /* @__PURE__ */ jsx(StudioApp, {
13
+ camoxApp,
14
+ input: readHydrationData(),
15
+ queryClient
16
+ }));
17
+ }
18
+
19
+ //#endregion
20
+ export { hydrateStudioWithApp };
@@ -1,8 +1,8 @@
1
1
  import { Navigate, useLocation } from "../navigation/navigation.js";
2
2
  import { useAuthState, useSignInRedirect } from "../../lib/auth.js";
3
- import { trackClientEvent } from "../../lib/telemetry-client.js";
4
3
  import { STUDIO_BASE_PATH } from "./routes.js";
5
4
  import { Navbar } from "./components/Navbar.js";
5
+ import { trackClientEvent } from "../../lib/telemetry-client.js";
6
6
  import { c } from "react/compiler-runtime";
7
7
  import * as React from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -1,18 +1,18 @@
1
1
  import { AuthContext } from "../../../lib/auth.js";
2
2
  import { environmentMutations, environmentQueries, projectQueries } from "../../../lib/queries.js";
3
3
  import { c } from "react/compiler-runtime";
4
- import { Popover, PopoverContent, PopoverTrigger } from "@camox/ui/popover";
5
4
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
6
5
  import * as React from "react";
7
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
- import { toast } from "@camox/ui/toaster";
9
7
  import { Button } from "@camox/ui/button";
10
8
  import { AlertCircle, ChevronDown, Download, Upload } from "lucide-react";
11
9
  import { Alert, AlertDescription } from "@camox/ui/alert";
12
10
  import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
13
11
  import { Badge } from "@camox/ui/badge";
12
+ import { Popover, PopoverContent, PopoverTrigger } from "@camox/ui/popover";
14
13
  import { Separator } from "@camox/ui/separator";
15
14
  import { Spinner } from "@camox/ui/spinner";
15
+ import { toast } from "@camox/ui/toaster";
16
16
 
17
17
  //#region src/features/studio/components/EnvironmentMenu.tsx
18
18
  const PRODUCTION_ENV = "production";
@@ -9,27 +9,6 @@ function readStoredTheme() {
9
9
  return localStorage.getItem("theme") || "system";
10
10
  }
11
11
  /**
12
- * Read-only access to the studio theme. Does not mutate `<html>` or localStorage.
13
- * Use this when you need the current theme value (e.g. to pass to a Toaster) but
14
- * are not the owner of the studio chrome — applying the theme would bleed onto
15
- * the host site.
16
- */
17
- function useThemeValue() {
18
- const $ = c(3);
19
- if ($[0] !== "da3935c3f496f05138d1e012522f8d34be97b470fa5c8f37185df49127eab10f") {
20
- for (let $i = 0; $i < 3; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
21
- $[0] = "da3935c3f496f05138d1e012522f8d34be97b470fa5c8f37185df49127eab10f";
22
- }
23
- const [theme] = React.useState(readStoredTheme);
24
- let t0;
25
- if ($[1] !== theme) {
26
- t0 = { theme };
27
- $[1] = theme;
28
- $[2] = t0;
29
- } else t0 = $[2];
30
- return t0;
31
- }
32
- /**
33
12
  * Owns the studio theme: writes the active class onto `<html>` and persists
34
13
  * changes to localStorage. Should only be mounted from the studio chrome —
35
14
  * never from contexts that share `<html>` with the user's site.
@@ -222,4 +201,4 @@ function _temp() {
222
201
  }
223
202
 
224
203
  //#endregion
225
- export { useApplyTheme, useThemeActions, useThemeValue };
204
+ export { useApplyTheme, useThemeActions };
@@ -19,6 +19,10 @@ const VIRTUAL_PAGE_CLIENT = "virtual:camox/page-client";
19
19
  const RESOLVED_VIRTUAL_PAGE_CLIENT = "\0" + VIRTUAL_PAGE_CLIENT;
20
20
  const VIRTUAL_PAGE_CLIENT_URL = "virtual:camox/page-client-url";
21
21
  const RESOLVED_VIRTUAL_PAGE_CLIENT_URL = "\0" + VIRTUAL_PAGE_CLIENT_URL;
22
+ const VIRTUAL_STUDIO_CLIENT = "virtual:camox/studio-client";
23
+ const RESOLVED_VIRTUAL_STUDIO_CLIENT = "\0" + VIRTUAL_STUDIO_CLIENT;
24
+ const VIRTUAL_STUDIO_CLIENT_URL = "virtual:camox/studio-client-url";
25
+ const RESOLVED_VIRTUAL_STUDIO_CLIENT_URL = "\0" + VIRTUAL_STUDIO_CLIENT_URL;
22
26
  const VIRTUAL_APP_STYLESHEET_URL = "virtual:camox/app-stylesheet-url";
23
27
  const RESOLVED_VIRTUAL_APP_STYLESHEET_URL = "\0" + VIRTUAL_APP_STYLESHEET_URL;
24
28
  const VIRTUAL_STUDIO_CSS = "virtual:camox-studio-css";
@@ -56,6 +60,7 @@ function resolveCamoxSourceImport(id) {
56
60
  "camox/navigation": resolve(sdkRoot, "src/features/navigation/navigation.tsx"),
57
61
  "camox/_internal/pageServer": resolve(sdkRoot, "src/features/runtime/pageServer.tsx"),
58
62
  "camox/_internal/pageClient": resolve(sdkRoot, "src/features/runtime/pageClient.tsx"),
63
+ "camox/_internal/studioClient": resolve(sdkRoot, "src/features/runtime/studioClient.tsx"),
59
64
  "camox/_internal/studioServer": resolve(sdkRoot, "src/features/runtime/studioServer.tsx"),
60
65
  "camox/_internal/runtime": resolve(sdkRoot, "src/features/runtime/runtime.ts")
61
66
  }[id];
@@ -106,10 +111,17 @@ export async function renderStudio(input) {
106
111
  `;
107
112
  }
108
113
  function generateVirtualPageClient() {
109
- return `import { hydrateRuntimeWithApp } from "camox/_internal/pageClient";
114
+ return `import { hydratePageWithApp } from "camox/_internal/pageClient";
110
115
  import { camoxApp } from "virtual:camox/app";
111
116
 
112
- hydrateRuntimeWithApp(camoxApp);
117
+ hydratePageWithApp(camoxApp);
118
+ `;
119
+ }
120
+ function generateVirtualStudioClient() {
121
+ return `import { hydrateStudioWithApp } from "camox/_internal/studioClient";
122
+ import { camoxApp } from "virtual:camox/app";
123
+
124
+ hydrateStudioWithApp(camoxApp);
113
125
  `;
114
126
  }
115
127
  function wrapViteDevId(id) {
@@ -118,6 +130,9 @@ function wrapViteDevId(id) {
118
130
  function generateVirtualPageClientUrl() {
119
131
  return `export default ${JSON.stringify(wrapViteDevId(RESOLVED_VIRTUAL_PAGE_CLIENT))};`;
120
132
  }
133
+ function generateVirtualStudioClientUrl() {
134
+ return `export default ${JSON.stringify(wrapViteDevId(RESOLVED_VIRTUAL_STUDIO_CLIENT))};`;
135
+ }
121
136
  function generateVirtualAppStylesheetUrl() {
122
137
  return `import stylesheetUrl from "/src/styles.css?url";
123
138
 
@@ -130,6 +145,7 @@ import { camoxApp } from "virtual:camox/app";
130
145
  import { camoxDocument } from "virtual:camox/document";
131
146
  import appStylesheetUrl from "virtual:camox/app-stylesheet-url";
132
147
  import pageClientEntryUrl from "virtual:camox/page-client-url";
148
+ import studioClientEntryUrl from "virtual:camox/studio-client-url";
133
149
  import { renderPage } from "virtual:camox/page-server";
134
150
  import { renderStudio } from "virtual:camox/studio-server";
135
151
 
@@ -137,7 +153,8 @@ export async function handleCamoxRequest(request) {
137
153
  return handleRuntimeRequest(request, {
138
154
  apiUrl: __CAMOX_API_URL__,
139
155
  authenticationUrl: __CAMOX_AUTHENTICATION_URL__,
140
- clientEntryUrl: pageClientEntryUrl,
156
+ pageClientEntryUrl,
157
+ studioClientEntryUrl,
141
158
  environmentName: __CAMOX_ENVIRONMENT_NAME__,
142
159
  getCamoxApp: async () => camoxApp,
143
160
  getDocument: async () => camoxDocument,
@@ -228,6 +245,8 @@ function resolveRuntimeDevId(id, importer) {
228
245
  if (id === VIRTUAL_STUDIO_SERVER) return RESOLVED_VIRTUAL_STUDIO_SERVER;
229
246
  if (id === VIRTUAL_PAGE_CLIENT) return RESOLVED_VIRTUAL_PAGE_CLIENT;
230
247
  if (id === VIRTUAL_PAGE_CLIENT_URL) return RESOLVED_VIRTUAL_PAGE_CLIENT_URL;
248
+ if (id === VIRTUAL_STUDIO_CLIENT) return RESOLVED_VIRTUAL_STUDIO_CLIENT;
249
+ if (id === VIRTUAL_STUDIO_CLIENT_URL) return RESOLVED_VIRTUAL_STUDIO_CLIENT_URL;
231
250
  if (id === VIRTUAL_APP_STYLESHEET_URL) return RESOLVED_VIRTUAL_APP_STYLESHEET_URL;
232
251
  if (id === VIRTUAL_STUDIO_CSS) return RESOLVED_VIRTUAL_STUDIO_CSS;
233
252
  if (id === VIRTUAL_OVERLAY_CSS) return RESOLVED_VIRTUAL_OVERLAY_CSS;
@@ -241,6 +260,8 @@ function loadRuntimeDevModule(id, options = {}) {
241
260
  if (id === RESOLVED_VIRTUAL_STUDIO_SERVER) return generateVirtualStudioServer();
242
261
  if (id === RESOLVED_VIRTUAL_PAGE_CLIENT) return generateVirtualPageClient();
243
262
  if (id === RESOLVED_VIRTUAL_PAGE_CLIENT_URL) return generateVirtualPageClientUrl();
263
+ if (id === RESOLVED_VIRTUAL_STUDIO_CLIENT) return generateVirtualStudioClient();
264
+ if (id === RESOLVED_VIRTUAL_STUDIO_CLIENT_URL) return generateVirtualStudioClientUrl();
244
265
  if (id === RESOLVED_VIRTUAL_APP_STYLESHEET_URL) return generateVirtualAppStylesheetUrl();
245
266
  if (id === RESOLVED_VIRTUAL_STUDIO_CSS) return `export default "/@fs/${resolve(sdkRoot, "dist/studio.css")}";`;
246
267
  if (id === RESOLVED_VIRTUAL_OVERLAY_CSS) return `export default ${JSON.stringify(readFileSync(resolve(sdkRoot, "dist/studio-overlays.css"), "utf-8"))};`;
@@ -19,6 +19,8 @@ const VIRTUAL_OVERLAY_CSS = "virtual:camox-overlay-css";
19
19
  const RESOLVED_VIRTUAL_OVERLAY_CSS = "\0" + VIRTUAL_OVERLAY_CSS;
20
20
  const VIRTUAL_PAGE_CLIENT = "virtual:camox/page-client";
21
21
  const RESOLVED_VIRTUAL_PAGE_CLIENT_URL = "\0virtual:camox/page-client-url";
22
+ const VIRTUAL_STUDIO_CLIENT = "virtual:camox/studio-client";
23
+ const RESOLVED_VIRTUAL_STUDIO_CLIENT_URL = "\0virtual:camox/studio-client-url";
22
24
  const PRODUCTION_API_URL = "https://api.camox.ai";
23
25
  /** Authentication URL to use for Camox authentication (production Camox Dashboard) */
24
26
  const DEFAULT_AUTHENTICATION_URL = "https://app.camox.ai";
@@ -97,6 +99,7 @@ function camox(options) {
97
99
  return `export default ${JSON.stringify(css)};`;
98
100
  }
99
101
  if (id === RESOLVED_VIRTUAL_PAGE_CLIENT_URL && isBuild) return "export default \"/_chunks/camox-page-client.mjs\";";
102
+ if (id === RESOLVED_VIRTUAL_STUDIO_CLIENT_URL && isBuild) return "export default \"/_chunks/camox-studio-client.mjs\";";
100
103
  return loadRuntimeDevModule(id, { runtimeBasePath });
101
104
  },
102
105
  nitro: { setup(nitro) {
@@ -121,7 +124,10 @@ function camox(options) {
121
124
  __CAMOX_PROJECT_SLUG__: JSON.stringify(options.projectSlug)
122
125
  },
123
126
  environments: { client: { build: { rollupOptions: {
124
- input: { "camox-page-client": VIRTUAL_PAGE_CLIENT },
127
+ input: {
128
+ "camox-page-client": VIRTUAL_PAGE_CLIENT,
129
+ "camox-studio-client": VIRTUAL_STUDIO_CLIENT
130
+ },
125
131
  output: {
126
132
  assetFileNames: "assets/[name]-[hash][extname]",
127
133
  chunkFileNames: "_chunks/[name]-[hash].mjs",
@@ -1,4 +1,4 @@
1
- import { blockQueries } from "./queries.js";
1
+ import { viewBlockQueries } from "./view-queries.js";
2
2
  import { c } from "react/compiler-runtime";
3
3
  import { useQueries } from "@tanstack/react-query";
4
4
  import * as React from "react";
@@ -11,9 +11,9 @@ const NormalizedDataContext = React.createContext({
11
11
  });
12
12
  const NormalizedDataProvider = (t0) => {
13
13
  const $ = c(13);
14
- if ($[0] !== "08bed558b0a428c072e8a0761d5efbb6bd49b29518144153bf64ed61004f9dda") {
14
+ if ($[0] !== "9680f54d18eb424030716d5c43a9901462a27cc0d8227fb40b5d6abb9b464a89") {
15
15
  for (let $i = 0; $i < 13; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
16
- $[0] = "08bed558b0a428c072e8a0761d5efbb6bd49b29518144153bf64ed61004f9dda";
16
+ $[0] = "9680f54d18eb424030716d5c43a9901462a27cc0d8227fb40b5d6abb9b464a89";
17
17
  }
18
18
  const { files, repeatableItems, children } = t0;
19
19
  let t1;
@@ -74,9 +74,9 @@ function useStableArray(next) {
74
74
  }
75
75
  function usePageBlocks(pageStructure, t0) {
76
76
  const $ = c(37);
77
- if ($[0] !== "08bed558b0a428c072e8a0761d5efbb6bd49b29518144153bf64ed61004f9dda") {
77
+ if ($[0] !== "9680f54d18eb424030716d5c43a9901462a27cc0d8227fb40b5d6abb9b464a89") {
78
78
  for (let $i = 0; $i < 37; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
79
- $[0] = "08bed558b0a428c072e8a0761d5efbb6bd49b29518144153bf64ed61004f9dda";
79
+ $[0] = "9680f54d18eb424030716d5c43a9901462a27cc0d8227fb40b5d6abb9b464a89";
80
80
  }
81
81
  const source = t0 === void 0 ? "draft" : t0;
82
82
  const blockIds = pageStructure.page.blockIds;
@@ -97,7 +97,7 @@ function usePageBlocks(pageStructure, t0) {
97
97
  const allIds = t1;
98
98
  let t2;
99
99
  if ($[5] !== allIds || $[6] !== source) {
100
- t2 = { queries: allIds.map((id) => blockQueries.get(id, source)) };
100
+ t2 = { queries: allIds.map((id) => viewBlockQueries.get(id, source)) };
101
101
  $[5] = allIds;
102
102
  $[6] = source;
103
103
  $[7] = t2;