camox 0.42.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/core/components/lexical/{GradientNode.js → HighlightNode.js} +34 -34
  2. package/dist/core/components/lexical/InlineLexicalEditor.js +14 -14
  3. package/dist/core/components/lexical/InlineStylesPlugin.js +6 -6
  4. package/dist/core/components/lexical/SelectionBroadcaster.js +5 -5
  5. package/dist/core/components/lexical/SidebarLexicalEditor.js +20 -20
  6. package/dist/core/components/lexical/TextLinkPopover.js +191 -208
  7. package/dist/core/components/lexical/editorConfig.js +2 -2
  8. package/dist/core/createApp.d.ts +3 -2
  9. package/dist/core/createApp.js +2 -1
  10. package/dist/core/createLayout.d.ts +16 -3
  11. package/dist/core/createLayout.js +15 -15
  12. package/dist/core/derivedRoutes.js +1 -1
  13. package/dist/core/dom.d.ts +17 -0
  14. package/dist/core/dom.js +22 -0
  15. package/dist/core/lib/lexicalReact.js +4 -4
  16. package/dist/core/lib/lexicalState.js +3 -3
  17. package/dist/core/lib/modifierFormats.js +1 -1
  18. package/dist/core/lib/textLinks.js +5 -2
  19. package/dist/core/lib/textStyles.d.ts +2 -2
  20. package/dist/core/lib/textStyles.js +6 -11
  21. package/dist/core/pageDestinations.js +37 -0
  22. package/dist/features/og/imageResponse.node.js +11 -9
  23. package/dist/features/preview/CamoxPreview.js +42 -65
  24. package/dist/features/preview/components/AddBlockSidebar.js +1 -1
  25. package/dist/features/preview/components/BlockActionsPopover.js +1 -1
  26. package/dist/features/preview/components/CreatePageModal.js +4 -4
  27. package/dist/features/preview/components/DerivedLayoutSidebar.js +45 -26
  28. package/dist/features/preview/components/DerivedPageInfoSidebar.js +38 -26
  29. package/dist/features/preview/components/FieldToolbar.js +7 -7
  30. package/dist/features/preview/components/LinkFieldEditor.js +212 -209
  31. package/dist/features/preview/components/PageEditorSidebar.js +1 -1
  32. package/dist/features/preview/components/PageInfoSidebar.js +28 -28
  33. package/dist/features/preview/components/PagePicker.js +16 -16
  34. package/dist/features/preview/components/PageTree.js +1 -1
  35. package/dist/features/preview/components/PublicationRow.js +8 -4
  36. package/dist/features/preview/components/useRepeatableItemActions.js +1 -1
  37. package/dist/features/preview/publication.js +10 -0
  38. package/dist/features/provider/CoreCamoxProvider.js +1 -1
  39. package/dist/features/runtime/runtime.js +20 -21
  40. package/dist/features/studio/components/EnvironmentMenu.js +3 -2
  41. package/dist/features/studio/components/Navbar.js +53 -80
  42. package/dist/features/vite/layoutGeneration.js +7 -3
  43. package/dist/features/vite/vite.js +5 -1
  44. package/dist/hooks/use-page-destinations.js +53 -0
  45. package/dist/lib/auth.js +11 -14
  46. package/dist/lib/server-auth-cookie.js +21 -0
  47. package/dist/studio.css +1 -1
  48. package/package.json +8 -4
  49. package/skills/camox/SKILL.md +32 -9
  50. package/skills/camox/references/block-definitions.md +84 -290
  51. package/skills/camox/references/cli-common.md +2 -4
  52. package/skills/camox/references/cli-content.md +147 -0
  53. package/skills/camox/references/cli-environments.md +1 -1
  54. package/skills/camox/references/dom-integrations.md +93 -0
  55. package/skills/camox/references/field-styling.md +50 -0
  56. package/skills/camox/references/layout-definitions.md +33 -147
  57. package/skills/camox/references/routed-layouts.md +71 -0
  58. package/skills/camoxify/SKILL.md +52 -0
  59. package/skills/camox/references/cli-blocks.md +0 -78
  60. package/skills/camox/references/cli-pages.md +0 -53
