camox 0.34.0 → 0.36.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 (80) 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 +110 -93
  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 +47 -111
  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 +40 -30
  37. package/dist/features/preview/components/PageInfoSidebar.js +158 -74
  38. package/dist/features/preview/components/PageLocationFieldset.js +1 -1
  39. package/dist/features/preview/components/PageNavigatorSidebar.js +244 -316
  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 +77 -51
  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/preview/previewStore.js +13 -6
  52. package/dist/features/provider/AuthenticatedCamoxProvider.js +63 -0
  53. package/dist/features/provider/CamoxProvider.d.ts +5 -12
  54. package/dist/features/provider/CamoxProvider.js +80 -338
  55. package/dist/features/provider/CoreCamoxProvider.js +37 -0
  56. package/dist/features/provider/LocalhostPreviewProvider.js +159 -0
  57. package/dist/features/provider/components/CommandPalette.js +1 -1
  58. package/dist/features/provider/useAdminShortcuts.js +1 -1
  59. package/dist/features/runtime/hydrationData.js +9 -0
  60. package/dist/features/runtime/pageApp.js +148 -35
  61. package/dist/features/runtime/pageClient.d.ts +1 -2
  62. package/dist/features/runtime/pageClient.js +3 -20
  63. package/dist/features/runtime/runtime.d.ts +1 -0
  64. package/dist/features/runtime/studioApp.js +76 -8
  65. package/dist/features/runtime/studioClient.d.ts +6 -0
  66. package/dist/features/runtime/studioClient.js +20 -0
  67. package/dist/features/runtime/studioNavigation.js +7 -2
  68. package/dist/features/studio/CamoxStudio.js +1 -1
  69. package/dist/features/studio/components/EnvironmentMenu.js +2 -2
  70. package/dist/features/studio/components/Navbar.js +5 -5
  71. package/dist/features/studio/components/ProjectMenu.js +5 -5
  72. package/dist/features/studio/useTheme.js +1 -22
  73. package/dist/features/vite/runtimeDev.js +24 -3
  74. package/dist/features/vite/vite.d.ts +1 -1
  75. package/dist/features/vite/vite.js +9 -3
  76. package/dist/lib/normalized-data.js +6 -6
  77. package/dist/lib/telemetry-client.js +2 -2
  78. package/dist/lib/view-queries.js +28 -0
  79. package/dist/studio.css +1 -1
  80. package/package.json +9 -4
@@ -1,367 +1,109 @@
1
1
  import { useLocation } from "../navigation/navigation.js";
2
- import { actionsStore } from "./actionsStore.js";
3
- import { AuthContext, createCamoxAuthClient, useAuthActions, useProcessOtt, useSignInRedirect } from "../../lib/auth.js";
4
- import { initApiClient } from "../../lib/api-client.js";
5
- import { projectQueries } from "../../lib/queries.js";
6
- import { identifyProject, identifyUser } from "../../lib/telemetry-client.js";
7
- import { CamoxAppProvider } from "./components/CamoxAppContext.js";
2
+ import { useSignInRedirect } from "../../lib/auth.js";
8
3
  import { STUDIO_BASE_PATH } from "../studio/routes.js";
9
- import { useApplyTheme, useThemeActions, useThemeValue } from "../studio/useTheme.js";
10
- import { useNavbarActions } from "../studio/components/Navbar.js";
11
- import { PreviewPanel } from "../preview/components/PreviewPanel.js";
12
- import { usePreviewPagesActions } from "../preview/CamoxPreview.js";
13
4
  import { AuthGate } from "../../components/AuthGate.js";
14
- import { useProjectRoom } from "../../lib/use-project-room.js";
15
- import { CommandPalette, useCommandPaletteActions } from "./components/CommandPalette.js";
16
- import { useAdminShortcuts } from "./useAdminShortcuts.js";
5
+ import { AuthenticatedCamoxProvider } from "./AuthenticatedCamoxProvider.js";
6
+ import { CoreCamoxProvider } from "./CoreCamoxProvider.js";
7
+ import { LocalhostPreviewProvider } from "./LocalhostPreviewProvider.js";
17
8
  import { c } from "react/compiler-runtime";
18
- import { useQuery } from "@tanstack/react-query";
19
9
  import * as React from "react";
