camox 0.48.0 → 0.52.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.
Files changed (127) hide show
  1. package/dist/core/createApp.d.ts +1 -0
  2. package/dist/core/createApp.js +1 -0
  3. package/dist/core/editing/contentEdits.js +78 -0
  4. package/dist/core/editing/createEditableBlock.js +277 -311
  5. package/dist/core/layoutContext.d.ts +1 -0
  6. package/dist/core/lib/contentType.js +2 -2
  7. package/dist/core/recordItem.js +3 -3
  8. package/dist/features/canvas/CamoxCanvas.js +15 -15
  9. package/dist/features/canvas/CanvasLoadingScreen.js +15 -11
  10. package/dist/features/canvas/CanvasPageFrame.js +81 -87
  11. package/dist/features/canvas/CanvasPreviewPageSlot.js +1 -1
  12. package/dist/features/canvas/DerivedPagePathInput.js +12 -12
  13. package/dist/features/canvas/canvasOverlayGeometry.js +1 -1
  14. package/dist/features/canvas/canvasStore.js +2 -2
  15. package/dist/features/canvas/sidebar/CanvasInspector.js +1 -1
  16. package/dist/features/canvas/sidebar/CuratedPageInspector.js +1 -1
  17. package/dist/features/canvas/sidebar/LayoutPageBlocks.js +23 -31
  18. package/dist/features/canvas/useCanvasCamera.js +1 -1
  19. package/dist/features/canvas/useDiscoveredPreviewPaths.js +16 -9
  20. package/dist/features/content/ContentAssets.js +84 -88
  21. package/dist/features/page/CuratedPageContent.js +1 -1
  22. package/dist/features/preview/CamoxPreview.d.ts +8 -4
  23. package/dist/features/preview/CamoxPreview.js +258 -443
  24. package/dist/features/preview/EditablePageContent.js +244 -2
  25. package/dist/features/preview/EditablePageExperience.js +19 -13
  26. package/dist/features/preview/components/AddBlockSheet.js +55 -15
  27. package/dist/features/preview/components/BlockActionsPopover.js +23 -51
  28. package/dist/features/preview/components/BlockPeek.js +66 -0
  29. package/dist/features/preview/components/BlockThumbnail.js +134 -119
  30. package/dist/features/preview/components/CanvasPreview.js +1 -1
  31. package/dist/features/preview/components/CreatePageModal.js +150 -156
  32. package/dist/features/preview/components/FieldToolbar.js +1 -1
  33. package/dist/features/preview/components/Frame.js +27 -4
  34. package/dist/features/preview/components/MobilePreviewDrawer.js +6 -9
  35. package/dist/features/preview/components/PageInfo.js +161 -126
  36. package/dist/features/preview/components/PagePicker.js +2 -2
  37. package/dist/features/preview/components/PageTree.js +174 -190
  38. package/dist/features/preview/components/PreviewPanel.js +13 -67
  39. package/dist/features/preview/components/PreviewToolbar.js +1 -1
  40. package/dist/features/preview/components/ReferenceFieldEditor.js +4 -4
  41. package/dist/features/preview/components/ReferenceListFieldEditor.js +4 -4
  42. package/dist/features/preview/components/RemovedBlockPlaceholder.js +37 -70
  43. package/dist/features/preview/components/RepeatableItemsList.js +1 -1
  44. package/dist/features/preview/components/SelectionEditor.js +248 -256
  45. package/dist/features/preview/components/StudioEditingFallback.js +22 -26
  46. package/dist/features/preview/components/useFieldWriter.js +19 -19
  47. package/dist/features/preview/components/useRecordView.js +105 -147
  48. package/dist/features/preview/components/useRepeatableItemActions.js +0 -2
  49. package/dist/features/preview/pageRecord.js +30 -24
  50. package/dist/features/preview/previewConstants.js +2 -8
  51. package/dist/features/preview/previewStore.js +2 -0
  52. package/dist/features/preview/studioNotice.js +20 -0
  53. package/dist/features/preview/usePreviewViewportActions.js +1 -1
  54. package/dist/features/provider/AuthenticatedCamoxProvider.js +47 -31
  55. package/dist/features/provider/components/CommandPalette.js +2 -5
  56. package/dist/features/provider/signInShortcut.js +1 -2
  57. package/dist/features/provider/useAdminShortcuts.js +47 -53
  58. package/dist/features/renderer/RendererApp.js +542 -0
  59. package/dist/features/renderer/RendererFrames.js +450 -0
  60. package/dist/features/renderer/definitionAnswers.js +26 -0
  61. package/dist/features/renderer/protocol.js +35 -0
  62. package/dist/features/renderer/rendererHost.js +249 -0
  63. package/dist/features/renderer/studioConnection.js +186 -0
  64. package/dist/features/routes/pageRuntime.d.ts +2 -1
  65. package/dist/features/routes/pageRuntime.js +34 -22
  66. package/dist/features/runtime/RuntimeChrome.js +2 -5
  67. package/dist/features/runtime/assetPrefix.js +14 -0
  68. package/dist/features/runtime/breadcrumbs.js +1 -1
  69. package/dist/features/runtime/editingFallback.js +4 -8
  70. package/dist/features/runtime/livePages.js +1 -1
  71. package/dist/features/runtime/pageApp.js +57 -83
  72. package/dist/features/runtime/pageClient.js +1 -1
  73. package/dist/features/runtime/pageNavigation.js +3 -2
  74. package/dist/features/runtime/publicCache.js +95 -0
  75. package/dist/features/runtime/publishingDraft.js +23 -0
  76. package/dist/features/runtime/rendererClient.d.ts +8 -0
  77. package/dist/features/runtime/rendererClient.js +77 -0
  78. package/dist/features/runtime/runtime.d.ts +22 -3
  79. package/dist/features/runtime/runtime.js +209 -96
  80. package/dist/features/runtime/runtimeRoutes.d.ts +2 -0
  81. package/dist/features/runtime/runtimeRoutes.js +2 -0
  82. package/dist/features/runtime/worker.d.ts +14 -1
  83. package/dist/features/runtime/worker.js +34 -4
  84. package/dist/features/settings/AnalyticsSettings.js +622 -0
  85. package/dist/features/settings/CamoxSettings.js +95 -0
  86. package/dist/features/settings/FaviconSettings.js +254 -0
  87. package/dist/features/settings/ProjectNameSettings.js +145 -0
  88. package/dist/features/settings/SettingsPart.js +73 -0
  89. package/dist/features/settings/SocialProfilesSettings.js +245 -0
  90. package/dist/features/settings/useProjectMutation.js +61 -0
  91. package/dist/features/studio/FollowAgentProvider.js +10 -10
  92. package/dist/features/studio/components/DraftsControl.js +136 -131
  93. package/dist/features/studio/components/LocalePicker.js +178 -174
  94. package/dist/features/studio/components/Navbar.js +107 -66
  95. package/dist/features/studio/components/ProjectMenu.js +119 -171
  96. package/dist/features/studio/components/ReviewDraftSheet.js +1151 -991
  97. package/dist/features/studio/components/ThreadMessages.js +100 -65
  98. package/dist/features/studio/components/UserButton.js +2 -2
  99. package/dist/features/studio/routes.js +3 -1
  100. package/dist/features/studio/showInCanvas.js +129 -0
  101. package/dist/features/vite/definitionsSync.js +5 -6
  102. package/dist/features/vite/hostedChecks.js +127 -0
  103. package/dist/features/vite/runtimeDev.js +58 -17
  104. package/dist/features/vite/staticAssetHeaders.js +52 -0
  105. package/dist/features/vite/vite.d.ts +1 -1
  106. package/dist/features/vite/vite.js +49 -9
  107. package/dist/hooks/use-page-destinations.js +10 -10
  108. package/dist/lib/api-client-server.d.ts +1 -1
  109. package/dist/lib/api-client.d.ts +2 -1
  110. package/dist/lib/draft-scope.d.ts +1 -0
  111. package/dist/lib/locale-path.d.ts +3 -11
  112. package/dist/lib/locale-path.js +3 -27
  113. package/dist/lib/queries.js +7 -1
  114. package/dist/lib/revisions.js +20 -0
  115. package/dist/lib/shortcuts.js +29 -0
  116. package/dist/lib/studio-definitions.js +160 -0
  117. package/dist/lib/studio-reads.d.ts +1 -0
  118. package/dist/lib/studio-reads.js +65 -21
  119. package/dist/lib/use-project-room.js +16 -10
  120. package/dist/lib/utils.js +1 -104
  121. package/dist/package.js +1 -1
  122. package/dist/studio.css +1 -1
  123. package/package.json +9 -4
  124. package/skills/camox/SKILL.md +4 -0
  125. package/skills/camox/references/artifacts.md +1 -1
  126. package/dist/features/studio/components/FaviconDialog.js +0 -318
  127. package/dist/features/studio/components/SocialProfilesDialog.js +0 -342
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+ import { toast } from "@camox/ui/toaster";
3
+
4
+ //#region src/features/preview/studioNotice.ts
5
+ /** Shows a notice in this document's toasts. */
6
+ function showNotice({ tone, message }) {
7
+ toast[tone](message);
8
+ }
9
+ /**
10
+ * Where the notices of a page's blocks go. The renderer frame's document shows no toasts: it
11
+ * hands them to the studio, which shows them.
12
+ */
13
+ const StudioNoticeContext = React.createContext(null);
14
+ /** Tells the editor something, in the studio's toasts. */
15
+ function useStudioNotice() {
16
+ return React.use(StudioNoticeContext) ?? showNotice;
17
+ }
18
+
19
+ //#endregion
20
+ export { StudioNoticeContext, showNotice, useStudioNotice };
@@ -27,7 +27,7 @@ function _temp10() {
27
27
  groupLabel: "Website",
28
28
  checkIfAvailable: _temp,
29
29
  execute: _temp2,
30
- shortcut: { key: "m" }
30
+ shortcut: "M"
31
31
  },
