camox 0.41.0 → 0.42.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 (60) hide show
  1. package/dist/core/components/lexical/SidebarLexicalEditor.js +42 -39
  2. package/dist/core/createApp.d.ts +16 -2
  3. package/dist/core/createBlock.js +11 -25
  4. package/dist/core/editing/BlockEditingRuntime.js +4 -4
  5. package/dist/core/editing/CompleteBlockEditingRuntime.js +5 -5
  6. package/dist/core/editing/createEditableBlock.d.ts +8 -1
  7. package/dist/core/editing/createEditableBlock.js +684 -644
  8. package/dist/core/hooks/useIsEditable.js +4 -7
  9. package/dist/core/hooks/useOverlayState.js +11 -0
  10. package/dist/core/hooks/useRequireDraftSource.js +7 -11
  11. package/dist/core/lib/fieldTypes.js +5 -5
  12. package/dist/core/lib/lexicalState.js +17 -1
  13. package/dist/features/preview/CamoxPreview.js +123 -137
  14. package/dist/features/preview/DerivedPreview.js +6 -9
  15. package/dist/features/preview/commentsEnabled.js +8 -0
  16. package/dist/features/preview/components/AddBlockSidebar.js +79 -89
  17. package/dist/features/preview/components/AssetLightbox.js +4 -11
  18. package/dist/features/preview/components/AttachedComments.js +194 -0
  19. package/dist/features/preview/components/BlockActionsPopover.js +19 -70
  20. package/dist/features/preview/components/CommentHeader.js +122 -0
  21. package/dist/features/preview/components/CommentSidebar.js +29 -0
  22. package/dist/features/preview/components/CommentTargetQuote.js +166 -0
  23. package/dist/features/preview/components/CreatePageModal.js +2 -8
  24. package/dist/features/preview/components/DerivedLayoutSidebar.js +4 -7
  25. package/dist/features/preview/components/ItemFieldsEditor.js +275 -204
  26. package/dist/features/preview/components/LeftSidebar.js +18 -18
  27. package/dist/features/preview/components/LinkFieldEditor.js +3 -4
  28. package/dist/features/preview/components/MobilePreviewDrawer.js +3 -3
  29. package/dist/features/preview/components/OverlayTracker.js +14 -20
  30. package/dist/features/preview/components/Overlays.js +28 -40
  31. package/dist/features/preview/components/PageEditorSidebar.js +231 -241
  32. package/dist/features/preview/components/PageInfoSidebar.js +126 -157
  33. package/dist/features/preview/components/PagePicker.js +13 -8
  34. package/dist/features/preview/components/PageTree.js +255 -319
  35. package/dist/features/preview/components/PreviewComments.js +56 -0
  36. package/dist/features/preview/components/PreviewPanel.js +149 -107
  37. package/dist/features/preview/components/PreviewToolbar.js +292 -246
  38. package/dist/features/preview/components/PreviewToolbarSpacer.js +43 -0
  39. package/dist/features/preview/components/PublicationRow.js +11 -24
  40. package/dist/features/preview/components/RightSidebar.js +14 -11
  41. package/dist/features/preview/components/SidebarSection.js +121 -0
  42. package/dist/features/preview/previewCommentsStore.js +115 -0
  43. package/dist/features/preview/previewSelection.js +75 -0
  44. package/dist/features/preview/previewStore.js +32 -63
  45. package/dist/features/provider/AuthenticatedCamoxProvider.js +46 -34
  46. package/dist/features/provider/components/CommandPalette.js +142 -58
  47. package/dist/features/provider/useAdminShortcuts.js +20 -8
  48. package/dist/features/routes/pageRuntime.js +0 -6
  49. package/dist/features/runtime/RuntimeChrome.js +102 -87
  50. package/dist/features/studio/CamoxStudio.js +30 -50
  51. package/dist/features/studio/components/UserButton.js +4 -4
  52. package/dist/features/vite/runtimeDev.js +4 -1
  53. package/dist/features/vite/vite.d.ts +3 -2
  54. package/dist/features/vite/vite.js +9 -5
  55. package/dist/hooks/use-file-upload.js +0 -2
  56. package/dist/studio.css +1 -1
  57. package/package.json +5 -7
  58. package/dist/features/preview/components/DraftSwitchDialog.js +0 -66
  59. package/dist/lib/telemetry-client.js +0 -66
  60. package/dist/lib/telemetry.js +0 -26
@@ -2,7 +2,6 @@ import { Navigate, useLocation } from "../navigation/navigation.js";
2
2
  import { useAuthState, useSignInRedirect } from "../../lib/auth.js";
