camox 0.33.0 → 0.34.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 (100) hide show
  1. package/dist/components/AuthGate.js +5 -4
  2. package/dist/core/createBlock.js +19 -19
  3. package/dist/core/defineDocument.d.ts +7 -0
  4. package/dist/core/defineDocument.js +7 -0
  5. package/dist/features/agent-chat/components/AgentChatSidebar.js +3 -3
  6. package/dist/features/agent-chat/components/AgentChatThread.js +10 -11
  7. package/dist/features/navigation/navigation.d.ts +39 -0
  8. package/dist/features/navigation/navigation.js +231 -0
  9. package/dist/features/preview/CamoxPreview.d.ts +3 -0
  10. package/dist/features/preview/CamoxPreview.js +12 -12
  11. package/dist/features/preview/components/AddBlockSidebar.js +4 -4
  12. package/dist/features/preview/components/AssetLightbox.js +10 -9
  13. package/dist/features/preview/components/CreatePageModal.js +3 -3
  14. package/dist/features/preview/components/FieldToolbar.js +1 -1
  15. package/dist/features/preview/components/PageInfoSidebar.js +23 -23
  16. package/dist/features/preview/components/PageNavigatorSidebar.js +6 -6
  17. package/dist/features/preview/components/PagePicker.js +1 -1
  18. package/dist/features/preview/components/PreviewToolbar.js +3 -3
  19. package/dist/features/preview/components/useUpdateBlockPosition.js +3 -3
  20. package/dist/features/provider/CamoxProvider.js +10 -8
  21. package/dist/features/routes/pageRuntime.js +6 -0
  22. package/dist/features/runtime/pageApp.js +75 -0
  23. package/dist/features/runtime/pageClient.d.ts +7 -0
  24. package/dist/features/runtime/pageClient.js +37 -0
  25. package/dist/features/runtime/pageNavigation.js +170 -0
  26. package/dist/features/runtime/pageServer.d.ts +9 -0
  27. package/dist/features/runtime/pageServer.js +18 -0
  28. package/dist/features/runtime/runtime.d.ts +24 -0
  29. package/dist/features/runtime/runtime.js +44 -0
  30. package/dist/features/runtime/studioApp.d.ts +15 -0
  31. package/dist/features/runtime/studioApp.js +117 -0
  32. package/dist/features/runtime/studioNavigation.js +115 -0
  33. package/dist/features/runtime/studioServer.d.ts +9 -0
  34. package/dist/features/runtime/studioServer.js +18 -0
  35. package/dist/features/studio/CamoxStudio.js +3 -3
  36. package/dist/features/studio/components/Navbar.js +7 -7
  37. package/dist/features/studio/components/ProjectMenu.js +9 -9
  38. package/dist/features/studio/components/UserButton.js +3 -3
  39. package/dist/features/vite/appGeneration.js +16 -5
  40. package/dist/features/vite/blockBoilerplate.js +1 -1
  41. package/dist/features/vite/definitionsSync.js +4 -4
  42. package/dist/features/vite/routeGeneration.js +9 -156
  43. package/dist/features/vite/runtimeDev.js +270 -0
  44. package/dist/features/vite/utils.js +3 -1
  45. package/dist/features/vite/vite.d.ts +22 -3
  46. package/dist/features/vite/vite.js +36 -19
  47. package/dist/hooks/use-file-upload.js +3 -1
  48. package/dist/lib/api-client.js +6 -3
  49. package/dist/lib/auth.js +45 -68
  50. package/dist/lib/queries.js +6 -4
  51. package/dist/lib/telemetry.js +1 -24
  52. package/dist/lib/utils.js +1 -1
  53. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/Matches.d.ts +114 -0
  54. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/RouterProvider.d.ts +25 -0
  55. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/config.d.ts +1 -0
  56. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/defer.d.ts +1 -0
  57. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/fileRoute.d.ts +20 -0
  58. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/global.d.ts +8 -0
  59. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/hash-scroll.d.ts +1 -0
  60. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/index.d.ts +18 -0
  61. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/link.d.ts +161 -0
  62. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/load-matches.d.ts +6 -0
  63. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/location.d.ts +54 -0
  64. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/lru-cache.d.ts +8 -0
  65. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/manifest.d.ts +32 -0
  66. 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
  67. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/not-found.d.ts +1 -0
  68. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/redirect.d.ts +49 -0
  69. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/rewrite.d.ts +1 -0
  70. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/root.d.ts +6 -0
  71. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/route.d.ts +343 -0
  72. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/routeInfo.d.ts +48 -0
  73. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/router.d.ts +695 -0
  74. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/scroll-restoration.d.ts +1 -0
  75. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/searchMiddleware.d.ts +1 -0
  76. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/searchParams.d.ts +5 -0
  77. 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
  78. 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
  79. 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
  80. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/stores.d.ts +69 -0
  81. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/structuralSharing.d.ts +1 -0
  82. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/typePrimitives.d.ts +1 -0
  83. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useLoaderData.d.ts +1 -0
  84. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useLoaderDeps.d.ts +1 -0
  85. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useNavigate.d.ts +10 -0
  86. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useParams.d.ts +1 -0
  87. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useRouteContext.d.ts +1 -0
  88. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/useSearch.d.ts +1 -0
  89. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/utils.d.ts +28 -0
  90. package/dist/node_modules/.pnpm/@tanstack_router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/validators.d.ts +49 -0
  91. package/package.json +34 -12
  92. package/skills/camox-block/SKILL.md +4 -4
  93. package/skills/camox-cli/SKILL.md +3 -3
  94. package/skills/camox-layout/SKILL.md +2 -2
  95. package/dist/features/routes/ogRoute.d.ts +0 -12
  96. package/dist/features/routes/ogRoute.js +0 -20
  97. package/dist/features/routes/pageRoute.d.ts +0 -48
  98. package/dist/features/routes/pageRoute.js +0 -254
  99. package/dist/lib/api-client.d.ts +0 -7
  100. package/dist/lib/queries.d.ts +0 -12
