camox 0.40.0 → 0.41.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 (108) hide show
  1. package/dist/components/PlatformLabel.js +62 -0
  2. package/dist/core/components/lexical/GradientNode.js +126 -0
  3. package/dist/core/components/lexical/InlineLexicalEditor.js +37 -56
  4. package/dist/core/components/lexical/InlineStylesPlugin.js +183 -0
  5. package/dist/core/components/lexical/SelectionBroadcaster.js +49 -46
  6. package/dist/core/components/lexical/SidebarLexicalEditor.js +197 -151
  7. package/dist/core/components/lexical/editorConfig.js +25 -7
  8. package/dist/core/components/lexical/selectTextLink.js +21 -0
  9. package/dist/core/createApp.d.ts +30 -17
  10. package/dist/core/createApp.js +14 -3
  11. package/dist/core/createBlock.d.ts +2 -2
  12. package/dist/core/createBlock.js +17 -28
  13. package/dist/core/createLayout.d.ts +48 -4
  14. package/dist/core/createLayout.js +51 -23
  15. package/dist/core/derivedRoutes.js +36 -0
  16. package/dist/core/editing/BlockEditingRuntime.js +4 -4
  17. package/dist/core/editing/CompleteBlockEditingRuntime.js +5 -5
  18. package/dist/core/editing/createEditableBlock.d.ts +9 -8
  19. package/dist/core/editing/createEditableBlock.js +265 -403
  20. package/dist/core/hooks/useIsEditable.js +4 -7
  21. package/dist/core/hooks/useRequireDraftSource.js +7 -11
  22. package/dist/core/lib/lexicalReact.d.ts +1 -26
  23. package/dist/core/lib/lexicalReact.js +46 -60
  24. package/dist/core/lib/lexicalState.js +164 -81
  25. package/dist/core/lib/modifierFormats.js +4 -15
  26. package/dist/core/lib/textStyles.d.ts +27 -0
  27. package/dist/core/lib/textStyles.js +47 -0
  28. package/dist/features/navigation/navigation.d.ts +2 -0
  29. package/dist/features/navigation/navigation.js +51 -46
  30. package/dist/features/page/DerivedPageContent.js +61 -0
  31. package/dist/features/page/PublishedPageContent.js +52 -83
  32. package/dist/features/page/SharedLayoutContent.js +66 -0
  33. package/dist/features/preview/CamoxPreview.d.ts +16 -1
  34. package/dist/features/preview/CamoxPreview.js +246 -290
  35. package/dist/features/preview/DerivedPreview.js +134 -0
  36. package/dist/features/preview/EditablePageExperience.js +25 -8
  37. package/dist/features/preview/components/AddBlockSidebar.js +43 -33
  38. package/dist/features/preview/components/AssetLightbox.js +1 -1
  39. package/dist/features/preview/components/BlockActionsPopover.js +8 -8
  40. package/dist/features/preview/components/BlockThumbnail.js +192 -0
  41. package/dist/features/preview/components/CreatePageModal.js +123 -115
  42. package/dist/features/preview/components/DerivedLayoutDialog.js +100 -0
  43. package/dist/features/preview/components/DerivedLayoutSidebar.d.ts +5 -0
  44. package/dist/features/preview/components/DerivedLayoutSidebar.js +160 -0
  45. package/dist/features/preview/components/DerivedPageInfoSidebar.js +57 -0
  46. package/dist/features/preview/components/FieldToolbar.js +42 -20
  47. package/dist/features/preview/components/Frame.js +133 -140
  48. package/dist/features/preview/components/LeftSidebar.js +42 -38
  49. package/dist/features/preview/components/LinkFieldEditor.js +3 -4
  50. package/dist/features/preview/components/MobilePreviewDrawer.js +4 -4
  51. package/dist/features/preview/components/Overlays.js +59 -47
  52. package/dist/features/preview/components/PageEditorSidebar.js +194 -203
  53. package/dist/features/preview/components/PageInfoSidebar.js +63 -55
  54. package/dist/features/preview/components/PageNavigatorSidebar.js +34 -483
  55. package/dist/features/preview/components/PagePicker.js +205 -153
  56. package/dist/features/preview/components/PageTree.js +366 -340
  57. package/dist/features/preview/components/PreviewActivation.js +78 -0
  58. package/dist/features/preview/components/PreviewPanel.js +98 -68
  59. package/dist/features/preview/components/PreviewToolbar.js +224 -241
  60. package/dist/features/preview/components/PreviewToolbarSpacer.js +43 -0
  61. package/dist/features/preview/components/PublicationRow.js +425 -0
  62. package/dist/features/preview/components/PublishDialog.js +180 -97
  63. package/dist/features/preview/components/RightSidebar.js +19 -34
  64. package/dist/features/preview/components/previewStyles.js +8 -0
  65. package/dist/features/preview/components/useUpdateBlockPosition.js +7 -13
  66. package/dist/features/preview/previewConstants.js +8 -0
  67. package/dist/features/preview/previewStore.js +18 -39
  68. package/dist/features/preview/publication.js +71 -0
  69. package/dist/features/provider/AuthenticatedCamoxProvider.js +2 -1
  70. package/dist/features/provider/CoreCamoxProvider.js +11 -2
  71. package/dist/features/provider/LocalhostPreviewProvider.js +6 -7
  72. package/dist/features/provider/useAdminShortcuts.js +5 -4
  73. package/dist/features/routes/pageRuntime.d.ts +10 -0
  74. package/dist/features/routes/pageRuntime.js +7 -9
  75. package/dist/features/runtime/PreviewDocumentContext.js +7 -0
  76. package/dist/features/runtime/RuntimeChrome.js +149 -0
  77. package/dist/features/runtime/SharedChromeContext.js +7 -0
  78. package/dist/features/runtime/navigationRequest.js +21 -0
  79. package/dist/features/runtime/navigationTarget.js +23 -0
  80. package/dist/features/runtime/pageApp.js +196 -121
  81. package/dist/features/runtime/pageNavigation.js +79 -130
  82. package/dist/features/runtime/runtime.d.ts +11 -0
  83. package/dist/features/runtime/runtime.js +183 -47
  84. package/dist/features/runtime/studioApp.d.ts +2 -11
  85. package/dist/features/runtime/studioApp.js +14 -177
  86. package/dist/features/studio/CamoxStudio.js +27 -13
  87. package/dist/features/studio/components/Navbar.js +80 -74
  88. package/dist/features/studio/components/UserButton.js +4 -4
  89. package/dist/features/studio/studioTheme.js +25 -0
  90. package/dist/features/studio/useTheme.js +94 -109
  91. package/dist/features/vite/appGeneration.js +12 -3
  92. package/dist/features/vite/definitionsSync.js +4 -2
  93. package/dist/features/vite/layoutGeneration.js +38 -0
  94. package/dist/features/vite/runtimeDev.js +3 -1
  95. package/dist/lib/auth.js +15 -13
  96. package/dist/lib/normalized-data.js +4 -4
  97. package/dist/lib/platform.js +13 -0
  98. package/dist/lib/utils.js +90 -38
  99. package/dist/studio-overlays.css +5 -40
  100. package/dist/studio.css +1 -1
  101. package/package.json +8 -4
  102. package/skills/camox/SKILL.md +2 -0
  103. package/skills/camox/references/block-definitions.md +31 -12
  104. package/skills/camox/references/layout-definitions.md +2 -0
  105. package/dist/core/lib/modifiers.js +0 -24
  106. package/dist/features/preview/components/DraftSwitchDialog.js +0 -66
  107. package/dist/features/preview/previewQueryFns.js +0 -23
  108. package/dist/features/runtime/studioNavigation.js +0 -120
