camox 0.33.1 → 0.35.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 (146) hide show
  1. package/dist/core/components/lexical/InlineLexicalEditor.js +1 -1
  2. package/dist/core/components/lexical/SidebarLexicalEditor.js +7 -7
  3. package/dist/core/components/lexical/TextLinkPopover.js +4 -4
  4. package/dist/core/createApp.d.ts +2 -1
  5. package/dist/core/createBlock.d.ts +5 -1451
  6. package/dist/core/createBlock.js +450 -1603
  7. package/dist/core/defineDocument.d.ts +7 -0
  8. package/dist/core/defineDocument.js +7 -0
  9. package/dist/core/editing/BlockEditingRuntime.js +36 -0
  10. package/dist/core/editing/CompleteBlockEditingRuntime.js +76 -0
  11. package/dist/core/editing/createEditableBlock.d.ts +1455 -0
  12. package/dist/core/editing/createEditableBlock.js +1751 -0
  13. package/dist/core/lib/lexicalState.js +1 -1
  14. package/dist/features/agent-chat/components/AgentChatSidebar.js +4 -4
  15. package/dist/features/agent-chat/components/AgentChatThread.js +5 -5
  16. package/dist/features/content/components/AssetCard.js +1 -1
  17. package/dist/features/navigation/navigation.d.ts +39 -0
  18. package/dist/features/navigation/navigation.js +231 -0
  19. package/dist/features/page/PublishedPageContent.js +236 -0
  20. package/dist/features/page/PublishedPageExperience.js +23 -0
  21. package/dist/features/preview/CamoxPreview.d.ts +4 -0
  22. package/dist/features/preview/CamoxPreview.js +16 -16
  23. package/dist/features/preview/EditablePageContent.js +3 -0
  24. package/dist/features/preview/EditablePageExperience.js +24 -0
  25. package/dist/features/preview/components/AddBlockSidebar.js +7 -7
  26. package/dist/features/preview/components/AssetFieldEditor.js +1 -1
  27. package/dist/features/preview/components/AssetLightbox.js +46 -110
  28. package/dist/features/preview/components/BlockActionsPopover.js +6 -6
  29. package/dist/features/preview/components/CreatePageModal.js +7 -7
  30. package/dist/features/preview/components/DebouncedFieldEditor.js +2 -2
  31. package/dist/features/preview/components/DraftSwitchDialog.js +1 -1
  32. package/dist/features/preview/components/FieldToolbar.js +4 -4
  33. package/dist/features/preview/components/Frame.js +1 -1
  34. package/dist/features/preview/components/ItemFieldsEditor.js +3 -3
  35. package/dist/features/preview/components/LeftSidebar.js +1 -1
  36. package/dist/features/preview/components/LinkFieldEditor.js +3 -3
  37. package/dist/features/preview/components/Metadata.js +87 -0
  38. package/dist/features/preview/components/MultipleAssetFieldEditor.js +1 -1
  39. package/dist/features/preview/components/OverlayTracker.js +3 -3
  40. package/dist/features/preview/components/Overlays.js +3 -3
  41. package/dist/features/preview/components/PageEditorSidebar.js +5 -5
  42. package/dist/features/preview/components/PageInfoSidebar.js +158 -74
  43. package/dist/features/preview/components/PageLocationFieldset.js +1 -1
  44. package/dist/features/preview/components/PageNavigatorSidebar.js +10 -10
  45. package/dist/features/preview/components/PageNicknameField.js +2 -2
  46. package/dist/features/preview/components/PagePicker.js +4 -4
  47. package/dist/features/preview/components/PageTree.js +3 -3
  48. package/dist/features/preview/components/PeekedBlock.js +2 -2
  49. package/dist/features/preview/components/PreviewPanel.js +2 -2
  50. package/dist/features/preview/components/PreviewToolbar.js +2 -2
  51. package/dist/features/preview/components/PublishDialog.js +2 -2
  52. package/dist/features/preview/components/RepeatableItemsList.js +1 -1
  53. package/dist/features/preview/components/RightSidebar.js +1 -1
  54. package/dist/features/preview/components/useRepeatableItemActions.js +1 -1
  55. package/dist/features/preview/components/useUpdateBlockPosition.js +4 -4
  56. package/dist/features/provider/AuthenticatedCamoxProvider.js +63 -0
  57. package/dist/features/provider/CamoxProvider.d.ts +5 -12
  58. package/dist/features/provider/CamoxProvider.js +81 -337
  59. package/dist/features/provider/CoreCamoxProvider.js +37 -0
  60. package/dist/features/provider/LocalhostPreviewProvider.js +159 -0
  61. package/dist/features/provider/components/CommandPalette.js +1 -1
  62. package/dist/features/provider/useAdminShortcuts.js +1 -1
  63. package/dist/features/routes/pageRuntime.js +6 -0
  64. package/dist/features/runtime/hydrationData.js +9 -0
  65. package/dist/features/runtime/pageApp.js +188 -0
  66. package/dist/features/runtime/pageClient.d.ts +6 -0
  67. package/dist/features/runtime/pageClient.js +20 -0
  68. package/dist/features/runtime/pageNavigation.js +170 -0
  69. package/dist/features/runtime/pageServer.d.ts +9 -0
  70. package/dist/features/runtime/pageServer.js +18 -0
  71. package/dist/features/runtime/runtime.d.ts +25 -0
  72. package/dist/features/runtime/runtime.js +44 -0
  73. package/dist/features/runtime/studioApp.d.ts +15 -0
  74. package/dist/features/runtime/studioApp.js +185 -0
  75. package/dist/features/runtime/studioClient.d.ts +6 -0
  76. package/dist/features/runtime/studioClient.js +20 -0
  77. package/dist/features/runtime/studioNavigation.js +115 -0
  78. package/dist/features/runtime/studioServer.d.ts +9 -0
  79. package/dist/features/runtime/studioServer.js +18 -0
  80. package/dist/features/studio/CamoxStudio.js +4 -4
  81. package/dist/features/studio/components/EnvironmentMenu.js +2 -2
  82. package/dist/features/studio/components/Navbar.js +7 -7
  83. package/dist/features/studio/components/ProjectMenu.js +9 -9
  84. package/dist/features/studio/components/UserButton.js +3 -3
  85. package/dist/features/studio/useTheme.js +1 -22
  86. package/dist/features/vite/appGeneration.js +16 -5
  87. package/dist/features/vite/blockBoilerplate.js +1 -1
  88. package/dist/features/vite/definitionsSync.js +4 -4
  89. package/dist/features/vite/routeGeneration.js +9 -156
  90. package/dist/features/vite/runtimeDev.js +291 -0
  91. package/dist/features/vite/utils.js +3 -1
  92. package/dist/features/vite/vite.d.ts +22 -3
  93. package/dist/features/vite/vite.js +42 -19
  94. package/dist/lib/auth.js +42 -68
  95. package/dist/lib/normalized-data.js +6 -6
  96. package/dist/lib/telemetry.js +1 -24
  97. package/dist/lib/utils.js +1 -1
  98. package/dist/lib/view-queries.js +28 -0
  99. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/Matches.d.ts +114 -0
  100. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/RouterProvider.d.ts +25 -0
  101. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/config.d.ts +1 -0
  102. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/defer.d.ts +1 -0
  103. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/fileRoute.d.ts +20 -0
  104. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/global.d.ts +8 -0
  105. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/hash-scroll.d.ts +1 -0
  106. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/index.d.ts +18 -0
  107. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/link.d.ts +161 -0
  108. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/load-matches.d.ts +6 -0
  109. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/location.d.ts +54 -0
  110. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/lru-cache.d.ts +8 -0
  111. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/manifest.d.ts +32 -0
  112. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/new-process-route-tree.d.ts +115 -0
  113. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/not-found.d.ts +1 -0
  114. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/redirect.d.ts +49 -0
  115. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/rewrite.d.ts +1 -0
  116. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/root.d.ts +6 -0
  117. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/route.d.ts +343 -0
  118. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/routeInfo.d.ts +48 -0
  119. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/router.d.ts +695 -0
  120. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/scroll-restoration.d.ts +1 -0
  121. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/searchMiddleware.d.ts +1 -0
  122. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/searchParams.d.ts +5 -0
  123. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/ssr/serializer/RawStream.d.ts +38 -0
  124. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/ssr/serializer/seroval-plugins.d.ts +1 -0
  125. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/ssr/serializer/transformer.d.ts +65 -0
  126. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/stores.d.ts +69 -0
  127. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/structuralSharing.d.ts +1 -0
  128. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/typePrimitives.d.ts +1 -0
  129. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useLoaderData.d.ts +1 -0
  130. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useLoaderDeps.d.ts +1 -0
  131. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useNavigate.d.ts +10 -0
  132. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useParams.d.ts +1 -0
  133. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useRouteContext.d.ts +1 -0
  134. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useSearch.d.ts +1 -0
  135. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/utils.d.ts +28 -0
  136. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/validators.d.ts +49 -0
  137. package/package.json +39 -12
  138. package/skills/camox-block/SKILL.md +4 -4
  139. package/skills/camox-cli/SKILL.md +3 -3
  140. package/skills/camox-layout/SKILL.md +2 -2
  141. package/dist/features/routes/ogRoute.d.ts +0 -12
  142. package/dist/features/routes/ogRoute.js +0 -20
  143. package/dist/features/routes/pageRoute.d.ts +0 -48
  144. package/dist/features/routes/pageRoute.js +0 -254
  145. package/dist/lib/api-client.d.ts +0 -7
  146. package/dist/lib/queries.d.ts +0 -12
