camox 0.3.0 → 0.3.1

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 (69) hide show
  1. package/dist/components/AuthGate.js +2 -1
  2. package/dist/core/components/AddBlockControlBar.js +117 -44
  3. package/dist/core/components/lexical/InlineContentEditable.js +37 -17
  4. package/dist/core/components/lexical/InlineLexicalEditor.js +84 -25
  5. package/dist/core/components/lexical/SelectionBroadcaster.js +84 -47
  6. package/dist/core/components/lexical/SidebarLexicalEditor.js +54 -19
  7. package/dist/core/createBlock.js +1172 -414
  8. package/dist/core/createLayout.js +48 -16
  9. package/dist/core/hooks/useFieldSelection.js +24 -13
  10. package/dist/core/hooks/useIsEditable.js +8 -2
  11. package/dist/core/hooks/useOverlayMessage.js +51 -20
  12. package/dist/features/content/CamoxContent.js +239 -107
  13. package/dist/features/content/components/AssetCard.js +78 -16
  14. package/dist/features/content/components/AssetCardSkeleton.js +11 -4
  15. package/dist/features/content/components/ContentSidebar.js +15 -8
  16. package/dist/features/content/components/UploadDropZone.js +77 -34
  17. package/dist/features/content/components/UploadProgressDrawer.js +201 -58
  18. package/dist/features/metadata/sitemap.js +15 -0
  19. package/dist/features/preview/CamoxPreview.js +447 -179
  20. package/dist/features/preview/components/AddBlockSheet.js +344 -167
  21. package/dist/features/preview/components/AgentChatSheet.js +32 -10
  22. package/dist/features/preview/components/AssetFieldEditor.js +185 -50
  23. package/dist/features/preview/components/AssetLightbox.js +60 -33
  24. package/dist/features/preview/components/AssetPickerGrid.js +203 -71
  25. package/dist/features/preview/components/BlockActionsPopover.js +295 -218
  26. package/dist/features/preview/components/CreatePageSheet.js +3 -3
  27. package/dist/features/preview/components/DebouncedFieldEditor.js +80 -23
  28. package/dist/features/preview/components/EditPageSheet.js +241 -86
  29. package/dist/features/preview/components/ItemFieldsEditor.js +209 -115
  30. package/dist/features/preview/components/LinkFieldEditor.js +351 -153
  31. package/dist/features/preview/components/MultipleAssetFieldEditor.js +245 -92
  32. package/dist/features/preview/components/OverlayTracker.js +58 -23
  33. package/dist/features/preview/components/Overlays.js +85 -43
  34. package/dist/features/preview/components/PageContentSheet.js +18 -18
  35. package/dist/features/preview/components/PageLocationFieldset.js +229 -63
  36. package/dist/features/preview/components/PagePicker.js +27 -27
  37. package/dist/features/preview/components/PageTree.js +921 -319
  38. package/dist/features/preview/components/PeekedBlock.js +173 -63
  39. package/dist/features/preview/components/PreviewPanel.js +271 -148
  40. package/dist/features/preview/components/PreviewSideSheet.js +44 -11
  41. package/dist/features/preview/components/PreviewToolbar.js +262 -59
  42. package/dist/features/preview/components/RepeatableItemsList.js +187 -78
  43. package/dist/features/preview/components/ShikiMarkdown.js +46 -20
  44. package/dist/features/preview/components/TextFormatToolbar.js +81 -23
  45. package/dist/features/preview/components/UnlinkAssetButton.js +161 -40
  46. package/dist/features/preview/components/useUpdateBlockPosition.js +64 -47
  47. package/dist/features/preview/previewStore.d.ts +2 -2
  48. package/dist/features/provider/CamoxProvider.js +69 -21
  49. package/dist/features/provider/actionsStore.d.ts +2 -2
  50. package/dist/features/provider/components/CamoxAppContext.js +15 -5
  51. package/dist/features/provider/components/CommandPalette.js +199 -92
  52. package/dist/features/provider/useAdminShortcuts.js +80 -64
  53. package/dist/features/routes/pageRoute.js +8 -1
  54. package/dist/features/studio/CamoxStudio.js +45 -9
  55. package/dist/features/studio/components/EnvironmentMenu.js +47 -12
  56. package/dist/features/studio/components/Navbar.js +163 -65
  57. package/dist/features/studio/components/ProjectMenu.js +263 -82
  58. package/dist/features/studio/components/UserButton.js +21 -6
  59. package/dist/features/studio/studioStore.d.ts +2 -2
  60. package/dist/features/studio/useTheme.js +128 -74
  61. package/dist/hooks/use-file-upload.js +11 -11
  62. package/dist/hooks/use-marquee-selection.js +121 -74
  63. package/dist/lib/auth.js +95 -51
  64. package/dist/lib/normalized-data.js +103 -30
  65. package/dist/lib/use-project-room.js +55 -22
  66. package/dist/studio.css +2 -2
  67. package/package.json +29 -26
  68. package/dist/lib/auth.d.ts +0 -2130
  69. package/dist/lib/auth.d.ts.map +0 -1
