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.
Files changed (82) hide show
  1. package/dist/core/createApp.d.ts +19 -6
  2. package/dist/core/createApp.js +7 -2
  3. package/dist/core/createBlock.js +54 -43
  4. package/dist/core/createCollection.d.ts +25 -7
  5. package/dist/core/createCollection.js +28 -9
  6. package/dist/core/createLayout.d.ts +98 -71
  7. package/dist/core/createLayout.js +10 -16
  8. package/dist/core/derivedRoutes.js +1 -1
  9. package/dist/core/editing/BlockEditingRuntime.d.ts +3 -2
  10. package/dist/core/editing/CompleteBlockEditingRuntime.js +2 -1
  11. package/dist/core/editing/createEditableBlock.d.ts +59 -19
  12. package/dist/core/editing/createEditableBlock.js +162 -151
  13. package/dist/core/editing/useLatestRecord.js +7 -7
  14. package/dist/core/layoutContext.d.ts +54 -0
  15. package/dist/core/layoutContext.js +66 -0
  16. package/dist/core/lib/contentType.d.ts +91 -4
  17. package/dist/core/lib/contentType.js +84 -7
  18. package/dist/core/lib/recordScope.js +19 -17
  19. package/dist/core/lib/reference.d.ts +6 -2
  20. package/dist/core/recordItem.js +55 -2
  21. package/dist/core/requestContext.d.ts +18 -0
  22. package/dist/core/structuredData.d.ts +126 -0
  23. package/dist/core/structuredData.js +40 -0
  24. package/dist/features/canvas/canvasCamera.js +21 -6
  25. package/dist/features/canvas/sidebar/CanvasSidebarFrame.js +1 -1
  26. package/dist/features/canvas/useCanvasCamera.js +16 -11
  27. package/dist/features/content/ContentCollection.js +13 -7
  28. package/dist/features/content/collection-form.js +6 -2
  29. package/dist/features/content/components/MissingFromLocale.js +1 -1
  30. package/dist/features/og/pageImage.js +89 -0
  31. package/dist/features/page/CuratedPageContent.js +45 -32
  32. package/dist/features/page/DerivedPageContent.js +49 -22
  33. package/dist/features/page/SharedLayoutContent.js +26 -22
  34. package/dist/features/preview/CamoxPreview.js +176 -145
  35. package/dist/features/preview/components/AddBlockSheet.js +1 -0
  36. package/dist/features/preview/components/BlockActionsPopover.js +8 -6
  37. package/dist/features/preview/components/PageInfo.js +244 -264
  38. package/dist/features/preview/components/PageTree.js +63 -53
  39. package/dist/features/preview/components/PreviewToolbar.js +74 -85
  40. package/dist/features/preview/components/RecordCard.js +50 -34
  41. package/dist/features/preview/components/RecordCombobox.js +12 -5
  42. package/dist/features/preview/components/ReferenceFieldEditor.js +4 -2
  43. package/dist/features/preview/components/ReferenceListFieldEditor.js +24 -19
  44. package/dist/features/preview/components/RepeatableItemsList.js +62 -46
  45. package/dist/features/preview/components/SelectionEditor.js +3 -2
  46. package/dist/features/preview/components/useFieldWriter.js +2 -4
  47. package/dist/features/preview/components/useRecordView.js +2 -2
  48. package/dist/features/preview/entityName.js +11 -0
  49. package/dist/features/preview/pageRecord.js +17 -18
  50. package/dist/features/provider/CamoxProvider.js +8 -16
  51. package/dist/features/provider/CoreCamoxProvider.js +1 -6
  52. package/dist/features/provider/signInShortcut.js +60 -0
  53. package/dist/features/routes/pageRuntime.d.ts +15 -1
  54. package/dist/features/routes/pageRuntime.js +35 -38
  55. package/dist/features/runtime/RuntimeChrome.js +2 -2
  56. package/dist/features/runtime/breadcrumbs.js +68 -0
  57. package/dist/features/runtime/livePages.js +3 -2
  58. package/dist/features/runtime/pageApp.js +11 -39
  59. package/dist/features/runtime/pageGraph.js +92 -0
  60. package/dist/features/runtime/projectLogo.js +110 -0
  61. package/dist/features/runtime/runtime.d.ts +11 -6
  62. package/dist/features/runtime/runtime.js +278 -55
  63. package/dist/features/runtime/runtimeRoutes.d.ts +1 -0
  64. package/dist/features/runtime/runtimeRoutes.js +1 -0
  65. package/dist/features/runtime/structuredData.js +213 -0
  66. package/dist/features/studio/components/ChatSidebar.js +5 -5
  67. package/dist/features/studio/components/ProjectMenu.js +127 -100
  68. package/dist/features/studio/components/SocialProfilesDialog.js +342 -0
  69. package/dist/features/studio/components/ThreadMessages.js +2 -2
  70. package/dist/features/vite/blockBoilerplate.js +3 -2
  71. package/dist/features/vite/layoutGeneration.js +3 -2
  72. package/dist/features/vite/vite.js +1 -0
  73. package/dist/lib/queries.d.ts +4 -0
  74. package/dist/lib/queries.js +1 -0
  75. package/dist/lib/studio-reads.js +3 -1
  76. package/dist/package.js +1 -1
  77. package/dist/studio.css +1 -1
  78. package/package.json +5 -4
  79. package/skills/camox/references/block-definitions.md +105 -25
  80. package/skills/camox/references/layout-definitions.md +53 -17
  81. package/skills/camox/references/routed-layouts.md +17 -14
  82. 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 = .01056;
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 = .14;
30
- const ZOOM_SNAP_RELEASE = .18;
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 = .12;
33
- const PAN_SNAP_RELEASE = .18;
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 };
@@ -24,7 +24,7 @@ function CanvasSidebarFrame(t0) {
24
24
  }
