camox 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/components/AuthGate.js +2 -1
  2. package/dist/core/components/AddBlockControlBar.js +117 -44
  3. package/dist/core/components/lexical/InlineContentEditable.js +37 -17
  4. package/dist/core/components/lexical/InlineLexicalEditor.js +84 -25
  5. package/dist/core/components/lexical/SelectionBroadcaster.js +84 -47
  6. package/dist/core/components/lexical/SidebarLexicalEditor.js +54 -19
  7. package/dist/core/createBlock.js +1172 -414
  8. package/dist/core/createLayout.js +48 -16
  9. package/dist/core/hooks/useFieldSelection.js +24 -13
  10. package/dist/core/hooks/useIsEditable.js +8 -2
  11. package/dist/core/hooks/useOverlayMessage.js +51 -20
  12. package/dist/features/content/CamoxContent.js +239 -107
  13. package/dist/features/content/components/AssetCard.js +78 -16
  14. package/dist/features/content/components/AssetCardSkeleton.js +11 -4
  15. package/dist/features/content/components/ContentSidebar.js +15 -8
  16. package/dist/features/content/components/UploadDropZone.js +77 -34
  17. package/dist/features/content/components/UploadProgressDrawer.js +201 -58
  18. package/dist/features/metadata/sitemap.js +15 -0
  19. package/dist/features/preview/CamoxPreview.js +447 -179
  20. package/dist/features/preview/components/AddBlockSheet.js +344 -167
  21. package/dist/features/preview/components/AgentChatSheet.js +32 -10
  22. package/dist/features/preview/components/AssetFieldEditor.js +185 -50
  23. package/dist/features/preview/components/AssetLightbox.js +60 -33
  24. package/dist/features/preview/components/AssetPickerGrid.js +203 -71
  25. package/dist/features/preview/components/BlockActionsPopover.js +295 -218
  26. package/dist/features/preview/components/CreatePageSheet.js +3 -3
  27. package/dist/features/preview/components/DebouncedFieldEditor.js +80 -23
  28. package/dist/features/preview/components/EditPageSheet.js +241 -86
  29. package/dist/features/preview/components/ItemFieldsEditor.js +209 -115
  30. package/dist/features/preview/components/LinkFieldEditor.js +351 -153
  31. package/dist/features/preview/components/MultipleAssetFieldEditor.js +245 -92
  32. package/dist/features/preview/components/OverlayTracker.js +58 -23
  33. package/dist/features/preview/components/Overlays.js +85 -43
  34. package/dist/features/preview/components/PageContentSheet.js +18 -18
  35. package/dist/features/preview/components/PageLocationFieldset.js +229 -63
  36. package/dist/features/preview/components/PagePicker.js +27 -27
  37. package/dist/features/preview/components/PageTree.js +921 -319
  38. package/dist/features/preview/components/PeekedBlock.js +173 -63
  39. package/dist/features/preview/components/PreviewPanel.js +271 -148
  40. package/dist/features/preview/components/PreviewSideSheet.js +44 -11
  41. package/dist/features/preview/components/PreviewToolbar.js +262 -59
  42. package/dist/features/preview/components/RepeatableItemsList.js +187 -78
  43. package/dist/features/preview/components/ShikiMarkdown.js +46 -20
  44. package/dist/features/preview/components/TextFormatToolbar.js +81 -23
  45. package/dist/features/preview/components/UnlinkAssetButton.js +161 -40
  46. package/dist/features/preview/components/useUpdateBlockPosition.js +64 -47
  47. package/dist/features/preview/previewStore.d.ts +2 -2
  48. package/dist/features/provider/CamoxProvider.js +69 -21
  49. package/dist/features/provider/actionsStore.d.ts +2 -2
  50. package/dist/features/provider/components/CamoxAppContext.js +15 -5
  51. package/dist/features/provider/components/CommandPalette.js +199 -92
  52. package/dist/features/provider/useAdminShortcuts.js +80 -64
  53. package/dist/features/routes/pageRoute.js +8 -1
  54. package/dist/features/studio/CamoxStudio.js +45 -9
  55. package/dist/features/studio/components/EnvironmentMenu.js +47 -12
  56. package/dist/features/studio/components/Navbar.js +163 -65
  57. package/dist/features/studio/components/ProjectMenu.js +263 -82
  58. package/dist/features/studio/components/UserButton.js +21 -6
  59. package/dist/features/studio/studioStore.d.ts +2 -2
  60. package/dist/features/studio/useTheme.js +128 -74
  61. package/dist/hooks/use-file-upload.js +11 -11
  62. package/dist/hooks/use-marquee-selection.js +121 -74
  63. package/dist/lib/auth.js +95 -51
  64. package/dist/lib/normalized-data.js +103 -30
  65. package/dist/lib/use-project-room.js +55 -22
  66. package/dist/studio.css +2 -2
  67. package/package.json +29 -26
  68. package/dist/lib/auth.d.ts +0 -2130
  69. package/dist/lib/auth.d.ts.map +0 -1