@@ -1,18 +1,18 @@
1
+ import { useLocation } from "../../navigation/navigation.js";
1
2
  import { blockMutations } from "../../../lib/queries.js";
2
3
  import { previewStore } from "../previewStore.js";
3
4
  import { c } from "react/compiler-runtime";
4
5
  import { useMutation, useQueryClient } from "@tanstack/react-query";
5
- import { useLocation } from "@tanstack/react-router";
6
- import { useSelector } from "@xstate/store-react";
7
6
  import { generateKeyBetween } from "fractional-indexing";
7
+ import { useSelector } from "@xstate/store-react";
8
8
  import { queryKeys } from "@camox/api-contract/query-keys";
9
9
 
10
10
  //#region src/features/preview/components/useUpdateBlockPosition.ts
11
11
  function useUpdateBlockPosition() {
12
12
  const $ = c(5);
13
- if ($[0] !== "13182e6fc3bf905233106f71f311ee66fbdf35afd4c8eee1eed03bd0725a9e4a") {
13
+ if ($[0] !== "c7adf6cdbf960268a5bfbb85b92c76404d7abbe36258eed14eb7062e652330a8") {
14
14
  for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
15
- $[0] = "13182e6fc3bf905233106f71f311ee66fbdf35afd4c8eee1eed03bd0725a9e4a";
15
+ $[0] = "c7adf6cdbf960268a5bfbb85b92c76404d7abbe36258eed14eb7062e652330a8";
16
16
  }
17
17
  const queryClient = useQueryClient();
18
18
  const { pathname } = useLocation();
@@ -0,0 +1,63 @@
1
+ import { AuthContext, useAuthActions } from "../../lib/auth.js";
2
+ import { projectQueries } from "../../lib/queries.js";
3
+ import { useApplyTheme, useThemeActions } from "../studio/useTheme.js";
4
+ import { useNavbarActions } from "../studio/components/Navbar.js";
5
+ import { identifyProject, identifyUser } from "../../lib/telemetry-client.js";
6
+ import { usePreviewPagesActions } from "../preview/CamoxPreview.js";
7
+ import { useProjectRoom } from "../../lib/use-project-room.js";
8
+ import { CommandPalette, useCommandPaletteActions } from "./components/CommandPalette.js";
9
+ import { useAdminShortcuts } from "./useAdminShortcuts.js";
10
+ import { useQuery } from "@tanstack/react-query";
11
+ import * as React from "react";
12
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
+ import { Toaster } from "@camox/ui/toaster";
14
+ import studioCssUrl from "virtual:camox-studio-css";
15
+
16
+ //#region src/features/provider/AuthenticatedCamoxProvider.tsx
17
+ function AuthenticatedCamoxProvider({ children }) {
18
+ useAdminShortcuts();
19
+ useCommandPaletteActions();
20
+ useThemeActions();
21
+ useAuthActions();
22
+ useNavbarActions();
23
+ usePreviewPagesActions();
24
+ const { authClient, apiUrl, projectSlug, environmentName } = React.useContext(AuthContext);
25
+ const { data: session } = authClient.useSession();
26
+ const { data: project } = useQuery(projectQueries.getBySlug(projectSlug));
27
+ useProjectRoom(apiUrl, project?.id);
28
+ React.useEffect(() => {
29
+ const user = session?.user;
30
+ if (!user) return;
31
+ identifyUser({
32
+ userId: user.id,
33
+ email: user.email,
34
+ name: user.name
35
+ });
36
+ }, [session?.user]);
37
+ React.useEffect(() => {
38
+ if (!project) return;
39
+ identifyProject({
40
+ projectId: project.id,
41
+ projectSlug,
42
+ projectName: project.name,
43
+ environmentName
44
+ });
45
+ }, [
46
+ environmentName,
47
+ project,
48
+ projectSlug
49
+ ]);
50
+ const { resolvedTheme } = useApplyTheme();
51
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
52
+ /* @__PURE__ */ jsx("link", {
53
+ rel: "stylesheet",
54
+ href: studioCssUrl
55
+ }),
56
+ children,
57
+ /* @__PURE__ */ jsx(Toaster, { theme: resolvedTheme }),
58
+ /* @__PURE__ */ jsx(CommandPalette, {})
59
+ ] });
60
+ }
61
+
62
+ //#endregion
63
+ export { AuthenticatedCamoxProvider };
@@ -4,20 +4,13 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
4
4
 