25
25
  let t1;
26
26
  if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
27
- t1 = { width: 250 };
27
+ t1 = { width: 265 };
28
28
  $[4] = t1;
29
29
  } else t1 = $[4];
30
30
  let t2;
@@ -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, PAN_SNAP_CAPTURE, PAN_SNAP_RELEASE, ZOOM_STRETCH, canvasMaximumScale, canvasMinimumScale, canvasOverview, canvasVerticalRail, canvasWheelDelta, constrainCanvasCamera, findCanvasSnapTarget, fitCanvasPage, isCanvasCameraSnapped, isCanvasPageScale, placeCanvasPageAnchor, snapCanvasZoom, stretchCanvasZoom, unstretchCanvasZoom, zoomCanvasAt } from "./canvasCamera.js";
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 || !isCanvasPageScale(base.scale, fit.scale)) return intended;
237
- const held = Math.abs(base.x - fit.x) < 1e-8;
238
- const band = viewportSize.width * (held ? PAN_SNAP_RELEASE : PAN_SNAP_CAPTURE);
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
- return {
243
- ...intended,
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: Math.abs(camera.scale - minimumScale) < 1e-8
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 = Math.abs(target.scale - minimumScale) < 1e-8;
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__ */ jsx("span", {
181
- className: "truncate",
182
- children: record.label || "Untitled item"
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.label,
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, label, projectUuid, collectionId, record, initialContent, onSaved }) {
253
+ function CollectionItemForm({ contentSchema, toTitle, projectUuid, collectionId, record, initialContent, onSaved }) {
248
254
  const studioCache = useStudioCache();
249
- const fields = collectionFormFields(contentSchema, label);
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
- label: definition.label,
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
- function collectionFormFields(contentSchema, label) {
5
- return Object.entries(contentSchema.properties).sort(([a], [b]) => Number(b === label) - Number(a === label));
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]) => {
@@ -144,7 +144,7 @@ function missingGroups(missing, collections) {
144
144
  entity: "record",
145
145
  id: record.id,
146
146
  collectionId: record.collectionId,
147
- name: record.label || "Untitled item"
147
+ name: record.title || "Untitled item"
148
148
  }))
149
149
  });
150
150
  }
