fuma-content 1.1.0 → 1.1.2

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 (125) hide show
  1. package/dist/{build-mdx-BZxE8t2a.js → build-mdx-CUp6FpfT.js} +2 -2
  2. package/dist/{build-mdx-BZxE8t2a.js.map → build-mdx-CUp6FpfT.js.map} +1 -1
  3. package/dist/build-mdx-D6zM3Sgl.js +4 -0
  4. package/dist/bun/index.d.ts +1 -1
  5. package/dist/bun/index.js +2 -2
  6. package/dist/{code-generator-CjC4EEXg.js → code-generator-Qhhq7kHh.js} +30 -24
  7. package/dist/code-generator-Qhhq7kHh.js.map +1 -0
  8. package/dist/collections/data/runtime.d.ts +6 -6
  9. package/dist/collections/data.d.ts +5 -5
  10. package/dist/collections/data.d.ts.map +1 -1
  11. package/dist/collections/data.js +3 -3
  12. package/dist/collections/fs.d.ts +2 -2
  13. package/dist/collections/fs.js +1 -1
  14. package/dist/collections/index.d.ts +1 -1
  15. package/dist/collections/index.js +1 -1
  16. package/dist/collections/json/loader-webpack.d.ts +3 -3
  17. package/dist/collections/json/loader-webpack.js +6 -6
  18. package/dist/collections/mdx/loader-webpack.d.ts +3 -3
  19. package/dist/collections/mdx/loader-webpack.js +6 -6
  20. package/dist/collections/mdx/react.d.ts +10 -10
  21. package/dist/collections/mdx/runtime-browser.d.ts +10 -10
  22. package/dist/collections/mdx/runtime-browser.js +1 -1
  23. package/dist/collections/mdx/runtime-dynamic.d.ts +9 -9
  24. package/dist/collections/mdx/runtime-dynamic.js +6 -6
  25. package/dist/collections/mdx/runtime.d.ts +9 -9
  26. package/dist/collections/mdx.d.ts +5 -5
  27. package/dist/collections/mdx.js +4 -4
  28. package/dist/collections/runtime/file-store.d.ts +3 -3
  29. package/dist/collections/runtime/file-store.js +1 -4
  30. package/dist/collections/runtime/file-store.js.map +1 -1
  31. package/dist/collections/runtime/store.d.ts +2 -2
  32. package/dist/collections/runtime/store.js +1 -1
  33. package/dist/collections/yaml/loader-webpack.d.ts +3 -3
  34. package/dist/collections/yaml/loader-webpack.js +6 -6
  35. package/dist/{collections-DNFRdCuB.js → collections-CNWuMDAZ.js} +7 -13
  36. package/dist/collections-CNWuMDAZ.js.map +1 -0
  37. package/dist/config/index.d.ts +2 -2
  38. package/dist/config/index.js.map +1 -1
  39. package/dist/{core-BO3b8jMg.d.ts → core-CT06v32N.d.ts} +23 -24
  40. package/dist/core-CT06v32N.d.ts.map +1 -0
  41. package/dist/{core-D5QHSKk6.js → core-Uv3jZqL-.js} +15 -20
  42. package/dist/core-Uv3jZqL-.js.map +1 -0
  43. package/dist/{data-9h98oZwj.js → data-Cxsx5KPD.js} +34 -33
  44. package/dist/data-Cxsx5KPD.js.map +1 -0
  45. package/dist/{dynamic-CTYYdl7_.d.ts → dynamic-Ck1wYoaL.d.ts} +2 -2
  46. package/dist/{dynamic-CTYYdl7_.d.ts.map → dynamic-Ck1wYoaL.d.ts.map} +1 -1
  47. package/dist/{dynamic-DhKTOrIl.js → dynamic-CtOB4Rkp.js} +2 -2
  48. package/dist/{dynamic-DhKTOrIl.js.map → dynamic-CtOB4Rkp.js.map} +1 -1
  49. package/dist/dynamic.d.ts +2 -2
  50. package/dist/dynamic.js +1 -1
  51. package/dist/{file-store-laO4IjvB.d.ts → file-store-Dm1SjuLg.d.ts} +2 -3
  52. package/dist/file-store-Dm1SjuLg.d.ts.map +1 -0
  53. package/dist/fs-CXzVd2Dp.js +68 -0
  54. package/dist/fs-CXzVd2Dp.js.map +1 -0
  55. package/dist/{fs-D34Sztbh.d.ts → fs-CmwaaFyx.d.ts} +6 -5
  56. package/dist/fs-CmwaaFyx.d.ts.map +1 -0
  57. package/dist/{git-CQWA37-X.js → git-DnejL9r_.js} +2 -2
  58. package/dist/{git-CQWA37-X.js.map → git-DnejL9r_.js.map} +1 -1
  59. package/dist/{git-2CjUW3M5.d.ts → git-n-9ddn78.d.ts} +2 -2
  60. package/dist/{git-2CjUW3M5.d.ts.map → git-n-9ddn78.d.ts.map} +1 -1
  61. package/dist/{index-Da88Sj8w.d.ts → index-BheUVWBm.d.ts} +3 -3
  62. package/dist/{index-Da88Sj8w.d.ts.map → index-BheUVWBm.d.ts.map} +1 -1
  63. package/dist/index.d.ts +2 -2
  64. package/dist/index.js +2 -2
  65. package/dist/load-from-file-D-Xm95Fz.js +3 -0
  66. package/dist/{load-from-file-irx0JI6j.js → load-from-file-z7EGuf2n.js} +2 -2
  67. package/dist/{load-from-file-irx0JI6j.js.map → load-from-file-z7EGuf2n.js.map} +1 -1
  68. package/dist/{loader-BuR4gkKg.js → loader-B4nQrRwA.js} +2 -2
  69. package/dist/{loader-BuR4gkKg.js.map → loader-B4nQrRwA.js.map} +1 -1
  70. package/dist/loader-B6ordrWK.js +9 -0
  71. package/dist/{loader-BhXHF8vy.js → loader-BK8PnqRg.js} +2 -2
  72. package/dist/{loader-BhXHF8vy.js.map → loader-BK8PnqRg.js.map} +1 -1
  73. package/dist/{loader-D6StkShK.js → loader-CnksfM7I.js} +3 -3
  74. package/dist/{loader-D6StkShK.js.map → loader-CnksfM7I.js.map} +1 -1
  75. package/dist/{loader-DwpOcxgh.js → loader-Cnz-VHne.js} +2 -2
  76. package/dist/{loader-DwpOcxgh.js.map → loader-Cnz-VHne.js.map} +1 -1
  77. package/dist/{loader-BzQpSBvP.js → loader-CuntMmR4.js} +2 -2
  78. package/dist/{loader-BzQpSBvP.js.map → loader-CuntMmR4.js.map} +1 -1
  79. package/dist/loader-Cx1Rg_VM.js +8 -0
  80. package/dist/loader-Dao_nv3e.js +8 -0
  81. package/dist/mdx-Cw1nBJ0D.js +306 -0
  82. package/dist/mdx-Cw1nBJ0D.js.map +1 -0
  83. package/dist/{mdx-Dt9hirUu.d.ts → mdx-PaqRNZMS.d.ts} +7 -16
  84. package/dist/mdx-PaqRNZMS.d.ts.map +1 -0
  85. package/dist/next/index.d.ts +1 -1
  86. package/dist/next/index.js +3 -3
  87. package/dist/node/index.d.ts +1 -1
  88. package/dist/node/loader.d.ts +1 -1
  89. package/dist/node/loader.js +3 -3
  90. package/dist/plugins/git.d.ts +2 -2
  91. package/dist/plugins/git.js +1 -1
  92. package/dist/plugins/json-schema.d.ts +1 -1
  93. package/dist/plugins/json-schema.js +2 -2
  94. package/dist/plugins/loader/index.d.ts +3 -3
  95. package/dist/plugins/loader/index.js +1 -1
  96. package/dist/plugins/loader/webpack.d.ts +3 -3
  97. package/dist/plugins/loader/webpack.js +2 -2
  98. package/dist/{runtime-HN-HSB0Z.d.ts → runtime-BUUHSFlR.d.ts} +5 -5
  99. package/dist/{runtime-HN-HSB0Z.d.ts.map → runtime-BUUHSFlR.d.ts.map} +1 -1
  100. package/dist/{runtime-browser-BQEk7qjc.d.ts → runtime-browser-B70WGxeQ.d.ts} +4 -4
  101. package/dist/{runtime-browser-BQEk7qjc.d.ts.map → runtime-browser-B70WGxeQ.d.ts.map} +1 -1
  102. package/dist/{store-IvpEBdxi.js → store-CRyvZFKN.js} +7 -10
  103. package/dist/{store-IvpEBdxi.js.map → store-CRyvZFKN.js.map} +1 -1
  104. package/dist/{store-DiuGdV5M.d.ts → store-D_PPrdRE.d.ts} +4 -4
  105. package/dist/{store-DiuGdV5M.d.ts.map → store-D_PPrdRE.d.ts.map} +1 -1
  106. package/dist/vite/index.d.ts +1 -1
  107. package/dist/vite/index.js +3 -3
  108. package/package.json +10 -10
  109. package/dist/build-mdx-LhpFasX-.js +0 -4
  110. package/dist/code-generator-CjC4EEXg.js.map +0 -1
  111. package/dist/collections-DNFRdCuB.js.map +0 -1
  112. package/dist/core-BO3b8jMg.d.ts.map +0 -1
  113. package/dist/core-D5QHSKk6.js.map +0 -1
  114. package/dist/data-9h98oZwj.js.map +0 -1
  115. package/dist/file-store-laO4IjvB.d.ts.map +0 -1
  116. package/dist/fs-D34Sztbh.d.ts.map +0 -1
  117. package/dist/fs-WWbLA7Gx.js +0 -66
  118. package/dist/fs-WWbLA7Gx.js.map +0 -1
  119. package/dist/load-from-file-BZxc_BhC.js +0 -3
  120. package/dist/loader-AIEwGc2f.js +0 -9
  121. package/dist/loader-DCK4RwOh.js +0 -8
  122. package/dist/loader-zsTVgQjO.js +0 -8
  123. package/dist/mdx-Dt9hirUu.d.ts.map +0 -1
  124. package/dist/mdx-iZ2uP27Z.js +0 -303
  125. package/dist/mdx-iZ2uP27Z.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import "../../core-BO3b8jMg.js";
