fumadocs-mdx 13.0.2 → 13.0.4

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 (67) hide show
  1. package/dist/bin.cjs +381 -279
  2. package/dist/{build-mdx-D-r3_eQL.d.cts → build-mdx-BjXOmv0b.d.cts} +1 -1
  3. package/dist/{build-mdx-CCNr86q6.d.ts → build-mdx-CY5UldCO.d.ts} +1 -1
  4. package/dist/bun/index.cjs +177 -57
  5. package/dist/bun/index.d.cts +2 -2
  6. package/dist/bun/index.d.ts +2 -2
  7. package/dist/bun/index.js +26 -34
  8. package/dist/chunk-2HXTGJBI.js +101 -0
  9. package/dist/chunk-4JSFLXXT.js +8 -0
  10. package/dist/{chunk-JVZFH6ND.js → chunk-QXHN25N3.js} +2 -2
  11. package/dist/{chunk-EELYB2XC.js → chunk-TZ5EQBFW.js} +9 -103
  12. package/dist/chunk-VUEZTR2H.js +26 -0
  13. package/dist/{chunk-XQ5O7IPO.js → chunk-XYGORKQA.js} +5 -3
  14. package/dist/chunk-YAIPHUCZ.js +56 -0
  15. package/dist/chunk-ZNVPB2IR.js +170 -0
  16. package/dist/config/index.d.cts +2 -2
  17. package/dist/config/index.d.ts +2 -2
  18. package/dist/{core-B6j6Fxse.d.cts → core-DB7TdlyC.d.cts} +23 -7
  19. package/dist/{core-B6j6Fxse.d.ts → core-DB7TdlyC.d.ts} +23 -7
  20. package/dist/index-D7s7kCc2.d.cts +7 -0
  21. package/dist/index-D7s7kCc2.d.ts +7 -0
  22. package/dist/index.d.cts +4 -4
  23. package/dist/index.d.ts +4 -4
  24. package/dist/load-from-file-AVYOFOI7.js +7 -0
  25. package/dist/next/index.cjs +147 -142
  26. package/dist/next/index.js +58 -39
  27. package/dist/node/loader.cjs +242 -128
  28. package/dist/node/loader.d.cts +2 -2
  29. package/dist/node/loader.d.ts +2 -2
  30. package/dist/node/loader.js +29 -16
  31. package/dist/plugins/json-schema.cjs +22 -70
  32. package/dist/plugins/json-schema.d.cts +2 -2
  33. package/dist/plugins/json-schema.d.ts +2 -2
  34. package/dist/plugins/json-schema.js +19 -14
  35. package/dist/runtime/next/async.cjs +56 -11
  36. package/dist/runtime/next/async.d.cts +4 -6
  37. package/dist/runtime/next/async.d.ts +4 -6
  38. package/dist/runtime/next/async.js +3 -6
  39. package/dist/runtime/next/index.d.cts +5 -5
  40. package/dist/runtime/next/index.d.ts +5 -5
  41. package/dist/runtime/vite/browser.d.cts +3 -3
  42. package/dist/runtime/vite/browser.d.ts +3 -3
  43. package/dist/runtime/vite/server.d.cts +3 -3
  44. package/dist/runtime/vite/server.d.ts +3 -3
  45. package/dist/{types-DKGMoay5.d.cts → types-Bnh9n7mj.d.cts} +2 -2
  46. package/dist/{types-AGzTfBmf.d.ts → types-ey1AZqrg.d.ts} +2 -2
  47. package/dist/vite/index.cjs +265 -163
  48. package/dist/vite/index.d.cts +4 -0
  49. package/dist/vite/index.d.ts +4 -0
  50. package/dist/vite/index.js +140 -122
  51. package/dist/webpack/{index.cjs → mdx.cjs} +126 -104
  52. package/dist/webpack/mdx.d.cts +6 -0
  53. package/dist/webpack/mdx.d.ts +6 -0
  54. package/dist/webpack/{index.js → mdx.js} +12 -14
  55. package/dist/webpack/meta.cjs +528 -0
  56. package/dist/webpack/meta.d.cts +6 -0
  57. package/dist/webpack/meta.d.ts +6 -0
  58. package/dist/webpack/meta.js +42 -0
  59. package/loader-mdx.cjs +1 -1
  60. package/loader-meta.cjs +7 -0
  61. package/package.json +11 -8
  62. package/dist/chunk-U4MQ44TS.js +0 -53
  63. package/dist/chunk-XZY2AWJI.js +0 -81
  64. package/dist/chunk-YVCR6FUH.js +0 -82
  65. package/dist/load-MNG3CLET.js +0 -7
  66. package/dist/webpack/index.d.cts +0 -15
  67. package/dist/webpack/index.d.ts +0 -15
