veryfront 0.1.984 → 0.1.986

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 (120) hide show
  1. package/LICENSE +16 -4
  2. package/NOTICE +2 -0
  3. package/esm/cli/commands/build/command.js +1 -1
  4. package/esm/cli/commands/build/handler.d.ts.map +1 -1
  5. package/esm/cli/commands/build/handler.js +3 -1
  6. package/esm/cli/commands/dev/handler.d.ts.map +1 -1
  7. package/esm/cli/commands/dev/handler.js +3 -1
  8. package/esm/cli/commands/knowledge/parser.d.ts.map +1 -1
  9. package/esm/cli/commands/knowledge/parser.js +2 -1
  10. package/esm/cli/commands/serve/handler.d.ts.map +1 -1
  11. package/esm/cli/commands/serve/handler.js +3 -1
  12. package/esm/cli/commands/start/handler.d.ts.map +1 -1
  13. package/esm/cli/commands/start/handler.js +3 -1
  14. package/esm/cli/main.js +0 -17
  15. package/esm/cli/router.d.ts.map +1 -1
  16. package/esm/cli/router.js +67 -98
  17. package/esm/cli/shared/default-contracts.d.ts +3 -0
  18. package/esm/cli/shared/default-contracts.d.ts.map +1 -0
  19. package/esm/cli/shared/default-contracts.js +19 -0
  20. package/esm/cli/shared/ensure-content-processor.d.ts +9 -1
  21. package/esm/cli/shared/ensure-content-processor.d.ts.map +1 -1
  22. package/esm/cli/shared/ensure-content-processor.js +23 -2
  23. package/esm/cli/shared/server-startup.d.ts.map +1 -1
  24. package/esm/cli/shared/server-startup.js +7 -4
  25. package/esm/deno.d.ts +3 -0
  26. package/esm/deno.js +5 -2
  27. package/esm/src/agent/hosted/veryfront-cloud-agent-service.d.ts.map +1 -1
  28. package/esm/src/agent/hosted/veryfront-cloud-agent-service.js +7 -5
  29. package/esm/src/agent/service/auth.d.ts.map +1 -1
  30. package/esm/src/agent/service/auth.js +2 -2
  31. package/esm/src/extensions/builtin-extensions.d.ts +9 -1
  32. package/esm/src/extensions/builtin-extensions.d.ts.map +1 -1
  33. package/esm/src/extensions/builtin-extensions.js +138 -54
  34. package/esm/src/extensions/first-party-import.d.ts +25 -0
  35. package/esm/src/extensions/first-party-import.d.ts.map +1 -0
  36. package/esm/src/extensions/first-party-import.js +120 -0
  37. package/esm/src/html/styles-builder/tailwind-compiler-cache.d.ts.map +1 -1
  38. package/esm/src/html/styles-builder/tailwind-compiler-cache.js +2 -1
  39. package/esm/src/internal-agents/run-stream.d.ts.map +1 -1
  40. package/esm/src/internal-agents/run-stream.js +2 -1
  41. package/esm/src/provider/local/local-engine.d.ts.map +1 -1
  42. package/esm/src/provider/local/local-engine.js +7 -4
  43. package/esm/src/provider/types.d.ts +1 -0
  44. package/esm/src/provider/types.d.ts.map +1 -1
  45. package/esm/src/provider/types.js +1 -1
  46. package/esm/src/proxy/main.js +4 -1
  47. package/esm/src/testing/init.js +18 -4
  48. package/esm/src/utils/version-constant.d.ts +1 -1
  49. package/esm/src/utils/version-constant.js +1 -1
  50. package/package.json +18 -94
  51. package/esm/extensions/ext-auth-jwt/src/index.d.ts +0 -39
  52. package/esm/extensions/ext-auth-jwt/src/index.d.ts.map +0 -1
  53. package/esm/extensions/ext-auth-jwt/src/index.js +0 -123
  54. package/esm/extensions/ext-bundler-esbuild/src/binary.d.ts +0 -7
  55. package/esm/extensions/ext-bundler-esbuild/src/binary.d.ts.map +0 -1
  56. package/esm/extensions/ext-bundler-esbuild/src/binary.js +0 -143
  57. package/esm/extensions/ext-bundler-esbuild/src/es-module-lexer.d.ts +0 -17
  58. package/esm/extensions/ext-bundler-esbuild/src/es-module-lexer.d.ts.map +0 -1
  59. package/esm/extensions/ext-bundler-esbuild/src/es-module-lexer.js +0 -29
  60. package/esm/extensions/ext-bundler-esbuild/src/esbuild-bundler.d.ts +0 -20
  61. package/esm/extensions/ext-bundler-esbuild/src/esbuild-bundler.d.ts.map +0 -1
  62. package/esm/extensions/ext-bundler-esbuild/src/esbuild-bundler.js +0 -98
  63. package/esm/extensions/ext-bundler-esbuild/src/index.d.ts +0 -19
  64. package/esm/extensions/ext-bundler-esbuild/src/index.d.ts.map +0 -1
  65. package/esm/extensions/ext-bundler-esbuild/src/index.js +0 -40
  66. package/esm/extensions/ext-bundler-esbuild/src/plugin-adapter.d.ts +0 -14
  67. package/esm/extensions/ext-bundler-esbuild/src/plugin-adapter.d.ts.map +0 -1
  68. package/esm/extensions/ext-bundler-esbuild/src/plugin-adapter.js +0 -55
  69. package/esm/extensions/ext-bundler-esbuild/src/runtime.d.ts +0 -4
  70. package/esm/extensions/ext-bundler-esbuild/src/runtime.d.ts.map +0 -1
  71. package/esm/extensions/ext-bundler-esbuild/src/runtime.js +0 -43
  72. package/esm/extensions/ext-content-mdx/src/compiler/markdown-compile.d.ts +0 -3
  73. package/esm/extensions/ext-content-mdx/src/compiler/markdown-compile.d.ts.map +0 -1
  74. package/esm/extensions/ext-content-mdx/src/compiler/markdown-compile.js +0 -99
  75. package/esm/extensions/ext-content-mdx/src/compiler/mdx-compile.d.ts +0 -3
  76. package/esm/extensions/ext-content-mdx/src/compiler/mdx-compile.d.ts.map +0 -1
  77. package/esm/extensions/ext-content-mdx/src/compiler/mdx-compile.js +0 -53
  78. package/esm/extensions/ext-content-mdx/src/index.d.ts +0 -30
  79. package/esm/extensions/ext-content-mdx/src/index.d.ts.map +0 -1
  80. package/esm/extensions/ext-content-mdx/src/index.js +0 -55
  81. package/esm/extensions/ext-content-mdx/src/plugins/plugin-loader.d.ts +0 -4
  82. package/esm/extensions/ext-content-mdx/src/plugins/plugin-loader.d.ts.map +0 -1
  83. package/esm/extensions/ext-content-mdx/src/plugins/plugin-loader.js +0 -18
  84. package/esm/extensions/ext-content-mdx/src/plugins/rehype-node-positions.d.ts +0 -20
  85. package/esm/extensions/ext-content-mdx/src/plugins/rehype-node-positions.d.ts.map +0 -1
  86. package/esm/extensions/ext-content-mdx/src/plugins/rehype-node-positions.js +0 -45
  87. package/esm/extensions/ext-content-mdx/src/plugins/remark-headings.d.ts +0 -4
  88. package/esm/extensions/ext-content-mdx/src/plugins/remark-headings.d.ts.map +0 -1
  89. package/esm/extensions/ext-content-mdx/src/plugins/remark-headings.js +0 -69
  90. package/esm/extensions/ext-content-mdx/src/plugins/remark-mdx-utils.d.ts +0 -14
  91. package/esm/extensions/ext-content-mdx/src/plugins/remark-mdx-utils.d.ts.map +0 -1
  92. package/esm/extensions/ext-content-mdx/src/plugins/remark-mdx-utils.js +0 -191
  93. package/esm/extensions/ext-css-tailwind/src/index.d.ts +0 -9
  94. package/esm/extensions/ext-css-tailwind/src/index.d.ts.map +0 -1
  95. package/esm/extensions/ext-css-tailwind/src/index.js +0 -71
  96. package/esm/extensions/ext-db-sqlite/src/index.d.ts +0 -15
  97. package/esm/extensions/ext-db-sqlite/src/index.d.ts.map +0 -1
  98. package/esm/extensions/ext-db-sqlite/src/index.js +0 -38
  99. package/esm/extensions/ext-document-kreuzberg/src/index.d.ts +0 -9
  100. package/esm/extensions/ext-document-kreuzberg/src/index.d.ts.map +0 -1
  101. package/esm/extensions/ext-document-kreuzberg/src/index.js +0 -81
  102. package/esm/extensions/ext-document-kreuzberg/src/kreuzberg.d.ts +0 -3
  103. package/esm/extensions/ext-document-kreuzberg/src/kreuzberg.d.ts.map +0 -1
  104. package/esm/extensions/ext-document-kreuzberg/src/kreuzberg.js +0 -67
  105. package/esm/extensions/ext-document-kreuzberg/src/runtime.d.ts +0 -3
  106. package/esm/extensions/ext-document-kreuzberg/src/runtime.d.ts.map +0 -1
  107. package/esm/extensions/ext-document-kreuzberg/src/runtime.js +0 -26
  108. package/esm/extensions/ext-document-kreuzberg/src/upload-extraction-worker.js +0 -20
  109. package/esm/extensions/ext-observability-opentelemetry/src/index.d.ts +0 -56
  110. package/esm/extensions/ext-observability-opentelemetry/src/index.d.ts.map +0 -1
  111. package/esm/extensions/ext-observability-opentelemetry/src/index.js +0 -338
  112. package/esm/extensions/ext-parser-babel/src/index.d.ts +0 -27
  113. package/esm/extensions/ext-parser-babel/src/index.d.ts.map +0 -1
  114. package/esm/extensions/ext-parser-babel/src/index.js +0 -82
  115. package/esm/extensions/ext-parser-babel/src/inject-node-positions.d.ts +0 -16
  116. package/esm/extensions/ext-parser-babel/src/inject-node-positions.d.ts.map +0 -1
  117. package/esm/extensions/ext-parser-babel/src/inject-node-positions.js +0 -129
  118. package/esm/extensions/ext-sandbox-shell-tools/src/index.d.ts +0 -16
  119. package/esm/extensions/ext-sandbox-shell-tools/src/index.d.ts.map +0 -1
  120. package/esm/extensions/ext-sandbox-shell-tools/src/index.js +0 -29