32
32
  {
33
33
  id: "set-viewport-full",
@@ -1,22 +1,23 @@
1
1
  import { AuthContext, useAuthActions } from "../../lib/auth.js";
2
2
  import { useDraftScope } from "../../lib/draft-scope.js";
3
3
  import { reads, useReadQuery, useStudioCache } from "../../lib/studio-reads.js";
4
+ import { RevisionsContext, createRevisions } from "../../lib/revisions.js";
5
+ import { useAdminShortcuts } from "./useAdminShortcuts.js";
4
6
  import { useApplyTheme, useThemeActions } from "../studio/useTheme.js";
5
7
  import { usePreviewPagesActions, useShowCanvasAction } from "../preview/CamoxPreview.js";
6
8
  import { useProjectRoom } from "../../lib/use-project-room.js";
7
9
  import { useNavbarActions } from "../studio/components/Navbar.js";
8
10
  import { draftNoticeMessage } from "../studio/draftNotice.js";
9
11
  import { CommandPalette, useCommandPaletteActions } from "./components/CommandPalette.js";
10
- import { useAdminShortcuts } from "./useAdminShortcuts.js";
11
12
  import { c } from "react/compiler-runtime";
12
13
  import * as React from "react";
13
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
14
15
  import { Toaster, toast } from "@camox/ui/toaster";
15
16
  import studioCssUrl from "virtual:camox-studio-css";
16
17
 
17
18
  //#region src/features/provider/AuthenticatedCamoxProvider.tsx
18
19
  function AuthenticatedCamoxProvider(t0) {
19
- const $ = c(14);
20
+ const $ = c(18);
20
21
  const { children } = t0;
21
22
  useAdminShortcuts();
22
23
  useCommandPaletteActions();
@@ -48,49 +49,64 @@ function AuthenticatedCamoxProvider(t0) {
48
49
  t3 = $[4];
49
50
  }
50
51
  React.useEffect(t2, t3);
52
+ const [revisions] = React.useState(createRevisions);
51
53
  let t4;
52
- if ($[5] !== draftScope) {
53
- t4 = { onDraftEnded(ended) {
54
- if (ended.draftId !== draftScope.current()) return;
55
- draftScope.leave(ended, { notice: true });
56
- } };
54
+ if ($[5] !== draftScope || $[6] !== revisions) {
55
+ let t5;
56
+ if ($[8] !== revisions) {
57
+ t5 = (revision) => revisions.announce(revision);
58
+ $[8] = revisions;
59
+ $[9] = t5;
60
+ } else t5 = $[9];
61
+ t4 = {
62
+ onDraftEnded(ended) {
63
+ if (ended.draftId !== draftScope.current()) return;
64
+ draftScope.leave(ended, { notice: true });
65
+ },
66
+ onRevision: t5
67
+ };
57
68
  $[5] = draftScope;
58
- $[6] = t4;
59
- } else t4 = $[6];
69
+ $[6] = revisions;
70
+ $[7] = t4;
71
+ } else t4 = $[7];
60
72
  useProjectRoom(apiUrl, project?.id, studioCache, t4);
61
73
  const { resolvedTheme } = useApplyTheme();
62
74
  let t5;
63
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
75
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
64
76
  t5 = /* @__PURE__ */ jsx("link", {
65
77
  rel: "stylesheet",
66
78
  href: studioCssUrl,
67
79
  "data-camox-studio": true
68
80
  });
69
- $[7] = t5;
70
- } else t5 = $[7];
81
+ $[10] = t5;
82
+ } else t5 = $[10];
71
83
  let t6;
