camox 0.3.0 → 0.4.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 (76) hide show
  1. package/dist/components/AuthGate.js +2 -1
  2. package/dist/core/components/AddBlockControlBar.js +117 -44
  3. package/dist/core/components/lexical/InlineContentEditable.js +37 -17
  4. package/dist/core/components/lexical/InlineLexicalEditor.js +84 -25
  5. package/dist/core/components/lexical/SelectionBroadcaster.js +84 -47
  6. package/dist/core/components/lexical/SidebarLexicalEditor.js +54 -19
  7. package/dist/core/createBlock.js +1172 -414
  8. package/dist/core/createLayout.js +48 -16
  9. package/dist/core/hooks/useFieldSelection.js +24 -13
  10. package/dist/core/hooks/useIsEditable.js +8 -2
  11. package/dist/core/hooks/useOverlayMessage.js +51 -20
  12. package/dist/features/content/CamoxContent.js +239 -107
  13. package/dist/features/content/components/AssetCard.js +78 -16
  14. package/dist/features/content/components/AssetCardSkeleton.js +11 -4
  15. package/dist/features/content/components/ContentSidebar.js +15 -8
  16. package/dist/features/content/components/UploadDropZone.js +77 -34
  17. package/dist/features/content/components/UploadProgressDrawer.js +201 -58
  18. package/dist/features/metadata/sitemap.js +15 -0
  19. package/dist/features/preview/CamoxPreview.js +447 -179
  20. package/dist/features/preview/components/AddBlockSheet.js +344 -167
  21. package/dist/features/preview/components/AgentChatSheet.js +32 -10
  22. package/dist/features/preview/components/AssetFieldEditor.js +185 -50
  23. package/dist/features/preview/components/AssetLightbox.js +60 -33
  24. package/dist/features/preview/components/AssetPickerGrid.js +203 -71
  25. package/dist/features/preview/components/BlockActionsPopover.js +295 -218
  26. package/dist/features/preview/components/CreatePageSheet.js +3 -3
  27. package/dist/features/preview/components/DebouncedFieldEditor.js +80 -23
  28. package/dist/features/preview/components/EditPageSheet.js +241 -86
  29. package/dist/features/preview/components/ItemFieldsEditor.js +209 -115
  30. package/dist/features/preview/components/LinkFieldEditor.js +351 -153
  31. package/dist/features/preview/components/MultipleAssetFieldEditor.js +245 -92
  32. package/dist/features/preview/components/OverlayTracker.js +58 -23
  33. package/dist/features/preview/components/Overlays.js +85 -43
  34. package/dist/features/preview/components/PageContentSheet.js +18 -18
  35. package/dist/features/preview/components/PageLocationFieldset.js +229 -63
  36. package/dist/features/preview/components/PagePicker.js +27 -27
  37. package/dist/features/preview/components/PageTree.js +921 -319
  38. package/dist/features/preview/components/PeekedBlock.js +173 -63
  39. package/dist/features/preview/components/PreviewPanel.js +271 -148
  40. package/dist/features/preview/components/PreviewSideSheet.js +44 -11
  41. package/dist/features/preview/components/PreviewToolbar.js +262 -59
  42. package/dist/features/preview/components/RepeatableItemsList.js +187 -78
  43. package/dist/features/preview/components/ShikiMarkdown.js +46 -20
  44. package/dist/features/preview/components/TextFormatToolbar.js +81 -23
  45. package/dist/features/preview/components/UnlinkAssetButton.js +161 -40
  46. package/dist/features/preview/components/useUpdateBlockPosition.js +64 -47
  47. package/dist/features/preview/previewStore.d.ts +2 -2
  48. package/dist/features/provider/CamoxProvider.js +69 -21
  49. package/dist/features/provider/actionsStore.d.ts +2 -2
  50. package/dist/features/provider/components/CamoxAppContext.js +15 -5
  51. package/dist/features/provider/components/CommandPalette.js +199 -92
  52. package/dist/features/provider/useAdminShortcuts.js +80 -64
  53. package/dist/features/routes/pageRoute.js +8 -1
  54. package/dist/features/studio/CamoxStudio.js +45 -9
  55. package/dist/features/studio/components/EnvironmentMenu.js +47 -12
  56. package/dist/features/studio/components/Navbar.js +163 -65
  57. package/dist/features/studio/components/ProjectMenu.d.ts.map +1 -1
  58. package/dist/features/studio/components/ProjectMenu.js +284 -83
  59. package/dist/features/studio/components/UserButton.js +21 -6
  60. package/dist/features/studio/studioStore.d.ts +2 -2
  61. package/dist/features/studio/useTheme.js +128 -74
  62. package/dist/features/vite/definitionsSync.d.ts +7 -12
  63. package/dist/features/vite/definitionsSync.d.ts.map +1 -1
  64. package/dist/features/vite/definitionsSync.js +5 -16
  65. package/dist/features/vite/vite.d.ts +0 -3
  66. package/dist/features/vite/vite.d.ts.map +1 -1
  67. package/dist/features/vite/vite.js +1 -2
  68. package/dist/hooks/use-file-upload.js +11 -11
  69. package/dist/hooks/use-marquee-selection.js +121 -74
  70. package/dist/lib/auth.js +95 -51
  71. package/dist/lib/normalized-data.js +103 -30
  72. package/dist/lib/use-project-room.js +55 -22
  73. package/dist/studio.css +2 -2
  74. package/package.json +29 -26
  75. package/dist/lib/auth.d.ts +0 -2130
  76. package/dist/lib/auth.d.ts.map +0 -1
