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.
- package/dist/core/components/lexical/InlineLexicalEditor.js +1 -1
- package/dist/core/components/lexical/SidebarLexicalEditor.js +7 -7
- package/dist/core/components/lexical/TextLinkPopover.js +4 -4
- package/dist/core/createApp.d.ts +2 -1
- package/dist/core/createBlock.d.ts +5 -1451
- package/dist/core/createBlock.js +450 -1603
- package/dist/core/defineDocument.d.ts +7 -0
- package/dist/core/defineDocument.js +7 -0
- package/dist/core/editing/BlockEditingRuntime.js +36 -0
- package/dist/core/editing/CompleteBlockEditingRuntime.js +76 -0
- package/dist/core/editing/createEditableBlock.d.ts +1455 -0
- package/dist/core/editing/createEditableBlock.js +1751 -0
- package/dist/core/lib/lexicalState.js +1 -1
- package/dist/features/agent-chat/components/AgentChatSidebar.js +4 -4
- package/dist/features/agent-chat/components/AgentChatThread.js +5 -5
- package/dist/features/content/components/AssetCard.js +1 -1
- package/dist/features/navigation/navigation.d.ts +39 -0
- package/dist/features/navigation/navigation.js +231 -0
- package/dist/features/page/PublishedPageContent.js +236 -0
- package/dist/features/page/PublishedPageExperience.js +23 -0
- package/dist/features/preview/CamoxPreview.d.ts +4 -0
- package/dist/features/preview/CamoxPreview.js +16 -16
- package/dist/features/preview/EditablePageContent.js +3 -0
- package/dist/features/preview/EditablePageExperience.js +24 -0
- package/dist/features/preview/components/AddBlockSidebar.js +7 -7
- package/dist/features/preview/components/AssetFieldEditor.js +1 -1
- package/dist/features/preview/components/AssetLightbox.js +46 -110
- package/dist/features/preview/components/BlockActionsPopover.js +6 -6
- package/dist/features/preview/components/CreatePageModal.js +7 -7
- package/dist/features/preview/components/DebouncedFieldEditor.js +2 -2
- package/dist/features/preview/components/DraftSwitchDialog.js +1 -1
- package/dist/features/preview/components/FieldToolbar.js +4 -4
- package/dist/features/preview/components/Frame.js +1 -1
- package/dist/features/preview/components/ItemFieldsEditor.js +3 -3
- package/dist/features/preview/components/LeftSidebar.js +1 -1
- package/dist/features/preview/components/LinkFieldEditor.js +3 -3
- package/dist/features/preview/components/Metadata.js +87 -0
- package/dist/features/preview/components/MultipleAssetFieldEditor.js +1 -1
- package/dist/features/preview/components/OverlayTracker.js +3 -3
- package/dist/features/preview/components/Overlays.js +3 -3
- package/dist/features/preview/components/PageEditorSidebar.js +5 -5
- package/dist/features/preview/components/PageInfoSidebar.js +158 -74
- package/dist/features/preview/components/PageLocationFieldset.js +1 -1
- package/dist/features/preview/components/PageNavigatorSidebar.js +10 -10
- package/dist/features/preview/components/PageNicknameField.js +2 -2
- package/dist/features/preview/components/PagePicker.js +4 -4
- package/dist/features/preview/components/PageTree.js +3 -3
- package/dist/features/preview/components/PeekedBlock.js +2 -2
- package/dist/features/preview/components/PreviewPanel.js +2 -2
- package/dist/features/preview/components/PreviewToolbar.js +2 -2
- package/dist/features/preview/components/PublishDialog.js +2 -2
- package/dist/features/preview/components/RepeatableItemsList.js +1 -1
- package/dist/features/preview/components/RightSidebar.js +1 -1
- package/dist/features/preview/components/useRepeatableItemActions.js +1 -1
- package/dist/features/preview/components/useUpdateBlockPosition.js +4 -4
- package/dist/features/provider/AuthenticatedCamoxProvider.js +63 -0
- package/dist/features/provider/CamoxProvider.d.ts +5 -12
- package/dist/features/provider/CamoxProvider.js +81 -337
- package/dist/features/provider/CoreCamoxProvider.js +37 -0
- package/dist/features/provider/LocalhostPreviewProvider.js +159 -0
- package/dist/features/provider/components/CommandPalette.js +1 -1
- package/dist/features/provider/useAdminShortcuts.js +1 -1
- package/dist/features/routes/pageRuntime.js +6 -0
- package/dist/features/runtime/hydrationData.js +9 -0
- package/dist/features/runtime/pageApp.js +188 -0
- package/dist/features/runtime/pageClient.d.ts +6 -0
- package/dist/features/runtime/pageClient.js +20 -0
- package/dist/features/runtime/pageNavigation.js +170 -0
- package/dist/features/runtime/pageServer.d.ts +9 -0
- package/dist/features/runtime/pageServer.js +18 -0
- package/dist/features/runtime/runtime.d.ts +25 -0
- package/dist/features/runtime/runtime.js +44 -0
- package/dist/features/runtime/studioApp.d.ts +15 -0
- package/dist/features/runtime/studioApp.js +185 -0
- package/dist/features/runtime/studioClient.d.ts +6 -0
- package/dist/features/runtime/studioClient.js +20 -0
- package/dist/features/runtime/studioNavigation.js +115 -0
- package/dist/features/runtime/studioServer.d.ts +9 -0
- package/dist/features/runtime/studioServer.js +18 -0
- package/dist/features/studio/CamoxStudio.js +4 -4
- package/dist/features/studio/components/EnvironmentMenu.js +2 -2
- package/dist/features/studio/components/Navbar.js +7 -7
- package/dist/features/studio/components/ProjectMenu.js +9 -9
- package/dist/features/studio/components/UserButton.js +3 -3
- package/dist/features/studio/useTheme.js +1 -22
- package/dist/features/vite/appGeneration.js +16 -5
- package/dist/features/vite/blockBoilerplate.js +1 -1
- package/dist/features/vite/definitionsSync.js +4 -4
- package/dist/features/vite/routeGeneration.js +9 -156
- package/dist/features/vite/runtimeDev.js +291 -0
- package/dist/features/vite/utils.js +3 -1
- package/dist/features/vite/vite.d.ts +22 -3
- package/dist/features/vite/vite.js +42 -19
- package/dist/lib/auth.js +42 -68
- package/dist/lib/normalized-data.js +6 -6
- package/dist/lib/telemetry.js +1 -24
- package/dist/lib/utils.js +1 -1
- package/dist/lib/view-queries.js +28 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/Matches.d.ts +114 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/RouterProvider.d.ts +25 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/config.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/defer.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/fileRoute.d.ts +20 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/global.d.ts +8 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/hash-scroll.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/index.d.ts +18 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/link.d.ts +161 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/load-matches.d.ts +6 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/location.d.ts +54 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/lru-cache.d.ts +8 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/manifest.d.ts +32 -0
- 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
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/not-found.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/redirect.d.ts +49 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/rewrite.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/root.d.ts +6 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/route.d.ts +343 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/routeInfo.d.ts +48 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/router.d.ts +695 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/scroll-restoration.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/searchMiddleware.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/searchParams.d.ts +5 -0
- 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
- 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
- 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
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/stores.d.ts +69 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/structuralSharing.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/typePrimitives.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useLoaderData.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useLoaderDeps.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useNavigate.d.ts +10 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useParams.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useRouteContext.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useSearch.d.ts +1 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/utils.d.ts +28 -0
- package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/validators.d.ts +49 -0
- package/package.json +39 -12
- package/skills/camox-block/SKILL.md +4 -4
- package/skills/camox-cli/SKILL.md +3 -3
- package/skills/camox-layout/SKILL.md +2 -2
- package/dist/features/routes/ogRoute.d.ts +0 -12
- package/dist/features/routes/ogRoute.js +0 -20
- package/dist/features/routes/pageRoute.d.ts +0 -48
- package/dist/features/routes/pageRoute.js +0 -254
- package/dist/lib/api-client.d.ts +0 -7
- package/dist/lib/queries.d.ts +0 -12
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { actionsStore } from "./actionsStore.js";
|
|
2
|
+
import { useSignInRedirect } from "../../lib/auth.js";
|
|
3
|
+
import { useApplyTheme } from "../studio/useTheme.js";
|
|
4
|
+
import { PreviewPanel } from "../preview/components/PreviewPanel.js";
|
|
5
|
+
import { useAdminShortcuts } from "./useAdminShortcuts.js";
|
|
6
|
+
import { c } from "react/compiler-runtime";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
|
|
10
|
+
import { Toaster } from "@camox/ui/toaster";
|
|
11
|
+
import studioCssUrl from "virtual:camox-studio-css";
|
|
12
|
+
|
|
13
|
+
//#region src/features/provider/LocalhostPreviewProvider.tsx
|
|
14
|
+
function LocalhostPreviewProvider(t0) {
|
|
15
|
+
const $ = c(21);
|
|
16
|
+
if ($[0] !== "bd39c46de8381d98c4a04fb8c92df87704f578a9561f6fbfafaa182175dd58dd") {
|
|
17
|
+
for (let $i = 0; $i < 21; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
18
|
+
$[0] = "bd39c46de8381d98c4a04fb8c92df87704f578a9561f6fbfafaa182175dd58dd";
|
|
19
|
+
}
|
|
20
|
+
const { children } = t0;
|
|
21
|
+
const signInRedirect = useSignInRedirect();
|
|
22
|
+
const { resolvedTheme } = useApplyTheme();
|
|
23
|
+
const [isSignInDialogOpen, setIsSignInDialogOpen] = React.useState(false);
|
|
24
|
+
useAdminShortcuts();
|
|
25
|
+
let t1;
|
|
26
|
+
let t2;
|
|
27
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
28
|
+
t1 = () => {
|
|
29
|
+
const actions = [{
|
|
30
|
+
id: "sign-in-to-edit",
|
|
31
|
+
label: "Sign in to edit",
|
|
32
|
+
aliases: ["Enter edit mode", "Edit mode"],
|
|
33
|
+
groupLabel: "Preview",
|
|
34
|
+
checkIfAvailable: _temp,
|
|
35
|
+
execute: () => setIsSignInDialogOpen(true),
|
|
36
|
+
shortcut: {
|
|
37
|
+
key: "Enter",
|
|
38
|
+
withMeta: true
|
|
39
|
+
}
|
|
40
|
+
}];
|
|
41
|
+
actionsStore.send({
|
|
42
|
+
type: "registerManyActions",
|
|
43
|
+
actions
|
|
44
|
+
});
|
|
45
|
+
return () => {
|
|
46
|
+
actionsStore.send({
|
|
47
|
+
type: "unregisterManyActions",
|
|
48
|
+
ids: actions.map(_temp2)
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
t2 = [];
|
|
53
|
+
$[1] = t1;
|
|
54
|
+
$[2] = t2;
|
|
55
|
+
} else {
|
|
56
|
+
t1 = $[1];
|
|
57
|
+
t2 = $[2];
|
|
58
|
+
}
|
|
59
|
+
React.useEffect(t1, t2);
|
|
60
|
+
let t3;
|
|
61
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
62
|
+
t3 = /* @__PURE__ */ jsx("link", {
|
|
63
|
+
rel: "stylesheet",
|
|
64
|
+
href: studioCssUrl
|
|
65
|
+
});
|
|
66
|
+
$[3] = t3;
|
|
67
|
+
} else t3 = $[3];
|
|
68
|
+
let t4;
|
|
69
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
70
|
+
t4 = { bottom: "1rem" };
|
|
71
|
+
$[4] = t4;
|
|
72
|
+
} else t4 = $[4];
|
|
73
|
+
let t5;
|
|
74
|
+
if ($[5] !== resolvedTheme) {
|
|
75
|
+
t5 = /* @__PURE__ */ jsx(Toaster, {
|
|
76
|
+
theme: resolvedTheme,
|
|
77
|
+
position: "bottom-right",
|
|
78
|
+
offset: t4
|
|
79
|
+
});
|
|
80
|
+
$[5] = resolvedTheme;
|
|
81
|
+
$[6] = t5;
|
|
82
|
+
} else t5 = $[6];
|
|
83
|
+
let t6;
|
|
84
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
85
|
+
t6 = { onEditModeChange: (checked) => {
|
|
86
|
+
if (checked) setIsSignInDialogOpen(true);
|
|
87
|
+
} };
|
|
88
|
+
$[7] = t6;
|
|
89
|
+
} else t6 = $[7];
|
|
90
|
+
let t7;
|
|
91
|
+
if ($[8] !== children) {
|
|
92
|
+
t7 = /* @__PURE__ */ jsx("div", {
|
|
93
|
+
className: "bg-background flex h-screen flex-col overflow-hidden",
|
|
94
|
+
children: /* @__PURE__ */ jsx(PreviewPanel, {
|
|
95
|
+
toolbarProps: t6,
|
|
96
|
+
children
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
$[8] = children;
|
|
100
|
+
$[9] = t7;
|
|
101
|
+
} else t7 = $[9];
|
|
102
|
+
let t8;
|
|
103
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
104
|
+
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." })] });
|
|
105
|
+
$[10] = t8;
|
|
106
|
+
} else t8 = $[10];
|
|
107
|
+
let t9;
|
|
108
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
109
|
+
t9 = /* @__PURE__ */ jsx(AlertDialogCancel, {
|
|
110
|
+
variant: "outline",
|
|
111
|
+
size: "default",
|
|
112
|
+
children: "Cancel"
|
|
113
|
+
});
|
|
114
|
+
$[11] = t9;
|
|
115
|
+
} else t9 = $[11];
|
|
116
|
+
let t10;
|
|
117
|
+
if ($[12] !== signInRedirect) {
|
|
118
|
+
t10 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t8, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t9, /* @__PURE__ */ jsx(AlertDialogAction, {
|
|
119
|
+
onClick: signInRedirect,
|
|
120
|
+
children: "Sign in"
|
|
121
|
+
})] })] });
|
|
122
|
+
$[12] = signInRedirect;
|
|
123
|
+
$[13] = t10;
|
|
124
|
+
} else t10 = $[13];
|
|
125
|
+
let t11;
|
|
126
|
+
if ($[14] !== isSignInDialogOpen || $[15] !== t10) {
|
|
127
|
+
t11 = /* @__PURE__ */ jsx(AlertDialog, {
|
|
128
|
+
open: isSignInDialogOpen,
|
|
129
|
+
onOpenChange: setIsSignInDialogOpen,
|
|
130
|
+
children: t10
|
|
131
|
+
});
|
|
132
|
+
$[14] = isSignInDialogOpen;
|
|
133
|
+
$[15] = t10;
|
|
134
|
+
$[16] = t11;
|
|
135
|
+
} else t11 = $[16];
|
|
136
|
+
let t12;
|
|
137
|
+
if ($[17] !== t11 || $[18] !== t5 || $[19] !== t7) {
|
|
138
|
+
t12 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
139
|
+
t3,
|
|
140
|
+
t5,
|
|
141
|
+
t7,
|
|
142
|
+
t11
|
|
143
|
+
] });
|
|
144
|
+
$[17] = t11;
|
|
145
|
+
$[18] = t5;
|
|
146
|
+
$[19] = t7;
|
|
147
|
+
$[20] = t12;
|
|
148
|
+
} else t12 = $[20];
|
|
149
|
+
return t12;
|
|
150
|
+
}
|
|
151
|
+
function _temp2(action) {
|
|
152
|
+
return action.id;
|
|
153
|
+
}
|
|
154
|
+
function _temp() {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
//#endregion
|
|
159
|
+
export { LocalhostPreviewProvider };
|
|
@@ -2,9 +2,9 @@ import { actionsStore } from "../actionsStore.js";
|
|
|
2
2
|
import { formatShortcut } from "../../../lib/utils.js";
|
|
3
3
|
import { studioStore } from "../../studio/studioStore.js";
|
|
4
4
|
import { c } from "react/compiler-runtime";
|
|
5
|
-
import { useSelector } from "@xstate/store-react";
|
|
6
5
|
import * as React from "react";
|
|
7
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { useSelector } from "@xstate/store-react";
|
|
8
8
|
import { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandShortcut } from "@camox/ui/command";
|
|
9
9
|
|
|
10
10
|
//#region src/features/provider/components/CommandPalette.tsx
|
|
@@ -1,8 +1,8 @@
|
|
|
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 { useSelector } from "@xstate/store-react";
|
|
5
4
|
import * as React from "react";
|
|
5
|
+
import { useSelector } from "@xstate/store-react";
|
|
6
6
|
|
|
7
7
|
//#region src/features/provider/useAdminShortcuts.tsx
|
|
8
8
|
/**
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/features/runtime/hydrationData.ts
|
|
2
|
+
function readHydrationData() {
|
|
3
|
+
const script = document.getElementById("__CAMOX_DATA__");
|
|
4
|
+
if (!script?.textContent) throw new Error("Camox runtime hydration data was not found.");
|
|
5
|
+
return JSON.parse(script.textContent);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { readHydrationData };
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { useAuthState } from "../../lib/auth.js";
|
|
2
|
+
import { CoreCamoxProvider, isLocalhostPreview } from "../provider/CoreCamoxProvider.js";
|
|
3
|
+
import { PublishedPageExperience } from "../page/PublishedPageExperience.js";
|
|
4
|
+
import { PageNavigationProvider } from "./pageNavigation.js";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
6
|
+
import { HydrationBoundary, QueryClientProvider } from "@tanstack/react-query";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
//#region src/features/runtime/pageApp.tsx
|
|
11
|
+
function PageApp(t0) {
|
|
12
|
+
const $ = c(22);
|
|
13
|
+
if ($[0] !== "41b609b6b6e9223ab6f76c85adfea25789d9d089bc02ca12ea1dd789dd8294d1") {
|
|
14
|
+
for (let $i = 0; $i < 22; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
15
|
+
$[0] = "41b609b6b6e9223ab6f76c85adfea25789d9d089bc02ca12ea1dd789dd8294d1";
|
|
16
|
+
}
|
|
17
|
+
const { camoxApp, input, queryClient } = t0;
|
|
18
|
+
const t1 = input.dehydratedState;
|
|
19
|
+
let t2;
|
|
20
|
+
if ($[1] !== camoxApp || $[2] !== input || $[3] !== queryClient) {
|
|
21
|
+
t2 = /* @__PURE__ */ jsx(PageExperience, {
|
|
22
|
+
camoxApp,
|
|
23
|
+
input,
|
|
24
|
+
queryClient
|
|
25
|
+
});
|
|
26
|
+
$[1] = camoxApp;
|
|
27
|
+
$[2] = input;
|
|
28
|
+
$[3] = queryClient;
|
|
29
|
+
$[4] = t2;
|
|
30
|
+
} else t2 = $[4];
|
|
31
|
+
let t3;
|
|
32
|
+
if ($[5] !== camoxApp || $[6] !== input.apiUrl || $[7] !== input.authenticationUrl || $[8] !== input.environmentName || $[9] !== input.projectSlug || $[10] !== t2) {
|
|
33
|
+
t3 = /* @__PURE__ */ jsx(CoreCamoxProvider, {
|
|
34
|
+
camoxApp,
|
|
35
|
+
authenticationUrl: input.authenticationUrl,
|
|
36
|
+
apiUrl: input.apiUrl,
|
|
37
|
+
projectSlug: input.projectSlug,
|
|
38
|
+
environmentName: input.environmentName,
|
|
39
|
+
children: t2
|
|
40
|
+
});
|
|
41
|
+
$[5] = camoxApp;
|
|
42
|
+
$[6] = input.apiUrl;
|
|
43
|
+
$[7] = input.authenticationUrl;
|
|
44
|
+
$[8] = input.environmentName;
|
|
45
|
+
$[9] = input.projectSlug;
|
|
46
|
+
$[10] = t2;
|
|
47
|
+
$[11] = t3;
|
|
48
|
+
} else t3 = $[11];
|
|
49
|
+
let t4;
|
|
50
|
+
if ($[12] !== input || $[13] !== queryClient || $[14] !== t3) {
|
|
51
|
+
t4 = /* @__PURE__ */ jsx(PageNavigationProvider, {
|
|
52
|
+
initialInput: input,
|
|
53
|
+
queryClient,
|
|
54
|
+
children: t3
|
|
55
|
+
});
|
|
56
|
+
$[12] = input;
|
|
57
|
+
$[13] = queryClient;
|
|
58
|
+
$[14] = t3;
|
|
59
|
+
$[15] = t4;
|
|
60
|
+
} else t4 = $[15];
|
|
61
|
+
let t5;
|
|
62
|
+
if ($[16] !== t1 || $[17] !== t4) {
|
|
63
|
+
t5 = /* @__PURE__ */ jsx(HydrationBoundary, {
|
|
64
|
+
state: t1,
|
|
65
|
+
children: t4
|
|
66
|
+
});
|
|
67
|
+
$[16] = t1;
|
|
68
|
+
$[17] = t4;
|
|
69
|
+
$[18] = t5;
|
|
70
|
+
} else t5 = $[18];
|
|
71
|
+
let t6;
|
|
72
|
+
if ($[19] !== queryClient || $[20] !== t5) {
|
|
73
|
+
t6 = /* @__PURE__ */ jsx(QueryClientProvider, {
|
|
74
|
+
client: queryClient,
|
|
75
|
+
children: t5
|
|
76
|
+
});
|
|
77
|
+
$[19] = queryClient;
|
|
78
|
+
$[20] = t5;
|
|
79
|
+
$[21] = t6;
|
|
80
|
+
} else t6 = $[21];
|
|
81
|
+
return t6;
|
|
82
|
+
}
|
|
83
|
+
const LazyEditablePageExperience = React.lazy(() => import("../preview/EditablePageExperience.js").then((module) => ({ default: module.EditablePageExperience })));
|
|
84
|
+
const LazyLocalhostPreviewProvider = React.lazy(() => import("../provider/LocalhostPreviewProvider.js").then((module) => ({ default: module.LocalhostPreviewProvider })));
|
|
85
|
+
var EditingActivationBoundary = class extends React.Component {
|
|
86
|
+
state = { failed: false };
|
|
87
|
+
static getDerivedStateFromError() {
|
|
88
|
+
return { failed: true };
|
|
89
|
+
}
|
|
90
|
+
componentDidCatch(error) {
|
|
91
|
+
console.error("Camox editing runtime failed to load; keeping the published page visible.", error);
|
|
92
|
+
}
|
|
93
|
+
render() {
|
|
94
|
+
if (this.state.failed) return this.props.fallback;
|
|
95
|
+
return this.props.children;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
function PageExperience(t0) {
|
|
99
|
+
const $ = c(21);
|
|
100
|
+
if ($[0] !== "41b609b6b6e9223ab6f76c85adfea25789d9d089bc02ca12ea1dd789dd8294d1") {
|
|
101
|
+
for (let $i = 0; $i < 21; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
102
|
+
$[0] = "41b609b6b6e9223ab6f76c85adfea25789d9d089bc02ca12ea1dd789dd8294d1";
|
|
103
|
+
}
|
|
104
|
+
const { camoxApp, input, queryClient } = t0;
|
|
105
|
+
const { isAuthenticated } = useAuthState();
|
|
106
|
+
const [hasOtt] = React.useState(_temp);
|
|
107
|
+
const local = isLocalhostPreview();
|
|
108
|
+
const shouldActivateEditing = isAuthenticated || input.source === "draft" || hasOtt;
|
|
109
|
+
let t1;
|
|
110
|
+
if ($[1] !== input.source) {
|
|
111
|
+
t1 = /* @__PURE__ */ jsx(PublishedPageExperience, { source: input.source });
|
|
112
|
+
$[1] = input.source;
|
|
113
|
+
$[2] = t1;
|
|
114
|
+
} else t1 = $[2];
|
|
115
|
+
const published = t1;
|
|
116
|
+
if (shouldActivateEditing) {
|
|
117
|
+
let t2;
|
|
118
|
+
if ($[3] !== camoxApp || $[4] !== input || $[5] !== queryClient) {
|
|
119
|
+
t2 = /* @__PURE__ */ jsx(LazyEditablePageExperience, {
|
|
120
|
+
camoxApp,
|
|
121
|
+
input,
|
|
122
|
+
queryClient
|
|
123
|
+
});
|
|
124
|
+
$[3] = camoxApp;
|
|
125
|
+
$[4] = input;
|
|
126
|
+
$[5] = queryClient;
|
|
127
|
+
$[6] = t2;
|
|
128
|
+
} else t2 = $[6];
|
|
129
|
+
let t3;
|
|
130
|
+
if ($[7] !== published || $[8] !== t2) {
|
|
131
|
+
t3 = /* @__PURE__ */ jsx(React.Suspense, {
|
|
132
|
+
fallback: published,
|
|
133
|
+
children: t2
|
|
134
|
+
});
|
|
135
|
+
$[7] = published;
|
|
136
|
+
$[8] = t2;
|
|
137
|
+
$[9] = t3;
|
|
138
|
+
} else t3 = $[9];
|
|
139
|
+
let t4;
|
|
140
|
+
if ($[10] !== published || $[11] !== t3) {
|
|
141
|
+
t4 = /* @__PURE__ */ jsx(EditingActivationBoundary, {
|
|
142
|
+
fallback: published,
|
|
143
|
+
children: t3
|
|
144
|
+
});
|
|
145
|
+
$[10] = published;
|
|
146
|
+
$[11] = t3;
|
|
147
|
+
$[12] = t4;
|
|
148
|
+
} else t4 = $[12];
|
|
149
|
+
return t4;
|
|
150
|
+
}
|
|
151
|
+
if (local) {
|
|
152
|
+
let t2;
|
|
153
|
+
if ($[13] !== published) {
|
|
154
|
+
t2 = /* @__PURE__ */ jsx(LazyLocalhostPreviewProvider, { children: published });
|
|
155
|
+
$[13] = published;
|
|
156
|
+
$[14] = t2;
|
|
157
|
+
} else t2 = $[14];
|
|
158
|
+
let t3;
|
|
159
|
+
if ($[15] !== published || $[16] !== t2) {
|
|
160
|
+
t3 = /* @__PURE__ */ jsx(React.Suspense, {
|
|
161
|
+
fallback: published,
|
|
162
|
+
children: t2
|
|
163
|
+
});
|
|
164
|
+
$[15] = published;
|
|
165
|
+
$[16] = t2;
|
|
166
|
+
$[17] = t3;
|
|
167
|
+
} else t3 = $[17];
|
|
168
|
+
let t4;
|
|
169
|
+
if ($[18] !== published || $[19] !== t3) {
|
|
170
|
+
t4 = /* @__PURE__ */ jsx(EditingActivationBoundary, {
|
|
171
|
+
fallback: published,
|
|
172
|
+
children: t3
|
|
173
|
+
});
|
|
174
|
+
$[18] = published;
|
|
175
|
+
$[19] = t3;
|
|
176
|
+
$[20] = t4;
|
|
177
|
+
} else t4 = $[20];
|
|
178
|
+
return t4;
|
|
179
|
+
}
|
|
180
|
+
return published;
|
|
181
|
+
}
|
|
182
|
+
function _temp() {
|
|
183
|
+
if (typeof window === "undefined") return false;
|
|
184
|
+
return new URL(window.location.href).searchParams.has("ott");
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
//#endregion
|
|
188
|
+
export { PageApp };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PageApp } from "./pageApp.js";
|
|
2
|
+
import { readHydrationData } from "./hydrationData.js";
|
|
3
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { hydrateRoot } from "react-dom/client";
|
|
6
|
+
|
|
7
|
+
//#region src/features/runtime/pageClient.tsx
|
|
8
|
+
function hydratePageWithApp(camoxApp) {
|
|
9
|
+
const root = document.getElementById("root");
|
|
10
|
+
if (!root) throw new Error("Camox runtime root element was not found.");
|
|
11
|
+
const queryClient = new QueryClient();
|
|
12
|
+
hydrateRoot(root, /* @__PURE__ */ jsx(PageApp, {
|
|
13
|
+
camoxApp,
|
|
14
|
+
input: readHydrationData(),
|
|
15
|
+
queryClient
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { hydratePageWithApp };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { NavigationProvider } from "../navigation/navigation.js";
|
|
2
|
+
import { createPageHeadInput } from "./runtime.js";
|
|
3
|
+
import { hydrate } from "@tanstack/react-query";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { createHead, renderDOMHead } from "@unhead/react/client";
|
|
7
|
+
|
|
8
|
+
//#region src/features/runtime/pageNavigation.tsx
|
|
9
|
+
function normalizeRuntimeBasePath(basePath) {
|
|
10
|
+
if (!basePath || basePath === "/") return "";
|
|
11
|
+
return basePath.startsWith("/") ? basePath.replace(/\/+$/, "") : `/${basePath.replace(/\/+$/, "")}`;
|
|
12
|
+
}
|
|
13
|
+
function normalizePagePath(pathname, runtimeBasePath) {
|
|
14
|
+
const basePath = normalizeRuntimeBasePath(runtimeBasePath);
|
|
15
|
+
if (!basePath) return pathname || "/";
|
|
16
|
+
if (pathname === basePath) return "/";
|
|
17
|
+
if (pathname.startsWith(`${basePath}/`)) return pathname.slice(basePath.length) || "/";
|
|
18
|
+
return pathname || "/";
|
|
19
|
+
}
|
|
20
|
+
function toRuntimePathname(pagePathname, runtimeBasePath) {
|
|
21
|
+
const basePath = normalizeRuntimeBasePath(runtimeBasePath);
|
|
22
|
+
const normalizedPathname = pagePathname.startsWith("/") ? pagePathname : `/${pagePathname}`;
|
|
23
|
+
if (!basePath) return normalizedPathname;
|
|
24
|
+
if (normalizedPathname === "/") return `${basePath}/`;
|
|
25
|
+
if (normalizedPathname.startsWith(`${basePath}/`)) return normalizedPathname;
|
|
26
|
+
return `${basePath}${normalizedPathname}`;
|
|
27
|
+
}
|
|
28
|
+
function getRuntimeLocation(runtimeBasePath) {
|
|
29
|
+
return {
|
|
30
|
+
hash: window.location.hash,
|
|
31
|
+
href: window.location.href,
|
|
32
|
+
pathname: normalizePagePath(window.location.pathname, runtimeBasePath),
|
|
33
|
+
search: window.location.search
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function isReservedPagePath(pathname) {
|
|
37
|
+
return pathname.startsWith("/_camox/") || pathname === "/_camox" || pathname === "/camox" || pathname.startsWith("/camox/") || pathname === "/og" || pathname === "/sitemap.xml";
|
|
38
|
+
}
|
|
39
|
+
function getClientNavigationTarget(to, runtimeBasePath) {
|
|
40
|
+
const url = new URL(to, window.location.href);
|
|
41
|
+
if (url.origin !== window.location.origin) return null;
|
|
42
|
+
const pagePathname = normalizePagePath(url.pathname, runtimeBasePath);
|
|
43
|
+
if (isReservedPagePath(pagePathname)) return null;
|
|
44
|
+
url.pathname = toRuntimePathname(pagePathname, runtimeBasePath);
|
|
45
|
+
return url;
|
|
46
|
+
}
|
|
47
|
+
async function fetchPageData(pagePathname, runtimeBasePath) {
|
|
48
|
+
const dataUrl = new URL(toRuntimePathname("/_camox/data", runtimeBasePath), window.location.origin);
|
|
49
|
+
dataUrl.searchParams.set("path", pagePathname);
|
|
50
|
+
const response = await fetch(dataUrl, {
|
|
51
|
+
headers: { Accept: "application/json" },
|
|
52
|
+
credentials: "same-origin"
|
|
53
|
+
});
|
|
54
|
+
if (!response.ok) throw new Error(`Page data request failed: ${response.status}`);
|
|
55
|
+
return await response.json();
|
|
56
|
+
}
|
|
57
|
+
function isPageHead(head) {
|
|
58
|
+
return !!head && typeof head === "object";
|
|
59
|
+
}
|
|
60
|
+
function updateHead(head, manager) {
|
|
61
|
+
if (!isPageHead(head)) return;
|
|
62
|
+
if (!manager.removedServerPageHead) {
|
|
63
|
+
document.querySelectorAll("[data-camox-page-head]").forEach((element) => element.remove());
|
|
64
|
+
manager.removedServerPageHead = true;
|
|
65
|
+
}
|
|
66
|
+
manager.entry?.dispose();
|
|
67
|
+
manager.entry = manager.head.push(createPageHeadInput(head));
|
|
68
|
+
renderDOMHead(manager.head);
|
|
69
|
+
}
|
|
70
|
+
function hasSameLayoutIdentity(current, next) {
|
|
71
|
+
return !!current && !!next && current.id === next.id && current.layoutId === next.layoutId && current.version === next.version;
|
|
72
|
+
}
|
|
73
|
+
function isLayoutBlockQuery(query, layoutBlockIds) {
|
|
74
|
+
if (!query || typeof query !== "object") return false;
|
|
75
|
+
const queryKey = query.queryKey;
|
|
76
|
+
return Array.isArray(queryKey) && queryKey[0] === "camox" && queryKey[1] === "blocks" && queryKey[2] === "get" && typeof queryKey[3] === "number" && layoutBlockIds.has(queryKey[3]);
|
|
77
|
+
}
|
|
78
|
+
function preserveStableLayoutBlockCaches(dehydratedState, currentLayout, nextLayout) {
|
|
79
|
+
if (!hasSameLayoutIdentity(currentLayout, nextLayout)) return dehydratedState;
|
|
80
|
+
if (!dehydratedState || typeof dehydratedState !== "object") return dehydratedState;
|
|
81
|
+
if (!Array.isArray(dehydratedState.queries)) return dehydratedState;
|
|
82
|
+
const layoutBlockIds = new Set(currentLayout?.blockIds ?? []);
|
|
83
|
+
return {
|
|
84
|
+
...dehydratedState,
|
|
85
|
+
queries: dehydratedState.queries.filter((query) => !isLayoutBlockQuery(query, layoutBlockIds))
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function PageNavigationProvider({ children, initialInput, queryClient }) {
|
|
89
|
+
const headManagerRef = React.useRef(null);
|
|
90
|
+
if (!headManagerRef.current) headManagerRef.current = {
|
|
91
|
+
head: createHead(),
|
|
92
|
+
removedServerPageHead: false
|
|
93
|
+
};
|
|
94
|
+
const headManager = headManagerRef.current;
|
|
95
|
+
const currentLayoutIdentityRef = React.useRef(initialInput.layoutIdentity);
|
|
96
|
+
const navigate = React.useCallback(async ({ replace, to }) => {
|
|
97
|
+
const target = getClientNavigationTarget(to, initialInput.runtimeBasePath);
|
|
98
|
+
if (!target) {
|
|
99
|
+
window.location.assign(to);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const pagePathname = normalizePagePath(target.pathname, initialInput.runtimeBasePath);
|
|
103
|
+
try {
|
|
104
|
+
const data = await fetchPageData(pagePathname, initialInput.runtimeBasePath);
|
|
105
|
+
if (data.dehydratedState) hydrate(queryClient, preserveStableLayoutBlockCaches(data.dehydratedState, currentLayoutIdentityRef.current, data.layoutIdentity));
|
|
106
|
+
currentLayoutIdentityRef.current = data.layoutIdentity ?? null;
|
|
107
|
+
updateHead(data.head, headManager);
|
|
108
|
+
} catch {
|
|
109
|
+
window.location.assign(target.href);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (replace) window.history.replaceState(null, "", target.href);
|
|
113
|
+
else {
|
|
114
|
+
window.history.pushState(null, "", target.href);
|
|
115
|
+
window.scrollTo({ top: 0 });
|
|
116
|
+
}
|
|
117
|
+
window.dispatchEvent(new Event("camox:navigation"));
|
|
118
|
+
}, [
|
|
119
|
+
headManager,
|
|
120
|
+
initialInput.runtimeBasePath,
|
|
121
|
+
queryClient
|
|
122
|
+
]);
|
|
123
|
+
React.useEffect(() => {
|
|
124
|
+
const onClick = (event) => {
|
|
125
|
+
if (event.defaultPrevented) return;
|
|
126
|
+
if (event.button !== 0) return;
|
|
127
|
+
if (event.metaKey || event.altKey || event.ctrlKey || event.shiftKey) return;
|
|
128
|
+
const anchor = event.target?.closest("a");
|
|
129
|
+
if (!anchor) return;
|
|
130
|
+
if (anchor.hasAttribute("download")) return;
|
|
131
|
+
if (anchor.target && anchor.target !== "_self") return;
|
|
132
|
+
const target_0 = getClientNavigationTarget(anchor.href, initialInput.runtimeBasePath);
|
|
133
|
+
if (!target_0) return;
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
navigate({ to: target_0.href });
|
|
136
|
+
};
|
|
137
|
+
document.addEventListener("click", onClick);
|
|
138
|
+
return () => document.removeEventListener("click", onClick);
|
|
139
|
+
}, [navigate]);
|
|
140
|
+
React.useEffect(() => {
|
|
141
|
+
const onPopState = () => {
|
|
142
|
+
fetchPageData(normalizePagePath(window.location.pathname, initialInput.runtimeBasePath), initialInput.runtimeBasePath).then((data_0) => {
|
|
143
|
+
if (data_0.dehydratedState) hydrate(queryClient, preserveStableLayoutBlockCaches(data_0.dehydratedState, currentLayoutIdentityRef.current, data_0.layoutIdentity));
|
|
144
|
+
currentLayoutIdentityRef.current = data_0.layoutIdentity ?? null;
|
|
145
|
+
updateHead(data_0.head, headManager);
|
|
146
|
+
window.dispatchEvent(new Event("camox:navigation"));
|
|
147
|
+
}).catch(() => window.location.reload());
|
|
148
|
+
};
|
|
149
|
+
window.addEventListener("popstate", onPopState);
|
|
150
|
+
return () => window.removeEventListener("popstate", onPopState);
|
|
151
|
+
}, [
|
|
152
|
+
headManager,
|
|
153
|
+
initialInput.runtimeBasePath,
|
|
154
|
+
queryClient
|
|
155
|
+
]);
|
|
156
|
+
return /* @__PURE__ */ jsx(NavigationProvider, {
|
|
157
|
+
getLocation: React.useCallback(() => getRuntimeLocation(initialInput.runtimeBasePath), [initialInput.runtimeBasePath]),
|
|
158
|
+
initialLocation: {
|
|
159
|
+
hash: new URL(initialInput.href).hash,
|
|
160
|
+
href: initialInput.href,
|
|
161
|
+
pathname: initialInput.pathname,
|
|
162
|
+
search: new URL(initialInput.href).search
|
|
163
|
+
},
|
|
164
|
+
navigate,
|
|
165
|
+
children
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
export { PageNavigationProvider };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CamoxApp } from "../../core/createApp.js";
|
|
2
|
+
import { PageRenderInput } from "./runtime.js";
|
|
3
|
+
|
|
4
|
+
//#region src/features/runtime/pageServer.d.ts
|
|
5
|
+
declare function renderPageWithApp(input: PageRenderInput & {
|
|
6
|
+
camoxApp: CamoxApp;
|
|
7
|
+
}): Promise<string>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { renderPageWithApp };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PageApp } from "./pageApp.js";
|
|
2
|
+
import { QueryClient, hydrate } from "@tanstack/react-query";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { renderToString } from "react-dom/server";
|
|
5
|
+
|
|
6
|
+
//#region src/features/runtime/pageServer.tsx
|
|
7
|
+
async function renderPageWithApp(input) {
|
|
8
|
+
const queryClient = new QueryClient();
|
|
9
|
+
hydrate(queryClient, input.dehydratedState);
|
|
10
|
+
return renderToString(/* @__PURE__ */ jsx(PageApp, {
|
|
11
|
+
camoxApp: input.camoxApp,
|
|
12
|
+
input,
|
|
13
|
+
queryClient
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { renderPageWithApp };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { UseHeadInput } from "unhead/types";
|
|
2
|
+
|
|
3
|
+
//#region src/features/runtime/runtime.d.ts
|
|
4
|
+
interface LayoutIdentity {
|
|
5
|
+
blockIds: number[];
|
|
6
|
+
id: number;
|
|
7
|
+
layoutId: string;
|
|
8
|
+
version: string;
|
|
9
|
+
}
|
|
10
|
+
interface PageRenderInput {
|
|
11
|
+
apiUrl: string;
|
|
12
|
+
authenticationUrl: string;
|
|
13
|
+
dehydratedState: unknown;
|
|
14
|
+
environmentName?: string;
|
|
15
|
+
head: unknown;
|
|
16
|
+
href: string;
|
|
17
|
+
layoutIdentity: LayoutIdentity | null;
|
|
18
|
+
loaderData: unknown;
|
|
19
|
+
pathname: string;
|
|
20
|
+
projectSlug: string;
|
|
21
|
+
runtimeBasePath: string;
|
|
22
|
+
source: "live" | "draft";
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { PageRenderInput };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import "../routes/pageRuntime.js";
|
|
2
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
3
|
+
import "@unhead/react/server";
|
|
4
|
+
|
|
5
|
+
//#region src/features/runtime/runtime.ts
|
|
6
|
+
function createPageHeadInput(head) {
|
|
7
|
+
const meta = head.meta ?? [];
|
|
8
|
+
const links = head.links ?? [];
|
|
9
|
+
const title = meta.find((entry) => entry.title)?.title;
|
|
10
|
+
const pageMeta = [];
|
|
11
|
+
for (const entry of meta) {
|
|
12
|
+
if (entry.title) continue;
|
|
13
|
+
if (entry.name && entry.content) {
|
|
14
|
+
pageMeta.push({
|
|
15
|
+
name: entry.name,
|
|
16
|
+
content: entry.content,
|
|
17
|
+
"data-camox-page-head": "true"
|
|
18
|
+
});
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (entry.property && entry.content) pageMeta.push({
|
|
22
|
+
property: entry.property,
|
|
23
|
+
content: entry.content,
|
|
24
|
+
"data-camox-page-head": "true"
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const pageLinks = [];
|
|
28
|
+
for (const entry of links) {
|
|
29
|
+
if (entry.rel !== "icon" || !entry.href) continue;
|
|
30
|
+
pageLinks.push({
|
|
31
|
+
rel: "icon",
|
|
32
|
+
href: entry.href,
|
|
33
|
+
"data-camox-page-head": "true"
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
...title && { title },
|
|
38
|
+
meta: pageMeta,
|
|
39
|
+
link: pageLinks
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { createPageHeadInput };
|