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.
- package/dist/components/AuthGate.js +2 -1
- package/dist/core/components/AddBlockControlBar.js +117 -44
- package/dist/core/components/lexical/InlineContentEditable.js +37 -17
- package/dist/core/components/lexical/InlineLexicalEditor.js +84 -25
- package/dist/core/components/lexical/SelectionBroadcaster.js +84 -47
- package/dist/core/components/lexical/SidebarLexicalEditor.js +54 -19
- package/dist/core/createBlock.js +1172 -414
- package/dist/core/createLayout.js +48 -16
- package/dist/core/hooks/useFieldSelection.js +24 -13
- package/dist/core/hooks/useIsEditable.js +8 -2
- package/dist/core/hooks/useOverlayMessage.js +51 -20
- package/dist/features/content/CamoxContent.js +239 -107
- package/dist/features/content/components/AssetCard.js +78 -16
- package/dist/features/content/components/AssetCardSkeleton.js +11 -4
- package/dist/features/content/components/ContentSidebar.js +15 -8
- package/dist/features/content/components/UploadDropZone.js +77 -34
- package/dist/features/content/components/UploadProgressDrawer.js +201 -58
- package/dist/features/metadata/sitemap.js +15 -0
- package/dist/features/preview/CamoxPreview.js +447 -179
- package/dist/features/preview/components/AddBlockSheet.js +344 -167
- package/dist/features/preview/components/AgentChatSheet.js +32 -10
- package/dist/features/preview/components/AssetFieldEditor.js +185 -50
- package/dist/features/preview/components/AssetLightbox.js +60 -33
- package/dist/features/preview/components/AssetPickerGrid.js +203 -71
- package/dist/features/preview/components/BlockActionsPopover.js +295 -218
- package/dist/features/preview/components/CreatePageSheet.js +3 -3
- package/dist/features/preview/components/DebouncedFieldEditor.js +80 -23
- package/dist/features/preview/components/EditPageSheet.js +241 -86
- package/dist/features/preview/components/ItemFieldsEditor.js +209 -115
- package/dist/features/preview/components/LinkFieldEditor.js +351 -153
- package/dist/features/preview/components/MultipleAssetFieldEditor.js +245 -92
- package/dist/features/preview/components/OverlayTracker.js +58 -23
- package/dist/features/preview/components/Overlays.js +85 -43
- package/dist/features/preview/components/PageContentSheet.js +18 -18
- package/dist/features/preview/components/PageLocationFieldset.js +229 -63
- package/dist/features/preview/components/PagePicker.js +27 -27
- package/dist/features/preview/components/PageTree.js +921 -319
- package/dist/features/preview/components/PeekedBlock.js +173 -63
- package/dist/features/preview/components/PreviewPanel.js +271 -148
- package/dist/features/preview/components/PreviewSideSheet.js +44 -11
- package/dist/features/preview/components/PreviewToolbar.js +262 -59
- package/dist/features/preview/components/RepeatableItemsList.js +187 -78
- package/dist/features/preview/components/ShikiMarkdown.js +46 -20
- package/dist/features/preview/components/TextFormatToolbar.js +81 -23
- package/dist/features/preview/components/UnlinkAssetButton.js +161 -40
- package/dist/features/preview/components/useUpdateBlockPosition.js +64 -47
- package/dist/features/preview/previewStore.d.ts +2 -2
- package/dist/features/provider/CamoxProvider.js +69 -21
- package/dist/features/provider/actionsStore.d.ts +2 -2
- package/dist/features/provider/components/CamoxAppContext.js +15 -5
- package/dist/features/provider/components/CommandPalette.js +199 -92
- package/dist/features/provider/useAdminShortcuts.js +80 -64
- package/dist/features/routes/pageRoute.js +8 -1
- package/dist/features/studio/CamoxStudio.js +45 -9
- package/dist/features/studio/components/EnvironmentMenu.js +47 -12
- package/dist/features/studio/components/Navbar.js +163 -65
- package/dist/features/studio/components/ProjectMenu.js +263 -82
- package/dist/features/studio/components/UserButton.js +21 -6
- package/dist/features/studio/studioStore.d.ts +2 -2
- package/dist/features/studio/useTheme.js +128 -74
- package/dist/hooks/use-file-upload.js +11 -11
- package/dist/hooks/use-marquee-selection.js +121 -74
- package/dist/lib/auth.js +95 -51
- package/dist/lib/normalized-data.js +103 -30
- package/dist/lib/use-project-room.js +55 -22
- package/dist/studio.css +2 -2
- package/package.json +29 -26
- package/dist/lib/auth.d.ts +0 -2130
- 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((
|
|
55
|
-
...
|
|
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
|
-
} :
|
|
58
|
+
} : u_0));
|
|
59
59
|
setTimeout(() => {
|
|
60
|
-
setUploads((
|
|
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((
|
|
66
|
+
const newItems = Array.from(files).map((file_0) => ({
|
|
67
67
|
id: String(nextId.current++),
|
|
68
|
-
filename:
|
|
68
|
+
filename: file_0.name,
|
|
69
69
|
progress: 0,
|
|
70
70
|
status: "uploading"
|
|
71
71
|
}));
|
|
72
|
-
setUploads((
|
|
73
|
-
Promise.all(Array.from(files).map((
|
|
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((
|
|
76
|
-
...
|
|
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
|
-
} :
|
|
79
|
+
} : u_2));
|
|
80
80
|
})));
|
|
81
81
|
}, [uploadSingleFile]),
|
|
82
82
|
clearAll: useCallback(() => {
|
|
@@ -1,88 +1,135 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
window
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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: "
|
|
243
|
-
|
|
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
|
-
|
|
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 = (
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
afterIds
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
44
|
-
|
|
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
|
-
|
|
51
|
-
pageBlocks: blockIds.map((
|
|
52
|
-
beforeBlocks: beforeIds.map((
|
|
53
|
-
afterBlocks: afterIds.map((
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
blockIds
|
|
61
|
-
|
|
62
|
-
|
|
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 };
|