veryfront 0.1.45 → 0.1.47

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 (75) hide show
  1. package/esm/deno.d.ts +0 -2
  2. package/esm/deno.js +3 -5
  3. package/esm/src/modules/server/module-server.d.ts.map +1 -1
  4. package/esm/src/modules/server/module-server.js +4 -1
  5. package/esm/src/platform/adapters/fs/veryfront/content-metrics.js +1 -1
  6. package/esm/src/platform/adapters/fs/veryfront/read-operations.js +2 -2
  7. package/esm/src/platform/adapters/fs/veryfront/websocket-manager.js +1 -1
  8. package/esm/src/platform/compat/dynamic-import.d.ts +11 -0
  9. package/esm/src/platform/compat/dynamic-import.d.ts.map +1 -0
  10. package/esm/src/platform/compat/dynamic-import.js +11 -0
  11. package/esm/src/platform/compat/opaque-deps.d.ts +21 -0
  12. package/esm/src/platform/compat/opaque-deps.d.ts.map +1 -0
  13. package/esm/src/platform/compat/opaque-deps.js +29 -0
  14. package/esm/src/platform/compat/process.d.ts.map +1 -1
  15. package/esm/src/platform/compat/process.js +1 -3
  16. package/esm/src/provider/local/local-engine.d.ts.map +1 -1
  17. package/esm/src/provider/local/local-engine.js +2 -1
  18. package/esm/src/proxy/handler.d.ts.map +1 -1
  19. package/esm/src/proxy/handler.js +61 -15
  20. package/esm/src/rendering/component-handling.d.ts.map +1 -1
  21. package/esm/src/rendering/component-handling.js +4 -1
  22. package/esm/src/rendering/page-rendering.d.ts.map +1 -1
  23. package/esm/src/rendering/page-rendering.js +2 -2
  24. package/esm/src/server/bootstrap.d.ts.map +1 -1
  25. package/esm/src/server/bootstrap.js +2 -1
  26. package/esm/src/transforms/md/compiler/md-compiler.d.ts +1 -1
  27. package/esm/src/transforms/md/compiler/md-compiler.d.ts.map +1 -1
  28. package/esm/src/transforms/md/compiler/md-compiler.js +10 -5
  29. package/esm/src/transforms/mdx/compiler/index.d.ts +1 -1
  30. package/esm/src/transforms/mdx/compiler/index.d.ts.map +1 -1
  31. package/esm/src/transforms/mdx/compiler/index.js +3 -3
  32. package/esm/src/transforms/mdx/compiler/mdx-compiler.d.ts +1 -1
  33. package/esm/src/transforms/mdx/compiler/mdx-compiler.d.ts.map +1 -1
  34. package/esm/src/transforms/mdx/compiler/mdx-compiler.js +5 -1
  35. package/esm/src/transforms/plugins/babel-node-positions.d.ts +1 -1
  36. package/esm/src/transforms/plugins/babel-node-positions.d.ts.map +1 -1
  37. package/esm/src/transforms/plugins/babel-node-positions.js +4 -5
  38. package/esm/src/transforms/plugins/rehype-node-positions.d.ts +19 -0
  39. package/esm/src/transforms/plugins/rehype-node-positions.d.ts.map +1 -0
  40. package/esm/src/transforms/plugins/rehype-node-positions.js +44 -0
  41. package/esm/src/utils/index.d.ts +1 -1
  42. package/esm/src/utils/index.d.ts.map +1 -1
  43. package/esm/src/utils/index.js +1 -1
  44. package/esm/src/utils/logger/index.d.ts +1 -1
  45. package/esm/src/utils/logger/index.d.ts.map +1 -1
  46. package/esm/src/utils/logger/index.js +1 -1
  47. package/esm/src/utils/logger/logger.d.ts +10 -9
  48. package/esm/src/utils/logger/logger.d.ts.map +1 -1
  49. package/esm/src/utils/logger/logger.js +47 -59
  50. package/esm/src/workflow/claude-code/agent.d.ts +8 -0
  51. package/esm/src/workflow/claude-code/agent.d.ts.map +1 -1
  52. package/esm/src/workflow/claude-code/agent.js +5 -4
  53. package/package.json +1 -3
  54. package/src/deno.js +3 -5
  55. package/src/src/modules/server/module-server.ts +4 -1
  56. package/src/src/platform/adapters/fs/veryfront/content-metrics.ts +1 -1
  57. package/src/src/platform/adapters/fs/veryfront/read-operations.ts +2 -2
  58. package/src/src/platform/adapters/fs/veryfront/websocket-manager.ts +1 -1
  59. package/src/src/platform/compat/dynamic-import.ts +14 -0
  60. package/src/src/platform/compat/opaque-deps.ts +33 -0
  61. package/src/src/platform/compat/process.ts +1 -6
  62. package/src/src/provider/local/local-engine.ts +2 -1
  63. package/src/src/proxy/handler.ts +90 -17
  64. package/src/src/rendering/component-handling.ts +4 -1
  65. package/src/src/rendering/page-rendering.ts +4 -0
  66. package/src/src/server/bootstrap.ts +2 -1
  67. package/src/src/transforms/md/compiler/md-compiler.ts +11 -4
  68. package/src/src/transforms/mdx/compiler/index.ts +12 -1
  69. package/src/src/transforms/mdx/compiler/mdx-compiler.ts +6 -0
  70. package/src/src/transforms/plugins/babel-node-positions.ts +7 -15
  71. package/src/src/transforms/plugins/rehype-node-positions.ts +66 -0
  72. package/src/src/utils/index.ts +1 -0
  73. package/src/src/utils/logger/index.ts +1 -0
  74. package/src/src/utils/logger/logger.ts +54 -69
  75. package/src/src/workflow/claude-code/agent.ts +5 -5