5
5
  //#region src/features/provider/CamoxProvider.d.ts
6
6
  interface CamoxProviderProps {
7
- children: React.ReactNode;
8
- camoxApp: CamoxApp;
9
- authenticationUrl: string;
10
7
  apiUrl: string;
11
- projectSlug: string;
8
+ authenticationUrl: string;
9
+ camoxApp: CamoxApp;
10
+ children: React.ReactNode;
12
11
  environmentName?: string;
12
+ projectSlug: string;
13
13
  }
14
- declare function CamoxProvider({
15
- children,
16
- camoxApp,
17
- authenticationUrl,
18
- apiUrl,
19
- projectSlug,
20
- environmentName
21
- }: CamoxProviderProps): _$react_jsx_runtime0.JSX.Element | null;
14
+ declare function CamoxProvider(props: CamoxProviderProps): _$react_jsx_runtime0.JSX.Element;
22
15
  //#endregion
23
16
  export { CamoxProvider };
@@ -1,365 +1,109 @@
1
- import { actionsStore } from "./actionsStore.js";
2
- import { AuthContext, createCamoxAuthClient, useAuthActions, useProcessOtt, useSignInRedirect } from "../../lib/auth.js";
3
- import { initApiClient } from "../../lib/api-client.js";
4
- import { projectQueries } from "../../lib/queries.js";
5
- import { identifyProject, identifyUser } from "../../lib/telemetry-client.js";
6
- import { CamoxAppProvider } from "./components/CamoxAppContext.js";
1
+ import { useLocation } from "../navigation/navigation.js";
2
+ import { useSignInRedirect } from "../../lib/auth.js";
7
3
  import { STUDIO_BASE_PATH } from "../studio/routes.js";
