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,7 +1,7 @@
1
1
  import { c } from "react/compiler-runtime";
2
- import { Input } from "@camox/ui/input";
3
- import { Label } from "@camox/ui/label";
4
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Label } from "@camox/ui/label";
4
+ import { Input } from "@camox/ui/input";
5
5
 
6
6
  //#region src/features/preview/components/PageNicknameField.tsx
7
7
  const PAGE_NICKNAME_MAX_LENGTH = 80;
@@ -4,15 +4,15 @@ import { pageMutations, pageQueries, projectQueries } from "../../../lib/queries
4
4
  import { cn } from "../../../lib/utils.js";
5
5
  import { previewStore } from "../previewStore.js";
6
6
  import { PageStatusBadge } from "./PageStatusBadge.js";
7
- import { Popover, PopoverContent, PopoverTrigger } from "@camox/ui/popover";
8
7
  import { useMutation, useQuery } from "@tanstack/react-query";
9
- import { useSelector } from "@xstate/store-react";
10
8
  import * as React from "react";
11
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
- import { toast } from "@camox/ui/toaster";
10
+ import { useSelector } from "@xstate/store-react";
13
11
  import { Button } from "@camox/ui/button";
14
12
  import { Check, ChevronsUpDown, Pencil, Plus, Trash2 } from "lucide-react";
15
13
  import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
14
+ import { Popover, PopoverContent, PopoverTrigger } from "@camox/ui/popover";
15
+ import { toast } from "@camox/ui/toaster";
16
16
  import { Skeleton } from "@camox/ui/skeleton";
17
17
  import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator } from "@camox/ui/command";
18
18
 
@@ -1,15 +1,15 @@
1
- import { cn } from "../../../lib/utils.js";
2
- import { previewStore } from "../previewStore.js";
3
1
  import { usePageBlocks } from "../../../lib/normalized-data.js";
2
+ import { cn } from "../../../lib/utils.js";
4
3
  import { useCamoxApp } from "../../provider/components/CamoxAppContext.js";
4
+ import { previewStore } from "../previewStore.js";
5
5
  import { useRequireDraftSource } from "../../../core/hooks/useRequireDraftSource.js";
6
6
  import { useUpdateBlockPosition } from "./useUpdateBlockPosition.js";
7
7
  import { BlockActionsPopover } from "./BlockActionsPopover.js";
8
8
  import { usePreviewedPage } from "../CamoxPreview.js";
9
9
  import { c } from "react/compiler-runtime";
10
- import { useSelector } from "@xstate/store-react";
11
10
  import * as React from "react";
12
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
+ import { useSelector } from "@xstate/store-react";
13
13
  import { Button } from "@camox/ui/button";
14
14
  import { Ellipsis, GripVertical, LayoutTemplate, Plus } from "lucide-react";
15
15
  import { Tooltip, TooltipContent, TooltipTrigger } from "@camox/ui/tooltip";
@@ -1,10 +1,10 @@
1
- import { previewStore } from "../previewStore.js";
2
1
  import { NormalizedDataProvider } from "../../../lib/normalized-data.js";
3
2
  import { BlockErrorBoundary } from "./BlockErrorBoundary.js";
3
+ import { previewStore } from "../previewStore.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 } from "react/jsx-runtime";
7
+ import { useSelector } from "@xstate/store-react";
8
8
 
9
9
  //#region src/features/preview/components/PeekedBlock.tsx
