fumadocs-mdx 13.0.0 → 13.0.2

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 (55) hide show
  1. package/dist/bin.cjs +294 -257
  2. package/dist/{build-mdx-CzrQDBRZ.d.ts → build-mdx-CCNr86q6.d.ts} +1 -1
  3. package/dist/{build-mdx-BHG-_uxo.d.cts → build-mdx-D-r3_eQL.d.cts} +1 -1
  4. package/dist/bun/index.cjs +114 -34
  5. package/dist/bun/index.d.cts +8 -3
  6. package/dist/bun/index.d.ts +8 -3
  7. package/dist/bun/index.js +20 -10
  8. package/dist/{chunk-6Y5JDZHD.js → chunk-CXA4JO4Z.js} +1 -21
  9. package/dist/chunk-EELYB2XC.js +207 -0
  10. package/dist/{chunk-CEA6MYJU.js → chunk-XQ5O7IPO.js} +29 -27
  11. package/dist/chunk-XZY2AWJI.js +81 -0
  12. package/dist/{chunk-XV5Z4BFL.js → chunk-YVCR6FUH.js} +1 -1
  13. package/dist/config/index.d.cts +2 -2
  14. package/dist/config/index.d.ts +2 -2
  15. package/dist/{define-BCNh3n4O.d.cts → core-B6j6Fxse.d.cts} +101 -38
  16. package/dist/{define-bck_EB4t.d.ts → core-B6j6Fxse.d.ts} +101 -38
  17. package/dist/index.d.cts +7 -2
  18. package/dist/index.d.ts +7 -2
  19. package/dist/next/index.cjs +195 -163
  20. package/dist/next/index.js +79 -71
  21. package/dist/node/loader.cjs +120 -35
  22. package/dist/node/loader.js +10 -5
  23. package/dist/plugins/json-schema.cjs +103 -2
  24. package/dist/plugins/json-schema.d.cts +12 -4
  25. package/dist/plugins/json-schema.d.ts +12 -4
  26. package/dist/plugins/json-schema.js +40 -2
  27. package/dist/runtime/next/async.d.cts +4 -4
  28. package/dist/runtime/next/async.d.ts +4 -4
  29. package/dist/runtime/next/async.js +3 -3
  30. package/dist/runtime/next/index.d.cts +5 -5
  31. package/dist/runtime/next/index.d.ts +5 -5
  32. package/dist/runtime/vite/browser.d.cts +3 -3
  33. package/dist/runtime/vite/browser.d.ts +3 -3
  34. package/dist/runtime/vite/server.d.cts +3 -3
  35. package/dist/runtime/vite/server.d.ts +3 -3
  36. package/dist/{types-1cCFEzWt.d.ts → types-AGzTfBmf.d.ts} +1 -1
  37. package/dist/{types-D5NhXTJY.d.cts → types-DKGMoay5.d.cts} +1 -1
  38. package/dist/vite/index.cjs +145 -108
  39. package/dist/vite/index.js +53 -45
  40. package/dist/{loader-mdx.cjs → webpack/index.cjs} +151 -58
  41. package/dist/webpack/index.js +44 -0
  42. package/loader-mdx.cjs +1 -1
  43. package/package.json +4 -3
  44. package/dist/chunk-4MAYA5QX.js +0 -44
  45. package/dist/chunk-HI62EXSB.js +0 -127
  46. package/dist/loader-mdx.js +0 -39
  47. package/dist/plugins/index.cjs +0 -78
  48. package/dist/plugins/index.d.cts +0 -7
  49. package/dist/plugins/index.d.ts +0 -7
  50. package/dist/plugins/index.js +0 -6
  51. package/dist/remark-postprocess-K233ZVBK.d.cts +0 -22
  52. package/dist/remark-postprocess-K233ZVBK.d.ts +0 -22
  53. package/dist/watcher-WXJDWRZY.js +0 -22
  54. /package/dist/{loader-mdx.d.cts → webpack/index.d.cts} +0 -0
  55. /package/dist/{loader-mdx.d.ts → webpack/index.d.ts} +0 -0
