fuma-content 1.1.4 → 1.2.0

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 (176) hide show
  1. package/dist/{async-cache-DRmFaVGm.js → async-cache-C47yxLCv.js} +4 -3
  2. package/dist/async-cache-C47yxLCv.js.map +1 -0
  3. package/dist/bin.js +2 -3
  4. package/dist/bin.js.map +1 -1
  5. package/dist/build-mdx-C8u32vDa.js +158 -0
  6. package/dist/build-mdx-C8u32vDa.js.map +1 -0
  7. package/dist/bun/index.d.ts +1 -1
  8. package/dist/bun/index.js +2 -3
  9. package/dist/bun/index.js.map +1 -1
  10. package/dist/{bun-Be5pgXW_.js → bun-NahDFkhR.js} +3 -4
  11. package/dist/{bun-Be5pgXW_.js.map → bun-NahDFkhR.js.map} +1 -1
  12. package/dist/{code-generator-CHcOrCeM.js → code-generator-pLUE7Rk7.js} +2 -3
  13. package/dist/{code-generator-CHcOrCeM.js.map → code-generator-pLUE7Rk7.js.map} +1 -1
  14. package/dist/collections/data/runtime.d.ts +2 -3
  15. package/dist/collections/data/runtime.d.ts.map +1 -1
  16. package/dist/collections/data/runtime.js +1 -2
  17. package/dist/collections/data/runtime.js.map +1 -1
  18. package/dist/collections/data.d.ts +3 -4
  19. package/dist/collections/data.d.ts.map +1 -1
  20. package/dist/collections/data.js +5 -6
  21. package/dist/collections/data.js.map +1 -1
  22. package/dist/collections/fs.d.ts +2 -45
  23. package/dist/collections/fs.js +3 -4
  24. package/dist/collections/fs.js.map +1 -1
  25. package/dist/collections/index.d.ts +2 -37
  26. package/dist/collections/index.js +1 -37
  27. package/dist/collections/json/loader-webpack.d.ts +1 -3
  28. package/dist/collections/json/loader-webpack.js +4 -5
  29. package/dist/collections/json/loader-webpack.js.map +1 -1
  30. package/dist/collections/mdx/loader-webpack.d.ts +1 -3
  31. package/dist/collections/mdx/loader-webpack.js +4 -5
  32. package/dist/collections/mdx/loader-webpack.js.map +1 -1
  33. package/dist/collections/mdx/react.d.ts +2 -3
  34. package/dist/collections/mdx/react.d.ts.map +1 -1
  35. package/dist/collections/mdx/react.js +2 -3
  36. package/dist/collections/mdx/react.js.map +1 -1
  37. package/dist/collections/mdx/runtime-browser.d.ts +3 -25
  38. package/dist/collections/mdx/runtime-browser.js +2 -4
  39. package/dist/collections/mdx/runtime-browser.js.map +1 -1
  40. package/dist/collections/mdx/runtime-dynamic.d.ts +4 -5
  41. package/dist/collections/mdx/runtime-dynamic.d.ts.map +1 -1
  42. package/dist/collections/mdx/runtime-dynamic.js +9 -8
  43. package/dist/collections/mdx/runtime-dynamic.js.map +1 -1
  44. package/dist/collections/mdx/runtime.d.ts +2 -26
  45. package/dist/collections/mdx/runtime.js +1 -2
  46. package/dist/collections/mdx/runtime.js.map +1 -1
  47. package/dist/collections/mdx/vue.d.ts +27 -0
  48. package/dist/collections/mdx/vue.d.ts.map +1 -0
  49. package/dist/collections/mdx/vue.js +34 -0
  50. package/dist/collections/mdx/vue.js.map +1 -0
  51. package/dist/collections/mdx.d.ts +2 -66
  52. package/dist/collections/mdx.js +16 -10
  53. package/dist/collections/mdx.js.map +1 -1
  54. package/dist/collections/obsidian.d.ts +4 -5
  55. package/dist/collections/obsidian.d.ts.map +1 -1
  56. package/dist/collections/obsidian.js +169 -128
  57. package/dist/collections/obsidian.js.map +1 -1
  58. package/dist/collections/runtime/file-store.d.ts +2 -21
  59. package/dist/collections/runtime/file-store.js +1 -2
  60. package/dist/collections/runtime/file-store.js.map +1 -1
  61. package/dist/collections/runtime/store.d.ts +2 -31
  62. package/dist/collections/runtime/store.js +1 -1
  63. package/dist/collections/runtime/store.js.map +1 -1
  64. package/dist/collections/yaml/loader-webpack.d.ts +1 -3
  65. package/dist/collections/yaml/loader-webpack.js +4 -5
  66. package/dist/collections/yaml/loader-webpack.js.map +1 -1
  67. package/dist/{pipe-CvCqOpXX.js → collections-BuskUhft.js} +36 -4
  68. package/dist/collections-BuskUhft.js.map +1 -0
  69. package/dist/config/index.d.ts +2 -35
  70. package/dist/config/index.js +1 -1
  71. package/dist/{core-BuUsOElL.js → core-Buwp1MPi.js} +4 -5
  72. package/dist/{core-BuUsOElL.js.map → core-Buwp1MPi.js.map} +1 -1
  73. package/dist/{core-FjA_Xoho.d.ts → core-Cd_KERZa.d.ts} +65 -4
  74. package/dist/core-Cd_KERZa.d.ts.map +1 -0
  75. package/dist/dynamic-BaUDAMS6.d.ts +32 -0
  76. package/dist/dynamic-BaUDAMS6.d.ts.map +1 -0
  77. package/dist/dynamic.d.ts +2 -25
  78. package/dist/dynamic.js +2 -3
  79. package/dist/dynamic.js.map +1 -1
  80. package/dist/file-store-TyqUJE3V.d.ts +20 -0
  81. package/dist/file-store-TyqUJE3V.d.ts.map +1 -0
  82. package/dist/flatten-m0wfHxLH.js +10 -0
  83. package/dist/flatten-m0wfHxLH.js.map +1 -0
  84. package/dist/fs-BHzpv9Wl.d.ts +44 -0
  85. package/dist/fs-BHzpv9Wl.d.ts.map +1 -0
  86. package/dist/{fuma-matter-B4gT09gM.js → fuma-matter-E30PU53R.js} +2 -3
  87. package/dist/{fuma-matter-B4gT09gM.js.map → fuma-matter-E30PU53R.js.map} +1 -1
  88. package/dist/git-Kdo9j47k.d.ts +37 -0
  89. package/dist/git-Kdo9j47k.d.ts.map +1 -0
  90. package/dist/index-DZkwl_pd.d.ts +84 -0
  91. package/dist/index-DZkwl_pd.d.ts.map +1 -0
  92. package/dist/index.d.ts +1 -1
  93. package/dist/index.js +4 -5
  94. package/dist/{is-promise-like-DYHv0Yap.js → is-promise-like-C04ERo2r.js} +2 -2
  95. package/dist/{is-promise-like-DYHv0Yap.js.map → is-promise-like-C04ERo2r.js.map} +1 -1
  96. package/dist/{load-from-file-BhdBOcQT.js → load-from-file-C3CnD8mJ.js} +3 -4
  97. package/dist/{load-from-file-BhdBOcQT.js.map → load-from-file-C3CnD8mJ.js.map} +1 -1
  98. package/dist/{loader-BT4fwLTJ.js → loader-CyhM9SLt.js} +8 -7
  99. package/dist/{loader-BT4fwLTJ.js.map → loader-CyhM9SLt.js.map} +1 -1
  100. package/dist/{loader-Cb9kSSxT.js → loader-D_sKOzDc.js} +4 -5
  101. package/dist/{loader-Cb9kSSxT.js.map → loader-D_sKOzDc.js.map} +1 -1
  102. package/dist/{loader-BOYLUNfh.js → loader-e2SkeDfY.js} +4 -5
  103. package/dist/{loader-BOYLUNfh.js.map → loader-e2SkeDfY.js.map} +1 -1
  104. package/dist/{loader-UhlX4xbz.js → loader-ol04zeoP.js} +3 -4
  105. package/dist/{loader-UhlX4xbz.js.map → loader-ol04zeoP.js.map} +1 -1
  106. package/dist/mdx-DY0zm9lN.d.ts +138 -0
  107. package/dist/mdx-DY0zm9lN.d.ts.map +1 -0
  108. package/dist/next/index.d.ts +1 -1
  109. package/dist/next/index.js +3 -4
  110. package/dist/next/index.js.map +1 -1
  111. package/dist/node/index.d.ts +0 -1
  112. package/dist/node/index.d.ts.map +1 -1
  113. package/dist/node/index.js +1 -2
  114. package/dist/node/index.js.map +1 -1
  115. package/dist/node/loader.d.ts +1 -1
  116. package/dist/node/loader.js +3 -4
  117. package/dist/node/loader.js.map +1 -1
  118. package/dist/{node-Cu5Pqxxo.js → node-Du4i4XDg.js} +2 -3
  119. package/dist/{node-Cu5Pqxxo.js.map → node-Du4i4XDg.js.map} +1 -1
  120. package/dist/plugins/git.d.ts +2 -38
  121. package/dist/plugins/git.js +3 -5
  122. package/dist/plugins/git.js.map +1 -1
  123. package/dist/plugins/json-schema.d.ts +1 -2
  124. package/dist/plugins/json-schema.d.ts.map +1 -1
  125. package/dist/plugins/json-schema.js +2 -3
  126. package/dist/plugins/json-schema.js.map +1 -1
  127. package/dist/plugins/loader/index.d.ts +2 -72
  128. package/dist/plugins/loader/index.js +6 -7
  129. package/dist/plugins/loader/index.js.map +1 -1
  130. package/dist/plugins/loader/webpack.d.ts +2 -21
  131. package/dist/plugins/loader/webpack.js +3 -4
  132. package/dist/plugins/loader/webpack.js.map +1 -1
  133. package/dist/plugins/remark/include.d.ts +23 -0
  134. package/dist/plugins/remark/include.d.ts.map +1 -0
  135. package/dist/plugins/remark/include.js +203 -0
  136. package/dist/plugins/remark/include.js.map +1 -0
  137. package/dist/rolldown-runtime-CiIaOW0V.js +13 -0
  138. package/dist/runtime-DiDP9Ajm.d.ts +25 -0
  139. package/dist/runtime-DiDP9Ajm.d.ts.map +1 -0
  140. package/dist/runtime-browser-a0rQ1BCJ.d.ts +29 -0
  141. package/dist/runtime-browser-a0rQ1BCJ.d.ts.map +1 -0
  142. package/dist/store-C3RuJOrY.d.ts +31 -0
  143. package/dist/store-C3RuJOrY.d.ts.map +1 -0
  144. package/dist/{validation-C3kXuveD.js → validation-Bf_v2L3p.js} +2 -2
  145. package/dist/{validation-C3kXuveD.js.map → validation-Bf_v2L3p.js.map} +1 -1
  146. package/dist/vite/index.d.ts +1 -1
  147. package/dist/vite/index.js +3 -4
  148. package/dist/vite/index.js.map +1 -1
  149. package/dist/{vite-CoJIMNWk.js → vite-DVIOnBqW.js} +2 -3
  150. package/dist/{vite-CoJIMNWk.js.map → vite-DVIOnBqW.js.map} +1 -1
  151. package/package.json +40 -59
  152. package/dist/async-cache-BVuJiIDT.d.ts +0 -9
  153. package/dist/async-cache-BVuJiIDT.d.ts.map +0 -1
  154. package/dist/async-cache-DRmFaVGm.js.map +0 -1
  155. package/dist/build-mdx-DRqbcE1d.d.ts +0 -79
  156. package/dist/build-mdx-DRqbcE1d.d.ts.map +0 -1
  157. package/dist/build-mdx-DgzggXIL.js +0 -387
  158. package/dist/build-mdx-DgzggXIL.js.map +0 -1
  159. package/dist/collections/fs.d.ts.map +0 -1
  160. package/dist/collections/index.d.ts.map +0 -1
  161. package/dist/collections/index.js.map +0 -1
  162. package/dist/collections/mdx/runtime-browser.d.ts.map +0 -1
  163. package/dist/collections/mdx/runtime.d.ts.map +0 -1
  164. package/dist/collections/mdx.d.ts.map +0 -1
  165. package/dist/collections/runtime/file-store.d.ts.map +0 -1
  166. package/dist/collections/runtime/store.d.ts.map +0 -1
  167. package/dist/config/index.d.ts.map +0 -1
  168. package/dist/core-FjA_Xoho.d.ts.map +0 -1
  169. package/dist/dynamic.d.ts.map +0 -1
  170. package/dist/load-from-file-CIYdu-B5.d.ts +0 -10
  171. package/dist/load-from-file-CIYdu-B5.d.ts.map +0 -1
  172. package/dist/pipe-CvCqOpXX.js.map +0 -1
  173. package/dist/plugins/git.d.ts.map +0 -1
  174. package/dist/plugins/loader/index.d.ts.map +0 -1
  175. package/dist/plugins/loader/webpack.d.ts.map +0 -1
  176. package/dist/rolldown-runtime-CjeV3_4I.js +0 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fuma-content",
