camox 0.6.0 → 0.6.1

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":"definitionsSync.d.ts","sourceRoot":"","sources":["../../../src/features/vite/definitionsSync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAElD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAOjD,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB;AAgBD,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAClD,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwFhB;AASD,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAkLf"}
1
+ {"version":3,"file":"definitionsSync.d.ts","sourceRoot":"","sources":["../../../src/features/vite/definitionsSync.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAA0C,MAAM,MAAM,CAAC;AAE/F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAOjD,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB;AAgBD,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAClD,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwFhB;AAsCD,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAkLf"}
@@ -1,5 +1,6 @@
1
1
  import { createServerApiClient } from "../../lib/api-client-server.js";
2
2
  import path from "node:path";
3
+ import { createServer, isRunnableDevEnvironment } from "vite";
3
4
  //#region src/features/vite/definitionsSync.ts
4
5
  var SYNC_DEBOUNCE_DELAY_MS = 100;
5
6
  /**
@@ -71,12 +72,33 @@ function getBlockIdFromFilePath(filePath) {
71
72
  return path.basename(filePath, path.extname(filePath));
72
73
  }
73
74
  var CAMOX_APP_PATH = "./src/camox/app.ts";
75
+ /**
76
+ * Load a module using SSR. Uses the server's SSR environment runner if available,
77
+ * otherwise falls back to a temporary Vite server (needed when Nitro or other
78
+ * frameworks configure the SSR environment as non-runnable).
79
+ */
80
+ async function ssrLoadModule(server, modulePath) {
81
+ const ssrEnv = server.environments.ssr;
82
+ if (ssrEnv && isRunnableDevEnvironment(ssrEnv)) return ssrEnv.runner.import(modulePath);
83
+ const tempServer = await createServer({
84
+ configFile: false,
85
+ root: server.config.root,
86
+ resolve: server.config.resolve,
87
+ server: { middlewareMode: true },
88
+ logLevel: "silent"
89
+ });
90
+ try {
91
+ return await tempServer.ssrLoadModule(modulePath);
92
+ } finally {
93
+ await tempServer.close();
94
+ }
95
+ }
74
96
  async function syncDefinitions(server, options) {
75
97
  const { projectSlug, syncSecret, apiUrl, environmentName } = options;
76
98
  const blocksDir = path.resolve(server.config.root, "src/camox/blocks");
77
99
  const client = createServerApiClient(apiUrl, environmentName);
78
100
  async function performInitialSync() {
79
- const camoxModule = await server.ssrLoadModule(CAMOX_APP_PATH);
101
+ const camoxModule = await ssrLoadModule(server, CAMOX_APP_PATH);
80
102
  if (!camoxModule.camoxApp) {
81
103
  server.config.logger.warn(`[camox] No camoxApp export found in ${CAMOX_APP_PATH}`, { timestamp: true });
82
104
  return;
@@ -94,7 +116,7 @@ async function syncDefinitions(server, options) {
94
116
  const relativePath = "./" + path.relative(server.config.root, filePath);
95
117
  const moduleNode = server.moduleGraph.getModuleById(relativePath);
96
118
  if (moduleNode) server.moduleGraph.invalidateModule(moduleNode);
97
- const blockModule = await server.ssrLoadModule(relativePath);
119
+ const blockModule = await ssrLoadModule(server, relativePath);
98
120
  if (!blockModule.block) {
99
121
  server.config.logger.warn(`[camox] No block export found in ${relativePath}`, { timestamp: true });
100
122
  return;
@@ -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;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"}
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../src/features/vite/vite.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,MAAM,EAAyD,MAAM,MAAM,CAAC;AAoD1F,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,CAuHzD"}
@@ -7,6 +7,7 @@ import { readFileSync } from "node:fs";
7
7
  import { homedir } from "node:os";
8
8
  import { dirname, join, resolve } from "node:path";
9
9
  import { fileURLToPath } from "node:url";
10
+ import { createServer } from "vite";
10
11
  //#region src/features/vite/vite.ts
11
12
  var sdkRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../../..");
12
13
  var VIRTUAL_STUDIO_CSS = "virtual:camox-studio-css";
@@ -112,7 +113,6 @@ function camox(options) {
112
113
  },
113
114
  async closeBundle() {
114
115
  if (!isBuild) return;
115
- const { createServer } = await import("vite");
116
116
  const camoxAppPath = "./src/camox/app.ts";
117
117
  const tempServer = await createServer({
118
118
  configFile: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camox",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
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.6.0",
102
- "@camox/ui": "0.6.0",
103
- "@camox/cli": "0.6.0"
101
+ "@camox/api": "0.6.1",
102
+ "@camox/cli": "0.6.1",
103
+ "@camox/ui": "0.6.1"
104
104
  },
105
105
  "devDependencies": {
106
106
  "@babel/core": "^7.29.0",