20
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
21
- import { Toaster } from "@camox/ui/toaster";
22
- import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
23
- import { ReactQueryDevtools } from "@tanstack/react-query-devtools/production";
24
- import studioCssUrl from "virtual:camox-studio-css";
10
+ import { jsx } from "react/jsx-runtime";
25
11
 
26
12
  //#region src/features/provider/CamoxProvider.tsx
27
- const isLocalhost = () => {
28
- if (typeof window === "undefined") return false;
29
- const { hostname } = window.location;
30
- return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
31
- };
32
- const isStudioPathname = (pathname) => {
33
- return pathname === STUDIO_BASE_PATH || pathname.startsWith(`${STUDIO_BASE_PATH}/`);
34
- };
35
- const AuthenticatedCamoxProvider = ({ children }) => {
36
- useAdminShortcuts();
37
- useCommandPaletteActions();
38
- useThemeActions();
39
- useAuthActions();
40
- useNavbarActions();
41
- usePreviewPagesActions();
42
- const { authClient, apiUrl, projectSlug, environmentName } = React.useContext(AuthContext);
43
- const { data: session } = authClient.useSession();
44
- const user = session?.user;
45
- const { data: project } = useQuery(projectQueries.getBySlug(projectSlug));
46
- useProjectRoom(apiUrl, project?.id);
47
- React.useEffect(() => {
48
- if (!user) return;
49
- identifyUser({
50
- userId: user.id,
51
- email: user.email,
52
- name: user.name
53
- });
54
- }, [user]);
55
- React.useEffect(() => {
56
- if (!project) return;
57
- identifyProject({
58
- projectId: project.id,
59
- projectSlug,
60
- projectName: project.name,
61
- environmentName
62
- });
63
- }, [
64
- project,
65
- projectSlug,
66
- environmentName
67
- ]);
68
- const { resolvedTheme } = useApplyTheme();
69
- return /* @__PURE__ */ jsxs(Fragment, { children: [
70
- children,
71
- /* @__PURE__ */ jsx(Toaster, { theme: resolvedTheme }),
72
- /* @__PURE__ */ jsx(CommandPalette, {})
73
- ] });
74
- };
75
- const UnauthenticatedLocalhostPreview = (t0) => {
76
- const $ = c(21);
77
- if ($[0] !== "b1c15713f3d5278144fdb4341407ebb87565133d460491e2bdc2f40d8bd07203") {
78
- for (let $i = 0; $i < 21; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
79
- $[0] = "b1c15713f3d5278144fdb4341407ebb87565133d460491e2bdc2f40d8bd07203";
80
- }
81
- const { children } = t0;
82
- const signInRedirect = useSignInRedirect();
83
- const { resolvedTheme } = useApplyTheme();
84
- const [isSignInDialogOpen, setIsSignInDialogOpen] = React.useState(false);
85
- useAdminShortcuts();
86
- let t1;
87
- let t2;
88
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
89
- t1 = () => {
90
- const actions = [{
91
- id: "sign-in-to-edit",
92
- label: "Sign in to edit",
93
- aliases: ["Enter edit mode", "Edit mode"],
94
- groupLabel: "Preview",
95
- checkIfAvailable: _temp,
96
- execute: () => setIsSignInDialogOpen(true),
97
- shortcut: {
98
- key: "Enter",
99
- withMeta: true
100
- }
101
- }];
102
- actionsStore.send({
103
- type: "registerManyActions",
104
- actions
105
- });
106
- return () => {
107
- actionsStore.send({
108
- type: "unregisterManyActions",
109
- ids: actions.map(_temp2)
110
- });
111
- };
112
- };
113
- t2 = [];
114
- $[1] = t1;
115
- $[2] = t2;
116
- } else {
117
- t1 = $[1];
118
- t2 = $[2];
119
- }
120
- React.useEffect(t1, t2);
121
- let t3;
122
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
123
- t3 = /* @__PURE__ */ jsx("link", {
124
- rel: "stylesheet",
125
- href: studioCssUrl
126
- });
127
- $[3] = t3;
128
- } else t3 = $[3];
129
- let t4;
130
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
131
- t4 = { bottom: "1rem" };
132
- $[4] = t4;
133
- } else t4 = $[4];
134
- let t5;
135
- if ($[5] !== resolvedTheme) {
136
- t5 = /* @__PURE__ */ jsx(Toaster, {
137
- theme: resolvedTheme,
138
- position: "bottom-right",
139
- offset: t4
140
- });
141
- $[5] = resolvedTheme;
142
- $[6] = t5;
143
- } else t5 = $[6];
144
- let t6;
145
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
146
- t6 = { onEditModeChange: (checked) => {
147
- if (checked) setIsSignInDialogOpen(true);
148
- } };
149
- $[7] = t6;
150
- } else t6 = $[7];
151
- let t7;
152
- if ($[8] !== children) {
153
- t7 = /* @__PURE__ */ jsx("div", {
154
- className: "bg-background flex h-screen flex-col overflow-hidden",
155
- children: /* @__PURE__ */ jsx(PreviewPanel, {
156
- toolbarProps: t6,
157
- children
158
- })
159
- });
160
- $[8] = children;
161
- $[9] = t7;
162
- } else t7 = $[9];
163
- let t8;
164
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
165
- t8 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Sign in to edit" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "You need to sign in before you can enable edit mode." })] });
166
- $[10] = t8;
167
- } else t8 = $[10];
168
- let t9;
169
- if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
170
- t9 = /* @__PURE__ */ jsx(AlertDialogCancel, {
171
- variant: "outline",
172
- size: "default",
173
- children: "Cancel"
174
- });
175
- $[11] = t9;
176
- } else t9 = $[11];
177
- let t10;
178
- if ($[12] !== signInRedirect) {
179
- t10 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t8, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t9, /* @__PURE__ */ jsx(AlertDialogAction, {
180
- onClick: signInRedirect,
181
- children: "Sign in"
182
- })] })] });
183
- $[12] = signInRedirect;
184
- $[13] = t10;
185
- } else t10 = $[13];
186
- let t11;
187
- if ($[14] !== isSignInDialogOpen || $[15] !== t10) {
188
- t11 = /* @__PURE__ */ jsx(AlertDialog, {
189
- open: isSignInDialogOpen,
190
- onOpenChange: setIsSignInDialogOpen,
191
- children: t10
192
- });
193
- $[14] = isSignInDialogOpen;
194
- $[15] = t10;
195
- $[16] = t11;
196
- } else t11 = $[16];
197
- let t12;
198
- if ($[17] !== t11 || $[18] !== t5 || $[19] !== t7) {
199
- t12 = /* @__PURE__ */ jsxs(Fragment, { children: [
200
- t3,
201
- t5,
202
- t7,
203
- t11
204
- ] });
205
- $[17] = t11;
206
- $[18] = t5;
207
- $[19] = t7;
208
- $[20] = t12;
209
- } else t12 = $[20];
210
- return t12;
211
- };
212
- const UnauthenticatedPage = (t0) => {
213
- const $ = c(9);
214
- if ($[0] !== "b1c15713f3d5278144fdb4341407ebb87565133d460491e2bdc2f40d8bd07203") {
215
- for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
216
- $[0] = "b1c15713f3d5278144fdb4341407ebb87565133d460491e2bdc2f40d8bd07203";
217
- }
218
- const { children } = t0;
219
- const { theme } = useThemeValue();
220
- let t1;
221
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
222
- t1 = { bottom: "1rem" };
223
- $[1] = t1;
224
- } else t1 = $[1];
225
- let t2;
226
- if ($[2] !== theme) {
227
- t2 = /* @__PURE__ */ jsx(Toaster, {
228
- theme,
229
- position: "bottom-right",
230
- offset: t1
231
- });
232
- $[2] = theme;
233
- $[3] = t2;
234
- } else t2 = $[3];
235
- let t3;
236
- if ($[4] !== children) {
237
- t3 = /* @__PURE__ */ jsx("div", {
238
- className: "bg-background min-h-screen",
239
- children
240
- });
241
- $[4] = children;
242
- $[5] = t3;
243
- } else t3 = $[5];
244
- let t4;
245
- if ($[6] !== t2 || $[7] !== t3) {
246
- t4 = /* @__PURE__ */ jsxs(Fragment, { children: [t2, t3] });
247
- $[6] = t2;
248
- $[7] = t3;
249
- $[8] = t4;
250
- } else t4 = $[8];
251
- return t4;
252
- };
253
- const UnauthenticatedCamoxProvider = (t0) => {
254
- const $ = c(14);
255
- if ($[0] !== "b1c15713f3d5278144fdb4341407ebb87565133d460491e2bdc2f40d8bd07203") {
256
- for (let $i = 0; $i < 14; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
257
- $[0] = "b1c15713f3d5278144fdb4341407ebb87565133d460491e2bdc2f40d8bd07203";
13
+ function UnauthenticatedExperience(t0) {
14
+ const $ = c(13);
15
+ if ($[0] !== "29d68a11213af2b1fef531271ea0f2268b5c50fdad0696b9211d3ed97537e7c8") {
16
+ for (let $i = 0; $i < 13; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
17
+ $[0] = "29d68a11213af2b1fef531271ea0f2268b5c50fdad0696b9211d3ed97537e7c8";
258
18
  }
259
19
  const { children } = t0;
260
20
  const { pathname } = useLocation();
261
21
  let t1;
262
22
  if ($[1] !== pathname) {
263
- t1 = () => {
264
- if (typeof window === "undefined") return;
265
- if (pathname !== STUDIO_BASE_PATH) return window.location.href;
266
- return new URL("/", window.location.href).href;
267
- };
23
+ t1 = pathname === STUDIO_BASE_PATH || pathname.startsWith(`${STUDIO_BASE_PATH}/`);
268
24
  $[1] = pathname;
269
25
  $[2] = t1;
270
26
  } else t1 = $[2];
271
- const signInRedirect = useSignInRedirect(t1);
27
+ const isStudio = t1;
272
28
  let t2;
273
- let t3;
274
- if ($[3] !== pathname || $[4] !== signInRedirect) {
29
+ if ($[3] !== isStudio) {
275
30
  t2 = () => {
276
- if (!isStudioPathname(pathname)) return;
277
- signInRedirect();
31
+ if (typeof window === "undefined") return;
32
+ if (!isStudio) return window.location.href;
33
+ return new URL("/", window.location.href).href;
278
34
  };
279
- t3 = [pathname, signInRedirect];
280
- $[3] = pathname;
281
- $[4] = signInRedirect;
282
- $[5] = t2;
283
- $[6] = t3;
284
- } else {
285
- t2 = $[5];
286
- t3 = $[6];
287
- }
288
- React.useEffect(t2, t3);
35
+ $[3] = isStudio;
36
+ $[4] = t2;
37
+ } else t2 = $[4];
38
+ const signInRedirect = useSignInRedirect(t2);
39
+ let t3;
289
40
  let t4;
290
- let t5;
291
- if ($[7] !== signInRedirect) {
292
- t4 = () => {
293
- const handleKeyDown = (event) => {
294
- if (isLocalhost()) return;
295
- if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
296
- event.preventDefault();
297
- signInRedirect();
298
- }
299
- };
300
- document.addEventListener("keydown", handleKeyDown);
301
- return () => document.removeEventListener("keydown", handleKeyDown);
41
+ if ($[5] !== isStudio || $[6] !== signInRedirect) {
42
+ t3 = () => {
43
+ if (isStudio) signInRedirect();
302
44
  };
303
- t5 = [signInRedirect];
304
- $[7] = signInRedirect;
45
+ t4 = [isStudio, signInRedirect];
46
+ $[5] = isStudio;
47
+ $[6] = signInRedirect;
48
+ $[7] = t3;
305
49
  $[8] = t4;
306
- $[9] = t5;
307
50
  } else {
51
+ t3 = $[7];
308
52
  t4 = $[8];
309
- t5 = $[9];
310
- }
311
- React.useEffect(t4, t5);
312
- if (isStudioPathname(pathname)) return null;
313
- if (isLocalhost() && !isStudioPathname(pathname)) {
314
- let t6;
315
- if ($[10] !== children) {
316
- t6 = /* @__PURE__ */ jsx(UnauthenticatedLocalhostPreview, { children });
317
- $[10] = children;
318
- $[11] = t6;
319
- } else t6 = $[11];
320
- return t6;
321
53
  }
322
- let t6;
323
- if ($[12] !== children) {
324
- t6 = /* @__PURE__ */ jsx(UnauthenticatedPage, { children });
325
- $[12] = children;
326
- $[13] = t6;
327
- } else t6 = $[13];
328
- return t6;
329
- };
330
- function CamoxProvider({ children, camoxApp, authenticationUrl, apiUrl, projectSlug, environmentName }) {
331
- const authClient = React.useMemo(() => createCamoxAuthClient(apiUrl), [apiUrl]);
332
- const initializedApiUrl = React.useRef(null);
333
- if (initializedApiUrl.current !== apiUrl) {
334
- initApiClient(apiUrl, environmentName);
335
- initializedApiUrl.current = apiUrl;
54
+ React.useEffect(t3, t4);
55
+ if (isStudio) return null;
56
+ if (typeof window !== "undefined" && [
57
+ "localhost",
58
+ "127.0.0.1",
59
+ "::1"
60
+ ].includes(location.hostname)) {
61
+ let t5;
62
+ if ($[9] !== children) {
63
+ t5 = /* @__PURE__ */ jsx(LocalhostPreviewProvider, { children });
64
+ $[9] = children;
65
+ $[10] = t5;
66
+ } else t5 = $[10];
67
+ return t5;
336
68
  }
337
- if (!useProcessOtt(authClient)) return null;
338
- const unauthenticated = /* @__PURE__ */ jsx(UnauthenticatedCamoxProvider, { children });
339
- return /* @__PURE__ */ jsx(AuthContext.Provider, {
340
- value: {
341
- authClient,
342
- authenticationUrl,
343
- apiUrl,
344
- projectSlug,
345
- environmentName
346
- },
347
- children: /* @__PURE__ */ jsxs(CamoxAppProvider, {
348
- app: camoxApp,
349
- children: [__ENABLE_TANSTACK_DEVTOOLS__ && /* @__PURE__ */ jsx(ReactQueryDevtools, { initialIsOpen: false }), /* @__PURE__ */ jsx(AuthGate, {
350
- authenticated: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("link", {
351
- rel: "stylesheet",
352
- href: studioCssUrl
353
- }), /* @__PURE__ */ jsx(AuthenticatedCamoxProvider, { children })] }),
354
- loading: unauthenticated,
355
- unauthenticated
356
- })]
357
- })
358
- });
359
- }
360
- function _temp() {
361
- return true;
69
+ let t5;
70
+ if ($[11] !== children) {
71
+ t5 = /* @__PURE__ */ jsx("div", {
72
+ className: "bg-background min-h-screen",
73
+ children
74
+ });
75
+ $[11] = children;
76
+ $[12] = t5;
77
+ } else t5 = $[12];
78
+ return t5;
362
79
  }
363
- function _temp2(action) {
364
- return action.id;
80
+ function CamoxProvider(props) {
81
+ const $ = c(6);
82
+ if ($[0] !== "29d68a11213af2b1fef531271ea0f2268b5c50fdad0696b9211d3ed97537e7c8") {
83
+ for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
84
+ $[0] = "29d68a11213af2b1fef531271ea0f2268b5c50fdad0696b9211d3ed97537e7c8";
85
+ }
86
+ let t0;
87
+ if ($[1] !== props.children) {
88
+ t0 = /* @__PURE__ */ jsx(AuthGate, {
89
+ authenticated: /* @__PURE__ */ jsx(AuthenticatedCamoxProvider, { children: props.children }),
90
+ loading: /* @__PURE__ */ jsx(UnauthenticatedExperience, { children: props.children }),
91
+ unauthenticated: /* @__PURE__ */ jsx(UnauthenticatedExperience, { children: props.children })
92
+ });
93
+ $[1] = props.children;
94
+ $[2] = t0;
95
+ } else t0 = $[2];
96
+ let t1;
97
+ if ($[3] !== props || $[4] !== t0) {
98
+ t1 = /* @__PURE__ */ jsx(CoreCamoxProvider, {
99
+ ...props,
100
+ children: t0
101
+ });
102
+ $[3] = props;
103
+ $[4] = t0;
104
+ $[5] = t1;
105
+ } else t1 = $[5];
106
+ return t1;
365
107
  }
366
108
 
367
109
  //#endregion
@@ -0,0 +1,37 @@
1
+ import { AuthContext, createCamoxAuthClient, useProcessOtt } from "../../lib/auth.js";
2
+ import { initApiClient } from "../../lib/api-client.js";
3
+ import { CamoxAppProvider } from "./components/CamoxAppContext.js";
4
+ import * as React from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+
7
+ //#region src/features/provider/CoreCamoxProvider.tsx
8
+ function isLocalhostPreview() {
9
+ if (typeof window === "undefined") return false;
10
+ const { hostname } = window.location;
11
+ return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
12
+ }
13
+ function CoreCamoxProvider({ apiUrl, authenticationUrl, camoxApp, children, environmentName, projectSlug }) {
14
+ const authClient = React.useMemo(() => createCamoxAuthClient(apiUrl), [apiUrl]);
15
+ const initializedApiUrl = React.useRef(null);
16
+ if (initializedApiUrl.current !== apiUrl) {
17
+ initApiClient(apiUrl, environmentName);
18
+ initializedApiUrl.current = apiUrl;
19
+ }
20
+ useProcessOtt(authClient);
21
+ return /* @__PURE__ */ jsx(AuthContext.Provider, {
22
+ value: {
23
+ authClient,
24
+ authenticationUrl,
25
+ apiUrl,
26
+ projectSlug,
27
+ environmentName
28
+ },
29
+ children: /* @__PURE__ */ jsx(CamoxAppProvider, {
30
+ app: camoxApp,
31
+ children
32
+ })
33
+ });
34
+ }
35
+
36
+ //#endregion
37
+ export { CoreCamoxProvider, isLocalhostPreview };
@@ -0,0 +1,159 @@
1
+ import { actionsStore } from "./actionsStore.js";
2
+ import { useSignInRedirect } from "../../lib/auth.js";
3
+ import { useApplyTheme } from "../studio/useTheme.js";
4
+ import { PreviewPanel } from "../preview/components/PreviewPanel.js";
5
+ import { useAdminShortcuts } from "./useAdminShortcuts.js";
6
+ import { c } from "react/compiler-runtime";
7
+ import * as React from "react";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
10
+ import { Toaster } from "@camox/ui/toaster";
11
+ import studioCssUrl from "virtual:camox-studio-css";
12
+
13
+ //#region src/features/provider/LocalhostPreviewProvider.tsx
14
+ function LocalhostPreviewProvider(t0) {
15
+ const $ = c(21);
16
+ if ($[0] !== "bd39c46de8381d98c4a04fb8c92df87704f578a9561f6fbfafaa182175dd58dd") {
17
+ for (let $i = 0; $i < 21; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
18
+ $[0] = "bd39c46de8381d98c4a04fb8c92df87704f578a9561f6fbfafaa182175dd58dd";
19
+ }
20
+ const { children } = t0;
21
+ const signInRedirect = useSignInRedirect();
22
+ const { resolvedTheme } = useApplyTheme();
23
+ const [isSignInDialogOpen, setIsSignInDialogOpen] = React.useState(false);
24
+ useAdminShortcuts();
25
+ let t1;
26
+ let t2;
27
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
28
+ t1 = () => {
29
+ const actions = [{
30
+ id: "sign-in-to-edit",
31
+ label: "Sign in to edit",
32
+ aliases: ["Enter edit mode", "Edit mode"],
33
+ groupLabel: "Preview",
34
+ checkIfAvailable: _temp,
35
+ execute: () => setIsSignInDialogOpen(true),
36
+ shortcut: {
37
+ key: "Enter",
38
+ withMeta: true
39
+ }
40
+ }];
41
+ actionsStore.send({
42
+ type: "registerManyActions",
43
+ actions
44
+ });
45
+ return () => {
46
+ actionsStore.send({
47
+ type: "unregisterManyActions",
48
+ ids: actions.map(_temp2)
49
+ });
50
+ };
51
+ };
52
+ t2 = [];
53
+ $[1] = t1;
54
+ $[2] = t2;
55
+ } else {
56
+ t1 = $[1];
57
+ t2 = $[2];
58
+ }
59
+ React.useEffect(t1, t2);
60
+ let t3;
61
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
62
+ t3 = /* @__PURE__ */ jsx("link", {
63
+ rel: "stylesheet",
64
+ href: studioCssUrl
65
+ });
66
+ $[3] = t3;
67
+ } else t3 = $[3];
68
+ let t4;
69
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
70
+ t4 = { bottom: "1rem" };
71
+ $[4] = t4;
72
+ } else t4 = $[4];
73
+ let t5;
74
+ if ($[5] !== resolvedTheme) {
75
+ t5 = /* @__PURE__ */ jsx(Toaster, {
76
+ theme: resolvedTheme,
77
+ position: "bottom-right",
78
+ offset: t4
79
+ });
80
+ $[5] = resolvedTheme;
81
+ $[6] = t5;
82
+ } else t5 = $[6];
83
+ let t6;
84
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
85
+ t6 = { onEditModeChange: (checked) => {
86
+ if (checked) setIsSignInDialogOpen(true);
87
+ } };
88
+ $[7] = t6;
89
+ } else t6 = $[7];
90
+ let t7;
91
+ if ($[8] !== children) {
92
+ t7 = /* @__PURE__ */ jsx("div", {
93
+ className: "bg-background flex h-screen flex-col overflow-hidden",
94
+ children: /* @__PURE__ */ jsx(PreviewPanel, {
95
+ toolbarProps: t6,
96
+ children
97
+ })
98
+ });
99
+ $[8] = children;
100
+ $[9] = t7;
101
+ } else t7 = $[9];
102
+ let t8;
103
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
104
+ t8 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Sign in to edit" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "You need to sign in before you can enable edit mode." })] });
105
+ $[10] = t8;
106
+ } else t8 = $[10];
107
+ let t9;
108
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
109
+ t9 = /* @__PURE__ */ jsx(AlertDialogCancel, {
110
+ variant: "outline",
111
+ size: "default",
112
+ children: "Cancel"
113
+ });
114
+ $[11] = t9;
115
+ } else t9 = $[11];
116
+ let t10;
117
+ if ($[12] !== signInRedirect) {
118
+ t10 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t8, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t9, /* @__PURE__ */ jsx(AlertDialogAction, {
119
+ onClick: signInRedirect,
120
+ children: "Sign in"
121
+ })] })] });
122
+ $[12] = signInRedirect;
123
+ $[13] = t10;
124
+ } else t10 = $[13];
125
+ let t11;
126
+ if ($[14] !== isSignInDialogOpen || $[15] !== t10) {
127
+ t11 = /* @__PURE__ */ jsx(AlertDialog, {
128
+ open: isSignInDialogOpen,
129
+ onOpenChange: setIsSignInDialogOpen,
130
+ children: t10
131
+ });
132
+ $[14] = isSignInDialogOpen;
133
+ $[15] = t10;
134
+ $[16] = t11;
135
+ } else t11 = $[16];
136
+ let t12;
137
+ if ($[17] !== t11 || $[18] !== t5 || $[19] !== t7) {
138
+ t12 = /* @__PURE__ */ jsxs(Fragment, { children: [
139
+ t3,
140
+ t5,
141
+ t7,
142
+ t11
143
+ ] });
144
+ $[17] = t11;
145
+ $[18] = t5;
146
+ $[19] = t7;
147
+ $[20] = t12;
148
+ } else t12 = $[20];
149
+ return t12;
150
+ }
151
+ function _temp2(action) {
152
+ return action.id;
153
+ }
154
+ function _temp() {
155
+ return true;
156
+ }
157
+
158
+ //#endregion
159
+ export { LocalhostPreviewProvider };
@@ -2,9 +2,9 @@ import { actionsStore } from "../actionsStore.js";
2
2
  import { formatShortcut } from "../../../lib/utils.js";