10
10
  const PeekedBlock = (t0) => {
@@ -1,17 +1,17 @@
1
1
  import { actionsStore } from "../../provider/actionsStore.js";
2
2
  import { checkIfInputFocused, cn } from "../../../lib/utils.js";
3
- import { Frame, useFrame } from "./Frame.js";
4
3
  import { previewStore } from "../previewStore.js";
5
4
  import { useBlockActionsShortcuts } from "./BlockActionsPopover.js";
6
5
  import { FieldOverlayStyles } from "./FieldOverlayStyles.js";
7
6
  import { FieldToolbar } from "./FieldToolbar.js";
7
+ import { Frame, useFrame } from "./Frame.js";
8
8
  import { Overlays } from "./Overlays.js";
9
9
  import { OverlayTracker } from "./OverlayTracker.js";
10
10
  import { PreviewToolbar } from "./PreviewToolbar.js";
11
11
  import { c } from "react/compiler-runtime";
12
- import { useSelector } from "@xstate/store-react";
13
12
  import * as React from "react";
14
13
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
14
+ import { useSelector } from "@xstate/store-react";
15
15
  import { PanelContent } from "@camox/ui/panel";
16
16
 
17
17
  //#region src/features/preview/components/PreviewPanel.tsx
@@ -2,25 +2,25 @@ import { actionsStore } from "../../provider/actionsStore.js";
2
2
  import { getActionShortcut } from "../../../lib/utils.js";
3
3
  import { previewStore } from "../previewStore.js";
4
4
  import { c } from "react/compiler-runtime";
5
- import { Label } from "@camox/ui/label";
6
- import { useSelector } from "@xstate/store-react";
7
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { useSelector } from "@xstate/store-react";
8
7
  import { Button } from "@camox/ui/button";
9
8
  import { Monitor, Smartphone, Tablet, X } from "lucide-react";
9
+ import { Label } from "@camox/ui/label";
10
10
  import { ButtonGroup } from "@camox/ui/button-group";
11
- import { Switch } from "@camox/ui/switch";
12
11
  import * as Tooltip$1 from "@camox/ui/tooltip";
12
+ import { Switch } from "@camox/ui/switch";
13
13
  import { FloatingToolbar } from "@camox/ui/floating-toolbar";
14
14
  import { Toggle } from "@camox/ui/toggle";
15
15
 
16
16
  //#region src/features/preview/components/PreviewToolbar.tsx
17
17
  const PreviewToolbar = (t0) => {
18
- const $ = c(68);
19
- if ($[0] !== "68e35a20462160afd6c2aeaffaf03edcd93240318bca212e17001e624c1d829c") {
20
- for (let $i = 0; $i < 68; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
21
- $[0] = "68e35a20462160afd6c2aeaffaf03edcd93240318bca212e17001e624c1d829c";
18
+ const $ = c(74);
19
+ if ($[0] !== "f9ff999569a69264033e31a270ebbb7097b2072aec97a7129d1758e95b5b6407") {
20
+ for (let $i = 0; $i < 74; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
21
+ $[0] = "f9ff999569a69264033e31a270ebbb7097b2072aec97a7129d1758e95b5b6407";
22
22
  }
23
- const { onEditModeChange } = t0;
23
+ const { onEditModeChange, pageStatus, hasLiveVersion } = t0;
24
24
  const isEditMode = useSelector(previewStore, _temp);
25
25
  const isToolbarHidden = useSelector(previewStore, _temp2);
26
26
  const actions = useSelector(actionsStore, _temp3);
@@ -70,7 +70,7 @@ const PreviewToolbar = (t0) => {
70
70
  let t5;
71
71
  if ($[11] !== t2 || $[12] !== t4) {
72
72
  t5 = /* @__PURE__ */ jsxs("div", {
73
- className: "flex items-center gap-2 px-2",
73
+ className: "flex shrink-0 items-center gap-2 px-2",
74
74
  children: [t2, t4]
75
75
  });
76
76
  $[11] = t2;
@@ -246,65 +246,88 @@ const PreviewToolbar = (t0) => {
246
246
  $[53] = t30;
247
247
  } else t30 = $[53];
248
248
  let t31;
249
- if ($[54] !== isEditMode) {
250
- t31 = /* @__PURE__ */ jsx(Button, {
249
+ if ($[54] !== hasLiveVersion || $[55] !== pageStatus) {
250
+ t31 = pageStatus && /* @__PURE__ */ jsx(Button, {
251
+ type: "button",
252
+ variant: "outline",
253
+ disabled: pageStatus === "published" || !hasLiveVersion,
254
+ onClick: _temp5,
255
+ children: "View live site"
256
+ });
257
+ $[54] = hasLiveVersion;
258
+ $[55] = pageStatus;
259
+ $[56] = t31;
260
+ } else t31 = $[56];
261
+ let t32;
262
+ if ($[57] !== isEditMode) {
263
+ t32 = /* @__PURE__ */ jsx(Button, {
251
264
  type: "button",
252
265
  variant: "ghost",
253
266
  size: "icon",
254
267
  disabled: isEditMode,
255
- onClick: _temp5,
268
+ onClick: _temp6,
256
269
  "aria-label": "Hide toolbar",
257
270
  className: "text-muted-foreground"
258
271
  });
259
- $[54] = isEditMode;
260
- $[55] = t31;
261
- } else t31 = $[55];
262
- let t32;
263
- if ($[56] === Symbol.for("react.memo_cache_sentinel")) {
264
- t32 = /* @__PURE__ */ jsx(X, {});
265
- $[56] = t32;
266
- } else t32 = $[56];
272
+ $[57] = isEditMode;
273
+ $[58] = t32;
274
+ } else t32 = $[58];
267
275
  let t33;
268
- if ($[57] !== t31) {
269
- t33 = /* @__PURE__ */ jsx(Tooltip$1.TooltipTrigger, {
270
- render: t31,
271
- children: t32
272
- });
273
- $[57] = t31;
274
- $[58] = t33;
275
- } else t33 = $[58];
276
- let t34;
277
276
  if ($[59] === Symbol.for("react.memo_cache_sentinel")) {
278
- t34 = /* @__PURE__ */ jsx(Tooltip$1.TooltipContent, { children: "Hide toolbar" });
279
- $[59] = t34;
280
- } else t34 = $[59];
277
+ t33 = /* @__PURE__ */ jsx(X, {});
278
+ $[59] = t33;
279
+ } else t33 = $[59];
280
+ let t34;
281
+ if ($[60] !== t32) {
282
+ t34 = /* @__PURE__ */ jsx(Tooltip$1.TooltipTrigger, {
283
+ render: t32,
284
+ children: t33
285
+ });
286
+ $[60] = t32;
287
+ $[61] = t34;
288
+ } else t34 = $[61];
281
289
  let t35;
282
- if ($[60] !== t33) {
283
- t35 = /* @__PURE__ */ jsxs(Tooltip$1.Tooltip, { children: [t33, t34] });
284
- $[60] = t33;
285
- $[61] = t35;
286
- } else t35 = $[61];
290
+ if ($[62] === Symbol.for("react.memo_cache_sentinel")) {
291
+ t35 = /* @__PURE__ */ jsx(Tooltip$1.TooltipContent, { children: "Hide toolbar" });
292
+ $[62] = t35;
293
+ } else t35 = $[62];
287
294
  let t36;
288
- if ($[62] !== t30 || $[63] !== t35) {
289
- t36 = /* @__PURE__ */ jsxs("div", {
290
- className: "flex items-center gap-2",
291
- children: [t30, t35]
292
- });
293
- $[62] = t30;
294
- $[63] = t35;
295
+ if ($[63] !== t34) {
296
+ t36 = /* @__PURE__ */ jsxs(Tooltip$1.Tooltip, { children: [t34, t35] });
297
+ $[63] = t34;
295
298
  $[64] = t36;
296
299
  } else t36 = $[64];
297
300
  let t37;
298
- if ($[65] !== t36 || $[66] !== t5) {
299
- t37 = /* @__PURE__ */ jsxs(FloatingToolbar, {
300
- className: "bottom-2 justify-between gap-8 transition-none",
301
- children: [t5, t36]
301
+ if ($[65] !== t31 || $[66] !== t36) {
302
+ t37 = /* @__PURE__ */ jsxs("div", {
303
+ className: "flex items-center gap-2",
304
+ children: [t31, t36]
302
305
  });
303
- $[65] = t36;
304
- $[66] = t5;
306
+ $[65] = t31;
307
+ $[66] = t36;
305
308
  $[67] = t37;
306
309
  } else t37 = $[67];
307
- return t37;
310
+ let t38;
311
+ if ($[68] !== t30 || $[69] !== t37) {
312
+ t38 = /* @__PURE__ */ jsxs("div", {
313
+ className: "flex shrink-0 items-center gap-8 self-stretch",
314
+ children: [t30, t37]
315
+ });
316
+ $[68] = t30;
317
+ $[69] = t37;
318
+ $[70] = t38;
319
+ } else t38 = $[70];
320
+ let t39;
321
+ if ($[71] !== t38 || $[72] !== t5) {
322
+ t39 = /* @__PURE__ */ jsxs(FloatingToolbar, {
323
+ className: "bottom-2 w-max justify-between gap-8 transition-none",
324
+ children: [t5, t38]
325
+ });
326
+ $[71] = t38;
327
+ $[72] = t5;
328
+ $[73] = t39;
329
+ } else t39 = $[73];
330
+ return t39;
308
331
  };
309
332
  function _temp(state) {
310
333
  return state.context.isEditMode;
@@ -319,6 +342,9 @@ function _temp4(state_2) {
319
342
  return state_2.context.viewportMode;
320
343
  }
321
344
  function _temp5() {
345
+ return previewStore.send({ type: "viewLivePage" });
346
+ }
347
+ function _temp6() {
322
348
  return previewStore.send({ type: "hideToolbar" });
323
349
  }
324
350
 
@@ -1,11 +1,11 @@
1
1
  import { pageMutations } from "../../../lib/queries.js";
2
2
  import { trackClientEvent } from "../../../lib/telemetry-client.js";
3
- import { Label } from "@camox/ui/label";
4
3
  import { useMutation } from "@tanstack/react-query";
5
4
  import * as React from "react";
6
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
- import { toast } from "@camox/ui/toaster";
8
6
  import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
7
+ import { toast } from "@camox/ui/toaster";
8
+ import { Label } from "@camox/ui/label";
9
9
  import { Switch } from "@camox/ui/switch";
10
10
 
11
11
  //#region src/features/preview/components/PublishDialog.tsx
@@ -4,8 +4,8 @@ import { previewStore, selectionItemId } from "../previewStore.js";
4
4
  import { useRepeatableItemActions } from "./useRepeatableItemActions.js";
5
5
  import { c } from "react/compiler-runtime";
6
6
  import { useMutation } from "@tanstack/react-query";
7
- import { useSelector } from "@xstate/store-react";
8
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
+ import { useSelector } from "@xstate/store-react";
9
9
  import { Button } from "@camox/ui/button";
10
10
  import { CircleMinus, CirclePlus, GripVertical } from "lucide-react";
11
11
  import { Tooltip, TooltipContent, TooltipTrigger } from "@camox/ui/tooltip";
@@ -3,8 +3,8 @@ import { AgentChatSidebar } from "../../agent-chat/components/AgentChatSidebar.j
3
3
  import { PageEditorSidebar } from "./PageEditorSidebar.js";
4
4
  import { PageInfoSidebar } from "./PageInfoSidebar.js";
5
5
  import { c } from "react/compiler-runtime";
6
- import { useSelector } from "@xstate/store-react";
7
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { useSelector } from "@xstate/store-react";
8
8
 
9
9
  //#region src/features/preview/components/RightSidebar.tsx
10
10
  const getRightSidebarRoute = ({ pageId, selectedBlockId, isAgentChatSidebarOpen }) => {
@@ -1,6 +1,6 @@
1
1
  import { repeatableItemMutations } from "../../../lib/queries.js";
2
- import { previewStore } from "../previewStore.js";
3
2
  import "../../provider/components/CamoxAppContext.js";
3
+ import { previewStore } from "../previewStore.js";
4
4
  import { useRequireDraftSource } from "../../../core/hooks/useRequireDraftSource.js";
5
5
  import { c } from "react/compiler-runtime";
6
6
  import { useMutation, useQuery } from "@tanstack/react-query";
@@ -3,8 +3,8 @@ import { blockMutations } from "../../../lib/queries.js";
3
3
  import { previewStore } from "../previewStore.js";
4
4
  import { c } from "react/compiler-runtime";
5
5
  import { useMutation, useQueryClient } from "@tanstack/react-query";
6
- import { useSelector } from "@xstate/store-react";
7
6
  import { generateKeyBetween } from "fractional-indexing";
7
+ import { useSelector } from "@xstate/store-react";
8
8
  import { queryKeys } from "@camox/api-contract/query-keys";
9
9
 
10
10
  //#region src/features/preview/components/useUpdateBlockPosition.ts
@@ -26,7 +26,6 @@ const previewStore = createStore({
26
26
  context: {
27
27
  isEditMode: false,
28
28
  isToolbarHidden: false,
29
- isSidebarOpen: true,
30
29
  isPageEditorSidebarOpen: false,
31
30
  isAddBlockSidebarOpen: false,
32
31
  addBlockSource: null,
@@ -64,17 +63,25 @@ const previewStore = createStore({
64
63
  return {
65
64
  ...context,
66
65
  isEditMode: true,
67
- isSidebarOpen: true
66
+ isToolbarHidden: false
68
67
  };
69
68
  },
70
69
  hideToolbar: (context) => ({
71
70
  ...context,
72
71
  isToolbarHidden: true
73
72
  }),
74
- toggleSidebar: (context) => ({
75
- ...context,
76
- isSidebarOpen: true
77
- }),
73
+ viewLivePage: (context, _, enqueue) => {
74
+ enqueue.effect(() => {
75
+ if (context.isEditMode) trackClientEvent("edit_mode_toggled", { enabled: false });
76
+ toast("Viewing live version of the site");
77
+ });
78
+ return {
79
+ ...context,
80
+ isEditMode: false,
81
+ isToolbarHidden: true,
82
+ previewSource: "live"
83
+ };
84
+ },
78
85
  setViewportMode: (context, event) => {
79
86
  if (context.viewportMode === event.mode) return context;
80
87
  return {
@@ -0,0 +1,63 @@
1
+ import { AuthContext, useAuthActions } from "../../lib/auth.js";
2
+ import { projectQueries } from "../../lib/queries.js";
3
+ import { useApplyTheme, useThemeActions } from "../studio/useTheme.js";
4
+ import { useNavbarActions } from "../studio/components/Navbar.js";
5
+ import { identifyProject, identifyUser } from "../../lib/telemetry-client.js";
6
+ import { usePreviewPagesActions } from "../preview/CamoxPreview.js";
7
+ import { useProjectRoom } from "../../lib/use-project-room.js";
8
+ import { CommandPalette, useCommandPaletteActions } from "./components/CommandPalette.js";
9
+ import { useAdminShortcuts } from "./useAdminShortcuts.js";
10
+ import { useQuery } from "@tanstack/react-query";
11
+ import * as React from "react";
12
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
+ import { Toaster } from "@camox/ui/toaster";
14
+ import studioCssUrl from "virtual:camox-studio-css";
15
+
16
+ //#region src/features/provider/AuthenticatedCamoxProvider.tsx
17
+ function AuthenticatedCamoxProvider({ children }) {
18
+ useAdminShortcuts();
19
+ useCommandPaletteActions();
20
+ useThemeActions();
21
+ useAuthActions();
22
+ useNavbarActions();
23
+ usePreviewPagesActions();
24
+ const { authClient, apiUrl, projectSlug, environmentName } = React.useContext(AuthContext);
25
+ const { data: session } = authClient.useSession();
26
+ const { data: project } = useQuery(projectQueries.getBySlug(projectSlug));
27
+ useProjectRoom(apiUrl, project?.id);
28
+ React.useEffect(() => {
29
+ const user = session?.user;
30
+ if (!user) return;
31
+ identifyUser({
32
+ userId: user.id,
33
+ email: user.email,
34
+ name: user.name
35
+ });
36
+ }, [session?.user]);
37
+ React.useEffect(() => {
38
+ if (!project) return;
39
+ identifyProject({
40
+ projectId: project.id,
41
+ projectSlug,
42
+ projectName: project.name,
43
+ environmentName
44
+ });
45
+ }, [
46
+ environmentName,
47
+ project,
48
+ projectSlug
49
+ ]);
50
+ const { resolvedTheme } = useApplyTheme();
51
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
52
+ /* @__PURE__ */ jsx("link", {
53
+ rel: "stylesheet",
54
+ href: studioCssUrl
55
+ }),
56
+ children,
57
+ /* @__PURE__ */ jsx(Toaster, { theme: resolvedTheme }),
58
+ /* @__PURE__ */ jsx(CommandPalette, {})
59
+ ] });
60
+ }
61
+
62
+ //#endregion
63
+ export { AuthenticatedCamoxProvider };
@@ -4,20 +4,13 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
4
4
 
5
5
  //#region src/features/provider/CamoxProvider.d.ts
6
6
  interface CamoxProviderProps {
7
- children: React.ReactNode;
8
- camoxApp: CamoxApp;
9
- authenticationUrl: string;
10
7
  apiUrl: string;
11
- projectSlug: string;
8
+ authenticationUrl: string;
9
+ camoxApp: CamoxApp;
10
+ children: React.ReactNode;
12
11
  environmentName?: string;
12
+ projectSlug: string;
13
13
  }
14
- declare function CamoxProvider({
15
- children,
16
- camoxApp,
17
- authenticationUrl,
18
- apiUrl,
19
- projectSlug,
20
- environmentName
21
- }: CamoxProviderProps): _$react_jsx_runtime0.JSX.Element | null;
14
+ declare function CamoxProvider(props: CamoxProviderProps): _$react_jsx_runtime0.JSX.Element;
22
15
  //#endregion
23
16
  export { CamoxProvider };