camox 0.14.2 → 0.16.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 (75) hide show
  1. package/dist/components/AuthGate.js +6 -0
  2. package/dist/core/components/AddBlockControlBar.js +30 -26
  3. package/dist/core/components/lexical/InlineContentEditable.js +19 -15
  4. package/dist/core/components/lexical/InlineLexicalEditor.js +62 -42
  5. package/dist/core/components/lexical/SelectionBroadcaster.js +25 -21
  6. package/dist/core/components/lexical/SidebarLexicalEditor.js +33 -21
  7. package/dist/core/createBlock.js +524 -488
  8. package/dist/core/createLayout.js +40 -28
  9. package/dist/core/hooks/useFieldSelection.js +12 -8
  10. package/dist/core/hooks/useIsEditable.js +6 -0
  11. package/dist/core/hooks/useOverlayMessage.js +19 -15
  12. package/dist/core/lib/contentType.d.ts +8 -8
  13. package/dist/core/lib/contentType.js +63 -0
  14. package/dist/features/content/CamoxContent.js +92 -88
  15. package/dist/features/content/components/AssetCard.js +46 -42
  16. package/dist/features/content/components/AssetCardSkeleton.js +8 -4
  17. package/dist/features/content/components/ContentSidebar.js +8 -4
  18. package/dist/features/content/components/UploadDropZone.js +31 -27
  19. package/dist/features/content/components/UploadProgressDrawer.js +98 -90
  20. package/dist/features/preview/CamoxPreview.js +162 -146
  21. package/dist/features/preview/components/AddBlockSheet.js +105 -101
  22. package/dist/features/preview/components/AgentChatSheet.js +74 -21
  23. package/dist/features/preview/components/AssetFieldEditor.js +98 -90
  24. package/dist/features/preview/components/AssetLightbox.js +21 -17
  25. package/dist/features/preview/components/AssetPickerGrid.js +84 -80
  26. package/dist/features/preview/components/BlockActionsPopover.js +35 -31
  27. package/dist/features/preview/components/BlockErrorBoundary.js +12 -8
  28. package/dist/features/preview/components/CreatePageModal.js +1 -1
  29. package/dist/features/preview/components/DebouncedFieldEditor.js +41 -37
  30. package/dist/features/preview/components/EditPageModal.js +114 -98
  31. package/dist/features/preview/components/FieldOverlayStyles.js +8 -4
  32. package/dist/features/preview/components/FieldToolbar.js +95 -54
  33. package/dist/features/preview/components/Frame.js +50 -46
  34. package/dist/features/preview/components/ItemFieldsEditor.js +81 -79
  35. package/dist/features/preview/components/LinkFieldEditor.js +138 -134
  36. package/dist/features/preview/components/MultipleAssetFieldEditor.js +105 -97
  37. package/dist/features/preview/components/OverlayTracker.js +19 -15
  38. package/dist/features/preview/components/Overlays.js +27 -23
  39. package/dist/features/preview/components/PageContentSheet.js +54 -4
  40. package/dist/features/preview/components/PageLocationFieldset.js +113 -109
  41. package/dist/features/preview/components/PagePicker.js +1 -1
  42. package/dist/features/preview/components/PageTree.js +443 -399
  43. package/dist/features/preview/components/PeekedBlock.js +69 -65
  44. package/dist/features/preview/components/PreviewPanel.js +64 -52
  45. package/dist/features/preview/components/PreviewSideSheet.js +25 -16
  46. package/dist/features/preview/components/PreviewToolbar.js +127 -123
  47. package/dist/features/preview/components/RepeatableItemsList.js +176 -171
  48. package/dist/features/preview/components/ShikiMarkdown.js +18 -14
  49. package/dist/features/preview/components/UnlinkAssetButton.js +74 -70
  50. package/dist/features/preview/components/useRepeatableItemActions.js +266 -0
  51. package/dist/features/preview/components/useUpdateBlockPosition.js +13 -9
  52. package/dist/features/provider/CamoxProvider.js +60 -52
  53. package/dist/features/provider/components/CamoxAppContext.js +10 -6
  54. package/dist/features/provider/components/CommandPalette.js +77 -69
  55. package/dist/features/provider/useAdminShortcuts.js +11 -7
  56. package/dist/features/routes/pageRoute.js +8 -4
  57. package/dist/features/studio/CamoxStudio.js +23 -19
  58. package/dist/features/studio/components/EnvironmentMenu.js +32 -28
  59. package/dist/features/studio/components/Navbar.js +62 -54
  60. package/dist/features/studio/components/ProjectMenu.js +131 -123
  61. package/dist/features/studio/components/UserButton.js +15 -11
  62. package/dist/features/studio/useTheme.js +82 -42
  63. package/dist/features/vite/definitionsSync.js +5 -5
  64. package/dist/features/vite/skillGeneration.js +43 -8
  65. package/dist/features/vite/vite.d.ts +1 -1
  66. package/dist/features/vite/vite.js +20 -2
  67. package/dist/hooks/use-marquee-selection.js +36 -32
  68. package/dist/lib/auth.js +49 -22
  69. package/dist/lib/normalized-data.js +55 -47
  70. package/dist/lib/use-project-room.js +22 -18
  71. package/dist/studio.css +1 -1
  72. package/package.json +10 -11
  73. package/skills/camox-block/SKILL.md +4 -0
  74. package/skills/camox-cli/SKILL.md +142 -0
  75. package/skills/camox-layout/SKILL.md +4 -0
