fuma-content 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/dist/async-cache-CBEZB25o.d.ts +9 -0
  2. package/dist/async-cache-CBEZB25o.d.ts.map +1 -0
  3. package/dist/{async-cache-U87GzQTb.js → async-cache-DRmFaVGm.js} +1 -1
  4. package/dist/{async-cache-U87GzQTb.js.map → async-cache-DRmFaVGm.js.map} +1 -1
  5. package/dist/build-mdx-DkAvzRNg.d.ts +73 -0
  6. package/dist/build-mdx-DkAvzRNg.d.ts.map +1 -0
  7. package/dist/{build-mdx-CUp6FpfT.js → build-mdx-oug7zk0w.js} +23 -36
  8. package/dist/build-mdx-oug7zk0w.js.map +1 -0
  9. package/dist/bun/index.d.ts +1 -1
  10. package/dist/bun/index.d.ts.map +1 -1
  11. package/dist/bun/index.js +2 -2
  12. package/dist/{bun-CBROq3I0.js → bun-cxKGeSx6.js} +1 -1
  13. package/dist/bun-cxKGeSx6.js.map +1 -0
  14. package/dist/{code-generator-Qhhq7kHh.js → code-generator-C_Gu9y3h.js} +4 -4
  15. package/dist/code-generator-C_Gu9y3h.js.map +1 -0
  16. package/dist/collections/data/runtime.d.ts +3 -6
  17. package/dist/collections/data/runtime.d.ts.map +1 -1
  18. package/dist/collections/data/runtime.js.map +1 -1
  19. package/dist/collections/data.d.ts +4 -4
  20. package/dist/collections/data.d.ts.map +1 -1
  21. package/dist/collections/data.js +158 -4
  22. package/dist/collections/data.js.map +1 -0
  23. package/dist/collections/fs.d.ts +45 -3
  24. package/dist/collections/fs.d.ts.map +1 -0
  25. package/dist/collections/fs.js +65 -2
  26. package/dist/collections/fs.js.map +1 -0
  27. package/dist/collections/index.d.ts +37 -2
  28. package/dist/collections/index.d.ts.map +1 -0
  29. package/dist/collections/index.js +37 -2
  30. package/dist/collections/index.js.map +1 -0
  31. package/dist/collections/json/loader-webpack.d.ts +3 -3
  32. package/dist/collections/json/loader-webpack.d.ts.map +1 -1
  33. package/dist/collections/json/loader-webpack.js +3 -7
  34. package/dist/collections/json/loader-webpack.js.map +1 -1
  35. package/dist/collections/mdx/loader-webpack.d.ts +3 -3
  36. package/dist/collections/mdx/loader-webpack.d.ts.map +1 -1
  37. package/dist/collections/mdx/loader-webpack.js +3 -8
  38. package/dist/collections/mdx/loader-webpack.js.map +1 -1
  39. package/dist/collections/mdx/react.d.ts +4 -10
  40. package/dist/collections/mdx/react.d.ts.map +1 -1
  41. package/dist/collections/mdx/runtime-browser.d.ts +26 -11
  42. package/dist/collections/mdx/runtime-browser.d.ts.map +1 -0
  43. package/dist/collections/mdx/runtime-browser.js +2 -2
  44. package/dist/collections/mdx/runtime-browser.js.map +1 -1
  45. package/dist/collections/mdx/runtime-dynamic.d.ts +7 -10
  46. package/dist/collections/mdx/runtime-dynamic.d.ts.map +1 -1
  47. package/dist/collections/mdx/runtime-dynamic.js +9 -12
  48. package/dist/collections/mdx/runtime-dynamic.js.map +1 -1
  49. package/dist/collections/mdx/runtime.d.ts +27 -10
  50. package/dist/collections/mdx/runtime.d.ts.map +1 -0
  51. package/dist/collections/mdx/runtime.js.map +1 -1
  52. package/dist/collections/mdx.d.ts +67 -6
  53. package/dist/collections/mdx.d.ts.map +1 -0
  54. package/dist/collections/mdx.js +318 -6
  55. package/dist/collections/mdx.js.map +1 -0
  56. package/dist/collections/runtime/file-store.d.ts +21 -4
  57. package/dist/collections/runtime/file-store.d.ts.map +1 -0
  58. package/dist/collections/runtime/file-store.js +1 -1
  59. package/dist/collections/runtime/store.d.ts +31 -3
  60. package/dist/collections/runtime/store.d.ts.map +1 -0
  61. package/dist/collections/runtime/store.js +33 -2
  62. package/dist/collections/runtime/store.js.map +1 -0
  63. package/dist/collections/yaml/loader-webpack.d.ts +3 -3
  64. package/dist/collections/yaml/loader-webpack.d.ts.map +1 -1
  65. package/dist/collections/yaml/loader-webpack.js +3 -7
  66. package/dist/collections/yaml/loader-webpack.js.map +1 -1
  67. package/dist/config/index.d.ts +36 -2
  68. package/dist/config/index.d.ts.map +1 -0
  69. package/dist/{core-CT06v32N.d.ts → core-CG2zTL4c.d.ts} +4 -66
  70. package/dist/core-CG2zTL4c.d.ts.map +1 -0
  71. package/dist/{core-Uv3jZqL-.js → core-DmbQk8Z2.js} +9 -9
  72. package/dist/core-DmbQk8Z2.js.map +1 -0
  73. package/dist/dynamic.d.ts +25 -3
  74. package/dist/dynamic.d.ts.map +1 -0
  75. package/dist/dynamic.js +28 -2
  76. package/dist/dynamic.js.map +1 -0
  77. package/dist/{fuma-matter-BuBO2w-p.js → fuma-matter-Pwr2S9Ab.js} +1 -1
  78. package/dist/fuma-matter-Pwr2S9Ab.js.map +1 -0
  79. package/dist/index.d.ts +1 -1
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +3 -3
  82. package/dist/{load-from-file-z7EGuf2n.js → load-from-file-BeLFB77e.js} +4 -2
  83. package/dist/{load-from-file-z7EGuf2n.js.map → load-from-file-BeLFB77e.js.map} +1 -1
  84. package/dist/load-from-file-CpA8UQXX.d.ts +10 -0
  85. package/dist/load-from-file-CpA8UQXX.d.ts.map +1 -0
  86. package/dist/loader-DKTW82eK.js +19 -0
  87. package/dist/{loader-Cnz-VHne.js.map → loader-DKTW82eK.js.map} +1 -1
  88. package/dist/{loader-CnksfM7I.js → loader-DOjRBsog.js} +7 -5
  89. package/dist/loader-DOjRBsog.js.map +1 -0
  90. package/dist/loader-DTODFdmk.js +18 -0
  91. package/dist/{loader-BK8PnqRg.js.map → loader-DTODFdmk.js.map} +1 -1
  92. package/dist/{loader-CuntMmR4.js → loader-gwXIGo5Q.js} +3 -3
  93. package/dist/loader-gwXIGo5Q.js.map +1 -0
  94. package/dist/next/index.d.ts +1 -1
  95. package/dist/next/index.d.ts.map +1 -1
  96. package/dist/next/index.js +3 -3
  97. package/dist/next/index.js.map +1 -1
  98. package/dist/node/index.d.ts +1 -1
  99. package/dist/node/index.d.ts.map +1 -1
  100. package/dist/node/loader.d.ts +1 -1
  101. package/dist/node/loader.d.ts.map +1 -1
  102. package/dist/node/loader.js +8 -8
  103. package/dist/node/loader.js.map +1 -1
  104. package/dist/{node-2VZOh3P9.js → node-l03HaPSS.js} +1 -1
  105. package/dist/{node-2VZOh3P9.js.map → node-l03HaPSS.js.map} +1 -1
  106. package/dist/{collections-CNWuMDAZ.js → pipe-CvCqOpXX.js} +2 -36
  107. package/dist/pipe-CvCqOpXX.js.map +1 -0
  108. package/dist/plugins/git.d.ts +38 -3
  109. package/dist/plugins/git.d.ts.map +1 -0
  110. package/dist/plugins/git.js +60 -2
  111. package/dist/plugins/git.js.map +1 -0
  112. package/dist/plugins/json-schema.d.ts +2 -1
  113. package/dist/plugins/json-schema.d.ts.map +1 -1
  114. package/dist/plugins/json-schema.js +2 -2
  115. package/dist/plugins/json-schema.js.map +1 -1
  116. package/dist/plugins/loader/index.d.ts +75 -4
  117. package/dist/plugins/loader/index.d.ts.map +1 -0
  118. package/dist/plugins/loader/index.js +76 -2
  119. package/dist/plugins/loader/index.js.map +1 -0
  120. package/dist/plugins/loader/webpack.d.ts +21 -4
  121. package/dist/plugins/loader/webpack.d.ts.map +1 -0
  122. package/dist/plugins/loader/webpack.js +4 -4
  123. package/dist/plugins/loader/webpack.js.map +1 -1
  124. package/dist/rolldown-runtime-CjeV3_4I.js +18 -0
  125. package/dist/{validation-BvVvvLII.js → validation-C3kXuveD.js} +1 -1
  126. package/dist/{validation-BvVvvLII.js.map → validation-C3kXuveD.js.map} +1 -1
  127. package/dist/vite/index.d.ts +1 -1
  128. package/dist/vite/index.d.ts.map +1 -1
  129. package/dist/vite/index.js +3 -3
  130. package/dist/{vite-C1qXY47G.js → vite-mAc2TZyp.js} +3 -3
  131. package/dist/vite-mAc2TZyp.js.map +1 -0
  132. package/package.json +19 -10
  133. package/dist/build-mdx-CUp6FpfT.js.map +0 -1
  134. package/dist/build-mdx-D6zM3Sgl.js +0 -4
  135. package/dist/bun-CBROq3I0.js.map +0 -1
  136. package/dist/code-generator-Qhhq7kHh.js.map +0 -1
  137. package/dist/collections-CNWuMDAZ.js.map +0 -1
  138. package/dist/core-CT06v32N.d.ts.map +0 -1
  139. package/dist/core-Uv3jZqL-.js.map +0 -1
  140. package/dist/data-Cxsx5KPD.js +0 -159
  141. package/dist/data-Cxsx5KPD.js.map +0 -1
  142. package/dist/dynamic-Ck1wYoaL.d.ts +0 -33
  143. package/dist/dynamic-Ck1wYoaL.d.ts.map +0 -1
  144. package/dist/dynamic-CtOB4Rkp.js +0 -29
  145. package/dist/dynamic-CtOB4Rkp.js.map +0 -1
  146. package/dist/file-store-Dm1SjuLg.d.ts +0 -20
  147. package/dist/file-store-Dm1SjuLg.d.ts.map +0 -1
  148. package/dist/fs-CXzVd2Dp.js +0 -68
  149. package/dist/fs-CXzVd2Dp.js.map +0 -1
  150. package/dist/fs-CmwaaFyx.d.ts +0 -45
  151. package/dist/fs-CmwaaFyx.d.ts.map +0 -1
  152. package/dist/fuma-matter-BuBO2w-p.js.map +0 -1
  153. package/dist/git-DnejL9r_.js +0 -60
  154. package/dist/git-DnejL9r_.js.map +0 -1
  155. package/dist/git-n-9ddn78.d.ts +0 -37
  156. package/dist/git-n-9ddn78.d.ts.map +0 -1
  157. package/dist/index-BheUVWBm.d.ts +0 -87
  158. package/dist/index-BheUVWBm.d.ts.map +0 -1
  159. package/dist/load-from-file-D-Xm95Fz.js +0 -3
  160. package/dist/loader-B4nQrRwA.js +0 -77
  161. package/dist/loader-B4nQrRwA.js.map +0 -1
  162. package/dist/loader-B6ordrWK.js +0 -9
  163. package/dist/loader-BK8PnqRg.js +0 -16
  164. package/dist/loader-CnksfM7I.js.map +0 -1
  165. package/dist/loader-Cnz-VHne.js +0 -17
  166. package/dist/loader-CuntMmR4.js.map +0 -1
  167. package/dist/loader-Cx1Rg_VM.js +0 -8
  168. package/dist/loader-Dao_nv3e.js +0 -8
  169. package/dist/mdx-Cw1nBJ0D.js +0 -306
  170. package/dist/mdx-Cw1nBJ0D.js.map +0 -1
  171. package/dist/mdx-PaqRNZMS.d.ts +0 -135
  172. package/dist/mdx-PaqRNZMS.d.ts.map +0 -1
  173. package/dist/runtime-BUUHSFlR.d.ts +0 -31
  174. package/dist/runtime-BUUHSFlR.d.ts.map +0 -1
  175. package/dist/runtime-browser-B70WGxeQ.d.ts +0 -29
  176. package/dist/runtime-browser-B70WGxeQ.d.ts.map +0 -1
  177. package/dist/store-CRyvZFKN.js +0 -34
  178. package/dist/store-CRyvZFKN.js.map +0 -1
  179. package/dist/store-D_PPrdRE.d.ts +0 -31
  180. package/dist/store-D_PPrdRE.d.ts.map +0 -1
  181. package/dist/vite-C1qXY47G.js.map +0 -1