@@ -51,32 +51,32 @@ function useFileUpload(options) {
51
51
  mimeType: result.mimeType
52
52
  });
53
53
  trackClientEvent("file_uploaded", { mimeType: file.type });
54
- setUploads((prev) => prev.map((u) => u.id === itemId ? {
55
- ...u,
54
+ setUploads((prev_0) => prev_0.map((u_0) => u_0.id === itemId ? {
55
+ ...u_0,
56
56
  status: "complete",
57
57
  progress: 100
58
- } : u));
58
+ } : u_0));
59
59
  setTimeout(() => {
60
- setUploads((prev) => prev.filter((u) => u.id !== itemId));
60
+ setUploads((prev_1) => prev_1.filter((u_1) => u_1.id !== itemId));
61
61
  }, 2e3);
62
62
  }, [apiUrl]);
63
63
  return {
64
64
  uploads,
65
65
  uploadFiles: useCallback((files) => {
66
- const newItems = Array.from(files).map((file) => ({
66
+ const newItems = Array.from(files).map((file_0) => ({
67
67
  id: String(nextId.current++),
68
- filename: file.name,
68
+ filename: file_0.name,
69
69
  progress: 0,
70
70
  status: "uploading"
71
71
  }));
72
- setUploads((prev) => [...prev, ...newItems]);
73
- Promise.all(Array.from(files).map((file, i) => uploadSingleFile(file, newItems[i].id).catch((err) => {
72
+ setUploads((prev_2) => [...prev_2, ...newItems]);
73
+ Promise.all(Array.from(files).map((file_1, i) => uploadSingleFile(file_1, newItems[i].id).catch((err) => {
74
74
  const message = err instanceof Error ? err.message : "Upload failed";
75
- setUploads((prev) => prev.map((u) => u.id === newItems[i].id ? {
76
- ...u,
75
+ setUploads((prev_3) => prev_3.map((u_2) => u_2.id === newItems[i].id ? {
76
+ ...u_2,
77
77
  status: "error",
78
78
  error: message
79
- } : u));
79
+ } : u_2));
80
80
  })));
81
81
  }, [uploadSingleFile]),
82
82
  clearAll: useCallback(() => {
@@ -1,88 +1,135 @@
1
- import { useCallback, useRef, useState } from "react";
1
+ import { c } from "react/compiler-runtime";
2
+ import { useRef, useState } from "react";
2
3
  //#region src/hooks/use-marquee-selection.ts
3
4
  var DRAG_THRESHOLD = 5;
4
5
  function useMarqueeSelection(containerRef, onSelectionChange) {
6
+ const $ = c(17);
5
7
  const [selectionRect, setSelectionRect] = useState(null);
6
8
  const startPoint = useRef(null);
7
9
  const isDragging = useRef(false);
8
- const getContainerRelativePoint = useCallback((e) => {
9
- const container = containerRef.current;
10
- if (!container) return null;
11
- const bounds = container.getBoundingClientRect();
12
- return {
13
- x: e.clientX - bounds.left + container.scrollLeft,
14
- y: e.clientY - bounds.top + container.scrollTop
10
+ let t0;
11
+ if ($[0] !== containerRef) {
12
+ t0 = (e) => {
13
+ const container = containerRef.current;
14
+ if (!container) return null;
15
+ const bounds = container.getBoundingClientRect();
16
+ return {
17
+ x: e.clientX - bounds.left + container.scrollLeft,
18
+ y: e.clientY - bounds.top + container.scrollTop
19
+ };
15
20
  };
16
- }, [containerRef]);
17
- const computeRect = (a, b) => ({
18
- left: Math.min(a.x, b.x),
19
- top: Math.min(a.y, b.y),
20
- width: Math.abs(a.x - b.x),
21
- height: Math.abs(a.y - b.y)
22
- });
23
- const findIntersectingIds = useCallback((rect) => {
24
- const container = containerRef.current;
25
- if (!container) return /* @__PURE__ */ new Set();
26
- const containerBounds = container.getBoundingClientRect();
27
- const scrollLeft = container.scrollLeft;
28
- const scrollTop = container.scrollTop;
29
- const selViewport = {
30
- left: rect.left - scrollLeft + containerBounds.left,
31
- top: rect.top - scrollTop + containerBounds.top,
32
- right: rect.left + rect.width - scrollLeft + containerBounds.left,
33
- bottom: rect.top + rect.height - scrollTop + containerBounds.top
21
+ $[0] = containerRef;
22
+ $[1] = t0;
23
+ } else t0 = $[1];
24
+ const getContainerRelativePoint = t0;
25
+ const computeRect = _temp;
26
+ let t1;
27
+ if ($[2] !== containerRef) {
28
+ t1 = (rect) => {
29
+ const container_0 = containerRef.current;
30
+ if (!container_0) return /* @__PURE__ */ new Set();
31
+ const containerBounds = container_0.getBoundingClientRect();
32
+ const scrollLeft = container_0.scrollLeft;
33
+ const scrollTop = container_0.scrollTop;
34
+ const selViewport = {
35
+ left: rect.left - scrollLeft + containerBounds.left,
36
+ top: rect.top - scrollTop + containerBounds.top,
37
+ right: rect.left + rect.width - scrollLeft + containerBounds.left,
38
+ bottom: rect.top + rect.height - scrollTop + containerBounds.top
39
+ };
40
+ const ids = /* @__PURE__ */ new Set();
41
+ const cards = container_0.querySelectorAll("[data-asset-id]");
42
+ for (const card of cards) {
43
+ const cardBounds = card.getBoundingClientRect();
44
+ if (selViewport.left < cardBounds.right && selViewport.right > cardBounds.left && selViewport.top < cardBounds.bottom && selViewport.bottom > cardBounds.top) ids.add(card.dataset.assetId);
45
+ }
46
+ return ids;
34
47
  };
35
- const ids = /* @__PURE__ */ new Set();
36
- const cards = container.querySelectorAll("[data-asset-id]");
37
- for (const card of cards) {
38
- const cardBounds = card.getBoundingClientRect();
39
- if (selViewport.left < cardBounds.right && selViewport.right > cardBounds.left && selViewport.top < cardBounds.bottom && selViewport.bottom > cardBounds.top) ids.add(card.dataset.assetId);
40
- }
41
- return ids;
42
- }, [containerRef]);
43
- const onPointerDown = useCallback((e) => {
44
- if (e.button !== 0) return;
45
- if (e.target.closest("[data-asset-id]")) return;
46
- const point = getContainerRelativePoint(e);
47
- if (!point) return;
48
- startPoint.current = point;
49
- isDragging.current = false;
50
- e.currentTarget.setPointerCapture(e.pointerId);
51
- }, [getContainerRelativePoint]);
52
- const onPointerMove = useCallback((e) => {
53
- if (!startPoint.current) return;
54
- const point = getContainerRelativePoint(e);
55
- if (!point) return;
56
- const dx = point.x - startPoint.current.x;
57
- const dy = point.y - startPoint.current.y;
58
- if (!isDragging.current) {
59
- if (Math.abs(dx) < DRAG_THRESHOLD && Math.abs(dy) < DRAG_THRESHOLD) return;
60
- isDragging.current = true;
61
- }
62
- const rect = computeRect(startPoint.current, point);
63
- setSelectionRect(rect);
64
- onSelectionChange(findIntersectingIds(rect));
65
- }, [
66
- getContainerRelativePoint,
67
- findIntersectingIds,
68
- onSelectionChange
69
- ]);
48
+ $[2] = containerRef;
49
+ $[3] = t1;
50
+ } else t1 = $[3];
51
+ const findIntersectingIds = t1;
52
+ let t2;
53
+ if ($[4] !== getContainerRelativePoint) {
54
+ t2 = (e_0) => {
55
+ if (e_0.button !== 0) return;
56
+ if (e_0.target.closest("[data-asset-id]")) return;
57
+ const point = getContainerRelativePoint(e_0);
58
+ if (!point) return;
59
+ startPoint.current = point;
60
+ isDragging.current = false;
61
+ e_0.currentTarget.setPointerCapture(e_0.pointerId);
62
+ };
63
+ $[4] = getContainerRelativePoint;
64
+ $[5] = t2;
65
+ } else t2 = $[5];
66
+ const onPointerDown = t2;
67
+ let t3;
68
+ if ($[6] !== findIntersectingIds || $[7] !== getContainerRelativePoint || $[8] !== onSelectionChange) {
69
+ t3 = (e_1) => {
70
+ if (!startPoint.current) return;
71
+ const point_0 = getContainerRelativePoint(e_1);
72
+ if (!point_0) return;
73
+ const dx = point_0.x - startPoint.current.x;
74
+ const dy = point_0.y - startPoint.current.y;
75
+ if (!isDragging.current) {
76
+ if (Math.abs(dx) < DRAG_THRESHOLD && Math.abs(dy) < DRAG_THRESHOLD) return;
77
+ isDragging.current = true;
78
+ }
79
+ const rect_0 = computeRect(startPoint.current, point_0);
80
+ setSelectionRect(rect_0);
81
+ onSelectionChange(findIntersectingIds(rect_0));
82
+ };
83
+ $[6] = findIntersectingIds;
84
+ $[7] = getContainerRelativePoint;
85
+ $[8] = onSelectionChange;
86
+ $[9] = t3;
87
+ } else t3 = $[9];
88
+ const onPointerMove = t3;
70
89
  const didDrag = useRef(false);
71
- return {
72
- selectionRect,
73
- didDragRef: didDrag,
74
- handlers: {
90
+ let t4;
91
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
92
+ t4 = (e_2) => {
93
+ if (!startPoint.current) return;
94
+ e_2.currentTarget.releasePointerCapture(e_2.pointerId);
95
+ didDrag.current = isDragging.current;
96
+ startPoint.current = null;
97
+ isDragging.current = false;
98
+ setSelectionRect(null);
99
+ };
100
+ $[10] = t4;
101
+ } else t4 = $[10];
102
+ const onPointerUp = t4;
103
+ let t5;
104
+ if ($[11] !== onPointerDown || $[12] !== onPointerMove) {
105
+ t5 = {
75
106
  onPointerDown,
76
107
  onPointerMove,
77
- onPointerUp: useCallback((e) => {
78
- if (!startPoint.current) return;
79
- e.currentTarget.releasePointerCapture(e.pointerId);
80
- didDrag.current = isDragging.current;
81
- startPoint.current = null;
82
- isDragging.current = false;
83
- setSelectionRect(null);
84
- }, [])
85
- }
108
+ onPointerUp
109
+ };
110
+ $[11] = onPointerDown;
111
+ $[12] = onPointerMove;
112
+ $[13] = t5;
113
+ } else t5 = $[13];
114
+ let t6;
115
+ if ($[14] !== selectionRect || $[15] !== t5) {
116
+ t6 = {
117
+ selectionRect,
118
+ didDragRef: didDrag,
119
+ handlers: t5
120
+ };
121
+ $[14] = selectionRect;
122
+ $[15] = t5;
123
+ $[16] = t6;
124
+ } else t6 = $[16];
125
+ return t6;
126
+ }
127
+ function _temp(a, b) {
128
+ return {
129
+ left: Math.min(a.x, b.x),
130
+ top: Math.min(a.y, b.y),
131
+ width: Math.abs(a.x - b.x),
132
+ height: Math.abs(a.y - b.y)
86
133
  };
87
134
  }
88
135
  //#endregion
package/dist/lib/auth.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { actionsStore } from "../features/provider/actionsStore.js";
2
+ import { c } from "react/compiler-runtime";
2
3
  import * as React from "react";
3
4
  import { oneTimeTokenClient, organizationClient } from "better-auth/client/plugins";
4
5
  import { createAuthClient } from "better-auth/react";
@@ -159,30 +160,45 @@ function createCamoxAuthClient(apiUrl) {
159
160
  * Returns `true` once processing is complete (or if there was no OTT).
160
161
  */
161
162
  function useProcessOtt(authClient) {
162
- const [ready, setReady] = React.useState(() => {
163
- if (typeof window === "undefined") return true;
164
- return !new URL(window.location.href).searchParams.has("ott");
165
- });
166
- React.useEffect(() => {
167
- if (ready) return;
168
- const url = new URL(window.location.href);
169
- const ott = url.searchParams.get("ott");
170
- if (!ott) {
171
- setReady(true);
172
- return;
173
- }
174
- url.searchParams.delete("ott");
175
- window.history.replaceState({}, "", url);
176
- (async () => {
177
- try {
178
- await authClient.oneTimeToken.verify({ token: ott });
179
- authClient.updateSession();
180
- } catch {}
181
- setReady(true);
182
- })();
183
- }, [authClient, ready]);
163
+ const $ = c(4);
164
+ const [ready, setReady] = React.useState(_temp);
165
+ let t0;
166
+ let t1;
167
+ if ($[0] !== authClient || $[1] !== ready) {
168
+ t0 = () => {
169
+ if (ready) return;
170
+ const url = new URL(window.location.href);
171
+ const ott = url.searchParams.get("ott");
172
+ if (!ott) {
173
+ setReady(true);
174
+ return;
175
+ }
176
+ url.searchParams.delete("ott");
177
+ window.history.replaceState({}, "", url);
178
+ (async () => {
179
+ try {
180
+ await authClient.oneTimeToken.verify({ token: ott });
181
+ authClient.updateSession();
182
+ } catch {}
183
+ setReady(true);
184
+ })();
185
+ };
186
+ t1 = [authClient, ready];
187
+ $[0] = authClient;
188
+ $[1] = ready;
189
+ $[2] = t0;
190
+ $[3] = t1;
191
+ } else {
192
+ t0 = $[2];
193
+ t1 = $[3];
194
+ }
195
+ React.useEffect(t0, t1);
184
196
  return ready;
185
197
  }
198
+ function _temp() {
199
+ if (typeof window === "undefined") return true;
200
+ return !new URL(window.location.href).searchParams.has("ott");
201
+ }
186
202
  var AuthContext = React.createContext(null);
187
203
  function useAuthContext() {
188
204
  const ctx = React.useContext(AuthContext);
@@ -205,45 +221,73 @@ function useIsAuthenticated() {
205
221
  return isAuthenticated;
206
222
  }
207
223
  function useSignInRedirect() {
224
+ const $ = c(2);
208
225
  const { authenticationUrl } = useAuthContext();
209
- return React.useCallback(() => {
210
- if (typeof window !== "undefined") {
211
- const redirect = encodeURIComponent(window.location.href);
212
- window.location.href = `${authenticationUrl}/login?redirect=${redirect}`;
213
- }
214
- }, [authenticationUrl]);
226
+ let t0;
227
+ if ($[0] !== authenticationUrl) {
228
+ t0 = () => {
229
+ if (typeof window !== "undefined") {
230
+ const redirect = encodeURIComponent(window.location.href);
231
+ window.location.href = `${authenticationUrl}/login?redirect=${redirect}`;
232
+ }
233
+ };
234
+ $[0] = authenticationUrl;
235
+ $[1] = t0;
236
+ } else t0 = $[1];
237
+ return t0;
215
238
  }
216
239
  /**
217
240
  * Registers sign-out and manage-account actions in the command palette.
218
241
  */
219
242
  function useAuthActions() {
243
+ const $ = c(4);
220
244
  const { authClient, authenticationUrl } = useAuthContext();
221
- React.useEffect(() => {
222
- actionsStore.send({
223
- type: "registerManyActions",
224
- actions: [{
225
- id: "manage-account",
226
- label: "Manage account",
227
- groupLabel: "Studio",
228
- checkIfAvailable: () => true,
229
- execute: () => {
230
- window.open(`${authenticationUrl}/profile`, "_blank");
231
- }
232
- }, {
233
- id: "log-out",
234
- label: "Log out",
235
- groupLabel: "Studio",
236
- checkIfAvailable: () => true,
237
- execute: () => authClient.signOut()
238
- }]
239
- });
240
- return () => {
245
+ let t0;
246
+ let t1;
247
+ if ($[0] !== authClient || $[1] !== authenticationUrl) {
248
+ t0 = () => {
241
249
  actionsStore.send({
242
- type: "unregisterManyActions",
243
- ids: ["manage-account", "log-out"]
250
+ type: "registerManyActions",
251
+ actions: [{
252
+ id: "manage-account",
253
+ label: "Manage account",
254
+ groupLabel: "Studio",
255
+ checkIfAvailable: _temp2,
256
+ execute: () => {
257
+ window.open(`${authenticationUrl}/profile`, "_blank");
258
+ }
259
+ }, {
260
+ id: "log-out",
261
+ label: "Log out",
262
+ groupLabel: "Studio",
263
+ checkIfAvailable: _temp3,
264
+ execute: () => authClient.signOut()
265
+ }]
244
266
  });
267
+ return _temp4;
245
268
  };
246
- }, [authClient, authenticationUrl]);
269
+ t1 = [authClient, authenticationUrl];
270
+ $[0] = authClient;
271
+ $[1] = authenticationUrl;
272
+ $[2] = t0;
273
+ $[3] = t1;
274
+ } else {
275
+ t0 = $[2];
276
+ t1 = $[3];
277
+ }
278
+ React.useEffect(t0, t1);
279
+ }
280
+ function _temp4() {
281
+ actionsStore.send({
282
+ type: "unregisterManyActions",
283
+ ids: ["manage-account", "log-out"]
284
+ });
285
+ }
286
+ function _temp3() {
287
+ return true;
288
+ }
289
+ function _temp2() {
290
+ return true;
247
291
  }
248
292
  //#endregion
249
293
  export { AuthContext, createCamoxAuthClient, getAuthCookieHeader, useAuthActions, useAuthContext, useAuthState, useIsAuthenticated, useProcessOtt, useProjectSlug, useSignInRedirect };
@@ -1,4 +1,5 @@
1
1
  import { blockQueries } from "./queries.js";
2
+ import { c } from "react/compiler-runtime";
2
3
  import { useQueries } from "@tanstack/react-query";
3
4
  import * as React from "react";
4
5
  import { queryKeys } from "@camox/api/query-keys";
@@ -7,32 +8,78 @@ var NormalizedDataContext = React.createContext({
7
8
  filesMap: /* @__PURE__ */ new Map(),
8
9
  itemsMap: /* @__PURE__ */ new Map()
9
10
  });
10
- var NormalizedDataProvider = ({ files, repeatableItems, children }) => {
11
- const value = React.useMemo(() => ({
12
- filesMap: new Map(files.map((f) => [f.id, f])),
13
- itemsMap: new Map(repeatableItems.map((i) => [i.id, i]))
14
- }), [files, repeatableItems]);
15
- return React.createElement(NormalizedDataContext.Provider, { value }, children);
11
+ var NormalizedDataProvider = (t0) => {
12
+ const $ = c(12);
13
+ const { files, repeatableItems, children } = t0;
14
+ let t1;
15
+ if ($[0] !== files) {
16
+ t1 = new Map(files.map(_temp));
17
+ $[0] = files;
18
+ $[1] = t1;
19
+ } else t1 = $[1];
20
+ let t2;
21
+ if ($[2] !== repeatableItems) {
22
+ t2 = new Map(repeatableItems.map(_temp2));
23
+ $[2] = repeatableItems;
24
+ $[3] = t2;
25
+ } else t2 = $[3];
26
+ let t3;
27
+ if ($[4] !== t1 || $[5] !== t2) {
28
+ t3 = {
29
+ filesMap: t1,
30
+ itemsMap: t2
31
+ };
32
+ $[4] = t1;
33
+ $[5] = t2;
34
+ $[6] = t3;
35
+ } else t3 = $[6];
36
+ const value = t3;
37
+ let t4;
38
+ if ($[7] !== children || $[8] !== value) {
39
+ let t5;
40
+ if ($[10] !== value) {
41
+ t5 = { value };
42
+ $[10] = value;
43
+ $[11] = t5;
44
+ } else t5 = $[11];
45
+ t4 = React.createElement(NormalizedDataContext.Provider, t5, children);
46
+ $[7] = children;
47
+ $[8] = value;
48
+ $[9] = t4;
49
+ } else t4 = $[9];
50
+ return t4;
16
51
  };
17
52
  function useNormalizedData() {
18
53
  return React.use(NormalizedDataContext);
19
54
  }
20
55
  var EMPTY_IDS = [];
21
56
  function usePageBlocks(pageStructure) {
57
+ const $ = c(15);
22
58
  const blockIds = pageStructure.page.blockIds;
23
59
  const beforeIds = pageStructure.layout?.beforeBlockIds ?? EMPTY_IDS;
24
60
  const afterIds = pageStructure.layout?.afterBlockIds ?? EMPTY_IDS;
25
- const allIds = React.useMemo(() => [
26
- ...blockIds,
27
- ...beforeIds,
28
- ...afterIds
29
- ], [
30
- blockIds,
31
- beforeIds,
32
- afterIds
33
- ]);
34
- const results = useQueries({ queries: allIds.map((id) => blockQueries.get(id)) });
35
- return React.useMemo(() => {
61
+ let t0;
62
+ if ($[0] !== afterIds || $[1] !== beforeIds || $[2] !== blockIds) {
63
+ t0 = [
64
+ ...blockIds,
65
+ ...beforeIds,
66
+ ...afterIds
67
+ ];
68
+ $[0] = afterIds;
69
+ $[1] = beforeIds;
70
+ $[2] = blockIds;
71
+ $[3] = t0;
72
+ } else t0 = $[3];
73
+ const allIds = t0;
74
+ let t1;
75
+ if ($[4] !== allIds) {
76
+ t1 = { queries: allIds.map(_temp3) };
77
+ $[4] = allIds;
78
+ $[5] = t1;
79
+ } else t1 = $[5];
80
+ const results = useQueries(t1);
81
+ let t2;
82
+ if ($[6] !== afterIds || $[7] !== allIds || $[8] !== beforeIds || $[9] !== blockIds || $[10] !== results) {
36
83
  const bundleMap = /* @__PURE__ */ new Map();
37
84
  for (let i = 0; i < allIds.length; i++) {
38
85
  const data = results[i]?.data;
@@ -40,29 +87,49 @@ function usePageBlocks(pageStructure) {
40
87
  }
41
88
  const layoutFiles = [];
42
89
  const layoutItems = [];
43
- for (const id of [...beforeIds, ...afterIds]) {
44
- const bundle = bundleMap.get(id);
90
+ let t3;
91
+ if ($[12] !== afterIds || $[13] !== beforeIds) {
92
+ t3 = [...beforeIds, ...afterIds];
93
+ $[12] = afterIds;
94
+ $[13] = beforeIds;
95
+ $[14] = t3;
96
+ } else t3 = $[14];
97
+ for (const id_0 of t3) {
98
+ const bundle = bundleMap.get(id_0);
45
99
  if (bundle) {
46
100
  layoutFiles.push(...bundle.files);
47
101
  layoutItems.push(...bundle.repeatableItems);
48
102
  }
49
103
  }
50
- return {
51
- pageBlocks: blockIds.map((id) => bundleMap.get(id)?.block).filter((b) => b != null),
52
- beforeBlocks: beforeIds.map((id) => bundleMap.get(id)?.block).filter((b) => b != null),
53
- afterBlocks: afterIds.map((id) => bundleMap.get(id)?.block).filter((b) => b != null),
104
+ t2 = {
105
+ pageBlocks: blockIds.map((id_1) => bundleMap.get(id_1)?.block).filter(_temp4),
106
+ beforeBlocks: beforeIds.map((id_2) => bundleMap.get(id_2)?.block).filter(_temp5),
107
+ afterBlocks: afterIds.map((id_3) => bundleMap.get(id_3)?.block).filter(_temp6),
54
108
  layoutFiles,
55
109
  layoutItems
56
110
  };
57
- }, [
58
- results,
59
- allIds,
60
- blockIds,
61
- beforeIds,
62
- afterIds
63
- ]);
111
+ $[6] = afterIds;
112
+ $[7] = allIds;
113
+ $[8] = beforeIds;
114
+ $[9] = blockIds;
115
+ $[10] = results;
116
+ $[11] = t2;
117
+ } else t2 = $[11];
118
+ return t2;
64
119
  }
65
120
  /** Check if a value is a { _fileId } marker */
121
+ function _temp6(b_1) {
122
+ return b_1 != null;
123
+ }
124
+ function _temp5(b_0) {
125
+ return b_0 != null;
126
+ }
127
+ function _temp4(b) {
128
+ return b != null;
129
+ }
130
+ function _temp3(id) {
131
+ return blockQueries.get(id);
132
+ }
66
133
  function isFileMarker(value) {
67
134
  return value != null && typeof value === "object" && "_fileId" in value && value._fileId != null;
68
135
  }
@@ -110,5 +177,11 @@ function resolveFileMarker(marker, filesMap) {
110
177
  _fileId: marker._fileId
111
178
  };
112
179
  }
180
+ function _temp(f) {
181
+ return [f.id, f];
182
+ }
183
+ function _temp2(i) {
184
+ return [i.id, i];
185
+ }
113
186
  //#endregion
114
187
  export { NormalizedDataProvider, isFileMarker, isItemMarker, resolveFileMarker, seedBlockCaches, useNormalizedData, usePageBlocks };