@@ -12,39 +12,43 @@ import { Skeleton } from "@camox/ui/skeleton";
12
12
 
13
13
  //#region src/features/studio/components/ProjectMenu.tsx
14
14
  const Favicon = (t0) => {
15
- const $ = c(18);
15
+ const $ = c(19);
16
+ if ($[0] !== "40bfae178d4420104da32b869316c5a2f7a1b383b1d8724af7281134abe451e3") {
17
+ for (let $i = 0; $i < 19; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
18
+ $[0] = "40bfae178d4420104da32b869316c5a2f7a1b383b1d8724af7281134abe451e3";
19
+ }
16
20
  const { size: t1 } = t0;
17
21
  const size = t1 === void 0 ? 16 : t1;
18
22
  const [faviconUrl, setFaviconUrl] = React.useState(null);
19
23
  const [hasError, setHasError] = React.useState(false);
20
24
  let t2;
21
25
  let t3;
22
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
26
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
23
27
  t2 = () => {
24
28
  setFaviconUrl(_temp());
25
29
  };
26
30
  t3 = [];
27
- $[0] = t2;
28
- $[1] = t3;
31
+ $[1] = t2;
32
+ $[2] = t3;
29
33
  } else {
30
- t2 = $[0];
31
- t3 = $[1];
34
+ t2 = $[1];
35
+ t3 = $[2];
32
36
  }
33
37
  React.useEffect(t2, t3);
34
38
  if (!faviconUrl || hasError) {
35
39
  let t4;
36
- if ($[2] !== size) {
40
+ if ($[3] !== size) {
37
41
  t4 = {
38
42
  height: size,
39
43
  width: size
40
44
  };
41
- $[2] = size;
42
- $[3] = t4;
43
- } else t4 = $[3];
45
+ $[3] = size;
46
+ $[4] = t4;
47
+ } else t4 = $[4];
44
48
  const t5 = size * .6;
45
49
  const t6 = size * .6;
46
50
  let t7;
47
- if ($[4] !== t5 || $[5] !== t6) {
51
+ if ($[5] !== t5 || $[6] !== t6) {
48
52
  t7 = /* @__PURE__ */ jsx(Globe, {
49
53
  className: "text-muted-foreground",
50
54
  style: {
@@ -52,94 +56,98 @@ const Favicon = (t0) => {
52
56
  width: t6
53
57
  }
54
58
  });
55
- $[4] = t5;
56
- $[5] = t6;
57
- $[6] = t7;
58
- } else t7 = $[6];
59
+ $[5] = t5;
60
+ $[6] = t6;
61
+ $[7] = t7;
62
+ } else t7 = $[7];
59
63
  let t8;
60
- if ($[7] !== t4 || $[8] !== t7) {
64
+ if ($[8] !== t4 || $[9] !== t7) {
61
65
  t8 = /* @__PURE__ */ jsx("div", {
62
66
  className: "bg-muted flex items-center justify-center rounded-full",
63
67
  style: t4,
64
68
  children: t7
65
69
  });
66
- $[7] = t4;
67
- $[8] = t7;
68
- $[9] = t8;
69
- } else t8 = $[9];
70
+ $[8] = t4;
71
+ $[9] = t7;
72
+ $[10] = t8;
73
+ } else t8 = $[10];
70
74
  return t8;
71
75
  }
72
76
  let t4;
73
- if ($[10] !== size) {
77
+ if ($[11] !== size) {
74
78
  t4 = {
75
79
  height: size,
76
80
  width: size
77
81
  };
78
- $[10] = size;
79
- $[11] = t4;
80
- } else t4 = $[11];
82
+ $[11] = size;
83
+ $[12] = t4;
84
+ } else t4 = $[12];
81
85
  let t5;
82
- if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
86
+ if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
83
87
  t5 = () => setHasError(true);
84
- $[12] = t5;
85
- } else t5 = $[12];
88
+ $[13] = t5;
89
+ } else t5 = $[13];
86
90
  let t6;
