camox 0.41.0 → 0.42.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 (60) hide show
  1. package/dist/core/components/lexical/SidebarLexicalEditor.js +42 -39
  2. package/dist/core/createApp.d.ts +16 -2
  3. package/dist/core/createBlock.js +11 -25
  4. package/dist/core/editing/BlockEditingRuntime.js +4 -4
  5. package/dist/core/editing/CompleteBlockEditingRuntime.js +5 -5
  6. package/dist/core/editing/createEditableBlock.d.ts +8 -1
  7. package/dist/core/editing/createEditableBlock.js +684 -644
  8. package/dist/core/hooks/useIsEditable.js +4 -7
  9. package/dist/core/hooks/useOverlayState.js +11 -0
  10. package/dist/core/hooks/useRequireDraftSource.js +7 -11
  11. package/dist/core/lib/fieldTypes.js +5 -5
  12. package/dist/core/lib/lexicalState.js +17 -1
  13. package/dist/features/preview/CamoxPreview.js +123 -137
  14. package/dist/features/preview/DerivedPreview.js +6 -9
  15. package/dist/features/preview/commentsEnabled.js +8 -0
  16. package/dist/features/preview/components/AddBlockSidebar.js +79 -89
  17. package/dist/features/preview/components/AssetLightbox.js +4 -11
  18. package/dist/features/preview/components/AttachedComments.js +194 -0
  19. package/dist/features/preview/components/BlockActionsPopover.js +19 -70
  20. package/dist/features/preview/components/CommentHeader.js +122 -0
  21. package/dist/features/preview/components/CommentSidebar.js +29 -0
  22. package/dist/features/preview/components/CommentTargetQuote.js +166 -0
  23. package/dist/features/preview/components/CreatePageModal.js +2 -8
  24. package/dist/features/preview/components/DerivedLayoutSidebar.js +4 -7
  25. package/dist/features/preview/components/ItemFieldsEditor.js +275 -204
  26. package/dist/features/preview/components/LeftSidebar.js +18 -18
  27. package/dist/features/preview/components/LinkFieldEditor.js +3 -4
  28. package/dist/features/preview/components/MobilePreviewDrawer.js +3 -3
  29. package/dist/features/preview/components/OverlayTracker.js +14 -20
  30. package/dist/features/preview/components/Overlays.js +28 -40
  31. package/dist/features/preview/components/PageEditorSidebar.js +231 -241
  32. package/dist/features/preview/components/PageInfoSidebar.js +126 -157
  33. package/dist/features/preview/components/PagePicker.js +13 -8
  34. package/dist/features/preview/components/PageTree.js +255 -319
  35. package/dist/features/preview/components/PreviewComments.js +56 -0
  36. package/dist/features/preview/components/PreviewPanel.js +149 -107
  37. package/dist/features/preview/components/PreviewToolbar.js +292 -246
  38. package/dist/features/preview/components/PreviewToolbarSpacer.js +43 -0
  39. package/dist/features/preview/components/PublicationRow.js +11 -24
  40. package/dist/features/preview/components/RightSidebar.js +14 -11
  41. package/dist/features/preview/components/SidebarSection.js +121 -0
  42. package/dist/features/preview/previewCommentsStore.js +115 -0
  43. package/dist/features/preview/previewSelection.js +75 -0
  44. package/dist/features/preview/previewStore.js +32 -63
  45. package/dist/features/provider/AuthenticatedCamoxProvider.js +46 -34
  46. package/dist/features/provider/components/CommandPalette.js +142 -58
  47. package/dist/features/provider/useAdminShortcuts.js +20 -8
  48. package/dist/features/routes/pageRuntime.js +0 -6
  49. package/dist/features/runtime/RuntimeChrome.js +102 -87
  50. package/dist/features/studio/CamoxStudio.js +30 -50
  51. package/dist/features/studio/components/UserButton.js +4 -4
  52. package/dist/features/vite/runtimeDev.js +4 -1
  53. package/dist/features/vite/vite.d.ts +3 -2
  54. package/dist/features/vite/vite.js +9 -5
  55. package/dist/hooks/use-file-upload.js +0 -2
  56. package/dist/studio.css +1 -1
  57. package/package.json +5 -7
  58. package/dist/features/preview/components/DraftSwitchDialog.js +0 -66
  59. package/dist/lib/telemetry-client.js +0 -66
  60. package/dist/lib/telemetry.js +0 -26