@@ -1,53 +0,0 @@
1
- // src/config/build.ts
2
- function buildConfig(config) {
3
- const collections = /* @__PURE__ */ new Map();
4
- let globalConfig = {};
5
- for (const [k, v] of Object.entries(config)) {
6
- if (!v) {
7
- continue;
8
- }
9
- if (typeof v === "object" && "type" in v) {
10
- if (v.type === "docs") {
11
- collections.set(k, v);
12
- continue;
13
- }
14
- if (v.type === "doc" || v.type === "meta") {
15
- collections.set(k, v);
16
- continue;
17
- }
18
- }
19
- if (k === "default" && v) {
20
- globalConfig = v;
21
- continue;
22
- }
23
- throw new Error(
24
- `Unknown export "${k}", you can only export collections from source configuration file.`
25
- );
26
- }
27
- const mdxOptionsCache = /* @__PURE__ */ new Map();
28
- return {
29
- global: globalConfig,
30
- collections,
31
- async getDefaultMDXOptions(mode = "default") {
32
- const cached = mdxOptionsCache.get(mode);
33
- if (cached) return cached;
34
- const input = this.global.mdxOptions;
35
- async function uncached() {
36
- const options = typeof input === "function" ? await input() : input;
37
- const { getDefaultMDXOptions } = await import("./preset-ZMP6U62C.js");
38
- if (options?.preset === "minimal") return options;
39
- return getDefaultMDXOptions({
40
- ...options,
41
- _withoutBundler: mode === "remote"
42
- });
43
- }
44
- const result = uncached();
45
- mdxOptionsCache.set(mode, result);
46
- return result;
47
- }
48
- };
49
- }
50
-
51
- export {
52
- buildConfig
53
- };
@@ -1,81 +0,0 @@
1
- // src/utils/collections.ts
2
- import picomatch from "picomatch";
3
- import { glob } from "tinyglobby";
4
- import path from "path";
5
- var SupportedFormats = {
6
- doc: ["mdx", "md"],
7
- meta: ["json", "yaml"]
8
- };
9
- function getGlobPatterns(collection) {
10
- if (collection.files) return collection.files;
11
- return [`**/*.{${SupportedFormats[collection.type].join(",")}}`];
12
- }
13
- function isFileSupported(filePath, collection) {
14
- return SupportedFormats[collection.type].some(
15
- (format) => filePath.endsWith(`.${format}`)
16
- );
17
- }
18
- function createCollectionMatcher(core) {
19
- const CacheKey = "collection-matcher";
20
- return {
21
- scan(config) {
22
- const scanned = [];
23
- function scan(name, collection) {
24
- const patterns = getGlobPatterns(collection);
25
- for (const dir of Array.isArray(collection.dir) ? collection.dir : [collection.dir]) {
26
- scanned.push({
27
- name,
28
- collection,
29
- matcher: picomatch(patterns, {
30
- cwd: dir
31
- })
32
- });
33
- }
34
- }
35
- for (const [name, collection] of config.collections) {
36
- if (collection.type === "docs") {
37
- scan(name, collection.meta);
38
- scan(name, collection.docs);
39
- } else {
40
- scan(name, collection);
41
- }
42
- }
43
- return scanned;
44
- },
45
- getFileCollection(file) {
46
- const scanned = core.cache.get(CacheKey) ?? this.scan(core.getConfig());
47
- core.cache.set(CacheKey, scanned);
48
- for (const item of scanned) {
49
- if (isFileSupported(file, item.collection) && item.matcher(file))
50
- return { name: item.name, collection: item.collection };
51
- }
52
- }
53
- };
54
- }
55
- async function getCollectionFiles(collection) {
56
- const files = /* @__PURE__ */ new Map();
57
- const dirs = Array.isArray(collection.dir) ? collection.dir : [collection.dir];
58
- const patterns = getGlobPatterns(collection);
59
- await Promise.all(
60
- dirs.map(async (dir) => {
61
- const result = await glob(patterns, {
62
- cwd: path.resolve(dir)
63
- });
64
- for (const item of result) {
65
- if (!isFileSupported(item, collection)) continue;
66
- const fullPath = path.join(dir, item);
67
- files.set(fullPath, {
68
- path: item,
69
- fullPath
70
- });
71
- }
72
- })
73
- );
74
- return Array.from(files.values());
75
- }
76
-
77
- export {
78
- getGlobPatterns,
79
- createCollectionMatcher,
80
- getCollectionFiles
81
- };
@@ -1,82 +0,0 @@
1
- import {
2
- ValidationError
3
- } from "./chunk-EELYB2XC.js";
4
-
5
- // src/loaders/adapter.ts
6
- import { fileURLToPath } from "url";
7
- import fs from "fs/promises";
8
- import { parse } from "querystring";
9
- import path from "path";
10
- function toNode(loader, filterByPath) {
11
- return async (url, _context, nextLoad) => {
12
- if (!url.startsWith("file:///")) return nextLoad(url);
13
- const parsedUrl = new URL(url);
14
- const filePath = fileURLToPath(parsedUrl);
15
- if (filterByPath(filePath)) {
16
- const source = (await fs.readFile(filePath)).toString();
17
- const result = await loader({
18
- filePath,
19
- query: Object.fromEntries(parsedUrl.searchParams.entries()),
20
- source,
21
- development: false,
22
- compiler: {
23
- addDependency() {
24
- }
25
- }
26
- });
27
- return {
28
- source: result.code,
29
- format: "module",
30
- shortCircuit: true
31
- };
32
- }
33
- return nextLoad(url);
34
- };
35
- }
36
- function toVite(loader) {
37
- return async function(file, query, value) {
38
- const result = await loader({
39
- filePath: file,
40
- query: parse(query),
41
- source: value,
42
- development: this.environment.mode === "dev",
43
- compiler: {
44
- addDependency: (file2) => {
45
- this.addWatchFile(file2);
46
- }
47
- }
48
- });
49
- return {
50
- code: result.code,
51
- map: result.map
52
- };
53
- };
54
- }
55
- function toWebpack(loader) {
56
- return async function(source, callback) {
57
- try {
58
- const result = await loader({
59
- filePath: this.resourcePath,
60
- query: parse(this.resourceQuery.slice(1)),
61
- source,
62
- development: this.mode === "development",
63
- compiler: this
64
- });
65
- callback(void 0, result.code, result.map);
66
- } catch (error) {
67
- if (error instanceof ValidationError) {
68
- return callback(new Error(error.toStringFormatted()));
69
- }
70
- if (!(error instanceof Error)) throw error;
71
- const fpath = path.relative(this.context, this.resourcePath);
72
- error.message = `${fpath}:${error.name}: ${error.message}`;
73
- callback(error);
74
- }
75
- };
76
- }
77
-
78
- export {
79
- toNode,
80
- toVite,
81
- toWebpack
82
- };
@@ -1,7 +0,0 @@
1
- import {
2
- loadConfig
3
- } from "./chunk-JVZFH6ND.js";
4
- import "./chunk-U4MQ44TS.js";
5
- export {
6
- loadConfig
7
- };
@@ -1,15 +0,0 @@
1
- import { LoaderContext } from 'webpack';
2
-
3
- interface Options {
4
- configPath: string;
5
- outDir: string;
6
- isDev: boolean;
7
- }
8
- /**
9
- * Load MDX/markdown files
10
- *
11
- * it supports frontmatter by parsing and injecting the data in `vfile.data.frontmatter`
12
- */
13
- declare function loader(this: LoaderContext<Options>, source: string, callback: LoaderContext<Options>['callback']): Promise<void>;
14
-
15
- export { type Options, loader as default };
@@ -1,15 +0,0 @@
1
- import { LoaderContext } from 'webpack';
2
-
3
- interface Options {
4
- configPath: string;
5
- outDir: string;
6
- isDev: boolean;
7
- }
8
- /**
9
- * Load MDX/markdown files
10
- *
11
- * it supports frontmatter by parsing and injecting the data in `vfile.data.frontmatter`
12
- */
13
- declare function loader(this: LoaderContext<Options>, source: string, callback: LoaderContext<Options>['callback']): Promise<void>;
14
-
15
- export { type Options, loader as default };