@@ -1,110 +1,193 @@
1
- import { pageMutations } from "../../../lib/queries.js";
2
- import { trackClientEvent } from "../../../lib/telemetry-client.js";
3
- import { useMutation } from "@tanstack/react-query";
1
+ import { c } from "react/compiler-runtime";
4
2
  import * as React from "react";
5
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
6
4
  import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
7
- import { toast } from "@camox/ui/toaster";
8
5
  import { Label } from "@camox/ui/label";
9
6
  import { Switch } from "@camox/ui/switch";
10
7
 
11
8
  //#region src/features/preview/components/PublishDialog.tsx
12
- /**
13
- * Confirmation dialog for `pages.publish`. Shows the path that will go live
14
- * (= the current draft path; same as today's public URL unless the user
15
- * changed it while drafting), and a primary Publish button.
16
- *
17
- * Description copy branches on the page's current status: a `'draft'` page
18
- * has never been public so we frame it as "will go live"; a `'modified'`
19
- * page is already public and we're promoting the latest edits.
20
- *
21
- * When the page's layout is itself modified (`alsoPublishLayout` prop set),
22
- * a toggle appears below the primary action, pre-checked. Bundling is the
23
- * common case — the user is usually editing page + layout together and
24
- * expects "Publish" to mean "what I see goes live". Power users who edited
25
- * the layout independently can opt out before confirming.
26
- */
27
- function PublishDialog({ page, pageStatus, alsoPublishLayout, open, onOpenChange }) {
28
- const publishPage = useMutation(pageMutations.publish());
29
- const [bundleLayout, setBundleLayout] = React.useState(true);
30
- React.useEffect(() => {
31
- if (open) setBundleLayout(true);
32
- }, [open]);
33
- const handlePublish = async () => {
34
- if (!page) return;
35
- const shouldBundle = bundleLayout && alsoPublishLayout != null;
36
- try {
37
- await publishPage.mutateAsync({
38
- id: page.id,
39
- ...shouldBundle ? { alsoPublishLayout: true } : {}
40
- });
41
- trackClientEvent("page_published", {
42
- pageId: page.id,
43
- ...shouldBundle ? { alsoPublishedLayout: true } : {}
44
- });
45
- toast.success(shouldBundle ? `Published this page and layout ${alsoPublishLayout?.layoutHandle}` : "Published this page");
46
- onOpenChange(false);
47
- } catch (error) {
48
- console.error("Failed to publish page:", error);
49
- toast.error("Could not publish this page");
50
- }
51
- };
52
- const pathCode = /* @__PURE__ */ jsx("code", {
53
- className: "bg-muted rounded px-1 py-0.5 font-mono text-xs",
54
- children: page?.fullPath ?? ""
55
- });
56
- return /* @__PURE__ */ jsx(AlertDialog, {
57
- open,
58
- onOpenChange,
59
- children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
60
- /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: pageStatus === "modified" ? "Publish changes" : "Publish page" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: pageStatus === "modified" ? /* @__PURE__ */ jsxs(Fragment, { children: [
61
- "Visitors at ",
62
- pathCode,
63
- " will start seeing your latest changes."
64
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
65
- "This page will go live at ",
66
- pathCode,
67
- ". Visitors will see the current draft."
68
- ] }) })] }),
69
- alsoPublishLayout && /* @__PURE__ */ jsxs("div", {
9
+ /** Shared scope/impact review. Mount afresh for each publication attempt. */
10
+ function PublishDialog(t0) {
11
+ const $ = c(53);
12
+ if ($[0] !== "0ada477bb5fc69a9b0f1551db385228a0e85d0d93484a56040a42f62e6af3eb0") {
13
+ for (let $i = 0; $i < 53; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
14
+ $[0] = "0ada477bb5fc69a9b0f1551db385228a0e85d0d93484a56040a42f62e6af3eb0";
15
+ }
16
+ const { plan, pending, onPublish, onOpenChange } = t0;
17
+ const id = React.useId();
18
+ let t1;
19
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
20
+ t1 = [];
21
+ $[1] = t1;
22
+ } else t1 = $[1];
23
+ const [excludedKeys, setExcludedKeys] = React.useState(t1);
24
+ let T0;
25
+ let T1;
26
+ let includedKeys;
27
+ let t2;
28
+ let t3;
29
+ let t4;
30
+ let t5;
31
+ if ($[2] !== excludedKeys || $[3] !== id || $[4] !== onOpenChange || $[5] !== pending || $[6] !== plan.description || $[7] !== plan.items || $[8] !== plan.title) {
32
+ const sideEffects = plan.items.filter(_temp);
33
+ let t6;
34
+ if ($[16] !== excludedKeys || $[17] !== plan.items) {
35
+ let t7;
36
+ if ($[19] !== excludedKeys) {
37
+ t7 = (item_0) => !item_0.optional || !excludedKeys.includes(item_0.key);
38
+ $[19] = excludedKeys;
39
+ $[20] = t7;
40
+ } else t7 = $[20];
41
+ t6 = plan.items.filter(t7).map(_temp2);
42
+ $[16] = excludedKeys;
43
+ $[17] = plan.items;
44
+ $[18] = t6;
45
+ } else t6 = $[18];
46
+ includedKeys = t6;
47
+ T1 = AlertDialog;
48
+ t4 = true;
49
+ if ($[21] !== onOpenChange || $[22] !== pending) {
50
+ t5 = (open) => !pending && onOpenChange(open);
51
+ $[21] = onOpenChange;
52
+ $[22] = pending;
53
+ $[23] = t5;
54
+ } else t5 = $[23];
55
+ T0 = AlertDialogContent;
56
+ let t7;
57
+ if ($[24] !== plan.title) {
58
+ t7 = /* @__PURE__ */ jsx(AlertDialogTitle, { children: plan.title });
59
+ $[24] = plan.title;
60
+ $[25] = t7;
61
+ } else t7 = $[25];
62
+ let t8;
63
+ if ($[26] !== plan.description) {
64
+ t8 = /* @__PURE__ */ jsx(AlertDialogDescription, { children: plan.description });
65
+ $[26] = plan.description;
66
+ $[27] = t8;
67
+ } else t8 = $[27];
68
+ if ($[28] !== t7 || $[29] !== t8) {
69
+ t2 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [t7, t8] });
70
+ $[28] = t7;
71
+ $[29] = t8;
72
+ $[30] = t2;
73
+ } else t2 = $[30];
74
+ t3 = sideEffects.length > 0 && /* @__PURE__ */ jsx("div", {
75
+ className: "space-y-3",
76
+ children: sideEffects.map((item_2) => /* @__PURE__ */ jsxs("div", {
70
77
  className: "flex items-start gap-3",
71
78
  children: [/* @__PURE__ */ jsx(Switch, {
72
- id: "also-publish-layout",
73
- checked: bundleLayout,
74
- onCheckedChange: (checked) => setBundleLayout(checked),
75
- disabled: publishPage.isPending
76
- }), /* @__PURE__ */ jsxs(Label, {
77
- htmlFor: "also-publish-layout",
78
- className: "flex flex-col items-start gap-1",
79
- children: [/* @__PURE__ */ jsxs("span", { children: [
80
- "Also publish layout",
81
- " ",
82
- /* @__PURE__ */ jsx("code", {
83
- className: "bg-muted rounded px-1 py-0.5 font-mono text-xs",
84
- children: alsoPublishLayout.layoutHandle
85
- })
86
- ] }), /* @__PURE__ */ jsx("span", {
87
- className: "text-muted-foreground text-xs font-normal",
88
- children: (() => {
89
- const others = Math.max(0, alsoPublishLayout.affectedPagesCount - 1);
90
- if (others === 0) return "Affects no other pages";
91
- return `Affects ${others} other ${others === 1 ? "page" : "pages"}`;
92
- })()
79
+ id: `${id}-${item_2.key}`,
80
+ checked: !excludedKeys.includes(item_2.key),
81
+ onCheckedChange: (checked) => setExcludedKeys((keys) => checked ? keys.filter((key) => key !== item_2.key) : [...keys, item_2.key]),
82
+ disabled: pending
83
+ }), /* @__PURE__ */ jsxs("div", {
84
+ className: "min-w-0 space-y-1",
85
+ children: [/* @__PURE__ */ jsxs(Label, {
86
+ htmlFor: `${id}-${item_2.key}`,
87
+ children: ["Also publish ", item_2.label]
88
+ }), /* @__PURE__ */ jsx("p", {
89
+ className: "text-muted-foreground text-sm",
90
+ children: item_2.impact
93
91
  })]
94
92
  })]
95
- }),
96
- /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [/* @__PURE__ */ jsx(AlertDialogCancel, {
97
- variant: "outline",
98
- size: "default",
99
- disabled: publishPage.isPending,
100
- children: "Cancel"
101
- }), /* @__PURE__ */ jsx(AlertDialogAction, {
102
- onClick: handlePublish,
103
- disabled: publishPage.isPending,
104
- children: publishPage.isPending ? "Publishing…" : "Publish"
105
- })] })
106
- ] })
107
- });
93
+ }, item_2.key))
94
+ });
95
+ $[2] = excludedKeys;
96
+ $[3] = id;
97
+ $[4] = onOpenChange;
98
+ $[5] = pending;
99
+ $[6] = plan.description;
100
+ $[7] = plan.items;
101
+ $[8] = plan.title;
102
+ $[9] = T0;
103
+ $[10] = T1;
104
+ $[11] = includedKeys;
105
+ $[12] = t2;
106
+ $[13] = t3;
107
+ $[14] = t4;
108
+ $[15] = t5;
109
+ } else {
110
+ T0 = $[9];
111
+ T1 = $[10];
112
+ includedKeys = $[11];
113
+ t2 = $[12];
114
+ t3 = $[13];
115
+ t4 = $[14];
116
+ t5 = $[15];
117
+ }
118
+ let t6;
119
+ if ($[31] !== pending) {
120
+ t6 = /* @__PURE__ */ jsx(AlertDialogCancel, {
121
+ variant: "outline",
122
+ disabled: pending,
123
+ children: "Cancel"
124
+ });
125
+ $[31] = pending;
126
+ $[32] = t6;
127
+ } else t6 = $[32];
128
+ let t7;
129
+ if ($[33] !== includedKeys || $[34] !== onPublish) {
130
+ t7 = (event) => {
131
+ event.preventDefault();
132
+ onPublish(includedKeys);
133
+ };
134
+ $[33] = includedKeys;
135
+ $[34] = onPublish;
136
+ $[35] = t7;
137
+ } else t7 = $[35];
138
+ const t8 = pending ? "Publishing…" : "Publish";
139
+ let t9;
140
+ if ($[36] !== pending || $[37] !== t7 || $[38] !== t8) {
141
+ t9 = /* @__PURE__ */ jsx(AlertDialogAction, {
142
+ disabled: pending,
143
+ onClick: t7,
144
+ children: t8
145
+ });
146
+ $[36] = pending;
147
+ $[37] = t7;
148
+ $[38] = t8;
149
+ $[39] = t9;
150
+ } else t9 = $[39];
151
+ let t10;
152
+ if ($[40] !== t6 || $[41] !== t9) {
153
+ t10 = /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t6, t9] });
154
+ $[40] = t6;
155
+ $[41] = t9;
156
+ $[42] = t10;
157
+ } else t10 = $[42];
158
+ let t11;
159
+ if ($[43] !== T0 || $[44] !== t10 || $[45] !== t2 || $[46] !== t3) {
160
+ t11 = /* @__PURE__ */ jsxs(T0, { children: [
161
+ t2,
162
+ t3,
163
+ t10
164
+ ] });
165
+ $[43] = T0;
166
+ $[44] = t10;
167
+ $[45] = t2;
168
+ $[46] = t3;
169
+ $[47] = t11;
170
+ } else t11 = $[47];
171
+ let t12;
172
+ if ($[48] !== T1 || $[49] !== t11 || $[50] !== t4 || $[51] !== t5) {
173
+ t12 = /* @__PURE__ */ jsx(T1, {
174
+ open: t4,
175
+ onOpenChange: t5,
176
+ children: t11
177
+ });
178
+ $[48] = T1;
179
+ $[49] = t11;
180
+ $[50] = t4;
181
+ $[51] = t5;
182
+ $[52] = t12;
183
+ } else t12 = $[52];
184
+ return t12;
185
+ }
186
+ function _temp2(item_1) {
187
+ return item_1.key;
188
+ }
189
+ function _temp(item) {
190
+ return item.optional;
108
191
  }