2
- import "../../store-DiuGdV5M.js";
3
- import { n as FileInfo, t as FileCollectionStore } from "../../file-store-laO4IjvB.js";
1
+ import "../../core-CT06v32N.js";
2
+ import "../../store-D_PPrdRE.js";
3
+ import { n as FileInfo, t as FileCollectionStore } from "../../file-store-Dm1SjuLg.js";
4
4
  export { FileCollectionStore, FileInfo };
@@ -1,4 +1,4 @@
1
- import { t as MapCollectionStore } from "../../store-IvpEBdxi.js";
1
+ import { t as MapCollectionStore } from "../../store-CRyvZFKN.js";
2
2
  import path from "node:path";
3
3
 
4
4
  //#region src/collections/runtime/file-store.ts
@@ -19,9 +19,6 @@ var FileCollectionStore = class extends MapCollectionStore {
19
19
  }
20
20
  super(data);
21
21
  }
22
- transform(fn) {
23
- return super.transform(fn);
24
- }
25
22
  castData(_cast) {
26
23
  return super.castData(_cast);
27
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"file-store.js","names":[],"sources":["../../../src/collections/runtime/file-store.ts"],"sourcesContent":["import path from \"node:path\";\nimport { MapCollectionStore } from \"@/collections/runtime/store\";\n\nexport interface FileInfo {\n /**\n * path relative to content directory\n */\n path: string;\n\n /**\n * the full file path in file system\n */\n fullPath: string;\n}\n\nfunction formatGlobKey(globKey: string) {\n if (globKey.startsWith(\"./\")) {\n return globKey.slice(2);\n }\n\n return globKey;\n}\n\nexport class FileCollectionStore<V> extends MapCollectionStore<string, FileInfo & V> {\n constructor(base: string, glob: Record<string, V>) {\n const data = new Map<string, FileInfo & V>();\n for (const [key, value] of Object.entries(glob)) {\n const filePath = formatGlobKey(key);\n data.set(key, {\n ...value,\n path: filePath,\n fullPath: path.join(base, filePath),\n });\n }\n super(data);\n }\n\n transform<T>(fn: (input: FileInfo & V) => FileInfo & T): FileCollectionStore<T> {\n return super.transform(fn);\n }\n\n castData<T>(_cast: (input: FileInfo & V) => FileInfo & T): FileCollectionStore<T> {\n return super.castData(_cast);\n }\n}\n"],"mappings":";;;;AAeA,SAAS,cAAc,SAAiB;AACtC,KAAI,QAAQ,WAAW,KAAK,CAC1B,QAAO,QAAQ,MAAM,EAAE;AAGzB,QAAO;;AAGT,IAAa,sBAAb,cAA4C,mBAAyC;CACnF,YAAY,MAAc,MAAyB;EACjD,MAAM,uBAAO,IAAI,KAA2B;AAC5C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,EAAE;GAC/C,MAAM,WAAW,cAAc,IAAI;AACnC,QAAK,IAAI,KAAK;IACZ,GAAG;IACH,MAAM;IACN,UAAU,KAAK,KAAK,MAAM,SAAS;IACpC,CAAC;;AAEJ,QAAM,KAAK;;CAGb,UAAa,IAAmE;AAC9E,SAAO,MAAM,UAAU,GAAG;;CAG5B,SAAY,OAAsE;AAChF,SAAO,MAAM,SAAS,MAAM"}
1
+ {"version":3,"file":"file-store.js","names":[],"sources":["../../../src/collections/runtime/file-store.ts"],"sourcesContent":["import path from \"node:path\";\nimport { MapCollectionStore } from \"@/collections/runtime/store\";\n\nexport interface FileInfo {\n /**\n * path relative to content directory\n */\n path: string;\n\n /**\n * the full file path in file system\n */\n fullPath: string;\n}\n\nfunction formatGlobKey(globKey: string) {\n if (globKey.startsWith(\"./\")) {\n return globKey.slice(2);\n }\n\n return globKey;\n}\n\nexport class FileCollectionStore<V> extends MapCollectionStore<string, FileInfo & V> {\n constructor(base: string, glob: Record<string, V>) {\n const data = new Map<string, FileInfo & V>();\n for (const [key, value] of Object.entries(glob)) {\n const filePath = formatGlobKey(key);\n data.set(key, {\n ...value,\n path: filePath,\n fullPath: path.join(base, filePath),\n });\n }\n super(data);\n }\n\n castData<T>(_cast: (input: FileInfo & V) => FileInfo & T): FileCollectionStore<T> {\n return super.castData(_cast);\n }\n}\n"],"mappings":";;;;AAeA,SAAS,cAAc,SAAiB;AACtC,KAAI,QAAQ,WAAW,KAAK,CAC1B,QAAO,QAAQ,MAAM,EAAE;AAGzB,QAAO;;AAGT,IAAa,sBAAb,cAA4C,mBAAyC;CACnF,YAAY,MAAc,MAAyB;EACjD,MAAM,uBAAO,IAAI,KAA2B;AAC5C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,EAAE;GAC/C,MAAM,WAAW,cAAc,IAAI;AACnC,QAAK,IAAI,KAAK;IACZ,GAAG;IACH,MAAM;IACN,UAAU,KAAK,KAAK,MAAM,SAAS;IACpC,CAAC;;AAEJ,QAAM,KAAK;;CAGb,SAAY,OAAsE;AAChF,SAAO,MAAM,SAAS,MAAM"}
@@ -1,3 +1,3 @@
1
- import "../../core-BO3b8jMg.js";
2
- import { n as MapCollectionStore, t as CollectionStore } from "../../store-DiuGdV5M.js";
1
+ import "../../core-CT06v32N.js";
2
+ import { n as MapCollectionStore, t as CollectionStore } from "../../store-D_PPrdRE.js";
3
3
  export { CollectionStore, MapCollectionStore };