72
- if ($[8] !== resolvedTheme) {
84
+ if ($[11] !== resolvedTheme) {
73
85
  t6 = /* @__PURE__ */ jsx(Toaster, { theme: resolvedTheme });
74
- $[8] = resolvedTheme;
75
- $[9] = t6;
76
- } else t6 = $[9];
86
+ $[11] = resolvedTheme;
87
+ $[12] = t6;
88
+ } else t6 = $[12];
77
89
  let t7;
78
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
90
+ if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
79
91
  t7 = /* @__PURE__ */ jsx(CommandPalette, {});
80
- $[10] = t7;
81
- } else t7 = $[10];
92
+ $[13] = t7;
93
+ } else t7 = $[13];
82
94
  let t8;
83
- if ($[11] !== children || $[12] !== t6) {
84
- t8 = /* @__PURE__ */ jsxs(Fragment, { children: [
85
- t5,
86
- children,
87
- t6,
88
- t7
89
- ] });
90
- $[11] = children;
91
- $[12] = t6;
92
- $[13] = t8;
93
- } else t8 = $[13];
95
+ if ($[14] !== children || $[15] !== revisions || $[16] !== t6) {
96
+ t8 = /* @__PURE__ */ jsxs(RevisionsContext, {
97
+ value: revisions,
98
+ children: [
99
+ t5,
100
+ children,
101
+ t6,
102
+ t7
103
+ ]
104
+ });
105
+ $[14] = children;
106
+ $[15] = revisions;
107
+ $[16] = t6;
108
+ $[17] = t8;
109
+ } else t8 = $[17];
94
110
  return t8;