3
3
  import { SharedChromeContext } from "../runtime/SharedChromeContext.js";
4
4
  import { STUDIO_BASE_PATH } from "./routes.js";
5
- import { trackClientEvent } from "../../lib/telemetry-client.js";
6
5
  import { Navbar } from "./components/Navbar.js";
7
6
  import { c } from "react/compiler-runtime";
8
7
  import * as React from "react";
@@ -10,10 +9,10 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
9
 
11
10
  //#region src/features/studio/CamoxStudio.tsx
12
11
  const CamoxStudio = (t0) => {
13
- const $ = c(16);
14
- if ($[0] !== "424ccf9eb3e0b68f3206047ad39569798182b6392a92ca98a7e9d6cf3cc9ff22") {
15
- for (let $i = 0; $i < 16; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
16
- $[0] = "424ccf9eb3e0b68f3206047ad39569798182b6392a92ca98a7e9d6cf3cc9ff22";
12
+ const $ = c(12);
13
+ if ($[0] !== "5f0b5c1c244f7af982fa1d0e99a04fcbc60b872999562c3737760c88a71ce1d0") {
14
+ for (let $i = 0; $i < 12; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
15
+ $[0] = "5f0b5c1c244f7af982fa1d0e99a04fcbc60b872999562c3737760c88a71ce1d0";
17
16
  }
18
17
  const { children } = t0;
19
18
  const { isAuthenticated, isLoading: isLoadingAuth } = useAuthState();
@@ -41,61 +40,42 @@ const CamoxStudio = (t0) => {
41
40
  t2 = $[5];
42
41
  }
43
42
  React.useEffect(t1, t2);
44
- const hasTrackedOpenRef = React.useRef(false);
45
- let t3;
46
- let t4;
47
- if ($[6] !== isAuthenticated || $[7] !== pathname) {
48
- t3 = () => {
49
- if (!isAuthenticated || hasTrackedOpenRef.current) return;
50
- hasTrackedOpenRef.current = true;
51
- trackClientEvent("studio_opened", { route: pathname });
52
- };
53
- t4 = [isAuthenticated, pathname];
54
- $[6] = isAuthenticated;
55
- $[7] = pathname;
56
- $[8] = t3;
57
- $[9] = t4;
58
- } else {
59
- t3 = $[8];
60
- t4 = $[9];
61
- }
62
- React.useEffect(t3, t4);
63
43
  if (!isAuthenticated) return null;
64
44
  if (pathname === STUDIO_BASE_PATH) {
65
- let t5;
66
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
67
- t5 = /* @__PURE__ */ jsx(Navigate, {
45
+ let t3;
46
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
47
+ t3 = /* @__PURE__ */ jsx(Navigate, {
68
48
  to: "/",
69
49
  replace: true
70
50
  });
71
- $[10] = t5;
72
- } else t5 = $[10];
73
- return t5;
51
+ $[6] = t3;
52
+ } else t3 = $[6];
53
+ return t3;
74
54
  }
75
55
  if (sharedChrome) {
76
- let t5;
77
- if ($[11] !== children) {
78
- t5 = /* @__PURE__ */ jsx(Fragment, { children });
79
- $[11] = children;
80
- $[12] = t5;
81
- } else t5 = $[12];
82
- return t5;
56
+ let t3;
57
+ if ($[7] !== children) {
58
+ t3 = /* @__PURE__ */ jsx(Fragment, { children });
59
+ $[7] = children;
60
+ $[8] = t3;
61
+ } else t3 = $[8];
62
+ return t3;
83
63
  }
84
- let t5;
85
- if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
86
- t5 = /* @__PURE__ */ jsx(Navbar, {});
87
- $[13] = t5;
88
- } else t5 = $[13];
89
- let t6;
90
- if ($[14] !== children) {
91
- t6 = /* @__PURE__ */ jsxs("div", {
64
+ let t3;
65
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
66
+ t3 = /* @__PURE__ */ jsx(Navbar, {});
67
+ $[9] = t3;
68
+ } else t3 = $[9];
69
+ let t4;
70
+ if ($[10] !== children) {
71
+ t4 = /* @__PURE__ */ jsxs("div", {
92
72
  className: "bg-background flex h-screen flex-col overflow-hidden",
93
- children: [t5, children]
73
+ children: [t3, children]
94
74
  });
95
- $[14] = children;
96
- $[15] = t6;
97
- } else t6 = $[15];
98
- return t6;
75
+ $[10] = children;
76
+ $[11] = t4;
77
+ } else t4 = $[11];
78
+ return t4;
99
79
  };
100
80
 
101
81
  //#endregion
@@ -1,7 +1,7 @@
1
1
  import { useLocation, useNavigate } from "../../navigation/navigation.js";
2
2
  import { useAuthContext, useAuthState } from "../../../lib/auth.js";
3
3
  import { STUDIO_BASE_PATH } from "../routes.js";
4
- import { previewStore } from "../../preview/previewStore.js";
4
+ import { previewStore, selectIsEditMode } from "../../preview/previewStore.js";
5
5
  import { useApplyTheme } from "../useTheme.js";
6
6
  import { c } from "react/compiler-runtime";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -14,9 +14,9 @@ import { Avatar, AvatarFallback, AvatarImage } from "@camox/ui/avatar";
14
14
  //#region src/features/studio/components/UserButton.tsx
15
15
  const UserButton = () => {
16
16
  const $ = c(5);
17
- if ($[0] !== "a09d40e74ed3a5b0583d8899c9b1d3c569af18304db9c6f598775bf2c16e2608") {
17
+ if ($[0] !== "b876c985f56cb759905567177978ca8597789d0818f006e69fd4bcfb86c58f94") {
18
18
  for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
19
- $[0] = "a09d40e74ed3a5b0583d8899c9b1d3c569af18304db9c6f598775bf2c16e2608";
19
+ $[0] = "b876c985f56cb759905567177978ca8597789d0818f006e69fd4bcfb86c58f94";
20
20
  }
21
21
  const { isAuthenticated, isLoading } = useAuthState();
22
22
  const { theme, setTheme } = useApplyTheme();
@@ -48,7 +48,7 @@ function AuthenticatedUserButton({ theme, setTheme }) {
48
48
  const authCtx = useAuthContext();
49
49
  const { data: session } = authCtx.authClient.useSession();
50
50
  const authenticationUrl = authCtx.authenticationUrl;
51
- const isEditMode = useSelector(previewStore, (state) => state.context.isEditMode);
51
+ const isEditMode = useSelector(previewStore, selectIsEditMode);
52
52
  const { pathname } = useLocation();
53
53
  const navigate = useNavigate();
54
54
  const isPreviewPage = pathname !== STUDIO_BASE_PATH && !pathname.startsWith(`${STUDIO_BASE_PATH}/`);
@@ -267,7 +267,10 @@ function loadRuntimeDevModule(id, options = {}) {
267
267
  if (id === RESOLVED_VIRTUAL_STUDIO_CLIENT) return generateVirtualStudioClient();
268
268
  if (id === RESOLVED_VIRTUAL_STUDIO_CLIENT_URL) return generateVirtualStudioClientUrl();
269
269
  if (id === RESOLVED_VIRTUAL_APP_STYLESHEET_URL) return generateVirtualAppStylesheetUrl();
270
- if (id === RESOLVED_VIRTUAL_STUDIO_CSS) return `export default "/@fs/${resolve(sdkRoot, "dist/studio.css")}";`;
270
+ if (id === RESOLVED_VIRTUAL_STUDIO_CSS) {
271
+ const cssUrl = `/@fs/${resolve(sdkRoot, "dist/studio.css").replaceAll("\\", "/").replace(/^\/+/, "")}`;
272
+ return `export default ${JSON.stringify(cssUrl)};`;
273
+ }
271
274
  if (id === RESOLVED_VIRTUAL_OVERLAY_CSS) return `export default ${JSON.stringify(readFileSync(resolve(sdkRoot, "dist/studio-overlays.css"), "utf-8"))};`;
272
275
  }
273
276
  function normalizeRuntimeBasePath(basePath) {
@@ -23,13 +23,14 @@ type CamoxVitePlugin = Plugin & {
23
23
  interface CamoxPluginOptions {
24
24
  /** Stable, human-readable slug identifying this project (e.g. "prestigious-impala-84") */
25
25
  projectSlug: string;
26
- /** Disable PostHog telemetry collection (default: false) */
26
+ /** Disable telemetry collection (default: false) */
27
27
  disableTelemetry?: boolean;
28
28
  /** Internal options (intended for Camox contributors in development, not for public use) */
29
29
  _internal?: {
30
30
  /** URL of the Camox API backend, used for data fetching */apiUrl?: string; /** URL of the Camox authentication backend (default: https://app.camox.dev) */
31
31
  authenticationUrl?: string; /** Show Tanstack query devtools (default: false) */
32
- enableTanstackDevtools?: boolean; /** Disable automatic code generation (route files and app file) (default: false) */
32
+ enableTanstackDevtools?: boolean; /** Enable the frontend-only comments prototype (default: false). */
33
+ enableComments?: boolean; /** Disable automatic code generation (route files and app file) (default: false) */
33
34
  disableCodeGen?: boolean; /** Mount the Camox-owned dev runtime at this base path. Use "/" for root mode. */
34
35
  runtimeBasePath?: string;
35
36
  };
@@ -11,7 +11,9 @@ import { fileURLToPath } from "node:url";
11
11
  import { createServer } from "vite-plus";
12
12
 
13
13
  //#region src/features/vite/vite.ts
14
- const sdkRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../../..");
14
+ const pluginDir = dirname(fileURLToPath(import.meta.url));
15
+ const sdkRoot = resolve(pluginDir, "../../..");
16
+ const isSdkSource = pluginDir === resolve(sdkRoot, "src/features/vite");
15
17
  const VIRTUAL_STUDIO_CSS = "virtual:camox-studio-css";
16
18
  const RESOLVED_VIRTUAL_STUDIO_CSS = "\0" + VIRTUAL_STUDIO_CSS;
17
19
  const VIRTUAL_OVERLAY_CSS = "virtual:camox-overlay-css";
@@ -58,17 +60,19 @@ function camox(options) {
58
60
  if (id === VIRTUAL_OVERLAY_CSS) return RESOLVED_VIRTUAL_OVERLAY_CSS;
59
61
  },
60
62
  load(id) {
63
+ const stylesDir = resolve(sdkRoot, !isBuild && isSdkSource ? ".dev" : "dist");
61
64
  if (id === RESOLVED_VIRTUAL_STUDIO_CSS) {
62
- const cssPath = resolve(sdkRoot, "dist/studio.css");
65
+ const cssPath = resolve(stylesDir, "studio.css");
63
66
  if (isBuild) {
64
67
  const css = readFileSync(cssPath, "utf-8");
65
68
  const dataUrl = `data:text/css;base64,${Buffer.from(css).toString("base64")}`;
66
69
  return `export default ${JSON.stringify(dataUrl)};`;
67
70
  }
68
- return `export default "/@fs/${cssPath}";`;
71
+ const cssUrl = `/@fs/${cssPath.replaceAll("\\", "/").replace(/^\/+/, "")}`;
72
+ return `export default ${JSON.stringify(cssUrl)};`;
69
73
  }
70
74
  if (id === RESOLVED_VIRTUAL_OVERLAY_CSS) {
71
- const css = readFileSync(resolve(sdkRoot, "dist/studio-overlays.css"), "utf-8");
75
+ const css = readFileSync(resolve(stylesDir, "studio-overlays.css"), "utf-8");
72
76
  return `export default ${JSON.stringify(css)};`;
73
77
  }
74
78
  if (id === RESOLVED_VIRTUAL_PAGE_CLIENT_URL && isBuild) return "export default \"/_chunks/camox-page-client.mjs\";";
@@ -101,6 +105,7 @@ function camox(options) {
101
105
  define: {
102
106
  __CAMOX_TELEMETRY_DISABLED__: JSON.stringify(!!options.disableTelemetry),
103
107
  __ENABLE_TANSTACK_DEVTOOLS__: JSON.stringify(enableTanstackDevtools),
108
+ __CAMOX_ENABLE_COMMENTS__: JSON.stringify(options._internal?.enableComments ?? false),
104
109
  __CAMOX_ENVIRONMENT_NAME__: JSON.stringify(environmentName),
105
110
  __CAMOX_API_URL__: JSON.stringify(apiUrl),
106
111
  __CAMOX_AUTHENTICATION_URL__: JSON.stringify(authenticationUrl),
@@ -181,7 +186,6 @@ function camox(options) {
181
186
  "camox > fractional-indexing",
182
187
  "camox > lexical",
183
188
  "camox > lucide-react",
184
- "camox > posthog-js",
185
189
  "camox > @tanstack/react-query-devtools/production",
186
190
  "camox > partysocket/react"
187
191
  ] }
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { getAuthCookieHeader } from "../lib/auth.js";
4
4
  import { getApiUrl, getEnvironmentName } from "../lib/api-client.js";
5
- import { trackClientEvent } from "../lib/telemetry-client.js";
6
5
  import { useCallback, useRef, useState } from "react";
7
6
 
8
7
  //#region src/hooks/use-file-upload.ts
@@ -54,7 +53,6 @@ function useFileUpload(options) {
54
53
  filename: result.filename,
55
54
  mimeType: result.mimeType
56
55
  });
57
- trackClientEvent("file_uploaded", { mimeType: file.type });
58
56
  setUploads((prev_0) => prev_0.map((u_0) => u_0.id === itemId ? {
59
57
  ...u_0,
60
58
  status: "complete",