3
- "version": "1.1.4",
3
+ "version": "1.2.0",
4
4
  "description": "The content processing layer for your app.",
5
5
  "keywords": [
6
6
  "Content",
@@ -15,58 +15,38 @@
15
15
  "dist/*"
16
16
  ],
17
17
  "type": "module",
18
- "main": "./dist/index.js",
19
18
  "types": "./dist/index.d.ts",
20
19
  "exports": {
21
- "./config": {
22
- "types": "./dist/config/index.d.ts",
23
- "import": "./dist/config/index.js"
24
- },
25
- "./dynamic": {
26
- "types": "./dist/dynamic.d.ts",
27
- "import": "./dist/dynamic.js"
28
- },
29
- "./next": {
30
- "types": "./dist/next/index.d.ts",
31
- "import": "./dist/next/index.js"
32
- },
33
- "./vite": {
34
- "types": "./dist/vite/index.d.ts",
35
- "import": "./dist/vite/index.js"
36
- },
37
- ".": {
38
- "types": "./dist/index.d.ts",
39
- "import": "./dist/index.js"
40
- },
41
- "./collections": {
42
- "types": "./dist/collections/index.d.ts",
43
- "import": "./dist/collections/index.js"
44
- },
45
- "./collections/mdx/react": {
46
- "types": "./dist/collections/mdx/react.d.ts",
47
- "import": "./dist/collections/mdx/react.js"
48
- },
49
- "./collections/*": {
50
- "types": "./dist/collections/*.d.ts",
51
- "import": "./dist/collections/*.js",
52
- "default": "./dist/collections/*.js"
53
- },
54
- "./node": {
55
- "types": "./dist/node/index.d.ts",
56
- "import": "./dist/node/index.js"
57
- },
58
- "./bun": {
59
- "types": "./dist/bun/index.d.ts",
60
- "import": "./dist/bun/index.js"
61
- },
62
- "./plugins/loader": {
63
- "types": "./dist/plugins/loader/index.d.ts",
64
- "import": "./dist/plugins/loader/index.js"
65
- },
66
- "./plugins/*": {
67
- "types": "./dist/plugins/*.d.ts",
68
- "import": "./dist/plugins/*.js"
69
- }
20
+ ".": "./dist/index.js",
21
+ "./bun": "./dist/bun/index.js",
22
+ "./collections": "./dist/collections/index.js",
23
+ "./collections/data": "./dist/collections/data.js",
24
+ "./collections/data/runtime": "./dist/collections/data/runtime.js",
25
+ "./collections/fs": "./dist/collections/fs.js",
26
+ "./collections/json/loader-webpack": "./dist/collections/json/loader-webpack.js",
27
+ "./collections/mdx": "./dist/collections/mdx.js",
28
+ "./collections/mdx/loader-webpack": "./dist/collections/mdx/loader-webpack.js",
29
+ "./collections/mdx/react": "./dist/collections/mdx/react.js",
30
+ "./collections/mdx/runtime": "./dist/collections/mdx/runtime.js",
31
+ "./collections/mdx/runtime-browser": "./dist/collections/mdx/runtime-browser.js",
32
+ "./collections/mdx/runtime-dynamic": "./dist/collections/mdx/runtime-dynamic.js",
33
+ "./collections/mdx/vue": "./dist/collections/mdx/vue.js",
34
+ "./collections/obsidian": "./dist/collections/obsidian.js",
35
+ "./collections/runtime/file-store": "./dist/collections/runtime/file-store.js",
36
+ "./collections/runtime/store": "./dist/collections/runtime/store.js",
37
+ "./collections/yaml/loader-webpack": "./dist/collections/yaml/loader-webpack.js",
38
+ "./config": "./dist/config/index.js",
39
+ "./dynamic": "./dist/dynamic.js",
40
+ "./next": "./dist/next/index.js",
41
+ "./node": "./dist/node/index.js",
42
+ "./node/loader": "./dist/node/loader.js",
43
+ "./plugins/git": "./dist/plugins/git.js",
44
+ "./plugins/json-schema": "./dist/plugins/json-schema.js",
45
+ "./plugins/loader": "./dist/plugins/loader/index.js",
46
+ "./plugins/loader/webpack": "./dist/plugins/loader/webpack.js",
47
+ "./plugins/remark/include": "./dist/plugins/remark/include.js",
48
+ "./vite": "./dist/vite/index.js",
49
+ "./package.json": "./package.json"
70
50
  },
