@frontmcp/uipack 0.6.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 (417) hide show
  1. package/CLAUDE.md +246 -0
  2. package/LICENSE +201 -0
  3. package/README.md +150 -0
  4. package/adapters/index.d.ts +13 -0
  5. package/adapters/index.d.ts.map +1 -0
  6. package/adapters/index.js +462 -0
  7. package/adapters/platform-meta.d.ts +166 -0
  8. package/adapters/platform-meta.d.ts.map +1 -0
  9. package/adapters/response-builder.d.ts +108 -0
  10. package/adapters/response-builder.d.ts.map +1 -0
  11. package/adapters/serving-mode.d.ts +107 -0
  12. package/adapters/serving-mode.d.ts.map +1 -0
  13. package/base-template/bridge.d.ts +90 -0
  14. package/base-template/bridge.d.ts.map +1 -0
  15. package/base-template/default-base-template.d.ts +92 -0
  16. package/base-template/default-base-template.d.ts.map +1 -0
  17. package/base-template/index.d.ts +15 -0
  18. package/base-template/index.d.ts.map +1 -0
  19. package/base-template/index.js +1398 -0
  20. package/base-template/polyfills.d.ts +31 -0
  21. package/base-template/polyfills.d.ts.map +1 -0
  22. package/base-template/theme-styles.d.ts +74 -0
  23. package/base-template/theme-styles.d.ts.map +1 -0
  24. package/bridge-runtime/iife-generator.d.ts +62 -0
  25. package/bridge-runtime/iife-generator.d.ts.map +1 -0
  26. package/bridge-runtime/index.d.ts +10 -0
  27. package/bridge-runtime/index.d.ts.map +1 -0
  28. package/bridge-runtime/index.js +883 -0
  29. package/build/cdn-resources.d.ts +243 -0
  30. package/build/cdn-resources.d.ts.map +1 -0
  31. package/build/index.d.ts +295 -0
  32. package/build/index.d.ts.map +1 -0
  33. package/build/index.js +6861 -0
  34. package/build/widget-manifest.d.ts +362 -0
  35. package/build/widget-manifest.d.ts.map +1 -0
  36. package/bundler/cache.d.ts +173 -0
  37. package/bundler/cache.d.ts.map +1 -0
  38. package/bundler/file-cache/component-builder.d.ts +167 -0
  39. package/bundler/file-cache/component-builder.d.ts.map +1 -0
  40. package/bundler/file-cache/hash-calculator.d.ts +155 -0
  41. package/bundler/file-cache/hash-calculator.d.ts.map +1 -0
  42. package/bundler/file-cache/index.d.ts +12 -0
  43. package/bundler/file-cache/index.d.ts.map +1 -0
  44. package/bundler/file-cache/storage/filesystem.d.ts +149 -0
  45. package/bundler/file-cache/storage/filesystem.d.ts.map +1 -0
  46. package/bundler/file-cache/storage/index.d.ts +11 -0
  47. package/bundler/file-cache/storage/index.d.ts.map +1 -0
  48. package/bundler/file-cache/storage/interface.d.ts +152 -0
  49. package/bundler/file-cache/storage/interface.d.ts.map +1 -0
  50. package/bundler/file-cache/storage/redis.d.ts +139 -0
  51. package/bundler/file-cache/storage/redis.d.ts.map +1 -0
  52. package/bundler/index.d.ts +35 -0
  53. package/bundler/index.d.ts.map +1 -0
  54. package/bundler/index.js +2947 -0
  55. package/bundler/sandbox/enclave-adapter.d.ts +121 -0
  56. package/bundler/sandbox/enclave-adapter.d.ts.map +1 -0
  57. package/bundler/sandbox/executor.d.ts +14 -0
  58. package/bundler/sandbox/executor.d.ts.map +1 -0
  59. package/bundler/sandbox/policy.d.ts +62 -0
  60. package/bundler/sandbox/policy.d.ts.map +1 -0
  61. package/bundler/types.d.ts +702 -0
  62. package/bundler/types.d.ts.map +1 -0
  63. package/dependency/cdn-registry.d.ts +98 -0
  64. package/dependency/cdn-registry.d.ts.map +1 -0
  65. package/dependency/import-map.d.ts +186 -0
  66. package/dependency/import-map.d.ts.map +1 -0
  67. package/dependency/import-parser.d.ts +82 -0
  68. package/dependency/import-parser.d.ts.map +1 -0
  69. package/dependency/index.d.ts +17 -0
  70. package/dependency/index.d.ts.map +1 -0
  71. package/dependency/index.js +3215 -0
  72. package/dependency/resolver.d.ts +164 -0
  73. package/dependency/resolver.d.ts.map +1 -0
  74. package/dependency/schemas.d.ts +486 -0
  75. package/dependency/schemas.d.ts.map +1 -0
  76. package/dependency/template-loader.d.ts +204 -0
  77. package/dependency/template-loader.d.ts.map +1 -0
  78. package/dependency/template-processor.d.ts +118 -0
  79. package/dependency/template-processor.d.ts.map +1 -0
  80. package/dependency/types.d.ts +739 -0
  81. package/dependency/types.d.ts.map +1 -0
  82. package/esm/adapters/index.d.ts +13 -0
  83. package/esm/adapters/index.d.ts.map +1 -0
  84. package/esm/adapters/index.js +427 -0
  85. package/esm/adapters/platform-meta.d.ts +166 -0
  86. package/esm/adapters/platform-meta.d.ts.map +1 -0
  87. package/esm/adapters/response-builder.d.ts +108 -0
  88. package/esm/adapters/response-builder.d.ts.map +1 -0
  89. package/esm/adapters/serving-mode.d.ts +107 -0
  90. package/esm/adapters/serving-mode.d.ts.map +1 -0
  91. package/esm/base-template/bridge.d.ts +90 -0
  92. package/esm/base-template/bridge.d.ts.map +1 -0
  93. package/esm/base-template/default-base-template.d.ts +92 -0
  94. package/esm/base-template/default-base-template.d.ts.map +1 -0
  95. package/esm/base-template/index.d.ts +15 -0
  96. package/esm/base-template/index.d.ts.map +1 -0
  97. package/esm/base-template/index.js +1364 -0
  98. package/esm/base-template/polyfills.d.ts +31 -0
  99. package/esm/base-template/polyfills.d.ts.map +1 -0
  100. package/esm/base-template/theme-styles.d.ts +74 -0
  101. package/esm/base-template/theme-styles.d.ts.map +1 -0
  102. package/esm/bridge-runtime/iife-generator.d.ts +62 -0
  103. package/esm/bridge-runtime/iife-generator.d.ts.map +1 -0
  104. package/esm/bridge-runtime/index.d.ts +10 -0
  105. package/esm/bridge-runtime/index.d.ts.map +1 -0
  106. package/esm/bridge-runtime/index.js +853 -0
  107. package/esm/build/cdn-resources.d.ts +243 -0
  108. package/esm/build/cdn-resources.d.ts.map +1 -0
  109. package/esm/build/index.d.ts +295 -0
  110. package/esm/build/index.d.ts.map +1 -0
  111. package/esm/build/index.js +6786 -0
  112. package/esm/build/widget-manifest.d.ts +362 -0
  113. package/esm/build/widget-manifest.d.ts.map +1 -0
  114. package/esm/bundler/cache.d.ts +173 -0
  115. package/esm/bundler/cache.d.ts.map +1 -0
  116. package/esm/bundler/file-cache/component-builder.d.ts +167 -0
  117. package/esm/bundler/file-cache/component-builder.d.ts.map +1 -0
  118. package/esm/bundler/file-cache/hash-calculator.d.ts +155 -0
  119. package/esm/bundler/file-cache/hash-calculator.d.ts.map +1 -0
  120. package/esm/bundler/file-cache/index.d.ts +12 -0
  121. package/esm/bundler/file-cache/index.d.ts.map +1 -0
  122. package/esm/bundler/file-cache/storage/filesystem.d.ts +149 -0
  123. package/esm/bundler/file-cache/storage/filesystem.d.ts.map +1 -0
  124. package/esm/bundler/file-cache/storage/index.d.ts +11 -0
  125. package/esm/bundler/file-cache/storage/index.d.ts.map +1 -0
  126. package/esm/bundler/file-cache/storage/interface.d.ts +152 -0
  127. package/esm/bundler/file-cache/storage/interface.d.ts.map +1 -0
  128. package/esm/bundler/file-cache/storage/redis.d.ts +139 -0
  129. package/esm/bundler/file-cache/storage/redis.d.ts.map +1 -0
  130. package/esm/bundler/index.d.ts +35 -0
  131. package/esm/bundler/index.d.ts.map +1 -0
  132. package/esm/bundler/index.js +2882 -0
  133. package/esm/bundler/sandbox/enclave-adapter.d.ts +121 -0
  134. package/esm/bundler/sandbox/enclave-adapter.d.ts.map +1 -0
  135. package/esm/bundler/sandbox/executor.d.ts +14 -0
  136. package/esm/bundler/sandbox/executor.d.ts.map +1 -0
  137. package/esm/bundler/sandbox/policy.d.ts +62 -0
  138. package/esm/bundler/sandbox/policy.d.ts.map +1 -0
  139. package/esm/bundler/types.d.ts +702 -0
  140. package/esm/bundler/types.d.ts.map +1 -0
  141. package/esm/dependency/cdn-registry.d.ts +98 -0
  142. package/esm/dependency/cdn-registry.d.ts.map +1 -0
  143. package/esm/dependency/import-map.d.ts +186 -0
  144. package/esm/dependency/import-map.d.ts.map +1 -0
  145. package/esm/dependency/import-parser.d.ts +82 -0
  146. package/esm/dependency/import-parser.d.ts.map +1 -0
  147. package/esm/dependency/index.d.ts +17 -0
  148. package/esm/dependency/index.d.ts.map +1 -0
  149. package/esm/dependency/index.js +3096 -0
  150. package/esm/dependency/resolver.d.ts +164 -0
  151. package/esm/dependency/resolver.d.ts.map +1 -0
  152. package/esm/dependency/schemas.d.ts +486 -0
  153. package/esm/dependency/schemas.d.ts.map +1 -0
  154. package/esm/dependency/template-loader.d.ts +204 -0
  155. package/esm/dependency/template-loader.d.ts.map +1 -0
  156. package/esm/dependency/template-processor.d.ts +118 -0
  157. package/esm/dependency/template-processor.d.ts.map +1 -0
  158. package/esm/dependency/types.d.ts +739 -0
  159. package/esm/dependency/types.d.ts.map +1 -0
  160. package/esm/handlebars/expression-extractor.d.ts +147 -0
  161. package/esm/handlebars/expression-extractor.d.ts.map +1 -0
  162. package/esm/handlebars/helpers.d.ts +339 -0
  163. package/esm/handlebars/helpers.d.ts.map +1 -0
  164. package/esm/handlebars/index.d.ts +195 -0
  165. package/esm/handlebars/index.d.ts.map +1 -0
  166. package/esm/handlebars/index.js +587 -0
  167. package/esm/index.d.ts +50 -0
  168. package/esm/index.d.ts.map +1 -0
  169. package/esm/index.js +12434 -0
  170. package/esm/package.json +68 -0
  171. package/esm/registry/index.d.ts +46 -0
  172. package/esm/registry/index.d.ts.map +1 -0
  173. package/esm/registry/index.js +6237 -0
  174. package/esm/registry/render-template.d.ts +91 -0
  175. package/esm/registry/render-template.d.ts.map +1 -0
  176. package/esm/registry/tool-ui.registry.d.ts +294 -0
  177. package/esm/registry/tool-ui.registry.d.ts.map +1 -0
  178. package/esm/registry/uri-utils.d.ts +56 -0
  179. package/esm/registry/uri-utils.d.ts.map +1 -0
  180. package/esm/renderers/cache.d.ts +145 -0
  181. package/esm/renderers/cache.d.ts.map +1 -0
  182. package/esm/renderers/html.renderer.d.ts +123 -0
  183. package/esm/renderers/html.renderer.d.ts.map +1 -0
  184. package/esm/renderers/index.d.ts +36 -0
  185. package/esm/renderers/index.d.ts.map +1 -0
  186. package/esm/renderers/index.js +1654 -0
  187. package/esm/renderers/mdx.renderer.d.ts +120 -0
  188. package/esm/renderers/mdx.renderer.d.ts.map +1 -0
  189. package/esm/renderers/registry.d.ts +133 -0
  190. package/esm/renderers/registry.d.ts.map +1 -0
  191. package/esm/renderers/types.d.ts +342 -0
  192. package/esm/renderers/types.d.ts.map +1 -0
  193. package/esm/renderers/utils/detect.d.ts +107 -0
  194. package/esm/renderers/utils/detect.d.ts.map +1 -0
  195. package/esm/renderers/utils/hash.d.ts +40 -0
  196. package/esm/renderers/utils/hash.d.ts.map +1 -0
  197. package/esm/renderers/utils/index.d.ts +9 -0
  198. package/esm/renderers/utils/index.d.ts.map +1 -0
  199. package/esm/renderers/utils/transpiler.d.ts +89 -0
  200. package/esm/renderers/utils/transpiler.d.ts.map +1 -0
  201. package/esm/runtime/adapters/html.adapter.d.ts +59 -0
  202. package/esm/runtime/adapters/html.adapter.d.ts.map +1 -0
  203. package/esm/runtime/adapters/index.d.ts +26 -0
  204. package/esm/runtime/adapters/index.d.ts.map +1 -0
  205. package/esm/runtime/adapters/mdx.adapter.d.ts +73 -0
  206. package/esm/runtime/adapters/mdx.adapter.d.ts.map +1 -0
  207. package/esm/runtime/adapters/types.d.ts +95 -0
  208. package/esm/runtime/adapters/types.d.ts.map +1 -0
  209. package/esm/runtime/csp.d.ts +48 -0
  210. package/esm/runtime/csp.d.ts.map +1 -0
  211. package/esm/runtime/index.d.ts +17 -0
  212. package/esm/runtime/index.d.ts.map +1 -0
  213. package/esm/runtime/index.js +4976 -0
  214. package/esm/runtime/mcp-bridge.d.ts +101 -0
  215. package/esm/runtime/mcp-bridge.d.ts.map +1 -0
  216. package/esm/runtime/renderer-runtime.d.ts +133 -0
  217. package/esm/runtime/renderer-runtime.d.ts.map +1 -0
  218. package/esm/runtime/sanitizer.d.ts +172 -0
  219. package/esm/runtime/sanitizer.d.ts.map +1 -0
  220. package/esm/runtime/types.d.ts +415 -0
  221. package/esm/runtime/types.d.ts.map +1 -0
  222. package/esm/runtime/wrapper.d.ts +421 -0
  223. package/esm/runtime/wrapper.d.ts.map +1 -0
  224. package/esm/styles/index.d.ts +8 -0
  225. package/esm/styles/index.d.ts.map +1 -0
  226. package/esm/styles/index.js +171 -0
  227. package/esm/styles/variants.d.ts +51 -0
  228. package/esm/styles/variants.d.ts.map +1 -0
  229. package/esm/theme/cdn.d.ts +195 -0
  230. package/esm/theme/cdn.d.ts.map +1 -0
  231. package/esm/theme/index.d.ts +18 -0
  232. package/esm/theme/index.d.ts.map +1 -0
  233. package/esm/theme/index.js +700 -0
  234. package/esm/theme/platforms.d.ts +107 -0
  235. package/esm/theme/platforms.d.ts.map +1 -0
  236. package/esm/theme/presets/github-openai.d.ts +50 -0
  237. package/esm/theme/presets/github-openai.d.ts.map +1 -0
  238. package/esm/theme/presets/index.d.ts +11 -0
  239. package/esm/theme/presets/index.d.ts.map +1 -0
  240. package/esm/theme/theme.d.ts +396 -0
  241. package/esm/theme/theme.d.ts.map +1 -0
  242. package/esm/tool-template/builder.d.ts +213 -0
  243. package/esm/tool-template/builder.d.ts.map +1 -0
  244. package/esm/tool-template/index.d.ts +16 -0
  245. package/esm/tool-template/index.d.ts.map +1 -0
  246. package/esm/tool-template/index.js +3518 -0
  247. package/esm/types/index.d.ts +14 -0
  248. package/esm/types/index.d.ts.map +1 -0
  249. package/esm/types/index.js +75 -0
  250. package/esm/types/ui-config.d.ts +641 -0
  251. package/esm/types/ui-config.d.ts.map +1 -0
  252. package/esm/types/ui-runtime.d.ts +1008 -0
  253. package/esm/types/ui-runtime.d.ts.map +1 -0
  254. package/esm/typings/cache/cache-adapter.d.ts +125 -0
  255. package/esm/typings/cache/cache-adapter.d.ts.map +1 -0
  256. package/esm/typings/cache/index.d.ts +10 -0
  257. package/esm/typings/cache/index.d.ts.map +1 -0
  258. package/esm/typings/cache/memory-cache.d.ts +92 -0
  259. package/esm/typings/cache/memory-cache.d.ts.map +1 -0
  260. package/esm/typings/dts-parser.d.ts +90 -0
  261. package/esm/typings/dts-parser.d.ts.map +1 -0
  262. package/esm/typings/index.d.ts +48 -0
  263. package/esm/typings/index.d.ts.map +1 -0
  264. package/esm/typings/index.js +812 -0
  265. package/esm/typings/schemas.d.ts +232 -0
  266. package/esm/typings/schemas.d.ts.map +1 -0
  267. package/esm/typings/type-fetcher.d.ts +89 -0
  268. package/esm/typings/type-fetcher.d.ts.map +1 -0
  269. package/esm/typings/types.d.ts +320 -0
  270. package/esm/typings/types.d.ts.map +1 -0
  271. package/esm/utils/escape-html.d.ts +58 -0
  272. package/esm/utils/escape-html.d.ts.map +1 -0
  273. package/esm/utils/index.d.ts +10 -0
  274. package/esm/utils/index.d.ts.map +1 -0
  275. package/esm/utils/index.js +40 -0
  276. package/esm/utils/safe-stringify.d.ts +30 -0
  277. package/esm/utils/safe-stringify.d.ts.map +1 -0
  278. package/esm/validation/error-box.d.ts +56 -0
  279. package/esm/validation/error-box.d.ts.map +1 -0
  280. package/esm/validation/index.d.ts +13 -0
  281. package/esm/validation/index.d.ts.map +1 -0
  282. package/esm/validation/index.js +542 -0
  283. package/esm/validation/schema-paths.d.ts +118 -0
  284. package/esm/validation/schema-paths.d.ts.map +1 -0
  285. package/esm/validation/template-validator.d.ts +143 -0
  286. package/esm/validation/template-validator.d.ts.map +1 -0
  287. package/esm/validation/wrapper.d.ts +97 -0
  288. package/esm/validation/wrapper.d.ts.map +1 -0
  289. package/handlebars/expression-extractor.d.ts +147 -0
  290. package/handlebars/expression-extractor.d.ts.map +1 -0
  291. package/handlebars/helpers.d.ts +339 -0
  292. package/handlebars/helpers.d.ts.map +1 -0
  293. package/handlebars/index.d.ts +195 -0
  294. package/handlebars/index.d.ts.map +1 -0
  295. package/handlebars/index.js +666 -0
  296. package/index.d.ts +50 -0
  297. package/index.d.ts.map +1 -0
  298. package/index.js +12683 -0
  299. package/package.json +66 -0
  300. package/registry/index.d.ts +46 -0
  301. package/registry/index.d.ts.map +1 -0
  302. package/registry/index.js +6280 -0
  303. package/registry/render-template.d.ts +91 -0
  304. package/registry/render-template.d.ts.map +1 -0
  305. package/registry/tool-ui.registry.d.ts +294 -0
  306. package/registry/tool-ui.registry.d.ts.map +1 -0
  307. package/registry/uri-utils.d.ts +56 -0
  308. package/registry/uri-utils.d.ts.map +1 -0
  309. package/renderers/cache.d.ts +145 -0
  310. package/renderers/cache.d.ts.map +1 -0
  311. package/renderers/html.renderer.d.ts +123 -0
  312. package/renderers/html.renderer.d.ts.map +1 -0
  313. package/renderers/index.d.ts +36 -0
  314. package/renderers/index.d.ts.map +1 -0
  315. package/renderers/index.js +1706 -0
  316. package/renderers/mdx.renderer.d.ts +120 -0
  317. package/renderers/mdx.renderer.d.ts.map +1 -0
  318. package/renderers/registry.d.ts +133 -0
  319. package/renderers/registry.d.ts.map +1 -0
  320. package/renderers/types.d.ts +342 -0
  321. package/renderers/types.d.ts.map +1 -0
  322. package/renderers/utils/detect.d.ts +107 -0
  323. package/renderers/utils/detect.d.ts.map +1 -0
  324. package/renderers/utils/hash.d.ts +40 -0
  325. package/renderers/utils/hash.d.ts.map +1 -0
  326. package/renderers/utils/index.d.ts +9 -0
  327. package/renderers/utils/index.d.ts.map +1 -0
  328. package/renderers/utils/transpiler.d.ts +89 -0
  329. package/renderers/utils/transpiler.d.ts.map +1 -0
  330. package/runtime/adapters/html.adapter.d.ts +59 -0
  331. package/runtime/adapters/html.adapter.d.ts.map +1 -0
  332. package/runtime/adapters/index.d.ts +26 -0
  333. package/runtime/adapters/index.d.ts.map +1 -0
  334. package/runtime/adapters/mdx.adapter.d.ts +73 -0
  335. package/runtime/adapters/mdx.adapter.d.ts.map +1 -0
  336. package/runtime/adapters/types.d.ts +95 -0
  337. package/runtime/adapters/types.d.ts.map +1 -0
  338. package/runtime/csp.d.ts +48 -0
  339. package/runtime/csp.d.ts.map +1 -0
  340. package/runtime/index.d.ts +17 -0
  341. package/runtime/index.d.ts.map +1 -0
  342. package/runtime/index.js +5052 -0
  343. package/runtime/mcp-bridge.d.ts +101 -0
  344. package/runtime/mcp-bridge.d.ts.map +1 -0
  345. package/runtime/renderer-runtime.d.ts +133 -0
  346. package/runtime/renderer-runtime.d.ts.map +1 -0
  347. package/runtime/sanitizer.d.ts +172 -0
  348. package/runtime/sanitizer.d.ts.map +1 -0
  349. package/runtime/types.d.ts +415 -0
  350. package/runtime/types.d.ts.map +1 -0
  351. package/runtime/wrapper.d.ts +421 -0
  352. package/runtime/wrapper.d.ts.map +1 -0
  353. package/styles/index.d.ts +8 -0
  354. package/styles/index.d.ts.map +1 -0
  355. package/styles/index.js +222 -0
  356. package/styles/variants.d.ts +51 -0
  357. package/styles/variants.d.ts.map +1 -0
  358. package/theme/cdn.d.ts +195 -0
  359. package/theme/cdn.d.ts.map +1 -0
  360. package/theme/index.d.ts +18 -0
  361. package/theme/index.d.ts.map +1 -0
  362. package/theme/index.js +757 -0
  363. package/theme/platforms.d.ts +107 -0
  364. package/theme/platforms.d.ts.map +1 -0
  365. package/theme/presets/github-openai.d.ts +50 -0
  366. package/theme/presets/github-openai.d.ts.map +1 -0
  367. package/theme/presets/index.d.ts +11 -0
  368. package/theme/presets/index.d.ts.map +1 -0
  369. package/theme/theme.d.ts +396 -0
  370. package/theme/theme.d.ts.map +1 -0
  371. package/tool-template/builder.d.ts +213 -0
  372. package/tool-template/builder.d.ts.map +1 -0
  373. package/tool-template/index.d.ts +16 -0
  374. package/tool-template/index.d.ts.map +1 -0
  375. package/tool-template/index.js +3562 -0
  376. package/types/index.d.ts +14 -0
  377. package/types/index.d.ts.map +1 -0
  378. package/types/index.js +108 -0
  379. package/types/ui-config.d.ts +641 -0
  380. package/types/ui-config.d.ts.map +1 -0
  381. package/types/ui-runtime.d.ts +1008 -0
  382. package/types/ui-runtime.d.ts.map +1 -0
  383. package/typings/cache/cache-adapter.d.ts +125 -0
  384. package/typings/cache/cache-adapter.d.ts.map +1 -0
  385. package/typings/cache/index.d.ts +10 -0
  386. package/typings/cache/index.d.ts.map +1 -0
  387. package/typings/cache/memory-cache.d.ts +92 -0
  388. package/typings/cache/memory-cache.d.ts.map +1 -0
  389. package/typings/dts-parser.d.ts +90 -0
  390. package/typings/dts-parser.d.ts.map +1 -0
  391. package/typings/index.d.ts +48 -0
  392. package/typings/index.d.ts.map +1 -0
  393. package/typings/index.js +868 -0
  394. package/typings/schemas.d.ts +232 -0
  395. package/typings/schemas.d.ts.map +1 -0
  396. package/typings/type-fetcher.d.ts +89 -0
  397. package/typings/type-fetcher.d.ts.map +1 -0
  398. package/typings/types.d.ts +320 -0
  399. package/typings/types.d.ts.map +1 -0
  400. package/utils/escape-html.d.ts +58 -0
  401. package/utils/escape-html.d.ts.map +1 -0
  402. package/utils/index.d.ts +10 -0
  403. package/utils/index.d.ts.map +1 -0
  404. package/utils/index.js +70 -0
  405. package/utils/safe-stringify.d.ts +30 -0
  406. package/utils/safe-stringify.d.ts.map +1 -0
  407. package/validation/error-box.d.ts +56 -0
  408. package/validation/error-box.d.ts.map +1 -0
  409. package/validation/index.d.ts +13 -0
  410. package/validation/index.d.ts.map +1 -0
  411. package/validation/index.js +583 -0
  412. package/validation/schema-paths.d.ts +118 -0
  413. package/validation/schema-paths.d.ts.map +1 -0
  414. package/validation/template-validator.d.ts +143 -0
  415. package/validation/template-validator.d.ts.map +1 -0
  416. package/validation/wrapper.d.ts +97 -0
  417. package/validation/wrapper.d.ts.map +1 -0