@@ -1,3 +1,3 @@
1
- import { t as MapCollectionStore } from "../../store-IvpEBdxi.js";
1
+ import { t as MapCollectionStore } from "../../store-CRyvZFKN.js";
2
2
 
3
3
  export { MapCollectionStore };
@@ -1,6 +1,6 @@
1
- import "../../core-BO3b8jMg.js";
2
- import "../../dynamic-CTYYdl7_.js";
3
- import { l as WebpackLoader } from "../../index-Da88Sj8w.js";
1
+ import "../../core-CT06v32N.js";
2
+ import "../../dynamic-Ck1wYoaL.js";
3
+ import { l as WebpackLoader } from "../../index-BheUVWBm.js";
4
4
 
5
5
  //#region src/collections/yaml/loader-webpack.d.ts
6
6
  declare const _default: WebpackLoader;
@@ -1,11 +1,11 @@
1
- import "../../dynamic-DhKTOrIl.js";
1
+ import "../../dynamic-CtOB4Rkp.js";
2
2
  import "../../validation-BvVvvLII.js";
3
- import "../../loader-BuR4gkKg.js";
4
- import "../../fs-WWbLA7Gx.js";
5
- import "../../data-9h98oZwj.js";
3
+ import "../../loader-B4nQrRwA.js";
4
+ import "../../fs-CXzVd2Dp.js";
5
+ import "../../data-Cxsx5KPD.js";
6
6
  import { createWebpackLoader } from "../../plugins/loader/webpack.js";
7
- import "../../loader-BzQpSBvP.js";
8
- import { t as createYamlLoader } from "../../loader-DwpOcxgh.js";
7
+ import "../../loader-CuntMmR4.js";
8
+ import { t as createYamlLoader } from "../../loader-Cnz-VHne.js";
9
9
 
10
10
  //#region src/collections/yaml/loader-webpack.ts
11
11
  var loader_webpack_default = createWebpackLoader((core) => createYamlLoader(core));
@@ -7,7 +7,8 @@ function hook(steps = []) {
7
7
  hook(fn) {
8
8
  steps.push(fn);
9
9
  return this;
10
- }
10
+ },
11
+ $inferHandler: void 0
11
12
  };
12
13
  }
13
14
  function asyncHook(steps = []) {
@@ -18,7 +19,8 @@ function asyncHook(steps = []) {
18
19
  hook(fn) {
19
20
  steps.push(fn);
20
21
  return this;
21
- }
22
+ },
23
+ $inferHandler: void 0
22
24
  };
23
25
  }
24
26
 
@@ -34,9 +36,7 @@ function pipe(steps = []) {
34
36
  steps.push(fn);
35
37
  return this;
36
38
  },
37
- clone() {
38
- return pipe([...steps]);
39
- }
39
+ $inferHandler: void 0
40
40
  };
41
41
  }
42
42
  function asyncPipe(steps = []) {
@@ -49,9 +49,7 @@ function asyncPipe(steps = []) {
49
49
  steps.push(fn);
50
50
  return this;
51
51
  },
52
- clone() {
53
- return asyncPipe([...steps]);
54
- }
52
+ $inferHandler: void 0
55
53
  };
56
54
  }
57
55
 
@@ -71,10 +69,6 @@ var Collection = class {
71
69
  onInit = asyncHook();
72
70
  onEmit = asyncPipe();
73
71
  plugins = [];
74
- transform(transformer) {
75
- transformer(this);
76
- return this;
77
- }
78
72
  pluginHook(hook$1, options) {
79
73
  let created = this.pluginHooks.get(hook$1.id);
80
74
  if (created) return created;
@@ -95,4 +89,4 @@ function defineCollectionHook(init) {
95
89
 
96
90
  //#endregion
97
91
  export { asyncHook as a, pipe as i, defineCollectionHook as n, hook as o, asyncPipe as r, Collection as t };
98
- //# sourceMappingURL=collections-DNFRdCuB.js.map
92
+ //# sourceMappingURL=collections-CNWuMDAZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections-CNWuMDAZ.js","names":["hook"],"sources":["../src/utils/hook.ts","../src/utils/pipe.ts","../src/collections/index.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","import { Core, EmitContext, EmitEntry, PluginOption, ResolvedConfig, ServerContext } from \"@/core\";\nimport { asyncHook, hook } from \"@/utils/hook\";\nimport { asyncPipe } from \"@/utils/pipe\";\n\nexport interface CollectionHookContext {\n core: Core;\n collection: Collection;\n}\n\nexport class Collection {\n private readonly pluginHooks = new Map<symbol, unknown>();\n name = null as unknown as string;\n\n /**\n * on config loaded/updated\n */\n readonly onConfig = hook<CollectionHookContext & { config: ResolvedConfig }>();\n /**\n * Configure watch/dev server\n */\n readonly onServer = hook<CollectionHookContext & { server: ServerContext }>();\n readonly onInit = asyncHook<CollectionHookContext>();\n readonly onEmit = asyncPipe<EmitEntry[], EmitContext>();\n readonly plugins: PluginOption[] = [];\n\n pluginHook<T, Options>(hook: CollectionHook<T, Options>, options: Options): T;\n pluginHook<T>(hook: CollectionHook<T>): T;\n\n pluginHook<T, O>(hook: CollectionHook<T, O>, options?: O): T {\n let created = this.pluginHooks.get(hook.id) as T | undefined;\n if (created) return created;\n\n created = hook.create(this, options as O);\n this.pluginHooks.set(hook.id, created);\n return created;\n }\n\n getPluginHook<T>(hook: CollectionHook<T>): T | undefined {\n return this.pluginHooks.get(hook.id) as T | undefined;\n }\n}\n\nexport interface CollectionHook<T = unknown, Options = undefined> {\n id: symbol;\n create: (collection: Collection, options: Options) => T;\n}\n\nexport function defineCollectionHook<T, Options = undefined>(\n init: (collection: Collection, options: Options) => T,\n): CollectionHook<T, Options> {\n return {\n id: Symbol(),\n create: init,\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;;;;;AChDH,IAAa,aAAb,MAAwB;CACtB,AAAiB,8BAAc,IAAI,KAAsB;CACzD,OAAO;;;;CAKP,AAAS,WAAW,MAA0D;;;;CAI9E,AAAS,WAAW,MAAyD;CAC7E,AAAS,SAAS,WAAkC;CACpD,AAAS,SAAS,WAAqC;CACvD,AAAS,UAA0B,EAAE;CAKrC,WAAiB,QAA4B,SAAgB;EAC3D,IAAI,UAAU,KAAK,YAAY,IAAIA,OAAK,GAAG;AAC3C,MAAI,QAAS,QAAO;AAEpB,YAAUA,OAAK,OAAO,MAAM,QAAa;AACzC,OAAK,YAAY,IAAIA,OAAK,IAAI,QAAQ;AACtC,SAAO;;CAGT,cAAiB,QAAwC;AACvD,SAAO,KAAK,YAAY,IAAIA,OAAK,GAAG;;;AASxC,SAAgB,qBACd,MAC4B;AAC5B,QAAO;EACL,IAAI,QAAQ;EACZ,QAAQ;EACT"}
@@ -1,2 +1,2 @@
1
- import { A as defineConfig, O as GlobalConfig, k as WorkspaceConfig } from "../core-BO3b8jMg.js";
2
- export { GlobalConfig, WorkspaceConfig, defineConfig };
1
+ import { A as WorkspaceConfig, O as EmitConfig, j as defineConfig, k as GlobalConfig } from "../core-CT06v32N.js";
2
+ export { EmitConfig, GlobalConfig, WorkspaceConfig, defineConfig };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/config/index.ts"],"sourcesContent":["import { Collection } from \"@/collections\";\nimport type { PluginOption } from \"@/core\";\n\nexport interface GlobalConfig<\n Collections extends Record<string, Collection> = Record<string, Collection>,\n> {\n plugins?: PluginOption[];\n collections?: Collections;\n workspaces?: Record<string, WorkspaceConfig>;\n\n /**\n * specify a directory to access & store cache (disabled during development mode).\n *\n * The cache will never be updated, delete the cache folder to clean.\n */\n experimentalBuildCache?: string;\n\n /**\n * configure code generation\n */\n emit?: {\n target?: \"default\" | \"vite\";\n /**\n * add .js extenstion to imports\n */\n jsExtension?: boolean;\n };\n}\n\nexport interface WorkspaceConfig {\n dir: string;\n config: GlobalConfig | { default: GlobalConfig };\n}\n\nexport function defineConfig<\n Collections extends Record<string, Collection> = Record<string, Collection>,\n>(config: GlobalConfig<Collections> = {}): GlobalConfig<Collections> {\n return config;\n}\n"],"mappings":";AAkCA,SAAgB,aAEd,SAAoC,EAAE,EAA6B;AACnE,QAAO"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/config/index.ts"],"sourcesContent":["import { Collection } from \"@/collections\";\nimport type { PluginOption } from \"@/core\";\n\nexport interface GlobalConfig<\n Collections extends Record<string, Collection> = Record<string, Collection>,\n> {\n plugins?: PluginOption[];\n collections?: Collections;\n workspaces?: Record<string, WorkspaceConfig>;\n\n /**\n * specify a directory to access & store cache (disabled during development mode).\n *\n * The cache will never be updated, delete the cache folder to clean.\n */\n experimentalBuildCache?: string;\n\n /**\n * configure code generation\n */\n emit?: EmitConfig;\n}\n\nexport interface EmitConfig {\n target?: \"default\" | \"vite\";\n /**\n * add .js extenstion to imports\n */\n jsExtension?: boolean;\n}\n\nexport interface WorkspaceConfig {\n dir: string;\n config: GlobalConfig | { default: GlobalConfig };\n}\n\nexport function defineConfig<\n Collections extends Record<string, Collection> = Record<string, Collection>,\n>(config: GlobalConfig<Collections> = {}): GlobalConfig<Collections> {\n return config;\n}\n"],"mappings":";AAoCA,SAAgB,aAEd,SAAoC,EAAE,EAA6B;AACnE,QAAO"}
@@ -17,13 +17,14 @@ interface GlobalConfig<Collections$1 extends Record<string, Collection> = Record
17
17
  /**
18
18
  * configure code generation
19
19
  */