8
- import { useApplyTheme, useThemeActions, useThemeValue } from "../studio/useTheme.js";
9
- import { useNavbarActions } from "../studio/components/Navbar.js";
10
- import { PreviewPanel } from "../preview/components/PreviewPanel.js";
11
- import { usePreviewPagesActions } from "../preview/CamoxPreview.js";
12
4
  import { AuthGate } from "../../components/AuthGate.js";
13
- import { useProjectRoom } from "../../lib/use-project-room.js";
14
- import { CommandPalette, useCommandPaletteActions } from "./components/CommandPalette.js";
15
- import { useAdminShortcuts } from "./useAdminShortcuts.js";
5
+ import { AuthenticatedCamoxProvider } from "./AuthenticatedCamoxProvider.js";
6
+ import { CoreCamoxProvider } from "./CoreCamoxProvider.js";
7
+ import { LocalhostPreviewProvider } from "./LocalhostPreviewProvider.js";
16
8
  import { c } from "react/compiler-runtime";
17
- import { useQuery } from "@tanstack/react-query";
18
- import { useLocation } from "@tanstack/react-router";
19
9
  import * as React from "react";
20
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
21
- import { Toaster } from "@camox/ui/toaster";
22
- import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
23
- import { ReactQueryDevtools } from "@tanstack/react-query-devtools/production";
24
- import studioCssUrl from "virtual:camox-studio-css";
10
+ import { jsx } from "react/jsx-runtime";
25
11
 
26
12
  //#region src/features/provider/CamoxProvider.tsx