109
192
 
110
193
  //#endregion
@@ -1,18 +1,20 @@
1
1
  import { previewStore, selectionBlockId } from "../previewStore.js";
2
+ import { AddBlockSidebar } from "./AddBlockSidebar.js";
2
3
  import { PageEditorSidebar } from "./PageEditorSidebar.js";
3
4
  import { PageInfoSidebar } from "./PageInfoSidebar.js";
5
+ import { DerivedPageInfoSidebar } from "./DerivedPageInfoSidebar.js";
4
6
  import { c } from "react/compiler-runtime";
5
- import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { jsx } from "react/jsx-runtime";
6
8
  import { useSelector } from "@xstate/store-react";
7
9
 
8
10
  //#region src/features/preview/components/RightSidebar.tsx
9
11
  const RightSidebar = (t0) => {
10
- const $ = c(12);
11
- if ($[0] !== "b9589c1fea2c3efabdd9fae80871373106138216610ee3b8e2f4045e3b45670f") {
12
- for (let $i = 0; $i < 12; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
13
- $[0] = "b9589c1fea2c3efabdd9fae80871373106138216610ee3b8e2f4045e3b45670f";
12
+ const $ = c(9);
13
+ if ($[0] !== "d71e54add8a0890703a029e4ca30b5b8fa7b144767455a2e03c5c0c217ac64a0") {
14
+ for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
15
+ $[0] = "d71e54add8a0890703a029e4ca30b5b8fa7b144767455a2e03c5c0c217ac64a0";
14
16
  }
15
- const { pageId } = t0;
17
+ const { pageId, derivedLayoutId } = t0;
16
18
  const selection = useSelector(previewStore, _temp);
17
19
  const isAddBlockSidebarOpen = useSelector(previewStore, _temp2);
18
20
  let t1;
@@ -22,40 +24,26 @@ const RightSidebar = (t0) => {
22
24
  $[2] = t1;
23
25
  } else t1 = $[2];
24
26
  const selectedBlockId = t1;
27
+ if (pageId == null && derivedLayoutId == null && selectedBlockId == null) return null;
25
28
  let t2;
26
29
  if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
27
30
  t2 = { width: 250 };
28
31
  $[3] = t2;
29
32
  } else t2 = $[3];
30
33
  let t3;
31
- if ($[4] !== pageId || $[5] !== selectedBlockId) {
32
- t3 = selectedBlockId == null ? /* @__PURE__ */ jsx(PageInfoSidebar, { pageId }) : /* @__PURE__ */ jsx(PageEditorSidebar, {});
33
- $[4] = pageId;
34
- $[5] = selectedBlockId;
35
- $[6] = t3;
36
- } else t3 = $[6];
37
- let t4;
38
- if ($[7] !== isAddBlockSidebarOpen) {
39
- t4 = isAddBlockSidebarOpen && /* @__PURE__ */ jsx("div", {
40
- className: "absolute inset-0 z-20",
41
- style: { background: "rgba(0, 0, 0, 0.66)" },
42
- onClick: _temp3
43
- });
44
- $[7] = isAddBlockSidebarOpen;
45
- $[8] = t4;
46
- } else t4 = $[8];
47
- let t5;
48
- if ($[9] !== t3 || $[10] !== t4) {
49
- t5 = /* @__PURE__ */ jsxs("aside", {
34
+ if ($[4] !== derivedLayoutId || $[5] !== isAddBlockSidebarOpen || $[6] !== pageId || $[7] !== selectedBlockId) {
35
+ t3 = /* @__PURE__ */ jsx("aside", {
50
36
  className: "bg-background relative flex shrink-0 flex-col border-l-2",
51
37
  style: t2,
52
- children: [t3, t4]
38
+ children: pageId != null && isAddBlockSidebarOpen ? /* @__PURE__ */ jsx(AddBlockSidebar, {}) : selectedBlockId != null ? /* @__PURE__ */ jsx(PageEditorSidebar, {}) : pageId != null ? /* @__PURE__ */ jsx(PageInfoSidebar, { pageId }) : /* @__PURE__ */ jsx(DerivedPageInfoSidebar, { layoutId: derivedLayoutId })
53
39
  });
54
- $[9] = t3;
55
- $[10] = t4;
56
- $[11] = t5;
57
- } else t5 = $[11];
58
- return t5;
40
+ $[4] = derivedLayoutId;
41
+ $[5] = isAddBlockSidebarOpen;
42
+ $[6] = pageId;
43
+ $[7] = selectedBlockId;
44
+ $[8] = t3;
45
+ } else t3 = $[8];
46
+ return t3;
59
47
  };
60
48
  function _temp(state) {
61
49
  return state.context.selection;
@@ -63,9 +51,6 @@ function _temp(state) {
63
51
  function _temp2(state_0) {
64
52
  return state_0.context.isAddBlockSidebarOpen;
65
53
  }
66
- function _temp3() {
67
- return previewStore.send({ type: "closeAddBlockSidebar" });
68
- }
69
54
 
70
55
  //#endregion
71
56
  export { RightSidebar };
@@ -0,0 +1,8 @@
1
+ //#region src/features/preview/components/previewStyles.ts
2
+ function isSiteStyle(element) {
3
+ return !element.hasAttribute("data-camox-studio");
4
+ }
5
+ const EMPTY_PREVIEW_DOCUMENT = "<!doctype html><html><head></head><body><div id=\"root\" data-camox-preview-root></div></body></html>";
6
+
7
+ //#endregion
8
+ export { EMPTY_PREVIEW_DOCUMENT, isSiteStyle };
@@ -1,33 +1,30 @@
1
1
  import { useLocation } from "../../navigation/navigation.js";
2
2
  import { blockMutations } from "../../../lib/queries.js";
3
- import { previewStore } from "../previewStore.js";
4
3
  import { c } from "react/compiler-runtime";
5
4
  import { useMutation, useQueryClient } from "@tanstack/react-query";
6
5
  import { generateKeyBetween } from "fractional-indexing";
7
- import { useSelector } from "@xstate/store-react";
8
6
  import { queryKeys } from "@camox/api-contract/query-keys";
9
7
 
10
8
  //#region src/features/preview/components/useUpdateBlockPosition.ts
11
9
  function useUpdateBlockPosition() {
12
10
  const $ = c(5);
13
- if ($[0] !== "c7adf6cdbf960268a5bfbb85b92c76404d7abbe36258eed14eb7062e652330a8") {
11
+ if ($[0] !== "fed14916f5b55681b4a767606bad92ee9c3a074376e24f2981a9af1a6551ad97") {
14
12
  for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
15
- $[0] = "c7adf6cdbf960268a5bfbb85b92c76404d7abbe36258eed14eb7062e652330a8";
13
+ $[0] = "fed14916f5b55681b4a767606bad92ee9c3a074376e24f2981a9af1a6551ad97";
16
14
  }
17
15
  const queryClient = useQueryClient();
18
16
  const { pathname } = useLocation();
19
- const pagePathname = useSelector(previewStore, _temp) ?? pathname;
20
17
  let t0;
21
18
  if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
22
19
  t0 = blockMutations.updatePosition();
23
20
  $[1] = t0;
24
21
  } else t0 = $[1];
25
22
  let t1;
26
- if ($[2] !== pagePathname || $[3] !== queryClient) {
23
+ if ($[2] !== pathname || $[3] !== queryClient) {
27
24
  t1 = {
28
25
  ...t0,
29
26
  onMutate: (variables) => {
30
- const pageQueryKey = queryKeys.pages.getByPath(pagePathname, "draft");
27
+ const pageQueryKey = queryKeys.pages.getByPath(pathname, "draft");
31
28
  const previousPage = queryClient.getQueryData(pageQueryKey);
32
29
  if (!previousPage) return {};
33
30
  const newPosition = generateKeyBetween(variables.afterPosition ?? null, variables.beforePosition ?? null);
@@ -66,22 +63,19 @@ function useUpdateBlockPosition() {
66
63
  };
67
64
  },
68
65
  onError: (_error, variables_0, context) => {
69
- if (context?.previousPage) queryClient.setQueryData(queryKeys.pages.getByPath(pagePathname, "draft"), context.previousPage);
66
+ if (context?.previousPage) queryClient.setQueryData(queryKeys.pages.getByPath(pathname, "draft"), context.previousPage);
70
67
  if (context?.prevBundle) queryClient.setQueryData(queryKeys.blocks.get(variables_0.id, "draft"), context.prevBundle);
71
68
  },
72
69
  onSettled: () => {
73
- queryClient.invalidateQueries({ queryKey: queryKeys.pages.getByPath(pagePathname, "draft") });
70
+ queryClient.invalidateQueries({ queryKey: queryKeys.pages.getByPath(pathname, "draft") });
74
71
  }
75
72
  };
76
- $[2] = pagePathname;
73
+ $[2] = pathname;
77
74
  $[3] = queryClient;
78
75
  $[4] = t1;
79
76
  } else t1 = $[4];
80
77
  return useMutation(t1);
81
78
  }
82
- function _temp(state) {
83
- return state.context.peekedPagePathname;
84
- }
85
79
 
86
80
  //#endregion
87
81
  export { useUpdateBlockPosition };
@@ -0,0 +1,8 @@
1
+ //#region src/features/preview/previewConstants.ts
2
+ const EDIT_MODE_SHORTCUT = {
3
+ key: "Enter",
4
+ withMeta: true
5
+ };
6
+
7
+ //#endregion
8
+ export { EDIT_MODE_SHORTCUT };
@@ -22,44 +22,43 @@ function selectionField(sel) {
22
22
  };
23
23
  return null;
24
24
  }
25
+ const selectIsEditMode = (state) => state.context.mode === "editing-draft";
26
+ const selectPreviewSource = (state) => state.context.mode === "previewing-live" ? "live" : "draft";
25
27
  const previewStore = createStore({
26
28
  context: {
27
- isEditMode: false,
29
+ mode: "previewing-draft",
28
30
  isToolbarHidden: false,
29
31
  isPageEditorSidebarOpen: false,
30
32
  isAddBlockSidebarOpen: false,
31
33
  addBlockSource: null,
32
34
  isCreatePageModalOpen: false,
33
35
  editingPageId: null,
34
- isDraftSwitchDialogOpen: false,
35
36
  viewportMode: "full",
36
37
  peekedBlock: null,
37
38
  peekedBlockPosition: null,
38
- peekedPagePathname: null,
39
39
  skipPeekedBlockExitAnimation: false,
40
40
  selection: null,
41
- iframeElement: null,
42
- previewSource: "draft"
41
+ iframeElement: null
43
42
  },
44
43
  on: {
45
44
  exitEditMode: (context, _, enqueue) => {
46
- if (!context.isEditMode) return context;
45
+ if (context.mode !== "editing-draft") return context;
47
46
  enqueue.effect(() => {
48
47
  trackClientEvent("edit_mode_toggled", { enabled: false });
49
48
  });
50
49
  return {
51
50
  ...context,
52
- isEditMode: false
51
+ mode: "previewing-draft"
53
52
  };
54
53
  },
55
54
  enterEditMode: (context, _, enqueue) => {
56
- if (context.isEditMode) return context;
55
+ if (context.mode === "editing-draft") return context;
57
56
  enqueue.effect(() => {
58
57
  trackClientEvent("edit_mode_toggled", { enabled: true });
59
58
  });
60
59
  return {
61
60
  ...context,
62
- isEditMode: true,
61
+ mode: "editing-draft",
63
62
  isToolbarHidden: false
64
63
  };
65
64
  },
@@ -69,14 +68,13 @@ const previewStore = createStore({
69
68
  }),
70
69
  viewLivePage: (context, _, enqueue) => {
71
70
  enqueue.effect(() => {
72
- if (context.isEditMode) trackClientEvent("edit_mode_toggled", { enabled: false });
71
+ if (context.mode === "editing-draft") trackClientEvent("edit_mode_toggled", { enabled: false });
73
72
  toast("Viewing live version of the site");
74
73
  });
75
74
  return {
76
75
  ...context,
77
- isEditMode: false,
78
- isToolbarHidden: true,
79
- previewSource: "live"
76
+ mode: "previewing-live",
77
+ isToolbarHidden: true
80
78
  };
81
79
  },
82
80
  setViewportMode: (context, event) => {
@@ -184,15 +182,6 @@ const previewStore = createStore({
184
182
  ...context,
185
183
  selection: null
186
184
  }),
187
- setPeekedPage: (context, event) => ({
188
- ...context,
189
- selection: null,
190
- peekedPagePathname: event.pathname
191
- }),
192
- clearPeekedPage: (context) => ({
193
- ...context,
194
- peekedPagePathname: null
195
- }),
196
185
  openAddBlockSidebar: (context, event) => ({
197
186
  ...context,
198
187
  isAddBlockSidebarOpen: true,
@@ -265,29 +254,19 @@ const previewStore = createStore({
265
254
  ...context,
266
255
  iframeElement: event.element
267
256
  }),
268
- setPreviewSource: (context, event, enqueue) => {
269
- if (event.source === context.previewSource) return context;
257
+ viewDraftPage: (context, _, enqueue) => {
258
+ if (context.mode !== "previewing-live") return context;
270
259
  enqueue.effect(() => {
271
- toast(event.source === "draft" ? "Previewing draft content" : "Previewing live content", { duration: 2500 });
260
+ toast("Previewing draft content", { duration: 2500 });
272
261
  });
273
262
  return {
274
263
  ...context,
275
- previewSource: event.source
276
- };
277
- },
278
- requestDraftSwitch: (context) => {
279
- if (context.previewSource === "draft") return context;
280
- return {
281
- ...context,
282
- isDraftSwitchDialogOpen: true
264
+ mode: "previewing-draft",
265
+ isToolbarHidden: false
283
266
  };
284
- },
285
- dismissDraftSwitch: (context) => ({
286
- ...context,
287
- isDraftSwitchDialogOpen: false
288
- })
267
+ }
289
268
  }
290
269
  });
291
270
 
292
271
  //#endregion
293
- export { previewStore, selectionBlockId, selectionField, selectionItemId };
272
+ export { previewStore, selectIsEditMode, selectPreviewSource, selectionBlockId, selectionField, selectionItemId };
@@ -0,0 +1,71 @@
1
+ //#region src/features/preview/publication.ts
2
+ /** Scope and impact are shared by all publishing entry points. Only expose choices
3
+ * the backend can execute: a page and its optional layout, or a whole layout.
4
+ * Synced-block dependencies will need backend planning/execution support here,
5
+ * not a separate publishing UI or a sequence of independent block requests.
6
+ */
7
+ function buildPublicationPlan(target) {
8
+ if (target.kind === "layout") return {
9
+ title: target.layout.status === "modified" ? "Publish changes" : "Publish layout",
10
+ description: `Publishes ${target.name} on every page using this layout. Generated content and external data are not published by this action.`,
11
+ items: [{
12
+ key: `layout:${target.layout.id}`,
13
+ label: `${target.name} layout blocks`,
14
+ impact: "Updates the before and after blocks on every page using this layout, including all derived URLs.",
15
+ optional: false
16
+ }]
17
+ };
18
+ const { page } = target;
19
+ const items = [{
20
+ key: `page:${page.id}`,
21
+ label: page.fullPath,
22
+ impact: page.status === "draft" ? "Makes this page live with its current draft content." : "Updates this page with its latest draft content.",
23
+ optional: false
24
+ }];
25
+ const reason = page.modifiedReason;
26
+ if (reason && (reason.reason === "layout" || reason.reason === "both")) {
27
+ const others = Math.max(0, reason.affectedPagesCount - 1);
28
+ items.push({
29
+ key: `layout:${reason.layoutId}`,
30
+ label: `${reason.layoutHandle} layout blocks`,
31
+ impact: others === 0 ? "Updates shared blocks on this page. Affects no other pages." : `Updates shared blocks on this page and ${others} other ${others === 1 ? "page" : "pages"}.`,
32
+ optional: true
33
+ });
34
+ }
35
+ return {
36
+ title: page.status === "modified" ? "Publish changes" : "Publish page",
37
+ description: page.status === "draft" ? `This page will go live at ${page.fullPath}.` : `Visitors at ${page.fullPath} will see your latest changes.`,
38
+ items
39
+ };
40
+ }
41
+ function getPublicationCapabilities(target, source) {
42
+ if (!target) return {
43
+ publish: false,
44
+ unpublish: false,
45
+ discard: false
46
+ };
47
+ const record = target.kind === "page" ? target.page : target.layout;
48
+ return {
49
+ publish: record.status !== "published" && source === "draft",
50
+ unpublish: record.livePublishedCheckpointId != null && !(target.kind === "page" && target.page.fullPath === "/"),
51
+ discard: target.kind === "page" && record.status === "modified"
52
+ };
53
+ }
54
+ function getPublicationRequest(target, includedKeys) {
55
+ if (target.kind === "layout") return {
56
+ kind: "layout",
57
+ input: { id: target.layout.id }
58
+ };
59
+ const optionalLayout = buildPublicationPlan(target).items.find((item) => item.optional);
60
+ const alsoPublishLayout = optionalLayout && includedKeys.includes(optionalLayout.key);
61
+ return {
62
+ kind: "page",
63
+ input: {
64
+ id: target.page.id,
65
+ ...alsoPublishLayout ? { alsoPublishLayout: true } : {}
66
+ }
67
+ };
68
+ }
69
+
70
+ //#endregion
71
+ export { buildPublicationPlan, getPublicationCapabilities, getPublicationRequest };