@kubb/fabric-core 0.13.2 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/{Fabric-BOjvMvNC.d.ts → Fabric-CFkgoZwY.d.ts} +4 -1
  2. package/dist/chunk-MlS0t1Af.cjs +53 -0
  3. package/dist/chunk-O_arW02_.js +17 -0
  4. package/dist/defaultParser-D0_-Uy2Z.cjs +19 -0
  5. package/dist/{defaultParser-BAgmtMo_.cjs.map → defaultParser-D0_-Uy2Z.cjs.map} +1 -1
  6. package/dist/{defaultParser-C1atU7yU.js → defaultParser-iCpMSYCp.js} +4 -4
  7. package/dist/{defaultParser-C1atU7yU.js.map → defaultParser-iCpMSYCp.js.map} +1 -1
  8. package/dist/{getRelativePath-BcieQL5M.js → getRelativePath-NAm_Y-vp.js} +3 -5
  9. package/dist/{getRelativePath-BcieQL5M.js.map → getRelativePath-NAm_Y-vp.js.map} +1 -1
  10. package/dist/{getRelativePath-DVG8dIzW.cjs → getRelativePath-WX4HB169.cjs} +18 -21
  11. package/dist/{getRelativePath-DVG8dIzW.cjs.map → getRelativePath-WX4HB169.cjs.map} +1 -1
  12. package/dist/index.cjs +75 -93
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.ts +54 -54
  15. package/dist/index.js +71 -88
  16. package/dist/index.js.map +1 -1
  17. package/dist/{onProcessExit-DENCUkMz.cjs → onProcessExit-C2AuepQI.cjs} +213 -227
  18. package/dist/onProcessExit-C2AuepQI.cjs.map +1 -0
  19. package/dist/{onProcessExit-B0rJqX4s.js → onProcessExit-Cput7j2c.js} +124 -137
  20. package/dist/onProcessExit-Cput7j2c.js.map +1 -0
  21. package/dist/parsers/typescript.cjs +4 -5
  22. package/dist/parsers/typescript.cjs.map +1 -1
  23. package/dist/parsers/typescript.d.ts +2 -1
  24. package/dist/parsers/typescript.js +3 -3
  25. package/dist/parsers/typescript.js.map +1 -1
  26. package/dist/parsers.cjs +6 -6
  27. package/dist/parsers.cjs.map +1 -1
  28. package/dist/parsers.d.ts +2 -1
  29. package/dist/parsers.js +4 -4
  30. package/dist/plugins.cjs +7 -13
  31. package/dist/plugins.cjs.map +1 -1
  32. package/dist/plugins.d.ts +5 -4
  33. package/dist/plugins.js +6 -11
  34. package/dist/plugins.js.map +1 -1
  35. package/dist/{RootContext-BQHfIhhC.d.ts → types-BwR3_cUx.d.ts} +10 -4
  36. package/dist/types.cjs +13 -15
  37. package/dist/types.d.ts +4 -11
  38. package/dist/types.js +2 -3
  39. package/dist/{useNodeTree-Brj-fAVZ.d.ts → useNodeTree-Wc1WxA05.d.ts} +3 -2
  40. package/package.json +4 -3
  41. package/src/components/{App.ts → Fabric.ts} +8 -8
  42. package/src/composables/{useApp.ts → useFabric.ts} +4 -4
  43. package/src/contexts/{AppContext.ts → FabricContext.ts} +2 -2
  44. package/src/index.ts +4 -6
  45. package/src/plugins/fsxPlugin/fsxPlugin.ts +4 -4
  46. package/dist/Fabric-w9Y9duM6.d.ts +0 -516
  47. package/dist/RootContext-Cbs-UQXM.d.ts +0 -26
  48. package/dist/chunk-BYypO7fO.js +0 -18
  49. package/dist/chunk-uaV2rQ02.cjs +0 -53
  50. package/dist/defaultParser-BAgmtMo_.cjs +0 -20
  51. package/dist/onProcessExit-B0rJqX4s.js.map +0 -1
  52. package/dist/onProcessExit-DENCUkMz.cjs.map +0 -1
  53. package/dist/useNodeTree-6ZhDpI13.d.ts +0 -58
  54. package/src/components/__snapshots__/arrow_function_with_generics.ts +0 -3
  55. package/src/components/__snapshots__/async_arrow_function.ts +0 -3
  56. package/src/components/__snapshots__/async_function.ts +0 -3
  57. package/src/components/__snapshots__/async_function_with_Promise_return_type.ts +0 -3
  58. package/src/components/__snapshots__/basic_arrow_function.ts +0 -3
  59. package/src/components/__snapshots__/basic_const.ts +0 -1
  60. package/src/components/__snapshots__/basic_export.ts +0 -1
  61. package/src/components/__snapshots__/basic_function.ts +0 -3
  62. package/src/components/__snapshots__/basic_import.ts +0 -1
  63. package/src/components/__snapshots__/basic_type.ts +0 -1
  64. package/src/components/__snapshots__/const_with_JSDoc.ts +0 -4
  65. package/src/components/__snapshots__/const_with_as_const.ts +0 -1
  66. package/src/components/__snapshots__/const_with_type.ts +0 -1
  67. package/src/components/__snapshots__/default_exported_arrow_function.ts +0 -3
  68. package/src/components/__snapshots__/default_exported_function.ts +0 -3
  69. package/src/components/__snapshots__/exported_arrow_function.ts +0 -3
  70. package/src/components/__snapshots__/exported_const.ts +0 -1
  71. package/src/components/__snapshots__/exported_function.ts +0 -3
  72. package/src/components/__snapshots__/exported_type.ts +0 -1
  73. package/src/components/__snapshots__/function_with_JSDoc.ts +0 -6
  74. package/src/components/__snapshots__/function_with_generics.ts +0 -3
  75. package/src/components/__snapshots__/function_with_parameters.ts +0 -3
  76. package/src/components/__snapshots__/function_with_return_type.ts +0 -3
  77. package/src/components/__snapshots__/matches_with_root_import.ts +0 -1
  78. package/src/components/__snapshots__/named_export.ts +0 -1
  79. package/src/components/__snapshots__/named_export_(object_advanced).ts +0 -1
  80. package/src/components/__snapshots__/named_import.ts +0 -1
  81. package/src/components/__snapshots__/named_import_(object).ts +0 -1
  82. package/src/components/__snapshots__/named_import_(object_advanced).ts +0 -1
  83. package/src/components/__snapshots__/named_typed_export.ts +0 -1
  84. package/src/components/__snapshots__/named_typed_import.ts +0 -1
  85. package/src/components/__snapshots__/single_line_arrow_function.ts +0 -1
  86. package/src/components/__snapshots__/type_with_JSDoc.ts +0 -4
  87. package/src/components/__snapshots__/typed_export.ts +0 -1
  88. package/src/components/__snapshots__/typed_import.ts +0 -1