@@ -216,12 +216,12 @@ var init_load = __esm({
216
216
  }
217
217
  });
218
218
 
219
- // src/loader-mdx.ts
220
- var loader_mdx_exports = {};
221
- __export(loader_mdx_exports, {
219
+ // src/webpack/index.ts
220
+ var webpack_exports = {};
221
+ __export(webpack_exports, {
222
222
  default: () => loader
223
223
  });
224
- module.exports = __toCommonJS(loader_mdx_exports);
224
+ module.exports = __toCommonJS(webpack_exports);
225
225
 
226
226
  // src/utils/fuma-matter.ts
227
227
  var import_js_yaml = require("js-yaml");
@@ -667,14 +667,6 @@ var cacheEntry = import_zod.z.object({
667
667
  map: import_zod.z.any().optional(),
668
668
  hash: import_zod.z.string().optional()
669
669
  });
670
- var hashes = /* @__PURE__ */ new WeakMap();
671
- function getConfigHash(config) {
672
- let hash = hashes.get(config);
673
- if (hash) return hash;
674
- hash = Date.now().toString();
675
- hashes.set(config, hash);
676
- return hash;
677
- }
678
670
  function createMdxLoader(configLoader) {
679
671
  return async ({
680
672
  source: value,
@@ -685,14 +677,25 @@ function createMdxLoader(configLoader) {
685
677
  }) => {
686
678
  const matter = fumaMatter(value);
687
679
  const parsed = querySchema.parse(query);
688
- const loaded = await configLoader.getConfig();
689
- const cacheDir = isDevelopment ? void 0 : loaded.global.experimentalBuildCache;
690
- const cacheKey = `${parsed.hash}_${parsed.collection ?? "global"}_${generateCacheHash(filePath)}`;
691
- if (cacheDir) {
680
+ const config = await configLoader.getConfig();
681
+ let after;
682
+ if (!isDevelopment && config.global.experimentalBuildCache) {
683
+ const cacheDir = config.global.experimentalBuildCache;
684
+ const cacheKey = `${parsed.hash}_${parsed.collection ?? "global"}_${generateCacheHash(filePath)}`;
692
685
  const cached = await import_promises.default.readFile(import_node_path2.default.join(cacheDir, cacheKey)).then((content) => cacheEntry.parse(JSON.parse(content.toString()))).catch(() => null);
693
686
  if (cached && cached.hash === generateCacheHash(value)) return cached;
687
+ after = async () => {
688
+ await import_promises.default.mkdir(cacheDir, { recursive: true });
689
+ await import_promises.default.writeFile(
690
+ import_node_path2.default.join(cacheDir, cacheKey),
691
+ JSON.stringify({
692
+ ...out,
693
+ hash: generateCacheHash(value)
694
+ })
695
+ );
696
+ };
694
697
  }
695
- const collection = parsed.collection ? loaded.collections.get(parsed.collection) : void 0;
698
+ const collection = parsed.collection ? config.collections.get(parsed.collection) : void 0;
696
699
  let docCollection;
697
700
  switch (collection?.type) {
698
701
  case "doc":
@@ -720,16 +723,16 @@ function createMdxLoader(configLoader) {
720
723
  };
721
724
  }
722
725
  const data = {};
723
- if (loaded.global.lastModifiedTime === "git") {
726
+ if (config.global.lastModifiedTime === "git") {
724
727
  data.lastModified = (await getGitTimestamp(filePath))?.getTime();
725
728
  }
726
729
  const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
727
730
  const compiled = await buildMDX(
728
- `${getConfigHash(loaded)}:${parsed.collection ?? "global"}`,
731
+ `${getConfigHash(config)}:${parsed.collection ?? "global"}`,
729
732
  "\n".repeat(lineOffset) + matter.content,
730
733
  {
731
734
  development: isDevelopment,
732
- ...docCollection?.mdxOptions ?? await loaded.getDefaultMDXOptions(),
735
+ ...docCollection?.mdxOptions ?? await config.getDefaultMDXOptions(),
733
736
  postprocess: docCollection?.postprocess,
734
737
  data,
735
738
  filePath,
@@ -741,19 +744,18 @@ function createMdxLoader(configLoader) {
741
744
  code: String(compiled.value),
742
745
  map: compiled.map
743
746
  };
744
- if (cacheDir) {
745
- await import_promises.default.mkdir(cacheDir, { recursive: true });
746
- await import_promises.default.writeFile(
747
- import_node_path2.default.join(cacheDir, cacheKey),
748
- JSON.stringify({
749
- ...out,
750
- hash: generateCacheHash(value)
751
- })
752
- );
753
- }
747
+ await after?.();
754
748
  return out;
755
749
  };
756
750
  }
751
+ var hashes = /* @__PURE__ */ new WeakMap();
752
+ function getConfigHash(config) {
753
+ let hash = hashes.get(config);
754
+ if (hash) return hash;
755
+ hash = Date.now().toString();
756
+ hashes.set(config, hash);
757
+ return hash;
758
+ }
757
759
  function generateCacheHash(input) {
758
760
  return (0, import_node_crypto.createHash)("md5").update(input).digest("hex");
759
761
  }
@@ -769,43 +771,57 @@ function countLines(s) {
769
771
  var import_node_path3 = __toESM(require("path"), 1);
770
772
  var import_promises2 = __toESM(require("fs/promises"), 1);
771
773
  function staticConfig({
772
- outDir,
773
- configPath,
774
+ core,
774
775
  buildConfig: buildConfig2
775
776
  }) {
776
777
  let cached;
778
+ async function newConfig() {
779
+ const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_load(), load_exports));
780
+ await core.init({
781
+ config: loadConfig2(
782
+ core._options.configPath,
783
+ core._options.outDir,
784
+ buildConfig2
785
+ )
786
+ });
787
+ return core.getConfig();
788
+ }
777
789
  return {
778
790
  async getConfig() {
779
- if (cached) return cached;
780
- cached = Promise.resolve().then(() => (init_load(), load_exports)).then(
781
- (mod) => mod.loadConfig(configPath, outDir, buildConfig2)
782
- );
783
- return cached;
791
+ return cached ??= newConfig();
784
792
  }
785
793
  };
786
794
  }
787
795
  function dynamicConfig({
788
- outDir,
789
- configPath,
796
+ core,
790
797
  buildConfig: buildConfig2
791
798
  }) {
792
799
  let loaded;
793
800
  async function getConfigHash2() {
794
- const stats = await import_promises2.default.stat(configPath).catch(() => void 0);
801
+ const stats = await import_promises2.default.stat(core._options.configPath).catch(() => void 0);
795
802
  if (stats) {
796
803
  return stats.mtime.getTime().toString();
797
804
  }
798
805
  throw new Error("Cannot find config file");
799
806
  }
807
+ async function newConfig() {
808
+ const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_load(), load_exports));
809
+ await core.init({
810
+ config: loadConfig2(
811
+ core._options.configPath,
812
+ core._options.outDir,
813
+ buildConfig2
814
+ )
815
+ });
816
+ return core.getConfig();
817
+ }
800
818
  return {
801
819
  async getConfig() {
802
820
  const hash = await getConfigHash2();
803
821
  if (loaded && loaded.hash === hash) return loaded.config;
804
822
  loaded = {
805
823
  hash,
806
- config: Promise.resolve().then(() => (init_load(), load_exports)).then(
807
- (mod) => mod.loadConfig(configPath, outDir, buildConfig2)
808
- )
824
+ config: newConfig()
809
825
  };
810
826
  return loaded.config;
811
827
  }
@@ -840,25 +856,102 @@ function toWebpack(loader2) {
840
856
  };
841
857
  }
842
858
 
843
- // src/loader-mdx.ts
859
+ // src/core.ts
860
+ var import_node_path5 = __toESM(require("path"), 1);
861
+ var import_promises4 = __toESM(require("fs/promises"), 1);
862
+ function createCore(options, defaultPlugins = []) {
863
+ let config;
864
+ let plugins2;
865
+ return {
866
+ _options: options,
867
+ getPluginContext() {
868
+ return {
869
+ core: this,
870
+ ...options
871
+ };
872
+ },
873
+ /**
874
+ * Convenient cache store, reset when config changes
875
+ */
876
+ cache: /* @__PURE__ */ new Map(),
877
+ async init({ config: newConfig }) {
878
+ config = await newConfig;
879
+ this.cache.clear();
880
+ plugins2 = [];
881
+ for await (const option of [
882
+ ...defaultPlugins,
883
+ ...config.global.plugins ?? []
884
+ ]) {
885
+ if (!option) continue;
886
+ if (Array.isArray(option)) plugins2.push(...option);
887
+ else plugins2.push(option);
888
+ }
889
+ for (const plugin of plugins2) {
890
+ const out = await plugin.config?.call(this.getPluginContext(), config);
891
+ if (out) config = out;
892
+ }
893
+ return this;
894
+ },
895
+ getConfig() {
896
+ return config;
897
+ },
898
+ creatConfigLoader() {
899
+ return {
900
+ getConfig() {
901
+ return config;
902
+ }
903
+ };
904
+ },
905
+ async initServer(server) {
906
+ for (const plugin of plugins2) {
907
+ await plugin.configureServer?.call(this.getPluginContext(), server);
908
+ }
909
+ },
910
+ async emitAndWrite({
911
+ filterPlugin = () => true
912
+ } = {}) {
913
+ const start = performance.now();
914
+ const out = await Promise.all(
915
+ plugins2.map((plugin) => {
916
+ if (!filterPlugin(plugin) || !plugin.emit) return [];
917
+ return plugin.emit.call(this.getPluginContext());
918
+ })
919
+ );
920
+ await Promise.all(
921
+ out.flat().map(async (entry) => {
922
+ const file = import_node_path5.default.join(options.outDir, entry.path);
923
+ await import_promises4.default.mkdir(import_node_path5.default.dirname(file), { recursive: true });
924
+ await import_promises4.default.writeFile(file, entry.content);
925
+ })
926
+ );
927
+ console.log(`[MDX] generated files in ${performance.now() - start}ms`);
928
+ }
929
+ };
930
+ }
931
+
932
+ // src/webpack/index.ts
844
933
  var instance;
845
934
  async function loader(source, callback) {
846
935
  const { isDev, outDir, configPath } = this.getOptions();
847
936
  this.cacheable(true);
848
937
  this.addDependency(configPath);
849
- instance ??= toWebpack(
850
- createMdxLoader(
851
- // the config is built on dev server
852
- isDev ? dynamicConfig({
853
- outDir,
854
- configPath,
855
- buildConfig: false
856
- }) : staticConfig({
857
- outDir,
858
- configPath,
859
- buildConfig: false
860
- })
861
- )
862
- );
938
+ if (!instance) {
939
+ const core = createCore({
940
+ environment: "webpack",
941
+ outDir,
942
+ configPath
943
+ });
944
+ instance = toWebpack(
945
+ createMdxLoader(
946
+ isDev ? dynamicConfig({
947
+ core,
948
+ buildConfig: false
949
+ }) : staticConfig({
950
+ core,
951
+ buildConfig: false
952
+ })
953
+ )
954
+ );
955
+ }
863
956
  await instance.call(this, source, callback);
864
957
  }
@@ -0,0 +1,44 @@
1
+ import {
2
+ toWebpack
3
+ } from "../chunk-YVCR6FUH.js";
4
+ import {
5
+ createMdxLoader
6
+ } from "../chunk-XQ5O7IPO.js";
7
+ import "../chunk-3J3WL7WN.js";
8
+ import "../chunk-K5ZLPEIQ.js";
9
+ import {
10
+ createCore,
11
+ dynamicConfig,
12
+ staticConfig
13
+ } from "../chunk-EELYB2XC.js";
14
+ import "../chunk-VWJKRQZR.js";
15
+
16
+ // src/webpack/index.ts
17
+ var instance;
18
+ async function loader(source, callback) {
19
+ const { isDev, outDir, configPath } = this.getOptions();
20
+ this.cacheable(true);
21
+ this.addDependency(configPath);
22
+ if (!instance) {
23
+ const core = createCore({
24
+ environment: "webpack",
25
+ outDir,
26
+ configPath
27
+ });
28
+ instance = toWebpack(
29
+ createMdxLoader(
30
+ isDev ? dynamicConfig({
31
+ core,
32
+ buildConfig: false
33
+ }) : staticConfig({
34
+ core,
35
+ buildConfig: false
36
+ })
37
+ )
38
+ );
39
+ }
40
+ await instance.call(this, source, callback);
41
+ }
42
+ export {
43
+ loader as default
44
+ };
package/loader-mdx.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  module.exports = function loader(code) {
2
2
  const callback = this.async();
3
3
 
4
- import('./dist/loader-mdx.js').then((mod) =>
4
+ import('./dist/webpack/index.js').then((mod) =>
5
5
  mod.default.call(this, code, callback),
6
6
  );
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "13.0.0",
3
+ "version": "13.0.2",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -83,8 +83,8 @@
83
83
  "lru-cache": "^11.2.2",
84
84
  "mdast-util-to-markdown": "^2.1.2",
85
85
  "picocolors": "^1.1.1",
86
+ "picomatch": "^4.0.3",
86
87
  "remark-mdx": "^3.1.1",
87
- "remark-parse": "^11.0.0",
88
88
  "tinyexec": "^1.0.1",
89
89
  "tinyglobby": "^0.2.15",
90
90
  "unified": "^11.0.5",
@@ -98,6 +98,7 @@
98
98
  "@types/mdast": "^4.0.4",
99
99
  "@types/mdx": "^2.0.13",
100
100
  "@types/node": "^24.9.1",
101
+ "@types/picomatch": "^4.0.2",
101
102
  "@types/react": "^19.2.2",
102
103
  "mdast-util-directive": "^3.1.0",
103
104
  "mdast-util-mdx-jsx": "^3.2.0",
@@ -112,7 +113,7 @@
112
113
  "webpack": "^5.102.1",
113
114
  "@fumadocs/mdx-remote": "1.4.3",
114
115
  "eslint-config-custom": "0.0.0",
115
- "fumadocs-core": "16.0.0",
116
+ "fumadocs-core": "16.0.3",
116
117
  "tsconfig": "0.0.0"
117
118
  },
118
119
  "peerDependencies": {
@@ -1,44 +0,0 @@
1
- // src/plugins/index.ts
2
- import path from "path";
3
- import fs from "fs/promises";
4
- function createPluginHandler(context, defaultPlugins = []) {
5
- const plugins = [];
6
- async function write(entry) {
7
- const file = path.join(context.outDir, entry.path);
8
- await fs.mkdir(path.dirname(file), { recursive: true });
9
- await fs.writeFile(file, entry.content);
10
- }
11
- return {
12
- async init(config) {
13
- if (config.global.plugins) {
14
- defaultPlugins.push(...config.global.plugins);
15
- }
16
- for await (const option of defaultPlugins) {
17
- if (!option) continue;
18
- if (Array.isArray(option)) plugins.push(...option);
19
- else plugins.push(option);
20
- }
21
- for (const plugin of plugins) {
22
- const out = await plugin.config?.call(context, config);
23
- if (out) config = out;
24
- }
25
- return config;
26
- },
27
- async emit() {
28
- const out = await Promise.all(
29
- plugins.map((plugin) => {
30
- return plugin.emit?.call(context) ?? [];
31
- })
32
- );
33
- return out.flat();
34
- },
35
- async emitAndWrite() {
36
- const entries = await this.emit();
37
- await Promise.all(entries.map(write));
38
- }
39
- };
40
- }
41
-
42
- export {
43
- createPluginHandler
44
- };
@@ -1,127 +0,0 @@
1
- // src/loaders/config/index.ts
2
- import path from "path";
3
- import fs from "fs/promises";
4
- function findConfigFile() {
5
- return path.resolve("source.config.ts");
6
- }
7
- function resolvedConfig(loaded) {
8
- return {
9
- getConfig() {
10
- return loaded;
11
- }
12
- };
13
- }
14
- function staticConfig({
15
- outDir,
16
- configPath,
17
- buildConfig
18
- }) {
19
- let cached;
20
- return {
21
- async getConfig() {
22
- if (cached) return cached;
23
- cached = import("./load-MNG3CLET.js").then(
24
- (mod) => mod.loadConfig(configPath, outDir, buildConfig)
25
- );
26
- return cached;
27
- }
28
- };
29
- }
30
- function dynamicConfig({
31
- outDir,
32
- configPath,
33
- buildConfig
34
- }) {
35
- let loaded;
36
- async function getConfigHash() {
37
- const stats = await fs.stat(configPath).catch(() => void 0);
38
- if (stats) {
39
- return stats.mtime.getTime().toString();
40
- }
41
- throw new Error("Cannot find config file");
42
- }
43
- return {
44
- async getConfig() {
45
- const hash = await getConfigHash();
46
- if (loaded && loaded.hash === hash) return loaded.config;
47
- loaded = {
48
- hash,
49
- config: import("./load-MNG3CLET.js").then(
50
- (mod) => mod.loadConfig(configPath, outDir, buildConfig)
51
- )
52
- };
53
- return loaded.config;
54
- }
55
- };
56
- }
57
-
58
- // src/utils/validation.ts
59
- import picocolors from "picocolors";
60
- var ValidationError = class extends Error {
61
- constructor(message, issues) {
62
- super(
63
- `${message}:
64
- ${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`
65
- );
66
- this.title = message;
67
- this.issues = issues;
68
- }
69
- toStringFormatted() {
70
- return [
71
- picocolors.bold(`[MDX] ${this.title}:`),
72
- ...this.issues.map(
73
- (issue) => picocolors.redBright(
74
- `- ${picocolors.bold(issue.path?.join(".") ?? "*")}: ${issue.message}`
75
- )
76
- )
77
- ].join("\n");
78
- }
79
- };
80
- async function validate(schema, data, context, errorMessage) {
81
- if (typeof schema === "function" && !("~standard" in schema)) {
82
- schema = schema(context);
83
- }
84
- if ("~standard" in schema) {
85
- const result = await schema["~standard"].validate(
86
- data
87
- );
88
- if (result.issues) {
89
- throw new ValidationError(errorMessage, result.issues);
90
- }
91
- return result.value;
92
- }
93
- return data;
94
- }
95
-
96
- // src/utils/git-timestamp.ts
97
- import path2 from "path";
98
- import { x } from "tinyexec";
99
- var cache = /* @__PURE__ */ new Map();
100
- async function getGitTimestamp(file) {
101
- const cached = cache.get(file);
102
- if (cached) return cached;
103
- try {
104
- const out = await x(
105
- "git",
106
- ["log", "-1", '--pretty="%ai"', path2.relative(process.cwd(), file)],
107
- {
108
- throwOnError: true
109
- }
110
- );
111
- const time = new Date(out.stdout);
112
- cache.set(file, time);
113
- return time;
114
- } catch {
115
- return;
116
- }
117
- }
118
-
119
- export {
120
- findConfigFile,
121
- resolvedConfig,
122
- staticConfig,
123
- dynamicConfig,
124
- ValidationError,
125
- validate,
126
- getGitTimestamp
127
- };
@@ -1,39 +0,0 @@
1
- import {
2
- toWebpack
3
- } from "./chunk-XV5Z4BFL.js";
4
- import {
5
- createMdxLoader
6
- } from "./chunk-CEA6MYJU.js";
7
- import "./chunk-3J3WL7WN.js";
8
- import "./chunk-K5ZLPEIQ.js";
9
- import {
10
- dynamicConfig,
11
- staticConfig
12
- } from "./chunk-HI62EXSB.js";
13
- import "./chunk-VWJKRQZR.js";
14
-
15
- // src/loader-mdx.ts
16
- var instance;
17
- async function loader(source, callback) {
18
- const { isDev, outDir, configPath } = this.getOptions();
19
- this.cacheable(true);
20
- this.addDependency(configPath);
21
- instance ??= toWebpack(
22
- createMdxLoader(
23
- // the config is built on dev server
24
- isDev ? dynamicConfig({
25
- outDir,
26
- configPath,
27
- buildConfig: false
28
- }) : staticConfig({
29
- outDir,
30
- configPath,
31
- buildConfig: false
32
- })
33
- )
34
- );
35
- await instance.call(this, source, callback);
36
- }
37
- export {
38
- loader as default
39
- };
@@ -1,78 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/plugins/index.ts
31
- var plugins_exports = {};
32
- __export(plugins_exports, {
33
- createPluginHandler: () => createPluginHandler
34
- });
35
- module.exports = __toCommonJS(plugins_exports);
36
- var import_node_path = __toESM(require("path"), 1);
37
- var import_promises = __toESM(require("fs/promises"), 1);
38
- function createPluginHandler(context, defaultPlugins = []) {
39
- const plugins = [];
40
- async function write(entry) {
41
- const file = import_node_path.default.join(context.outDir, entry.path);
42
- await import_promises.default.mkdir(import_node_path.default.dirname(file), { recursive: true });
43
- await import_promises.default.writeFile(file, entry.content);
44
- }
45
- return {
46
- async init(config) {
47
- if (config.global.plugins) {
48
- defaultPlugins.push(...config.global.plugins);
49
- }
50
- for await (const option of defaultPlugins) {
51
- if (!option) continue;
52
- if (Array.isArray(option)) plugins.push(...option);
53
- else plugins.push(option);
54
- }
55
- for (const plugin of plugins) {
56
- const out = await plugin.config?.call(context, config);
57
- if (out) config = out;
58
- }
59
- return config;
60
- },
61
- async emit() {
62
- const out = await Promise.all(
63
- plugins.map((plugin) => {
64
- return plugin.emit?.call(context) ?? [];
65
- })
66
- );
67
- return out.flat();
68
- },
69
- async emitAndWrite() {
70
- const entries = await this.emit();
71
- await Promise.all(entries.map(write));
72
- }
73
- };
74
- }
75
- // Annotate the CommonJS export names for ESM import in node:
76
- 0 && (module.exports = {
77
- createPluginHandler
78
- });
@@ -1,7 +0,0 @@
1
- export { E as EmitEntry, P as Plugin, h as PluginContext, i as PluginOption, j as createPluginHandler } from '../define-BCNh3n4O.cjs';
2
- import '@standard-schema/spec';
3
- import 'fumadocs-core/mdx-plugins';
4
- import '@mdx-js/mdx';
5
- import 'unified';
6
- import 'zod';
7
- import '../remark-postprocess-K233ZVBK.cjs';
@@ -1,7 +0,0 @@
1
- export { E as EmitEntry, P as Plugin, h as PluginContext, i as PluginOption, j as createPluginHandler } from '../define-bck_EB4t.js';
2
- import '@standard-schema/spec';
3
- import 'fumadocs-core/mdx-plugins';
4
- import '@mdx-js/mdx';
5
- import 'unified';
6
- import 'zod';
7
- import '../remark-postprocess-K233ZVBK.js';