27
- const isLocalhost = () => {
28
- if (typeof window === "undefined") return false;
29
- const { hostname } = window.location;
30
- return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
31
- };
32
- const isStudioPathname = (pathname) => {
33
- return pathname === STUDIO_BASE_PATH || pathname.startsWith(`${STUDIO_BASE_PATH}/`);
34
- };
35
- const AuthenticatedCamoxProvider = ({ children }) => {
36
- useAdminShortcuts();
37
- useCommandPaletteActions();
38
- useThemeActions();
39
- useAuthActions();
40
- useNavbarActions();
41
- usePreviewPagesActions();
42
- const { authClient, apiUrl, projectSlug, environmentName } = React.useContext(AuthContext);
43
- const { data: session } = authClient.useSession();
44
- const user = session?.user;
45
- const { data: project } = useQuery(projectQueries.getBySlug(projectSlug));
46
- useProjectRoom(apiUrl, project?.id);
47
- React.useEffect(() => {
48
- if (!user) return;
49
- identifyUser({
50
- userId: user.id,
51
- email: user.email,
52
- name: user.name
53
- });
54
- }, [user]);
55
- React.useEffect(() => {
56
- if (!project) return;
57
- identifyProject({
58
- projectId: project.id,
59
- projectSlug,
60
- projectName: project.name,
61
- environmentName
62
- });
63
- }, [
64
- project,
65
- projectSlug,
66
- environmentName
67
- ]);
68
- const { resolvedTheme } = useApplyTheme();
69
- return /* @__PURE__ */ jsxs(Fragment, { children: [
70
- children,
71
- /* @__PURE__ */ jsx(Toaster, { theme: resolvedTheme }),
72
- /* @__PURE__ */ jsx(CommandPalette, {})
73
- ] });
74
- };
75
- const UnauthenticatedLocalhostPreview = (t0) => {
76
- const $ = c(21);
77
- if ($[0] !== "2345da22a3008afc4c6b84025e9a92cb83736efc9029df9e88c3c92247986a8f") {
78
- for (let $i = 0; $i < 21; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
79
- $[0] = "2345da22a3008afc4c6b84025e9a92cb83736efc9029df9e88c3c92247986a8f";
80
- }
81
- const { children } = t0;
82
- const signInRedirect = useSignInRedirect();
83
- const { resolvedTheme } = useApplyTheme();
84
- const [isSignInDialogOpen, setIsSignInDialogOpen] = React.useState(false);
85
- useAdminShortcuts();
86
- let t1;
87
- let t2;
88
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
89
- t1 = () => {
90
- const actions = [{
91
- id: "sign-in-to-edit",
92
- label: "Sign in to edit",
93
- aliases: ["Enter edit mode", "Edit mode"],
94
- groupLabel: "Preview",
95
- checkIfAvailable: _temp,
96
- execute: () => setIsSignInDialogOpen(true),
97
- shortcut: {
98
- key: "Enter",
99
- withMeta: true
100
- }
101
- }];
102
- actionsStore.send({
103
- type: "registerManyActions",
104
- actions
105
- });
106
- return () => {
107
- actionsStore.send({
108
- type: "unregisterManyActions",
109
- ids: actions.map(_temp2)
110
- });
111
- };
112
- };
113
- t2 = [];
114
- $[1] = t1;
115
- $[2] = t2;
116
- } else {
117
- t1 = $[1];
118
- t2 = $[2];
119
- }
120
- React.useEffect(t1, t2);
121
- let t3;
122
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
123
- t3 = /* @__PURE__ */ jsx("link", {
124
- rel: "stylesheet",
125
- href: studioCssUrl
126
- });
127
- $[3] = t3;
128
- } else t3 = $[3];
129
- let t4;
130
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
131
- t4 = { bottom: "1rem" };
132
- $[4] = t4;
133
- } else t4 = $[4];
134
- let t5;
135
- if ($[5] !== resolvedTheme) {
136
- t5 = /* @__PURE__ */ jsx(Toaster, {
137
- theme: resolvedTheme,
138
- position: "bottom-right",
139
- offset: t4
140
- });
141
- $[5] = resolvedTheme;
142
- $[6] = t5;
143
- } else t5 = $[6];
144
- let t6;
145
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
146
- t6 = { onEditModeChange: (checked) => {
147
- if (checked) setIsSignInDialogOpen(true);
148
- } };
149
- $[7] = t6;
150
- } else t6 = $[7];
151
- let t7;
152
- if ($[8] !== children) {
153
- t7 = /* @__PURE__ */ jsx("div", {
154
- className: "bg-background flex h-screen flex-col overflow-hidden",
155
- children: /* @__PURE__ */ jsx(PreviewPanel, {
156
- toolbarProps: t6,
157
- children
158
- })
159
- });
160
- $[8] = children;
161
- $[9] = t7;
162
- } else t7 = $[9];
163
- let t8;
164
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
165
- t8 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Sign in to edit" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "You need to sign in before you can enable edit mode." })] });
166
- $[10] = t8;
167
- } else t8 = $[10];
168
- let t9;
169
- if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
170
- t9 = /* @__PURE__ */ jsx(AlertDialogCancel, {
171
- variant: "outline",
172
- size: "default",
173
- children: "Cancel"
174
- });
175
- $[11] = t9;
176
- } else t9 = $[11];
177
- let t10;
178
- if ($[12] !== signInRedirect) {
179
- t10 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t8, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t9, /* @__PURE__ */ jsx(AlertDialogAction, {
180
- onClick: signInRedirect,
181
- children: "Sign in"
182
- })] })] });
183
- $[12] = signInRedirect;
184
- $[13] = t10;
185
- } else t10 = $[13];
186
- let t11;
187
- if ($[14] !== isSignInDialogOpen || $[15] !== t10) {
188
- t11 = /* @__PURE__ */ jsx(AlertDialog, {
189
- open: isSignInDialogOpen,
190
- onOpenChange: setIsSignInDialogOpen,
191
- children: t10
192
- });
193
- $[14] = isSignInDialogOpen;
194
- $[15] = t10;
195
- $[16] = t11;
196
- } else t11 = $[16];
197
- let t12;
198
- if ($[17] !== t11 || $[18] !== t5 || $[19] !== t7) {
199
- t12 = /* @__PURE__ */ jsxs(Fragment, { children: [
200
- t3,
201
- t5,
202
- t7,
203
- t11
204
- ] });
205
- $[17] = t11;
206
- $[18] = t5;
207
- $[19] = t7;
208
- $[20] = t12;
209
- } else t12 = $[20];
210
- return t12;
211
- };
212
- const UnauthenticatedPage = (t0) => {
213
- const $ = c(9);
214
- if ($[0] !== "2345da22a3008afc4c6b84025e9a92cb83736efc9029df9e88c3c92247986a8f") {
215
- for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
216
- $[0] = "2345da22a3008afc4c6b84025e9a92cb83736efc9029df9e88c3c92247986a8f";
217
- }
218
- const { children } = t0;
219
- const { theme } = useThemeValue();
220
- let t1;
221
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
222
- t1 = { bottom: "1rem" };
223
- $[1] = t1;
224
- } else t1 = $[1];
225
- let t2;
226
- if ($[2] !== theme) {
227
- t2 = /* @__PURE__ */ jsx(Toaster, {
228
- theme,
229
- position: "bottom-right",
230
- offset: t1
231
- });
232
- $[2] = theme;
233
- $[3] = t2;
234
- } else t2 = $[3];
235
- let t3;
236
- if ($[4] !== children) {
237
- t3 = /* @__PURE__ */ jsx("div", {
238
- className: "bg-background min-h-screen",
239
- children
240
- });
241
- $[4] = children;
242
- $[5] = t3;
243
- } else t3 = $[5];
244
- let t4;
245
- if ($[6] !== t2 || $[7] !== t3) {
246
- t4 = /* @__PURE__ */ jsxs(Fragment, { children: [t2, t3] });
247
- $[6] = t2;
248
- $[7] = t3;
249
- $[8] = t4;
250
- } else t4 = $[8];
251
- return t4;
252
- };
253
- const UnauthenticatedCamoxProvider = (t0) => {
254
- const $ = c(14);
255
- if ($[0] !== "2345da22a3008afc4c6b84025e9a92cb83736efc9029df9e88c3c92247986a8f") {
256
- for (let $i = 0; $i < 14; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
257
- $[0] = "2345da22a3008afc4c6b84025e9a92cb83736efc9029df9e88c3c92247986a8f";
13
+ function UnauthenticatedExperience(t0) {
14
+ const $ = c(13);
15
+ if ($[0] !== "29d68a11213af2b1fef531271ea0f2268b5c50fdad0696b9211d3ed97537e7c8") {
16
+ for (let $i = 0; $i < 13; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
17
+ $[0] = "29d68a11213af2b1fef531271ea0f2268b5c50fdad0696b9211d3ed97537e7c8";
258
18
  }
259
19
  const { children } = t0;
260
20
  const { pathname } = useLocation();
261
21
  let t1;
262
22
  if ($[1] !== pathname) {
263
- t1 = () => {
264
- if (typeof window === "undefined") return;
265
- if (pathname !== STUDIO_BASE_PATH) return window.location.href;
266
- return new URL("/", window.location.href).href;
267
- };
23
+ t1 = pathname === STUDIO_BASE_PATH || pathname.startsWith(`${STUDIO_BASE_PATH}/`);
268
24
  $[1] = pathname;
269
25
  $[2] = t1;
270
26
  } else t1 = $[2];
271
- const signInRedirect = useSignInRedirect(t1);
27
+ const isStudio = t1;
272
28
  let t2;
273
- let t3;
274
- if ($[3] !== pathname || $[4] !== signInRedirect) {
29
+ if ($[3] !== isStudio) {
275
30
  t2 = () => {
276
- if (!isStudioPathname(pathname)) return;
277
- signInRedirect();
31
+ if (typeof window === "undefined") return;
32
+ if (!isStudio) return window.location.href;
33
+ return new URL("/", window.location.href).href;
278
34
  };
279
- t3 = [pathname, signInRedirect];
280
- $[3] = pathname;
281
- $[4] = signInRedirect;
282
- $[5] = t2;
283
- $[6] = t3;
284
- } else {
285
- t2 = $[5];
286
- t3 = $[6];
287
- }
288
- React.useEffect(t2, t3);
35
+ $[3] = isStudio;
36
+ $[4] = t2;
37
+ } else t2 = $[4];
38
+ const signInRedirect = useSignInRedirect(t2);
39
+ let t3;
289
40
  let t4;
290
- let t5;
291
- if ($[7] !== signInRedirect) {
292
- t4 = () => {
293
- const handleKeyDown = (event) => {
294
- if (isLocalhost()) return;
295
- if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
296
- event.preventDefault();
297
- signInRedirect();
298
- }
299
- };
300
- document.addEventListener("keydown", handleKeyDown);
301
- return () => document.removeEventListener("keydown", handleKeyDown);
41
+ if ($[5] !== isStudio || $[6] !== signInRedirect) {
42
+ t3 = () => {
43
+ if (isStudio) signInRedirect();
302
44
  };
303
- t5 = [signInRedirect];
304
- $[7] = signInRedirect;
45
+ t4 = [isStudio, signInRedirect];
46
+ $[5] = isStudio;
47
+ $[6] = signInRedirect;
48
+ $[7] = t3;
305
49
  $[8] = t4;
306
- $[9] = t5;
307
50
  } else {
51
+ t3 = $[7];
308
52
  t4 = $[8];
309
- t5 = $[9];
310
- }
311
- React.useEffect(t4, t5);
312
- if (isStudioPathname(pathname)) return null;
313
- if (isLocalhost() && !isStudioPathname(pathname)) {
314
- let t6;
315
- if ($[10] !== children) {
316
- t6 = /* @__PURE__ */ jsx(UnauthenticatedLocalhostPreview, { children });
317
- $[10] = children;
318
- $[11] = t6;
319
- } else t6 = $[11];
320
- return t6;
321
53
  }
322
- let t6;
323
- if ($[12] !== children) {
324
- t6 = /* @__PURE__ */ jsx(UnauthenticatedPage, { children });
325
- $[12] = children;
326
- $[13] = t6;
327
- } else t6 = $[13];
328
- return t6;
329
- };
330
- function CamoxProvider({ children, camoxApp, authenticationUrl, apiUrl, projectSlug, environmentName }) {
331
- const authClient = React.useMemo(() => createCamoxAuthClient(apiUrl), [apiUrl]);
332
- const initializedApiUrl = React.useRef(null);
333
- if (initializedApiUrl.current !== apiUrl) {
334
- initApiClient(apiUrl, environmentName);
335
- initializedApiUrl.current = apiUrl;
54
+ React.useEffect(t3, t4);
55
+ if (isStudio) return null;
56
+ if (typeof window !== "undefined" && [
57
+ "localhost",
58
+ "127.0.0.1",
59
+ "::1"
60
+ ].includes(location.hostname)) {
61
+ let t5;
62
+ if ($[9] !== children) {
63
+ t5 = /* @__PURE__ */ jsx(LocalhostPreviewProvider, { children });
64
+ $[9] = children;
65
+ $[10] = t5;
66
+ } else t5 = $[10];
67
+ return t5;
336
68
  }
337
- if (!useProcessOtt(authClient)) return null;
338
- return /* @__PURE__ */ jsx(AuthContext.Provider, {
339
- value: {
340
- authClient,
341
- authenticationUrl,
342
- apiUrl,
343
- projectSlug,
344
- environmentName
345
- },
346
- children: /* @__PURE__ */ jsxs(CamoxAppProvider, {
347
- app: camoxApp,
348
- children: [__ENABLE_TANSTACK_DEVTOOLS__ && /* @__PURE__ */ jsx(ReactQueryDevtools, { initialIsOpen: false }), /* @__PURE__ */ jsx(AuthGate, {
349
- authenticated: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("link", {
350
- rel: "stylesheet",
351
- href: studioCssUrl
352
- }), /* @__PURE__ */ jsx(AuthenticatedCamoxProvider, { children })] }),
353
- unauthenticated: /* @__PURE__ */ jsx(UnauthenticatedCamoxProvider, { children })
354
- })]
355
- })
356
- });
357
- }
358
- function _temp() {
359
- return true;
69
+ let t5;
70
+ if ($[11] !== children) {
71
+ t5 = /* @__PURE__ */ jsx("div", {
72
+ className: "bg-background min-h-screen",
73
+ children
74
+ });
75
+ $[11] = children;
76
+ $[12] = t5;
77
+ } else t5 = $[12];
78
+ return t5;
360
79
  }
361
- function _temp2(action) {
362
- return action.id;
80
+ function CamoxProvider(props) {
81
+ const $ = c(6);
82
+ if ($[0] !== "29d68a11213af2b1fef531271ea0f2268b5c50fdad0696b9211d3ed97537e7c8") {
83
+ for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
84
+ $[0] = "29d68a11213af2b1fef531271ea0f2268b5c50fdad0696b9211d3ed97537e7c8";
85
+ }
86
+ let t0;
87
+ if ($[1] !== props.children) {
88
+ t0 = /* @__PURE__ */ jsx(AuthGate, {
89
+ authenticated: /* @__PURE__ */ jsx(AuthenticatedCamoxProvider, { children: props.children }),
90
+ loading: /* @__PURE__ */ jsx(UnauthenticatedExperience, { children: props.children }),
91
+ unauthenticated: /* @__PURE__ */ jsx(UnauthenticatedExperience, { children: props.children })
92
+ });
93
+ $[1] = props.children;
94
+ $[2] = t0;
95
+ } else t0 = $[2];
96
+ let t1;
97
+ if ($[3] !== props || $[4] !== t0) {
98
+ t1 = /* @__PURE__ */ jsx(CoreCamoxProvider, {
99
+ ...props,
100
+ children: t0
101
+ });
102
+ $[3] = props;
103
+ $[4] = t0;
104
+ $[5] = t1;
105
+ } else t1 = $[5];
106
+ return t1;
363
107
  }
364
108
 
365
109
  //#endregion
@@ -0,0 +1,37 @@
1
+ import { AuthContext, createCamoxAuthClient, useProcessOtt } from "../../lib/auth.js";
2
+ import { initApiClient } from "../../lib/api-client.js";
3
+ import { CamoxAppProvider } from "./components/CamoxAppContext.js";
4
+ import * as React from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+
7
+ //#region src/features/provider/CoreCamoxProvider.tsx
8
+ function isLocalhostPreview() {
9
+ if (typeof window === "undefined") return false;
10
+ const { hostname } = window.location;
11
+ return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
12
+ }
13
+ function CoreCamoxProvider({ apiUrl, authenticationUrl, camoxApp, children, environmentName, projectSlug }) {
14
+ const authClient = React.useMemo(() => createCamoxAuthClient(apiUrl), [apiUrl]);
15
+ const initializedApiUrl = React.useRef(null);
16
+ if (initializedApiUrl.current !== apiUrl) {
17
+ initApiClient(apiUrl, environmentName);
18
+ initializedApiUrl.current = apiUrl;
19
+ }
20
+ useProcessOtt(authClient);
21
+ return /* @__PURE__ */ jsx(AuthContext.Provider, {
22
+ value: {
23
+ authClient,
24
+ authenticationUrl,
25
+ apiUrl,
26
+ projectSlug,
27
+ environmentName
28
+ },
29
+ children: /* @__PURE__ */ jsx(CamoxAppProvider, {
30
+ app: camoxApp,
31
+ children
32
+ })
33
+ });
34
+ }
35
+
36
+ //#endregion
37
+ export { CoreCamoxProvider, isLocalhostPreview };