87
- if ($[13] !== faviconUrl) {
91
+ if ($[14] !== faviconUrl) {
88
92
  t6 = /* @__PURE__ */ jsx("img", {
89
93
  src: faviconUrl,
90
94
  alt: "Favicon",
91
95
  className: "h-full w-full object-cover",
92
96
  onError: t5
93
97
  });
94
- $[13] = faviconUrl;
95
- $[14] = t6;
96
- } else t6 = $[14];
98
+ $[14] = faviconUrl;
99
+ $[15] = t6;
100
+ } else t6 = $[15];
97
101
  let t7;
98
- if ($[15] !== t4 || $[16] !== t6) {
102
+ if ($[16] !== t4 || $[17] !== t6) {
99
103
  t7 = /* @__PURE__ */ jsx("div", {
100
104
  className: "bg-muted flex items-center justify-center overflow-hidden rounded-full",
101
105
  style: t4,
102
106
  children: t6
103
107
  });
104
- $[15] = t4;
105
- $[16] = t6;
106
- $[17] = t7;
107
- } else t7 = $[17];
108
+ $[16] = t4;
109
+ $[17] = t6;
110
+ $[18] = t7;
111
+ } else t7 = $[18];
108
112
  return t7;
109
113
  };
110
114
  const ProjectMenu = () => {
111
- const $ = c(40);
115
+ const $ = c(41);
116
+ if ($[0] !== "40bfae178d4420104da32b869316c5a2f7a1b383b1d8724af7281134abe451e3") {
117
+ for (let $i = 0; $i < 41; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
118
+ $[0] = "40bfae178d4420104da32b869316c5a2f7a1b383b1d8724af7281134abe451e3";
119
+ }
112
120
  const authCtx = React.useContext(AuthContext);
113
121
  let t0;
114
- if ($[0] !== authCtx.projectSlug) {
122
+ if ($[1] !== authCtx.projectSlug) {
115
123
  t0 = projectQueries.getBySlug(authCtx.projectSlug);
116
- $[0] = authCtx.projectSlug;
117
- $[1] = t0;
118
- } else t0 = $[1];
124
+ $[1] = authCtx.projectSlug;
125
+ $[2] = t0;
126
+ } else t0 = $[2];
119
127
  const { data: project } = useQuery(t0);
120
128
  if (!project) {
121
129
  let t1;
122
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
130
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
123
131
  t1 = /* @__PURE__ */ jsxs("div", {
124
132
  className: "flex h-9 min-w-[150px] items-center gap-2 px-4",
125
133
  children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-4 rounded-full" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-3 flex-1" })]
126
134
  });
