camox 0.3.0 → 0.4.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 (76) 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.d.ts.map +1 -1
  58. package/dist/features/studio/components/ProjectMenu.js +284 -83
  59. package/dist/features/studio/components/UserButton.js +21 -6
  60. package/dist/features/studio/studioStore.d.ts +2 -2
  61. package/dist/features/studio/useTheme.js +128 -74
  62. package/dist/features/vite/definitionsSync.d.ts +7 -12
  63. package/dist/features/vite/definitionsSync.d.ts.map +1 -1
  64. package/dist/features/vite/definitionsSync.js +5 -16
  65. package/dist/features/vite/vite.d.ts +0 -3
  66. package/dist/features/vite/vite.d.ts.map +1 -1
  67. package/dist/features/vite/vite.js +1 -2
  68. package/dist/hooks/use-file-upload.js +11 -11
  69. package/dist/hooks/use-marquee-selection.js +121 -74
  70. package/dist/lib/auth.js +95 -51
  71. package/dist/lib/normalized-data.js +103 -30
  72. package/dist/lib/use-project-room.js +55 -22
  73. package/dist/studio.css +2 -2
  74. package/package.json +29 -26
  75. package/dist/lib/auth.d.ts +0 -2130
  76. package/dist/lib/auth.d.ts.map +0 -1
@@ -1,107 +1,308 @@
1
1
  import { AuthContext } from "../../../lib/auth.js";
2
2
  import { projectQueries } from "../../../lib/queries.js";
3
+ import { c } from "react/compiler-runtime";
3
4
  import { useQuery } from "@tanstack/react-query";
4
5
  import * as React from "react";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
7
  import { Button } from "@camox/ui/button";
7
- import { ChevronDown, Globe, Settings, Users } from "lucide-react";
8
+ import { Link } from "@tanstack/react-router";
9
+ import { ChevronDown, Globe, Info, Settings, Users } from "lucide-react";
8
10
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "@camox/ui/dropdown-menu";
9
11
  import { Skeleton } from "@camox/ui/skeleton";
10
12
  //#region src/features/studio/components/ProjectMenu.tsx
