fumadocs-mdx 14.0.0 → 14.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.cjs +270 -201
- package/dist/bun/index.cjs +63 -28
- package/dist/bun/index.d.cts +7 -1
- package/dist/bun/index.d.ts +7 -1
- package/dist/bun/index.js +6 -5
- package/dist/{chunk-5YXP7JLN.js → chunk-5OBUOALK.js} +8 -5
- package/dist/{chunk-XHJCLBZ4.js → chunk-7UKSZSPY.js} +87 -162
- package/dist/{chunk-7L2KNF6B.js → chunk-BEBCWQC7.js} +51 -7
- package/dist/{chunk-5UMZCWKV.js → chunk-IQGEFL2B.js} +1 -1
- package/dist/{chunk-SRSRFOVI.js → chunk-K6HCOGOX.js} +3 -3
- package/dist/{chunk-OXSRIWQW.js → chunk-MTTISKQJ.js} +3 -2
- package/dist/chunk-WBIHDYMN.js +126 -0
- package/dist/config/index.d.cts +6 -1
- package/dist/config/index.d.ts +6 -1
- package/dist/{index-D7JdSMpp.d.cts → core-B9ZoS6sA.d.ts} +73 -4
- package/dist/{index-D7JdSMpp.d.ts → core-DTuP23zu.d.cts} +73 -4
- package/dist/{index-BlVBvy-z.d.ts → index-BD8Woo4m.d.cts} +1 -1
- package/dist/{index-P2NNUkHn.d.cts → index-CNOvhtOn.d.ts} +1 -1
- package/dist/index.d.cts +56 -3
- package/dist/index.d.ts +56 -3
- package/dist/{load-from-file-I3ALLIVB.js → load-from-file-5HUQN36V.js} +1 -1
- package/dist/next/index.cjs +260 -192
- package/dist/next/index.d.cts +7 -2
- package/dist/next/index.d.ts +7 -2
- package/dist/next/index.js +10 -8
- package/dist/node/loader.cjs +72 -37
- package/dist/node/loader.js +3 -3
- package/dist/plugins/index-file.cjs +69 -45
- package/dist/plugins/index-file.d.cts +7 -22
- package/dist/plugins/index-file.d.ts +7 -22
- package/dist/plugins/index-file.js +2 -2
- package/dist/plugins/json-schema.d.cts +7 -1
- package/dist/plugins/json-schema.d.ts +7 -1
- package/dist/plugins/last-modified.cjs +41 -6
- package/dist/plugins/last-modified.d.cts +11 -1
- package/dist/plugins/last-modified.d.ts +11 -1
- package/dist/plugins/last-modified.js +34 -4
- package/dist/runtime/browser.cjs +7 -8
- package/dist/runtime/browser.d.cts +22 -19
- package/dist/runtime/browser.d.ts +22 -19
- package/dist/runtime/browser.js +5 -6
- package/dist/runtime/dynamic.cjs +81 -43
- package/dist/runtime/dynamic.d.cts +12 -12
- package/dist/runtime/dynamic.d.ts +12 -12
- package/dist/runtime/dynamic.js +9 -8
- package/dist/runtime/server.cjs +9 -6
- package/dist/runtime/server.d.cts +10 -157
- package/dist/runtime/server.d.ts +10 -157
- package/dist/runtime/server.js +3 -3
- package/dist/runtime/types.cjs +18 -0
- package/dist/runtime/types.d.cts +61 -0
- package/dist/runtime/types.d.ts +61 -0
- package/dist/runtime/types.js +0 -0
- package/dist/vite/index.cjs +257 -190
- package/dist/vite/index.d.cts +7 -2
- package/dist/vite/index.d.ts +7 -2
- package/dist/vite/index.js +7 -6
- package/dist/webpack/mdx.cjs +60 -25
- package/dist/webpack/mdx.d.cts +8 -2
- package/dist/webpack/mdx.d.ts +8 -2
- package/dist/webpack/mdx.js +4 -4
- package/dist/webpack/meta.cjs +60 -25
- package/dist/webpack/meta.d.cts +8 -2
- package/dist/webpack/meta.d.ts +8 -2
- package/dist/webpack/meta.js +4 -4
- package/package.json +2 -2
- package/dist/chunk-PKI7ZDA5.js +0 -29
package/dist/next/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadConfig
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-MTTISKQJ.js";
|
|
4
4
|
import "../chunk-ZY6UZ7NH.js";
|
|
5
5
|
import "../chunk-E5DJTSIM.js";
|
|
6
6
|
import {
|
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
ValidationError,
|
|
12
12
|
_Defaults,
|
|
13
13
|
createCore
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-BEBCWQC7.js";
|
|
15
15
|
import {
|
|
16
16
|
indexFile
|
|
17
|
-
} from "../chunk-
|
|
18
|
-
import "../chunk-
|
|
17
|
+
} from "../chunk-7UKSZSPY.js";
|
|
18
|
+
import "../chunk-WBIHDYMN.js";
|
|
19
19
|
import "../chunk-VWJKRQZR.js";
|
|
20
20
|
|
|
21
21
|
// src/next/index.ts
|
|
@@ -30,7 +30,7 @@ function createMDX(createOptions = {}) {
|
|
|
30
30
|
}
|
|
31
31
|
return (nextConfig = {}) => {
|
|
32
32
|
const loaderOptions = {
|
|
33
|
-
...core.
|
|
33
|
+
...core.getOptions(),
|
|
34
34
|
compiledConfigPath: core.getCompiledConfigPath(),
|
|
35
35
|
isDev
|
|
36
36
|
};
|
|
@@ -112,12 +112,13 @@ async function init(dev, core) {
|
|
|
112
112
|
}
|
|
113
113
|
async function devServer() {
|
|
114
114
|
const { FSWatcher } = await import("chokidar");
|
|
115
|
+
const { configPath, outDir } = core.getOptions();
|
|
115
116
|
const watcher = new FSWatcher({
|
|
116
117
|
ignoreInitial: true,
|
|
117
118
|
persistent: true,
|
|
118
|
-
ignored: [
|
|
119
|
+
ignored: [outDir]
|
|
119
120
|
});
|
|
120
|
-
watcher.add(
|
|
121
|
+
watcher.add(configPath);
|
|
121
122
|
for (const collection of core.getConfig().collectionList) {
|
|
122
123
|
if (collection.type === "docs") {
|
|
123
124
|
watcher.add(collection.docs.dir);
|
|
@@ -129,8 +130,9 @@ async function init(dev, core) {
|
|
|
129
130
|
watcher.on("ready", () => {
|
|
130
131
|
console.log("[MDX] started dev server");
|
|
131
132
|
});
|
|
133
|
+
const absoluteConfigPath = path.resolve(configPath);
|
|
132
134
|
watcher.on("all", async (_event, file) => {
|
|
133
|
-
if (path.resolve(file) ===
|
|
135
|
+
if (path.resolve(file) === absoluteConfigPath) {
|
|
134
136
|
watcher.removeAllListeners();
|
|
135
137
|
await watcher.close();
|
|
136
138
|
await initOrReload();
|
package/dist/node/loader.cjs
CHANGED
|
@@ -177,7 +177,7 @@ function remarkInclude() {
|
|
|
177
177
|
const embedContent = async (file, heading, params, data) => {
|
|
178
178
|
let content;
|
|
179
179
|
try {
|
|
180
|
-
content = (await
|
|
180
|
+
content = (await fs2.readFile(file)).toString();
|
|
181
181
|
} catch (e) {
|
|
182
182
|
throw new Error(
|
|
183
183
|
`failed to read file ${file}
|
|
@@ -250,14 +250,14 @@ ${e instanceof Error ? e.message : String(e)}`,
|
|
|
250
250
|
await update(tree, path3.dirname(file.path), file.data);
|
|
251
251
|
};
|
|
252
252
|
}
|
|
253
|
-
var import_unified, import_unist_util_visit2, path3,
|
|
253
|
+
var import_unified, import_unist_util_visit2, path3, fs2, import_mdx_plugins, ElementLikeTypes;
|
|
254
254
|
var init_remark_include = __esm({
|
|
255
255
|
"src/loaders/mdx/remark-include.ts"() {
|
|
256
256
|
"use strict";
|
|
257
257
|
import_unified = require("unified");
|
|
258
258
|
import_unist_util_visit2 = require("unist-util-visit");
|
|
259
259
|
path3 = __toESM(require("path"), 1);
|
|
260
|
-
|
|
260
|
+
fs2 = __toESM(require("fs/promises"), 1);
|
|
261
261
|
init_fuma_matter();
|
|
262
262
|
import_mdx_plugins = require("fumadocs-core/mdx-plugins");
|
|
263
263
|
init_remark_unravel();
|
|
@@ -653,10 +653,11 @@ __export(load_from_file_exports, {
|
|
|
653
653
|
});
|
|
654
654
|
async function compileConfig(core2) {
|
|
655
655
|
const { build } = await import("esbuild");
|
|
656
|
+
const { configPath, outDir } = core2.getOptions();
|
|
656
657
|
const transformed = await build({
|
|
657
|
-
entryPoints: [{ in:
|
|
658
|
+
entryPoints: [{ in: configPath, out: "source.config" }],
|
|
658
659
|
bundle: true,
|
|
659
|
-
outdir:
|
|
660
|
+
outdir: outDir,
|
|
660
661
|
target: "node20",
|
|
661
662
|
write: true,
|
|
662
663
|
platform: "node",
|
|
@@ -698,24 +699,7 @@ module.exports = __toCommonJS(loader_exports);
|
|
|
698
699
|
|
|
699
700
|
// src/core.ts
|
|
700
701
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
701
|
-
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
702
|
-
|
|
703
|
-
// src/utils/codegen/cache.ts
|
|
704
|
-
var import_lru_cache = require("lru-cache");
|
|
705
702
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
706
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
707
|
-
var map = new import_lru_cache.LRUCache({
|
|
708
|
-
max: 100
|
|
709
|
-
});
|
|
710
|
-
function toFullPath(file) {
|
|
711
|
-
if (import_node_path.default.isAbsolute(file)) {
|
|
712
|
-
return import_node_path.default.relative(process.cwd(), file);
|
|
713
|
-
}
|
|
714
|
-
return file;
|
|
715
|
-
}
|
|
716
|
-
function removeFileCache(file) {
|
|
717
|
-
map.delete(toFullPath(file));
|
|
718
|
-
}
|
|
719
703
|
|
|
720
704
|
// src/utils/validation.ts
|
|
721
705
|
var ValidationError = class extends Error {
|
|
@@ -755,6 +739,13 @@ async function validate(schema, data, context, errorMessage) {
|
|
|
755
739
|
return data;
|
|
756
740
|
}
|
|
757
741
|
|
|
742
|
+
// src/utils/codegen.ts
|
|
743
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
744
|
+
var import_tinyglobby = require("tinyglobby");
|
|
745
|
+
function ident(code, tab = 1) {
|
|
746
|
+
return code.split("\n").map((v) => " ".repeat(tab) + v).join("\n");
|
|
747
|
+
}
|
|
748
|
+
|
|
758
749
|
// src/core.ts
|
|
759
750
|
var _Defaults = {
|
|
760
751
|
configPath: "source.config.ts",
|
|
@@ -788,7 +779,6 @@ function createCore(options, defaultPlugins = []) {
|
|
|
788
779
|
return data;
|
|
789
780
|
}
|
|
790
781
|
const core2 = {
|
|
791
|
-
_options: options,
|
|
792
782
|
/**
|
|
793
783
|
* Convenient cache store, reset when config changes
|
|
794
784
|
*/
|
|
@@ -797,6 +787,7 @@ function createCore(options, defaultPlugins = []) {
|
|
|
797
787
|
config = await newConfig;
|
|
798
788
|
this.cache.clear();
|
|
799
789
|
plugins = await getPlugins([
|
|
790
|
+
postprocessPlugin(),
|
|
800
791
|
...defaultPlugins,
|
|
801
792
|
...config.global.plugins ?? []
|
|
802
793
|
]);
|
|
@@ -804,7 +795,9 @@ function createCore(options, defaultPlugins = []) {
|
|
|
804
795
|
const out = await plugin.config?.call(pluginContext, config);
|
|
805
796
|
if (out) config = out;
|
|
806
797
|
}
|
|
807
|
-
|
|
798
|
+
},
|
|
799
|
+
getOptions() {
|
|
800
|
+
return options;
|
|
808
801
|
},
|
|
809
802
|
getConfig() {
|
|
810
803
|
return config;
|
|
@@ -815,10 +808,13 @@ function createCore(options, defaultPlugins = []) {
|
|
|
815
808
|
getCompiledConfigPath() {
|
|
816
809
|
return import_node_path2.default.join(options.outDir, "source.config.mjs");
|
|
817
810
|
},
|
|
811
|
+
getPlugins() {
|
|
812
|
+
return plugins;
|
|
813
|
+
},
|
|
814
|
+
getPluginContext() {
|
|
815
|
+
return pluginContext;
|
|
816
|
+
},
|
|
818
817
|
async initServer(server) {
|
|
819
|
-
server.watcher?.on("all", async (event, file) => {
|
|
820
|
-
if (event === "change") removeFileCache(file);
|
|
821
|
-
});
|
|
822
818
|
for (const plugin of plugins) {
|
|
823
819
|
await plugin.configureServer?.call(pluginContext, server);
|
|
824
820
|
}
|
|
@@ -837,8 +833,8 @@ function createCore(options, defaultPlugins = []) {
|
|
|
837
833
|
await Promise.all(
|
|
838
834
|
out.map(async (entry) => {
|
|
839
835
|
const file = import_node_path2.default.join(options.outDir, entry.path);
|
|
840
|
-
await
|
|
841
|
-
await
|
|
836
|
+
await import_promises.default.mkdir(import_node_path2.default.dirname(file), { recursive: true });
|
|
837
|
+
await import_promises.default.writeFile(file, entry.content);
|
|
842
838
|
})
|
|
843
839
|
);
|
|
844
840
|
console.log(`[MDX] generated files in ${performance.now() - start}ms`);
|
|
@@ -885,11 +881,50 @@ function createCore(options, defaultPlugins = []) {
|
|
|
885
881
|
};
|
|
886
882
|
return core2;
|
|
887
883
|
}
|
|
884
|
+
function postprocessPlugin() {
|
|
885
|
+
const LinkReferenceTypes = `{
|
|
886
|
+
/**
|
|
887
|
+
* extracted references (e.g. hrefs, paths), useful for analyzing relationships between pages.
|
|
888
|
+
*/
|
|
889
|
+
extractedReferences?: import('fumadocs-mdx').ExtractedReference[];
|
|
890
|
+
}`;
|
|
891
|
+
return {
|
|
892
|
+
"index-file": {
|
|
893
|
+
generateTypeConfig() {
|
|
894
|
+
const lines = [];
|
|
895
|
+
lines.push("{");
|
|
896
|
+
lines.push(" DocData: {");
|
|
897
|
+
for (const collection of this.core.getConfig().collectionList) {
|
|
898
|
+
let postprocessOptions;
|
|
899
|
+
switch (collection.type) {
|
|
900
|
+
case "doc":
|
|
901
|
+
postprocessOptions = collection.postprocess;
|
|
902
|
+
break;
|
|
903
|
+
case "docs":
|
|
904
|
+
postprocessOptions = collection.docs.postprocess;
|
|
905
|
+
break;
|
|
906
|
+
}
|
|
907
|
+
if (postprocessOptions?.extractLinkReferences) {
|
|
908
|
+
lines.push(ident(`${collection.name}: ${LinkReferenceTypes},`, 2));
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
lines.push(" }");
|
|
912
|
+
lines.push("}");
|
|
913
|
+
return lines.join("\n");
|
|
914
|
+
},
|
|
915
|
+
serverOptions(options) {
|
|
916
|
+
options.doc ??= {};
|
|
917
|
+
options.doc.passthroughs ??= [];
|
|
918
|
+
options.doc.passthroughs.push("extractedReferences");
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
}
|
|
888
923
|
|
|
889
924
|
// src/loaders/mdx/index.ts
|
|
890
925
|
init_fuma_matter();
|
|
891
926
|
var import_zod = require("zod");
|
|
892
|
-
var
|
|
927
|
+
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
893
928
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
894
929
|
var import_node_crypto = require("crypto");
|
|
895
930
|
|
|
@@ -925,11 +960,11 @@ function createMdxLoader(configLoader2) {
|
|
|
925
960
|
if (!isDevelopment && config.global.experimentalBuildCache) {
|
|
926
961
|
const cacheDir = config.global.experimentalBuildCache;
|
|
927
962
|
const cacheKey = `${parsed.hash}_${parsed.collection ?? "global"}_${generateCacheHash(filePath)}`;
|
|
928
|
-
const cached = await
|
|
963
|
+
const cached = await import_promises2.default.readFile(import_node_path3.default.join(cacheDir, cacheKey)).then((content) => cacheEntry.parse(JSON.parse(content.toString()))).catch(() => null);
|
|
929
964
|
if (cached && cached.hash === generateCacheHash(value)) return cached;
|
|
930
965
|
after = async () => {
|
|
931
|
-
await
|
|
932
|
-
await
|
|
966
|
+
await import_promises2.default.mkdir(cacheDir, { recursive: true });
|
|
967
|
+
await import_promises2.default.writeFile(
|
|
933
968
|
import_node_path3.default.join(cacheDir, cacheKey),
|
|
934
969
|
JSON.stringify({
|
|
935
970
|
...out,
|
|
@@ -992,7 +1027,7 @@ function countLines(s) {
|
|
|
992
1027
|
|
|
993
1028
|
// src/loaders/adapter.ts
|
|
994
1029
|
var import_node_url = require("url");
|
|
995
|
-
var
|
|
1030
|
+
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
996
1031
|
var import_node_querystring = require("querystring");
|
|
997
1032
|
var import_node_path4 = __toESM(require("path"), 1);
|
|
998
1033
|
var import_node_fs = require("fs");
|
|
@@ -1005,7 +1040,7 @@ function toNode(loader) {
|
|
|
1005
1040
|
filePath,
|
|
1006
1041
|
query: Object.fromEntries(parsedUrl.searchParams.entries()),
|
|
1007
1042
|
async getSource() {
|
|
1008
|
-
return (await
|
|
1043
|
+
return (await import_promises3.default.readFile(filePath)).toString();
|
|
1009
1044
|
},
|
|
1010
1045
|
development: false,
|
|
1011
1046
|
compiler: {
|
|
@@ -1026,7 +1061,7 @@ function toNode(loader) {
|
|
|
1026
1061
|
}
|
|
1027
1062
|
|
|
1028
1063
|
// src/loaders/config.ts
|
|
1029
|
-
var
|
|
1064
|
+
var import_promises4 = __toESM(require("fs/promises"), 1);
|
|
1030
1065
|
function createStandaloneConfigLoader({
|
|
1031
1066
|
core: core2,
|
|
1032
1067
|
buildConfig: buildConfig2,
|
|
@@ -1035,7 +1070,7 @@ function createStandaloneConfigLoader({
|
|
|
1035
1070
|
let loaded;
|
|
1036
1071
|
async function getConfigHash() {
|
|
1037
1072
|
if (mode === "production") return "static";
|
|
1038
|
-
const stats = await
|
|
1073
|
+
const stats = await import_promises4.default.stat(core2.getOptions().configPath).catch(() => {
|
|
1039
1074
|
throw new Error("Cannot find config file");
|
|
1040
1075
|
});
|
|
1041
1076
|
return stats.mtime.getTime().toString();
|
package/dist/node/loader.js
CHANGED
|
@@ -7,13 +7,13 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
createStandaloneConfigLoader,
|
|
9
9
|
toNode
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-K6HCOGOX.js";
|
|
11
11
|
import "../chunk-4JSFLXXT.js";
|
|
12
12
|
import {
|
|
13
13
|
_Defaults,
|
|
14
14
|
createCore
|
|
15
|
-
} from "../chunk-
|
|
16
|
-
import "../chunk-
|
|
15
|
+
} from "../chunk-BEBCWQC7.js";
|
|
16
|
+
import "../chunk-WBIHDYMN.js";
|
|
17
17
|
import "../chunk-VWJKRQZR.js";
|
|
18
18
|
|
|
19
19
|
// src/node/loader.ts
|
|
@@ -35,7 +35,7 @@ __export(index_file_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(index_file_exports);
|
|
36
36
|
var import_path = __toESM(require("path"), 1);
|
|
37
37
|
|
|
38
|
-
// src/utils/codegen
|
|
38
|
+
// src/utils/codegen.ts
|
|
39
39
|
var import_node_path = __toESM(require("path"), 1);
|
|
40
40
|
var import_tinyglobby = require("tinyglobby");
|
|
41
41
|
function createCodegen({
|
|
@@ -160,7 +160,7 @@ function ident(code, tab = 1) {
|
|
|
160
160
|
// src/plugins/index-file.ts
|
|
161
161
|
var import_tinyglobby2 = require("tinyglobby");
|
|
162
162
|
|
|
163
|
-
// src/utils/
|
|
163
|
+
// src/utils/fs-cache.ts
|
|
164
164
|
var import_lru_cache = require("lru-cache");
|
|
165
165
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
166
166
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
@@ -173,7 +173,7 @@ function toFullPath(file) {
|
|
|
173
173
|
}
|
|
174
174
|
return file;
|
|
175
175
|
}
|
|
176
|
-
|
|
176
|
+
function readFileWithCache(file) {
|
|
177
177
|
const fullPath = toFullPath(file);
|
|
178
178
|
const cached = map.get(fullPath);
|
|
179
179
|
if (cached) return cached;
|
|
@@ -181,6 +181,9 @@ async function readFileWithCache(file) {
|
|
|
181
181
|
map.set(fullPath, read);
|
|
182
182
|
return read;
|
|
183
183
|
}
|
|
184
|
+
function removeFileCache(file) {
|
|
185
|
+
map.delete(toFullPath(file));
|
|
186
|
+
}
|
|
184
187
|
|
|
185
188
|
// src/plugins/index-file.ts
|
|
186
189
|
var import_crypto = require("crypto");
|
|
@@ -214,6 +217,25 @@ function indexFile(options = {}) {
|
|
|
214
217
|
function isDynamic(collection) {
|
|
215
218
|
return collection.type === "docs" && collection.docs.dynamic || collection.type === "doc" && collection.dynamic;
|
|
216
219
|
}
|
|
220
|
+
function generateConfigs(core) {
|
|
221
|
+
const serverOptions = {};
|
|
222
|
+
const typeConfigs = [];
|
|
223
|
+
const ctx = core.getPluginContext();
|
|
224
|
+
for (const plugin of core.getPlugins()) {
|
|
225
|
+
const indexFilePlugin = plugin["index-file"];
|
|
226
|
+
if (!indexFilePlugin) continue;
|
|
227
|
+
indexFilePlugin.serverOptions?.call(ctx, serverOptions);
|
|
228
|
+
const config2 = indexFilePlugin.generateTypeConfig?.call(ctx);
|
|
229
|
+
if (config2) typeConfigs.push(config2);
|
|
230
|
+
}
|
|
231
|
+
if (typeConfigs.length === 0) {
|
|
232
|
+
typeConfigs.push("{ DocData: {} }");
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
serverOptions,
|
|
236
|
+
tc: typeConfigs.join(" & ")
|
|
237
|
+
};
|
|
238
|
+
}
|
|
217
239
|
return {
|
|
218
240
|
name: "index-file",
|
|
219
241
|
config(v) {
|
|
@@ -223,6 +245,7 @@ function indexFile(options = {}) {
|
|
|
223
245
|
configureServer(server) {
|
|
224
246
|
if (!server.watcher) return;
|
|
225
247
|
server.watcher.on("all", async (event, file) => {
|
|
248
|
+
removeFileCache(file);
|
|
226
249
|
if (dynamicCollections.length === 0) {
|
|
227
250
|
if (target === "vite") return;
|
|
228
251
|
if (target === "default" && event === "change") return;
|
|
@@ -242,48 +265,47 @@ function indexFile(options = {}) {
|
|
|
242
265
|
},
|
|
243
266
|
async emit() {
|
|
244
267
|
const globCache = /* @__PURE__ */ new Map();
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
268
|
+
const { serverOptions, tc } = generateConfigs(this.core);
|
|
269
|
+
const toEmitEntry = async (path4, content) => {
|
|
270
|
+
const codegen = createCodegen({
|
|
271
|
+
target,
|
|
272
|
+
outDir: this.outDir,
|
|
273
|
+
jsExtension: addJsExtension,
|
|
274
|
+
globCache
|
|
275
|
+
});
|
|
276
|
+
await content({
|
|
277
|
+
core: this.core,
|
|
278
|
+
codegen,
|
|
279
|
+
serverOptions,
|
|
280
|
+
tc
|
|
281
|
+
});
|
|
252
282
|
return {
|
|
253
283
|
path: path4,
|
|
254
|
-
content:
|
|
284
|
+
content: codegen.toString()
|
|
255
285
|
};
|
|
256
|
-
}
|
|
286
|
+
};
|
|
257
287
|
const out = [
|
|
258
|
-
toEmitEntry(
|
|
259
|
-
"server.ts",
|
|
260
|
-
generateServerIndexFile(makeCodeGen(), config, this.configPath)
|
|
261
|
-
)
|
|
288
|
+
toEmitEntry("server.ts", generateServerIndexFile)
|
|
262
289
|
];
|
|
263
290
|
if (dynamic)
|
|
264
|
-
out.push(
|
|
265
|
-
toEmitEntry(
|
|
266
|
-
"dynamic.ts",
|
|
267
|
-
generateDynamicIndexFile(this.core, makeCodeGen())
|
|
268
|
-
)
|
|
269
|
-
);
|
|
291
|
+
out.push(toEmitEntry("dynamic.ts", generateDynamicIndexFile));
|
|
270
292
|
if (browser)
|
|
271
|
-
out.push(
|
|
272
|
-
toEmitEntry(
|
|
273
|
-
"browser.ts",
|
|
274
|
-
generateBrowserIndexFile(makeCodeGen(), config, this.configPath)
|
|
275
|
-
)
|
|
276
|
-
);
|
|
293
|
+
out.push(toEmitEntry("browser.ts", generateBrowserIndexFile));
|
|
277
294
|
return await Promise.all(out);
|
|
278
295
|
}
|
|
279
296
|
};
|
|
280
297
|
}
|
|
281
|
-
async function generateServerIndexFile(
|
|
298
|
+
async function generateServerIndexFile({
|
|
299
|
+
core,
|
|
300
|
+
codegen,
|
|
301
|
+
serverOptions,
|
|
302
|
+
tc
|
|
303
|
+
}) {
|
|
282
304
|
codegen.lines.push(
|
|
283
|
-
`import {
|
|
284
|
-
`import type * as Config from '${codegen.formatImportPath(configPath)}';`,
|
|
305
|
+
`import { server } from 'fumadocs-mdx/runtime/server';`,
|
|
306
|
+
`import type * as Config from '${codegen.formatImportPath(core.getOptions().configPath)}';`,
|
|
285
307
|
"",
|
|
286
|
-
`const create =
|
|
308
|
+
`const create = server<typeof Config, ${tc}>(${JSON.stringify(serverOptions)});`
|
|
287
309
|
);
|
|
288
310
|
async function generateCollectionObject(collection) {
|
|
289
311
|
switch (collection.type) {
|
|
@@ -330,22 +352,26 @@ async function generateServerIndexFile(codegen, config, configPath) {
|
|
|
330
352
|
}
|
|
331
353
|
}
|
|
332
354
|
await codegen.pushAsync(
|
|
333
|
-
|
|
355
|
+
core.getConfig().collectionList.map(async (collection) => {
|
|
334
356
|
const obj = await generateCollectionObject(collection);
|
|
335
357
|
if (!obj) return;
|
|
336
358
|
return `
|
|
337
359
|
export const ${collection.name} = ${obj};`;
|
|
338
360
|
})
|
|
339
361
|
);
|
|
340
|
-
return codegen.toString();
|
|
341
362
|
}
|
|
342
|
-
async function generateDynamicIndexFile(
|
|
343
|
-
|
|
363
|
+
async function generateDynamicIndexFile({
|
|
364
|
+
core,
|
|
365
|
+
codegen,
|
|
366
|
+
serverOptions,
|
|
367
|
+
tc
|
|
368
|
+
}) {
|
|
369
|
+
const { configPath } = core.getOptions();
|
|
344
370
|
codegen.lines.push(
|
|
345
|
-
`import {
|
|
371
|
+
`import { dynamic } from 'fumadocs-mdx/runtime/dynamic';`,
|
|
346
372
|
`import * as Config from '${codegen.formatImportPath(configPath)}';`,
|
|
347
373
|
"",
|
|
348
|
-
`const create = await
|
|
374
|
+
`const create = await dynamic<typeof Config, ${tc}>(Config, ${JSON.stringify(core.getOptions())}, ${JSON.stringify(serverOptions)});`
|
|
349
375
|
);
|
|
350
376
|
async function generateCollectionObjectEntry(collection, file) {
|
|
351
377
|
const fullPath = import_path.default.join(collection.dir, file);
|
|
@@ -408,14 +434,13 @@ async function generateDynamicIndexFile(core, codegen) {
|
|
|
408
434
|
export const ${collection.name} = ${obj};`;
|
|
409
435
|
})
|
|
410
436
|
);
|
|
411
|
-
return codegen.toString();
|
|
412
437
|
}
|
|
413
|
-
async function generateBrowserIndexFile(
|
|
438
|
+
async function generateBrowserIndexFile({ core, codegen, tc }) {
|
|
414
439
|
codegen.lines.push(
|
|
415
|
-
`import {
|
|
416
|
-
`import type * as Config from '${codegen.formatImportPath(configPath)}';`,
|
|
440
|
+
`import { browser } from 'fumadocs-mdx/runtime/browser';`,
|
|
441
|
+
`import type * as Config from '${codegen.formatImportPath(core.getOptions().configPath)}';`,
|
|
417
442
|
"",
|
|
418
|
-
`const create =
|
|
443
|
+
`const create = browser<typeof Config, ${tc}>();`
|
|
419
444
|
);
|
|
420
445
|
async function generateCollectionObject(collection) {
|
|
421
446
|
switch (collection.type) {
|
|
@@ -430,14 +455,13 @@ async function generateBrowserIndexFile(codegen, config, configPath) {
|
|
|
430
455
|
}
|
|
431
456
|
codegen.lines.push("const browserCollections = {");
|
|
432
457
|
await codegen.pushAsync(
|
|
433
|
-
|
|
458
|
+
core.getConfig().collectionList.map(async (collection) => {
|
|
434
459
|
const obj = await generateCollectionObject(collection);
|
|
435
460
|
if (!obj) return;
|
|
436
461
|
return ident(`${collection.name}: ${obj},`);
|
|
437
462
|
})
|
|
438
463
|
);
|
|
439
464
|
codegen.lines.push("};", "export default browserCollections;");
|
|
440
|
-
return codegen.toString();
|
|
441
465
|
}
|
|
442
466
|
function generateDocCollectionFrontmatterGlob(codegen, collection, eager = false) {
|
|
443
467
|
return codegen.generateGlobImport(collection.patterns, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export { J as IndexFilePlugin, I as IndexFilePluginOptions, H as default } from '../core-DTuP23zu.cjs';
|
|
2
2
|
import '@mdx-js/mdx';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
import 'unified';
|
|
@@ -6,24 +6,9 @@ import 'fumadocs-core/mdx-plugins';
|
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'chokidar';
|
|
8
8
|
import 'vfile';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
addJsExtension?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Generate entry point for browser
|
|
18
|
-
* @defaultValue true
|
|
19
|
-
*/
|
|
20
|
-
browser?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Generate entry point for dynamic compilation
|
|
23
|
-
* @defaultValue true
|
|
24
|
-
*/
|
|
25
|
-
dynamic?: boolean;
|
|
26
|
-
}
|
|
27
|
-
declare function indexFile(options?: IndexFilePluginOptions): Plugin;
|
|
28
|
-
|
|
29
|
-
export { type IndexFilePluginOptions, indexFile as default };
|
|
9
|
+
import 'fumadocs-core/source';
|
|
10
|
+
import '../runtime/types.cjs';
|
|
11
|
+
import 'fumadocs-core/mdx-plugins/remark-structure';
|
|
12
|
+
import 'fumadocs-core/toc';
|
|
13
|
+
import 'mdast';
|
|
14
|
+
import 'mdx/types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export { J as IndexFilePlugin, I as IndexFilePluginOptions, H as default } from '../core-B9ZoS6sA.js';
|
|
2
2
|
import '@mdx-js/mdx';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
import 'unified';
|
|
@@ -6,24 +6,9 @@ import 'fumadocs-core/mdx-plugins';
|
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'chokidar';
|
|
8
8
|
import 'vfile';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
addJsExtension?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Generate entry point for browser
|
|
18
|
-
* @defaultValue true
|
|
19
|
-
*/
|
|
20
|
-
browser?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Generate entry point for dynamic compilation
|
|
23
|
-
* @defaultValue true
|
|
24
|
-
*/
|
|
25
|
-
dynamic?: boolean;
|
|
26
|
-
}
|
|
27
|
-
declare function indexFile(options?: IndexFilePluginOptions): Plugin;
|
|
28
|
-
|
|
29
|
-
export { type IndexFilePluginOptions, indexFile as default };
|
|
9
|
+
import 'fumadocs-core/source';
|
|
10
|
+
import '../runtime/types.js';
|
|
11
|
+
import 'fumadocs-core/mdx-plugins/remark-structure';
|
|
12
|
+
import 'fumadocs-core/toc';
|
|
13
|
+
import 'mdast';
|
|
14
|
+
import 'mdx/types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as Plugin } from '../
|
|
1
|
+
import { j as Plugin } from '../core-DTuP23zu.cjs';
|
|
2
2
|
import '@mdx-js/mdx';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
import 'unified';
|
|
@@ -6,6 +6,12 @@ import 'fumadocs-core/mdx-plugins';
|
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'chokidar';
|
|
8
8
|
import 'vfile';
|
|
9
|
+
import 'fumadocs-core/source';
|
|
10
|
+
import '../runtime/types.cjs';
|
|
11
|
+
import 'fumadocs-core/mdx-plugins/remark-structure';
|
|
12
|
+
import 'fumadocs-core/toc';
|
|
13
|
+
import 'mdast';
|
|
14
|
+
import 'mdx/types';
|
|
9
15
|
|
|
10
16
|
interface JSONSchemaOptions {
|
|
11
17
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as Plugin } from '../
|
|
1
|
+
import { j as Plugin } from '../core-B9ZoS6sA.js';
|
|
2
2
|
import '@mdx-js/mdx';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
import 'unified';
|
|
@@ -6,6 +6,12 @@ import 'fumadocs-core/mdx-plugins';
|
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'chokidar';
|
|
8
8
|
import 'vfile';
|
|
9
|
+
import 'fumadocs-core/source';
|
|
10
|
+
import '../runtime/types.js';
|
|
11
|
+
import 'fumadocs-core/mdx-plugins/remark-structure';
|
|
12
|
+
import 'fumadocs-core/toc';
|
|
13
|
+
import 'mdast';
|
|
14
|
+
import 'mdx/types';
|
|
9
15
|
|
|
10
16
|
interface JSONSchemaOptions {
|
|
11
17
|
/**
|