20
- emit?: {
21
- target?: "default" | "vite";
22
- /**
23
- * add .js extenstion to imports
24
- */
25
- jsExtension?: boolean;
26
- };
20
+ emit?: EmitConfig;
21
+ }
22
+ interface EmitConfig {
23
+ target?: "default" | "vite";
24
+ /**
25
+ * add .js extenstion to imports
26
+ */
27
+ jsExtension?: boolean;
27
28
  }
28
29
  interface WorkspaceConfig {
29
30
  dir: string;
@@ -48,6 +49,7 @@ interface Hook<Context = undefined> {
48
49
  */
49
50
  hook: (fn: (context: Context) => void) => Hook<Context>;
50
51
  run: (context: Context) => void;
52
+ $inferHandler: (context: Context) => Awaitable<void>;
51
53
  }
52
54
  interface AsyncHook<Context = undefined> {
53
55
  /**
@@ -57,6 +59,7 @@ interface AsyncHook<Context = undefined> {
57
59
  */
58
60
  hook: (fn: (context: Context) => Awaitable<void>) => AsyncHook<Context>;
59
61
  run: (context: Context) => Awaitable<void>;
62
+ $inferHandler: (context: Context) => Awaitable<void>;
60
63
  }
61
64
  declare function hook<Context>(steps?: ((ctx: Context) => void)[]): Hook<Context>;
62
65
  declare function asyncHook<Context>(steps?: ((ctx: Context) => Awaitable<void>)[]): AsyncHook<Context>;
@@ -70,7 +73,7 @@ interface Pipe<Data, Context = undefined> {
70
73
  */
71
74
  pipe: (fn: (data: Data, context: Context) => Data) => Pipe<Data, Context>;
72
75
  run: (data: Data, context: Context) => Data;
73
- clone: () => Pipe<Data, Context>;
76
+ $inferHandler: (data: Data, context: Context) => Data;
74
77
  }
75
78
  interface AsyncPipe<Data, Context = undefined> {
76
79
  /**
@@ -80,7 +83,7 @@ interface AsyncPipe<Data, Context = undefined> {
80
83
  */
81
84
  pipe: (fn: (data: Data, context: Context) => Awaitable<Data>) => AsyncPipe<Data, Context>;
82
85
  run: (data: Data, context: Context) => Awaitable<Data>;
83
- clone: () => AsyncPipe<Data, Context>;
86
+ $inferHandler: (data: Data, context: Context) => Awaitable<Data>;
84
87
  }
85
88
  declare function pipe<Data, Context>(steps?: ((data: Data, context: Context) => Data)[]): Pipe<Data, Context>;
86
89
  declare function asyncPipe<Data, Context>(steps?: ((data: Data, context: Context) => Awaitable<Data>)[]): AsyncPipe<Data, Context>;
@@ -108,7 +111,6 @@ declare class Collection {
108
111
  readonly onInit: AsyncHook<CollectionHookContext>;
109
112
  readonly onEmit: AsyncPipe<EmitEntry[], EmitContext>;
110
113
  readonly plugins: PluginOption$1[];
111
- transform(transformer: (collection: this) => void): this;
112
114
  pluginHook<T, Options>(hook: CollectionHook<T, Options>, options: Options): T;
113
115
  pluginHook<T>(hook: CollectionHook<T>): T;
114
116
  getPluginHook<T>(hook: CollectionHook<T>): T | undefined;
@@ -120,13 +122,8 @@ interface CollectionHook<T = unknown, Options = undefined> {
120
122
  declare function defineCollectionHook<T, Options = undefined>(init: (collection: Collection, options: Options) => T): CollectionHook<T, Options>;
121
123
  //#endregion
122
124
  //#region src/utils/code-generator.d.ts
123
- interface CodeGeneratorOptions {
124
- target: "default" | "vite";
125
+ interface CodeGeneratorOptions extends EmitConfig {
125
126
  outDir: string;
126
- /**
127
- * add .js extenstion to imports
128
- */
129
- jsExtension: boolean;
130
127
  }
131
128
  /**
132
129
  * Code generator (one instance per file)
@@ -168,12 +165,9 @@ interface PluginContext {
168
165
  core: Core;
169
166
  }
170
167
  interface EmitContext extends PluginContext {
171
- createCodeGenerator: (path: string, content: (ctx: EmitCodeGeneratorContext) => Promise<void>) => Promise<EmitEntry>;
172
- }
173
- interface EmitCodeGeneratorContext {
174
- core: Core;
175
- workspace?: string;
176
- codegen: CodeGenerator;
168
+ createCodeGenerator: (path: string, content: (ctx: {
169
+ codegen: CodeGenerator;
170
+ }) => Awaitable<void>) => Promise<EmitEntry>;
177
171
  }
178
172
  interface Plugin {
179
173
  /**
@@ -288,6 +282,11 @@ declare class Core {
288
282
  */
289
283
  config: Awaitable<Record<string, unknown>>;
290
284
  }): Promise<void>;
285
+ getWorkspace(): {
286
+ parent: Core;
287
+ name: string;
288
+ dir: string;
289
+ } | undefined;
291
290
  getWorkspaces(): Map<string, Core>;
292
291
  getOptions(): ResolvedCoreOptions;
293
292
  getConfig(): ResolvedConfig;
@@ -309,5 +308,5 @@ declare class Core {
309
308
  private initConfig;
310
309
  }
311
310
  //#endregion
312
- export { defineConfig as A, Hook as C, GetCollectionConfig as D, Awaitable as E, GlobalConfig as O, AsyncHook as S, hook as T, defineCollectionHook as _, EmitEntry as a, asyncPipe as b, Plugin as c, ResolvedConfig as d, ResolvedCoreOptions as f, CollectionHookContext as g, CollectionHook as h, EmitContext as i, WorkspaceConfig as k, PluginContext as l, Collection as m, CoreOptions as n, EmitOptions as o, ServerContext as p, EmitCodeGeneratorContext as r, EmitOutput as s, Core as t, PluginOption$1 as u, AsyncPipe as v, asyncHook as w, pipe as x, Pipe as y };
313
- //# sourceMappingURL=core-BO3b8jMg.d.ts.map
311
+ export { WorkspaceConfig as A, Hook as C, GetCollectionConfig as D, Awaitable as E, EmitConfig as O, AsyncHook as S, hook as T, defineCollectionHook as _, EmitOptions as a, asyncPipe as b, PluginContext as c, ResolvedCoreOptions as d, ServerContext as f, CollectionHookContext as g, CollectionHook as h, EmitEntry as i, defineConfig as j, GlobalConfig as k, PluginOption$1 as l, Collection as m, CoreOptions as n, EmitOutput as o, CodeGenerator as p, EmitContext as r, Plugin as s, Core as t, ResolvedConfig as u, AsyncPipe as v, asyncHook as w, pipe as x, Pipe as y };
312
+ //# sourceMappingURL=core-CT06v32N.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-CT06v32N.d.ts","names":[],"sources":["../src/config/index.ts","../src/types.ts","../src/utils/hook.ts","../src/utils/pipe.ts","../src/collections/index.ts","../src/utils/code-generator.ts","../src/core.ts"],"sourcesContent":[],"mappings":";;;;;;UAGiB,mCACK,eAAe,cAAc,eAAe;YAEtD;gBACI;eACD,eAAe;EALb;;;;;EAGL,sBAAA,CAAA,EAAA,MAAA;EACI;;;EAaP,IAAA,CAAA,EAAA,UAAA;;AAGQ,UAAA,UAAA,CAAU;EAQV,MAAA,CAAA,EAAA,SAAe,GAAA,MAAA;EAKhB;;;EACkD,WAAA,CAAA,EAAA,OAAA;;AAC3C,UAPN,eAAA,CAOM;EAAb,GAAA,EAAA,MAAA;EAA8C,MAAA,EAL9C,YAK8C,GAAA;IAAb,OAAA,EALP,YAKO;EAAY,CAAA;;iBAFvC,mCACM,eAAe,cAAc,eAAe,sBACxD,aAAa,iBAAoB,aAAa;;;KClC5C,mDACV,eAAe,OAAO,MAAM,cACxB,OAAO,QACP;WACa;IAEX,YAAY;KAGR,eAAe,IAAI,YAAY;;;UCX1B;;;;;AFCjB;EACqC,IAAA,EAAA,CAAA,EAAA,EAAA,CAAA,OAAA,EEId,OFJc,EAAA,GAAA,IAAA,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CAAA,EEsPZ,UFtPY,EAAA;EAAlB,aAAA,CAAA,IAAA,EAAA,MAAA,CAAA,EE+PA,UF/PA,GAAA,SAAA;EAAqC,gBAAA,CAAA,CAAA,EEkQ9C,aFlQ8C;EAAU,UAAA,CAAA,MAAA,EEuQnD,aFvQmD,CAAA,EEuQtC,OFvQsC,CAAA,IAAA,CAAA;EACzC,oBAAA,CAAA,CAAA,EEqRT,OFrRS,CAAA,IAAA,CAAA;EAAf,IAAA,CAAA,WAAA,CAAA,EEyRI,WFzRJ,CAAA,EEyRuB,OFzRvB,CEyR+B,UFzR/B,CAAA;EAAoB;;;EAWG,cAAA,CAAA,YAAA,EAAA,MAAA,CAAA,EAAA,MAAA;EAAC,QAAA,UAAA;AAK9C"}
@@ -1,5 +1,5 @@
1
- import { t as Collection } from "./collections-DNFRdCuB.js";
2
- import { t as CodeGenerator } from "./code-generator-CjC4EEXg.js";
1
+ import { t as Collection } from "./collections-CNWuMDAZ.js";
2
+ import { t as CodeGenerator } from "./code-generator-Qhhq7kHh.js";
3
3
  import fs from "node:fs/promises";
4
4
  import path from "node:path";
5
5
 
@@ -82,6 +82,9 @@ var Core = class Core {
82
82
  this.workspaces.set(name, child);
83
83
  }));