11
- var Favicon = ({ size = 16 }) => {
13
+ var Favicon = (t0) => {
14
+ const $ = c(18);
15
+ const { size: t1 } = t0;
16
+ const size = t1 === void 0 ? 16 : t1;
12
17
  const [faviconUrl, setFaviconUrl] = React.useState(null);
13
18
  const [hasError, setHasError] = React.useState(false);
14
- React.useEffect(() => {
15
- const getFaviconUrl = () => {
16
- for (const selector of [
17
- "link[rel=\"icon\"]",
18
- "link[rel=\"shortcut icon\"]",
19
- "link[rel=\"apple-touch-icon\"]"
20
- ]) {
21
- const link = document.querySelector(selector);
22
- if (link?.href) return link.href;
23
- }
24
- return null;
19
+ let t2;
20
+ let t3;
21
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
22
+ t2 = () => {
23
+ setFaviconUrl(_temp());
25
24
  };
26
- setFaviconUrl(getFaviconUrl());
27
- }, []);
28
- if (!faviconUrl || hasError) return /* @__PURE__ */ jsx("div", {
29
- className: "bg-muted flex items-center justify-center rounded-full",
30
- style: {
25
+ t3 = [];
26
+ $[0] = t2;
27
+ $[1] = t3;
28
+ } else {
29
+ t2 = $[0];
30
+ t3 = $[1];
31
+ }
32
+ React.useEffect(t2, t3);
33
+ if (!faviconUrl || hasError) {
34
+ let t4;
35
+ if ($[2] !== size) {
36
+ t4 = {
37
+ height: size,
38
+ width: size
39
+ };
40
+ $[2] = size;
41
+ $[3] = t4;
42
+ } else t4 = $[3];
43
+ const t5 = size * .6;
44
+ const t6 = size * .6;
45
+ let t7;
46
+ if ($[4] !== t5 || $[5] !== t6) {
47
+ t7 = /* @__PURE__ */ jsx(Globe, {
48
+ className: "text-muted-foreground",
49
+ style: {
50
+ height: t5,
51
+ width: t6
52
+ }
53
+ });
54
+ $[4] = t5;
55
+ $[5] = t6;
56
+ $[6] = t7;
57
+ } else t7 = $[6];
58
+ let t8;
59
+ if ($[7] !== t4 || $[8] !== t7) {
60
+ t8 = /* @__PURE__ */ jsx("div", {
61
+ className: "bg-muted flex items-center justify-center rounded-full",
62
+ style: t4,
63
+ children: t7
64
+ });
65
+ $[7] = t4;
66
+ $[8] = t7;
67
+ $[9] = t8;
68
+ } else t8 = $[9];
69
+ return t8;
70
+ }
71
+ let t4;
72
+ if ($[10] !== size) {
73
+ t4 = {
31
74
  height: size,
32
75
  width: size
33
- },
34
- children: /* @__PURE__ */ jsx(Globe, {
35
- className: "text-muted-foreground",
36
- style: {
37
- height: size * .6,
38
- width: size * .6
39
- }
40
- })
41
- });
42
- return /* @__PURE__ */ jsx("div", {
43
- className: "bg-muted flex items-center justify-center overflow-hidden rounded-full",
44
- style: {
45
- height: size,
46
- width: size
47
- },
48
- children: /* @__PURE__ */ jsx("img", {
76
+ };
77
+ $[10] = size;
78
+ $[11] = t4;
79
+ } else t4 = $[11];
80
+ let t5;
81
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
82
+ t5 = () => setHasError(true);
83
+ $[12] = t5;
84
+ } else t5 = $[12];
85
+ let t6;
86
+ if ($[13] !== faviconUrl) {
87
+ t6 = /* @__PURE__ */ jsx("img", {
49
88
  src: faviconUrl,
50
89
  alt: "Favicon",
51
90
  className: "h-full w-full object-cover",
52
- onError: () => setHasError(true)
53
- })
54
- });
91
+ onError: t5
92
+ });
93
+ $[13] = faviconUrl;
94
+ $[14] = t6;
95
+ } else t6 = $[14];
96
+ let t7;
97
+ if ($[15] !== t4 || $[16] !== t6) {
98
+ t7 = /* @__PURE__ */ jsx("div", {
99
+ className: "bg-muted flex items-center justify-center overflow-hidden rounded-full",
100
+ style: t4,
101
+ children: t6
102
+ });
103
+ $[15] = t4;
104
+ $[16] = t6;
105
+ $[17] = t7;
106
+ } else t7 = $[17];
107
+ return t7;
55
108
  };
