fuma-content 1.2.3 → 1.4.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 (165) hide show
  1. package/dist/async-cache-C47yxLCv.js +0 -2
  2. package/dist/async-cache-svlxyp4V.d.ts +10 -0
  3. package/dist/bin.js +0 -2
  4. package/dist/{build-mdx-C8u32vDa.js → build-mdx-DRJ7dZuq.js} +1 -3
  5. package/dist/bun/index.d.ts +1 -2
  6. package/dist/bun/index.js +1 -3
  7. package/dist/bun-NahDFkhR.js +0 -2
  8. package/dist/code-generator-DFGEY6P5.js +0 -2
  9. package/dist/collections/comark/loader-webpack.d.ts +6 -0
  10. package/dist/collections/comark/loader-webpack.js +6 -0
  11. package/dist/collections/comark/runtime-browser.d.ts +24 -0
  12. package/dist/collections/comark/runtime-browser.js +27 -0
  13. package/dist/collections/comark/runtime.d.ts +27 -0
  14. package/dist/collections/comark/runtime.js +23 -0
  15. package/dist/collections/comark.d.ts +40 -0
  16. package/dist/collections/comark.js +202 -0
  17. package/dist/collections/data/runtime.d.ts +2 -3
  18. package/dist/collections/data/runtime.js +0 -2
  19. package/dist/collections/data.d.ts +3 -4
  20. package/dist/collections/data.js +0 -2
  21. package/dist/collections/fs.d.ts +1 -1
  22. package/dist/collections/fs.js +0 -2
  23. package/dist/collections/json/loader-webpack.d.ts +2 -3
  24. package/dist/collections/json/loader-webpack.js +0 -4
  25. package/dist/collections/mdx/loader-webpack.d.ts +2 -3
  26. package/dist/collections/mdx/loader-webpack.js +1 -5
  27. package/dist/collections/mdx/react.d.ts +3 -4
  28. package/dist/collections/mdx/react.js +0 -2
  29. package/dist/collections/mdx/runtime-browser.d.ts +2 -2
  30. package/dist/collections/mdx/runtime-browser.js +0 -2
  31. package/dist/collections/mdx/runtime-dynamic.d.ts +4 -5
  32. package/dist/collections/mdx/runtime-dynamic.js +4 -7
  33. package/dist/collections/mdx/runtime.d.ts +1 -1
  34. package/dist/collections/mdx/runtime.js +0 -2
  35. package/dist/collections/mdx/vue.d.ts +7 -8
  36. package/dist/collections/mdx/vue.js +0 -2
  37. package/dist/collections/mdx.d.ts +1 -1
  38. package/dist/collections/mdx.js +1 -3
  39. package/dist/collections/obsidian.d.ts +2 -3
  40. package/dist/collections/obsidian.js +3 -6
  41. package/dist/collections/runtime/file-store.d.ts +1 -1
  42. package/dist/collections/runtime/file-store.js +0 -2
  43. package/dist/collections/runtime/store.js +0 -2
  44. package/dist/collections/yaml/loader-webpack.d.ts +2 -3
  45. package/dist/collections/yaml/loader-webpack.js +0 -4
  46. package/dist/collections-Bl9hpWMS.js +0 -2
  47. package/dist/config/index.js +0 -2
  48. package/dist/core-BbTeLenA.d.ts +1 -2
  49. package/dist/{core-CrYszxmc.js → core-Cgc-cdSx.js} +11 -12
  50. package/dist/{dynamic-CNEaikCN.d.ts → dynamic-CO84t8d3.d.ts} +1 -2
  51. package/dist/dynamic.d.ts +1 -1
  52. package/dist/dynamic.js +1 -3
  53. package/dist/{file-store-DutRtol_.d.ts → file-store-D5nKTMSL.d.ts} +1 -2
  54. package/dist/{flatten-m0wfHxLH.js → flatten-Db7WzTB7.js} +0 -2
  55. package/dist/{fs-KJjb32Nq.d.ts → fs-_EGvbkVM.d.ts} +1 -2
  56. package/dist/git-BxnPg5Ao.d.ts +1 -2
  57. package/dist/index.d.ts +1 -2
  58. package/dist/index.js +1 -1
  59. package/dist/is-promise-like-C04ERo2r.js +0 -2
  60. package/dist/{load-from-file-C3CnD8mJ.js → load-from-file-DpW8who8.js} +0 -2
  61. package/dist/{loader-CyhM9SLt.js → loader-9KbB2Twu.js} +8 -7
  62. package/dist/loader-D_sKOzDc.js +0 -2
  63. package/dist/loader-DjDk5eLt.js +51 -0
  64. package/dist/loader-e2SkeDfY.js +0 -2
  65. package/dist/loader-ol04zeoP.js +0 -2
  66. package/dist/{mdx-L0I8mePE.d.ts → mdx-CkXj06oG.d.ts} +2 -3
  67. package/dist/next/index.d.ts +1 -2
  68. package/dist/next/index.js +2 -4
  69. package/dist/node/index.d.ts +1 -2
  70. package/dist/node/index.js +0 -2
  71. package/dist/node/loader.d.ts +1 -2
  72. package/dist/node/loader.js +1 -3
  73. package/dist/{node-Du4i4XDg.js → node-XtGkkaiN.js} +4 -6
  74. package/dist/plugins/git.js +0 -2
  75. package/dist/plugins/json-schema.d.ts +1 -2
  76. package/dist/plugins/json-schema.js +0 -2
  77. package/dist/plugins/loader/index.d.ts +1 -1
  78. package/dist/plugins/loader/index.js +1 -3
  79. package/dist/plugins/loader/webpack.d.ts +1 -1
  80. package/dist/plugins/loader/webpack.js +1 -3
  81. package/dist/plugins/remark/include.d.ts +1 -2
  82. package/dist/plugins/remark/include.js +4 -5
  83. package/dist/{runtime-TETi5Giq.d.ts → runtime-5EdZjL1e.d.ts} +3 -4
  84. package/dist/{runtime-browser-M4sE6SmL.d.ts → runtime-browser-BI2h1vjc.d.ts} +3 -11
  85. package/dist/store-BC3n1VPY.d.ts +1 -2
  86. package/dist/utils/frontmatter.d.ts +15 -0
  87. package/dist/{fuma-matter-E30PU53R.js → utils/frontmatter.js} +3 -5
  88. package/dist/validation-Bf_v2L3p.js +0 -2
  89. package/dist/vite/index.d.ts +1 -2
  90. package/dist/vite/index.js +2 -4
  91. package/dist/vite-DVIOnBqW.js +0 -2
  92. package/dist/{index-DVqrqxzl.d.ts → webpack-C8ABoMB_.d.ts} +15 -16
  93. package/package.json +29 -20
  94. package/dist/async-cache-C47yxLCv.js.map +0 -1
  95. package/dist/bin.js.map +0 -1
  96. package/dist/build-mdx-C8u32vDa.js.map +0 -1
  97. package/dist/bun/index.d.ts.map +0 -1
  98. package/dist/bun/index.js.map +0 -1
  99. package/dist/bun-NahDFkhR.js.map +0 -1
  100. package/dist/code-generator-DFGEY6P5.js.map +0 -1
  101. package/dist/collections/data/runtime.d.ts.map +0 -1
  102. package/dist/collections/data/runtime.js.map +0 -1
  103. package/dist/collections/data.d.ts.map +0 -1
  104. package/dist/collections/data.js.map +0 -1
  105. package/dist/collections/fs.js.map +0 -1
  106. package/dist/collections/json/loader-webpack.d.ts.map +0 -1
  107. package/dist/collections/json/loader-webpack.js.map +0 -1
  108. package/dist/collections/mdx/loader-webpack.d.ts.map +0 -1
  109. package/dist/collections/mdx/loader-webpack.js.map +0 -1
  110. package/dist/collections/mdx/react.d.ts.map +0 -1
  111. package/dist/collections/mdx/react.js.map +0 -1
  112. package/dist/collections/mdx/runtime-browser.js.map +0 -1
  113. package/dist/collections/mdx/runtime-dynamic.d.ts.map +0 -1
  114. package/dist/collections/mdx/runtime-dynamic.js.map +0 -1
  115. package/dist/collections/mdx/runtime.js.map +0 -1
  116. package/dist/collections/mdx/vue.d.ts.map +0 -1
  117. package/dist/collections/mdx/vue.js.map +0 -1
  118. package/dist/collections/mdx.js.map +0 -1
  119. package/dist/collections/obsidian.d.ts.map +0 -1
  120. package/dist/collections/obsidian.js.map +0 -1
  121. package/dist/collections/runtime/file-store.js.map +0 -1
  122. package/dist/collections/runtime/store.js.map +0 -1
  123. package/dist/collections/yaml/loader-webpack.d.ts.map +0 -1
  124. package/dist/collections/yaml/loader-webpack.js.map +0 -1
  125. package/dist/collections-Bl9hpWMS.js.map +0 -1
  126. package/dist/config/index.js.map +0 -1
  127. package/dist/core-BbTeLenA.d.ts.map +0 -1
  128. package/dist/core-CrYszxmc.js.map +0 -1
  129. package/dist/dynamic-CNEaikCN.d.ts.map +0 -1
  130. package/dist/dynamic.js.map +0 -1
  131. package/dist/file-store-DutRtol_.d.ts.map +0 -1
  132. package/dist/flatten-m0wfHxLH.js.map +0 -1
  133. package/dist/fs-KJjb32Nq.d.ts.map +0 -1
  134. package/dist/fuma-matter-E30PU53R.js.map +0 -1
  135. package/dist/git-BxnPg5Ao.d.ts.map +0 -1
  136. package/dist/index-DVqrqxzl.d.ts.map +0 -1
  137. package/dist/index.d.ts.map +0 -1
  138. package/dist/is-promise-like-C04ERo2r.js.map +0 -1
  139. package/dist/load-from-file-C3CnD8mJ.js.map +0 -1
  140. package/dist/loader-CyhM9SLt.js.map +0 -1
  141. package/dist/loader-D_sKOzDc.js.map +0 -1
  142. package/dist/loader-e2SkeDfY.js.map +0 -1
  143. package/dist/loader-ol04zeoP.js.map +0 -1
  144. package/dist/mdx-L0I8mePE.d.ts.map +0 -1
  145. package/dist/next/index.d.ts.map +0 -1
  146. package/dist/next/index.js.map +0 -1
  147. package/dist/node/index.d.ts.map +0 -1
  148. package/dist/node/index.js.map +0 -1
  149. package/dist/node/loader.d.ts.map +0 -1
  150. package/dist/node/loader.js.map +0 -1
  151. package/dist/node-Du4i4XDg.js.map +0 -1
  152. package/dist/plugins/git.js.map +0 -1
  153. package/dist/plugins/json-schema.d.ts.map +0 -1
  154. package/dist/plugins/json-schema.js.map +0 -1
  155. package/dist/plugins/loader/index.js.map +0 -1
  156. package/dist/plugins/loader/webpack.js.map +0 -1
  157. package/dist/plugins/remark/include.d.ts.map +0 -1
  158. package/dist/plugins/remark/include.js.map +0 -1
  159. package/dist/runtime-TETi5Giq.d.ts.map +0 -1
  160. package/dist/runtime-browser-M4sE6SmL.d.ts.map +0 -1
  161. package/dist/store-BC3n1VPY.d.ts.map +0 -1
  162. package/dist/validation-Bf_v2L3p.js.map +0 -1
  163. package/dist/vite/index.d.ts.map +0 -1
  164. package/dist/vite/index.js.map +0 -1
  165. package/dist/vite-DVIOnBqW.js.map +0 -1