84
84
  }
85
+ getWorkspace() {
86
+ return this.options.workspace;
87
+ }
85
88
  getWorkspaces() {
86
89
  return this.workspaces;
87
90
  }
@@ -134,44 +137,36 @@ var Core = class Core {
134
137
  });
135
138
  }
136
139
  async emit(emitOptions = {}) {
140
+ const emitConfig = this.config.emit;
137
141
  const { workspace, outDir } = this.options;
138
- const { target, jsExtension } = this.config.emit ?? {};
139
142
  const { filterCollection, filterWorkspace, write = false } = emitOptions;
140
143
  const start = performance.now();
141
144
  const ctx = {
142
- ...this.getPluginContext(),
143
- createCodeGenerator: async (path$1, content) => {
145
+ core: this,
146
+ async createCodeGenerator(path$1, content) {
144
147
  const codegen = new CodeGenerator({
145
- target,
146
- outDir,
147
- jsExtension
148
- });
149
- await content({
150
- core: this,
151
- codegen,
152
- workspace: workspace?.name
148
+ ...emitConfig,
149
+ outDir
153
150
  });
151
+ await content({ codegen });
154
152
  return {
155
153
  path: path$1,
156
154
  content: codegen.toString()
157
155
  };
158
156
  }
159
157
  };
160
- const added = /* @__PURE__ */ new Set();
161
158
  const out = {
162
159
  entries: [],
163
160
  workspaces: {}
164
161
  };
162
+ const entryMap = /* @__PURE__ */ new Map();
165
163
  const generated = [];
166
164
  for (const collection of this.getCollections()) {
167
165
  if (filterCollection && !filterCollection(collection)) continue;
168
166
  generated.push(collection.onEmit.run([], ctx));
169
167
  }
170
- for (const entries of await Promise.all(generated)) for (const item of entries) {
171
- if (added.has(item.path)) continue;
172
- out.entries.push(item);
173
- added.add(item.path);
174
- }
168
+ for (const entries of await Promise.all(generated)) for (const item of entries) entryMap.set(item.path, item);
169
+ out.entries = Array.from(entryMap.values());
175
170
  if (write) {
176
171
  await Promise.all(out.entries.map(async (entry) => {
177
172
  const file = path.join(outDir, entry.path);
@@ -220,4 +215,4 @@ var Core = class Core {
220
215
 
221
216
  //#endregion
222
217
  export { Core as t };
223
- //# sourceMappingURL=core-D5QHSKk6.js.map
218
+ //# sourceMappingURL=core-Uv3jZqL-.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-Uv3jZqL-.js","names":["plugins: Plugin[]","deduped: Plugin[]","workspace","ctx: EmitContext","out: EmitOutput","generated: Awaitable<EmitEntry[]>[]","globalConfig: GlobalConfig"],"sources":["../src/core.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs/promises\";\nimport type { FSWatcher } from \"chokidar\";\nimport { Collection } from \"@/collections\";\nimport type * as Vite from \"vite\";\nimport type { NextConfig } from \"next\";\nimport type { LoadHook } from \"node:module\";\nimport { CodeGenerator } from \"@/utils/code-generator\";\nimport type { Awaitable } from \"@/types\";\nimport type { GlobalConfig } from \"./config\";\n\nexport interface ResolvedConfig extends Omit<GlobalConfig, \"collections\"> {\n collections: Map<string, Collection>;\n}\n\nexport interface EmitEntry {\n /**\n * path relative to output directory\n */\n path: string;\n content: string;\n}\n\nexport interface PluginContext {\n core: Core;\n}\n\nexport interface EmitContext extends PluginContext {\n createCodeGenerator: (\n path: string,\n content: (ctx: { codegen: CodeGenerator }) => Awaitable<void>,\n ) => Promise<EmitEntry>;\n}\n\nexport interface Plugin {\n /**\n * unique name for plugin\n *\n * @example `my-package:my-plugin`\n */\n name: string;\n\n /** when `true`, only keep the last plugin with same `name`. */\n dedupe?: boolean;\n\n /**\n * on config loaded/updated\n */\n config?: (this: PluginContext, config: ResolvedConfig) => Awaitable<void | ResolvedConfig>;\n\n /**\n * called after collection initialization\n */\n collection?: (this: PluginContext, collection: Collection) => Awaitable<void>;\n\n /**\n * Configure watch/dev server\n */\n configureServer?: (this: PluginContext, server: ServerContext) => void;\n\n vite?: {\n createPlugin?: (this: PluginContext) => Vite.PluginOption;\n };\n\n bun?: {\n setup?: (this: PluginContext, build: Bun.PluginBuilder) => Awaitable<void>;\n };\n\n next?: {\n config?: (this: PluginContext, config: NextConfig) => NextConfig;\n };\n\n node?: {\n createLoad?: (this: PluginContext) => Awaitable<LoadHook>;\n };\n}\n\nexport type PluginOption = Awaitable<Plugin | PluginOption[] | false | undefined>;\n\nexport interface ServerContext {\n /**\n * the file watcher, by default all content files are watched, along with other files.\n *\n * make sure to filter when listening to events\n */\n watcher?: FSWatcher;\n}\n\nexport type CoreOptions = Partial<ResolvedCoreOptions>;\n\n/**\n * the resolved options, all paths are absolute\n */\nexport interface ResolvedCoreOptions {\n cwd: string;\n /**\n * Path to source configuration file\n *\n * @defaultValue content.config.ts\n */\n configPath: string;\n /**\n * Directory for output files\n *\n * @defaultValue '.content'\n */\n outDir: string;\n /**\n * the workspace info if this instance is created as a workspace\n */\n workspace?: {\n parent: Core;\n name: string;\n dir: string;\n };\n plugins?: PluginOption;\n}\n\nexport interface EmitOptions {\n /**\n * filter the collections to run emit\n */\n filterCollection?: (collection: Collection) => boolean;\n\n /**\n * filter the workspaces to run emit\n */\n filterWorkspace?: (workspace: string) => boolean;\n\n /**\n * write files\n */\n write?: boolean;\n}\n\nexport interface EmitOutput {\n entries: EmitEntry[];\n workspaces: Record<string, EmitEntry[]>;\n}\n\nasync function getPlugins(pluginOptions: PluginOption[], dedupe = true): Promise<Plugin[]> {\n const plugins: Plugin[] = [];\n for (const option of await Promise.all(pluginOptions)) {\n if (!option) continue;\n if (Array.isArray(option)) plugins.push(...(await getPlugins(option, false)));\n else plugins.push(option);\n }\n\n if (!dedupe) return plugins;\n\n const excludedName = new Set<string>();\n const deduped: Plugin[] = [];\n for (let i = plugins.length - 1; i >= 0; i--) {\n const plugin = plugins[i];\n if (excludedName.has(plugin.name)) continue;\n deduped.unshift(plugin);\n if (plugin.dedupe) excludedName.add(plugin.name);\n }\n return deduped;\n}\n\nexport class Core {\n private readonly workspaces = new Map<string, Core>();\n private readonly options: ResolvedCoreOptions;\n private plugins: Plugin[] = [];\n private config!: ResolvedConfig;\n static defaultOptions = {\n configPath: \"content.config.ts\",\n outDir: \".content\",\n };\n\n /**\n * Convenient cache store, reset when config changes.\n *\n * You can group namespaces in cache key with \":\", like `my-plugin:data`\n */\n readonly cache = new Map<string, unknown>();\n\n constructor(options: CoreOptions = {}) {\n const cwd = options.cwd ? path.resolve(options.cwd) : process.cwd();\n this.options = {\n ...options,\n cwd,\n outDir: path.resolve(cwd, options.outDir ?? Core.defaultOptions.outDir),\n configPath: path.resolve(cwd, options.configPath ?? Core.defaultOptions.configPath),\n };\n }\n\n async init({\n config: newConfig,\n }: {\n /**\n * either the default export or all exports of config file.\n */\n config: Awaitable<Record<string, unknown>>;\n }) {\n this.config = await this.initConfig(await newConfig);\n this.cache.clear();\n this.workspaces.clear();\n this.plugins = await getPlugins([\n this.options.plugins,\n this.config.plugins,\n ...this.config.collections.values().map((collection) => collection.plugins),\n ]);\n\n const ctx = this.getPluginContext();\n for (const plugin of this.plugins) {\n const out = await plugin.config?.call(ctx, this.config);\n if (out) this.config = out;\n }\n\n await Promise.all(\n this.config.collections.values().map(async (collection) => {\n collection.onConfig.run({ collection, core: this, config: this.config });\n\n for (const plugin of this.plugins) {\n await plugin.collection?.call(ctx, collection);\n }\n }),\n );\n\n // only support workspaces with max depth 1\n if (!this.options.workspace && this.config.workspaces) {\n await Promise.all(\n Object.entries(this.config.workspaces).map(async ([name, workspace]) => {\n const child = new Core({\n ...this.options,\n cwd: path.resolve(this.options.cwd, workspace.dir),\n workspace: {\n name,\n parent: this,\n dir: workspace.dir,\n },\n });\n\n await child.init({ config: workspace.config as Record<string, unknown> });\n this.workspaces.set(name, child);\n }),\n );\n }\n }\n\n getWorkspace() {\n return this.options.workspace;\n }\n getWorkspaces() {\n return this.workspaces;\n }\n getOptions() {\n return this.options;\n }\n getConfig(): ResolvedConfig {\n return this.config;\n }\n /**\n * The file path of compiled config file, the file may not exist (e.g. on Vite, or still compiling)\n */\n getCompiledConfigPath(): string {\n return path.join(this.options.outDir, \"content.config.mjs\");\n }\n getPlugins(workspace = false) {\n if (workspace) {\n const plugins = [...this.plugins];\n for (const workspace of this.workspaces.values()) {\n plugins.push(...workspace.plugins);\n }\n return plugins;\n }\n\n return this.plugins;\n }\n getCollections(workspace = false): Collection[] {\n const list = Array.from(this.config.collections.values());\n if (workspace) {\n for (const workspace of this.workspaces.values()) {\n list.push(...workspace.getCollections());\n }\n }\n return list;\n }\n getCollection(name: string): Collection | undefined {\n return this.config.collections.get(name);\n }\n getPluginContext(): PluginContext {\n return {\n core: this,\n };\n }\n async initServer(server: ServerContext) {\n const ctx = this.getPluginContext();\n\n server.watcher?.add(this.options.configPath);\n for (const plugin of this.plugins) {\n plugin.configureServer?.call(ctx, server);\n }\n for (const collection of this.getCollections()) {\n collection.onServer.run({ collection, core: this, server });\n }\n for (const workspace of this.workspaces.values()) {\n await workspace.initServer(server);\n }\n }\n\n async clearOutputDirectory() {\n await fs.rm(this.options.outDir, { recursive: true, force: true });\n }\n\n async emit(emitOptions: EmitOptions = {}): Promise<EmitOutput> {\n const emitConfig = this.config.emit;\n const { workspace, outDir } = this.options;\n const { filterCollection, filterWorkspace, write = false } = emitOptions;\n const start = performance.now();\n const ctx: EmitContext = {\n core: this,\n async createCodeGenerator(path, content) {\n const codegen = new CodeGenerator({\n ...emitConfig,\n outDir,\n });\n await content({\n codegen,\n });\n return {\n path,\n content: codegen.toString(),\n };\n },\n };\n\n const out: EmitOutput = {\n entries: [],\n workspaces: {},\n };\n\n const entryMap = new Map<string, EmitEntry>();\n const generated: Awaitable<EmitEntry[]>[] = [];\n for (const collection of this.getCollections()) {\n if (filterCollection && !filterCollection(collection)) continue;\n generated.push(collection.onEmit.run([], ctx));\n }\n for (const entries of await Promise.all(generated)) {\n for (const item of entries) {\n entryMap.set(item.path, item);\n }\n }\n out.entries = Array.from(entryMap.values());\n\n if (write) {\n await Promise.all(\n out.entries.map(async (entry) => {\n const file = path.join(outDir, entry.path);\n await fs.mkdir(path.dirname(file), { recursive: true });\n await fs.writeFile(file, entry.content);\n }),\n );\n\n console.log(\n workspace\n ? `[fuma-content: ${workspace.name}] generated files in ${performance.now() - start}ms`\n : `[fuma-content] generated files in ${performance.now() - start}ms`,\n );\n }\n\n for (const [name, workspace] of this.workspaces.entries()) {\n if (filterWorkspace && !filterWorkspace(name)) continue;\n out.workspaces[name] = (await workspace.emit(emitOptions)).entries;\n }\n\n return out;\n }\n\n /**\n * convert absolute path into a runtime path (relative to **runtime** cwd)\n */\n _toRuntimePath(absolutePath: string) {\n return path.relative(process.cwd(), absolutePath);\n }\n\n private async initConfig(config: Record<string, unknown>): Promise<ResolvedConfig> {\n const collections = new Map<string, Collection>();\n let globalConfig: GlobalConfig;\n\n if (\"default\" in config) {\n globalConfig = config.default as GlobalConfig;\n for (const [k, v] of Object.entries(config)) {\n if (v instanceof Collection) {\n globalConfig.collections ??= {};\n globalConfig.collections[k] = v;\n }\n }\n } else {\n globalConfig = config as GlobalConfig;\n }\n\n globalConfig.collections ??= {};\n await Promise.all(\n Object.entries(globalConfig.collections).map(async ([name, collection]) => {\n collection.name = name;\n collections.set(name, collection);\n await collection.onInit.run({ collection, core: this });\n }),\n );\n return {\n ...globalConfig,\n collections,\n };\n }\n}\n"],"mappings":";;;;;;AA4IA,eAAe,WAAW,eAA+B,SAAS,MAAyB;CACzF,MAAMA,UAAoB,EAAE;AAC5B,MAAK,MAAM,UAAU,MAAM,QAAQ,IAAI,cAAc,EAAE;AACrD,MAAI,CAAC,OAAQ;AACb,MAAI,MAAM,QAAQ,OAAO,CAAE,SAAQ,KAAK,GAAI,MAAM,WAAW,QAAQ,MAAM,CAAE;MACxE,SAAQ,KAAK,OAAO;;AAG3B,KAAI,CAAC,OAAQ,QAAO;CAEpB,MAAM,+BAAe,IAAI,KAAa;CACtC,MAAMC,UAAoB,EAAE;AAC5B,MAAK,IAAI,IAAI,QAAQ,SAAS,GAAG,KAAK,GAAG,KAAK;EAC5C,MAAM,SAAS,QAAQ;AACvB,MAAI,aAAa,IAAI,OAAO,KAAK,CAAE;AACnC,UAAQ,QAAQ,OAAO;AACvB,MAAI,OAAO,OAAQ,cAAa,IAAI,OAAO,KAAK;;AAElD,QAAO;;AAGT,IAAa,OAAb,MAAa,KAAK;CAChB,AAAiB,6BAAa,IAAI,KAAmB;CACrD,AAAiB;CACjB,AAAQ,UAAoB,EAAE;CAC9B,AAAQ;CACR,OAAO,iBAAiB;EACtB,YAAY;EACZ,QAAQ;EACT;;;;;;CAOD,AAAS,wBAAQ,IAAI,KAAsB;CAE3C,YAAY,UAAuB,EAAE,EAAE;EACrC,MAAM,MAAM,QAAQ,MAAM,KAAK,QAAQ,QAAQ,IAAI,GAAG,QAAQ,KAAK;AACnE,OAAK,UAAU;GACb,GAAG;GACH;GACA,QAAQ,KAAK,QAAQ,KAAK,QAAQ,UAAU,KAAK,eAAe,OAAO;GACvE,YAAY,KAAK,QAAQ,KAAK,QAAQ,cAAc,KAAK,eAAe,WAAW;GACpF;;CAGH,MAAM,KAAK,EACT,QAAQ,aAMP;AACD,OAAK,SAAS,MAAM,KAAK,WA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ACjF,MAAM,8BAAc,IAAI,KAAyB;EACjD,IAAII;AAEJ,MAAI,aAAa,QAAQ;AACvB,kBAAe,OAAO;AACtB,QAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,OAAO,CACzC,KAAI,aAAa,YAAY;AAC3B,iBAAa,gBAAgB,EAAE;AAC/B,iBAAa,YAAY,KAAK;;QAIlC,gBAAe;AAGjB,eAAa,gBAAgB,EAAE;AAC/B,QAAM,QAAQ,IACZ,OAAO,QAAQ,aAAa,YAAY,CAAC,IAAI,OAAO,CAAC,MAAM,gBAAgB;AACzE,cAAW,OAAO;AAClB,eAAY,IAAI,MAAM,WAAW;AACjC,SAAM,WAAW,OAAO,IAAI;IAAE;IAAY,MAAM;IAAM,CAAC;IACvD,CACH;AACD,SAAO;GACL,GAAG;GACH;GACD"}
@@ -1,7 +1,7 @@
1
- import { r as asyncPipe } from "./collections-DNFRdCuB.js";
2
- import { n as slash } from "./code-generator-CjC4EEXg.js";
3
- import { t as loaderHook } from "./loader-BuR4gkKg.js";
4
- import { t as FileSystemCollection } from "./fs-WWbLA7Gx.js";
1
+ import { r as asyncPipe } from "./collections-CNWuMDAZ.js";
2
+ import { n as slash } from "./code-generator-Qhhq7kHh.js";
3
+ import { t as loaderHook } from "./loader-B4nQrRwA.js";
4
+ import { t as FileSystemCollection } from "./fs-CXzVd2Dp.js";
5
5
  import path from "node:path";
6
6
 
7
7
  //#region src/collections/data.ts
@@ -34,32 +34,31 @@ var DataCollection = class extends FileSystemCollection {
34
34
  });
35
35
  });
36
36
  });
37
- this.onEmit.pipe(async (entries, { createCodeGenerator }) => {
38
- entries.push(await createCodeGenerator(`${this.name}.ts`, (ctx) => this.generateCollectionStore(ctx)));
39
- return entries;
40
- });
37
+ this.onEmit.pipe(this.#onEmitHandler.bind(this));
41
38
  this.pluginHook(loaderHook).loaders.push(...Object.values(loadersConfig));
42
39
  }
43
- async generateCollectionStore(context) {
44
- const { codegen, core, workspace } = context;
45
- codegen.addNamedImport(["dataStore"], "fuma-content/collections/data/runtime");
46
- codegen.addNamespaceImport("Config", codegen.formatImportPath(core.getOptions().configPath), true);
47
- const base = slash(core._toRuntimePath(this.dir));
48
- let records = "{";
49
- const query = codegen.formatQuery({
50
- collection: this.name,
51
- workspace
52
- });
53
- for (const file of await this.getFiles()) {
54
- const fullPath = path.join(this.dir, file);
55
- const specifier = `${codegen.formatImportPath(fullPath)}?${query}`;
56
- const name = codegen.generateImportName();
57
- codegen.addNamedImport([`default as ${name}`], specifier);
58
- records += `"${slash(file)}": ${name},`;
59
- }
60
- records += "}";
61
- codegen.push(`export const ${this.name} = dataStore<typeof Config, "${this.name}">("${this.name}", "${base}", ${records});`);
62
- }
40
+ #onEmitHandler = async (entries, { core, createCodeGenerator }) => {
41
+ entries.push(await createCodeGenerator(`${this.name}.ts`, async ({ codegen }) => {
42
+ codegen.addNamedImport(["dataStore"], "fuma-content/collections/data/runtime");
43
+ codegen.addNamespaceImport("Config", codegen.formatImportPath(core.getOptions().configPath), true);
44
+ const base = slash(core._toRuntimePath(this.dir));
45
+ let records = "{";
46
+ const query = codegen.formatQuery({
47
+ collection: this.name,
48
+ workspace: core.getWorkspace()?.name
49
+ });
50
+ for (const file of await this.getFiles()) {
51
+ const fullPath = path.join(this.dir, file);
52
+ const specifier = `${codegen.formatImportPath(fullPath)}?${query}`;
53
+ const name = codegen.generateImportName();
54
+ codegen.addNamedImport([`default as ${name}`], specifier);
55
+ records += `"${slash(file)}": ${name},`;
56
+ }
57
+ records += "}";
58
+ codegen.push(`export const ${this.name} = dataStore<typeof Config, "${this.name}">("${this.name}", "${base}", ${records});`);
59
+ }));
60
+ return entries;
61
+ };
63
62
  };