@@ -16,6 +16,7 @@ import { PagePicker } from "./components/PagePicker.js";
16
16
  import { PageTree } from "./components/PageTree.js";
17
17
  import { PeekedBlock } from "./components/PeekedBlock.js";
18
18
  import { PreviewFrame, PreviewPanel } from "./components/PreviewPanel.js";
19
+ import { c } from "react/compiler-runtime";
19
20
  import { keepPreviousData, useQuery, useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
20
21
  import { useSelector } from "@xstate/store/react";
21
22
  import * as React from "react";
@@ -64,52 +65,164 @@ function pageFullQueryFn(queryClient, path, projectSlug) {
64
65
  };
65
66
  }
66
67
  function usePreviewedPage() {
68
+ const $ = c(21);
67
69
  const { pathname } = useLocation();
68
70
  const queryClient = useQueryClient();
69
71
  const projectSlug = useProjectSlug();
70
- const peekedPagePathname = useSelector(previewStore, (state) => state.context.peekedPagePathname);
72
+ const peekedPagePathname = useSelector(previewStore, _temp);
71
73
  const prevPathnameRef = React.useRef(pathname);
72
- React.useEffect(() => {
73
- if (prevPathnameRef.current !== pathname) {
74
- prevPathnameRef.current = pathname;
75
- previewStore.send({ type: "clearPeekedPage" });
76
- }
77
- }, [pathname]);
78
- const { data: currentPage } = useSuspenseQuery({
79
- queryKey: queryKeys.pages.getByPath(pathname),
80
- queryFn: pageStructureQueryFn(pathname, projectSlug),
81
- staleTime: Infinity
82
- });
74
+ let t0;
75
+ let t1;
76
+ if ($[0] !== pathname) {
77
+ t0 = () => {
78
+ if (prevPathnameRef.current !== pathname) {
79
+ prevPathnameRef.current = pathname;
80
+ previewStore.send({ type: "clearPeekedPage" });
81
+ }
82
+ };
83
+ t1 = [pathname];
84
+ $[0] = pathname;
85
+ $[1] = t0;
86
+ $[2] = t1;
87
+ } else {
88
+ t0 = $[1];
89
+ t1 = $[2];
90
+ }
91
+ React.useEffect(t0, t1);
92
+ let t2;
93
+ if ($[3] !== pathname) {
94
+ t2 = queryKeys.pages.getByPath(pathname);
95
+ $[3] = pathname;
96
+ $[4] = t2;
97
+ } else t2 = $[4];
98
+ let t3;
99
+ if ($[5] !== pathname || $[6] !== projectSlug) {
100
+ t3 = pageStructureQueryFn(pathname, projectSlug);
101
+ $[5] = pathname;
102
+ $[6] = projectSlug;
103
+ $[7] = t3;
104
+ } else t3 = $[7];
105
+ let t4;
106
+ if ($[8] !== t2 || $[9] !== t3) {
107
+ t4 = {
108
+ queryKey: t2,
109
+ queryFn: t3,
110
+ staleTime: Infinity
111
+ };
112
+ $[8] = t2;
113
+ $[9] = t3;
114
+ $[10] = t4;
115
+ } else t4 = $[10];
116
+ const { data: currentPage } = useSuspenseQuery(t4);
83
117
  const isAuthenticated = useIsAuthenticated();
84
- const { data: peekedPage } = useQuery({
85
- queryKey: queryKeys.pages.getByPath(peekedPagePathname ?? ""),
86
- queryFn: pageFullQueryFn(queryClient, peekedPagePathname ?? "", projectSlug),
87
- enabled: isAuthenticated && !!peekedPagePathname,
88
- placeholderData: keepPreviousData,
89
- staleTime: Infinity
90
- });
118
+ let t5;
119
+ if ($[11] !== peekedPagePathname) {
120
+ t5 = queryKeys.pages.getByPath(peekedPagePathname ?? "");
121
+ $[11] = peekedPagePathname;
122
+ $[12] = t5;
123
+ } else t5 = $[12];
124
+ const t6 = peekedPagePathname ?? "";
125
+ let t7;
126
+ if ($[13] !== projectSlug || $[14] !== queryClient || $[15] !== t6) {
127
+ t7 = pageFullQueryFn(queryClient, t6, projectSlug);
128
+ $[13] = projectSlug;
129
+ $[14] = queryClient;
130
+ $[15] = t6;
131
+ $[16] = t7;
132
+ } else t7 = $[16];
133
+ const t8 = isAuthenticated && !!peekedPagePathname;
134
+ let t9;
135
+ if ($[17] !== t5 || $[18] !== t7 || $[19] !== t8) {
136
+ t9 = {
137
+ queryKey: t5,
138
+ queryFn: t7,
139
+ enabled: t8,
140
+ placeholderData: keepPreviousData,
141
+ staleTime: Infinity
142
+ };
143
+ $[17] = t5;
144
+ $[18] = t7;
145
+ $[19] = t8;
146
+ $[20] = t9;
147
+ } else t9 = $[20];
148
+ const { data: peekedPage } = useQuery(t9);
91
149
  return peekedPage ?? currentPage;
92
150
  }
