fuma-content 1.2.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/dist/async-cache-C47yxLCv.js +0 -2
  2. package/dist/bin.js +0 -2
  3. package/dist/{build-mdx-C8u32vDa.js → build-mdx-DjMJg3TP.js} +1 -3
  4. package/dist/bun/index.d.ts +2 -3
  5. package/dist/bun/index.js +0 -2
  6. package/dist/{bun-NahDFkhR.js → bun-qVjHRKNw.js} +0 -2
  7. package/dist/code-generator-DFGEY6P5.js +0 -2
  8. package/dist/collections/data/runtime.d.ts +3 -4
  9. package/dist/collections/data/runtime.js +0 -2
  10. package/dist/collections/data.d.ts +4 -5
  11. package/dist/collections/data.js +2 -4
  12. package/dist/collections/fs.d.ts +1 -1
  13. package/dist/collections/fs.js +0 -2
  14. package/dist/collections/index.d.ts +1 -1
  15. package/dist/collections/json/loader-webpack.d.ts +2 -3
  16. package/dist/collections/json/loader-webpack.js +1 -5
  17. package/dist/collections/mdx/loader-webpack.d.ts +2 -3
  18. package/dist/collections/mdx/loader-webpack.js +1 -5
  19. package/dist/collections/mdx/react.d.ts +3 -4
  20. package/dist/collections/mdx/react.js +0 -2
  21. package/dist/collections/mdx/runtime-browser.d.ts +2 -2
  22. package/dist/collections/mdx/runtime-browser.js +0 -2
  23. package/dist/collections/mdx/runtime-dynamic.d.ts +5 -6
  24. package/dist/collections/mdx/runtime-dynamic.js +3 -6
  25. package/dist/collections/mdx/runtime.d.ts +1 -1
  26. package/dist/collections/mdx/runtime.js +0 -2
  27. package/dist/collections/mdx/vue.d.ts +7 -8
  28. package/dist/collections/mdx/vue.js +0 -2
  29. package/dist/collections/mdx.d.ts +1 -1
  30. package/dist/collections/mdx.js +1 -3
  31. package/dist/collections/obsidian.d.ts +2 -3
  32. package/dist/collections/obsidian.js +3 -6
  33. package/dist/collections/runtime/file-store.d.ts +1 -1
  34. package/dist/collections/runtime/file-store.js +0 -2
  35. package/dist/collections/runtime/store.d.ts +1 -1
  36. package/dist/collections/runtime/store.js +0 -2
  37. package/dist/collections/yaml/loader-webpack.d.ts +2 -3
  38. package/dist/collections/yaml/loader-webpack.js +1 -5
  39. package/dist/collections-Bl9hpWMS.js +0 -2
  40. package/dist/config/index.d.ts +1 -1
  41. package/dist/config/index.js +0 -2
  42. package/dist/core-CrYszxmc.js +0 -2
  43. package/dist/{core-BbTeLenA.d.ts → core-Dmd3yqUH.d.ts} +1 -2
  44. package/dist/{dynamic-CNEaikCN.d.ts → dynamic-C15fv7uG.d.ts} +2 -3
  45. package/dist/dynamic.d.ts +1 -1
  46. package/dist/dynamic.js +1 -3
  47. package/dist/{file-store-DutRtol_.d.ts → file-store-Bs81Afz5.d.ts} +2 -3
  48. package/dist/{flatten-m0wfHxLH.js → flatten-Db7WzTB7.js} +0 -2
  49. package/dist/{fs-KJjb32Nq.d.ts → fs-DYfoYdl-.d.ts} +2 -3
  50. package/dist/{git-BxnPg5Ao.d.ts → git-C0-Uazuh.d.ts} +2 -3
  51. package/dist/{index-DVqrqxzl.d.ts → index-Dfg2QKTT.d.ts} +3 -4
  52. package/dist/index.d.ts +2 -3
  53. package/dist/is-promise-like-C04ERo2r.js +0 -2
  54. package/dist/{load-from-file-C3CnD8mJ.js → load-from-file-DpW8who8.js} +0 -2
  55. package/dist/{loader-ol04zeoP.js → loader-B19JQedw.js} +0 -2
  56. package/dist/{loader-CyhM9SLt.js → loader-BTPxE-0W.js} +3 -5
  57. package/dist/{loader-e2SkeDfY.js → loader-CORy1xd9.js} +1 -3
  58. package/dist/{loader-D_sKOzDc.js → loader-DJcLC5Gg.js} +1 -3
  59. package/dist/{mdx-L0I8mePE.d.ts → mdx-0plToRQa.d.ts} +3 -4
  60. package/dist/next/index.d.ts +2 -3
  61. package/dist/next/index.js +1 -3
  62. package/dist/node/index.d.ts +1 -2
  63. package/dist/node/index.js +0 -2
  64. package/dist/node/loader.d.ts +2 -3
  65. package/dist/node/loader.js +0 -2
  66. package/dist/{node-Du4i4XDg.js → node--IKK4_8Y.js} +0 -2
  67. package/dist/plugins/git.d.ts +1 -1
  68. package/dist/plugins/git.js +0 -2
  69. package/dist/plugins/json-schema.d.ts +2 -3
  70. package/dist/plugins/json-schema.js +0 -2
  71. package/dist/plugins/loader/index.d.ts +1 -1
  72. package/dist/plugins/loader/index.js +3 -5
  73. package/dist/plugins/loader/webpack.d.ts +1 -1
  74. package/dist/plugins/loader/webpack.js +0 -2
  75. package/dist/plugins/remark/include.d.ts +1 -2
  76. package/dist/plugins/remark/include.js +4 -5
  77. package/dist/{runtime-TETi5Giq.d.ts → runtime-4S3BDs-G.d.ts} +5 -6
  78. package/dist/{runtime-browser-M4sE6SmL.d.ts → runtime-browser-CXjm3FXK.d.ts} +4 -6
  79. package/dist/{store-BC3n1VPY.d.ts → store-j10gHjm1.d.ts} +2 -3
  80. package/dist/utils/frontmatter.d.ts +15 -0
  81. package/dist/{fuma-matter-E30PU53R.js → utils/frontmatter.js} +3 -5
  82. package/dist/validation-Bf_v2L3p.js +0 -2
  83. package/dist/vite/index.d.ts +2 -3
  84. package/dist/vite/index.js +1 -3
  85. package/dist/{vite-DVIOnBqW.js → vite-myuLielb.js} +0 -2
  86. package/package.json +24 -20
  87. package/dist/async-cache-C47yxLCv.js.map +0 -1
  88. package/dist/bin.js.map +0 -1
  89. package/dist/build-mdx-C8u32vDa.js.map +0 -1
  90. package/dist/bun/index.d.ts.map +0 -1
  91. package/dist/bun/index.js.map +0 -1
  92. package/dist/bun-NahDFkhR.js.map +0 -1
  93. package/dist/code-generator-DFGEY6P5.js.map +0 -1
  94. package/dist/collections/data/runtime.d.ts.map +0 -1
  95. package/dist/collections/data/runtime.js.map +0 -1
  96. package/dist/collections/data.d.ts.map +0 -1
  97. package/dist/collections/data.js.map +0 -1
  98. package/dist/collections/fs.js.map +0 -1
  99. package/dist/collections/json/loader-webpack.d.ts.map +0 -1
  100. package/dist/collections/json/loader-webpack.js.map +0 -1
  101. package/dist/collections/mdx/loader-webpack.d.ts.map +0 -1
  102. package/dist/collections/mdx/loader-webpack.js.map +0 -1
  103. package/dist/collections/mdx/react.d.ts.map +0 -1
  104. package/dist/collections/mdx/react.js.map +0 -1
  105. package/dist/collections/mdx/runtime-browser.js.map +0 -1
  106. package/dist/collections/mdx/runtime-dynamic.d.ts.map +0 -1
  107. package/dist/collections/mdx/runtime-dynamic.js.map +0 -1
  108. package/dist/collections/mdx/runtime.js.map +0 -1
  109. package/dist/collections/mdx/vue.d.ts.map +0 -1
  110. package/dist/collections/mdx/vue.js.map +0 -1
  111. package/dist/collections/mdx.js.map +0 -1
  112. package/dist/collections/obsidian.d.ts.map +0 -1
  113. package/dist/collections/obsidian.js.map +0 -1
  114. package/dist/collections/runtime/file-store.js.map +0 -1
  115. package/dist/collections/runtime/store.js.map +0 -1
  116. package/dist/collections/yaml/loader-webpack.d.ts.map +0 -1
  117. package/dist/collections/yaml/loader-webpack.js.map +0 -1
  118. package/dist/collections-Bl9hpWMS.js.map +0 -1
  119. package/dist/config/index.js.map +0 -1
  120. package/dist/core-BbTeLenA.d.ts.map +0 -1
  121. package/dist/core-CrYszxmc.js.map +0 -1
  122. package/dist/dynamic-CNEaikCN.d.ts.map +0 -1
  123. package/dist/dynamic.js.map +0 -1
  124. package/dist/file-store-DutRtol_.d.ts.map +0 -1
  125. package/dist/flatten-m0wfHxLH.js.map +0 -1
  126. package/dist/fs-KJjb32Nq.d.ts.map +0 -1
  127. package/dist/fuma-matter-E30PU53R.js.map +0 -1
  128. package/dist/git-BxnPg5Ao.d.ts.map +0 -1
  129. package/dist/index-DVqrqxzl.d.ts.map +0 -1
  130. package/dist/index.d.ts.map +0 -1
  131. package/dist/is-promise-like-C04ERo2r.js.map +0 -1
  132. package/dist/load-from-file-C3CnD8mJ.js.map +0 -1
  133. package/dist/loader-CyhM9SLt.js.map +0 -1
  134. package/dist/loader-D_sKOzDc.js.map +0 -1
  135. package/dist/loader-e2SkeDfY.js.map +0 -1
  136. package/dist/loader-ol04zeoP.js.map +0 -1
  137. package/dist/mdx-L0I8mePE.d.ts.map +0 -1
  138. package/dist/next/index.d.ts.map +0 -1
  139. package/dist/next/index.js.map +0 -1
  140. package/dist/node/index.d.ts.map +0 -1
  141. package/dist/node/index.js.map +0 -1
  142. package/dist/node/loader.d.ts.map +0 -1
  143. package/dist/node/loader.js.map +0 -1
  144. package/dist/node-Du4i4XDg.js.map +0 -1
  145. package/dist/plugins/git.js.map +0 -1
  146. package/dist/plugins/json-schema.d.ts.map +0 -1
  147. package/dist/plugins/json-schema.js.map +0 -1
  148. package/dist/plugins/loader/index.js.map +0 -1
  149. package/dist/plugins/loader/webpack.js.map +0 -1
  150. package/dist/plugins/remark/include.d.ts.map +0 -1
  151. package/dist/plugins/remark/include.js.map +0 -1
  152. package/dist/runtime-TETi5Giq.d.ts.map +0 -1
  153. package/dist/runtime-browser-M4sE6SmL.d.ts.map +0 -1
  154. package/dist/store-BC3n1VPY.d.ts.map +0 -1
  155. package/dist/validation-Bf_v2L3p.js.map +0 -1
  156. package/dist/vite/index.d.ts.map +0 -1
  157. package/dist/vite/index.js.map +0 -1
  158. package/dist/vite-DVIOnBqW.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