64
63
  function dataCollection(config) {
65
64
  return new DataCollection(config);
@@ -103,8 +102,9 @@ function yamlLoader() {
103
102
  };
104
103
  },
105
104
  async createLoader() {
106
- const { createYamlLoader } = await import("./loader-zsTVgQjO.js");
107
- return createYamlLoader({ getCore: () => this.core });
105
+ const { createYamlLoader } = await import("./loader-Cx1Rg_VM.js");
106
+ const core = this.core;
107
+ return createYamlLoader({ getCore: () => core });
108
108
  }
109
109
  };
110
110
  }
@@ -147,12 +147,13 @@ function jsonLoader() {
147
147
  };
148
148
  },
149
149
  async createLoader(environment) {
150
- const { createJsonLoader } = await import("./loader-DCK4RwOh.js");
151
- return createJsonLoader({ getCore: () => this.core }, environment === "vite" ? "json" : "js");
150
+ const { createJsonLoader } = await import("./loader-Dao_nv3e.js");
151
+ const core = this.core;
152
+ return createJsonLoader({ getCore: () => core }, environment === "vite" ? "json" : "js");
152
153
  }
153
154
  };
154
155
  }
155
156
 
156
157
  //#endregion
157
158
  export { yamlLoader as i, dataCollection as n, jsonLoader as r, DataCollection as t };
