fuma-content 1.1.2 → 1.1.3

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 (181) hide show
  1. package/dist/async-cache-CBEZB25o.d.ts +9 -0
  2. package/dist/async-cache-CBEZB25o.d.ts.map +1 -0
  3. package/dist/{async-cache-U87GzQTb.js → async-cache-DRmFaVGm.js} +1 -1
  4. package/dist/{async-cache-U87GzQTb.js.map → async-cache-DRmFaVGm.js.map} +1 -1
  5. package/dist/build-mdx-DkAvzRNg.d.ts +73 -0
  6. package/dist/build-mdx-DkAvzRNg.d.ts.map +1 -0
  7. package/dist/{build-mdx-CUp6FpfT.js → build-mdx-oug7zk0w.js} +23 -36
  8. package/dist/build-mdx-oug7zk0w.js.map +1 -0
  9. package/dist/bun/index.d.ts +1 -1
  10. package/dist/bun/index.d.ts.map +1 -1
  11. package/dist/bun/index.js +2 -2
  12. package/dist/{bun-CBROq3I0.js → bun-cxKGeSx6.js} +1 -1
  13. package/dist/bun-cxKGeSx6.js.map +1 -0
  14. package/dist/{code-generator-Qhhq7kHh.js → code-generator-C_Gu9y3h.js} +4 -4
  15. package/dist/code-generator-C_Gu9y3h.js.map +1 -0
  16. package/dist/collections/data/runtime.d.ts +3 -6
  17. package/dist/collections/data/runtime.d.ts.map +1 -1
  18. package/dist/collections/data/runtime.js.map +1 -1
  19. package/dist/collections/data.d.ts +4 -4
  20. package/dist/collections/data.d.ts.map +1 -1
  21. package/dist/collections/data.js +158 -4
  22. package/dist/collections/data.js.map +1 -0
  23. package/dist/collections/fs.d.ts +45 -3
  24. package/dist/collections/fs.d.ts.map +1 -0
  25. package/dist/collections/fs.js +65 -2
  26. package/dist/collections/fs.js.map +1 -0
  27. package/dist/collections/index.d.ts +37 -2
  28. package/dist/collections/index.d.ts.map +1 -0
  29. package/dist/collections/index.js +37 -2
  30. package/dist/collections/index.js.map +1 -0
  31. package/dist/collections/json/loader-webpack.d.ts +3 -3
  32. package/dist/collections/json/loader-webpack.d.ts.map +1 -1
  33. package/dist/collections/json/loader-webpack.js +3 -7
  34. package/dist/collections/json/loader-webpack.js.map +1 -1
  35. package/dist/collections/mdx/loader-webpack.d.ts +3 -3
  36. package/dist/collections/mdx/loader-webpack.d.ts.map +1 -1
  37. package/dist/collections/mdx/loader-webpack.js +3 -8
  38. package/dist/collections/mdx/loader-webpack.js.map +1 -1
  39. package/dist/collections/mdx/react.d.ts +4 -10
  40. package/dist/collections/mdx/react.d.ts.map +1 -1
  41. package/dist/collections/mdx/runtime-browser.d.ts +26 -11
  42. package/dist/collections/mdx/runtime-browser.d.ts.map +1 -0
  43. package/dist/collections/mdx/runtime-browser.js +2 -2
  44. package/dist/collections/mdx/runtime-browser.js.map +1 -1
  45. package/dist/collections/mdx/runtime-dynamic.d.ts +7 -10
  46. package/dist/collections/mdx/runtime-dynamic.d.ts.map +1 -1
  47. package/dist/collections/mdx/runtime-dynamic.js +9 -12
  48. package/dist/collections/mdx/runtime-dynamic.js.map +1 -1
  49. package/dist/collections/mdx/runtime.d.ts +27 -10
  50. package/dist/collections/mdx/runtime.d.ts.map +1 -0
  51. package/dist/collections/mdx/runtime.js.map +1 -1
  52. package/dist/collections/mdx.d.ts +67 -6
  53. package/dist/collections/mdx.d.ts.map +1 -0
  54. package/dist/collections/mdx.js +318 -6
  55. package/dist/collections/mdx.js.map +1 -0
  56. package/dist/collections/runtime/file-store.d.ts +21 -4
  57. package/dist/collections/runtime/file-store.d.ts.map +1 -0
  58. package/dist/collections/runtime/file-store.js +1 -1
  59. package/dist/collections/runtime/store.d.ts +31 -3
  60. package/dist/collections/runtime/store.d.ts.map +1 -0
  61. package/dist/collections/runtime/store.js +33 -2
  62. package/dist/collections/runtime/store.js.map +1 -0
  63. package/dist/collections/yaml/loader-webpack.d.ts +3 -3
  64. package/dist/collections/yaml/loader-webpack.d.ts.map +1 -1
  65. package/dist/collections/yaml/loader-webpack.js +3 -7
  66. package/dist/collections/yaml/loader-webpack.js.map +1 -1
  67. package/dist/config/index.d.ts +36 -2
  68. package/dist/config/index.d.ts.map +1 -0
  69. package/dist/{core-CT06v32N.d.ts → core-CG2zTL4c.d.ts} +4 -66
  70. package/dist/core-CG2zTL4c.d.ts.map +1 -0
  71. package/dist/{core-Uv3jZqL-.js → core-DmbQk8Z2.js} +9 -9
  72. package/dist/core-DmbQk8Z2.js.map +1 -0
  73. package/dist/dynamic.d.ts +25 -3
  74. package/dist/dynamic.d.ts.map +1 -0
  75. package/dist/dynamic.js +28 -2
  76. package/dist/dynamic.js.map +1 -0
  77. package/dist/{fuma-matter-BuBO2w-p.js → fuma-matter-Pwr2S9Ab.js} +1 -1
  78. package/dist/fuma-matter-Pwr2S9Ab.js.map +1 -0
  79. package/dist/index.d.ts +1 -1
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +3 -3
  82. package/dist/{load-from-file-z7EGuf2n.js → load-from-file-BeLFB77e.js} +4 -2
  83. package/dist/{load-from-file-z7EGuf2n.js.map → load-from-file-BeLFB77e.js.map} +1 -1
  84. package/dist/load-from-file-CpA8UQXX.d.ts +10 -0
  85. package/dist/load-from-file-CpA8UQXX.d.ts.map +1 -0
  86. package/dist/loader-DKTW82eK.js +19 -0
  87. package/dist/{loader-Cnz-VHne.js.map → loader-DKTW82eK.js.map} +1 -1
  88. package/dist/{loader-CnksfM7I.js → loader-DOjRBsog.js} +7 -5
  89. package/dist/loader-DOjRBsog.js.map +1 -0
  90. package/dist/loader-DTODFdmk.js +18 -0
  91. package/dist/{loader-BK8PnqRg.js.map → loader-DTODFdmk.js.map} +1 -1
  92. package/dist/{loader-CuntMmR4.js → loader-gwXIGo5Q.js} +3 -3
  93. package/dist/loader-gwXIGo5Q.js.map +1 -0
  94. package/dist/next/index.d.ts +1 -1
  95. package/dist/next/index.d.ts.map +1 -1
  96. package/dist/next/index.js +3 -3
  97. package/dist/next/index.js.map +1 -1
  98. package/dist/node/index.d.ts +1 -1
  99. package/dist/node/index.d.ts.map +1 -1
  100. package/dist/node/loader.d.ts +1 -1
  101. package/dist/node/loader.d.ts.map +1 -1
  102. package/dist/node/loader.js +8 -8
  103. package/dist/node/loader.js.map +1 -1
  104. package/dist/{node-2VZOh3P9.js → node-l03HaPSS.js} +1 -1
  105. package/dist/{node-2VZOh3P9.js.map → node-l03HaPSS.js.map} +1 -1
  106. package/dist/{collections-CNWuMDAZ.js → pipe-CvCqOpXX.js} +2 -36
  107. package/dist/pipe-CvCqOpXX.js.map +1 -0
  108. package/dist/plugins/git.d.ts +38 -3
  109. package/dist/plugins/git.d.ts.map +1 -0
  110. package/dist/plugins/git.js +60 -2
  111. package/dist/plugins/git.js.map +1 -0
  112. package/dist/plugins/json-schema.d.ts +2 -1
  113. package/dist/plugins/json-schema.d.ts.map +1 -1
  114. package/dist/plugins/json-schema.js +2 -2
  115. package/dist/plugins/json-schema.js.map +1 -1
  116. package/dist/plugins/loader/index.d.ts +75 -4
  117. package/dist/plugins/loader/index.d.ts.map +1 -0
  118. package/dist/plugins/loader/index.js +76 -2
  119. package/dist/plugins/loader/index.js.map +1 -0
  120. package/dist/plugins/loader/webpack.d.ts +21 -4
  121. package/dist/plugins/loader/webpack.d.ts.map +1 -0
  122. package/dist/plugins/loader/webpack.js +4 -4
  123. package/dist/plugins/loader/webpack.js.map +1 -1
  124. package/dist/rolldown-runtime-CjeV3_4I.js +18 -0
  125. package/dist/{validation-BvVvvLII.js → validation-C3kXuveD.js} +1 -1
  126. package/dist/{validation-BvVvvLII.js.map → validation-C3kXuveD.js.map} +1 -1
  127. package/dist/vite/index.d.ts +1 -1
  128. package/dist/vite/index.d.ts.map +1 -1
  129. package/dist/vite/index.js +3 -3
  130. package/dist/{vite-C1qXY47G.js → vite-mAc2TZyp.js} +3 -3
  131. package/dist/vite-mAc2TZyp.js.map +1 -0
  132. package/package.json +19 -10
  133. package/dist/build-mdx-CUp6FpfT.js.map +0 -1
  134. package/dist/build-mdx-D6zM3Sgl.js +0 -4
  135. package/dist/bun-CBROq3I0.js.map +0 -1
  136. package/dist/code-generator-Qhhq7kHh.js.map +0 -1
  137. package/dist/collections-CNWuMDAZ.js.map +0 -1
  138. package/dist/core-CT06v32N.d.ts.map +0 -1
  139. package/dist/core-Uv3jZqL-.js.map +0 -1
  140. package/dist/data-Cxsx5KPD.js +0 -159
  141. package/dist/data-Cxsx5KPD.js.map +0 -1
  142. package/dist/dynamic-Ck1wYoaL.d.ts +0 -33
  143. package/dist/dynamic-Ck1wYoaL.d.ts.map +0 -1
  144. package/dist/dynamic-CtOB4Rkp.js +0 -29
  145. package/dist/dynamic-CtOB4Rkp.js.map +0 -1
  146. package/dist/file-store-Dm1SjuLg.d.ts +0 -20
  147. package/dist/file-store-Dm1SjuLg.d.ts.map +0 -1
  148. package/dist/fs-CXzVd2Dp.js +0 -68
  149. package/dist/fs-CXzVd2Dp.js.map +0 -1
  150. package/dist/fs-CmwaaFyx.d.ts +0 -45
  151. package/dist/fs-CmwaaFyx.d.ts.map +0 -1
  152. package/dist/fuma-matter-BuBO2w-p.js.map +0 -1
  153. package/dist/git-DnejL9r_.js +0 -60
  154. package/dist/git-DnejL9r_.js.map +0 -1
  155. package/dist/git-n-9ddn78.d.ts +0 -37
  156. package/dist/git-n-9ddn78.d.ts.map +0 -1
  157. package/dist/index-BheUVWBm.d.ts +0 -87
  158. package/dist/index-BheUVWBm.d.ts.map +0 -1
  159. package/dist/load-from-file-D-Xm95Fz.js +0 -3
  160. package/dist/loader-B4nQrRwA.js +0 -77
  161. package/dist/loader-B4nQrRwA.js.map +0 -1
  162. package/dist/loader-B6ordrWK.js +0 -9
  163. package/dist/loader-BK8PnqRg.js +0 -16
  164. package/dist/loader-CnksfM7I.js.map +0 -1
  165. package/dist/loader-Cnz-VHne.js +0 -17
  166. package/dist/loader-CuntMmR4.js.map +0 -1
  167. package/dist/loader-Cx1Rg_VM.js +0 -8
  168. package/dist/loader-Dao_nv3e.js +0 -8
  169. package/dist/mdx-Cw1nBJ0D.js +0 -306
  170. package/dist/mdx-Cw1nBJ0D.js.map +0 -1
  171. package/dist/mdx-PaqRNZMS.d.ts +0 -135
  172. package/dist/mdx-PaqRNZMS.d.ts.map +0 -1
  173. package/dist/runtime-BUUHSFlR.d.ts +0 -31
  174. package/dist/runtime-BUUHSFlR.d.ts.map +0 -1
  175. package/dist/runtime-browser-B70WGxeQ.d.ts +0 -29
  176. package/dist/runtime-browser-B70WGxeQ.d.ts.map +0 -1
  177. package/dist/store-CRyvZFKN.js +0 -34
  178. package/dist/store-CRyvZFKN.js.map +0 -1
  179. package/dist/store-D_PPrdRE.d.ts +0 -31
  180. package/dist/store-D_PPrdRE.d.ts.map +0 -1
  181. package/dist/vite-C1qXY47G.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fuma-content",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "The content processing layer for your app.",