71
51
  "publishConfig": {
72
52
  "access": "public"
@@ -83,7 +63,6 @@
83
63
  "mdast-util-to-markdown": "^2.1.2",
84
64
  "picocolors": "^1.1.1",
85
65
  "picomatch": "^4.0.3",
86
- "remark-mdx": "^3.1.1",
87
66
  "tinyexec": "^1.0.2",
88
67
  "tinyglobby": "^0.2.15",
89
68
  "unified": "^11.0.5",
@@ -93,28 +72,30 @@
93
72
  "zod": "^4.3.6"
94
73
  },
95
74
  "devDependencies": {
96
- "@types/bun": "^1.3.9",
75
+ "@types/bun": "^1.3.10",
97
76
  "@types/js-yaml": "^4.0.9",
98
77
  "@types/mdast": "^4.0.4",
99
78
  "@types/mdx": "^2.0.13",
100
- "@types/node": "^25.2.3",
79
+ "@types/node": "^25.4.0",
101
80
  "@types/picomatch": "^4.0.2",
102
81
  "@types/react": "^19.2.14",
103
82
  "mdast-util-directive": "^3.1.0",
104
83
  "mdast-util-mdx-jsx": "^3.2.0",
84
+ "micromark-util-types": "^2.0.2",
105
85
  "next": "16.1.6",
106
86
  "react": "^19.2.4",
107
87
  "remark": "^15.0.1",
108
88
  "remark-directive": "^4.0.0",
89
+ "remark-mdx": "^3.1.1",
109
90
  "remark-stringify": "^11.0.0",
110
- "rollup": "^4.57.1",
111
- "tsdown": "^0.20.3",
91
+ "rollup": "^4.59.0",
92
+ "tsdown": "^0.21.2",
112
93
  "typescript": "^5.9.3",
113
94
  "unplugin-vue": "^7.1.1",
114
95
  "vite": "^7.3.1",
115
- "vue": "^3.5.28",
116
- "vue-tsc": "^3.2.4",
117
- "webpack": "^5.105.1",
96
+ "vue": "^3.5.30",
97
+ "vue-tsc": "^3.2.5",
98
+ "webpack": "^5.105.4",
118
99
  "typescript-config": "0.0.0"
119
100
  },
