@kubb/fabric-core 0.13.0 → 0.13.1

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 (51) hide show
  1. package/dist/{Fabric-CrRJykMN.d.ts → Fabric-CE-4sqCG.d.ts} +1 -4
  2. package/dist/{Fabric-DMmgrLto.d.cts → Fabric-efyCO1t7.d.ts} +2 -2
  3. package/dist/{RootContext-Cf7WJM7r.d.cts → RootContext-BgiMS39h.d.ts} +3 -3
  4. package/dist/{RootContext-CvaGJ-4g.d.ts → RootContext-CA-zkTEp.d.ts} +3 -4
  5. package/dist/{chunk-BVHe6Par.js → chunk-BYypO7fO.js} +1 -5
  6. package/dist/{chunk-DVipidnM.cjs → chunk-uaV2rQ02.cjs} +0 -10
  7. package/dist/{defaultParser-BK-zOanQ.cjs → defaultParser-BAgmtMo_.cjs} +2 -3
  8. package/dist/{defaultParser-BK-zOanQ.cjs.map → defaultParser-BAgmtMo_.cjs.map} +1 -1
  9. package/dist/{defaultParser-BD_N68Bo.js → defaultParser-C1atU7yU.js} +2 -3
  10. package/dist/{defaultParser-BD_N68Bo.js.map → defaultParser-C1atU7yU.js.map} +1 -1
  11. package/dist/{getRelativePath-C4Au07ON.js → getRelativePath-BcieQL5M.js} +1 -2
  12. package/dist/{getRelativePath-C4Au07ON.js.map → getRelativePath-BcieQL5M.js.map} +1 -1
  13. package/dist/{getRelativePath-DpbA6qm5.cjs → getRelativePath-DVG8dIzW.cjs} +2 -2
  14. package/dist/{getRelativePath-DpbA6qm5.cjs.map → getRelativePath-DVG8dIzW.cjs.map} +1 -1
  15. package/dist/index.cjs +8 -8
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.ts +3 -4
  18. package/dist/index.js +7 -8
  19. package/dist/index.js.map +1 -1
  20. package/dist/{onProcessExit-C7dVg0S0.cjs → onProcessExit-B7_bTfyR.cjs} +74 -205
  21. package/dist/onProcessExit-B7_bTfyR.cjs.map +1 -0
  22. package/dist/{onProcessExit-7fgW-UTF.js → onProcessExit-CF200hsz.js} +74 -182
  23. package/dist/onProcessExit-CF200hsz.js.map +1 -0
  24. package/dist/parsers/typescript.cjs +4 -4
  25. package/dist/parsers/typescript.cjs.map +1 -1
  26. package/dist/parsers/typescript.d.ts +1 -2
  27. package/dist/parsers/typescript.js +3 -4
  28. package/dist/parsers/typescript.js.map +1 -1
  29. package/dist/parsers.cjs +2 -3
  30. package/dist/parsers.cjs.map +1 -1
  31. package/dist/parsers.d.ts +1 -2
  32. package/dist/parsers.js +2 -3
  33. package/dist/parsers.js.map +1 -1
  34. package/dist/plugins.cjs +31 -41
  35. package/dist/plugins.cjs.map +1 -1
  36. package/dist/plugins.d.ts +2 -3
  37. package/dist/plugins.js +30 -41
  38. package/dist/plugins.js.map +1 -1
  39. package/dist/types.cjs +1 -1
  40. package/dist/types.d.ts +3 -4
  41. package/dist/types.js +1 -1
  42. package/dist/{useNodeTree-CgEKFUV-.d.cts → useNodeTree-BpHR6gQx.d.ts} +2 -2
  43. package/dist/{useNodeTree-CamNuFQP.d.ts → useNodeTree-DuQ5Df0t.d.ts} +2 -3
  44. package/package.json +3 -3
  45. package/dist/index.d.cts +0 -602
  46. package/dist/onProcessExit-7fgW-UTF.js.map +0 -1
  47. package/dist/onProcessExit-C7dVg0S0.cjs.map +0 -1
  48. package/dist/parsers/typescript.d.cts +0 -45
  49. package/dist/parsers.d.cts +0 -37
  50. package/dist/plugins.d.cts +0 -119
  51. package/dist/types.d.cts +0 -11
@@ -1,6 +1,3 @@
1
- import { n as __name, t as __exportAll } from "./chunk-BVHe6Par.js";
2
-
3
- //#region src/KubbFile.d.ts
4
1
  declare namespace KubbFile_d_exports {
5
2
  export { BaseName, Export, Extname, File, Import, Mode, Path, ResolvedFile, Source };
6
3
  }
@@ -516,4 +513,4 @@ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
516
513
  }
517
514
  //#endregion
518
515
  export { Path as A, UserParser as C, File as D, Extname as E, Source as M, Import as O, Parser as S, Export as T, inject as _, FabricElement as a, FileManager as b, FabricOptions as c, renderIndent as d, renderIntrinsic as f, createContext as g, Context as h, FabricContext as i, ResolvedFile as j, KubbFile_d_exports as k, Plugin as l, RenderContextProps as m, FabricComponent as n, FabricMode as o, RenderContext as p, FabricConfig as r, FabricNode as s, Fabric as t, UserPlugin as u, provide as v, BaseName as w, FileProcessor as x, unprovide as y };
519
- //# sourceMappingURL=Fabric-CrRJykMN.d.ts.map
516
+ //# sourceMappingURL=Fabric-CE-4sqCG.d.ts.map
@@ -512,5 +512,5 @@ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
512
512
  upsertFile(...files: File[]): Promise<void>;
513
513
  }
514
514
  //#endregion
515
- export { Path as A, UserParser as C, File as D, Extname as E, Source as M, __name as N, Import as O, Parser as S, Export as T, inject as _, FabricElement as a, FileManager as b, FabricOptions as c, renderIndent as d, renderIntrinsic as f, createContext as g, Context as h, FabricContext as i, ResolvedFile as j, KubbFile_d_exports as k, Plugin as l, RenderContextProps as m, FabricComponent as n, FabricMode as o, RenderContext as p, FabricConfig as r, FabricNode as s, Fabric as t, UserPlugin as u, provide as v, BaseName as w, FileProcessor as x, unprovide as y };
516
- //# sourceMappingURL=Fabric-DMmgrLto.d.cts.map
515
+ export { Path as A, UserParser as C, File as D, Extname as E, Source as M, Import as O, Parser as S, Export as T, inject as _, FabricElement as a, FileManager as b, FabricOptions as c, renderIndent as d, renderIntrinsic as f, createContext as g, Context as h, FabricContext as i, ResolvedFile as j, KubbFile_d_exports as k, Plugin as l, RenderContextProps as m, FabricComponent as n, FabricMode as o, RenderContext as p, FabricConfig as r, FabricNode as s, Fabric as t, UserPlugin as u, provide as v, BaseName as w, FileProcessor as x, unprovide as y };
516
+ //# sourceMappingURL=Fabric-efyCO1t7.d.ts.map
@@ -1,5 +1,5 @@
1
- import { N as __name, b as FileManager, h as Context } from "./Fabric-DMmgrLto.cjs";
2
- import { r as TreeNode, t as ComponentNode } from "./useNodeTree-CgEKFUV-.cjs";
1
+ import { b as FileManager, h as Context } from "./Fabric-CE-4sqCG.js";
2
+ import { r as TreeNode, t as ComponentNode } from "./useNodeTree-BpHR6gQx.js";
3
3
 
4
4
  //#region src/contexts/RootContext.d.ts