@@ -3,6 +3,9 @@ import { existsSync, readFileSync, readdirSync } from "node:fs";
3
3
  import { basename, resolve } from "node:path";
4
4
 
5
5
  //#region src/features/vite/layoutGeneration.ts
6
+ function propertyName(name) {
7
+ return /^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u.test(name) ? name : JSON.stringify(name);
8
+ }
6
9
  /** Keep file identities stable across moves without executing application modules. */
7
10
  function generateLayoutFiles(appRoot) {
8
11
  const directory = resolve(appRoot, "src/layouts");
@@ -28,10 +31,11 @@ export const Layout = createLayout(${JSON.stringify(id)})({
28
31
  writeIfChanged(path, source);
29
32
  const segments = id.split(".");
30
33
  const route = "/" + segments.map((segment) => segment.startsWith("$") ? `:${segment.slice(1)}` : segment).join("/");
31
- const params = segments.filter((segment) => segment.startsWith("$")).map((segment) => `${JSON.stringify(segment.slice(1))}: string`).join("; ");
32
- declarations.push(`${JSON.stringify(id)}: { route: ${JSON.stringify(route)}; params: { ${params} } };`);
34
+ const params = segments.filter((segment) => segment.startsWith("$")).map((segment) => ` ${propertyName(segment.slice(1))}: string;`);
35
+ const paramsType = params.length ? `{\n${params.join("\n")}\n }` : "{}";
36
+ declarations.push(` ${propertyName(id)}: {\n route: ${JSON.stringify(route)};\n params: ${paramsType};\n };`);
33
37
  }
34
- writeIfChanged(resolve(appRoot, "src/camox/layouts.gen.d.ts"), `// Generated by Camox.\nimport "camox/createLayout";\ndeclare module "camox/createLayout" {\n interface LayoutFileRoutes {\n ${declarations.join("\n ")}\n }\n}\n`);
38
+ writeIfChanged(resolve(appRoot, "src/camox/layouts.gen.d.ts"), `// Generated by Camox.\nimport "camox/createLayout";\ndeclare module "camox/createLayout" {\n interface LayoutFileRoutes ${declarations.length ? `{\n${declarations.join("\n")}\n }` : "{}"}\n}\n`);
35
39
  }
36
40
 
37
41
  //#endregion
@@ -82,7 +82,11 @@ function camox(options) {
82
82
  nitro: { setup(nitro) {
83
83
  if (nitro.options.noExternals !== true) {
84
84
  const noExternals = Array.isArray(nitro.options.noExternals) ? nitro.options.noExternals : [];
85
- nitro.options.noExternals = [...noExternals, "camox"];
85
+ nitro.options.noExternals = [
86
+ ...noExternals,
87
+ "camox",
88
+ "tslib"
89
+ ];
86
90
  }
87
91
  installRuntimeNitroRoutes(nitro, { runtimeBasePath });
88
92
  nitro.hooks.hook("compiled", ({ options }) => {
@@ -0,0 +1,53 @@
1
+ import { useProjectSlug } from "../lib/auth.js";
2
+ import { getPageDestinations } from "../core/pageDestinations.js";
3
+ import { useCamoxApp } from "../features/provider/components/CamoxAppContext.js";
4
+ import { pageQueries, projectQueries } from "../lib/queries.js";
5
+ import { c } from "react/compiler-runtime";
6
+ import { useQuery } from "@tanstack/react-query";
7
+
8
+ //#region src/hooks/use-page-destinations.ts
9
+ function usePageDestinations() {
10
+ const $ = c(11);
11
+ if ($[0] !== "5104e69847ee48202a1abdefc32d4e478db3a82331029421687a5ec8f7a46eaa") {
12
+ for (let $i = 0; $i < 11; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
13
+ $[0] = "5104e69847ee48202a1abdefc32d4e478db3a82331029421687a5ec8f7a46eaa";
14
+ }
15
+ const app = useCamoxApp();
16
+ const projectSlug = useProjectSlug();
17
+ let t0;
18
+ if ($[1] !== projectSlug) {
19
+ t0 = projectQueries.getBySlug(projectSlug);
20
+ $[1] = projectSlug;
21
+ $[2] = t0;
22
+ } else t0 = $[2];
23
+ const { data: project } = useQuery(t0);
24
+ let t1;
25
+ if ($[3] !== project?.id) {
26
+ t1 = pageQueries.list(project?.id ?? 0);
27
+ $[3] = project?.id;
28
+ $[4] = t1;
29
+ } else t1 = $[4];
30
+ const t2 = !!project;
31
+ let t3;
32
+ if ($[5] !== t1 || $[6] !== t2) {
33
+ t3 = {
34
+ ...t1,
35
+ enabled: t2
36
+ };
37
+ $[5] = t1;
38
+ $[6] = t2;
39
+ $[7] = t3;
40
+ } else t3 = $[7];
41
+ const { data: pages } = useQuery(t3);
42
+ let t4;
43
+ if ($[8] !== app || $[9] !== pages) {
44
+ t4 = getPageDestinations(pages ?? [], app.getLayouts());
45
+ $[8] = app;
46
+ $[9] = pages;
47
+ $[10] = t4;
48
+ } else t4 = $[10];
49
+ return t4;
50
+ }
51
+
52
+ //#endregion
53
+ export { usePageDestinations };
package/dist/lib/auth.js CHANGED
@@ -1,14 +1,11 @@
1
1
  import { actionsStore } from "../features/provider/actionsStore.js";
2
+ import { SERVER_AUTH_COOKIE_NAME, buildClearServerAuthCookieHeader, getServerAuthCookieHeader } from "./server-auth-cookie.js";
2
3
  import { c } from "react/compiler-runtime";
3
4
  import * as React from "react";
4
5
  import { oneTimeTokenClient, organizationClient } from "better-auth/client/plugins";
5
6
  import { createAuthClient } from "better-auth/react";
6
7
 
7
8
  //#region src/lib/auth.ts
8
- const SERVER_AUTH_COOKIE_NAME = "camox_auth_cookie";
9
- function buildClearServerAuthCookieHeader() {
10
- return `${SERVER_AUTH_COOKIE_NAME}=; Path=/; SameSite=Lax; Max-Age=0`;
11
- }
12
9
  function writeServerAuthCookie(cookie) {
13
10
  if (typeof document === "undefined") return;
14
11
  const secure = window.location.protocol === "https:" ? "; Secure" : "";
@@ -217,9 +214,9 @@ function useProcessOtt(authClient) {
217
214
  const AuthContext = React.createContext(null);
218
215
  function useAuthContext() {
219
216
  const $ = c(1);
220
- if ($[0] !== "613abd4be0f81de0bf8df48c671a83e40c3e6ac86dab4c38ebcffe92268b614b") {
217
+ if ($[0] !== "49cbba734e7826ee7cc1d1d95d5d7895a7a71f25806548ac312288b5b8a802f3") {
221
218
  for (let $i = 0; $i < 1; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
222
- $[0] = "613abd4be0f81de0bf8df48c671a83e40c3e6ac86dab4c38ebcffe92268b614b";
219
+ $[0] = "49cbba734e7826ee7cc1d1d95d5d7895a7a71f25806548ac312288b5b8a802f3";
223
220
  }
224
221
  const ctx = React.useContext(AuthContext);
225
222
  if (!ctx) throw new Error("Missing CamoxProvider");
@@ -227,9 +224,9 @@ function useAuthContext() {
227
224
  }
228
225
  function useProjectSlug() {
229
226
  const $ = c(1);
230
- if ($[0] !== "613abd4be0f81de0bf8df48c671a83e40c3e6ac86dab4c38ebcffe92268b614b") {
227
+ if ($[0] !== "49cbba734e7826ee7cc1d1d95d5d7895a7a71f25806548ac312288b5b8a802f3") {
231
228
  for (let $i = 0; $i < 1; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
232
- $[0] = "613abd4be0f81de0bf8df48c671a83e40c3e6ac86dab4c38ebcffe92268b614b";
229
+ $[0] = "49cbba734e7826ee7cc1d1d95d5d7895a7a71f25806548ac312288b5b8a802f3";
233
230
  }
234
231
  return useAuthContext().projectSlug;
235
232
  }
@@ -245,18 +242,18 @@ function useAuthState() {
245
242
  }
246
243
  function useIsAuthenticated() {
247
244
  const $ = c(1);
248
- if ($[0] !== "613abd4be0f81de0bf8df48c671a83e40c3e6ac86dab4c38ebcffe92268b614b") {
245
+ if ($[0] !== "49cbba734e7826ee7cc1d1d95d5d7895a7a71f25806548ac312288b5b8a802f3") {
249
246
  for (let $i = 0; $i < 1; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
250
- $[0] = "613abd4be0f81de0bf8df48c671a83e40c3e6ac86dab4c38ebcffe92268b614b";
247
+ $[0] = "49cbba734e7826ee7cc1d1d95d5d7895a7a71f25806548ac312288b5b8a802f3";
251
248
  }
252
249
  const { isAuthenticated } = useAuthState();
253
250
  return isAuthenticated;
254
251
  }
255
252
  function useSignInRedirect(callbackHref) {
256
253
  const $ = c(4);
257
- if ($[0] !== "613abd4be0f81de0bf8df48c671a83e40c3e6ac86dab4c38ebcffe92268b614b") {
254
+ if ($[0] !== "49cbba734e7826ee7cc1d1d95d5d7895a7a71f25806548ac312288b5b8a802f3") {
258
255
  for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
259
- $[0] = "613abd4be0f81de0bf8df48c671a83e40c3e6ac86dab4c38ebcffe92268b614b";
256
+ $[0] = "49cbba734e7826ee7cc1d1d95d5d7895a7a71f25806548ac312288b5b8a802f3";
260
257
  }
261
258
  const { authenticationUrl } = useAuthContext();
262
259
  let t0;
@@ -278,9 +275,9 @@ function useSignInRedirect(callbackHref) {
278
275
  */
279
276
  function useAuthActions() {
280
277
  const $ = c(5);
281
- if ($[0] !== "613abd4be0f81de0bf8df48c671a83e40c3e6ac86dab4c38ebcffe92268b614b") {
278
+ if ($[0] !== "49cbba734e7826ee7cc1d1d95d5d7895a7a71f25806548ac312288b5b8a802f3") {
282
279
  for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
283
- $[0] = "613abd4be0f81de0bf8df48c671a83e40c3e6ac86dab4c38ebcffe92268b614b";
280
+ $[0] = "49cbba734e7826ee7cc1d1d95d5d7895a7a71f25806548ac312288b5b8a802f3";
284
281
  }
285
282
  const { authClient, authenticationUrl } = useAuthContext();
286
283
  let t0;
@@ -0,0 +1,21 @@
1
+ //#region src/lib/server-auth-cookie.ts
2
+ const SERVER_AUTH_COOKIE_NAME = "camox_auth_cookie";
3
+ function buildClearServerAuthCookieHeader() {
4
+ return `${SERVER_AUTH_COOKIE_NAME}=; Path=/; SameSite=Lax; Max-Age=0`;
5
+ }
6
+ /** Forward credentials to the API for validation; cookie presence is not authentication.
7
+ * Cross-domain sessions use the mirror. Same-host sessions (including localhost
8
+ * on different ports) may only have Better Auth's native, HttpOnly cookie.
9
+ */
10
+ function getServerAuthCookieHeader(headers) {
11
+ const cookies = (headers.get("Cookie") ?? "").split(";").map((part) => part.trim());
12
+ const mirror = cookies.find((part) => part.startsWith(`${SERVER_AUTH_COOKIE_NAME}=`));
13
+ if (mirror) try {
14
+ const value = decodeURIComponent(mirror.slice(18));
15
+ if (value) return value;
16
+ } catch {}
17
+ return cookies.filter((part) => part.startsWith("better-auth.session_token=") || part.startsWith("__Secure-better-auth.session_token=")).join("; ");
18
+ }
19
+
20
+ //#endregion
21
+ export { SERVER_AUTH_COOKIE_NAME, buildClearServerAuthCookieHeader, getServerAuthCookieHeader };