package/esm/deno.d.ts CHANGED
@@ -229,7 +229,6 @@ declare namespace _default {
229
229
  "@ai-sdk/openai": string;
230
230
  "@ai-sdk/anthropic": string;
231
231
  "@ai-sdk/google": string;
232
- "@anthropic-ai/claude-agent-sdk": string;
233
232
  tailwindcss: string;
234
233
  "tailwindcss/plugin": string;
235
234
  "tailwindcss/defaultTheme": string;
@@ -247,7 +246,6 @@ declare namespace _default {
247
246
  "@babel/traverse": string;
248
247
  "@babel/generator": string;
249
248
  "@babel/types": string;
250
- "@huggingface/transformers": string;
251
249
  };
252
250
  namespace compilerOptions {
253
251
  let jsx: string;
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.45",
3
+ "version": "0.1.47",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "exclude": [
@@ -239,7 +239,6 @@ export default {
239
239
  "@ai-sdk/openai": "npm:@ai-sdk/openai@3.0.28",
240
240
  "@ai-sdk/anthropic": "npm:@ai-sdk/anthropic@3.0.43",
241
241
  "@ai-sdk/google": "npm:@ai-sdk/google@3.0.29",
242
- "@anthropic-ai/claude-agent-sdk": "npm:@anthropic-ai/claude-agent-sdk@0.2.37",
243
242
  "tailwindcss": "https://esm.sh/tailwindcss@4.1.8",
244
243
  "tailwindcss/plugin": "https://esm.sh/tailwindcss@4.1.8/plugin",
245
244
  "tailwindcss/defaultTheme": "https://esm.sh/tailwindcss@4.1.8/defaultTheme",
@@ -256,8 +255,7 @@ export default {
256
255
  "@babel/parser": "npm:@babel/parser@7.26.3",
257
256
  "@babel/traverse": "npm:@babel/traverse@7.26.3",
258
257
  "@babel/generator": "npm:@babel/generator@7.26.3",
259
- "@babel/types": "npm:@babel/types@7.26.3",
260
- "@huggingface/transformers": "npm:@huggingface/transformers@3.4.2"
258
+ "@babel/types": "npm:@babel/types@7.26.3"
261
259
  },
262
260
  "compilerOptions": {
263
261
  "jsx": "react-jsx",
@@ -391,7 +389,7 @@ export default {
391
389
  "allowScripts": {
392
390
  "allow": [
393
391
  "npm:sharp@0.33.5",
394
- "npm:onnxruntime-node@1.20.1"
392
+ "npm:onnxruntime-node@1.21.0"
395
393
  ],
396
394
  "deny": [
397
395
  "npm:esbuild@0.20.2",
@@ -1 +1 @@
1
- {"version":3,"file":"module-server.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAIlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAmBtE;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAkDrD,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CAuB/D;AASD,MAAM,WAAW,mBAAmB;IAClC,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB,uBAAuB;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAiTzG;AAmND;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,GAAG,OAAO,CAG7D"}
1
+ {"version":3,"file":"module-server.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAIlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAmBtE;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAkDrD,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CAuB/D;AASD,MAAM,WAAW,mBAAmB;IAClC,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB,uBAAuB;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAoTzG;AAmND;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,GAAG,OAAO,CAG7D"}
@@ -301,7 +301,10 @@ export function serveModule(req, options) {
301
301
  const studioEmbed = url.searchParams.get("studio_embed") === "true";
302
302
  const isJsxFile = /\.(tsx|jsx)$/i.test(sourceFile);
303
303
  if (studioEmbed && !isFrameworkFile && isJsxFile) {
304
- source = injectNodePositions(source, { filePath: sourceFile });
304
+ const relativeFilePath = sourceFile.startsWith(projectDir)
305
+ ? sourceFile.slice(projectDir.length).replace(/^\/+/, "")
306
+ : sourceFile;
307
+ source = injectNodePositions(source, { filePath: relativeFilePath });
305
308
  }
306
309
  logger.debug("SSR mode check", {
307
310
  isSSR,
@@ -61,7 +61,7 @@ export function endRequestMetrics(requestContext) {
61
61
  cumulativeMetrics.totalNetworkMs += req.networkMs;
62
62
  cumulativeMetrics.requestsTracked++;
63
63
  recordContentNetworkFetch(req.networkMs, req.isPreviewMode ?? false);
64
- logger.info("REQUEST_SUMMARY", {
64
+ logger.debug("REQUEST_SUMMARY", {
65
65
  ...requestContext,
66
66
  durationMs,
67
67
  networkMs: req.networkMs,
@@ -400,13 +400,13 @@ export class ReadOperations {
400
400
  return null;
401
401
  }
402
402
  async fetchDraftContent(normalizedPath, apiPath, cacheKey, shouldCache) {
403
- logger.info("API_FETCH_START - fetching draft from API", {
403
+ logger.debug("API_FETCH_START - fetching draft from API", {
404
404
  path: normalizedPath,
405
405
  apiPath,
406
406
  cacheKey,
407
407
  });
408
408
  const content = await this.client.getFileContent(apiPath);
409
- logger.info("API_FETCH_DONE - got content from API", {
409
+ logger.debug("API_FETCH_DONE - got content from API", {
410
410
  path: normalizedPath,
411
411
  contentLength: content.length,
412
412
  preview: previewText(content).replace(/\n/g, "\\n"),
@@ -70,7 +70,7 @@ export class WebSocketManager {
70
70
  };
71
71
  this.ws.onmessage = (event) => {
72
72
  this.wsLastPong = Date.now();
73
- logger.info("WebSocket message received:", { data: event.data });
73
+ logger.debug("WebSocket message received:", { data: event.data });
74
74
  this.handlePokeMessage(event);
75
75
  };
76
76
  this.ws.onclose = () => {
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Opaque dynamic import helper.
3
+ *
4
+ * Uses `new Function` to hide the `import()` call from static analysis
5
+ * by bundlers and `deno compile`, preventing them from tracing into
6
+ * the imported specifier.
7
+ *
8
+ * @module platform/compat
9
+ */
10
+ export declare const dynamicImport: <T = any>(specifier: string) => Promise<T>;
11
+ //# sourceMappingURL=dynamic-import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamic-import.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/dynamic-import.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,eAAO,MAAM,aAAa,EAA4D,CAAC,CAAC,GAAG,GAAG,EAC5F,SAAS,EAAE,MAAM,KACd,OAAO,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Opaque dynamic import helper.
3
+ *
4
+ * Uses `new Function` to hide the `import()` call from static analysis
5
+ * by bundlers and `deno compile`, preventing them from tracing into
6
+ * the imported specifier.
7
+ *
8
+ * @module platform/compat
9
+ */
10
+ // deno-lint-ignore no-explicit-any
11
+ export const dynamicImport = new Function("specifier", "return import(specifier)");
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Opaque dynamic imports for heavy optional dependencies.
3
+ *
4
+ * These packages are excluded from the deno.json import map to prevent
5
+ * `deno compile` from bundling them into the binary. The `new Function`
6
+ * pattern makes the import invisible to static analysis so `deno compile`
7
+ * won't trace it.
8
+ *
9
+ * - Deno: resolves via `npm:` specifiers at runtime
10
+ * - Node/Bun: resolves via bare package names from node_modules
11
+ * - Compiled binary: fails (callers must handle the error)
12
+ *
13
+ * Update versions here when upgrading these packages.
14
+ *
15
+ * @module platform/compat
16
+ */
17
+ /** Lazily import `@huggingface/transformers` (+ onnxruntime, ~500MB). */
18
+ export declare function importTransformers(): Promise<any>;
19
+ /** Lazily import `@anthropic-ai/claude-agent-sdk` (~69MB). */
20
+ export declare function importClaudeAgentSDK(): Promise<any>;
21
+ //# sourceMappingURL=opaque-deps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opaque-deps.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/opaque-deps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,yEAAyE;AACzE,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,CAEjD;AAED,8DAA8D;AAC9D,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,GAAG,CAAC,CAEnD"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Opaque dynamic imports for heavy optional dependencies.
3
+ *
4
+ * These packages are excluded from the deno.json import map to prevent
5
+ * `deno compile` from bundling them into the binary. The `new Function`
6
+ * pattern makes the import invisible to static analysis so `deno compile`
7
+ * won't trace it.
8
+ *
9
+ * - Deno: resolves via `npm:` specifiers at runtime
10
+ * - Node/Bun: resolves via bare package names from node_modules
11
+ * - Compiled binary: fails (callers must handle the error)
12
+ *
13
+ * Update versions here when upgrading these packages.
14
+ *
15
+ * @module platform/compat
16
+ */
17
+ import { isDeno } from "./runtime.js";
18
+ import { dynamicImport } from "./dynamic-import.js";
19
+ function resolve(pkg, version) {
20
+ return isDeno ? `npm:${pkg}@${version}` : pkg;
21
+ }
22
+ /** Lazily import `@huggingface/transformers` (+ onnxruntime, ~500MB). */
23
+ export function importTransformers() {
24
+ return dynamicImport(resolve("@huggingface/transformers", "3.4.2"));
25
+ }
26
+ /** Lazily import `@anthropic-ai/claude-agent-sdk` (~69MB). */
27
+ export function importClaudeAgentSDK() {
28
+ return dynamicImport(resolve("@anthropic-ai/claude-agent-sdk", "0.2.37"));
29
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAmBlD,6EAA6E;AAC7E,wBAAgB,OAAO,IAAI,MAAM,EAAE,CAIlC;AAED,yFAAyF;AACzF,wBAAgB,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,CAIzC;AAED,wBAAgB,GAAG,IAAI,MAAM,CAI5B;AAED,wBAAgB,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAU7C;AAED,wBAAgB,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAI5C;AAqCD,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAatD;AAKD,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAUD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAC9D,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;AAOpE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAC9D,wBAA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,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAaxE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG1D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,IAAI,CAkBjD;AAMD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,gDAAgD;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sEAAsE;IACtE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAwBD;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CA6HxB"}
@@ -1,10 +1,8 @@
1
1
  import * as dntShim from "../../../_dnt.shims.js";
2
2
  import { isBun as IS_BUN, isDeno as IS_DENO } from "./runtime.js";
3
+ import { dynamicImport } from "./dynamic-import.js";
3
4
  const nodeProcess = dntShim.dntGlobalThis.process;
4
5
  const hasNodeProcess = !!nodeProcess?.versions?.node;
5
- // Dynamic import helper to avoid static analysis by bundlers
6
- // This prevents Bun from trying to resolve node:child_process at compile time
7
- const dynamicImport = new Function("specifier", "return import(specifier)");
8
6
  function isWindowsPlatform() {
9
7
  if (IS_DENO)
10
8
  return dntShim.Deno.build.os === "windows";
@@ -1 +1 @@
1
- {"version":3,"file":"local-engine.d.ts","sourceRoot":"","sources":["../../../../src/src/provider/local/local-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,kCAAkC;AAClC,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AA6HD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGxE;AAED;;;;GAIG;AACH,wBAAuB,cAAc,CACnC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,GAAE,eAAoB,GAC5B,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,CAoEzC;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAMjB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGjE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGtD"}
1
+ {"version":3,"file":"local-engine.d.ts","sourceRoot":"","sources":["../../../../src/src/provider/local/local-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,kCAAkC;AAClC,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AA6HD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGxE;AAED;;;;GAIG;AACH,wBAAuB,cAAc,CACnC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,GAAE,eAAoB,GAC5B,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,CAoEzC;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAMjB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGjE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGtD"}
@@ -12,6 +12,7 @@
12
12
  */
13
13
  import { serverLogger } from "../../utils/index.js";
14
14
  import { createError, toError } from "../../errors/veryfront-error.js";
15
+ import { importTransformers } from "../../platform/compat/opaque-deps.js";
15
16
  import { DEFAULT_LOCAL_MODEL, resolveLocalModel } from "./model-catalog.js";
16
17
  import { isLocalAIDisabled } from "./env.js";
17
18
  const logger = serverLogger.component("local-llm");
@@ -36,7 +37,7 @@ async function getTransformers() {
36
37
  }
37
38
  logger.info("Loading @huggingface/transformers...");
38
39
  try {
39
- transformersModule = await import("@huggingface/transformers");
40
+ transformersModule = await importTransformers();
40
41
  }
41
42
  catch {
42
43
  throw toError(createError({
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/src/proxy/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,kCAAkC,CAAC;AACzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAOnD,eAAO,MAAM,sBAAsB,0MAYzB,CAAC;AA4EX,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,SAAS,GAAG,YAAY,CAAC;IACtC,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,YAAY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? decodeURIComponent(match[1]) : undefined;
71
71
  }
72
+ function extractUserIdFromToken(token) {
73
+ try {
74
+ const payload = token.split(".")[1];
75
+ if (!payload)
76
+ return undefined;
77
+ // JWT payloads are base64url-encoded: normalize to standard base64 before decoding
78
+ let base64 = payload.replace(/-/g, "+").replace(/_/g, "/");
79
+ const remainder = base64.length % 4;
80
+ if (remainder === 2)
81
+ base64 += "==";
82
+ else if (remainder === 3)
83
+ base64 += "=";
84
+ const decoded = JSON.parse(atob(base64));
85
+ return decoded?.userId;
86
+ }
87
+ catch {
88
+ return undefined;
89
+ }
90
+ }
91
+ function isProjectMember(users, userId) {
92
+ if (!users || !userId)
93
+ return false;
94
+ return users.some((u) => u.id === userId);
95
+ }
72
96
  export function createProxyHandler(options) {
73
97
  const { config, cache, logger } = options;
74
98
  const localProjects = config.localProjects ?? {};
@@ -145,20 +169,47 @@ export function createProxyHandler(options) {
145
169
  const returnPath = safePath + url.search;
146
170
  return `https://veryfront.com/sign-in?from=${encodeURIComponent(returnPath)}`;
147
171
  }
148
- async function resolveReleaseAndProtection(req, token, userToken, lookupKey, envMatcher, logContext) {
149
- const lookupResult = await lookupProjectByDomain(lookupKey, config.apiBaseUrl, token, logger);
150
- if (!lookupResult)
151
- return { projectId: undefined, releaseId: undefined };
152
- const matchingEnv = lookupResult.environments?.find(envMatcher);
153
- if (matchingEnv?.protected && !userToken) {
172
+ function checkProtectedAccess(req, matchingEnv, userToken, users, logContext) {
173
+ if (!matchingEnv?.protected)
174
+ return null;
175
+ if (!userToken) {
154
176
  const redirectUrl = makeAuthRedirectUrl(req);
155
177
  logger?.info("Protected environment requires authentication", {
156
178
  ...logContext,
157
179
  environmentName: matchingEnv.name,
158
180
  redirectUrl,
159
181
  });
160
- return { error: { status: 302, message: "Authentication required", redirectUrl } };
182
+ return { status: 302, message: "Authentication required", redirectUrl };
183
+ }
184
+ const userId = extractUserIdFromToken(userToken);
185
+ if (!userId) {
186
+ // Malformed token — treat as unauthenticated so user can re-sign-in
187
+ const redirectUrl = makeAuthRedirectUrl(req);
188
+ logger?.info("Could not extract userId from token", {
189
+ ...logContext,
190
+ environmentName: matchingEnv.name,
191
+ redirectUrl,
192
+ });
193
+ return { status: 302, message: "Authentication required", redirectUrl };
194
+ }
195
+ if (!isProjectMember(users, userId)) {
196
+ logger?.info("User is not a member of the project", {
197
+ ...logContext,
198
+ environmentName: matchingEnv.name,
199
+ userId,
200
+ });
201
+ return { status: 403, message: "Access denied" };
161
202
  }
203
+ return null;
204
+ }
205
+ async function resolveReleaseAndProtection(req, token, userToken, lookupKey, envMatcher, logContext) {
206
+ const lookupResult = await lookupProjectByDomain(lookupKey, config.apiBaseUrl, token, logger);
207
+ if (!lookupResult)
208
+ return { projectId: undefined, releaseId: undefined };
209
+ const matchingEnv = lookupResult.environments?.find(envMatcher);
210
+ const protectionError = checkProtectedAccess(req, matchingEnv, userToken, lookupResult.users, logContext);
211
+ if (protectionError)
212
+ return { error: protectionError };
162
213
  return {
163
214
  projectId: lookupResult.id,
164
215
  releaseId: matchingEnv?.active_release_id ?? undefined,
@@ -240,14 +291,9 @@ export function createProxyHandler(options) {
240
291
  const matchingEnv = lookupResult.environments?.find((env) => env.domains?.some((d) => d.toLowerCase() === normalizedHost));
241
292
  releaseId = matchingEnv?.active_release_id ?? undefined;
242
293
  environmentId = matchingEnv?.id;
243
- if (matchingEnv?.protected && !userToken) {
244
- const redirectUrl = makeAuthRedirectUrl(req);
245
- logger?.info("Protected environment requires authentication", {
246
- domain: host,
247
- environmentName: matchingEnv.name,
248
- redirectUrl,
249
- });
250
- return makeErrorContext(base, 302, "Authentication required", token, redirectUrl);
294
+ const protectionError = checkProtectedAccess(req, matchingEnv, userToken, lookupResult.users, { domain: host });
295
+ if (protectionError) {
296
+ return makeErrorContext(base, protectionError.status, protectionError.message, token, protectionError.redirectUrl);
251
297
  }
252
298
  logger?.info("Resolved custom domain to project", {
253
299
  domain: host,
@@ -1 +1 @@
1
- {"version":3,"file":"component-handling.d.ts","sourceRoot":"","sources":["../../../src/src/rendering/component-handling.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,KAAK,YAAY,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQhE,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,YAAY,CAAC,YAAY,CAAC;IACvC,UAAU,EAAE,UAAU,CAAC;CACxB;AAgBD;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,kBAAkB,EAAE,OAAO,EAC3B,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE;IACR,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GACA,OAAO,CAAC,mBAAmB,CAAC,CAsE9B"}
1
+ {"version":3,"file":"component-handling.d.ts","sourceRoot":"","sources":["../../../src/src/rendering/component-handling.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,KAAK,YAAY,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQhE,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,YAAY,CAAC,YAAY,CAAC;IACvC,UAAU,EAAE,UAAU,CAAC;CACxB;AAgBD;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,kBAAkB,EAAE,OAAO,EAC3B,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE;IACR,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GACA,OAAO,CAAC,mBAAmB,CAAC,CAyE9B"}
@@ -28,8 +28,11 @@ export async function handleComponentPage(pageInfo, slug, projectDir, _component
28
28
  try {
29
29
  logger.debug(`Loading TSX/JSX file: ${pageInfo.entity.path}`);
30
30
  const rawFileContent = await adapter.fs.readFile(pageInfo.entity.path);
31
+ const normalizedPath = pageInfo.entity.path.startsWith(projectDir)
32
+ ? pageInfo.entity.path.slice(projectDir.length).replace(/^\/+/, "")
33
+ : pageInfo.entity.path;
31
34
  const fileContent = options?.studioEmbed
32
- ? injectNodePositions(rawFileContent, { filePath: pageInfo.entity.path })
35
+ ? injectNodePositions(rawFileContent, { filePath: normalizedPath })
33
36
  : rawFileContent;
34
37
  const clientModuleCode = options?.cachedClientModule ??
35
38
  (await bundleComponentForClient(fileContent, pageInfo.entity.path, projectDir, adapter, options?.moduleServerUrl, options?.projectId, options?.reactVersion));
@@ -1 +1 @@
1
- {"version":3,"file":"page-rendering.d.ts","sourceRoot":"","sources":["../../../src/src/rendering/page-rendering.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,YAAY,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAa,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAOrG,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,YAAY,CAAC,YAAY,CAAC;IACvC,UAAU,EAAE,UAAU,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,aAAa,EAC/B,WAAW,EAAE,CACX,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,CAAC,EAAE,MAAM,KACd,OAAO,CAAC,SAAS,CAAC,EACvB,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC3C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GACA,OAAO,CAAC,aAAa,CAAC,CA2GxB"}
1
+ {"version":3,"file":"page-rendering.d.ts","sourceRoot":"","sources":["../../../src/src/rendering/page-rendering.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,YAAY,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAa,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAOrG,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,YAAY,CAAC,YAAY,CAAC;IACvC,UAAU,EAAE,UAAU,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,aAAa,EAC/B,WAAW,EAAE,CACX,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,CAAC,EAAE,MAAM,KACd,OAAO,CAAC,SAAS,CAAC,EACvB,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC3C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GACA,OAAO,CAAC,aAAa,CAAC,CA+GxB"}
@@ -9,7 +9,7 @@ export function handleMDXPage(pageInfo, slug, projectDir, mergedComponents, _com
9
9
  return withSpan("rendering.handleMDXPage", async () => {
10
10
  const { frontmatter, content, path } = pageInfo.entity;
11
11
  const fmArg = frontmatter && Object.keys(frontmatter).length > 0 ? frontmatter : undefined;
12
- const ssrBundle = await compileContent("development", projectDir, content, fmArg, path, "server");
12
+ const ssrBundle = await compileContent("development", projectDir, content, fmArg, path, "server", undefined, options?.studioEmbed);
13
13
  const pageBundle = ssrBundle;
14
14
  let collectedMetadata = {};
15
15
  try {
@@ -17,7 +17,7 @@ export function handleMDXPage(pageInfo, slug, projectDir, mergedComponents, _com
17
17
  pageBundle.clientModuleCode = options.precompiledModule;
18
18
  }
19
19
  else {
20
- const browserBundle = await compileContent("development", projectDir, content, fmArg, path, "browser");
20
+ const browserBundle = await compileContent("development", projectDir, content, fmArg, path, "browser", undefined, options?.studioEmbed);
21
21
  pageBundle.clientModuleCode = browserBundle.compiledCode;
22
22
  }
23
23
  const clientModuleCode = pageBundle.clientModuleCode;
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../src/src/server/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AA4B1D,MAAM,WAAW,eAAe;IAC9B,8DAA8D;IAC9D,OAAO,EAAE,cAAc,CAAC;IAExB,2BAA2B;IAC3B,MAAM,EAAE,eAAe,CAAC;IAExB,wCAAwC;IACxC,cAAc,EAAE,OAAO,CAAC;IAExB,+BAA+B;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAkDD,wBAAsB,SAAS,CAC7B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,eAAe,CAAC,CAqG1B;AAED,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,eAAe,CAAC,CAa1B;AAED,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,eAAe,CAAC,CAyB1B"}
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../src/src/server/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AA4B1D,MAAM,WAAW,eAAe;IAC9B,8DAA8D;IAC9D,OAAO,EAAE,cAAc,CAAC;IAExB,2BAA2B;IAC3B,MAAM,EAAE,eAAe,CAAC;IAExB,wCAAwC;IACxC,cAAc,EAAE,OAAO,CAAC;IAExB,+BAA+B;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAmDD,wBAAsB,SAAS,CAC7B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,eAAe,CAAC,CAqG1B;AAED,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,eAAe,CAAC,CAa1B;AAED,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,eAAe,CAAC,CAyB1B"}
@@ -5,7 +5,7 @@ import { enhanceAdapterWithFS } from "../platform/adapters/fs/integration.js";
5
5
  import { isExtendedFSAdapter } from "../platform/adapters/fs/wrapper.js";
6
6
  import { getEnv } from "../platform/compat/process.js";
7
7
  import { initializeEsbuild } from "../platform/compat/esbuild.js";
8
- import { logger } from "../utils/index.js";
8
+ import { logger, refreshLoggerConfig } from "../utils/index.js";
9
9
  import { isDebugEnabled } from "../utils/constants/env.js";
10
10
  import { getEnvSource, hasEnvLoaded, loadEnv, markEnvLoaded, supportsEnvFiles, } from "../utils/env-loader.js";
11
11
  import { ReloadNotifier } from "./reload-notifier.js";
@@ -26,6 +26,7 @@ async function ensureEnvLoaded(projectDir, adapter) {
26
26
  debug: isDebugEnabled(adapter.env),
27
27
  });
28
28
  refreshEnvironmentConfig();
29
+ refreshLoggerConfig();
29
30
  }
30
31
  catch (error) {
31
32
  bootstrapLog.warn("Failed to load .env files", {
@@ -1,3 +1,3 @@
1
1
  import type { CompilationMode, CompilationTarget, MdxRuntimeBundle } from "../../mdx/compiler/types.js";
2
- export declare function compileMarkdownRuntime(_mode: CompilationMode, _projectDir: string, content: string, frontmatter?: Record<string, unknown>, filePath?: string, _target?: CompilationTarget, _baseUrl?: string): Promise<MdxRuntimeBundle>;
2
+ export declare function compileMarkdownRuntime(_mode: CompilationMode, _projectDir: string, content: string, frontmatter?: Record<string, unknown>, filePath?: string, _target?: CompilationTarget, _baseUrl?: string, studioEmbed?: boolean): Promise<MdxRuntimeBundle>;
3
3
  //# sourceMappingURL=md-compiler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"md-compiler.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/md/compiler/md-compiler.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAoDrC,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,eAAe,EACtB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,GAAE,iBAA4B,EACrC,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,gBAAgB,CAAC,CAsE3B"}
1
+ {"version":3,"file":"md-compiler.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/md/compiler/md-compiler.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAoDrC,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,eAAe,EACtB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,GAAE,iBAA4B,EACrC,QAAQ,CAAC,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,gBAAgB,CAAC,CA2E3B"}
@@ -9,6 +9,7 @@ import rehypeStringify from "rehype-stringify";
9
9
  import { visit } from "unist-util-visit";
10
10
  import { toString } from "mdast-util-to-string";
11
11
  import { rendererLogger } from "../../../utils/index.js";
12
+ import { rehypeNodePositions } from "../../plugins/rehype-node-positions.js";
12
13
  import { extractFrontmatter } from "../../mdx/compiler/frontmatter-extractor.js";
13
14
  import { isMarkdownPreview as checkMarkdownPreview } from "../utils.js";
14
15
  import { createError, toError } from "../../../errors/veryfront-error.js";
@@ -48,21 +49,25 @@ export default function MDContent({ components, params, className, ...props }) {
48
49
  }
49
50
  `;
50
51
  }
51
- export function compileMarkdownRuntime(_mode, _projectDir, content, frontmatter, filePath, _target = "server", _baseUrl) {
52
+ export function compileMarkdownRuntime(_mode, _projectDir, content, frontmatter, filePath, _target = "server", _baseUrl, studioEmbed) {
52
53
  return withSpan("transforms.compileMarkdownRuntime", async () => {
53
54
  try {
54
55
  const { body, frontmatter: extractedFrontmatter } = extractFrontmatter(content, frontmatter);
55
56
  const headings = [];
56
- const processor = unified()
57
+ const pipeline = unified()
57
58
  .use(remarkParse)
58
59
  .use(remarkGfm)
59
60
  .use(remarkFrontmatter)
60
61
  .use(remarkExtractHeadings, headings)
61
62
  .use(remarkRehype, { allowDangerousHtml: true })
62
63
  .use(rehypeStarryNight)
63
- .use(rehypeSlug)
64
- .use(rehypeStringify, { allowDangerousHtml: true });
65
- const result = await processor.process(body);
64
+ .use(rehypeSlug);
65
+ if (studioEmbed && filePath) {
66
+ pipeline.use(rehypeNodePositions, { filePath });
67
+ }
68
+ const result = await pipeline
69
+ .use(rehypeStringify, { allowDangerousHtml: true })
70
+ .process(body);
66
71
  const html = String(result);
67
72
  logger.debug("Compiled markdown:", {
68
73
  filePath,
@@ -10,5 +10,5 @@ export type { CompilationMode, CompilationTarget, MdxRuntimeBundle } from "./typ
10
10
  export type { FrontmatterExtractionResult } from "./frontmatter-extractor.js";
11
11
  export type { ImportRewriterConfig } from "./import-rewriter.js";
12
12
  import type { CompilationMode, CompilationTarget, MdxRuntimeBundle } from "./types.js";
13
- export declare function compileContent(mode: CompilationMode, projectDir: string, content: string, frontmatter?: Record<string, unknown>, filePath?: string, target?: CompilationTarget, baseUrl?: string): Promise<MdxRuntimeBundle>;
13
+ export declare function compileContent(mode: CompilationMode, projectDir: string, content: string, frontmatter?: Record<string, unknown>, filePath?: string, target?: CompilationTarget, baseUrl?: string, studioEmbed?: boolean): Promise<MdxRuntimeBundle>;
14
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/compiler/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAClF,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACvF,YAAY,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAC9E,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAIjE,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMvF,wBAAgB,cAAc,CAC5B,IAAI,EAAE,eAAe,EACrB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,GAAE,iBAA4B,EACpC,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,gBAAgB,CAAC,CAc3B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/compiler/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAClF,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACvF,YAAY,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAC9E,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAIjE,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMvF,wBAAgB,cAAc,CAC5B,IAAI,EAAE,eAAe,EACrB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,GAAE,iBAA4B,EACpC,OAAO,CAAC,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,gBAAgB,CAAC,CAwB3B"}
@@ -11,9 +11,9 @@ import { compileMarkdownRuntime } from "../../md/compiler/index.js";
11
11
  function isMarkdownFile(filePath) {
12
12
  return filePath?.endsWith(".md") ?? false;
13
13
  }
14
- export function compileContent(mode, projectDir, content, frontmatter, filePath, target = "server", baseUrl) {
14
+ export function compileContent(mode, projectDir, content, frontmatter, filePath, target = "server", baseUrl, studioEmbed) {
15
15
  if (isMarkdownFile(filePath)) {
16
- return compileMarkdownRuntime(mode, projectDir, content, frontmatter, filePath, target, baseUrl);
16
+ return compileMarkdownRuntime(mode, projectDir, content, frontmatter, filePath, target, baseUrl, studioEmbed);
17
17
  }
18
- return compileMDXRuntime(mode, projectDir, content, frontmatter, filePath, target, baseUrl);
18
+ return compileMDXRuntime(mode, projectDir, content, frontmatter, filePath, target, baseUrl, studioEmbed);
19
19
  }
@@ -1,3 +1,3 @@
1
1
  import type { CompilationMode, CompilationTarget, MdxRuntimeBundle } from "./types.js";
2
- export declare function compileMDXRuntime(_mode: CompilationMode, projectDir: string, content: string, frontmatter?: Record<string, unknown>, filePath?: string, target?: CompilationTarget, baseUrl?: string): Promise<MdxRuntimeBundle>;
2
+ export declare function compileMDXRuntime(_mode: CompilationMode, projectDir: string, content: string, frontmatter?: Record<string, unknown>, filePath?: string, target?: CompilationTarget, baseUrl?: string, studioEmbed?: boolean): Promise<MdxRuntimeBundle>;
3
3
  //# sourceMappingURL=mdx-compiler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mdx-compiler.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/compiler/mdx-compiler.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAQvF,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,GAAE,iBAA4B,EACpC,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,gBAAgB,CAAC,CAyF3B"}
1
+ {"version":3,"file":"mdx-compiler.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/compiler/mdx-compiler.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAQvF,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,GAAE,iBAA4B,EACpC,OAAO,CAAC,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,gBAAgB,CAAC,CA6F3B"}
@@ -1,16 +1,20 @@
1
1
  import { rendererLogger } from "../../../utils/index.js";
2
2
  import { getRehypePlugins, getRemarkPlugins } from "../../plugins/plugin-loader.js";
3
+ import { rehypeNodePositions } from "../../plugins/rehype-node-positions.js";
3
4
  import { extractFrontmatter } from "./frontmatter-extractor.js";
4
5
  import { rewriteBodyImports, rewriteCompiledImports } from "./import-rewriter.js";
5
6
  import { createError, toError } from "../../../errors/veryfront-error.js";
6
7
  import { withSpan } from "../../../observability/tracing/otlp-setup.js";
7
8
  const logger = rendererLogger.component("mdx-compiler");
8
- export function compileMDXRuntime(_mode, projectDir, content, frontmatter, filePath, target = "server", baseUrl) {
9
+ export function compileMDXRuntime(_mode, projectDir, content, frontmatter, filePath, target = "server", baseUrl, studioEmbed) {
9
10
  return withSpan("transforms.compileMDXRuntime", async () => {
10
11
  try {
11
12
  const { compile } = await import("@mdx-js/mdx");
12
13
  const remarkPlugins = (await getRemarkPlugins());
13
14
  const rehypePlugins = (await getRehypePlugins());
15
+ if (studioEmbed && filePath) {
16
+ rehypePlugins.push([rehypeNodePositions, { filePath }]);
17
+ }
14
18
  const { body: extractedBody, frontmatter: extractedFrontmatter } = extractFrontmatter(content, frontmatter);
15
19
  const shouldRewriteImports = Boolean(filePath) &&
16
20
  (target === "browser" || target === "server");
@@ -11,6 +11,6 @@ interface TransformOptions {
11
11
  * Transform TSX source to inject position data attributes into JSX elements.
12
12
  * This enables Studio Navigator to map rendered elements back to source positions.
13
13
  */
14
- export declare function injectNodePositions(source: string, _options: TransformOptions): string;
14
+ export declare function injectNodePositions(source: string, options: TransformOptions): string;
15
15
  export {};
16
16
  //# sourceMappingURL=babel-node-positions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"babel-node-positions.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/plugins/babel-node-positions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA2EH,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB;AA4CD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,GAAG,MAAM,CA6DtF"}
1
+ {"version":3,"file":"babel-node-positions.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/plugins/babel-node-positions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA2EH,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB;AA4CD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAqDrF"}
@@ -87,9 +87,11 @@ function hasPositionAttribute(attributes) {
87
87
  * Transform TSX source to inject position data attributes into JSX elements.
88
88
  * This enables Studio Navigator to map rendered elements back to source positions.
89
89
  */
90
- export function injectNodePositions(source, _options) {
90
+ export function injectNodePositions(source, options) {
91
91
  if (!source.trim())
92
92
  return source;
93
+ if (!options.filePath)
94
+ return source;
93
95
  try {
94
96
  const ast = parser.parse(source, {
95
97
  sourceType: "module",
@@ -111,10 +113,7 @@ export function injectNodePositions(source, _options) {
111
113
  if (!loc)
112
114
  return;
113
115
  const nodeId = `node-${nodeCounter++}`;
114
- openingElement.attributes.push(t.jsxAttribute(t.jsxIdentifier("data-node-id"), t.stringLiteral(nodeId)), t.jsxAttribute(t.jsxIdentifier("data-node-line"), t.stringLiteral(String(loc.start.line))), t.jsxAttribute(t.jsxIdentifier("data-node-column"), t.stringLiteral(String(loc.start.column))));
115
- if (!loc.end)
116
- return;
117
- openingElement.attributes.push(t.jsxAttribute(t.jsxIdentifier("data-node-end-line"), t.stringLiteral(String(loc.end.line))), t.jsxAttribute(t.jsxIdentifier("data-node-end-column"), t.stringLiteral(String(loc.end.column))));
116
+ openingElement.attributes.push(t.jsxAttribute(t.jsxIdentifier("data-node-id"), t.stringLiteral(nodeId)), t.jsxAttribute(t.jsxIdentifier("data-node-file"), t.stringLiteral(options.filePath)), t.jsxAttribute(t.jsxIdentifier("data-node-name"), t.stringLiteral(elementName)), t.jsxAttribute(t.jsxIdentifier("data-node-line"), t.stringLiteral(String(loc.start.line))), t.jsxAttribute(t.jsxIdentifier("data-node-column"), t.stringLiteral(String(loc.start.column))));
118
117
  },
119
118
  },
120
119
  });