93
- var BlockRenderer = ({ blockId, mode, showAddBlockTop, showAddBlockBottom }) => {
94
- const { data } = useSuspenseQuery(blockQueries.get(blockId));
95
- const blockDef = useCamoxApp().getBlockById(data.block.type);
151
+ function _temp(state) {
152
+ return state.context.peekedPagePathname;
153
+ }
154
+ var BlockRenderer = (t0) => {
155
+ const $ = c(21);
156
+ const { blockId, mode, showAddBlockTop, showAddBlockBottom } = t0;
157
+ let t1;
158
+ if ($[0] !== blockId) {
159
+ t1 = blockQueries.get(blockId);
160
+ $[0] = blockId;
161
+ $[1] = t1;
162
+ } else t1 = $[1];
163
+ const { data } = useSuspenseQuery(t1);
164
+ const camoxApp = useCamoxApp();
165
+ let t2;
166
+ if ($[2] !== camoxApp || $[3] !== data.block.type) {
167
+ t2 = camoxApp.getBlockById(data.block.type);
168
+ $[2] = camoxApp;
169
+ $[3] = data.block.type;
170
+ $[4] = t2;
171
+ } else t2 = $[4];
172
+ const blockDef = t2;
96
173
  if (!blockDef) return null;
97
- return /* @__PURE__ */ jsx(NormalizedDataProvider, {
98
- files: data.files,
99
- repeatableItems: data.repeatableItems,
100
- children: /* @__PURE__ */ jsx(blockDef.Component, {
101
- blockData: {
102
- _id: String(data.block.id),
103
- type: data.block.type,
104
- content: data.block.content,
105
- settings: data.block.settings,
106
- position: String(data.block.position)
107
- },
174
+ const t3 = data.files;
175
+ const t4 = data.repeatableItems;
176
+ const T0 = blockDef.Component;
177
+ const t5 = String(data.block.id);
178
+ const t6 = data.block.type;
179
+ const t7 = data.block.content;
180
+ const t8 = data.block.settings;
181
+ const t9 = String(data.block.position);
182
+ let t10;
183
+ if ($[5] !== data.block.type || $[6] !== t5 || $[7] !== t7 || $[8] !== t8 || $[9] !== t9) {
184
+ t10 = {
185
+ _id: t5,
186
+ type: t6,
187
+ content: t7,
188
+ settings: t8,
189
+ position: t9
190
+ };
191
+ $[5] = data.block.type;
192
+ $[6] = t5;
193
+ $[7] = t7;
194
+ $[8] = t8;
195
+ $[9] = t9;
196
+ $[10] = t10;
197
+ } else t10 = $[10];
198
+ let t11;
199
+ if ($[11] !== blockDef.Component || $[12] !== mode || $[13] !== showAddBlockBottom || $[14] !== showAddBlockTop || $[15] !== t10) {
200
+ t11 = /* @__PURE__ */ jsx(T0, {
201
+ blockData: t10,
108
202
  mode,
109
203
  showAddBlockTop,
110
204
  showAddBlockBottom
111
- })
112
- });
205
+ });
206
+ $[11] = blockDef.Component;
207
+ $[12] = mode;
208
+ $[13] = showAddBlockBottom;
209
+ $[14] = showAddBlockTop;
210
+ $[15] = t10;
211
+ $[16] = t11;
212
+ } else t11 = $[16];
213
+ let t12;
214
+ if ($[17] !== data.files || $[18] !== data.repeatableItems || $[19] !== t11) {
215
+ t12 = /* @__PURE__ */ jsx(NormalizedDataProvider, {
216
+ files: t3,
217
+ repeatableItems: t4,
218
+ children: t11
219
+ });
220
+ $[17] = data.files;
221
+ $[18] = data.repeatableItems;
222
+ $[19] = t11;
223
+ $[20] = t12;
224
+ } else t12 = $[20];
225
+ return t12;
113
226
  };
114
227
  var PageContent = () => {
115
228
  const pageData = usePreviewedPage();
@@ -134,12 +247,12 @@ var PageContent = () => {
134
247
  if (!pageData.layout) return null;
135
248
  const allLayoutBlocks = [...beforeBlocks, ...afterBlocks];
136
249
  const blocks = {};
137
- for (const block of allLayoutBlocks) blocks[block.type] = {
138
- _id: String(block.id),
139
- type: block.type,
140
- content: block.content,
141
- settings: block.settings,
142
- position: String(block.position)
250
+ for (const block_0 of allLayoutBlocks) blocks[block_0.type] = {
251
+ _id: String(block_0.id),
252
+ type: block_0.type,
253
+ content: block_0.content,
254
+ settings: block_0.settings,
255
+ position: String(block_0.position)
143
256
  };
144
257
  return blocks;
145
258
  }, [
@@ -173,157 +286,312 @@ var PageContent = () => {
173
286
  children: pageBlocksContent
174
287
  });
175
288
  };
176
- var CamoxPreview = ({ children }) => {
289
+ var CamoxPreview = (t0) => {
290
+ const $ = c(28);
291
+ const { children } = t0;
177
292
  const isAuthenticated = useIsAuthenticated();
178
- const isPresentationMode = useSelector(previewStore, (state) => state.context.isPresentationMode);
179
- const isSidebarOpen = useSelector(previewStore, (state) => state.context.isSidebarOpen);
293
+ const isPresentationMode = useSelector(previewStore, _temp2);
294
+ const isSidebarOpen = useSelector(previewStore, _temp3);
180
295
  const pageData = usePreviewedPage();
181
- React.useEffect(() => {
182
- const actions = [{
183
- id: "enter-presentation-mode",
184
- label: "Enter presentation mode",
185
- groupLabel: "Preview",
186
- checkIfAvailable: () => isAuthenticated && !isPresentationMode,
187
- execute: () => previewStore.send({ type: "enterPresentationMode" }),
188
- shortcut: {
189
- key: "Enter",
190
- withMeta: true
191
- }
192
- }, {
193
- id: "exit-presentation-mode",
194
- label: "Exit presentation mode",
195
- groupLabel: "Preview",
196
- checkIfAvailable: () => isAuthenticated && isPresentationMode,
197
- execute: () => previewStore.send({ type: "exitPresentationMode" }),
198
- shortcut: {
199
- key: "Escape",
200
- withMeta: true
201
- }
202
- }];
203
- actionsStore.send({
204
- type: "registerManyActions",
205
- actions
206
- });
207
- return () => {
296
+ let t1;
297
+ let t2;
298
+ if ($[0] !== isAuthenticated || $[1] !== isPresentationMode) {
299
+ t1 = () => {
300
+ const actions = [{
301
+ id: "enter-presentation-mode",
302
+ label: "Enter presentation mode",
303
+ groupLabel: "Preview",
304
+ checkIfAvailable: () => isAuthenticated && !isPresentationMode,
305
+ execute: _temp4,
306
+ shortcut: {
307
+ key: "Enter",
308
+ withMeta: true
309
+ }
310
+ }, {
311
+ id: "exit-presentation-mode",
312
+ label: "Exit presentation mode",
313
+ groupLabel: "Preview",
314
+ checkIfAvailable: () => isAuthenticated && isPresentationMode,
315
+ execute: _temp5,
316
+ shortcut: {
317
+ key: "Escape",
318
+ withMeta: true
319
+ }
320
+ }];
208
321
  actionsStore.send({
209
- type: "unregisterManyActions",
210
- ids: actions.map((a) => a.id)
322
+ type: "registerManyActions",
323
+ actions
211
324
  });
325
+ return () => {
326
+ actionsStore.send({
327
+ type: "unregisterManyActions",
328
+ ids: actions.map(_temp6)
329
+ });
330
+ };
212
331
  };
213
- }, [isPresentationMode, isAuthenticated]);
214
- if (isPresentationMode) return /* @__PURE__ */ jsx(PreviewFrame, {
215
- className: "h-screen w-full",
216
- children
217
- });
218
- if (!isAuthenticated) return /* @__PURE__ */ jsx(Fragment, { children });
219
- return /* @__PURE__ */ jsxs("div", {
220
- className: "bg-background flex h-screen flex-col overflow-hidden",
221
- children: [
222
- /* @__PURE__ */ jsx(Navbar, {}),
223
- /* @__PURE__ */ jsxs("div", {
224
- className: "flex h-full flex-row items-stretch",
225
- children: [isSidebarOpen && /* @__PURE__ */ jsxs("div", {
226
- className: "flex w-[300px] flex-col border-r-2",
227
- children: [/* @__PURE__ */ jsxs(PanelHeader, {
228
- className: "flew-row flex gap-2 px-2 py-2",
229
- children: [/* @__PURE__ */ jsx(PagePicker, {}), /* @__PURE__ */ jsxs(Tooltip, {
230
- delayDuration: 500,
231
- children: [/* @__PURE__ */ jsx(TooltipTrigger, {
232
- asChild: true,
233
- children: /* @__PURE__ */ jsx(Button, {
234
- type: "button",
235
- variant: "outline",
236
- size: "icon",
237
- onClick: () => previewStore.send({
238
- type: "openEditPageSheet",
239
- pageId: pageData.page.id
240
- }),
241
- children: /* @__PURE__ */ jsx(Info, { className: "text-muted-foreground size-4" })
242
- })
243
- }), /* @__PURE__ */ jsx(TooltipContent, { children: "Page metadata, SEO and markdown" })]
244
- })]
245
- }), /* @__PURE__ */ jsx(PanelContent, {
246
- className: "flex grow basis-0 flex-col gap-2 overflow-auto p-2",
247
- children: /* @__PURE__ */ jsx(PageTree, {})
248
- })]
249
- }), /* @__PURE__ */ jsxs(PreviewPanel, { children: [children, !isPresentationMode && isAuthenticated && /* @__PURE__ */ jsx("div", { style: {
250
- height: "80px",
251
- background: "transparent"
252
- } })] })]
253
- }),
254
- /* @__PURE__ */ jsx(PageContentSheet, {}),
255
- /* @__PURE__ */ jsx(AddBlockSheet, {}),
256
- /* @__PURE__ */ jsx(AgentChatSheet, {}),
257
- /* @__PURE__ */ jsx(CreatePageSheet, {}),
258
- /* @__PURE__ */ jsx(EditPageSheet, {})
259
- ]
260
- });
332
+ t2 = [isPresentationMode, isAuthenticated];
333
+ $[0] = isAuthenticated;
334
+ $[1] = isPresentationMode;
335
+ $[2] = t1;
336
+ $[3] = t2;
337
+ } else {
338
+ t1 = $[2];
339
+ t2 = $[3];
340
+ }
341
+ React.useEffect(t1, t2);
342
+ if (isPresentationMode) {
343
+ let t3;
344
+ if ($[4] !== children) {
345
+ t3 = /* @__PURE__ */ jsx(PreviewFrame, {
346
+ className: "h-screen w-full",
347
+ children
348
+ });
349
+ $[4] = children;
350
+ $[5] = t3;
351
+ } else t3 = $[5];
352
+ return t3;
353
+ }
354
+ if (!isAuthenticated) {
355
+ let t3;
356
+ if ($[6] !== children) {
357
+ t3 = /* @__PURE__ */ jsx(Fragment, { children });
358
+ $[6] = children;
359
+ $[7] = t3;
360
+ } else t3 = $[7];
361
+ return t3;
362
+ }
363
+ let t3;
364
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
365
+ t3 = /* @__PURE__ */ jsx(Navbar, {});
366
+ $[8] = t3;
367
+ } else t3 = $[8];
368
+ let t4;
369
+ if ($[9] !== isSidebarOpen || $[10] !== pageData) {
370
+ t4 = isSidebarOpen && /* @__PURE__ */ jsxs("div", {
371
+ className: "flex w-[300px] flex-col border-r-2",
372
+ children: [/* @__PURE__ */ jsxs(PanelHeader, {
373
+ className: "flew-row flex gap-2 px-2 py-2",
374
+ children: [/* @__PURE__ */ jsx(PagePicker, {}), /* @__PURE__ */ jsxs(Tooltip, {
375
+ delayDuration: 500,
376
+ children: [/* @__PURE__ */ jsx(TooltipTrigger, {
377
+ asChild: true,
378
+ children: /* @__PURE__ */ jsx(Button, {
379
+ type: "button",
380
+ variant: "outline",
381
+ size: "icon",
382
+ onClick: () => previewStore.send({
383
+ type: "openEditPageSheet",
384
+ pageId: pageData.page.id
385
+ }),
386
+ children: /* @__PURE__ */ jsx(Info, { className: "text-muted-foreground size-4" })
387
+ })
388
+ }), /* @__PURE__ */ jsx(TooltipContent, { children: "Page metadata, SEO and markdown" })]
389
+ })]
390
+ }), /* @__PURE__ */ jsx(PanelContent, {
391
+ className: "flex grow basis-0 flex-col gap-2 overflow-auto p-2",
392
+ children: /* @__PURE__ */ jsx(PageTree, {})
393
+ })]
394
+ });
395
+ $[9] = isSidebarOpen;
396
+ $[10] = pageData;
397
+ $[11] = t4;
398
+ } else t4 = $[11];
399
+ let t5;
400
+ if ($[12] !== isAuthenticated || $[13] !== isPresentationMode) {
401
+ t5 = !isPresentationMode && isAuthenticated && /* @__PURE__ */ jsx("div", { style: {
402
+ height: "80px",
403
+ background: "transparent"
404
+ } });
405
+ $[12] = isAuthenticated;
406
+ $[13] = isPresentationMode;
407
+ $[14] = t5;
408
+ } else t5 = $[14];
409
+ let t6;
410
+ if ($[15] !== children || $[16] !== t5) {
411
+ t6 = /* @__PURE__ */ jsxs(PreviewPanel, { children: [children, t5] });
412
+ $[15] = children;
413
+ $[16] = t5;
414
+ $[17] = t6;
415
+ } else t6 = $[17];
416
+ let t7;
417
+ if ($[18] !== t4 || $[19] !== t6) {
418
+ t7 = /* @__PURE__ */ jsxs("div", {
419
+ className: "flex h-full flex-row items-stretch",
420
+ children: [t4, t6]
421
+ });
422
+ $[18] = t4;
423
+ $[19] = t6;
424
+ $[20] = t7;
425
+ } else t7 = $[20];
426
+ let t10;
427
+ let t11;
428
+ let t12;
429
+ let t8;
430
+ let t9;
431
+ if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
432
+ t8 = /* @__PURE__ */ jsx(PageContentSheet, {});
433
+ t9 = /* @__PURE__ */ jsx(AddBlockSheet, {});
434
+ t10 = /* @__PURE__ */ jsx(AgentChatSheet, {});
435
+ t11 = /* @__PURE__ */ jsx(CreatePageSheet, {});
436
+ t12 = /* @__PURE__ */ jsx(EditPageSheet, {});
437
+ $[21] = t10;
438
+ $[22] = t11;
439
+ $[23] = t12;
440
+ $[24] = t8;
441
+ $[25] = t9;
442
+ } else {
443
+ t10 = $[21];
444
+ t11 = $[22];
445
+ t12 = $[23];
446
+ t8 = $[24];
447
+ t9 = $[25];
448
+ }
449
+ let t13;
450
+ if ($[26] !== t7) {
451
+ t13 = /* @__PURE__ */ jsxs("div", {
452
+ className: "bg-background flex h-screen flex-col overflow-hidden",
453
+ children: [
454
+ t3,
455
+ t7,
456
+ t8,
457
+ t9,
458
+ t10,
459
+ t11,
460
+ t12
461
+ ]
462
+ });
463
+ $[26] = t7;
464
+ $[27] = t13;
465
+ } else t13 = $[27];
466
+ return t13;
261
467
  };
262
468
  function usePreviewPagesActions() {
469
+ const $ = c(12);
263
470
  const navigate = useNavigate();
264
471
  const { pathname } = useLocation();
265
472
  const projectSlug = useProjectSlug();
266
- const { data: project } = useQuery(projectQueries.getBySlug(projectSlug));
267
- const { data: pages } = useQuery({
268
- ...pageQueries.list(project?.id ?? 0),
269
- enabled: !!project
270
- });
271
- React.useEffect(() => {
272
- const GO_TO_PAGE_ID = "go-to-page";
273
- const currentPage = pages?.find((p) => p.fullPath === pathname);
274
- const actions = [
275
- {
276
- id: "create-page",
277
- label: "Create page",
278
- groupLabel: "Preview",
279
- checkIfAvailable: () => true,
280
- execute: () => previewStore.send({ type: "openCreatePageSheet" })
281
- },
282
- {
283
- id: "edit-current-page",
284
- label: "Edit current page",
285
- groupLabel: "Preview",
286
- checkIfAvailable: () => !!currentPage,
287
- execute: () => {
288
- if (!currentPage) return;
289
- previewStore.send({
290
- type: "openEditPageSheet",
291
- pageId: currentPage.id
292
- });
293
- }
294
- },
295
- {
296
- id: GO_TO_PAGE_ID,
297
- label: "Go to page",
298
- groupLabel: "Preview",
299
- checkIfAvailable: () => !!pages,
300
- hasChildren: true,
301
- execute: () => {}
302
- },
303
- ...pages ? pages.map((page) => ({
304
- id: `go-to-page-${page.id}`,
305
- parentActionId: GO_TO_PAGE_ID,
306
- label: `Go to "${page.metaTitle ?? formatPathSegment(page.pathSegment)}"`,
307
- groupLabel: "Preview",
308
- checkIfAvailable: () => true,
309
- execute: () => navigate({ to: page.fullPath })
310
- })) : []
311
- ];
312
- actionsStore.send({
313
- type: "registerManyActions",
314
- actions
315
- });
316
- return () => {
473
+ let t0;
474
+ if ($[0] !== projectSlug) {
475
+ t0 = projectQueries.getBySlug(projectSlug);
476
+ $[0] = projectSlug;
477
+ $[1] = t0;
478
+ } else t0 = $[1];
479
+ const { data: project } = useQuery(t0);
480
+ let t1;
481
+ if ($[2] !== project?.id) {
482
+ t1 = pageQueries.list(project?.id ?? 0);
483
+ $[2] = project?.id;
484
+ $[3] = t1;
485
+ } else t1 = $[3];
486
+ const t2 = !!project;
487
+ let t3;
488
+ if ($[4] !== t1 || $[5] !== t2) {
489
+ t3 = {
490
+ ...t1,
491
+ enabled: t2
492
+ };
493
+ $[4] = t1;
494
+ $[5] = t2;
495
+ $[6] = t3;
496
+ } else t3 = $[6];
497
+ const { data: pages } = useQuery(t3);
498
+ let t4;
499
+ let t5;
500
+ if ($[7] !== navigate || $[8] !== pages || $[9] !== pathname) {
501
+ t4 = () => {
502
+ const currentPage = pages?.find((p) => p.fullPath === pathname);
503
+ const actions = [
504
+ {
505
+ id: "create-page",
506
+ label: "Create page",
507
+ groupLabel: "Preview",
508
+ checkIfAvailable: _temp7,
509
+ execute: _temp8
510
+ },
511
+ {
512
+ id: "edit-current-page",
513
+ label: "Edit current page",
514
+ groupLabel: "Preview",
515
+ checkIfAvailable: () => !!currentPage,
516
+ execute: () => {
517
+ if (!currentPage) return;
518
+ previewStore.send({
519
+ type: "openEditPageSheet",
520
+ pageId: currentPage.id
521
+ });
522
+ }
523
+ },
524
+ {
525
+ id: "go-to-page",
526
+ label: "Go to page",
527
+ groupLabel: "Preview",
528
+ checkIfAvailable: () => !!pages,
529
+ hasChildren: true,
530
+ execute: _temp9
531
+ },
532
+ ...pages ? pages.map((page) => ({
533
+ id: `go-to-page-${page.id}`,
534
+ parentActionId: "go-to-page",
535
+ label: `Go to "${page.metaTitle ?? formatPathSegment(page.pathSegment)}"`,
536
+ groupLabel: "Preview",
537
+ checkIfAvailable: _temp0,
538
+ execute: () => navigate({ to: page.fullPath })
539
+ })) : []
540
+ ];
317
541
  actionsStore.send({
318
- type: "unregisterManyActions",
319
- ids: actions.map((a) => a.id)
542
+ type: "registerManyActions",
543
+ actions
320
544
  });
545
+ return () => {
546
+ actionsStore.send({
547
+ type: "unregisterManyActions",
548
+ ids: actions.map(_temp1)
549
+ });
550
+ };
321
551
  };
322
- }, [
323
- navigate,
324
- pages,
325
- pathname
326
- ]);
552
+ t5 = [
553
+ navigate,
554
+ pages,
555
+ pathname
556
+ ];
557
+ $[7] = navigate;
558
+ $[8] = pages;
559
+ $[9] = pathname;
560
+ $[10] = t4;
561
+ $[11] = t5;
562
+ } else {
563
+ t4 = $[10];
564
+ t5 = $[11];
565
+ }
566
+ React.useEffect(t4, t5);
567
+ }
568
+ function _temp1(a) {
569
+ return a.id;
570
+ }
571
+ function _temp0() {
572
+ return true;
573
+ }
574
+ function _temp9() {}
575
+ function _temp8() {
576
+ return previewStore.send({ type: "openCreatePageSheet" });
577
+ }
578
+ function _temp7() {
579
+ return true;
580
+ }
581
+ function _temp2(state) {
582
+ return state.context.isPresentationMode;
583
+ }
584
+ function _temp3(state_0) {
585
+ return state_0.context.isSidebarOpen;
586
+ }
587
+ function _temp4() {
588
+ return previewStore.send({ type: "enterPresentationMode" });
589
+ }
590
+ function _temp5() {
591
+ return previewStore.send({ type: "exitPresentationMode" });
592
+ }
593
+ function _temp6(a) {
594
+ return a.id;
327
595
  }
328
596
  //#endregion
329
597
  export { CamoxPreview, PageContent, usePreviewPagesActions, usePreviewedPage };