@kubb/agent 5.0.0-alpha.35 → 5.0.0-alpha.36

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 (180) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/server/chunks/nitro/nitro.mjs +1293 -20554
  3. package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
  4. package/.output/server/chunks/routes/api/health.get.mjs +16 -14
  5. package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
  6. package/.output/server/index.mjs +16 -14
  7. package/.output/server/index.mjs.map +1 -1
  8. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/constants.js +18 -0
  9. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/permessage-deflate.js +514 -0
  10. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/sender.js +602 -0
  11. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/stream.js +159 -0
  12. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket-server.js +540 -0
  13. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket.js +1388 -0
  14. package/.output/server/node_modules/.nitro/ws@8.18.0/package.json +69 -0
  15. package/.output/server/node_modules/.nitro/ws@8.18.0/wrapper.mjs +8 -0
  16. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/buffer-util.js +131 -0
  17. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/event-target.js +292 -0
  18. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/extension.js +203 -0
  19. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/limiter.js +55 -0
  20. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/receiver.js +706 -0
  21. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/subprotocol.js +62 -0
  22. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/validation.js +152 -0
  23. package/.output/server/node_modules/@clack/core/dist/index.mjs +11 -0
  24. package/.output/server/node_modules/@clack/core/package.json +60 -0
  25. package/.output/server/node_modules/@clack/prompts/dist/index.mjs +137 -0
  26. package/.output/server/node_modules/@clack/prompts/package.json +65 -0
  27. package/.output/server/node_modules/@kubb/ast/dist/chunk--u3MIqq1.js +8 -0
  28. package/.output/server/node_modules/@kubb/ast/dist/index.js +423 -0
  29. package/.output/server/node_modules/@kubb/ast/package.json +70 -0
  30. package/.output/server/node_modules/@kubb/core/dist/chunk--u3MIqq1.js +8 -0
  31. package/.output/server/node_modules/@kubb/core/dist/hooks.js +23 -0
  32. package/.output/server/node_modules/@kubb/core/dist/index.js +2311 -0
  33. package/.output/server/node_modules/@kubb/core/package.json +109 -0
  34. package/.output/server/node_modules/@kubb/fabric-core/dist/chunk-O_arW02_.js +17 -0
  35. package/.output/server/node_modules/@kubb/fabric-core/dist/defaultParser-iCpMSYCp.js +15 -0
  36. package/.output/server/node_modules/@kubb/fabric-core/dist/getRelativePath-NAm_Y-vp.js +55 -0
  37. package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +653 -0
  38. package/.output/server/node_modules/@kubb/fabric-core/dist/onProcessExit-Cput7j2c.js +742 -0
  39. package/.output/server/node_modules/@kubb/fabric-core/dist/parsers/typescript.js +101 -0
  40. package/.output/server/node_modules/@kubb/fabric-core/dist/parsers.js +17 -0
  41. package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +375 -0
  42. package/.output/server/node_modules/@kubb/fabric-core/package.json +111 -0
  43. package/.output/server/node_modules/@kubb/oas/dist/chunk--u3MIqq1.js +8 -0
  44. package/.output/server/node_modules/@kubb/oas/dist/index.js +918 -0
  45. package/.output/server/node_modules/@kubb/oas/package.json +94 -0
  46. package/.output/server/node_modules/@kubb/plugin-client/dist/StaticClassClient-bCe7RG_w.js +636 -0
  47. package/.output/server/node_modules/@kubb/plugin-client/dist/chunk--u3MIqq1.js +8 -0
  48. package/.output/server/node_modules/@kubb/plugin-client/dist/components.js +2 -0
  49. package/.output/server/node_modules/@kubb/plugin-client/dist/generators-BffddRNu.js +723 -0
  50. package/.output/server/node_modules/@kubb/plugin-client/dist/index.js +124 -0
  51. package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/axios.source.js +6 -0
  52. package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/fetch.source.js +6 -0
  53. package/.output/server/node_modules/@kubb/plugin-client/dist/templates/config.source.js +6 -0
  54. package/.output/server/node_modules/@kubb/plugin-client/package.json +153 -0
  55. package/.output/server/node_modules/@kubb/plugin-cypress/dist/chunk--u3MIqq1.js +8 -0
  56. package/.output/server/node_modules/@kubb/plugin-cypress/dist/components-BK_6GU4v.js +257 -0
  57. package/.output/server/node_modules/@kubb/plugin-cypress/dist/generators-D5YFtyyC.js +71 -0
  58. package/.output/server/node_modules/@kubb/plugin-cypress/dist/index.js +79 -0
  59. package/.output/server/node_modules/@kubb/plugin-cypress/package.json +108 -0
  60. package/.output/server/node_modules/@kubb/plugin-faker/dist/chunk--u3MIqq1.js +8 -0
  61. package/.output/server/node_modules/@kubb/plugin-faker/dist/components-BkBIov4R.js +419 -0
  62. package/.output/server/node_modules/@kubb/plugin-faker/dist/fakerGenerator-BztogaeO.js +200 -0
  63. package/.output/server/node_modules/@kubb/plugin-faker/dist/index.js +141 -0
  64. package/.output/server/node_modules/@kubb/plugin-faker/package.json +103 -0
  65. package/.output/server/node_modules/@kubb/plugin-mcp/dist/Server-H3SwqhwF.js +178 -0
  66. package/.output/server/node_modules/@kubb/plugin-mcp/dist/chunk--u3MIqq1.js +8 -0
  67. package/.output/server/node_modules/@kubb/plugin-mcp/dist/generators-BqkMrcs9.js +274 -0
  68. package/.output/server/node_modules/@kubb/plugin-mcp/dist/index.js +122 -0
  69. package/.output/server/node_modules/@kubb/plugin-mcp/package.json +107 -0
  70. package/.output/server/node_modules/@kubb/plugin-msw/dist/chunk--u3MIqq1.js +8 -0
  71. package/.output/server/node_modules/@kubb/plugin-msw/dist/components-DgtTZkWX.js +277 -0
  72. package/.output/server/node_modules/@kubb/plugin-msw/dist/generators-C34kqa1L.js +161 -0
  73. package/.output/server/node_modules/@kubb/plugin-msw/dist/index.js +84 -0
  74. package/.output/server/node_modules/@kubb/plugin-msw/package.json +109 -0
  75. package/.output/server/node_modules/@kubb/plugin-oas/dist/SchemaMapper-CqMkO2T1.js +58 -0
  76. package/.output/server/node_modules/@kubb/plugin-oas/dist/chunk--u3MIqq1.js +8 -0
  77. package/.output/server/node_modules/@kubb/plugin-oas/dist/generators-D7C3CXsN.js +79 -0
  78. package/.output/server/node_modules/@kubb/plugin-oas/dist/generators.js +2 -0
  79. package/.output/server/node_modules/@kubb/plugin-oas/dist/getFooter-Pw3tLCiV.js +112 -0
  80. package/.output/server/node_modules/@kubb/plugin-oas/dist/hooks.js +200 -0
  81. package/.output/server/node_modules/@kubb/plugin-oas/dist/index.js +408 -0
  82. package/.output/server/node_modules/@kubb/plugin-oas/dist/requestBody-pRavthCw.js +1336 -0
  83. package/.output/server/node_modules/@kubb/plugin-oas/dist/utils.js +268 -0
  84. package/.output/server/node_modules/@kubb/plugin-oas/package.json +122 -0
  85. package/.output/server/node_modules/@kubb/plugin-react-query/dist/chunk--u3MIqq1.js +8 -0
  86. package/.output/server/node_modules/@kubb/plugin-react-query/dist/components-CpyHYGOw.js +1520 -0
  87. package/.output/server/node_modules/@kubb/plugin-react-query/dist/generators-CpiBv5eE.js +1427 -0
  88. package/.output/server/node_modules/@kubb/plugin-react-query/dist/index.js +166 -0
  89. package/.output/server/node_modules/@kubb/plugin-react-query/package.json +112 -0
  90. package/.output/server/node_modules/@kubb/plugin-redoc/dist/chunk--u3MIqq1.js +8 -0
  91. package/.output/server/node_modules/@kubb/plugin-redoc/dist/index.js +65 -0
  92. package/.output/server/node_modules/@kubb/plugin-redoc/package.json +85 -0
  93. package/.output/server/node_modules/@kubb/plugin-redoc/static/redoc.hbs +22 -0
  94. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/chunk--u3MIqq1.js +8 -0
  95. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/components-BhStIi1M.js +665 -0
  96. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/generators-CQClzsST.js +415 -0
  97. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/index.js +145 -0
  98. package/.output/server/node_modules/@kubb/plugin-solid-query/package.json +113 -0
  99. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/chunk--u3MIqq1.js +8 -0
  100. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/components-DntKBsnB.js +666 -0
  101. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/generators-BtTsGGrM.js +414 -0
  102. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/index.js +145 -0
  103. package/.output/server/node_modules/@kubb/plugin-svelte-query/package.json +113 -0
  104. package/.output/server/node_modules/@kubb/plugin-swr/dist/chunk--u3MIqq1.js +8 -0
  105. package/.output/server/node_modules/@kubb/plugin-swr/dist/components-DRDGvgXG.js +702 -0
  106. package/.output/server/node_modules/@kubb/plugin-swr/dist/generators-ClWZJ-YG.js +399 -0
  107. package/.output/server/node_modules/@kubb/plugin-swr/dist/index.js +144 -0
  108. package/.output/server/node_modules/@kubb/plugin-swr/package.json +115 -0
  109. package/.output/server/node_modules/@kubb/plugin-ts/dist/chunk--u3MIqq1.js +8 -0
  110. package/.output/server/node_modules/@kubb/plugin-ts/dist/components-C7fu-sK1.js +723 -0
  111. package/.output/server/node_modules/@kubb/plugin-ts/dist/index.js +2 -0
  112. package/.output/server/node_modules/@kubb/plugin-ts/dist/plugin-CYC-FGXe.js +479 -0
  113. package/.output/server/node_modules/@kubb/plugin-ts/package.json +105 -0
  114. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/chunk--u3MIqq1.js +8 -0
  115. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/components-_AMBl0g-.js +1029 -0
  116. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/generators-Zb1s5Wmb.js +661 -0
  117. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/index.js +157 -0
  118. package/.output/server/node_modules/@kubb/plugin-vue-query/package.json +114 -0
  119. package/.output/server/node_modules/@kubb/plugin-zod/dist/chunk--u3MIqq1.js +8 -0
  120. package/.output/server/node_modules/@kubb/plugin-zod/dist/components-eECfXVou.js +842 -0
  121. package/.output/server/node_modules/@kubb/plugin-zod/dist/generators-D1R6NNf2.js +290 -0
  122. package/.output/server/node_modules/@kubb/plugin-zod/dist/index.js +175 -0
  123. package/.output/server/node_modules/@kubb/plugin-zod/dist/templates/ToZod.source.js +6 -0
  124. package/.output/server/node_modules/@kubb/plugin-zod/package.json +112 -0
  125. package/.output/server/node_modules/@kubb/react-fabric/dist/chunk-BGCRLu6H.js +38 -0
  126. package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +525 -0
  127. package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime-Bl0DfUmV.js +1448 -0
  128. package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime.js +12 -0
  129. package/.output/server/node_modules/@kubb/react-fabric/dist/parsers.js +2 -0
  130. package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +4 -0
  131. package/.output/server/node_modules/@kubb/react-fabric/dist/reactPlugin-QQPrjNuQ.js +17813 -0
  132. package/.output/server/node_modules/@kubb/react-fabric/package.json +143 -0
  133. package/.output/server/node_modules/buffer-from/index.js +72 -0
  134. package/.output/server/node_modules/buffer-from/package.json +19 -0
  135. package/.output/server/node_modules/empathic/access.js +39 -0
  136. package/.output/server/node_modules/empathic/access.mjs +34 -0
  137. package/.output/server/node_modules/empathic/find.js +81 -0
  138. package/.output/server/node_modules/empathic/find.mjs +76 -0
  139. package/.output/server/node_modules/empathic/package.json +49 -0
  140. package/.output/server/node_modules/empathic/package.mjs +52 -0
  141. package/.output/server/node_modules/empathic/resolve.js +31 -0
  142. package/.output/server/node_modules/empathic/resolve.mjs +27 -0
  143. package/.output/server/node_modules/empathic/walk.js +22 -0
  144. package/.output/server/node_modules/empathic/walk.mjs +20 -0
  145. package/.output/server/node_modules/fast-string-truncated-width/dist/index.js +171 -0
  146. package/.output/server/node_modules/fast-string-truncated-width/dist/utils.js +15 -0
  147. package/.output/server/node_modules/fast-string-truncated-width/package.json +35 -0
  148. package/.output/server/node_modules/fast-string-width/dist/index.js +14 -0
  149. package/.output/server/node_modules/fast-string-width/package.json +34 -0
  150. package/.output/server/node_modules/fast-wrap-ansi/lib/main.js +216 -0
  151. package/.output/server/node_modules/fast-wrap-ansi/package.json +51 -0
  152. package/.output/server/node_modules/p-limit/index.js +127 -0
  153. package/.output/server/node_modules/p-limit/package.json +58 -0
  154. package/.output/server/node_modules/react-devtools-core/dist/backend.js +18302 -0
  155. package/.output/server/node_modules/react-devtools-core/package.json +38 -0
  156. package/.output/server/node_modules/sisteransi/package.json +34 -0
  157. package/.output/server/node_modules/sisteransi/src/index.js +58 -0
  158. package/.output/server/node_modules/source-map-support/package.json +31 -0
  159. package/.output/server/node_modules/source-map-support/source-map-support.js +625 -0
  160. package/.output/server/node_modules/typescript/lib/typescript.js +200276 -0
  161. package/.output/server/node_modules/typescript/package.json +120 -0
  162. package/.output/server/node_modules/yocto-queue/index.js +90 -0
  163. package/.output/server/node_modules/yocto-queue/package.json +48 -0
  164. package/.output/server/package.json +34 -2
  165. package/package.json +20 -20
  166. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/buffer-util.js +0 -0
  167. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/event-target.js +0 -0
  168. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/extension.js +0 -0
  169. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/limiter.js +0 -0
  170. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/receiver.js +0 -0
  171. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/subprotocol.js +0 -0
  172. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/validation.js +0 -0
  173. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/constants.js +0 -0
  174. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/permessage-deflate.js +0 -0
  175. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/sender.js +0 -0
  176. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/stream.js +0 -0
  177. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket-server.js +0 -0
  178. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket.js +0 -0
  179. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/package.json +0 -0
  180. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/wrapper.mjs +0 -0
