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
@@ -1,45 +0,0 @@
1
- import { m as Collection } from "./core-CT06v32N.js";
2
-
3
- //#region src/collections/fs.d.ts
4
- declare class FileSystemCollection extends Collection {
5
- #private;
6
- private matcher;
7
- /**
8
- * content directory (absolute)
9
- */
10
- dir: string;
11
- private readonly filesCache;
12
- /** the glob patterns to match files in collection, this doesn't take `supportedFormats` into account. */
13
- private readonly patterns;
14
- readonly supportedFileFormats: string[] | undefined;
15
- constructor(config: FileSystemCollectionConfig);
16
- isFileSupported(filePath: string): boolean;
17
- /**
18
- * get all included files, relative to `dir`.
19
- *
20
- * the result is cached.
21
- */
22
- getFiles(): Promise<string[]>;
23
- hasFile(filePath: string): boolean;
24
- invalidateCache(): void;
25
- }
26
- interface FileSystemCollectionConfig {
27
- /**
28
- * Directory to scan
29
- */
30
- dir: string;
31
- /**
32
- * what files to include/exclude (glob patterns)
33
- *
34
- * Include all files if not specified
35
- */
36
- files?: string[];
37
- /**
38
- * Restrict to a list of file extensions to include, e.g. `['js', 'ts']`.
39
- */
40
- supportedFormats?: string[];
41
- }
42
- declare function fileSystemCollection(config: FileSystemCollectionConfig): FileSystemCollection;
43
- //#endregion
44
- export { FileSystemCollectionConfig as n, fileSystemCollection as r, FileSystemCollection as t };
45
- //# sourceMappingURL=fs-CmwaaFyx.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fs-CmwaaFyx.d.ts","names":[],"sources":["../src/collections/fs.ts"],"sourcesContent":[],"mappings":";;;cAKa,oBAAA,SAA6B,UAAA;;EAA7B,QAAA,OAAA;EAWS;;;EAX8B,GAAA,EAAA,MAAA;EAmEnC,iBAAA,UAAA;EAmBD;;;sBA3EM;;;;;;;cAiCN;;;;UAuBC,0BAAA;;;;;;;;;;;;;;;;iBAmBD,oBAAA,SAA6B,6BAA0B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"fuma-matter-BuBO2w-p.js","names":["output: Output"],"sources":["../src/collections/mdx/fuma-matter.ts"],"sourcesContent":["/**\n * Inspired by https://github.com/jonschlinkert/gray-matter\n */\nimport { load } from \"js-yaml\";\n\ninterface Output {\n /**\n * The matter section, including the delimiter.\n */\n matter: string;\n content: string;\n data: unknown;\n}\n\nconst regex = /^---\\r?\\n(.+?)\\r?\\n---\\r?\\n/s;\n\n/**\n * parse frontmatter, it supports only yaml format\n */\nexport function fumaMatter(input: string): Output {\n const output: Output = { matter: \"\", data: {}, content: input };\n const match = regex.exec(input);\n if (!match) {\n return output;\n }\n\n // get the raw front-matter block\n output.matter = match[0];\n output.content = input.slice(match[0].length);\n\n const loaded = load(match[1]);\n output.data = loaded ?? {};\n\n return output;\n}\n"],"mappings":";;;;;;AAcA,MAAM,QAAQ;;;;AAKd,SAAgB,WAAW,OAAuB;CAChD,MAAMA,SAAiB;EAAE,QAAQ;EAAI,MAAM,EAAE;EAAE,SAAS;EAAO;CAC/D,MAAM,QAAQ,MAAM,KAAK,MAAM;AAC/B,KAAI,CAAC,MACH,QAAO;AAIT,QAAO,SAAS,MAAM;AACtB,QAAO,UAAU,MAAM,MAAM,MAAM,GAAG,OAAO;AAG7C,QAAO,OADQ,KAAK,MAAM,GAAG,IACL,EAAE;AAE1B,QAAO"}
@@ -1,60 +0,0 @@
1
- import { a as asyncHook, n as defineCollectionHook } from "./collections-CNWuMDAZ.js";
2
- import { t as createCache } from "./async-cache-U87GzQTb.js";
3
- import path from "node:path";
4
- import { x } from "tinyexec";
5
-
6
- //#region src/plugins/git.ts
7
- const gitHook = defineCollectionHook(() => ({ onClient: asyncHook() }));
8
- /**
9
- * Add version control integration for Git.
10
- * 1. Injects `creationDate` & `lastModified` properties to page exports.
11
- *
12
- * @remarks If you are using Vercel, please set `VERCEL_DEEP_CLONE` environment variable to `true`. This ensures the client can access the full commit history of Git.
13
- */
14
- function git() {
15
- let client;
16
- return {
17
- name: "git",
18
- config() {
19
- const { cwd } = this.core.getOptions();
20
- client = createGitClient(cwd);
21
- },
22
- async collection(collection) {
23
- await collection.getPluginHook(gitHook)?.onClient.run({ client });
24
- }
25
- };
26
- }
27
- function createGitClient(cwd) {
28
- const cache = createCache();
29
- function mapDate(out) {
30
- if (out.exitCode !== 0) return null;
31
- const date = new Date(out.stdout);
32
- return Number.isNaN(date.getTime()) ? null : date;
33
- }
34
- return { async getFileData({ filePath }) {
35
- return cache.cached(filePath, async () => {
36
- const relativePath = path.relative(cwd, filePath);
37
- const [mod, create] = await Promise.all([x("git", [
38
- "log",
39
- "-1",
40
- "--pretty=%ai",
41
- relativePath
42
- ], { nodeOptions: { cwd } }), x("git", [
43
- "log",
44
- "--diff-filter=A",
45
- "--follow",
46
- "--format=%ai",
47
- "-1",
48
- relativePath
49
- ], { nodeOptions: { cwd } })]);
50
- return {
51
- lastModified: mapDate(mod),
52
- creationDate: mapDate(create)
53
- };
54
- });
55
- } };
56
- }
57
-
58
- //#endregion
59
- export { gitHook as n, git as t };
60
- //# sourceMappingURL=git-DnejL9r_.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git-DnejL9r_.js","names":["client: GitClient"],"sources":["../src/plugins/git.ts"],"sourcesContent":["import path from \"node:path\";\nimport { type Output, x } from \"tinyexec\";\nimport type { Plugin } from \"@/core\";\nimport { createCache } from \"@/utils/async-cache\";\nimport { defineCollectionHook } from \"@/collections\";\nimport { asyncHook, AsyncHook } from \"@/utils/hook\";\n\nexport interface GitFileData {\n /**\n * Last modified date of file, obtained from version control.\n */\n lastModified: Date | null;\n /**\n * Creation date of file, obtained from version control.\n */\n creationDate: Date | null;\n}\n\nexport interface GitHook {\n /**\n * receive the client.\n */\n onClient: AsyncHook<{ client: GitClient }>;\n}\n\nexport const gitHook = defineCollectionHook<GitHook>(() => ({\n onClient: asyncHook(),\n}));\n\n/**\n * Add version control integration for Git.\n * 1. Injects `creationDate` & `lastModified` properties to page exports.\n *\n * @remarks If you are using Vercel, please set `VERCEL_DEEP_CLONE` environment variable to `true`. This ensures the client can access the full commit history of Git.\n */\nexport default function git(): Plugin {\n let client: GitClient;\n\n return {\n name: \"git\",\n config() {\n const { cwd } = this.core.getOptions();\n client = createGitClient(cwd);\n },\n async collection(collection) {\n await collection.getPluginHook(gitHook)?.onClient.run({ client });\n },\n };\n}\n\nexport interface GitClient {\n getFileData: (options: { filePath: string }) => Promise<GitFileData>;\n}\n\nfunction createGitClient(cwd: string): GitClient {\n const cache = createCache<GitFileData>();\n\n function mapDate(out: Output): Date | null {\n if (out.exitCode !== 0) return null;\n const date = new Date(out.stdout);\n return Number.isNaN(date.getTime()) ? null : date;\n }\n\n return {\n async getFileData({ filePath }) {\n return cache.cached(filePath, async () => {\n const relativePath = path.relative(cwd, filePath);\n const [mod, create] = await Promise.all([\n x(\"git\", [\"log\", \"-1\", \"--pretty=%ai\", relativePath], {\n nodeOptions: {\n cwd,\n },\n }),\n x(\"git\", [\"log\", \"--diff-filter=A\", \"--follow\", \"--format=%ai\", \"-1\", relativePath], {\n nodeOptions: {\n cwd,\n },\n }),\n ]);\n\n return {\n lastModified: mapDate(mod),\n creationDate: mapDate(create),\n };\n });\n },\n };\n}\n"],"mappings":";;;;;;AAyBA,MAAa,UAAU,4BAAqC,EAC1D,UAAU,WAAW,EACtB,EAAE;;;;;;;AAQH,SAAwB,MAAc;CACpC,IAAIA;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP,MAAM,EAAE,QAAQ,KAAK,KAAK,YAAY;AACtC,YAAS,gBAAgB,IAAI;;EAE/B,MAAM,WAAW,YAAY;AAC3B,SAAM,WAAW,cAAc,QAAQ,EAAE,SAAS,IAAI,EAAE,QAAQ,CAAC;;EAEpE;;AAOH,SAAS,gBAAgB,KAAwB;CAC/C,MAAM,QAAQ,aAA0B;CAExC,SAAS,QAAQ,KAA0B;AACzC,MAAI,IAAI,aAAa,EAAG,QAAO;EAC/B,MAAM,OAAO,IAAI,KAAK,IAAI,OAAO;AACjC,SAAO,OAAO,MAAM,KAAK,SAAS,CAAC,GAAG,OAAO;;AAG/C,QAAO,EACL,MAAM,YAAY,EAAE,YAAY;AAC9B,SAAO,MAAM,OAAO,UAAU,YAAY;GACxC,MAAM,eAAe,KAAK,SAAS,KAAK,SAAS;GACjD,MAAM,CAAC,KAAK,UAAU,MAAM,QAAQ,IAAI,CACtC,EAAE,OAAO;IAAC;IAAO;IAAM;IAAgB;IAAa,EAAE,EACpD,aAAa,EACX,KACD,EACF,CAAC,EACF,EAAE,OAAO;IAAC;IAAO;IAAmB;IAAY;IAAgB;IAAM;IAAa,EAAE,EACnF,aAAa,EACX,KACD,EACF,CAAC,CACH,CAAC;AAEF,UAAO;IACL,cAAc,QAAQ,IAAI;IAC1B,cAAc,QAAQ,OAAO;IAC9B;IACD;IAEL"}
@@ -1,37 +0,0 @@
1
- import { S as AsyncHook, h as CollectionHook, s as Plugin } from "./core-CT06v32N.js";
2
-
3
- //#region src/plugins/git.d.ts
4
- interface GitFileData {
5
- /**
6
- * Last modified date of file, obtained from version control.
7
- */
8
- lastModified: Date | null;
9
- /**
10
- * Creation date of file, obtained from version control.
11
- */
12
- creationDate: Date | null;
13
- }
14
- interface GitHook {
15
- /**
16
- * receive the client.
17
- */
18
- onClient: AsyncHook<{
19
- client: GitClient;
20
- }>;
21
- }
22
- declare const gitHook: CollectionHook<GitHook, undefined>;
23
- /**
24
- * Add version control integration for Git.
25
- * 1. Injects `creationDate` & `lastModified` properties to page exports.
26
- *
27
- * @remarks If you are using Vercel, please set `VERCEL_DEEP_CLONE` environment variable to `true`. This ensures the client can access the full commit history of Git.
28
- */
29
- declare function git(): Plugin;
30
- interface GitClient {
31
- getFileData: (options: {
32
- filePath: string;
33
- }) => Promise<GitFileData>;
34
- }
35
- //#endregion
36
- export { gitHook as a, git as i, GitFileData as n, GitHook as r, GitClient as t };
37
- //# sourceMappingURL=git-n-9ddn78.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git-n-9ddn78.d.ts","names":[],"sources":["../src/plugins/git.ts"],"sourcesContent":[],"mappings":";;;UAOiB,WAAA;EAAA;AAWjB;AAOA;EAUwB,YAAG,EAxBX,IAwBe,GAAA,IAAM;EAepB;;;gBAnCD;;UAGC,OAAA;;;;YAIL;YAAoB;;;cAGnB,SAAO,eAAA;;;;;;;iBAUI,GAAA,CAAA,GAAO;UAed,SAAA;;;QACiC,QAAQ"}
@@ -1,87 +0,0 @@
1
- import { c as PluginContext, h as CollectionHook, s as Plugin } from "./core-CT06v32N.js";
2
- import { t as DynamicCore } from "./dynamic-Ck1wYoaL.js";
3
- import { NextConfig } from "next";
4
- import { LoaderContext } from "webpack";
5
-
6
- //#region src/plugins/loader/webpack.d.ts
7
- interface WebpackLoaderOptions {
8
- absoluteCompiledConfigPath: string;
9
- configPath: string;
10
- outDir: string;
11
- isDev: boolean;
12
- }
13
- type WebpackLoader = (this: LoaderContext<WebpackLoaderOptions>, source: string) => void;
14
- /**
15
- * Note: need to handle the `test` regex in Webpack config instead.
16
- */
17
- declare function createWebpackLoader(loaderFactory: (core: DynamicCore) => Loader): WebpackLoader;
18
- //#endregion
19
- //#region src/plugins/loader/index.d.ts
20
- type Awaitable<T> = T | Promise<T>;
21
- interface CompilerOptions {
22
- addDependency: (file: string) => void;
23
- }
24
- type LoaderEnvironment = "vite" | "bun" | "node";
25
- interface Loader {
26
- /**
27
- * Transform input into JavaScript.
28
- *
29
- * Returns:
30
- * - `LoaderOutput`: JavaScript code & source map.
31
- * - `null`: skip the loader. Fallback to default behaviour if possible, otherwise the adapter will try workarounds.
32
- */
33
- load: (input: LoaderInput) => Awaitable<LoaderOutput | null>;
34
- bun?: {
35
- /**
36
- * 1. Bun doesn't allow `null` in loaders.
37
- * 2. Bun requires sync result to support dynamic require().
38
- */
39
- load?: (source: string, input: LoaderInput) => Awaitable<Bun.OnLoadResult>;
40
- };
41
- }
42
- interface LoaderInput {
43
- development: boolean;
44
- compiler: CompilerOptions;
45
- filePath: string;
46
- query: Record<string, string | string[] | undefined>;
47
- getSource: () => string | Promise<string>;
48
- }
49
- interface LoaderOutput {
50
- code: string;
51
- map?: unknown;
52
- /**
53
- * only supported on Vite 8 at the moment, specify the output module type.
54
- *
55
- * on unsupported environments, it will be ignored.
56
- */
57
- moduleType?: "js" | "json";
58
- }
59
- interface NextLoaderContext extends PluginContext {
60
- getLoaderOptions: () => WebpackLoaderOptions;
61
- }
62
- interface LoaderConfig {
63
- /** unique ID for loader, used to deduplicate loaders */
64
- id?: string;
65
- /**
66
- * Filter file paths, the input can be either a file URL or file path.
67
- *
68
- * Must take resource query into consideration.
69
- */
70
- test?: RegExp;
71
- /**
72
- * @remarks it doesn't configure automatically for Next.js, you have to define the webpack/turbopack config in `configureNext()`.
73
- */
74
- createLoader: (this: PluginContext, environment: LoaderEnvironment) => Promise<Loader>;
75
- configureNext?: (this: NextLoaderContext, next: NextConfig) => NextConfig;
76
- }
77
- /**
78
- * a light layer for implementing loaders.
79
- */
80
- declare function loaderPlugin(): Plugin;
81
- interface LoaderHook {
82
- loaders: LoaderConfig[];
83
- }
84
- declare const loaderHook: CollectionHook<LoaderHook, undefined>;
85
- //#endregion
86
- export { LoaderInput as a, loaderPlugin as c, createWebpackLoader as d, LoaderHook as i, WebpackLoader as l, Loader as n, LoaderOutput as o, LoaderConfig as r, loaderHook as s, CompilerOptions as t, WebpackLoaderOptions as u };
87
- //# sourceMappingURL=index-BheUVWBm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-BheUVWB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AAA,GAjB/C,oBAiB+C;;AACvB,UAfjC,YAAA,CAeiC;EAAe;EAAU,EAAA,CAAA,EAAA,MAAA;EAY3D;AAqFhB;AAIA;;;SA3GS;;;;uBAKc,4BAA4B,sBAAsB,QAAQ;yBACxD,yBAAyB,eAAe;;;;;iBAYjD,YAAA,CAAA,GAAgB;UAqFf,UAAA;WACN;;cAGE,YAAU,eAAA"}
@@ -1,3 +0,0 @@
1
- import { t as loadConfig } from "./load-from-file-z7EGuf2n.js";
2
-
3
- export { loadConfig };
@@ -1,77 +0,0 @@
1
- import { n as defineCollectionHook } from "./collections-CNWuMDAZ.js";
2
- import { t as createCache } from "./async-cache-U87GzQTb.js";
3
- import path from "node:path";
4
-
5
- //#region src/plugins/loader/index.ts
6
- /**
7
- * a light layer for implementing loaders.
8
- */
9
- function loaderPlugin() {
10
- const cachedLoaders = createCache();
11
- function initLoaders(ctx, env) {
12
- return cachedLoaders.cached(env, async () => {
13
- const usedIds = /* @__PURE__ */ new Set();
14
- const out = [];
15
- for (const collection of ctx.core.getCollections()) {
16
- const hook = collection.getPluginHook(loaderHook);
17
- if (!hook) continue;
18
- let nextId = 0;
19
- for (const loader of hook.loaders) {
20
- if (loader.id && usedIds.has(loader.id)) continue;
21
- if (loader.id) usedIds.add(loader.id);
22
- out.push({
23
- id: loader.id ?? `${collection.name}:${nextId++}`,
24
- test: loader.test,
25
- loader: await loader.createLoader.call(ctx, env)
26
- });
27
- }
28
- }
29
- return out;
30
- });
31
- }
32
- return {
33
- name: "fuma-content:loader",
34
- next: { config(config) {
35
- const ctx = {
36
- ...this,
37
- getLoaderOptions: () => {
38
- const { configPath, outDir } = this.core.getOptions();
39
- return {
40
- configPath,
41
- outDir,
42
- absoluteCompiledConfigPath: path.resolve(this.core.getCompiledConfigPath()),
43
- isDev: process.env.NODE_ENV === "development"
44
- };
45
- }
46
- };
47
- for (const collection of this.core.getCollections()) {
48
- const hook = collection.getPluginHook(loaderHook);
49
- if (!hook) continue;
50
- for (const loader of hook.loaders) {
51
- if (!loader.configureNext) continue;
52
- config = loader.configureNext.call(ctx, config);
53
- }
54
- }
55
- return config;
56
- } },
57
- bun: { async setup(build) {
58
- const { toBun } = await import("./bun-CBROq3I0.js");
59
- for (const loader of await initLoaders(this, "bun")) toBun(loader.test, loader.loader)(build);
60
- } },
61
- node: { async createLoad() {
62
- const { toNode } = await import("./node-2VZOh3P9.js");
63
- return toNode(await initLoaders(this, "node"));
64
- } },
65
- vite: { async createPlugin() {
66
- const { toVite } = await import("./vite-C1qXY47G.js");
67
- return (await initLoaders(this, "vite")).map((loader) => {
68
- return toVite(`fuma-content:${loader.id}`, loader.test, loader.loader);
69
- });
70
- } }
71
- };
72
- }
73
- const loaderHook = defineCollectionHook(() => ({ loaders: [] }));
74
-
75
- //#endregion
76
- export { loaderPlugin as n, loaderHook as t };
77
- //# sourceMappingURL=loader-B4nQrRwA.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loader-B4nQrRwA.js","names":["out: ResolvedLoader[]","ctx: NextLoaderContext"],"sources":["../src/plugins/loader/index.ts"],"sourcesContent":["import { defineCollectionHook } from \"@/collections\";\nimport type { Plugin, PluginContext } from \"@/core\";\nimport { createCache } from \"@/utils/async-cache\";\nimport { NextConfig } from \"next\";\nimport { WebpackLoaderOptions } from \"./webpack.js\";\nimport path from \"node:path\";\n\ntype Awaitable<T> = T | Promise<T>;\n\nexport interface CompilerOptions {\n addDependency: (file: string) => void;\n}\n\ntype LoaderEnvironment = \"vite\" | \"bun\" | \"node\";\n\nexport interface Loader {\n /**\n * Transform input into JavaScript.\n *\n * Returns:\n * - `LoaderOutput`: JavaScript code & source map.\n * - `null`: skip the loader. Fallback to default behaviour if possible, otherwise the adapter will try workarounds.\n */\n load: (input: LoaderInput) => Awaitable<LoaderOutput | null>;\n\n bun?: {\n /**\n * 1. Bun doesn't allow `null` in loaders.\n * 2. Bun requires sync result to support dynamic require().\n */\n load?: (source: string, input: LoaderInput) => Awaitable<Bun.OnLoadResult>;\n };\n}\n\nexport interface LoaderInput {\n development: boolean;\n compiler: CompilerOptions;\n\n filePath: string;\n query: Record<string, string | string[] | undefined>;\n getSource: () => string | Promise<string>;\n}\n\nexport interface LoaderOutput {\n code: string;\n map?: unknown;\n\n /**\n * only supported on Vite 8 at the moment, specify the output module type.\n *\n * on unsupported environments, it will be ignored.\n */\n moduleType?: \"js\" | \"json\";\n}\n\ninterface NextLoaderContext extends PluginContext {\n getLoaderOptions: () => WebpackLoaderOptions;\n}\n\nexport interface LoaderConfig {\n /** unique ID for loader, used to deduplicate loaders */\n id?: string;\n\n /**\n * Filter file paths, the input can be either a file URL or file path.\n *\n * Must take resource query into consideration.\n */\n test?: RegExp;\n\n /**\n * @remarks it doesn't configure automatically for Next.js, you have to define the webpack/turbopack config in `configureNext()`.\n */\n createLoader: (this: PluginContext, environment: LoaderEnvironment) => Promise<Loader>;\n configureNext?: (this: NextLoaderContext, next: NextConfig) => NextConfig;\n}\n\ninterface ResolvedLoader {\n id: string;\n test: RegExp | undefined;\n loader: Loader;\n}\n\n/**\n * a light layer for implementing loaders.\n */\nexport function loaderPlugin(): Plugin {\n // env -> loaders\n const cachedLoaders = createCache<ResolvedLoader[]>();\n\n function initLoaders(ctx: PluginContext, env: LoaderEnvironment) {\n return cachedLoaders.cached(env, async () => {\n const usedIds = new Set<string>();\n const out: ResolvedLoader[] = [];\n\n for (const collection of ctx.core.getCollections()) {\n const hook = collection.getPluginHook(loaderHook);\n if (!hook) continue;\n\n let nextId = 0;\n for (const loader of hook.loaders) {\n if (loader.id && usedIds.has(loader.id)) continue;\n if (loader.id) usedIds.add(loader.id);\n\n out.push({\n id: loader.id ?? `${collection.name}:${nextId++}`,\n test: loader.test,\n loader: await loader.createLoader.call(ctx, env),\n });\n }\n }\n return out;\n });\n }\n\n return {\n name: \"fuma-content:loader\",\n next: {\n config(config) {\n const ctx: NextLoaderContext = {\n ...this,\n getLoaderOptions: () => {\n const { configPath, outDir } = this.core.getOptions();\n return {\n configPath,\n outDir,\n absoluteCompiledConfigPath: path.resolve(this.core.getCompiledConfigPath()),\n isDev: process.env.NODE_ENV === \"development\",\n };\n },\n };\n for (const collection of this.core.getCollections()) {\n const hook = collection.getPluginHook(loaderHook);\n if (!hook) continue;\n\n for (const loader of hook.loaders) {\n if (!loader.configureNext) continue;\n\n config = loader.configureNext.call(ctx, config);\n }\n }\n\n return config;\n },\n },\n bun: {\n async setup(build) {\n const { toBun } = await import(\"./bun\");\n\n for (const loader of await initLoaders(this, \"bun\")) {\n toBun(loader.test, loader.loader)(build);\n }\n },\n },\n node: {\n async createLoad() {\n const { toNode } = await import(\"./node\");\n return toNode(await initLoaders(this, \"node\"));\n },\n },\n vite: {\n async createPlugin() {\n const { toVite } = await import(\"./vite\");\n return (await initLoaders(this, \"vite\")).map((loader) => {\n return toVite(`fuma-content:${loader.id}`, loader.test, loader.loader);\n });\n },\n },\n };\n}\n\nexport interface LoaderHook {\n loaders: LoaderConfig[];\n}\n\nexport const loaderHook = defineCollectionHook<LoaderHook>(() => ({\n loaders: [],\n}));\n"],"mappings":";;;;;;;;AAsFA,SAAgB,eAAuB;CAErC,MAAM,gBAAgB,aAA+B;CAErD,SAAS,YAAY,KAAoB,KAAwB;AAC/D,SAAO,cAAc,OAAO,KAAK,YAAY;GAC3C,MAAM,0BAAU,IAAI,KAAa;GACjC,MAAMA,MAAwB,EAAE;AAEhC,QAAK,MAAM,cAAc,IAAI,KAAK,gBAAgB,EAAE;IAClD,MAAM,OAAO,WAAW,cAAc,WAAW;AACjD,QAAI,CAAC,KAAM;IAEX,IAAI,SAAS;AACb,SAAK,MAAM,UAAU,KAAK,SAAS;AACjC,SAAI,OAAO,MAAM,QAAQ,IAAI,OAAO,GAAG,CAAE;AACzC,SAAI,OAAO,GAAI,SAAQ,IAAI,OAAO,GAAG;AAErC,SAAI,KAAK;MACP,IAAI,OAAO,MAAM,GAAG,WAAW,KAAK,GAAG;MACvC,MAAM,OAAO;MACb,QAAQ,MAAM,OAAO,aAAa,KAAK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"./mdx-Cw1nBJ0D.js";
6
- import "./fuma-matter-BuBO2w-p.js";
7
- import { t as createMdxLoader } from "./loader-CnksfM7I.js";
8
-
9
- export { createMdxLoader };
@@ -1,16 +0,0 @@
1
- import { t as createDataLoader } from "./loader-CuntMmR4.js";
2
-
3
- //#region src/collections/json/loader.ts
4
- function createJsonLoader(core, resolveJson = "js") {
5
- return createDataLoader(core, (filePath, source) => {
6
- try {
7
- return JSON.parse(source);
8
- } catch (e) {
9
- throw new Error(`invalid data in ${filePath}`, { cause: e });
10
- }
11
- }, resolveJson);
12
- }
13
-
14
- //#endregion
15
- export { createJsonLoader as t };
16
- //# sourceMappingURL=loader-BK8PnqRg.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loader-CnksfM7I.js","names":["after: (() => Promise<void>) | undefined"],"sources":["../src/collections/mdx/loader.ts"],"sourcesContent":["import { fumaMatter } from \"@/collections/mdx/fuma-matter\";\nimport type { SourceMap } from \"rollup\";\nimport { z } from \"zod\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport type { Loader } from \"@/plugins/loader\";\nimport type { DynamicCore } from \"@/dynamic\";\nimport { MDXCollection } from \"../mdx\";\n\nconst querySchema = z\n .object({\n only: z.literal([\"frontmatter\", \"all\"]).default(\"all\"),\n collection: z.string().optional(),\n workspace: z.string().optional(),\n })\n .loose();\n\nconst cacheEntry = z.object({\n code: z.string(),\n map: z.any().optional(),\n hash: z.string().optional(),\n});\n\ntype CacheEntry = z.infer<typeof cacheEntry>;\n\nexport function createMdxLoader({ getCore }: DynamicCore): Loader {\n return {\n async load({ getSource, development: isDevelopment, query, compiler, filePath }) {\n let core = await getCore();\n const value = await getSource();\n const matter = fumaMatter(value);\n const { collection: collectionName, workspace, only } = querySchema.parse(query);\n if (workspace) {\n core = core.getWorkspaces().get(workspace) ?? core;\n }\n\n let after: (() => Promise<void>) | undefined;\n\n const { experimentalBuildCache = false } = core.getConfig();\n if (!isDevelopment && experimentalBuildCache) {\n const cacheDir = experimentalBuildCache;\n const cacheKey = `${collectionName ?? \"global\"}_${generateCacheHash(filePath)}`;\n\n const cached = await fs\n .readFile(path.join(cacheDir, cacheKey))\n .then((content) => cacheEntry.parse(JSON.parse(content.toString())))\n .catch(() => null);\n\n if (cached && cached.hash === generateCacheHash(value)) return cached;\n after = async () => {\n await fs.mkdir(cacheDir, { recursive: true });\n await fs.writeFile(\n path.join(cacheDir, cacheKey),\n JSON.stringify({\n ...out,\n hash: generateCacheHash(value),\n } satisfies CacheEntry),\n );\n };\n }\n\n let collection = collectionName ? core.getCollection(collectionName) : undefined;\n if (!(collection instanceof MDXCollection)) collection = undefined;\n\n if (collection?.frontmatter) {\n matter.data = await collection.frontmatter.run(matter.data as Record<string, unknown>, {\n collection,\n filePath,\n source: value,\n });\n }\n\n if (only === \"frontmatter\") {\n return {\n code: `export const frontmatter = ${JSON.stringify(matter.data)}`,\n map: null,\n };\n }\n\n // ensure the line number is correct in dev mode\n const lineOffset = isDevelopment ? countLines(matter.matter) : 0;\n\n const { buildMDX } = await import(\"@/collections/mdx/build-mdx\");\n const compiled = await buildMDX(core, collection, {\n isDevelopment,\n source: \"\\n\".repeat(lineOffset) + matter.content,\n filePath,\n frontmatter: matter.data as Record<string, unknown>,\n _compiler: compiler,\n environment: \"bundler\",\n });\n\n const out = {\n code: String(compiled.value),\n map: compiled.map as SourceMap,\n };\n\n await after?.();\n return out;\n },\n };\n}\n\nfunction generateCacheHash(input: string): string {\n return createHash(\"md5\").update(input).digest(\"hex\");\n}\n\nfunction countLines(s: string) {\n let num = 0;\n\n for (const c of s) {\n if (c === \"\\n\") num++;\n }\n\n return num;\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,cAAc,EACjB,OAAO;CACN,MAAM,EAAE,QAAQ,CAAC,eAAe,MAAM,CAAC,CAAC,QAAQ,MAAM;CACtD,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,WAAW,EAAE,QAAQ,CAAC,UAAU;CAC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O,MAAiC;GACrF;GACA;GACA,QAAQ;GACT,CAAC;AAGJ,MAAI,SAAS,cACX,QAAO;GACL,MAAM,8BAA8B,KAAK,UAAU,OAAO,KAAK;GAC/D,KAAK;GACN;EAIH,MAAM,aAAa,gBAAgB,WAAW,OAAO,OAAO,GAAG;EAE/D,MAAM,EAAE,aAAa,MAAM,OAAO;EAClC,MAAM,WAAW,MAAM,SAAS,MAAM,YAAY;GAChD;GACA,QAAQ,KAAK,OAAO,WAAW,GAAG,OAAO;GACzC;GACA,aAAa,OAAO;GACpB,WAAW;GACX,aAAa;GACd,CAAC;EAEF,MAAM,MAAM;GACV,MAAM,OAAO,SAAS,MAAM;GAC5B,KAAK,SAAS;GACf;AAED,QAAM,SAAS;AACf,SAAO;IAEV;;AAGH,SAAS,kBAAkB,OAAuB;AAChD,QAAO,WAAW,MAAM,CAAC,OAAO,MAAM,CAAC,OAAO,MAAM;;AAGtD,SAAS,WAAW,GAAW;CAC7B,IAAI,MAAM;AAEV,MAAK,MAAM,KAAK,EACd,KAAI,MAAM,KAAM;AAGlB,QAAO"}
@@ -1,17 +0,0 @@
1
- import { t as createDataLoader } from "./loader-CuntMmR4.js";
2
- import { load } from "js-yaml";
3
-
4
- //#region src/collections/yaml/loader.ts
5
- function createYamlLoader(core) {
6
- return createDataLoader(core, (filePath, source) => {
7
- try {
8
- return load(source);
9
- } catch (e) {
10
- throw new Error(`invalid data in ${filePath}`, { cause: e });
11
- }
12
- });
13
- }
14
-
15
- //#endregion
16
- export { createYamlLoader as t };
17
- //# sourceMappingURL=loader-Cnz-VHne.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loader-CuntMmR4.js","names":["data: unknown","context: DataTransformationContext"],"sources":["../src/collections/data/loader.ts"],"sourcesContent":["import type { Loader, LoaderInput } from \"@/plugins/loader\";\nimport { z } from \"zod\";\nimport { validate } from \"@/utils/validation\";\nimport { DataCollection, type DataTransformationContext } from \"@/collections/data\";\nimport type { DynamicCore } from \"@/dynamic\";\n\nconst querySchema = z\n .object({\n collection: z.string().optional(),\n workspace: z.string().optional(),\n })\n .loose();\n\n/**\n * load data files, fallback to bundler's built-in plugins when ?collection is unspecified.\n */\nexport function createDataLoader(\n { getCore }: DynamicCore,\n parse: (filePath: string, source: string) => Record<string, unknown>,\n moduleType: \"json\" | \"js\" = \"js\",\n): Loader {\n function getCollectionProcessor({ filePath, query }: LoaderInput) {\n const parsed = querySchema.safeParse(query);\n if (!parsed.success || !parsed.data.collection) return null;\n const { collection: collectionName, workspace } = parsed.data;\n\n return async (source: string): Promise<unknown> => {\n let core = await getCore();\n if (workspace) {\n core = core.getWorkspaces().get(workspace) ?? core;\n }\n\n let collection = core.getCollection(collectionName);\n let data: unknown = parse(filePath, source);\n if (!collection || !(collection instanceof DataCollection)) return data;\n\n const context: DataTransformationContext = {\n path: filePath,\n source,\n };\n\n if (collection.schema) {\n data = await validate(collection.schema, data, context, `invalid data in ${filePath}`);\n }\n\n return collection.onLoad.run(data, context);\n };\n }\n\n return {\n async load(input) {\n const processor = getCollectionProcessor(input);\n if (processor === null) return null;\n const data = await processor(await input.getSource());\n\n if (moduleType === \"json\") {\n return {\n code: JSON.stringify(data),\n moduleType,\n };\n } else {\n return {\n code: `export default ${JSON.stringify(data)}`,\n };\n }\n },\n bun: {\n load(source, input) {\n const processor = getCollectionProcessor(input);\n if (processor === null)\n return {\n loader: \"object\",\n exports: parse(input.filePath, source),\n };\n\n return processor(source).then((data) => ({\n loader: \"object\",\n exports: { default: data },\n }));\n },\n },\n };\n}\n"],"mappings":";;;;;AAMA,MAAM,cAAc,EACjB,OAAO;CACN,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,WAAW,EAAE,QAAQ,CAAC,UAAU;CACjC,CAAC,CACD,OAAO;;;;AAKV,SAAgB,iBACd,EAAE,WACF,OACA,aAA4B,MACpB;CACR,SAAS,uBAAuB,EAAE,UAAU,SAAsB;EAChE,MAAM,SAAS,YAAY,UAAU,MAAM;AAC3C,MAAI,CAAC,OAAO,WAAW,CAAC,OAAO,KAAK,WAAY,QAAO;EACvD,MAAM,EAAE,YAAY,gBAAgB,cAAc,OAAO;AAEzD,SAAO,OAAO,WAAqC;GACjD,IAAI,OAAO,MAAM,SAAS;AAC1B,OAAI,UACF,QAAO,KAAK,eAAe,CAAC,IAAI,UAAU,IAAI;GAGhD,IAAI,aAAa,KAAK,cAAc,eAAe;GACnD,IAAIA,OAAgB,MAAM,UAAU,OAAO;AAC3C,OAAI,CAAC,cAAc,EAAE,sBAAsB,gBAAiB,QAAO;GAEnE,MAAMC,UAAqC;IACzC,MAAM;IACN;IACD;AAED,OAAI,WAAW,OACb,QAAO,MAAM,SAAS,WAAW,QAAQ,MAAM,SAAS,mBAAmB,WAAW;AAGxF,UAAO,WAAW,OAAO,IAAI,MAAM,QAAQ;;;AAI/C,QAAO;EACL,MAAM,KAAK,OAAO;GAChB,MAAM,YAAY,uBAAuB,MAAM;AAC/C,OAAI,cAAc,KAAM,QAAO;GAC/B,MAAM,OAAO,MAAM,UAAU,MAAM,MAAM,WAAW,CAAC;AAErD,OAAI,eAAe,OACjB,QAAO;IACL,MAAM,KAAK,UAAU,KAAK;IAC1B;IACD;OAED,QAAO,EACL,MAAM,kBAAkB,KAAK,UAAU,KAAK,IAC7C;;EAGL,KAAK,EACH,KAAK,QAAQ,OAAO;GAClB,MAAM,YAAY,uBAAuB,MAAM;AAC/C,OAAI,cAAc,KAChB,QAAO;IACL,QAAQ;IACR,SAAS,MAAM,MAAM,UAAU,OAAO;IACvC;AAEH,UAAO,UAAU,OAAO,CAAC,MAAM,UAAU;IACvC,QAAQ;IACR,SAAS,EAAE,SAAS,MAAM;IAC3B,EAAE;KAEN;EACF"}
@@ -1,8 +0,0 @@
1
- import "./validation-BvVvvLII.js";
2
- import "./loader-B4nQrRwA.js";
3
- import "./fs-CXzVd2Dp.js";
4
- import "./data-Cxsx5KPD.js";
5
- import "./loader-CuntMmR4.js";
6
- import { t as createYamlLoader } from "./loader-Cnz-VHne.js";
7
-
8
- export { createYamlLoader };
@@ -1,8 +0,0 @@
1
- import "./validation-BvVvvLII.js";
2
- import "./loader-B4nQrRwA.js";
3
- import "./fs-CXzVd2Dp.js";
4
- import "./data-Cxsx5KPD.js";
5
- import "./loader-CuntMmR4.js";
6
- import { t as createJsonLoader } from "./loader-BK8PnqRg.js";
7
-
8
- export { createJsonLoader };