camox 0.41.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 (27) hide show
  1. package/dist/core/createApp.d.ts +2 -2
  2. package/dist/core/createBlock.js +11 -25
  3. package/dist/core/createLayout.d.ts +1 -1
  4. package/dist/core/editing/BlockEditingRuntime.js +4 -4
  5. package/dist/core/editing/CompleteBlockEditingRuntime.js +5 -5
  6. package/dist/core/editing/createEditableBlock.js +169 -306
  7. package/dist/core/hooks/useIsEditable.js +4 -7
  8. package/dist/core/hooks/useRequireDraftSource.js +7 -11
  9. package/dist/features/preview/CamoxPreview.js +59 -80
  10. package/dist/features/preview/DerivedPreview.js +6 -9
  11. package/dist/features/preview/components/BlockActionsPopover.js +8 -8
  12. package/dist/features/preview/components/DerivedLayoutSidebar.js +4 -7
  13. package/dist/features/preview/components/LinkFieldEditor.js +3 -4
  14. package/dist/features/preview/components/MobilePreviewDrawer.js +3 -3
  15. package/dist/features/preview/components/Overlays.js +6 -9
  16. package/dist/features/preview/components/PageEditorSidebar.js +194 -203
  17. package/dist/features/preview/components/PageTree.js +162 -228
  18. package/dist/features/preview/components/PreviewPanel.js +39 -41
  19. package/dist/features/preview/components/PreviewToolbar.js +15 -18
  20. package/dist/features/preview/components/PreviewToolbarSpacer.js +43 -0
  21. package/dist/features/preview/components/PublicationRow.js +11 -17
  22. package/dist/features/preview/previewStore.js +18 -29
  23. package/dist/features/provider/useAdminShortcuts.js +5 -4
  24. package/dist/features/runtime/RuntimeChrome.js +98 -86
  25. package/dist/features/studio/components/UserButton.js +4 -4
  26. package/package.json +4 -4
  27. package/dist/features/preview/components/DraftSwitchDialog.js +0 -66
@@ -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(33);
16
+ if ($[0] !== "b6bc64556f010bff957a9ab8a6f788b2f582426a19b86427f9d0314970d7a4dc") {
17
+ for (let $i = 0; $i < 33; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
18
+ $[0] = "b6bc64556f010bff957a9ab8a6f788b2f582426a19b86427f9d0314970d7a4dc";
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,117 @@ 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];
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 = preview && !input.derived ? page?.page.status : void 0;
96
+ const t13 = !!page?.page.livePublishedCheckpointId;
92
97
  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
+ if ($[20] !== t12 || $[21] !== t13) {
99
+ t14 = /* @__PURE__ */ jsx(PreviewToolbar, {
100
+ pageStatus: t12,
101
+ hasLiveVersion: t13
98
102
  });
99
- $[18] = t10;
100
- $[19] = t13;
101
- $[20] = t9;
102
- $[21] = t14;
103
- } else t14 = $[21];
103
+ $[20] = t12;
104
+ $[21] = t13;
105
+ $[22] = t14;
106
+ } else t14 = $[22];
104
107
  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]
108
+ if ($[23] !== t10 || $[24] !== t11 || $[25] !== t14) {
109
+ t15 = /* @__PURE__ */ jsx("div", {
110
+ hidden: t10,
111
+ className: t11,
112
+ children: t14
109
113
  });
110
- $[22] = t14;
111
- $[23] = t8;
112
- $[24] = t15;
113
- } else t15 = $[24];
114
+ $[23] = t10;
115
+ $[24] = t11;
116
+ $[25] = t14;
117
+ $[26] = t15;
118
+ } else t15 = $[26];
114
119
  let t16;
