camox 0.5.1 → 0.6.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.
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../src/features/vite/vite.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAiC,MAAM,MAAM,CAAC;AAuClE,MAAM,WAAW,kBAAkB;IACjC,0FAA0F;IAC1F,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,4FAA4F;IAC5F,SAAS,CAAC,EAAE;QACV,2DAA2D;QAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,0EAA0E;QAC1E,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,oDAAoD;QACpD,sBAAsB,CAAC,EAAE,OAAO,CAAC;KAClC,CAAC;CACH;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CA2HzD"}
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../src/features/vite/vite.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAiC,MAAM,MAAM,CAAC;AAoDlE,MAAM,WAAW,kBAAkB;IACjC,0FAA0F;IAC1F,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,4FAA4F;IAC5F,SAAS,CAAC,EAAE;QACV,2DAA2D;QAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,0EAA0E;QAC1E,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,oDAAoD;QACpD,sBAAsB,CAAC,EAAE,OAAO,CAAC;KAClC,CAAC;CACH;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAwHzD"}
@@ -11,19 +11,28 @@ import { fileURLToPath } from "node:url";
11
11
  var sdkRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../../..");
12
12
  var VIRTUAL_STUDIO_CSS = "virtual:camox-studio-css";
13
13
  var RESOLVED_VIRTUAL_STUDIO_CSS = "\0" + VIRTUAL_STUDIO_CSS;
14
+ /**
15
+ * use-sync-external-store is CJS-only and causes issues in ESM environments.
16
+ * Since all Camox apps use React 19+, we can redirect imports to React's built-in
17
+ * useSyncExternalStore instead. This handles all subpaths (e.g. /shim, /shim/index.js).
18
+ */
19
+ var USE_SYNC_EXTERNAL_STORE_RE = /^use-sync-external-store(\/|$)/;
20
+ var RESOLVED_USE_SYNC_SHIM = "\0use-sync-external-store-shim";
21
+ var USE_SYNC_SHIM_CODE = `export { useSyncExternalStore } from "react";\n`;
14
22
  var PRODUCTION_API_URL = "https://api.camox.ai";
15
23
  /** Authentication URL to use for Camox authentication (production Camox web app) */
16
24
  var DEFAULT_AUTHENTICATION_URL = "https://camox.ai";
17
- function resolveEnvironmentName(isDev) {
25
+ function resolveEnvironmentName(isDev, authenticationUrl) {
18
26
  if (!isDev) return "production";
19
27
  const authFile = join(homedir(), ".camox", "auth.json");
28
+ const key = authenticationUrl.replace(/\/+$/, "");
20
29
  let auth;
21
30
  try {
22
- auth = JSON.parse(readFileSync(authFile, "utf-8"));
31
+ auth = JSON.parse(readFileSync(authFile, "utf-8"))[key];
23
32
  } catch {
24
- throw new Error("Camox: not authenticated. Run `camox login` before starting the dev server.\nAuthentication is required so your dev environment is scoped to your user.");
33
+ throw new Error(`Camox: not authenticated for ${key}. Run \`camox login\` before starting the dev server.\nAuthentication is required so your dev environment is scoped to your user.`);
25
34
  }
26
- if (!auth.email) throw new Error("Camox: ~/.camox/auth.json is missing an email. Run `camox login` again.");
35
+ if (!auth?.email) throw new Error(`Camox: no session found for ${key} in ~/.camox/auth.json. Run \`camox login\` again.`);
27
36
  return `${auth.email.split("@")[0]}-dev`;
28
37
  }
29
38
  function camox(options) {
@@ -37,8 +46,10 @@ function camox(options) {
37
46
  name: "camox",
38
47
  resolveId(id) {
39
48
  if (id === VIRTUAL_STUDIO_CSS) return RESOLVED_VIRTUAL_STUDIO_CSS;
49
+ if (USE_SYNC_EXTERNAL_STORE_RE.test(id)) return RESOLVED_USE_SYNC_SHIM;
40
50
  },
41
51
  load(id) {
52
+ if (id === RESOLVED_USE_SYNC_SHIM) return USE_SYNC_SHIM_CODE;
42
53
  if (id !== RESOLVED_VIRTUAL_STUDIO_CSS) return;
43
54
  const cssPath = resolve(sdkRoot, "dist/studio.css");
44
55
  if (isBuild) {
@@ -53,17 +64,14 @@ function camox(options) {
53
64
  },
54
65
  config(_config, env) {
55
66
  isBuild = env.command === "build";
56
- environmentName = resolveEnvironmentName(env.command === "serve");
57
- return {
58
- optimizeDeps: { include: ["use-sync-external-store/shim"] },
59
- define: {
60
- __CAMOX_ANALYTICS_DISABLED__: JSON.stringify(!!options.disableAnalytics),
61
- __ENABLE_TANSTACK_DEVTOOLS__: JSON.stringify(enableTanstackDevtools),
62
- __CAMOX_ENVIRONMENT_NAME__: JSON.stringify(environmentName),
63
- __CAMOX_API_URL__: JSON.stringify(apiUrl),
64
- __CAMOX_PROJECT_SLUG__: JSON.stringify(options.projectSlug)
65
- }
66
- };
67
+ environmentName = resolveEnvironmentName(env.command === "serve", authenticationUrl);
68
+ return { define: {
69
+ __CAMOX_ANALYTICS_DISABLED__: JSON.stringify(!!options.disableAnalytics),
70
+ __ENABLE_TANSTACK_DEVTOOLS__: JSON.stringify(enableTanstackDevtools),
71
+ __CAMOX_ENVIRONMENT_NAME__: JSON.stringify(environmentName),
72
+ __CAMOX_API_URL__: JSON.stringify(apiUrl),
73
+ __CAMOX_PROJECT_SLUG__: JSON.stringify(options.projectSlug)
74
+ } };
67
75
  },
68
76
  configResolved(config) {
69
77
  resolvedConfig = config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camox",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "bin": {
5
5
  "camox": "./bin/camox.mjs"
6
6
  },
@@ -98,9 +98,9 @@
98
98
  "react-dom": "^19.2.5",
99
99
  "react-og-preview": "^0.2.0",
100
100
  "shiki": "^4.0.2",
101
- "@camox/api": "0.5.1",
102
- "@camox/cli": "0.5.1",
103
- "@camox/ui": "0.5.1"
101
+ "@camox/api": "0.6.0",
102
+ "@camox/ui": "0.6.0",
103
+ "@camox/cli": "0.6.0"
104
104
  },
105
105
  "devDependencies": {
106
106
  "@babel/core": "^7.29.0",