127
- $[2] = t1;
128
- } else t1 = $[2];
135
+ $[3] = t1;
136
+ } else t1 = $[3];
129
137
  return t1;
130
138
  }
131
139
  let t1;
132
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
140
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
133
141
  t1 = /* @__PURE__ */ jsx(Button, { variant: "ghost" });
134
- $[3] = t1;
135
- } else t1 = $[3];
142
+ $[4] = t1;
143
+ } else t1 = $[4];
136
144
  let t2;
137
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
145
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
138
146
  t2 = /* @__PURE__ */ jsx(Favicon, { size: 16 });
139
- $[4] = t2;
140
- } else t2 = $[4];
147
+ $[5] = t2;
148
+ } else t2 = $[5];
141
149
  let t3;
142
- if ($[5] !== project.name) {
150
+ if ($[6] !== project.name) {
143
151
  t3 = /* @__PURE__ */ jsxs("div", {
144
152
  className: "flex items-center gap-2",
145
153
  children: [t2, /* @__PURE__ */ jsx("span", {
@@ -147,131 +155,131 @@ const ProjectMenu = () => {
147
155
  children: project.name
148
156
  })]
149
157
  });
150
- $[5] = project.name;
151
- $[6] = t3;
152
- } else t3 = $[6];
158
+ $[6] = project.name;
159
+ $[7] = t3;
160
+ } else t3 = $[7];
153
161
  let t4;
154
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
162
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
155
163
  t4 = /* @__PURE__ */ jsx(ChevronDown, { className: "shrink-0 opacity-50" });
156
- $[7] = t4;
157
- } else t4 = $[7];
164
+ $[8] = t4;
165
+ } else t4 = $[8];
158
166
  let t5;
159
- if ($[8] !== t3) {
167
+ if ($[9] !== t3) {
160
168
  t5 = /* @__PURE__ */ jsxs(DropdownMenuTrigger, {
161
169
  render: t1,
162
170
  children: [t3, t4]
163
171
  });
164
- $[8] = t3;
165
- $[9] = t5;
166
- } else t5 = $[9];
172
+ $[9] = t3;
173
+ $[10] = t5;
174
+ } else t5 = $[10];
167
175
  const t6 = authCtx ? `${authCtx.authenticationUrl}/dashboard/${project.organizationSlug}/${project.slug}/overview` : "#";
168
176
  let t7;
169
- if ($[10] !== t6) {
177
+ if ($[11] !== t6) {
170
178
  t7 = /* @__PURE__ */ jsx("a", {
171
179
  href: t6,
172
180
  target: "_blank",
173
181
  rel: "noopener noreferrer"
174
182
  });
175
- $[10] = t6;
176
- $[11] = t7;
177
- } else t7 = $[11];
183
+ $[11] = t6;
184
+ $[12] = t7;
185
+ } else t7 = $[12];
178
186
  let t8;
179
- if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
187
+ if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
180
188
  t8 = /* @__PURE__ */ jsx(Settings, {});
181
- $[12] = t8;
182
- } else t8 = $[12];
189
+ $[13] = t8;
190
+ } else t8 = $[13];
183
191
  let t9;
184
- if ($[13] !== t7) {
192
+ if ($[14] !== t7) {
185
193
  t9 = /* @__PURE__ */ jsxs(DropdownMenuItem, {
186
194
  render: t7,
187
195
  children: [t8, "Project settings"]
188
196
  });
189
- $[13] = t7;
190
- $[14] = t9;
191
- } else t9 = $[14];
197
+ $[14] = t7;
198
+ $[15] = t9;
199
+ } else t9 = $[15];
192
200
  let t10;
193
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
201
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
194
202
  t10 = /* @__PURE__ */ jsx(DropdownMenuSeparator, {});
195
- $[15] = t10;
196
- } else t10 = $[15];
203
+ $[16] = t10;
204
+ } else t10 = $[16];
197
205
  let t11;