56
109
  var ProjectMenu = () => {
110
+ const $ = c(41);
57
111
  const authCtx = React.useContext(AuthContext);
58
- const { data: project } = useQuery(projectQueries.getBySlug(authCtx.projectSlug));
59
- if (!project) return /* @__PURE__ */ jsxs("div", {
60
- className: "flex h-9 min-w-[150px] items-center gap-2 px-4",
61
- children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-4 rounded-full" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-3 flex-1" })]
62
- });
63
- return /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
64
- asChild: true,
65
- children: /* @__PURE__ */ jsxs(Button, {
66
- variant: "ghost",
67
- children: [/* @__PURE__ */ jsxs("div", {
68
- className: "flex items-center gap-2",
69
- children: [/* @__PURE__ */ jsx(Favicon, { size: 16 }), /* @__PURE__ */ jsx("span", {
70
- className: "select-none",
71
- children: project.name
72
- })]
73
- }), /* @__PURE__ */ jsx(ChevronDown, { className: "ml-1 h-4 w-4 shrink-0 opacity-50" })]
74
- })
75
- }), /* @__PURE__ */ jsxs(DropdownMenuContent, {
76
- className: "w-72",
77
- align: "start",
78
- side: "bottom",
79
- children: [
80
- /* @__PURE__ */ jsxs(DropdownMenuItem, {
81
- onSelect: () => {
82
- if (authCtx) window.open(`${authCtx.authenticationUrl}/dashboard/${project.organizationSlug}/${project.slug}/overview`, "_blank");
83
- },
84
- children: [/* @__PURE__ */ jsx(Settings, { className: "mr-2 h-4 w-4" }), "Project settings"]
85
- }),
86
- /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
87
- /* @__PURE__ */ jsx(DropdownMenuLabel, {
88
- className: "text-muted-foreground text-xs font-normal",
89
- children: project.organizationSlug
90
- }),
91
- /* @__PURE__ */ jsxs(DropdownMenuItem, {
92
- onSelect: () => {
93
- if (authCtx) window.open(`${authCtx.authenticationUrl}/dashboard/${project.organizationSlug}/team?tab=members`, "_blank");
94
- },
95
- children: [/* @__PURE__ */ jsx(Users, { className: "mr-2 h-4 w-4" }), "Team members"]
96
- }),
97
- /* @__PURE__ */ jsxs(DropdownMenuItem, {
98
- onSelect: () => {
99
- if (authCtx) window.open(`${authCtx.authenticationUrl}/dashboard/${project.organizationSlug}/team?tab=settings`, "_blank");
100
- },
101
- children: [/* @__PURE__ */ jsx(Settings, { className: "mr-2 h-4 w-4" }), "Team settings"]
112
+ let t0;
113
+ if ($[0] !== authCtx.projectSlug) {
114
+ t0 = projectQueries.getBySlug(authCtx.projectSlug);
115
+ $[0] = authCtx.projectSlug;
116
+ $[1] = t0;
117
+ } else t0 = $[1];
118
+ const { data: project } = useQuery(t0);
119
+ if (!project) {
120
+ let t1;
121
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
122
+ t1 = /* @__PURE__ */ jsxs("div", {
123
+ className: "flex h-9 min-w-[150px] items-center gap-2 px-4",
124
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-4 rounded-full" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-3 flex-1" })]
125
+ });
126
+ $[2] = t1;
127
+ } else t1 = $[2];
128
+ return t1;
129
+ }
130
+ let t1;
131
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
132
+ t1 = /* @__PURE__ */ jsx(Favicon, { size: 16 });
133
+ $[3] = t1;
134
+ } else t1 = $[3];
135
+ let t2;
136
+ if ($[4] !== project.name) {
137
+ t2 = /* @__PURE__ */ jsxs("div", {
138
+ className: "flex items-center gap-2",
139
+ children: [t1, /* @__PURE__ */ jsx("span", {
140
+ className: "select-none",
141
+ children: project.name
142
+ })]
143
+ });
144
+ $[4] = project.name;
145
+ $[5] = t2;
146
+ } else t2 = $[5];
147
+ let t3;
148
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
149
+ t3 = /* @__PURE__ */ jsx(ChevronDown, { className: "shrink-0 opacity-50" });
150
+ $[6] = t3;
151
+ } else t3 = $[6];
152
+ let t4;
153
+ if ($[7] !== t2) {
154
+ t4 = /* @__PURE__ */ jsx(DropdownMenuTrigger, {
155
+ asChild: true,
156
+ children: /* @__PURE__ */ jsxs(Button, {
157
+ variant: "ghost",
158
+ children: [t2, t3]
159
+ })
160
+ });
161
+ $[7] = t2;
162
+ $[8] = t4;
163
+ } else t4 = $[8];
164
+ let t5;
165
+ if ($[9] !== authCtx || $[10] !== project.organizationSlug || $[11] !== project.slug) {
166
+ t5 = () => {
167
+ if (authCtx) window.open(`${authCtx.authenticationUrl}/dashboard/${project.organizationSlug}/${project.slug}/overview`, "_blank");
168
+ };
169
+ $[9] = authCtx;
170
+ $[10] = project.organizationSlug;
171
+ $[11] = project.slug;
172
+ $[12] = t5;
173
+ } else t5 = $[12];
174
+ let t6;
175
+ if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
176
+ t6 = /* @__PURE__ */ jsx(Settings, {});
177
+ $[13] = t6;
178
+ } else t6 = $[13];
179
+ let t7;
180
+ if ($[14] !== t5) {
181
+ t7 = /* @__PURE__ */ jsxs(DropdownMenuItem, {
182
+ onSelect: t5,
183
+ children: [t6, "Project settings"]
184
+ });
185
+ $[14] = t5;
186
+ $[15] = t7;
187
+ } else t7 = $[15];
188
+ let t8;
189
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
190
+ t8 = /* @__PURE__ */ jsx(DropdownMenuSeparator, {});
191
+ $[16] = t8;
192
+ } else t8 = $[16];
193
+ let t9;
194
+ if ($[17] !== project.organizationSlug) {
195
+ t9 = /* @__PURE__ */ jsx(DropdownMenuLabel, {
196
+ className: "text-muted-foreground text-xs font-normal",
197
+ children: project.organizationSlug
198
+ });
199
+ $[17] = project.organizationSlug;
200
+ $[18] = t9;
201
+ } else t9 = $[18];
202
+ let t10;
203
+ if ($[19] !== authCtx || $[20] !== project.organizationSlug) {
204
+ t10 = () => {
205
+ if (authCtx) window.open(`${authCtx.authenticationUrl}/dashboard/${project.organizationSlug}/team?tab=members`, "_blank");
206
+ };
207
+ $[19] = authCtx;
208
+ $[20] = project.organizationSlug;
209
+ $[21] = t10;
210
+ } else t10 = $[21];
211
+ let t11;
212
+ if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
213
+ t11 = /* @__PURE__ */ jsx(Users, {});
214
+ $[22] = t11;
215
+ } else t11 = $[22];
216
+ let t12;
217
+ if ($[23] !== t10) {
218
+ t12 = /* @__PURE__ */ jsxs(DropdownMenuItem, {
219
+ onSelect: t10,
220
+ children: [t11, "Team members"]
221
+ });
222
+ $[23] = t10;
223
+ $[24] = t12;
224
+ } else t12 = $[24];
225
+ let t13;
226
+ if ($[25] !== authCtx || $[26] !== project.organizationSlug) {
227
+ t13 = () => {
228
+ if (authCtx) window.open(`${authCtx.authenticationUrl}/dashboard/${project.organizationSlug}/team?tab=settings`, "_blank");
229
+ };
230
+ $[25] = authCtx;
231
+ $[26] = project.organizationSlug;
232
+ $[27] = t13;
233
+ } else t13 = $[27];
234
+ let t14;
235
+ if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
236
+ t14 = /* @__PURE__ */ jsx(Settings, { className: "h-4 w-4" });
237
+ $[28] = t14;
238
+ } else t14 = $[28];
239
+ let t15;
240
+ if ($[29] !== t13) {
241
+ t15 = /* @__PURE__ */ jsxs(DropdownMenuItem, {
242
+ onSelect: t13,
243
+ children: [t14, "Team settings"]
244
+ });
245
+ $[29] = t13;
246
+ $[30] = t15;
247
+ } else t15 = $[30];
248
+ let t16;
249
+ if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
250
+ t16 = /* @__PURE__ */ jsx(DropdownMenuSeparator, {});
251
+ $[31] = t16;
252
+ } else t16 = $[31];
253
+ let t17;
254
+ if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
255
+ t17 = /* @__PURE__ */ jsx(DropdownMenuItem, {
256
+ asChild: true,
257
+ children: /* @__PURE__ */ jsxs(Link, {
258
+ to: "https://camox.ai",
259
+ target: "_blank",
260
+ children: [/* @__PURE__ */ jsx(Info, { className: "h-4 w-4" }), "Powered by Camox"]
102
261
  })
103
- ]
104
- })] });
262
+ });
263
+ $[32] = t17;
264
+ } else t17 = $[32];
265
+ let t18;
266
+ if ($[33] !== t12 || $[34] !== t15 || $[35] !== t7 || $[36] !== t9) {
267
+ t18 = /* @__PURE__ */ jsxs(DropdownMenuContent, {
268
+ className: "w-72",
269
+ align: "start",
270
+ side: "bottom",
271
+ children: [
272
+ t7,
273
+ t8,
274
+ t9,
275
+ t12,
276
+ t15,
277
+ t16,
278
+ t17
279
+ ]
280
+ });
281
+ $[33] = t12;
282
+ $[34] = t15;
283
+ $[35] = t7;
284
+ $[36] = t9;
285
+ $[37] = t18;
286
+ } else t18 = $[37];
287
+ let t19;
288
+ if ($[38] !== t18 || $[39] !== t4) {
289
+ t19 = /* @__PURE__ */ jsxs(DropdownMenu, { children: [t4, t18] });
290
+ $[38] = t18;
291
+ $[39] = t4;
292
+ $[40] = t19;
293
+ } else t19 = $[40];
294
+ return t19;
105
295
  };