158
- //# sourceMappingURL=data-9h98oZwj.js.map
159
+ //# sourceMappingURL=data-Cxsx5KPD.js.map
@@ -0,0 +1 @@
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,OAAO,OAAO,cAAc,CAAC;;CAG3E,iBAA2D,OACzD,SACA,EAAE,MAAM,0BACL;AACH,UAAQ,KACN,MAAM,oBAAoB,GAAG,KAAK,KAAK,MAAM,OAAO,EAAE,cAAc;AAClE,WAAQ,eAAe,CAAC,YAAY,EAAE,wCAAwC;AAC9E,WAAQ,mBACN,UACA,QAAQ,iBAAiB,KAAK,YAAY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AM,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,4 +1,4 @@
1
- import { t as Core } from "./core-BO3b8jMg.js";
1
+ import { t as Core } from "./core-CT06v32N.js";
2
2
 
3
3
  //#region src/config/load-from-file.d.ts
4
4
 
@@ -30,4 +30,4 @@ declare function createDynamicCore({
30
30
  }): DynamicCore;
31
31
  //#endregion
32
32
  export { createDynamicCore as n, DynamicCore as t };
33
- //# sourceMappingURL=dynamic-CTYYdl7_.d.ts.map
33
+ //# sourceMappingURL=dynamic-Ck1wYoaL.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-CTYYdl7_.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
+ {"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"}
@@ -10,7 +10,7 @@ function createDynamicCore({ core, compileMode = true, mode }) {
10
10
  })).mtime.getTime().toString();