198
- if ($[16] !== project.organizationSlug) {
206
+ if ($[17] !== project.organizationSlug) {
199
207
  t11 = /* @__PURE__ */ jsx(DropdownMenuLabel, {
200
208
  className: "text-muted-foreground text-xs font-normal",
201
209
  children: project.organizationSlug
202
210
  });
203
- $[16] = project.organizationSlug;
204
- $[17] = t11;
205
- } else t11 = $[17];
211
+ $[17] = project.organizationSlug;
212
+ $[18] = t11;
213
+ } else t11 = $[18];
206
214
  const t12 = authCtx ? `${authCtx.authenticationUrl}/dashboard/${project.organizationSlug}/team` : "#";
207
215
  let t13;
208
- if ($[18] !== t12) {
216
+ if ($[19] !== t12) {
209
217
  t13 = /* @__PURE__ */ jsx("a", {
210
218
  href: t12,
211
219
  target: "_blank",
212
220
  rel: "noopener noreferrer"
213
221
  });
214
- $[18] = t12;
215
- $[19] = t13;
216
- } else t13 = $[19];
222
+ $[19] = t12;
223
+ $[20] = t13;
224
+ } else t13 = $[20];
217
225
  let t14;
218
- if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
226
+ if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
219
227
  t14 = /* @__PURE__ */ jsx(Users, {});
220
- $[20] = t14;
221
- } else t14 = $[20];
228
+ $[21] = t14;
229
+ } else t14 = $[21];
222
230
  let t15;
223
- if ($[21] !== t13) {
231
+ if ($[22] !== t13) {
224
232
  t15 = /* @__PURE__ */ jsxs(DropdownMenuItem, {
225
233
  render: t13,
226
234
  children: [t14, "Team members"]
227
235
  });
228
- $[21] = t13;
229
- $[22] = t15;
230
- } else t15 = $[22];
236
+ $[22] = t13;
237
+ $[23] = t15;
238
+ } else t15 = $[23];
231
239
  const t16 = authCtx ? `${authCtx.authenticationUrl}/dashboard/${project.organizationSlug}/settings` : "#";
232
240
  let t17;
233
- if ($[23] !== t16) {
241
+ if ($[24] !== t16) {
234
242
  t17 = /* @__PURE__ */ jsx("a", {
235
243
  href: t16,
236
244
  target: "_blank",
237
245
  rel: "noopener noreferrer"
238
246
  });
239
- $[23] = t16;
240
- $[24] = t17;
241
- } else t17 = $[24];
247
+ $[24] = t16;
248
+ $[25] = t17;
249
+ } else t17 = $[25];
242
250
  let t18;
243
- if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
251
+ if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
244
252
  t18 = /* @__PURE__ */ jsx(Settings, { className: "h-4 w-4" });
245
- $[25] = t18;
246
- } else t18 = $[25];
253
+ $[26] = t18;
254
+ } else t18 = $[26];
247
255
  let t19;
248
- if ($[26] !== t17) {
256
+ if ($[27] !== t17) {
249
257
  t19 = /* @__PURE__ */ jsxs(DropdownMenuItem, {
250
258
  render: t17,
251
259
  children: [t18, "Team settings"]
252
260
  });
253
- $[26] = t17;
254
- $[27] = t19;
255
- } else t19 = $[27];
261
+ $[27] = t17;
262
+ $[28] = t19;
263
+ } else t19 = $[28];
256
264
  let t20;
257
- if ($[28] !== t11 || $[29] !== t15 || $[30] !== t19) {
265
+ if ($[29] !== t11 || $[30] !== t15 || $[31] !== t19) {
258
266
  t20 = /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
259
267
  t11,
260
268
  t15,
261
269
  t19
262
270
  ] });
263
- $[28] = t11;
264
- $[29] = t15;
265
- $[30] = t19;
266
- $[31] = t20;
267
- } else t20 = $[31];
271
+ $[29] = t11;
272
+ $[30] = t15;
273
+ $[31] = t19;
274
+ $[32] = t20;
275
+ } else t20 = $[32];
268
276
  let t21;
269
- if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
277
+ if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
270
278
  t21 = /* @__PURE__ */ jsx(DropdownMenuSeparator, {});