296
+ function _temp() {
297
+ for (const selector of [
298
+ "link[rel=\"icon\"]",
299
+ "link[rel=\"shortcut icon\"]",
300
+ "link[rel=\"apple-touch-icon\"]"
301
+ ]) {
302
+ const link = document.querySelector(selector);
303
+ if (link?.href) return link.href;
304
+ }
305
+ return null;
306
+ }
106
307
  //#endregion
107
308
  export { ProjectMenu };
@@ -1,5 +1,6 @@
1
1
  import { AuthContext, useAuthState } from "../../../lib/auth.js";
2
2
  import { useTheme } from "../useTheme.js";
3
+ import { c } from "react/compiler-runtime";
3
4
  import { useContext } from "react";
4
5
  import { jsx, jsxs } from "react/jsx-runtime";
5
6
  import { Button } from "@camox/ui/button";
@@ -8,14 +9,28 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel,
8
9
  import { Avatar, AvatarFallback, AvatarImage } from "@camox/ui/avatar";
9
10
  //#region src/features/studio/components/UserButton.tsx
10
11
  var UserButton = () => {
12
+ const $ = c(3);
11
13
  const { isAuthenticated, isLoading } = useAuthState();
12
14
  const { setTheme } = useTheme();
13
- if (!isAuthenticated || isLoading) return /* @__PURE__ */ jsx(Button, {
14
- variant: "outline",
15
- size: "icon",
16
- children: /* @__PURE__ */ jsx(User, { className: "h-4 w-4" })
17
- });
18
- return /* @__PURE__ */ jsx(AuthenticatedUserButton, { setTheme });
15
+ if (!isAuthenticated || isLoading) {
16
+ let t0;
17
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
18
+ t0 = /* @__PURE__ */ jsx(Button, {
19
+ variant: "outline",
20
+ size: "icon",
21
+ children: /* @__PURE__ */ jsx(User, { className: "h-4 w-4" })
22
+ });
23
+ $[0] = t0;
24
+ } else t0 = $[0];
25
+ return t0;
26
+ }
27
+ let t0;
28
+ if ($[1] !== setTheme) {
29
+ t0 = /* @__PURE__ */ jsx(AuthenticatedUserButton, { setTheme });
30
+ $[1] = setTheme;
31
+ $[2] = t0;
32
+ } else t0 = $[2];
33
+ return t0;
19
34
  };