@@ -1,98 +0,0 @@
1
- /**
2
- * esbuild-backed implementation of the {@link Bundler} contract.
3
- *
4
- * Lazy-initializes the esbuild binary (including `deno compile` VFS
5
- * extraction) on first use. All options pass through to esbuild unchanged
6
- * because the {@link BundleOptions} shape was designed to be esbuild-compatible;
7
- * the only translation is converting {@link BundlerPlugin}s into esbuild
8
- * plugins via {@link toEsbuildPlugin}.
9
- *
10
- * @module extensions/ext-bundler-esbuild/esbuild-bundler
11
- */
12
- import { ensureEsbuildBinary } from "./binary.js";
13
- import { toEsbuildPlugin } from "./plugin-adapter.js";
14
- let esbuildModule = null;
15
- async function getEsbuild() {
16
- await ensureEsbuildBinary();
17
- if (esbuildModule)
18
- return esbuildModule;
19
- esbuildModule = await import("esbuild");
20
- return esbuildModule;
21
- }
22
- // deno-lint-ignore no-explicit-any
23
- function toMessage(m) {
24
- return {
25
- text: m.text,
26
- location: m.location ?? null,
27
- notes: m.notes,
28
- pluginName: m.pluginName,
29
- detail: m.detail,
30
- };
31
- }
32
- // deno-lint-ignore no-explicit-any
33
- function toMessages(ms) {
34
- return (ms ?? []).map(toMessage);
35
- }
36
- // deno-lint-ignore no-explicit-any
37
- function toOutput(f) {
38
- return {
39
- path: f.path,
40
- contents: f.contents,
41
- text: f.text,
42
- hash: f.hash,
43
- };
44
- }
45
- function mapOptions(options) {
46
- const { plugins, ...rest } = options;
47
- const mapped = { ...rest };
48
- if (plugins && plugins.length > 0) {
49
- mapped.plugins = plugins.map(toEsbuildPlugin);
50
- }
51
- return mapped;
52
- }
53
- /** esbuild-backed {@link Bundler} implementation. */
54
- export class EsbuildBundler {
55
- async bundle(options) {
56
- const esbuild = await getEsbuild();
57
- const result = await esbuild.build(mapOptions(options));
58
- return {
59
- outputFiles: (result.outputFiles ?? []).map(toOutput),
60
- warnings: toMessages(result.warnings),
61
- errors: toMessages(result.errors),
62
- metafile: result.metafile,
63
- };
64
- }
65
- async transform(options) {
66
- const esbuild = await getEsbuild();
67
- const { code, ...rest } = options;
68
- const result = await esbuild.transform(code, rest);
69
- return {
70
- code: result.code,
71
- map: result.map,
72
- warnings: toMessages(result.warnings).map((m) => m.text),
73
- };
74
- }
75
- async context(options) {
76
- const esbuild = await getEsbuild();
77
- const ctx = await esbuild.context(mapOptions(options));
78
- return {
79
- rebuild: async () => {
80
- const result = await ctx.rebuild();
81
- return {
82
- outputFiles: (result.outputFiles ?? []).map(toOutput),
83
- warnings: toMessages(result.warnings),
84
- errors: toMessages(result.errors),
85
- metafile: result.metafile,
86
- };
87
- },
88
- dispose: () => ctx.dispose(),
89
- };
90
- }
91
- async stop() {
92
- const m = esbuildModule;
93
- if (!m)
94
- return;
95
- esbuildModule = null;
96
- await m.stop();
97
- }
98
- }
@@ -1,19 +0,0 @@
1
- /**
2
- * ext-bundler-esbuild — Bundler + ModuleLexer contract implementations backed by
3
- * esbuild and es-module-lexer.
4
- *
5
- * @module extensions/ext-bundler-esbuild
6
- */
7
- import type { ExtensionFactory } from "../../../src/extensions/index.js";
8
- import { EsbuildBundler } from "./esbuild-bundler.js";
9
- import { EsModuleLexer } from "./es-module-lexer.js";
10
- /**
11
- * Default export — the ext-bundler-esbuild extension factory.
12
- *
13
- * Registers both the `Bundler` (esbuild-backed) and `ModuleLexer`
14
- * (es-module-lexer-backed) contracts.
15
- */
16
- declare const extEsbuild: ExtensionFactory;
17
- export default extEsbuild;
18
- export { EsbuildBundler, EsModuleLexer };
19
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-bundler-esbuild/src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;;;GAKG;AACH,QAAA,MAAM,UAAU,EAAE,gBAwBjB,CAAC;AAEF,eAAe,UAAU,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC"}
@@ -1,40 +0,0 @@
1
- /**
2
- * ext-bundler-esbuild — Bundler + ModuleLexer contract implementations backed by
3
- * esbuild and es-module-lexer.
4
- *
5
- * @module extensions/ext-bundler-esbuild
6
- */
7
- import { EsbuildBundler } from "./esbuild-bundler.js";
8
- import { EsModuleLexer } from "./es-module-lexer.js";
9
- /**
10
- * Default export — the ext-bundler-esbuild extension factory.
11
- *
12
- * Registers both the `Bundler` (esbuild-backed) and `ModuleLexer`
13
- * (es-module-lexer-backed) contracts.
14
- */
15
- const extEsbuild = () => {
16
- const bundler = new EsbuildBundler();
17
- const lexer = new EsModuleLexer();
18
- return {
19
- name: "ext-bundler-esbuild",
20
- version: "0.1.0",
21
- contracts: {
22
- provides: ["Bundler", "ModuleLexer"],
23
- },
24
- capabilities: [],
25
- setup(ctx) {
26
- if (!ctx.get("Bundler")) {
27
- ctx.provide("Bundler", bundler);
28
- }
29
- if (!ctx.get("ModuleLexer")) {
30
- ctx.provide("ModuleLexer", lexer);
31
- }
32
- ctx.logger.info("[ext-bundler-esbuild] Bundler + ModuleLexer registered");
33
- },
34
- async teardown() {
35
- await bundler.stop?.();
36
- },
37
- };
38
- };
39
- export default extEsbuild;
40
- export { EsbuildBundler, EsModuleLexer };
@@ -1,14 +0,0 @@
1
- /**
2
- * Plugin adapter — converts {@link BundlerPlugin} (the bundler-agnostic
3
- * contract shape) into an esbuild `Plugin`. The contract's onResolve /
4
- * onLoad shapes were deliberately designed to match esbuild's, so the
5
- * translation is near-1:1; this module exists to isolate the esbuild
6
- * import from the rest of the extension.
7
- *
8
- * @module extensions/ext-bundler-esbuild/plugin-adapter
9
- */
10
- import type { BundlerPlugin } from "../../../src/extensions/bundler/index.js";
11
- type EsbuildPlugin = any;
12
- export declare function toEsbuildPlugin(plugin: BundlerPlugin): EsbuildPlugin;
13
- export {};
14
- //# sourceMappingURL=plugin-adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-adapter.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-bundler-esbuild/src/plugin-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,aAAa,EAMd,MAAM,0CAA0C,CAAC;AAElD,KAAK,aAAa,GAAG,GAAG,CAAC;AAEzB,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CA4CpE"}
@@ -1,55 +0,0 @@
1
- /**
2
- * Plugin adapter — converts {@link BundlerPlugin} (the bundler-agnostic
3
- * contract shape) into an esbuild `Plugin`. The contract's onResolve /
4
- * onLoad shapes were deliberately designed to match esbuild's, so the
5
- * translation is near-1:1; this module exists to isolate the esbuild
6
- * import from the rest of the extension.
7
- *
8
- * @module extensions/ext-bundler-esbuild/plugin-adapter
9
- */
10
- export function toEsbuildPlugin(plugin) {
11
- return {
12
- name: plugin.name,
13
- // deno-lint-ignore no-explicit-any
14
- setup(build) {
15
- const bridged = {
16
- onResolve(options, callback) {
17
- // deno-lint-ignore no-explicit-any
18
- build.onResolve(options, async (args) => {
19
- const resolveArgs = {
20
- path: args.path,
21
- importer: args.importer,
22
- namespace: args.namespace,
23
- resolveDir: args.resolveDir,
24
- kind: args.kind,
25
- pluginData: args.pluginData,
26
- };
27
- const result = await callback(resolveArgs);
28
- if (result == null)
29
- return result ?? null;
30
- return result;
31
- });
32
- },
33
- onLoad(options, callback) {
34
- // deno-lint-ignore no-explicit-any
35
- build.onLoad(options, async (args) => {
36
- const loadArgs = {
37
- path: args.path,
38
- namespace: args.namespace,
39
- suffix: args.suffix,
40
- pluginData: args.pluginData,
41
- };
42
- const result = await callback(loadArgs);
43
- if (result == null)
44
- return result ?? null;
45
- return result;
46
- });
47
- },
48
- onDispose(callback) {
49
- build.onDispose(callback);
50
- },
51
- };
52
- plugin.setup(bridged);
53
- },
54
- };
55
- }
@@ -1,4 +0,0 @@
1
- export declare const isDeno: boolean;
2
- /** True if running inside a `deno compile`'d binary (needs VFS extraction). */
3
- export declare const isDenoCompiled: boolean;
4
- //# sourceMappingURL=runtime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-bundler-esbuild/src/runtime.ts"],"names":[],"mappings":"AAkCA,eAAO,MAAM,MAAM,EAAE,OAA+D,CAAC;AAkBrF,+EAA+E;AAC/E,eAAO,MAAM,cAAc,EAAE,OAA0C,CAAC"}
@@ -1,43 +0,0 @@
1
- /**
2
- * Runtime detection — inlined from src/platform/compat/runtime.ts so the
3
- * extension stays dependency-free on core.
4
- *
5
- * Only the bits needed by the esbuild binary extractor are included here.
6
- *
7
- * @module extensions/ext-bundler-esbuild/runtime
8
- */
9
- import * as dntShim from "../../../_dnt.shims.js";
10
- function hasRealDeno() {
11
- return (typeof dntShim.Deno !== "undefined" &&
12
- typeof dntShim.Deno.version === "object" &&
13
- typeof dntShim.Deno.build === "object" &&
14
- typeof dntShim.Deno.build.os === "string");
15
- }
16
- function hasBunGlobal() {
17
- return dntShim.dntGlobalThis.Bun != null;
18
- }
19
- function hasNodeProcess() {
20
- const g = dntShim.dntGlobalThis;
21
- return g.process?.versions?.node != null && !g.process?.versions?.deno;
22
- }
23
- export const isDeno = !hasNodeProcess() && !hasBunGlobal() && hasRealDeno();
24
- function testDenoCompiledDetection(execPath) {
25
- if (!execPath)
26
- return false;
27
- const binary = execPath.split(/[/\\]/).pop()?.toLowerCase();
28
- if (!binary)
29
- return false;
30
- return binary !== "deno" && binary !== "deno.exe";
31
- }
32
- function isDenoCompiledBinary() {
33
- if (!hasRealDeno())
34
- return false;
35
- try {
36
- return testDenoCompiledDetection(dntShim.Deno.execPath());
37
- }
38
- catch {
39
- return false;
40
- }
41
- }
42
- /** True if running inside a `deno compile`'d binary (needs VFS extraction). */
43
- export const isDenoCompiled = isDeno && isDenoCompiledBinary();
@@ -1,3 +0,0 @@
1
- import type { ContentCompileOptions, ContentProcessingResult } from "../../../../src/extensions/content/index.js";
2
- export declare function compileMarkdown(options: ContentCompileOptions): Promise<ContentProcessingResult>;
3
- //# sourceMappingURL=markdown-compile.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown-compile.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/ext-content-mdx/src/compiler/markdown-compile.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAkDlH,wBAAsB,eAAe,CACnC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,uBAAuB,CAAC,CA4DlC"}
@@ -1,99 +0,0 @@
1
- import { unified } from "unified";
2
- import remarkParse from "remark-parse";
3
- import remarkGfm from "remark-gfm";
4
- import remarkFrontmatter from "remark-frontmatter";
5
- import remarkRehype from "remark-rehype";
6
- import rehypeStarryNight from "rehype-starry-night";
7
- import rehypeSlug from "rehype-slug";
8
- import rehypeRaw from "rehype-raw";
9
- import rehypeSanitize, { defaultSchema } from "rehype-sanitize";
10
- import rehypeStringify from "rehype-stringify";
11
- import { visit } from "unist-util-visit";
12
- import { toString } from "mdast-util-to-string";
13
- import Slugger from "github-slugger";
14
- import { extractFrontmatter } from "../../../../src/transforms/mdx/compiler/frontmatter-extractor.js";
15
- import { isMarkdownPreview } from "../../../../src/transforms/md/utils.js";
16
- import { rehypeNodePositions } from "../plugins/rehype-node-positions.js";
17
- function remarkExtractHeadings(headings) {
18
- const slugger = new Slugger();
19
- return (tree) => {
20
- visit(tree, "heading", (node) => {
21
- const text = toString(node);
22
- const id = slugger.slug(text);
23
- headings.push({ id, text, level: node.depth });
24
- });
25
- };
26
- }
27
- function escapeForJsString(str) {
28
- return str.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
29
- }
30
- function createCompiledCode(escapedHtml, isPreview) {
31
- const injector = `dangerouslySetInnerHTML: { __html: \`${escapedHtml}\` }`;
32
- if (isPreview) {
33
- return `import { jsx as _jsx } from "react/jsx-runtime";
34
- export default function MDContent({ components, params, ...props }) {
35
- return _jsx("div", {
36
- className: "markdown-body",
37
- ${injector}
38
- });
39
- }
40
- `;
41
- }
42
- return `import { jsx as _jsx } from "react/jsx-runtime";
43
- export default function MDContent({ components, params, className, ...props }) {
44
- return _jsx("div", {
45
- className,
46
- ${injector}
47
- });
48
- }
49
- `;
50
- }
51
- export async function compileMarkdown(options) {
52
- const { content, frontmatter: providedFrontmatter, filePath, studioEmbed } = options;
53
- const { body, frontmatter: extractedFrontmatter } = extractFrontmatter(content, providedFrontmatter);
54
- const headings = [];
55
- const pipeline = unified()
56
- .use(remarkParse)
57
- .use(remarkGfm)
58
- .use(remarkFrontmatter)
59
- .use(remarkExtractHeadings, headings)
60
- .use(remarkRehype, { allowDangerousHtml: true })
61
- .use(rehypeStarryNight)
62
- .use(rehypeSlug);
63
- pipeline.use(rehypeRaw);
64
- if (studioEmbed && filePath) {
65
- pipeline.use(rehypeNodePositions, { filePath });
66
- }
67
- const sanitizeSchema = studioEmbed
68
- ? {
69
- ...defaultSchema,
70
- attributes: {
71
- ...defaultSchema.attributes,
72
- "*": [
73
- ...(defaultSchema.attributes?.["*"] ?? []),
74
- "data-node-file",
75
- "data-node-name",
76
- "data-node-line",
77
- "data-node-column",
78
- "data-node-source",
79
- ],
80
- },
81
- }
82
- : defaultSchema;
83
- const result = await pipeline
84
- .use(rehypeSanitize, sanitizeSchema)
85
- .use(rehypeStringify)
86
- .process(body);
87
- const html = String(result);
88
- const escapedHtml = escapeForJsString(html);
89
- const isPreview = isMarkdownPreview(filePath, extractedFrontmatter);
90
- const compiledCode = createCompiledCode(escapedHtml, isPreview);
91
- return {
92
- compiledCode,
93
- frontmatter: extractedFrontmatter,
94
- globals: {},
95
- headings,
96
- nodeMap: new Map(),
97
- rawHtml: html,
98
- };
99
- }
@@ -1,3 +0,0 @@
1
- import type { ContentCompileOptions, ContentProcessingResult } from "../../../../src/extensions/content/index.js";
2
- export declare function compileMdx(options: ContentCompileOptions): Promise<ContentProcessingResult>;
3
- //# sourceMappingURL=mdx-compile.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mdx-compile.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/ext-content-mdx/src/compiler/mdx-compile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAQlH,wBAAsB,UAAU,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAuEjG"}
@@ -1,53 +0,0 @@
1
- import { compile } from "@mdx-js/mdx";
2
- import { extractFrontmatter } from "../../../../src/transforms/mdx/compiler/frontmatter-extractor.js";
3
- import { rewriteBodyImports, rewriteCompiledImports } from "../../../../src/transforms/mdx/compiler/import-rewriter.js";
4
- import { getRehypePlugins, getRemarkPlugins } from "../plugins/plugin-loader.js";
5
- import { rehypeNodePositions } from "../plugins/rehype-node-positions.js";
6
- export async function compileMdx(options) {
7
- const { projectDir, content, frontmatter: providedFrontmatter, filePath, target = "server", baseUrl, studioEmbed, outputFormat = "program", remarkPlugins: additionalRemarkPlugins = [], rehypePlugins: additionalRehypePlugins = [], } = options;
8
- const remarkPlugins = [
9
- ...getRemarkPlugins(),
10
- ...additionalRemarkPlugins,
11
- ];
12
- const rehypePlugins = [
13
- ...getRehypePlugins(),
14
- ...additionalRehypePlugins,
15
- ];
16
- if (studioEmbed && filePath) {
17
- rehypePlugins.push([rehypeNodePositions, { filePath }]);
18
- }
19
- const { body: extractedBody, frontmatter: extractedFrontmatter } = extractFrontmatter(content, providedFrontmatter);
20
- const shouldRewriteImports = Boolean(filePath) &&
21
- (target === "browser" || target === "server");
22
- const body = shouldRewriteImports
23
- ? rewriteBodyImports(extractedBody, { filePath: filePath, target, baseUrl, projectDir })
24
- : extractedBody;
25
- const compiled = await compile(body, {
26
- outputFormat,
27
- // Always false: @mdx-js/mdx development mode emits extra JSX
28
- // transforms that break the existing rendering pipeline.
29
- development: false,
30
- remarkPlugins,
31
- rehypePlugins,
32
- providerImportSource: undefined,
33
- jsxImportSource: "react",
34
- });
35
- const headings = compiled.data?.headings ??
36
- [];
37
- const compiledString = String(compiled);
38
- const compiledCode = shouldRewriteImports
39
- ? rewriteCompiledImports(compiledString, {
40
- filePath: filePath,
41
- target,
42
- baseUrl,
43
- projectDir,
44
- })
45
- : compiledString;
46
- return {
47
- compiledCode,
48
- frontmatter: extractedFrontmatter,
49
- globals: {},
50
- headings,
51
- nodeMap: new Map(),
52
- };
53
- }
@@ -1,30 +0,0 @@
1
- /**
2
- * ext-content-mdx: ContentProcessor implementation backed by MDX + remark/rehype.
3
- *
4
- * Provides the `ContentProcessor` contract:
5
- * - `compileMdx(options)` runs @mdx-js/mdx through Veryfront's remark +
6
- * rehype plugin stack and returns compiled ESM plus extracted headings
7
- * and frontmatter.
8
- * - `compileMarkdown(options)` runs a unified markdown pipeline
9
- * (remark-parse to remark-rehype to rehype-sanitize to rehype-stringify)
10
- * producing sanitized HTML wrapped in a React component.
11
- *
12
- * Core's `src/transforms/md/compiler` and `src/transforms/mdx/compiler`
13
- * resolve this contract at call time. When the extension is not installed,
14
- * core throws an actionable install message (see
15
- * `src/extensions/recommendations.ts`).
16
- *
17
- * @module extensions/ext-content-mdx
18
- */
19
- import type { ExtensionFactory } from "../../../src/extensions/index.js";
20
- import type { ContentCompileOptions, ContentPlugin, ContentProcessingResult, ContentProcessor } from "../../../src/extensions/content/index.js";
21
- declare class MdxContentProcessor implements ContentProcessor {
22
- compileMdx(options: ContentCompileOptions): Promise<ContentProcessingResult>;
23
- compileMarkdown(options: ContentCompileOptions): Promise<ContentProcessingResult>;
24
- getRemarkPlugins(): ContentPlugin[];
25
- getRehypePlugins(): ContentPlugin[];
26
- }
27
- declare const extMdx: ExtensionFactory;
28
- export default extMdx;
29
- export { MdxContentProcessor };
30
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-content-mdx/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EACV,qBAAqB,EACrB,aAAa,EACb,uBAAuB,EACvB,gBAAgB,EACjB,MAAM,0CAA0C,CAAC;AAKlD,cAAM,mBAAoB,YAAW,gBAAgB;IACnD,UAAU,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAG5E,eAAe,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAGjF,gBAAgB,IAAI,aAAa,EAAE;IAGnC,gBAAgB,IAAI,aAAa,EAAE;CAGpC;AAED,QAAA,MAAM,MAAM,EAAE,gBAiBb,CAAC;AAEF,eAAe,MAAM,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -1,55 +0,0 @@
1
- /**
2
- * ext-content-mdx: ContentProcessor implementation backed by MDX + remark/rehype.
3
- *
4
- * Provides the `ContentProcessor` contract:
5
- * - `compileMdx(options)` runs @mdx-js/mdx through Veryfront's remark +
6
- * rehype plugin stack and returns compiled ESM plus extracted headings
7
- * and frontmatter.
8
- * - `compileMarkdown(options)` runs a unified markdown pipeline
9
- * (remark-parse to remark-rehype to rehype-sanitize to rehype-stringify)
10
- * producing sanitized HTML wrapped in a React component.
11
- *
12
- * Core's `src/transforms/md/compiler` and `src/transforms/mdx/compiler`
13
- * resolve this contract at call time. When the extension is not installed,
14
- * core throws an actionable install message (see
15
- * `src/extensions/recommendations.ts`).
16
- *
17
- * @module extensions/ext-content-mdx
18
- */
19
- import { compileMdx } from "./compiler/mdx-compile.js";
20
- import { compileMarkdown } from "./compiler/markdown-compile.js";
21
- import { getRehypePlugins, getRemarkPlugins } from "./plugins/plugin-loader.js";
22
- class MdxContentProcessor {
23
- compileMdx(options) {
24
- return compileMdx(options);
25
- }
26
- compileMarkdown(options) {
27
- return compileMarkdown(options);
28
- }
29
- getRemarkPlugins() {
30
- return getRemarkPlugins();
31
- }
32
- getRehypePlugins() {
33
- return getRehypePlugins();
34
- }
35
- }
36
- const extMdx = () => {
37
- const impl = new MdxContentProcessor();
38
- return {
39
- name: "ext-content-mdx",
40
- version: "0.1.0",
41
- contracts: {
42
- provides: ["ContentProcessor"],
43
- },
44
- capabilities: [],
45
- setup(ctx) {
46
- ctx.provide("ContentProcessor", impl);
47
- ctx.logger.info("[ext-content-mdx] ContentProcessor registered");
48
- },
49
- teardown() {
50
- // No resources to release.
51
- },
52
- };
53
- };
54
- export default extMdx;
55
- export { MdxContentProcessor };
@@ -1,4 +0,0 @@
1
- import type { Pluggable } from "unified";
2
- export declare function getRemarkPlugins(): Pluggable[];
3
- export declare function getRehypePlugins(): Pluggable[];
4
- //# sourceMappingURL=plugin-loader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-loader.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/ext-content-mdx/src/plugins/plugin-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAQzC,wBAAgB,gBAAgB,IAAI,SAAS,EAAE,CAQ9C;AAED,wBAAgB,gBAAgB,IAAI,SAAS,EAAE,CAE9C"}
@@ -1,18 +0,0 @@
1
- import rehypeHighlight from "rehype-highlight";
2
- import rehypeSlug from "rehype-slug";
3
- import remarkFrontmatter from "remark-frontmatter";
4
- import remarkGfm from "remark-gfm";
5
- import { remarkMdxHeadings } from "./remark-headings.js";
6
- import { remarkCodeBlocks, remarkMdxRemoveParagraphs } from "./remark-mdx-utils.js";
7
- export function getRemarkPlugins() {
8
- return [
9
- remarkGfm,
10
- remarkFrontmatter,
11
- remarkMdxHeadings,
12
- remarkMdxRemoveParagraphs,
13
- remarkCodeBlocks,
14
- ];
15
- }
16
- export function getRehypePlugins() {
17
- return [rehypeHighlight, rehypeSlug];
18
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Rehype plugin that injects source location attributes on every element.
3
- *
4
- * Handles both:
5
- * - HTML elements from markdown (h1, p, li, …)
6
- * - MDX JSX nodes (mdxJsxFlowElement, mdxJsxTextElement)
7
- *
8
- * Injected attributes:
9
- * data-node-file — project-relative source file path
10
- * data-node-name — element or component name
11
- * data-node-line — source line number
12
- * data-node-column — source column number (0-based)
13
- */
14
- import type { Root } from "@types/hast";
15
- interface RehypeNodePositionsOptions {
16
- filePath?: string;
17
- }
18
- export declare function rehypeNodePositions(options?: RehypeNodePositionsOptions): (tree: Root) => void;
19
- export {};
20
- //# sourceMappingURL=rehype-node-positions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rehype-node-positions.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/ext-content-mdx/src/plugins/rehype-node-positions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,aAAa,CAAC;AAGjD,UAAU,0BAA0B;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AASD,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,0BAA+B,GACvC,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAoCtB"}
@@ -1,45 +0,0 @@
1
- /**
2
- * Rehype plugin that injects source location attributes on every element.
3
- *
4
- * Handles both:
5
- * - HTML elements from markdown (h1, p, li, …)
6
- * - MDX JSX nodes (mdxJsxFlowElement, mdxJsxTextElement)
7
- *
8
- * Injected attributes:
9
- * data-node-file — project-relative source file path
10
- * data-node-name — element or component name
11
- * data-node-line — source line number
12
- * data-node-column — source column number (0-based)
13
- */
14
- import { visit } from "unist-util-visit";
15
- export function rehypeNodePositions(options = {}) {
16
- return function transform(tree) {
17
- visit(tree, (node) => {
18
- if (node.type === "element") {
19
- const el = node;
20
- if (!el.position)
21
- return;
22
- const props = el.properties ?? (el.properties = {});
23
- const { start } = el.position;
24
- if (options.filePath)
25
- props["data-node-file"] = options.filePath;
26
- props["data-node-name"] = el.tagName;
27
- props["data-node-line"] = String(start.line);
28
- props["data-node-column"] = String(start.column - 1);
29
- props["data-node-source"] = "md";
30
- return;
31
- }
32
- if (node.type !== "mdxJsxFlowElement" && node.type !== "mdxJsxTextElement")
33
- return;
34
- const mdx = node;
35
- if (!mdx.position)
36
- return;
37
- const attrs = mdx.attributes ?? (mdx.attributes = []);
38
- const { start } = mdx.position;
39
- if (options.filePath) {
40
- attrs.push({ type: "mdxJsxAttribute", name: "data-node-file", value: options.filePath });
41
- }
42
- attrs.push({ type: "mdxJsxAttribute", name: "data-node-name", value: mdx.name || "unknown" }, { type: "mdxJsxAttribute", name: "data-node-line", value: String(start.line) }, { type: "mdxJsxAttribute", name: "data-node-column", value: String(start.column - 1) });
43
- });
44
- };
45
- }
@@ -1,4 +0,0 @@
1
- import type { Root } from "@types/mdast";
2
- import type { VFile } from "vfile";
3
- export declare function remarkMdxHeadings(): (tree: Root, file: VFile) => void;
4
- //# sourceMappingURL=remark-headings.d.ts.map