@@ -1,6 +1,24 @@
1
1
  import { Plugin } from "vite-plus";
2
2
 
3
3
  //#region src/features/vite/vite.d.ts
4
+ interface CamoxNitro {
5
+ hooks: {
6
+ hook: (name: "compiled", callback: (nitro: CamoxNitro) => void) => void;
7
+ };
8
+ options: {
9
+ output: {
10
+ publicDir: string;
11
+ serverDir: string;
12
+ };
13
+ routes: Record<string, string>;
14
+ virtual: Record<string, string>;
15
+ };
16
+ }
17
+ type CamoxVitePlugin = Plugin & {
18
+ nitro?: {
19
+ setup: (nitro: CamoxNitro) => void;
20
+ };
21
+ };
4
22
  interface CamoxPluginOptions {
5
23
  /** Stable, human-readable slug identifying this project (e.g. "prestigious-impala-84") */
6
24
  projectSlug: string;
@@ -10,12 +28,13 @@ interface CamoxPluginOptions {
10
28
  disableTelemetry?: boolean;
11
29
  /** Internal options (intended for Camox contributors in development, not for public use) */
12
30
  _internal?: {
13
- /** URL of the Camox API backend, used for data fetching */apiUrl?: string; /** URL of the Camox authentication backend (default: https://camox.ai) */
31
+ /** URL of the Camox API backend, used for data fetching */apiUrl?: string; /** URL of the Camox authentication backend (default: https://app.camox.ai) */
14
32
  authenticationUrl?: string; /** Show Tanstack query devtools (default: false) */
15
33
  enableTanstackDevtools?: boolean; /** Disable automatic code generation (route files, app file, skill files) (default: false) */
16
- disableCodeGen?: boolean;
34
+ disableCodeGen?: boolean; /** Mount the Camox-owned dev runtime at this base path. Use "/" for root mode. */
35
+ runtimeBasePath?: string;
17
36
  };
18
37
  }
19
- declare function camox(options: CamoxPluginOptions): Plugin;
38
+ declare function camox(options: CamoxPluginOptions): CamoxVitePlugin;
20
39
  //#endregion
21
40
  export { CamoxPluginOptions, camox };
@@ -1,9 +1,10 @@
1
1
  import { generateAppFile, watchAppFile } from "./appGeneration.js";
2
2
  import { watchNewBlockFiles } from "./blockBoilerplate.js";
3
3
  import { syncDefinitions, syncDefinitionsToApi } from "./definitionsSync.js";
4
- import { generateRouteFiles, watchRouteFiles } from "./routeGeneration.js";
4
+ import { cleanupGeneratedRouteFiles } from "./routeGeneration.js";
5
+ import { installRuntimeNitroRoutes, loadRuntimeDevModule, resolveRuntimeDevId } from "./runtimeDev.js";
5
6
  import { generateSkillFiles, watchSkillFiles } from "./skillGeneration.js";
6
- import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
7
+ import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
7
8
  import { homedir } from "node:os";
8
9
  import { dirname, join, resolve } from "node:path";
9
10
  import { fileURLToPath } from "node:url";
@@ -16,9 +17,11 @@ const VIRTUAL_STUDIO_CSS = "virtual:camox-studio-css";
16
17
  const RESOLVED_VIRTUAL_STUDIO_CSS = "\0" + VIRTUAL_STUDIO_CSS;
17
18
  const VIRTUAL_OVERLAY_CSS = "virtual:camox-overlay-css";
18
19
  const RESOLVED_VIRTUAL_OVERLAY_CSS = "\0" + VIRTUAL_OVERLAY_CSS;
20
+ const VIRTUAL_PAGE_CLIENT = "virtual:camox/page-client";
21
+ const RESOLVED_VIRTUAL_PAGE_CLIENT_URL = "\0virtual:camox/page-client-url";
19
22
  const PRODUCTION_API_URL = "https://api.camox.ai";
20
- /** Authentication URL to use for Camox authentication (production Camox web app) */
21
- const DEFAULT_AUTHENTICATION_URL = "https://camox.ai";
23
+ /** Authentication URL to use for Camox authentication (production Camox Dashboard) */
24
+ const DEFAULT_AUTHENTICATION_URL = "https://app.camox.ai";
22
25
  const authTokenSchema = z.object({
23
26
  token: z.string(),
24
27
  name: z.string(),
@@ -66,12 +69,16 @@ function camox(options) {
66
69
  const authenticationUrl = options._internal?.authenticationUrl ?? DEFAULT_AUTHENTICATION_URL;
67
70
  const enableTanstackDevtools = options._internal?.enableTanstackDevtools ?? false;
68
71
  const disableCodeGen = options._internal?.disableCodeGen ?? false;
72
+ const runtimeBasePath = options._internal?.runtimeBasePath;
69
73
  let isBuild = false;
70
74
  let resolvedConfig;
71
75
  let environmentName;
72
76
  return {
73
77
  name: "camox",
74
- resolveId(id) {
78
+ enforce: "pre",
79
+ resolveId(id, importer) {
80
+ const runtimeId = resolveRuntimeDevId(id, importer);
81
+ if (runtimeId) return runtimeId;
75
82
  if (id === VIRTUAL_STUDIO_CSS) return RESOLVED_VIRTUAL_STUDIO_CSS;
76
83
  if (id === VIRTUAL_OVERLAY_CSS) return RESOLVED_VIRTUAL_OVERLAY_CSS;
77
84
  },
@@ -80,11 +87,8 @@ function camox(options) {
80
87
  const cssPath = resolve(sdkRoot, "dist/studio.css");
81
88
  if (isBuild) {
82
89
  const css = readFileSync(cssPath, "utf-8");
83
- return `export default import.meta.ROLLUP_FILE_URL_${this.emitFile({
84
- type: "asset",
85
- name: "studio.css",
86
- source: css
87
- })};`;
90
+ const dataUrl = `data:text/css;base64,${Buffer.from(css).toString("base64")}`;
91
+ return `export default ${JSON.stringify(dataUrl)};`;
88
92
  }
89
93
  return `export default "/@fs/${cssPath}";`;
90
94
  }
@@ -92,18 +96,38 @@ function camox(options) {
92
96
  const css = readFileSync(resolve(sdkRoot, "dist/studio-overlays.css"), "utf-8");
93
97
  return `export default ${JSON.stringify(css)};`;
94
98
  }
99
+ if (id === RESOLVED_VIRTUAL_PAGE_CLIENT_URL && isBuild) return "export default \"/_chunks/camox-page-client.mjs\";";
100
+ return loadRuntimeDevModule(id, { runtimeBasePath });
95
101
  },
102
+ nitro: { setup(nitro) {
103
+ installRuntimeNitroRoutes(nitro, { runtimeBasePath });
104
+ nitro.hooks.hook("compiled", ({ options }) => {
105
+ const serverAssets = join(options.output.serverDir, "assets");
106
+ if (!existsSync(serverAssets)) return;
107
+ cpSync(serverAssets, join(options.output.publicDir, "assets"), { recursive: true });
108
+ });
109
+ } },
96
110
  config(_config, env) {
97
111
  isBuild = env.command === "build";
98
112
  environmentName = resolveEnvironmentName(env.command, authenticationUrl);
99
113
  return {
114
+ build: { emitAssets: true },
100
115
  define: {
101
116
  __CAMOX_TELEMETRY_DISABLED__: JSON.stringify(!!options.disableTelemetry),
102
117
  __ENABLE_TANSTACK_DEVTOOLS__: JSON.stringify(enableTanstackDevtools),
103
118
  __CAMOX_ENVIRONMENT_NAME__: JSON.stringify(environmentName),
104
119
  __CAMOX_API_URL__: JSON.stringify(apiUrl),
120
+ __CAMOX_AUTHENTICATION_URL__: JSON.stringify(authenticationUrl),
105
121
  __CAMOX_PROJECT_SLUG__: JSON.stringify(options.projectSlug)
106
122
  },
123
+ environments: { client: { build: { rollupOptions: {
124
+ input: { "camox-page-client": VIRTUAL_PAGE_CLIENT },
125
+ output: {
126
+ assetFileNames: "assets/[name]-[hash][extname]",
127
+ chunkFileNames: "_chunks/[name]-[hash].mjs",
128
+ entryFileNames: "_chunks/[name].mjs"
129
+ }
130
+ } } } },
107
131
  resolve: { alias: [{
108
132
  find: /^tslib$/,
109
133
  replacement: "tslib/tslib.es6.mjs"
@@ -189,10 +213,7 @@ function camox(options) {
189
213
  });
190
214
  if (!disableCodeGen) {
191
215
  generateAppFile(config.root);
192
- generateRouteFiles({
193
- routesDir,
194
- authenticationUrl
195
- });
216
+ cleanupGeneratedRouteFiles(routesDir);
196
217
  generateSkillFiles(config.root);
197
218
  }
198
219
  if (disableCodeGen) config.logger.warn("⚠️ Code generation is disabled (_internal.disableCodeGen). This option is only meant for momentary debugging — do not deploy or commit your app with it enabled.", { timestamp: true });
@@ -203,11 +224,7 @@ function camox(options) {
203
224
  const routesDir = resolve(server.config.root, "src/routes");
204
225
  if (!disableCodeGen) {
205
226
  watchAppFile(server, server.config.root);
206
- watchRouteFiles({
207
- server,
208
- routesDir,
209
- authenticationUrl
210
- });
227
+ cleanupGeneratedRouteFiles(routesDir);
211
228
  watchSkillFiles(server, server.config.root);
212
229
  watchNewBlockFiles(server);
213
230
  }
@@ -40,8 +40,10 @@ function useFileUpload(options) {
40
40
  formData.append("file", file);
41
41
  formData.append("projectId", String(projectIdRef.current ?? 0));
42
42
  const uploadUrl = `${apiUrl}/files/upload`;
43
+ const authCookieHeader = getAuthCookieHeader();
43
44
  xhr.open("POST", uploadUrl);
44
- xhr.setRequestHeader("Better-Auth-Cookie", getAuthCookieHeader());
45
+ xhr.withCredentials = !authCookieHeader;
46
+ if (authCookieHeader) xhr.setRequestHeader("Better-Auth-Cookie", authCookieHeader);
45
47
  const envName = getEnvironmentName();
46
48
  if (envName) xhr.setRequestHeader("x-environment-name", envName);
47
49
  xhr.send(formData);
@@ -1,4 +1,4 @@
1
- import { getAuthCookieHeader } from "./auth.js";
1
+ import { getAuthCookieHeader, getAuthRequestCredentials } from "./auth.js";
2
2
  import { createORPCClient } from "@orpc/client";
3
3
  import { RPCLink } from "@orpc/client/fetch";
4
4
  import { createTanstackQueryUtils } from "@orpc/tanstack-query";
@@ -18,10 +18,13 @@ function initApiClient(apiUrl, environmentName) {
18
18
  url: `${apiUrl}/rpc`,
19
19
  headers,
20
20
  fetch: (request, init) => {
21
- if (request instanceof Request) request.headers.set("Better-Auth-Cookie", getAuthCookieHeader());
21
+ const authCookieHeader = getAuthCookieHeader();
22
+ if (request instanceof Request) {
23
+ if (authCookieHeader) request.headers.set("Better-Auth-Cookie", authCookieHeader);
24
+ }
22
25
  return fetch(request, {
23
26
  ...init,
24
- credentials: "omit"
27
+ credentials: getAuthRequestCredentials(authCookieHeader)
25
28
  });
26
29
  }
27
30
  }));
package/dist/lib/auth.js CHANGED
@@ -18,16 +18,6 @@ function writeServerAuthCookie(cookie) {
18
18
  }
19
19
  document.cookie = `${SERVER_AUTH_COOKIE_NAME}=${encodeURIComponent(cookie)}; Path=/; SameSite=Lax; Max-Age=2592000${secure}`;
20
20
  }
21
- function getServerAuthCookieHeader(headers) {
22
- const authCookie = (headers.get("Cookie") ?? headers.get("cookie") ?? "").split(";").map((part) => part.trim()).find((part) => part.startsWith(`${SERVER_AUTH_COOKIE_NAME}=`));
23
- if (!authCookie) return "";
24
- const value = authCookie.slice(18);
25
- try {
26
- return decodeURIComponent(value);
27
- } catch {
28
- return "";
29
- }
30
- }
31
21
  function parseSetCookieHeader(header) {
32
22
  const cookieMap = /* @__PURE__ */ new Map();
33
23
  header.split(", ").forEach((cookie) => {
@@ -86,6 +76,9 @@ function getAuthCookieHeader() {
86
76
  writeServerAuthCookie(cookie);
87
77
  return cookie;
88
78
  }
79
+ function getAuthRequestCredentials(authCookieHeader = getAuthCookieHeader()) {
80
+ return authCookieHeader ? "omit" : "include";
81
+ }
89
82
  function crossDomainClient(opts = {}) {
90
83
  let store = null;
91
84
  const cookieName = `${opts?.storagePrefix || "better-auth"}_cookie`;
@@ -154,7 +147,7 @@ function crossDomainClient(opts = {}) {
154
147
  options = options || {};
155
148
  const cookie = getCookie(storage.getItem(cookieName) || "{}");
156
149
  writeServerAuthCookie(cookie);
157
- options.credentials = "omit";
150
+ options.credentials = getAuthRequestCredentials(cookie);
158
151
  options.headers = {
159
152
  ...options.headers,
160
153
  "Better-Auth-Cookie": cookie
@@ -194,55 +187,39 @@ function createCamoxAuthClient(apiUrl) {
194
187
  * Returns `true` once processing is complete (or if there was no OTT).
195
188
  */
196
189
  function useProcessOtt(authClient) {
197
- const $ = c(5);
198
- if ($[0] !== "ca7c79c76d5f8a744a7d4c29bced16850552ef3c635510b89bf8588163655fe3") {
199
- for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
200
- $[0] = "ca7c79c76d5f8a744a7d4c29bced16850552ef3c635510b89bf8588163655fe3";
201
- }
202
- const [ready, setReady] = React.useState(_temp);
203
- let t0;
204
- let t1;
205
- if ($[1] !== authClient || $[2] !== ready) {
206
- t0 = () => {
207
- if (ready) return;
208
- const url = new URL(window.location.href);
209
- const ott = url.searchParams.get("ott");
210
- if (!ott) {
211
- setReady(true);
190
+ const [ready, setReady] = React.useState(() => {
191
+ if (typeof window === "undefined") return true;
192
+ return !new URL(window.location.href).searchParams.has("ott");
193
+ });
194
+ React.useEffect(() => {
195
+ if (ready) return;
196
+ const url = new URL(window.location.href);
197
+ const ott = url.searchParams.get("ott");
198
+ if (!ott) {
199
+ setReady(true);
200
+ return;
201
+ }
202
+ url.searchParams.delete("ott");
203
+ window.history.replaceState({}, "", url);
204
+ (async () => {
205
+ try {
206
+ const verification = await authClient.oneTimeToken.verify({ token: ott });
207
+ if (verification.error) throw verification.error;
208
+ if (!verification.data) throw new Error("OTT verification returned no session");
209
+ window.location.reload();
212
210
  return;
213
- }
214
- url.searchParams.delete("ott");
215
- window.history.replaceState({}, "", url);
216
- (async () => {
217
- try {
218
- await authClient.oneTimeToken.verify({ token: ott });
219
- await authClient.updateSession();
220
- } catch {}
221
- setReady(true);
222
- })();
223
- };
224
- t1 = [authClient, ready];
225
- $[1] = authClient;
226
- $[2] = ready;
227
- $[3] = t0;
228
- $[4] = t1;
229
- } else {
230
- t0 = $[3];
231
- t1 = $[4];
232
- }
233
- React.useEffect(t0, t1);
211
+ } catch {}
212
+ setReady(true);
213
+ })();
214
+ }, [authClient, ready]);
234
215
  return ready;
235
216
  }
236
- function _temp() {
237
- if (typeof window === "undefined") return true;
238
- return !new URL(window.location.href).searchParams.has("ott");
239
- }
240
217
  const AuthContext = React.createContext(null);
241
218
  function useAuthContext() {
242
219
  const $ = c(1);
243
- if ($[0] !== "ca7c79c76d5f8a744a7d4c29bced16850552ef3c635510b89bf8588163655fe3") {
220
+ if ($[0] !== "96393d5626632a69960ca7e18d98e06ae87b8528faab082732a3cc7b48adfd93") {
244
221
  for (let $i = 0; $i < 1; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
245
- $[0] = "ca7c79c76d5f8a744a7d4c29bced16850552ef3c635510b89bf8588163655fe3";
222
+ $[0] = "96393d5626632a69960ca7e18d98e06ae87b8528faab082732a3cc7b48adfd93";
246
223
  }
247
224
  const ctx = React.useContext(AuthContext);
248
225
  if (!ctx) throw new Error("Missing CamoxProvider");
@@ -250,9 +227,9 @@ function useAuthContext() {
250
227
  }
251
228
  function useProjectSlug() {
252
229
  const $ = c(1);
253
- if ($[0] !== "ca7c79c76d5f8a744a7d4c29bced16850552ef3c635510b89bf8588163655fe3") {
230
+ if ($[0] !== "96393d5626632a69960ca7e18d98e06ae87b8528faab082732a3cc7b48adfd93") {
254
231
  for (let $i = 0; $i < 1; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
255
- $[0] = "ca7c79c76d5f8a744a7d4c29bced16850552ef3c635510b89bf8588163655fe3";
232
+ $[0] = "96393d5626632a69960ca7e18d98e06ae87b8528faab082732a3cc7b48adfd93";
256
233
  }
257
234
  return useAuthContext().projectSlug;
258
235
  }
@@ -266,18 +243,18 @@ function useAuthState() {
266
243
  }
267
244
  function useIsAuthenticated() {
268
245
  const $ = c(1);
269
- if ($[0] !== "ca7c79c76d5f8a744a7d4c29bced16850552ef3c635510b89bf8588163655fe3") {
246
+ if ($[0] !== "96393d5626632a69960ca7e18d98e06ae87b8528faab082732a3cc7b48adfd93") {
270
247
  for (let $i = 0; $i < 1; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
271
- $[0] = "ca7c79c76d5f8a744a7d4c29bced16850552ef3c635510b89bf8588163655fe3";
248
+ $[0] = "96393d5626632a69960ca7e18d98e06ae87b8528faab082732a3cc7b48adfd93";
272
249
  }
273
250
  const { isAuthenticated } = useAuthState();
274
251
  return isAuthenticated;
275
252
  }
276
253
  function useSignInRedirect(callbackHref) {
277
254
  const $ = c(4);
278
- if ($[0] !== "ca7c79c76d5f8a744a7d4c29bced16850552ef3c635510b89bf8588163655fe3") {
255
+ if ($[0] !== "96393d5626632a69960ca7e18d98e06ae87b8528faab082732a3cc7b48adfd93") {
279
256
  for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
280
- $[0] = "ca7c79c76d5f8a744a7d4c29bced16850552ef3c635510b89bf8588163655fe3";
257
+ $[0] = "96393d5626632a69960ca7e18d98e06ae87b8528faab082732a3cc7b48adfd93";
281
258
  }
282
259
  const { authenticationUrl } = useAuthContext();
283
260
  let t0;
@@ -299,9 +276,9 @@ function useSignInRedirect(callbackHref) {
299
276
  */
300
277
  function useAuthActions() {
301
278
  const $ = c(5);
302
- if ($[0] !== "ca7c79c76d5f8a744a7d4c29bced16850552ef3c635510b89bf8588163655fe3") {
279
+ if ($[0] !== "96393d5626632a69960ca7e18d98e06ae87b8528faab082732a3cc7b48adfd93") {
303
280
  for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
304
- $[0] = "ca7c79c76d5f8a744a7d4c29bced16850552ef3c635510b89bf8588163655fe3";
281
+ $[0] = "96393d5626632a69960ca7e18d98e06ae87b8528faab082732a3cc7b48adfd93";
305
282
  }
306
283
  const { authClient, authenticationUrl } = useAuthContext();
307
284
  let t0;
@@ -319,7 +296,7 @@ function useAuthActions() {
319
296
  "User settings"
320
297
  ],
321
298
  groupLabel: "Studio",
322
- checkIfAvailable: _temp2,
299
+ checkIfAvailable: _temp,
323
300
  execute: () => {
324
301
  window.open(`${authenticationUrl}/profile`, "_blank");
325
302
  }
@@ -328,11 +305,11 @@ function useAuthActions() {
328
305
  label: "Log out",
329
306
  aliases: ["Sign out", "Logout"],
330
307
  groupLabel: "Studio",
331
- checkIfAvailable: _temp3,
308
+ checkIfAvailable: _temp2,
332
309
  execute: () => authClient.signOut()
333
310
  }]
334
311
  });
335
- return _temp4;
312
+ return _temp3;
336
313
  };
337
314
  t1 = [authClient, authenticationUrl];
338
315
  $[1] = authClient;
@@ -345,18 +322,18 @@ function useAuthActions() {
345
322
  }
346
323
  React.useEffect(t0, t1);
347
324
  }
348
- function _temp4() {
325
+ function _temp3() {
349
326
  actionsStore.send({
350
327
  type: "unregisterManyActions",
351
328
  ids: ["manage-account", "log-out"]
352
329
  });
353
330
  }
354
- function _temp3() {
331
+ function _temp2() {
355
332
  return true;
356
333
  }
357
- function _temp2() {
334
+ function _temp() {
358
335
  return true;
359
336
  }
360
337
 
361
338
  //#endregion
362
- export { AuthContext, buildClearServerAuthCookieHeader, createCamoxAuthClient, getAuthCookieHeader, getServerAuthCookieHeader, useAuthActions, useAuthContext, useAuthState, useIsAuthenticated, useProcessOtt, useProjectSlug, useSignInRedirect };
339
+ export { AuthContext, createCamoxAuthClient, getAuthCookieHeader, getAuthRequestCredentials, useAuthActions, useAuthContext, useAuthState, useIsAuthenticated, useProcessOtt, useProjectSlug, useSignInRedirect };
@@ -1,4 +1,4 @@
1
- import { getAuthCookieHeader } from "./auth.js";
1
+ import { getAuthCookieHeader, getAuthRequestCredentials } from "./auth.js";
2
2
  import { getApiUrl, getEnvironmentName, getOrpc } from "./api-client.js";
3
3
  import { queryKeys } from "@camox/api-contract/query-keys";
4
4
 
@@ -130,7 +130,9 @@ const repeatableItemMutations = {
130
130
  updatePosition: () => getOrpc().repeatableItems.updatePosition.mutationOptions()
131
131
  };
132
132
  function ogImageHeaders() {
133
- const headers = { "Better-Auth-Cookie": getAuthCookieHeader() };
133
+ const authCookieHeader = getAuthCookieHeader();
134
+ const headers = {};
135
+ if (authCookieHeader) headers["Better-Auth-Cookie"] = authCookieHeader;
134
136
  const envName = getEnvironmentName();
135
137
  if (envName) headers["x-environment-name"] = envName;
136
138
  return headers;
@@ -153,7 +155,7 @@ const pageMutations = {
153
155
  method: "POST",
154
156
  body: formData,
155
157
  headers: ogImageHeaders(),
156
- credentials: "omit"
158
+ credentials: getAuthRequestCredentials()
157
159
  });
158
160
  if (!res.ok) {
159
161
  const body = await res.json().catch(() => null);
@@ -165,7 +167,7 @@ const pageMutations = {
165
167
  const res = await fetch(`${getApiUrl()}/pages/${pageId}/og-image`, {
166
168
  method: "DELETE",
167
169
  headers: ogImageHeaders(),
168
- credentials: "omit"
170
+ credentials: getAuthRequestCredentials()
169
171
  });
170
172
  if (!res.ok) throw new Error(`Delete failed: ${res.status}`);
171
173
  return res.json();
@@ -1,26 +1,3 @@
1
1
  import { POSTHOG_PUBLIC_KEY } from "@camox/api-contract";
2
2
 
3
- //#region src/lib/telemetry.ts
4
- let client = null;
5
- async function getClient() {
6
- if (__CAMOX_TELEMETRY_DISABLED__) return null;
7
- if (!client) {
8
- const { PostHog } = await import("posthog-node");
9
- client = new PostHog(POSTHOG_PUBLIC_KEY, { host: "https://us.i.posthog.com" });
10
- }
11
- return client;
12
- }
13
- /** Server-side tracking for page views (used in pageRoute.tsx) */
14
- async function trackEvent(event, properties) {
15
- const posthog = await getClient();
16
- if (!posthog) return;
17
- const distinctId = properties.projectId ?? "unknown";
18
- posthog.capture({
19
- distinctId,
20
- event,
21
- properties
22
- });
23
- }
24
-
25
- //#endregion
26
- export { trackEvent };
3
+ export { };
package/dist/lib/utils.js CHANGED
@@ -1,5 +1,5 @@
1
- import { Kbd } from "@camox/ui/kbd";
2
1
  import { jsxs } from "react/jsx-runtime";
2
+ import { Kbd } from "@camox/ui/kbd";
3
3
  import { INPUT_BASE_STYLES, INPUT_FOCUS_STYLES, cn } from "@camox/ui/utils";
4
4
 
5
5
  //#region src/lib/utils.tsx
@@ -0,0 +1,114 @@
1
+ import { ControlledPromise } from "./utils.js";
2
+ import { ParseRoute } from "./routeInfo.js";
3
+ import { AnyRoute, StaticDataRouteOption } from "./route.js";
4
+ import { AnyRouter, RegisteredRouter, SSROption } from "./router.js";
5
+
6
+ //#region ../../node_modules/.pnpm/@tanstack+router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/Matches.d.ts
7
+ interface DefaultRouteMatchExtensions {
8
+ scripts?: unknown;
9
+ links?: unknown;
10
+ headScripts?: unknown;
11
+ meta?: unknown;
12
+ styles?: unknown;
13
+ }
14
+ interface RouteMatchExtensions extends DefaultRouteMatchExtensions {}
15
+ interface RouteMatch<out TRouteId, out TFullPath, out TAllParams, out TFullSearchSchema, out TLoaderData, out TAllContext, out TLoaderDeps> extends RouteMatchExtensions {
16
+ id: string;
17
+ routeId: TRouteId;
18
+ fullPath: TFullPath;
19
+ index: number;
20
+ pathname: string;
21
+ params: TAllParams;
22
+ _strictParams: TAllParams;
23
+ status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound';
24
+ isFetching: false | 'beforeLoad' | 'loader';
25
+ error: unknown;
26
+ paramsError: unknown;
27
+ searchError: unknown;
28
+ updatedAt: number;
29
+ _nonReactive: {
30
+ loadPromise?: ControlledPromise<void>;
31
+ displayPendingPromise?: Promise<void>;
32
+ minPendingPromise?: ControlledPromise<void>;
33
+ dehydrated?: boolean;
34
+ };
35
+ loaderData?: TLoaderData;
36
+ context: TAllContext;
37
+ search: TFullSearchSchema;
38
+ _strictSearch: TFullSearchSchema;
39
+ fetchCount: number;
40
+ abortController: AbortController;
41
+ cause: 'preload' | 'enter' | 'stay';
42
+ loaderDeps: TLoaderDeps;
43
+ preload: boolean;
44
+ invalid: boolean;
45
+ headers?: Record<string, string>;
46
+ globalNotFound?: boolean;
47
+ staticData: StaticDataRouteOption;
48
+ /** This attribute is not reactive */
49
+ ssr?: SSROption;
50
+ _forcePending?: boolean;
51
+ _displayPending?: boolean;
52
+ }
53
+ interface PreValidationErrorHandlingRouteMatch<TRouteId, TFullPath, TAllParams, TFullSearchSchema> {
54
+ id: string;
55
+ routeId: TRouteId;
56
+ fullPath: TFullPath;
57
+ index: number;
58
+ pathname: string;
59
+ search: {
60
+ status: 'success';
61
+ value: TFullSearchSchema;
62
+ } | {
63
+ status: 'error';
64
+ error: unknown;
65
+ };
66
+ params: {
67
+ status: 'success';
68
+ value: TAllParams;
69
+ } | {
70
+ status: 'error';
71
+ error: unknown;
72
+ };
73
+ staticData: StaticDataRouteOption;
74
+ ssr?: boolean | 'data-only';
75
+ }
76
+ type MakePreValidationErrorHandlingRouteMatchUnion<TRouter extends AnyRouter = RegisteredRouter, TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>> = TRoute extends any ? PreValidationErrorHandlingRouteMatch<TRoute['id'], TRoute['fullPath'], TRoute['types']['allParams'], TRoute['types']['fullSearchSchema']> : never;
77
+ type MakeRouteMatchFromRoute<TRoute extends AnyRoute> = RouteMatch<TRoute['types']['id'], TRoute['types']['fullPath'], TRoute['types']['allParams'], TRoute['types']['fullSearchSchema'], TRoute['types']['loaderData'], TRoute['types']['allContext'], TRoute['types']['loaderDeps']>;
78
+ type AnyRouteMatch = RouteMatch<any, any, any, any, any, any, any>;
79
+ type MakeRouteMatchUnion<TRouter extends AnyRouter = RegisteredRouter, TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>> = TRoute extends any ? RouteMatch<TRoute['id'], TRoute['fullPath'], TRoute['types']['allParams'], TRoute['types']['fullSearchSchema'], TRoute['types']['loaderData'], TRoute['types']['allContext'], TRoute['types']['loaderDeps']> : never;
80
+ /**
81
+ * The `MatchRouteOptions` type is used to describe the options that can be used when matching a route.
82
+ *
83
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#matchrouteoptions-type)
84
+ */
85
+ interface MatchRouteOptions {
86
+ /**
87
+ * If `true`, will match against pending location instead of the current location.
88
+ *
89
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#pending-property)
90
+ */
91
+ pending?: boolean;
92
+ /**
93
+ * If `true`, will match against the current location with case sensitivity.
94
+ *
95
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#casesensitive-property)
96
+ *
97
+ * @deprecated Declare case sensitivity in the route definition instead, or globally for all routes using the `caseSensitive` option on the router.
98
+ */
99
+ caseSensitive?: boolean;
100
+ /**
101
+ * If `true`, will match against the current location's search params using a deep inclusive check. e.g. `{ a: 1 }` will match for a current location of `{ a: 1, b: 2 }`.
102
+ *
103
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#includesearch-property)
104
+ */
105
+ includeSearch?: boolean;
106
+ /**
107
+ * If `true`, will match against the current location using a fuzzy match. e.g. `/posts` will match for a current location of `/posts/123`.
108
+ *
109
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#fuzzy-property)
110
+ */
111
+ fuzzy?: boolean;
112
+ }
113
+ //#endregion
114
+ export { AnyRouteMatch, MakePreValidationErrorHandlingRouteMatchUnion, MakeRouteMatchFromRoute, MakeRouteMatchUnion, MatchRouteOptions, RouteMatch, RouteMatchExtensions };
@@ -0,0 +1,25 @@
1
+ import { NavigateOptions, ToOptions } from "./link.js";
2
+ import { RoutePaths } from "./routeInfo.js";
3
+ import { ParsedLocation } from "./location.js";
4
+ import { RegisteredRouter, ViewTransitionOptions } from "./router.js";
5
+
6
+ //#region ../../node_modules/.pnpm/@tanstack+router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/RouterProvider.d.ts
7
+ interface CommitLocationOptions {
8
+ replace?: boolean;
9
+ resetScroll?: boolean;
10
+ hashScrollIntoView?: boolean | ScrollIntoViewOptions;
11
+ viewTransition?: boolean | ViewTransitionOptions;
12
+ /**
13
+ * @deprecated All navigations use transitions under the hood now
14
+ **/
15
+ startTransition?: boolean;
16
+ ignoreBlocker?: boolean;
17
+ }
18
+ type NavigateFn = <TRouter extends RegisteredRouter, TTo extends string | undefined, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = ''>(opts: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<void>;
19
+ type BuildLocationFn = <TRouter extends RegisteredRouter, TTo extends string | undefined, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = ''>(opts: ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {
20
+ leaveParams?: boolean;
21
+ _includeValidateSearch?: boolean;
22
+ _isNavigate?: boolean;
23
+ }) => ParsedLocation;
24
+ //#endregion
25
+ export { BuildLocationFn, CommitLocationOptions, NavigateFn };
@@ -0,0 +1,20 @@
1
+ import { AnyContext, AnyPathParams, AnyRoute, UpdatableRouteOptions } from "./route.js";
2
+ import { AnyValidator } from "./validators.js";
3
+ //#region ../../node_modules/.pnpm/@tanstack+router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/fileRoute.d.ts
4
+ interface FileRouteTypes {
5
+ fileRoutesByFullPath: any;
6
+ fullPaths: any;
7
+ to: any;
8
+ fileRoutesByTo: any;
9
+ id: any;
10
+ fileRoutesById: any;
11
+ }
12
+ type InferFileRouteTypes<TRouteTree extends AnyRoute> = unknown extends TRouteTree['types']['fileRouteTypes'] ? never : TRouteTree['types']['fileRouteTypes'] extends FileRouteTypes ? TRouteTree['types']['fileRouteTypes'] : never;
13
+ type LazyRouteOptions = Pick<UpdatableRouteOptions<AnyRoute, string, string, AnyPathParams, AnyValidator, {}, AnyContext, AnyContext, AnyContext, AnyContext>, 'component' | 'errorComponent' | 'pendingComponent' | 'notFoundComponent'>;
14
+ interface LazyRoute<in out TRoute extends AnyRoute> {
15
+ options: {
16
+ id: string;
17
+ } & LazyRouteOptions;
18
+ }
19
+ //#endregion
20
+ export { FileRouteTypes, InferFileRouteTypes, LazyRoute, LazyRouteOptions };
@@ -0,0 +1,8 @@
1
+ import { AnyRouter } from "./router.js";
2
+
3
+ //#region ../../node_modules/.pnpm/@tanstack+router-core@1.168.14/node_modules/@tanstack/router-core/dist/esm/global.d.ts
4
+ declare global {
5
+ interface Window {
6
+ __TSR_ROUTER__?: AnyRouter;
7
+ }
8
+ }