@@ -1,16 +1,10 @@
1
1
  import { Logger, ViteDevServer } from 'vite';
2
2
  import { CamoxApp } from '../../core/createApp';
3
- export interface DefinitionsSyncOptions {
4
- /** Stable project slug used to resolve the project */
5
- projectSlug?: string;
6
- /** Path to the module that exports the camoxApp (relative to project root) */
7
- camoxAppPath?: string;
8
- /** URL of the Camox API backend */
9
- apiUrl?: string;
10
- /** Secret used to authenticate sync requests with the API */
11
- syncSecret?: string;
12
- /** Environment name to scope definitions to (e.g. "production", "alice-dev") */
13
- environmentName?: string;
3
+ interface SyncDefinitionsOptions {
4
+ projectSlug: string;
5
+ syncSecret: string;
6
+ apiUrl: string;
7
+ environmentName: string;
14
8
  }
15
9
  export declare function syncDefinitionsToApi(options: {
16
10
  camoxApp: CamoxApp;
@@ -20,5 +14,6 @@ export declare function syncDefinitionsToApi(options: {
20
14
  environmentName?: string;
21
15
  logger: Logger;
22
16
  }): Promise<void>;
23
- export declare function syncDefinitions(server: ViteDevServer, options?: DefinitionsSyncOptions): Promise<void>;
17
+ export declare function syncDefinitions(server: ViteDevServer, options: SyncDefinitionsOptions): Promise<void>;
18
+ export {};
24
19
  //# sourceMappingURL=definitionsSync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"definitionsSync.d.ts","sourceRoot":"","sources":["../../../src/features/vite/definitionsSync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAElD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAOjD,MAAM,WAAW,sBAAsB;IACrC,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAgBD,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAClD,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwFhB;AAOD,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,IAAI,CAAC,CAoMf"}
1
+ {"version":3,"file":"definitionsSync.d.ts","sourceRoot":"","sources":["../../../src/features/vite/definitionsSync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAElD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAOjD,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB;AAgBD,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAClD,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwFhB;AASD,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAkLf"}
@@ -70,26 +70,15 @@ async function syncDefinitionsToApi(options) {
70
70
  function getBlockIdFromFilePath(filePath) {
71
71
  return path.basename(filePath, path.extname(filePath));
72
72
  }
73
- async function syncDefinitions(server, options = {}) {
74
- const camoxAppPath = options.camoxAppPath ?? "./src/camox/app.ts";
73
+ var CAMOX_APP_PATH = "./src/camox/app.ts";
74
+ async function syncDefinitions(server, options) {
75
+ const { projectSlug, syncSecret, apiUrl, environmentName } = options;
75
76
  const blocksDir = path.resolve(server.config.root, "src/camox/blocks");
76
- if (!options.projectSlug) {
77
- server.config.logger.warn("[camox] No projectSlug provided, skipping block definitions sync", { timestamp: true });
78
- return;
79
- }
80
- const projectSlug = options.projectSlug;
81
- const apiUrl = options.apiUrl ?? "http://localhost:8787";
82
- if (!options.syncSecret) {
83
- server.config.logger.warn("[camox] No syncSecret provided, skipping definitions sync", { timestamp: true });
84
- return;
85
- }
86
- const syncSecret = options.syncSecret;
87
- const environmentName = options.environmentName;
88
77
  const client = createServerApiClient(apiUrl, environmentName);
89
78
  async function performInitialSync() {
90
- const camoxModule = await server.ssrLoadModule(camoxAppPath);
79
+ const camoxModule = await server.ssrLoadModule(CAMOX_APP_PATH);
91
80
  if (!camoxModule.camoxApp) {
92
- server.config.logger.warn(`[camox] No camoxApp export found in ${camoxAppPath}`, { timestamp: true });
81
+ server.config.logger.warn(`[camox] No camoxApp export found in ${CAMOX_APP_PATH}`, { timestamp: true });
93
82
  return;
94
83
  }
95
84
  await syncDefinitionsToApi({
@@ -1,12 +1,9 @@
1
1
  import { Plugin } from 'vite';
2
- import { DefinitionsSyncOptions } from './definitionsSync';
3
2
  export interface CamoxPluginOptions {
4
3
  /** Stable, human-readable slug identifying this project (e.g. "prestigious-impala-84") */
5
4
  projectSlug: string;
6
5
  /** Secret used to authenticate definition sync requests with the API */
7
6
  syncSecret: string;
8
- /** Options for definitions sync */
9
- definitionsSync?: DefinitionsSyncOptions;
10
7
  /** Disable PostHog analytics collection (default: false) */
11
8
  disableAnalytics?: boolean;
12
9
  /** Internal options (intended for Camox contributors in development, not for public use) */
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../src/features/vite/vite.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAiC,MAAM,MAAM,CAAC;AAUlE,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,mBAAmB,CAAC;AA6B3B,MAAM,WAAW,kBAAkB;IACjC,0FAA0F;IAC1F,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,4FAA4F;IAC5F,SAAS,CAAC,EAAE;QACV,2DAA2D;QAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,0EAA0E;QAC1E,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,oDAAoD;QACpD,sBAAsB,CAAC,EAAE,OAAO,CAAC;KAClC,CAAC;CACH;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAuHzD"}
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../src/features/vite/vite.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAiC,MAAM,MAAM,CAAC;AAuClE,MAAM,WAAW,kBAAkB;IACjC,0FAA0F;IAC1F,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,4FAA4F;IAC5F,SAAS,CAAC,EAAE;QACV,2DAA2D;QAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,0EAA0E;QAC1E,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,oDAAoD;QACpD,sBAAsB,CAAC,EAAE,OAAO,CAAC;KAClC,CAAC;CACH;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAsHzD"}
@@ -92,7 +92,6 @@ function camox(options) {
92
92
  watchNewBlockFiles(server);
93
93
  server.httpServer?.once("listening", () => {
94
94
  syncDefinitions(server, {
95
- ...options.definitionsSync,
96
95
  projectSlug: options.projectSlug,
97
96
  syncSecret: options.syncSecret,
98
97
  apiUrl,
@@ -103,7 +102,7 @@ function camox(options) {
103
102
  async closeBundle() {
104
103
  if (!isBuild) return;
105
104
  const { createServer } = await import("vite");
106
- const camoxAppPath = options.definitionsSync?.camoxAppPath ?? "./src/camox/app.ts";
105
+ const camoxAppPath = "./src/camox/app.ts";
107
106
  const tempServer = await createServer({
108
107
  configFile: false,
109
108
  root: resolvedConfig.root,
@@ -51,32 +51,32 @@ function useFileUpload(options) {
51
51
  mimeType: result.mimeType
52
52
  });
53
53
  trackClientEvent("file_uploaded", { mimeType: file.type });
54
- setUploads((prev) => prev.map((u) => u.id === itemId ? {
55
- ...u,
54
+ setUploads((prev_0) => prev_0.map((u_0) => u_0.id === itemId ? {
55
+ ...u_0,
56
56
  status: "complete",
57
57
  progress: 100
58
- } : u));
58
+ } : u_0));
59
59
  setTimeout(() => {
60
- setUploads((prev) => prev.filter((u) => u.id !== itemId));
60
+ setUploads((prev_1) => prev_1.filter((u_1) => u_1.id !== itemId));
61
61
  }, 2e3);
62
62
  }, [apiUrl]);
63
63
  return {
64
64
  uploads,
65
65
  uploadFiles: useCallback((files) => {
66
- const newItems = Array.from(files).map((file) => ({
66
+ const newItems = Array.from(files).map((file_0) => ({
67
67
  id: String(nextId.current++),
68
- filename: file.name,
68
+ filename: file_0.name,
69
69
  progress: 0,
70
70
  status: "uploading"
71
71
  }));
72
- setUploads((prev) => [...prev, ...newItems]);
73
- Promise.all(Array.from(files).map((file, i) => uploadSingleFile(file, newItems[i].id).catch((err) => {
72
+ setUploads((prev_2) => [...prev_2, ...newItems]);
73
+ Promise.all(Array.from(files).map((file_1, i) => uploadSingleFile(file_1, newItems[i].id).catch((err) => {
74
74
  const message = err instanceof Error ? err.message : "Upload failed";
75
- setUploads((prev) => prev.map((u) => u.id === newItems[i].id ? {
76
- ...u,
75
+ setUploads((prev_3) => prev_3.map((u_2) => u_2.id === newItems[i].id ? {
76
+ ...u_2,
77
77
  status: "error",
78
78
  error: message
79
- } : u));
79
+ } : u_2));
80
80
  })));
81
81
  }, [uploadSingleFile]),
82
82
  clearAll: useCallback(() => {
@@ -1,88 +1,135 @@
1
- import { useCallback, useRef, useState } from "react";
1
+ import { c } from "react/compiler-runtime";
2
+ import { useRef, useState } from "react";
2
3
  //#region src/hooks/use-marquee-selection.ts
3
4
  var DRAG_THRESHOLD = 5;
4
5
  function useMarqueeSelection(containerRef, onSelectionChange) {
6
+ const $ = c(17);
5
7
  const [selectionRect, setSelectionRect] = useState(null);
6
8
  const startPoint = useRef(null);
7
9
  const isDragging = useRef(false);
8
- const getContainerRelativePoint = useCallback((e) => {
9
- const container = containerRef.current;
10
- if (!container) return null;
11
- const bounds = container.getBoundingClientRect();
12
- return {
13
- x: e.clientX - bounds.left + container.scrollLeft,
14
- y: e.clientY - bounds.top + container.scrollTop
10
+ let t0;
11
+ if ($[0] !== containerRef) {
12
+ t0 = (e) => {
13
+ const container = containerRef.current;
14
+ if (!container) return null;
15
+ const bounds = container.getBoundingClientRect();
16
+ return {
17
+ x: e.clientX - bounds.left + container.scrollLeft,
18
+ y: e.clientY - bounds.top + container.scrollTop
19
+ };
15
20
  };
16
- }, [containerRef]);
17
- const computeRect = (a, b) => ({
18
- left: Math.min(a.x, b.x),
19
- top: Math.min(a.y, b.y),
20
- width: Math.abs(a.x - b.x),
21
- height: Math.abs(a.y - b.y)
22
- });
23
- const findIntersectingIds = useCallback((rect) => {
24
- const container = containerRef.current;
25
- if (!container) return /* @__PURE__ */ new Set();
26
- const containerBounds = container.getBoundingClientRect();
27
- const scrollLeft = container.scrollLeft;
28
- const scrollTop = container.scrollTop;
29
- const selViewport = {
30
- left: rect.left - scrollLeft + containerBounds.left,
31
- top: rect.top - scrollTop + containerBounds.top,
32
- right: rect.left + rect.width - scrollLeft + containerBounds.left,
33
- bottom: rect.top + rect.height - scrollTop + containerBounds.top
21
+ $[0] = containerRef;
22
+ $[1] = t0;
23
+ } else t0 = $[1];
24
+ const getContainerRelativePoint = t0;
25
+ const computeRect = _temp;
26
+ let t1;
27
+ if ($[2] !== containerRef) {
28
+ t1 = (rect) => {
29
+ const container_0 = containerRef.current;
30
+ if (!container_0) return /* @__PURE__ */ new Set();
31
+ const containerBounds = container_0.getBoundingClientRect();
32
+ const scrollLeft = container_0.scrollLeft;
33
+ const scrollTop = container_0.scrollTop;
34
+ const selViewport = {
35
+ left: rect.left - scrollLeft + containerBounds.left,
36
+ top: rect.top - scrollTop + containerBounds.top,
37
+ right: rect.left + rect.width - scrollLeft + containerBounds.left,
38
+ bottom: rect.top + rect.height - scrollTop + containerBounds.top
39
+ };
40
+ const ids = /* @__PURE__ */ new Set();
41
+ const cards = container_0.querySelectorAll("[data-asset-id]");
42
+ for (const card of cards) {
43
+ const cardBounds = card.getBoundingClientRect();
44
+ if (selViewport.left < cardBounds.right && selViewport.right > cardBounds.left && selViewport.top < cardBounds.bottom && selViewport.bottom > cardBounds.top) ids.add(card.dataset.assetId);
45
+ }
46
+ return ids;
34
47
  };
35
- const ids = /* @__PURE__ */ new Set();
36
- const cards = container.querySelectorAll("[data-asset-id]");
37
- for (const card of cards) {
38
- const cardBounds = card.getBoundingClientRect();
39
- if (selViewport.left < cardBounds.right && selViewport.right > cardBounds.left && selViewport.top < cardBounds.bottom && selViewport.bottom > cardBounds.top) ids.add(card.dataset.assetId);
40
- }
41
- return ids;
42
- }, [containerRef]);
43
- const onPointerDown = useCallback((e) => {
44
- if (e.button !== 0) return;
45
- if (e.target.closest("[data-asset-id]")) return;
46
- const point = getContainerRelativePoint(e);
47
- if (!point) return;
48
- startPoint.current = point;
49
- isDragging.current = false;
50
- e.currentTarget.setPointerCapture(e.pointerId);
51
- }, [getContainerRelativePoint]);
52
- const onPointerMove = useCallback((e) => {
53
- if (!startPoint.current) return;
54
- const point = getContainerRelativePoint(e);
55
- if (!point) return;
56
- const dx = point.x - startPoint.current.x;
57
- const dy = point.y - startPoint.current.y;
58
- if (!isDragging.current) {
59
- if (Math.abs(dx) < DRAG_THRESHOLD && Math.abs(dy) < DRAG_THRESHOLD) return;
60
- isDragging.current = true;
61
- }
62
- const rect = computeRect(startPoint.current, point);
63
- setSelectionRect(rect);
64
- onSelectionChange(findIntersectingIds(rect));
65
- }, [
66
- getContainerRelativePoint,
67
- findIntersectingIds,
68
- onSelectionChange
69
- ]);
48
+ $[2] = containerRef;
49
+ $[3] = t1;
50
+ } else t1 = $[3];
51
+ const findIntersectingIds = t1;
52
+ let t2;
53
+ if ($[4] !== getContainerRelativePoint) {
54
+ t2 = (e_0) => {
55
+ if (e_0.button !== 0) return;
56
+ if (e_0.target.closest("[data-asset-id]")) return;
57
+ const point = getContainerRelativePoint(e_0);
58
+ if (!point) return;
59
+ startPoint.current = point;
60
+ isDragging.current = false;
61
+ e_0.currentTarget.setPointerCapture(e_0.pointerId);
62
+ };
63
+ $[4] = getContainerRelativePoint;
64
+ $[5] = t2;
65
+ } else t2 = $[5];
66
+ const onPointerDown = t2;
67
+ let t3;
68
+ if ($[6] !== findIntersectingIds || $[7] !== getContainerRelativePoint || $[8] !== onSelectionChange) {
69
+ t3 = (e_1) => {
70
+ if (!startPoint.current) return;
71
+ const point_0 = getContainerRelativePoint(e_1);
72
+ if (!point_0) return;
73
+ const dx = point_0.x - startPoint.current.x;
74
+ const dy = point_0.y - startPoint.current.y;
75
+ if (!isDragging.current) {
76
+ if (Math.abs(dx) < DRAG_THRESHOLD && Math.abs(dy) < DRAG_THRESHOLD) return;
77
+ isDragging.current = true;
78
+ }
79
+ const rect_0 = computeRect(startPoint.current, point_0);
80
+ setSelectionRect(rect_0);
81
+ onSelectionChange(findIntersectingIds(rect_0));
82
+ };
83
+ $[6] = findIntersectingIds;
84
+ $[7] = getContainerRelativePoint;
85
+ $[8] = onSelectionChange;
86
+ $[9] = t3;
87
+ } else t3 = $[9];
88
+ const onPointerMove = t3;
70
89
  const didDrag = useRef(false);
71
- return {
72
- selectionRect,
73
- didDragRef: didDrag,
74
- handlers: {
90
+ let t4;
91
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
92
+ t4 = (e_2) => {
93
+ if (!startPoint.current) return;
94
+ e_2.currentTarget.releasePointerCapture(e_2.pointerId);
95
+ didDrag.current = isDragging.current;
96
+ startPoint.current = null;
97
+ isDragging.current = false;
98
+ setSelectionRect(null);
99
+ };
100
+ $[10] = t4;
101
+ } else t4 = $[10];
102
+ const onPointerUp = t4;
103
+ let t5;
104
+ if ($[11] !== onPointerDown || $[12] !== onPointerMove) {
105
+ t5 = {
75
106
  onPointerDown,
76
107
  onPointerMove,
77
- onPointerUp: useCallback((e) => {
78
- if (!startPoint.current) return;
79
- e.currentTarget.releasePointerCapture(e.pointerId);
80
- didDrag.current = isDragging.current;
81
- startPoint.current = null;
82
- isDragging.current = false;
83
- setSelectionRect(null);
84
- }, [])
85
- }
108
+ onPointerUp
109
+ };
110
+ $[11] = onPointerDown;
111
+ $[12] = onPointerMove;
112
+ $[13] = t5;
113
+ } else t5 = $[13];
114
+ let t6;
115
+ if ($[14] !== selectionRect || $[15] !== t5) {
116
+ t6 = {
117
+ selectionRect,
118
+ didDragRef: didDrag,
119
+ handlers: t5
120
+ };
121
+ $[14] = selectionRect;
122
+ $[15] = t5;
123
+ $[16] = t6;
124
+ } else t6 = $[16];
125
+ return t6;
126
+ }
127
+ function _temp(a, b) {
128
+ return {
129
+ left: Math.min(a.x, b.x),
130
+ top: Math.min(a.y, b.y),
131
+ width: Math.abs(a.x - b.x),
132
+ height: Math.abs(a.y - b.y)
86
133
  };
87
134
  }
88
135
  //#endregion
package/dist/lib/auth.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { actionsStore } from "../features/provider/actionsStore.js";
2
+ import { c } from "react/compiler-runtime";
2
3
  import * as React from "react";
3
4
  import { oneTimeTokenClient, organizationClient } from "better-auth/client/plugins";
4
5
  import { createAuthClient } from "better-auth/react";
@@ -159,30 +160,45 @@ function createCamoxAuthClient(apiUrl) {
159
160
  * Returns `true` once processing is complete (or if there was no OTT).
160
161
  */
161
162
  function useProcessOtt(authClient) {
162
- const [ready, setReady] = React.useState(() => {
163
- if (typeof window === "undefined") return true;
164
- return !new URL(window.location.href).searchParams.has("ott");
165
- });
166
- React.useEffect(() => {
167
- if (ready) return;
168
- const url = new URL(window.location.href);
169
- const ott = url.searchParams.get("ott");
170
- if (!ott) {
171
- setReady(true);
172
- return;
173
- }
174
- url.searchParams.delete("ott");
175
- window.history.replaceState({}, "", url);
176
- (async () => {
177
- try {
178
- await authClient.oneTimeToken.verify({ token: ott });
179
- authClient.updateSession();
180
- } catch {}
181
- setReady(true);
182
- })();
183
- }, [authClient, ready]);
163
+ const $ = c(4);
164
+ const [ready, setReady] = React.useState(_temp);
165
+ let t0;
166
+ let t1;
167
+ if ($[0] !== authClient || $[1] !== ready) {
168
+ t0 = () => {
169
+ if (ready) return;
170
+ const url = new URL(window.location.href);
171
+ const ott = url.searchParams.get("ott");
172
+ if (!ott) {
173
+ setReady(true);
174
+ return;
175
+ }
176
+ url.searchParams.delete("ott");
177
+ window.history.replaceState({}, "", url);
178
+ (async () => {
179
+ try {
180
+ await authClient.oneTimeToken.verify({ token: ott });
181
+ authClient.updateSession();
182
+ } catch {}
183
+ setReady(true);
184
+ })();
185
+ };
186
+ t1 = [authClient, ready];
187
+ $[0] = authClient;
188
+ $[1] = ready;
189
+ $[2] = t0;
190
+ $[3] = t1;
191
+ } else {
192
+ t0 = $[2];
193
+ t1 = $[3];
194
+ }
195
+ React.useEffect(t0, t1);
184
196
  return ready;
185
197
  }
198
+ function _temp() {
199
+ if (typeof window === "undefined") return true;
200
+ return !new URL(window.location.href).searchParams.has("ott");
201
+ }
186
202
  var AuthContext = React.createContext(null);
187
203
  function useAuthContext() {
188
204
  const ctx = React.useContext(AuthContext);
@@ -205,45 +221,73 @@ function useIsAuthenticated() {
205
221
  return isAuthenticated;
206
222
  }
207
223
  function useSignInRedirect() {
224
+ const $ = c(2);
208
225
  const { authenticationUrl } = useAuthContext();
209
- return React.useCallback(() => {
210
- if (typeof window !== "undefined") {
211
- const redirect = encodeURIComponent(window.location.href);
212
- window.location.href = `${authenticationUrl}/login?redirect=${redirect}`;
213
- }
214
- }, [authenticationUrl]);
226
+ let t0;
227
+ if ($[0] !== authenticationUrl) {
228
+ t0 = () => {
229
+ if (typeof window !== "undefined") {
230
+ const redirect = encodeURIComponent(window.location.href);
231
+ window.location.href = `${authenticationUrl}/login?redirect=${redirect}`;
232
+ }
233
+ };
234
+ $[0] = authenticationUrl;
235
+ $[1] = t0;
236
+ } else t0 = $[1];
237
+ return t0;
215
238
  }
216
239
  /**
217
240
  * Registers sign-out and manage-account actions in the command palette.
218
241
  */
219
242
  function useAuthActions() {
243
+ const $ = c(4);
220
244
  const { authClient, authenticationUrl } = useAuthContext();
221
- React.useEffect(() => {
222
- actionsStore.send({
223
- type: "registerManyActions",
224
- actions: [{
225
- id: "manage-account",
226
- label: "Manage account",
227
- groupLabel: "Studio",
228
- checkIfAvailable: () => true,
229
- execute: () => {
230
- window.open(`${authenticationUrl}/profile`, "_blank");
231
- }
232
- }, {
233
- id: "log-out",
234
- label: "Log out",
235
- groupLabel: "Studio",
236
- checkIfAvailable: () => true,
237
- execute: () => authClient.signOut()
238
- }]
239
- });
240
- return () => {
245
+ let t0;
246
+ let t1;
247
+ if ($[0] !== authClient || $[1] !== authenticationUrl) {
248
+ t0 = () => {
241
249
  actionsStore.send({
242
- type: "unregisterManyActions",
243
- ids: ["manage-account", "log-out"]
250
+ type: "registerManyActions",
251
+ actions: [{
252
+ id: "manage-account",
253
+ label: "Manage account",
254
+ groupLabel: "Studio",
255
+ checkIfAvailable: _temp2,
256
+ execute: () => {
257
+ window.open(`${authenticationUrl}/profile`, "_blank");
258
+ }
259
+ }, {
260
+ id: "log-out",
261
+ label: "Log out",
262
+ groupLabel: "Studio",
263
+ checkIfAvailable: _temp3,
264
+ execute: () => authClient.signOut()
265
+ }]
244
266
  });
267
+ return _temp4;
245
268
  };
246
- }, [authClient, authenticationUrl]);
269
+ t1 = [authClient, authenticationUrl];
270
+ $[0] = authClient;
271
+ $[1] = authenticationUrl;
272
+ $[2] = t0;
273
+ $[3] = t1;
274
+ } else {
275
+ t0 = $[2];
276
+ t1 = $[3];
277
+ }
278
+ React.useEffect(t0, t1);
279
+ }
280
+ function _temp4() {
281
+ actionsStore.send({
282
+ type: "unregisterManyActions",
283
+ ids: ["manage-account", "log-out"]
284
+ });
285
+ }
286
+ function _temp3() {
287
+ return true;
288
+ }
289
+ function _temp2() {
290
+ return true;
247
291
  }
248
292
  //#endregion
249
293
  export { AuthContext, createCamoxAuthClient, getAuthCookieHeader, useAuthActions, useAuthContext, useAuthState, useIsAuthenticated, useProcessOtt, useProjectSlug, useSignInRedirect };