@@ -30,4 +30,4 @@ function toNode(loaders) {
30
30
 
31
31
  //#endregion
32
32
  export { toNode };
33
- //# sourceMappingURL=node-2VZOh3P9.js.map
33
+ //# sourceMappingURL=node-l03HaPSS.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-2VZOh3P9.js","names":[],"sources":["../src/plugins/loader/node.ts"],"sourcesContent":["import type { LoadFnOutput, LoadHook } from \"node:module\";\nimport { fileURLToPath } from \"node:url\";\nimport fs from \"node:fs/promises\";\nimport type { Loader } from \"@/plugins/loader\";\n\nexport function toNode(loaders: { test: RegExp | undefined; loader: Loader }[]): LoadHook {\n return async (url, _context, nextLoad): Promise<LoadFnOutput> => {\n if (!url.startsWith(\"file:///\")) return nextLoad(url);\n\n const config = loaders.find((loader) => !loader.test || loader.test.test(url));\n if (config) {\n const parsedUrl = new URL(url);\n const filePath = fileURLToPath(parsedUrl);\n\n const result = await config.loader.load({\n filePath,\n query: Object.fromEntries(parsedUrl.searchParams.entries()),\n async getSource() {\n return (await fs.readFile(filePath)).toString();\n },\n development: false,\n compiler: {\n addDependency() {},\n },\n });\n\n if (result) {\n return {\n source: result.code,\n format: \"module\",\n shortCircuit: true,\n };\n }\n }\n\n return nextLoad(url);\n };\n}\n"],"mappings":";;;;AAKA,SAAgB,OAAO,SAAmE;AACxF,QAAO,OAAO,KAAK,UAAU,aAAoC;AAC/D,MAAI,CAAC,IAAI,WAAW,WAAW,CAAE,QAAO,SAAS,IAAI;EAErD,MAAM,SAAS,QAAQ,MAAM,WAAW,CAAC,OAAO,QAAQ,OAAO,KAAK,KAAK,IAAI,CAAC;AAC9E,MAAI,QAAQ;GACV,MAAM,YAAY,IAAI,IAAI,IAAI;GAC9B,MAAM,WAAW,cAAc,UAAU;GAEzC,MAAM,SAAS,MAAM,OAAO,OAAO,KAAK;IACtC;IACA,OAAO,OAAO,YAAY,UAAU,aAAa,SAAS,CAAC;IAC3D,MAAM,YAAY;AAChB,aAAQ,MAAM,GAAG,SAAS,SAAS,EAAE,UAAU;;IAEjD,aAAa;IACb,UAAU,EACR,gBAAgB,IACjB;IACF,CAAC;AAEF,OAAI,OACF,QAAO;IACL,QAAQ,OAAO;IACf,QAAQ;IACR,cAAc;IACf;;AAIL,SAAO,SAAS,IAAI"}
1
+ {"version":3,"file":"node-l03HaPSS.js","names":[],"sources":["../src/plugins/loader/node.ts"],"sourcesContent":["import type { LoadFnOutput, LoadHook } from \"node:module\";\nimport { fileURLToPath } from \"node:url\";\nimport fs from \"node:fs/promises\";\nimport type { Loader } from \"@/plugins/loader\";\n\nexport function toNode(loaders: { test: RegExp | undefined; loader: Loader }[]): LoadHook {\n return async (url, _context, nextLoad): Promise<LoadFnOutput> => {\n if (!url.startsWith(\"file:///\")) return nextLoad(url);\n\n const config = loaders.find((loader) => !loader.test || loader.test.test(url));\n if (config) {\n const parsedUrl = new URL(url);\n const filePath = fileURLToPath(parsedUrl);\n\n const result = await config.loader.load({\n filePath,\n query: Object.fromEntries(parsedUrl.searchParams.entries()),\n async getSource() {\n return (await fs.readFile(filePath)).toString();\n },\n development: false,\n compiler: {\n addDependency() {},\n },\n });\n\n if (result) {\n return {\n source: result.code,\n format: \"module\",\n shortCircuit: true,\n };\n }\n }\n\n return nextLoad(url);\n };\n}\n"],"mappings":";;;;AAKA,SAAgB,OAAO,SAAmE;AACxF,QAAO,OAAO,KAAK,UAAU,aAAoC;AAC/D,MAAI,CAAC,IAAI,WAAW,WAAW,CAAE,QAAO,SAAS,IAAI;EAErD,MAAM,SAAS,QAAQ,MAAM,WAAW,CAAC,OAAO,QAAQ,OAAO,KAAK,KAAK,IAAI,CAAC;AAC9E,MAAI,QAAQ;GACV,MAAM,YAAY,IAAI,IAAI,IAAI;GAC9B,MAAM,WAAW,cAAc,UAAU;GAEzC,MAAM,SAAS,MAAM,OAAO,OAAO,KAAK;IACtC;IACA,OAAO,OAAO,YAAY,UAAU,aAAa,SAAS,CAAC;IAC3D,MAAM,YAAY;AAChB,aAAQ,MAAM,GAAG,SAAS,SAAS,EAAE,UAAU;;IAEjD,aAAa;IACb,UAAU,EACR,gBAAgB,IACjB;IACF,CAAC;AAEF,OAAI,OACF,QAAO;IACL,QAAQ,OAAO;IACf,QAAQ;IACR,cAAc;IACf;;AAIL,SAAO,SAAS,IAAI"}
@@ -54,39 +54,5 @@ function asyncPipe(steps = []) {
54
54
  }
55
55
 
56
56
  //#endregion
57
- //#region src/collections/index.ts
58
- var Collection = class {
59
- pluginHooks = /* @__PURE__ */ new Map();
60
- name = null;
61
- /**
62
- * on config loaded/updated
63
- */
64
- onConfig = hook();
65
- /**
66
- * Configure watch/dev server
67
- */
68
- onServer = hook();
69
- onInit = asyncHook();
70
- onEmit = asyncPipe();
71
- plugins = [];
72
- pluginHook(hook$1, options) {
73
- let created = this.pluginHooks.get(hook$1.id);
74
- if (created) return created;
75
- created = hook$1.create(this, options);
76
- this.pluginHooks.set(hook$1.id, created);
77
- return created;
78
- }
79
- getPluginHook(hook$1) {
80
- return this.pluginHooks.get(hook$1.id);
81
- }
82
- };
83
- function defineCollectionHook(init) {
84
- return {
85
- id: Symbol(),
86
- create: init
87
- };
88
- }
89
-
90
- //#endregion
91
- export { asyncHook as a, pipe as i, defineCollectionHook as n, hook as o, asyncPipe as r, Collection as t };
92
- //# sourceMappingURL=collections-CNWuMDAZ.js.map
57
+ export { hook as i, pipe as n, asyncHook as r, asyncPipe as t };
58
+ //# sourceMappingURL=pipe-CvCqOpXX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe-CvCqOpXX.js","names":[],"sources":["../src/utils/hook.ts","../src/utils/pipe.ts"],"sourcesContent":["import type { Awaitable } from \"@/types\";\n\nexport interface Hook<Context = undefined> {\n /**\n * add a hook\n *\n * @returns the same pipe instance\n */\n hook: (fn: (context: Context) => void) => Hook<Context>;\n run: (context: Context) => void;\n $inferHandler: (context: Context) => Awaitable<void>;\n}\n\nexport interface AsyncHook<Context = undefined> {\n /**\n * add a hook\n *\n * @returns the same pipe instance\n */\n hook: (fn: (context: Context) => Awaitable<void>) => AsyncHook<Context>;\n run: (context: Context) => Awaitable<void>;\n $inferHandler: (context: Context) => Awaitable<void>;\n}\n\nexport function hook<Context>(steps: ((ctx: Context) => void)[] = []): Hook<Context> {\n return {\n async run(ctx) {\n for (const step of steps) step(ctx);\n },\n hook(fn) {\n steps.push(fn);\n return this;\n },\n $inferHandler: undefined as never,\n };\n}\n\nexport function asyncHook<Context>(\n steps: ((ctx: Context) => Awaitable<void>)[] = [],\n): AsyncHook<Context> {\n return {\n async run(ctx) {\n await Promise.all(steps.map((step) => step(ctx)));\n },\n hook(fn) {\n steps.push(fn);\n return this;\n },\n $inferHandler: undefined as never,\n };\n}\n","import type { Awaitable } from \"@/types\";\n\nexport interface Pipe<Data, Context = undefined> {\n /**\n * add a transformation step\n *\n * @returns the same pipe instance\n */\n pipe: (fn: (data: Data, context: Context) => Data) => Pipe<Data, Context>;\n run: (data: Data, context: Context) => Data;\n $inferHandler: (data: Data, context: Context) => Data;\n}\n\nexport interface AsyncPipe<Data, Context = undefined> {\n /**\n * add a transformation step\n *\n * @returns the same pipe instance\n */\n pipe: (fn: (data: Data, context: Context) => Awaitable<Data>) => AsyncPipe<Data, Context>;\n run: (data: Data, context: Context) => Awaitable<Data>;\n $inferHandler: (data: Data, context: Context) => Awaitable<Data>;\n}\n\nexport function pipe<Data, Context>(\n steps: ((data: Data, context: Context) => Data)[] = [],\n): Pipe<Data, Context> {\n return {\n run(data, ctx) {\n for (const step of steps) {\n data = step(data, ctx);\n }\n return data;\n },\n pipe(fn) {\n steps.push(fn);\n return this;\n },\n $inferHandler: undefined as never,\n };\n}\n\nexport function asyncPipe<Data, Context>(\n steps: ((data: Data, context: Context) => Awaitable<Data>)[] = [],\n): AsyncPipe<Data, Context> {\n return {\n async run(data, ctx) {\n for (const step of steps) {\n data = await step(data, ctx);\n }\n return data;\n },\n pipe(fn) {\n steps.push(fn);\n return this;\n },\n $inferHandler: undefined as never,\n };\n}\n"],"mappings":";AAwBA,SAAgB,KAAc,QAAoC,EAAE,EAAiB;AACnF,QAAO;EACL,MAAM,IAAI,KAAK;AACb,QAAK,MAAM,QAAQ,MAAO,MAAK,IAAI;;EAErC,KAAK,IAAI;AACP,SAAM,KAAK,GAAG;AACd,UAAO;;EAET,eAAe;EAChB;;AAGH,SAAgB,UACd,QAA+C,EAAE,EAC7B;AACpB,QAAO;EACL,MAAM,IAAI,KAAK;AACb,SAAM,QAAQ,IAAI,MAAM,KAAK,SAAS,KAAK,IAAI,CAAC,CAAC;;EAEnD,KAAK,IAAI;AACP,SAAM,KAAK,GAAG;AACd,UAAO;;EAET,eAAe;EAChB;;;;;ACzBH,SAAgB,KACd,QAAoD,EAAE,EACjC;AACrB,QAAO;EACL,IAAI,MAAM,KAAK;AACb,QAAK,MAAM,QAAQ,MACjB,QAAO,KAAK,MAAM,IAAI;AAExB,UAAO;;EAET,KAAK,IAAI;AACP,SAAM,KAAK,GAAG;AACd,UAAO;;EAET,eAAe;EAChB;;AAGH,SAAgB,UACd,QAA+D,EAAE,EACvC;AAC1B,QAAO;EACL,MAAM,IAAI,MAAM,KAAK;AACnB,QAAK,MAAM,QAAQ,MACjB,QAAO,MAAM,KAAK,MAAM,IAAI;AAE9B,UAAO;;EAET,KAAK,IAAI;AACP,SAAM,KAAK,GAAG;AACd,UAAO;;EAET,eAAe;EAChB"}
@@ -1,3 +1,38 @@
1
- import "../core-CT06v32N.js";
2
- import { a as gitHook, i as git, n as GitFileData, r as GitHook, t as GitClient } from "../git-n-9ddn78.js";
3
- export { GitClient, GitFileData, GitHook, git as default, gitHook };
1
+ import { s as Plugin, v as AsyncHook } from "../core-CG2zTL4c.js";
2
+ import { CollectionHook } from "../collections/index.js";
3
+
4
+ //#region src/plugins/git.d.ts
5
+ interface GitFileData {
6
+ /**
7
+ * Last modified date of file, obtained from version control.
8
+ */
9
+ lastModified: Date | null;
10
+ /**
11
+ * Creation date of file, obtained from version control.
12
+ */
13
+ creationDate: Date | null;
14
+ }
15
+ interface GitHook {
16
+ /**
17
+ * receive the client.
18
+ */
19
+ onClient: AsyncHook<{
20
+ client: GitClient;
21
+ }>;
22
+ }
23
+ declare const gitHook: CollectionHook<GitHook, undefined>;
24
+ /**
25
+ * Add version control integration for Git.
26
+ * 1. Injects `creationDate` & `lastModified` properties to page exports.
27
+ *
28
+ * @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.
29
+ */
30
+ declare function git(): Plugin;
31
+ interface GitClient {
32
+ getFileData: (options: {
33
+ filePath: string;
34
+ }) => Promise<GitFileData>;
35
+ }
36
+ //#endregion
37
+ export { GitClient, GitFileData, GitHook, git as default, gitHook };
38
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.d.ts","names":[],"sources":["../../src/plugins/git.ts"],"mappings":";;;;UAOiB,WAAA;;AAAjB;;EAIE,YAAA,EAAc,IAAA;EAII;;;EAAlB,YAAA,EAAc,IAAA;AAAA;AAAA,UAGC,OAAA;EAHG;AAGpB;;EAIE,QAAA,EAAU,SAAA;IAAY,MAAA,EAAQ,SAAA;EAAA;AAAA;AAAA,cAGnB,OAAA,EAAO,cAAA,CAAA,OAAA;;;;AAApB;;;iBAUwB,GAAA,CAAA,GAAO,MAAA;AAAA,UAed,SAAA;EACf,WAAA,GAAc,OAAA;IAAW,QAAA;EAAA,MAAuB,OAAA,CAAQ,WAAA;AAAA"}
@@ -1,3 +1,61 @@
1
- import { n as gitHook, t as git } from "../git-DnejL9r_.js";
1
+ import { r as asyncHook } from "../pipe-CvCqOpXX.js";
2
+ import { defineCollectionHook } from "../collections/index.js";
3
+ import { t as createCache } from "../async-cache-DRmFaVGm.js";
4
+ import path from "node:path";
5
+ import { x } from "tinyexec";
2
6
 
3
- export { git as default, gitHook };
7
+ //#region src/plugins/git.ts
8
+ const gitHook = defineCollectionHook(() => ({ onClient: asyncHook() }));
9
+ /**
10
+ * Add version control integration for Git.
11
+ * 1. Injects `creationDate` & `lastModified` properties to page exports.
12
+ *
13
+ * @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.
14
+ */
15
+ function git() {
16
+ let client;
17
+ return {
18
+ name: "git",
19
+ config() {
20
+ const { cwd } = this.core.getOptions();
21
+ client = createGitClient(cwd);
22
+ },
23
+ async collection(collection) {
24
+ await collection.getPluginHook(gitHook)?.onClient.run({ client });
25
+ }
26
+ };
27
+ }
28
+ function createGitClient(cwd) {
29
+ const cache = createCache();
30
+ function mapDate(out) {
31
+ if (out.exitCode !== 0) return null;
32
+ const date = new Date(out.stdout);
33
+ return Number.isNaN(date.getTime()) ? null : date;
34
+ }
35
+ return { async getFileData({ filePath }) {
36
+ return cache.cached(filePath, async () => {
37
+ const relativePath = path.relative(cwd, filePath);
38
+ const [mod, create] = await Promise.all([x("git", [
39
+ "log",
40
+ "-1",
41
+ "--pretty=%ai",
42
+ relativePath
43
+ ], { nodeOptions: { cwd } }), x("git", [
44
+ "log",
45
+ "--diff-filter=A",
46
+ "--follow",
47
+ "--format=%ai",
48
+ "-1",
49
+ relativePath
50
+ ], { nodeOptions: { cwd } })]);
51
+ return {
52
+ lastModified: mapDate(mod),
53
+ creationDate: mapDate(create)
54
+ };
55
+ });
56
+ } };
57
+ }
58
+
59
+ //#endregion
60
+ export { git as default, gitHook };
61
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.js","names":[],"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,IAAI;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,4 +1,5 @@
1
- import { E as Awaitable, h as CollectionHook } from "../core-CT06v32N.js";
1
+ import { S as Awaitable } from "../core-CG2zTL4c.js";
2
+ import { CollectionHook } from "../collections/index.js";
2
3
 
3
4
  //#region src/plugins/json-schema.d.ts
4
5
  interface JSONSchemaOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema.d.ts","names":[],"sources":["../../src/plugins/json-schema.ts"],"sourcesContent":[],"mappings":";;;UAMiB,iBAAA;;AAAjB;AAcA;AAQA;;EAA2B,MAAA,CAAA,EAAA,OAAA;EAAA;;;iBAXV;;UAGA,cAAA;;iBAEA;;;;;cAMJ,gBAAc,eAAA,gBAAA"}
1
+ {"version":3,"file":"json-schema.d.ts","names":[],"sources":["../../src/plugins/json-schema.ts"],"mappings":";;;;UAMiB,iBAAA;;;AAAjB;;;EAME,MAAA;EAAA;;;EAKA,MAAA,SAAe,SAAA;AAAA;AAAA,UAGA,cAAA;EACf,aAAA;EACA,MAAA,SAAe,SAAA;AAAA;;;;cAMJ,cAAA,EAAc,cAAA,CAAA,cAAA,EAAA,iBAAA"}
@@ -1,5 +1,5 @@
1
- import { n as defineCollectionHook } from "../collections-CNWuMDAZ.js";
2
- import { t as FileSystemCollection } from "../fs-CXzVd2Dp.js";
1
+ import { defineCollectionHook } from "../collections/index.js";
2
+ import { FileSystemCollection } from "../collections/fs.js";
3
3
  import fs from "node:fs/promises";
4
4
  import path from "node:path";
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema.js","names":["hook: JSONSchemaHook","obj: object"],"sources":["../../src/plugins/json-schema.ts"],"sourcesContent":["import { defineCollectionHook } from \"@/collections\";\nimport { FileSystemCollection } from \"@/collections/fs\";\nimport { Awaitable } from \"@/types\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport interface JSONSchemaOptions {\n /**\n * insert `$schema` field to JSON files on creation.\n *\n * @defaultValue false\n */\n insert?: boolean;\n\n /**\n * create JSON schema\n */\n create?: () => Awaitable<object | undefined>;\n}\n\nexport interface JSONSchemaHook {\n getSchemaPath: () => string;\n create?: () => Awaitable<object | undefined>;\n}\n\n/**\n * Generate JSON schemas locally for collection schemas.\n */\nexport const jsonSchemaHook = defineCollectionHook<JSONSchemaHook, JSONSchemaOptions>(\n (collection, { insert = false, create }) => {\n const hook: JSONSchemaHook = {\n create,\n getSchemaPath() {\n return `json-schema/${collection.name}.json`;\n },\n };\n\n collection.onServer.hook(({ core, server }) => {\n const { outDir } = core.getOptions();\n if (!server.watcher || !insert || !(collection instanceof FileSystemCollection)) return;\n\n server.watcher.on(\"add\", async (file) => {\n if (!collection.hasFile(file) || !file.endsWith(\".json\")) return;\n\n let obj: object;\n try {\n const content = (await fs.readFile(file)).toString();\n obj = content.length > 0 ? JSON.parse(content) : {};\n } catch {\n return;\n }\n\n if (\"$schema\" in obj) return;\n const schemaPath = path.join(outDir, hook.getSchemaPath());\n const updated = {\n $schema: path.relative(path.dirname(file), schemaPath),\n ...obj,\n };\n\n await fs.writeFile(file, JSON.stringify(updated, null, 2));\n });\n });\n collection.onEmit.pipe(async (entries) => {\n const jsonSchema = await hook.create?.();\n if (!jsonSchema) return entries;\n entries.push({\n path: hook.getSchemaPath(),\n content: JSON.stringify(jsonSchema, null, 2),\n });\n return entries;\n });\n return hook;\n },\n);\n"],"mappings":";;;;;;;;;AA4BA,MAAa,iBAAiB,sBAC3B,YAAY,EAAE,SAAS,OAAO,aAAa;CAC1C,MAAMA,OAAuB;EAC3B;EACA,gBAAgB;AACd,UAAO,eAAe,WAAW,KAAK;;EAEzC;AAED,YAAW,SAAS,MAAM,EAAE,MAAM,aAAa;EAC7C,MAAM,EAAE,WAAW,KAAK,YAAY;AACpC,MAAI,CAAC,OAAO,WAAW,CAAC,UAAU,EAAE,sBAAsB,sBAAuB;AAEjF,SAAO,QAAQ,GAAG,OAAO,OAAO,SAAS;AACvC,OAAI,CAAC,WAAW,QAAQ,KAAK,IAAI,CAAC,KAAK,SAAS,QAAQ,CAAE;GAE1D,IAAIC;AACJ,OAAI;IACF,MAAM,WAAW,MAAM,GAAG,SAAS,KAAK,EAAE,UAAU;AACpD,UAAM,QAAQ,SAAS,IAAI,KAAK,MAAM,QAAQ,GAAG,EAAE;WAC7C;AACN;;AAGF,OAAI,aAAa,IAAK;GACtB,MAAM,aAAa,KAAK,KAAK,QAAQ,KAAK,eAAe,CAAC;GAC1D,MAAM,UAAU;IACd,SAAS,KAAK,SAAS,KAAK,QAAQ,KAAK,EAAE,WAAW;IACtD,GAAG;IACJ;AAED,SAAM,GAAG,UAAU,MAAM,KAAK,UAAU,SAAS,MAAM,EAAE,CAAC;IAC1D;GACF;AACF,YAAW,OAAO,KAAK,OAAO,YAAY;EACxC,MAAM,aAAa,MAAM,KAAK,UAAU;AACxC,MAAI,CAAC,WAAY,QAAO;AACxB,UAAQ,KAAK;GACX,MAAM,KAAK,eAAe;GAC1B,SAAS,KAAK,UAAU,YAAY,MAAM,EAAE;GAC7C,CAAC;AACF,SAAO;GACP;AACF,QAAO;EAEV"}
1
+ {"version":3,"file":"json-schema.js","names":[],"sources":["../../src/plugins/json-schema.ts"],"sourcesContent":["import { defineCollectionHook } from \"@/collections\";\nimport { FileSystemCollection } from \"@/collections/fs\";\nimport { Awaitable } from \"@/types\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport interface JSONSchemaOptions {\n /**\n * insert `$schema` field to JSON files on creation.\n *\n * @defaultValue false\n */\n insert?: boolean;\n\n /**\n * create JSON schema\n */\n create?: () => Awaitable<object | undefined>;\n}\n\nexport interface JSONSchemaHook {\n getSchemaPath: () => string;\n create?: () => Awaitable<object | undefined>;\n}\n\n/**\n * Generate JSON schemas locally for collection schemas.\n */\nexport const jsonSchemaHook = defineCollectionHook<JSONSchemaHook, JSONSchemaOptions>(\n (collection, { insert = false, create }) => {\n const hook: JSONSchemaHook = {\n create,\n getSchemaPath() {\n return `json-schema/${collection.name}.json`;\n },\n };\n\n collection.onServer.hook(({ core, server }) => {\n const { outDir } = core.getOptions();\n if (!server.watcher || !insert || !(collection instanceof FileSystemCollection)) return;\n\n server.watcher.on(\"add\", async (file) => {\n if (!collection.hasFile(file) || !file.endsWith(\".json\")) return;\n\n let obj: object;\n try {\n const content = (await fs.readFile(file)).toString();\n obj = content.length > 0 ? JSON.parse(content) : {};\n } catch {\n return;\n }\n\n if (\"$schema\" in obj) return;\n const schemaPath = path.join(outDir, hook.getSchemaPath());\n const updated = {\n $schema: path.relative(path.dirname(file), schemaPath),\n ...obj,\n };\n\n await fs.writeFile(file, JSON.stringify(updated, null, 2));\n });\n });\n collection.onEmit.pipe(async (entries) => {\n const jsonSchema = await hook.create?.();\n if (!jsonSchema) return entries;\n entries.push({\n path: hook.getSchemaPath(),\n content: JSON.stringify(jsonSchema, null, 2),\n });\n return entries;\n });\n return hook;\n },\n);\n"],"mappings":";;;;;;;;;AA4BA,MAAa,iBAAiB,sBAC3B,YAAY,EAAE,SAAS,OAAO,aAAa;CAC1C,MAAM,OAAuB;EAC3B;EACA,gBAAgB;AACd,UAAO,eAAe,WAAW,KAAK;;EAEzC;AAED,YAAW,SAAS,MAAM,EAAE,MAAM,aAAa;EAC7C,MAAM,EAAE,WAAW,KAAK,YAAY;AACpC,MAAI,CAAC,OAAO,WAAW,CAAC,UAAU,EAAE,sBAAsB,sBAAuB;AAEjF,SAAO,QAAQ,GAAG,OAAO,OAAO,SAAS;AACvC,OAAI,CAAC,WAAW,QAAQ,KAAK,IAAI,CAAC,KAAK,SAAS,QAAQ,CAAE;GAE1D,IAAI;AACJ,OAAI;IACF,MAAM,WAAW,MAAM,GAAG,SAAS,KAAK,EAAE,UAAU;AACpD,UAAM,QAAQ,SAAS,IAAI,KAAK,MAAM,QAAQ,GAAG,EAAE;WAC7C;AACN;;AAGF,OAAI,aAAa,IAAK;GACtB,MAAM,aAAa,KAAK,KAAK,QAAQ,KAAK,eAAe,CAAC;GAC1D,MAAM,UAAU;IACd,SAAS,KAAK,SAAS,KAAK,QAAQ,KAAK,EAAE,WAAW;IACtD,GAAG;IACJ;AAED,SAAM,GAAG,UAAU,MAAM,KAAK,UAAU,SAAS,MAAM,EAAE,CAAC;IAC1D;GACF;AACF,YAAW,OAAO,KAAK,OAAO,YAAY;EACxC,MAAM,aAAa,MAAM,KAAK,UAAU;AACxC,MAAI,CAAC,WAAY,QAAO;AACxB,UAAQ,KAAK;GACX,MAAM,KAAK,eAAe;GAC1B,SAAS,KAAK,UAAU,YAAY,MAAM,EAAE;GAC7C,CAAC;AACF,SAAO;GACP;AACF,QAAO;EAEV"}
@@ -1,4 +1,75 @@
1
- import "../../core-CT06v32N.js";
2
- import "../../dynamic-Ck1wYoaL.js";
3
- import { a as LoaderInput, c as loaderPlugin, i as LoaderHook, n as Loader, o as LoaderOutput, r as LoaderConfig, s as loaderHook, t as CompilerOptions } from "../../index-BheUVWBm.js";
4
- export { CompilerOptions, Loader, LoaderConfig, LoaderHook, LoaderInput, LoaderOutput, loaderHook, loaderPlugin };
1
+ import { c as PluginContext, s as Plugin } from "../../core-CG2zTL4c.js";
2
+ import { CollectionHook } from "../../collections/index.js";
3
+ import "../../load-from-file-CpA8UQXX.js";
4
+ import { WebpackLoaderOptions } from "./webpack.js";
5
+ import { NextConfig } from "next";
6
+
7
+ //#region src/plugins/loader/index.d.ts
8
+ type Awaitable<T> = T | Promise<T>;
9
+ interface CompilerOptions {
10
+ addDependency: (file: string) => void;
11
+ }
12
+ type LoaderEnvironment = "vite" | "bun" | "node";
13
+ interface Loader {
14
+ /**
15
+ * Transform input into JavaScript.
16
+ *
17
+ * Returns:
18
+ * - `LoaderOutput`: JavaScript code & source map.
19
+ * - `null`: skip the loader. Fallback to default behaviour if possible, otherwise the adapter will try workarounds.
20
+ */
21
+ load: (input: LoaderInput) => Awaitable<LoaderOutput | null>;
22
+ bun?: {
23
+ /**
24
+ * 1. Bun doesn't allow `null` in loaders.
25
+ * 2. Bun requires sync result to support dynamic require().
26
+ */
27
+ load?: (source: string, input: LoaderInput) => Awaitable<Bun.OnLoadResult>;
28
+ };
29
+ }
30
+ interface LoaderInput {
31
+ development: boolean;
32
+ compiler: CompilerOptions;
33
+ filePath: string;
34
+ query: Record<string, string | string[] | undefined>;
35
+ getSource: () => string | Promise<string>;
36
+ }
37
+ interface LoaderOutput {
38
+ code: string;
39
+ map?: unknown;
40
+ /**
41
+ * only supported on Vite 8 at the moment, specify the output module type.
42
+ *
43
+ * on unsupported environments, it will be ignored.
44
+ */
45
+ moduleType?: "js" | "json";
46
+ }
47
+ interface NextLoaderContext extends PluginContext {
48
+ getLoaderOptions: () => WebpackLoaderOptions;
49
+ }
50
+ interface LoaderConfig {
51
+ /** unique ID for loader, used to deduplicate loaders */
52
+ id?: string;
53
+ /**
54
+ * Filter file paths, the input can be either a file URL or file path.
55
+ *
56
+ * Must take resource query into consideration.
57
+ */
58
+ test?: RegExp;
59
+ /**
60
+ * @remarks it doesn't configure automatically for Next.js, you have to define the webpack/turbopack config in `configureNext()`.
61
+ */
62
+ createLoader: (this: PluginContext, environment: LoaderEnvironment) => Promise<Loader>;
63
+ configureNext?: (this: NextLoaderContext, next: NextConfig) => NextConfig;
64
+ }
65
+ /**
66
+ * a light layer for implementing loaders.
67
+ */
68
+ declare function loaderPlugin(): Plugin;
69
+ interface LoaderHook {
70
+ loaders: LoaderConfig[];
71
+ }
72
+ declare const loaderHook: CollectionHook<LoaderHook, undefined>;
73
+ //#endregion
74
+ export { CompilerOptions, Loader, LoaderConfig, LoaderHook, LoaderInput, LoaderOutput, loaderHook, loaderPlugin };
75
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/plugins/loader/index.ts"],"mappings":";;;;;;;KAOK,SAAA,MAAe,CAAA,GAAI,OAAA,CAAQ,CAAA;AAAA,UAEf,eAAA;EACf,aAAA,GAAgB,IAAA;AAAA;AAAA,KAGb,iBAAA;AAAA,UAEY,MAAA;EARH;;;;;;;EAgBZ,IAAA,GAAO,KAAA,EAAO,WAAA,KAAgB,SAAA,CAAU,YAAA;EAExC,GAAA;IAlB8B;;;AAEhC;IAqBI,IAAA,IAAQ,MAAA,UAAgB,KAAA,EAAO,WAAA,KAAgB,SAAA,CAAU,GAAA,CAAI,YAAA;EAAA;AAAA;AAAA,UAIhD,WAAA;EACf,WAAA;EACA,QAAA,EAAU,eAAA;EAEV,QAAA;EACA,KAAA,EAAO,MAAA;EACP,SAAA,iBAA0B,OAAA;AAAA;AAAA,UAGX,YAAA;EACf,IAAA;EACA,GAAA;EAtBwC;;;;;EA6BxC,UAAA;AAAA;AAAA,UAGQ,iBAAA,SAA0B,aAAA;EAClC,gBAAA,QAAwB,oBAAA;AAAA;AAAA,UAGT,YAAA;EApCyB;EAsCxC,EAAA;EA/BE;;;;;EAsCF,IAAA,GAAO,MAAA;EAtCwD;;;EA2C/D,YAAA,GAAe,IAAA,EAAM,aAAA,EAAe,WAAA,EAAa,iBAAA,KAAsB,OAAA,CAAQ,MAAA;EAC/E,aAAA,IAAiB,IAAA,EAAM,iBAAA,EAAmB,IAAA,EAAM,UAAA,KAAe,UAAA;AAAA;;;;iBAYjD,YAAA,CAAA,GAAgB,MAAA;AAAA,UAqFf,UAAA;EACf,OAAA,EAAS,YAAA;AAAA;AAAA,cAGE,UAAA,EAAU,cAAA,CAAA,UAAA"}
@@ -1,3 +1,77 @@
1
- import { n as loaderPlugin, t as loaderHook } from "../../loader-B4nQrRwA.js";
1
+ import { defineCollectionHook } from "../../collections/index.js";
2
+ import { t as createCache } from "../../async-cache-DRmFaVGm.js";
3
+ import path from "node:path";
2
4
 