@@ -1,12 +1,12 @@
1
1
  import { AuthContext, useAuthActions } from "../../lib/auth.js";
2
2
  import { projectQueries } from "../../lib/queries.js";
3
- import { identifyProject, identifyUser } from "../../lib/telemetry-client.js";
4
3
  import { useApplyTheme, useThemeActions } from "../studio/useTheme.js";
5
4
  import { useNavbarActions } from "../studio/components/Navbar.js";
6
5
  import { usePreviewPagesActions } from "../preview/CamoxPreview.js";
7
6
  import { useProjectRoom } from "../../lib/use-project-room.js";
8
7
  import { CommandPalette, useCommandPaletteActions } from "./components/CommandPalette.js";
9
8
  import { useAdminShortcuts } from "./useAdminShortcuts.js";
9
+ import { c } from "react/compiler-runtime";
10
10
  import { useQuery } from "@tanstack/react-query";
11
11
  import * as React from "react";
12
12
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -14,50 +14,62 @@ import { Toaster } from "@camox/ui/toaster";
14
14
  import studioCssUrl from "virtual:camox-studio-css";
15
15
 
16
16
  //#region src/features/provider/AuthenticatedCamoxProvider.tsx
17
- function AuthenticatedCamoxProvider({ children }) {
17
+ function AuthenticatedCamoxProvider(t0) {
18
+ const $ = c(10);
19
+ if ($[0] !== "5934dd91b5a9b867275ab8801058e109f6352a3ac512ceb2f083d56bd54b2d7a") {
20
+ for (let $i = 0; $i < 10; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
21
+ $[0] = "5934dd91b5a9b867275ab8801058e109f6352a3ac512ceb2f083d56bd54b2d7a";
22
+ }
23
+ const { children } = t0;
18
24
  useAdminShortcuts();
19
25
  useCommandPaletteActions();
20
26
  useThemeActions();
21
27
  useAuthActions();
22
28
  useNavbarActions();
23
29
  usePreviewPagesActions();
24
- const { authClient, apiUrl, projectSlug, environmentName } = React.useContext(AuthContext);
25
- const { data: session } = authClient.useSession();
26
- const { data: project } = useQuery(projectQueries.getBySlug(projectSlug));
30
+ const { apiUrl, projectSlug } = React.useContext(AuthContext);
31
+ let t1;
32
+ if ($[1] !== projectSlug) {
33
+ t1 = projectQueries.getBySlug(projectSlug);
34
+ $[1] = projectSlug;
35
+ $[2] = t1;
36
+ } else t1 = $[2];
37
+ const { data: project } = useQuery(t1);
27
38
  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
39
  const { resolvedTheme } = useApplyTheme();
51
- return /* @__PURE__ */ jsxs(Fragment, { children: [
52
- /* @__PURE__ */ jsx("link", {
40
+ let t2;
41
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
42
+ t2 = /* @__PURE__ */ jsx("link", {
53
43
  rel: "stylesheet",
54
44
  href: studioCssUrl,
55
45
  "data-camox-studio": true
56
- }),
57
- children,
58
- /* @__PURE__ */ jsx(Toaster, { theme: resolvedTheme }),
59
- /* @__PURE__ */ jsx(CommandPalette, {})
60
- ] });
46
+ });
47
+ $[3] = t2;
48
+ } else t2 = $[3];
49
+ let t3;
50
+ if ($[4] !== resolvedTheme) {
51
+ t3 = /* @__PURE__ */ jsx(Toaster, { theme: resolvedTheme });
52
+ $[4] = resolvedTheme;
53
+ $[5] = t3;
54
+ } else t3 = $[5];
55
+ let t4;
56
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
57
+ t4 = /* @__PURE__ */ jsx(CommandPalette, {});
58
+ $[6] = t4;
59
+ } else t4 = $[6];
60
+ let t5;
61
+ if ($[7] !== children || $[8] !== t3) {
62
+ t5 = /* @__PURE__ */ jsxs(Fragment, { children: [
63
+ t2,
64
+ children,
65
+ t3,
66
+ t4
67
+ ] });
68
+ $[7] = children;
69
+ $[8] = t3;
70
+ $[9] = t5;
71
+ } else t5 = $[9];
72
+ return t5;
61
73
  }