@@ -1,3 +1,6 @@
1
+ import { n as __name, t as __exportAll } from "./chunk-O_arW02_.js";
2
+
3
+ //#region src/KubbFile.d.ts
1
4
  declare namespace KubbFile_d_exports {
2
5
  export { BaseName, Export, Extname, File, Import, Mode, Path, ResolvedFile, Source };
3
6
  }
@@ -513,4 +516,4 @@ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
513
516
  }
514
517
  //#endregion
515
518
  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-BOjvMvNC.d.ts.map
519
+ //# sourceMappingURL=Fabric-CFkgoZwY.d.ts.map
@@ -0,0 +1,53 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", {
5
+ value,
6
+ configurable: true
7
+ });
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __exportAll = (all, no_symbols) => {
13
+ let target = {};
14
+ for (var name in all) __defProp(target, name, {
15
+ get: all[name],
16
+ enumerable: true
17
+ });
18
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
19
+ return target;
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
23
+ key = keys[i];
24
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
25
+ get: ((k) => from[k]).bind(null, key),
26
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
27
+ });
28
+ }
29
+ return to;
30
+ };
31
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
32
+ value: mod,
33
+ enumerable: true
34
+ }) : target, mod));
35
+ //#endregion
36
+ Object.defineProperty(exports, "__exportAll", {
37
+ enumerable: true,
38
+ get: function() {
39
+ return __exportAll;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "__name", {
43
+ enumerable: true,
44
+ get: function() {
45
+ return __name;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "__toESM", {
49
+ enumerable: true,
50
+ get: function() {
51
+ return __toESM;
52
+ }
53
+ });
@@ -0,0 +1,17 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __name = (target, value) => __defProp(target, "name", {
4
+ value,
5
+ configurable: true
6
+ });
7
+ var __exportAll = (all, no_symbols) => {
8
+ let target = {};
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
14
+ return target;
15
+ };
16
+ //#endregion
17
+ export { __name as n, __exportAll as t };
@@ -0,0 +1,19 @@
1
+ require("./chunk-MlS0t1Af.cjs");
2
+ //#region src/parsers/defaultParser.ts
3
+ const defaultParser = require("./getRelativePath-WX4HB169.cjs").defineParser({
4
+ name: "default",
5
+ extNames: [".json"],
6
+ install() {},
7
+ async parse(file) {
8
+ return file.sources.map((item) => item.value).join("\n\n");
9
+ }
10
+ });
11
+ //#endregion
12
+ Object.defineProperty(exports, "defaultParser", {
13
+ enumerable: true,
14
+ get: function() {
15
+ return defaultParser;
16
+ }
17
+ });
18
+
19
+ //# sourceMappingURL=defaultParser-D0_-Uy2Z.cjs.map
@@ -1 +1 @@
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
+ {"version":3,"file":"defaultParser-D0_-Uy2Z.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,0DAAgBA,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,5 +1,5 @@
1
- import { n as defineParser } from "./getRelativePath-BcieQL5M.js";
2
-
1
+ import "./chunk-O_arW02_.js";
2
+ import { n as defineParser } from "./getRelativePath-NAm_Y-vp.js";
3
3
  //#region src/parsers/defaultParser.ts
4
4
  const defaultParser = defineParser({
5
5
  name: "default",
@@ -9,7 +9,7 @@ const defaultParser = defineParser({
9
9
  return file.sources.map((item) => item.value).join("\n\n");
10
10
  }
11
11
  });
12
-
13
12
  //#endregion
14
13
  export { defaultParser as t };
15
- //# sourceMappingURL=defaultParser-C1atU7yU.js.map
14
+
15
+ //# sourceMappingURL=defaultParser-iCpMSYCp.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"defaultParser-iCpMSYCp.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,10 +1,9 @@
1
+ import "./chunk-O_arW02_.js";
1
2
  import { normalize, relative } from "node:path";
2
-
3
3
  //#region src/utils/trimExtName.ts
4
4
  function trimExtName(text) {
5
5
  return text.replace(/\.[^/.]+$/, "");
6
6
  }
7
-
8
7
  //#endregion
9
8
  //#region src/parsers/defineParser.ts
10
9
  /**
@@ -36,7 +35,6 @@ function defineParser(parser) {
36
35
  ...parser
37
36
  };
38
37
  }
39
-
40
38
  //#endregion
41
39
  //#region src/utils/getRelativePath.ts
42
40
  function slash(path, platform = "linux") {
@@ -51,7 +49,7 @@ function getRelativePath(rootDir, filePath, platform = "linux") {
51
49
  if (slashedPath.startsWith("../")) return slashedPath;
52
50
  return `./${slashedPath}`;
53
51
  }
54
-
55
52
  //#endregion
56
53
  export { defineParser as n, trimExtName as r, getRelativePath as t };
57
- //# sourceMappingURL=getRelativePath-BcieQL5M.js.map
54
+
55
+ //# sourceMappingURL=getRelativePath-NAm_Y-vp.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"getRelativePath-NAm_Y-vp.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,11 +1,9 @@
1
- const require_chunk = require('./chunk-uaV2rQ02.cjs');
1
+ require("./chunk-MlS0t1Af.cjs");
2
2
  let node_path = require("node:path");
3
-
4
3
  //#region src/utils/trimExtName.ts
5
4
  function trimExtName(text) {
6
5
  return text.replace(/\.[^/.]+$/, "");
7
6
  }
8
-
9
7
  //#endregion
10
8
  //#region src/parsers/defineParser.ts
11
9
  /**
@@ -37,7 +35,6 @@ function defineParser(parser) {
37
35
  ...parser
38
36
  };
39
37
  }
40
-
41
38
  //#endregion
42
39
  //#region src/utils/getRelativePath.ts
43
40
  function slash(path, platform = "linux") {
@@ -52,24 +49,24 @@ function getRelativePath(rootDir, filePath, platform = "linux") {
52
49
  if (slashedPath.startsWith("../")) return slashedPath;
53
50
  return `./${slashedPath}`;
54
51
  }
55
-
56
52
  //#endregion
57
- Object.defineProperty(exports, 'defineParser', {
58
- enumerable: true,
59
- get: function () {
60
- return defineParser;
61
- }
53
+ Object.defineProperty(exports, "defineParser", {
54
+ enumerable: true,
55
+ get: function() {
56
+ return defineParser;
57
+ }
62
58
  });
63
- Object.defineProperty(exports, 'getRelativePath', {
64
- enumerable: true,
65
- get: function () {
66
- return getRelativePath;
67
- }
59
+ Object.defineProperty(exports, "getRelativePath", {
60
+ enumerable: true,
61
+ get: function() {
62
+ return getRelativePath;
63
+ }
68
64
  });
69
- Object.defineProperty(exports, 'trimExtName', {
70
- enumerable: true,
71
- get: function () {
72
- return trimExtName;
73
- }
65
+ Object.defineProperty(exports, "trimExtName", {
66
+ enumerable: true,
67
+ get: function() {
68
+ return trimExtName;
69
+ }
74
70
  });
75
- //# sourceMappingURL=getRelativePath-DVG8dIzW.cjs.map
71
+
72
+ //# sourceMappingURL=getRelativePath-WX4HB169.cjs.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"getRelativePath-WX4HB169.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,kBAAA,GAAA,UAAA,WAA2B,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,OAAA,GAAA,UAAA,UAJU,SAAS,SAAS,EAIR,SAAS;AAEjD,KAAI,YAAY,WAAW,MAAM,CAC/B,QAAO;AAGT,QAAO,KAAK"}
package/dist/index.cjs CHANGED
@@ -1,15 +1,33 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_chunk = require('./chunk-uaV2rQ02.cjs');
3
- const require_onProcessExit = require('./onProcessExit-DENCUkMz.cjs');
4
- const require_getRelativePath = require('./getRelativePath-DVG8dIzW.cjs');
5
- const require_parsers_typescript = require('./parsers/typescript.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("./chunk-MlS0t1Af.cjs");
3
+ const require_onProcessExit = require("./onProcessExit-C2AuepQI.cjs");
4
+ const require_getRelativePath = require("./getRelativePath-WX4HB169.cjs");
5
+ const require_parsers_typescript = require("./parsers/typescript.cjs");
6
6
  let remeda = require("remeda");
7
-
7
+ //#region src/components/Br.ts
8
+ /**
9
+ * Generates a line break in the output.
10
+ *
11
+ * Use this component to add newlines in generated code.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * <>
16
+ * const x = 1
17
+ * <Br />
18
+ * const y = 2
19
+ * </>
20
+ * ```
21
+ */
22
+ const Br = require_onProcessExit.createComponent("br", () => {
23
+ return require_onProcessExit.createIntrinsic("br");
24
+ });
25
+ Br.displayName = "Br";
26
+ //#endregion
8
27
  //#region src/composables/useContext.ts
9
28
  function useContext(key, defaultValue) {
10
29
  return require_onProcessExit.inject(key, defaultValue);
11
30
  }
12
-
13
31
  //#endregion
14
32
  //#region src/composables/useNodeTree.ts
15
33
  /**
@@ -31,72 +49,6 @@ function useContext(key, defaultValue) {
31
49
  function useNodeTree() {
32
50
  return useContext(require_onProcessExit.NodeTreeContext);
33
51
  }
34
-
35
- //#endregion
36
- //#region src/contexts/AppContext.ts
37
- /**
38
- * Provides app-level metadata and lifecycle hooks (like `exit`) to
39
- * components and composables within a Fabric runtime.
40
- */
41
- const AppContext = require_onProcessExit.createContext({
42
- exit: () => {},
43
- meta: {}
44
- });
45
-
46
- //#endregion
47
- //#region src/components/App.ts
48
- /**
49
- * Container component providing App context with metadata and lifecycle.
50
- *
51
- * Use this component to wrap your application and provide shared metadata
52
- * that can be accessed by child components using the useApp composable.
53
- *
54
- * @example
55
- * ```tsx
56
- * <App meta={{ version: '1.0.0', author: 'John Doe' }}>
57
- * <File baseName="user.ts" path="./user.ts">
58
- * <File.Source>export type User = {}</File.Source>
59
- * </File>
60
- * </App>
61
- * ```
62
- */
63
- const App = require_onProcessExit.createComponent("App", ({ children, ...props }) => {
64
- const { meta = {} } = props;
65
- const { exit } = useContext(require_onProcessExit.RootContext);
66
- const nodeTree = useNodeTree();
67
- if (nodeTree) require_onProcessExit.provide(require_onProcessExit.NodeTreeContext, nodeTree.addChild({
68
- type: "App",
69
- props
70
- }));
71
- require_onProcessExit.provide(AppContext, {
72
- exit,
73
- meta
74
- });
75
- return children;
76
- });
77
- App.displayName = "App";
78
-
79
- //#endregion
80
- //#region src/components/Br.ts
81
- /**
82
- * Generates a line break in the output.
83
- *
84
- * Use this component to add newlines in generated code.
85
- *
86
- * @example
87
- * ```tsx
88
- * <>
89
- * const x = 1
90
- * <Br />
91
- * const y = 2
92
- * </>
93
- * ```
94
- */
95
- const Br = require_onProcessExit.createComponent("br", () => {
96
- return require_onProcessExit.createIntrinsic("br");
97
- });
98
- Br.displayName = "Br";
99
-
100
52
  //#endregion
101
53
  //#region src/utils/createJSDoc.ts
102
54
  /**
@@ -112,7 +64,6 @@ function createJSDoc({ comments }) {
112
64
  " */"
113
65
  ].join("\n");
114
66
  }
115
-
116
67
  //#endregion
117
68
  //#region src/components/Const.ts
118
69
  /**
@@ -146,7 +97,6 @@ const Const = require_onProcessExit.createComponent("Const", ({ children, ...pro
146
97
  return result;
147
98
  });
148
99
  Const.displayName = "Const";
149
-
150
100
  //#endregion
151
101
  //#region src/components/Dedent.ts
152
102
  /**
@@ -170,7 +120,48 @@ const Dedent = require_onProcessExit.createComponent("dedent", () => {
170
120
  return require_onProcessExit.createIntrinsic("dedent");
171
121
  });
172
122
  Dedent.displayName = "Dedent";
173
-
123
+ //#endregion
124
+ //#region src/contexts/FabricContext.ts
125
+ /**
126
+ * Provides app-level metadata and lifecycle hooks (like `exit`) to
127
+ * components and composables within a Fabric runtime.
128
+ */
129
+ const FabricContext = require_onProcessExit.createContext({
130
+ exit: () => {},
131
+ meta: {}
132
+ });
133
+ //#endregion
134
+ //#region src/components/Fabric.ts
135
+ /**
136
+ * Container component providing App context with metadata and lifecycle.
137
+ *
138
+ * Use this component to wrap your application and provide shared metadata
139
+ * that can be accessed by child components using the useApp composable.
140
+ *
141
+ * @example
142
+ * ```tsx
143
+ * <Fabric meta={{ version: '1.0.0', author: 'John Doe' }}>
144
+ * <File baseName="user.ts" path="./user.ts">
145
+ * <File.Source>export type User = {}</File.Source>
146
+ * </File>
147
+ * </Fabric>
148
+ * ```
149
+ */
150
+ const Fabric = require_onProcessExit.createComponent("Fabric", ({ children, ...props }) => {
151
+ const { meta = {} } = props;
152
+ const { exit } = useContext(require_onProcessExit.RootContext);
153
+ const nodeTree = useNodeTree();
154
+ if (nodeTree) require_onProcessExit.provide(require_onProcessExit.NodeTreeContext, nodeTree.addChild({
155
+ type: "Fabric",
156
+ props
157
+ }));
158
+ require_onProcessExit.provide(FabricContext, {
159
+ exit,
160
+ meta
161
+ });
162
+ return children;
163
+ });
164
+ Fabric.displayName = "Fabric";
174
165
  //#endregion
175
166
  //#region src/contexts/FileContext.ts
176
167
  /**
@@ -178,7 +169,6 @@ Dedent.displayName = "Dedent";
178
169
  * components and composables within a Fabric runtime.
179
170
  */
180
171
  const FileContext = require_onProcessExit.createContext(null);
181
-
182
172
  //#endregion
183
173
  //#region src/composables/useFile.ts
184
174
  /**
@@ -201,7 +191,6 @@ const FileContext = require_onProcessExit.createContext(null);
201
191
  function useFile() {
202
192
  return useContext(FileContext);
203
193
  }
204
-
205
194
  //#endregion
206
195
  //#region src/composables/useFileManager.ts
207
196
  /**
@@ -226,7 +215,6 @@ function useFileManager() {
226
215
  const { fileManager } = useContext(require_onProcessExit.RootContext);
227
216
  return fileManager;
228
217
  }
229
-
230
218
  //#endregion
231
219
  //#region src/components/File.ts
232
220
  /**
@@ -362,7 +350,6 @@ const FileImport = require_onProcessExit.createComponent("FileImport", (props) =
362
350
  File.Source = FileSource;
363
351
  File.Import = FileImport;
364
352
  File.Export = FileExport;
365
-
366
353
  //#endregion
367
354
  //#region src/components/Indent.ts
368
355
  /**
@@ -386,7 +373,6 @@ const Indent = require_onProcessExit.createComponent("indent", () => {
386
373
  return require_onProcessExit.createIntrinsic("indent");
387
374
  });
388
375
  Indent.displayName = "Indent";
389
-
390
376
  //#endregion
391
377
  //#region src/components/Function.ts
392
378
  /**
@@ -491,7 +477,6 @@ const ArrowFunction = require_onProcessExit.createComponent("ArrowFunction", ({
491
477
  });
492
478
  ArrowFunction.displayName = "ArrowFunction";
493
479
  Function.Arrow = ArrowFunction;
494
-
495
480
  //#endregion
496
481
  //#region src/components/Type.ts
497
482
  /**
@@ -523,9 +508,8 @@ const Type = require_onProcessExit.createComponent("Type", ({ children, ...props
523
508
  return result;
524
509
  });
525
510
  Type.displayName = "Type";
526
-
527
511
  //#endregion
528
- //#region src/composables/useApp.ts
512
+ //#region src/composables/useFabric.ts
529
513
  /**
530
514
  * Accesses the App context with metadata and exit function.
531
515
  *
@@ -536,14 +520,13 @@ Type.displayName = "Type";
536
520
  *
537
521
  * @example
538
522
  * ```ts
539
- * const { meta, exit } = useApp<{ version: string }>()
523
+ * const { meta, exit } = useFabric<{ version: string }>()
540
524
  * console.log(meta.version)
541
525
  * ```
542
526
  */
543
- function useApp() {
544
- return useContext(AppContext);
527
+ function useFabric() {
528
+ return useContext(FabricContext);
545
529
  }
546
-
547
530
  //#endregion
548
531
  //#region src/composables/useLifecycle.ts
549
532
  /**
@@ -568,7 +551,6 @@ function useLifecycle() {
568
551
  const { exit } = useContext(require_onProcessExit.RootContext);
569
552
  return { exit };
570
553
  }
571
-
572
554
  //#endregion
573
555
  //#region src/createFabric.ts
574
556
  /**
@@ -666,13 +648,12 @@ function createFabric(config = { mode: "sequential" }) {
666
648
  };
667
649
  return fabric;
668
650
  }
669
-
670
651
  //#endregion
671
- exports.App = App;
672
- exports.AppContext = AppContext;
673
652
  exports.Br = Br;
674
653
  exports.Const = Const;
675
654
  exports.Dedent = Dedent;
655
+ exports.Fabric = Fabric;
656
+ exports.FabricContext = FabricContext;
676
657
  exports.File = File;
677
658
  exports.FileContext = FileContext;
678
659
  exports.FileManager = require_onProcessExit.FileManager;
@@ -697,10 +678,11 @@ exports.provide = require_onProcessExit.provide;
697
678
  exports.renderIndent = require_onProcessExit.renderIndent;
698
679
  exports.renderIntrinsic = require_onProcessExit.renderIntrinsic;
699
680
  exports.unprovide = require_onProcessExit.unprovide;
700
- exports.useApp = useApp;
701
681
  exports.useContext = useContext;
682
+ exports.useFabric = useFabric;
702
683
  exports.useFile = useFile;
703
684
  exports.useFileManager = useFileManager;
704
685
  exports.useLifecycle = useLifecycle;
705
686
  exports.useNodeTree = useNodeTree;
687
+
706
688
  //# sourceMappingURL=index.cjs.map