camox 0.77.0 → 0.78.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 (29) hide show
  1. package/dist/features/canvas/CamoxCanvas.js +187 -197
  2. package/dist/features/canvas/canvasCameraController.js +1 -1
  3. package/dist/features/canvas/canvasItems.js +40 -9
  4. package/dist/features/canvas/sidebar/ContentSidebarFrame.js +15 -11
  5. package/dist/features/canvas/useCanvasLayout.js +34 -0
  6. package/dist/features/memory/CamoxMemory.js +747 -0
  7. package/dist/features/preview/EditablePageExperience.js +2 -0
  8. package/dist/features/runtime/publicCache.d.ts +2 -0
  9. package/dist/features/runtime/publicCache.js +27 -4
  10. package/dist/features/runtime/runtime.d.ts +1 -1
  11. package/dist/features/runtime/runtime.js +34 -15
  12. package/dist/features/studio/FollowAgentProvider.js +1 -1
  13. package/dist/features/studio/components/AgentSidebar.js +22 -16
  14. package/dist/features/studio/components/DraftBar.js +167 -103
  15. package/dist/features/studio/components/{ReviewDraftDialog.js → DraftReview.js} +191 -218
  16. package/dist/features/studio/components/DraftsControl.js +174 -202
  17. package/dist/features/studio/components/DraftsSheet.js +102 -94
  18. package/dist/features/studio/components/Navbar.js +121 -84
  19. package/dist/features/studio/components/PublishedTab.js +21 -20
  20. package/dist/features/studio/routes.js +3 -1
  21. package/dist/features/studio/studioStore.js +12 -9
  22. package/dist/features/studio/usePublishDraft.js +116 -0
  23. package/dist/features/studio/viewSwitch.js +10 -7
  24. package/dist/lib/queries.js +7 -1
  25. package/dist/lib/studio-reads.js +6 -0
  26. package/dist/package.js +1 -1
  27. package/dist/studio.css +1 -1
  28. package/package.json +5 -5
  29. package/LICENSE.md +0 -21
@@ -2,7 +2,38 @@ import { fitCanvasPage } from "./canvasCamera.js";
2
2
  import { CANVAS_DEVICES } from "./canvasPages.js";
3
3
 
4
4
  //#region src/features/canvas/canvasItems.ts
5
- const CANVAS_SLOT_WIDTH = CANVAS_DEVICES.desktop.width;
5
+ /** The narrowest a Page's area gets: the desktop its frame emulates. */
6
+ const MIN_CANVAS_SLOT_WIDTH = CANVAS_DEVICES.desktop.width;
7
+ /**
8
+ * The width of a Page's area in the Canvas row, which a desktop frame fills. Device selection
9
+ * resizes frames, not their area. A working area wider than the desktop widens it, so a snapped
10
+ * Page shows at its true size, never enlarged; a narrower one keeps the desktop, zoomed out.
11
+ */
12
+ function canvasSlotWidth(workingAreaWidth) {
13
+ return Math.max(MIN_CANVAS_SLOT_WIDTH, workingAreaWidth - 16 * 2);
14
+ }
15
+ /** How much wider than CMS_SIDEBAR_WIDTH each sidebar beside the Canvas gets, at most. */
16
+ const MAX_CMS_SIDEBAR_GROWTH = 100;
17
+ /**
18
+ * How the window splits between the sidebars and the Canvas row. Once a snapped desktop Page
19
+ * shows at its true size, extra width first widens both sidebars, by up to
20
+ * MAX_CMS_SIDEBAR_GROWTH each, then widens the Pages' areas.
21
+ */
22
+ function canvasLayout(windowWidth) {
23
+ const snappedDesktop = MIN_CANVAS_SLOT_WIDTH + 16 * 2;
24
+ const spare = (windowWidth - 265 * 2 - snappedDesktop) / 2;
25
+ const sidebarWidth = 265 + Math.floor(Math.min(100, Math.max(0, spare)));
26
+ const width = Math.max(0, windowWidth - sidebarWidth * 2);
27
+ const slotWidth = canvasSlotWidth(width);
28
+ return {
29
+ sidebarWidth,
30
+ slotWidth,
31
+ gap: canvasItemGap({
32
+ width,
33
+ height: 0
34
+ }, sidebarWidth, slotWidth)
35
+ };
36
+ }
6
37
  /** World-space bounds of the gap, so very narrow or wide canvases still space Pages alike. */
7
38
  const MIN_CANVAS_ITEM_GAP = 96;
8
39
  const MAX_CANVAS_ITEM_GAP = 320;
@@ -11,27 +42,27 @@ const MAX_CANVAS_ITEM_GAP = 320;
11
42
  * across the sidebar laid over the working area's edge. The snapped zoom follows the working
12
43
  * area's width, so the gap does too.
13
44
  */