62
74
 
63
75
  //#endregion
@@ -5,14 +5,15 @@ import { c } from "react/compiler-runtime";
5
5
  import * as React from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { useSelector } from "@xstate/store-react";
8
+ import { Kbd } from "@camox/ui/kbd";
8
9
  import { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandShortcut } from "@camox/ui/command";
9
10
 
10
11
  //#region src/features/provider/components/CommandPalette.tsx
11
12
  function CommandPalette() {
12
- const $ = c(36);
13
- if ($[0] !== "85ba0b6dafc30e5e42d7a8100e19fddf7f674f2db2d4daf495b1cb749edf3f68") {
14
- for (let $i = 0; $i < 36; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
15
- $[0] = "85ba0b6dafc30e5e42d7a8100e19fddf7f674f2db2d4daf495b1cb749edf3f68";
13
+ const $ = c(43);
14
+ if ($[0] !== "911725dec1e42161265ff27436f9ae9c6c82392d2b8fce53f3eb80dfb29cb6f0") {
15
+ for (let $i = 0; $i < 43; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
16
+ $[0] = "911725dec1e42161265ff27436f9ae9c6c82392d2b8fce53f3eb80dfb29cb6f0";
16
17
  }
17
18
  const isOpen = useSelector(studioStore, _temp);
18
19
  const [search, setSearch] = React.useState("");
@@ -119,75 +120,158 @@ function CommandPalette() {
119
120
  } else t5 = $[19];
120
121
  const handleOpenChange = t5;
121
122
  let t6;
122
- if ($[20] !== search) {
123
- t6 = (e) => {
123
+ if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
124
+ t6 = /* @__PURE__ */ jsxs("div", {
125
+ className: "px-5 pt-5 pr-14 pb-3",
126
+ children: [/* @__PURE__ */ jsx("h2", {
127
+ className: "text-lg font-semibold tracking-tight",
128
+ children: "Command palette"
129
+ }), /* @__PURE__ */ jsx("p", {
130
+ className: "text-muted-foreground mt-1 text-sm",
131
+ children: "Navigate your site and switch settings quickly."
132
+ })]
133
+ });
134
+ $[20] = t6;
135
+ } else t6 = $[20];
136
+ let t7;
137
+ if ($[21] !== search) {
138
+ t7 = (e) => {
124
139
  if (e.key === "Escape" || e.key === "Backspace" && !search) {
125
140
  e.preventDefault();
126
141
  studioStore.send({ type: "popCommandPalettePage" });
127
142
  }
128
143
  };
129
- $[20] = search;
130
- $[21] = t6;
131
- } else t6 = $[21];
132
- let t7;
133
- if ($[22] !== search || $[23] !== t6) {
134
- t7 = /* @__PURE__ */ jsx(CommandInput, {
135
- value: search,
136
- onValueChange: setSearch,
137
- placeholder: "Type a command or search...",
138
- onKeyDown: t6
144
+ $[21] = search;
145
+ $[22] = t7;
146
+ } else t7 = $[22];
147
+ let t8;
148
+ if ($[23] !== search || $[24] !== t7) {
149
+ t8 = /* @__PURE__ */ jsx("div", {
150
+ className: "px-4 pb-4",
151
+ children: /* @__PURE__ */ jsx(CommandInput, {
152
+ className: "placeholder:text-muted-foreground h-full text-base",
153
+ inputGroupClassName: "h-11! border-2 border-primary bg-background rounded-xl! *:data-[slot=input-group-addon]:pl-4!",
154
+ value: search,
155
+ onValueChange: setSearch,
156
+ placeholder: "Type a command or search...",
157
+ onKeyDown: t7
158
+ })
139
159
  });
140
- $[22] = search;
141
- $[23] = t6;
160
+ $[23] = search;
142
161
  $[24] = t7;
143
- } else t7 = $[24];
144
- let t8;
145
- if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
146
- t8 = /* @__PURE__ */ jsx(CommandEmpty, { children: "No results found." });
147
162
  $[25] = t8;
148
163
  } else t8 = $[25];
149
164
  let t9;
150
- if ($[26] !== groupedActions || $[27] !== handleSelect) {
151
- t9 = /* @__PURE__ */ jsxs(CommandList, { children: [t8, Array.from(groupedActions.entries()).map((t10) => {
152
- const [groupLabel_0, groupActions] = t10;
153
- return /* @__PURE__ */ jsx(CommandGroup, {
154
- heading: groupLabel_0,
155
- children: groupActions.map((action_2) => /* @__PURE__ */ jsxs(CommandItem, {
156
- keywords: action_2.aliases,
157
- onSelect: () => handleSelect(action_2.id),
158
- className: "justify-between",
159
- children: [action_2.label, action_2.shortcut && /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut(action_2.shortcut) })]
160
- }, action_2.id))
161
- }, groupLabel_0);
162
- })] });
163
- $[26] = groupedActions;
164
- $[27] = handleSelect;
165
- $[28] = t9;
166
- } else t9 = $[28];
165
+ if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
166
+ t9 = /* @__PURE__ */ jsxs("span", {
167
+ className: "flex items-center gap-1.5",
168
+ children: [
169
+ /* @__PURE__ */ jsx(Kbd, { children: "↑" }),
170
+ /* @__PURE__ */ jsx(Kbd, { children: "↓" }),
171
+ " to navigate"
172
+ ]
173
+ });
174
+ $[26] = t9;
175
+ } else t9 = $[26];
167
176
  let t10;
168
- if ($[29] !== t7 || $[30] !== t9 || $[31] !== value) {
169
- t10 = /* @__PURE__ */ jsxs(Command, {
177
+ if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
178
+ t10 = /* @__PURE__ */ jsxs("span", {
179
+ className: "flex items-center gap-1.5",
180
+ children: [/* @__PURE__ */ jsx(Kbd, { children: "↵" }), " to select"]
181
+ });
182
+ $[27] = t10;
183
+ } else t10 = $[27];
184
+ let t11;
185
+ if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
186
+ t11 = /* @__PURE__ */ jsx(Kbd, { children: "Esc" });
187
+ $[28] = t11;
188
+ } else t11 = $[28];
189
+ const t12 = page ? "to go back" : "to close";
190
+ let t13;
191
+ if ($[29] !== t12) {
192
+ t13 = /* @__PURE__ */ jsxs("div", {
193
+ className: "text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-2 border-b px-5 pb-3 text-xs",
194
+ children: [
195
+ t9,
196
+ t10,
197
+ /* @__PURE__ */ jsxs("span", {
198
+ className: "flex items-center gap-1.5",
199
+ children: [
200
+ t11,
201
+ " ",
202
+ t12
203
+ ]
204
+ })
205
+ ]
206
+ });
207
+ $[29] = t12;
208
+ $[30] = t13;
209
+ } else t13 = $[30];
210
+ let t14;
211
+ if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
212
+ t14 = /* @__PURE__ */ jsx(CommandEmpty, {
213
+ className: "text-muted-foreground py-8",
214
+ children: "No results found."
215
+ });
216
+ $[31] = t14;
217
+ } else t14 = $[31];
218
+ let t15;
219
+ if ($[32] !== groupedActions || $[33] !== handleSelect) {
220
+ t15 = /* @__PURE__ */ jsxs(CommandList, {
221
+ className: "max-h-[min(24rem,45dvh)] min-h-0 scroll-py-1 px-2 pt-1 pb-2",
222
+ children: [t14, Array.from(groupedActions.entries()).map((t16) => {
223
+ const [groupLabel_0, groupActions] = t16;
224
+ return /* @__PURE__ */ jsx(CommandGroup, {
225
+ heading: groupLabel_0,
226
+ className: "mb-2 p-0 last:mb-0 **:[[cmdk-group-heading]]:px-3 **:[[cmdk-group-heading]]:py-2 **:[[cmdk-group-heading]]:text-[11px] **:[[cmdk-group-heading]]:tracking-widest **:[[cmdk-group-heading]]:uppercase",
227
+ children: groupActions.map((action_2) => /* @__PURE__ */ jsxs(CommandItem, {
228
+ keywords: action_2.aliases,
229
+ onSelect: () => handleSelect(action_2.id),
230
+ className: "min-h-10 justify-between gap-3 px-3 py-2 text-sm",
231
+ hideCheck: true,
232
+ children: [action_2.label, action_2.shortcut && /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut(action_2.shortcut) })]
233
+ }, action_2.id))
234
+ }, groupLabel_0);
235
+ })]
236
+ });
237
+ $[32] = groupedActions;
238
+ $[33] = handleSelect;
239
+ $[34] = t15;
240
+ } else t15 = $[34];
241
+ let t16;
242
+ if ($[35] !== t13 || $[36] !== t15 || $[37] !== t8 || $[38] !== value) {
243
+ t16 = /* @__PURE__ */ jsxs(Command, {
170
244
  value,
171
245
  onValueChange: setValue,
172
- children: [t7, t9]
246
+ className: "h-auto max-h-[80dvh] p-0",
247
+ children: [
248
+ t6,
249
+ t8,
250
+ t13,
251
+ t15
252
+ ]
173
253
  });
174
- $[29] = t7;
175
- $[30] = t9;
176
- $[31] = value;
177
- $[32] = t10;
178
- } else t10 = $[32];
179
- let t11;
180
- if ($[33] !== isOpen || $[34] !== t10) {
181
- t11 = /* @__PURE__ */ jsx(CommandDialog, {
254
+ $[35] = t13;
255
+ $[36] = t15;
256
+ $[37] = t8;
257
+ $[38] = value;
258
+ $[39] = t16;
259
+ } else t16 = $[39];
260
+ let t17;
261
+ if ($[40] !== isOpen || $[41] !== t16) {
262
+ t17 = /* @__PURE__ */ jsx(CommandDialog, {
182
263
  open: isOpen,
183
264
  onOpenChange: handleOpenChange,
184
- children: t10
265
+ className: "top-[12vh] sm:max-w-xl",
266
+ description: "Navigate your site and switch settings quickly.",
267
+ showCloseButton: true,
268
+ children: t16
185
269
  });
186
- $[33] = isOpen;
187
- $[34] = t10;
188
- $[35] = t11;
189
- } else t11 = $[35];
190
- return t11;
270
+ $[40] = isOpen;
271
+ $[41] = t16;
272
+ $[42] = t17;
273
+ } else t17 = $[42];
274
+ return t17;
191
275
  }
192
276
  function _temp3(state_1) {
193
277
  return state_1.context.commandPalettePages;
@@ -200,9 +284,9 @@ function _temp(state) {
200
284
  }
201
285
  function useCommandPaletteActions() {
202
286
  const $ = c(2);
203
- if ($[0] !== "85ba0b6dafc30e5e42d7a8100e19fddf7f674f2db2d4daf495b1cb749edf3f68") {
287
+ if ($[0] !== "911725dec1e42161265ff27436f9ae9c6c82392d2b8fce53f3eb80dfb29cb6f0") {
204
288
  for (let $i = 0; $i < 2; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
205
- $[0] = "85ba0b6dafc30e5e42d7a8100e19fddf7f674f2db2d4daf495b1cb749edf3f68";
289
+ $[0] = "911725dec1e42161265ff27436f9ae9c6c82392d2b8fce53f3eb80dfb29cb6f0";
206
290
  }
207
291
  let t0;
208
292
  if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
@@ -10,9 +10,9 @@ import { useSelector } from "@xstate/store-react";
10
10
  */
11
11
  function useAdminShortcuts() {
12
12
  const $ = c(4);
13
- if ($[0] !== "e5d3a4bbb325cbcce579826abdfc85cc9e0df725cd31dd3b6fd2c699d88a926c") {
13
+ if ($[0] !== "bebc7f337697130a10955205113d613ef306f5f46f2a4a506e5e0a4faba82906") {
14
14
  for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
15
- $[0] = "e5d3a4bbb325cbcce579826abdfc85cc9e0df725cd31dd3b6fd2c699d88a926c";
15
+ $[0] = "bebc7f337697130a10955205113d613ef306f5f46f2a4a506e5e0a4faba82906";
16
16
  }
17
17
  const actions = useSelector(actionsStore, _temp);
18
18
  let t0;
@@ -29,23 +29,35 @@ function useAdminShortcuts() {
29
29
  if (!matchingAction) return;
30
30
  const shortcut = matchingAction.shortcut;
31
31
  if (checkIfInputFocused()) {
32
- if (!shortcut.withMeta && !shortcut.withAlt) return;
32
+ if (shortcut.key !== "Escape" && !shortcut.withMeta && !shortcut.withAlt) return;
33
33
  if (shortcut.key === "Backspace") return;
34
34
  }
35
35
  event.preventDefault();
36
+ event.stopPropagation();
37
+ if (shortcut.key === "Escape" && checkIfInputFocused()) document.activeElement.blur();
36
38
  matchingAction.execute();
37
39
  };
38
- const handleMessage = (event_0) => {
39
- if (event_0.data?.type === "executeAction") {
40
- const { actionId } = event_0.data;
40
+ const handleCapturedKeyDown = (event_0) => {
41
+ if (event_0.key === "Escape") return;
42
+ handleKeyDown(event_0);
43
+ };
44
+ const handleEscape = (event_1) => {
45
+ if (event_1.key !== "Escape" || event_1.defaultPrevented) return;
46
+ handleKeyDown(event_1);
47
+ };
48
+ const handleMessage = (event_2) => {
49
+ if (event_2.data?.type === "executeAction") {
50
+ const { actionId } = event_2.data;
41
51
  const action_0 = actions.find((a) => a.id === actionId);
42
52
  if (action_0) action_0.execute();
43
53
  }
44
54
  };
45
- document.addEventListener("keydown", handleKeyDown);
55
+ document.addEventListener("keydown", handleCapturedKeyDown, true);
56
+ window.addEventListener("keydown", handleEscape);
46
57
  window.addEventListener("message", handleMessage);
47
58
  return () => {
48
- document.removeEventListener("keydown", handleKeyDown);
59
+ document.removeEventListener("keydown", handleCapturedKeyDown, true);
60
+ window.removeEventListener("keydown", handleEscape);
49
61
  window.removeEventListener("message", handleMessage);
50
62
  };
51
63
  };
@@ -1,4 +1,3 @@
1
- import { trackEvent } from "../../lib/telemetry.js";
2
1
  import { queryKeys } from "@camox/api-contract/query-keys";
3
2
  import { createORPCClient } from "@orpc/client";
4
3
  import { RPCLink } from "@orpc/client/fetch";
@@ -176,11 +175,6 @@ async function createMarkdownResponse({ apiUrl, environmentName, pathname, proje
176
175
  });
177
176
  const { markdown } = await api.blocks.getPageMarkdown({ pageId: page.page.id });
178
177
  if (!markdown) return null;
179
- trackEvent("markdown_served", {
180
- pathname: requestPathname,
181
- projectId: page.page.projectId,
182
- projectName: page.projectName
183
- });
184
178
  return new Response(markdown, { headers: { "Content-Type": "text/markdown; charset=utf-8" } });
185
179
  } catch {
186
180
  return null;
@@ -1,9 +1,10 @@
1
+ import { getApiClient } from "../../lib/api-client.js";
1
2
  import { SharedChromeContext } from "./SharedChromeContext.js";
2
- import { previewStore } from "../preview/previewStore.js";
3
+ import { previewStore, selectPreviewSource } from "../preview/previewStore.js";
3
4
  import { Navbar } from "../studio/components/Navbar.js";
4
5
  import { PreviewToolbar } from "../preview/components/PreviewToolbar.js";
5
6
  import { c } from "react/compiler-runtime";
6
- import { skipToken, useQuery } from "@tanstack/react-query";
7
+ import { useQuery } from "@tanstack/react-query";
7
8
  import { jsx, jsxs } from "react/jsx-runtime";
8
9
  import { useSelector } from "@xstate/store-react";
9
10
  import { queryKeys } from "@camox/api-contract/query-keys";
@@ -11,15 +12,15 @@ import studioCssUrl from "virtual:camox-studio-css";
11
12
 
12
13
  //#region src/features/runtime/RuntimeChrome.tsx
13
14
  function RuntimeChrome(t0) {
14
- const $ = c(28);
15
- if ($[0] !== "aeb65c1f74ba1b6829f439e1b5b486e7595e47ca43050621ed9eca5dd60f7680") {
16
- for (let $i = 0; $i < 28; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
17
- $[0] = "aeb65c1f74ba1b6829f439e1b5b486e7595e47ca43050621ed9eca5dd60f7680";
15
+ const $ = c(34);
16
+ if ($[0] !== "4f2448cdd08f7a2c7703fe11bfa7e45ebc2f0485d14029a9a68ae33e62958b54") {
17
+ for (let $i = 0; $i < 34; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
18
+ $[0] = "4f2448cdd08f7a2c7703fe11bfa7e45ebc2f0485d14029a9a68ae33e62958b54";
18
19
  }
19
20
  const { input, children } = t0;
20
21
  const preview = !input.routeKind;
21
22
  const hidden = useSelector(previewStore, _temp);
22
- const source = useSelector(previewStore, _temp2);
23
+ const source = useSelector(previewStore, selectPreviewSource);
23
24
  let t1;
24
25
  if ($[1] !== input.pathname || $[2] !== source) {
25
26
  t1 = queryKeys.pages.getByPath(input.pathname, source);
@@ -28,106 +29,120 @@ function RuntimeChrome(t0) {
28
29
  $[3] = t1;
29
30
  } else t1 = $[3];
30
31
  let t2;
31
- if ($[4] !== t1) {
32
- t2 = {
32
+ if ($[4] !== input.pathname || $[5] !== input.projectSlug || $[6] !== source) {
33
+ t2 = () => getApiClient().pages.getStructure({
34
+ path: input.pathname,
35
+ projectSlug: input.projectSlug,
36
+ source
37
+ });
38
+ $[4] = input.pathname;
39
+ $[5] = input.projectSlug;
40
+ $[6] = source;
41
+ $[7] = t2;
42
+ } else t2 = $[7];
43
+ let t3;
44
+ if ($[8] !== t1 || $[9] !== t2) {
45
+ t3 = {
33
46
  queryKey: t1,
34
- queryFn: skipToken
47
+ queryFn: t2,
48
+ enabled: false
35
49
  };
36
- $[4] = t1;
37
- $[5] = t2;
38
- } else t2 = $[5];
39
- const { data: page } = useQuery(t2);
40
- let t3;
41
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
42
- t3 = /* @__PURE__ */ jsx("link", {
50
+ $[8] = t1;
51
+ $[9] = t2;
52
+ $[10] = t3;
53
+ } else t3 = $[10];
54
+ const { data: page } = useQuery(t3);
55
+ let t4;
56
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
57
+ t4 = /* @__PURE__ */ jsx("link", {
43
58
  rel: "stylesheet",
44
59
  href: studioCssUrl,
45
60
  "data-camox-studio": true
46
61
  });
47
- $[6] = t3;
48
- } else t3 = $[6];
49
- const t4 = preview ? "max-md:hidden" : void 0;
50
- const t5 = preview && hidden;
51
- let t6;
52
- if ($[7] !== preview) {
53
- t6 = /* @__PURE__ */ jsx(Navbar, { isPreview: preview });
54
- $[7] = preview;
55
- $[8] = t6;
56
- } else t6 = $[8];
62
+ $[11] = t4;
63
+ } else t4 = $[11];
64
+ const t5 = preview ? "max-md:hidden" : void 0;
65
+ const t6 = preview && hidden;
57
66
  let t7;
58
- if ($[9] !== t4 || $[10] !== t5 || $[11] !== t6) {
59
- t7 = /* @__PURE__ */ jsx("div", {
60
- className: t4,
61
- hidden: t5,
62
- children: t6
63
- });
64
- $[9] = t4;
65
- $[10] = t5;
66
- $[11] = t6;
67
- $[12] = t7;
68
- } else t7 = $[12];
67
+ if ($[12] !== preview) {
68
+ t7 = /* @__PURE__ */ jsx(Navbar, { isPreview: preview });
69
+ $[12] = preview;
70
+ $[13] = t7;
71
+ } else t7 = $[13];
69
72
  let t8;
70
- if ($[13] !== children) {
73
+ if ($[14] !== t5 || $[15] !== t6 || $[16] !== t7) {
71
74
  t8 = /* @__PURE__ */ jsx("div", {
75
+ className: t5,
76
+ hidden: t6,
77
+ children: t7
78
+ });
79
+ $[14] = t5;
80
+ $[15] = t6;
81
+ $[16] = t7;
82
+ $[17] = t8;
83
+ } else t8 = $[17];
84
+ let t9;
85
+ if ($[18] !== children) {
86
+ t9 = /* @__PURE__ */ jsx("div", {
72
87
  className: "flex min-h-0 flex-1 flex-col overflow-auto",
73
88
  children
74
89
  });
75
- $[13] = children;
76
- $[14] = t8;
77
- } else t8 = $[14];
78
- const t9 = !preview;
79
- const t10 = input.derived ? void 0 : "max-md:hidden";
80
- const t11 = preview && !input.derived ? page?.page.status : void 0;
81
- const t12 = !!page?.page.livePublishedCheckpointId;
82
- let t13;
83
- if ($[15] !== t11 || $[16] !== t12) {
84
- t13 = /* @__PURE__ */ jsx(PreviewToolbar, {
85
- pageStatus: t11,
86
- hasLiveVersion: t12
87
- });
88
- $[15] = t11;
89
- $[16] = t12;
90
- $[17] = t13;
91
- } else t13 = $[17];
92
- let t14;
93
- if ($[18] !== t10 || $[19] !== t13 || $[20] !== t9) {
94
- t14 = /* @__PURE__ */ jsx("div", {
95
- hidden: t9,
96
- className: t10,
97
- children: t13
98
- });
99
- $[18] = t10;
100
- $[19] = t13;
101
- $[20] = t9;
102
- $[21] = t14;
103
- } else t14 = $[21];
90
+ $[18] = children;
91
+ $[19] = t9;
92
+ } else t9 = $[19];
93
+ const t10 = !preview;
94
+ const t11 = input.derived ? void 0 : "max-md:hidden";
95
+ const t12 = page?.page.id;
96
+ const t13 = preview && !input.derived ? page?.page.status : void 0;
97
+ const t14 = !!page?.page.livePublishedCheckpointId;
104
98
  let t15;
105
- if ($[22] !== t14 || $[23] !== t8) {
106
- t15 = /* @__PURE__ */ jsxs("div", {
107
- className: "relative flex min-h-0 flex-1 flex-col",
108
- children: [t8, t14]
99
+ if ($[20] !== t12 || $[21] !== t13 || $[22] !== t14) {
100
+ t15 = /* @__PURE__ */ jsx(PreviewToolbar, {
101
+ pageId: t12,
102
+ pageStatus: t13,
103
+ hasLiveVersion: t14
109
104
  });
105
+ $[20] = t12;
106
+ $[21] = t13;
110
107
  $[22] = t14;
111
- $[23] = t8;
112
- $[24] = t15;
113
- } else t15 = $[24];
108
+ $[23] = t15;
109
+ } else t15 = $[23];
114
110
  let t16;
115
- if ($[25] !== t15 || $[26] !== t7) {
116
- t16 = /* @__PURE__ */ jsxs(SharedChromeContext.Provider, {
111
+ if ($[24] !== t10 || $[25] !== t11 || $[26] !== t15) {
112
+ t16 = /* @__PURE__ */ jsx("div", {
113
+ hidden: t10,
114
+ className: t11,
115
+ children: t15
116
+ });
117
+ $[24] = t10;
118
+ $[25] = t11;
119
+ $[26] = t15;
120
+ $[27] = t16;
121
+ } else t16 = $[27];
122
+ let t17;
123
+ if ($[28] !== t16 || $[29] !== t9) {
124
+ t17 = /* @__PURE__ */ jsxs("div", {
125
+ className: "relative flex min-h-0 flex-1 flex-col",
126
+ children: [t9, t16]
127
+ });
128
+ $[28] = t16;
129
+ $[29] = t9;
130
+ $[30] = t17;
131
+ } else t17 = $[30];
132
+ let t18;
133
+ if ($[31] !== t17 || $[32] !== t8) {
134
+ t18 = /* @__PURE__ */ jsxs(SharedChromeContext.Provider, {
117
135
  value: true,
118
- children: [t3, /* @__PURE__ */ jsxs("div", {
136
+ children: [t4, /* @__PURE__ */ jsxs("div", {
119
137
  className: "bg-background flex h-screen flex-col overflow-hidden",
120
- children: [t7, t15]
138
+ children: [t8, t17]
121
139
  })]
122
140
  });
123
- $[25] = t15;
124
- $[26] = t7;
125
- $[27] = t16;
126
- } else t16 = $[27];
127
- return t16;
128
- }
129
- function _temp2(state_0) {
130
- return state_0.context.previewSource;
141
+ $[31] = t17;
142
+ $[32] = t8;
143
+ $[33] = t18;
144
+ } else t18 = $[33];
145
+ return t18;
131
146
  }
132
147
  function _temp(state) {
133
148
  return state.context.isToolbarHidden;