@@ -26,5 +26,3 @@ function createCache(store = /* @__PURE__ */ new Map()) {
26
26
  }
27
27
  //#endregion
28
28
  export { createCache as t };
29
-
30
- //# sourceMappingURL=async-cache-C47yxLCv.js.map
@@ -0,0 +1,10 @@
1
+ import { E as Awaitable } from "./core-BbTeLenA.js";
2
+
3
+ //#region src/utils/async-cache.d.ts
4
+ interface AsyncCache<V> {
5
+ cached: (key: string, fn: () => Awaitable<V>) => V | PromiseLike<V>;
6
+ $value: <T>() => AsyncCache<T>;
7
+ invalidate: (key: string) => void;
8
+ }
9
+ //#endregion
10
+ export { AsyncCache as t };
package/dist/bin.js CHANGED
@@ -20,5 +20,3 @@ async function start() {
20
20
  start();
21
21
  //#endregion
22
22
  export {};
23
-
24
- //# sourceMappingURL=bin.js.map
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
2
2
  import { t as createCache } from "./async-cache-C47yxLCv.js";
3
- import { t as flattenNode } from "./flatten-m0wfHxLH.js";
3
+ import { t as flattenNode } from "./flatten-Db7WzTB7.js";
4
4
  import { visit } from "unist-util-visit";
5
5
  import { VFile } from "vfile";
6
6
  import { createProcessor } from "@mdx-js/mdx";
@@ -154,5 +154,3 @@ async function buildMDX({ core, collection, filePath, frontmatter, source, compi
154
154
  }
155
155
  //#endregion
156
156
  export { build_mdx_exports as n, buildMDX as t };
157
-
158
- //# sourceMappingURL=build-mdx-C8u32vDa.js.map
@@ -8,5 +8,4 @@ declare class BunCore extends Core {
8
8
  createBunPlugin(): BunPlugin;
9
9
  }
10
10
  //#endregion
11
- export { BunCore, BunOptions, createContent };
12
- //# sourceMappingURL=index.d.ts.map
11
+ export { BunCore, BunOptions, createContent };
package/dist/bun/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as Core } from "../core-CrYszxmc.js";
1
+ import { t as Core } from "../core-Cgc-cdSx.js";
2
2
  import { loaderPlugin } from "../plugins/loader/index.js";
3
3
  import { pathToFileURL } from "node:url";
4
4
  //#region src/bun/index.ts
@@ -27,5 +27,3 @@ var BunCore = class extends Core {
27
27
  };
28
28
  //#endregion
29
29
  export { BunCore, createContent };
30
-
31
- //# sourceMappingURL=index.js.map
@@ -31,5 +31,3 @@ function toBun(test = /.+/, loader) {
31
31
  }
32
32
  //#endregion
33
33
  export { toBun };
34
-
35
- //# sourceMappingURL=bun-NahDFkhR.js.map
@@ -101,5 +101,3 @@ function slash(path) {
101
101
  }
102
102
  //#endregion
103
103
  export { slash as n, CodeGenerator as t };
104
-
105
- //# sourceMappingURL=code-generator-DFGEY6P5.js.map
@@ -0,0 +1,6 @@
1
+ import { t as WebpackLoader } from "../../webpack-C8ABoMB_.js";
2
+
3
+ //#region src/collections/comark/loader-webpack.d.ts
4
+ declare const _default: WebpackLoader;
5
+ //#endregion
6
+ export { _default as default };
@@ -0,0 +1,6 @@
1
+ import { t as createComarkLoader } from "../../loader-DjDk5eLt.js";
2
+ import { createWebpackLoader } from "../../plugins/loader/webpack.js";
3
+ //#region src/collections/comark/loader-webpack.ts
4
+ var loader_webpack_default = createWebpackLoader(createComarkLoader);
5
+ //#endregion
6
+ export { loader_webpack_default as default };
@@ -0,0 +1,24 @@
1
+ import { D as GetCollectionConfig, E as Awaitable } from "../../core-BbTeLenA.js";
2
+ import { n as MapCollectionStore } from "../../store-BC3n1VPY.js";
3
+ import { t as AsyncCache } from "../../async-cache-svlxyp4V.js";
4
+ import { ParsedComark } from "./runtime.js";
5
+
6
+ //#region src/collections/comark/runtime-browser.d.ts
7
+ interface ComarkStoreBrowserData<Frontmatter, Attached = unknown> {
8
+ id: string;
9
+ preload: () => Awaitable<ParsedComark<Frontmatter> & Attached>;
10
+ _store: StoreContext;
11
+ }
12
+ interface StoreContext {
13
+ storeId: string;
14
+ }
15
+ interface StoreData {
16
+ preloaded: AsyncCache<ParsedComark<unknown>>;
17
+ }
18
+ type GetFrontmatter<Config, Name extends string> = GetCollectionConfig<Config, Name> extends {
19
+ $inferFrontmatter: unknown;
20
+ } ? GetCollectionConfig<Config, Name>["$inferFrontmatter"] : never;
21
+ declare const _internal_data: Map<string, StoreData>;
22
+ declare function comarkStoreBrowser<Config, Name extends string, Attached>(name: Name, _input: Record<string, () => Promise<unknown>>): MapCollectionStore<string, ComarkStoreBrowserData<GetFrontmatter<Config, Name>, Attached>>;
23
+ //#endregion
24
+ export { ComarkStoreBrowserData, _internal_data, comarkStoreBrowser };
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { t as createCache } from "../../async-cache-C47yxLCv.js";
3
+ import { MapCollectionStore } from "../runtime/store.js";
4
+ //#region src/collections/comark/runtime-browser.ts
5
+ const _internal_data = /* @__PURE__ */ new Map();
6
+ function comarkStoreBrowser(name, _input) {
7
+ const input = _input;
8
+ const merged = /* @__PURE__ */ new Map();
9
+ function getStoreData() {
10
+ let store = _internal_data.get(name);
11
+ if (store) return store;
12
+ store = { preloaded: createCache() };
13
+ _internal_data.set(name, store);
14
+ return store;
15
+ }
16
+ const context = { storeId: name };
17
+ for (const [key, value] of Object.entries(input)) merged.set(key, {
18
+ id: key,
19
+ preload() {
20
+ return getStoreData().preloaded.$value().cached(key, value);
21
+ },
22
+ _store: context
23
+ });
24
+ return new MapCollectionStore(merged);
25
+ }
26
+ //#endregion
27
+ export { _internal_data, comarkStoreBrowser };
@@ -0,0 +1,27 @@
1
+ import { D as GetCollectionConfig } from "../../core-BbTeLenA.js";
2
+ import { t as FileCollectionStore } from "../../file-store-D5nKTMSL.js";
3
+ import { ComarkTree } from "comark";
4
+
5
+ //#region src/collections/comark/runtime.d.ts
6
+ type ParsedComark<Frontmatter> = Omit<ComarkTree, "frontmatter"> & {
7
+ frontmatter: Frontmatter;
8
+ };
9
+ interface ComarkStoreData<Frontmatter, Attached = unknown> {
10
+ id: string;
11
+ tree: ParsedComark<Frontmatter> & Attached;
12
+ }
13
+ type GetFrontmatter<Config, Name extends string> = GetCollectionConfig<Config, Name> extends {
14
+ $inferFrontmatter: unknown;
15
+ } ? GetCollectionConfig<Config, Name>["$inferFrontmatter"] : never;
16
+ declare function comarkStore<Config, Name extends string, Attached>(_name: Name, base: string, _input: Record<string, unknown>): FileCollectionStore<ComarkStoreData<GetFrontmatter<Config, Name>, Attached>>;
17
+ interface ComarkStoreLazyData<Frontmatter, Attached> {
18
+ id: string;
19
+ frontmatter: Frontmatter;
20
+ load: () => Promise<ParsedComark<Frontmatter> & Attached>;
21
+ }
22
+ declare function comarkStoreLazy<Config, Name extends string, Attached>(_name: Name, base: string, _input: {
23
+ head: Record<string, unknown>;
24
+ body: Record<string, () => Promise<unknown>>;
25
+ }): FileCollectionStore<ComarkStoreLazyData<GetFrontmatter<Config, Name>, Attached>>;
26
+ //#endregion
27
+ export { ComarkStoreData, ComarkStoreLazyData, ParsedComark, comarkStore, comarkStoreLazy };
@@ -0,0 +1,23 @@
1
+ import { FileCollectionStore } from "../runtime/file-store.js";
2
+ //#region src/collections/comark/runtime.ts
3
+ function comarkStore(_name, base, _input) {
4
+ const input = _input;
5
+ const merged = {};
6
+ for (const [key, value] of Object.entries(input)) merged[key] = {
7
+ id: key,
8
+ tree: value
9
+ };
10
+ return new FileCollectionStore(base, merged);
11
+ }
12
+ function comarkStoreLazy(_name, base, _input) {
13
+ const input = _input;
14
+ const merged = {};
15
+ for (const [key, value] of Object.entries(input.head)) merged[key] = {
16
+ id: key,
17
+ frontmatter: value,
18
+ load: input.body[key]
19
+ };
20
+ return new FileCollectionStore(base, merged);
21
+ }
22
+ //#endregion
23
+ export { comarkStore, comarkStoreLazy };
@@ -0,0 +1,40 @@
1
+ import { E as Awaitable, m as Collection, v as AsyncPipe } from "../core-BbTeLenA.js";
2
+ import { n as FileSystemCollectionConfig, t as FileSystemCollection } from "../fs-_EGvbkVM.js";
3
+ import { StandardSchemaV1 } from "@standard-schema/spec";
4
+ import { ComarkTree, ComarkTree as ComarkTree$1, ParseOptions, ParseOptions as ParseOptions$1 } from "comark";
5
+
6
+ //#region src/collections/comark.d.ts
7
+ interface CompilationContext {
8
+ collection: Collection;
9
+ filePath: string;
10
+ source: string;
11
+ }
12
+ interface ComarkCollectionConfig<FrontmatterSchema extends StandardSchemaV1 | undefined = StandardSchemaV1 | undefined> extends Omit<FileSystemCollectionConfig, "supportedFormats"> {
13
+ frontmatter?: FrontmatterSchema;
14
+ options?: ParseOptions$1 | ((environment: "bundler" | "runtime") => Awaitable<ParseOptions$1>);
15
+ lazy?: boolean;
16
+ }
17
+ declare class ComarkCollection<FrontmatterSchema extends StandardSchemaV1 | undefined = StandardSchemaV1 | undefined> extends FileSystemCollection {
18
+ #private;
19
+ readonly lazy: boolean;
20
+ getComarkOptions(environment: "bundler" | "runtime"): Promise<ParseOptions$1>;
21
+ /**
22
+ * Frontmatter schema
23
+ */
24
+ frontmatterSchema?: FrontmatterSchema;
25
+ /**
26
+ * Transform & validate frontmatter
27
+ */
28
+ frontmatter: AsyncPipe<Record<string, unknown> | undefined, CompilationContext>;
29
+ /**
30
+ * Transform the parsed Comark tree.
31
+ */
32
+ tree: AsyncPipe<ComarkTree$1, CompilationContext>;
33
+ $inferFrontmatter: FrontmatterSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<FrontmatterSchema> : Record<string, unknown>;
34
+ constructor(config: ComarkCollectionConfig<FrontmatterSchema>);
35
+ private generateFrontmatterGlob;
36
+ private generateTreeGlob;
37
+ }
38
+ declare function comarkCollection<FrontmatterSchema extends StandardSchemaV1 | undefined = undefined>(config: ComarkCollectionConfig<FrontmatterSchema>): ComarkCollection<FrontmatterSchema>;
39
+ //#endregion
40
+ export { ComarkCollection, ComarkCollectionConfig, type ComarkTree, type ParseOptions, comarkCollection };
@@ -0,0 +1,202 @@
1
+ import { r as asyncPipe } from "../collections-Bl9hpWMS.js";
2
+ import { n as slash } from "../code-generator-DFGEY6P5.js";
3
+ import { r as validate } from "../validation-Bf_v2L3p.js";
4
+ import { t as createCache } from "../async-cache-C47yxLCv.js";
5
+ import { loaderHook } from "../plugins/loader/index.js";
6
+ import { FileSystemCollection } from "./fs.js";
7
+ import path from "node:path";
8
+ //#region src/collections/comark.ts
9
+ function formatInitializer(code) {
10
+ return `${code.fn}<${code.typeParams.join()}>(${code.params.join()})`;
11
+ }
12
+ var ComarkCollection = class extends FileSystemCollection {
13
+ lazy;
14
+ #comarkOptions;
15
+ #comarkOptionsCache;
16
+ async getComarkOptions(environment) {
17
+ const options = this.#comarkOptions;
18
+ if (!options) return {};
19
+ if (typeof options !== "function") return options;
20
+ this.#comarkOptionsCache ??= createCache();
21
+ return this.#comarkOptionsCache.cached(environment, () => options(environment));
22
+ }
23
+ /**
24
+ * Frontmatter schema
25
+ */
26
+ frontmatterSchema;
27
+ /**
28
+ * Transform & validate frontmatter
29
+ */
30
+ frontmatter = asyncPipe();
31
+ /**
32
+ * Transform the parsed Comark tree.
33
+ */
34
+ tree = asyncPipe();
35
+ $inferFrontmatter = void 0;
36
+ constructor(config) {
37
+ super({
38
+ dir: config.dir,
39
+ files: config.files,
40
+ supportedFormats: ["md", "mdc"]
41
+ });
42
+ this.#comarkOptions = config.options;
43
+ this.lazy = config.lazy ?? false;
44
+ this.frontmatterSchema = config.frontmatter;
45
+ this.frontmatter.pipe(this.#onFrontmatter.bind(this));
46
+ this.onServer.hook(this.#onServerHandler.bind(this));
47
+ this.onEmit.pipe(this.#onEmitHandler.bind(this));
48
+ this.pluginHook(loaderHook).loaders.push(comarkLoader());
49
+ }
50
+ #onFrontmatter = (data, { filePath }) => {
51
+ if (!this.frontmatterSchema) return data;
52
+ return validate(this.frontmatterSchema, data, void 0, `invalid frontmatter in ${filePath}`);
53
+ };
54
+ #onServerHandler = ({ server, core }) => {
55
+ if (!server.watcher) return;
56
+ server.watcher.on("all", async (event, file) => {
57
+ if (event === "change" || !this.hasFile(file)) return;
58
+ await core.emit({
59
+ filterCollection: (item) => item === this,
60
+ filterWorkspace: () => false,
61
+ write: true
62
+ });
63
+ });
64
+ };
65
+ #onEmitHandler = async (entries, { core, createCodeGenerator }) => {
66
+ entries.push(await createCodeGenerator(`${this.name}.ts`, async ({ codegen }) => {
67
+ const base = slash(core._toRuntimePath(this.dir));
68
+ codegen.addNamespaceImport("Config", codegen.formatImportPath(core.getOptions().configPath), true);
69
+ if (this.lazy) {
70
+ codegen.addNamedImport(["comarkStoreLazy"], "fuma-content/collections/comark/runtime");
71
+ const headGlob = await this.generateFrontmatterGlob(core, codegen, true);
72
+ const bodyGlob = await this.generateTreeGlob(core, codegen);
73
+ codegen.push(`export const ${this.name} = ${formatInitializer({
74
+ fn: "comarkStoreLazy",
75
+ typeParams: [
76
+ "typeof Config",
77
+ `"${this.name}"`,
78
+ "unknown"
79
+ ],
80
+ params: [
81
+ `"${this.name}"`,
82
+ `"${base}"`,
83
+ `{ head: ${headGlob}, body: ${bodyGlob} }`
84
+ ]
85
+ })};`);
86
+ } else {
87
+ codegen.addNamedImport(["comarkStore"], "fuma-content/collections/comark/runtime");
88
+ codegen.push(`export const ${this.name} = ${formatInitializer({
89
+ fn: "comarkStore",
90
+ typeParams: [
91
+ "typeof Config",
92
+ `"${this.name}"`,
93
+ "unknown"
94
+ ],
95
+ params: [
96
+ `"${this.name}"`,
97
+ `"${base}"`,
98
+ await this.generateTreeGlob(core, codegen, true)
99
+ ]
100
+ })};`);
101
+ }
102
+ }), await createCodeGenerator(`${this.name}.browser.ts`, async ({ codegen }) => {
103
+ codegen.addNamedImport(["comarkStoreBrowser"], "fuma-content/collections/comark/runtime-browser");
104
+ codegen.addNamespaceImport("Config", codegen.formatImportPath(core.getOptions().configPath), true);
105
+ codegen.push(`export const ${this.name} = ${formatInitializer({
106
+ fn: "comarkStoreBrowser",
107
+ typeParams: [
108
+ "typeof Config",
109
+ `"${this.name}"`,
110
+ "unknown"
111
+ ],
112
+ params: [`"${this.name}"`, await this.generateTreeGlob(core, codegen)]
113
+ })};`);
114
+ }));
115
+ return entries;
116
+ };
117
+ async generateFrontmatterGlob(core, codegen, eager = false) {
118
+ let s = `{`;
119
+ const query = codegen.formatQuery({
120
+ collection: this.name,
121
+ only: "frontmatter",
122
+ workspace: core.getWorkspace()?.name
123
+ });
124
+ for (const file of await this.getFiles()) {
125
+ const fullPath = path.join(this.dir, file);
126
+ const specifier = `${codegen.formatImportPath(fullPath)}?${query}`;
127
+ if (eager) {
128
+ const name = codegen.generateImportName();
129
+ codegen.addNamedImport([`frontmatter as ${name}`], specifier);
130
+ s += `"${slash(file)}": ${name},`;
131
+ } else s += `"${slash(file)}": () => ${codegen.formatDynamicImport(specifier, "frontmatter")},`;
132
+ }
133
+ s += "}";
134
+ return s;
135
+ }
136
+ async generateTreeGlob(core, codegen, eager = false) {
137
+ let s = `{`;
138
+ const query = codegen.formatQuery({
139
+ collection: this.name,
140
+ workspace: core.getWorkspace()?.name
141
+ });
142
+ for (const file of await this.getFiles()) {
143
+ const fullPath = path.join(this.dir, file);
144
+ const specifier = `${codegen.formatImportPath(fullPath)}?${query}`;
145
+ if (eager) {
146
+ const name = codegen.generateImportName();
147
+ codegen.addNamedImport([`default as ${name}`], specifier);
148
+ s += `"${slash(file)}": ${name},`;
149
+ } else s += `"${slash(file)}": () => ${codegen.formatDynamicImport(specifier, "default")},`;
150
+ }
151
+ s += "}";
152
+ return s;
153
+ }
154
+ };
155
+ function comarkCollection(config) {
156
+ return new ComarkCollection(config);
157
+ }
158
+ function comarkLoader() {
159
+ const test = /\.(?:md|mdc)(\?.+?)?$/;
160
+ return {
161
+ id: "comark",
162
+ test,
163
+ configureNext(nextConfig) {
164
+ const loaderPath = "fuma-content/collections/comark/loader-webpack";
165
+ const loaderOptions = this.getLoaderOptions();
166
+ return {
167
+ ...nextConfig,
168
+ turbopack: {
169
+ ...nextConfig.turbopack,
170
+ rules: {
171
+ ...nextConfig.turbopack?.rules,
172
+ "*.{md,mdc}": {
173
+ loaders: [{
174
+ loader: loaderPath,
175
+ options: loaderOptions
176
+ }],
177
+ as: "*.js"
178
+ }
179
+ }
180
+ },
181
+ webpack(config, options) {
182
+ config.module ||= {};
183
+ config.module.rules ||= [];
184
+ config.module.rules.push({
185
+ test,
186
+ use: [options.defaultLoaders.babel, {
187
+ loader: loaderPath,
188
+ options: loaderOptions
189
+ }]
190
+ });
191
+ return nextConfig.webpack?.(config, options) ?? config;
192
+ }
193
+ };
194
+ },
195
+ async createLoader() {
196
+ const { createComarkLoader } = await import("../loader-DjDk5eLt.js").then((n) => n.n);
197
+ return createComarkLoader({ getCore: () => this.core });
198
+ }
199
+ };
200
+ }
201
+ //#endregion
202
+ export { ComarkCollection, comarkCollection };
@@ -1,5 +1,5 @@
1
1
  import { D as GetCollectionConfig } from "../../core-BbTeLenA.js";
2
- import { t as FileCollectionStore } from "../../file-store-DutRtol_.js";
2
+ import { t as FileCollectionStore } from "../../file-store-D5nKTMSL.js";
3
3
 
4
4
  //#region src/collections/data/runtime.d.ts
5
5
  declare function dataStore<Config, Name extends string>(_name: Name, base: string, input: Record<string, unknown>): FileCollectionStore<{
@@ -8,5 +8,4 @@ declare function dataStore<Config, Name extends string>(_name: Name, base: strin
8
8
  } ? GetCollectionConfig<Config, Name>["$inferOutput"] : never;
9
9
  }>;
10
10
  //#endregion
11
- export { dataStore };
12
- //# sourceMappingURL=runtime.d.ts.map
11
+ export { dataStore };
@@ -7,5 +7,3 @@ function dataStore(_name, base, input) {
7
7
  }
8
8
  //#endregion
9
9
  export { dataStore };
10
-
11
- //# sourceMappingURL=runtime.js.map
@@ -1,6 +1,6 @@
1
1
  import { v as AsyncPipe } from "../core-BbTeLenA.js";
2
- import { n as LoaderConfig } from "../index-DVqrqxzl.js";
3
- import { n as FileSystemCollectionConfig, t as FileSystemCollection } from "../fs-KJjb32Nq.js";
2
+ import { n as FileSystemCollectionConfig, t as FileSystemCollection } from "../fs-_EGvbkVM.js";
3
+ import { a as LoaderConfig } from "../webpack-C8ABoMB_.js";
4
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
5
 
6
6
  //#region src/collections/data.d.ts
@@ -42,5 +42,4 @@ declare function dataCollection<Schema extends StandardSchemaV1 | undefined = un
42
42
  declare function yamlLoader(): LoaderConfig;
43
43
  declare function jsonLoader(): LoaderConfig;
44
44
  //#endregion
45
- export { DataCollection, DataCollectionConfig, DataTransformationContext, dataCollection, jsonLoader, yamlLoader };
46
- //# sourceMappingURL=data.d.ts.map
45
+ export { DataCollection, DataCollectionConfig, DataTransformationContext, dataCollection, jsonLoader, yamlLoader };
@@ -154,5 +154,3 @@ function jsonLoader() {
154
154
  }
155
155
  //#endregion
156
156
  export { DataCollection, dataCollection, jsonLoader, yamlLoader };
157
-
158
- //# sourceMappingURL=data.js.map
@@ -1,2 +1,2 @@
1
- import { n as FileSystemCollectionConfig, r as fileSystemCollection, t as FileSystemCollection } from "../fs-KJjb32Nq.js";
1
+ import { n as FileSystemCollectionConfig, r as fileSystemCollection, t as FileSystemCollection } from "../fs-_EGvbkVM.js";
2
2
  export { FileSystemCollection, FileSystemCollectionConfig, fileSystemCollection };
@@ -61,5 +61,3 @@ function fileSystemCollection(config) {
61
61
  }
62
62
  //#endregion
63
63
  export { FileSystemCollection, fileSystemCollection };
64
-
65
- //# sourceMappingURL=fs.js.map
@@ -1,7 +1,6 @@
1
- import { c as WebpackLoader } from "../../index-DVqrqxzl.js";
1
+ import { t as WebpackLoader } from "../../webpack-C8ABoMB_.js";
2
2
 
3
3
  //#region src/collections/json/loader-webpack.d.ts
4
4
  declare const _default: WebpackLoader;
5
5
  //#endregion
6
- export { _default as default };
7
- //# sourceMappingURL=loader-webpack.d.ts.map
6
+ export { _default as default };
@@ -1,10 +1,6 @@
1
- import "../../validation-Bf_v2L3p.js";
2
1
  import { createWebpackLoader } from "../../plugins/loader/webpack.js";
3
- import "../../loader-ol04zeoP.js";
4
2
  import { t as createJsonLoader } from "../../loader-e2SkeDfY.js";
5
3
  //#region src/collections/json/loader-webpack.ts
6
4
  var loader_webpack_default = createWebpackLoader((core) => createJsonLoader(core, "json"));
7
5
  //#endregion
8
6
  export { loader_webpack_default as default };
9
-
10
- //# sourceMappingURL=loader-webpack.js.map
@@ -1,7 +1,6 @@
1
- import { c as WebpackLoader } from "../../index-DVqrqxzl.js";
1
+ import { t as WebpackLoader } from "../../webpack-C8ABoMB_.js";
2
2
 
3
3
  //#region src/collections/mdx/loader-webpack.d.ts
4
4
  declare const _default: WebpackLoader;
5
5
  //#endregion
6
- export { _default as default };
7
- //# sourceMappingURL=loader-webpack.d.ts.map
6
+ export { _default as default };
@@ -1,10 +1,6 @@
1
- import "../../validation-Bf_v2L3p.js";
2
- import "../../fuma-matter-E30PU53R.js";
3
1
  import { createWebpackLoader } from "../../plugins/loader/webpack.js";
4
- import { t as createMdxLoader } from "../../loader-CyhM9SLt.js";
2
+ import { t as createMdxLoader } from "../../loader-9KbB2Twu.js";
5
3
  //#region src/collections/mdx/loader-webpack.ts
6
4
  var loader_webpack_default = createWebpackLoader(createMdxLoader);
7
5
  //#endregion
8
6
  export { loader_webpack_default as default };
9
-
10
- //# sourceMappingURL=loader-webpack.js.map
@@ -1,5 +1,5 @@
1
- import { i as CompiledMDX } from "../../mdx-L0I8mePE.js";
2
- import { t as MDXStoreBrowserData } from "../../runtime-browser-M4sE6SmL.js";
1
+ import { i as CompiledMDX } from "../../mdx-CkXj06oG.js";
2
+ import { t as MDXStoreBrowserData } from "../../runtime-browser-BI2h1vjc.js";
3
3
  import { ReactNode } from "react";
4
4
 
5
5
  //#region src/collections/mdx/react.d.ts
@@ -10,5 +10,4 @@ import { ReactNode } from "react";
10
10
  */
11
11
  declare function useRenderer<Frontmatter, Attached>(entry: MDXStoreBrowserData<Frontmatter, Attached> | undefined, renderFn: (data: CompiledMDX<Frontmatter> & Attached) => ReactNode): ReactNode;
12
12
  //#endregion
13
- export { useRenderer };
14
- //# sourceMappingURL=react.d.ts.map
13
+ export { useRenderer };
@@ -31,5 +31,3 @@ function useRenderer(entry, renderFn) {
31
31
  }
32
32
  //#endregion
33
33
  export { useRenderer };
34
-
35
- //# sourceMappingURL=react.js.map
@@ -1,3 +1,3 @@
1
- import { n as _internal_data, r as mdxStoreBrowser, t as MDXStoreBrowserData } from "../../runtime-browser-M4sE6SmL.js";
2
- import { r as WithGit } from "../../runtime-TETi5Giq.js";
1
+ import { r as WithGit } from "../../runtime-5EdZjL1e.js";
2
+ import { n as _internal_data, r as mdxStoreBrowser, t as MDXStoreBrowserData } from "../../runtime-browser-BI2h1vjc.js";
3
3
  export { MDXStoreBrowserData, WithGit, _internal_data, mdxStoreBrowser };
@@ -25,5 +25,3 @@ function mdxStoreBrowser(name, _input) {
25
25
  }
26
26
  //#endregion
27
27
  export { _internal_data, mdxStoreBrowser };
28
-
29
- //# sourceMappingURL=runtime-browser.js.map
@@ -1,7 +1,7 @@
1
1
  import { D as GetCollectionConfig, n as CoreOptions } 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 { r as WithGit } from "../../runtime-TETi5Giq.js";
2
+ import { t as FileCollectionStore } from "../../file-store-D5nKTMSL.js";
3
+ import { i as CompiledMDX } from "../../mdx-CkXj06oG.js";
4
+ import { r as WithGit } from "../../runtime-5EdZjL1e.js";
5
5
  import { MDXContent } from "mdx/types";
6
6
 
7
7
  //#region src/collections/mdx/runtime-dynamic.d.ts
@@ -16,5 +16,4 @@ type GetFrontmatter<Config, Name extends string> = GetCollectionConfig<Config, N
16
16
  declare function mdxStoreDynamic<Config, Name extends string, Attached>(config: Config, coreOptions: CoreOptions, name: Name, base: string, _frontmatter: Record<string, unknown>, jsxRuntime: unknown): Promise<FileCollectionStore<MDXStoreDynamicData<GetFrontmatter<Config, Name>, Attached>>>;
17
17
  type MdxContent = MDXContent;
18
18
  //#endregion
19
- export { MDXStoreDynamicData, MdxContent, type WithGit, mdxStoreDynamic };
20
- //# sourceMappingURL=runtime-dynamic.d.ts.map
19
+ export { MDXStoreDynamicData, MdxContent, type WithGit, mdxStoreDynamic };
@@ -1,10 +1,9 @@
1
- import { t as Core } from "../../core-CrYszxmc.js";
2
- import "../../validation-Bf_v2L3p.js";
1
+ import { t as Core } from "../../core-Cgc-cdSx.js";
3
2
  import { t as createCache } from "../../async-cache-C47yxLCv.js";
4
3
  import { MDXCollection } from "../mdx.js";
5
- import { t as fumaMatter } from "../../fuma-matter-E30PU53R.js";
4
+ import { parseFrontmatter } from "../../utils/frontmatter.js";
6
5
  import { FileCollectionStore } from "../runtime/file-store.js";
7
- import { t as buildMDX } from "../../build-mdx-C8u32vDa.js";
6
+ import { t as buildMDX } from "../../build-mdx-DRJ7dZuq.js";
8
7
  import fs from "node:fs/promises";
9
8
  import path from "node:path";
10
9
  import { pathToFileURL } from "node:url";
@@ -29,7 +28,7 @@ async function mdxStoreDynamic(config, coreOptions, name, base, _frontmatter, js
29
28
  return cache.cached(k, async () => {
30
29
  const filePath = path.join(base, k);
31
30
  let content = (await fs.readFile(filePath)).toString();
32
- content = fumaMatter(content).content;
31
+ content = parseFrontmatter(content).content;
33
32
  const compiled = await buildMDX({
34
33
  core,
35
34
  collection,
@@ -69,5 +68,3 @@ async function executeMdx(compiled, options = {}) {
69
68
  }
70
69
  //#endregion
71
70
  export { mdxStoreDynamic };
72
-
73
- //# sourceMappingURL=runtime-dynamic.js.map
@@ -1,2 +1,2 @@
1
- import { a as mdxStoreLazy, i as mdxStore, n as MDXStoreLazyData, r as WithGit, t as MDXStoreData } from "../../runtime-TETi5Giq.js";
1
+ import { a as mdxStoreLazy, i as mdxStore, n as MDXStoreLazyData, r as WithGit, t as MDXStoreData } from "../../runtime-5EdZjL1e.js";
2
2
  export { MDXStoreData, MDXStoreLazyData, WithGit, mdxStore, mdxStoreLazy };
@@ -21,5 +21,3 @@ function mdxStoreLazy(_name, base, _input) {
21
21
  }
22
22
  //#endregion
23
23
  export { mdxStore, mdxStoreLazy };
24
-
25
- //# sourceMappingURL=runtime.js.map