5
5
  type RootContextProps = {
@@ -23,4 +23,4 @@ type RootContextProps = {
23
23
  declare const RootContext: Context<RootContextProps>;
24
24
  //#endregion
25
25
  export { RootContextProps as n, RootContext as t };
26
- //# sourceMappingURL=RootContext-Cf7WJM7r.d.cts.map
26
+ //# sourceMappingURL=RootContext-BgiMS39h.d.ts.map
@@ -1,6 +1,5 @@
1
- import { n as __name } from "./chunk-BVHe6Par.js";
2
- import { b as FileManager, h as Context } from "./Fabric-CrRJykMN.js";
3
- import { r as TreeNode, t as ComponentNode } from "./useNodeTree-CamNuFQP.js";
1
+ import { b as FileManager, h as Context } from "./Fabric-efyCO1t7.js";
2
+ import { r as TreeNode, t as ComponentNode } from "./useNodeTree-DuQ5Df0t.js";
4
3
 
5
4
  //#region src/contexts/RootContext.d.ts
6
5
  type RootContextProps = {
@@ -24,4 +23,4 @@ type RootContextProps = {
24
23
  declare const RootContext: Context<RootContextProps>;
25
24
  //#endregion
26
25
  export { RootContextProps as n, RootContext as t };
27
- //# sourceMappingURL=RootContext-CvaGJ-4g.d.ts.map
26
+ //# sourceMappingURL=RootContext-CA-zkTEp.d.ts.map
@@ -1,9 +1,5 @@
1
1
  //#region \0rolldown/runtime.js
2
2
  var __defProp = Object.defineProperty;
3
- var __name = (target, value) => __defProp(target, "name", {
4
- value,
5
- configurable: true
6
- });
7
3
  var __exportAll = (all, no_symbols) => {
8
4
  let target = {};
9
5
  for (var name in all) {
@@ -19,4 +15,4 @@ var __exportAll = (all, no_symbols) => {
19
15
  };
20
16
 
21
17
  //#endregion
22
- export { __name as n, __exportAll as t };
18
+ export { __exportAll as t };
@@ -1,10 +1,6 @@
1
1
  //#region \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", {
5
- value,
6
- configurable: true
7
- });
8
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
10
6
  var __getProtoOf = Object.getPrototypeOf;
@@ -49,12 +45,6 @@ Object.defineProperty(exports, '__exportAll', {
49
45
  return __exportAll;
50
46
  }
51
47
  });
52
- Object.defineProperty(exports, '__name', {
53
- enumerable: true,
54
- get: function () {
55
- return __name;
56
- }
57
- });
58
48
  Object.defineProperty(exports, '__toESM', {
59
49
  enumerable: true,
60
50
  get: function () {
@@ -1,5 +1,4 @@
1
- const require_chunk = require('./chunk-DVipidnM.cjs');
2
- const require_getRelativePath = require('./getRelativePath-DpbA6qm5.cjs');
1
+ const require_getRelativePath = require('./getRelativePath-DVG8dIzW.cjs');
3
2
 
4
3
  //#region src/parsers/defaultParser.ts
5
4
  const defaultParser = require_getRelativePath.defineParser({
@@ -18,4 +17,4 @@ Object.defineProperty(exports, 'defaultParser', {
18
17
  return defaultParser;
19
18
  }
20
19
  });
21
- //# sourceMappingURL=defaultParser-BK-zOanQ.cjs.map
20
+ //# sourceMappingURL=defaultParser-BAgmtMo_.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaultParser-BK-zOanQ.cjs","names":["defineParser"],"sources":["../src/parsers/defaultParser.ts"],"sourcesContent":["import { defineParser } from './defineParser.ts'\n\nexport const defaultParser = defineParser({\n name: 'default',\n extNames: ['.json'],\n install() {},\n async parse(file) {\n return file.sources.map((item) => item.value).join('\\n\\n')\n },\n})\n"],"mappings":";;;;AAEA,MAAa,gBAAgBA,qCAAa;CACxC,MAAM;CACN,UAAU,CAAC,QAAQ;CACnB,UAAU;CACV,MAAM,MAAM,MAAM;AAChB,SAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,OAAO;;CAE7D,CAAC"}
1
+ {"version":3,"file":"defaultParser-BAgmtMo_.cjs","names":["defineParser"],"sources":["../src/parsers/defaultParser.ts"],"sourcesContent":["import { defineParser } from './defineParser.ts'\n\nexport const defaultParser = defineParser({\n name: 'default',\n extNames: ['.json'],\n install() {},\n async parse(file) {\n return file.sources.map((item) => item.value).join('\\n\\n')\n },\n})\n"],"mappings":";;;AAEA,MAAa,gBAAgBA,qCAAa;CACxC,MAAM;CACN,UAAU,CAAC,QAAQ;CACnB,UAAU;CACV,MAAM,MAAM,MAAM;AAChB,SAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,OAAO;;CAE7D,CAAC"}
@@ -1,5 +1,4 @@
1
- import { n as __name } from "./chunk-BVHe6Par.js";
2
- import { n as defineParser } from "./getRelativePath-C4Au07ON.js";
1
+ import { n as defineParser } from "./getRelativePath-BcieQL5M.js";
3
2
 
4
3
  //#region src/parsers/defaultParser.ts
5
4
  const defaultParser = defineParser({
@@ -13,4 +12,4 @@ const defaultParser = defineParser({
13
12
 
14
13
  //#endregion
15
14
  export { defaultParser as t };
16
- //# sourceMappingURL=defaultParser-BD_N68Bo.js.map
15
+ //# sourceMappingURL=defaultParser-C1atU7yU.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaultParser-BD_N68Bo.js","names":[],"sources":["../src/parsers/defaultParser.ts"],"sourcesContent":["import { defineParser } from './defineParser.ts'\n\nexport const defaultParser = defineParser({\n name: 'default',\n extNames: ['.json'],\n install() {},\n async parse(file) {\n return file.sources.map((item) => item.value).join('\\n\\n')\n },\n})\n"],"mappings":";;;;AAEA,MAAa,gBAAgB,aAAa;CACxC,MAAM;CACN,UAAU,CAAC,QAAQ;CACnB,UAAU;CACV,MAAM,MAAM,MAAM;AAChB,SAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,OAAO;;CAE7D,CAAC"}
1
+ {"version":3,"file":"defaultParser-C1atU7yU.js","names":[],"sources":["../src/parsers/defaultParser.ts"],"sourcesContent":["import { defineParser } from './defineParser.ts'\n\nexport const defaultParser = defineParser({\n name: 'default',\n extNames: ['.json'],\n install() {},\n async parse(file) {\n return file.sources.map((item) => item.value).join('\\n\\n')\n },\n})\n"],"mappings":";;;AAEA,MAAa,gBAAgB,aAAa;CACxC,MAAM;CACN,UAAU,CAAC,QAAQ;CACnB,UAAU;CACV,MAAM,MAAM,MAAM;AAChB,SAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,OAAO;;CAE7D,CAAC"}
@@ -1,4 +1,3 @@
1
- import { n as __name } from "./chunk-BVHe6Par.js";
2
1
  import { normalize, relative } from "node:path";
3
2
 
4
3
  //#region src/utils/trimExtName.ts
@@ -55,4 +54,4 @@ function getRelativePath(rootDir, filePath, platform = "linux") {
55
54
 
56
55
  //#endregion
57
56
  export { defineParser as n, trimExtName as r, getRelativePath as t };
58
- //# sourceMappingURL=getRelativePath-C4Au07ON.js.map
57
+ //# sourceMappingURL=getRelativePath-BcieQL5M.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getRelativePath-C4Au07ON.js","names":[],"sources":["../src/utils/trimExtName.ts","../src/parsers/defineParser.ts","../src/utils/getRelativePath.ts"],"sourcesContent":["export function trimExtName(text: string): string {\n return text.replace(/\\.[^/.]+$/, '')\n}\n","import type { Parser, UserParser } from './types.ts'\n\n/**\n * Defines a Fabric parser with type safety.\n *\n * Use this function to create parsers that transform files based on\n * their extension.\n *\n * @param parser - The parser configuration object\n * @returns A typed parser ready to use with Fabric\n *\n * @example\n * ```ts\n * import { defineParser } from '@kubb/fabric-core'\n *\n * export const jsonParser = defineParser({\n * name: 'json-parser',\n * extensions: ['.json'],\n * async parse(source, meta) {\n * const data = JSON.parse(source)\n * return data\n * }\n * })\n * ```\n */\nexport function defineParser<TOptions = unknown, TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta> {\n return {\n type: 'parser',\n ...parser,\n }\n}\n","import { normalize, relative } from 'node:path'\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n const normalizedPath = normalize(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n }\n\n // windows\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath\n }\n\n return `./${slashedPath}`\n}\n"],"mappings":";;;;AAAA,SAAgB,YAAY,MAAsB;AAChD,QAAO,KAAK,QAAQ,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACwBtC,SAAgB,aAA6D,QAA8D;AACzI,QAAO;EACL,MAAM;EACN,GAAG;EACJ;;;;;AC3BH,SAAS,MAAM,MAAc,WAAwC,SAAS;CAC5E,MAAM,gBAAgB,YAAY,KAAK,KAAK;CAC5C,MAAM,iBAAiB,UAAU,KAAK;AAEtC,KAAI,CAAC,SAAS,MAAM,CAAC,SAAS,SAAS,IAAI,CAAC,cAE1C,QAAO,eAAe,WAAW,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;AAIjE,QAAO,eAAe,WAAW,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;;AAGjE,SAAgB,gBAAgB,SAAyB,UAA0B,WAAwC,SAAiB;AAC1I,KAAI,CAAC,WAAW,CAAC,SACf,OAAM,IAAI,MAAM,uEAAuE,WAAW,GAAG,GAAG,YAAY,KAAK;CAO3H,MAAM,cAAc,MAJC,SAAS,SAAS,SAAS,EAIR,SAAS;AAEjD,KAAI,YAAY,WAAW,MAAM,CAC/B,QAAO;AAGT,QAAO,KAAK"}
1
+ {"version":3,"file":"getRelativePath-BcieQL5M.js","names":[],"sources":["../src/utils/trimExtName.ts","../src/parsers/defineParser.ts","../src/utils/getRelativePath.ts"],"sourcesContent":["export function trimExtName(text: string): string {\n return text.replace(/\\.[^/.]+$/, '')\n}\n","import type { Parser, UserParser } from './types.ts'\n\n/**\n * Defines a Fabric parser with type safety.\n *\n * Use this function to create parsers that transform files based on\n * their extension.\n *\n * @param parser - The parser configuration object\n * @returns A typed parser ready to use with Fabric\n *\n * @example\n * ```ts\n * import { defineParser } from '@kubb/fabric-core'\n *\n * export const jsonParser = defineParser({\n * name: 'json-parser',\n * extensions: ['.json'],\n * async parse(source, meta) {\n * const data = JSON.parse(source)\n * return data\n * }\n * })\n * ```\n */\nexport function defineParser<TOptions = unknown, TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta> {\n return {\n type: 'parser',\n ...parser,\n }\n}\n","import { normalize, relative } from 'node:path'\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n const normalizedPath = normalize(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n }\n\n // windows\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath\n }\n\n return `./${slashedPath}`\n}\n"],"mappings":";;;AAAA,SAAgB,YAAY,MAAsB;AAChD,QAAO,KAAK,QAAQ,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACwBtC,SAAgB,aAA6D,QAA8D;AACzI,QAAO;EACL,MAAM;EACN,GAAG;EACJ;;;;;AC3BH,SAAS,MAAM,MAAc,WAAwC,SAAS;CAC5E,MAAM,gBAAgB,YAAY,KAAK,KAAK;CAC5C,MAAM,iBAAiB,UAAU,KAAK;AAEtC,KAAI,CAAC,SAAS,MAAM,CAAC,SAAS,SAAS,IAAI,CAAC,cAE1C,QAAO,eAAe,WAAW,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;AAIjE,QAAO,eAAe,WAAW,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;;AAGjE,SAAgB,gBAAgB,SAAyB,UAA0B,WAAwC,SAAiB;AAC1I,KAAI,CAAC,WAAW,CAAC,SACf,OAAM,IAAI,MAAM,uEAAuE,WAAW,GAAG,GAAG,YAAY,KAAK;CAO3H,MAAM,cAAc,MAJC,SAAS,SAAS,SAAS,EAIR,SAAS;AAEjD,KAAI,YAAY,WAAW,MAAM,CAC/B,QAAO;AAGT,QAAO,KAAK"}
@@ -1,4 +1,4 @@
1
- const require_chunk = require('./chunk-DVipidnM.cjs');
1
+ const require_chunk = require('./chunk-uaV2rQ02.cjs');
2
2
  let node_path = require("node:path");
3
3
 
4
4
  //#region src/utils/trimExtName.ts
@@ -72,4 +72,4 @@ Object.defineProperty(exports, 'trimExtName', {
72
72
  return trimExtName;
73
73
  }
74
74
  });
75
- //# sourceMappingURL=getRelativePath-DpbA6qm5.cjs.map
75
+ //# sourceMappingURL=getRelativePath-DVG8dIzW.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getRelativePath-DpbA6qm5.cjs","names":[],"sources":["../src/utils/trimExtName.ts","../src/parsers/defineParser.ts","../src/utils/getRelativePath.ts"],"sourcesContent":["export function trimExtName(text: string): string {\n return text.replace(/\\.[^/.]+$/, '')\n}\n","import type { Parser, UserParser } from './types.ts'\n\n/**\n * Defines a Fabric parser with type safety.\n *\n * Use this function to create parsers that transform files based on\n * their extension.\n *\n * @param parser - The parser configuration object\n * @returns A typed parser ready to use with Fabric\n *\n * @example\n * ```ts\n * import { defineParser } from '@kubb/fabric-core'\n *\n * export const jsonParser = defineParser({\n * name: 'json-parser',\n * extensions: ['.json'],\n * async parse(source, meta) {\n * const data = JSON.parse(source)\n * return data\n * }\n * })\n * ```\n */\nexport function defineParser<TOptions = unknown, TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta> {\n return {\n type: 'parser',\n ...parser,\n }\n}\n","import { normalize, relative } from 'node:path'\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n const normalizedPath = normalize(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n }\n\n // windows\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath\n }\n\n return `./${slashedPath}`\n}\n"],"mappings":";;;;AAAA,SAAgB,YAAY,MAAsB;AAChD,QAAO,KAAK,QAAQ,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACwBtC,SAAgB,aAA6D,QAA8D;AACzI,QAAO;EACL,MAAM;EACN,GAAG;EACJ;;;;;AC3BH,SAAS,MAAM,MAAc,WAAwC,SAAS;CAC5E,MAAM,gBAAgB,YAAY,KAAK,KAAK;CAC5C,MAAM,0CAA2B,KAAK;AAEtC,KAAI,CAAC,SAAS,MAAM,CAAC,SAAS,SAAS,IAAI,CAAC,cAE1C,QAAO,eAAe,WAAW,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;AAIjE,QAAO,eAAe,WAAW,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;;AAGjE,SAAgB,gBAAgB,SAAyB,UAA0B,WAAwC,SAAiB;AAC1I,KAAI,CAAC,WAAW,CAAC,SACf,OAAM,IAAI,MAAM,uEAAuE,WAAW,GAAG,GAAG,YAAY,KAAK;CAO3H,MAAM,cAAc,8BAJU,SAAS,SAAS,EAIR,SAAS;AAEjD,KAAI,YAAY,WAAW,MAAM,CAC/B,QAAO;AAGT,QAAO,KAAK"}
1
+ {"version":3,"file":"getRelativePath-DVG8dIzW.cjs","names":[],"sources":["../src/utils/trimExtName.ts","../src/parsers/defineParser.ts","../src/utils/getRelativePath.ts"],"sourcesContent":["export function trimExtName(text: string): string {\n return text.replace(/\\.[^/.]+$/, '')\n}\n","import type { Parser, UserParser } from './types.ts'\n\n/**\n * Defines a Fabric parser with type safety.\n *\n * Use this function to create parsers that transform files based on\n * their extension.\n *\n * @param parser - The parser configuration object\n * @returns A typed parser ready to use with Fabric\n *\n * @example\n * ```ts\n * import { defineParser } from '@kubb/fabric-core'\n *\n * export const jsonParser = defineParser({\n * name: 'json-parser',\n * extensions: ['.json'],\n * async parse(source, meta) {\n * const data = JSON.parse(source)\n * return data\n * }\n * })\n * ```\n */\nexport function defineParser<TOptions = unknown, TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta> {\n return {\n type: 'parser',\n ...parser,\n }\n}\n","import { normalize, relative } from 'node:path'\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n const normalizedPath = normalize(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n }\n\n // windows\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath\n }\n\n return `./${slashedPath}`\n}\n"],"mappings":";;;;AAAA,SAAgB,YAAY,MAAsB;AAChD,QAAO,KAAK,QAAQ,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACwBtC,SAAgB,aAA6D,QAA8D;AACzI,QAAO;EACL,MAAM;EACN,GAAG;EACJ;;;;;AC3BH,SAAS,MAAM,MAAc,WAAwC,SAAS;CAC5E,MAAM,gBAAgB,YAAY,KAAK,KAAK;CAC5C,MAAM,0CAA2B,KAAK;AAEtC,KAAI,CAAC,SAAS,MAAM,CAAC,SAAS,SAAS,IAAI,CAAC,cAE1C,QAAO,eAAe,WAAW,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;AAIjE,QAAO,eAAe,WAAW,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;;AAGjE,SAAgB,gBAAgB,SAAyB,UAA0B,WAAwC,SAAiB;AAC1I,KAAI,CAAC,WAAW,CAAC,SACf,OAAM,IAAI,MAAM,uEAAuE,WAAW,GAAG,GAAG,YAAY,KAAK;CAO3H,MAAM,cAAc,8BAJU,SAAS,SAAS,EAIR,SAAS;AAEjD,KAAI,YAAY,WAAW,MAAM,CAC/B,QAAO;AAGT,QAAO,KAAK"}
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_chunk = require('./chunk-DVipidnM.cjs');
3
- const require_onProcessExit = require('./onProcessExit-C7dVg0S0.cjs');
4
- const require_getRelativePath = require('./getRelativePath-DpbA6qm5.cjs');
2
+ const require_chunk = require('./chunk-uaV2rQ02.cjs');
3
+ const require_onProcessExit = require('./onProcessExit-B7_bTfyR.cjs');
4
+ const require_getRelativePath = require('./getRelativePath-DVG8dIzW.cjs');
5
5
  const require_parsers_typescript = require('./parsers/typescript.cjs');
6
6
  let remeda = require("remeda");
7
7
 
@@ -104,7 +104,7 @@ Br.displayName = "Br";
104
104
  */
105
105
  function createJSDoc({ comments }) {
106
106
  if (!comments || comments.length === 0) return "";
107
- const lines = comments.flatMap((c) => String(c !== null && c !== void 0 ? c : "").split(/\r?\n/)).map((l) => l.replace(/\*\//g, "*\\/").replace(/\r/g, "")).filter((l) => l.trim().length > 0);
107
+ const lines = comments.flatMap((c) => String(c ?? "").split(/\r?\n/)).map((l) => l.replace(/\*\//g, "*\\/").replace(/\r/g, "")).filter((l) => l.trim().length > 0);
108
108
  if (lines.length === 0) return "";
109
109
  return [
110
110
  "/**",
@@ -134,7 +134,7 @@ const Const = require_onProcessExit.createComponent("Const", ({ children, ...pro
134
134
  }));
135
135
  const value = require_onProcessExit.renderIntrinsic(children);
136
136
  let result = "";
137
- if (JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) {
137
+ if (JSDoc?.comments) {
138
138
  result += createJSDoc({ comments: JSDoc.comments });
139
139
  result += "\n";
140
140
  }
@@ -413,7 +413,7 @@ const Function = require_onProcessExit.createComponent("Function", ({ children,
413
413
  props
414
414
  }));
415
415
  const parts = [];
416
- if (JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) {
416
+ if (JSDoc?.comments) {
417
417
  parts.push(createJSDoc({ comments: JSDoc.comments }));
418
418
  parts.push("\n");
419
419
  }
@@ -457,7 +457,7 @@ const ArrowFunction = require_onProcessExit.createComponent("ArrowFunction", ({
457
457
  props
458
458
  }));
459
459
  const parts = [];
460
- if (JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) {
460
+ if (JSDoc?.comments) {
461
461
  parts.push(createJSDoc({ comments: JSDoc.comments }));
462
462
  parts.push("\n");
463
463
  }
@@ -514,7 +514,7 @@ const Type = require_onProcessExit.createComponent("Type", ({ children, ...props
514
514
  if (name.charAt(0).toUpperCase() !== name.charAt(0)) throw new Error("Name should start with a capital letter (see TypeScript types)");
515
515
  const value = require_onProcessExit.renderIntrinsic(children);
516
516
  let result = "";
517
- if (JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) {
517
+ if (JSDoc?.comments) {
518
518
  result += createJSDoc({ comments: JSDoc.comments });
519
519
  result += "\n";
520
520
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["inject","NodeTreeContext","createContext","createComponent","RootContext","NodeTreeContext","createComponent","createIntrinsic","createComponent","NodeTreeContext","renderIntrinsic","createComponent","createIntrinsic","createContext","RootContext","createComponent","NodeTreeContext","renderIntrinsic","print","createExport","createImport","createComponent","createIntrinsic","createComponent","NodeTreeContext","createComponent","NodeTreeContext","renderIntrinsic","RootContext","AsyncEventEmitter","FileManager"],"sources":["../src/composables/useContext.ts","../src/composables/useNodeTree.ts","../src/contexts/AppContext.ts","../src/components/App.ts","../src/components/Br.ts","../src/utils/createJSDoc.ts","../src/components/Const.ts","../src/components/Dedent.ts","../src/contexts/FileContext.ts","../src/composables/useFile.ts","../src/composables/useFileManager.ts","../src/components/File.ts","../src/components/Indent.ts","../src/components/Function.ts","../src/components/Type.ts","../src/composables/useApp.ts","../src/composables/useLifecycle.ts","../src/createFabric.ts"],"sourcesContent":["import type { Context } from '../context.ts'\nimport { inject } from '../context.ts'\n\n/**\n * React-style alias for inject\n *\n * @example\n * ```ts\n * const theme = useContext(ThemeContext) // type is inferred from ThemeContext\n * ```\n */\nexport function useContext<T>(key: Context<T>): T\nexport function useContext<T, TValue = T>(key: Context<T>, defaultValue: TValue): NonNullable<T> | TValue\nexport function useContext<T>(key: Context<T>, defaultValue?: T): T {\n return inject(key, defaultValue)\n}\n","import { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport type { TreeNode } from '../utils/TreeNode.ts'\nimport { useContext } from './useContext.ts'\n\nexport type ComponentNode = {\n type: string\n props: Record<string, unknown>\n}\n\n/**\n * Accesses the current node tree for tracking component hierarchy.\n *\n * Use this composable to inspect or manipulate the component tree structure.\n * Returns null if not within a component that provides NodeTreeContext.\n *\n * @returns The current TreeNode or null\n *\n * @example\n * ```ts\n * const nodeTree = useNodeTree()\n * if (nodeTree) {\n * const childTree = nodeTree.addChild({ type: 'MyComponent', props: {} })\n * }\n * ```\n */\nexport function useNodeTree(): TreeNode<ComponentNode> | null {\n return useContext(NodeTreeContext)\n}\n","import { createContext } from '../context.ts'\n\nexport type AppContextProps<TMeta extends object = object> = {\n /**\n * Exit (unmount)\n */\n exit: (error?: Error) => void\n meta: TMeta\n}\n\n/**\n * Provides app-level metadata and lifecycle hooks (like `exit`) to\n * components and composables within a Fabric runtime.\n */\nexport const AppContext = createContext<AppContextProps>({\n exit: () => {},\n meta: {},\n})\n","import { useContext } from '../composables/useContext.ts'\nimport { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { AppContext } from '../contexts/AppContext.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { RootContext } from '../contexts/RootContext.ts'\nimport { createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\n\nexport type AppProps<TMeta extends Object = Object> = {\n /**\n * Metadata attached to the App context.\n *\n * Use this to pass custom data to child components via useApp.\n */\n meta?: TMeta\n /**\n * Child components.\n */\n children?: FabricNode\n}\n\n/**\n * Container component providing App context with metadata and lifecycle.\n *\n * Use this component to wrap your application and provide shared metadata\n * that can be accessed by child components using the useApp composable.\n *\n * @example\n * ```tsx\n * <App meta={{ version: '1.0.0', author: 'John Doe' }}>\n * <File baseName=\"user.ts\" path=\"./user.ts\">\n * <File.Source>export type User = {}</File.Source>\n * </File>\n * </App>\n * ```\n */\nexport const App = createComponent('App', ({ children, ...props }: AppProps) => {\n const { meta = {} } = props\n\n const { exit } = useContext(RootContext)\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'App', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n provide(AppContext, { exit, meta })\n\n return children\n})\n\nApp.displayName = 'App'\n","import { createComponent } from '../createComponent.ts'\nimport { createIntrinsic } from '../intrinsic.ts'\n\n/**\n * Generates a line break in the output.\n *\n * Use this component to add newlines in generated code.\n *\n * @example\n * ```tsx\n * <>\n * const x = 1\n * <Br />\n * const y = 2\n * </>\n * ```\n */\nexport const Br = createComponent('br', () => {\n return createIntrinsic('br')\n})\n\nBr.displayName = 'Br'\n","/**\n * Create JSDoc comment block from comments array\n */\nexport function createJSDoc({ comments }: { comments: string[] }): string {\n if (!comments || comments.length === 0) return ''\n\n const lines = comments\n .flatMap((c) => String(c ?? '').split(/\\r?\\n/))\n .map((l) => l.replace(/\\*\\//g, '*\\\\/').replace(/\\r/g, ''))\n .filter((l) => l.trim().length > 0)\n\n if (lines.length === 0) return ''\n\n return ['/**', ...lines.map((l) => ` * ${l}`), ' */'].join('\\n')\n}\n","import { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\nimport { renderIntrinsic } from '../intrinsic.ts'\nimport type { JSDoc } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\n\nexport type ConstProps = {\n /**\n * Name of the constant.\n */\n name: string\n /**\n * Export this constant.\n * - `true` generates `export const`\n * - `false` generates internal const\n * @default false\n */\n export?: boolean\n /**\n * TypeScript type annotation.\n *\n * @example 'string' or 'User[]'\n */\n type?: string\n /**\n * JSDoc comments for the constant.\n */\n JSDoc?: JSDoc\n /**\n * Use const assertion.\n * - `true` adds `as const` for deep readonly\n * - `false` uses inferred or explicit type\n * @default false\n */\n asConst?: boolean\n /**\n * Constant value.\n */\n children?: FabricNode\n}\n\n/**\n * Generates a TypeScript constant declaration.\n *\n * @example\n * ```tsx\n * <Const name=\"API_URL\" export type=\"string\">\n * 'https://api.example.com'\n * </Const>\n * ```\n */\nexport const Const = createComponent('Const', ({ children, ...props }: ConstProps) => {\n const { name, export: canExport, type, JSDoc, asConst } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'Const', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const value = renderIntrinsic(children)\n\n let result = ''\n\n if (JSDoc?.comments) {\n result += createJSDoc({ comments: JSDoc.comments })\n result += '\\n'\n }\n\n if (canExport) {\n result += 'export '\n }\n\n result += `const ${name}`\n\n if (type) {\n result += `: ${type}`\n }\n\n result += ` = ${children ? value : ''}`\n\n if (asConst) {\n result += ' as const'\n }\n\n return result\n})\n\nConst.displayName = 'Const'\n","import { createComponent } from '../createComponent.ts'\nimport { createIntrinsic } from '../intrinsic.ts'\n\n/**\n * Decreases indentation level in the output.\n *\n * Use this component to reduce indentation after an indented code block.\n * Typically paired with Indent to control indentation levels.\n *\n * @example\n * ```tsx\n * <>\n * function example() {'{'}<Br />\n * <Indent />\n * return true<Br />\n * <Dedent />\n * {'}'}\n * </>\n * ```\n */\nexport const Dedent = createComponent('dedent', () => {\n return createIntrinsic('dedent')\n})\nDedent.displayName = 'Dedent'\n","import { createContext } from '../context.ts'\nimport type * as KubbFile from '../KubbFile.ts'\n\n/**\n * Provides app-level metadata and lifecycle hooks (like `exit`) to\n * components and composables within a Fabric runtime.\n */\nexport const FileContext = createContext<KubbFile.ResolvedFile | null>(null)\n","import { FileContext } from '../contexts/FileContext.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { useContext } from './useContext.ts'\n\n/**\n * Accesses the current File context.\n *\n * Use this composable to access or modify the current file's properties,\n * sources, imports, or exports.\n *\n * @returns The current file object or null if not within a File component\n *\n * @example\n * ```ts\n * const file = useFile()\n * if (file) {\n * console.log(file.path)\n * file.sources.push({ value: 'export const x = 1', isExportable: true })\n * }\n * ```\n */\nexport function useFile(): KubbFile.ResolvedFile | null {\n return useContext(FileContext)\n}\n","import { RootContext } from '../contexts/RootContext.ts'\nimport type { FileManager } from '../FileManager.ts'\nimport { useContext } from './useContext.ts'\n\n/**\n * Accesses the FileManager from the Root context.\n *\n * Use this composable to interact with the FileManager directly,\n * such as adding, retrieving, or managing files.\n *\n * @returns The current FileManager instance\n *\n * @example\n * ```ts\n * const fileManager = useFileManager()\n * fileManager.add({\n * baseName: 'user.ts',\n * path: './generated/user.ts',\n * sources: []\n * })\n * ```\n */\nexport function useFileManager(): FileManager {\n const { fileManager } = useContext(RootContext)\n\n return fileManager\n}\n","import { useFile } from '../composables/useFile.ts'\nimport { useFileManager } from '../composables/useFileManager.ts'\nimport { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { FileContext } from '../contexts/FileContext.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { type ComponentBuilder, createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\nimport { renderIntrinsic } from '../intrinsic.ts'\nimport { createExport, createImport, print } from '../parsers/typescriptParser.ts'\nimport type { KubbFile } from '../types.ts'\n\nexport type FileProps<TMeta extends object = object> = {\n /**\n * File name with extension.\n *\n * @example 'user.ts'\n */\n baseName: KubbFile.BaseName\n /**\n * Full path to the file including directory and file name.\n *\n * The path must include the baseName at the end.\n *\n * @example './generated/types/user.ts'\n */\n path: KubbFile.Path\n /**\n * Optional metadata attached to the file.\n *\n * Use this to store custom information about the file.\n */\n meta?: TMeta\n /**\n * Optional banner text added at the top of the file.\n */\n banner?: string\n /**\n * Optional footer text added at the bottom of the file.\n */\n footer?: string\n /**\n * Child components (File.Source, File.Import, File.Export).\n */\n children?: FabricNode\n}\n\n/**\n * Component for generating files with sources, imports, and exports.\n *\n * Creates files in the FileManager that can be written to disk.\n *\n * @example\n * ```tsx\n * <File baseName=\"user.ts\" path=\"./generated/user.ts\">\n * <File.Source isExportable>\n * export type User = {{ '{' }} id: number {{ '}' }}\n * </File.Source>\n * </File>\n * ```\n */\nexport const File = createComponent('File', ({ children, ...props }: FileProps) => {\n const { baseName, path, meta = {}, footer, banner } = props\n\n const fileManager = useFileManager()\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'File', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const file: KubbFile.File = {\n baseName,\n path,\n meta,\n banner,\n footer,\n sources: [],\n imports: [],\n exports: [],\n }\n\n const [resolvedFile] = fileManager.add(file)\n provide(FileContext, resolvedFile)\n\n return children\n}) as ComponentBuilder<FileProps<object>> & { Source: typeof FileSource; Import: typeof FileImport; Export: typeof FileExport }\n\ntype FileSourceProps = Omit<KubbFile.Source, 'value'> & {\n /**\n * Source code content.\n */\n children?: FabricNode\n}\n\n/**\n * Adds source code to a file.\n *\n * Use this component inside a File component to add code blocks.\n *\n * @example\n * ```tsx\n * <File.Source isExportable name=\"User\">\n * export type User = {{ '{' }} id: number {{ '}' }}\n * </File.Source>\n * ```\n */\nexport const FileSource = createComponent('FileSource', ({ children, ...props }: FileSourceProps) => {\n const { name, isExportable, isIndexable, isTypeOnly } = props\n\n const nodeTree = useNodeTree()\n const file = useFile()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'FileSource', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const value = renderIntrinsic(children)\n\n if (file) {\n file.sources.push({\n name,\n isExportable,\n isIndexable,\n isTypeOnly,\n value,\n })\n }\n\n return value\n})\n\nexport type FileExportProps = KubbFile.Export\n\n/**\n * Adds export statements to a file.\n *\n * Use this component to create re-exports from other files.\n *\n * @example\n * ```tsx\n * <File.Export name=\"User\" path=\"./types/user\" isTypeOnly />\n * ```\n */\nexport const FileExport = createComponent('FileExport', (props: FileExportProps) => {\n const { name, path, isTypeOnly, asAlias } = props\n\n const nodeTree = useNodeTree()\n const file = useFile()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'FileExport', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n if (file) {\n file.exports.push({\n name,\n path,\n asAlias,\n isTypeOnly,\n })\n }\n\n return print(createExport({ name, path, isTypeOnly, asAlias }))\n})\n\nexport type FileImportProps = KubbFile.Import\n\n/**\n * Adds import statements to a file.\n *\n * Use this component to import types or values from other files.\n *\n * @example\n * ```tsx\n * <File.Import name=\"User\" path=\"./types/user\" isTypeOnly />\n * ```\n */\nexport const FileImport = createComponent('FileImport', (props: FileImportProps) => {\n const { name, path, root, isNameSpace, isTypeOnly } = props\n\n const nodeTree = useNodeTree()\n const file = useFile()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'FileImport', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n if (file) {\n file.imports.push({\n name,\n path,\n root,\n isNameSpace,\n isTypeOnly,\n })\n }\n\n return print(createImport({ name, path, root, isNameSpace, isTypeOnly }))\n})\n\nFile.Source = FileSource\nFile.Import = FileImport\nFile.Export = FileExport\n","import { createComponent } from '../createComponent.ts'\nimport { createIntrinsic } from '../intrinsic.ts'\n\n/**\n * Increases indentation level in the output.\n *\n * Use this component to add indentation for nested code blocks.\n * Typically paired with Dedent to control indentation levels.\n *\n * @example\n * ```tsx\n * <>\n * function example() {'{'}<Br />\n * <Indent />\n * return true<Br />\n * <Dedent />\n * {'}'}\n * </>\n * ```\n */\nexport const Indent = createComponent('indent', () => {\n return createIntrinsic('indent')\n})\nIndent.displayName = 'Indent'\n","import { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { type ComponentBuilder, createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\nimport type { JSDoc } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\nimport { Br } from './Br.ts'\nimport { Dedent } from './Dedent.ts'\nimport { Indent } from './Indent.ts'\n\ntype FunctionProps = {\n /**\n * Name of the function.\n */\n name: string\n /**\n * Export with default keyword.\n * - `true` generates `export default function`\n * - `false` generates named export or no export\n * @default false\n */\n default?: boolean\n /**\n * Function parameters.\n *\n * @example 'id: number, name: string'\n */\n params?: string\n /**\n * Export this function.\n * - `true` generates `export function`\n * - `false` generates internal function\n * @default false\n */\n export?: boolean\n /**\n * Make the function async.\n * - `true` adds async keyword and wraps return type in Promise\n * - `false` generates synchronous function\n * @default false\n */\n async?: boolean\n /**\n * TypeScript generics.\n *\n * @example 'T' or ['T', 'U']\n */\n generics?: string | string[]\n /**\n * Return type of the function.\n *\n * When async is true, this is automatically wrapped in Promise.\n */\n returnType?: string\n /**\n * JSDoc comments for the function.\n */\n JSDoc?: JSDoc\n /**\n * Function body.\n */\n children?: FabricNode\n}\n\n/**\n * Generates a TypeScript function declaration.\n *\n * @example\n * ```tsx\n * <Function\n * name=\"getUser\"\n * export\n * async\n * params=\"id: number\"\n * returnType=\"User\"\n * >\n * return fetch(`/users/${id}`).then(r => r.json())\n * </Function>\n * ```\n */\nexport const Function = createComponent('Function', ({ children, ...props }: FunctionProps) => {\n const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'Function', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const parts: string[] = []\n\n if (JSDoc?.comments) {\n parts.push(createJSDoc({ comments: JSDoc.comments }))\n parts.push('\\n')\n }\n\n if (canExport) {\n parts.push('export ')\n }\n\n if (isDefault) {\n parts.push('default ')\n }\n\n if (async) {\n parts.push('async ')\n }\n\n parts.push(`function ${name}`)\n\n if (generics) {\n parts.push('<')\n parts.push(Array.isArray(generics) ? generics.join(', ').trim() : generics)\n parts.push('>')\n }\n\n parts.push(`(${params || ''})`)\n\n if (returnType && !async) {\n parts.push(`: ${returnType}`)\n }\n\n if (returnType && async) {\n parts.push(`: Promise<${returnType}>`)\n }\n\n parts.push(' {')\n\n if (children) {\n return [parts.join(''), Br(), Indent(), children, Br(), Dedent(), '}']\n }\n\n return [parts.join(''), '}']\n}) as ComponentBuilder<FunctionProps> & { Arrow: typeof ArrowFunction }\n\nFunction.displayName = 'Function'\n\ntype ArrowFunctionProps = FunctionProps & {\n /**\n * Create Arrow function in one line\n */\n singleLine?: boolean\n}\n\n/**\n * ArrowFunction\n *\n * Builds an arrow function declaration string for the fsx renderer. Supports\n * the same options as `Function`. Use `singleLine` to produce a one-line\n * arrow expression.\n */\nconst ArrowFunction = createComponent('ArrowFunction', ({ children, ...props }: ArrowFunctionProps) => {\n const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'ArrowFunction', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const parts: string[] = []\n\n if (JSDoc?.comments) {\n parts.push(createJSDoc({ comments: JSDoc.comments }))\n parts.push('\\n')\n }\n\n if (canExport) {\n parts.push('export ')\n }\n\n if (isDefault) {\n parts.push('default ')\n }\n\n parts.push(`const ${name} = `)\n\n if (async) {\n parts.push('async ')\n }\n\n if (generics) {\n parts.push('<')\n parts.push(Array.isArray(generics) ? generics.join(', ').trim() : generics)\n parts.push('>')\n }\n\n parts.push(`(${params || ''})`)\n\n if (returnType && !async) {\n parts.push(`: ${returnType}`)\n }\n\n if (returnType && async) {\n parts.push(`: Promise<${returnType}>`)\n }\n\n if (singleLine) {\n parts.push(` => ${children || ''}\\n`)\n return parts.join('')\n }\n\n if (children) {\n return [parts.join(''), ' => {', Br(), Indent(), children, Br(), Dedent(), '}']\n }\n\n return [parts.join(''), ' => {}']\n})\n\nArrowFunction.displayName = 'ArrowFunction'\nFunction.Arrow = ArrowFunction\n","import { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\nimport { renderIntrinsic } from '../intrinsic.ts'\nimport type { JSDoc } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\n\nexport type TypeProps = {\n /**\n * Name of the type (must start with a capital letter).\n */\n name: string\n /**\n * Export this type.\n * - `true` generates `export type`\n * - `false` generates internal type\n * @default false\n */\n export?: boolean\n /**\n * JSDoc comments for the type.\n */\n JSDoc?: JSDoc\n /**\n * Type definition.\n */\n children?: FabricNode\n}\n\n/**\n * Generates a TypeScript type declaration.\n *\n * @example\n * ```tsx\n * <Type name=\"User\" export>\n * {'{'} id: number; name: string {'}'}\n * </Type>\n * ```\n */\nexport const Type = createComponent('Type', ({ children, ...props }: TypeProps) => {\n const { name, export: canExport, JSDoc } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'Type', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n if (name.charAt(0).toUpperCase() !== name.charAt(0)) {\n throw new Error('Name should start with a capital letter (see TypeScript types)')\n }\n\n const value = renderIntrinsic(children)\n\n let result = ''\n\n if (JSDoc?.comments) {\n result += createJSDoc({ comments: JSDoc.comments })\n result += '\\n'\n }\n\n if (canExport) {\n result += 'export '\n }\n\n result += `type ${name} = ${value || ''}`\n\n return result\n})\n\nType.displayName = 'Type'\n","import { AppContext, type AppContextProps } from '../contexts/AppContext.ts'\nimport { useContext } from './useContext.ts'\n\n/**\n * Accesses the App context with metadata and exit function.\n *\n * Use this composable to access metadata defined in the App component\n * or to exit the rendering process early.\n *\n * @throws Error when no AppContext is available\n *\n * @example\n * ```ts\n * const { meta, exit } = useApp<{ version: string }>()\n * console.log(meta.version)\n * ```\n */\nexport function useApp<TMeta extends object = object>(): AppContextProps<TMeta> {\n return useContext(AppContext) as AppContextProps<TMeta>\n}\n","import { RootContext } from '../contexts/RootContext.ts'\nimport { useContext } from './useContext.ts'\n\n/**\n * Accesses lifecycle helpers for controlling generation flow.\n *\n * Use this composable to exit the rendering process early or perform\n * cleanup operations.\n *\n * @returns Object with lifecycle methods (exit)\n *\n * @example\n * ```ts\n * const { exit } = useLifecycle()\n *\n * // Stop generation on error\n * if (invalidData) {\n * exit(new Error('Invalid data'))\n * }\n * ```\n */\nexport function useLifecycle() {\n const { exit } = useContext(RootContext)\n\n return {\n exit,\n }\n}\n","import { isFunction } from 'remeda'\nimport type { Fabric, FabricConfig, FabricContext, FabricEvents, FabricOptions } from './Fabric.ts'\nimport { FileManager } from './FileManager.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport type { Parser } from './parsers/types.ts'\nimport type { Plugin } from './plugins/types.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\n\n/**\n * Creates a new Fabric instance for file generation.\n *\n * The Fabric instance provides methods for registering plugins,\n * adding files, and triggering file generation.\n *\n * @param config - Optional configuration object\n * @returns A new Fabric instance\n *\n * @example\n * ```ts\n * import { createFabric } from '@kubb/fabric-core'\n * import { fsPlugin } from '@kubb/fabric-core/plugins'\n * import { typescriptParser } from '@kubb/fabric-core/parsers'\n *\n * const fabric = createFabric()\n * fabric.use(fsPlugin)\n * fabric.use(typescriptParser)\n *\n * await fabric.addFile({\n * baseName: 'user.ts',\n * path: './generated/user.ts',\n * sources: [{ value: 'export type User = {}', isExportable: true }],\n * imports: [],\n * exports: [],\n * })\n *\n * await fabric.write({ extension: { '.ts': '.ts' } })\n * ```\n */\nexport function createFabric<T extends FabricOptions>(config: FabricConfig<T> = { mode: 'sequential' } as FabricConfig<T>): Fabric<T> {\n const events = new AsyncEventEmitter<FabricEvents>()\n const installedPlugins = new Set<Plugin<any>>()\n const installedParsers = new Map<KubbFile.Extname, Parser<any>>()\n const installedParserNames = new Set<string>()\n const fileManager = new FileManager({ events })\n\n const context: FabricContext<T> = {\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n config,\n fileManager,\n installedPlugins,\n installedParsers,\n on: events.on.bind(events),\n off: events.off.bind(events),\n onOnce: events.onOnce.bind(events),\n removeAll: events.removeAll.bind(events),\n emit: events.emit.bind(events),\n } as FabricContext<T>\n\n const fabric: Fabric<T> = {\n context,\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n async upsertFile(...files) {\n await fileManager.upsert(...files)\n },\n async use(pluginOrParser, ...options) {\n if (pluginOrParser.type === 'plugin') {\n if (installedPlugins.has(pluginOrParser)) {\n console.warn(`Plugin \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedPlugins.add(pluginOrParser)\n }\n\n if (isFunction(pluginOrParser.inject)) {\n const injecter = pluginOrParser.inject\n\n const injected = (injecter as any)(context, ...options)\n Object.assign(fabric, injected)\n }\n }\n\n if (pluginOrParser.type === 'parser') {\n if (installedParserNames.has(pluginOrParser.name)) {\n console.warn(`Parser \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedParserNames.add(pluginOrParser.name)\n }\n\n if (pluginOrParser.extNames) {\n for (const extName of pluginOrParser.extNames) {\n const existing = installedParsers.get(extName)\n if (existing && existing.name !== pluginOrParser.name) {\n console.warn(`Parser \"${pluginOrParser.name}\" is overriding parser \"${existing.name}\" for extension \"${extName}\".`)\n }\n installedParsers.set(extName, pluginOrParser)\n }\n }\n }\n\n if (isFunction(pluginOrParser.install)) {\n const installer = pluginOrParser.install\n\n await (installer as any)(context, ...options)\n }\n\n return fabric\n },\n } as Fabric<T>\n\n return fabric\n}\n"],"mappings":";;;;;;;;AAaA,SAAgB,WAAc,KAAiB,cAAqB;AAClE,QAAOA,6BAAO,KAAK,aAAa;;;;;;;;;;;;;;;;;;;;;ACWlC,SAAgB,cAA8C;AAC5D,QAAO,WAAWC,sCAAgB;;;;;;;;;ACZpC,MAAa,aAAaC,oCAA+B;CACvD,YAAY;CACZ,MAAM,EAAE;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,GAAG,SAAS;AACpC,OAAI,eAAe,SAAS,UAAU;AACpC,QAAI,iBAAiB,IAAI,eAAe,CACtC,SAAQ,KAAK,WAAW,eAAe,KAAK,oBAAoB;QAEhE,kBAAiB,IAAI,eAAe;AAGtC,+BAAe,eAAe,OAAO,EAAE;KACrC,MAAM,WAAW,eAAe;KAEhC,MAAM,WAAY,SAAiB,SAAS,GAAG,QAAQ;AACvD,YAAO,OAAO,QAAQ,SAAS;;;AAInC,OAAI,eAAe,SAAS,UAAU;AACpC,QAAI,qBAAqB,IAAI,eAAe,KAAK,CAC/C,SAAQ,KAAK,WAAW,eAAe,KAAK,oBAAoB;QAEhE,sBAAqB,IAAI,eAAe,KAAK;AAG/C,QAAI,eAAe,SACjB,MAAK,MAAM,WAAW,eAAe,UAAU;KAC7C,MAAM,WAAW,iBAAiB,IAAI,QAAQ;AAC9C,SAAI,YAAY,SAAS,SAAS,eAAe,KAC/C,SAAQ,KAAK,WAAW,eAAe,KAAK,0BAA0B,SAAS,KAAK,mBAAmB,QAAQ,IAAI;AAErH,sBAAiB,IAAI,SAAS,eAAe;;;AAKnD,8BAAe,eAAe,QAAQ,EAAE;IACtC,MAAM,YAAY,eAAe;AAEjC,UAAO,UAAkB,SAAS,GAAG,QAAQ;;AAG/C,UAAO;;EAEV;AAED,QAAO"}
1
+ {"version":3,"file":"index.cjs","names":["inject","NodeTreeContext","createContext","createComponent","RootContext","NodeTreeContext","createComponent","createIntrinsic","createComponent","NodeTreeContext","renderIntrinsic","createComponent","createIntrinsic","createContext","RootContext","createComponent","NodeTreeContext","renderIntrinsic","print","createExport","createImport","createComponent","createIntrinsic","createComponent","NodeTreeContext","createComponent","NodeTreeContext","renderIntrinsic","RootContext","AsyncEventEmitter","FileManager"],"sources":["../src/composables/useContext.ts","../src/composables/useNodeTree.ts","../src/contexts/AppContext.ts","../src/components/App.ts","../src/components/Br.ts","../src/utils/createJSDoc.ts","../src/components/Const.ts","../src/components/Dedent.ts","../src/contexts/FileContext.ts","../src/composables/useFile.ts","../src/composables/useFileManager.ts","../src/components/File.ts","../src/components/Indent.ts","../src/components/Function.ts","../src/components/Type.ts","../src/composables/useApp.ts","../src/composables/useLifecycle.ts","../src/createFabric.ts"],"sourcesContent":["import type { Context } from '../context.ts'\nimport { inject } from '../context.ts'\n\n/**\n * React-style alias for inject\n *\n * @example\n * ```ts\n * const theme = useContext(ThemeContext) // type is inferred from ThemeContext\n * ```\n */\nexport function useContext<T>(key: Context<T>): T\nexport function useContext<T, TValue = T>(key: Context<T>, defaultValue: TValue): NonNullable<T> | TValue\nexport function useContext<T>(key: Context<T>, defaultValue?: T): T {\n return inject(key, defaultValue)\n}\n","import { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport type { TreeNode } from '../utils/TreeNode.ts'\nimport { useContext } from './useContext.ts'\n\nexport type ComponentNode = {\n type: string\n props: Record<string, unknown>\n}\n\n/**\n * Accesses the current node tree for tracking component hierarchy.\n *\n * Use this composable to inspect or manipulate the component tree structure.\n * Returns null if not within a component that provides NodeTreeContext.\n *\n * @returns The current TreeNode or null\n *\n * @example\n * ```ts\n * const nodeTree = useNodeTree()\n * if (nodeTree) {\n * const childTree = nodeTree.addChild({ type: 'MyComponent', props: {} })\n * }\n * ```\n */\nexport function useNodeTree(): TreeNode<ComponentNode> | null {\n return useContext(NodeTreeContext)\n}\n","import { createContext } from '../context.ts'\n\nexport type AppContextProps<TMeta extends object = object> = {\n /**\n * Exit (unmount)\n */\n exit: (error?: Error) => void\n meta: TMeta\n}\n\n/**\n * Provides app-level metadata and lifecycle hooks (like `exit`) to\n * components and composables within a Fabric runtime.\n */\nexport const AppContext = createContext<AppContextProps>({\n exit: () => {},\n meta: {},\n})\n","import { useContext } from '../composables/useContext.ts'\nimport { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { AppContext } from '../contexts/AppContext.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { RootContext } from '../contexts/RootContext.ts'\nimport { createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\n\nexport type AppProps<TMeta extends Object = Object> = {\n /**\n * Metadata attached to the App context.\n *\n * Use this to pass custom data to child components via useApp.\n */\n meta?: TMeta\n /**\n * Child components.\n */\n children?: FabricNode\n}\n\n/**\n * Container component providing App context with metadata and lifecycle.\n *\n * Use this component to wrap your application and provide shared metadata\n * that can be accessed by child components using the useApp composable.\n *\n * @example\n * ```tsx\n * <App meta={{ version: '1.0.0', author: 'John Doe' }}>\n * <File baseName=\"user.ts\" path=\"./user.ts\">\n * <File.Source>export type User = {}</File.Source>\n * </File>\n * </App>\n * ```\n */\nexport const App = createComponent('App', ({ children, ...props }: AppProps) => {\n const { meta = {} } = props\n\n const { exit } = useContext(RootContext)\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'App', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n provide(AppContext, { exit, meta })\n\n return children\n})\n\nApp.displayName = 'App'\n","import { createComponent } from '../createComponent.ts'\nimport { createIntrinsic } from '../intrinsic.ts'\n\n/**\n * Generates a line break in the output.\n *\n * Use this component to add newlines in generated code.\n *\n * @example\n * ```tsx\n * <>\n * const x = 1\n * <Br />\n * const y = 2\n * </>\n * ```\n */\nexport const Br = createComponent('br', () => {\n return createIntrinsic('br')\n})\n\nBr.displayName = 'Br'\n","/**\n * Create JSDoc comment block from comments array\n */\nexport function createJSDoc({ comments }: { comments: string[] }): string {\n if (!comments || comments.length === 0) return ''\n\n const lines = comments\n .flatMap((c) => String(c ?? '').split(/\\r?\\n/))\n .map((l) => l.replace(/\\*\\//g, '*\\\\/').replace(/\\r/g, ''))\n .filter((l) => l.trim().length > 0)\n\n if (lines.length === 0) return ''\n\n return ['/**', ...lines.map((l) => ` * ${l}`), ' */'].join('\\n')\n}\n","import { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\nimport { renderIntrinsic } from '../intrinsic.ts'\nimport type { JSDoc } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\n\nexport type ConstProps = {\n /**\n * Name of the constant.\n */\n name: string\n /**\n * Export this constant.\n * - `true` generates `export const`\n * - `false` generates internal const\n * @default false\n */\n export?: boolean\n /**\n * TypeScript type annotation.\n *\n * @example 'string' or 'User[]'\n */\n type?: string\n /**\n * JSDoc comments for the constant.\n */\n JSDoc?: JSDoc\n /**\n * Use const assertion.\n * - `true` adds `as const` for deep readonly\n * - `false` uses inferred or explicit type\n * @default false\n */\n asConst?: boolean\n /**\n * Constant value.\n */\n children?: FabricNode\n}\n\n/**\n * Generates a TypeScript constant declaration.\n *\n * @example\n * ```tsx\n * <Const name=\"API_URL\" export type=\"string\">\n * 'https://api.example.com'\n * </Const>\n * ```\n */\nexport const Const = createComponent('Const', ({ children, ...props }: ConstProps) => {\n const { name, export: canExport, type, JSDoc, asConst } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'Const', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const value = renderIntrinsic(children)\n\n let result = ''\n\n if (JSDoc?.comments) {\n result += createJSDoc({ comments: JSDoc.comments })\n result += '\\n'\n }\n\n if (canExport) {\n result += 'export '\n }\n\n result += `const ${name}`\n\n if (type) {\n result += `: ${type}`\n }\n\n result += ` = ${children ? value : ''}`\n\n if (asConst) {\n result += ' as const'\n }\n\n return result\n})\n\nConst.displayName = 'Const'\n","import { createComponent } from '../createComponent.ts'\nimport { createIntrinsic } from '../intrinsic.ts'\n\n/**\n * Decreases indentation level in the output.\n *\n * Use this component to reduce indentation after an indented code block.\n * Typically paired with Indent to control indentation levels.\n *\n * @example\n * ```tsx\n * <>\n * function example() {'{'}<Br />\n * <Indent />\n * return true<Br />\n * <Dedent />\n * {'}'}\n * </>\n * ```\n */\nexport const Dedent = createComponent('dedent', () => {\n return createIntrinsic('dedent')\n})\nDedent.displayName = 'Dedent'\n","import { createContext } from '../context.ts'\nimport type * as KubbFile from '../KubbFile.ts'\n\n/**\n * Provides app-level metadata and lifecycle hooks (like `exit`) to\n * components and composables within a Fabric runtime.\n */\nexport const FileContext = createContext<KubbFile.ResolvedFile | null>(null)\n","import { FileContext } from '../contexts/FileContext.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { useContext } from './useContext.ts'\n\n/**\n * Accesses the current File context.\n *\n * Use this composable to access or modify the current file's properties,\n * sources, imports, or exports.\n *\n * @returns The current file object or null if not within a File component\n *\n * @example\n * ```ts\n * const file = useFile()\n * if (file) {\n * console.log(file.path)\n * file.sources.push({ value: 'export const x = 1', isExportable: true })\n * }\n * ```\n */\nexport function useFile(): KubbFile.ResolvedFile | null {\n return useContext(FileContext)\n}\n","import { RootContext } from '../contexts/RootContext.ts'\nimport type { FileManager } from '../FileManager.ts'\nimport { useContext } from './useContext.ts'\n\n/**\n * Accesses the FileManager from the Root context.\n *\n * Use this composable to interact with the FileManager directly,\n * such as adding, retrieving, or managing files.\n *\n * @returns The current FileManager instance\n *\n * @example\n * ```ts\n * const fileManager = useFileManager()\n * fileManager.add({\n * baseName: 'user.ts',\n * path: './generated/user.ts',\n * sources: []\n * })\n * ```\n */\nexport function useFileManager(): FileManager {\n const { fileManager } = useContext(RootContext)\n\n return fileManager\n}\n","import { useFile } from '../composables/useFile.ts'\nimport { useFileManager } from '../composables/useFileManager.ts'\nimport { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { FileContext } from '../contexts/FileContext.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { type ComponentBuilder, createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\nimport { renderIntrinsic } from '../intrinsic.ts'\nimport { createExport, createImport, print } from '../parsers/typescriptParser.ts'\nimport type { KubbFile } from '../types.ts'\n\nexport type FileProps<TMeta extends object = object> = {\n /**\n * File name with extension.\n *\n * @example 'user.ts'\n */\n baseName: KubbFile.BaseName\n /**\n * Full path to the file including directory and file name.\n *\n * The path must include the baseName at the end.\n *\n * @example './generated/types/user.ts'\n */\n path: KubbFile.Path\n /**\n * Optional metadata attached to the file.\n *\n * Use this to store custom information about the file.\n */\n meta?: TMeta\n /**\n * Optional banner text added at the top of the file.\n */\n banner?: string\n /**\n * Optional footer text added at the bottom of the file.\n */\n footer?: string\n /**\n * Child components (File.Source, File.Import, File.Export).\n */\n children?: FabricNode\n}\n\n/**\n * Component for generating files with sources, imports, and exports.\n *\n * Creates files in the FileManager that can be written to disk.\n *\n * @example\n * ```tsx\n * <File baseName=\"user.ts\" path=\"./generated/user.ts\">\n * <File.Source isExportable>\n * export type User = {{ '{' }} id: number {{ '}' }}\n * </File.Source>\n * </File>\n * ```\n */\nexport const File = createComponent('File', ({ children, ...props }: FileProps) => {\n const { baseName, path, meta = {}, footer, banner } = props\n\n const fileManager = useFileManager()\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'File', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const file: KubbFile.File = {\n baseName,\n path,\n meta,\n banner,\n footer,\n sources: [],\n imports: [],\n exports: [],\n }\n\n const [resolvedFile] = fileManager.add(file)\n provide(FileContext, resolvedFile)\n\n return children\n}) as ComponentBuilder<FileProps<object>> & { Source: typeof FileSource; Import: typeof FileImport; Export: typeof FileExport }\n\ntype FileSourceProps = Omit<KubbFile.Source, 'value'> & {\n /**\n * Source code content.\n */\n children?: FabricNode\n}\n\n/**\n * Adds source code to a file.\n *\n * Use this component inside a File component to add code blocks.\n *\n * @example\n * ```tsx\n * <File.Source isExportable name=\"User\">\n * export type User = {{ '{' }} id: number {{ '}' }}\n * </File.Source>\n * ```\n */\nexport const FileSource = createComponent('FileSource', ({ children, ...props }: FileSourceProps) => {\n const { name, isExportable, isIndexable, isTypeOnly } = props\n\n const nodeTree = useNodeTree()\n const file = useFile()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'FileSource', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const value = renderIntrinsic(children)\n\n if (file) {\n file.sources.push({\n name,\n isExportable,\n isIndexable,\n isTypeOnly,\n value,\n })\n }\n\n return value\n})\n\nexport type FileExportProps = KubbFile.Export\n\n/**\n * Adds export statements to a file.\n *\n * Use this component to create re-exports from other files.\n *\n * @example\n * ```tsx\n * <File.Export name=\"User\" path=\"./types/user\" isTypeOnly />\n * ```\n */\nexport const FileExport = createComponent('FileExport', (props: FileExportProps) => {\n const { name, path, isTypeOnly, asAlias } = props\n\n const nodeTree = useNodeTree()\n const file = useFile()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'FileExport', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n if (file) {\n file.exports.push({\n name,\n path,\n asAlias,\n isTypeOnly,\n })\n }\n\n return print(createExport({ name, path, isTypeOnly, asAlias }))\n})\n\nexport type FileImportProps = KubbFile.Import\n\n/**\n * Adds import statements to a file.\n *\n * Use this component to import types or values from other files.\n *\n * @example\n * ```tsx\n * <File.Import name=\"User\" path=\"./types/user\" isTypeOnly />\n * ```\n */\nexport const FileImport = createComponent('FileImport', (props: FileImportProps) => {\n const { name, path, root, isNameSpace, isTypeOnly } = props\n\n const nodeTree = useNodeTree()\n const file = useFile()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'FileImport', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n if (file) {\n file.imports.push({\n name,\n path,\n root,\n isNameSpace,\n isTypeOnly,\n })\n }\n\n return print(createImport({ name, path, root, isNameSpace, isTypeOnly }))\n})\n\nFile.Source = FileSource\nFile.Import = FileImport\nFile.Export = FileExport\n","import { createComponent } from '../createComponent.ts'\nimport { createIntrinsic } from '../intrinsic.ts'\n\n/**\n * Increases indentation level in the output.\n *\n * Use this component to add indentation for nested code blocks.\n * Typically paired with Dedent to control indentation levels.\n *\n * @example\n * ```tsx\n * <>\n * function example() {'{'}<Br />\n * <Indent />\n * return true<Br />\n * <Dedent />\n * {'}'}\n * </>\n * ```\n */\nexport const Indent = createComponent('indent', () => {\n return createIntrinsic('indent')\n})\nIndent.displayName = 'Indent'\n","import { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { type ComponentBuilder, createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\nimport type { JSDoc } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\nimport { Br } from './Br.ts'\nimport { Dedent } from './Dedent.ts'\nimport { Indent } from './Indent.ts'\n\ntype FunctionProps = {\n /**\n * Name of the function.\n */\n name: string\n /**\n * Export with default keyword.\n * - `true` generates `export default function`\n * - `false` generates named export or no export\n * @default false\n */\n default?: boolean\n /**\n * Function parameters.\n *\n * @example 'id: number, name: string'\n */\n params?: string\n /**\n * Export this function.\n * - `true` generates `export function`\n * - `false` generates internal function\n * @default false\n */\n export?: boolean\n /**\n * Make the function async.\n * - `true` adds async keyword and wraps return type in Promise\n * - `false` generates synchronous function\n * @default false\n */\n async?: boolean\n /**\n * TypeScript generics.\n *\n * @example 'T' or ['T', 'U']\n */\n generics?: string | string[]\n /**\n * Return type of the function.\n *\n * When async is true, this is automatically wrapped in Promise.\n */\n returnType?: string\n /**\n * JSDoc comments for the function.\n */\n JSDoc?: JSDoc\n /**\n * Function body.\n */\n children?: FabricNode\n}\n\n/**\n * Generates a TypeScript function declaration.\n *\n * @example\n * ```tsx\n * <Function\n * name=\"getUser\"\n * export\n * async\n * params=\"id: number\"\n * returnType=\"User\"\n * >\n * return fetch(`/users/${id}`).then(r => r.json())\n * </Function>\n * ```\n */\nexport const Function = createComponent('Function', ({ children, ...props }: FunctionProps) => {\n const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'Function', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const parts: string[] = []\n\n if (JSDoc?.comments) {\n parts.push(createJSDoc({ comments: JSDoc.comments }))\n parts.push('\\n')\n }\n\n if (canExport) {\n parts.push('export ')\n }\n\n if (isDefault) {\n parts.push('default ')\n }\n\n if (async) {\n parts.push('async ')\n }\n\n parts.push(`function ${name}`)\n\n if (generics) {\n parts.push('<')\n parts.push(Array.isArray(generics) ? generics.join(', ').trim() : generics)\n parts.push('>')\n }\n\n parts.push(`(${params || ''})`)\n\n if (returnType && !async) {\n parts.push(`: ${returnType}`)\n }\n\n if (returnType && async) {\n parts.push(`: Promise<${returnType}>`)\n }\n\n parts.push(' {')\n\n if (children) {\n return [parts.join(''), Br(), Indent(), children, Br(), Dedent(), '}']\n }\n\n return [parts.join(''), '}']\n}) as ComponentBuilder<FunctionProps> & { Arrow: typeof ArrowFunction }\n\nFunction.displayName = 'Function'\n\ntype ArrowFunctionProps = FunctionProps & {\n /**\n * Create Arrow function in one line\n */\n singleLine?: boolean\n}\n\n/**\n * ArrowFunction\n *\n * Builds an arrow function declaration string for the fsx renderer. Supports\n * the same options as `Function`. Use `singleLine` to produce a one-line\n * arrow expression.\n */\nconst ArrowFunction = createComponent('ArrowFunction', ({ children, ...props }: ArrowFunctionProps) => {\n const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'ArrowFunction', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n const parts: string[] = []\n\n if (JSDoc?.comments) {\n parts.push(createJSDoc({ comments: JSDoc.comments }))\n parts.push('\\n')\n }\n\n if (canExport) {\n parts.push('export ')\n }\n\n if (isDefault) {\n parts.push('default ')\n }\n\n parts.push(`const ${name} = `)\n\n if (async) {\n parts.push('async ')\n }\n\n if (generics) {\n parts.push('<')\n parts.push(Array.isArray(generics) ? generics.join(', ').trim() : generics)\n parts.push('>')\n }\n\n parts.push(`(${params || ''})`)\n\n if (returnType && !async) {\n parts.push(`: ${returnType}`)\n }\n\n if (returnType && async) {\n parts.push(`: Promise<${returnType}>`)\n }\n\n if (singleLine) {\n parts.push(` => ${children || ''}\\n`)\n return parts.join('')\n }\n\n if (children) {\n return [parts.join(''), ' => {', Br(), Indent(), children, Br(), Dedent(), '}']\n }\n\n return [parts.join(''), ' => {}']\n})\n\nArrowFunction.displayName = 'ArrowFunction'\nFunction.Arrow = ArrowFunction\n","import { useNodeTree } from '../composables/useNodeTree.ts'\nimport { provide } from '../context.ts'\nimport { NodeTreeContext } from '../contexts/NodeTreeContext.ts'\nimport { createComponent } from '../createComponent.ts'\nimport type { FabricNode } from '../Fabric.ts'\nimport { renderIntrinsic } from '../intrinsic.ts'\nimport type { JSDoc } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\n\nexport type TypeProps = {\n /**\n * Name of the type (must start with a capital letter).\n */\n name: string\n /**\n * Export this type.\n * - `true` generates `export type`\n * - `false` generates internal type\n * @default false\n */\n export?: boolean\n /**\n * JSDoc comments for the type.\n */\n JSDoc?: JSDoc\n /**\n * Type definition.\n */\n children?: FabricNode\n}\n\n/**\n * Generates a TypeScript type declaration.\n *\n * @example\n * ```tsx\n * <Type name=\"User\" export>\n * {'{'} id: number; name: string {'}'}\n * </Type>\n * ```\n */\nexport const Type = createComponent('Type', ({ children, ...props }: TypeProps) => {\n const { name, export: canExport, JSDoc } = props\n\n const nodeTree = useNodeTree()\n\n if (nodeTree) {\n const childTree = nodeTree.addChild({ type: 'Type', props })\n\n provide(NodeTreeContext, childTree)\n }\n\n if (name.charAt(0).toUpperCase() !== name.charAt(0)) {\n throw new Error('Name should start with a capital letter (see TypeScript types)')\n }\n\n const value = renderIntrinsic(children)\n\n let result = ''\n\n if (JSDoc?.comments) {\n result += createJSDoc({ comments: JSDoc.comments })\n result += '\\n'\n }\n\n if (canExport) {\n result += 'export '\n }\n\n result += `type ${name} = ${value || ''}`\n\n return result\n})\n\nType.displayName = 'Type'\n","import { AppContext, type AppContextProps } from '../contexts/AppContext.ts'\nimport { useContext } from './useContext.ts'\n\n/**\n * Accesses the App context with metadata and exit function.\n *\n * Use this composable to access metadata defined in the App component\n * or to exit the rendering process early.\n *\n * @throws Error when no AppContext is available\n *\n * @example\n * ```ts\n * const { meta, exit } = useApp<{ version: string }>()\n * console.log(meta.version)\n * ```\n */\nexport function useApp<TMeta extends object = object>(): AppContextProps<TMeta> {\n return useContext(AppContext) as AppContextProps<TMeta>\n}\n","import { RootContext } from '../contexts/RootContext.ts'\nimport { useContext } from './useContext.ts'\n\n/**\n * Accesses lifecycle helpers for controlling generation flow.\n *\n * Use this composable to exit the rendering process early or perform\n * cleanup operations.\n *\n * @returns Object with lifecycle methods (exit)\n *\n * @example\n * ```ts\n * const { exit } = useLifecycle()\n *\n * // Stop generation on error\n * if (invalidData) {\n * exit(new Error('Invalid data'))\n * }\n * ```\n */\nexport function useLifecycle() {\n const { exit } = useContext(RootContext)\n\n return {\n exit,\n }\n}\n","import { isFunction } from 'remeda'\nimport type { Fabric, FabricConfig, FabricContext, FabricEvents, FabricOptions } from './Fabric.ts'\nimport { FileManager } from './FileManager.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport type { Parser } from './parsers/types.ts'\nimport type { Plugin } from './plugins/types.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\n\n/**\n * Creates a new Fabric instance for file generation.\n *\n * The Fabric instance provides methods for registering plugins,\n * adding files, and triggering file generation.\n *\n * @param config - Optional configuration object\n * @returns A new Fabric instance\n *\n * @example\n * ```ts\n * import { createFabric } from '@kubb/fabric-core'\n * import { fsPlugin } from '@kubb/fabric-core/plugins'\n * import { typescriptParser } from '@kubb/fabric-core/parsers'\n *\n * const fabric = createFabric()\n * fabric.use(fsPlugin)\n * fabric.use(typescriptParser)\n *\n * await fabric.addFile({\n * baseName: 'user.ts',\n * path: './generated/user.ts',\n * sources: [{ value: 'export type User = {}', isExportable: true }],\n * imports: [],\n * exports: [],\n * })\n *\n * await fabric.write({ extension: { '.ts': '.ts' } })\n * ```\n */\nexport function createFabric<T extends FabricOptions>(config: FabricConfig<T> = { mode: 'sequential' } as FabricConfig<T>): Fabric<T> {\n const events = new AsyncEventEmitter<FabricEvents>()\n const installedPlugins = new Set<Plugin<any>>()\n const installedParsers = new Map<KubbFile.Extname, Parser<any>>()\n const installedParserNames = new Set<string>()\n const fileManager = new FileManager({ events })\n\n const context: FabricContext<T> = {\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n config,\n fileManager,\n installedPlugins,\n installedParsers,\n on: events.on.bind(events),\n off: events.off.bind(events),\n onOnce: events.onOnce.bind(events),\n removeAll: events.removeAll.bind(events),\n emit: events.emit.bind(events),\n } as FabricContext<T>\n\n const fabric: Fabric<T> = {\n context,\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n async upsertFile(...files) {\n await fileManager.upsert(...files)\n },\n async use(pluginOrParser, ...options) {\n if (pluginOrParser.type === 'plugin') {\n if (installedPlugins.has(pluginOrParser)) {\n console.warn(`Plugin \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedPlugins.add(pluginOrParser)\n }\n\n if (isFunction(pluginOrParser.inject)) {\n const injecter = pluginOrParser.inject\n\n const injected = (injecter as any)(context, ...options)\n Object.assign(fabric, injected)\n }\n }\n\n if (pluginOrParser.type === 'parser') {\n if (installedParserNames.has(pluginOrParser.name)) {\n console.warn(`Parser \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedParserNames.add(pluginOrParser.name)\n }\n\n if (pluginOrParser.extNames) {\n for (const extName of pluginOrParser.extNames) {\n const existing = installedParsers.get(extName)\n if (existing && existing.name !== pluginOrParser.name) {\n console.warn(`Parser \"${pluginOrParser.name}\" is overriding parser \"${existing.name}\" for extension \"${extName}\".`)\n }\n installedParsers.set(extName, pluginOrParser)\n }\n }\n }\n\n if (isFunction(pluginOrParser.install)) {\n const installer = pluginOrParser.install\n\n await (installer as any)(context, ...options)\n }\n\n return fabric\n },\n } as Fabric<T>\n\n return fabric\n}\n"],"mappings":";;;;;;;;AAaA,SAAgB,WAAc,KAAiB,cAAqB;AAClE,QAAOA,6BAAO,KAAK,aAAa;;;;;;;;;;;;;;;;;;;;;ACWlC,SAAgB,cAA8C;AAC5D,QAAO,WAAWC,sCAAgB;;;;;;;;;ACZpC,MAAa,aAAaC,oCAA+B;CACvD,YAAY;CACZ,MAAM,EAAE;CACT,CAAC;;;;;;;;;;;;;;;;;;;ACoBF,MAAa,MAAMC,sCAAgB,QAAQ,EAAE,UAAU,GAAG,YAAsB;CAC9E,MAAM,EAAE,OAAO,EAAE,KAAK;CAEtB,MAAM,EAAE,SAAS,WAAWC,kCAAY;CAExC,MAAM,WAAW,aAAa;AAE9B,KAAI,SAGF,+BAAQC,uCAFU,SAAS,SAAS;EAAE,MAAM;EAAO;EAAO,CAAC,CAExB;AAGrC,+BAAQ,YAAY;EAAE;EAAM;EAAM,CAAC;AAEnC,QAAO;EACP;AAEF,IAAI,cAAc;;;;;;;;;;;;;;;;;;ACtClB,MAAa,KAAKC,sCAAgB,YAAY;AAC5C,QAAOC,sCAAgB,KAAK;EAC5B;AAEF,GAAG,cAAc;;;;;;;AClBjB,SAAgB,YAAY,EAAE,YAA4C;AACxE,KAAI,CAAC,YAAY,SAAS,WAAW,EAAG,QAAO;CAE/C,MAAM,QAAQ,SACX,SAAS,MAAM,OAAO,KAAK,GAAG,CAAC,MAAM,QAAQ,CAAC,CAC9C,KAAK,MAAM,EAAE,QAAQ,SAAS,OAAO,CAAC,QAAQ,OAAO,GAAG,CAAC,CACzD,QAAQ,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE;AAErC,KAAI,MAAM,WAAW,EAAG,QAAO;AAE/B,QAAO;EAAC;EAAO,GAAG,MAAM,KAAK,MAAM,MAAM,IAAI;EAAE;EAAM,CAAC,KAAK,KAAK;;;;;;;;;;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M as Source, O as Import, T as Export, _ as inject, b as FileManager, c as FabricOptions, d as renderIndent, f as renderIntrinsic, g as createContext, h as Context, j as ResolvedFile, n as FabricComponent, p as RenderContext, r as FabricConfig, s as FabricNode, t as Fabric, v as provide, w as BaseName, x as FileProcessor, y as unprovide } from "./Fabric-CrRJykMN.js";
3
- import { n as useNodeTree, r as TreeNode, t as ComponentNode } from "./useNodeTree-CamNuFQP.js";
4
- import { t as RootContext } from "./RootContext-CvaGJ-4g.js";
1
+ import { A as Path, D as File$1, M as Source, O as Import, T as Export, _ as inject, b as FileManager, c as FabricOptions, d as renderIndent, f as renderIntrinsic, g as createContext, h as Context, j as ResolvedFile, n as FabricComponent, p as RenderContext, r as FabricConfig, s as FabricNode, t as Fabric, v as provide, w as BaseName, x as FileProcessor, y as unprovide } from "./Fabric-efyCO1t7.js";
2
+ import { n as useNodeTree, r as TreeNode, t as ComponentNode } from "./useNodeTree-DuQ5Df0t.js";
3
+ import { t as RootContext } from "./RootContext-CA-zkTEp.js";
5
4
  import { JSDoc } from "./types.js";
6
5
 
7
6
  //#region src/createComponent.d.ts
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
- import { n as __name } from "./chunk-BVHe6Par.js";
2
- import { S as unprovide, _ as createFile, a as renderIndent, b as inject, c as RootContext, d as FileProcessor, i as createIntrinsic, l as TreeNode, n as Root, o as renderIntrinsic, p as AsyncEventEmitter, r as createComponent, s as RenderContext, t as onProcessExit, u as FileManager, v as NodeTreeContext, x as provide, y as createContext } from "./onProcessExit-7fgW-UTF.js";
3
- import { t as getRelativePath } from "./getRelativePath-C4Au07ON.js";
1
+ import { _ as provide, a as renderIndent, c as RootContext, d as FileProcessor, f as AsyncEventEmitter, g as inject, h as createContext, i as createIntrinsic, l as TreeNode, m as NodeTreeContext, n as Root, o as renderIntrinsic, p as createFile, r as createComponent, s as RenderContext, t as onProcessExit, u as FileManager, v as unprovide } from "./onProcessExit-CF200hsz.js";
2
+ import { t as getRelativePath } from "./getRelativePath-BcieQL5M.js";
4
3
  import { createExport, createImport, print } from "./parsers/typescript.js";
5
4
  import { isFunction } from "remeda";
6
5
 
@@ -103,7 +102,7 @@ Br.displayName = "Br";
103
102
  */
104
103
  function createJSDoc({ comments }) {
105
104
  if (!comments || comments.length === 0) return "";
106
- const lines = comments.flatMap((c) => String(c !== null && c !== void 0 ? c : "").split(/\r?\n/)).map((l) => l.replace(/\*\//g, "*\\/").replace(/\r/g, "")).filter((l) => l.trim().length > 0);
105
+ const lines = comments.flatMap((c) => String(c ?? "").split(/\r?\n/)).map((l) => l.replace(/\*\//g, "*\\/").replace(/\r/g, "")).filter((l) => l.trim().length > 0);
107
106
  if (lines.length === 0) return "";
108
107
  return [
109
108
  "/**",
@@ -133,7 +132,7 @@ const Const = createComponent("Const", ({ children, ...props }) => {
133
132
  }));
134
133
  const value = renderIntrinsic(children);
135
134
  let result = "";
136
- if (JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) {
135
+ if (JSDoc?.comments) {
137
136
  result += createJSDoc({ comments: JSDoc.comments });
138
137
  result += "\n";
139
138
  }
@@ -412,7 +411,7 @@ const Function = createComponent("Function", ({ children, ...props }) => {
412
411
  props
413
412
  }));
414
413
  const parts = [];
415
- if (JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) {
414
+ if (JSDoc?.comments) {
416
415
  parts.push(createJSDoc({ comments: JSDoc.comments }));
417
416
  parts.push("\n");
418
417
  }
@@ -456,7 +455,7 @@ const ArrowFunction = createComponent("ArrowFunction", ({ children, ...props })
456
455
  props
457
456
  }));
458
457
  const parts = [];
459
- if (JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) {
458
+ if (JSDoc?.comments) {
460
459
  parts.push(createJSDoc({ comments: JSDoc.comments }));
461
460
  parts.push("\n");
462
461
  }
@@ -513,7 +512,7 @@ const Type = createComponent("Type", ({ children, ...props }) => {
513
512
  if (name.charAt(0).toUpperCase() !== name.charAt(0)) throw new Error("Name should start with a capital letter (see TypeScript types)");
514
513
  const value = renderIntrinsic(children);
515
514
  let result = "";
516
- if (JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) {
515
+ if (JSDoc?.comments) {
517
516
  result += createJSDoc({ comments: JSDoc.comments });
518
517
  result += "\n";
519
518
  }