fuma-content 1.1.2 → 1.1.4

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 (192) hide show
  1. package/dist/async-cache-BVuJiIDT.d.ts +9 -0
  2. package/dist/async-cache-BVuJiIDT.d.ts.map +1 -0
  3. package/dist/{async-cache-U87GzQTb.js → async-cache-DRmFaVGm.js} +1 -1
  4. package/dist/{async-cache-U87GzQTb.js.map → async-cache-DRmFaVGm.js.map} +1 -1
  5. package/dist/build-mdx-DRqbcE1d.d.ts +79 -0
  6. package/dist/build-mdx-DRqbcE1d.d.ts.map +1 -0
  7. package/dist/{build-mdx-CUp6FpfT.js → build-mdx-DgzggXIL.js} +27 -40
  8. package/dist/build-mdx-DgzggXIL.js.map +1 -0
  9. package/dist/bun/index.d.ts +1 -1
  10. package/dist/bun/index.d.ts.map +1 -1
  11. package/dist/bun/index.js +2 -2
  12. package/dist/{bun-CBROq3I0.js → bun-Be5pgXW_.js} +4 -3
  13. package/dist/bun-Be5pgXW_.js.map +1 -0
  14. package/dist/{code-generator-Qhhq7kHh.js → code-generator-CHcOrCeM.js} +5 -7
  15. package/dist/code-generator-CHcOrCeM.js.map +1 -0
  16. package/dist/collections/data/runtime.d.ts +3 -6
  17. package/dist/collections/data/runtime.d.ts.map +1 -1
  18. package/dist/collections/data/runtime.js.map +1 -1
  19. package/dist/collections/data.d.ts +4 -4
  20. package/dist/collections/data.d.ts.map +1 -1
  21. package/dist/collections/data.js +158 -4
  22. package/dist/collections/data.js.map +1 -0
  23. package/dist/collections/fs.d.ts +45 -3
  24. package/dist/collections/fs.d.ts.map +1 -0
  25. package/dist/collections/fs.js +65 -2
  26. package/dist/collections/fs.js.map +1 -0
  27. package/dist/collections/index.d.ts +37 -2
  28. package/dist/collections/index.d.ts.map +1 -0
  29. package/dist/collections/index.js +37 -2
  30. package/dist/collections/index.js.map +1 -0
  31. package/dist/collections/json/loader-webpack.d.ts +3 -3
  32. package/dist/collections/json/loader-webpack.d.ts.map +1 -1
  33. package/dist/collections/json/loader-webpack.js +3 -7
  34. package/dist/collections/json/loader-webpack.js.map +1 -1
  35. package/dist/collections/mdx/loader-webpack.d.ts +3 -3
  36. package/dist/collections/mdx/loader-webpack.d.ts.map +1 -1
  37. package/dist/collections/mdx/loader-webpack.js +3 -8
  38. package/dist/collections/mdx/loader-webpack.js.map +1 -1
  39. package/dist/collections/mdx/react.d.ts +3 -10
  40. package/dist/collections/mdx/react.d.ts.map +1 -1
  41. package/dist/collections/mdx/react.js +2 -1
  42. package/dist/collections/mdx/react.js.map +1 -1
  43. package/dist/collections/mdx/runtime-browser.d.ts +25 -11
  44. package/dist/collections/mdx/runtime-browser.d.ts.map +1 -0
  45. package/dist/collections/mdx/runtime-browser.js +2 -2
  46. package/dist/collections/mdx/runtime-browser.js.map +1 -1
  47. package/dist/collections/mdx/runtime-dynamic.d.ts +6 -10
  48. package/dist/collections/mdx/runtime-dynamic.d.ts.map +1 -1
  49. package/dist/collections/mdx/runtime-dynamic.js +15 -13
  50. package/dist/collections/mdx/runtime-dynamic.js.map +1 -1
  51. package/dist/collections/mdx/runtime.d.ts +26 -10
  52. package/dist/collections/mdx/runtime.d.ts.map +1 -0
  53. package/dist/collections/mdx/runtime.js.map +1 -1
  54. package/dist/collections/mdx.d.ts +66 -6
  55. package/dist/collections/mdx.d.ts.map +1 -0
  56. package/dist/collections/mdx.js +316 -6
  57. package/dist/collections/mdx.js.map +1 -0
  58. package/dist/collections/obsidian.d.ts +10 -0
  59. package/dist/collections/obsidian.d.ts.map +1 -0
  60. package/dist/collections/obsidian.js +497 -0
  61. package/dist/collections/obsidian.js.map +1 -0
  62. package/dist/collections/runtime/file-store.d.ts +21 -4
  63. package/dist/collections/runtime/file-store.d.ts.map +1 -0
  64. package/dist/collections/runtime/file-store.js +1 -1
  65. package/dist/collections/runtime/store.d.ts +31 -3
  66. package/dist/collections/runtime/store.d.ts.map +1 -0
  67. package/dist/collections/runtime/store.js +33 -2
  68. package/dist/collections/runtime/store.js.map +1 -0
  69. package/dist/collections/yaml/loader-webpack.d.ts +3 -3
  70. package/dist/collections/yaml/loader-webpack.d.ts.map +1 -1
  71. package/dist/collections/yaml/loader-webpack.js +3 -7
  72. package/dist/collections/yaml/loader-webpack.js.map +1 -1
  73. package/dist/config/index.d.ts +35 -2
  74. package/dist/config/index.d.ts.map +1 -0
  75. package/dist/config/index.js.map +1 -1
  76. package/dist/{core-Uv3jZqL-.js → core-BuUsOElL.js} +9 -9
  77. package/dist/core-BuUsOElL.js.map +1 -0
  78. package/dist/{core-CT06v32N.d.ts → core-FjA_Xoho.d.ts} +4 -67
  79. package/dist/core-FjA_Xoho.d.ts.map +1 -0
  80. package/dist/dynamic.d.ts +25 -3
  81. package/dist/dynamic.d.ts.map +1 -0
  82. package/dist/dynamic.js +28 -2
  83. package/dist/dynamic.js.map +1 -0
  84. package/dist/{fuma-matter-BuBO2w-p.js → fuma-matter-B4gT09gM.js} +1 -1
  85. package/dist/fuma-matter-B4gT09gM.js.map +1 -0
  86. package/dist/index.d.ts +1 -1
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +3 -3
  89. package/dist/is-promise-like-DYHv0Yap.js +8 -0
  90. package/dist/is-promise-like-DYHv0Yap.js.map +1 -0
  91. package/dist/{load-from-file-z7EGuf2n.js → load-from-file-BhdBOcQT.js} +4 -2
  92. package/dist/{load-from-file-z7EGuf2n.js.map → load-from-file-BhdBOcQT.js.map} +1 -1
  93. package/dist/load-from-file-CIYdu-B5.d.ts +10 -0
  94. package/dist/load-from-file-CIYdu-B5.d.ts.map +1 -0
  95. package/dist/loader-BOYLUNfh.js +18 -0
  96. package/dist/{loader-BK8PnqRg.js.map → loader-BOYLUNfh.js.map} +1 -1
  97. package/dist/{loader-CnksfM7I.js → loader-BT4fwLTJ.js} +13 -7
  98. package/dist/loader-BT4fwLTJ.js.map +1 -0
  99. package/dist/loader-Cb9kSSxT.js +19 -0
  100. package/dist/{loader-Cnz-VHne.js.map → loader-Cb9kSSxT.js.map} +1 -1
  101. package/dist/{loader-CuntMmR4.js → loader-UhlX4xbz.js} +3 -3
  102. package/dist/loader-UhlX4xbz.js.map +1 -0
  103. package/dist/next/index.d.ts +1 -1
  104. package/dist/next/index.d.ts.map +1 -1
  105. package/dist/next/index.js +3 -3
  106. package/dist/next/index.js.map +1 -1
  107. package/dist/node/index.d.ts +1 -1
  108. package/dist/node/index.d.ts.map +1 -1
  109. package/dist/node/loader.d.ts +1 -1
  110. package/dist/node/loader.d.ts.map +1 -1
  111. package/dist/node/loader.js +8 -8
  112. package/dist/node/loader.js.map +1 -1
  113. package/dist/{node-2VZOh3P9.js → node-Cu5Pqxxo.js} +2 -2
  114. package/dist/node-Cu5Pqxxo.js.map +1 -0
  115. package/dist/{collections-CNWuMDAZ.js → pipe-CvCqOpXX.js} +2 -36
  116. package/dist/pipe-CvCqOpXX.js.map +1 -0
  117. package/dist/plugins/git.d.ts +38 -3
  118. package/dist/plugins/git.d.ts.map +1 -0
  119. package/dist/plugins/git.js +60 -2
  120. package/dist/plugins/git.js.map +1 -0
  121. package/dist/plugins/json-schema.d.ts +2 -1
  122. package/dist/plugins/json-schema.d.ts.map +1 -1
  123. package/dist/plugins/json-schema.js +2 -2
  124. package/dist/plugins/json-schema.js.map +1 -1
  125. package/dist/plugins/loader/index.d.ts +72 -4
  126. package/dist/plugins/loader/index.d.ts.map +1 -0
  127. package/dist/plugins/loader/index.js +77 -2
  128. package/dist/plugins/loader/index.js.map +1 -0
  129. package/dist/plugins/loader/webpack.d.ts +21 -4
  130. package/dist/plugins/loader/webpack.d.ts.map +1 -0
  131. package/dist/plugins/loader/webpack.js +7 -5
  132. package/dist/plugins/loader/webpack.js.map +1 -1
  133. package/dist/rolldown-runtime-CjeV3_4I.js +18 -0
  134. package/dist/{validation-BvVvvLII.js → validation-C3kXuveD.js} +1 -1
  135. package/dist/{validation-BvVvvLII.js.map → validation-C3kXuveD.js.map} +1 -1
  136. package/dist/vite/index.d.ts +1 -1
  137. package/dist/vite/index.d.ts.map +1 -1
  138. package/dist/vite/index.js +4 -15
  139. package/dist/vite/index.js.map +1 -1
  140. package/dist/{vite-C1qXY47G.js → vite-CoJIMNWk.js} +4 -4
  141. package/dist/vite-CoJIMNWk.js.map +1 -0
  142. package/package.json +27 -11
  143. package/dist/build-mdx-CUp6FpfT.js.map +0 -1
  144. package/dist/build-mdx-D6zM3Sgl.js +0 -4
  145. package/dist/bun-CBROq3I0.js.map +0 -1
  146. package/dist/code-generator-Qhhq7kHh.js.map +0 -1
  147. package/dist/collections-CNWuMDAZ.js.map +0 -1
  148. package/dist/core-CT06v32N.d.ts.map +0 -1
  149. package/dist/core-Uv3jZqL-.js.map +0 -1
  150. package/dist/data-Cxsx5KPD.js +0 -159
  151. package/dist/data-Cxsx5KPD.js.map +0 -1
  152. package/dist/dynamic-Ck1wYoaL.d.ts +0 -33
  153. package/dist/dynamic-Ck1wYoaL.d.ts.map +0 -1
  154. package/dist/dynamic-CtOB4Rkp.js +0 -29
  155. package/dist/dynamic-CtOB4Rkp.js.map +0 -1
  156. package/dist/file-store-Dm1SjuLg.d.ts +0 -20
  157. package/dist/file-store-Dm1SjuLg.d.ts.map +0 -1
  158. package/dist/fs-CXzVd2Dp.js +0 -68
  159. package/dist/fs-CXzVd2Dp.js.map +0 -1
  160. package/dist/fs-CmwaaFyx.d.ts +0 -45
  161. package/dist/fs-CmwaaFyx.d.ts.map +0 -1
  162. package/dist/fuma-matter-BuBO2w-p.js.map +0 -1
  163. package/dist/git-DnejL9r_.js +0 -60
  164. package/dist/git-DnejL9r_.js.map +0 -1
  165. package/dist/git-n-9ddn78.d.ts +0 -37
  166. package/dist/git-n-9ddn78.d.ts.map +0 -1
  167. package/dist/index-BheUVWBm.d.ts +0 -87
  168. package/dist/index-BheUVWBm.d.ts.map +0 -1
  169. package/dist/load-from-file-D-Xm95Fz.js +0 -3
  170. package/dist/loader-B4nQrRwA.js +0 -77
  171. package/dist/loader-B4nQrRwA.js.map +0 -1
  172. package/dist/loader-B6ordrWK.js +0 -9
  173. package/dist/loader-BK8PnqRg.js +0 -16
  174. package/dist/loader-CnksfM7I.js.map +0 -1
  175. package/dist/loader-Cnz-VHne.js +0 -17
  176. package/dist/loader-CuntMmR4.js.map +0 -1
  177. package/dist/loader-Cx1Rg_VM.js +0 -8
  178. package/dist/loader-Dao_nv3e.js +0 -8
  179. package/dist/mdx-Cw1nBJ0D.js +0 -306
  180. package/dist/mdx-Cw1nBJ0D.js.map +0 -1
  181. package/dist/mdx-PaqRNZMS.d.ts +0 -135
  182. package/dist/mdx-PaqRNZMS.d.ts.map +0 -1
  183. package/dist/node-2VZOh3P9.js.map +0 -1
  184. package/dist/runtime-BUUHSFlR.d.ts +0 -31
  185. package/dist/runtime-BUUHSFlR.d.ts.map +0 -1
  186. package/dist/runtime-browser-B70WGxeQ.d.ts +0 -29
  187. package/dist/runtime-browser-B70WGxeQ.d.ts.map +0 -1
  188. package/dist/store-CRyvZFKN.js +0 -34
  189. package/dist/store-CRyvZFKN.js.map +0 -1
  190. package/dist/store-D_PPrdRE.d.ts +0 -31
  191. package/dist/store-D_PPrdRE.d.ts.map +0 -1
  192. package/dist/vite-C1qXY47G.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-Cxsx5KPD.js","names":["loadersConfig: Record<string, LoaderConfig>","#onEmitHandler"],"sources":["../src/collections/data.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { Configuration } from \"webpack\";\nimport { LoaderConfig, loaderHook } from \"@/plugins/loader\";\nimport type { TurbopackLoaderOptions } from \"next/dist/server/config-shared\";\nimport { asyncPipe } from \"@/utils/pipe\";\nimport { slash } from \"@/utils/code-generator\";\nimport { FileSystemCollection, FileSystemCollectionConfig } from \"./fs\";\nimport path from \"node:path\";\n\nexport interface DataTransformationContext {\n path: string;\n source: string;\n}\n\ninterface LoadersConfig {\n json?: boolean;\n yaml?: boolean;\n custom?: Record<string, LoaderConfig>;\n}\n\nexport interface DataCollectionConfig<Schema extends StandardSchemaV1 | undefined> extends Omit<\n FileSystemCollectionConfig,\n \"supportedFormats\"\n> {\n schema?: Schema;\n /**\n * Configurations for loaders to parse data files.\n *\n * By default, JSON and YAML are enabled.\n * */\n loaders?: LoadersConfig;\n}\n\nexport class DataCollection<\n Schema extends StandardSchemaV1 | undefined = StandardSchemaV1 | undefined,\n> extends FileSystemCollection {\n schema?: Schema;\n /**\n * Transform data\n */\n readonly onLoad = asyncPipe<unknown, DataTransformationContext>();\n $inferInput: Schema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Schema> : unknown =\n undefined as never;\n $inferOutput: Schema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Schema> : unknown =\n undefined as never;\n\n constructor({ dir, files, loaders: _loadersConfig = {}, schema }: DataCollectionConfig<Schema>) {\n const loadersConfig: Record<string, LoaderConfig> = {\n ..._loadersConfig.custom,\n };\n if (_loadersConfig.json !== false) loadersConfig.json = jsonLoader();\n if (_loadersConfig.yaml !== false) loadersConfig.yaml = yamlLoader();\n\n super({ dir, files, supportedFormats: Object.keys(loadersConfig) });\n this.schema = schema;\n this.onServer.hook(({ core, server }) => {\n if (!server.watcher) return;\n\n server.watcher.on(\"all\", async (event, file) => {\n if (event === \"change\" || !this.hasFile(file)) return;\n\n await core.emit({\n filterCollection: (collection) => collection === this,\n filterWorkspace: () => false,\n write: true,\n });\n });\n });\n this.onEmit.pipe(this.#onEmitHandler.bind(this));\n this.pluginHook(loaderHook).loaders.push(...Object.values(loadersConfig));\n }\n\n #onEmitHandler: (typeof this)[\"onEmit\"][\"$inferHandler\"] = async (\n entries,\n { core, createCodeGenerator },\n ) => {\n entries.push(\n await createCodeGenerator(`${this.name}.ts`, async ({ codegen }) => {\n codegen.addNamedImport([\"dataStore\"], \"fuma-content/collections/data/runtime\");\n codegen.addNamespaceImport(\n \"Config\",\n codegen.formatImportPath(core.getOptions().configPath),\n true,\n );\n const base = slash(core._toRuntimePath(this.dir));\n let records = \"{\";\n const query = codegen.formatQuery({\n collection: this.name,\n workspace: core.getWorkspace()?.name,\n });\n\n for (const file of await this.getFiles()) {\n const fullPath = path.join(this.dir, file);\n const specifier = `${codegen.formatImportPath(fullPath)}?${query}`;\n const name = codegen.generateImportName();\n codegen.addNamedImport([`default as ${name}`], specifier);\n records += `\"${slash(file)}\": ${name},`;\n }\n records += \"}\";\n codegen.push(\n `export const ${this.name} = dataStore<typeof Config, \"${this.name}\">(\"${this.name}\", \"${base}\", ${records});`,\n );\n }),\n );\n return entries;\n };\n}\n\nexport function dataCollection<Schema extends StandardSchemaV1 | undefined = undefined>(\n config: DataCollectionConfig<Schema>,\n) {\n return new DataCollection(config);\n}\n\nexport function yamlLoader(): LoaderConfig {\n const test = /\\.yaml(\\?.+?)?$/;\n\n return {\n id: \"yaml\",\n test,\n configureNext(nextConfig) {\n const loaderPath = \"fuma-content/collections/yaml/loader-webpack\";\n const loaderOptions = this.getLoaderOptions();\n\n return {\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n rules: {\n ...nextConfig.turbopack?.rules,\n \"*.yaml\": {\n loaders: [\n {\n loader: loaderPath,\n options: loaderOptions as unknown as TurbopackLoaderOptions,\n },\n ],\n as: \"*.js\",\n },\n },\n },\n webpack(config: Configuration, options) {\n config.module ||= {};\n config.module.rules ||= [];\n config.module.rules.push({\n test,\n enforce: \"pre\",\n use: [\n {\n loader: loaderPath,\n options: loaderOptions,\n },\n ],\n });\n\n return nextConfig.webpack?.(config, options) ?? config;\n },\n };\n },\n async createLoader() {\n const { createYamlLoader } = await import(\"./yaml/loader\");\n const core = this.core;\n return createYamlLoader({\n getCore: () => core,\n });\n },\n };\n}\n\nexport function jsonLoader(): LoaderConfig {\n const test = /\\.json(\\?.+?)?$/;\n\n return {\n id: \"json\",\n test,\n configureNext(nextConfig) {\n const loaderPath = \"fuma-content/collections/json/loader-webpack\";\n const loaderOptions = this.getLoaderOptions();\n\n return {\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n rules: {\n ...nextConfig.turbopack?.rules,\n \"*.json\": {\n loaders: [\n {\n loader: loaderPath,\n options: loaderOptions as unknown as TurbopackLoaderOptions,\n },\n ],\n as: \"*.json\",\n },\n },\n },\n webpack(config: Configuration, options) {\n config.module ||= {};\n config.module.rules ||= [];\n config.module.rules.push({\n test,\n enforce: \"pre\",\n use: [\n {\n loader: loaderPath,\n options: loaderOptions,\n },\n ],\n });\n\n return nextConfig.webpack?.(config, options) ?? config;\n },\n };\n },\n async createLoader(environment) {\n const { createJsonLoader } = await import(\"./json/loader\");\n const core = this.core;\n return createJsonLoader(\n {\n getCore: () => core,\n },\n environment === \"vite\" ? \"json\" : \"js\",\n );\n },\n };\n}\n"],"mappings":";;;;;;;AAiCA,IAAa,iBAAb,cAEU,qBAAqB;CAC7B;;;;CAIA,AAAS,SAAS,WAA+C;CACjE,cACE;CACF,eACE;CAEF,YAAY,EAAE,KAAK,OAAO,SAAS,iBAAiB,EAAE,EAAE,UAAwC;EAC9F,MAAMA,gBAA8C,EAClD,GAAG,eAAe,QACnB;AACD,MAAI,eAAe,SAAS,MAAO,eAAc,OAAO,YAAY;AACpE,MAAI,eAAe,SAAS,MAAO,eAAc,OAAO,YAAY;AAEpE,QAAM;GAAE;GAAK;GAAO,kBAAkB,OAAO,KAAK,cAAc;GAAE,CAAC;AACnE,OAAK,SAAS;AACd,OAAK,SAAS,MAAM,EAAE,MAAM,aAAa;AACvC,OAAI,CAAC,OAAO,QAAS;AAErB,UAAO,QAAQ,GAAG,OAAO,OAAO,OAAO,SAAS;AAC9C,QAAI,UAAU,YAAY,CAAC,KAAK,QAAQ,KAAK,CAAE;AAE/C,UAAM,KAAK,KAAK;KACd,mBAAmB,eAAe,eAAe;KACjD,uBAAuB;KACvB,OAAO;KACR,CAAC;KACF;IACF;AACF,OAAK,OAAO,KAAK,MAAKC,cAAe,KAAK,KAAK,CAAC;AAChD,OAAK,WAAW,WAAW,CAAC,QAAQ,KAAK,GAAG,O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,QAAuB,SAAS;AACtC,YAAO,WAAW,EAAE;AACpB,YAAO,OAAO,UAAU,EAAE;AAC1B,YAAO,OAAO,MAAM,KAAK;MACvB;MACA,SAAS;MACT,KAAK,CACH;OACE,QAAQ;OACR,SAAS;OACV,CACF;MACF,CAAC;AAEF,YAAO,WAAW,UAAU,QAAQ,QAAQ,IAAI;;IAEnD;;EAEH,MAAM,eAAe;GACnB,MAAM,EAAE,qBAAqB,MAAM,OAAO;GAC1C,MAAM,OAAO,KAAK;AAClB,UAAO,iBAAiB,EACtB,eAAe,MAChB,CAAC;;EAEL;;AAGH,SAAgB,aAA2B;CACzC,MAAM,OAAO;AAEb,QAAO;EACL,IAAI;EACJ;EACA,cAAc,YAAY;GACxB,MAAM,aAAa;GACnB,MAAM,gBAAgB,KAAK,kBAAkB;AAE7C,UAAO;IACL,GAAG;IACH,WAAW;KACT,GAAG,WAAW;KACd,OAAO;MACL,GAAG,WAAW,WAAW;MACzB,UAAU;OACR,SAAS,CACP;QACE,QAAQ;QACR,SAAS;QACV,CACF;OACD,IAAI;OACL;MACF;KACF;IACD,QAAQ,QAAuB,SAAS;AACtC,YAAO,WAAW,EAAE;AACpB,YAAO,OAAO,UAAU,EAAE;AAC1B,YAAO,OAAO,MAAM,KAAK;MACvB;MACA,SAAS;MACT,KAAK,CACH;OACE,QAAQ;OACR,SAAS;OACV,CACF;MACF,CAAC;AAEF,YAAO,WAAW,UAAU,QAAQ,QAAQ,IAAI;;IAEnD;;EAEH,MAAM,aAAa,aAAa;GAC9B,MAAM,EAAE,qBAAqB,MAAM,OAAO;GAC1C,MAAM,OAAO,KAAK;AAClB,UAAO,iBACL,EACE,eAAe,MAChB,EACD,gBAAgB,SAAS,SAAS,KACnC;;EAEJ"}