115
- if ($[25] !== t15 || $[26] !== t7) {
116
- t16 = /* @__PURE__ */ jsxs(SharedChromeContext.Provider, {
120
+ if ($[27] !== t15 || $[28] !== t9) {
121
+ t16 = /* @__PURE__ */ jsxs("div", {
122
+ className: "relative flex min-h-0 flex-1 flex-col",
123
+ children: [t9, t15]
124
+ });
125
+ $[27] = t15;
126
+ $[28] = t9;
127
+ $[29] = t16;
128
+ } else t16 = $[29];
129
+ let t17;
130
+ if ($[30] !== t16 || $[31] !== t8) {
131
+ t17 = /* @__PURE__ */ jsxs(SharedChromeContext.Provider, {
117
132
  value: true,
118
- children: [t3, /* @__PURE__ */ jsxs("div", {
133
+ children: [t4, /* @__PURE__ */ jsxs("div", {
119
134
  className: "bg-background flex h-screen flex-col overflow-hidden",
120
- children: [t7, t15]
135
+ children: [t8, t16]
121
136
  })]
122
137
  });
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;
138
+ $[30] = t16;
139
+ $[31] = t8;
140
+ $[32] = t17;
141
+ } else t17 = $[32];
142
+ return t17;
131
143
  }
132
144
  function _temp(state) {
133
145
  return state.context.isToolbarHidden;
@@ -1,7 +1,7 @@
1
1
  import { useLocation, useNavigate } from "../../navigation/navigation.js";
2
2
  import { useAuthContext, useAuthState } from "../../../lib/auth.js";
3
3
  import { STUDIO_BASE_PATH } from "../routes.js";
4
- import { previewStore } from "../../preview/previewStore.js";
4
+ import { previewStore, selectIsEditMode } from "../../preview/previewStore.js";
5
5
  import { useApplyTheme } from "../useTheme.js";
6
6
  import { c } from "react/compiler-runtime";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -14,9 +14,9 @@ import { Avatar, AvatarFallback, AvatarImage } from "@camox/ui/avatar";
14
14
  //#region src/features/studio/components/UserButton.tsx
15
15
  const UserButton = () => {
16
16
  const $ = c(5);
17
- if ($[0] !== "a09d40e74ed3a5b0583d8899c9b1d3c569af18304db9c6f598775bf2c16e2608") {
17
+ if ($[0] !== "b876c985f56cb759905567177978ca8597789d0818f006e69fd4bcfb86c58f94") {
18
18
  for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
19
- $[0] = "a09d40e74ed3a5b0583d8899c9b1d3c569af18304db9c6f598775bf2c16e2608";
19
+ $[0] = "b876c985f56cb759905567177978ca8597789d0818f006e69fd4bcfb86c58f94";
20
20
  }
21
21
  const { isAuthenticated, isLoading } = useAuthState();
22
22
  const { theme, setTheme } = useApplyTheme();
@@ -48,7 +48,7 @@ function AuthenticatedUserButton({ theme, setTheme }) {
48
48
  const authCtx = useAuthContext();
49
49
  const { data: session } = authCtx.authClient.useSession();
50
50
  const authenticationUrl = authCtx.authenticationUrl;
51
- const isEditMode = useSelector(previewStore, (state) => state.context.isEditMode);
51
+ const isEditMode = useSelector(previewStore, selectIsEditMode);
52
52
  const { pathname } = useLocation();
53
53
  const navigate = useNavigate();
54
54
  const isPreviewPage = pathname !== STUDIO_BASE_PATH && !pathname.startsWith(`${STUDIO_BASE_PATH}/`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camox",
3
- "version": "0.41.0",
3
+ "version": "0.41.1",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "camox": "./bin/camox.mjs"
@@ -136,9 +136,9 @@
136
136
  "shiki": "^4.1.0",
137
137
  "unhead": "^3.1.7",
138
138
  "zod": "^4.4.3",
139
- "@camox/api-contract": "0.41.0",
140
- "@camox/cli": "0.41.0",
141
- "@camox/ui": "0.41.0"
139
+ "@camox/cli": "0.41.1",
140
+ "@camox/api-contract": "0.41.1",
141
+ "@camox/ui": "0.41.1"
142
142
  },
143
143
  "devDependencies": {
144
144
  "@babel/core": "^7.29.0",
@@ -1,66 +0,0 @@
1
- import { previewStore } from "../previewStore.js";
2
- import { c } from "react/compiler-runtime";
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- import { useSelector } from "@xstate/store-react";
5
- import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
6
-
7
- //#region src/features/preview/components/DraftSwitchDialog.tsx
8
- /**
9
- * Global confirmation that the user wants to leave a non-draft preview
10
- * before editing. The CTA only flips `previewSource` to `'draft'` — the
11
- * original edit attempt is intentionally NOT replayed; the user re-issues it
12
- * once back on draft. This keeps the action explicit and avoids "magical"
13
- * delayed edits the user might no longer want.
14
- */
15
- function DraftSwitchDialog() {
16
- const $ = c(5);
17
- if ($[0] !== "3be875184f6abab2ae16a64fbececa2389b1e6a2f4ea614823966b8277e4826b") {
18
- for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
19
- $[0] = "3be875184f6abab2ae16a64fbececa2389b1e6a2f4ea614823966b8277e4826b";
20
- }
21
- const open = useSelector(previewStore, _temp);
22
- let t0;
23
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
24
- t0 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Switch to draft to edit?" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "You're previewing the live version. Switch to the draft to make changes." })] });
25
- $[1] = t0;
26
- } else t0 = $[1];
27
- let t1;
28
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
29
- t1 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t0, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [/* @__PURE__ */ jsx(AlertDialogCancel, {
30
- variant: "outline",
31
- size: "default",
32
- children: "Cancel"
33
- }), /* @__PURE__ */ jsx(AlertDialogAction, {
34
- onClick: _temp3,
35
- children: "Switch to draft"
36
- })] })] });
37
- $[2] = t1;
38
- } else t1 = $[2];
39
- let t2;
40
- if ($[3] !== open) {
41
- t2 = /* @__PURE__ */ jsx(AlertDialog, {
42
- open,
43
- onOpenChange: _temp2,
44
- children: t1
45
- });
46
- $[3] = open;
47
- $[4] = t2;
48
- } else t2 = $[4];
49
- return t2;
50
- }
51
- function _temp3() {
52
- previewStore.send({
53
- type: "setPreviewSource",
54
- source: "draft"
55
- });
56
- previewStore.send({ type: "dismissDraftSwitch" });
57
- }
58
- function _temp2(next) {
59
- if (!next) previewStore.send({ type: "dismissDraftSwitch" });
60
- }
61
- function _temp(state) {
62
- return state.context.isDraftSwitchDialogOpen;
63
- }
64
-
65
- //#endregion
66
- export { DraftSwitchDialog };