3
3
  import { studioStore } from "../../studio/studioStore.js";
4
4
  import { c } from "react/compiler-runtime";
5
- import { useSelector } from "@xstate/store-react";
6
5
  import * as React from "react";
7
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { useSelector } from "@xstate/store-react";
8
8
  import { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandShortcut } from "@camox/ui/command";
9
9
 
10
10
  //#region src/features/provider/components/CommandPalette.tsx
@@ -1,8 +1,8 @@
1
1
  import { actionsStore } from "./actionsStore.js";
2
2
  import { checkIfInputFocused } from "../../lib/utils.js";
3
3
  import { c } from "react/compiler-runtime";
4
- import { useSelector } from "@xstate/store-react";
5
4
  import * as React from "react";
5
+ import { useSelector } from "@xstate/store-react";
6
6
 
7
7
  //#region src/features/provider/useAdminShortcuts.tsx
8
8
  /**
@@ -0,0 +1,9 @@
1
+ //#region src/features/runtime/hydrationData.ts
2
+ function readHydrationData() {
3
+ const script = document.getElementById("__CAMOX_DATA__");
4
+ if (!script?.textContent) throw new Error("Camox runtime hydration data was not found.");
5
+ return JSON.parse(script.textContent);
6
+ }
7
+
8
+ //#endregion
9
+ export { readHydrationData };