2
2
  import { MDXCollection } from "./collections/mdx.js";
3
- import { t as fumaMatter } from "./fuma-matter-E30PU53R.js";
3
+ import { parseFrontmatter } from "./utils/frontmatter.js";
4
4
  import fs from "node:fs/promises";
5
5
  import path from "node:path";
6
6
  import { z } from "zod";
@@ -21,7 +21,7 @@ function createMdxLoader({ getCore }) {
21
21
  return { async load({ getSource, development: isDevelopment, query, addDependency, filePath }) {
22
22
  let core = await getCore();
23
23
  const value = await getSource();
24
- const matter = fumaMatter(value);
24
+ const matter = parseFrontmatter(value);
25
25
  const { collection: collectionName, workspace, only } = querySchema.parse(query);
26
26
  if (workspace) core = core.getWorkspaces().get(workspace) ?? core;
27
27
  let after;
@@ -51,7 +51,7 @@ function createMdxLoader({ getCore }) {
51
51
  map: null
52
52
  };
53
53
  const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
54
- const { buildMDX } = await import("./build-mdx-C8u32vDa.js").then((n) => n.n);
54
+ const { buildMDX } = await import("./build-mdx-DjMJg3TP.js").then((n) => n.n);
55
55
  const compiled = await buildMDX({
56
56
  core,
57
57
  collection,
@@ -84,5 +84,3 @@ function countLines(s) {
84
84
  }
85
85
  //#endregion
86
86
  export { loader_exports as n, createMdxLoader as t };
87
-
88
- //# sourceMappingURL=loader-CyhM9SLt.js.map
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
2
- import { t as createDataLoader } from "./loader-ol04zeoP.js";
2
+ import { t as createDataLoader } from "./loader-B19JQedw.js";
3
3
  //#region src/collections/json/loader.ts
4
4
  var loader_exports = /* @__PURE__ */ __exportAll({ createJsonLoader: () => createJsonLoader });
5
5
  function createJsonLoader(core, resolveJson = "js") {
@@ -13,5 +13,3 @@ function createJsonLoader(core, resolveJson = "js") {
13
13
  }
14
14
  //#endregion
15
15
  export { loader_exports as n, createJsonLoader as t };
16
-
17
- //# sourceMappingURL=loader-e2SkeDfY.js.map
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
2
- import { t as createDataLoader } from "./loader-ol04zeoP.js";
2
+ import { t as createDataLoader } from "./loader-B19JQedw.js";
3
3
  import { load } from "js-yaml";
4
4
  //#region src/collections/yaml/loader.ts
5
5
  var loader_exports = /* @__PURE__ */ __exportAll({ createYamlLoader: () => createYamlLoader });
@@ -14,5 +14,3 @@ function createYamlLoader(core) {
14
14
  }
15
15
  //#endregion
16
16
  export { loader_exports as n, createYamlLoader as t };
17
-
18
- //# sourceMappingURL=loader-D_sKOzDc.js.map
@@ -1,5 +1,5 @@
1
- import { E as Awaitable, m as Collection, p as CodeGenerator, t as Core, v as AsyncPipe, y as Pipe } from "./core-BbTeLenA.js";
2
- import { n as FileSystemCollectionConfig, t as FileSystemCollection } from "./fs-KJjb32Nq.js";
1
+ import { E as Awaitable, m as Collection, p as CodeGenerator, t as Core, v as AsyncPipe, y as Pipe } from "./core-Dmd3yqUH.js";
2
+ import { n as FileSystemCollectionConfig, t as FileSystemCollection } from "./fs-DYfoYdl-.js";
3
3
  import { VFile } from "vfile";
4
4
  import { ProcessorOptions, createProcessor } from "@mdx-js/mdx";
5
5
  import { StandardSchemaV1 } from "@standard-schema/spec";
@@ -134,5 +134,4 @@ declare class MDXCollection<FrontmatterSchema extends StandardSchemaV1 | undefin
134
134
  }
135
135
  declare function mdxCollection<FrontmatterSchema extends StandardSchemaV1 | undefined = undefined>(config: MDXCollectionConfig<FrontmatterSchema>): MDXCollection<FrontmatterSchema>;
136
136
  //#endregion
137
- export { LinkReference as a, CompiledMDX as i, MDXCollectionConfig as n, mdxCollection as r, MDXCollection as t };
138
- //# sourceMappingURL=mdx-L0I8mePE.d.ts.map
137
+ export { LinkReference as a, CompiledMDX as i, MDXCollectionConfig as n, mdxCollection as r, MDXCollection as t };
@@ -1,4 +1,4 @@
1
- import { n as CoreOptions, t as Core } from "../core-BbTeLenA.js";
1
+ import { n as CoreOptions, t as Core } from "../core-Dmd3yqUH.js";
2
2
  import { NextConfig } from "next";
3
3
 
4
4
  //#region src/next/index.d.ts
@@ -13,5 +13,4 @@ interface NextOptions extends Pick<CoreOptions, "cwd" | "configPath" | "outDir">
13
13
  declare function createContent(options?: NextOptions): Promise<(nextConfig?: NextConfig) => NextConfig>;
14
14
  declare function createStandaloneCore(options: NextOptions): Promise<Core>;
15
15
  //#endregion
16
- export { NextOptions, createContent, createStandaloneCore };
17
- //# sourceMappingURL=index.d.ts.map
16
+ export { NextOptions, createContent, createStandaloneCore };
@@ -1,6 +1,6 @@
1
1
  import { t as Core } from "../core-CrYszxmc.js";
2
2
  import { loaderPlugin } from "../plugins/loader/index.js";
3
- import { t as loadConfig } from "../load-from-file-C3CnD8mJ.js";
3
+ import { t as loadConfig } from "../load-from-file-DpW8who8.js";
4
4
  import path from "node:path";
5
5
  //#region src/next/index.ts
6
6
  async function createContent(options = {}) {
@@ -69,5 +69,3 @@ function createNextCore({ configPath, cwd, outDir }) {
69
69
  }
70
70
  //#endregion
71
71
  export { createContent, createStandaloneCore };
72
-
73
- //# sourceMappingURL=index.js.map
@@ -3,5 +3,4 @@ import { LoaderOptions } from "./loader.js";
3
3
  //#region src/node/index.d.ts
4
4
  declare function register(options?: LoaderOptions): void;
5
5
  //#endregion
6
- export { register };
7
- //# sourceMappingURL=index.d.ts.map
6
+ export { register };
@@ -5,5 +5,3 @@ function register(options = {}) {
5
5
  }
6
6
  //#endregion
7
7
  export { register };
8
-
9
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { n as CoreOptions } from "../core-BbTeLenA.js";
1
+ import { n as CoreOptions } from "../core-Dmd3yqUH.js";
2
2
  import { InitializeHook, LoadHook } from "node:module";
3
3
 
4
4
  //#region src/node/loader.d.ts
@@ -6,5 +6,4 @@ type LoaderOptions = Omit<CoreOptions, "plugins" | "workspace">;
6
6
  declare const initialize: InitializeHook<LoaderOptions>;
7
7
  declare const load: LoadHook;
8
8
  //#endregion
9
- export { LoaderOptions, initialize, load };
10
- //# sourceMappingURL=loader.d.ts.map
9
+ export { LoaderOptions, initialize, load };
@@ -33,5 +33,3 @@ const load = async (url, context, nextLoad) => {
33
33
  };
34
34
  //#endregion
35
35
  export { initialize, load };
36
-
37
- //# sourceMappingURL=loader.js.map
@@ -28,5 +28,3 @@ function toNode(loaders) {
28
28
  }
29
29
  //#endregion
30
30
  export { toNode };
31
-
32
- //# sourceMappingURL=node-Du4i4XDg.js.map
@@ -1,2 +1,2 @@
1
- import { a as gitHook, i as git, n as GitFileData, r as GitHook, t as GitClient } from "../git-BxnPg5Ao.js";
1
+ import { a as gitHook, i as git, n as GitFileData, r as GitHook, t as GitClient } from "../git-C0-Uazuh.js";
2
2
  export { GitClient, GitFileData, GitHook, git as default, gitHook };
@@ -55,5 +55,3 @@ function createGitClient(cwd) {
55
55
  }
56
56
  //#endregion
57
57
  export { git as default, gitHook };
58
-
59
- //# sourceMappingURL=git.js.map
@@ -1,4 +1,4 @@
1
- import { E as Awaitable, h as CollectionHook } from "../core-BbTeLenA.js";
1
+ import { E as Awaitable, h as CollectionHook } from "../core-Dmd3yqUH.js";
2
2
 
3
3
  //#region src/plugins/json-schema.d.ts
4
4
  interface JSONSchemaOptions {
@@ -22,5 +22,4 @@ interface JSONSchemaHook {
22
22
  */
23
23
  declare const jsonSchemaHook: CollectionHook<JSONSchemaHook, JSONSchemaOptions>;
24
24
  //#endregion
25
- export { JSONSchemaHook, JSONSchemaOptions, jsonSchemaHook };
26
- //# sourceMappingURL=json-schema.d.ts.map
25
+ export { JSONSchemaHook, JSONSchemaOptions, jsonSchemaHook };
@@ -47,5 +47,3 @@ const jsonSchemaHook = defineCollectionHook("json-schema", (collection, { insert
47
47
  });
48
48
  //#endregion
49
49
  export { jsonSchemaHook };
50
-
51
- //# sourceMappingURL=json-schema.js.map
@@ -1,2 +1,2 @@
1
- import { a as LoaderOutput, i as LoaderInput, n as LoaderConfig, o as loaderHook, r as LoaderHook, s as loaderPlugin, t as Loader } from "../../index-DVqrqxzl.js";
1
+ import { a as LoaderOutput, i as LoaderInput, n as LoaderConfig, o as loaderHook, r as LoaderHook, s as loaderPlugin, t as Loader } from "../../index-Dfg2QKTT.js";
2
2
  export { Loader, LoaderConfig, LoaderHook, LoaderInput, LoaderOutput, loaderHook, loaderPlugin };
@@ -52,15 +52,15 @@ function loaderPlugin() {
52
52
  return config;
53
53
  } },
54
54
  bun: { async setup(build) {
55
- const { toBun } = await import("../../bun-NahDFkhR.js");
55
+ const { toBun } = await import("../../bun-qVjHRKNw.js");
56
56
  for (const loader of await initLoaders(this, "bun")) toBun(loader.test, loader.loader)(build);
57
57
  } },
58
58
  node: { async createLoad() {
59
- const { toNode } = await import("../../node-Du4i4XDg.js");
59
+ const { toNode } = await import("../../node--IKK4_8Y.js");
60
60
  return toNode(await initLoaders(this, "node"));
61
61
  } },
62
62
  vite: { async createPlugin() {
63
- const { toVite } = await import("../../vite-DVIOnBqW.js");
63
+ const { toVite } = await import("../../vite-myuLielb.js");
64
64
  return (await initLoaders(this, "vite")).map((loader) => {
65
65
  return toVite(`fuma-content:${loader.id}`, loader.test, loader.loader);
66
66
  });
@@ -70,5 +70,3 @@ function loaderPlugin() {
70
70
  const loaderHook = defineCollectionHook("loader", () => ({ loaders: [] }));
71
71
  //#endregion
72
72
  export { loaderHook, loaderPlugin };
73
-
74
- //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import { c as WebpackLoader, l as WebpackLoaderOptions, u as createWebpackLoader } from "../../index-DVqrqxzl.js";
1
+ import { c as WebpackLoader, l as WebpackLoaderOptions, u as createWebpackLoader } from "../../index-Dfg2QKTT.js";
2
2
  export { WebpackLoader, WebpackLoaderOptions, createWebpackLoader };
@@ -57,5 +57,3 @@ function createWebpackLoader(loaderFactory) {
57
57
  }
58
58
  //#endregion
59
59
  export { createWebpackLoader };
60
-
61
- //# sourceMappingURL=webpack.js.map
@@ -19,5 +19,4 @@ declare function remarkInclude(this: Processor, {
19
19
  tagName
20
20
  }?: RemarkIncludeOptions): Transformer<Root, Root>;
21
21
  //#endregion
22
- export { Params, RemarkIncludeOptions, remarkInclude };
23
- //# sourceMappingURL=include.d.ts.map
22
+ export { Params, RemarkIncludeOptions, remarkInclude };
@@ -1,5 +1,5 @@
1
- import { t as fumaMatter } from "../../fuma-matter-E30PU53R.js";
2
- import { t as flattenNode } from "../../flatten-m0wfHxLH.js";
1
+ import { parseFrontmatter } from "../../utils/frontmatter.js";
2
+ import { t as flattenNode } from "../../flatten-Db7WzTB7.js";
3
3
  import * as fs$1 from "node:fs/promises";
4
4
  import * as path$1 from "node:path";
5
5
  import { visit } from "unist-util-visit";
@@ -145,7 +145,7 @@ function remarkInclude({ tagName = "include" } = {}) {
145
145
  data: {}
146
146
  };
147
147
  const processor = await _getProcessor(ext === ".mdx" ? "mdx" : "md");
148
- const parsed = fumaMatter(content);
148
+ const parsed = parseFrontmatter(content);
149
149
  const targetFile = new VFile({
150
150
  path: targetPath,
151
151
  value: parsed.content,
@@ -193,11 +193,10 @@ function remarkInclude({ tagName = "include" } = {}) {
193
193
  };
194
194
  }
195
195
  var Terminated = class {
196
+ value;
196
197
  constructor(value) {
197
198
  this.value = value;
198
199
  }
199
200
  };
200
201
  //#endregion
201
202
  export { remarkInclude };
202
-
203
- //# sourceMappingURL=include.js.map
@@ -1,7 +1,7 @@
1
- import { D as GetCollectionConfig } from "./core-BbTeLenA.js";
2
- import { t as FileCollectionStore } from "./file-store-DutRtol_.js";
3
- import { i as CompiledMDX } from "./mdx-L0I8mePE.js";
4
- import { n as GitFileData } from "./git-BxnPg5Ao.js";
1
+ import { D as GetCollectionConfig } from "./core-Dmd3yqUH.js";
2
+ import { t as FileCollectionStore } from "./file-store-Bs81Afz5.js";
3
+ import { i as CompiledMDX } from "./mdx-0plToRQa.js";
4
+ import { n as GitFileData } from "./git-C0-Uazuh.js";
5
5
 
6
6
  //#region src/collections/mdx/runtime.d.ts
7
7
  interface MDXStoreData<Frontmatter, Attached = unknown> {
@@ -23,5 +23,4 @@ declare function mdxStoreLazy<Config, Name extends string, Attached>(_name: Name
23
23
  }): FileCollectionStore<MDXStoreLazyData<GetFrontmatter<Config, Name>, Attached>>;
24
24
  type WithGit = GitFileData;
25
25
  //#endregion
26
- export { mdxStoreLazy as a, mdxStore as i, MDXStoreLazyData as n, WithGit as r, MDXStoreData as t };
27
- //# sourceMappingURL=runtime-TETi5Giq.d.ts.map
26
+ export { mdxStoreLazy as a, mdxStore as i, MDXStoreLazyData as n, WithGit as r, MDXStoreData as t };
@@ -1,7 +1,6 @@
1
- import { D as GetCollectionConfig, E as Awaitable } from "./core-BbTeLenA.js";
2
- import { n as MapCollectionStore } from "./store-BC3n1VPY.js";
3
- import { i as CompiledMDX } from "./mdx-L0I8mePE.js";
4
-
1
+ import { D as GetCollectionConfig, E as Awaitable } from "./core-Dmd3yqUH.js";
2
+ import { n as MapCollectionStore } from "./store-j10gHjm1.js";
3
+ import { i as CompiledMDX } from "./mdx-0plToRQa.js";
5
4
  //#region src/utils/async-cache.d.ts
6
5
  interface AsyncCache<V> {
7
6
  cached: (key: string, fn: () => Awaitable<V>) => V | PromiseLike<V>;
@@ -27,5 +26,4 @@ type GetFrontmatter<Config, Name extends string> = GetCollectionConfig<Config, N
27
26
  declare const _internal_data: Map<string, StoreData>;
28
27
  declare function mdxStoreBrowser<Config, Name extends string, Attached>(name: Name, _input: Record<string, () => Promise<unknown>>): MapCollectionStore<string, MDXStoreBrowserData<GetFrontmatter<Config, Name>, Attached>>;
29
28
  //#endregion
30
- export { _internal_data as n, mdxStoreBrowser as r, MDXStoreBrowserData as t };
31
- //# sourceMappingURL=runtime-browser-M4sE6SmL.d.ts.map
29
+ export { _internal_data as n, mdxStoreBrowser as r, MDXStoreBrowserData as t };
@@ -1,4 +1,4 @@
1
- import { E as Awaitable } from "./core-BbTeLenA.js";
1
+ import { E as Awaitable } from "./core-Dmd3yqUH.js";
2
2
 
3
3
  //#region src/collections/runtime/store.d.ts
4
4
  interface CollectionStore<Id, Data> {
@@ -26,5 +26,4 @@ declare class MapCollectionStore<Id, Data> implements CollectionStore<Id, Data>
26
26
  get $inferData(): Data;
27
27
  }
28
28
  //#endregion
29
- export { MapCollectionStore as n, CollectionStore as t };
30
- //# sourceMappingURL=store-BC3n1VPY.d.ts.map
29
+ export { MapCollectionStore as n, CollectionStore as t };
@@ -0,0 +1,15 @@
1
+ //#region src/utils/frontmatter.d.ts
2
+ interface Output {
3
+ /**
4
+ * The matter section, including the delimiter.
5
+ */
6
+ matter: string;
7
+ content: string;
8
+ data: unknown;
9
+ }
10
+ /**
11
+ * parse frontmatter, it supports only yaml format
12
+ */
13
+ declare function parseFrontmatter(input: string): Output;
14
+ //#endregion
15
+ export { parseFrontmatter };
@@ -1,5 +1,5 @@
1
1
  import { load } from "js-yaml";
2
- //#region src/collections/mdx/fuma-matter.ts
2
+ //#region src/utils/frontmatter.ts
3
3
  /**
4
4
  * Inspired by https://github.com/jonschlinkert/gray-matter
5
5
  */
@@ -7,7 +7,7 @@ const regex = /^---\r?\n(.+?)\r?\n---\r?\n/s;
7
7
  /**
8
8
  * parse frontmatter, it supports only yaml format
9
9
  */
10
- function fumaMatter(input) {
10
+ function parseFrontmatter(input) {
11
11
  const output = {
12
12
  matter: "",
13
13
  data: {},
@@ -21,6 +21,4 @@ function fumaMatter(input) {
21
21
  return output;
22
22
  }
23
23
  //#endregion
24
- export { fumaMatter as t };
25
-
26
- //# sourceMappingURL=fuma-matter-E30PU53R.js.map
24
+ export { parseFrontmatter };
@@ -33,5 +33,3 @@ function getJSONSchema(schema) {
33
33
  }
34
34
  //#endregion
35
35
  export { getJSONSchema as n, validate as r, ValidationError as t };
36
-
37
- //# sourceMappingURL=validation-Bf_v2L3p.js.map
@@ -1,4 +1,4 @@
1
- import { n as CoreOptions, t as Core } from "../core-BbTeLenA.js";
1
+ import { n as CoreOptions, t as Core } from "../core-Dmd3yqUH.js";
2
2
  import { PluginOption } from "vite";
3
3
 
4
4
  //#region src/vite/index.d.ts
@@ -13,5 +13,4 @@ interface PluginOptions extends Pick<CoreOptions, "configPath" | "cwd" | "outDir
13
13
  declare function content(config: Record<string, unknown>, pluginOpitons?: PluginOptions): Promise<PluginOption[]>;
14
14
  declare function createStandaloneCore(pluginOptions?: PluginOptions): Promise<Core>;
15
15
  //#endregion
16
- export { PluginOptions, createStandaloneCore, content as default };
17
- //# sourceMappingURL=index.d.ts.map
16
+ export { PluginOptions, createStandaloneCore, content as default };
@@ -26,12 +26,10 @@ function createViteCore({ configPath, outDir, cwd }) {
26
26
  });
27
27
  }
28
28
  async function createStandaloneCore(pluginOptions = {}) {
29
- const { loadConfig } = await import("../load-from-file-C3CnD8mJ.js").then((n) => n.n);
29
+ const { loadConfig } = await import("../load-from-file-DpW8who8.js").then((n) => n.n);
30
30
  const core = createViteCore(pluginOptions);
31
31
  await core.init({ config: loadConfig(core, true) });
32
32
  return core;
33
33
  }
34
34
  //#endregion
35
35
  export { createStandaloneCore, content as default };
36
-
37
- //# sourceMappingURL=index.js.map
@@ -28,5 +28,3 @@ function toVite(name, test, loader) {
28
28
  }
29
29
  //#endregion
30
30
  export { toVite };
31
-
32
- //# sourceMappingURL=vite-DVIOnBqW.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fuma-content",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "description": "The content processing layer for your app.",
5
5
  "keywords": [
6
6
  "Content",
@@ -10,7 +10,9 @@
10
10
  "license": "MIT",
11
11
  "author": "Fuma Nama",
12
12
  "repository": "github:fuma-nama/fuma-content",
13
- "bin": "./dist/bin.js",
13
+ "bin": {
14
+ "fuma-content": "./dist/bin.js"
15
+ },
14
16
  "files": [
15
17
  "dist/*"
16
18
  ],
@@ -45,6 +47,7 @@
45
47
  "./plugins/loader": "./dist/plugins/loader/index.js",
46
48
  "./plugins/loader/webpack": "./dist/plugins/loader/webpack.js",
47
49
  "./plugins/remark/include": "./dist/plugins/remark/include.js",
50
+ "./utils/frontmatter": "./dist/utils/frontmatter.js",
48
51
  "./vite": "./dist/vite/index.js",
49
52
  "./package.json": "./package.json"
50
53
  },
@@ -55,47 +58,48 @@
55
58
  "@mdx-js/mdx": "^3.1.1",
56
59
  "@standard-schema/spec": "^1.1.0",
57
60
  "chokidar": "^5.0.0",
58
- "esbuild": "^0.27.4",
61
+ "esbuild": "^0.28.0",
59
62
  "estree-util-value-to-estree": "^3.5.0",
60
63
  "github-slugger": "^2.0.0",
61
64
  "js-yaml": "^4.1.1",
62
65
  "mdast-util-mdx": "^3.0.0",
63
66
  "mdast-util-to-markdown": "^2.1.2",
64
67
  "picocolors": "^1.1.1",
65
- "picomatch": "^4.0.3",
66
- "tinyexec": "^1.0.2",
67
- "tinyglobby": "^0.2.15",
68
+ "picomatch": "^4.0.4",
69
+ "tinyexec": "^1.1.2",
70
+ "tinyglobby": "^0.2.16",
68
71
  "unified": "^11.0.5",
69
72
  "unist-util-remove-position": "^5.0.0",
70
73
  "unist-util-visit": "^5.1.0",
71
74
  "vfile": "^6.0.3",
72
- "zod": "^4.3.6"
75
+ "zod": "^4.4.3"
73
76
  },
74
77
  "devDependencies": {
75
- "@types/bun": "^1.3.10",
78
+ "@types/bun": "^1.3.13",
76
79
  "@types/js-yaml": "^4.0.9",
77
80
  "@types/mdast": "^4.0.4",
78
81
  "@types/mdx": "^2.0.13",
79
- "@types/node": "^25.5.0",
80
- "@types/picomatch": "^4.0.2",
82
+ "@types/node": "^25.6.2",
83
+ "@types/picomatch": "^4.0.3",
81
84
  "@types/react": "^19.2.14",
85
+ "fumadocs-core": "16.8.9",
82
86
  "mdast-util-directive": "^3.1.0",
83
87
  "mdast-util-mdx-jsx": "^3.2.0",
84
88
  "micromark-util-types": "^2.0.2",
85
- "next": "16.1.6",
86
- "react": "^19.2.4",
89
+ "next": "^16.2.6",
90
+ "react": "^19.2.6",
87
91
  "remark": "^15.0.1",
88
92
  "remark-directive": "^4.0.0",
89
93
  "remark-mdx": "^3.1.1",
90
94
  "remark-stringify": "^11.0.0",
91
- "rollup": "^4.59.0",
92
- "tsdown": "^0.21.2",
93
- "typescript": "^5.9.3",
94
- "unplugin-vue": "^7.1.1",
95
- "vite": "^8.0.0",
96
- "vue": "^3.5.30",
97
- "vue-tsc": "^3.2.5",
98
- "webpack": "^5.105.4",
95
+ "rollup": "^4.60.3",
96
+ "tsdown": "^0.22.0",
97
+ "typescript": "^6.0.3",
98
+ "unplugin-vue": "^7.2.0",
99
+ "vite": "^8.0.12",
100
+ "vue": "3.5.34",
101
+ "vue-tsc": "^3.2.8",
102
+ "webpack": "^5.106.2",
99
103
  "typescript-config": "0.0.0"
100
104
  },
101
105
  "peerDependencies": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-cache-C47yxLCv.js","names":[],"sources":["../src/utils/async-cache.ts"],"sourcesContent":["import { Awaitable } from \"@/types\";\nimport { isPromiseLike } from \"./is-promise-like\";\n\nexport interface AsyncCache<V> {\n cached: (key: string, fn: () => Awaitable<V>) => V | PromiseLike<V>;\n $value: <T>() => AsyncCache<T>;\n invalidate: (key: string) => void;\n}\n\n/**\n * cache for async resources, finished promises will be resolved into original value, otherwise wrapped with a promise.\n */\nexport function createCache<V>(store = new Map<string, V | PromiseLike<V>>()): AsyncCache<V> {\n return {\n cached(key, fn) {\n let cached = store.get(key);\n if (cached) return cached;\n\n cached = fn();\n if (isPromiseLike(cached)) {\n cached = cached.then((out) => {\n // replace with resolved if still exists\n if (store.has(key)) {\n store.set(key, out);\n }\n\n return out;\n });\n }\n store.set(key, cached);\n return cached;\n },\n invalidate(key) {\n store.delete(key);\n },\n $value<T>() {\n return this as unknown as AsyncCache<T>;\n },\n };\n}\n"],"mappings":";;;;;AAYA,SAAgB,YAAe,wBAAQ,IAAI,KAAiC,EAAiB;AAC3F,QAAO;EACL,OAAO,KAAK,IAAI;GACd,IAAI,SAAS,MAAM,IAAI,IAAI;AAC3B,OAAI,OAAQ,QAAO;AAEnB,YAAS,IAAI;AACb,OAAI,cAAc,OAAO,CACvB,UAAS,OAAO,MAAM,QAAQ;AAE5B,QAAI,MAAM,IAAI,IAAI,CAChB,OAAM,IAAI,KAAK,IAAI;AAGrB,WAAO;KACP;AAEJ,SAAM,IAAI,KAAK,OAAO;AACtB,UAAO;;EAET,WAAW,KAAK;AACd,SAAM,OAAO,IAAI;;EAEnB,SAAY;AACV,UAAO;;EAEV"}
package/dist/bin.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"bin.js","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { existsSync } from \"node:fs\";\n\nasync function start() {\n const [configPath, outDir] = process.argv.slice(2);\n const isNext =\n existsSync(\"next.config.js\") ||\n existsSync(\"next.config.mjs\") ||\n existsSync(\"next.config.mts\") ||\n existsSync(\"next.config.ts\");\n\n if (isNext) {\n const { createStandaloneCore } = await import(\"./next\");\n const core = await createStandaloneCore({ configPath, outDir });\n await core.emit({ write: true });\n } else {\n const { createStandaloneCore } = await import(\"./vite\");\n const core = await createStandaloneCore({ configPath, outDir });\n await core.emit({ write: true });\n }\n}\n\nvoid start();\n"],"mappings":";;;AAIA,eAAe,QAAQ;CACrB,MAAM,CAAC,YAAY,UAAU,QAAQ,KAAK,MAAM,EAAE;AAOlD,KALE,WAAW,iBAAiB,IAC5B,WAAW,kBAAkB,IAC7B,WAAW,kBAAkB,IAC7B,WAAW,iBAAiB,EAElB;EACV,MAAM,EAAE,yBAAyB,MAAM,OAAO;AAE9C,SADa,MAAM,qBAAqB;GAAE;GAAY;GAAQ,CAAC,EACpD,KAAK,EAAE,OAAO,MAAM,CAAC;QAC3B;EACL,MAAM,EAAE,yBAAyB,MAAM,OAAO;AAE9C,SADa,MAAM,qBAAqB;GAAE;GAAY;GAAQ,CAAC,EACpD,KAAK,EAAE,OAAO,MAAM,CAAC;;;AAI/B,OAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-mdx-C8u32vDa.js","names":[],"sources":["../src/collections/mdx/remark-postprocess.ts","../src/utils/unified/pluggable.ts","../src/collections/mdx/build-mdx.ts"],"sourcesContent":["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 { flattenNode } from \"@/utils/mdast/flatten\";\nimport { mdxToMarkdown } from \"mdast-util-mdx\";\n\nexport interface LinkReference {\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 processedMarkdown?:\n | boolean\n | {\n as?: string;\n /**\n * include heading IDs into the processed markdown.\n */\n headingIds?: boolean;\n };\n\n /**\n * extract link references, export via `_linkReferences`.\n */\n linkReferences?:\n | boolean\n | {\n as?: string;\n };\n\n /**\n * store MDAST and export via `_mdast`.\n */\n mdast?:\n | boolean\n | {\n as?: string;\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 processedMarkdown = false,\n mdast = false,\n linkReferences = false,\n valueToExport = [],\n }: PostprocessOptions,\n): Transformer<Root, Root> {\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 (linkReferences) {\n const { as = \"_linkReferences\" } = linkReferences === true ? {} : linkReferences;\n const urls: LinkReference[] = [];\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: as,\n value: urls,\n });\n }\n\n if (processedMarkdown) {\n const { as = \"_markdown\", headingIds = true } =\n processedMarkdown === true ? {} : processedMarkdown;\n const extensions = this.data(\"toMarkdownExtensions\") ?? [];\n\n const markdown = toMarkdown(tree, {\n ...this.data(\"settings\"),\n extensions: _format === \"md\" ? [...extensions, mdxToMarkdown()] : extensions,\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: as,\n value: markdown,\n });\n }\n\n if (mdast) {\n const { as = \"_mdast\", removePosition: shouldRemovePosition = false } =\n mdast === true ? {} : mdast;\n const stringified = JSON.stringify(\n shouldRemovePosition ? removePosition(structuredClone(tree)) : tree,\n );\n\n file.data[\"mdx-export\"].push({\n name: as,\n value: stringified,\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 { Pluggable, Plugin } from \"unified\";\n\nexport function pluggable<PluginParameters extends unknown[]>(\n plugin: Plugin<PluginParameters, any, any>,\n ...params: PluginParameters\n): Pluggable {\n return [plugin, ...params];\n}\n","import { createProcessor, type ProcessorOptions } from \"@mdx-js/mdx\";\nimport { VFile } from \"vfile\";\nimport { remarkPostprocess } from \"@/collections/mdx/remark-postprocess\";\nimport type { Core } from \"@/core\";\nimport { createCache } from \"@/utils/async-cache\";\nimport type { MDXContent } from \"mdx/types\";\nimport { MDXCollection } from \"../mdx\";\nimport type { PluggableList } from \"unified\";\nimport type { Awaitable } from \"@/types\";\nimport { pluggable } from \"@/utils/unified/pluggable\";\n\ntype MDXProcessor = ReturnType<typeof createProcessor>;\n\ninterface MDXCompilerContext {\n addDependency: (file: string) => void;\n collection: MDXCollection | undefined;\n core: Core;\n}\n\ninterface BuildMDXOptions {\n core: Core;\n collection: MDXCollection | undefined;\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: MDXCompilerContext;\n}\n\nexport interface FumaContentProcessorOptions extends Omit<ProcessorOptions, \"remarkPlugins\"> {\n remarkPlugins?:\n | PluggableList\n | ((plugins: { preprocess: PluggableList; postprocess: PluggableList }) => PluggableList)\n | null\n | undefined;\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 internal compiler info\n */\n _compiler?: MDXCompilerContext;\n\n /**\n * [Fuma Content] get internal processor, do not use this on user land.\n */\n _getProcessor?: (format: \"md\" | \"mdx\") => Awaitable<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,\n collection,\n filePath,\n frontmatter,\n source,\n compiler,\n environment,\n isDevelopment,\n}: BuildMDXOptions): 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 postprocess = [\n pluggable(remarkPostprocess, {\n _format: format,\n ...collection?.postprocess,\n }),\n ];\n\n return createProcessor({\n outputFormat: \"program\",\n development: isDevelopment,\n ...mdxOptions,\n remarkPlugins:\n typeof mdxOptions?.remarkPlugins === \"function\"\n ? mdxOptions.remarkPlugins({\n preprocess: [],\n postprocess,\n })\n : [...(mdxOptions?.remarkPlugins ?? []), ...postprocess],\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: 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":";;;;;;;;;;;;;;;AA0DA,SAAgB,kBAEd,EACE,SACA,oBAAoB,OACpB,QAAQ,OACR,iBAAiB,OACjB,gBAAgB,EAAE,IAEK;AACzB,SAAQ,MAAM,SAAS;EACrB,MAAM,cAAe,KAAK,KAAK,gBAAgB,EAAE;AACjD,MAAI,CAAC,YAAY,MACf,OAAM,MAAM,YAAY,SAAS;AAC/B,OAAI,KAAK,UAAU,GAAG;AACpB,gBAAY,QAAQ,YAAY,KAAK;AACrC,WAAO;;IAET;AAGJ,OAAK,KAAK,kBAAkB,EAAE;AAC9B,OAAK,KAAK,cAAc,KAAK;GAC3B,MAAM;GACN,OAAO;GACR,CAAC;AAEF,MAAI,gBAAgB;GAClB,MAAM,EAAE,KAAK,sBAAsB,mBAAmB,OAAO,EAAE,GAAG;GAClE,MAAM,OAAwB,EAAE;AAEhC,SAAM,MAAM,SAAS,SAAS;AAC5B,SAAK,KAAK,EACR,MAAM,KAAK,KACZ,CAAC;AACF,WAAO;KACP;AAEF,QAAK,KAAK,cAAc,KAAK;IAC3B,MAAM;IACN,OAAO;IACR,CAAC;;AAGJ,MAAI,mBAAmB;GACrB,MAAM,EAAE,KAAK,aAAa,aAAa,SACrC,sBAAsB,OAAO,EAAE,GAAG;GACpC,MAAM,aAAa,KAAK,KAAK,uBAAuB,IAAI,EAAE;GAE1D,MAAM,WAAW,WAAW,MAAM;IAChC,GAAG,KAAK,KAAK,WAAW;IACxB,YAAY,YAAY,OAAO,C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,MACA,YACA,UACA,aACA,QACA,UACA,aACA,iBACkC;CAClC,MAAM,iBAAiB,YAAY,KAAK,MAAM,CAAC,QAAsB;CAErE,SAAS,aAAa,QAAsB;EAC1C,MAAM,MAAM,aAAa,YAAY,QAAQ,SAAS,GAAG;AAEzD,SAAO,eAAe,OAAO,KAAK,YAAY;GAC5C,MAAM,aAAa,MAAM,YAAY,gBAAgB,YAAY;GACjE,MAAM,cAAc,CAClB,UAAU,mBAAmB;IAC3B,SAAS;IACT,GAAG,YAAY;IAChB,CAAC,CACH;AAED,UAAO,gBAAgB;IACrB,cAAc;IACd,aAAa;IACb,GAAG;IACH,eACE,OAAO,YAAY,kBAAkB,aACjC,WAAW,cAAc;KACvB,YAAY,EAAE;KACd;KACD,CAAC,GACF,CAAC,GAAI,YAAY,iBAAiB,EAAE,EAAG,GAAG,YAAY;IAC5D;IACD,CAAC;IACF;;CAGJ,IAAI,QAAQ,IAAI,MAAM;EACpB,OAAO;EACP,MAAM;EACN,KAAK,KAAK,YAAY,CAAC;EACvB,MAAM;GACJ;GACA,WAAW;GACX,eAAe;GAChB;EACF,CAAC;AAEF,KAAI,cAAc,WAChB,SAAQ,MAAM,WAAW,MAAM,IAAI,OAAO;EACxC;EACA;EACA;EACD,CAAC;AAGJ,SAAQ,MAAM,aAAa,SAAS,SAAS,OAAO,GAAG,QAAQ,KAAK,EAAE,QAAQ,MAAM"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/bun/index.ts"],"mappings":";;;;KAKY,UAAA,GAAa,IAAA,CAAK,WAAA;AAAA,iBAER,aAAA,CAAc,OAAA,GAAS,UAAA,GAAkB,OAAA,CAAQ,OAAA;AAAA,cAa1D,OAAA,SAAgB,IAAA;EAC3B,eAAA,CAAA,GAAmB,SAAA;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/bun/index.ts"],"sourcesContent":["import type { BunPlugin } from \"bun\";\nimport { pathToFileURL } from \"node:url\";\nimport { type CoreOptions, Core } from \"@/core\";\nimport { loaderPlugin } from \"@/plugins/loader\";\n\nexport type BunOptions = Omit<CoreOptions, \"plugins\" | \"workspace\">;\n\nexport async function createContent(options: BunOptions = {}): Promise<BunCore> {\n const core = new BunCore({\n ...options,\n plugins: [loaderPlugin()],\n });\n const importPath = pathToFileURL(core.getOptions().configPath).href;\n\n await core.init({\n config: await import(importPath),\n });\n return core;\n}\n\nexport class BunCore extends Core {\n createBunPlugin(): BunPlugin {\n return {\n name: \"fuma-content\",\n setup: async (build) => {\n const ctx = this.getPluginContext();\n\n for (const plugin of this.getPlugins(true)) {\n const setup = plugin.bun?.setup;\n if (setup) await setup.call(ctx, build);\n }\n },\n };\n }\n}\n"],"mappings":";;;;AAOA,eAAsB,cAAc,UAAsB,EAAE,EAAoB;CAC9E,MAAM,OAAO,IAAI,QAAQ;EACvB,GAAG;EACH,SAAS,CAAC,cAAc,CAAC;EAC1B,CAAC;CACF,MAAM,aAAa,cAAc,KAAK,YAAY,CAAC,WAAW,CAAC;AAE/D,OAAM,KAAK,KAAK,EACd,QAAQ,MAAM,OAAO,aACtB,CAAC;AACF,QAAO;;AAGT,IAAa,UAAb,cAA6B,KAAK;CAChC,kBAA6B;AAC3B,SAAO;GACL,MAAM;GACN,OAAO,OAAO,UAAU;IACtB,MAAM,MAAM,KAAK,kBAAkB;AAEnC,SAAK,MAAM,UAAU,KAAK,WAAW,KAAK,EAAE;KAC1C,MAAM,QAAQ,OAAO,KAAK;AAC1B,SAAI,MAAO,OAAM,MAAM,KAAK,KAAK,MAAM;;;GAG5C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"bun-NahDFkhR.js","names":[],"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\";\nimport { isPromiseLike } from \"@/utils/is-promise-like\";\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 addDependency() {},\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 (isPromiseLike(result)) {\n return result.then(toResult);\n }\n return toResult(result);\n });\n };\n}\n"],"mappings":";;;;AAKA,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,MAAM,QAAqB;IACzB,MAAM,YAAY;AAChB,YAAO,IAAI,KAAK,SAAS,CAAC,MAAM;;IAElC,OAAO,MAAM,MAAM;IACnB;IACA,aAAa;IACb,gBAAgB;IACjB;AAED,OAAI,OAAO,KAAK,KACd,QAAO,OAAO,IAAI,KAAK,aAAa,SAAS,CAAC,UAAU,EAAE,MAAM;GAGlE,MAAM,SAAS,OAAO,KAAK,MAAM;AACjC,OAAI,cAAc,OAAO,CACvB,QAAO,OAAO,KAAK,SAAS;AAE9B,UAAO,SAAS,OAAO;IACvB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"code-generator-DFGEY6P5.js","names":["#lines","#importInfos","#eagerImportId"],"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 readonly #lines: string[] = [];\n // specifier -> imported members/info\n readonly #importInfos = new Map<string, ImportInfo>();\n #eagerImportId = 0;\n\n readonly options: CodeGeneratorOptions;\n constructor({ jsExtension = false, outDir = \"\" }: Partial<CodeGeneratorOptions>) {\n this.options = {\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\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((v) => \" \".repeat(tab) + v)\n .join(\"\\n\");\n}\n"],"mappings":";;;;;;AAuBA,IAAa,gBAAb,MAA2B;CACzB,SAA4B,EAAE;CAE9B,+BAAwB,IAAI,KAAyB;CACrD,iBAAiB;CAEjB;CACA,YAAY,EAAE,cAAc,OAAO,SAAS,MAAqC;AAC/E,OAAK,UAAU;GACb;GACA;GACD;;CAGH,mBAAmB,WAAmB,WAAmB,WAAW,OAAO;EACzE,MAAM,OAAO,MAAA,YAAkB,IAAI,UA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;EAAA,IAC9C,mBAAA,CAAoB,MAAA,EAAQ,IAAA;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime.js","names":[],"sources":["../../../src/collections/data/runtime.ts"],"sourcesContent":["import type { GetCollectionConfig } from \"@/types\";\nimport { FileCollectionStore } from \"@/collections/runtime/file-store\";\n\nexport function dataStore<Config, Name extends string>(\n _name: Name,\n base: string,\n input: Record<string, unknown>,\n): FileCollectionStore<{\n data: GetCollectionConfig<Config, Name> extends { $inferOutput: unknown }\n ? GetCollectionConfig<Config, Name>[\"$inferOutput\"]\n : never;\n}> {\n type Data =\n GetCollectionConfig<Config, Name> extends { $inferOutput: unknown }\n ? GetCollectionConfig<Config, Name>[\"$inferOutput\"]\n : never;\n const merged: Record<\n string,\n {\n data: Data;\n }\n > = {};\n\n for (const [key, value] of Object.entries(input)) {\n merged[key] = {\n data: value as Data,\n };\n }\n\n return new FileCollectionStore(base, merged);\n}\n"],"mappings":";;AAGA,SAAgB,UACd,OACA,MACA,OAKC;CAKD,MAAM,SAKF,EAAE;AAEN,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,QAAO,OAAO,EACZ,MAAM,OACP;AAGH,QAAO,IAAI,oBAAoB,MAAM,OAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"data.d.ts","names":[],"sources":["../../src/collections/data.ts"],"mappings":";;;;;;UASiB,yBAAA;EACf,IAAA;EACA,MAAA;AAAA;AAAA,UAGQ,aAAA;EACR,IAAA;EACA,IAAA;EACA,MAAA,GAAS,MAAA,SAAe,YAAA;AAAA;AAAA,UAGT,oBAAA,gBAAoC,gBAAA,sBAAsC,IAAA,CACzF,0BAAA;EAGA,MAAA,GAAS,MAAA;;;;;;EAMT,OAAA,GAAU,aAAA;AAAA;AAAA,cAGC,cAAA,gBACI,gBAAA,eAA+B,gBAAA,sBACtC,oBAAA;EAAA;EACR,MAAA,GAAS,MAAA;EAhB0B;;;EAAA,SAoB1B,MAAA,EAAM,SAAA,UAAA,yBAAA;EACf,WAAA,EAAa,MAAA,SAAe,gBAAA,GAAmB,gBAAA,CAAiB,UAAA,CAAW,MAAA;EAE3E,YAAA,EAAc,MAAA,SAAe,gBAAA,GAAmB,gBAAA,CAAiB,WAAA,CAAY,MAAA;;IAG/D,GAAA;IAAK,KAAA;IAAO,OAAA,EAAS,cAAA;IAAqB;EAAA,GAAU,oBAAA,CAAqB,MAAA;AAAA;AAAA,iBA8DzE,cAAA,gBAA8B,gBAAA,yBAAA,CAC5C,MAAA,EAAQ,oBAAA,CAAqB,MAAA,IAAO,cAAA,CAAA,MAAA;AAAA,iBAKtB,UAAA,CAAA,GAAc,YAAA;AAAA,iBAuDd,UAAA,CAAA,GAAc,YAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"data.js","names":["#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,SAAkB,WAA+C;CACjE,cACE,KAAA;CACF,eACE,KAAA;CAEF,YAAY,EAAE,KAAK,OAAO,SAAS,iBAAiB,EAAE,EAAE,UAAwC;EAC9F,MAAM,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,MAAA,cAAoB,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,QAAQ,iBAAiB,KAAK,YAAY,CAAC,WAAW,EACtD,KACD;GACD,MAAM,OAAO,MAAM,KAAK,eAAe,KAAK,IAAI,CAAC;GACj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