271
- $[32] = t21;
272
- } else t21 = $[32];
279
+ $[33] = t21;
280
+ } else t21 = $[33];
273
281
  let t22;
274
- if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
282
+ if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
275
283
  t22 = /* @__PURE__ */ jsxs(DropdownMenuItem, {
276
284
  render: /* @__PURE__ */ jsx(Link, {
277
285
  to: "https://camox.ai",
@@ -279,10 +287,10 @@ const ProjectMenu = () => {
279
287
  }),
280
288
  children: [/* @__PURE__ */ jsx(Info, { className: "h-4 w-4" }), "Powered by Camox"]
281
289
  });
282
- $[33] = t22;
283
- } else t22 = $[33];
290
+ $[34] = t22;
291
+ } else t22 = $[34];
284
292
  let t23;
285
- if ($[34] !== t20 || $[35] !== t9) {
293
+ if ($[35] !== t20 || $[36] !== t9) {
286
294
  t23 = /* @__PURE__ */ jsxs(DropdownMenuContent, {
287
295
  className: "w-72",
288
296
  align: "start",
@@ -295,17 +303,17 @@ const ProjectMenu = () => {
295
303
  t22
296
304
  ]
297
305
  });
298
- $[34] = t20;
299
- $[35] = t9;
300
- $[36] = t23;
301
- } else t23 = $[36];
306
+ $[35] = t20;
307
+ $[36] = t9;
308
+ $[37] = t23;
309
+ } else t23 = $[37];
302
310
  let t24;
303
- if ($[37] !== t23 || $[38] !== t5) {
311
+ if ($[38] !== t23 || $[39] !== t5) {
304
312
  t24 = /* @__PURE__ */ jsxs(DropdownMenu, { children: [t5, t23] });
305
- $[37] = t23;
306
- $[38] = t5;
307
- $[39] = t24;
308
- } else t24 = $[39];
313
+ $[38] = t23;
314
+ $[39] = t5;
315
+ $[40] = t24;
316
+ } else t24 = $[40];
309
317
  return t24;
310
318
  };
311
319
  function _temp() {
@@ -1,5 +1,5 @@
1
1
  import { useAuthContext, useAuthState } from "../../../lib/auth.js";
2
- import { useTheme } from "../useTheme.js";
2
+ import { useApplyTheme } from "../useTheme.js";
3
3
  import { c } from "react/compiler-runtime";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { Button } from "@camox/ui/button";
@@ -9,31 +9,35 @@ import { Avatar, AvatarFallback, AvatarImage } from "@camox/ui/avatar";
9
9
 
10
10
  //#region src/features/studio/components/UserButton.tsx
11
11
  const UserButton = () => {
12
- const $ = c(4);
12
+ const $ = c(5);
13
+ if ($[0] !== "97ed2ef8d3be381ca1619f023223f59b7d963b94f2c1afa998b161358220d4af") {
14
+ for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
15
+ $[0] = "97ed2ef8d3be381ca1619f023223f59b7d963b94f2c1afa998b161358220d4af";
16
+ }
13
17
  const { isAuthenticated, isLoading } = useAuthState();
14
- const { theme, setTheme } = useTheme();
18
+ const { theme, setTheme } = useApplyTheme();
15
19
  if (!isAuthenticated || isLoading) {
16
20
  let t0;
17
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
21
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
18
22
  t0 = /* @__PURE__ */ jsx(Button, {
19
23
  variant: "outline",
20
24
  size: "icon",
21
25
  children: /* @__PURE__ */ jsx(User, { className: "h-4 w-4" })
22
26
  });
23
- $[0] = t0;
24
- } else t0 = $[0];
27
+ $[1] = t0;
28
+ } else t0 = $[1];
25
29
  return t0;
26
30
  }
27
31
  let t0;