@@ -0,0 +1,1706 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // libs/uipack/src/utils/safe-stringify.ts
34
+ var init_safe_stringify = __esm({
35
+ "libs/uipack/src/utils/safe-stringify.ts"() {
36
+ "use strict";
37
+ }
38
+ });
39
+
40
+ // libs/uipack/src/utils/escape-html.ts
41
+ function escapeHtml(str) {
42
+ if (str === null || str === void 0) {
43
+ return "";
44
+ }
45
+ const s = String(str);
46
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
47
+ }
48
+ var init_escape_html = __esm({
49
+ "libs/uipack/src/utils/escape-html.ts"() {
50
+ "use strict";
51
+ }
52
+ });
53
+
54
+ // libs/uipack/src/utils/index.ts
55
+ var init_utils = __esm({
56
+ "libs/uipack/src/utils/index.ts"() {
57
+ "use strict";
58
+ init_safe_stringify();
59
+ init_escape_html();
60
+ }
61
+ });
62
+
63
+ // libs/uipack/src/handlebars/helpers.ts
64
+ function formatDate(date, format) {
65
+ if (date === null || date === void 0) {
66
+ return "";
67
+ }
68
+ let dateObj;
69
+ if (date instanceof Date) {
70
+ dateObj = date;
71
+ } else if (typeof date === "string" || typeof date === "number") {
72
+ dateObj = new Date(date);
73
+ } else {
74
+ return String(date);
75
+ }
76
+ if (isNaN(dateObj.getTime())) {
77
+ return String(date);
78
+ }
79
+ const options = {};
80
+ switch (format) {
81
+ case "short":
82
+ options.dateStyle = "short";
83
+ break;
84
+ case "medium":
85
+ options.dateStyle = "medium";
86
+ break;
87
+ case "long":
88
+ options.dateStyle = "long";
89
+ break;
90
+ case "full":
91
+ options.dateStyle = "full";
92
+ break;
93
+ case "time":
94
+ options.timeStyle = "short";
95
+ break;
96
+ case "datetime":
97
+ options.dateStyle = "medium";
98
+ options.timeStyle = "short";
99
+ break;
100
+ case "iso":
101
+ return dateObj.toISOString();
102
+ case "relative":
103
+ return formatRelativeDate(dateObj);
104
+ default:
105
+ options.dateStyle = "medium";
106
+ }
107
+ return new Intl.DateTimeFormat("en-US", options).format(dateObj);
108
+ }
109
+ function formatRelativeDate(date) {
110
+ const now = /* @__PURE__ */ new Date();
111
+ const diffMs = now.getTime() - date.getTime();
112
+ const diffSecs = Math.floor(diffMs / 1e3);
113
+ const diffMins = Math.floor(diffSecs / 60);
114
+ const diffHours = Math.floor(diffMins / 60);
115
+ const diffDays = Math.floor(diffHours / 24);
116
+ if (diffSecs < 60) {
117
+ return "just now";
118
+ } else if (diffMins < 60) {
119
+ return `${diffMins} minute${diffMins === 1 ? "" : "s"} ago`;
120
+ } else if (diffHours < 24) {
121
+ return `${diffHours} hour${diffHours === 1 ? "" : "s"} ago`;
122
+ } else if (diffDays < 7) {
123
+ return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`;
124
+ } else {
125
+ return formatDate(date, "medium");
126
+ }
127
+ }
128
+ function formatCurrency(amount, currency) {
129
+ if (amount === null || amount === void 0) {
130
+ return "";
131
+ }
132
+ const num = typeof amount === "number" ? amount : parseFloat(String(amount));
133
+ if (isNaN(num)) {
134
+ return String(amount);
135
+ }
136
+ return new Intl.NumberFormat("en-US", {
137
+ style: "currency",
138
+ currency: typeof currency === "string" ? currency : "USD"
139
+ }).format(num);
140
+ }
141
+ function formatNumber(value, decimals) {
142
+ if (value === null || value === void 0) {
143
+ return "";
144
+ }
145
+ const num = typeof value === "number" ? value : parseFloat(String(value));
146
+ if (isNaN(num)) {
147
+ return String(value);
148
+ }
149
+ const options = {};
150
+ if (typeof decimals === "number") {
151
+ options.minimumFractionDigits = decimals;
152
+ options.maximumFractionDigits = decimals;
153
+ }
154
+ return new Intl.NumberFormat("en-US", options).format(num);
155
+ }
156
+ function jsonEmbed(data) {
157
+ const json2 = JSON.stringify(data ?? null);
158
+ return json2.replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
159
+ }
160
+ function json(data, pretty) {
161
+ return JSON.stringify(data ?? null, null, pretty ? 2 : void 0);
162
+ }
163
+ function eq(a, b) {
164
+ return a === b;
165
+ }
166
+ function ne(a, b) {
167
+ return a !== b;
168
+ }
169
+ function gt(a, b) {
170
+ return Number(a) > Number(b);
171
+ }
172
+ function gte(a, b) {
173
+ return Number(a) >= Number(b);
174
+ }
175
+ function lt(a, b) {
176
+ return Number(a) < Number(b);
177
+ }
178
+ function lte(a, b) {
179
+ return Number(a) <= Number(b);
180
+ }
181
+ function and(a, b) {
182
+ return Boolean(a) && Boolean(b);
183
+ }
184
+ function or(a, b) {
185
+ return Boolean(a) || Boolean(b);
186
+ }
187
+ function not(value) {
188
+ return !value;
189
+ }
190
+ function first(arr) {
191
+ if (!Array.isArray(arr)) return void 0;
192
+ return arr[0];
193
+ }
194
+ function last(arr) {
195
+ if (!Array.isArray(arr)) return void 0;
196
+ return arr[arr.length - 1];
197
+ }
198
+ function length(value) {
199
+ if (Array.isArray(value)) return value.length;
200
+ if (typeof value === "string") return value.length;
201
+ return 0;
202
+ }
203
+ function includes(arr, value) {
204
+ if (!Array.isArray(arr)) return false;
205
+ return arr.includes(value);
206
+ }
207
+ function join(arr, separator) {
208
+ if (!Array.isArray(arr)) return "";
209
+ return arr.join(typeof separator === "string" ? separator : ", ");
210
+ }
211
+ function uppercase(str) {
212
+ return String(str ?? "").toUpperCase();
213
+ }
214
+ function lowercase(str) {
215
+ return String(str ?? "").toLowerCase();
216
+ }
217
+ function capitalize(str) {
218
+ const s = String(str ?? "");
219
+ return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
220
+ }
221
+ function truncate(str, maxLength, suffix) {
222
+ const s = String(str ?? "");
223
+ const len = typeof maxLength === "number" ? maxLength : 50;
224
+ const suf = typeof suffix === "string" ? suffix : "...";
225
+ if (s.length <= len) return s;
226
+ return s.slice(0, len - suf.length) + suf;
227
+ }
228
+ function defaultValue(value, defaultValue2) {
229
+ return value || defaultValue2;
230
+ }
231
+ function uniqueId(prefix) {
232
+ const id = ++idCounter;
233
+ return prefix ? `${prefix}-${id}` : `id-${id}`;
234
+ }
235
+ function resetUniqueIdCounter() {
236
+ idCounter = 0;
237
+ }
238
+ function classNames(...classes) {
239
+ return classes.filter(Boolean).map(String).join(" ");
240
+ }
241
+ var idCounter, builtinHelpers;
242
+ var init_helpers = __esm({
243
+ "libs/uipack/src/handlebars/helpers.ts"() {
244
+ "use strict";
245
+ init_utils();
246
+ idCounter = 0;
247
+ builtinHelpers = {
248
+ // Escaping
249
+ escapeHtml,
250
+ // Formatting
251
+ formatDate,
252
+ formatCurrency,
253
+ formatNumber,
254
+ json,
255
+ jsonEmbed,
256
+ // Comparison
257
+ eq,
258
+ ne,
259
+ gt,
260
+ gte,
261
+ lt,
262
+ lte,
263
+ // Logical
264
+ and,
265
+ or,
266
+ not,
267
+ // Array
268
+ first,
269
+ last,
270
+ length,
271
+ includes,
272
+ join,
273
+ // String
274
+ uppercase,
275
+ lowercase,
276
+ capitalize,
277
+ truncate,
278
+ // Utility
279
+ default: defaultValue,
280
+ uniqueId,
281
+ classNames
282
+ };
283
+ }
284
+ });
285
+
286
+ // libs/uipack/src/handlebars/expression-extractor.ts
287
+ function extractExpressions(template) {
288
+ const expressions = [];
289
+ const lines = template.split("\n");
290
+ const positionMap = buildPositionMap(template);
291
+ let match;
292
+ EXPRESSION_REGEX.lastIndex = 0;
293
+ while ((match = EXPRESSION_REGEX.exec(template)) !== null) {
294
+ const fullExpression = match[0];
295
+ const prefix = match[1];
296
+ const content = match[2].trim();
297
+ const position = positionMap.get(match.index) ?? { line: 1, column: 1 };
298
+ let type = "variable";
299
+ let helperName;
300
+ if (prefix === "/") {
301
+ type = "block-close";
302
+ helperName = content;
303
+ } else if (prefix === "#") {
304
+ type = "block";
305
+ const parts = content.split(/\s+/);
306
+ helperName = parts[0];
307
+ } else {
308
+ const parts = content.split(/\s+/);
309
+ if (parts.length > 1 && !content.startsWith("(")) {
310
+ const firstToken = parts[0];
311
+ if (!firstToken.includes(".") && !KEYWORDS.has(firstToken)) {
312
+ type = "helper";
313
+ helperName = firstToken;
314
+ }
315
+ }
316
+ }
317
+ const paths = extractPathsFromContent(content);
318
+ for (const path of paths) {
319
+ expressions.push({
320
+ path,
321
+ fullExpression,
322
+ line: position.line,
323
+ column: position.column,
324
+ type,
325
+ helperName
326
+ });
327
+ }
328
+ if (paths.length === 0 && type === "variable") {
329
+ const cleanContent = content.trim();
330
+ if (!KEYWORDS.has(cleanContent) && !cleanContent.includes(" ") && !cleanContent.startsWith("(")) {
331
+ }
332
+ }
333
+ }
334
+ return expressions;
335
+ }
336
+ function extractPathsFromContent(content) {
337
+ const paths = [];
338
+ let match;
339
+ const regex = new RegExp(PATH_REGEX.source, "g");
340
+ while ((match = regex.exec(content)) !== null) {
341
+ paths.push(match[0]);
342
+ }
343
+ return paths;
344
+ }
345
+ function buildPositionMap(template) {
346
+ const map = /* @__PURE__ */ new Map();
347
+ let line = 1;
348
+ let column = 1;
349
+ for (let i = 0; i < template.length; i++) {
350
+ map.set(i, { line, column });
351
+ if (template[i] === "\n") {
352
+ line++;
353
+ column = 1;
354
+ } else {
355
+ column++;
356
+ }
357
+ }
358
+ return map;
359
+ }
360
+ function extractVariablePaths(template) {
361
+ const expressions = extractExpressions(template);
362
+ const paths = new Set(expressions.map((e) => e.path));
363
+ return Array.from(paths);
364
+ }
365
+ function extractOutputPaths(template) {
366
+ return extractVariablePaths(template).filter((p) => p.startsWith("output."));
367
+ }
368
+ function extractInputPaths(template) {
369
+ return extractVariablePaths(template).filter((p) => p.startsWith("input."));
370
+ }
371
+ function extractStructuredContentPaths(template) {
372
+ return extractVariablePaths(template).filter((p) => p.startsWith("structuredContent."));
373
+ }
374
+ function extractAll(template) {
375
+ const expressions = extractExpressions(template);
376
+ const paths = [...new Set(expressions.map((e) => e.path))];
377
+ return {
378
+ expressions,
379
+ paths,
380
+ outputPaths: paths.filter((p) => p.startsWith("output.")),
381
+ inputPaths: paths.filter((p) => p.startsWith("input.")),
382
+ structuredContentPaths: paths.filter((p) => p.startsWith("structuredContent."))
383
+ };
384
+ }
385
+ function hasVariablePaths(template) {
386
+ return extractVariablePaths(template).length > 0;
387
+ }
388
+ function getExpressionAt(template, line, column) {
389
+ const expressions = extractExpressions(template);
390
+ return expressions.find((expr) => {
391
+ if (expr.line !== line) return false;
392
+ const exprEnd = expr.column + expr.fullExpression.length;
393
+ return column >= expr.column && column <= exprEnd;
394
+ });
395
+ }
396
+ function normalizePath(path) {
397
+ return path.replace(/\.\d+\./g, ".[].").replace(/\.\d+$/g, ".[]").replace(/\[\d+\]/g, ".[]");
398
+ }
399
+ var EXPRESSION_REGEX, PATH_REGEX, KEYWORDS;
400
+ var init_expression_extractor = __esm({
401
+ "libs/uipack/src/handlebars/expression-extractor.ts"() {
402
+ "use strict";
403
+ EXPRESSION_REGEX = /\{\{\{?(?!!)(#|\/)?([^}]+?)\}?\}\}/g;
404
+ PATH_REGEX = /\b(output|input|structuredContent)(\.[a-zA-Z_$][a-zA-Z0-9_$]*|\.\[[^\]]+\])+/g;
405
+ KEYWORDS = /* @__PURE__ */ new Set(["this", "else", "@index", "@key", "@first", "@last", "@root"]);
406
+ }
407
+ });
408
+
409
+ // libs/uipack/src/handlebars/index.ts
410
+ var handlebars_exports = {};
411
+ __export(handlebars_exports, {
412
+ HandlebarsRenderer: () => HandlebarsRenderer,
413
+ and: () => and,
414
+ builtinHelpers: () => builtinHelpers,
415
+ capitalize: () => capitalize,
416
+ classNames: () => classNames,
417
+ containsHandlebars: () => containsHandlebars,
418
+ createHandlebarsRenderer: () => createHandlebarsRenderer,
419
+ defaultValue: () => defaultValue,
420
+ eq: () => eq,
421
+ escapeHtml: () => escapeHtml,
422
+ extractAll: () => extractAll,
423
+ extractExpressions: () => extractExpressions,
424
+ extractInputPaths: () => extractInputPaths,
425
+ extractOutputPaths: () => extractOutputPaths,
426
+ extractStructuredContentPaths: () => extractStructuredContentPaths,
427
+ extractVariablePaths: () => extractVariablePaths,
428
+ first: () => first,
429
+ formatCurrency: () => formatCurrency,
430
+ formatDate: () => formatDate,
431
+ formatNumber: () => formatNumber,
432
+ getExpressionAt: () => getExpressionAt,
433
+ gt: () => gt,
434
+ gte: () => gte,
435
+ hasVariablePaths: () => hasVariablePaths,
436
+ includes: () => includes,
437
+ isHandlebarsAvailable: () => isHandlebarsAvailable,
438
+ join: () => join,
439
+ json: () => json,
440
+ jsonEmbed: () => jsonEmbed,
441
+ last: () => last,
442
+ length: () => length,
443
+ lowercase: () => lowercase,
444
+ lt: () => lt,
445
+ lte: () => lte,
446
+ ne: () => ne,
447
+ normalizePath: () => normalizePath,
448
+ not: () => not,
449
+ or: () => or,
450
+ renderTemplate: () => renderTemplate,
451
+ resetUniqueIdCounter: () => resetUniqueIdCounter,
452
+ truncate: () => truncate,
453
+ uniqueId: () => uniqueId,
454
+ uppercase: () => uppercase
455
+ });
456
+ async function loadHandlebars() {
457
+ if (Handlebars !== null) {
458
+ return Handlebars;
459
+ }
460
+ try {
461
+ Handlebars = await import("handlebars");
462
+ return Handlebars;
463
+ } catch {
464
+ throw new Error("Handlebars is required for template rendering. Install it: npm install handlebars");
465
+ }
466
+ }
467
+ async function isHandlebarsAvailable() {
468
+ try {
469
+ await loadHandlebars();
470
+ return true;
471
+ } catch {
472
+ return false;
473
+ }
474
+ }
475
+ function createHandlebarsRenderer(options) {
476
+ return new HandlebarsRenderer(options);
477
+ }
478
+ async function renderTemplate(template, context) {
479
+ const renderer = createHandlebarsRenderer();
480
+ return renderer.render(template, context);
481
+ }
482
+ function containsHandlebars(template) {
483
+ return HandlebarsRenderer.containsHandlebars(template);
484
+ }
485
+ var Handlebars, HandlebarsRenderer;
486
+ var init_handlebars = __esm({
487
+ "libs/uipack/src/handlebars/index.ts"() {
488
+ "use strict";
489
+ init_helpers();
490
+ init_helpers();
491
+ init_expression_extractor();
492
+ Handlebars = null;
493
+ HandlebarsRenderer = class {
494
+ options;
495
+ compiledTemplates = /* @__PURE__ */ new Map();
496
+ initialized = false;
497
+ hbs = null;
498
+ constructor(options = {}) {
499
+ this.options = {
500
+ strict: false,
501
+ autoEscape: true,
502
+ ...options
503
+ };
504
+ }
505
+ /**
506
+ * Initialize the renderer with Handlebars.
507
+ */
508
+ async init() {
509
+ if (this.initialized) return;
510
+ this.hbs = await loadHandlebars();
511
+ for (const [name, helper] of Object.entries(builtinHelpers)) {
512
+ this.hbs.registerHelper(name, helper);
513
+ }
514
+ if (this.options.helpers) {
515
+ for (const [name, helper] of Object.entries(this.options.helpers)) {
516
+ this.hbs.registerHelper(name, helper);
517
+ }
518
+ }
519
+ if (this.options.partials) {
520
+ for (const [name, template] of Object.entries(this.options.partials)) {
521
+ this.hbs.registerPartial(name, template);
522
+ }
523
+ }
524
+ this.initialized = true;
525
+ }
526
+ /**
527
+ * Render a Handlebars template.
528
+ *
529
+ * @param template - Template string
530
+ * @param context - Render context with input/output
531
+ * @returns Rendered HTML string
532
+ */
533
+ async render(template, context) {
534
+ await this.init();
535
+ if (!this.hbs) {
536
+ throw new Error("Handlebars not initialized");
537
+ }
538
+ let compiled = this.compiledTemplates.get(template);
539
+ if (!compiled) {
540
+ compiled = this.hbs.compile(template, {
541
+ strict: this.options.strict,
542
+ noEscape: !this.options.autoEscape
543
+ });
544
+ this.compiledTemplates.set(template, compiled);
545
+ }
546
+ const data = {
547
+ input: context.input ?? {},
548
+ output: context.output ?? {},
549
+ structuredContent: context.structuredContent,
550
+ // Also expose at root level for convenience
551
+ ...context.input,
552
+ ...typeof context.output === "object" && context.output !== null ? context.output : {}
553
+ };
554
+ try {
555
+ return compiled(data);
556
+ } catch (error) {
557
+ throw new Error(`Template rendering failed: ${error instanceof Error ? error.message : String(error)}`);
558
+ }
559
+ }
560
+ /**
561
+ * Render a template synchronously.
562
+ *
563
+ * Note: Requires Handlebars to be pre-loaded. Use `render()` for async loading.
564
+ *
565
+ * @param template - Template string
566
+ * @param context - Render context
567
+ * @returns Rendered HTML string
568
+ */
569
+ renderSync(template, context) {
570
+ if (!this.initialized || !this.hbs) {
571
+ throw new Error("HandlebarsRenderer not initialized. Call render() first or use initSync().");
572
+ }
573
+ let compiled = this.compiledTemplates.get(template);
574
+ if (!compiled) {
575
+ compiled = this.hbs.compile(template, {
576
+ strict: this.options.strict,
577
+ noEscape: !this.options.autoEscape
578
+ });
579
+ this.compiledTemplates.set(template, compiled);
580
+ }
581
+ const data = {
582
+ input: context.input ?? {},
583
+ output: context.output ?? {},
584
+ structuredContent: context.structuredContent,
585
+ ...context.input,
586
+ ...typeof context.output === "object" && context.output !== null ? context.output : {}
587
+ };
588
+ return compiled(data);
589
+ }
590
+ /**
591
+ * Initialize synchronously (for environments where Handlebars is already loaded).
592
+ */
593
+ initSync(handlebars) {
594
+ this.hbs = handlebars;
595
+ for (const [name, helper] of Object.entries(builtinHelpers)) {
596
+ this.hbs.registerHelper(name, helper);
597
+ }
598
+ if (this.options.helpers) {
599
+ for (const [name, helper] of Object.entries(this.options.helpers)) {
600
+ this.hbs.registerHelper(name, helper);
601
+ }
602
+ }
603
+ if (this.options.partials) {
604
+ for (const [name, template] of Object.entries(this.options.partials)) {
605
+ this.hbs.registerPartial(name, template);
606
+ }
607
+ }
608
+ this.initialized = true;
609
+ }
610
+ /**
611
+ * Register a custom helper.
612
+ *
613
+ * @param name - Helper name
614
+ * @param fn - Helper function
615
+ */
616
+ registerHelper(name, fn) {
617
+ if (this.hbs) {
618
+ this.hbs.registerHelper(name, fn);
619
+ }
620
+ if (!this.options.helpers) {
621
+ this.options.helpers = {};
622
+ }
623
+ this.options.helpers[name] = fn;
624
+ }
625
+ /**
626
+ * Register a partial template.
627
+ *
628
+ * @param name - Partial name
629
+ * @param template - Partial template string
630
+ */
631
+ registerPartial(name, template) {
632
+ if (this.hbs) {
633
+ this.hbs.registerPartial(name, template);
634
+ }
635
+ if (!this.options.partials) {
636
+ this.options.partials = {};
637
+ }
638
+ this.options.partials[name] = template;
639
+ }
640
+ /**
641
+ * Clear compiled template cache.
642
+ */
643
+ clearCache() {
644
+ this.compiledTemplates.clear();
645
+ }
646
+ /**
647
+ * Check if a template string contains Handlebars syntax.
648
+ *
649
+ * @param template - Template string to check
650
+ * @returns true if contains {{...}} syntax
651
+ */
652
+ static containsHandlebars(template) {
653
+ return /\{\{(?!!)[\s\S]*?\}\}/.test(template);
654
+ }
655
+ /**
656
+ * Check if the renderer is initialized.
657
+ */
658
+ get isInitialized() {
659
+ return this.initialized;
660
+ }
661
+ };
662
+ }
663
+ });
664
+
665
+ // libs/uipack/src/renderers/index.ts
666
+ var renderers_exports = {};
667
+ __export(renderers_exports, {
668
+ HtmlRenderer: () => HtmlRenderer,
669
+ MdxRenderer: () => MdxRenderer,
670
+ RendererRegistry: () => RendererRegistry,
671
+ TranspileCache: () => TranspileCache,
672
+ buildMdxHydrationScript: () => buildMdxHydrationScript,
673
+ containsJsx: () => containsJsx,
674
+ containsMdxSyntax: () => containsMdxSyntax,
675
+ detectTemplateType: () => detectTemplateType,
676
+ executeTranspiledCode: () => executeTranspiledCode,
677
+ hashCombined: () => hashCombined,
678
+ hashString: () => hashString,
679
+ htmlRenderer: () => htmlRenderer,
680
+ isHash: () => isHash,
681
+ isPlainHtml: () => isPlainHtml,
682
+ isReactComponent: () => isReactComponent,
683
+ isSwcAvailable: () => isSwcAvailable,
684
+ isTemplateBuilderFunction: () => isTemplateBuilderFunction,
685
+ mdxRenderer: () => mdxRenderer,
686
+ renderCache: () => renderCache,
687
+ rendererRegistry: () => rendererRegistry,
688
+ transpileAndExecute: () => transpileAndExecute,
689
+ transpileCache: () => transpileCache,
690
+ transpileJsx: () => transpileJsx
691
+ });
692
+ module.exports = __toCommonJS(renderers_exports);
693
+
694
+ // libs/uipack/src/renderers/utils/hash.ts
695
+ function hashString(source) {
696
+ let hash = 2166136261;
697
+ for (let i = 0; i < source.length; i++) {
698
+ hash ^= source.charCodeAt(i);
699
+ hash = hash * 16777619 >>> 0;
700
+ }
701
+ return hash.toString(36);
702
+ }
703
+ function hashCombined(...values) {
704
+ const combined = values.map((v) => {
705
+ if (typeof v === "string") return v;
706
+ if (v === null) return "null";
707
+ if (v === void 0) return "undefined";
708
+ try {
709
+ return JSON.stringify(v);
710
+ } catch {
711
+ return String(v);
712
+ }
713
+ }).join("|");
714
+ return hashString(combined);
715
+ }
716
+ function isHash(value) {
717
+ return /^[0-9a-z]{5,10}$/i.test(value);
718
+ }
719
+
720
+ // libs/uipack/src/renderers/cache.ts
721
+ var TranspileCache = class {
722
+ cache = /* @__PURE__ */ new Map();
723
+ maxSize;
724
+ ttl;
725
+ /** Cache statistics */
726
+ stats = {
727
+ hits: 0,
728
+ misses: 0,
729
+ evictions: 0
730
+ };
731
+ constructor(options = {}) {
732
+ this.maxSize = options.maxSize ?? 500;
733
+ this.ttl = options.ttl ?? 0;
734
+ }
735
+ /**
736
+ * Get a cached transpile result by source content.
737
+ *
738
+ * @param source - Source code to look up
739
+ * @returns Cached result or undefined if not found/expired
740
+ */
741
+ get(source) {
742
+ const key = hashString(source);
743
+ return this.getByKey(key);
744
+ }
745
+ /**
746
+ * Get a cached transpile result by hash key.
747
+ *
748
+ * @param key - Hash key
749
+ * @returns Cached result or undefined if not found/expired
750
+ */
751
+ getByKey(key) {
752
+ const entry = this.cache.get(key);
753
+ if (!entry) {
754
+ this.stats.misses++;
755
+ return void 0;
756
+ }
757
+ if (this.ttl > 0 && Date.now() - entry.timestamp > this.ttl) {
758
+ this.cache.delete(key);
759
+ this.stats.misses++;
760
+ return void 0;
761
+ }
762
+ this.cache.delete(key);
763
+ entry.accessCount++;
764
+ this.cache.set(key, entry);
765
+ this.stats.hits++;
766
+ return entry.value;
767
+ }
768
+ /**
769
+ * Store a transpile result.
770
+ *
771
+ * @param source - Source code (used to generate key)
772
+ * @param value - Transpile result to cache
773
+ * @returns The hash key used for storage
774
+ */
775
+ set(source, value) {
776
+ const key = hashString(source);
777
+ this.setByKey(key, value);
778
+ return key;
779
+ }
780
+ /**
781
+ * Store a transpile result by hash key.
782
+ *
783
+ * @param key - Hash key
784
+ * @param value - Transpile result to cache
785
+ */
786
+ setByKey(key, value) {
787
+ if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
788
+ const oldestKey = this.cache.keys().next().value;
789
+ if (oldestKey) {
790
+ this.cache.delete(oldestKey);
791
+ this.stats.evictions++;
792
+ }
793
+ }
794
+ this.cache.set(key, {
795
+ value,
796
+ timestamp: Date.now(),
797
+ accessCount: 1
798
+ });
799
+ }
800
+ /**
801
+ * Check if a source is cached.
802
+ *
803
+ * @param source - Source code to check
804
+ * @returns True if cached and not expired
805
+ */
806
+ has(source) {
807
+ const key = hashString(source);
808
+ return this.hasByKey(key);
809
+ }
810
+ /**
811
+ * Check if a key is cached.
812
+ *
813
+ * @param key - Hash key to check
814
+ * @returns True if cached and not expired
815
+ */
816
+ hasByKey(key) {
817
+ const entry = this.cache.get(key);
818
+ if (!entry) return false;
819
+ if (this.ttl > 0 && Date.now() - entry.timestamp > this.ttl) {
820
+ this.cache.delete(key);
821
+ return false;
822
+ }
823
+ return true;
824
+ }
825
+ /**
826
+ * Delete a cached entry by source.
827
+ *
828
+ * @param source - Source code to delete
829
+ * @returns True if entry was deleted
830
+ */
831
+ delete(source) {
832
+ const key = hashString(source);
833
+ return this.cache.delete(key);
834
+ }
835
+ /**
836
+ * Clear all cached entries.
837
+ */
838
+ clear() {
839
+ this.cache.clear();
840
+ this.stats = { hits: 0, misses: 0, evictions: 0 };
841
+ }
842
+ /**
843
+ * Get current cache size.
844
+ */
845
+ get size() {
846
+ return this.cache.size;
847
+ }
848
+ /**
849
+ * Get cache statistics.
850
+ */
851
+ getStats() {
852
+ const total = this.stats.hits + this.stats.misses;
853
+ return {
854
+ ...this.stats,
855
+ size: this.cache.size,
856
+ hitRate: total > 0 ? this.stats.hits / total : 0
857
+ };
858
+ }
859
+ };
860
+ var transpileCache = new TranspileCache({ maxSize: 500 });
861
+ var renderCache = new TranspileCache({
862
+ maxSize: 1e3,
863
+ ttl: 5 * 60 * 1e3
864
+ // 5 minutes
865
+ });
866
+ var ComponentCache = class {
867
+ cache = /* @__PURE__ */ new Map();
868
+ maxSize;
869
+ constructor(maxSize = 200) {
870
+ this.maxSize = maxSize;
871
+ }
872
+ get(key) {
873
+ const entry = this.cache.get(key);
874
+ if (!entry) return void 0;
875
+ this.cache.delete(key);
876
+ this.cache.set(key, entry);
877
+ return entry.value;
878
+ }
879
+ set(key, value) {
880
+ if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
881
+ const oldestKey = this.cache.keys().next().value;
882
+ if (oldestKey) {
883
+ this.cache.delete(oldestKey);
884
+ }
885
+ }
886
+ this.cache.set(key, { value, timestamp: Date.now() });
887
+ }
888
+ has(key) {
889
+ return this.cache.has(key);
890
+ }
891
+ delete(key) {
892
+ return this.cache.delete(key);
893
+ }
894
+ clear() {
895
+ this.cache.clear();
896
+ }
897
+ get size() {
898
+ return this.cache.size;
899
+ }
900
+ };
901
+ var componentCache = new ComponentCache();
902
+
903
+ // libs/uipack/src/theme/platforms.ts
904
+ var OPENAI_PLATFORM = {
905
+ id: "openai",
906
+ name: "OpenAI",
907
+ supportsWidgets: true,
908
+ supportsTailwind: true,
909
+ supportsHtmx: true,
910
+ networkMode: "full",
911
+ scriptStrategy: "cdn",
912
+ options: {
913
+ sdk: "apps-sdk",
914
+ version: "1.0"
915
+ }
916
+ };
917
+ var CLAUDE_PLATFORM = {
918
+ id: "claude",
919
+ name: "Claude (Artifacts)",
920
+ supportsWidgets: true,
921
+ supportsTailwind: true,
922
+ supportsHtmx: false,
923
+ // Network blocked, HTMX won't work for API calls
924
+ networkMode: "blocked",
925
+ scriptStrategy: "inline",
926
+ maxInlineSize: 100 * 1024,
927
+ // 100KB limit for artifacts
928
+ cspRestrictions: ["script-src 'unsafe-inline'", "connect-src 'none'"],
929
+ options: {
930
+ mode: "artifacts",
931
+ framework: "react"
932
+ // Claude artifacts prefer React
933
+ }
934
+ };
935
+
936
+ // libs/uipack/src/renderers/utils/detect.ts
937
+ function isReactComponent(value) {
938
+ if (typeof value !== "function") {
939
+ return false;
940
+ }
941
+ const fn = value;
942
+ const typeofSymbol = fn.$$typeof;
943
+ if (typeofSymbol) {
944
+ const symbolString = typeofSymbol.toString();
945
+ return symbolString.includes("react.memo") || symbolString.includes("react.forward_ref") || symbolString.includes("react.lazy");
946
+ }
947
+ if (fn.prototype?.isReactComponent) {
948
+ return true;
949
+ }
950
+ if (fn.name && /^[A-Z]/.test(fn.name)) {
951
+ return true;
952
+ }
953
+ return false;
954
+ }
955
+ function isTemplateBuilderFunction(fn) {
956
+ if (isReactComponent(fn)) {
957
+ return false;
958
+ }
959
+ if (fn.name && /^[A-Z]/.test(fn.name)) {
960
+ return false;
961
+ }
962
+ return true;
963
+ }
964
+ function containsJsx(source) {
965
+ if (/<[A-Z][a-zA-Z0-9]*(\s|>|\/)/.test(source)) {
966
+ return true;
967
+ }
968
+ if (/<[A-Z][a-zA-Z0-9]*[^>]*\/>/.test(source)) {
969
+ return true;
970
+ }
971
+ if (/<[a-z]+[^>]*\{[^}]+\}/.test(source)) {
972
+ return true;
973
+ }
974
+ if (/\s(className|onClick|onChange|onSubmit|htmlFor)=/.test(source)) {
975
+ return true;
976
+ }
977
+ if (/<>|<\/>|<React\.Fragment>/.test(source)) {
978
+ return true;
979
+ }
980
+ if (/=>\s*\(?\s*</.test(source)) {
981
+ return true;
982
+ }
983
+ if (/return\s*\(?\s*</.test(source)) {
984
+ return true;
985
+ }
986
+ return false;
987
+ }
988
+ function containsMdxSyntax(source) {
989
+ if (/<[A-Z][a-zA-Z0-9]*/.test(source)) {
990
+ return true;
991
+ }
992
+ if (/^(import|export)\s/m.test(source)) {
993
+ return true;
994
+ }
995
+ if (/\s(className|onClick|onChange|onSubmit|htmlFor|dangerouslySetInnerHTML)=/.test(source)) {
996
+ return true;
997
+ }
998
+ if (/\{[^}"'\n]*\}/.test(source) && !/=\s*["'][^"']*\{/.test(source)) {
999
+ return true;
1000
+ }
1001
+ if (/^---[\s\S]*?---/m.test(source)) {
1002
+ return true;
1003
+ }
1004
+ if (/<>|<\/>/.test(source)) {
1005
+ return true;
1006
+ }
1007
+ return false;
1008
+ }
1009
+ function isPlainHtml(source) {
1010
+ return !containsJsx(source) && !containsMdxSyntax(source);
1011
+ }
1012
+ function detectTemplateType(template) {
1013
+ if (typeof template === "function") {
1014
+ if (isReactComponent(template)) {
1015
+ return {
1016
+ type: "react",
1017
+ confidence: 0.9,
1018
+ reason: "Function detected as React component (PascalCase name or React symbols)"
1019
+ };
1020
+ }
1021
+ return {
1022
+ type: "html-function",
1023
+ confidence: 0.8,
1024
+ reason: "Function assumed to be HTML template builder"
1025
+ };
1026
+ }
1027
+ if (typeof template === "string") {
1028
+ if (containsMdxSyntax(template)) {
1029
+ const hasMarkdown = /^#{1,6}\s|^\*\s|^\d+\.\s|^-\s/m.test(template);
1030
+ if (hasMarkdown) {
1031
+ return {
1032
+ type: "mdx",
1033
+ confidence: 0.9,
1034
+ reason: "String contains Markdown with JSX components"
1035
+ };
1036
+ }
1037
+ return {
1038
+ type: "jsx-string",
1039
+ confidence: 0.8,
1040
+ reason: "String contains JSX syntax"
1041
+ };
1042
+ }
1043
+ if (containsJsx(template)) {
1044
+ return {
1045
+ type: "jsx-string",
1046
+ confidence: 0.85,
1047
+ reason: "String contains JSX component tags or expressions"
1048
+ };
1049
+ }
1050
+ return {
1051
+ type: "html-string",
1052
+ confidence: 1,
1053
+ reason: "Plain HTML string"
1054
+ };
1055
+ }
1056
+ return {
1057
+ type: "html-string",
1058
+ confidence: 0.5,
1059
+ reason: "Unknown template type, defaulting to HTML"
1060
+ };
1061
+ }
1062
+
1063
+ // libs/uipack/src/renderers/html.renderer.ts
1064
+ var handlebarsRenderer = null;
1065
+ async function loadHandlebarsRenderer() {
1066
+ if (handlebarsRenderer !== null) {
1067
+ return handlebarsRenderer;
1068
+ }
1069
+ try {
1070
+ const handlebarsModule = await Promise.resolve().then(() => (init_handlebars(), handlebars_exports));
1071
+ const { HandlebarsRenderer: HandlebarsRenderer2 } = handlebarsModule;
1072
+ const renderer = new HandlebarsRenderer2();
1073
+ handlebarsRenderer = {
1074
+ render: (template, context) => renderer.render(template, {
1075
+ input: context.input ?? {},
1076
+ output: context.output,
1077
+ structuredContent: context.structuredContent
1078
+ }),
1079
+ containsHandlebars: (template) => HandlebarsRenderer2.containsHandlebars(template)
1080
+ };
1081
+ return handlebarsRenderer;
1082
+ } catch {
1083
+ return null;
1084
+ }
1085
+ }
1086
+ function containsHandlebars2(template) {
1087
+ return /\{\{(?!!)[\s\S]*?\}\}/.test(template);
1088
+ }
1089
+ var HtmlRenderer = class {
1090
+ type = "html";
1091
+ priority = 0;
1092
+ // Lowest priority - fallback renderer
1093
+ /**
1094
+ * Check if this renderer can handle the given template.
1095
+ *
1096
+ * Accepts:
1097
+ * - Any string (assumed to be HTML, with or without Handlebars)
1098
+ * - Functions that are template builders (not React components)
1099
+ */
1100
+ canHandle(template) {
1101
+ if (typeof template === "string") {
1102
+ return true;
1103
+ }
1104
+ if (typeof template === "function") {
1105
+ return isTemplateBuilderFunction(template);
1106
+ }
1107
+ return false;
1108
+ }
1109
+ /**
1110
+ * Check if a template uses Handlebars syntax.
1111
+ *
1112
+ * @param template - Template string to check
1113
+ * @returns true if template contains {{...}} syntax
1114
+ */
1115
+ usesHandlebars(template) {
1116
+ return containsHandlebars2(template);
1117
+ }
1118
+ /**
1119
+ * Transpile the template.
1120
+ *
1121
+ * For HTML templates, no transpilation is needed.
1122
+ * This method returns a dummy result for consistency.
1123
+ */
1124
+ async transpile(template, _options) {
1125
+ const source = typeof template === "string" ? template : template.toString();
1126
+ const hash = hashString(source);
1127
+ return {
1128
+ code: "",
1129
+ // No transpiled code needed
1130
+ hash,
1131
+ cached: true
1132
+ // Always "cached" since no work is done
1133
+ };
1134
+ }
1135
+ /**
1136
+ * Render the template to HTML string.
1137
+ *
1138
+ * For static strings without Handlebars, returns the string directly.
1139
+ * For strings with Handlebars syntax, processes with HandlebarsRenderer.
1140
+ * For functions, calls the function with the context.
1141
+ */
1142
+ async render(template, context, _options) {
1143
+ if (typeof template === "string") {
1144
+ if (containsHandlebars2(template)) {
1145
+ return this.renderHandlebars(template, context);
1146
+ }
1147
+ return template;
1148
+ }
1149
+ if (typeof template === "function") {
1150
+ const result = template(context);
1151
+ if (typeof result === "string" && containsHandlebars2(result)) {
1152
+ return this.renderHandlebars(result, context);
1153
+ }
1154
+ return result;
1155
+ }
1156
+ return String(template);
1157
+ }
1158
+ /**
1159
+ * Render Handlebars template with context.
1160
+ */
1161
+ async renderHandlebars(template, context) {
1162
+ const renderer = await loadHandlebarsRenderer();
1163
+ if (!renderer) {
1164
+ console.warn(
1165
+ "[@frontmcp/ui] Template contains Handlebars syntax but handlebars is not installed. Install it for template interpolation: npm install handlebars"
1166
+ );
1167
+ return template;
1168
+ }
1169
+ return renderer.render(template, {
1170
+ input: context.input,
1171
+ output: context.output,
1172
+ structuredContent: context.structuredContent
1173
+ });
1174
+ }
1175
+ /**
1176
+ * Get runtime scripts for client-side functionality.
1177
+ *
1178
+ * HTML templates don't need additional runtime scripts.
1179
+ */
1180
+ getRuntimeScripts(_platform) {
1181
+ return {
1182
+ headScripts: "",
1183
+ isInline: false
1184
+ };
1185
+ }
1186
+ };
1187
+ var htmlRenderer = new HtmlRenderer();
1188
+
1189
+ // libs/uipack/src/renderers/registry.ts
1190
+ var RendererRegistry = class {
1191
+ renderers = /* @__PURE__ */ new Map();
1192
+ sortedRenderers = [];
1193
+ defaultRenderer = "html";
1194
+ debug;
1195
+ constructor(options = {}) {
1196
+ this.debug = options.debug ?? false;
1197
+ this.register(htmlRenderer);
1198
+ }
1199
+ /**
1200
+ * Register a renderer.
1201
+ *
1202
+ * Renderers are sorted by priority (highest first) for detection.
1203
+ *
1204
+ * @param renderer - Renderer to register
1205
+ */
1206
+ register(renderer) {
1207
+ this.renderers.set(renderer.type, renderer);
1208
+ this.updateSortedList();
1209
+ if (this.debug) {
1210
+ console.log(`[RendererRegistry] Registered renderer: ${renderer.type} (priority: ${renderer.priority})`);
1211
+ }
1212
+ }
1213
+ /**
1214
+ * Unregister a renderer.
1215
+ *
1216
+ * @param type - Type of renderer to remove
1217
+ * @returns True if renderer was removed
1218
+ */
1219
+ unregister(type) {
1220
+ const removed = this.renderers.delete(type);
1221
+ if (removed) {
1222
+ this.updateSortedList();
1223
+ }
1224
+ return removed;
1225
+ }
1226
+ /**
1227
+ * Get a renderer by type.
1228
+ *
1229
+ * @param type - Renderer type
1230
+ * @returns Renderer or undefined if not found
1231
+ */
1232
+ get(type) {
1233
+ return this.renderers.get(type);
1234
+ }
1235
+ /**
1236
+ * Check if a renderer type is registered.
1237
+ *
1238
+ * @param type - Renderer type
1239
+ * @returns True if registered
1240
+ */
1241
+ has(type) {
1242
+ return this.renderers.has(type);
1243
+ }
1244
+ /**
1245
+ * Get all registered renderer types.
1246
+ *
1247
+ * @returns Array of renderer types
1248
+ */
1249
+ getTypes() {
1250
+ return Array.from(this.renderers.keys());
1251
+ }
1252
+ /**
1253
+ * Auto-detect the renderer for a template.
1254
+ *
1255
+ * Checks renderers in priority order (highest first).
1256
+ * Returns HTML renderer as fallback.
1257
+ *
1258
+ * @param template - Template to detect
1259
+ * @returns Detection result with renderer and confidence
1260
+ */
1261
+ detect(template) {
1262
+ for (const renderer of this.sortedRenderers) {
1263
+ if (renderer.canHandle(template)) {
1264
+ const result = {
1265
+ renderer,
1266
+ confidence: renderer.priority / 100,
1267
+ // Normalize to 0-1
1268
+ reason: `Matched by ${renderer.type} renderer`
1269
+ };
1270
+ if (this.debug) {
1271
+ console.log(`[RendererRegistry] Detected template as ${renderer.type} (confidence: ${result.confidence})`);
1272
+ }
1273
+ return result;
1274
+ }
1275
+ }
1276
+ const fallback = this.renderers.get(this.defaultRenderer);
1277
+ if (!fallback) {
1278
+ throw new Error(`Default renderer '${this.defaultRenderer}' not found`);
1279
+ }
1280
+ return {
1281
+ renderer: fallback,
1282
+ confidence: 0.5,
1283
+ reason: "Fallback to default HTML renderer"
1284
+ };
1285
+ }
1286
+ /**
1287
+ * Render a template with auto-detection.
1288
+ *
1289
+ * @param template - Template to render (React, MDX, or HTML)
1290
+ * @param context - Template context with input/output
1291
+ * @param options - Render options
1292
+ * @returns Rendered result with HTML and metadata
1293
+ */
1294
+ async render(template, context, options = {}) {
1295
+ const platform = options.platform ?? OPENAI_PLATFORM;
1296
+ const detection = this.detect(template);
1297
+ const renderer = detection.renderer;
1298
+ if (this.debug) {
1299
+ console.log(`[RendererRegistry] Rendering with ${renderer.type} renderer`);
1300
+ }
1301
+ const transpileResult = await renderer.transpile(template);
1302
+ const html = await renderer.render(template, context, options);
1303
+ const runtimeScripts = renderer.getRuntimeScripts(platform);
1304
+ return {
1305
+ html,
1306
+ rendererType: renderer.type,
1307
+ transpileCached: transpileResult.cached,
1308
+ runtimeScripts
1309
+ };
1310
+ }
1311
+ /**
1312
+ * Render with a specific renderer type.
1313
+ *
1314
+ * @param type - Renderer type to use
1315
+ * @param template - Template to render
1316
+ * @param context - Template context
1317
+ * @param options - Render options
1318
+ * @returns Rendered result
1319
+ */
1320
+ async renderWith(type, template, context, options = {}) {
1321
+ const renderer = this.renderers.get(type);
1322
+ if (!renderer) {
1323
+ throw new Error(`Renderer '${type}' not registered`);
1324
+ }
1325
+ const platform = options.platform ?? OPENAI_PLATFORM;
1326
+ const transpileResult = await renderer.transpile(template);
1327
+ const html = await renderer.render(template, context, options);
1328
+ const runtimeScripts = renderer.getRuntimeScripts(platform);
1329
+ return {
1330
+ html,
1331
+ rendererType: type,
1332
+ transpileCached: transpileResult.cached,
1333
+ runtimeScripts
1334
+ };
1335
+ }
1336
+ /**
1337
+ * Update the sorted renderer list by priority.
1338
+ */
1339
+ updateSortedList() {
1340
+ this.sortedRenderers = Array.from(this.renderers.values()).sort((a, b) => b.priority - a.priority);
1341
+ }
1342
+ /**
1343
+ * Set the default renderer type.
1344
+ *
1345
+ * @param type - Renderer type to use as default
1346
+ */
1347
+ setDefault(type) {
1348
+ if (!this.renderers.has(type)) {
1349
+ throw new Error(`Cannot set default to unregistered renderer '${type}'`);
1350
+ }
1351
+ this.defaultRenderer = type;
1352
+ }
1353
+ /**
1354
+ * Get registry statistics.
1355
+ */
1356
+ getStats() {
1357
+ return {
1358
+ registeredRenderers: this.getTypes(),
1359
+ defaultRenderer: this.defaultRenderer,
1360
+ priorityOrder: this.sortedRenderers.map((r) => ({
1361
+ type: r.type,
1362
+ priority: r.priority
1363
+ }))
1364
+ };
1365
+ }
1366
+ };
1367
+ var rendererRegistry = new RendererRegistry();
1368
+
1369
+ // libs/uipack/src/renderers/mdx.renderer.ts
1370
+ var REACT_CDN = {
1371
+ react: "https://unpkg.com/react@18/umd/react.production.min.js",
1372
+ reactDom: "https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"
1373
+ };
1374
+ var INLINE_MDX_PLACEHOLDER = `
1375
+ // MDX runtime not available inline yet.
1376
+ // For blocked-network platforms, use pre-rendered HTML templates.
1377
+ console.warn('[FrontMCP] MDX hydration not available on this platform.');
1378
+ `;
1379
+ var MdxRenderer = class {
1380
+ type = "mdx";
1381
+ priority = 10;
1382
+ // Between HTML (0) and React (20)
1383
+ /**
1384
+ * Lazy-loaded modules.
1385
+ */
1386
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1387
+ React = null;
1388
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1389
+ ReactDOMServer = null;
1390
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1391
+ jsxRuntime = null;
1392
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1393
+ mdxEvaluate = null;
1394
+ /**
1395
+ * Check if this renderer can handle the given template.
1396
+ *
1397
+ * Accepts strings containing MDX syntax (Markdown + JSX).
1398
+ */
1399
+ canHandle(template) {
1400
+ if (typeof template !== "string") {
1401
+ return false;
1402
+ }
1403
+ return containsMdxSyntax(template);
1404
+ }
1405
+ /**
1406
+ * Transpile MDX to executable JavaScript.
1407
+ *
1408
+ * Uses @mdx-js/mdx to compile MDX source to a module.
1409
+ * Note: For MDX, we use evaluate() which combines compile + run,
1410
+ * so this method just returns the source hash for caching purposes.
1411
+ */
1412
+ async transpile(template, _options) {
1413
+ const hash = hashString(template);
1414
+ const cached = transpileCache.getByKey(hash);
1415
+ if (cached) {
1416
+ return { ...cached, cached: true };
1417
+ }
1418
+ const transpileResult = {
1419
+ code: template,
1420
+ // Store original MDX for evaluate()
1421
+ hash,
1422
+ cached: false
1423
+ };
1424
+ transpileCache.setByKey(hash, transpileResult);
1425
+ return transpileResult;
1426
+ }
1427
+ /**
1428
+ * Render MDX template to HTML string.
1429
+ *
1430
+ * Uses @mdx-js/mdx's evaluate() for clean compilation + execution,
1431
+ * then renders the resulting React component to HTML via SSR.
1432
+ */
1433
+ async render(template, context, options) {
1434
+ await this.loadReact();
1435
+ await this.loadMdx();
1436
+ if (!this.mdxEvaluate) {
1437
+ throw new Error("MDX compilation requires @mdx-js/mdx. Install it: npm install @mdx-js/mdx");
1438
+ }
1439
+ const templateHash = hashString(template);
1440
+ const cacheKey = `mdx-component:${templateHash}`;
1441
+ let Content = componentCache.get(cacheKey);
1442
+ if (!Content) {
1443
+ const result = await this.mdxEvaluate(template, {
1444
+ ...this.jsxRuntime,
1445
+ Fragment: this.React.Fragment,
1446
+ development: false
1447
+ });
1448
+ Content = result.default;
1449
+ componentCache.set(cacheKey, Content);
1450
+ }
1451
+ const mdxComponents = {
1452
+ // User-provided components from tool config
1453
+ ...options?.mdxComponents,
1454
+ // Wrapper that provides context to the content
1455
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1456
+ wrapper: ({ children }) => {
1457
+ return this.React.createElement("div", { className: "mdx-content" }, children);
1458
+ }
1459
+ };
1460
+ const props = {
1461
+ input: context.input,
1462
+ output: context.output,
1463
+ structuredContent: context.structuredContent,
1464
+ helpers: context.helpers
1465
+ };
1466
+ const spreadProps = {
1467
+ ...props,
1468
+ ...typeof context.output === "object" && context.output !== null ? context.output : {}
1469
+ };
1470
+ const element = this.React.createElement(Content, {
1471
+ components: mdxComponents,
1472
+ ...spreadProps
1473
+ });
1474
+ const html = this.ReactDOMServer.renderToString(element);
1475
+ if (options?.hydrate) {
1476
+ const escapedProps = JSON.stringify(props).replace(/&/g, "&amp;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1477
+ return `<div data-mdx-hydrate="true" data-props='${escapedProps}'>${html}</div>`;
1478
+ }
1479
+ return html;
1480
+ }
1481
+ /**
1482
+ * Get runtime scripts for client-side functionality.
1483
+ */
1484
+ getRuntimeScripts(platform) {
1485
+ if (platform.networkMode === "blocked") {
1486
+ return {
1487
+ headScripts: "",
1488
+ inlineScripts: INLINE_MDX_PLACEHOLDER,
1489
+ isInline: true
1490
+ };
1491
+ }
1492
+ return {
1493
+ headScripts: `
1494
+ <script crossorigin src="${REACT_CDN.react}"></script>
1495
+ <script crossorigin src="${REACT_CDN.reactDom}"></script>
1496
+ `,
1497
+ isInline: false
1498
+ };
1499
+ }
1500
+ /**
1501
+ * Load React and ReactDOMServer modules.
1502
+ */
1503
+ async loadReact() {
1504
+ if (this.React && this.ReactDOMServer && this.jsxRuntime) {
1505
+ return;
1506
+ }
1507
+ try {
1508
+ const [react, reactDomServer, jsxRuntime] = await Promise.all([
1509
+ import("react"),
1510
+ import("react-dom/server"),
1511
+ import("react/jsx-runtime")
1512
+ ]);
1513
+ this.React = react;
1514
+ this.ReactDOMServer = reactDomServer;
1515
+ this.jsxRuntime = jsxRuntime;
1516
+ } catch {
1517
+ throw new Error("React is required for MdxRenderer. Install react and react-dom: npm install react react-dom");
1518
+ }
1519
+ }
1520
+ /**
1521
+ * Load @mdx-js/mdx evaluate function.
1522
+ *
1523
+ * evaluate() is the cleanest way to run MDX - it combines
1524
+ * compile and run in a single step, handling all the runtime
1525
+ * injection automatically.
1526
+ */
1527
+ async loadMdx() {
1528
+ if (this.mdxEvaluate) {
1529
+ return;
1530
+ }
1531
+ try {
1532
+ const mdx = await import("@mdx-js/mdx");
1533
+ this.mdxEvaluate = mdx.evaluate;
1534
+ } catch {
1535
+ console.warn(
1536
+ "[@frontmcp/ui] @mdx-js/mdx not available. MDX rendering disabled. Install @mdx-js/mdx to enable: npm install @mdx-js/mdx"
1537
+ );
1538
+ }
1539
+ }
1540
+ };
1541
+ var mdxRenderer = new MdxRenderer();
1542
+ function buildMdxHydrationScript() {
1543
+ return `
1544
+ <script>
1545
+ (function() {
1546
+ // MDX hydration requires React and component definitions
1547
+ if (typeof React === 'undefined' || typeof ReactDOM === 'undefined') {
1548
+ console.warn('[FrontMCP] React not available for MDX hydration');
1549
+ return;
1550
+ }
1551
+
1552
+ // Find all elements marked for MDX hydration
1553
+ document.querySelectorAll('[data-mdx-hydrate]').forEach(function(root) {
1554
+ var propsJson = root.getAttribute('data-props');
1555
+ var props = propsJson ? JSON.parse(propsJson) : {};
1556
+
1557
+ // MDX content is pre-rendered, hydration mainly attaches event handlers
1558
+ // For full interactivity, components need to be available client-side
1559
+ if (window.__frontmcp_mdx_content) {
1560
+ try {
1561
+ ReactDOM.hydrateRoot(root, React.createElement(
1562
+ window.__frontmcp_mdx_content,
1563
+ props
1564
+ ));
1565
+ } catch (e) {
1566
+ console.error('[FrontMCP] MDX hydration failed', e);
1567
+ }
1568
+ }
1569
+ });
1570
+ })();
1571
+ </script>
1572
+ `;
1573
+ }
1574
+
1575
+ // libs/uipack/src/renderers/utils/transpiler.ts
1576
+ var DEFAULT_SWC_OPTIONS = {
1577
+ typescript: true,
1578
+ jsx: true,
1579
+ jsxRuntime: "automatic",
1580
+ development: false
1581
+ };
1582
+ var swcTransform = null;
1583
+ async function loadSwcTransform() {
1584
+ if (swcTransform !== null) {
1585
+ return swcTransform;
1586
+ }
1587
+ try {
1588
+ const swc = await import("@swc/core");
1589
+ swcTransform = swc.transform;
1590
+ return swcTransform;
1591
+ } catch {
1592
+ console.warn(
1593
+ "[@frontmcp/ui] @swc/core not available. Runtime JSX transpilation disabled. Install @swc/core to enable: npm install @swc/core"
1594
+ );
1595
+ return null;
1596
+ }
1597
+ }
1598
+ async function transpileJsx(source, options = {}) {
1599
+ const hash = hashString(source);
1600
+ const cached = transpileCache.getByKey(hash);
1601
+ if (cached) {
1602
+ return { ...cached, cached: true };
1603
+ }
1604
+ const transform = await loadSwcTransform();
1605
+ if (!transform) {
1606
+ throw new Error(
1607
+ "Runtime JSX transpilation requires @swc/core. Either install @swc/core or use pre-compiled React components."
1608
+ );
1609
+ }
1610
+ const opts = { ...DEFAULT_SWC_OPTIONS, ...options };
1611
+ const swcOptions = {
1612
+ jsc: {
1613
+ parser: {
1614
+ syntax: opts.typescript ? "typescript" : "ecmascript",
1615
+ tsx: opts.jsx,
1616
+ jsx: opts.jsx
1617
+ },
1618
+ transform: {
1619
+ react: {
1620
+ runtime: opts.jsxRuntime,
1621
+ development: opts.development
1622
+ }
1623
+ },
1624
+ target: "es2020"
1625
+ },
1626
+ module: {
1627
+ type: "commonjs"
1628
+ }
1629
+ };
1630
+ const result = await transform(source, swcOptions);
1631
+ const transpileResult = {
1632
+ code: result.code,
1633
+ hash,
1634
+ cached: false
1635
+ };
1636
+ transpileCache.setByKey(hash, transpileResult);
1637
+ return transpileResult;
1638
+ }
1639
+ async function isSwcAvailable() {
1640
+ const transform = await loadSwcTransform();
1641
+ return transform !== null;
1642
+ }
1643
+ async function executeTranspiledCode(code, context = {}) {
1644
+ let React;
1645
+ let jsxRuntime;
1646
+ try {
1647
+ React = await import("react");
1648
+ jsxRuntime = await import("react/jsx-runtime");
1649
+ } catch {
1650
+ throw new Error("React is required for JSX templates. Install react: npm install react react-dom");
1651
+ }
1652
+ const exports2 = {};
1653
+ const module2 = { exports: exports2 };
1654
+ const require2 = (id) => {
1655
+ switch (id) {
1656
+ case "react":
1657
+ return React;
1658
+ case "react/jsx-runtime":
1659
+ return jsxRuntime;
1660
+ case "react/jsx-dev-runtime":
1661
+ return jsxRuntime;
1662
+ default:
1663
+ if (context[id]) {
1664
+ return context[id];
1665
+ }
1666
+ throw new Error(`Module '${id}' not available in JSX template context`);
1667
+ }
1668
+ };
1669
+ try {
1670
+ const fn = new Function("exports", "require", "module", "__filename", "__dirname", "React", "context", code);
1671
+ fn(exports2, require2, module2, "template.js", "/", React, context);
1672
+ return module2.exports["default"] || module2.exports[Object.keys(module2.exports)[0]] || module2.exports;
1673
+ } catch (error) {
1674
+ throw new Error(`Failed to execute transpiled JSX: ${error instanceof Error ? error.message : String(error)}`);
1675
+ }
1676
+ }
1677
+ async function transpileAndExecute(source, context = {}) {
1678
+ const result = await transpileJsx(source);
1679
+ return executeTranspiledCode(result.code, context);
1680
+ }
1681
+ // Annotate the CommonJS export names for ESM import in node:
1682
+ 0 && (module.exports = {
1683
+ HtmlRenderer,
1684
+ MdxRenderer,
1685
+ RendererRegistry,
1686
+ TranspileCache,
1687
+ buildMdxHydrationScript,
1688
+ containsJsx,
1689
+ containsMdxSyntax,
1690
+ detectTemplateType,
1691
+ executeTranspiledCode,
1692
+ hashCombined,
1693
+ hashString,
1694
+ htmlRenderer,
1695
+ isHash,
1696
+ isPlainHtml,
1697
+ isReactComponent,
1698
+ isSwcAvailable,
1699
+ isTemplateBuilderFunction,
1700
+ mdxRenderer,
1701
+ renderCache,
1702
+ rendererRegistry,
1703
+ transpileAndExecute,
1704
+ transpileCache,
1705
+ transpileJsx
1706
+ });