20
35
  function AuthenticatedUserButton({ setTheme }) {
21
36
  const authCtx = useContext(AuthContext);
@@ -2,7 +2,7 @@ interface StudioContext {
2
2
  isCommandPaletteOpen: boolean;
3
3
  commandPalettePages: string[];
4
4
  }
5
- export declare const studioStore: import('@xstate/store').Store<StudioContext, import('@xstate/store').ExtractEvents<{
5
+ export declare const studioStore: import('@xstate/store').Store<StudioContext, {
6
6
  openCommandPalette: unknown;
7
7
  closeCommandPalette: unknown;
8
8
  toggleCommandPalette: unknown;
@@ -10,7 +10,7 @@ export declare const studioStore: import('@xstate/store').Store<StudioContext, i
10
10
  page: string;
11
11
  };
12
12
  popCommandPalettePage: unknown;
13
- }>, {
13
+ }, {
14
14
  type: string;
15
15
  }>;
16
16
  export {};
@@ -1,87 +1,141 @@
1
1
  import { actionsStore } from "../provider/actionsStore.js";
2
+ import { c } from "react/compiler-runtime";
2
3
  import * as React from "react";
3
4
  //#region src/features/studio/useTheme.ts
4
5
  function useTheme() {
5
- const [theme, setTheme] = React.useState(() => {
6
- if (typeof window !== "undefined") return localStorage.getItem("theme") || "system";
7
- return "system";
8
- });
9
- const applyTheme = (themeToApply) => {
10
- const root = window.document.documentElement;
11
- root.classList.remove("light", "dark");
12
- root.classList.add(themeToApply);
13
- };
14
- React.useEffect(() => {
15
- const root = window.document.documentElement;
16
- root.classList.remove("light", "dark");
17
- if (theme === "system") {
18
- const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
19
- const updateSystemTheme = () => {
20
- applyTheme(mediaQuery.matches ? "dark" : "light");
21
- };
22
- updateSystemTheme();
23
- mediaQuery.addEventListener("change", updateSystemTheme);
24
- return () => mediaQuery.removeEventListener("change", updateSystemTheme);
25
- }
26
- root.classList.add(theme);
27
- }, [theme]);
28
- React.useEffect(() => {
29
- localStorage.setItem("theme", theme);
30
- }, [theme]);
31
- return {
32
- theme,
33
- setTheme
34
- };
6
+ const $ = c(8);
7
+ const [theme, setTheme] = React.useState(_temp);
8
+ const applyTheme = _temp2;
9
+ let t0;
10
+ let t1;
11
+ if ($[0] !== theme) {
12
+ t0 = () => {
13
+ const root_0 = window.document.documentElement;
14
+ root_0.classList.remove("light", "dark");
15
+ if (theme === "system") {
16
+ const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
17
+ const updateSystemTheme = () => {
18
+ applyTheme(mediaQuery.matches ? "dark" : "light");
19
+ };
20
+ updateSystemTheme();
21
+ mediaQuery.addEventListener("change", updateSystemTheme);
22
+ return () => mediaQuery.removeEventListener("change", updateSystemTheme);
23
+ }
24
+ root_0.classList.add(theme);
25
+ };
26
+ t1 = [theme];
27
+ $[0] = theme;
28
+ $[1] = t0;
29
+ $[2] = t1;
30
+ } else {
31
+ t0 = $[1];
32
+ t1 = $[2];
33
+ }
34
+ React.useEffect(t0, t1);
35
+ let t2;
36
+ let t3;
37
+ if ($[3] !== theme) {
38
+ t2 = () => {
39
+ localStorage.setItem("theme", theme);
40
+ };
41
+ t3 = [theme];
42
+ $[3] = theme;
43
+ $[4] = t2;
44
+ $[5] = t3;
45
+ } else {
46
+ t2 = $[4];
47
+ t3 = $[5];
48
+ }
49
+ React.useEffect(t2, t3);
50
+ let t4;
51
+ if ($[6] !== theme) {
52
+ t4 = {
53
+ theme,
54
+ setTheme
55
+ };
56
+ $[6] = theme;
57
+ $[7] = t4;
58
+ } else t4 = $[7];
59
+ return t4;
60
+ }
61
+ function _temp2(themeToApply) {
62
+ const root = window.document.documentElement;
63
+ root.classList.remove("light", "dark");
64
+ root.classList.add(themeToApply);
65
+ }
66
+ function _temp() {
67
+ if (typeof window !== "undefined") return localStorage.getItem("theme") || "system";
68
+ return "system";
35
69
  }
36
70
  function useThemeActions() {
71
+ const $ = c(4);
37
72
  const { theme, setTheme } = useTheme();
38
- React.useEffect(() => {
39
- const pageId = "change-theme";
40
- const actions = [
41
- {
42
- id: pageId,
43
- label: "Change theme",
44
- groupLabel: "Studio",
45
- checkIfAvailable: () => true,
46
- hasChildren: true,
47
- execute: () => {}
48
- },
49
- {
50
- id: "switch-to-light-theme",
51
- parentActionId: pageId,
52
- label: "Switch to light theme",
53
- groupLabel: "Studio",
54
- checkIfAvailable: () => theme !== "light",
55
- execute: () => setTheme("light")
56
- },
57
- {
58
- id: "switch-to-dark-theme",
59
- parentActionId: pageId,
60
- label: "Switch to dark theme",
61
- groupLabel: "Studio",
62
- checkIfAvailable: () => theme !== "dark",
63
- execute: () => setTheme("dark")
64
- },
65
- {
66
- id: "switch-to-system-theme",
67
- parentActionId: pageId,
68
- label: "Switch to system theme",
69
- groupLabel: "Studio",
70
- checkIfAvailable: () => theme !== "system",
71
- execute: () => setTheme("system")
72
- }
73
- ];
74
- actionsStore.send({
75
- type: "registerManyActions",
76
- actions
77
- });
78
- return () => {
73
+ let t0;
74
+ let t1;
75
+ if ($[0] !== setTheme || $[1] !== theme) {
76
+ t0 = () => {
77
+ const actions = [
78
+ {
79
+ id: "change-theme",
80
+ label: "Change theme",
81
+ groupLabel: "Studio",
82
+ checkIfAvailable: _temp3,
83
+ hasChildren: true,
84
+ execute: _temp4
85
+ },
86
+ {
87
+ id: "switch-to-light-theme",
88
+ parentActionId: "change-theme",
89
+ label: "Switch to light theme",
90
+ groupLabel: "Studio",
91
+ checkIfAvailable: () => theme !== "light",
92
+ execute: () => setTheme("light")
93
+ },
94
+ {
95
+ id: "switch-to-dark-theme",
96
+ parentActionId: "change-theme",
97
+ label: "Switch to dark theme",
98
+ groupLabel: "Studio",
99
+ checkIfAvailable: () => theme !== "dark",
100
+ execute: () => setTheme("dark")
101
+ },
102
+ {
103
+ id: "switch-to-system-theme",
104
+ parentActionId: "change-theme",
105
+ label: "Switch to system theme",
106
+ groupLabel: "Studio",
107
+ checkIfAvailable: () => theme !== "system",
108
+ execute: () => setTheme("system")
109
+ }
110
+ ];
79
111
  actionsStore.send({
80
- type: "unregisterManyActions",
81
- ids: actions.map((a) => a.id)
112
+ type: "registerManyActions",
113
+ actions
82
114
  });
115
+ return () => {
116
+ actionsStore.send({
117
+ type: "unregisterManyActions",
118
+ ids: actions.map(_temp5)
119
+ });
120
+ };
83
121
  };
84
- }, [theme, setTheme]);
122
+ t1 = [theme, setTheme];
123
+ $[0] = setTheme;
124
+ $[1] = theme;
125
+ $[2] = t0;
126
+ $[3] = t1;
127
+ } else {
128
+ t0 = $[2];
129
+ t1 = $[3];
130
+ }
131
+ React.useEffect(t0, t1);
132
+ }
133
+ function _temp5(a) {
134
+ return a.id;
135
+ }
136
+ function _temp4() {}
137
+ function _temp3() {
138
+ return true;
85
139
  }
86
140
  //#endregion
87
141
  export { useTheme, useThemeActions };