5
5
  "keywords": [
6
6
  "Content",
@@ -74,11 +74,11 @@
74
74
  "dependencies": {
75
75
  "@mdx-js/mdx": "^3.1.1",
76
76
  "@standard-schema/spec": "^1.1.0",
77
- "@types/mdx": "^2.0.13",
78
77
  "chokidar": "^5.0.0",
79
- "esbuild": "^0.27.2",
78
+ "esbuild": "^0.27.3",
80
79
  "estree-util-value-to-estree": "^3.5.0",
81
80
  "js-yaml": "^4.1.1",
81
+ "mdast-util-mdx": "^3.0.0",
82
82
  "mdast-util-to-markdown": "^2.1.2",
83
83
  "picocolors": "^1.1.1",
84
84
  "picomatch": "^4.0.3",
@@ -92,13 +92,14 @@
92
92
  "zod": "^4.3.6"
93
93
  },
94
94
  "devDependencies": {
95
- "@types/bun": "^1.3.7",
95
+ "@types/bun": "^1.3.8",
96
96
  "@types/js-yaml": "^4.0.9",
97
97
  "@types/mdast": "^4.0.4",
98
- "@types/node": "^25.1.0",
98
+ "@types/mdx": "^2.0.13",
99
+ "@types/node": "^25.2.2",
99
100
  "@types/picomatch": "^4.0.2",
100
- "@types/react": "^19.2.10",
101
- "fumadocs-core": "^16.4.10",
101
+ "@types/react": "^19.2.13",
102
+ "fumadocs-core": "^16.5.2",
102
103
  "mdast-util-directive": "^3.1.0",
103
104
  "mdast-util-mdx-jsx": "^3.2.0",
104
105
  "next": "16.1.6",
@@ -106,19 +107,27 @@
106
107
  "remark": "^15.0.1",
107
108
  "remark-directive": "^4.0.0",
108
109
  "remark-stringify": "^11.0.0",
109
- "rollup": "^4.57.0",
110
- "tsdown": "^0.18.2",
110
+ "rollup": "^4.57.1",
111
+ "tsdown": "^0.20.3",
111
112
  "typescript": "^5.9.3",
112
113
  "vite": "^7.3.1",
113
- "webpack": "^5.104.1",
114
+ "webpack": "^5.105.0",
114
115
  "typescript-config": "0.0.0"
115
116
  },
116
117
  "peerDependencies": {
118
+ "@types/mdast": "*",
119
+ "@types/mdx": "*",
117
120
  "next": "^15.3.0 || ^16.0.0",
118
121
  "react": "*",
119
122
  "vite": "6.x.x || 7.x.x"
120
123
  },
121
124
  "peerDependenciesMeta": {
125
+ "@types/mdx": {
126
+ "optional": true
127
+ },
128
+ "@types/mdast": {
129
+ "optional": true
130
+ },
122
131
  "react": {
123
132
  "optional": true
124
133
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-mdx-CUp6FpfT.js","names":["newChildren: RootContent[]","ElementLikeTypes: ElementLikeContent[\"type\"][]","attributes: Record<string, string | null>","nodes: RootContent[] | undefined","extractedLines: string[]","content: string","fs","path","queue: Promise<void>[]","_stringifyProcessor: Processor | undefined","urls: ExtractedReference[]","postprocessOptions: PostprocessOptions","remarkIncludeOptions: RemarkIncludeOptions"],"sources":["../src/collections/mdx/remark-unravel.ts","../src/collections/mdx/mdast-utils.ts","../src/collections/mdx/remark-include.ts","../src/collections/mdx/remark-postprocess.ts","../src/collections/mdx/remark-preprocess.ts","../src/collections/mdx/build-mdx.ts"],"sourcesContent":["// from internal remark plugins in https://github.com/mdx-js/mdx/blob/main/packages/mdx/lib/plugin/remark-mark-and-unravel.js\n// we need to ensure consistency with MDX.js when parsing embed content in `remark-include`\nimport { visit } from \"unist-util-visit\";\nimport type { Transformer } from \"unified\";\nimport type { Root, RootContent } from \"mdast\";\n\nexport function remarkMarkAndUnravel(): Transformer<Root, Root> {\n return (tree) => {\n visit(tree, (node, index, parent) => {\n let offset = -1;\n let all = true;\n let oneOrMore = false;\n\n if (parent && typeof index === \"number\" && node.type === \"paragraph\") {\n const children = node.children;\n\n while (++offset < children.length) {\n const child = children[offset];\n\n if (child.type === \"mdxJsxTextElement\" || child.type === \"mdxTextExpression\") {\n oneOrMore = true;\n } else if (child.type === \"text\" && child.value.trim().length === 0) {\n // Empty.\n } else {\n all = false;\n break;\n }\n }\n\n if (all && oneOrMore) {\n offset = -1;\n const newChildren: RootContent[] = [];\n\n while (++offset < children.length) {\n const child = children[offset];\n\n if (child.type === \"mdxJsxTextElement\") {\n // @ts-expect-error: mutate because it is faster; content model is fine.\n child.type = \"mdxJsxFlowElement\";\n }\n\n if (child.type === \"mdxTextExpression\") {\n // @ts-expect-error: mutate because it is faster; content model is fine.\n child.type = \"mdxFlowExpression\";\n }\n\n if (child.type === \"text\" && /^[\\t\\r\\n ]+$/.test(String(child.value))) {\n // Empty.\n } else {\n newChildren.push(child);\n }\n }\n\n parent.children.splice(index, 1, ...newChildren);\n return index;\n }\n }\n });\n };\n}\n","import type { RootContent } from \"mdast\";\n\nexport function flattenNode(node: RootContent): string {\n if (\"children\" in node) return node.children.map((child) => flattenNode(child)).join(\"\");\n\n if (\"value\" in node) return node.value;\n\n return \"\";\n}\n","import { type PluggableList, type Processor, type Transformer, unified } from \"unified\";\nimport { visit } from \"unist-util-visit\";\nimport type { Code, Node, Root, RootContent } from \"mdast\";\nimport * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\nimport { fumaMatter } from \"@/collections/mdx/fuma-matter\";\nimport type { MdxJsxFlowElement, MdxJsxTextElement } from \"mdast-util-mdx-jsx\";\nimport { VFile } from \"vfile\";\nimport type { Directives } from \"mdast-util-directive\";\nimport { remarkMarkAndUnravel } from \"@/collections/mdx/remark-unravel\";\nimport { flattenNode } from \"./mdast-utils\";\n\nexport interface Params {\n lang?: string;\n meta?: string;\n}\n\nconst ElementLikeTypes: ElementLikeContent[\"type\"][] = [\n \"mdxJsxFlowElement\",\n \"mdxJsxTextElement\",\n \"containerDirective\",\n \"textDirective\",\n \"leafDirective\",\n];\ntype ElementLikeContent = MdxJsxFlowElement | MdxJsxTextElement | Directives;\n\nfunction isElementLike(node: Node): node is ElementLikeContent {\n return ElementLikeTypes.includes(node.type as ElementLikeContent[\"type\"]);\n}\n\nfunction parseElementAttributes(\n element: ElementLikeContent,\n): Record<string, string | null | undefined> {\n if (Array.isArray(element.attributes)) {\n const attributes: Record<string, string | null> = {};\n\n for (const attr of element.attributes) {\n if (\n attr.type === \"mdxJsxAttribute\" &&\n (typeof attr.value === \"string\" || attr.value === null)\n ) {\n attributes[attr.name] = attr.value;\n }\n }\n\n return attributes;\n }\n\n return element.attributes ?? {};\n}\n\nfunction parseSpecifier(specifier: string): {\n file: string;\n section?: string;\n} {\n const idx = specifier.lastIndexOf(\"#\");\n if (idx === -1) return { file: specifier };\n\n return {\n file: specifier.slice(0, idx),\n section: specifier.slice(idx + 1),\n };\n}\n\nfunction extractSection(root: Root, section: string): Root | undefined {\n let nodes: RootContent[] | undefined;\n let capturingHeadingContent = false;\n\n visit(root, (node) => {\n if (node.type === \"heading\") {\n if (capturingHeadingContent) {\n return false;\n }\n\n if (node.data?.hProperties?.id === section) {\n capturingHeadingContent = true;\n nodes = [node];\n return \"skip\";\n }\n\n return;\n }\n\n if (capturingHeadingContent) {\n nodes?.push(node as RootContent);\n return \"skip\";\n }\n\n if (isElementLike(node) && node.name === \"section\") {\n const attributes = parseElementAttributes(node);\n\n if (attributes.id === section) {\n nodes = node.children;\n return false;\n }\n }\n });\n\n if (nodes)\n return {\n type: \"root\",\n children: nodes,\n };\n}\n\n// region marker regexes\nconst REGION_MARKERS = [\n {\n start: /^\\s*\\/\\/\\s*#?region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*\\/\\/\\s*#?endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*<!--\\s*#?region\\b\\s*(.*?)\\s*-->/,\n end: /^\\s*<!--\\s*#?endregion\\b\\s*(.*?)\\s*-->/,\n },\n {\n start: /^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\//,\n end: /^\\s*\\/\\*\\s*#endregion\\b\\s*(.*?)\\s*\\*\\//,\n },\n {\n start: /^\\s*#[rR]egion\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#[eE]nd ?[rR]egion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*#\\s*#?region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#\\s*#?endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*(?:--|::|@?REM)\\s*#region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*(?:--|::|@?REM)\\s*#endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*#pragma\\s+region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#pragma\\s+endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*\\(\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\)/,\n end: /^\\s*\\(\\*\\s*#endregion\\b\\s*(.*?)\\s*\\*\\)/,\n },\n];\n\nfunction dedent(lines: string[]): string {\n const minIndent = lines.reduce((min, line) => {\n const match = line.match(/^(\\s*)\\S/);\n return match ? Math.min(min, match[1].length) : min;\n }, Infinity);\n\n return minIndent === Infinity\n ? lines.join(\"\\n\")\n : lines.map((l) => l.slice(minIndent)).join(\"\\n\");\n}\n\nfunction extractCodeRegion(content: string, regionName: string): string {\n const lines = content.split(\"\\n\");\n\n for (let i = 0; i < lines.length; i++) {\n for (const re of REGION_MARKERS) {\n let match = re.start.exec(lines[i]);\n if (match?.[1] !== regionName) continue;\n\n let depth = 1;\n const extractedLines: string[] = [];\n for (let j = i + 1; j < lines.length; j++) {\n match = re.start.exec(lines[j]);\n if (match) {\n depth++;\n continue;\n }\n\n match = re.end.exec(lines[j]);\n if (match) {\n if (match[1] === regionName) depth = 0;\n else if (match[1] === \"\") depth--;\n else continue;\n\n if (depth > 0) continue;\n return dedent(extractedLines);\n } else {\n extractedLines.push(lines[j]);\n }\n }\n }\n }\n throw new Error(`Region \"${regionName}\" not found`);\n}\n\nexport interface RemarkIncludeOptions {\n /**\n * remark plugins to preprocess the MDAST tree before scanning headings/sections.\n *\n * e.g. parse headings before extraction.\n */\n preprocess?: PluggableList;\n}\n\nexport function remarkInclude(\n this: Processor,\n { preprocess = [] }: RemarkIncludeOptions = {},\n): Transformer<Root, Root> {\n const TagName = \"include\";\n const preprocessor = unified().use(remarkMarkAndUnravel).use(preprocess);\n\n const embedContent = async (\n targetPath: string,\n heading: string | undefined,\n params: Params,\n parent: VFile,\n ) => {\n const { _getProcessor = () => this, _compiler } = parent.data;\n let content: string;\n try {\n content = (await fs.readFile(targetPath)).toString();\n } catch (e) {\n throw new Error(\n `failed to read file ${targetPath}\\n${e instanceof Error ? e.message : String(e)}`,\n { cause: e },\n );\n }\n\n const ext = path.extname(targetPath);\n _compiler?.addDependency(targetPath);\n if (params.lang || (ext !== \".md\" && ext !== \".mdx\")) {\n const lang = params.lang ?? ext.slice(1);\n\n return {\n type: \"code\",\n lang,\n meta: params.meta,\n value: heading ? extractCodeRegion(content, heading) : content,\n data: {},\n } satisfies Code;\n }\n\n const parser = await _getProcessor(ext === \".mdx\" ? \"mdx\" : \"md\");\n const parsed = fumaMatter(content);\n const targetFile = new VFile({\n path: targetPath,\n value: parsed.content,\n data: {\n ...parent.data,\n frontmatter: parsed.data as Record<string, unknown>,\n },\n });\n\n let mdast = await preprocessor.run(parser.parse(targetFile) as Root, targetFile);\n\n if (heading) {\n const extracted = extractSection(mdast, heading);\n if (!extracted)\n throw new Error(\n `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.`,\n );\n\n mdast = extracted;\n }\n\n await update(mdast, targetFile);\n return mdast;\n };\n\n async function update(tree: Root, file: VFile) {\n const queue: Promise<void>[] = [];\n\n visit(tree, ElementLikeTypes, (_node, _, parent) => {\n const node = _node as ElementLikeContent;\n if (node.name !== TagName) return;\n\n const specifier = flattenNode(node);\n if (specifier.length === 0) return \"skip\";\n\n const attributes = parseElementAttributes(node);\n const { file: relativePath, section } = parseSpecifier(specifier);\n const targetPath = path.resolve(\n \"cwd\" in attributes ? file.cwd : (file.dirname ?? \"\"),\n relativePath,\n );\n\n queue.push(\n embedContent(targetPath, section, attributes, file).then((replace) => {\n Object.assign(parent && parent.type === \"paragraph\" ? parent : node, replace);\n }),\n );\n\n return \"skip\";\n });\n\n await Promise.all(queue);\n }\n\n return async (tree, file) => {\n await update(tree, file);\n };\n}\n","import type { Processor, Transformer } from \"unified\";\nimport type { Heading, Root, RootContent } from \"mdast\";\nimport { visit } from \"unist-util-visit\";\nimport { toMarkdown } from \"mdast-util-to-markdown\";\nimport { valueToEstree } from \"estree-util-value-to-estree\";\nimport { removePosition } from \"unist-util-remove-position\";\nimport remarkMdx from \"remark-mdx\";\nimport { flattenNode } from \"./mdast-utils\";\n\nexport interface ExtractedReference {\n href: string;\n}\n\nexport interface PostprocessOptions {\n _format: \"md\" | \"mdx\";\n\n /**\n * Properties to export from `vfile.data`\n */\n valueToExport?: string[];\n\n /**\n * stringify MDAST and export via `_markdown`.\n */\n includeProcessedMarkdown?:\n | boolean\n | {\n /**\n * include heading IDs into the processed markdown.\n */\n headingIds?: boolean;\n };\n\n /**\n * extract link references, export via `extractedReferences`.\n */\n extractLinkReferences?: boolean;\n\n /**\n * store MDAST and export via `_mdast`.\n */\n includeMDAST?:\n | boolean\n | {\n removePosition?: boolean;\n };\n}\n\n/**\n * - collect references\n * - write frontmatter (auto-title & description)\n */\nexport function remarkPostprocess(\n this: Processor,\n {\n _format,\n includeProcessedMarkdown = false,\n includeMDAST = false,\n extractLinkReferences = false,\n valueToExport = [],\n }: PostprocessOptions,\n): Transformer<Root, Root> {\n let _stringifyProcessor: Processor | undefined;\n const getStringifyProcessor = () => {\n return (_stringifyProcessor ??=\n _format === \"mdx\"\n ? this\n : // force Markdown processor to stringify MDX nodes\n this().use(remarkMdx).freeze());\n };\n\n return (tree, file) => {\n const frontmatter = (file.data.frontmatter ??= {});\n if (!frontmatter.title) {\n visit(tree, \"heading\", (node) => {\n if (node.depth === 1) {\n frontmatter.title = flattenNode(node);\n return false;\n }\n });\n }\n\n file.data[\"mdx-export\"] ??= [];\n file.data[\"mdx-export\"].push({\n name: \"frontmatter\",\n value: frontmatter,\n });\n\n if (extractLinkReferences) {\n const urls: ExtractedReference[] = [];\n\n visit(tree, \"link\", (node) => {\n urls.push({\n href: node.url,\n });\n return \"skip\";\n });\n\n file.data[\"mdx-export\"].push({\n name: \"extractedReferences\",\n value: urls,\n });\n }\n\n if (includeProcessedMarkdown) {\n const { headingIds = true } =\n typeof includeProcessedMarkdown === \"object\" ? includeProcessedMarkdown : {};\n const processor = getStringifyProcessor();\n const markdown = toMarkdown(tree, {\n ...processor.data(\"settings\"),\n // from https://github.com/remarkjs/remark/blob/main/packages/remark-stringify/lib/index.js\n extensions: processor.data(\"toMarkdownExtensions\") || [],\n handlers: {\n heading(node: Heading) {\n const id = node.data?.hProperties?.id;\n const content = flattenNode(node);\n return headingIds && id ? `${content} [#${id}]` : content;\n },\n },\n });\n\n file.data[\"mdx-export\"].push({\n name: \"_markdown\",\n value: markdown,\n });\n }\n\n if (includeMDAST) {\n const options = includeMDAST === true ? {} : includeMDAST;\n const mdast = JSON.stringify(\n options.removePosition ? removePosition(structuredClone(tree)) : tree,\n );\n\n file.data[\"mdx-export\"].push({\n name: \"_mdast\",\n value: mdast,\n });\n }\n\n for (const { name, value } of file.data[\"mdx-export\"]) {\n tree.children.unshift(getMdastExport(name, value));\n }\n\n // reset the data to reduce memory usage\n file.data[\"mdx-export\"] = [];\n\n for (const name of valueToExport) {\n if (!(name in file.data)) continue;\n\n tree.children.unshift(getMdastExport(name, file.data[name]));\n }\n };\n}\n\n/**\n * MDX.js first converts javascript (with esm support) into mdast nodes with remark-mdx, then handle the other remark plugins\n *\n * Therefore, if we want to inject an export, we must convert the object into AST, then add the mdast node\n */\nfunction getMdastExport(name: string, value: unknown): RootContent {\n return {\n type: \"mdxjsEsm\",\n value: \"\",\n data: {\n estree: {\n type: \"Program\",\n sourceType: \"module\",\n body: [\n {\n type: \"ExportNamedDeclaration\",\n specifiers: [],\n attributes: [],\n source: null,\n declaration: {\n type: \"VariableDeclaration\",\n kind: \"let\",\n declarations: [\n {\n type: \"VariableDeclarator\",\n id: {\n type: \"Identifier\",\n name,\n },\n init: valueToEstree(value),\n },\n ],\n },\n },\n ],\n },\n },\n };\n}\n","import type { Processor, Transformer } from \"unified\";\nimport type { Root } from \"mdast\";\n\nexport interface PreprocessOptions {\n preprocessor?: Processor<Root>;\n}\n\ndeclare module \"vfile\" {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- extend data map\n interface DataMap {\n _preprocessed?: boolean;\n }\n}\n\nexport function remarkPreprocess(options?: PreprocessOptions): Transformer<Root, Root> {\n return async (tree, file) => {\n if (file.data._preprocessed) return;\n file.data._preprocessed = true;\n\n if (options?.preprocessor) {\n return (await options.preprocessor.run(tree)) as Root;\n }\n };\n}\n","import { createProcessor } from \"@mdx-js/mdx\";\nimport { VFile } from \"vfile\";\nimport { remarkInclude, type RemarkIncludeOptions } from \"@/collections/mdx/remark-include\";\nimport { type PostprocessOptions, remarkPostprocess } from \"@/collections/mdx/remark-postprocess\";\nimport type { Core } from \"@/core\";\nimport { remarkPreprocess } from \"@/collections/mdx/remark-preprocess\";\nimport type { Pluggable } from \"unified\";\nimport { createCache } from \"@/utils/async-cache\";\nimport type { CompilerOptions } from \"@/plugins/loader\";\nimport type { MDXContent } from \"mdx/types\";\nimport { MDXCollection } from \"../mdx\";\n\ntype MDXProcessor = ReturnType<typeof createProcessor>;\n\ninterface BuildMDXOptions {\n /**\n * Specify a file path for source\n */\n filePath: string;\n source: string;\n frontmatter?: Record<string, unknown>;\n\n environment: \"bundler\" | \"runtime\";\n isDevelopment: boolean;\n _compiler?: CompilerOptions;\n}\n\nexport interface FumaContentDataMap {\n /**\n * [Fuma Content] raw frontmatter, you can modify it\n */\n frontmatter?: Record<string, unknown>;\n\n /**\n * [Fuma Content] additional ESM exports to write\n */\n \"mdx-export\"?: { name: string; value: unknown }[];\n\n /**\n * [Fuma Content] The compiler object from loader\n */\n _compiler?: CompilerOptions;\n\n /**\n * [Fuma Content] get internal processor, do not use this on user land.\n */\n _getProcessor?: (format: \"md\" | \"mdx\") => MDXProcessor | Promise<MDXProcessor>;\n}\n\ndeclare module \"vfile\" {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- extend data map\n interface DataMap extends FumaContentDataMap {}\n}\n\nexport interface CompiledMDX<Frontmatter = Record<string, unknown>> extends Record<\n string,\n unknown\n> {\n frontmatter: Frontmatter;\n default: MDXContent;\n}\n\nexport async function buildMDX(\n core: Core,\n collection: MDXCollection | undefined,\n { filePath, frontmatter, source, _compiler, environment, isDevelopment }: BuildMDXOptions,\n): Promise<VFile> {\n const processorCache = createCache(core.cache).$value<MDXProcessor>();\n\n function getProcessor(format: \"md\" | \"mdx\") {\n const key = `build-mdx:${collection?.name ?? \"global\"}:${format}`;\n\n return processorCache.cached(key, async () => {\n const mdxOptions = await collection?.getMDXOptions?.(environment);\n const preprocessPlugin = [remarkPreprocess, collection?.preprocess] satisfies Pluggable;\n const postprocessOptions: PostprocessOptions = {\n _format: format,\n ...collection?.postprocess,\n };\n const remarkIncludeOptions: RemarkIncludeOptions = {\n preprocess: [preprocessPlugin],\n };\n\n return createProcessor({\n outputFormat: \"program\",\n development: isDevelopment,\n ...mdxOptions,\n remarkPlugins: [\n preprocessPlugin,\n [remarkInclude, remarkIncludeOptions],\n ...(mdxOptions?.remarkPlugins ?? []),\n [remarkPostprocess, postprocessOptions],\n ],\n format,\n });\n });\n }\n\n let vfile = new VFile({\n value: source,\n path: filePath,\n cwd: core.getOptions().cwd,\n data: {\n frontmatter,\n _compiler,\n _getProcessor: getProcessor,\n },\n });\n\n if (collection && collection) {\n vfile = await collection.vfile.run(vfile, {\n collection,\n filePath,\n source,\n });\n }\n\n return (await getProcessor(filePath.endsWith(\".mdx\") ? \"mdx\" : \"md\")).process(vfile);\n}\n"],"mappings":";;;;;;;;;;;;;;AAMA,SAAgB,uBAAgD;AAC9D,SAAQ,SAAS;AACf,QAAM,OAAO,MAAM,OAAO,WAAW;GACnC,IAAI,SAAS;GACb,IAAI,MAAM;GACV,IAAI,YAAY;AAEhB,OAAI,UAAU,OAAO,UAAU,YAAY,KAAK,SAAS,aAAa;IACpE,MAAM,WAAW,KAAK;AAEtB,WAAO,EAAE,SAAS,SAAS,QAAQ;KACjC,MAAM,QAAQ,SAAS;AAEvB,SAAI,MAAM,SAAS,uBAAuB,MAAM,SAAS,oBACvD,aAAY;cACH,MAAM,SAAS,UAAU,MAAM,MAAM,MAAM,CAAC,WAAW,GAAG,QAE9D;AACL,YAAM;AACN;;;AAIJ,QAAI,OAAO,WAAW;AACpB,cAAS;KACT,MAAMA,cAA6B,EAAE;AAErC,YAAO,EAAE,SAAS,SAAS,QAAQ;MACjC,MAAM,QAAQ,SAAS;AAEvB,UAAI,MAAM,SAAS,oBAEjB,OAAM,OAAO;AAGf,UAAI,MAAM,SAAS,oBAEjB,OAAM,OAAO;AAGf,UAAI,MAAM,SAAS,UAAU,eAAe,KAAK,OAAO,MAAM,MAAM,CAAC,EAAE,OAGrE,aAAY,KAAK,MAAM;;AAI3B,YAAO,SAAS,OAAO,OAAO,GAAG,GAAG,YAAY;AAChD,YAAO;;;IAGX;;;;;;ACvDN,SAAgB,YAAY,MAA2B;AACrD,KAAI,cAAc,KAAM,QAAO,KAAK,SAAS,KAAK,UAAU,YAAY,MAAM,CAAC,CAAC,KAAK,GAAG;AAExF,KAAI,WAAW,KAAM,QAAO,KAAK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MDX };
@@ -1 +0,0 @@
1
- {"version":3,"file":"bun-CBROq3I0.js","names":["input: LoaderInput"],"sources":["../src/plugins/loader/bun.ts"],"sourcesContent":["import { parse } from \"node:querystring\";\nimport { readFileSync } from \"node:fs\";\nimport type { LoaderInput, Loader, LoaderOutput } from \"@/plugins/loader\";\n\nexport function toBun(test: RegExp = /.+/, loader: Loader) {\n function toResult(output: LoaderOutput | null): Bun.OnLoadResult {\n // it errors, treat this as an exception\n if (!output) return;\n\n return {\n contents: output.code,\n loader: output.moduleType ?? \"js\",\n };\n }\n\n return (build: Bun.PluginBuilder): void => {\n // avoid using async here, because it will cause dynamic require() to fail\n build.onLoad({ filter: test }, (args) => {\n const [filePath, query = \"\"] = args.path.split(\"?\", 2);\n const input: LoaderInput = {\n async getSource() {\n return Bun.file(filePath).text();\n },\n query: parse(query),\n filePath,\n development: false,\n compiler: {\n addDependency() {},\n },\n };\n\n if (loader.bun?.load) {\n return loader.bun.load(readFileSync(filePath).toString(), input);\n }\n\n const result = loader.load(input);\n if (result instanceof Promise) {\n return result.then(toResult);\n }\n return toResult(result);\n });\n };\n}\n"],"mappings":";;;;AAIA,SAAgB,MAAM,OAAe,MAAM,QAAgB;CACzD,SAAS,SAAS,QAA+C;AAE/D,MAAI,CAAC,OAAQ;AAEb,SAAO;GACL,UAAU,OAAO;GACjB,QAAQ,OAAO,cAAc;GAC9B;;AAGH,SAAQ,UAAmC;AAEzC,QAAM,OAAO,EAAE,QAAQ,MAAM,GAAG,SAAS;GACvC,MAAM,CAAC,UAAU,QAAQ,MAAM,KAAK,KAAK,MAAM,KAAK,EAAE;GACtD,MAAMA,QAAqB;IACzB,MAAM,YAAY;AAChB,YAAO,IAAI,KAAK,SAAS,CAAC,MAAM;;IAElC,OAAO,MAAM,MAAM;IACnB;IACA,aAAa;IACb,UAAU,EACR,gBAAgB,IACjB;IACF;AAED,OAAI,OAAO,KAAK,KACd,QAAO,OAAO,IAAI,KAAK,aAAa,SAAS,CAAC,UAAU,EAAE,MAAM;GAGlE,MAAM,SAAS,OAAO,KAAK,MAAM;AACjC,OAAI,kBAAkB,QACpB,QAAO,OAAO,KAAK,SAAS;AAE9B,UAAO,SAAS,OAAO;IACvB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"code-generator-Qhhq7kHh.js","names":["filename: string","final: string[]","namedImports: string[]","path"],"sources":["../src/utils/code-generator.ts"],"sourcesContent":["import type { EmitConfig } from \"@/config\";\nimport path from \"node:path\";\nimport { URLSearchParams } from \"node:url\";\n\nexport interface CodeGeneratorOptions extends EmitConfig {\n outDir: string;\n}\n\ninterface ImportInfo {\n /**\n * import name -> member name\n */\n named?: Map<string, string>;\n namespaces?: Set<string>;\n /**\n * a set of import names, the import is type-only if its name is missing in this set.\n */\n isUsed?: Set<string>;\n}\n\n/**\n * Code generator (one instance per file)\n */\nexport class CodeGenerator {\n private readonly lines: string[] = [];\n // specifier -> imported members/info\n private readonly importInfos = new Map<string, ImportInfo>();\n private eagerImportId = 0;\n\n readonly options: CodeGeneratorOptions;\n constructor({\n target = \"default\",\n jsExtension = false,\n outDir = \"\",\n }: Partial<CodeGeneratorOptions>) {\n this.options = {\n target,\n jsExtension,\n outDir,\n };\n }\n\n addNamespaceImport(namespace: string, specifier: string, typeOnly = false) {\n const info = this.importInfos.get(specifier) ?? {};\n this.importInfos.set(specifier, info);\n if (!typeOnly) {\n info.isUsed ??= new Set();\n info.isUsed.add(namespace);\n }\n\n info.namespaces ??= new Set();\n info.namespaces.add(namespace);\n }\n\n addNamedImport(names: string[], specifier: string, typeOnly = false) {\n const info = this.importInfos.get(specifier) ?? {};\n this.importInfos.set(specifier, info);\n info.named ??= new Map();\n\n for (const name of names) {\n const [memberName, importName = memberName] = name.split(/\\s+as\\s+/, 2);\n info.named.set(importName, memberName);\n if (!typeOnly) {\n info.isUsed ??= new Set();\n info.isUsed.add(importName);\n }\n }\n }\n\n push(...insert: string[]) {\n this.lines.push(...insert);\n }\n\n async pushAsync(insert: Promise<string | undefined>[]) {\n for (const line of await Promise.all(insert)) {\n if (line === undefined) continue;\n\n this.lines.push(line);\n }\n }\n\n /** generate a random import name that is unique in file. */\n generateImportName(): string {\n return `__${this.eagerImportId++}`;\n }\n\n formatDynamicImport(specifier: string, mod?: string): string {\n let s = `import(\"${specifier}\")`;\n if (mod) s += `.then(mod => mod.${mod})`;\n return s;\n }\n\n formatQuery(query: Record<string, string | undefined>) {\n const params = new URLSearchParams();\n for (const k in query) {\n const value = query[k];\n if (typeof value === \"string\") params.set(k, value);\n }\n return params.toString();\n }\n\n formatImportPath(file: string) {\n const ext = path.extname(file);\n let filename: string;\n\n switch (ext) {\n case \".ts\":\n case \".tsx\":\n filename = file.substring(0, file.length - ext.length);\n if (this.options.jsExtension) filename += \".js\";\n break;\n default:\n filename = file;\n }\n\n const importPath = slash(path.relative(this.options.outDir, filename));\n return importPath.startsWith(\"../\") ? importPath : `./${importPath}`;\n }\n\n toString() {\n const final: string[] = [\"// @ts-nocheck\"];\n if (this.options.target === \"vite\") {\n final.push('/// <reference types=\"vite/client\" />');\n }\n\n for (const [specifier, { namespaces, isUsed, named }] of this.importInfos) {\n if (namespaces)\n for (const namespace of namespaces) {\n final.push(\n isUsed?.has(namespace)\n ? `import * as ${namespace} from \"${specifier}\";`\n : `import type * as ${namespace} from \"${specifier}\";`,\n );\n }\n\n if (named && named.size > 0) {\n const namedImports: string[] = [];\n\n for (const [importName, memberName] of named) {\n const item = importName === memberName ? importName : `${memberName} as ${importName}`;\n\n namedImports.push(isUsed?.has(importName) ? item : `type ${item}`);\n }\n\n final.push(`import { ${namedImports.join(\", \")} } from \"${specifier}\";`);\n }\n }\n\n final.push(...this.lines);\n return final.join(\"\\n\");\n }\n}\n\nexport function slash(path: string): string {\n const isExtendedLengthPath = path.startsWith(\"\\\\\\\\?\\\\\");\n\n if (isExtendedLengthPath) {\n return path;\n }\n\n return path.replaceAll(\"\\\\\", \"/\");\n}\n\nexport function ident(code: string, tab: number = 1) {\n return code\n .split(\"\\n\")\n .map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AG,KAAK,MAAM;AACzB,SAAO,MAAM,KAAK,KAAK;;;AAI3B,SAAgB,MAAM,QAAsB;AAG1C,KAF6BC,OAAK,WAAW,UAAU,CAGrD,QAAOA;AAGT,QAAOA,OAAK,WAAW,MAAM,IAAI"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"collections-CNWuMDAZ.js","names":["hook"],"sources":["../src/utils/hook.ts","../src/utils/pipe.ts","../src/collections/index.ts"],"sourcesContent":["import type { Awaitable } from \"@/types\";\n\nexport interface Hook<Context = undefined> {\n /**\n * add a hook\n *\n * @returns the same pipe instance\n */\n hook: (fn: (context: Context) => void) => Hook<Context>;\n run: (context: Context) => void;\n $inferHandler: (context: Context) => Awaitable<void>;\n}\n\nexport interface AsyncHook<Context = undefined> {\n /**\n * add a hook\n *\n * @returns the same pipe instance\n */\n hook: (fn: (context: Context) => Awaitable<void>) => AsyncHook<Context>;\n run: (context: Context) => Awaitable<void>;\n $inferHandler: (context: Context) => Awaitable<void>;\n}\n\nexport function hook<Context>(steps: ((ctx: Context) => void)[] = []): Hook<Context> {\n return {\n async run(ctx) {\n for (const step of steps) step(ctx);\n },\n hook(fn) {\n steps.push(fn);\n return this;\n },\n $inferHandler: undefined as never,\n };\n}\n\nexport function asyncHook<Context>(\n steps: ((ctx: Context) => Awaitable<void>)[] = [],\n): AsyncHook<Context> {\n return {\n async run(ctx) {\n await Promise.all(steps.map((step) => step(ctx)));\n },\n hook(fn) {\n steps.push(fn);\n return this;\n },\n $inferHandler: undefined as never,\n };\n}\n","import type { Awaitable } from \"@/types\";\n\nexport interface Pipe<Data, Context = undefined> {\n /**\n * add a transformation step\n *\n * @returns the same pipe instance\n */\n pipe: (fn: (data: Data, context: Context) => Data) => Pipe<Data, Context>;\n run: (data: Data, context: Context) => Data;\n $inferHandler: (data: Data, context: Context) => Data;\n}\n\nexport interface AsyncPipe<Data, Context = undefined> {\n /**\n * add a transformation step\n *\n * @returns the same pipe instance\n */\n pipe: (fn: (data: Data, context: Context) => Awaitable<Data>) => AsyncPipe<Data, Context>;\n run: (data: Data, context: Context) => Awaitable<Data>;\n $inferHandler: (data: Data, context: Context) => Awaitable<Data>;\n}\n\nexport function pipe<Data, Context>(\n steps: ((data: Data, context: Context) => Data)[] = [],\n): Pipe<Data, Context> {\n return {\n run(data, ctx) {\n for (const step of steps) {\n data = step(data, ctx);\n }\n return data;\n },\n pipe(fn) {\n steps.push(fn);\n return this;\n },\n $inferHandler: undefined as never,\n };\n}\n\nexport function asyncPipe<Data, Context>(\n steps: ((data: Data, context: Context) => Awaitable<Data>)[] = [],\n): AsyncPipe<Data, Context> {\n return {\n async run(data, ctx) {\n for (const step of steps) {\n data = await step(data, ctx);\n }\n return data;\n },\n pipe(fn) {\n steps.push(fn);\n return this;\n },\n $inferHandler: undefined as never,\n };\n}\n","import { Core, EmitContext, EmitEntry, PluginOption, ResolvedConfig, ServerContext } from \"@/core\";\nimport { asyncHook, hook } from \"@/utils/hook\";\nimport { asyncPipe } from \"@/utils/pipe\";\n\nexport interface CollectionHookContext {\n core: Core;\n collection: Collection;\n}\n\nexport class Collection {\n private readonly pluginHooks = new Map<symbol, unknown>();\n name = null as unknown as string;\n\n /**\n * on config loaded/updated\n */\n readonly onConfig = hook<CollectionHookContext & { config: ResolvedConfig }>();\n /**\n * Configure watch/dev server\n */\n readonly onServer = hook<CollectionHookContext & { server: ServerContext }>();\n readonly onInit = asyncHook<CollectionHookContext>();\n readonly onEmit = asyncPipe<EmitEntry[], EmitContext>();\n readonly plugins: PluginOption[] = [];\n\n pluginHook<T, Options>(hook: CollectionHook<T, Options>, options: Options): T;\n pluginHook<T>(hook: CollectionHook<T>): T;\n\n pluginHook<T, O>(hook: CollectionHook<T, O>, options?: O): T {\n let created = this.pluginHooks.get(hook.id) as T | undefined;\n if (created) return created;\n\n created = hook.create(this, options as O);\n this.pluginHooks.set(hook.id, created);\n return created;\n }\n\n getPluginHook<T>(hook: CollectionHook<T>): T | undefined {\n return this.pluginHooks.get(hook.id) as T | undefined;\n }\n}\n\nexport interface CollectionHook<T = unknown, Options = undefined> {\n id: symbol;\n create: (collection: Collection, options: Options) => T;\n}\n\nexport function defineCollectionHook<T, Options = undefined>(\n init: (collection: Collection, options: Options) => T,\n): CollectionHook<T, Options> {\n return {\n id: Symbol(),\n create: init,\n };\n}\n"],"mappings":";AAwBA,SAAgB,KAAc,QAAoC,EAAE,EAAiB;AACnF,QAAO;EACL,MAAM,IAAI,KAAK;AACb,QAAK,MAAM,QAAQ,MAAO,MAAK,IAAI;;EAErC,KAAK,IAAI;AACP,SAAM,KAAK,GAAG;AACd,UAAO;;EAET,eAAe;EAChB;;AAGH,SAAgB,UACd,QAA+C,EAAE,EAC7B;AACpB,QAAO;EACL,MAAM,IAAI,KAAK;AACb,SAAM,QAAQ,IAAI,MAAM,KAAK,SAAS,KAAK,IAAI,CAAC,CAAC;;EAEnD,KAAK,IAAI;AACP,SAAM,KAAK,GAAG;AACd,UAAO;;EAET,eAAe;EAChB;;;;;ACzBH,SAAgB,KACd,QAAoD,EAAE,EACjC;AACrB,QAAO;EACL,IAAI,MAAM,KAAK;AACb,QAAK,MAAM,QAAQ,MACjB,QAAO,KAAK,MAAM,IAAI;AAExB,UAAO;;EAET,KAAK,IAAI;AACP,SAAM,KAAK,GAAG;AACd,UAAO;;EAET,eAAe;EAChB;;AAGH,SAAgB,UACd,QAA+D,EAAE,EACvC;AAC1B,QAAO;EACL,MAAM,IAAI,MAAM,KAAK;AACnB,QAAK,MAAM,QAAQ,MACjB,QAAO,MAAM,KAAK,MAAM,IAAI;AAE9B,UAAO;;EAET,KAAK,IAAI;AACP,SAAM,KAAK,GAAG;AACd,UAAO;;EAET,eAAe;EAChB;;;;;AChDH,IAAa,aAAb,MAAwB;CACtB,AAAiB,8BAAc,IAAI,KAAsB;CACzD,OAAO;;;;CAKP,AAAS,WAAW,MAA0D;;;;CAI9E,AAAS,WAAW,MAAyD;CAC7E,AAAS,SAAS,WAAkC;CACpD,AAAS,SAAS,WAAqC;CACvD,AAAS,UAA0B,EAAE;CAKrC,WAAiB,QAA4B,SAAgB;EAC3D,IAAI,UAAU,KAAK,YAAY,IAAIA,OAAK,GAAG;AAC3C,MAAI,QAAS,QAAO;AAEpB,YAAUA,OAAK,OAAO,MAAM,QAAa;AACzC,OAAK,YAAY,IAAIA,OAAK,IAAI,QAAQ;AACtC,SAAO;;CAGT,cAAiB,QAAwC;AACvD,SAAO,KAAK,YAAY,IAAIA,OAAK,GAAG;;;AASxC,SAAgB,qBACd,MAC4B;AAC5B,QAAO;EACL,IAAI,QAAQ;EACZ,QAAQ;EACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"core-CT06v32N.d.ts","names":[],"sources":["../src/config/index.ts","../src/types.ts","../src/utils/hook.ts","../src/utils/pipe.ts","../src/collections/index.ts","../src/utils/code-generator.ts","../src/core.ts"],"sourcesContent":[],"mappings":";;;;;;UAGiB,mCACK,eAAe,cAAc,eAAe;YAEtD;gBACI;eACD,eAAe;EALb;;;;;EAGL,sBAAA,CAAA,EAAA,MAAA;EACI;;;EAaP,IAAA,CAAA,EAAA,UAAA;;AAGQ,UAAA,UAAA,CAAU;EAQV,MAAA,CAAA,EAAA,SAAe,GAAA,MAAA;EAKhB;;;EACkD,WAAA,CAAA,EAAA,OAAA;;AAC3C,UAPN,eAAA,CAOM;EAAb,GAAA,EAAA,MAAA;EAA8C,MAAA,EAL9C,YAK8C,GAAA;IAAb,OAAA,EALP,YAKO;EAAY,CAAA;;iBAFvC,mCACM,eAAe,cAAc,eAAe,sBACxD,aAAa,iBAAoB,aAAa;;;KClC5C,mDACV,eAAe,OAAO,MAAM,cACxB,OAAO,QACP;WACa;IAEX,YAAY;KAGR,eAAe,IAAI,YAAY;;;UCX1B;;;;;AFCjB;EACqC,IAAA,EAAA,CAAA,EAAA,EAAA,CAAA,OAAA,EEId,OFJc,EAAA,GAAA,IAAA,EAAA,GEIO,IFJP,CEIY,OFJZ,CAAA;EAAf,GAAA,EAAA,CAAA,OAAA,EEKL,OFL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,UF/PA,GAAA,SAAA;EAAqC,gBAAA,CAAA,CAAA,EEkQ9C,aFlQ8C;EAAU,UAAA,CAAA,MAAA,EEuQnD,aFvQmD,CAAA,EEuQtC,OFvQsC,CAAA,IAAA,CAAA;EACzC,oBAAA,CAAA,CAAA,EEqRT,OFrRS,CAAA,IAAA,CAAA;EAAf,IAAA,CAAA,WAAA,CAAA,EEyRI,WFzRJ,CAAA,EEyRuB,OFzRvB,CEyR+B,UFzR/B,CAAA;EAAoB;;;EAWG,cAAA,CAAA,YAAA,EAAA,MAAA,CAAA,EAAA,MAAA;EAAC,QAAA,UAAA;AAK9C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"core-Uv3jZqL-.js","names":["plugins: Plugin[]","deduped: Plugin[]","workspace","ctx: EmitContext","out: EmitOutput","generated: Awaitable<EmitEntry[]>[]","globalConfig: GlobalConfig"],"sources":["../src/core.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs/promises\";\nimport type { FSWatcher } from \"chokidar\";\nimport { Collection } from \"@/collections\";\nimport type * as Vite from \"vite\";\nimport type { NextConfig } from \"next\";\nimport type { LoadHook } from \"node:module\";\nimport { CodeGenerator } from \"@/utils/code-generator\";\nimport type { Awaitable } from \"@/types\";\nimport type { GlobalConfig } from \"./config\";\n\nexport interface ResolvedConfig extends Omit<GlobalConfig, \"collections\"> {\n collections: Map<string, Collection>;\n}\n\nexport interface EmitEntry {\n /**\n * path relative to output directory\n */\n path: string;\n content: string;\n}\n\nexport interface PluginContext {\n core: Core;\n}\n\nexport interface EmitContext extends PluginContext {\n createCodeGenerator: (\n path: string,\n content: (ctx: { codegen: CodeGenerator }) => Awaitable<void>,\n ) => Promise<EmitEntry>;\n}\n\nexport interface Plugin {\n /**\n * unique name for plugin\n *\n * @example `my-package:my-plugin`\n */\n name: string;\n\n /** when `true`, only keep the last plugin with same `name`. */\n dedupe?: boolean;\n\n /**\n * on config loaded/updated\n */\n config?: (this: PluginContext, config: ResolvedConfig) => Awaitable<void | ResolvedConfig>;\n\n /**\n * called after collection initialization\n */\n collection?: (this: PluginContext, collection: Collection) => Awaitable<void>;\n\n /**\n * Configure watch/dev server\n */\n configureServer?: (this: PluginContext, server: ServerContext) => void;\n\n vite?: {\n createPlugin?: (this: PluginContext) => Vite.PluginOption;\n };\n\n bun?: {\n setup?: (this: PluginContext, build: Bun.PluginBuilder) => Awaitable<void>;\n };\n\n next?: {\n config?: (this: PluginContext, config: NextConfig) => NextConfig;\n };\n\n node?: {\n createLoad?: (this: PluginContext) => Awaitable<LoadHook>;\n };\n}\n\nexport type PluginOption = Awaitable<Plugin | PluginOption[] | false | undefined>;\n\nexport interface ServerContext {\n /**\n * the file watcher, by default all content files are watched, along with other files.\n *\n * make sure to filter when listening to events\n */\n watcher?: FSWatcher;\n}\n\nexport type CoreOptions = Partial<ResolvedCoreOptions>;\n\n/**\n * the resolved options, all paths are absolute\n */\nexport interface ResolvedCoreOptions {\n cwd: string;\n /**\n * Path to source configuration file\n *\n * @defaultValue content.config.ts\n */\n configPath: string;\n /**\n * Directory for output files\n *\n * @defaultValue '.content'\n */\n outDir: string;\n /**\n * the workspace info if this instance is created as a workspace\n */\n workspace?: {\n parent: Core;\n name: string;\n dir: string;\n };\n plugins?: PluginOption;\n}\n\nexport interface EmitOptions {\n /**\n * filter the collections to run emit\n */\n filterCollection?: (collection: Collection) => boolean;\n\n /**\n * filter the workspaces to run emit\n */\n filterWorkspace?: (workspace: string) => boolean;\n\n /**\n * write files\n */\n write?: boolean;\n}\n\nexport interface EmitOutput {\n entries: EmitEntry[];\n workspaces: Record<string, EmitEntry[]>;\n}\n\nasync function getPlugins(pluginOptions: PluginOption[], dedupe = true): Promise<Plugin[]> {\n const plugins: Plugin[] = [];\n for (const option of await Promise.all(pluginOptions)) {\n if (!option) continue;\n if (Array.isArray(option)) plugins.push(...(await getPlugins(option, false)));\n else plugins.push(option);\n }\n\n if (!dedupe) return plugins;\n\n const excludedName = new Set<string>();\n const deduped: Plugin[] = [];\n for (let i = plugins.length - 1; i >= 0; i--) {\n const plugin = plugins[i];\n if (excludedName.has(plugin.name)) continue;\n deduped.unshift(plugin);\n if (plugin.dedupe) excludedName.add(plugin.name);\n }\n return deduped;\n}\n\nexport class Core {\n private readonly workspaces = new Map<string, Core>();\n private readonly options: ResolvedCoreOptions;\n private plugins: Plugin[] = [];\n private config!: ResolvedConfig;\n static defaultOptions = {\n configPath: \"content.config.ts\",\n outDir: \".content\",\n };\n\n /**\n * Convenient cache store, reset when config changes.\n *\n * You can group namespaces in cache key with \":\", like `my-plugin:data`\n */\n readonly cache = new Map<string, unknown>();\n\n constructor(options: CoreOptions = {}) {\n const cwd = options.cwd ? path.resolve(options.cwd) : process.cwd();\n this.options = {\n ...options,\n cwd,\n outDir: path.resolve(cwd, options.outDir ?? Core.defaultOptions.outDir),\n configPath: path.resolve(cwd, options.configPath ?? Core.defaultOptions.configPath),\n };\n }\n\n async init({\n config: newConfig,\n }: {\n /**\n * either the default export or all exports of config file.\n */\n config: Awaitable<Record<string, unknown>>;\n }) {\n this.config = await this.initConfig(await newConfig);\n this.cache.clear();\n this.workspaces.clear();\n this.plugins = await getPlugins([\n this.options.plugins,\n this.config.plugins,\n ...this.config.collections.values().map((collection) => collection.plugins),\n ]);\n\n const ctx = this.getPluginContext();\n for (const plugin of this.plugins) {\n const out = await plugin.config?.call(ctx, this.config);\n if (out) this.config = out;\n }\n\n await Promise.all(\n this.config.collections.values().map(async (collection) => {\n collection.onConfig.run({ collection, core: this, config: this.config });\n\n for (const plugin of this.plugins) {\n await plugin.collection?.call(ctx, collection);\n }\n }),\n );\n\n // only support workspaces with max depth 1\n if (!this.options.workspace && this.config.workspaces) {\n await Promise.all(\n Object.entries(this.config.workspaces).map(async ([name, workspace]) => {\n const child = new Core({\n ...this.options,\n cwd: path.resolve(this.options.cwd, workspace.dir),\n workspace: {\n name,\n parent: this,\n dir: workspace.dir,\n },\n });\n\n await child.init({ config: workspace.config as Record<string, unknown> });\n this.workspaces.set(name, child);\n }),\n );\n }\n }\n\n getWorkspace() {\n return this.options.workspace;\n }\n getWorkspaces() {\n return this.workspaces;\n }\n getOptions() {\n return this.options;\n }\n getConfig(): ResolvedConfig {\n return this.config;\n }\n /**\n * The file path of compiled config file, the file may not exist (e.g. on Vite, or still compiling)\n */\n getCompiledConfigPath(): string {\n return path.join(this.options.outDir, \"content.config.mjs\");\n }\n getPlugins(workspace = false) {\n if (workspace) {\n const plugins = [...this.plugins];\n for (const workspace of this.workspaces.values()) {\n plugins.push(...workspace.plugins);\n }\n return plugins;\n }\n\n return this.plugins;\n }\n getCollections(workspace = false): Collection[] {\n const list = Array.from(this.config.collections.values());\n if (workspace) {\n for (const workspace of this.workspaces.values()) {\n list.push(...workspace.getCollections());\n }\n }\n return list;\n }\n getCollection(name: string): Collection | undefined {\n return this.config.collections.get(name);\n }\n getPluginContext(): PluginContext {\n return {\n core: this,\n };\n }\n async initServer(server: ServerContext) {\n const ctx = this.getPluginContext();\n\n server.watcher?.add(this.options.configPath);\n for (const plugin of this.plugins) {\n plugin.configureServer?.call(ctx, server);\n }\n for (const collection of this.getCollections()) {\n collection.onServer.run({ collection, core: this, server });\n }\n for (const workspace of this.workspaces.values()) {\n await workspace.initServer(server);\n }\n }\n\n async clearOutputDirectory() {\n await fs.rm(this.options.outDir, { recursive: true, force: true });\n }\n\n async emit(emitOptions: EmitOptions = {}): Promise<EmitOutput> {\n const emitConfig = this.config.emit;\n const { workspace, outDir } = this.options;\n const { filterCollection, filterWorkspace, write = false } = emitOptions;\n const start = performance.now();\n const ctx: EmitContext = {\n core: this,\n async createCodeGenerator(path, content) {\n const codegen = new CodeGenerator({\n ...emitConfig,\n outDir,\n });\n await content({\n codegen,\n });\n return {\n path,\n content: codegen.toString(),\n };\n },\n };\n\n const out: EmitOutput = {\n entries: [],\n workspaces: {},\n };\n\n const entryMap = new Map<string, EmitEntry>();\n const generated: Awaitable<EmitEntry[]>[] = [];\n for (const collection of this.getCollections()) {\n if (filterCollection && !filterCollection(collection)) continue;\n generated.push(collection.onEmit.run([], ctx));\n }\n for (const entries of await Promise.all(generated)) {\n for (const item of entries) {\n entryMap.set(item.path, item);\n }\n }\n out.entries = Array.from(entryMap.values());\n\n if (write) {\n await Promise.all(\n out.entries.map(async (entry) => {\n const file = path.join(outDir, entry.path);\n await fs.mkdir(path.dirname(file), { recursive: true });\n await fs.writeFile(file, entry.content);\n }),\n );\n\n console.log(\n workspace\n ? `[fuma-content: ${workspace.name}] generated files in ${performance.now() - start}ms`\n : `[fuma-content] generated files in ${performance.now() - start}ms`,\n );\n }\n\n for (const [name, workspace] of this.workspaces.entries()) {\n if (filterWorkspace && !filterWorkspace(name)) continue;\n out.workspaces[name] = (await workspace.emit(emitOptions)).entries;\n }\n\n return out;\n }\n\n /**\n * convert absolute path into a runtime path (relative to **runtime** cwd)\n */\n _toRuntimePath(absolutePath: string) {\n return path.relative(process.cwd(), absolutePath);\n }\n\n private async initConfig(config: Record<string, unknown>): Promise<ResolvedConfig> {\n const collections = new Map<string, Collection>();\n let globalConfig: GlobalConfig;\n\n if (\"default\" in config) {\n globalConfig = config.default as GlobalConfig;\n for (const [k, v] of Object.entries(config)) {\n if (v instanceof Collection) {\n globalConfig.collections ??= {};\n globalConfig.collections[k] = v;\n }\n }\n } else {\n globalConfig = config as GlobalConfig;\n }\n\n globalConfig.collections ??= {};\n await Promise.all(\n Object.entries(globalConfig.collections).map(async ([name, collection]) => {\n collection.name = name;\n collections.set(name, collection);\n await collection.onInit.run({ collection, core: this });\n }),\n );\n return {\n ...globalConfig,\n collections,\n };\n }\n}\n"],"mappings":";;;;;;AA4IA,eAAe,WAAW,eAA+B,SAAS,MAAyB;CACzF,MAAMA,UAAoB,EAAE;AAC5B,MAAK,MAAM,UAAU,MAAM,QAAQ,IAAI,cAAc,EAAE;AACrD,MAAI,CAAC,OAAQ;AACb,MAAI,MAAM,QAAQ,OAAO,CAAE,SAAQ,KAAK,GAAI,MAAM,WAAW,QAAQ,MAAM,CAAE;MACxE,SAA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AgB;AACzE,cAAW,OAAO;AAClB,eAAY,IAAI,MAAM,WAAW;AACjC,SAAM,WAAW,OAAO,IAAI;IAAE;IAAY,MAAM;IAAM,CAAC;IACvD,CACH;AACD,SAAO;GACL,GAAG;GACH;GACD"}
@@ -1,159 +0,0 @@
1
- import { r as asyncPipe } from "./collections-CNWuMDAZ.js";
2
- import { n as slash } from "./code-generator-Qhhq7kHh.js";
3
- import { t as loaderHook } from "./loader-B4nQrRwA.js";
4
- import { t as FileSystemCollection } from "./fs-CXzVd2Dp.js";
5
- import path from "node:path";
6
-
7
- //#region src/collections/data.ts
8
- var DataCollection = class extends FileSystemCollection {
9
- schema;
10
- /**
11
- * Transform data
12
- */
13
- onLoad = asyncPipe();
14
- $inferInput = void 0;
15
- $inferOutput = void 0;
16
- constructor({ dir, files, loaders: _loadersConfig = {}, schema }) {
17
- const loadersConfig = { ..._loadersConfig.custom };
18
- if (_loadersConfig.json !== false) loadersConfig.json = jsonLoader();
19
- if (_loadersConfig.yaml !== false) loadersConfig.yaml = yamlLoader();
20
- super({
21
- dir,
22
- files,
23
- supportedFormats: Object.keys(loadersConfig)
24
- });
25
- this.schema = schema;
26
- this.onServer.hook(({ core, server }) => {
27
- if (!server.watcher) return;
28
- server.watcher.on("all", async (event, file) => {
29
- if (event === "change" || !this.hasFile(file)) return;
30
- await core.emit({
31
- filterCollection: (collection) => collection === this,
32
- filterWorkspace: () => false,
33
- write: true
34
- });
35
- });
36
- });
37
- this.onEmit.pipe(this.#onEmitHandler.bind(this));
38
- this.pluginHook(loaderHook).loaders.push(...Object.values(loadersConfig));
39
- }
40
- #onEmitHandler = async (entries, { core, createCodeGenerator }) => {
41
- entries.push(await createCodeGenerator(`${this.name}.ts`, async ({ codegen }) => {
42
- codegen.addNamedImport(["dataStore"], "fuma-content/collections/data/runtime");
43
- codegen.addNamespaceImport("Config", codegen.formatImportPath(core.getOptions().configPath), true);
44
- const base = slash(core._toRuntimePath(this.dir));
45
- let records = "{";
46
- const query = codegen.formatQuery({
47
- collection: this.name,
48
- workspace: core.getWorkspace()?.name
49
- });
50
- for (const file of await this.getFiles()) {
51
- const fullPath = path.join(this.dir, file);
52
- const specifier = `${codegen.formatImportPath(fullPath)}?${query}`;
53
- const name = codegen.generateImportName();
54
- codegen.addNamedImport([`default as ${name}`], specifier);
55
- records += `"${slash(file)}": ${name},`;
56
- }
57
- records += "}";
58
- codegen.push(`export const ${this.name} = dataStore<typeof Config, "${this.name}">("${this.name}", "${base}", ${records});`);
59
- }));
60
- return entries;
61
- };
62
- };
63
- function dataCollection(config) {
64
- return new DataCollection(config);
65
- }
66
- function yamlLoader() {
67
- const test = /\.yaml(\?.+?)?$/;
68
- return {
69
- id: "yaml",
70
- test,
71
- configureNext(nextConfig) {
72
- const loaderPath = "fuma-content/collections/yaml/loader-webpack";
73
- const loaderOptions = this.getLoaderOptions();
74
- return {
75
- ...nextConfig,
76
- turbopack: {
77
- ...nextConfig.turbopack,
78
- rules: {
79
- ...nextConfig.turbopack?.rules,
80
- "*.yaml": {
81
- loaders: [{
82
- loader: loaderPath,
83
- options: loaderOptions
84
- }],
85
- as: "*.js"
86
- }
87
- }
88
- },
89
- webpack(config, options) {
90
- config.module ||= {};
91
- config.module.rules ||= [];
92
- config.module.rules.push({
93
- test,
94
- enforce: "pre",
95
- use: [{
96
- loader: loaderPath,
97
- options: loaderOptions
98
- }]
99
- });
100
- return nextConfig.webpack?.(config, options) ?? config;
101
- }
102
- };
103
- },
104
- async createLoader() {
105
- const { createYamlLoader } = await import("./loader-Cx1Rg_VM.js");
106
- const core = this.core;
107
- return createYamlLoader({ getCore: () => core });
108
- }
109
- };
110
- }
111
- function jsonLoader() {
112
- const test = /\.json(\?.+?)?$/;
113
- return {
114
- id: "json",
115
- test,
116
- configureNext(nextConfig) {
117
- const loaderPath = "fuma-content/collections/json/loader-webpack";
118
- const loaderOptions = this.getLoaderOptions();
119
- return {
120
- ...nextConfig,
121
- turbopack: {
122
- ...nextConfig.turbopack,
123
- rules: {
124
- ...nextConfig.turbopack?.rules,
125
- "*.json": {
126
- loaders: [{
127
- loader: loaderPath,
128
- options: loaderOptions
129
- }],
130
- as: "*.json"
131
- }
132
- }
133
- },
134
- webpack(config, options) {
135
- config.module ||= {};
136
- config.module.rules ||= [];
137
- config.module.rules.push({
138
- test,
139
- enforce: "pre",
140
- use: [{
141
- loader: loaderPath,
142
- options: loaderOptions
143
- }]
144
- });
145
- return nextConfig.webpack?.(config, options) ?? config;
146
- }
147
- };
148
- },
149
- async createLoader(environment) {
150
- const { createJsonLoader } = await import("./loader-Dao_nv3e.js");
151
- const core = this.core;
152
- return createJsonLoader({ getCore: () => core }, environment === "vite" ? "json" : "js");
153
- }
154
- };
155
- }
156
-
157
- //#endregion
158
- export { yamlLoader as i, dataCollection as n, jsonLoader as r, DataCollection as t };
159
- //# sourceMappingURL=data-Cxsx5KPD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-Cxsx5KPD.js","names":["loadersConfig: Record<string, LoaderConfig>","#onEmitHandler"],"sources":["../src/collections/data.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { Configuration } from \"webpack\";\nimport { LoaderConfig, loaderHook } from \"@/plugins/loader\";\nimport type { TurbopackLoaderOptions } from \"next/dist/server/config-shared\";\nimport { asyncPipe } from \"@/utils/pipe\";\nimport { slash } from \"@/utils/code-generator\";\nimport { FileSystemCollection, FileSystemCollectionConfig } from \"./fs\";\nimport path from \"node:path\";\n\nexport interface DataTransformationContext {\n path: string;\n source: string;\n}\n\ninterface LoadersConfig {\n json?: boolean;\n yaml?: boolean;\n custom?: Record<string, LoaderConfig>;\n}\n\nexport interface DataCollectionConfig<Schema extends StandardSchemaV1 | undefined> extends Omit<\n FileSystemCollectionConfig,\n \"supportedFormats\"\n> {\n schema?: Schema;\n /**\n * Configurations for loaders to parse data files.\n *\n * By default, JSON and YAML are enabled.\n * */\n loaders?: LoadersConfig;\n}\n\nexport class DataCollection<\n Schema extends StandardSchemaV1 | undefined = StandardSchemaV1 | undefined,\n> extends FileSystemCollection {\n schema?: Schema;\n /**\n * Transform data\n */\n readonly onLoad = asyncPipe<unknown, DataTransformationContext>();\n $inferInput: Schema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Schema> : unknown =\n undefined as never;\n $inferOutput: Schema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Schema> : unknown =\n undefined as never;\n\n constructor({ dir, files, loaders: _loadersConfig = {}, schema }: DataCollectionConfig<Schema>) {\n const loadersConfig: Record<string, LoaderConfig> = {\n ..._loadersConfig.custom,\n };\n if (_loadersConfig.json !== false) loadersConfig.json = jsonLoader();\n if (_loadersConfig.yaml !== false) loadersConfig.yaml = yamlLoader();\n\n super({ dir, files, supportedFormats: Object.keys(loadersConfig) });\n this.schema = schema;\n this.onServer.hook(({ core, server }) => {\n if (!server.watcher) return;\n\n server.watcher.on(\"all\", async (event, file) => {\n if (event === \"change\" || !this.hasFile(file)) return;\n\n await core.emit({\n filterCollection: (collection) => collection === this,\n filterWorkspace: () => false,\n write: true,\n });\n });\n });\n this.onEmit.pipe(this.#onEmitHandler.bind(this));\n this.pluginHook(loaderHook).loaders.push(...Object.values(loadersConfig));\n }\n\n #onEmitHandler: (typeof this)[\"onEmit\"][\"$inferHandler\"] = async (\n entries,\n { core, createCodeGenerator },\n ) => {\n entries.push(\n await createCodeGenerator(`${this.name}.ts`, async ({ codegen }) => {\n codegen.addNamedImport([\"dataStore\"], \"fuma-content/collections/data/runtime\");\n codegen.addNamespaceImport(\n \"Config\",\n codegen.formatImportPath(core.getOptions().configPath),\n true,\n );\n const base = slash(core._toRuntimePath(this.dir));\n let records = \"{\";\n const query = codegen.formatQuery({\n collection: this.name,\n workspace: core.getWorkspace()?.name,\n });\n\n for (const file of await this.getFiles()) {\n const fullPath = path.join(this.dir, file);\n const specifier = `${codegen.formatImportPath(fullPath)}?${query}`;\n const name = codegen.generateImportName();\n codegen.addNamedImport([`default as ${name}`], specifier);\n records += `\"${slash(file)}\": ${name},`;\n }\n records += \"}\";\n codegen.push(\n `export const ${this.name} = dataStore<typeof Config, \"${this.name}\">(\"${this.name}\", \"${base}\", ${records});`,\n );\n }),\n );\n return entries;\n };\n}\n\nexport function dataCollection<Schema extends StandardSchemaV1 | undefined = undefined>(\n config: DataCollectionConfig<Schema>,\n) {\n return new DataCollection(config);\n}\n\nexport function yamlLoader(): LoaderConfig {\n const test = /\\.yaml(\\?.+?)?$/;\n\n return {\n id: \"yaml\",\n test,\n configureNext(nextConfig) {\n const loaderPath = \"fuma-content/collections/yaml/loader-webpack\";\n const loaderOptions = this.getLoaderOptions();\n\n return {\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n rules: {\n ...nextConfig.turbopack?.rules,\n \"*.yaml\": {\n loaders: [\n {\n loader: loaderPath,\n options: loaderOptions as unknown as TurbopackLoaderOptions,\n },\n ],\n as: \"*.js\",\n },\n },\n },\n webpack(config: Configuration, options) {\n config.module ||= {};\n config.module.rules ||= [];\n config.module.rules.push({\n test,\n enforce: \"pre\",\n use: [\n {\n loader: loaderPath,\n options: loaderOptions,\n },\n ],\n });\n\n return nextConfig.webpack?.(config, options) ?? config;\n },\n };\n },\n async createLoader() {\n const { createYamlLoader } = await import(\"./yaml/loader\");\n const core = this.core;\n return createYamlLoader({\n getCore: () => core,\n });\n },\n };\n}\n\nexport function jsonLoader(): LoaderConfig {\n const test = /\\.json(\\?.+?)?$/;\n\n return {\n id: \"json\",\n test,\n configureNext(nextConfig) {\n const loaderPath = \"fuma-content/collections/json/loader-webpack\";\n const loaderOptions = this.getLoaderOptions();\n\n return {\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n rules: {\n ...nextConfig.turbopack?.rules,\n \"*.json\": {\n loaders: [\n {\n loader: loaderPath,\n options: loaderOptions as unknown as TurbopackLoaderOptions,\n },\n ],\n as: \"*.json\",\n },\n },\n },\n webpack(config: Configuration, options) {\n config.module ||= {};\n config.module.rules ||= [];\n config.module.rules.push({\n test,\n enforce: \"pre\",\n use: [\n {\n loader: loaderPath,\n options: loaderOptions,\n },\n ],\n });\n\n return nextConfig.webpack?.(config, options) ?? config;\n },\n };\n },\n async createLoader(environment) {\n const { createJsonLoader } = await import(\"./json/loader\");\n const core = this.core;\n return createJsonLoader(\n {\n getCore: () => core,\n },\n environment === \"vite\" ? \"json\" : \"js\",\n );\n },\n };\n}\n"],"mappings":";;;;;;;AAiCA,IAAa,iBAAb,cAEU,qBAAqB;CAC7B;;;;CAIA,AAAS,SAAS,WAA+C;CACjE,cACE;CACF,eACE;CAEF,YAAY,EAAE,KAAK,OAAO,SAAS,iBAAiB,EAAE,EAAE,UAAwC;EAC9F,MAAMA,gBAA8C,EAClD,GAAG,eAAe,QACnB;AACD,MAAI,eAAe,SAAS,MAAO,eAAc,OAAO,YAAY;AACpE,MAAI,eAAe,SAAS,MAAO,eAAc,OAAO,YAAY;AAEpE,QAAM;GAAE;GAAK;GAAO,kBAAkB,OAAO,KAAK,cAAc;GAAE,CAAC;AACnE,OAAK,SAAS;AACd,OAAK,SAAS,MAAM,EAAE,MAAM,aAAa;AACvC,OAAI,CAAC,OAAO,QAAS;AAErB,UAAO,QAAQ,GAAG,OAAO,OAAO,OAAO,SAAS;AAC9C,QAAI,UAAU,YAAY,CAAC,KAAK,QAAQ,KAAK,CAAE;AAE/C,UAAM,KAAK,KAAK;KACd,mBAAmB,eAAe,eAAe;KACjD,uBAAuB;KACvB,OAAO;KACR,CAAC;KACF;IACF;AACF,OAAK,OAAO,KAAK,MAAKC,cAAe,KAAK,KAAK,CAAC;AAChD,OAAK,WAAW,WAAW,CAAC,QAAQ,KAAK,GAAG,OAAO,OAAO,cAAc,CAAC;;CAG3E,iBAA2D,OACzD,SACA,EAAE,MAAM,0BACL;AACH,UAAQ,KACN,MAAM,oBAAoB,GAAG,KAAK,KAAK,MAAM,OAAO,EAAE,cAAc;AAClE,WAAQ,eAAe,CAAC,YAAY,EAAE,wCAAwC;AAC9E,WAAQ,mBACN,UACA,Q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,IAAI;;IAEnD;;EAEH,MAAM,eAAe;GACnB,MAAM,EAAE,qBAAqB,MAAM,OAAO;GAC1C,MAAM,OAAO,KAAK;AAClB,UAAO,iBAAiB,EACtB,eAAe,MAChB,CAAC;;EAEL;;AAGH,SAAgB,aAA2B;CACzC,MAAM,OAAO;AAEb,QAAO;EACL,IAAI;EACJ;EACA,cAAc,YAAY;GACxB,MAAM,aAAa;GACnB,MAAM,gBAAgB,KAAK,kBAAkB;AAE7C,UAAO;IACL,GAAG;IACH,WAAW;KACT,GAAG,WAAW;KACd,OAAO;MACL,GAAG,WAAW,WAAW;MACzB,UAAU;OACR,SAAS,CACP;QACE,QAAQ;QACR,SAAS;QACV,CACF;OACD,IAAI;OACL;MACF;KACF;IACD,QAAQ,QAAuB,SAAS;AACtC,YAAO,WAAW,EAAE;AACpB,YAAO,OAAO,UAAU,EAAE;AAC1B,YAAO,OAAO,MAAM,KAAK;MACvB;MACA,SAAS;MACT,KAAK,CACH;OACE,QAAQ;OACR,SAAS;OACV,CACF;MACF,CAAC;AAEF,YAAO,WAAW,UAAU,QAAQ,QAAQ,IAAI;;IAEnD;;EAEH,MAAM,aAAa,aAAa;GAC9B,MAAM,EAAE,qBAAqB,MAAM,OAAO;GAC1C,MAAM,OAAO,KAAK;AAClB,UAAO,iBACL,EACE,eAAe,MAChB,EACD,gBAAgB,SAAS,SAAS,KACnC;;EAEJ"}
@@ -1,33 +0,0 @@
1
- import { t as Core } from "./core-CT06v32N.js";
2
-
3
- //#region src/config/load-from-file.d.ts
4
-
5
- /**
6
- * - `true`: compile the config before loading.
7
- * - `false`: import the config directly (without compiling it).
8
- * - `skip`: assume the config is already compiled.
9
- */
10
- type CompileMode = boolean | "skip";
11
- //#endregion
12
- //#region src/dynamic.d.ts
13
- interface DynamicCore {
14
- getCore(): Core | Promise<Core>;
15
- }
16
- declare function createDynamicCore({
17
- core,
18
- compileMode,
19
- mode
20
- }: {
21
- /**
22
- * core (not initialized)
23
- */
24
- core: Core;
25
- compileMode?: CompileMode;
26
- /**
27
- * In dev mode, the config file is dynamically re-loaded when it's updated.
28
- */
29
- mode: "dev" | "production";
30
- }): DynamicCore;
31
- //#endregion
32
- export { createDynamicCore as n, DynamicCore as t };
33
- //# sourceMappingURL=dynamic-Ck1wYoaL.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dynamic-Ck1wYoaL.d.ts","names":[],"sources":["../src/config/load-from-file.ts","../src/dynamic.ts"],"sourcesContent":[],"mappings":";;;;;;AAQA;;;KAAY,WAAA;;;UCJK,WAAA;EDIL,OAAA,EAAA,ECHC,IDGU,GCHH,ODGG,CCHK,IDGL,CAAA;;iBCAP,iBAAA;;;;;;AAJhB;;EAC4B,IAAA,EAWpB,IAXoB;EAAR,WAAA,CAAA,EAYJ,WAZI;EAAO;AAG3B;;EAEE,IAAA,EAAA,KAAA,GAAA,YAAA;CACA,CAAA,EAWE,WAXF"}
@@ -1,29 +0,0 @@
1
- import fs from "node:fs/promises";
2
-
3
- //#region src/dynamic.ts
4
- function createDynamicCore({ core, compileMode = true, mode }) {
5
- let prev;
6
- async function getConfigHash() {
7
- if (mode === "production") return "static";
8
- return (await fs.stat(core.getOptions().configPath).catch(() => {
9
- throw new Error("Cannot find config file");
10
- })).mtime.getTime().toString();
11
- }
12
- async function init() {
13
- const { loadConfig } = await import("./load-from-file-D-Xm95Fz.js");
14
- await core.init({ config: loadConfig(core, compileMode) });
15
- }
16
- return { async getCore() {
17
- const hash = await getConfigHash();
18
- if (!prev || hash !== prev.hash) prev = {
19
- hash,
20
- init: init()
21
- };
22
- await prev.init;
23
- return core;
24
- } };
25
- }
26
-
27
- //#endregion
28
- export { createDynamicCore as t };
29
- //# sourceMappingURL=dynamic-CtOB4Rkp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dynamic-CtOB4Rkp.js","names":["prev:\n | {\n hash: string;\n init: Promise<void>;\n }\n | undefined"],"sources":["../src/dynamic.ts"],"sourcesContent":["import type { Core } from \"@/core\";\nimport fs from \"node:fs/promises\";\nimport type { CompileMode } from \"./config/load-from-file\";\n\nexport interface DynamicCore {\n getCore(): Core | Promise<Core>;\n}\n\nexport function createDynamicCore({\n core,\n compileMode = true,\n mode,\n}: {\n /**\n * core (not initialized)\n */\n core: Core;\n compileMode?: CompileMode;\n /**\n * In dev mode, the config file is dynamically re-loaded when it's updated.\n */\n mode: \"dev\" | \"production\";\n}): DynamicCore {\n let prev:\n | {\n hash: string;\n init: Promise<void>;\n }\n | undefined;\n\n async function getConfigHash(): Promise<string> {\n if (mode === \"production\") return \"static\";\n\n const stats = await fs.stat(core.getOptions().configPath).catch(() => {\n throw new Error(\"Cannot find config file\");\n });\n\n return stats.mtime.getTime().toString();\n }\n\n async function init() {\n const { loadConfig } = await import(\"./config/load-from-file\");\n await core.init({\n config: loadConfig(core, compileMode),\n });\n }\n\n return {\n async getCore() {\n const hash = await getConfigHash();\n if (!prev || hash !== prev.hash) {\n prev = {\n hash,\n init: init(),\n };\n }\n\n await prev.init;\n return core;\n },\n };\n}\n"],"mappings":";;;AAQA,SAAgB,kBAAkB,EAChC,MACA,cAAc,MACd,QAWc;CACd,IAAIA;CAOJ,eAAe,gBAAiC;AAC9C,MAAI,SAAS,aAAc,QAAO;AAMlC,UAJc,MAAM,GAAG,KAAK,KAAK,YAAY,CAAC,WAAW,CAAC,YAAY;AACpE,SAAM,IAAI,MAAM,0BAA0B;IAC1C,EAEW,MAAM,SAAS,CAAC,UAAU;;CAGzC,eAAe,OAAO;EACpB,MAAM,EAAE,eAAe,MAAM,OAAO;AACpC,QAAM,KAAK,KAAK,EACd,QAAQ,WAAW,MAAM,YAAY,EACtC,CAAC;;AAGJ,QAAO,EACL,MAAM,UAAU;EACd,MAAM,OAAO,MAAM,eAAe;AAClC,MAAI,CAAC,QAAQ,SAAS,KAAK,KACzB,QAAO;GACL;GACA,MAAM,MAAM;GACb;AAGH,QAAM,KAAK;AACX,SAAO;IAEV"}
@@ -1,20 +0,0 @@
1
- import { n as MapCollectionStore } from "./store-D_PPrdRE.js";
2
-
3
- //#region src/collections/runtime/file-store.d.ts
4
- interface FileInfo {
5
- /**
6
- * path relative to content directory
7
- */
8
- path: string;
9
- /**
10
- * the full file path in file system
11
- */
12
- fullPath: string;
13
- }
14
- declare class FileCollectionStore<V> extends MapCollectionStore<string, FileInfo & V> {
15
- constructor(base: string, glob: Record<string, V>);
16
- castData<T>(_cast: (input: FileInfo & V) => FileInfo & T): FileCollectionStore<T>;
17
- }
18
- //#endregion
19
- export { FileInfo as n, FileCollectionStore as t };
20
- //# sourceMappingURL=file-store-Dm1SjuLg.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-store-Dm1SjuLg.d.ts","names":[],"sources":["../src/collections/runtime/file-store.ts"],"sourcesContent":[],"mappings":";;;UAGiB,QAAA;;AAAjB;AAoBA;EAAuE,IAAA,EAAA,MAAA;EAAW;;;EAcrD,QAAA,EAAA,MAAA;;AAAiB,cAdjC,mBAciC,CAAA,CAAA,CAAA,SAdF,kBAcE,CAAA,MAAA,EAdyB,QAczB,GAdoC,CAcpC,CAAA,CAAA;EAAW,WAAA,CAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAbvB,MAauB,CAAA,MAAA,EAbR,CAaQ,CAAA;EAAwB,QAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EAAA,CAAA,KAAA,EAApD,QAAoD,GAAzC,CAAyC,EAAA,GAAnC,QAAmC,GAAxB,CAAwB,CAAA,EAApB,mBAAoB,CAAA,CAAA,CAAA"}
@@ -1,68 +0,0 @@
1
- import { t as Collection } from "./collections-CNWuMDAZ.js";
2
- import { t as createCache } from "./async-cache-U87GzQTb.js";
3
- import path from "node:path";
4
- import picomatch from "picomatch";
5
-
6
- //#region src/collections/fs.ts
7
- var FileSystemCollection = class extends Collection {
8
- matcher;
9
- /**
10
- * content directory (absolute)
11
- */
12
- dir;
13
- filesCache = createCache();
14
- /** the glob patterns to match files in collection, this doesn't take `supportedFormats` into account. */
15
- patterns;
16
- supportedFileFormats;
17
- constructor(config) {
18
- super();
19
- const { files, supportedFormats } = config;
20
- this.dir = config.dir;
21
- this.patterns = files ?? [supportedFormats ? `**/*.{${supportedFormats.join(",")}}` : `**/*`];
22
- this.supportedFileFormats = supportedFormats;
23
- this.onInit.hook(this.#onInitHandler.bind(this));
24
- this.onServer.hook(this.#onServerHandler.bind(this));
25
- }
26
- #onInitHandler = ({ core }) => {
27
- this.dir = path.resolve(core.getOptions().cwd, this.dir);
28
- };
29
- #onServerHandler = ({ server }) => {
30
- if (!server.watcher) return;
31
- server.watcher.add(this.dir);
32
- server.watcher.on("all", (event, file) => {
33
- if (event === "change" || !this.hasFile(file)) return;
34
- this.filesCache.invalidate("");
35
- });
36
- };
37
- isFileSupported(filePath) {
38
- if (!this.supportedFileFormats) return true;
39
- return this.supportedFileFormats.some((format) => filePath.endsWith(`.${format}`));
40
- }
41
- /**
42
- * get all included files, relative to `dir`.
43
- *
44
- * the result is cached.
45
- */
46
- async getFiles() {
47
- return this.filesCache.cached("", async () => {
48
- const { glob } = await import("tinyglobby");
49
- return (await glob(this.patterns, { cwd: this.dir })).filter((v) => this.isFileSupported(v));
50
- });
51
- }
52
- hasFile(filePath) {
53
- if (!this.isFileSupported(filePath)) return false;
54
- const relativePath = path.relative(this.dir, filePath);
55
- if (relativePath.startsWith(`..${path.sep}`)) return false;
56
- return (this.matcher ??= picomatch(this.patterns))(relativePath);
57
- }
58
- invalidateCache() {
59
- this.filesCache.invalidate("");
60
- }
61
- };
62
- function fileSystemCollection(config) {
63
- return new FileSystemCollection(config);
64
- }
65
-
66
- //#endregion
67
- export { fileSystemCollection as n, FileSystemCollection as t };
68
- //# sourceMappingURL=fs-CXzVd2Dp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fs-CXzVd2Dp.js","names":["#onInitHandler","#onServerHandler"],"sources":["../src/collections/fs.ts"],"sourcesContent":["import picomatch from \"picomatch\";\nimport path from \"node:path\";\nimport { Collection } from \".\";\nimport { createCache } from \"@/utils/async-cache\";\n\nexport class FileSystemCollection extends Collection {\n private matcher: picomatch.Matcher | undefined;\n /**\n * content directory (absolute)\n */\n dir: string;\n private readonly filesCache = createCache<string[]>();\n /** the glob patterns to match files in collection, this doesn't take `supportedFormats` into account. */\n private readonly patterns: string[];\n readonly supportedFileFormats: string[] | undefined;\n\n constructor(config: FileSystemCollectionConfig) {\n super();\n const { files, supportedFormats } = config;\n this.dir = config.dir;\n this.patterns = files ?? [supportedFormats ? `**/*.{${supportedFormats.join(\",\")}}` : `**/*`];\n this.supportedFileFormats = supportedFormats;\n this.onInit.hook(this.#onInitHandler.bind(this));\n this.onServer.hook(this.#onServerHandler.bind(this));\n }\n\n #onInitHandler: (typeof this.onInit)[\"$inferHandler\"] = ({ core }) => {\n this.dir = path.resolve(core.getOptions().cwd, this.dir);\n };\n\n #onServerHandler: (typeof this.onServer)[\"$inferHandler\"] = ({ server }) => {\n if (!server.watcher) return;\n server.watcher.add(this.dir);\n server.watcher.on(\"all\", (event, file) => {\n if (event === \"change\" || !this.hasFile(file)) return;\n this.filesCache.invalidate(\"\");\n });\n };\n\n isFileSupported(filePath: string) {\n if (!this.supportedFileFormats) return true;\n return this.supportedFileFormats.some((format) => filePath.endsWith(`.${format}`));\n }\n\n /**\n * get all included files, relative to `dir`.\n *\n * the result is cached.\n */\n async getFiles() {\n return this.filesCache.cached(\"\", async () => {\n const { glob } = await import(\"tinyglobby\");\n\n const out = await glob(this.patterns, { cwd: this.dir });\n return out.filter((v) => this.isFileSupported(v));\n });\n }\n\n hasFile(filePath: string) {\n if (!this.isFileSupported(filePath)) return false;\n\n const relativePath = path.relative(this.dir, filePath);\n if (relativePath.startsWith(`..${path.sep}`)) return false;\n\n return (this.matcher ??= picomatch(this.patterns))(relativePath);\n }\n\n invalidateCache() {\n this.filesCache.invalidate(\"\");\n }\n}\n\nexport interface FileSystemCollectionConfig {\n /**\n * Directory to scan\n */\n dir: string;\n\n /**\n * what files to include/exclude (glob patterns)\n *\n * Include all files if not specified\n */\n files?: string[];\n\n /**\n * Restrict to a list of file extensions to include, e.g. `['js', 'ts']`.\n */\n supportedFormats?: string[];\n}\n\nexport function fileSystemCollection(config: FileSystemCollectionConfig) {\n return new FileSystemCollection(config);\n}\n"],"mappings":";;;;;;AAKA,IAAa,uBAAb,cAA0C,WAAW;CACnD,AAAQ;;;;CAIR;CACA,AAAiB,aAAa,aAAuB;;CAErD,AAAiB;CACjB,AAAS;CAET,YAAY,QAAoC;AAC9C,SAAO;EACP,MAAM,EAAE,OAAO,qBAAqB;AACpC,OAAK,MAAM,OAAO;AAClB,OAAK,WAAW,SAAS,CAAC,mBAAmB,SAAS,iBAAiB,KAAK,IAAI,CAAC,KAAK,OAAO;AAC7F,OAAK,uBAAuB;AAC5B,OAAK,OAAO,KAAK,MAAKA,cAAe,KAAK,KAAK,CAAC;AAChD,OAAK,SAAS,KAAK,MAAKC,gBAAiB,KAAK,KAAK,CAAC;;CAGtD,kBAAyD,EAAE,WAAW;AACpE,OAAK,MAAM,KAAK,QAAQ,KAAK,YAAY,CAAC,KAAK,KAAK,IAAI;;CAG1D,oBAA6D,EAAE,aAAa;AAC1E,MAAI,CAAC,OAAO,QAAS;AACrB,SAAO,QAAQ,IAAI,KAAK,IAAI;AAC5B,SAAO,QAAQ,GAAG,QAAQ,OAAO,SAAS;AACxC,OAAI,UAAU,YAAY,CAAC,KAAK,QAAQ,KAAK,CAAE;AAC/C,QAAK,WAAW,WAAW,GAAG;IAC9B;;CAGJ,gBAAgB,UAAkB;AAChC,MAAI,CAAC,KAAK,qBAAsB,QAAO;AACvC,SAAO,KAAK,qBAAqB,MAAM,WAAW,SAAS,SAAS,IAAI,SAAS,CAAC;;;;;;;CAQpF,MAAM,WAAW;AACf,SAAO,KAAK,WAAW,OAAO,IAAI,YAAY;GAC5C,MAAM,EAAE,SAAS,MAAM,OAAO;AAG9B,WADY,MAAM,KAAK,KAAK,UAAU,EAAE,KAAK,KAAK,KAAK,CAAC,EAC7C,QAAQ,MAAM,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