camox 0.76.1 → 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 (33) hide show
  1. package/dist/core/lib/artifactTheme.js +43 -6
  2. package/dist/features/canvas/CamoxCanvas.js +187 -197
  3. package/dist/features/canvas/canvasCameraController.js +1 -1
  4. package/dist/features/canvas/canvasItems.js +40 -9
  5. package/dist/features/canvas/sidebar/ContentSidebarFrame.js +15 -11
  6. package/dist/features/canvas/useCanvasLayout.js +34 -0
  7. package/dist/features/memory/CamoxMemory.js +747 -0
  8. package/dist/features/preview/EditablePageExperience.js +2 -0
  9. package/dist/features/runtime/publicCache.d.ts +2 -0
  10. package/dist/features/runtime/publicCache.js +27 -4
  11. package/dist/features/runtime/runtime.d.ts +1 -1
  12. package/dist/features/runtime/runtime.js +34 -15
  13. package/dist/features/studio/FollowAgentProvider.js +1 -1
  14. package/dist/features/studio/components/AgentSidebar.js +22 -16
  15. package/dist/features/studio/components/DraftBar.js +167 -103
  16. package/dist/features/studio/components/{ReviewDraftDialog.js → DraftReview.js} +191 -218
  17. package/dist/features/studio/components/DraftsControl.js +174 -202
  18. package/dist/features/studio/components/DraftsSheet.js +102 -94
  19. package/dist/features/studio/components/LocalePicker.js +518 -134
  20. package/dist/features/studio/components/Navbar.js +121 -84
  21. package/dist/features/studio/components/PublishedTab.js +21 -20
  22. package/dist/features/studio/routes.js +3 -1
  23. package/dist/features/studio/studioStore.js +12 -9
  24. package/dist/features/studio/usePublishDraft.js +116 -0
  25. package/dist/features/studio/viewSwitch.js +10 -7
  26. package/dist/lib/locale-path.js +2 -2
  27. package/dist/lib/queries.js +12 -2
  28. package/dist/lib/studio-reads.js +6 -0
  29. package/dist/package.js +1 -1
  30. package/dist/studio.css +1 -1
  31. package/package.json +5 -5
  32. package/skills/camox/references/artifacts.md +7 -0
  33. package/LICENSE.md +0 -21
@@ -39,18 +39,55 @@ function readArtifactTheme(frame) {
39
39
  function isThemeAttribute(name) {
40
40
  return name === "class" || name === "style" || !!name?.startsWith("data-");
41
41
  }
42
+ const isStylesheet = (node) => node?.nodeName === "STYLE" || node?.nodeName === "LINK" && /\bstylesheet\b/i.test(node.getAttribute("rel") ?? "");
43
+ /** Whether a change in the page's head may change its stylesheets. */
44
+ function isStylesheetChange(record) {
45
+ if (record.type === "childList") {
46
+ if (isStylesheet(record.target)) return true;
47
+ return [...record.addedNodes, ...record.removedNodes].some(isStylesheet);
48
+ }
49
+ const target = record.type === "characterData" ? record.target.parentNode : record.target;
50
+ return isStylesheet(target);
51
+ }
42
52
  /**
43
- * Calls `onChange` when the `class`, `style` or `data-*` attributes of the frame or one of its
44
- * ancestors change, as these may change the tokens at its position. Returns a disconnect.
53
+ * Calls `onChange` when the tokens at the frame's position may have changed: when the `class`,
54
+ * `style` or `data-*` attributes of the frame or one of its ancestors change, or when the page's
55
+ * stylesheets do, as the studio swaps them when it shows Live or a draft, or a draft's code
56
+ * changes them. A new stylesheet's tokens only resolve once it loaded, so its load counts too.
57
+ * Returns a disconnect.
45
58
  */
46
59
  function observeArtifactTheme(frame, onChange) {
47
- const page = frame.ownerDocument.defaultView;
60
+ const doc = frame.ownerDocument;
61
+ const page = doc.defaultView;
48
62
  if (!page) return () => {};
49
- const observer = new page.MutationObserver((records) => {
63
+ const ancestors = new page.MutationObserver((records) => {
50
64
  if (records.some((record) => isThemeAttribute(record.attributeName))) onChange();
51
65
  });
52
- for (let element = frame; element; element = element.parentElement) observer.observe(element, { attributes: true });
53
- return () => observer.disconnect();
66
+ for (let element = frame; element; element = element.parentElement) ancestors.observe(element, { attributes: true });
67
+ const stylesheets = new page.MutationObserver((records) => {
68
+ if (records.some(isStylesheetChange)) onChange();
69
+ });
70
+ stylesheets.observe(doc.head, {
71
+ childList: true,
72
+ subtree: true,
73
+ characterData: true,
74
+ attributes: true,
75
+ attributeFilter: [
76
+ "href",
77
+ "rel",
78
+ "media",
79
+ "disabled"
80
+ ]
81
+ });
82
+ const onLoad = (event) => {
83
+ if (isStylesheet(event.target)) onChange();
84
+ };
85
+ doc.addEventListener("load", onLoad, true);
86
+ return () => {
87
+ ancestors.disconnect();
88
+ stylesheets.disconnect();
89
+ doc.removeEventListener("load", onLoad, true);
90
+ };
54
91
  }
55
92
 
56
93
  //#endregion