95
111
  }
96
112
  function _temp(notice) {
@@ -1,5 +1,5 @@
1
1
  import { actionsStore } from "../actionsStore.js";
2
- import { formatShortcut } from "../../../lib/utils.js";
2
+ import { formatShortcut } from "../../../lib/shortcuts.js";
3
3
  import { studioStore } from "../../studio/studioStore.js";
4
4
  import { c } from "react/compiler-runtime";
5
5
  import * as React from "react";
@@ -249,10 +249,7 @@ function _temp7() {
249
249
  groupLabel: "Invisible",
250
250
  checkIfAvailable: _temp4,
251
251
  execute: _temp5,
252
- shortcut: {
253
- key: "k",
254
- withMeta: true
255
- }
252
+ shortcut: "Mod+K"
256
253
  }
257
254
  });
258
255
  return _temp6;
@@ -1,5 +1,4 @@
1
1
  import { useSignInRedirect } from "../../lib/auth.js";
2
- import { TOGGLE_CANVAS_SHORTCUT } from "../preview/previewConstants.js";
3
2
  import { c } from "react/compiler-runtime";
4
3
  import * as React from "react";
5
4
 
@@ -28,7 +27,7 @@ function useSignInShortcut(enabled) {
28
27
  t0 = () => {
29
28
  if (!enabled) return;
30
29
  const handleKeyDown = (event) => {
31
- if (event.key !== TOGGLE_CANVAS_SHORTCUT.key || !(event.metaKey || event.ctrlKey)) return;
30
+ if (event.key !== "Enter" || !(event.metaKey || event.ctrlKey)) return;
32
31
  if (event.altKey || event.shiftKey || event.defaultPrevented || isTyping()) return;
33
32
  event.preventDefault();
34
33
  signIn();
@@ -1,75 +1,69 @@
1
1
  import { actionsStore } from "./actionsStore.js";
2
2
  import { checkIfInputFocused } from "../../lib/utils.js";
3
3
  import { c } from "react/compiler-runtime";
4
- import * as React from "react";
5
4
  import { useSelector } from "@xstate/store-react";
5
+ import { parseHotkey, useHotkeys } from "@tanstack/react-hotkeys";
6
6
 
7
7
  //#region src/features/provider/useAdminShortcuts.tsx
8
+ /** Listens for the shortcuts of the actions in the actionsStore, on the Studio's window. */
9
+ function useAdminShortcuts() {
10
+ useActionShortcuts(typeof window === "undefined" ? null : window);
11
+ }
8
12
  /**
9
- * Hook that listens for global keyboard shortcuts defined in the actionsStore
13
+ * Runs the first available action whose shortcut is pressed in `win`, which may be a preview
14
+ * iframe's window. Shortcuts no available action claims leave the key to the page.
10
15
  */
11
- function useAdminShortcuts() {
12
- const $ = c(3);
16
+ function useActionShortcuts(win) {
17
+ const $ = c(4);
13
18
  const actions = useSelector(actionsStore, _temp);
14
19
  let t0;
15
20
  let t1;
16
- if ($[0] !== actions) {
17
- t0 = () => {
18
- const handleKeyDown = (event) => {
19
- const matchingAction = actions.find((action) => {
20
- if (!action.shortcut) return false;
21
- if (!action.checkIfAvailable()) return false;
22
- const { key, withMeta, withAlt, withShift } = action.shortcut;
23
- return (withAlt && key.length === 1 && /[a-z]/i.test(key) ? event.code === `Key${key.toUpperCase()}` : key.toLowerCase() === event.key.toLowerCase()) && !!withMeta === (event.metaKey || event.ctrlKey) && !!withAlt === event.altKey && !!withShift === event.shiftKey;
24
- });
25
- if (!matchingAction) return;
26
- const shortcut = matchingAction.shortcut;
27
- if (checkIfInputFocused()) {
28
- if (shortcut.key !== "Escape" && !shortcut.withMeta && !shortcut.withAlt) return;
29
- if (shortcut.key === "Backspace") return;
30
- }
31
- event.preventDefault();
32
- event.stopPropagation();
33
- if (shortcut.key === "Escape" && checkIfInputFocused()) document.activeElement.blur();
34
- matchingAction.execute();
35
- };
36
- const handleCapturedKeyDown = (event_0) => {
37
- if (event_0.key === "Escape") return;
38
- handleKeyDown(event_0);
39
- };
40
- const handleEscape = (event_1) => {
41
- if (event_1.key !== "Escape" || event_1.defaultPrevented) return;
42
- handleKeyDown(event_1);
43
- };
44
- const handleMessage = (event_2) => {
45
- if (event_2.data?.type === "executeAction") {
46
- const { actionId } = event_2.data;
47
- const action_0 = actions.find((a) => a.id === actionId);
48
- if (action_0) action_0.execute();
21
+ if ($[0] !== actions || $[1] !== win) {
22
+ const shortcuts = [...new Set(actions.flatMap(_temp2))];
23
+ t0 = useHotkeys;
24
+ t1 = win ? shortcuts.map((shortcut) => {
25
+ const { key, ctrl, meta, alt } = parseHotkey(shortcut);
26
+ const escape = key === "Escape";
27
+ return {
28
+ hotkey: shortcut,
29
+ callback: (event) => {
30
+ if (escape && event.defaultPrevented) return;
31
+ const action_0 = findAvailableAction(shortcut);
32
+ if (!action_0) return;
33
+ event.preventDefault();
34
+ event.stopPropagation();
35
+ if (escape && checkIfInputFocused(win.document)) win.document.activeElement.blur();
36
+ action_0.execute();
37
+ },
38
+ options: {
39
+ target: escape ? win : win.document,
40
+ capture: !escape,
41
+ ignoreInputs: key === "Backspace" || !ctrl && !meta && !alt && !escape,
42
+ preventDefault: false,
43
+ stopPropagation: false,
44
+ conflictBehavior: "allow"
49
45
  }
50
46
  };
51
- document.addEventListener("keydown", handleCapturedKeyDown, true);
52
- window.addEventListener("keydown", handleEscape);
53
- window.addEventListener("message", handleMessage);
54
- return () => {
55
- document.removeEventListener("keydown", handleCapturedKeyDown, true);
56
- window.removeEventListener("keydown", handleEscape);
57
- window.removeEventListener("message", handleMessage);
58
- };
59
- };
60
- t1 = [actions];
47
+ }) : [];
61
48
  $[0] = actions;
62
- $[1] = t0;
63
- $[2] = t1;
49
+ $[1] = win;
50
+ $[2] = t0;
51
+ $[3] = t1;
64
52
  } else {
65
- t0 = $[1];
66
- t1 = $[2];
53
+ t0 = $[2];
54
+ t1 = $[3];
67
55
  }
68
- React.useEffect(t0, t1);
56
+ t0(t1);
57
+ }
58
+ function _temp2(action) {
59
+ return action.shortcut ?? [];
69
60
  }
70
61
  function _temp(state) {
71
62
  return state.context.actions;
72
63
  }
64
+ function findAvailableAction(shortcut) {
65
+ return actionsStore.getSnapshot().context.actions.find((action) => action.shortcut === shortcut && action.checkIfAvailable());
66
+ }
73
67
 
74
68
  //#endregion
75
- export { useAdminShortcuts };
69
+ export { useActionShortcuts, useAdminShortcuts };