11
11
  }
12
12
  async function init() {
13
- const { loadConfig } = await import("./load-from-file-BZxc_BhC.js");
13
+ const { loadConfig } = await import("./load-from-file-D-Xm95Fz.js");
14
14
  await core.init({ config: loadConfig(core, compileMode) });
15
15
  }
16
16
  return { async getCore() {
@@ -26,4 +26,4 @@ function createDynamicCore({ core, compileMode = true, mode }) {
26
26
 
27
27
  //#endregion
28
28
  export { createDynamicCore as t };
29
- //# sourceMappingURL=dynamic-DhKTOrIl.js.map
29
+ //# sourceMappingURL=dynamic-CtOB4Rkp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-DhKTOrIl.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
+ {"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"}
package/dist/dynamic.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import "./core-BO3b8jMg.js";
2
- import { n as createDynamicCore, t as DynamicCore } from "./dynamic-CTYYdl7_.js";
1
+ import "./core-CT06v32N.js";
2
+ import { n as createDynamicCore, t as DynamicCore } from "./dynamic-Ck1wYoaL.js";
3
3
  export { DynamicCore, createDynamicCore };
package/dist/dynamic.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as createDynamicCore } from "./dynamic-DhKTOrIl.js";
1
+ import { t as createDynamicCore } from "./dynamic-CtOB4Rkp.js";
2
2
 
3
3
  export { createDynamicCore };
@@ -1,4 +1,4 @@
1
- import { n as MapCollectionStore } from "./store-DiuGdV5M.js";
1
+ import { n as MapCollectionStore } from "./store-D_PPrdRE.js";
2
2
 
3
3
  //#region src/collections/runtime/file-store.d.ts
4
4
  interface FileInfo {
@@ -13,9 +13,8 @@ interface FileInfo {
13
13
  }
14
14
  declare class FileCollectionStore<V> extends MapCollectionStore<string, FileInfo & V> {
15
15
  constructor(base: string, glob: Record<string, V>);
16
- transform<T>(fn: (input: FileInfo & V) => FileInfo & T): FileCollectionStore<T>;
17
16
  castData<T>(_cast: (input: FileInfo & V) => FileInfo & T): FileCollectionStore<T>;
18
17
  }
19
18
  //#endregion
20
19
  export { FileInfo as n, FileCollectionStore as t };
21
- //# sourceMappingURL=file-store-laO4IjvB.d.ts.map
20
+ //# sourceMappingURL=file-store-Dm1SjuLg.d.ts.map
@@ -0,0 +1 @@
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"}