@@ -1,33 +0,0 @@
1
- import { t as Core } from "./core-CT06v32N.js";
2
-
3
- //#region src/config/load-from-file.d.ts
4
-
5
- /**
6
- * - `true`: compile the config before loading.
7
- * - `false`: import the config directly (without compiling it).
8
- * - `skip`: assume the config is already compiled.
9
- */
10
- type CompileMode = boolean | "skip";
11
- //#endregion
12
- //#region src/dynamic.d.ts
13
- interface DynamicCore {
14
- getCore(): Core | Promise<Core>;
15
- }
16
- declare function createDynamicCore({
17
- core,
18
- compileMode,
19
- mode
20
- }: {
21
- /**
22
- * core (not initialized)
23
- */
24
- core: Core;
25
- compileMode?: CompileMode;
26
- /**
27
- * In dev mode, the config file is dynamically re-loaded when it's updated.
28
- */
29
- mode: "dev" | "production";
30
- }): DynamicCore;
31
- //#endregion
32
- export { createDynamicCore as n, DynamicCore as t };
33
- //# sourceMappingURL=dynamic-Ck1wYoaL.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dynamic-Ck1wYoaL.d.ts","names":[],"sources":["../src/config/load-from-file.ts","../src/dynamic.ts"],"sourcesContent":[],"mappings":";;;;;;AAQA;;;KAAY,WAAA;;;UCJK,WAAA;EDIL,OAAA,EAAA,ECHC,IDGU,GCHH,ODGG,CCHK,IDGL,CAAA;;iBCAP,iBAAA;;;;;;AAJhB;;EAC4B,IAAA,EAWpB,IAXoB;EAAR,WAAA,CAAA,EAYJ,WAZI;EAAO;AAG3B;;EAEE,IAAA,EAAA,KAAA,GAAA,YAAA;CACA,CAAA,EAWE,WAXF"}
@@ -1,29 +0,0 @@
1
- import fs from "node:fs/promises";
2
-
3
- //#region src/dynamic.ts
4
- function createDynamicCore({ core, compileMode = true, mode }) {
5
- let prev;
6
- async function getConfigHash() {
7
- if (mode === "production") return "static";
8
- return (await fs.stat(core.getOptions().configPath).catch(() => {
9
- throw new Error("Cannot find config file");
10
- })).mtime.getTime().toString();
11
- }
12
- async function init() {
13
- const { loadConfig } = await import("./load-from-file-D-Xm95Fz.js");
14
- await core.init({ config: loadConfig(core, compileMode) });
15
- }
16
- return { async getCore() {
17
- const hash = await getConfigHash();
18
- if (!prev || hash !== prev.hash) prev = {
19
- hash,
20
- init: init()
21
- };
22
- await prev.init;
23
- return core;
24
- } };
25
- }
26
-
27
- //#endregion
28
- export { createDynamicCore as t };
29
- //# sourceMappingURL=dynamic-CtOB4Rkp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dynamic-CtOB4Rkp.js","names":["prev:\n | {\n hash: string;\n init: Promise<void>;\n }\n | undefined"],"sources":["../src/dynamic.ts"],"sourcesContent":["import type { Core } from \"@/core\";\nimport fs from \"node:fs/promises\";\nimport type { CompileMode } from \"./config/load-from-file\";\n\nexport interface DynamicCore {\n getCore(): Core | Promise<Core>;\n}\n\nexport function createDynamicCore({\n core,\n compileMode = true,\n mode,\n}: {\n /**\n * core (not initialized)\n */\n core: Core;\n compileMode?: CompileMode;\n /**\n * In dev mode, the config file is dynamically re-loaded when it's updated.\n */\n mode: \"dev\" | \"production\";\n}): DynamicCore {\n let prev:\n | {\n hash: string;\n init: Promise<void>;\n }\n | undefined;\n\n async function getConfigHash(): Promise<string> {\n if (mode === \"production\") return \"static\";\n\n const stats = await fs.stat(core.getOptions().configPath).catch(() => {\n throw new Error(\"Cannot find config file\");\n });\n\n return stats.mtime.getTime().toString();\n }\n\n async function init() {\n const { loadConfig } = await import(\"./config/load-from-file\");\n await core.init({\n config: loadConfig(core, compileMode),\n });\n }\n\n return {\n async getCore() {\n const hash = await getConfigHash();\n if (!prev || hash !== prev.hash) {\n prev = {\n hash,\n init: init(),\n };\n }\n\n await prev.init;\n return core;\n },\n };\n}\n"],"mappings":";;;AAQA,SAAgB,kBAAkB,EAChC,MACA,cAAc,MACd,QAWc;CACd,IAAIA;CAOJ,eAAe,gBAAiC;AAC9C,MAAI,SAAS,aAAc,QAAO;AAMlC,UAJc,MAAM,GAAG,KAAK,KAAK,YAAY,CAAC,WAAW,CAAC,YAAY;AACpE,SAAM,IAAI,MAAM,0BAA0B;IAC1C,EAEW,MAAM,SAAS,CAAC,UAAU;;CAGzC,eAAe,OAAO;EACpB,MAAM,EAAE,eAAe,MAAM,OAAO;AACpC,QAAM,KAAK,KAAK,EACd,QAAQ,WAAW,MAAM,YAAY,EACtC,CAAC;;AAGJ,QAAO,EACL,MAAM,UAAU;EACd,MAAM,OAAO,MAAM,eAAe;AAClC,MAAI,CAAC,QAAQ,SAAS,KAAK,KACzB,QAAO;GACL;GACA,MAAM,MAAM;GACb;AAGH,QAAM,KAAK;AACX,SAAO;IAEV"}
@@ -1,20 +0,0 @@
1
- import { n as MapCollectionStore } from "./store-D_PPrdRE.js";
2
-
3
- //#region src/collections/runtime/file-store.d.ts
4
- interface FileInfo {
5
- /**
6
- * path relative to content directory
7
- */
8
- path: string;
9
- /**
10
- * the full file path in file system
11
- */
12
- fullPath: string;
13
- }
14
- declare class FileCollectionStore<V> extends MapCollectionStore<string, FileInfo & V> {
15
- constructor(base: string, glob: Record<string, V>);
16
- castData<T>(_cast: (input: FileInfo & V) => FileInfo & T): FileCollectionStore<T>;
17
- }
18
- //#endregion
19
- export { FileInfo as n, FileCollectionStore as t };
20
- //# sourceMappingURL=file-store-Dm1SjuLg.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-store-Dm1SjuLg.d.ts","names":[],"sources":["../src/collections/runtime/file-store.ts"],"sourcesContent":[],"mappings":";;;UAGiB,QAAA;;AAAjB;AAoBA;EAAuE,IAAA,EAAA,MAAA;EAAW;;;EAcrD,QAAA,EAAA,MAAA;;AAAiB,cAdjC,mBAciC,CAAA,CAAA,CAAA,SAdF,kBAcE,CAAA,MAAA,EAdyB,QAczB,GAdoC,CAcpC,CAAA,CAAA;EAAW,WAAA,CAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAbvB,MAauB,CAAA,MAAA,EAbR,CAaQ,CAAA;EAAwB,QAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EAAA,CAAA,KAAA,EAApD,QAAoD,GAAzC,CAAyC,EAAA,GAAnC,QAAmC,GAAxB,CAAwB,CAAA,EAApB,mBAAoB,CAAA,CAAA,CAAA"}
@@ -1,68 +0,0 @@
1
- import { t as Collection } from "./collections-CNWuMDAZ.js";
2
- import { t as createCache } from "./async-cache-U87GzQTb.js";
3
- import path from "node:path";
4
- import picomatch from "picomatch";
5
-
6
- //#region src/collections/fs.ts
7
- var FileSystemCollection = class extends Collection {
8
- matcher;
9
- /**
10
- * content directory (absolute)
11
- */
12
- dir;
13
- filesCache = createCache();
14
- /** the glob patterns to match files in collection, this doesn't take `supportedFormats` into account. */
15
- patterns;
16
- supportedFileFormats;
17
- constructor(config) {
18
- super();
19
- const { files, supportedFormats } = config;
20
- this.dir = config.dir;
21
- this.patterns = files ?? [supportedFormats ? `**/*.{${supportedFormats.join(",")}}` : `**/*`];
22
- this.supportedFileFormats = supportedFormats;
23
- this.onInit.hook(this.#onInitHandler.bind(this));
24
- this.onServer.hook(this.#onServerHandler.bind(this));
25
- }
26
- #onInitHandler = ({ core }) => {
27
- this.dir = path.resolve(core.getOptions().cwd, this.dir);
28
- };
29
- #onServerHandler = ({ server }) => {
30
- if (!server.watcher) return;
31
- server.watcher.add(this.dir);
32
- server.watcher.on("all", (event, file) => {
33
- if (event === "change" || !this.hasFile(file)) return;
34
- this.filesCache.invalidate("");
35
- });
36
- };
37
- isFileSupported(filePath) {
38
- if (!this.supportedFileFormats) return true;
39
- return this.supportedFileFormats.some((format) => filePath.endsWith(`.${format}`));
40
- }
41
- /**
42
- * get all included files, relative to `dir`.
43
- *
44
- * the result is cached.
45
- */
46
- async getFiles() {
47
- return this.filesCache.cached("", async () => {
48
- const { glob } = await import("tinyglobby");
49
- return (await glob(this.patterns, { cwd: this.dir })).filter((v) => this.isFileSupported(v));
50
- });
51
- }
52
- hasFile(filePath) {
53
- if (!this.isFileSupported(filePath)) return false;
54
- const relativePath = path.relative(this.dir, filePath);
55
- if (relativePath.startsWith(`..${path.sep}`)) return false;
56
- return (this.matcher ??= picomatch(this.patterns))(relativePath);
57
- }
58
- invalidateCache() {
59
- this.filesCache.invalidate("");
60
- }
61
- };
62
- function fileSystemCollection(config) {
63
- return new FileSystemCollection(config);
64
- }
65
-
66
- //#endregion
67
- export { fileSystemCollection as n, FileSystemCollection as t };
68
- //# sourceMappingURL=fs-CXzVd2Dp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fs-CXzVd2Dp.js","names":["#onInitHandler","#onServerHandler"],"sources":["../src/collections/fs.ts"],"sourcesContent":["import picomatch from \"picomatch\";\nimport path from \"node:path\";\nimport { Collection } from \".\";\nimport { createCache } from \"@/utils/async-cache\";\n\nexport class FileSystemCollection extends Collection {\n private matcher: picomatch.Matcher | undefined;\n /**\n * content directory (absolute)\n */\n dir: string;\n private readonly filesCache = createCache<string[]>();\n /** the glob patterns to match files in collection, this doesn't take `supportedFormats` into account. */\n private readonly patterns: string[];\n readonly supportedFileFormats: string[] | undefined;\n\n constructor(config: FileSystemCollectionConfig) {\n super();\n const { files, supportedFormats } = config;\n this.dir = config.dir;\n this.patterns = files ?? [supportedFormats ? `**/*.{${supportedFormats.join(\",\")}}` : `**/*`];\n this.supportedFileFormats = supportedFormats;\n this.onInit.hook(this.#onInitHandler.bind(this));\n this.onServer.hook(this.#onServerHandler.bind(this));\n }\n\n #onInitHandler: (typeof this.onInit)[\"$inferHandler\"] = ({ core }) => {\n this.dir = path.resolve(core.getOptions().cwd, this.dir);\n };\n\n #onServerHandler: (typeof this.onServer)[\"$inferHandler\"] = ({ server }) => {\n if (!server.watcher) return;\n server.watcher.add(this.dir);\n server.watcher.on(\"all\", (event, file) => {\n if (event === \"change\" || !this.hasFile(file)) return;\n this.filesCache.invalidate(\"\");\n });\n };\n\n isFileSupported(filePath: string) {\n if (!this.supportedFileFormats) return true;\n return this.supportedFileFormats.some((format) => filePath.endsWith(`.${format}`));\n }\n\n /**\n * get all included files, relative to `dir`.\n *\n * the result is cached.\n */\n async getFiles() {\n return this.filesCache.cached(\"\", async () => {\n const { glob } = await import(\"tinyglobby\");\n\n const out = await glob(this.patterns, { cwd: this.dir });\n return out.filter((v) => this.isFileSupported(v));\n });\n }\n\n hasFile(filePath: string) {\n if (!this.isFileSupported(filePath)) return false;\n\n const relativePath = path.relative(this.dir, filePath);\n if (relativePath.startsWith(`..${path.sep}`)) return false;\n\n return (this.matcher ??= picomatch(this.patterns))(relativePath);\n }\n\n invalidateCache() {\n this.filesCache.invalidate(\"\");\n }\n}\n\nexport interface FileSystemCollectionConfig {\n /**\n * Directory to scan\n */\n dir: string;\n\n /**\n * what files to include/exclude (glob patterns)\n *\n * Include all files if not specified\n */\n files?: string[];\n\n /**\n * Restrict to a list of file extensions to include, e.g. `['js', 'ts']`.\n */\n supportedFormats?: string[];\n}\n\nexport function fileSystemCollection(config: FileSystemCollectionConfig) {\n return new FileSystemCollection(config);\n}\n"],"mappings":";;;;;;AAKA,IAAa,uBAAb,cAA0C,WAAW;CACnD,AAAQ;;;;CAIR;CACA,AAAiB,aAAa,aAAuB;;CAErD,AAAiB;CACjB,AAAS;CAET,YAAY,QAAoC;AAC9C,SAAO;EACP,MAAM,EAAE,OAAO,qBAAqB;AACpC,OAAK,MAAM,OAAO;AAClB,OAAK,WAAW,SAAS,CAAC,mBAAmB,SAAS,iBAAiB,KAAK,IAAI,CAAC,KAAK,OAAO;AAC7F,OAAK,uBAAuB;AAC5B,OAAK,OAAO,KAAK,MAAKA,cAAe,KAAK,KAAK,CAAC;AAChD,OAAK,SAAS,KAAK,MAAKC,gBAAiB,KAAK,KAAK,CAAC;;CAGtD,kBAAyD,EAAE,WAAW;AACpE,OAAK,MAAM,KAAK,QAAQ,KAAK,YAAY,CAAC,KAAK,KAAK,IAAI;;CAG1D,oBAA6D,EAAE,aAAa;AAC1E,MAAI,CAAC,OAAO,QAAS;AACrB,SAAO,QAAQ,IAAI,KAAK,IAAI;AAC5B,SAAO,QAAQ,GAAG,QAAQ,OAAO,SAAS;AACxC,OAAI,UAAU,YAAY,CAAC,KAAK,QAAQ,KAAK,CAAE;AAC/C,QAAK,WAAW,WAAW,GAAG;IAC9B;;CAGJ,gBAAgB,UAAkB;AAChC,MAAI,CAAC,KAAK,qBAAsB,QAAO;AACvC,SAAO,KAAK,qBAAqB,MAAM,WAAW,SAAS,SAAS,IAAI,SAAS,CAAC;;;;;;;CAQpF,MAAM,WAAW;AACf,SAAO,KAAK,WAAW,OAAO,IAAI,YAAY;GAC5C,MAAM,EAAE,SAAS,MAAM,OAAO;AAG9B,WADY,MAAM,KAAK,KAAK,UAAU,EAAE,KAAK,KAAK,KAAK,CAAC,EAC7C,QAAQ,MAAM,KAAK,gBAAgB,EAAE,CAAC;IACjD;;CAGJ,QAAQ,UAAkB;AACxB,MAAI,CAAC,KAAK,gBAAgB,SAAS,CAAE,QAAO;EAE5C,MAAM,eAAe,KAAK,SAAS,KAAK,KAAK,SAAS;AACtD,MAAI,aAAa,WAAW,KAAK,KAAK,MAAM,CAAE,QAAO;AAErD,UAAQ,KAAK,YAAY,UAAU,KAAK,SAAS,EAAE,aAAa;;CAGlE,kBAAkB;AAChB,OAAK,WAAW,WAAW,GAAG;;;AAuBlC,SAAgB,qBAAqB,QAAoC;AACvE,QAAO,IAAI,qBAAqB,OAAO"}
@@ -1,45 +0,0 @@
1
- import { m as Collection } from "./core-CT06v32N.js";
2
-
3
- //#region src/collections/fs.d.ts
4
- declare class FileSystemCollection extends Collection {
5
- #private;
6
- private matcher;
7
- /**
8
- * content directory (absolute)
9
- */
10
- dir: string;
11
- private readonly filesCache;
12
- /** the glob patterns to match files in collection, this doesn't take `supportedFormats` into account. */
13
- private readonly patterns;
14
- readonly supportedFileFormats: string[] | undefined;
15
- constructor(config: FileSystemCollectionConfig);
16
- isFileSupported(filePath: string): boolean;
17
- /**
18
- * get all included files, relative to `dir`.
19
- *
20
- * the result is cached.
21
- */
22
- getFiles(): Promise<string[]>;
23
- hasFile(filePath: string): boolean;
24
- invalidateCache(): void;
25
- }
26
- interface FileSystemCollectionConfig {
27
- /**
28
- * Directory to scan
29
- */
30
- dir: string;
31
- /**
32
- * what files to include/exclude (glob patterns)
33
- *
34
- * Include all files if not specified
35
- */
36
- files?: string[];
37
- /**
38
- * Restrict to a list of file extensions to include, e.g. `['js', 'ts']`.
39
- */
40
- supportedFormats?: string[];
41
- }
42
- declare function fileSystemCollection(config: FileSystemCollectionConfig): FileSystemCollection;
43
- //#endregion
44
- export { FileSystemCollectionConfig as n, fileSystemCollection as r, FileSystemCollection as t };
45
- //# sourceMappingURL=fs-CmwaaFyx.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fs-CmwaaFyx.d.ts","names":[],"sources":["../src/collections/fs.ts"],"sourcesContent":[],"mappings":";;;cAKa,oBAAA,SAA6B,UAAA;;EAA7B,QAAA,OAAA;EAWS;;;EAX8B,GAAA,EAAA,MAAA;EAmEnC,iBAAA,UAAA;EAmBD;;;sBA3EM;;;;;;;cAiCN;;;;UAuBC,0BAAA;;;;;;;;;;;;;;;;iBAmBD,oBAAA,SAA6B,6BAA0B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"fuma-matter-BuBO2w-p.js","names":["output: Output"],"sources":["../src/collections/mdx/fuma-matter.ts"],"sourcesContent":["/**\n * Inspired by https://github.com/jonschlinkert/gray-matter\n */\nimport { load } from \"js-yaml\";\n\ninterface Output {\n /**\n * The matter section, including the delimiter.\n */\n matter: string;\n content: string;\n data: unknown;\n}\n\nconst regex = /^---\\r?\\n(.+?)\\r?\\n---\\r?\\n/s;\n\n/**\n * parse frontmatter, it supports only yaml format\n */\nexport function fumaMatter(input: string): Output {\n const output: Output = { matter: \"\", data: {}, content: input };\n const match = regex.exec(input);\n if (!match) {\n return output;\n }\n\n // get the raw front-matter block\n output.matter = match[0];\n output.content = input.slice(match[0].length);\n\n const loaded = load(match[1]);\n output.data = loaded ?? {};\n\n return output;\n}\n"],"mappings":";;;;;;AAcA,MAAM,QAAQ;;;;AAKd,SAAgB,WAAW,OAAuB;CAChD,MAAMA,SAAiB;EAAE,QAAQ;EAAI,MAAM,EAAE;EAAE,SAAS;EAAO;CAC/D,MAAM,QAAQ,MAAM,KAAK,MAAM;AAC/B,KAAI,CAAC,MACH,QAAO;AAIT,QAAO,SAAS,MAAM;AACtB,QAAO,UAAU,MAAM,MAAM,MAAM,GAAG,OAAO;AAG7C,QAAO,OADQ,KAAK,MAAM,GAAG,IACL,EAAE;AAE1B,QAAO"}
@@ -1,60 +0,0 @@
1
- import { a as asyncHook, n as defineCollectionHook } from "./collections-CNWuMDAZ.js";
2
- import { t as createCache } from "./async-cache-U87GzQTb.js";
3
- import path from "node:path";
4
- import { x } from "tinyexec";
5
-
6
- //#region src/plugins/git.ts
7
- const gitHook = defineCollectionHook(() => ({ onClient: asyncHook() }));
8
- /**
9
- * Add version control integration for Git.
10
- * 1. Injects `creationDate` & `lastModified` properties to page exports.
11
- *
12
- * @remarks If you are using Vercel, please set `VERCEL_DEEP_CLONE` environment variable to `true`. This ensures the client can access the full commit history of Git.
13
- */
14
- function git() {
15
- let client;
16
- return {
17
- name: "git",
18
- config() {
19
- const { cwd } = this.core.getOptions();
20
- client = createGitClient(cwd);
21
- },
22
- async collection(collection) {
23
- await collection.getPluginHook(gitHook)?.onClient.run({ client });
24
- }
25
- };
26
- }
27
- function createGitClient(cwd) {
28
- const cache = createCache();
29
- function mapDate(out) {
30
- if (out.exitCode !== 0) return null;
31
- const date = new Date(out.stdout);
32
- return Number.isNaN(date.getTime()) ? null : date;
33
- }
34
- return { async getFileData({ filePath }) {
35
- return cache.cached(filePath, async () => {
36
- const relativePath = path.relative(cwd, filePath);
37
- const [mod, create] = await Promise.all([x("git", [
38
- "log",
39
- "-1",
40
- "--pretty=%ai",
41
- relativePath
42
- ], { nodeOptions: { cwd } }), x("git", [
43
- "log",
44
- "--diff-filter=A",
45
- "--follow",
46
- "--format=%ai",
47
- "-1",
48
- relativePath
49
- ], { nodeOptions: { cwd } })]);
50
- return {
51
- lastModified: mapDate(mod),
52
- creationDate: mapDate(create)
53
- };
54
- });
55
- } };
56
- }
57
-
58
- //#endregion
59
- export { gitHook as n, git as t };
60
- //# sourceMappingURL=git-DnejL9r_.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git-DnejL9r_.js","names":["client: GitClient"],"sources":["../src/plugins/git.ts"],"sourcesContent":["import path from \"node:path\";\nimport { type Output, x } from \"tinyexec\";\nimport type { Plugin } from \"@/core\";\nimport { createCache } from \"@/utils/async-cache\";\nimport { defineCollectionHook } from \"@/collections\";\nimport { asyncHook, AsyncHook } from \"@/utils/hook\";\n\nexport interface GitFileData {\n /**\n * Last modified date of file, obtained from version control.\n */\n lastModified: Date | null;\n /**\n * Creation date of file, obtained from version control.\n */\n creationDate: Date | null;\n}\n\nexport interface GitHook {\n /**\n * receive the client.\n */\n onClient: AsyncHook<{ client: GitClient }>;\n}\n\nexport const gitHook = defineCollectionHook<GitHook>(() => ({\n onClient: asyncHook(),\n}));\n\n/**\n * Add version control integration for Git.\n * 1. Injects `creationDate` & `lastModified` properties to page exports.\n *\n * @remarks If you are using Vercel, please set `VERCEL_DEEP_CLONE` environment variable to `true`. This ensures the client can access the full commit history of Git.\n */\nexport default function git(): Plugin {\n let client: GitClient;\n\n return {\n name: \"git\",\n config() {\n const { cwd } = this.core.getOptions();\n client = createGitClient(cwd);\n },\n async collection(collection) {\n await collection.getPluginHook(gitHook)?.onClient.run({ client });\n },\n };\n}\n\nexport interface GitClient {\n getFileData: (options: { filePath: string }) => Promise<GitFileData>;\n}\n\nfunction createGitClient(cwd: string): GitClient {\n const cache = createCache<GitFileData>();\n\n function mapDate(out: Output): Date | null {\n if (out.exitCode !== 0) return null;\n const date = new Date(out.stdout);\n return Number.isNaN(date.getTime()) ? null : date;\n }\n\n return {\n async getFileData({ filePath }) {\n return cache.cached(filePath, async () => {\n const relativePath = path.relative(cwd, filePath);\n const [mod, create] = await Promise.all([\n x(\"git\", [\"log\", \"-1\", \"--pretty=%ai\", relativePath], {\n nodeOptions: {\n cwd,\n },\n }),\n x(\"git\", [\"log\", \"--diff-filter=A\", \"--follow\", \"--format=%ai\", \"-1\", relativePath], {\n nodeOptions: {\n cwd,\n },\n }),\n ]);\n\n return {\n lastModified: mapDate(mod),\n creationDate: mapDate(create),\n };\n });\n },\n };\n}\n"],"mappings":";;;;;;AAyBA,MAAa,UAAU,4BAAqC,EAC1D,UAAU,WAAW,EACtB,EAAE;;;;;;;AAQH,SAAwB,MAAc;CACpC,IAAIA;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP,MAAM,EAAE,QAAQ,KAAK,KAAK,YAAY;AACtC,YAAS,gBAAgB,IAAI;;EAE/B,MAAM,WAAW,YAAY;AAC3B,SAAM,WAAW,cAAc,QAAQ,EAAE,SAAS,IAAI,EAAE,QAAQ,CAAC;;EAEpE;;AAOH,SAAS,gBAAgB,KAAwB;CAC/C,MAAM,QAAQ,aAA0B;CAExC,SAAS,QAAQ,KAA0B;AACzC,MAAI,IAAI,aAAa,EAAG,QAAO;EAC/B,MAAM,OAAO,IAAI,KAAK,IAAI,OAAO;AACjC,SAAO,OAAO,MAAM,KAAK,SAAS,CAAC,GAAG,OAAO;;AAG/C,QAAO,EACL,MAAM,YAAY,EAAE,YAAY;AAC9B,SAAO,MAAM,OAAO,UAAU,YAAY;GACxC,MAAM,eAAe,KAAK,SAAS,KAAK,SAAS;GACjD,MAAM,CAAC,KAAK,UAAU,MAAM,QAAQ,IAAI,CACtC,EAAE,OAAO;IAAC;IAAO;IAAM;IAAgB;IAAa,EAAE,EACpD,aAAa,EACX,KACD,EACF,CAAC,EACF,EAAE,OAAO;IAAC;IAAO;IAAmB;IAAY;IAAgB;IAAM;IAAa,EAAE,EACnF,aAAa,EACX,KACD,EACF,CAAC,CACH,CAAC;AAEF,UAAO;IACL,cAAc,QAAQ,IAAI;IAC1B,cAAc,QAAQ,OAAO;IAC9B;IACD;IAEL"}
@@ -1,37 +0,0 @@
1
- import { S as AsyncHook, h as CollectionHook, s as Plugin } from "./core-CT06v32N.js";
2
-
3
- //#region src/plugins/git.d.ts
4
- interface GitFileData {
5
- /**
6
- * Last modified date of file, obtained from version control.
7
- */
8
- lastModified: Date | null;
9
- /**
10
- * Creation date of file, obtained from version control.
11
- */
12
- creationDate: Date | null;
13
- }
14
- interface GitHook {
15
- /**
16
- * receive the client.
17
- */
18
- onClient: AsyncHook<{
19
- client: GitClient;
20
- }>;
21
- }
22
- declare const gitHook: CollectionHook<GitHook, undefined>;
23
- /**
24
- * Add version control integration for Git.
25
- * 1. Injects `creationDate` & `lastModified` properties to page exports.
26
- *
27
- * @remarks If you are using Vercel, please set `VERCEL_DEEP_CLONE` environment variable to `true`. This ensures the client can access the full commit history of Git.
28
- */
29
- declare function git(): Plugin;
30
- interface GitClient {
31
- getFileData: (options: {
32
- filePath: string;
33
- }) => Promise<GitFileData>;
34
- }
35
- //#endregion
36
- export { gitHook as a, git as i, GitFileData as n, GitHook as r, GitClient as t };
37
- //# sourceMappingURL=git-n-9ddn78.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git-n-9ddn78.d.ts","names":[],"sources":["../src/plugins/git.ts"],"sourcesContent":[],"mappings":";;;UAOiB,WAAA;EAAA;AAWjB;AAOA;EAUwB,YAAG,EAxBX,IAwBe,GAAA,IAAM;EAepB;;;gBAnCD;;UAGC,OAAA;;;;YAIL;YAAoB;;;cAGnB,SAAO,eAAA;;;;;;;iBAUI,GAAA,CAAA,GAAO;UAed,SAAA;;;QACiC,QAAQ"}
@@ -1,87 +0,0 @@
1
- import { c as PluginContext, h as CollectionHook, s as Plugin } from "./core-CT06v32N.js";
2
- import { t as DynamicCore } from "./dynamic-Ck1wYoaL.js";
3
- import { NextConfig } from "next";
4
- import { LoaderContext } from "webpack";
5
-
6
- //#region src/plugins/loader/webpack.d.ts
7
- interface WebpackLoaderOptions {
8
- absoluteCompiledConfigPath: string;
9
- configPath: string;
10
- outDir: string;
11
- isDev: boolean;
12
- }
13
- type WebpackLoader = (this: LoaderContext<WebpackLoaderOptions>, source: string) => void;
14
- /**
15
- * Note: need to handle the `test` regex in Webpack config instead.
16
- */
17
- declare function createWebpackLoader(loaderFactory: (core: DynamicCore) => Loader): WebpackLoader;
18
- //#endregion
19
- //#region src/plugins/loader/index.d.ts
20
- type Awaitable<T> = T | Promise<T>;
21
- interface CompilerOptions {
22
- addDependency: (file: string) => void;
23
- }
24
- type LoaderEnvironment = "vite" | "bun" | "node";
25
- interface Loader {
26
- /**
27
- * Transform input into JavaScript.
28
- *
29
- * Returns:
30
- * - `LoaderOutput`: JavaScript code & source map.
31
- * - `null`: skip the loader. Fallback to default behaviour if possible, otherwise the adapter will try workarounds.
32
- */
33
- load: (input: LoaderInput) => Awaitable<LoaderOutput | null>;
34
- bun?: {
35
- /**
36
- * 1. Bun doesn't allow `null` in loaders.
37
- * 2. Bun requires sync result to support dynamic require().
38
- */
39
- load?: (source: string, input: LoaderInput) => Awaitable<Bun.OnLoadResult>;
40
- };
41
- }
42
- interface LoaderInput {
43
- development: boolean;
44
- compiler: CompilerOptions;
45
- filePath: string;
46
- query: Record<string, string | string[] | undefined>;
47
- getSource: () => string | Promise<string>;
48
- }
49
- interface LoaderOutput {
50
- code: string;
51
- map?: unknown;
52
- /**
53
- * only supported on Vite 8 at the moment, specify the output module type.
54
- *
55
- * on unsupported environments, it will be ignored.
56
- */
57
- moduleType?: "js" | "json";
58
- }
59
- interface NextLoaderContext extends PluginContext {
60
- getLoaderOptions: () => WebpackLoaderOptions;
61
- }
62
- interface LoaderConfig {
63
- /** unique ID for loader, used to deduplicate loaders */
64
- id?: string;
65
- /**
66
- * Filter file paths, the input can be either a file URL or file path.
67
- *
68
- * Must take resource query into consideration.
69
- */
70
- test?: RegExp;
71
- /**
72
- * @remarks it doesn't configure automatically for Next.js, you have to define the webpack/turbopack config in `configureNext()`.
73
- */
74
- createLoader: (this: PluginContext, environment: LoaderEnvironment) => Promise<Loader>;
75
- configureNext?: (this: NextLoaderContext, next: NextConfig) => NextConfig;
76
- }
77
- /**
78
- * a light layer for implementing loaders.
79
- */
80
- declare function loaderPlugin(): Plugin;
81
- interface LoaderHook {
82
- loaders: LoaderConfig[];
83
- }
84
- declare const loaderHook: CollectionHook<LoaderHook, undefined>;
85
- //#endregion
86
- export { LoaderInput as a, loaderPlugin as c, createWebpackLoader as d, LoaderHook as i, WebpackLoader as l, Loader as n, LoaderOutput as o, LoaderConfig as r, loaderHook as s, CompilerOptions as t, WebpackLoaderOptions as u };
87
- //# sourceMappingURL=index-BheUVWBm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-BheUVWBm.d.ts","names":[],"sources":["../src/plugins/loader/webpack.ts","../src/plugins/loader/index.ts"],"sourcesContent":[],"mappings":";;;;;;UAQiB,oBAAA;;;EAAA,MAAA,EAAA,MAAA;EAOL,KAAA,EAAA,OAAA;AAqBZ;AAA0D,KArB9C,aAAA,GAqB8C,CAAA,IAAA,EArBvB,aAqBuB,CArBT,oBAqBS,CAAA,EAAA,MAAA,EAAA,MAAA,EAAA,GAAA,IAAA;;;;iBAA1C,mBAAA,uBAA0C,gBAAgB,SAAS;;;KC7B9E,eAAe,IAAI,QAAQ;UAEf,eAAA;;ADDjB;AAOA,KCFK,iBAAA,GDEoB,MAAA,GAAwB,KAAA,GAAA,MAAA;AAqBjC,UCrBC,MAAA,CDqBD;EAA0C;;;;;;;EC7BrD,IAAA,EAAA,CAAA,KAAS,EAgBE,WAhBF,EAAA,GAgBkB,SAhBlB,CAgB4B,YAhB5B,GAAA,IAAA,CAAA;EAAM,GAAA,CAAA,EAAA;IAAY;;;AAEhC;IAIK,IAAA,CAAA,EAAA,CAAA,MAAA,EAAiB,MAAA,EAAA,KAAA,EAiBa,WAjBb,EAAA,GAiB6B,SAjB7B,CAiBuC,GAAA,CAAI,YAjB3C,CAAA;EAEL,CAAA;;AAQyB,UAWzB,WAAA,CAXyB;EAAV,WAAA,EAAA,OAAA;EAOG,QAAA,EAMvB,eANuB;EAA0B,QAAI,EAAA,MAAA;EAAd,KAAA,EAS1C,MAT0C,CAAA,MAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAAA,SAAA,CAAA;EAAS,SAAA,EAAA,GAAA,GAAA,MAAA,GAUhC,OAVgC,CAAA,MAAA,CAAA;AAI5D;AAEY,UAOK,YAAA,CAPL;EAGH,IAAA,EAAA,MAAA;EACmB,GAAA,CAAA,EAAA,OAAA;EAAO;AAGnC;AAUC;AAMD;;EAcuB,UAAA,CAAA,EAAA,IAAA,GAAA,MAAA;;UAlBb,iBAAA,SAA0B,aAkB6C,CAAA;EAAR,gBAAA,EAAA,GAAA,GAjB/C,oBAiB+C;;AACvB,UAfjC,YAAA,CAeiC;EAAe;EAAU,EAAA,CAAA,EAAA,MAAA;EAY3D;AAqFhB;AAIA;;;SA3GS;;;;uBAKc,4BAA4B,sBAAsB,QAAQ;yBACxD,yBAAyB,eAAe;;;;;iBAYjD,YAAA,CAAA,GAAgB;UAqFf,UAAA;WACN;;cAGE,YAAU,eAAA"}
@@ -1,3 +0,0 @@
1
- import { t as loadConfig } from "./load-from-file-z7EGuf2n.js";
2
-
3
- export { loadConfig };
@@ -1,77 +0,0 @@
1
- import { n as defineCollectionHook } from "./collections-CNWuMDAZ.js";
2
- import { t as createCache } from "./async-cache-U87GzQTb.js";
3
- import path from "node:path";
4
-
5
- //#region src/plugins/loader/index.ts
6
- /**
7
- * a light layer for implementing loaders.
8
- */
9
- function loaderPlugin() {
10
- const cachedLoaders = createCache();
11
- function initLoaders(ctx, env) {
12
- return cachedLoaders.cached(env, async () => {
13
- const usedIds = /* @__PURE__ */ new Set();
14
- const out = [];
15
- for (const collection of ctx.core.getCollections()) {
16
- const hook = collection.getPluginHook(loaderHook);
17
- if (!hook) continue;
18
- let nextId = 0;
19
- for (const loader of hook.loaders) {
20
- if (loader.id && usedIds.has(loader.id)) continue;
21
- if (loader.id) usedIds.add(loader.id);
22
- out.push({
23
- id: loader.id ?? `${collection.name}:${nextId++}`,
24
- test: loader.test,
25
- loader: await loader.createLoader.call(ctx, env)
26
- });
27
- }
28
- }
29
- return out;
30
- });
31
- }
32
- return {
33
- name: "fuma-content:loader",
34
- next: { config(config) {
35
- const ctx = {
36
- ...this,
37
- getLoaderOptions: () => {
38
- const { configPath, outDir } = this.core.getOptions();
39
- return {
40
- configPath,
41
- outDir,
42
- absoluteCompiledConfigPath: path.resolve(this.core.getCompiledConfigPath()),
43
- isDev: process.env.NODE_ENV === "development"
44
- };
45
- }
46
- };
47
- for (const collection of this.core.getCollections()) {
48
- const hook = collection.getPluginHook(loaderHook);
49
- if (!hook) continue;
50
- for (const loader of hook.loaders) {
51
- if (!loader.configureNext) continue;
52
- config = loader.configureNext.call(ctx, config);
53
- }
54
- }
55
- return config;
56
- } },
57
- bun: { async setup(build) {
58
- const { toBun } = await import("./bun-CBROq3I0.js");
59
- for (const loader of await initLoaders(this, "bun")) toBun(loader.test, loader.loader)(build);
60
- } },
61
- node: { async createLoad() {
62
- const { toNode } = await import("./node-2VZOh3P9.js");
63
- return toNode(await initLoaders(this, "node"));
64
- } },
65
- vite: { async createPlugin() {
66
- const { toVite } = await import("./vite-C1qXY47G.js");
67
- return (await initLoaders(this, "vite")).map((loader) => {
68
- return toVite(`fuma-content:${loader.id}`, loader.test, loader.loader);
69
- });
70
- } }
71
- };
72
- }
73
- const loaderHook = defineCollectionHook(() => ({ loaders: [] }));
74
-
75
- //#endregion
76
- export { loaderPlugin as n, loaderHook as t };
77
- //# sourceMappingURL=loader-B4nQrRwA.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loader-B4nQrRwA.js","names":["out: ResolvedLoader[]","ctx: NextLoaderContext"],"sources":["../src/plugins/loader/index.ts"],"sourcesContent":["import { defineCollectionHook } from \"@/collections\";\nimport type { Plugin, PluginContext } from \"@/core\";\nimport { createCache } from \"@/utils/async-cache\";\nimport { NextConfig } from \"next\";\nimport { WebpackLoaderOptions } from \"./webpack.js\";\nimport path from \"node:path\";\n\ntype Awaitable<T> = T | Promise<T>;\n\nexport interface CompilerOptions {\n addDependency: (file: string) => void;\n}\n\ntype LoaderEnvironment = \"vite\" | \"bun\" | \"node\";\n\nexport interface Loader {\n /**\n * Transform input into JavaScript.\n *\n * Returns:\n * - `LoaderOutput`: JavaScript code & source map.\n * - `null`: skip the loader. Fallback to default behaviour if possible, otherwise the adapter will try workarounds.\n */\n load: (input: LoaderInput) => Awaitable<LoaderOutput | null>;\n\n bun?: {\n /**\n * 1. Bun doesn't allow `null` in loaders.\n * 2. Bun requires sync result to support dynamic require().\n */\n load?: (source: string, input: LoaderInput) => Awaitable<Bun.OnLoadResult>;\n };\n}\n\nexport interface LoaderInput {\n development: boolean;\n compiler: CompilerOptions;\n\n filePath: string;\n query: Record<string, string | string[] | undefined>;\n getSource: () => string | Promise<string>;\n}\n\nexport interface LoaderOutput {\n code: string;\n map?: unknown;\n\n /**\n * only supported on Vite 8 at the moment, specify the output module type.\n *\n * on unsupported environments, it will be ignored.\n */\n moduleType?: \"js\" | \"json\";\n}\n\ninterface NextLoaderContext extends PluginContext {\n getLoaderOptions: () => WebpackLoaderOptions;\n}\n\nexport interface LoaderConfig {\n /** unique ID for loader, used to deduplicate loaders */\n id?: string;\n\n /**\n * Filter file paths, the input can be either a file URL or file path.\n *\n * Must take resource query into consideration.\n */\n test?: RegExp;\n\n /**\n * @remarks it doesn't configure automatically for Next.js, you have to define the webpack/turbopack config in `configureNext()`.\n */\n createLoader: (this: PluginContext, environment: LoaderEnvironment) => Promise<Loader>;\n configureNext?: (this: NextLoaderContext, next: NextConfig) => NextConfig;\n}\n\ninterface ResolvedLoader {\n id: string;\n test: RegExp | undefined;\n loader: Loader;\n}\n\n/**\n * a light layer for implementing loaders.\n */\nexport function loaderPlugin(): Plugin {\n // env -> loaders\n const cachedLoaders = createCache<ResolvedLoader[]>();\n\n function initLoaders(ctx: PluginContext, env: LoaderEnvironment) {\n return cachedLoaders.cached(env, async () => {\n const usedIds = new Set<string>();\n const out: ResolvedLoader[] = [];\n\n for (const collection of ctx.core.getCollections()) {\n const hook = collection.getPluginHook(loaderHook);\n if (!hook) continue;\n\n let nextId = 0;\n for (const loader of hook.loaders) {\n if (loader.id && usedIds.has(loader.id)) continue;\n if (loader.id) usedIds.add(loader.id);\n\n out.push({\n id: loader.id ?? `${collection.name}:${nextId++}`,\n test: loader.test,\n loader: await loader.createLoader.call(ctx, env),\n });\n }\n }\n return out;\n });\n }\n\n return {\n name: \"fuma-content:loader\",\n next: {\n config(config) {\n const ctx: NextLoaderContext = {\n ...this,\n getLoaderOptions: () => {\n const { configPath, outDir } = this.core.getOptions();\n return {\n configPath,\n outDir,\n absoluteCompiledConfigPath: path.resolve(this.core.getCompiledConfigPath()),\n isDev: process.env.NODE_ENV === \"development\",\n };\n },\n };\n for (const collection of this.core.getCollections()) {\n const hook = collection.getPluginHook(loaderHook);\n if (!hook) continue;\n\n for (const loader of hook.loaders) {\n if (!loader.configureNext) continue;\n\n config = loader.configureNext.call(ctx, config);\n }\n }\n\n return config;\n },\n },\n bun: {\n async setup(build) {\n const { toBun } = await import(\"./bun\");\n\n for (const loader of await initLoaders(this, \"bun\")) {\n toBun(loader.test, loader.loader)(build);\n }\n },\n },\n node: {\n async createLoad() {\n const { toNode } = await import(\"./node\");\n return toNode(await initLoaders(this, \"node\"));\n },\n },\n vite: {\n async createPlugin() {\n const { toVite } = await import(\"./vite\");\n return (await initLoaders(this, \"vite\")).map((loader) => {\n return toVite(`fuma-content:${loader.id}`, loader.test, loader.loader);\n });\n },\n },\n };\n}\n\nexport interface LoaderHook {\n loaders: LoaderConfig[];\n}\n\nexport const loaderHook = defineCollectionHook<LoaderHook>(() => ({\n loaders: [],\n}));\n"],"mappings":";;;;;;;;AAsFA,SAAgB,eAAuB;CAErC,MAAM,gBAAgB,aAA+B;CAErD,SAAS,YAAY,KAAoB,KAAwB;AAC/D,SAAO,cAAc,OAAO,KAAK,YAAY;GAC3C,MAAM,0BAAU,IAAI,KAAa;GACjC,MAAMA,MAAwB,EAAE;AAEhC,QAAK,MAAM,cAAc,IAAI,KAAK,gBAAgB,EAAE;IAClD,MAAM,OAAO,WAAW,cAAc,WAAW;AACjD,QAAI,CAAC,KAAM;IAEX,IAAI,SAAS;AACb,SAAK,MAAM,UAAU,KAAK,SAAS;AACjC,SAAI,OAAO,MAAM,QAAQ,IAAI,OAAO,GAAG,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Aa,aAAa,4BAAwC,EAChE,SAAS,EAAE,EACZ,EAAE"}
@@ -1,9 +0,0 @@
1
- import "./validation-BvVvvLII.js";
2
- import "./loader-B4nQrRwA.js";
3
- import "./fs-CXzVd2Dp.js";
4
- import "./git-DnejL9r_.js";
5
- import "./mdx-Cw1nBJ0D.js";
6
- import "./fuma-matter-BuBO2w-p.js";
7
- import { t as createMdxLoader } from "./loader-CnksfM7I.js";
8
-
9
- export { createMdxLoader };
@@ -1,16 +0,0 @@
1
- import { t as createDataLoader } from "./loader-CuntMmR4.js";
2
-
3
- //#region src/collections/json/loader.ts
4
- function createJsonLoader(core, resolveJson = "js") {
5
- return createDataLoader(core, (filePath, source) => {
6
- try {
7
- return JSON.parse(source);
8
- } catch (e) {
9
- throw new Error(`invalid data in ${filePath}`, { cause: e });
10
- }
11
- }, resolveJson);
12
- }
13
-
14
- //#endregion
15
- export { createJsonLoader as t };
16
- //# sourceMappingURL=loader-BK8PnqRg.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loader-CnksfM7I.js","names":["after: (() => Promise<void>) | undefined"],"sources":["../src/collections/mdx/loader.ts"],"sourcesContent":["import { fumaMatter } from \"@/collections/mdx/fuma-matter\";\nimport type { SourceMap } from \"rollup\";\nimport { z } from \"zod\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport type { Loader } from \"@/plugins/loader\";\nimport type { DynamicCore } from \"@/dynamic\";\nimport { MDXCollection } from \"../mdx\";\n\nconst querySchema = z\n .object({\n only: z.literal([\"frontmatter\", \"all\"]).default(\"all\"),\n collection: z.string().optional(),\n workspace: z.string().optional(),\n })\n .loose();\n\nconst cacheEntry = z.object({\n code: z.string(),\n map: z.any().optional(),\n hash: z.string().optional(),\n});\n\ntype CacheEntry = z.infer<typeof cacheEntry>;\n\nexport function createMdxLoader({ getCore }: DynamicCore): Loader {\n return {\n async load({ getSource, development: isDevelopment, query, compiler, filePath }) {\n let core = await getCore();\n const value = await getSource();\n const matter = fumaMatter(value);\n const { collection: collectionName, workspace, only } = querySchema.parse(query);\n if (workspace) {\n core = core.getWorkspaces().get(workspace) ?? core;\n }\n\n let after: (() => Promise<void>) | undefined;\n\n const { experimentalBuildCache = false } = core.getConfig();\n if (!isDevelopment && experimentalBuildCache) {\n const cacheDir = experimentalBuildCache;\n const cacheKey = `${collectionName ?? \"global\"}_${generateCacheHash(filePath)}`;\n\n const cached = await fs\n .readFile(path.join(cacheDir, cacheKey))\n .then((content) => cacheEntry.parse(JSON.parse(content.toString())))\n .catch(() => null);\n\n if (cached && cached.hash === generateCacheHash(value)) return cached;\n after = async () => {\n await fs.mkdir(cacheDir, { recursive: true });\n await fs.writeFile(\n path.join(cacheDir, cacheKey),\n JSON.stringify({\n ...out,\n hash: generateCacheHash(value),\n } satisfies CacheEntry),\n );\n };\n }\n\n let collection = collectionName ? core.getCollection(collectionName) : undefined;\n if (!(collection instanceof MDXCollection)) collection = undefined;\n\n if (collection?.frontmatter) {\n matter.data = await collection.frontmatter.run(matter.data as Record<string, unknown>, {\n collection,\n filePath,\n source: value,\n });\n }\n\n if (only === \"frontmatter\") {\n return {\n code: `export const frontmatter = ${JSON.stringify(matter.data)}`,\n map: null,\n };\n }\n\n // ensure the line number is correct in dev mode\n const lineOffset = isDevelopment ? countLines(matter.matter) : 0;\n\n const { buildMDX } = await import(\"@/collections/mdx/build-mdx\");\n const compiled = await buildMDX(core, collection, {\n isDevelopment,\n source: \"\\n\".repeat(lineOffset) + matter.content,\n filePath,\n frontmatter: matter.data as Record<string, unknown>,\n _compiler: compiler,\n environment: \"bundler\",\n });\n\n const out = {\n code: String(compiled.value),\n map: compiled.map as SourceMap,\n };\n\n await after?.();\n return out;\n },\n };\n}\n\nfunction generateCacheHash(input: string): string {\n return createHash(\"md5\").update(input).digest(\"hex\");\n}\n\nfunction countLines(s: string) {\n let num = 0;\n\n for (const c of s) {\n if (c === \"\\n\") num++;\n }\n\n return num;\n}\n"],"mappings":";;;;;;;;A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/B,CAAsB,CACxB;;;EAIL,IAAI,aAAa,iBAAiB,KAAK,cAAc,eAAe,GAAG;AACvE,MAAI,EAAE,sBAAsB,eAAgB,cAAa;AAEzD,MAAI,YAAY,YACd,QAAO,OAAO,MAAM,WAAW,YAAY,IAAI,OAAO,MAAiC;GACrF;GACA;GACA,QAAQ;GACT,CAAC;AAGJ,MAAI,SAAS,cACX,QAAO;GACL,MAAM,8BAA8B,KAAK,UAAU,OAAO,KAAK;GAC/D,KAAK;GACN;EAIH,MAAM,aAAa,gBAAgB,WAAW,OAAO,OAAO,GAAG;EAE/D,MAAM,EAAE,aAAa,MAAM,OAAO;EAClC,MAAM,WAAW,MAAM,SAAS,MAAM,YAAY;GAChD;GACA,QAAQ,KAAK,OAAO,WAAW,GAAG,OAAO;GACzC;GACA,aAAa,OAAO;GACpB,WAAW;GACX,aAAa;GACd,CAAC;EAEF,MAAM,MAAM;GACV,MAAM,OAAO,SAAS,MAAM;GAC5B,KAAK,SAAS;GACf;AAED,QAAM,SAAS;AACf,SAAO;IAEV;;AAGH,SAAS,kBAAkB,OAAuB;AAChD,QAAO,WAAW,MAAM,CAAC,OAAO,MAAM,CAAC,OAAO,MAAM;;AAGtD,SAAS,WAAW,GAAW;CAC7B,IAAI,MAAM;AAEV,MAAK,MAAM,KAAK,EACd,KAAI,MAAM,KAAM;AAGlB,QAAO"}
@@ -1,17 +0,0 @@
1
- import { t as createDataLoader } from "./loader-CuntMmR4.js";
2
- import { load } from "js-yaml";
3
-
4
- //#region src/collections/yaml/loader.ts
5
- function createYamlLoader(core) {
6
- return createDataLoader(core, (filePath, source) => {
7
- try {
8
- return load(source);
9
- } catch (e) {
10
- throw new Error(`invalid data in ${filePath}`, { cause: e });
11
- }
12
- });
13
- }
14
-
15
- //#endregion
16
- export { createYamlLoader as t };
17
- //# sourceMappingURL=loader-Cnz-VHne.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loader-CuntMmR4.js","names":["data: unknown","context: DataTransformationContext"],"sources":["../src/collections/data/loader.ts"],"sourcesContent":["import type { Loader, LoaderInput } from \"@/plugins/loader\";\nimport { z } from \"zod\";\nimport { validate } from \"@/utils/validation\";\nimport { DataCollection, type DataTransformationContext } from \"@/collections/data\";\nimport type { DynamicCore } from \"@/dynamic\";\n\nconst querySchema = z\n .object({\n collection: z.string().optional(),\n workspace: z.string().optional(),\n })\n .loose();\n\n/**\n * load data files, fallback to bundler's built-in plugins when ?collection is unspecified.\n */\nexport function createDataLoader(\n { getCore }: DynamicCore,\n parse: (filePath: string, source: string) => Record<string, unknown>,\n moduleType: \"json\" | \"js\" = \"js\",\n): Loader {\n function getCollectionProcessor({ filePath, query }: LoaderInput) {\n const parsed = querySchema.safeParse(query);\n if (!parsed.success || !parsed.data.collection) return null;\n const { collection: collectionName, workspace } = parsed.data;\n\n return async (source: string): Promise<unknown> => {\n let core = await getCore();\n if (workspace) {\n core = core.getWorkspaces().get(workspace) ?? core;\n }\n\n let collection = core.getCollection(collectionName);\n let data: unknown = parse(filePath, source);\n if (!collection || !(collection instanceof DataCollection)) return data;\n\n const context: DataTransformationContext = {\n path: filePath,\n source,\n };\n\n if (collection.schema) {\n data = await validate(collection.schema, data, context, `invalid data in ${filePath}`);\n }\n\n return collection.onLoad.run(data, context);\n };\n }\n\n return {\n async load(input) {\n const processor = getCollectionProcessor(input);\n if (processor === null) return null;\n const data = await processor(await input.getSource());\n\n if (moduleType === \"json\") {\n return {\n code: JSON.stringify(data),\n moduleType,\n };\n } else {\n return {\n code: `export default ${JSON.stringify(data)}`,\n };\n }\n },\n bun: {\n load(source, input) {\n const processor = getCollectionProcessor(input);\n if (processor === null)\n return {\n loader: \"object\",\n exports: parse(input.filePath, source),\n };\n\n return processor(source).then((data) => ({\n loader: \"object\",\n exports: { default: data },\n }));\n },\n },\n };\n}\n"],"mappings":";;;;;AAMA,MAAM,cAAc,EACjB,OAAO;CACN,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,WAAW,EAAE,QAAQ,CAAC,UAA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