28
- if ($[1] !== setTheme || $[2] !== theme) {
32
+ if ($[2] !== setTheme || $[3] !== theme) {
29
33
  t0 = /* @__PURE__ */ jsx(AuthenticatedUserButton, {
30
34
  theme,
31
35
  setTheme
32
36
  });
33
- $[1] = setTheme;
34
- $[2] = theme;
35
- $[3] = t0;
36
- } else t0 = $[3];
37
+ $[2] = setTheme;
38
+ $[3] = theme;
39
+ $[4] = t0;
40
+ } else t0 = $[4];
37
41
  return t0;
38
42
  };
39
43
  function AuthenticatedUserButton({ theme, setTheme }) {
@@ -3,13 +3,47 @@ import { c } from "react/compiler-runtime";
3
3
  import * as React from "react";
4
4
 
5
5
  //#region src/features/studio/useTheme.ts
6
- function useTheme() {
7
- const $ = c(8);
8
- const [theme, setTheme] = React.useState(_temp);
9
- const applyTheme = _temp2;
6
+ function readStoredTheme() {
7
+ if (typeof window === "undefined") return "system";
8
+ return localStorage.getItem("theme") || "system";
9
+ }
10
+ /**
11
+ * Read-only access to the studio theme. Does not mutate `<html>` or localStorage.
12
+ * Use this when you need the current theme value (e.g. to pass to a Toaster) but
13
+ * are not the owner of the studio chrome — applying the theme would bleed onto
14
+ * the host site.
15
+ */
16
+ function useThemeValue() {
17
+ const $ = c(3);
18
+ if ($[0] !== "ae0cc1c225b74076fa89c4e5926593d41740805053ad02469bbe3a3cacd4b93a") {
19
+ for (let $i = 0; $i < 3; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
20
+ $[0] = "ae0cc1c225b74076fa89c4e5926593d41740805053ad02469bbe3a3cacd4b93a";
21
+ }
22
+ const [theme] = React.useState(readStoredTheme);
23
+ let t0;
24
+ if ($[1] !== theme) {
25
+ t0 = { theme };
26
+ $[1] = theme;
27
+ $[2] = t0;
28
+ } else t0 = $[2];
29
+ return t0;
30
+ }
31
+ /**
32
+ * Owns the studio theme: writes the active class onto `<html>` and persists
33
+ * changes to localStorage. Should only be mounted from the studio chrome —
34
+ * never from contexts that share `<html>` with the user's site.
35
+ */
36
+ function useApplyTheme() {
37
+ const $ = c(9);
38
+ if ($[0] !== "ae0cc1c225b74076fa89c4e5926593d41740805053ad02469bbe3a3cacd4b93a") {
39
+ for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
40
+ $[0] = "ae0cc1c225b74076fa89c4e5926593d41740805053ad02469bbe3a3cacd4b93a";
41
+ }
42
+ const [theme, setTheme] = React.useState(readStoredTheme);
43
+ const applyTheme = _temp;
10
44
  let t0;
11
45
  let t1;
12
- if ($[0] !== theme) {
46
+ if ($[1] !== theme) {
13
47
  t0 = () => {
14
48
  const root_0 = window.document.documentElement;
15
49
  root_0.classList.remove("light", "dark");
@@ -20,69 +54,75 @@ function useTheme() {
20
54
  };
21
55
  updateSystemTheme();
22
56
  mediaQuery.addEventListener("change", updateSystemTheme);
23
- return () => mediaQuery.removeEventListener("change", updateSystemTheme);
57
+ return () => {
58
+ mediaQuery.removeEventListener("change", updateSystemTheme);
59
+ root_0.classList.remove("light", "dark");
60
+ };
24
61
  }
25
62
  root_0.classList.add(theme);
63
+ return () => {
64
+ root_0.classList.remove("light", "dark");
65
+ };
26
66
  };
27
67
  t1 = [theme];
28
- $[0] = theme;
29
- $[1] = t0;
30
- $[2] = t1;
68
+ $[1] = theme;
69
+ $[2] = t0;
70
+ $[3] = t1;
31
71
  } else {
32
- t0 = $[1];
33
- t1 = $[2];
72
+ t0 = $[2];
73
+ t1 = $[3];
34
74
  }
35
75
  React.useEffect(t0, t1);
36
76
  let t2;
37
77
  let t3;
38
- if ($[3] !== theme) {
78
+ if ($[4] !== theme) {
39
79
  t2 = () => {
40
80
  localStorage.setItem("theme", theme);
41
81
  };
42
82
  t3 = [theme];
43
- $[3] = theme;
44
- $[4] = t2;
45
- $[5] = t3;
83
+ $[4] = theme;
84
+ $[5] = t2;
85
+ $[6] = t3;
46
86
  } else {
47
- t2 = $[4];
48
- t3 = $[5];
87
+ t2 = $[5];
88
+ t3 = $[6];
49
89
  }
50
90
  React.useEffect(t2, t3);
51
91
  let t4;
52
- if ($[6] !== theme) {
92
+ if ($[7] !== theme) {
53
93
  t4 = {
54
94
  theme,
55
95
  setTheme
56
96
  };
57
- $[6] = theme;
58
- $[7] = t4;
59
- } else t4 = $[7];
97
+ $[7] = theme;
98
+ $[8] = t4;
99
+ } else t4 = $[8];
60
100
  return t4;
61
101
  }
62
- function _temp2(themeToApply) {
102
+ function _temp(themeToApply) {
63
103
  const root = window.document.documentElement;
64
104
  root.classList.remove("light", "dark");
65
105
  root.classList.add(themeToApply);
66
106
  }
67
- function _temp() {
68
- if (typeof window !== "undefined") return localStorage.getItem("theme") || "system";
69
- return "system";
70
- }
71
107
  function useThemeActions() {
72
- const $ = c(4);
73
- const { theme, setTheme } = useTheme();
108
+ const $ = c(5);
109
+ if ($[0] !== "ae0cc1c225b74076fa89c4e5926593d41740805053ad02469bbe3a3cacd4b93a") {
110
+ for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
111
+ $[0] = "ae0cc1c225b74076fa89c4e5926593d41740805053ad02469bbe3a3cacd4b93a";
112
+ }
113
+ const { theme, setTheme } = useApplyTheme();
74
114
  let t0;
75
115
  let t1;
76
- if ($[0] !== setTheme || $[1] !== theme) {
116
+ if ($[1] !== setTheme || $[2] !== theme) {
77
117
  t0 = () => {
78
118
  const actions = [
79
119
  {
80
120
  id: "change-theme",
81
121
  label: "Change theme",
82
122
  groupLabel: "Studio",
83
- checkIfAvailable: _temp3,
123
+ checkIfAvailable: _temp2,
84
124
  hasChildren: true,
85
- execute: _temp4
125
+ execute: _temp3
86
126
  },
87
127
  {
88
128
  id: "switch-to-light-theme",
@@ -116,28 +156,28 @@ function useThemeActions() {
116
156
  return () => {
117
157
  actionsStore.send({
118
158
  type: "unregisterManyActions",
119
- ids: actions.map(_temp5)
159
+ ids: actions.map(_temp4)
120
160
  });
121
161
  };
122
162
  };
123
163
  t1 = [theme, setTheme];
124
- $[0] = setTheme;
125
- $[1] = theme;
126
- $[2] = t0;
127
- $[3] = t1;
164
+ $[1] = setTheme;
165
+ $[2] = theme;
166
+ $[3] = t0;
167
+ $[4] = t1;
128
168
  } else {
129
- t0 = $[2];
130
- t1 = $[3];
169
+ t0 = $[3];
170
+ t1 = $[4];
131
171
  }
132
172
  React.useEffect(t0, t1);
133
173
  }
134
- function _temp5(a) {
174
+ function _temp4(a) {
135
175
  return a.id;
136
176
  }
137
- function _temp4() {}
138
- function _temp3() {
177
+ function _temp3() {}
178
+ function _temp2() {
139
179
  return true;
140
180
  }
141
181
 
142
182
  //#endregion
143
- export { useTheme, useThemeActions };
183
+ export { useApplyTheme, useThemeActions, useThemeValue };