120
101
  "peerDependencies": {
@@ -1,9 +0,0 @@
1
- //#region src/utils/async-cache.d.ts
2
- interface AsyncCache<V> {
3
- cached: (key: string, fn: () => V | Promise<V>) => V | Promise<V>;
4
- $value: <T>() => AsyncCache<T>;
5
- invalidate: (key: string) => void;
6
- }
7
- //#endregion
8
- export { AsyncCache as t };
9
- //# sourceMappingURL=async-cache-BVuJiIDT.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-cache-BVuJiIDT.d.ts","names":[],"sources":["../src/utils/async-cache.ts"],"mappings":";UAAiB,UAAA;EACf,MAAA,GAAS,GAAA,UAAa,EAAA,QAAU,CAAA,GAAI,OAAA,CAAQ,CAAA,MAAO,CAAA,GAAI,OAAA,CAAQ,CAAA;EAC/D,MAAA,WAAiB,UAAA,CAAW,CAAA;EAC5B,UAAA,GAAa,GAAA;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-cache-DRmFaVGm.js","names":[],"sources":["../src/utils/async-cache.ts"],"sourcesContent":["export interface AsyncCache<V> {\n cached: (key: string, fn: () => V | Promise<V>) => V | Promise<V>;\n $value: <T>() => AsyncCache<T>;\n invalidate: (key: string) => void;\n}\n\n/**\n * cache for async resources, finished promises will be resolved into original value, otherwise wrapped with a promise.\n */\nexport function createCache<V>(store = new Map<string, V | Promise<V>>()): AsyncCache<V> {\n return {\n cached(key, fn) {\n let cached = store.get(key);\n if (cached) return cached;\n\n cached = fn();\n if (cached instanceof Promise) {\n cached = cached.then((out) => {\n // replace with resolved if still exists\n if (store.has(key)) {\n store.set(key, out);\n }\n\n return out;\n });\n }\n store.set(key, cached);\n return cached;\n },\n invalidate(key) {\n store.delete(key);\n },\n $value<T>() {\n return this as unknown as AsyncCache<T>;\n },\n };\n}\n"],"mappings":";;;;AASA,SAAgB,YAAe,wBAAQ,IAAI,KAA6B,EAAiB;AACvF,QAAO;EACL,OAAO,KAAK,IAAI;GACd,IAAI,SAAS,MAAM,IAAI,IAAI;AAC3B,OAAI,OAAQ,QAAO;AAEnB,YAAS,IAAI;AACb,OAAI,kBAAkB,QACpB,UAAS,OAAO,MAAM,QAAQ;AAE5B,QAAI,MAAM,IAAI,IAAI,CAChB,OAAM,IAAI,KAAK,IAAI;AAGrB,WAAO;KACP;AAEJ,SAAM,IAAI,KAAK,OAAO;AACtB,UAAO;;EAET,WAAW,KAAK;AACd,SAAM,OAAO,IAAI;;EAEnB,SAAY;AACV,UAAO;;EAEV"}
@@ -1,79 +0,0 @@
1
- import { t as Core } from "./core-FjA_Xoho.js";
2
- import { MDXCollection } from "./collections/mdx.js";
3
- import { createProcessor } from "@mdx-js/mdx";
4
- import { VFile } from "vfile";
5
- import { MDXContent } from "mdx/types";
6
-
7
- //#region src/collections/mdx/remark-postprocess.d.ts
8
- interface LinkReference {
9
- href: string;
10
- }
11
- interface PostprocessOptions {
12
- _format: "md" | "mdx";
13
- /**
14
- * Properties to export from `vfile.data`
15
- */
16
- valueToExport?: string[];
17
- /**
18
- * stringify MDAST and export via `_markdown`.
19
- */
20
- processedMarkdown?: boolean | {
21
- as?: string;
22
- /**
23
- * include heading IDs into the processed markdown.
24
- */
25
- headingIds?: boolean;
26
- };
27
- /**
28
- * extract link references, export via `_linkReferences`.
29
- */
30
- linkReferences?: boolean | {
31
- as?: string;
32
- };
33
- /**
34
- * store MDAST and export via `_mdast`.
35
- */
36
- mdast?: boolean | {
37
- as?: string;
38
- removePosition?: boolean;
39
- };
40
- }
41
- //#endregion
42
- //#region src/collections/mdx/build-mdx.d.ts
43
- type MDXProcessor = ReturnType<typeof createProcessor>;
44
- interface MDXCompilerContext {
45
- addDependency: (file: string) => void;
46
- collection: MDXCollection | undefined;
47
- core: Core;
48
- }
49
- interface FumaContentDataMap {
50
- /**
51
- * [Fuma Content] raw frontmatter, you can modify it
52
- */
53
- frontmatter?: Record<string, unknown>;
54
- /**
55
- * [Fuma Content] additional ESM exports to write
56
- */
57
- "mdx-export"?: {
58
- name: string;
59
- value: unknown;
60
- }[];
61
- /**
62
- * [Fuma Content] The internal compiler info
63
- */
64
- _compiler?: MDXCompilerContext;
65
- /**
66
- * [Fuma Content] get internal processor, do not use this on user land.
67
- */
68
- _getProcessor?: (format: "md" | "mdx") => MDXProcessor | Promise<MDXProcessor>;
69
- }
70
- declare module "vfile" {
71
- interface DataMap extends FumaContentDataMap {}
72
- }
73
- interface CompiledMDX<Frontmatter = Record<string, unknown>> extends Record<string, unknown> {
74
- frontmatter: Frontmatter;
75
- default: MDXContent;
76
- }
77
- //#endregion
78
- export { LinkReference as n, PostprocessOptions as r, CompiledMDX as t };
79
- //# sourceMappingURL=build-mdx-DRqbcE1d.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-mdx-DRqbcE1d.d.ts","names":[],"sources":["../src/collections/mdx/remark-postprocess.ts","../src/collections/mdx/build-mdx.ts"],"mappings":";;;;;;;UASiB,aAAA;EACf,IAAA;AAAA;AAAA,UAGe,kBAAA;EACf,OAAA;EALe;;;EAUf,aAAA;EATI;AAGN;;EAWE,iBAAA;IAGM,EAAA;IAbN;;;IAiBM,UAAA;EAAA;EAMN;;;EAAA,cAAA;IAGM,EAAA;EAAA;EAUc;;;EAJpB,KAAA;IAGM,EAAA;IACA,cAAA;EAAA;AAAA;;;KCzCH,YAAA,GAAe,UAAA,QAAkB,eAAA;AAAA,UAE5B,kBAAA;EACR,aAAA,GAAgB,IAAA;EAChB,UAAA,EAAY,aAAA;EACZ,IAAA,EAAM,IAAA;AAAA;AAAA,UAgBS,kBAAA;EDgBf;;;ECZA,WAAA,GAAc,MAAA;EDgBM;;;ECXpB,YAAA;IAAiB,IAAA;IAAc,KAAA;EAAA;EA9Bb;;AAAiC;EAmCnD,SAAA,GAAY,kBAAA;;;;EAKZ,aAAA,IAAiB,MAAA,mBAAyB,YAAA,GAAe,OAAA,CAAQ,YAAA;AAAA;AAAA;EAAA,UAKvD,OAAA,SAAgB,kBAAA;AAAA;AAAA,UAGX,WAAA,eAA0B,MAAA,2BAAiC,MAAA;EAI1E,WAAA,EAAa,WAAA;EACb,OAAA,EAAS,UAAA;AAAA"}
@@ -1,387 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-CjeV3_4I.js";
2
- import { t as createCache } from "./async-cache-DRmFaVGm.js";
3
- import { t as fumaMatter } from "./fuma-matter-B4gT09gM.js";
4
- import * as fs$1 from "node:fs/promises";
5
- import * as path$1 from "node:path";
6
- import { visit } from "unist-util-visit";
7
- import { createProcessor } from "@mdx-js/mdx";
8
- import { VFile } from "vfile";
9
- import { unified } from "unified";
10
- import { toMarkdown } from "mdast-util-to-markdown";
11
- import { valueToEstree } from "estree-util-value-to-estree";
12
- import { removePosition } from "unist-util-remove-position";
13
- import { mdxToMarkdown } from "mdast-util-mdx";
14
-
15
- //#region src/collections/mdx/remark-unravel.ts
16
- function remarkMarkAndUnravel() {
17
- return (tree) => {
18
- visit(tree, (node, index, parent) => {
19
- let offset = -1;
20
- let all = true;
21
- let oneOrMore = false;
22
- if (parent && typeof index === "number" && node.type === "paragraph") {
23
- const children = node.children;
24
- while (++offset < children.length) {
25
- const child = children[offset];
26
- if (child.type === "mdxJsxTextElement" || child.type === "mdxTextExpression") oneOrMore = true;
27
- else if (child.type === "text" && child.value.trim().length === 0) {} else {
28
- all = false;
29
- break;
30
- }
31
- }
32
- if (all && oneOrMore) {
33
- offset = -1;
34
- const newChildren = [];
35
- while (++offset < children.length) {
36
- const child = children[offset];
37
- if (child.type === "mdxJsxTextElement") child.type = "mdxJsxFlowElement";
38
- if (child.type === "mdxTextExpression") child.type = "mdxFlowExpression";
39
- if (child.type === "text" && /^[\t\r\n ]+$/.test(String(child.value))) {} else newChildren.push(child);
40
- }
41
- parent.children.splice(index, 1, ...newChildren);
42
- return index;
43
- }
44
- }
45
- });
46
- };
47
- }
48
-
49
- //#endregion
50
- //#region src/utils/mdast/flatten.ts
51
- function flattenNode(node) {
52
- if ("children" in node) return node.children.map((child) => flattenNode(child)).join("");
53
- if ("value" in node) return node.value;
54
- return "";
55
- }
56
-
57
- //#endregion
58
- //#region src/collections/mdx/remark-include.ts
59
- const ElementLikeTypes = [
60
- "mdxJsxFlowElement",
61
- "mdxJsxTextElement",
62
- "containerDirective",
63
- "textDirective",
64
- "leafDirective"
65
- ];
66
- function isElementLike(node) {
67
- return ElementLikeTypes.includes(node.type);
68
- }
69
- function parseElementAttributes(element) {
70
- if (Array.isArray(element.attributes)) {
71
- const attributes = {};
72
- for (const attr of element.attributes) if (attr.type === "mdxJsxAttribute" && (typeof attr.value === "string" || attr.value === null)) attributes[attr.name] = attr.value;
73
- return attributes;
74
- }
75
- return element.attributes ?? {};
76
- }
77
- function parseSpecifier(specifier) {
78
- const idx = specifier.lastIndexOf("#");
79
- if (idx === -1) return { file: specifier };
80
- return {
81
- file: specifier.slice(0, idx),
82
- section: specifier.slice(idx + 1)
83
- };
84
- }
85
- function extractSection(root, section) {
86
- let nodes;
87
- let capturingHeadingContent = false;
88
- visit(root, (node) => {
89
- if (node.type === "heading") {
90
- if (capturingHeadingContent) return false;
91
- if (node.data?.hProperties?.id === section) {
92
- capturingHeadingContent = true;
93
- nodes = [node];
94
- return "skip";
95
- }
96
- return;
97
- }
98
- if (capturingHeadingContent) {
99
- nodes?.push(node);
100
- return "skip";
101
- }
102
- if (isElementLike(node) && node.name === "section") {
103
- if (parseElementAttributes(node).id === section) {
104
- nodes = node.children;
105
- return false;
106
- }
107
- }
108
- });
109
- if (nodes) return {
110
- type: "root",
111
- children: nodes
112
- };
113
- }
114
- const REGION_MARKERS = [
115
- {
116
- start: /^\s*\/\/\s*#?region\b\s*(.*?)\s*$/,
117
- end: /^\s*\/\/\s*#?endregion\b\s*(.*?)\s*$/
118
- },
119
- {
120
- start: /^\s*<!--\s*#?region\b\s*(.*?)\s*-->/,
121
- end: /^\s*<!--\s*#?endregion\b\s*(.*?)\s*-->/
122
- },
123
- {
124
- start: /^\s*\/\*\s*#region\b\s*(.*?)\s*\*\//,
125
- end: /^\s*\/\*\s*#endregion\b\s*(.*?)\s*\*\//
126
- },
127
- {
128
- start: /^\s*#[rR]egion\b\s*(.*?)\s*$/,
129
- end: /^\s*#[eE]nd ?[rR]egion\b\s*(.*?)\s*$/
130
- },
131
- {
132
- start: /^\s*#\s*#?region\b\s*(.*?)\s*$/,
133
- end: /^\s*#\s*#?endregion\b\s*(.*?)\s*$/
134
- },
135
- {
136
- start: /^\s*(?:--|::|@?REM)\s*#region\b\s*(.*?)\s*$/,
137
- end: /^\s*(?:--|::|@?REM)\s*#endregion\b\s*(.*?)\s*$/
138
- },
139
- {
140
- start: /^\s*#pragma\s+region\b\s*(.*?)\s*$/,
141
- end: /^\s*#pragma\s+endregion\b\s*(.*?)\s*$/
142
- },
143
- {
144
- start: /^\s*\(\*\s*#region\b\s*(.*?)\s*\*\)/,
145
- end: /^\s*\(\*\s*#endregion\b\s*(.*?)\s*\*\)/
146
- }
147
- ];
148
- function dedent(lines) {
149
- const minIndent = lines.reduce((min, line) => {
150
- const match = line.match(/^(\s*)\S/);
151
- return match ? Math.min(min, match[1].length) : min;
152
- }, Infinity);
153
- return minIndent === Infinity ? lines.join("\n") : lines.map((l) => l.slice(minIndent)).join("\n");
154
- }
155
- function extractCodeRegion(content, regionName) {
156
- const lines = content.split("\n");
157
- for (let i = 0; i < lines.length; i++) for (const re of REGION_MARKERS) {
158
- let match = re.start.exec(lines[i]);
159
- if (match?.[1] !== regionName) continue;
160
- let depth = 1;
161
- const extractedLines = [];
162
- for (let j = i + 1; j < lines.length; j++) {
163
- match = re.start.exec(lines[j]);
164
- if (match) {
165
- depth++;
166
- continue;
167
- }
168
- match = re.end.exec(lines[j]);
169
- if (match) {
170
- if (match[1] === regionName) depth = 0;
171
- else if (match[1] === "") depth--;
172
- else continue;
173
- if (depth > 0) continue;
174
- return dedent(extractedLines);
175
- } else extractedLines.push(lines[j]);
176
- }
177
- }
178
- throw new Error(`Region "${regionName}" not found`);
179
- }
180
- function remarkInclude({ preprocess = [] } = {}) {
181
- const TagName = "include";
182
- const preprocessor = unified().use(remarkMarkAndUnravel).use(preprocess);
183
- const embedContent = async (targetPath, heading, params, parent) => {
184
- const { _getProcessor = () => this, _compiler } = parent.data;
185
- let content;
186
- try {
187
- content = (await fs$1.readFile(targetPath)).toString();
188
- } catch (e) {
189
- throw new Error(`failed to read file ${targetPath}\n${e instanceof Error ? e.message : String(e)}`, { cause: e });
190
- }
191
- const ext = path$1.extname(targetPath);
192
- _compiler?.addDependency(targetPath);
193
- if (params.lang || ext !== ".md" && ext !== ".mdx") return {
194
- type: "code",
195
- lang: params.lang ?? ext.slice(1),
196
- meta: params.meta,
197
- value: heading ? extractCodeRegion(content, heading) : content,
198
- data: {}
199
- };
200
- const parser = await _getProcessor(ext === ".mdx" ? "mdx" : "md");
201
- const parsed = fumaMatter(content);
202
- const targetFile = new VFile({
203
- path: targetPath,
204
- value: parsed.content,
205
- data: {
206
- ...parent.data,
207
- frontmatter: parsed.data
208
- }
209
- });
210
- let mdast = await preprocessor.run(parser.parse(targetFile), targetFile);
211
- if (heading) {
212
- const extracted = extractSection(mdast, heading);
213
- if (!extracted) throw new Error(`Cannot find section ${heading} in ${targetPath}, make sure you have encapsulated the section in a <section id="${heading}"> tag, or a :::section directive with remark-directive configured.`);
214
- mdast = extracted;
215
- }
216
- await update(mdast, targetFile);
217
- return mdast;
218
- };
219
- async function update(tree, file) {
220
- const queue = [];
221
- visit(tree, ElementLikeTypes, (_node, _, parent) => {
222
- const node = _node;
223
- if (node.name !== TagName) return;
224
- const specifier = flattenNode(node);
225
- if (specifier.length === 0) return "skip";
226
- const attributes = parseElementAttributes(node);
227
- const { file: relativePath, section } = parseSpecifier(specifier);
228
- const targetPath = path$1.resolve("cwd" in attributes ? file.cwd : file.dirname ?? "", relativePath);
229
- queue.push(embedContent(targetPath, section, attributes, file).then((replace) => {
230
- Object.assign(parent && parent.type === "paragraph" ? parent : node, replace);
231
- }));
232
- return "skip";
233
- });
234
- await Promise.all(queue);
235
- }
236
- return async (tree, file) => {
237
- await update(tree, file);
238
- };
239
- }
240
-
241
- //#endregion
242
- //#region src/collections/mdx/remark-postprocess.ts
243
- /**
244
- * - collect references
245
- * - write frontmatter (auto-title & description)
246
- */
247
- function remarkPostprocess({ _format, processedMarkdown = false, mdast = false, linkReferences = false, valueToExport = [] }) {
248
- return (tree, file) => {
249
- const frontmatter = file.data.frontmatter ??= {};
250
- if (!frontmatter.title) visit(tree, "heading", (node) => {
251
- if (node.depth === 1) {
252
- frontmatter.title = flattenNode(node);
253
- return false;
254
- }
255
- });
256
- file.data["mdx-export"] ??= [];
257
- file.data["mdx-export"].push({
258
- name: "frontmatter",
259
- value: frontmatter
260
- });
261
- if (linkReferences) {
262
- const { as = "_linkReferences" } = linkReferences === true ? {} : linkReferences;
263
- const urls = [];
264
- visit(tree, "link", (node) => {
265
- urls.push({ href: node.url });
266
- return "skip";
267
- });
268
- file.data["mdx-export"].push({
269
- name: as,
270
- value: urls
271
- });
272
- }
273
- if (processedMarkdown) {
274
- const { as = "_markdown", headingIds = true } = processedMarkdown === true ? {} : processedMarkdown;
275
- const extensions = this.data("toMarkdownExtensions") ?? [];
276
- const markdown = toMarkdown(tree, {
277
- ...this.data("settings"),
278
- extensions: _format === "md" ? [...extensions, mdxToMarkdown()] : extensions,
279
- handlers: { heading(node) {
280
- const id = node.data?.hProperties?.id;
281
- const content = flattenNode(node);
282
- return headingIds && id ? `${content} [#${id}]` : content;
283
- } }
284
- });
285
- file.data["mdx-export"].push({
286
- name: as,
287
- value: markdown
288
- });
289
- }
290
- if (mdast) {
291
- const { as = "_mdast", removePosition: shouldRemovePosition = false } = mdast === true ? {} : mdast;
292
- const stringified = JSON.stringify(shouldRemovePosition ? removePosition(structuredClone(tree)) : tree);
293
- file.data["mdx-export"].push({
294
- name: as,
295
- value: stringified
296
- });
297
- }
298
- for (const { name, value } of file.data["mdx-export"]) tree.children.unshift(getMdastExport(name, value));
299
- file.data["mdx-export"] = [];
300
- for (const name of valueToExport) {
301
- if (!(name in file.data)) continue;
302
- tree.children.unshift(getMdastExport(name, file.data[name]));
303
- }
304
- };
305
- }
306
- /**
307
- * MDX.js first converts javascript (with esm support) into mdast nodes with remark-mdx, then handle the other remark plugins
308
- *
309
- * Therefore, if we want to inject an export, we must convert the object into AST, then add the mdast node
310
- */
311
- function getMdastExport(name, value) {
312
- return {
313
- type: "mdxjsEsm",
314
- value: "",
315
- data: { estree: {
316
- type: "Program",
317
- sourceType: "module",
318
- body: [{
319
- type: "ExportNamedDeclaration",
320
- specifiers: [],
321
- attributes: [],
322
- source: null,
323
- declaration: {
324
- type: "VariableDeclaration",
325
- kind: "let",
326
- declarations: [{
327
- type: "VariableDeclarator",
328
- id: {
329
- type: "Identifier",
330
- name
331
- },
332
- init: valueToEstree(value)
333
- }]
334
- }
335
- }]
336
- } }
337
- };
338
- }
339
-
340
- //#endregion
341
- //#region src/collections/mdx/build-mdx.ts
342
- var build_mdx_exports = /* @__PURE__ */ __exportAll({ buildMDX: () => buildMDX });
343
- async function buildMDX(core, collection, { filePath, frontmatter, source, compiler, environment, isDevelopment }) {
344
- const processorCache = createCache(core.cache).$value();
345
- function getProcessor(format) {
346
- const key = `build-mdx:${collection?.name ?? "global"}:${format}`;
347
- return processorCache.cached(key, async () => {
348
- const mdxOptions = await collection?.getMDXOptions?.(environment);
349
- const postprocessOptions = {
350
- _format: format,
351
- ...collection?.postprocess
352
- };
353
- const remarkIncludeOptions = { preprocess: collection?.preprocess?.remarkPlugins };
354
- return createProcessor({
355
- outputFormat: "program",
356
- development: isDevelopment,
357
- ...mdxOptions,
358
- remarkPlugins: [
359
- [remarkInclude, remarkIncludeOptions],
360
- ...mdxOptions?.remarkPlugins ?? [],
361
- [remarkPostprocess, postprocessOptions]
362
- ],
363
- format
364
- });
365
- });
366
- }
367
- let vfile = new VFile({
368
- value: source,
369
- path: filePath,
370
- cwd: core.getOptions().cwd,
371
- data: {
372
- frontmatter,
373
- _compiler: compiler,
374
- _getProcessor: getProcessor
375
- }
376
- });
377
- if (collection && collection) vfile = await collection.vfile.run(vfile, {
378
- collection,
379
- filePath,
380
- source
381
- });
382
- return (await getProcessor(filePath.endsWith(".mdx") ? "mdx" : "md")).process(vfile);
383
- }
384
-
385
- //#endregion
386
- export { build_mdx_exports as n, buildMDX as t };
387
- //# sourceMappingURL=build-mdx-DgzggXIL.js.map