@@ -0,0 +1,742 @@
1
+ import "./chunk-O_arW02_.js";
2
+ import { r as trimExtName } from "./getRelativePath-NAm_Y-vp.js";
3
+ import { t as defaultParser } from "./defaultParser-iCpMSYCp.js";
4
+ import { sortBy, uniqueBy } from "remeda";
5
+ import { createHash } from "node:crypto";
6
+ import path from "node:path";
7
+ import pLimit from "p-limit";
8
+ import { EventEmitter } from "node:events";
9
+ //#region src/context.ts
10
+ /**
11
+ * Context stack for tracking the current context values
12
+ *
13
+ * Note: This uses a global Map for simplicity in code generation scenarios.
14
+ * For concurrent runtime execution, consider using AsyncLocalStorage or
15
+ * instance-based context management.
16
+ */
17
+ const contextStack = /* @__PURE__ */ new Map();
18
+ const contextDefaults = /* @__PURE__ */ new Map();
19
+ /**
20
+ * Provides a value to descendant components (Vue 3 style)
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const ThemeKey = Symbol('theme')
25
+ * provide(ThemeKey, { color: 'blue' })
26
+ * ```
27
+ */
28
+ function provide(key, value) {
29
+ if (!contextStack.has(key)) contextStack.set(key, []);
30
+ contextStack.get(key).push(value);
31
+ }
32
+ /**
33
+ * Injects a value provided by an ancestor component (Vue 3 style)
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const theme = inject(ThemeKey, { color: 'default' })
38
+ * ```
39
+ */
40
+ function inject(key, defaultValue) {
41
+ const stack = contextStack.get(key);
42
+ if (!stack || stack.length === 0) {
43
+ if (defaultValue !== void 0) return defaultValue;
44
+ const storedDefault = contextDefaults.get(key);
45
+ if (storedDefault !== void 0) return storedDefault;
46
+ throw new Error(`No value provided for key: ${key.toString()}`);
47
+ }
48
+ return stack[stack.length - 1];
49
+ }
50
+ /**
51
+ * Unprovides a value (for cleanup)
52
+ * @internal
53
+ */
54
+ function unprovide(key) {
55
+ const stack = contextStack.get(key);
56
+ if (stack && stack.length > 0) stack.pop();
57
+ }
58
+ /**
59
+ * Creates a context key with a default value (React-style compatibility)
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const ThemeContext = createContext({ color: 'blue' })
64
+ * // ThemeContext is now typed as Context<{ color: string }>
65
+ * const theme = useContext(ThemeContext) // theme is { color: string }
66
+ * ```
67
+ */
68
+ function createContext(defaultValue) {
69
+ const key = Symbol("context");
70
+ contextDefaults.set(key, defaultValue);
71
+ return key;
72
+ }
73
+ //#endregion
74
+ //#region src/contexts/RenderContext.ts
75
+ /**
76
+ * Provides a context for tracking rendering state such as indentation and line length.
77
+ */
78
+ const RenderContext = createContext({
79
+ indentLevel: 0,
80
+ indentSize: 2,
81
+ currentLineLength: 0,
82
+ shouldBreak: false
83
+ });
84
+ //#endregion
85
+ //#region src/intrinsic.ts
86
+ function isFabricElement(value) {
87
+ return typeof value === "function" && "type" in value && "component" in value;
88
+ }
89
+ /**
90
+ * Type guard to check if a value is an intrinsic element
91
+ */
92
+ function isIntrinsic(value) {
93
+ return value && typeof value === "object" && value.__intrinsic === true;
94
+ }
95
+ /**
96
+ * Render a single intrinsic node
97
+ */
98
+ function renderIntrinsicNode(node, renderContext) {
99
+ switch (node.type) {
100
+ case "br":
101
+ renderContext.currentLineLength = 0;
102
+ return "\n";
103
+ case "indent":
104
+ renderContext.indentLevel++;
105
+ return "";
106
+ case "dedent":
107
+ renderContext.indentLevel = Math.max(0, renderContext.indentLevel - 1);
108
+ return "";
109
+ default: return "";
110
+ }
111
+ }
112
+ /**
113
+ * Helper: render a plain string while applying current indentation at the
114
+ * start of each logical line. This ensures `${indent}` intrinsics affect
115
+ * subsequent string content.
116
+ */
117
+ function renderIndent(content, renderContext) {
118
+ if (content.length === 0) return "";
119
+ const indentStr = " ".repeat(renderContext.indentLevel * renderContext.indentSize);
120
+ const lines = content.split("\n");
121
+ let out = "";
122
+ for (const [i, line] of lines.entries()) {
123
+ if (renderContext.currentLineLength === 0 && line.length > 0) {
124
+ out += indentStr + line;
125
+ renderContext.currentLineLength = indentStr.length + line.length;
126
+ } else {
127
+ out += line;
128
+ renderContext.currentLineLength += line.length;
129
+ }
130
+ if (i !== lines.length - 1) {
131
+ out += "\n";
132
+ renderContext.currentLineLength = 0;
133
+ }
134
+ }
135
+ return out;
136
+ }
137
+ function renderIntrinsic(children, context) {
138
+ const renderContext = context || inject(RenderContext);
139
+ provide(RenderContext, renderContext);
140
+ if (!children) return "";
141
+ if (isFabricElement(children)) try {
142
+ return renderIntrinsic(children());
143
+ } catch {
144
+ return "";
145
+ }
146
+ if (Array.isArray(children)) return children.map((child) => renderIntrinsic(child)).join("");
147
+ if (isIntrinsic(children)) return renderIntrinsicNode(children, renderContext);
148
+ if (typeof children === "function") return renderIntrinsic(children());
149
+ if (typeof children === "string") return renderIndent(children, renderContext);
150
+ if (typeof children === "number") return renderIndent(String(children), renderContext);
151
+ if (typeof children === "boolean") return renderIndent(children ? "true" : "false", renderContext);
152
+ try {
153
+ return renderIndent(children, renderContext);
154
+ } catch {
155
+ return "";
156
+ }
157
+ }
158
+ /**
159
+ * Create an intrinsic element
160
+ */
161
+ function createIntrinsic(type) {
162
+ return {
163
+ type,
164
+ __intrinsic: true
165
+ };
166
+ }
167
+ //#endregion
168
+ //#region src/createComponent.ts
169
+ function createComponent(type, Component) {
170
+ return (...args) => {
171
+ const fn = (() => renderIntrinsic(Component(args[0])));
172
+ fn.component = Component;
173
+ fn.props = args[0];
174
+ fn.type = type;
175
+ fn.children = (...children) => {
176
+ const propsWithChildren = {
177
+ ...args[0] ?? {},
178
+ children() {
179
+ return renderIntrinsic(children);
180
+ }
181
+ };
182
+ const fnChild = (() => renderIntrinsic(Component(propsWithChildren)));
183
+ fnChild.component = Component;
184
+ fnChild.props = args[0];
185
+ fnChild.type = type;
186
+ return fnChild;
187
+ };
188
+ return fn;
189
+ };
190
+ }
191
+ //#endregion
192
+ //#region src/contexts/NodeTreeContext.ts
193
+ /**
194
+ * Context for having the current NodeTree
195
+ */
196
+ const NodeTreeContext = createContext(null);
197
+ //#endregion
198
+ //#region src/createFile.ts
199
+ function combineSources(sources) {
200
+ return uniqueBy(sources, (obj) => {
201
+ return `${obj.name ?? obj.value ?? ""}:${obj.isExportable ?? false}:${obj.isTypeOnly ?? false}`;
202
+ });
203
+ }
204
+ function combineExports(exports) {
205
+ const sorted = sortBy(exports, (v) => !!Array.isArray(v.name), (v) => !v.isTypeOnly, (v) => v.path, (v) => !!v.name, (v) => Array.isArray(v.name) ? [...v.name].sort().join("\0") : v.name ?? "");
206
+ const prev = [];
207
+ const pathMap = /* @__PURE__ */ new Map();
208
+ const uniqueMap = /* @__PURE__ */ new Map();
209
+ for (const curr of sorted) {
210
+ const name = curr.name;
211
+ const pathKey = curr.path;
212
+ const prevByPath = pathMap.get(pathKey);
213
+ const uniqueKey = `${`${pathKey}:${Array.isArray(name) ? JSON.stringify(name) : name || ""}:${curr.isTypeOnly}`}:${curr.asAlias || ""}`;
214
+ if (uniqueMap.get(uniqueKey) || Array.isArray(name) && !name.length || prevByPath?.asAlias && !curr.asAlias) continue;
215
+ if (!prevByPath) {
216
+ const newItem = {
217
+ ...curr,
218
+ name: Array.isArray(name) ? [...new Set(name)] : name
219
+ };
220
+ prev.push(newItem);
221
+ pathMap.set(pathKey, newItem);
222
+ uniqueMap.set(uniqueKey, newItem);
223
+ continue;
224
+ }
225
+ if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {
226
+ prevByPath.name = [...new Set([...prevByPath.name, ...curr.name])];
227
+ continue;
228
+ }
229
+ prev.push(curr);
230
+ uniqueMap.set(uniqueKey, curr);
231
+ }
232
+ return prev;
233
+ }
234
+ function combineImports(imports, exports, source) {
235
+ const exportedNameLookup = /* @__PURE__ */ new Set();
236
+ for (const item of exports) {
237
+ const { name } = item;
238
+ if (!name) continue;
239
+ if (Array.isArray(name)) {
240
+ for (const value of name) if (value) exportedNameLookup.add(value);
241
+ continue;
242
+ }
243
+ exportedNameLookup.add(name);
244
+ }
245
+ const usageCache = /* @__PURE__ */ new Map();
246
+ const hasImportInSource = (importName) => {
247
+ if (!source) return true;
248
+ const cached = usageCache.get(importName);
249
+ if (cached !== void 0) return cached;
250
+ const isUsed = source.includes(importName) || exportedNameLookup.has(importName);
251
+ usageCache.set(importName, isUsed);
252
+ return isUsed;
253
+ };
254
+ const sorted = sortBy(imports, (v) => Array.isArray(v.name), (v) => !v.isTypeOnly, (v) => v.path, (v) => !!v.name, (v) => Array.isArray(v.name) ? [...v.name].sort().join("\0") : v.name ?? "");
255
+ const prev = [];
256
+ const pathTypeMap = /* @__PURE__ */ new Map();
257
+ const uniqueMap = /* @__PURE__ */ new Map();
258
+ for (const curr of sorted) {
259
+ let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name;
260
+ if (curr.path === curr.root) continue;
261
+ if (Array.isArray(name)) name = name.filter((item) => typeof item === "string" ? hasImportInSource(item) : hasImportInSource(item.propertyName));
262
+ const pathTypeKey = `${curr.path}:${curr.isTypeOnly}`;
263
+ const prevByPath = pathTypeMap.get(pathTypeKey);
264
+ const nameKey = Array.isArray(name) ? JSON.stringify(name) : name || "";
265
+ const pathNameTypeKey = `${curr.path}:${nameKey}:${curr.isTypeOnly}`;
266
+ if (uniqueMap.get(pathNameTypeKey) || Array.isArray(name) && !name.length) continue;
267
+ if (!prevByPath) {
268
+ const newItem = {
269
+ ...curr,
270
+ name
271
+ };
272
+ prev.push(newItem);
273
+ pathTypeMap.set(pathTypeKey, newItem);
274
+ uniqueMap.set(pathNameTypeKey, newItem);
275
+ continue;
276
+ }
277
+ if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {
278
+ prevByPath.name = [...new Set([...prevByPath.name, ...name])];
279
+ continue;
280
+ }
281
+ if (!Array.isArray(name) && name && !hasImportInSource(name)) continue;
282
+ prev.push(curr);
283
+ uniqueMap.set(pathNameTypeKey, curr);
284
+ }
285
+ return prev;
286
+ }
287
+ /**
288
+ * Helper to create a file with name and id set
289
+ */
290
+ function createFile(file) {
291
+ const extname = path.extname(file.baseName);
292
+ if (!extname) throw new Error(`No extname found for ${file.baseName}`);
293
+ const source = file.sources.map((item) => item.value).join("\n\n");
294
+ const exports = file.exports?.length ? combineExports(file.exports) : [];
295
+ const imports = file.imports?.length && source ? combineImports(file.imports, exports, source) : [];
296
+ const sources = file.sources?.length ? combineSources(file.sources) : [];
297
+ return {
298
+ ...file,
299
+ id: createHash("sha256").update(file.path).digest("hex"),
300
+ name: trimExtName(file.baseName),
301
+ extname,
302
+ imports,
303
+ exports,
304
+ sources,
305
+ meta: file.meta || {}
306
+ };
307
+ }
308
+ //#endregion
309
+ //#region src/utils/AsyncEventEmitter.ts
310
+ var AsyncEventEmitter = class {
311
+ constructor({ maxListener = 100, mode = "sequential" } = {}) {
312
+ this.#emitter.setMaxListeners(maxListener);
313
+ this.#mode = mode;
314
+ }
315
+ #emitter = new EventEmitter();
316
+ #mode;
317
+ async emit(eventName, ...eventArgs) {
318
+ const listeners = this.#emitter.listeners(eventName);
319
+ if (listeners.length === 0) return;
320
+ const errors = [];
321
+ if (this.#mode === "sequential") for (const listener of listeners) try {
322
+ await listener(...eventArgs);
323
+ } catch (err) {
324
+ const error = err instanceof Error ? err : new Error(String(err));
325
+ errors.push(error);
326
+ }
327
+ else {
328
+ const promises = listeners.map(async (listener) => {
329
+ try {
330
+ await listener(...eventArgs);
331
+ } catch (err) {
332
+ const error = err instanceof Error ? err : new Error(String(err));
333
+ errors.push(error);
334
+ }
335
+ });
336
+ await Promise.all(promises);
337
+ }
338
+ if (errors.length === 1) throw errors[0];
339
+ if (errors.length > 1) throw new AggregateError(errors, `Errors in async listeners for "${eventName}"`);
340
+ }
341
+ on(eventName, handler) {
342
+ this.#emitter.on(eventName, handler);
343
+ }
344
+ onOnce(eventName, handler) {
345
+ const wrapper = (...args) => {
346
+ this.off(eventName, wrapper);
347
+ handler(...args);
348
+ };
349
+ this.on(eventName, wrapper);
350
+ }
351
+ off(eventName, handler) {
352
+ this.#emitter.off(eventName, handler);
353
+ }
354
+ removeAll() {
355
+ this.#emitter.removeAllListeners();
356
+ }
357
+ };
358
+ //#endregion
359
+ //#region src/FileProcessor.ts
360
+ var FileProcessor = class {
361
+ #limit = pLimit(100);
362
+ events;
363
+ constructor({ events = new AsyncEventEmitter() } = {}) {
364
+ this.events = events;
365
+ return this;
366
+ }
367
+ async parse(file, { parsers, extension } = {}) {
368
+ const parseExtName = extension?.[file.extname] || void 0;
369
+ if (!parsers) {
370
+ console.warn("No parsers provided, using default parser. If you want to use a specific parser, please provide it in the options.");
371
+ return defaultParser.parse(file, { extname: parseExtName });
372
+ }
373
+ if (!file.extname) return defaultParser.parse(file, { extname: parseExtName });
374
+ const parser = parsers.get(file.extname);
375
+ if (!parser) return defaultParser.parse(file, { extname: parseExtName });
376
+ return parser.parse(file, { extname: parseExtName });
377
+ }
378
+ async run(files, { parsers, mode = "sequential", dryRun, extension } = {}) {
379
+ await this.events.emit("files:processing:start", files);
380
+ const total = files.length;
381
+ let processed = 0;
382
+ const processOne = async (resolvedFile, index) => {
383
+ await this.events.emit("file:processing:start", resolvedFile, index, total);
384
+ const source = dryRun ? void 0 : await this.parse(resolvedFile, {
385
+ extension,
386
+ parsers
387
+ });
388
+ const currentProcessed = ++processed;
389
+ const percentage = currentProcessed / total * 100;
390
+ await this.events.emit("file:processing:update", {
391
+ file: resolvedFile,
392
+ source,
393
+ processed: currentProcessed,
394
+ percentage,
395
+ total
396
+ });
397
+ await this.events.emit("file:processing:end", resolvedFile, index, total);
398
+ };
399
+ if (mode === "sequential") {
400
+ async function* asyncFiles() {
401
+ for (let index = 0; index < files.length; index++) yield [files[index], index];
402
+ }
403
+ for await (const [file, index] of asyncFiles()) if (file) await processOne(file, index);
404
+ } else {
405
+ const promises = files.map((resolvedFile, index) => this.#limit(() => processOne(resolvedFile, index)));
406
+ await Promise.all(promises);
407
+ }
408
+ await this.events.emit("files:processing:end", files);
409
+ return files;
410
+ }
411
+ };
412
+ //#endregion
413
+ //#region src/utils/Cache.ts
414
+ var Cache = class {
415
+ #buffer = /* @__PURE__ */ new Map();
416
+ get(key) {
417
+ return this.#buffer.get(key) ?? null;
418
+ }
419
+ set(key, value) {
420
+ this.#buffer.set(key, value);
421
+ }
422
+ delete(key) {
423
+ this.#buffer.delete(key);
424
+ }
425
+ clear() {
426
+ this.#buffer.clear();
427
+ }
428
+ keys() {
429
+ return [...this.#buffer.keys()];
430
+ }
431
+ values() {
432
+ return [...this.#buffer.values()];
433
+ }
434
+ flush() {}
435
+ };
436
+ //#endregion
437
+ //#region src/FileManager.ts
438
+ function mergeFile(a, b) {
439
+ return {
440
+ ...a,
441
+ sources: [...a.sources || [], ...b.sources || []],
442
+ imports: [...a.imports || [], ...b.imports || []],
443
+ exports: [...a.exports || [], ...b.exports || []]
444
+ };
445
+ }
446
+ var FileManager = class {
447
+ #cache = new Cache();
448
+ #filesCache = null;
449
+ events;
450
+ processor;
451
+ constructor({ events = new AsyncEventEmitter() } = {}) {
452
+ this.processor = new FileProcessor({ events });
453
+ this.events = events;
454
+ return this;
455
+ }
456
+ #resolvePath(file) {
457
+ this.events.emit("file:resolve:path", file);
458
+ return file;
459
+ }
460
+ #resolveName(file) {
461
+ this.events.emit("file:resolve:name", file);
462
+ return file;
463
+ }
464
+ add(...files) {
465
+ const resolvedFiles = [];
466
+ const mergedFiles = /* @__PURE__ */ new Map();
467
+ files.forEach((file) => {
468
+ const existing = mergedFiles.get(file.path);
469
+ if (existing) mergedFiles.set(file.path, mergeFile(existing, file));
470
+ else mergedFiles.set(file.path, file);
471
+ });
472
+ for (let file of mergedFiles.values()) {
473
+ file = this.#resolveName(file);
474
+ file = this.#resolvePath(file);
475
+ const resolvedFile = createFile(file);
476
+ this.#cache.set(resolvedFile.path, resolvedFile);
477
+ this.flush();
478
+ resolvedFiles.push(resolvedFile);
479
+ }
480
+ this.events.emit("files:added", resolvedFiles);
481
+ return resolvedFiles;
482
+ }
483
+ upsert(...files) {
484
+ const resolvedFiles = [];
485
+ const mergedFiles = /* @__PURE__ */ new Map();
486
+ files.forEach((file) => {
487
+ const existing = mergedFiles.get(file.path);
488
+ if (existing) mergedFiles.set(file.path, mergeFile(existing, file));
489
+ else mergedFiles.set(file.path, file);
490
+ });
491
+ for (let file of mergedFiles.values()) {
492
+ const existing = this.#cache.get(file.path);
493
+ file = this.#resolveName(file);
494
+ file = this.#resolvePath(file);
495
+ const resolvedFile = createFile(existing ? mergeFile(existing, file) : file);
496
+ this.#cache.set(resolvedFile.path, resolvedFile);
497
+ this.flush();
498
+ resolvedFiles.push(resolvedFile);
499
+ }
500
+ this.events.emit("files:added", resolvedFiles);
501
+ return resolvedFiles;
502
+ }
503
+ flush() {
504
+ this.#filesCache = null;
505
+ this.#cache.flush();
506
+ }
507
+ getByPath(path) {
508
+ return this.#cache.get(path);
509
+ }
510
+ deleteByPath(path) {
511
+ this.#cache.delete(path);
512
+ this.#filesCache = null;
513
+ }
514
+ clear() {
515
+ this.#cache.clear();
516
+ this.#filesCache = null;
517
+ }
518
+ get files() {
519
+ if (this.#filesCache) return this.#filesCache;
520
+ const keys = sortBy(this.#cache.keys(), (v) => v.length, (v) => trimExtName(v).endsWith("index"));
521
+ const files = [];
522
+ for (const key of keys) {
523
+ const file = this.#cache.get(key);
524
+ if (file) files.push(file);
525
+ }
526
+ this.#filesCache = files;
527
+ return files;
528
+ }
529
+ async write(options) {
530
+ await this.events.emit("files:writing:start", this.files);
531
+ const resolvedFiles = await this.processor.run(this.files, options);
532
+ this.clear();
533
+ await this.events.emit("files:writing:end", resolvedFiles);
534
+ return resolvedFiles;
535
+ }
536
+ };
537
+ //#endregion
538
+ //#region src/utils/TreeNode.ts
539
+ var TreeNode = class TreeNode {
540
+ data;
541
+ parent;
542
+ children = [];
543
+ #childrenMap = /* @__PURE__ */ new Map();
544
+ #cachedLeaves;
545
+ constructor(data, parent) {
546
+ this.data = data;
547
+ this.parent = parent;
548
+ }
549
+ addChild(data) {
550
+ const child = new TreeNode(data, this);
551
+ this.children.push(child);
552
+ if (typeof data === "object" && data !== null && "name" in data) this.#childrenMap.set(data.name, child);
553
+ this.#cachedLeaves = void 0;
554
+ return child;
555
+ }
556
+ getChildByName(name) {
557
+ return this.#childrenMap.get(name);
558
+ }
559
+ get leaves() {
560
+ if (this.#cachedLeaves) return this.#cachedLeaves;
561
+ if (this.children.length === 0) return [this];
562
+ const result = [];
563
+ const stack = [...this.children];
564
+ const visited = /* @__PURE__ */ new Set();
565
+ while (stack.length > 0) {
566
+ const node = stack.pop();
567
+ if (visited.has(node)) continue;
568
+ visited.add(node);
569
+ if (node.children.length > 0) stack.push(...node.children);
570
+ else result.push(node);
571
+ }
572
+ this.#cachedLeaves = result;
573
+ return result;
574
+ }
575
+ forEach(callback) {
576
+ const stack = [this];
577
+ for (let i = 0; i < stack.length; i++) {
578
+ const node = stack[i];
579
+ callback(node);
580
+ if (node.children.length > 0) stack.push(...node.children);
581
+ }
582
+ return this;
583
+ }
584
+ findDeep(predicate) {
585
+ for (const leaf of this.leaves) if (predicate(leaf)) return leaf;
586
+ }
587
+ static toGraph(root) {
588
+ const nodes = [];
589
+ const edges = [];
590
+ const stack = [root];
591
+ for (let i = 0; i < stack.length; i++) {
592
+ const node = stack[i];
593
+ nodes.push({
594
+ id: node.data.path,
595
+ label: node.data.name
596
+ });
597
+ const children = node.children;
598
+ if (children.length > 0) for (let j = 0, len = children.length; j < len; j++) {
599
+ const child = children[j];
600
+ edges.push({
601
+ from: node.data.path,
602
+ to: child.data.path
603
+ });
604
+ stack.push(child);
605
+ }
606
+ }
607
+ return {
608
+ nodes,
609
+ edges
610
+ };
611
+ }
612
+ static fromFiles(files, rootFolder = "") {
613
+ const normalizePath = (p) => p.replace(/\\/g, "/");
614
+ const normalizedRoot = normalizePath(rootFolder);
615
+ const rootPrefix = normalizedRoot.endsWith("/") ? normalizedRoot : `${normalizedRoot}/`;
616
+ const normalizedPaths = /* @__PURE__ */ new Map();
617
+ const filteredFiles = [];
618
+ for (const file of files) {
619
+ const filePath = normalizedPaths.get(file) ?? normalizePath(file.path);
620
+ normalizedPaths.set(file, filePath);
621
+ if (!filePath.endsWith(".json") && (!rootFolder || filePath.startsWith(rootPrefix))) filteredFiles.push(file);
622
+ }
623
+ if (filteredFiles.length === 0) return null;
624
+ const treeNode = new TreeNode({
625
+ name: rootFolder || "",
626
+ path: rootFolder || "",
627
+ file: void 0
628
+ });
629
+ for (const file of filteredFiles) {
630
+ const parts = normalizedPaths.get(file).slice(rootPrefix.length).split("/");
631
+ let current = treeNode;
632
+ let currentPath = rootFolder;
633
+ for (const [index, part] of parts.entries()) {
634
+ const isLast = index === parts.length - 1;
635
+ currentPath += (currentPath.endsWith("/") ? "" : "/") + part;
636
+ let next = current.getChildByName(part);
637
+ if (!next) next = current.addChild({
638
+ name: part,
639
+ path: currentPath,
640
+ file: isLast ? file : void 0
641
+ });
642
+ current = next;
643
+ }
644
+ }
645
+ return treeNode;
646
+ }
647
+ };
648
+ //#endregion
649
+ //#region src/contexts/RootContext.ts
650
+ /**
651
+ * Context providing root-level functionalities such as exit hook, tree node structure, and file management.
652
+ * Define in the `render` helper of the runtime.
653
+ */
654
+ const RootContext = createContext({
655
+ exit: () => {},
656
+ treeNode: new TreeNode({
657
+ type: "Root",
658
+ props: {}
659
+ }),
660
+ fileManager: new FileManager()
661
+ });
662
+ //#endregion
663
+ //#region src/components/Root.ts
664
+ /**
665
+ * Root component providing core Fabric runtime context.
666
+ *
667
+ * This component is typically used internally by the Fabric renderer.
668
+ * It provides the root context including FileManager, error handling,
669
+ * and lifecycle management.
670
+ *
671
+ * @example
672
+ * ```tsx
673
+ * <Root
674
+ * onExit={(error) => process.exit(error ? 1 : 0)}
675
+ * onError={(error) => console.error(error)}
676
+ * treeNode={treeNode}
677
+ * fileManager={fileManager}
678
+ * >
679
+ * <App>
680
+ * Your components here
681
+ * </App>
682
+ * </Root>
683
+ * ```
684
+ */
685
+ const Root = createComponent("Root", ({ onError, onExit, treeNode, fileManager, children }) => {
686
+ provide(RootContext, {
687
+ exit: onExit,
688
+ treeNode,
689
+ fileManager
690
+ });
691
+ provide(NodeTreeContext, treeNode);
692
+ try {
693
+ return children;
694
+ } catch (e) {
695
+ if (e instanceof Error) onError?.(e);
696
+ return "";
697
+ }
698
+ });
699
+ Root.displayName = "Root";
700
+ //#endregion
701
+ //#region src/utils/onProcessExit.ts
702
+ const SIGNALS = [
703
+ "SIGINT",
704
+ "SIGTERM",
705
+ "SIGHUP"
706
+ ];
707
+ /**
708
+ * Register a callback to run when the process exits (via exit event or common signals).
709
+ * Returns an unsubscribe function.
710
+ *
711
+ * Dynamically adjusts `process.maxListeners` to avoid MaxListenersExceededWarning
712
+ * when multiple instances are created (e.g. in tests).
713
+ */
714
+ function onProcessExit(callback) {
715
+ const exitHandler = (code) => callback(code);
716
+ const signalHandlers = /* @__PURE__ */ new Map();
717
+ const count = SIGNALS.length + 1;
718
+ process.setMaxListeners(process.getMaxListeners() + count);
719
+ for (const signal of SIGNALS) {
720
+ const handler = () => {
721
+ unsubscribe();
722
+ try {
723
+ callback(null);
724
+ } finally {
725
+ process.kill(process.pid, signal);
726
+ }
727
+ };
728
+ signalHandlers.set(signal, handler);
729
+ process.on(signal, handler);
730
+ }
731
+ process.on("exit", exitHandler);
732
+ function unsubscribe() {
733
+ process.removeListener("exit", exitHandler);
734
+ for (const [signal, handler] of signalHandlers) process.removeListener(signal, handler);
735
+ process.setMaxListeners(Math.max(process.getMaxListeners() - count, 0));
736
+ }
737
+ return unsubscribe;
738
+ }
739
+ //#endregion
740
+ export { provide as _, FileManager as a, createFile as c, createIntrinsic as d, renderIndent as f, inject as g, createContext as h, TreeNode as i, NodeTreeContext as l, RenderContext as m, Root as n, FileProcessor as o, renderIntrinsic as p, RootContext as r, AsyncEventEmitter as s, onProcessExit as t, createComponent as u, unprovide as v };
741
+
742
+ //# sourceMappingURL=onProcessExit-Cput7j2c.js.map