@@ -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(19);
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] !== pageBlocks) {
113
- t2 = pageBlocks.map(_temp);
114
- $[6] = pageBlocks;
115
- $[7] = t2;
116
- } else t2 = $[7];
117
- const pageBlocksContent = t2;
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 t3;
120
- if ($[8] !== pageBlocksContent) {
121
- t3 = /* @__PURE__ */ jsx("main", {
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
- $[8] = pageBlocksContent;
126
- $[9] = t3;
127
- } else t3 = $[9];
128
- return t3;
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] !== layout || $[14] !== layoutFiles || $[15] !== layoutItems || $[16] !== pageBlocksContent || $[17] !== t3) {
139
- t4 = /* @__PURE__ */ jsx(SharedLayoutContent, {
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
- blocks: t3,
152
+ context,
153
+ blocks: t4,
142
154
  files: layoutFiles,
143
155
  repeatableItems: layoutItems,
144
156
  children: pageBlocksContent
145
157
  });
146
- $[13] = layout;
147
- $[14] = layoutFiles;
148
- $[15] = layoutItems;
149
- $[16] = pageBlocksContent;
150
- $[17] = t3;
151
- $[18] = t4;
152
- } else t4 = $[18];
153
- return t4;
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(14);
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.layoutId) {
23
- t2 = camoxApp.getLayoutById(derived.layoutId);
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.layoutId;
26
- $[4] = t2;
27
- } else t2 = $[4];
28
- const layout = t2;
29
- if (!layout) throw new Error(`Unknown derived layout: ${derived.layoutId}`);
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 ($[5] !== afterBlocks || $[6] !== beforeBlocks) {
56
+ if ($[8] !== afterBlocks || $[9] !== beforeBlocks) {
32
57
  t3 = [...beforeBlocks, ...afterBlocks];
33
- $[5] = afterBlocks;
34
- $[6] = beforeBlocks;
35
- $[7] = t3;
36
- } else t3 = $[7];
58
+ $[8] = afterBlocks;
59
+ $[9] = beforeBlocks;
60
+ $[10] = t3;
61
+ } else t3 = $[10];
37
62
  let t4;
38
- if ($[8] !== derived.result || $[9] !== layout || $[10] !== layoutFiles || $[11] !== layoutItems || $[12] !== t3) {
63
+ if ($[11] !== context || $[12] !== layout || $[13] !== layoutFiles || $[14] !== layoutItems || $[15] !== result || $[16] !== t3) {
39
64
  t4 = /* @__PURE__ */ jsx(SharedLayoutContent, {
40
65
  layout,
41
- result: derived.result,
66
+ context,
67
+ result,
42
68
  blocks: t3,
43
69
  files: layoutFiles,
44
70
  repeatableItems: layoutItems
45
71
  });
46
- $[8] = derived.result;
47
- $[9] = layout;
48
- $[10] = layoutFiles;
49
- $[11] = layoutItems;
50
- $[12] = t3;
51
- $[13] = t4;
52
- } else t4 = $[13];
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(15);
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 Component = layout._internal.component;
25
+ const ToReact = layout._internal.toReact;
26
26
  let t1;
27
- if ($[2] !== Component || $[3] !== children) {
28
- t1 = /* @__PURE__ */ jsx(Component, { children });
29
- $[2] = Component;
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] = t1;
32
- } else t1 = $[4];
34
+ $[4] = context;
35
+ $[5] = t1;
36
+ } else t1 = $[5];
33
37
  let t2;
34
- if ($[5] !== layout._internal.Provider || $[6] !== layoutBlocks || $[7] !== result || $[8] !== t1) {
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
- $[5] = layout._internal.Provider;
41
- $[6] = layoutBlocks;
42
- $[7] = result;
43
- $[8] = t1;
44
- $[9] = t2;
45
- } else t2 = $[9];
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 ($[10] !== blocks || $[11] !== files || $[12] !== repeatableItems || $[13] !== t2) {
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
- $[10] = blocks;
55
- $[11] = files;
56
- $[12] = repeatableItems;
57
- $[13] = t2;
58
- $[14] = t3;
59
- } else t3 = $[14];
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