14
- function canvasItemGap(workingArea, sidebarWidth) {
45
+ function canvasItemGap(workingArea, sidebarWidth, slotWidth = canvasSlotWidth(workingArea.width)) {
15
46
  const fit = fitCanvasPage(workingArea, {
16
47
  left: 0,
17
- width: CANVAS_SLOT_WIDTH
48
+ width: slotWidth
18
49
  });
19
- const gap = ((workingArea.width - CANVAS_SLOT_WIDTH * fit.scale) / 2 + sidebarWidth / 2) / fit.scale;
50
+ const gap = ((workingArea.width - slotWidth * fit.scale) / 2 + sidebarWidth / 2) / fit.scale;
20
51
  return Math.min(320, Math.max(96, gap));
21
52
  }
22
53
  /**
23
54
  * World-space positions of the Canvas row, matching its flex layout: every Page
24
55
  * side by side, in Canvas order, a gap apart.
25
56
  */
26
- function positionCanvasPages(pages, gap) {
57
+ function positionCanvasPages(pages, gap, slotWidth) {
27
58
  return {
28
59
  items: pages.map((page, index) => ({
29
60
  key: page.key,
30
61
  page,
31
- left: index * (CANVAS_SLOT_WIDTH + gap),
32
- width: CANVAS_SLOT_WIDTH
62
+ left: index * (slotWidth + gap),
63
+ width: slotWidth
33
64
  })),
34
- width: Math.max(0, pages.length * (CANVAS_SLOT_WIDTH + gap) - gap)
65
+ width: Math.max(0, pages.length * (slotWidth + gap) - gap)
35
66
  };
36
67
  }
37
68
  function canvasSnapTargets(items) {
@@ -43,4 +74,4 @@ function canvasSnapTargets(items) {
43
74
  }
44
75
 
45
76
  //#endregion
46
- export { CANVAS_SLOT_WIDTH, canvasItemGap, canvasSnapTargets, positionCanvasPages };
77
+ export { MIN_CANVAS_SLOT_WIDTH, canvasItemGap, canvasLayout, canvasSlotWidth, canvasSnapTargets, positionCanvasPages };
@@ -1,3 +1,4 @@
1
+ import { useCanvasLayout } from "../useCanvasLayout.js";
1
2
  import { c } from "react/compiler-runtime";
2
3
  import { jsx } from "react/jsx-runtime";
3
4
 
@@ -8,7 +9,7 @@ import { jsx } from "react/jsx-runtime";
8
9
  * around them, the Canvas shows through.
9
10
  */
10
11
  function ContentSidebarFrame(t0) {
11
- const $ = c(9);
12
+ const $ = c(11);
12
13
  let children;
13
14
  let label;
14
15
  let props;
@@ -23,13 +24,15 @@ function ContentSidebarFrame(t0) {
23
24
  label = $[2];
24
25
  props = $[3];
25
26
  }
27
+ const { sidebarWidth } = useCanvasLayout();
26
28
  let t1;
27
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
28
- t1 = { width: 265 };
29
- $[4] = t1;
30
- } else t1 = $[4];
29
+ if ($[4] !== sidebarWidth) {
30
+ t1 = { width: sidebarWidth };
31
+ $[4] = sidebarWidth;
32
+ $[5] = t1;
33
+ } else t1 = $[5];
31
34
  let t2;
32
- if ($[5] !== children || $[6] !== label || $[7] !== props) {
35
+ if ($[6] !== children || $[7] !== label || $[8] !== props || $[9] !== t1) {
33
36
  t2 = /* @__PURE__ */ jsx("aside", {
34
37
  "aria-label": label,
35
38
  className: "absolute inset-y-0 left-0 z-10 flex flex-col py-2",
@@ -37,11 +40,12 @@ function ContentSidebarFrame(t0) {
37
40
  ...props,
38
41
  children
39
42
  });
40
- $[5] = children;
41
- $[6] = label;
42
- $[7] = props;
43
- $[8] = t2;
44
- } else t2 = $[8];
43
+ $[6] = children;
44
+ $[7] = label;
45
+ $[8] = props;
46
+ $[9] = t1;
47
+ $[10] = t2;
48
+ } else t2 = $[10];
45
49
  return t2;
46
50
  }
47
51
 
@@ -0,0 +1,34 @@
1
+ import { canvasLayout } from "./canvasItems.js";
2
+ import { c } from "react/compiler-runtime";
3
+ import * as React from "react";
4
+
5
+ //#region src/features/canvas/useCanvasLayout.ts
6
+ function subscribeToWindowWidth(onChange) {
7
+ window.addEventListener("resize", onChange);
8
+ return () => window.removeEventListener("resize", onChange);
9
+ }
10
+ /**
11
+ * The sidebars' width beside the Canvas, each Page's area in the Canvas row, and the gap between
12
+ * them. The Canvas spans the window, so all follow the window's width. They read the window from
13
+ * the first render, before the camera measures the Canvas.
14
+ */
15
+ function useCanvasLayout() {
16
+ const $ = c(2);
17
+ const windowWidth = React.useSyncExternalStore(subscribeToWindowWidth, _temp, _temp2);
18
+ let t0;
19
+ if ($[0] !== windowWidth) {
20
+ t0 = canvasLayout(windowWidth);
21
+ $[0] = windowWidth;
22
+ $[1] = t0;
23
+ } else t0 = $[1];
24
+ return t0;
25
+ }
26
+ function _temp2() {
27
+ return 0;
28
+ }
29
+ function _temp() {
30
+ return window.innerWidth;
31
+ }
32
+
33
+ //#endregion
34
+ export { useCanvasLayout };