camox 0.46.0 → 0.48.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.
- package/dist/core/createApp.d.ts +19 -6
- package/dist/core/createApp.js +7 -2
- package/dist/core/createBlock.js +54 -43
- package/dist/core/createCollection.d.ts +25 -7
- package/dist/core/createCollection.js +28 -9
- package/dist/core/createLayout.d.ts +98 -71
- package/dist/core/createLayout.js +10 -16
- package/dist/core/derivedRoutes.js +1 -1
- package/dist/core/editing/BlockEditingRuntime.d.ts +3 -2
- package/dist/core/editing/CompleteBlockEditingRuntime.js +2 -1
- package/dist/core/editing/createEditableBlock.d.ts +59 -19
- package/dist/core/editing/createEditableBlock.js +162 -151
- package/dist/core/editing/useLatestRecord.js +7 -7
- package/dist/core/layoutContext.d.ts +54 -0
- package/dist/core/layoutContext.js +66 -0
- package/dist/core/lib/contentType.d.ts +91 -4
- package/dist/core/lib/contentType.js +84 -7
- package/dist/core/lib/recordScope.js +19 -17
- package/dist/core/lib/reference.d.ts +6 -2
- package/dist/core/recordItem.js +55 -2
- package/dist/core/requestContext.d.ts +18 -0
- package/dist/core/structuredData.d.ts +126 -0
- package/dist/core/structuredData.js +40 -0
- package/dist/features/canvas/canvasCamera.js +21 -6
- package/dist/features/canvas/sidebar/CanvasSidebarFrame.js +1 -1
- package/dist/features/canvas/useCanvasCamera.js +16 -11
- package/dist/features/content/ContentCollection.js +13 -7
- package/dist/features/content/collection-form.js +6 -2
- package/dist/features/content/components/MissingFromLocale.js +1 -1
- package/dist/features/og/pageImage.js +89 -0
- package/dist/features/page/CuratedPageContent.js +45 -32
- package/dist/features/page/DerivedPageContent.js +49 -22
- package/dist/features/page/SharedLayoutContent.js +26 -22
- package/dist/features/preview/CamoxPreview.js +176 -145
- package/dist/features/preview/components/AddBlockSheet.js +1 -0
- package/dist/features/preview/components/BlockActionsPopover.js +8 -6
- package/dist/features/preview/components/PageInfo.js +244 -264
- package/dist/features/preview/components/PageTree.js +63 -53
- package/dist/features/preview/components/PreviewToolbar.js +74 -85
- package/dist/features/preview/components/RecordCard.js +50 -34
- package/dist/features/preview/components/RecordCombobox.js +12 -5
- package/dist/features/preview/components/ReferenceFieldEditor.js +4 -2
- package/dist/features/preview/components/ReferenceListFieldEditor.js +24 -19
- package/dist/features/preview/components/RepeatableItemsList.js +62 -46
- package/dist/features/preview/components/SelectionEditor.js +3 -2
- package/dist/features/preview/components/useFieldWriter.js +2 -4
- package/dist/features/preview/components/useRecordView.js +2 -2
- package/dist/features/preview/entityName.js +11 -0
- package/dist/features/preview/pageRecord.js +17 -18
- package/dist/features/provider/CamoxProvider.js +8 -16
- package/dist/features/provider/CoreCamoxProvider.js +1 -6
- package/dist/features/provider/signInShortcut.js +60 -0
- package/dist/features/routes/pageRuntime.d.ts +15 -1
- package/dist/features/routes/pageRuntime.js +35 -38
- package/dist/features/runtime/RuntimeChrome.js +2 -2
- package/dist/features/runtime/breadcrumbs.js +68 -0
- package/dist/features/runtime/livePages.js +3 -2
- package/dist/features/runtime/pageApp.js +11 -39
- package/dist/features/runtime/pageGraph.js +92 -0
- package/dist/features/runtime/projectLogo.js +110 -0
- package/dist/features/runtime/runtime.d.ts +11 -6
- package/dist/features/runtime/runtime.js +278 -55
- package/dist/features/runtime/runtimeRoutes.d.ts +1 -0
- package/dist/features/runtime/runtimeRoutes.js +1 -0
- package/dist/features/runtime/structuredData.js +213 -0
- package/dist/features/studio/components/ChatSidebar.js +5 -5
- package/dist/features/studio/components/ProjectMenu.js +127 -100
- package/dist/features/studio/components/SocialProfilesDialog.js +342 -0
- package/dist/features/studio/components/ThreadMessages.js +2 -2
- package/dist/features/vite/blockBoilerplate.js +3 -2
- package/dist/features/vite/layoutGeneration.js +3 -2
- package/dist/features/vite/vite.js +1 -0
- package/dist/lib/queries.d.ts +4 -0
- package/dist/lib/queries.js +1 -0
- package/dist/lib/studio-reads.js +3 -1
- package/dist/package.js +1 -1
- package/dist/studio.css +1 -1
- package/package.json +5 -4
- package/skills/camox/references/block-definitions.md +105 -25
- package/skills/camox/references/layout-definitions.md +53 -17
- package/skills/camox/references/routed-layouts.md +17 -14
- package/dist/features/provider/LocalhostPreviewProvider.js +0 -158
|
@@ -24,16 +24,31 @@ const MAX_CANVAS_ZOOM = 2;
|
|
|
24
24
|
*/
|
|
25
25
|
const MIN_CANVAS_ZOOM = .1;
|
|
26
26
|
/** Log-scale zoom per pixel of Ctrl/⌘ + wheel, including trackpad pinches. */
|
|
27
|
-
const CANVAS_WHEEL_ZOOM_RATE = .
|
|
27
|
+
const CANVAS_WHEEL_ZOOM_RATE = .0139392;
|
|
28
28
|
/** Relative (log-scale) bands make the detent feel the same at every page width. */
|
|
29
|
-
const ZOOM_SNAP_CAPTURE = .
|
|
30
|
-
const ZOOM_SNAP_RELEASE = .
|
|
29
|
+
const ZOOM_SNAP_CAPTURE = .168;
|
|
30
|
+
const ZOOM_SNAP_RELEASE = .216;
|
|
31
31
|
/** Fractions of viewport width: acquire near center, then hold a wider detent. */
|
|
32
|
-
const PAN_SNAP_CAPTURE = .
|
|
33
|
-
const PAN_SNAP_RELEASE = .
|
|
32
|
+
const PAN_SNAP_CAPTURE = .144;
|
|
33
|
+
const PAN_SNAP_RELEASE = .216;
|
|
34
34
|
function isCanvasPageScale(scale, pageScale) {
|
|
35
35
|
return pageScale !== void 0 && Math.abs(Math.log(scale / pageScale)) < 1e-8;
|
|
36
36
|
}
|
|
37
|
+
/** Signed screen distance from a target's center to the viewport's center. */
|
|
38
|
+
function canvasTargetOffset(camera, viewport, target) {
|
|
39
|
+
return camera.x + (target.left + target.width / 2) * camera.scale - viewport.width / 2;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Near a target's page fit in both zoom and position, so a pan snaps onto a
|
|
43
|
+
* page without its zoom matching exactly. A held snap releases from wider bands
|
|
44
|
+
* than it captures.
|
|
45
|
+
*/
|
|
46
|
+
function isInCanvasSnapWindow(camera, viewport, target, held) {
|
|
47
|
+
const fit = fitCanvasPage(viewport, target);
|
|
48
|
+
const zoomBand = held ? ZOOM_SNAP_RELEASE : ZOOM_SNAP_CAPTURE;
|
|
49
|
+
const panBand = viewport.width * (held ? PAN_SNAP_RELEASE : PAN_SNAP_CAPTURE);
|
|
50
|
+
return Math.abs(Math.log(camera.scale / fit.scale)) <= zoomBand && Math.abs(canvasTargetOffset(camera, viewport, target)) <= panBand;
|
|
51
|
+
}
|
|
37
52
|
/** Snapped to a target: at its page fit, centered on it. */
|
|
38
53
|
function isCanvasCameraSnapped(camera, viewport, target) {
|
|
39
54
|
const fit = fitCanvasPage(viewport, target);
|
|
@@ -226,4 +241,4 @@ function canvasWheelDelta(delta, mode, viewportSize) {
|
|
|
226
241
|
}
|
|
227
242
|
|
|
228
243
|
//#endregion
|
|
229
|
-
export { CANVAS_OVERSCROLL, CANVAS_WHEEL_ZOOM_RATE, MIN_CANVAS_ZOOM, PAN_SNAP_CAPTURE, PAN_SNAP_RELEASE, ZOOM_SNAP_CAPTURE, ZOOM_SNAP_RELEASE, ZOOM_STRETCH, canvasInsets, canvasMaximumScale, canvasMinimumScale, canvasOverview, canvasVerticalRail, canvasWheelDelta, constrainCanvasCamera, findCanvasSnapTarget, fitCanvas, fitCanvasPage, isCanvasCameraSnapped, isCanvasPageScale, placeCanvasPageAnchor, snapCanvasZoom, stretchCanvasZoom, unstretchCanvasZoom, zoomCanvasAt };
|
|
244
|
+
export { CANVAS_OVERSCROLL, CANVAS_WHEEL_ZOOM_RATE, MIN_CANVAS_ZOOM, PAN_SNAP_CAPTURE, PAN_SNAP_RELEASE, ZOOM_SNAP_CAPTURE, ZOOM_SNAP_RELEASE, ZOOM_STRETCH, canvasInsets, canvasMaximumScale, canvasMinimumScale, canvasOverview, canvasTargetOffset, canvasVerticalRail, canvasWheelDelta, constrainCanvasCamera, findCanvasSnapTarget, fitCanvas, fitCanvasPage, isCanvasCameraSnapped, isCanvasPageScale, isInCanvasSnapWindow, placeCanvasPageAnchor, snapCanvasZoom, stretchCanvasZoom, unstretchCanvasZoom, zoomCanvasAt };
|
|
@@ -2,7 +2,7 @@ import { canvasStore } from "./canvasStore.js";
|
|
|
2
2
|
import { ViewportContinuityContext, captureViewportAnchor, resolveViewportAnchor } from "../preview/viewportContinuity.js";
|
|
3
3
|
import { canvasPageIframe } from "../preview/previewPageFrame.js";
|
|
4
4
|
import { canvasBlockOverlap } from "./canvasFrameDocument.js";
|
|
5
|
-
import { CANVAS_WHEEL_ZOOM_RATE,
|
|
5
|
+
import { CANVAS_WHEEL_ZOOM_RATE, ZOOM_STRETCH, canvasMaximumScale, canvasMinimumScale, canvasOverview, canvasVerticalRail, canvasWheelDelta, constrainCanvasCamera, findCanvasSnapTarget, fitCanvasPage, isCanvasCameraSnapped, isCanvasPageScale, isInCanvasSnapWindow, placeCanvasPageAnchor, snapCanvasZoom, stretchCanvasZoom, unstretchCanvasZoom, zoomCanvasAt } from "./canvasCamera.js";
|
|
6
6
|
import { revealScrollDelta } from "../preview/selectionReveal.js";
|
|
7
7
|
import { createCanvasFlight, createCanvasPan } from "./canvasFlight.js";
|
|
8
8
|
import * as React from "react";
|
|
@@ -233,16 +233,17 @@ function useCanvasCamera(workspaceKey, initialTarget, row) {
|
|
|
233
233
|
};
|
|
234
234
|
const candidate = findCanvasSnapTarget(intended, viewportSize, targets());
|
|
235
235
|
const fit = candidate && fitCanvasPage(viewportSize, candidate);
|
|
236
|
-
if (!candidate || !fit ||
|
|
237
|
-
const held =
|
|
238
|
-
|
|
239
|
-
if (Math.abs(intended.x - fit.x) > band) return intended;
|
|
236
|
+
if (!candidate || !fit || fit.scale < minimumScale) return intended;
|
|
237
|
+
const held = isCanvasCameraSnapped(base, viewportSize, candidate);
|
|
238
|
+
if (!isInCanvasSnapWindow(intended, viewportSize, candidate, held)) return intended;
|
|
240
239
|
if (selection !== candidate.key) rowRef.current?.onSnap?.();
|
|
241
240
|
select(candidate.key);
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
x: fit.x
|
|
245
|
-
|
|
241
|
+
gesture.intendedX += (candidate.left + candidate.width / 2) * (intended.scale - fit.scale);
|
|
242
|
+
return constrain({
|
|
243
|
+
x: fit.x,
|
|
244
|
+
y: rescaleY(intended, fit.scale),
|
|
245
|
+
scale: fit.scale
|
|
246
|
+
});
|
|
246
247
|
};
|
|
247
248
|
const endZoom = () => {
|
|
248
249
|
ownerWindow.clearTimeout(zoomEnd);
|
|
@@ -264,6 +265,10 @@ function useCanvasCamera(workspaceKey, initialTarget, row) {
|
|
|
264
265
|
else delete element.dataset.canvasPan;
|
|
265
266
|
};
|
|
266
267
|
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
268
|
+
const isOverview = (view) => {
|
|
269
|
+
const overview = canvasOverview(viewportSize, contentSize);
|
|
270
|
+
return Math.abs(view.scale - overview.scale) < 1e-8 && Math.abs(view.x - overview.x) < .5 && Math.abs(view.y - overview.y) < .5;
|
|
271
|
+
};
|
|
267
272
|
const remember = () => {
|
|
268
273
|
if (restoredCamera || fittingInitialPage || !viewportSize.width || !viewportSize.height) return;
|
|
269
274
|
canvasStore.send({
|
|
@@ -271,7 +276,7 @@ function useCanvasCamera(workspaceKey, initialTarget, row) {
|
|
|
271
276
|
workspaceKey,
|
|
272
277
|
view: {
|
|
273
278
|
camera,
|
|
274
|
-
fitted:
|
|
279
|
+
fitted: isOverview(camera)
|
|
275
280
|
}
|
|
276
281
|
});
|
|
277
282
|
};
|
|
@@ -516,7 +521,7 @@ function useCanvasCamera(workspaceKey, initialTarget, row) {
|
|
|
516
521
|
};
|
|
517
522
|
const nextContent = measureContent();
|
|
518
523
|
if (nextViewport.width === viewportSize.width && nextViewport.height === viewportSize.height && nextContent.width === contentSize.width && nextContent.height === contentSize.height) return;
|
|
519
|
-
const wasFitted =
|
|
524
|
+
const wasFitted = isOverview(target);
|
|
520
525
|
gesture = void 0;
|
|
521
526
|
const held = nextViewport.width !== viewportSize.width && !flight && !fittingInitialPage ? targetOf(selection) : void 0;
|
|
522
527
|
updateGeometry(nextViewport, nextContent);
|
|
@@ -177,9 +177,15 @@ const ContentCollection = (t0) => {
|
|
|
177
177
|
itemId: record.id
|
|
178
178
|
}),
|
|
179
179
|
className: "focus-visible:bg-accent flex min-w-0 flex-1 items-center gap-2 px-4 py-3 text-sm",
|
|
180
|
-
children: [/* @__PURE__ */
|
|
181
|
-
className: "
|
|
182
|
-
children:
|
|
180
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
181
|
+
className: "flex min-w-0 flex-col items-start text-left",
|
|
182
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
183
|
+
className: "max-w-full truncate",
|
|
184
|
+
children: record.title || "Untitled item"
|
|
185
|
+
}), record.description && /* @__PURE__ */ jsx("span", {
|
|
186
|
+
className: "text-muted-foreground max-w-full truncate text-xs",
|
|
187
|
+
children: record.description
|
|
188
|
+
})]
|
|
183
189
|
}), record.duplicatePageValue && /* @__PURE__ */ jsx("span", {
|
|
184
190
|
className: "text-destructive shrink-0 text-xs",
|
|
185
191
|
title: "Another item's page has the same URL. Change one of them before publishing.",
|
|
@@ -189,7 +195,7 @@ const ContentCollection = (t0) => {
|
|
|
189
195
|
projectUuid,
|
|
190
196
|
collectionId: collection.collectionId,
|
|
191
197
|
id: record.id,
|
|
192
|
-
label: record.
|
|
198
|
+
label: record.title,
|
|
193
199
|
compact: true
|
|
194
200
|
})]
|
|
195
201
|
}, record.id)), /* @__PURE__ */ jsx("li", {
|
|
@@ -244,9 +250,9 @@ const ContentCollection = (t0) => {
|
|
|
244
250
|
return t14;
|
|
245
251
|
};
|
|
246
252
|
const fieldLabel = (name, schema) => schema.title ?? name.replace(/([A-Z])/g, " $1").replace(/^./, (letter) => letter.toUpperCase());
|
|
247
|
-
function CollectionItemForm({ contentSchema,
|
|
253
|
+
function CollectionItemForm({ contentSchema, toTitle, projectUuid, collectionId, record, initialContent, onSaved }) {
|
|
248
254
|
const studioCache = useStudioCache();
|
|
249
|
-
const fields = collectionFormFields(contentSchema,
|
|
255
|
+
const fields = collectionFormFields(contentSchema, toTitle);
|
|
250
256
|
const [savedRecord, setSavedRecord] = useState(record);
|
|
251
257
|
const [error, setError] = useState(null);
|
|
252
258
|
const create = useMutation(collectionMutations.create());
|
|
@@ -502,7 +508,7 @@ const ContentCollectionItemEditor = (t0) => {
|
|
|
502
508
|
if ($[20] !== collectionId || $[21] !== definition || $[22] !== initialContent || $[23] !== itemId || $[24] !== onSaved || $[25] !== projectUuid || $[26] !== recordQuery) {
|
|
503
509
|
t9 = definition && (!itemId || recordQuery.data) && /* @__PURE__ */ jsx(CollectionItemForm, {
|
|
504
510
|
contentSchema: definition.contentSchema,
|
|
505
|
-
|
|
511
|
+
toTitle: definition.toTitle,
|
|
506
512
|
projectUuid,
|
|
507
513
|
collectionId,
|
|
508
514
|
record: itemId ? recordQuery.data : void 0,
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { isLexicalState, lexicalStateToPlainText } from "../../core/lib/lexicalState.js";
|
|
2
|
+
import { titleField } from "../../core/recordItem.js";
|
|
2
3
|
|
|
3
4
|
//#region src/features/content/collection-form.ts
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
/** The form's fields, the one the record's title starts with first. */
|
|
6
|
+
function collectionFormFields(contentSchema, toTitle) {
|
|
7
|
+
const schema = contentSchema;
|
|
8
|
+
const first = titleField(toTitle);
|
|
9
|
+
return Object.entries(schema.properties).sort(([a], [b]) => Number(b === first) - Number(a === first));
|
|
6
10
|
}
|
|
7
11
|
function collectionFormDefaults(fields, content = {}) {
|
|
8
12
|
return Object.fromEntries(fields.map(([name, schema]) => {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/features/og/pageImage.tsx
|
|
5
|
+
/** The size every page image renders at, which the page head states. */
|
|
6
|
+
const PAGE_IMAGE_SIZE = {
|
|
7
|
+
width: 1200,
|
|
8
|
+
height: 630
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A page's image, chosen in order: the editor's custom image, else `/og` for the page, which
|
|
12
|
+
* renders its layout's `toImage` or Camox's default image. `/og` names the page by its path,
|
|
13
|
+
* with its locale's prefix.
|
|
14
|
+
*/
|
|
15
|
+
function pageImageUrl({ origin, path, customImageUrl }) {
|
|
16
|
+
return customImageUrl || `${origin}/og?${new URLSearchParams({ path }).toString()}`;
|
|
17
|
+
}
|
|
18
|
+
/** Camox's default image, for a page whose layout has no `toImage`: its title and project. */
|
|
19
|
+
function DefaultPageImage(t0) {
|
|
20
|
+
const $ = c(9);
|
|
21
|
+
const { page, project } = t0;
|
|
22
|
+
let t1;
|
|
23
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
24
|
+
t1 = {
|
|
25
|
+
display: "flex",
|
|
26
|
+
flexDirection: "column",
|
|
27
|
+
justifyContent: "center",
|
|
28
|
+
width: "100%",
|
|
29
|
+
height: "100%",
|
|
30
|
+
backgroundColor: "#09090b",
|
|
31
|
+
padding: "60px 80px"
|
|
32
|
+
};
|
|
33
|
+
$[0] = t1;
|
|
34
|
+
} else t1 = $[0];
|
|
35
|
+
let t2;
|
|
36
|
+
if ($[1] !== project.name) {
|
|
37
|
+
t2 = project.name && /* @__PURE__ */ jsx("div", {
|
|
38
|
+
style: {
|
|
39
|
+
fontSize: 24,
|
|
40
|
+
color: "#a1a1aa",
|
|
41
|
+
marginBottom: 24,
|
|
42
|
+
textTransform: "uppercase",
|
|
43
|
+
letterSpacing: "0.1em"
|
|
44
|
+
},
|
|
45
|
+
children: project.name
|
|
46
|
+
});
|
|
47
|
+
$[1] = project.name;
|
|
48
|
+
$[2] = t2;
|
|
49
|
+
} else t2 = $[2];
|
|
50
|
+
let t3;
|
|
51
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
52
|
+
t3 = {
|
|
53
|
+
fontSize: 64,
|
|
54
|
+
fontWeight: 700,
|
|
55
|
+
color: "#fafafa",
|
|
56
|
+
lineHeight: 1.2
|
|
57
|
+
};
|
|
58
|
+
$[3] = t3;
|
|
59
|
+
} else t3 = $[3];
|
|
60
|
+
let t4;
|
|
61
|
+
if ($[4] !== page.title) {
|
|
62
|
+
t4 = /* @__PURE__ */ jsx("div", {
|
|
63
|
+
style: t3,
|
|
64
|
+
children: page.title
|
|
65
|
+
});
|
|
66
|
+
$[4] = page.title;
|
|
67
|
+
$[5] = t4;
|
|
68
|
+
} else t4 = $[5];
|
|
69
|
+
let t5;
|
|
70
|
+
if ($[6] !== t2 || $[7] !== t4) {
|
|
71
|
+
t5 = /* @__PURE__ */ jsxs("div", {
|
|
72
|
+
style: t1,
|
|
73
|
+
children: [t2, t4]
|
|
74
|
+
});
|
|
75
|
+
$[6] = t2;
|
|
76
|
+
$[7] = t4;
|
|
77
|
+
$[8] = t5;
|
|
78
|
+
} else t5 = $[8];
|
|
79
|
+
return t5;
|
|
80
|
+
}
|
|
81
|
+
/** Renders a page image as a PNG response. Server only. */
|
|
82
|
+
async function renderPageImage(element) {
|
|
83
|
+
if (import.meta.env?.SSR === false) throw new Error("OG images can only be rendered on the server.");
|
|
84
|
+
const { ImageResponse } = await import("camox/_internal/imageResponse");
|
|
85
|
+
return new ImageResponse(element, PAGE_IMAGE_SIZE);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
export { DefaultPageImage, PAGE_IMAGE_SIZE, pageImageUrl, renderPageImage };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useProjectUuid } from "../../lib/auth.js";
|
|
2
|
+
import { useViewLocale } from "../../lib/view-locale-context.js";
|
|
2
3
|
import { useCamoxApp } from "../provider/components/CamoxAppContext.js";
|
|
3
4
|
import { NormalizedDataProvider, usePageBlocks } from "../../lib/normalized-data.js";
|
|
4
5
|
import { reads, useRead } from "../../lib/studio-reads.js";
|
|
5
6
|
import { BlockErrorBoundary } from "../preview/components/BlockErrorBoundary.js";
|
|
7
|
+
import { curatedLayoutContext } from "../../core/layoutContext.js";
|
|
6
8
|
import { useLocalePath } from "../../lib/view-locale.js";
|
|
7
9
|
import { SharedLayoutContent } from "./SharedLayoutContent.js";
|
|
8
10
|
import { c } from "react/compiler-runtime";
|
|
@@ -84,7 +86,7 @@ function PageBlock(t0) {
|
|
|
84
86
|
}
|
|
85
87
|
/** A curated page as visitors see it, without editing. */
|
|
86
88
|
function CuratedPageContent() {
|
|
87
|
-
const $ = c(
|
|
89
|
+
const $ = c(23);
|
|
88
90
|
const pathname = useLocalePath();
|
|
89
91
|
const projectUuid = useProjectUuid();
|
|
90
92
|
const camoxApp = useCamoxApp();
|
|
@@ -108,49 +110,60 @@ function CuratedPageContent() {
|
|
|
108
110
|
$[5] = t1;
|
|
109
111
|
} else t1 = $[5];
|
|
110
112
|
const layout = t1;
|
|
113
|
+
const { locale } = useViewLocale();
|
|
111
114
|
let t2;
|
|
112
|
-
if ($[6] !==
|
|
113
|
-
t2 =
|
|
114
|
-
$[6] =
|
|
115
|
-
$[7] =
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
if ($[6] !== locale || $[7] !== pageData) {
|
|
116
|
+
t2 = curatedLayoutContext(pageData, locale);
|
|
117
|
+
$[6] = locale;
|
|
118
|
+
$[7] = pageData;
|
|
119
|
+
$[8] = t2;
|
|
120
|
+
} else t2 = $[8];
|
|
121
|
+
const context = t2;
|
|
122
|
+
let t3;
|
|
123
|
+
if ($[9] !== pageBlocks) {
|
|
124
|
+
t3 = pageBlocks.map(_temp);
|
|
125
|
+
$[9] = pageBlocks;
|
|
126
|
+
$[10] = t3;
|
|
127
|
+
} else t3 = $[10];
|
|
128
|
+
const pageBlocksContent = t3;
|
|
118
129
|
if (!layout) {
|
|
119
|
-
let
|
|
120
|
-
if ($[
|
|
121
|
-
|
|
130
|
+
let t4;
|
|
131
|
+
if ($[11] !== pageBlocksContent) {
|
|
132
|
+
t4 = /* @__PURE__ */ jsx("main", {
|
|
122
133
|
className: "flex min-h-screen flex-col",
|
|
123
134
|
children: pageBlocksContent
|
|
124
135
|
});
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
} else
|
|
128
|
-
return
|
|
136
|
+
$[11] = pageBlocksContent;
|
|
137
|
+
$[12] = t4;
|
|
138
|
+
} else t4 = $[12];
|
|
139
|
+
return t4;
|
|
129
140
|
}
|
|
130
|
-
let t3;
|
|
131
|
-
if ($[10] !== afterBlocks || $[11] !== beforeBlocks) {
|
|
132
|
-
t3 = [...beforeBlocks, ...afterBlocks];
|
|
133
|
-
$[10] = afterBlocks;
|
|
134
|
-
$[11] = beforeBlocks;
|
|
135
|
-
$[12] = t3;
|
|
136
|
-
} else t3 = $[12];
|
|
137
141
|
let t4;
|
|
138
|
-
if ($[13] !==
|
|
139
|
-
t4 =
|
|
142
|
+
if ($[13] !== afterBlocks || $[14] !== beforeBlocks) {
|
|
143
|
+
t4 = [...beforeBlocks, ...afterBlocks];
|
|
144
|
+
$[13] = afterBlocks;
|
|
145
|
+
$[14] = beforeBlocks;
|
|
146
|
+
$[15] = t4;
|
|
147
|
+
} else t4 = $[15];
|
|
148
|
+
let t5;
|
|
149
|
+
if ($[16] !== context || $[17] !== layout || $[18] !== layoutFiles || $[19] !== layoutItems || $[20] !== pageBlocksContent || $[21] !== t4) {
|
|
150
|
+
t5 = /* @__PURE__ */ jsx(SharedLayoutContent, {
|
|
140
151
|
layout,
|
|
141
|
-
|
|
152
|
+
context,
|
|
153
|
+
blocks: t4,
|
|
142
154
|
files: layoutFiles,
|
|
143
155
|
repeatableItems: layoutItems,
|
|
144
156
|
children: pageBlocksContent
|
|
145
157
|
});
|
|
146
|
-
$[
|
|
147
|
-
$[
|
|
148
|
-
$[
|
|
149
|
-
$[
|
|
150
|
-
$[
|
|
151
|
-
$[
|
|
152
|
-
|
|
153
|
-
|
|
158
|
+
$[16] = context;
|
|
159
|
+
$[17] = layout;
|
|
160
|
+
$[18] = layoutFiles;
|
|
161
|
+
$[19] = layoutItems;
|
|
162
|
+
$[20] = pageBlocksContent;
|
|
163
|
+
$[21] = t4;
|
|
164
|
+
$[22] = t5;
|
|
165
|
+
} else t5 = $[22];
|
|
166
|
+
return t5;
|
|
154
167
|
}
|
|
155
168
|
function _temp(block) {
|
|
156
169
|
return /* @__PURE__ */ jsx(BlockErrorBoundary, {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { useViewLocale } from "../../lib/view-locale-context.js";
|
|
1
2
|
import { usePageBlocks } from "../../lib/normalized-data.js";
|
|
3
|
+
import { asCollectionItem, recordPageValues } from "../../core/recordItem.js";
|
|
4
|
+
import { buildLayoutContext } from "../../core/layoutContext.js";
|
|
2
5
|
import { SharedLayoutContent } from "./SharedLayoutContent.js";
|
|
3
6
|
import { c } from "react/compiler-runtime";
|
|
4
7
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -6,7 +9,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
9
|
//#region src/features/page/DerivedPageContent.tsx
|
|
7
10
|
const EMPTY_PAGE = { blockIds: [] };
|
|
8
11
|
function DerivedPageContent(t0) {
|
|
9
|
-
const $ = c(
|
|
12
|
+
const $ = c(18);
|
|
10
13
|
const { camoxApp, derived } = t0;
|
|
11
14
|
let t1;
|
|
12
15
|
if ($[0] !== derived.layout) {
|
|
@@ -18,38 +21,62 @@ function DerivedPageContent(t0) {
|
|
|
18
21
|
$[1] = t1;
|
|
19
22
|
} else t1 = $[1];
|
|
20
23
|
const { beforeBlocks, afterBlocks, layoutFiles, layoutItems } = usePageBlocks(t1);
|
|
24
|
+
const { locale } = useViewLocale();
|
|
25
|
+
let layout;
|
|
26
|
+
let result;
|
|
21
27
|
let t2;
|
|
22
|
-
if ($[2] !== camoxApp || $[3] !== derived
|
|
23
|
-
|
|
28
|
+
if ($[2] !== camoxApp || $[3] !== derived || $[4] !== locale) {
|
|
29
|
+
layout = camoxApp.getLayoutById(derived.layoutId);
|
|
30
|
+
if (!layout) throw new Error(`Unknown derived layout: ${derived.layoutId}`);
|
|
31
|
+
const { page, result: t3 } = derived;
|
|
32
|
+
result = t3;
|
|
33
|
+
const record = asCollectionItem(result);
|
|
34
|
+
const collection = record && camoxApp.getCollectionById(record.collectionId);
|
|
35
|
+
t2 = buildLayoutContext(layout._internal, {
|
|
36
|
+
path: page?.path ?? "",
|
|
37
|
+
locale: locale.tag,
|
|
38
|
+
projectName: page?.projectName ?? "",
|
|
39
|
+
data: result?.data,
|
|
40
|
+
params: page?.params,
|
|
41
|
+
record: record && collection ? recordPageValues(collection, record) : void 0
|
|
42
|
+
});
|
|
24
43
|
$[2] = camoxApp;
|
|
25
|
-
$[3] = derived
|
|
26
|
-
$[4] =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
$[3] = derived;
|
|
45
|
+
$[4] = locale;
|
|
46
|
+
$[5] = layout;
|
|
47
|
+
$[6] = result;
|
|
48
|
+
$[7] = t2;
|
|
49
|
+
} else {
|
|
50
|
+
layout = $[5];
|
|
51
|
+
result = $[6];
|
|
52
|
+
t2 = $[7];
|
|
53
|
+
}
|
|
54
|
+
const context = t2;
|
|
30
55
|
let t3;
|
|
31
|
-
if ($[
|
|
56
|
+
if ($[8] !== afterBlocks || $[9] !== beforeBlocks) {
|
|
32
57
|
t3 = [...beforeBlocks, ...afterBlocks];
|
|
33
|
-
$[
|
|
34
|
-
$[
|
|
35
|
-
$[
|
|
36
|
-
} else t3 = $[
|
|
58
|
+
$[8] = afterBlocks;
|
|
59
|
+
$[9] = beforeBlocks;
|
|
60
|
+
$[10] = t3;
|
|
61
|
+
} else t3 = $[10];
|
|
37
62
|
let t4;
|
|
38
|
-
if ($[
|
|
63
|
+
if ($[11] !== context || $[12] !== layout || $[13] !== layoutFiles || $[14] !== layoutItems || $[15] !== result || $[16] !== t3) {
|
|
39
64
|
t4 = /* @__PURE__ */ jsx(SharedLayoutContent, {
|
|
40
65
|
layout,
|
|
41
|
-
|
|
66
|
+
context,
|
|
67
|
+
result,
|
|
42
68
|
blocks: t3,
|
|
43
69
|
files: layoutFiles,
|
|
44
70
|
repeatableItems: layoutItems
|
|
45
71
|
});
|
|
46
|
-
$[
|
|
47
|
-
$[
|
|
48
|
-
$[
|
|
49
|
-
$[
|
|
50
|
-
$[
|
|
51
|
-
$[
|
|
52
|
-
|
|
72
|
+
$[11] = context;
|
|
73
|
+
$[12] = layout;
|
|
74
|
+
$[13] = layoutFiles;
|
|
75
|
+
$[14] = layoutItems;
|
|
76
|
+
$[15] = result;
|
|
77
|
+
$[16] = t3;
|
|
78
|
+
$[17] = t4;
|
|
79
|
+
} else t4 = $[17];
|
|
53
80
|
return t4;
|
|
54
81
|
}
|
|
55
82
|
|
|
@@ -6,8 +6,8 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
6
|
//#region src/features/page/SharedLayoutContent.tsx
|
|
7
7
|
/** Shared before/after rendering for both curated and data-derived pages. */
|
|
8
8
|
function SharedLayoutContent(t0) {
|
|
9
|
-
const $ = c(
|
|
10
|
-
const { layout, blocks, files, repeatableItems, result, children } = t0;
|
|
9
|
+
const $ = c(16);
|
|
10
|
+
const { layout, context, blocks, files, repeatableItems, result, children } = t0;
|
|
11
11
|
let result_0;
|
|
12
12
|
if ($[0] !== blocks) {
|
|
13
13
|
result_0 = {};
|
|
@@ -22,41 +22,45 @@ function SharedLayoutContent(t0) {
|
|
|
22
22
|
$[1] = result_0;
|
|
23
23
|
} else result_0 = $[1];
|
|
24
24
|
const layoutBlocks = result_0;
|
|
25
|
-
const
|
|
25
|
+
const ToReact = layout._internal.toReact;
|
|
26
26
|
let t1;
|
|
27
|
-
if ($[2] !==
|
|
28
|
-
t1 = /* @__PURE__ */ jsx(
|
|
29
|
-
|
|
27
|
+
if ($[2] !== ToReact || $[3] !== children || $[4] !== context) {
|
|
28
|
+
t1 = /* @__PURE__ */ jsx(ToReact, {
|
|
29
|
+
...context,
|
|
30
|
+
children
|
|
31
|
+
});
|
|
32
|
+
$[2] = ToReact;
|
|
30
33
|
$[3] = children;
|
|
31
|
-
$[4] =
|
|
32
|
-
|
|
34
|
+
$[4] = context;
|
|
35
|
+
$[5] = t1;
|
|
36
|
+
} else t1 = $[5];
|
|
33
37
|
let t2;
|
|
34
|
-
if ($[
|
|
38
|
+
if ($[6] !== layout._internal.Provider || $[7] !== layoutBlocks || $[8] !== result || $[9] !== t1) {
|
|
35
39
|
t2 = /* @__PURE__ */ jsx(layout._internal.Provider, {
|
|
36
40
|
layoutBlocks,
|
|
37
41
|
result,
|
|
38
42
|
children: t1
|
|
39
43
|
});
|
|
40
|
-
$[
|
|
41
|
-
$[
|
|
42
|
-
$[
|
|
43
|
-
$[
|
|
44
|
-
$[
|
|
45
|
-
} else t2 = $[
|
|
44
|
+
$[6] = layout._internal.Provider;
|
|
45
|
+
$[7] = layoutBlocks;
|
|
46
|
+
$[8] = result;
|
|
47
|
+
$[9] = t1;
|
|
48
|
+
$[10] = t2;
|
|
49
|
+
} else t2 = $[10];
|
|
46
50
|
let t3;
|
|
47
|
-
if ($[
|
|
51
|
+
if ($[11] !== blocks || $[12] !== files || $[13] !== repeatableItems || $[14] !== t2) {
|
|
48
52
|
t3 = /* @__PURE__ */ jsx(NormalizedDataProvider, {
|
|
49
53
|
files,
|
|
50
54
|
repeatableItems,
|
|
51
55
|
blocks,
|
|
52
56
|
children: t2
|
|
53
57
|
});
|
|
54
|
-
$[
|
|
55
|
-
$[
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
} else t3 = $[
|
|
58
|
+
$[11] = blocks;
|
|
59
|
+
$[12] = files;
|
|
60
|
+
$[13] = repeatableItems;
|
|
61
|
+
$[14] = t2;
|
|
62
|
+
$[15] = t3;
|
|
63
|
+
} else t3 = $[15];
|
|
60
64
|
return t3;
|
|
61
65
|
}
|
|
62
66
|
|