3
- export { loaderHook, loaderPlugin };
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-cxKGeSx6.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-l03HaPSS.js");
63
+ return toNode(await initLoaders(this, "node"));
64
+ } },
65
+ vite: { async createPlugin() {
66
+ const { toVite } = await import("../../vite-mAc2TZyp.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 { loaderHook, loaderPlugin };
77
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"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,MAAM,MAAwB,EAAE;AAEhC,QAAK,MAAM,cAAc,IAAI,KAAK,gBAAgB,EAAE;IAClD,MAAM,OAAO,WAAW,cAAc,WAAW;AACjD,QAAI,CAAC,KAAM;IAEX,IAAI,SAAS;AACb,SAAK,MAAM,UAAU,KAAK,SAAS;AACjC,SAAI,OAAO,MAAM,QAAQ,IAAI,OAAO,GAAG,CAAE;AACzC,SAAI,OAAO,GAAI,SAAQ,IAAI,OAAO,GAAG;AAErC,SAAI,KAAK;MACP,IAAI,OAAO,MAAM,GAAG,WAAW,KAAK,GAAG;MACvC,MAAM,OAAO;MACb,QAAQ,MAAM,OAAO,aAAa,KAAK,KAAK,IAAI;MACjD,CAAC;;;AAGN,UAAO;IACP;;AAGJ,QAAO;EACL,MAAM;EACN,MAAM,EACJ,OAAO,QAAQ;GACb,MAAM,MAAyB;IAC7B,GAAG;IACH,wBAAwB;KACtB,MAAM,EAAE,YAAY,WAAW,KAAK,KAAK,YAAY;AACrD,YAAO;MACL;MACA;MACA,4BAA4B,KAAK,QAAQ,KAAK,KAAK,uBAAuB,CAAC;MAC3E,OAAO,QAAQ,IAAI,aAAa;MACjC;;IAEJ;AACD,QAAK,MAAM,cAAc,KAAK,KAAK,gBAAgB,EAAE;IACnD,MAAM,OAAO,WAAW,cAAc,WAAW;AACjD,QAAI,CAAC,KAAM;AAEX,SAAK,MAAM,UAAU,KAAK,SAAS;AACjC,SAAI,CAAC,OAAO,cAAe;AAE3B,cAAS,OAAO,cAAc,KAAK,KAAK,OAAO;;;AAInD,UAAO;KAEV;EACD,KAAK,EACH,MAAM,MAAM,OAAO;GACjB,MAAM,EAAE,UAAU,MAAM,OAAO;AAE/B,QAAK,MAAM,UAAU,MAAM,YAAY,MAAM,MAAM,CACjD,OAAM,OAAO,MAAM,OAAO,OAAO,CAAC,MAAM;KAG7C;EACD,MAAM,EACJ,MAAM,aAAa;GACjB,MAAM,EAAE,WAAW,MAAM,OAAO;AAChC,UAAO,OAAO,MAAM,YAAY,MAAM,OAAO,CAAC;KAEjD;EACD,MAAM,EACJ,MAAM,eAAe;GACnB,MAAM,EAAE,WAAW,MAAM,OAAO;AAChC,WAAQ,MAAM,YAAY,MAAM,OAAO,EAAE,KAAK,WAAW;AACvD,WAAO,OAAO,gBAAgB,OAAO,MAAM,OAAO,MAAM,OAAO,OAAO;KACtE;KAEL;EACF;;AAOH,MAAa,aAAa,4BAAwC,EAChE,SAAS,EAAE,EACZ,EAAE"}
@@ -1,4 +1,21 @@
1
- import "../../core-CT06v32N.js";
2
- import "../../dynamic-Ck1wYoaL.js";
3
- import { d as createWebpackLoader, l as WebpackLoader, u as WebpackLoaderOptions } from "../../index-BheUVWBm.js";
4
- export { WebpackLoader, WebpackLoaderOptions, createWebpackLoader };
1
+ import "../../core-CG2zTL4c.js";
2
+ import "../../load-from-file-CpA8UQXX.js";
3
+ import { DynamicCore } from "../../dynamic.js";
4
+ import { Loader } from "./index.js";
5
+ import { LoaderContext } from "webpack";
6
+
7
+ //#region src/plugins/loader/webpack.d.ts
8
+ interface WebpackLoaderOptions {
9
+ absoluteCompiledConfigPath: string;
10
+ configPath: string;
11
+ outDir: string;
12
+ isDev: boolean;
13
+ }
14
+ type WebpackLoader = (this: LoaderContext<WebpackLoaderOptions>, source: string) => void;
15
+ /**
16
+ * Note: need to handle the `test` regex in Webpack config instead.
17
+ */
18
+ declare function createWebpackLoader(loaderFactory: (core: DynamicCore) => Loader): WebpackLoader;
19
+ //#endregion
20
+ export { WebpackLoader, WebpackLoaderOptions, createWebpackLoader };
21
+ //# sourceMappingURL=webpack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack.d.ts","names":[],"sources":["../../../src/plugins/loader/webpack.ts"],"mappings":";;;;;;;UAQiB,oBAAA;EACf,0BAAA;EACA,UAAA;EACA,MAAA;EACA,KAAA;AAAA;AAAA,KAGU,aAAA,IAAiB,IAAA,EAAM,aAAA,CAAc,oBAAA,GAAuB,MAAA;;;;iBAqBxD,mBAAA,CAAoB,aAAA,GAAgB,IAAA,EAAM,WAAA,KAAgB,MAAA,GAAS,aAAA"}
@@ -1,6 +1,6 @@
1
- import { t as createDynamicCore } from "../../dynamic-CtOB4Rkp.js";
2
- import { t as Core } from "../../core-Uv3jZqL-.js";
3
- import { t as ValidationError } from "../../validation-BvVvvLII.js";
1
+ import { createDynamicCore } from "../../dynamic.js";
2
+ import { t as Core } from "../../core-DmbQk8Z2.js";
3
+ import { t as ValidationError } from "../../validation-C3kXuveD.js";
4
4
  import path from "node:path";
5
5
  import { parse } from "node:querystring";
6
6
 
@@ -50,7 +50,7 @@ function createWebpackLoader(loaderFactory) {
50
50
  callback(error);
51
51
  }
52
52
  }
53
- return function loader$1(source) {
53
+ return function loader(source) {
54
54
  return asyncLoader.call(this, source, this.async());
55
55
  };
56
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webpack.js","names":["loader: Loader | undefined","loader"],"sources":["../../../src/plugins/loader/webpack.ts"],"sourcesContent":["import { parse } from \"node:querystring\";\nimport { ValidationError } from \"@/utils/validation\";\nimport path from \"node:path\";\nimport { Core } from \"@/core\";\nimport { createDynamicCore, type DynamicCore } from \"@/dynamic\";\nimport type { LoaderContext } from \"webpack\";\nimport type { Loader } from \"@/plugins/loader\";\n\nexport interface WebpackLoaderOptions {\n absoluteCompiledConfigPath: string;\n configPath: string;\n outDir: string;\n isDev: boolean;\n}\n\nexport type WebpackLoader = (this: LoaderContext<WebpackLoaderOptions>, source: string) => void;\n\nconst cachedCores = new Map<string, DynamicCore>();\n\nfunction initDynamicCore({ configPath, isDev, outDir }: WebpackLoaderOptions) {\n const key = `${configPath}:${isDev}:${outDir}`;\n let res = cachedCores.get(key);\n if (res) return res;\n\n res = createDynamicCore({\n core: new Core({ configPath, outDir }),\n compileMode: \"skip\",\n mode: isDev ? \"dev\" : \"production\",\n });\n cachedCores.set(key, res);\n return res;\n}\n\n/**\n * Note: need to handle the `test` regex in Webpack config instead.\n */\nexport function createWebpackLoader(loaderFactory: (core: DynamicCore) => Loader): WebpackLoader {\n let loader: Loader | undefined;\n\n async function asyncLoader(\n this: LoaderContext<WebpackLoaderOptions>,\n source: string,\n callback: LoaderContext<WebpackLoaderOptions>[\"callback\"],\n ) {\n const options = this.getOptions();\n this.cacheable(true);\n this.addDependency(options.absoluteCompiledConfigPath);\n\n if (!loader) {\n const core = initDynamicCore(options);\n loader = loaderFactory(core);\n }\n\n try {\n const result = await loader.load({\n filePath: this.resourcePath,\n query: parse(this.resourceQuery.slice(1)),\n getSource() {\n return source;\n },\n development: this.mode === \"development\",\n compiler: this,\n });\n\n if (result === null) {\n callback(undefined, source);\n } else {\n callback(undefined, result.code, result.map as string);\n }\n } catch (error) {\n if (error instanceof ValidationError) {\n return callback(new Error(await error.toStringFormatted()));\n }\n\n if (!(error instanceof Error)) throw error;\n\n const fpath = path.relative(this.context, this.resourcePath);\n error.message = `${fpath}:${error.name}: ${error.message}`;\n callback(error);\n }\n }\n\n return function loader(source) {\n return asyncLoader.call(this, source, this.async());\n };\n}\n"],"mappings":";;;;;;;AAiBA,MAAM,8BAAc,IAAI,KAA0B;AAElD,SAAS,gBAAgB,EAAE,YAAY,OAAO,UAAgC;CAC5E,MAAM,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG;CACtC,IAAI,MAAM,YAAY,IAAI,IAAI;AAC9B,KAAI,IAAK,QAAO;AAEhB,OAAM,kBAAkB;EACtB,MAAM,IAAI,KAAK;GAAE;GAAY;GAAQ,CAAC;EACtC,aAAa;EACb,MAAM,QAAQ,QAAQ;EACvB,CAAC;AACF,aAAY,IAAI,KAAK,IAAI;AACzB,QAAO;;;;;AAMT,SAAgB,oBAAoB,eAA6D;CAC/F,IAAIA;CAEJ,eAAe,YAEb,QACA,UACA;EACA,MAAM,UAAU,KAAK,YAAY;AACjC,OAAK,UAAU,KAAK;AACpB,OAAK,cAAc,QAAQ,2BAA2B;AAEtD,MAAI,CAAC,OAEH,UAAS,cADI,gBAAgB,QAAQ,CACT;AAG9B,MAAI;GACF,MAAM,SAAS,MAAM,OAAO,KAAK;IAC/B,UAAU,KAAK;IACf,OAAO,MAAM,KAAK,cAAc,MAAM,EAAE,CAAC;IACzC,YAAY;AACV,YAAO;;IAET,aAAa,KAAK,SAAS;IAC3B,UAAU;IACX,CAAC;AAEF,OAAI,WAAW,KACb,UAAS,QAAW,OAAO;OAE3B,UAAS,QAAW,OAAO,MAAM,OAAO,IAAc;WAEjD,OAAO;AACd,OAAI,iBAAiB,gBACnB,QAAO,SAAS,IAAI,MAAM,MAAM,MAAM,mBAAmB,CAAC,CAAC;AAG7D,OAAI,EAAE,iBAAiB,OAAQ,OAAM;AAGrC,SAAM,UAAU,GADF,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,CACnC,GAAG,MAAM,KAAK,IAAI,MAAM;AACjD,YAAS,MAAM;;;AAInB,QAAO,SAASC,SAAO,QAAQ;AAC7B,SAAO,YAAY,KAAK,MAAM,QAAQ,KAAK,OAAO,CAAC"}
1
+ {"version":3,"file":"webpack.js","names":[],"sources":["../../../src/plugins/loader/webpack.ts"],"sourcesContent":["import { parse } from \"node:querystring\";\nimport { ValidationError } from \"@/utils/validation\";\nimport path from \"node:path\";\nimport { Core } from \"@/core\";\nimport { createDynamicCore, type DynamicCore } from \"@/dynamic\";\nimport type { LoaderContext } from \"webpack\";\nimport type { Loader } from \"@/plugins/loader\";\n\nexport interface WebpackLoaderOptions {\n absoluteCompiledConfigPath: string;\n configPath: string;\n outDir: string;\n isDev: boolean;\n}\n\nexport type WebpackLoader = (this: LoaderContext<WebpackLoaderOptions>, source: string) => void;\n\nconst cachedCores = new Map<string, DynamicCore>();\n\nfunction initDynamicCore({ configPath, isDev, outDir }: WebpackLoaderOptions) {\n const key = `${configPath}:${isDev}:${outDir}`;\n let res = cachedCores.get(key);\n if (res) return res;\n\n res = createDynamicCore({\n core: new Core({ configPath, outDir }),\n compileMode: \"skip\",\n mode: isDev ? \"dev\" : \"production\",\n });\n cachedCores.set(key, res);\n return res;\n}\n\n/**\n * Note: need to handle the `test` regex in Webpack config instead.\n */\nexport function createWebpackLoader(loaderFactory: (core: DynamicCore) => Loader): WebpackLoader {\n let loader: Loader | undefined;\n\n async function asyncLoader(\n this: LoaderContext<WebpackLoaderOptions>,\n source: string,\n callback: LoaderContext<WebpackLoaderOptions>[\"callback\"],\n ) {\n const options = this.getOptions();\n this.cacheable(true);\n this.addDependency(options.absoluteCompiledConfigPath);\n\n if (!loader) {\n const core = initDynamicCore(options);\n loader = loaderFactory(core);\n }\n\n try {\n const result = await loader.load({\n filePath: this.resourcePath,\n query: parse(this.resourceQuery.slice(1)),\n getSource() {\n return source;\n },\n development: this.mode === \"development\",\n compiler: this,\n });\n\n if (result === null) {\n callback(undefined, source);\n } else {\n callback(undefined, result.code, result.map as string);\n }\n } catch (error) {\n if (error instanceof ValidationError) {\n return callback(new Error(await error.toStringFormatted()));\n }\n\n if (!(error instanceof Error)) throw error;\n\n const fpath = path.relative(this.context, this.resourcePath);\n error.message = `${fpath}:${error.name}: ${error.message}`;\n callback(error);\n }\n }\n\n return function loader(source) {\n return asyncLoader.call(this, source, this.async());\n };\n}\n"],"mappings":";;;;;;;AAiBA,MAAM,8BAAc,IAAI,KAA0B;AAElD,SAAS,gBAAgB,EAAE,YAAY,OAAO,UAAgC;CAC5E,MAAM,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG;CACtC,IAAI,MAAM,YAAY,IAAI,IAAI;AAC9B,KAAI,IAAK,QAAO;AAEhB,OAAM,kBAAkB;EACtB,MAAM,IAAI,KAAK;GAAE;GAAY;GAAQ,CAAC;EACtC,aAAa;EACb,MAAM,QAAQ,QAAQ;EACvB,CAAC;AACF,aAAY,IAAI,KAAK,IAAI;AACzB,QAAO;;;;;AAMT,SAAgB,oBAAoB,eAA6D;CAC/F,IAAI;CAEJ,eAAe,YAEb,QACA,UACA;EACA,MAAM,UAAU,KAAK,YAAY;AACjC,OAAK,UAAU,KAAK;AACpB,OAAK,cAAc,QAAQ,2BAA2B;AAEtD,MAAI,CAAC,OAEH,UAAS,cADI,gBAAgB,QAAQ,CACT;AAG9B,MAAI;GACF,MAAM,SAAS,MAAM,OAAO,KAAK;IAC/B,UAAU,KAAK;IACf,OAAO,MAAM,KAAK,cAAc,MAAM,EAAE,CAAC;IACzC,YAAY;AACV,YAAO;;IAET,aAAa,KAAK,SAAS;IAC3B,UAAU;IACX,CAAC;AAEF,OAAI,WAAW,KACb,UAAS,QAAW,OAAO;OAE3B,UAAS,QAAW,OAAO,MAAM,OAAO,IAAc;WAEjD,OAAO;AACd,OAAI,iBAAiB,gBACnB,QAAO,SAAS,IAAI,MAAM,MAAM,MAAM,mBAAmB,CAAC,CAAC;AAG7D,OAAI,EAAE,iBAAiB,OAAQ,OAAM;AAGrC,SAAM,UAAU,GADF,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,CACnC,GAAG,MAAM,KAAK,IAAI,MAAM;AACjD,YAAS,MAAM;;;AAInB,QAAO,SAAS,OAAO,QAAQ;AAC7B,SAAO,YAAY,KAAK,MAAM,QAAQ,KAAK,OAAO,CAAC"}
@@ -0,0 +1,18 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) {
6
+ __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ }
11
+ if (!no_symbols) {
12
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ }
14
+ return target;
15
+ };
16
+
17
+ //#endregion
18
+ export { __exportAll as t };
@@ -34,4 +34,4 @@ function getJSONSchema(schema) {
34
34
 
35
35
  //#endregion
36
36
  export { getJSONSchema as n, validate as r, ValidationError as t };
37
- //# sourceMappingURL=validation-BvVvvLII.js.map
37
+ //# sourceMappingURL=validation-C3kXuveD.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation-BvVvvLII.js","names":[],"sources":["../src/utils/validation.ts"],"sourcesContent":["import type { StandardJSONSchemaV1, StandardSchemaV1 } from \"@standard-schema/spec\";\n\nexport class ValidationError extends Error {\n title: string;\n issues: readonly StandardSchemaV1.Issue[];\n\n constructor(message: string, issues: readonly StandardSchemaV1.Issue[]) {\n super(`${message}:\\n${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join(\"\\n\")}`);\n\n this.title = message;\n this.issues = issues;\n }\n\n async toStringFormatted() {\n // Handle ESM/CJS interop: picocolors is a CJS module that exports via\n // module.exports = createColors(). When dynamically imported in ESM context\n // (e.g., Next.js 16 Turbopack), the exports are wrapped under .default\n const picocolorsModule = await import(\"picocolors\");\n const picocolors = picocolorsModule.default ?? picocolorsModule;\n\n return [\n picocolors.bold(`[Fuma Content] ${this.title}:`),\n ...this.issues.map((issue) =>\n picocolors.redBright(\n `- ${picocolors.bold(issue.path?.join(\".\") ?? \"*\")}: ${issue.message}`,\n ),\n ),\n ].join(\"\\n\");\n }\n}\n\nexport async function validate<Schema extends StandardSchemaV1, Context>(\n schema: StandardSchemaV1 | ((context: Context) => StandardSchemaV1),\n data: unknown,\n context: Context,\n errorMessage: string,\n): Promise<StandardSchemaV1.InferOutput<Schema>> {\n if (typeof schema === \"function\" && !(\"~standard\" in schema)) {\n schema = schema(context);\n }\n\n if (\"~standard\" in schema) {\n const result = await (schema as StandardSchemaV1)[\"~standard\"].validate(data);\n\n if (result.issues) {\n throw new ValidationError(errorMessage, result.issues);\n }\n\n return result.value;\n }\n\n return data;\n}\n\n/**\n * get JSON Schema from a Standard Schema\n */\nexport function getJSONSchema(schema: StandardSchemaV1) {\n return (schema as unknown as Partial<StandardJSONSchemaV1>)[\"~standard\"]?.jsonSchema.input({\n target: \"draft-2020-12\",\n libraryOptions: {\n // for Zod\n unrepresentable: \"any\",\n },\n });\n}\n"],"mappings":";AAEA,IAAa,kBAAb,cAAqC,MAAM;CACzC;CACA;CAEA,YAAY,SAAiB,QAA2C;AACtE,QAAM,GAAG,QAAQ,KAAK,OAAO,KAAK,UAAU,KAAK,MAAM,KAAK,IAAI,MAAM,UAAU,CAAC,KAAK,KAAK,GAAG;AAE9F,OAAK,QAAQ;AACb,OAAK,SAAS;;CAGhB,MAAM,oBAAoB;EAIxB,MAAM,mBAAmB,MAAM,OAAO;EACtC,MAAM,aAAa,iBAAiB,WAAW;AAE/C,SAAO,CACL,WAAW,KAAK,kBAAkB,KAAK,MAAM,GAAG,EAChD,GAAG,KAAK,OAAO,KAAK,UAClB,WAAW,UACT,KAAK,WAAW,KAAK,MAAM,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,MAAM,UAC9D,CACF,CACF,CAAC,KAAK,KAAK;;;AAIhB,eAAsB,SACpB,QACA,MACA,SACA,cAC+C;AAC/C,KAAI,OAAO,WAAW,cAAc,EAAE,eAAe,QACnD,UAAS,OAAO,QAAQ;AAG1B,KAAI,eAAe,QAAQ;EACzB,MAAM,SAAS,MAAO,OAA4B,aAAa,SAAS,KAAK;AAE7E,MAAI,OAAO,OACT,OAAM,IAAI,gBAAgB,cAAc,OAAO,OAAO;AAGxD,SAAO,OAAO;;AAGhB,QAAO;;;;;AAMT,SAAgB,cAAc,QAA0B;AACtD,QAAQ,OAAoD,cAAc,WAAW,MAAM;EACzF,QAAQ;EACR,gBAAgB,EAEd,iBAAiB,OAClB;EACF,CAAC"}
1
+ {"version":3,"file":"validation-C3kXuveD.js","names":[],"sources":["../src/utils/validation.ts"],"sourcesContent":["import type { StandardJSONSchemaV1, StandardSchemaV1 } from \"@standard-schema/spec\";\n\nexport class ValidationError extends Error {\n title: string;\n issues: readonly StandardSchemaV1.Issue[];\n\n constructor(message: string, issues: readonly StandardSchemaV1.Issue[]) {\n super(`${message}:\\n${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join(\"\\n\")}`);\n\n this.title = message;\n this.issues = issues;\n }\n\n async toStringFormatted() {\n // Handle ESM/CJS interop: picocolors is a CJS module that exports via\n // module.exports = createColors(). When dynamically imported in ESM context\n // (e.g., Next.js 16 Turbopack), the exports are wrapped under .default\n const picocolorsModule = await import(\"picocolors\");\n const picocolors = picocolorsModule.default ?? picocolorsModule;\n\n return [\n picocolors.bold(`[Fuma Content] ${this.title}:`),\n ...this.issues.map((issue) =>\n picocolors.redBright(\n `- ${picocolors.bold(issue.path?.join(\".\") ?? \"*\")}: ${issue.message}`,\n ),\n ),\n ].join(\"\\n\");\n }\n}\n\nexport async function validate<Schema extends StandardSchemaV1, Context>(\n schema: StandardSchemaV1 | ((context: Context) => StandardSchemaV1),\n data: unknown,\n context: Context,\n errorMessage: string,\n): Promise<StandardSchemaV1.InferOutput<Schema>> {\n if (typeof schema === \"function\" && !(\"~standard\" in schema)) {\n schema = schema(context);\n }\n\n if (\"~standard\" in schema) {\n const result = await (schema as StandardSchemaV1)[\"~standard\"].validate(data);\n\n if (result.issues) {\n throw new ValidationError(errorMessage, result.issues);\n }\n\n return result.value;\n }\n\n return data;\n}\n\n/**\n * get JSON Schema from a Standard Schema\n */\nexport function getJSONSchema(schema: StandardSchemaV1) {\n return (schema as unknown as Partial<StandardJSONSchemaV1>)[\"~standard\"]?.jsonSchema.input({\n target: \"draft-2020-12\",\n libraryOptions: {\n // for Zod\n unrepresentable: \"any\",\n },\n });\n}\n"],"mappings":";AAEA,IAAa,kBAAb,cAAqC,MAAM;CACzC;CACA;CAEA,YAAY,SAAiB,QAA2C;AACtE,QAAM,GAAG,QAAQ,KAAK,OAAO,KAAK,UAAU,KAAK,MAAM,KAAK,IAAI,MAAM,UAAU,CAAC,KAAK,KAAK,GAAG;AAE9F,OAAK,QAAQ;AACb,OAAK,SAAS;;CAGhB,MAAM,oBAAoB;EAIxB,MAAM,mBAAmB,MAAM,OAAO;EACtC,MAAM,aAAa,iBAAiB,WAAW;AAE/C,SAAO,CACL,WAAW,KAAK,kBAAkB,KAAK,MAAM,GAAG,EAChD,GAAG,KAAK,OAAO,KAAK,UAClB,WAAW,UACT,KAAK,WAAW,KAAK,MAAM,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,MAAM,UAC9D,CACF,CACF,CAAC,KAAK,KAAK;;;AAIhB,eAAsB,SACpB,QACA,MACA,SACA,cAC+C;AAC/C,KAAI,OAAO,WAAW,cAAc,EAAE,eAAe,QACnD,UAAS,OAAO,QAAQ;AAG1B,KAAI,eAAe,QAAQ;EACzB,MAAM,SAAS,MAAO,OAA4B,aAAa,SAAS,KAAK;AAE7E,MAAI,OAAO,OACT,OAAM,IAAI,gBAAgB,cAAc,OAAO,OAAO;AAGxD,SAAO,OAAO;;AAGhB,QAAO;;;;;AAMT,SAAgB,cAAc,QAA0B;AACtD,QAAQ,OAAoD,cAAc,WAAW,MAAM;EACzF,QAAQ;EACR,gBAAgB,EAEd,iBAAiB,OAClB;EACF,CAAC"}
@@ -1,4 +1,4 @@
1
- import { n as CoreOptions, t as Core } from "../core-CT06v32N.js";
1
+ import { n as CoreOptions, t as Core } from "../core-CG2zTL4c.js";
2
2
  import { PluginOption } from "vite";
3
3
 
4
4
  //#region src/vite/index.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/vite/index.ts"],"sourcesContent":[],"mappings":";;;;UAKiB,aAAA,SAAsB,KAAK;;AAA5C;AAOC;;;EAKU,KAAA,CAAA,EAAA,OAAA;;AAAD,iBAHoB,OAAA,CAGpB,MAAA,EAFA,MAEA,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,aAAA,CAAA,EADO,aACP,CAAA,EAAP,OAAO,CAAC,YAAD,EAAA,CAAA;AA8CY,iBAAA,oBAAA,CAAoB,aAAA,CAAA,EAAgB,aAAhB,CAAA,EAAkC,OAAlC,CAAkC,IAAlC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/vite/index.ts"],"mappings":";;;;UAKiB,aAAA,SAAsB,IAAA,CAAK,WAAA;;AAA5C;;;;EAME,KAAA;AAAA;AAAA,iBAG4B,OAAA,CAC5B,MAAA,EAAQ,MAAA,mBACR,aAAA,GAAe,aAAA,GACd,OAAA,CAAQ,YAAA;AAAA,iBA8CW,oBAAA,CAAqB,aAAA,GAAe,aAAA,GAAkB,OAAA,CAAA,IAAA"}
@@ -1,5 +1,5 @@
1
- import { t as Core } from "../core-Uv3jZqL-.js";
2
- import { n as loaderPlugin } from "../loader-B4nQrRwA.js";
1
+ import { t as Core } from "../core-DmbQk8Z2.js";
2
+ import { loaderPlugin } from "../plugins/loader/index.js";
3
3
 
4
4
  //#region src/vite/index.ts
5
5
  async function content(config, pluginOpitons = {}) {
@@ -38,7 +38,7 @@ function vitePlugin() {
38
38
  };
39
39
  }
40
40
  async function createStandaloneCore(pluginOptions = {}) {
41
- const { loadConfig } = await import("../load-from-file-D-Xm95Fz.js");
41
+ const { loadConfig } = await import("../load-from-file-BeLFB77e.js").then((n) => n.n);
42
42
  const core = createViteCore(pluginOptions);
43
43
  await core.init({ config: loadConfig(core, true) });
44
44
  return core;
@@ -14,8 +14,8 @@ function toVite(name, test, loader) {
14
14
  return value;
15
15
  },
16
16
  development: this.environment.mode === "dev",
17
- compiler: { addDependency: (file$1) => {
18
- this.addWatchFile(file$1);
17
+ compiler: { addDependency: (file) => {
18
+ this.addWatchFile(file);
19
19
  } }
20
20
  });
21
21
  if (result === null) return null;
@@ -30,4 +30,4 @@ function toVite(name, test, loader) {
30
30
 
31
31
  //#endregion
32
32
  export { toVite };
33
- //# sourceMappingURL=vite-C1qXY47G.js.map
33
+ //# sourceMappingURL=vite-mAc2TZyp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-mAc2TZyp.js","names":[],"sources":["../src/plugins/loader/vite.ts"],"sourcesContent":["import type { SourceMap } from \"rollup\";\nimport type { PluginOption } from \"vite\";\nimport { parse } from \"node:querystring\";\nimport type { Loader } from \"@/plugins/loader\";\n\nexport function toVite(name: string, test: RegExp | undefined, loader: Loader): PluginOption {\n return {\n name: `fuma-content:${name}`,\n async transform(value, id) {\n if (test && !test.test(id)) return;\n\n const [file, query = \"\"] = id.split(\"?\", 2);\n const result = await loader.load({\n filePath: file,\n query: parse(query),\n getSource() {\n return value;\n },\n development: this.environment.mode === \"dev\",\n compiler: {\n addDependency: (file) => {\n this.addWatchFile(file);\n },\n },\n });\n\n if (result === null) return null;\n return {\n code: result.code,\n map: result.map as SourceMap,\n moduleType: result.moduleType,\n };\n },\n };\n}\n"],"mappings":";;;AAKA,SAAgB,OAAO,MAAc,MAA0B,QAA8B;AAC3F,QAAO;EACL,MAAM,gBAAgB;EACtB,MAAM,UAAU,OAAO,IAAI;AACzB,OAAI,QAAQ,CAAC,KAAK,KAAK,GAAG,CAAE;GAE5B,MAAM,CAAC,MAAM,QAAQ,MAAM,GAAG,MAAM,KAAK,EAAE;GAC3C,MAAM,SAAS,MAAM,OAAO,KAAK;IAC/B,UAAU;IACV,OAAO,MAAM,MAAM;IACnB,YAAY;AACV,YAAO;;IAET,aAAa,KAAK,YAAY,SAAS;IACvC,UAAU,EACR,gBAAgB,SAAS;AACvB,UAAK,aAAa,KAAK;OAE1B;IACF,CAAC;AAEF,OAAI,WAAW,KAAM,QAAO;AAC5B,UAAO;IACL,MAAM,OAAO;IACb,KAAK,OAAO;IACZ,YAAY,OAAO;IACpB;;EAEJ"}