@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,3096 @@
1
+ // libs/uipack/src/dependency/types.ts
2
+ function detectTemplateMode(template) {
3
+ if (typeof template === "function") {
4
+ return "inline-function";
5
+ }
6
+ if (typeof template === "string") {
7
+ if (template.startsWith("http://") || template.startsWith("https://")) {
8
+ return "url";
9
+ }
10
+ const looksLikeFilePath = (
11
+ // Relative paths
12
+ template.startsWith("./") || template.startsWith("../") || // Absolute paths (Unix)
13
+ template.startsWith("/") || // Windows-style paths (C:\, D:\, etc.)
14
+ /^[A-Za-z]:\\/.test(template) || // File extensions (must not contain spaces to avoid false positives)
15
+ /\.(tsx?|jsx?|mdx?)$/i.test(template) && !template.includes(" ")
16
+ );
17
+ if (looksLikeFilePath && template.length < 500 && !template.includes("\n") && !template.includes("<")) {
18
+ return "file-path";
19
+ }
20
+ }
21
+ return "inline-string";
22
+ }
23
+ function detectFormatFromPath(pathOrUrl) {
24
+ const lower = pathOrUrl.toLowerCase();
25
+ if (lower.endsWith(".tsx") || lower.endsWith(".jsx")) {
26
+ return "react";
27
+ }
28
+ if (lower.endsWith(".mdx")) {
29
+ return "mdx";
30
+ }
31
+ if (lower.endsWith(".md")) {
32
+ return "markdown";
33
+ }
34
+ return "html";
35
+ }
36
+
37
+ // libs/uipack/src/dependency/schemas.ts
38
+ import { z } from "zod";
39
+ var cdnProviderSchema = z.enum(["cloudflare", "jsdelivr", "unpkg", "esm.sh", "skypack"]);
40
+ var cdnPlatformTypeSchema = z.enum(["claude", "openai", "cursor", "gemini", "continue", "cody", "unknown"]);
41
+ var cdnDependencySchema = z.object({
42
+ /**
43
+ * CDN URL (must be HTTPS).
44
+ */
45
+ url: z.string().url().refine((url) => url.startsWith("https://"), {
46
+ message: "CDN URLs must use HTTPS"
47
+ }),
48
+ /**
49
+ * SRI integrity hash.
50
+ */
51
+ integrity: z.string().regex(/^sha(256|384|512)-[A-Za-z0-9+/=]+$/, {
52
+ message: "Invalid SRI hash format. Must be sha256-, sha384-, or sha512- followed by base64"
53
+ }).optional(),
54
+ /**
55
+ * Global variable name for UMD builds.
56
+ */
57
+ global: z.string().min(1).optional(),
58
+ /**
59
+ * Named exports from the library.
60
+ */
61
+ exports: z.array(z.string().min(1)).optional(),
62
+ /**
63
+ * Whether this is an ES module.
64
+ */
65
+ esm: z.boolean().optional(),
66
+ /**
67
+ * Cross-origin attribute.
68
+ */
69
+ crossorigin: z.enum(["anonymous", "use-credentials"]).optional(),
70
+ /**
71
+ * Peer dependencies (npm package names).
72
+ */
73
+ peerDependencies: z.array(z.string().min(1)).optional()
74
+ }).strict();
75
+ var bundleTargetSchema = z.enum(["es2018", "es2019", "es2020", "es2021", "es2022", "esnext"]);
76
+ var fileBundleOptionsSchema = z.object({
77
+ /**
78
+ * Minify output.
79
+ */
80
+ minify: z.boolean().optional(),
81
+ /**
82
+ * Generate source maps.
83
+ */
84
+ sourceMaps: z.boolean().optional(),
85
+ /**
86
+ * Target JavaScript version.
87
+ */
88
+ target: bundleTargetSchema.optional(),
89
+ /**
90
+ * Enable tree shaking.
91
+ */
92
+ treeShake: z.boolean().optional(),
93
+ /**
94
+ * JSX factory function.
95
+ */
96
+ jsxFactory: z.string().min(1).optional(),
97
+ /**
98
+ * JSX fragment factory.
99
+ */
100
+ jsxFragment: z.string().min(1).optional(),
101
+ /**
102
+ * JSX import source.
103
+ */
104
+ jsxImportSource: z.string().min(1).optional()
105
+ }).strict();
106
+ var fileTemplateConfigSchema = z.object({
107
+ /**
108
+ * Packages to load from CDN.
109
+ */
110
+ externals: z.array(z.string().min(1)).optional(),
111
+ /**
112
+ * Explicit CDN dependency overrides.
113
+ */
114
+ dependencies: z.record(z.string().min(1), cdnDependencySchema).optional(),
115
+ /**
116
+ * Bundle options.
117
+ */
118
+ bundleOptions: fileBundleOptionsSchema.optional()
119
+ }).strict();
120
+ var importMapSchema = z.object({
121
+ /**
122
+ * Module specifier to URL mappings.
123
+ */
124
+ imports: z.record(
125
+ z.string().min(1),
126
+ z.string().url().refine((url) => url.startsWith("https://"), {
127
+ message: "Import map URLs must use HTTPS"
128
+ })
129
+ ),
130
+ /**
131
+ * Scoped mappings.
132
+ */
133
+ scopes: z.record(
134
+ z.string().min(1),
135
+ z.record(
136
+ z.string().min(1),
137
+ z.string().url().refine((url) => url.startsWith("https://"), {
138
+ message: "Scoped import URLs must use HTTPS"
139
+ })
140
+ )
141
+ ).optional(),
142
+ /**
143
+ * Integrity hashes.
144
+ */
145
+ integrity: z.record(z.string().url(), z.string().regex(/^sha(256|384|512)-[A-Za-z0-9+/=]+$/)).optional()
146
+ }).strict();
147
+ var resolvedDependencySchema = z.object({
148
+ packageName: z.string().min(1),
149
+ version: z.string().min(1),
150
+ cdnUrl: z.string().url(),
151
+ integrity: z.string().optional(),
152
+ global: z.string().optional(),
153
+ esm: z.boolean(),
154
+ provider: cdnProviderSchema
155
+ }).strict();
156
+ var buildManifestMetadataSchema = z.object({
157
+ createdAt: z.string().datetime(),
158
+ buildTimeMs: z.number().nonnegative(),
159
+ totalSize: z.number().nonnegative(),
160
+ bundlerVersion: z.string().optional()
161
+ }).strict();
162
+ var buildManifestOutputsSchema = z.object({
163
+ code: z.string(),
164
+ sourceMap: z.string().optional(),
165
+ ssrHtml: z.string().optional()
166
+ }).strict();
167
+ var componentBuildManifestSchema = z.object({
168
+ version: z.literal("1.0"),
169
+ buildId: z.string().uuid(),
170
+ toolName: z.string().min(1),
171
+ entryPath: z.string().min(1),
172
+ contentHash: z.string().regex(/^[a-f0-9]{64}$/, {
173
+ message: "Content hash must be a 64-character SHA-256 hex string"
174
+ }),
175
+ dependencies: z.array(resolvedDependencySchema),
176
+ outputs: buildManifestOutputsSchema,
177
+ importMap: importMapSchema,
178
+ metadata: buildManifestMetadataSchema
179
+ }).strict();
180
+ var cdnProviderConfigSchema = z.record(cdnProviderSchema, cdnDependencySchema);
181
+ var packageMetadataSchema = z.object({
182
+ description: z.string().optional(),
183
+ homepage: z.string().url().optional(),
184
+ license: z.string().optional()
185
+ }).strict();
186
+ var cdnRegistryEntrySchema = z.object({
187
+ packageName: z.string().min(1),
188
+ defaultVersion: z.string().min(1),
189
+ providers: cdnProviderConfigSchema,
190
+ preferredProviders: z.array(cdnProviderSchema).optional(),
191
+ metadata: packageMetadataSchema.optional()
192
+ }).strict();
193
+ var dependencyResolverOptionsSchema = z.object({
194
+ platform: cdnPlatformTypeSchema.optional(),
195
+ preferredProviders: z.array(cdnProviderSchema).optional(),
196
+ customRegistry: z.record(z.string().min(1), cdnRegistryEntrySchema).optional(),
197
+ strictMode: z.boolean().optional(),
198
+ requireIntegrity: z.boolean().optional()
199
+ }).strict();
200
+ var importTypeSchema = z.enum(["named", "default", "namespace", "side-effect", "dynamic"]);
201
+ var parsedImportSchema = z.object({
202
+ statement: z.string(),
203
+ specifier: z.string().min(1),
204
+ type: importTypeSchema,
205
+ namedImports: z.array(z.string().min(1)).optional(),
206
+ defaultImport: z.string().min(1).optional(),
207
+ namespaceImport: z.string().min(1).optional(),
208
+ line: z.number().int().positive(),
209
+ column: z.number().int().nonnegative()
210
+ }).strict();
211
+ var parsedImportResultSchema = z.object({
212
+ imports: z.array(parsedImportSchema),
213
+ externalImports: z.array(parsedImportSchema),
214
+ relativeImports: z.array(parsedImportSchema),
215
+ externalPackages: z.array(z.string().min(1))
216
+ }).strict();
217
+ var cacheStatsSchema = z.object({
218
+ entries: z.number().int().nonnegative(),
219
+ totalSize: z.number().nonnegative(),
220
+ hits: z.number().int().nonnegative(),
221
+ misses: z.number().int().nonnegative(),
222
+ hitRate: z.number().min(0).max(1)
223
+ }).strict();
224
+ function validateCDNDependency(data) {
225
+ return cdnDependencySchema.parse(data);
226
+ }
227
+ function safeParseCDNDependency(data) {
228
+ return cdnDependencySchema.safeParse(data);
229
+ }
230
+ function validateFileTemplateConfig(data) {
231
+ return fileTemplateConfigSchema.parse(data);
232
+ }
233
+ function safeParseFileTemplateConfig(data) {
234
+ return fileTemplateConfigSchema.safeParse(data);
235
+ }
236
+ function validateBuildManifest(data) {
237
+ return componentBuildManifestSchema.parse(data);
238
+ }
239
+ function safeParseBuildManifest(data) {
240
+ return componentBuildManifestSchema.safeParse(data);
241
+ }
242
+
243
+ // libs/uipack/src/dependency/cdn-registry.ts
244
+ var DEFAULT_CDN_REGISTRY = {
245
+ // ============================================
246
+ // React Ecosystem
247
+ // ============================================
248
+ react: {
249
+ packageName: "react",
250
+ defaultVersion: "18.3.1",
251
+ providers: {
252
+ cloudflare: {
253
+ url: "https://cdnjs.cloudflare.com/ajax/libs/react/18.3.1/umd/react.production.min.js",
254
+ integrity: "sha512-Qp8J4Xr8LBZ5CXNJQc/HmLqFrpXz6lNkbzMYkYHKzQx5p1q1yOqPQHntXKoYgPPE/n9m0QF1OkJdXa2ePpO4fw==",
255
+ global: "React",
256
+ crossorigin: "anonymous"
257
+ },
258
+ jsdelivr: {
259
+ url: "https://cdn.jsdelivr.net/npm/react@18.3.1/umd/react.production.min.js",
260
+ global: "React",
261
+ crossorigin: "anonymous"
262
+ },
263
+ unpkg: {
264
+ url: "https://unpkg.com/react@18.3.1/umd/react.production.min.js",
265
+ global: "React",
266
+ crossorigin: "anonymous"
267
+ },
268
+ "esm.sh": {
269
+ url: "https://esm.sh/react@18.3.1",
270
+ esm: true,
271
+ crossorigin: "anonymous"
272
+ }
273
+ },
274
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"],
275
+ metadata: {
276
+ description: "A JavaScript library for building user interfaces",
277
+ homepage: "https://react.dev",
278
+ license: "MIT"
279
+ }
280
+ },
281
+ "react-dom": {
282
+ packageName: "react-dom",
283
+ defaultVersion: "18.3.1",
284
+ providers: {
285
+ cloudflare: {
286
+ url: "https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.3.1/umd/react-dom.production.min.js",
287
+ integrity: "sha512-6s2gVRdS3aT+FDdZTRJSzKlzIPqDXWyYl/5hPQb6hSgzKPGFcQyZhbqjbWVxGrs2dYNrINFXb0k0UD3d+CKPJA==",
288
+ global: "ReactDOM",
289
+ crossorigin: "anonymous",
290
+ peerDependencies: ["react"]
291
+ },
292
+ jsdelivr: {
293
+ url: "https://cdn.jsdelivr.net/npm/react-dom@18.3.1/umd/react-dom.production.min.js",
294
+ global: "ReactDOM",
295
+ crossorigin: "anonymous",
296
+ peerDependencies: ["react"]
297
+ },
298
+ unpkg: {
299
+ url: "https://unpkg.com/react-dom@18.3.1/umd/react-dom.production.min.js",
300
+ global: "ReactDOM",
301
+ crossorigin: "anonymous",
302
+ peerDependencies: ["react"]
303
+ },
304
+ "esm.sh": {
305
+ url: "https://esm.sh/react-dom@18.3.1",
306
+ esm: true,
307
+ crossorigin: "anonymous",
308
+ peerDependencies: ["react"]
309
+ }
310
+ },
311
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"],
312
+ metadata: {
313
+ description: "React package for working with the DOM",
314
+ homepage: "https://react.dev",
315
+ license: "MIT"
316
+ }
317
+ },
318
+ // ============================================
319
+ // Charting Libraries
320
+ // ============================================
321
+ "chart.js": {
322
+ packageName: "chart.js",
323
+ defaultVersion: "4.4.7",
324
+ providers: {
325
+ cloudflare: {
326
+ url: "https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.7/chart.umd.min.js",
327
+ integrity: "sha512-dMDjIoZjJD6gs0KPBhFYjLQrH3kIohSEn6HzWs6Y6GiO0+L9kk/bM3cR5KNEDK1KvMNpTIZG6pHK9SZfCJHRpQ==",
328
+ global: "Chart",
329
+ crossorigin: "anonymous"
330
+ },
331
+ jsdelivr: {
332
+ url: "https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js",
333
+ global: "Chart",
334
+ crossorigin: "anonymous"
335
+ },
336
+ unpkg: {
337
+ url: "https://unpkg.com/chart.js@4.4.7/dist/chart.umd.min.js",
338
+ global: "Chart",
339
+ crossorigin: "anonymous"
340
+ }
341
+ },
342
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
343
+ metadata: {
344
+ description: "Simple yet flexible JavaScript charting library",
345
+ homepage: "https://www.chartjs.org",
346
+ license: "MIT"
347
+ }
348
+ },
349
+ "react-chartjs-2": {
350
+ packageName: "react-chartjs-2",
351
+ defaultVersion: "5.3.0",
352
+ providers: {
353
+ cloudflare: {
354
+ url: "https://cdnjs.cloudflare.com/ajax/libs/react-chartjs-2/5.3.0/react-chartjs-2.min.js",
355
+ global: "ReactChartjs2",
356
+ crossorigin: "anonymous",
357
+ peerDependencies: ["react", "chart.js"]
358
+ },
359
+ jsdelivr: {
360
+ url: "https://cdn.jsdelivr.net/npm/react-chartjs-2@5.3.0/dist/index.umd.js",
361
+ global: "ReactChartjs2",
362
+ crossorigin: "anonymous",
363
+ peerDependencies: ["react", "chart.js"]
364
+ },
365
+ "esm.sh": {
366
+ url: "https://esm.sh/react-chartjs-2@5.3.0",
367
+ esm: true,
368
+ crossorigin: "anonymous",
369
+ peerDependencies: ["react", "chart.js"]
370
+ }
371
+ },
372
+ preferredProviders: ["cloudflare", "jsdelivr", "esm.sh"],
373
+ metadata: {
374
+ description: "React components for Chart.js",
375
+ homepage: "https://react-chartjs-2.js.org",
376
+ license: "MIT"
377
+ }
378
+ },
379
+ // ============================================
380
+ // D3.js
381
+ // ============================================
382
+ d3: {
383
+ packageName: "d3",
384
+ defaultVersion: "7.9.0",
385
+ providers: {
386
+ cloudflare: {
387
+ url: "https://cdnjs.cloudflare.com/ajax/libs/d3/7.9.0/d3.min.js",
388
+ integrity: "sha512-vc58qvvBdrDR4etbxMdlTt4GBQk1qjvyORR2nrsPsFPyrs+/u5c3+1Ct6upOgdZoIl7eq6k3a1UPDSNAQi/32A==",
389
+ global: "d3",
390
+ crossorigin: "anonymous"
391
+ },
392
+ jsdelivr: {
393
+ url: "https://cdn.jsdelivr.net/npm/d3@7.9.0/dist/d3.min.js",
394
+ global: "d3",
395
+ crossorigin: "anonymous"
396
+ },
397
+ unpkg: {
398
+ url: "https://unpkg.com/d3@7.9.0/dist/d3.min.js",
399
+ global: "d3",
400
+ crossorigin: "anonymous"
401
+ }
402
+ },
403
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
404
+ metadata: {
405
+ description: "Data-Driven Documents",
406
+ homepage: "https://d3js.org",
407
+ license: "ISC"
408
+ }
409
+ },
410
+ // ============================================
411
+ // Utility Libraries
412
+ // ============================================
413
+ lodash: {
414
+ packageName: "lodash",
415
+ defaultVersion: "4.17.21",
416
+ providers: {
417
+ cloudflare: {
418
+ url: "https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js",
419
+ integrity: "sha512-WFN04846sdKMIP5LKNphMaWzU7YpMyCU245etK3g/2ARYbPK9Ub18eG+ljU96qKRCWh+quCY7yefSmlkQw1ANQ==",
420
+ global: "_",
421
+ crossorigin: "anonymous"
422
+ },
423
+ jsdelivr: {
424
+ url: "https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js",
425
+ global: "_",
426
+ crossorigin: "anonymous"
427
+ },
428
+ unpkg: {
429
+ url: "https://unpkg.com/lodash@4.17.21/lodash.min.js",
430
+ global: "_",
431
+ crossorigin: "anonymous"
432
+ }
433
+ },
434
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
435
+ metadata: {
436
+ description: "A modern JavaScript utility library",
437
+ homepage: "https://lodash.com",
438
+ license: "MIT"
439
+ }
440
+ },
441
+ "lodash-es": {
442
+ packageName: "lodash-es",
443
+ defaultVersion: "4.17.21",
444
+ providers: {
445
+ "esm.sh": {
446
+ url: "https://esm.sh/lodash-es@4.17.21",
447
+ esm: true,
448
+ crossorigin: "anonymous"
449
+ },
450
+ jsdelivr: {
451
+ url: "https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm",
452
+ esm: true,
453
+ crossorigin: "anonymous"
454
+ }
455
+ },
456
+ preferredProviders: ["esm.sh", "jsdelivr"],
457
+ metadata: {
458
+ description: "Lodash exported as ES modules",
459
+ homepage: "https://lodash.com",
460
+ license: "MIT"
461
+ }
462
+ },
463
+ dayjs: {
464
+ packageName: "dayjs",
465
+ defaultVersion: "1.11.13",
466
+ providers: {
467
+ cloudflare: {
468
+ url: "https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.13/dayjs.min.js",
469
+ integrity: "sha512-Ot7ArUEhJDU0cwoBNNnWe487kjL5wAOsIYig8llY/l0P2TUFwgsAHVmrZMHsT8NGo+HwkjTJsNErS6QqIkBxDw==",
470
+ global: "dayjs",
471
+ crossorigin: "anonymous"
472
+ },
473
+ jsdelivr: {
474
+ url: "https://cdn.jsdelivr.net/npm/dayjs@1.11.13/dayjs.min.js",
475
+ global: "dayjs",
476
+ crossorigin: "anonymous"
477
+ },
478
+ unpkg: {
479
+ url: "https://unpkg.com/dayjs@1.11.13/dayjs.min.js",
480
+ global: "dayjs",
481
+ crossorigin: "anonymous"
482
+ }
483
+ },
484
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
485
+ metadata: {
486
+ description: "Fast 2kB alternative to Moment.js with the same modern API",
487
+ homepage: "https://day.js.org",
488
+ license: "MIT"
489
+ }
490
+ },
491
+ "date-fns": {
492
+ packageName: "date-fns",
493
+ defaultVersion: "4.1.0",
494
+ providers: {
495
+ "esm.sh": {
496
+ url: "https://esm.sh/date-fns@4.1.0",
497
+ esm: true,
498
+ crossorigin: "anonymous"
499
+ },
500
+ jsdelivr: {
501
+ url: "https://cdn.jsdelivr.net/npm/date-fns@4.1.0/+esm",
502
+ esm: true,
503
+ crossorigin: "anonymous"
504
+ }
505
+ },
506
+ preferredProviders: ["esm.sh", "jsdelivr"],
507
+ metadata: {
508
+ description: "Modern JavaScript date utility library",
509
+ homepage: "https://date-fns.org",
510
+ license: "MIT"
511
+ }
512
+ },
513
+ // ============================================
514
+ // Animation Libraries
515
+ // ============================================
516
+ "framer-motion": {
517
+ packageName: "framer-motion",
518
+ defaultVersion: "11.15.0",
519
+ providers: {
520
+ "esm.sh": {
521
+ url: "https://esm.sh/framer-motion@11.15.0",
522
+ esm: true,
523
+ crossorigin: "anonymous",
524
+ peerDependencies: ["react", "react-dom"]
525
+ },
526
+ jsdelivr: {
527
+ url: "https://cdn.jsdelivr.net/npm/framer-motion@11.15.0/dist/framer-motion.js",
528
+ global: "Motion",
529
+ crossorigin: "anonymous",
530
+ peerDependencies: ["react", "react-dom"]
531
+ }
532
+ },
533
+ preferredProviders: ["esm.sh", "jsdelivr"],
534
+ metadata: {
535
+ description: "Production-ready motion library for React",
536
+ homepage: "https://www.framer.com/motion/",
537
+ license: "MIT"
538
+ }
539
+ },
540
+ // ============================================
541
+ // UI Component Libraries
542
+ // ============================================
543
+ "lucide-react": {
544
+ packageName: "lucide-react",
545
+ defaultVersion: "0.468.0",
546
+ providers: {
547
+ "esm.sh": {
548
+ url: "https://esm.sh/lucide-react@0.468.0",
549
+ esm: true,
550
+ crossorigin: "anonymous",
551
+ peerDependencies: ["react"]
552
+ },
553
+ jsdelivr: {
554
+ url: "https://cdn.jsdelivr.net/npm/lucide-react@0.468.0/dist/esm/lucide-react.js",
555
+ esm: true,
556
+ crossorigin: "anonymous",
557
+ peerDependencies: ["react"]
558
+ }
559
+ },
560
+ preferredProviders: ["esm.sh", "jsdelivr"],
561
+ metadata: {
562
+ description: "Beautiful & consistent icon toolkit for React",
563
+ homepage: "https://lucide.dev",
564
+ license: "ISC"
565
+ }
566
+ },
567
+ // ============================================
568
+ // Markdown/Syntax Highlighting
569
+ // ============================================
570
+ marked: {
571
+ packageName: "marked",
572
+ defaultVersion: "15.0.4",
573
+ providers: {
574
+ cloudflare: {
575
+ url: "https://cdnjs.cloudflare.com/ajax/libs/marked/15.0.4/marked.min.js",
576
+ integrity: "sha512-Rn/d0sGeizGbk3VJEiYNDt/mMcfuzYoFkia3iBffv+HX8VUrHMo/0cKjZuxWGoZLPh/VxUcC9ais+RBFZW9EBg==",
577
+ global: "marked",
578
+ crossorigin: "anonymous"
579
+ },
580
+ jsdelivr: {
581
+ url: "https://cdn.jsdelivr.net/npm/marked@15.0.4/marked.min.js",
582
+ global: "marked",
583
+ crossorigin: "anonymous"
584
+ },
585
+ unpkg: {
586
+ url: "https://unpkg.com/marked@15.0.4/marked.min.js",
587
+ global: "marked",
588
+ crossorigin: "anonymous"
589
+ }
590
+ },
591
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
592
+ metadata: {
593
+ description: "A markdown parser and compiler",
594
+ homepage: "https://marked.js.org",
595
+ license: "MIT"
596
+ }
597
+ },
598
+ "highlight.js": {
599
+ packageName: "highlight.js",
600
+ defaultVersion: "11.10.0",
601
+ providers: {
602
+ cloudflare: {
603
+ url: "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.10.0/highlight.min.js",
604
+ integrity: "sha512-6yoqbrcLAHDWAdQmiRlHG4+m0g/CT/V9AGyxabG8j7Jk8j3v3k6mIP1iN/PvSofcWet2tf8SRn/j3L/+pb7LRQ==",
605
+ global: "hljs",
606
+ crossorigin: "anonymous"
607
+ },
608
+ jsdelivr: {
609
+ url: "https://cdn.jsdelivr.net/npm/highlight.js@11.10.0/lib/core.min.js",
610
+ global: "hljs",
611
+ crossorigin: "anonymous"
612
+ },
613
+ unpkg: {
614
+ url: "https://unpkg.com/highlight.js@11.10.0/lib/core.min.js",
615
+ global: "hljs",
616
+ crossorigin: "anonymous"
617
+ }
618
+ },
619
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
620
+ metadata: {
621
+ description: "Syntax highlighting for the web",
622
+ homepage: "https://highlightjs.org",
623
+ license: "BSD-3-Clause"
624
+ }
625
+ },
626
+ // ============================================
627
+ // Interactive Libraries
628
+ // ============================================
629
+ "htmx.org": {
630
+ packageName: "htmx.org",
631
+ defaultVersion: "2.0.4",
632
+ providers: {
633
+ cloudflare: {
634
+ url: "https://cdnjs.cloudflare.com/ajax/libs/htmx/2.0.4/htmx.min.js",
635
+ integrity: "sha512-2kIcAizYXhIn5IyXrMC72f2nh0JAtESHRpOieVw5dYPYeHwLCC2eKCqvdZDYRSEgasKrPpEPpRFjL8gqwBZWAA==",
636
+ global: "htmx",
637
+ crossorigin: "anonymous"
638
+ },
639
+ jsdelivr: {
640
+ url: "https://cdn.jsdelivr.net/npm/htmx.org@2.0.4/dist/htmx.min.js",
641
+ global: "htmx",
642
+ crossorigin: "anonymous"
643
+ },
644
+ unpkg: {
645
+ url: "https://unpkg.com/htmx.org@2.0.4/dist/htmx.min.js",
646
+ global: "htmx",
647
+ crossorigin: "anonymous"
648
+ }
649
+ },
650
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
651
+ metadata: {
652
+ description: "High power tools for HTML",
653
+ homepage: "https://htmx.org",
654
+ license: "BSD-2-Clause"
655
+ }
656
+ },
657
+ alpinejs: {
658
+ packageName: "alpinejs",
659
+ defaultVersion: "3.14.3",
660
+ providers: {
661
+ cloudflare: {
662
+ url: "https://cdnjs.cloudflare.com/ajax/libs/alpinejs/3.14.3/cdn.min.js",
663
+ integrity: "sha512-lrQ8FHgsWKFSuQFq8NKPJicjlvJFEIrCqEj8zeX7ZOUlHWltN/Iow4jND+x84jqTdDf9n+hvQpJjGDvOl/eDRA==",
664
+ global: "Alpine",
665
+ crossorigin: "anonymous"
666
+ },
667
+ jsdelivr: {
668
+ url: "https://cdn.jsdelivr.net/npm/alpinejs@3.14.3/dist/cdn.min.js",
669
+ global: "Alpine",
670
+ crossorigin: "anonymous"
671
+ },
672
+ unpkg: {
673
+ url: "https://unpkg.com/alpinejs@3.14.3/dist/cdn.min.js",
674
+ global: "Alpine",
675
+ crossorigin: "anonymous"
676
+ }
677
+ },
678
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
679
+ metadata: {
680
+ description: "A rugged, minimal framework for composing behavior directly in your markup",
681
+ homepage: "https://alpinejs.dev",
682
+ license: "MIT"
683
+ }
684
+ },
685
+ // ============================================
686
+ // Templating Libraries
687
+ // ============================================
688
+ handlebars: {
689
+ packageName: "handlebars",
690
+ defaultVersion: "4.7.8",
691
+ providers: {
692
+ cloudflare: {
693
+ url: "https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.7.8/handlebars.min.js",
694
+ integrity: "sha512-E1dSFxg+wsfJ4HKjutk/WaCzK7S2wv1POn1RRPGh8ZK+ag9l244Vqxji3r6wgz9YBf6+vhQEYJZpSjqWFPg9gg==",
695
+ global: "Handlebars",
696
+ crossorigin: "anonymous"
697
+ },
698
+ jsdelivr: {
699
+ url: "https://cdn.jsdelivr.net/npm/handlebars@4.7.8/dist/handlebars.min.js",
700
+ global: "Handlebars",
701
+ crossorigin: "anonymous"
702
+ },
703
+ unpkg: {
704
+ url: "https://unpkg.com/handlebars@4.7.8/dist/handlebars.min.js",
705
+ global: "Handlebars",
706
+ crossorigin: "anonymous"
707
+ }
708
+ },
709
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
710
+ metadata: {
711
+ description: "Minimal templating on steroids",
712
+ homepage: "https://handlebarsjs.com",
713
+ license: "MIT"
714
+ }
715
+ }
716
+ };
717
+ var CDN_PROVIDER_PRIORITY = {
718
+ claude: ["cloudflare"],
719
+ // ONLY cloudflare for Claude
720
+ openai: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"],
721
+ cursor: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"],
722
+ gemini: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"],
723
+ continue: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"],
724
+ cody: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"],
725
+ unknown: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"]
726
+ // Default to cloudflare first
727
+ };
728
+ function lookupPackage(packageName, registry = DEFAULT_CDN_REGISTRY) {
729
+ return registry[packageName];
730
+ }
731
+ function getPackageCDNUrl(packageName, platform = "unknown", registry = DEFAULT_CDN_REGISTRY) {
732
+ const entry = lookupPackage(packageName, registry);
733
+ if (!entry) return void 0;
734
+ const providerPriority = CDN_PROVIDER_PRIORITY[platform];
735
+ for (const provider of providerPriority) {
736
+ const config = entry.providers[provider];
737
+ if (config?.url) {
738
+ return config.url;
739
+ }
740
+ }
741
+ for (const provider of Object.keys(entry.providers)) {
742
+ const config = entry.providers[provider];
743
+ if (config?.url) {
744
+ return config.url;
745
+ }
746
+ }
747
+ return void 0;
748
+ }
749
+ function getPackageCDNDependency(packageName, platform = "unknown", registry = DEFAULT_CDN_REGISTRY) {
750
+ const entry = lookupPackage(packageName, registry);
751
+ if (!entry) return void 0;
752
+ const providerPriority = CDN_PROVIDER_PRIORITY[platform];
753
+ for (const provider of providerPriority) {
754
+ const config = entry.providers[provider];
755
+ if (config?.url) {
756
+ return { provider, dependency: config };
757
+ }
758
+ }
759
+ for (const provider of Object.keys(entry.providers)) {
760
+ const config = entry.providers[provider];
761
+ if (config?.url) {
762
+ return { provider, dependency: config };
763
+ }
764
+ }
765
+ return void 0;
766
+ }
767
+ function getRegisteredPackages(registry = DEFAULT_CDN_REGISTRY) {
768
+ return Object.keys(registry);
769
+ }
770
+ function isPackageRegistered(packageName, registry = DEFAULT_CDN_REGISTRY) {
771
+ return packageName in registry;
772
+ }
773
+ function mergeRegistries(customRegistry) {
774
+ return {
775
+ ...DEFAULT_CDN_REGISTRY,
776
+ ...customRegistry
777
+ };
778
+ }
779
+ function getPackagePeerDependencies(packageName, registry = DEFAULT_CDN_REGISTRY) {
780
+ const entry = lookupPackage(packageName, registry);
781
+ if (!entry) return [];
782
+ for (const provider of Object.keys(entry.providers)) {
783
+ const config = entry.providers[provider];
784
+ if (config?.peerDependencies) {
785
+ return config.peerDependencies;
786
+ }
787
+ }
788
+ return [];
789
+ }
790
+ function resolveAllDependencies(packageNames, platform = "unknown", registry = DEFAULT_CDN_REGISTRY) {
791
+ const resolved = /* @__PURE__ */ new Set();
792
+ const queue = [...packageNames];
793
+ while (queue.length > 0) {
794
+ const packageName = queue.shift();
795
+ if (!packageName) continue;
796
+ if (resolved.has(packageName)) continue;
797
+ resolved.add(packageName);
798
+ const peers = getPackagePeerDependencies(packageName, registry);
799
+ for (const peer of peers) {
800
+ if (!resolved.has(peer)) {
801
+ queue.push(peer);
802
+ }
803
+ }
804
+ }
805
+ const result = [];
806
+ const remaining = new Set(resolved);
807
+ while (remaining.size > 0) {
808
+ let added = false;
809
+ for (const pkg of remaining) {
810
+ const peers = getPackagePeerDependencies(pkg, registry);
811
+ const allPeersResolved = peers.every((peer) => !remaining.has(peer) || result.includes(peer));
812
+ if (allPeersResolved) {
813
+ if (!result.includes(pkg)) {
814
+ result.push(pkg);
815
+ }
816
+ remaining.delete(pkg);
817
+ added = true;
818
+ }
819
+ }
820
+ if (!added && remaining.size > 0) {
821
+ const next = remaining.values().next().value;
822
+ if (next !== void 0) {
823
+ if (!result.includes(next)) {
824
+ result.push(next);
825
+ }
826
+ remaining.delete(next);
827
+ }
828
+ }
829
+ }
830
+ return result;
831
+ }
832
+
833
+ // libs/uipack/src/dependency/import-parser.ts
834
+ var IMPORT_PATTERNS = {
835
+ /**
836
+ * Named imports: import { foo, bar } from 'module'
837
+ * Also handles renamed imports: import { foo as f } from 'module'
838
+ */
839
+ named: /import\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/g,
840
+ /**
841
+ * Default imports: import foo from 'module'
842
+ */
843
+ default: /import\s+(\w+)\s+from\s*['"]([^'"]+)['"]/g,
844
+ /**
845
+ * Namespace imports: import * as foo from 'module'
846
+ */
847
+ namespace: /import\s*\*\s*as\s+(\w+)\s+from\s*['"]([^'"]+)['"]/g,
848
+ /**
849
+ * Side-effect imports: import 'module'
850
+ */
851
+ sideEffect: /import\s*['"]([^'"]+)['"]/g,
852
+ /**
853
+ * Dynamic imports: import('module') or await import('module')
854
+ */
855
+ dynamic: /(?:await\s+)?import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,
856
+ /**
857
+ * Combined default and named: import foo, { bar } from 'module'
858
+ */
859
+ defaultAndNamed: /import\s+(\w+)\s*,\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/g,
860
+ /**
861
+ * Combined default and namespace: import foo, * as bar from 'module'
862
+ */
863
+ defaultAndNamespace: /import\s+(\w+)\s*,\s*\*\s*as\s+(\w+)\s+from\s*['"]([^'"]+)['"]/g,
864
+ /**
865
+ * Re-exports: export { foo } from 'module'
866
+ */
867
+ reExport: /export\s*\{[^}]+\}\s*from\s*['"]([^'"]+)['"]/g,
868
+ /**
869
+ * Re-export all: export * from 'module'
870
+ */
871
+ reExportAll: /export\s*\*\s*from\s*['"]([^'"]+)['"]/g
872
+ };
873
+ function parseNamedImports(namedString) {
874
+ return namedString.split(",").map((s) => s.trim()).filter((s) => s.length > 0).map((s) => {
875
+ const asMatch = s.match(/^(\w+)\s+as\s+\w+$/);
876
+ return asMatch ? asMatch[1] : s;
877
+ });
878
+ }
879
+ function isRelativeImport(specifier) {
880
+ return specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/");
881
+ }
882
+ function isExternalImport(specifier) {
883
+ return !isRelativeImport(specifier) && !specifier.startsWith("#");
884
+ }
885
+ function getPackageName(specifier) {
886
+ if (specifier.startsWith("@")) {
887
+ const parts = specifier.split("/");
888
+ if (parts.length >= 2) {
889
+ return `${parts[0]}/${parts[1]}`;
890
+ }
891
+ return specifier;
892
+ }
893
+ const firstSlash = specifier.indexOf("/");
894
+ return firstSlash === -1 ? specifier : specifier.slice(0, firstSlash);
895
+ }
896
+ function getLineNumber(source, index) {
897
+ let line = 1;
898
+ for (let i = 0; i < index && i < source.length; i++) {
899
+ if (source[i] === "\n") {
900
+ line++;
901
+ }
902
+ }
903
+ return line;
904
+ }
905
+ function getColumnNumber(source, index) {
906
+ let column = 0;
907
+ for (let i = index - 1; i >= 0 && source[i] !== "\n"; i--) {
908
+ column++;
909
+ }
910
+ return column;
911
+ }
912
+ function parseImports(source) {
913
+ const imports = [];
914
+ const seenStatements = /* @__PURE__ */ new Set();
915
+ const addImport = (imp) => {
916
+ const key = `${imp.type}:${imp.specifier}:${imp.statement}`;
917
+ if (!seenStatements.has(key)) {
918
+ seenStatements.add(key);
919
+ imports.push(imp);
920
+ }
921
+ };
922
+ let match;
923
+ const defaultAndNamedRegex = new RegExp(IMPORT_PATTERNS.defaultAndNamed.source, "g");
924
+ while ((match = defaultAndNamedRegex.exec(source)) !== null) {
925
+ const [statement, defaultName, namedString, specifier] = match;
926
+ const namedImports = parseNamedImports(namedString);
927
+ addImport({
928
+ statement,
929
+ specifier,
930
+ type: "default",
931
+ defaultImport: defaultName,
932
+ namedImports,
933
+ line: getLineNumber(source, match.index),
934
+ column: getColumnNumber(source, match.index)
935
+ });
936
+ }
937
+ const defaultAndNamespaceRegex = new RegExp(IMPORT_PATTERNS.defaultAndNamespace.source, "g");
938
+ while ((match = defaultAndNamespaceRegex.exec(source)) !== null) {
939
+ const [statement, defaultName, namespaceName, specifier] = match;
940
+ addImport({
941
+ statement,
942
+ specifier,
943
+ type: "default",
944
+ defaultImport: defaultName,
945
+ namespaceImport: namespaceName,
946
+ line: getLineNumber(source, match.index),
947
+ column: getColumnNumber(source, match.index)
948
+ });
949
+ }
950
+ const namedRegex = new RegExp(IMPORT_PATTERNS.named.source, "g");
951
+ while ((match = namedRegex.exec(source)) !== null) {
952
+ const [statement, namedString, specifier] = match;
953
+ const namedImports = parseNamedImports(namedString);
954
+ addImport({
955
+ statement,
956
+ specifier,
957
+ type: "named",
958
+ namedImports,
959
+ line: getLineNumber(source, match.index),
960
+ column: getColumnNumber(source, match.index)
961
+ });
962
+ }
963
+ const defaultRegex = new RegExp(IMPORT_PATTERNS.default.source, "g");
964
+ while ((match = defaultRegex.exec(source)) !== null) {
965
+ const [statement, defaultName, specifier] = match;
966
+ const afterMatch = source.slice(match.index + match[0].length - specifier.length - 2);
967
+ if (afterMatch.startsWith(",")) continue;
968
+ addImport({
969
+ statement,
970
+ specifier,
971
+ type: "default",
972
+ defaultImport: defaultName,
973
+ line: getLineNumber(source, match.index),
974
+ column: getColumnNumber(source, match.index)
975
+ });
976
+ }
977
+ const namespaceRegex = new RegExp(IMPORT_PATTERNS.namespace.source, "g");
978
+ while ((match = namespaceRegex.exec(source)) !== null) {
979
+ const [statement, namespaceName, specifier] = match;
980
+ addImport({
981
+ statement,
982
+ specifier,
983
+ type: "namespace",
984
+ namespaceImport: namespaceName,
985
+ line: getLineNumber(source, match.index),
986
+ column: getColumnNumber(source, match.index)
987
+ });
988
+ }
989
+ const sideEffectRegex = new RegExp(IMPORT_PATTERNS.sideEffect.source, "g");
990
+ while ((match = sideEffectRegex.exec(source)) !== null) {
991
+ const [statement, specifier] = match;
992
+ const beforeMatch = source.slice(Math.max(0, match.index - 50), match.index);
993
+ if (beforeMatch.includes("from")) continue;
994
+ addImport({
995
+ statement,
996
+ specifier,
997
+ type: "side-effect",
998
+ line: getLineNumber(source, match.index),
999
+ column: getColumnNumber(source, match.index)
1000
+ });
1001
+ }
1002
+ const dynamicRegex = new RegExp(IMPORT_PATTERNS.dynamic.source, "g");
1003
+ while ((match = dynamicRegex.exec(source)) !== null) {
1004
+ const [statement, specifier] = match;
1005
+ addImport({
1006
+ statement,
1007
+ specifier,
1008
+ type: "dynamic",
1009
+ line: getLineNumber(source, match.index),
1010
+ column: getColumnNumber(source, match.index)
1011
+ });
1012
+ }
1013
+ const reExportRegex = new RegExp(IMPORT_PATTERNS.reExport.source, "g");
1014
+ while ((match = reExportRegex.exec(source)) !== null) {
1015
+ const [statement, specifier] = match;
1016
+ addImport({
1017
+ statement,
1018
+ specifier,
1019
+ type: "named",
1020
+ line: getLineNumber(source, match.index),
1021
+ column: getColumnNumber(source, match.index)
1022
+ });
1023
+ }
1024
+ const reExportAllRegex = new RegExp(IMPORT_PATTERNS.reExportAll.source, "g");
1025
+ while ((match = reExportAllRegex.exec(source)) !== null) {
1026
+ const [statement, specifier] = match;
1027
+ addImport({
1028
+ statement,
1029
+ specifier,
1030
+ type: "namespace",
1031
+ line: getLineNumber(source, match.index),
1032
+ column: getColumnNumber(source, match.index)
1033
+ });
1034
+ }
1035
+ const externalImports = imports.filter((imp) => isExternalImport(imp.specifier));
1036
+ const relativeImports = imports.filter((imp) => isRelativeImport(imp.specifier));
1037
+ const externalPackages = [...new Set(externalImports.map((imp) => getPackageName(imp.specifier)))];
1038
+ return {
1039
+ imports,
1040
+ externalImports,
1041
+ relativeImports,
1042
+ externalPackages
1043
+ };
1044
+ }
1045
+ function extractExternalPackages(source) {
1046
+ const result = parseImports(source);
1047
+ return result.externalPackages;
1048
+ }
1049
+ function filterImportsByPackages(result, packages) {
1050
+ const packageSet = new Set(packages);
1051
+ return result.externalImports.filter((imp) => {
1052
+ const pkgName = getPackageName(imp.specifier);
1053
+ return packageSet.has(pkgName);
1054
+ });
1055
+ }
1056
+ function getImportStats(source) {
1057
+ const result = parseImports(source);
1058
+ const byType = {
1059
+ named: 0,
1060
+ default: 0,
1061
+ namespace: 0,
1062
+ "side-effect": 0,
1063
+ dynamic: 0
1064
+ };
1065
+ for (const imp of result.imports) {
1066
+ byType[imp.type] = (byType[imp.type] || 0) + 1;
1067
+ }
1068
+ return {
1069
+ total: result.imports.length,
1070
+ external: result.externalImports.length,
1071
+ relative: result.relativeImports.length,
1072
+ byType,
1073
+ packages: result.externalPackages
1074
+ };
1075
+ }
1076
+
1077
+ // libs/uipack/src/utils/escape-html.ts
1078
+ function escapeHtml(str) {
1079
+ if (str === null || str === void 0) {
1080
+ return "";
1081
+ }
1082
+ const s = String(str);
1083
+ 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");
1084
+ }
1085
+ function escapeHtmlAttr(str) {
1086
+ return str.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
1087
+ }
1088
+
1089
+ // libs/uipack/src/dependency/import-map.ts
1090
+ function createImportMap(dependencies) {
1091
+ const imports = {};
1092
+ const integrity = {};
1093
+ for (const dep of dependencies) {
1094
+ imports[dep.packageName] = dep.cdnUrl;
1095
+ if (dep.integrity) {
1096
+ integrity[dep.cdnUrl] = dep.integrity;
1097
+ }
1098
+ }
1099
+ return {
1100
+ imports,
1101
+ integrity: Object.keys(integrity).length > 0 ? integrity : void 0
1102
+ };
1103
+ }
1104
+ function createImportMapFromOverrides(dependencies) {
1105
+ const imports = {};
1106
+ const integrity = {};
1107
+ for (const [pkgName, config] of Object.entries(dependencies)) {
1108
+ imports[pkgName] = config.url;
1109
+ if (config.integrity) {
1110
+ integrity[config.url] = config.integrity;
1111
+ }
1112
+ }
1113
+ return {
1114
+ imports,
1115
+ integrity: Object.keys(integrity).length > 0 ? integrity : void 0
1116
+ };
1117
+ }
1118
+ function mergeImportMaps(...maps) {
1119
+ const imports = {};
1120
+ const integrity = {};
1121
+ const scopes = {};
1122
+ for (const map of maps) {
1123
+ Object.assign(imports, map.imports);
1124
+ if (map.integrity) {
1125
+ Object.assign(integrity, map.integrity);
1126
+ }
1127
+ if (map.scopes) {
1128
+ for (const [scope, mappings] of Object.entries(map.scopes)) {
1129
+ scopes[scope] = { ...scopes[scope], ...mappings };
1130
+ }
1131
+ }
1132
+ }
1133
+ return {
1134
+ imports,
1135
+ integrity: Object.keys(integrity).length > 0 ? integrity : void 0,
1136
+ scopes: Object.keys(scopes).length > 0 ? scopes : void 0
1137
+ };
1138
+ }
1139
+ function addScope(map, scopeUrl, mappings) {
1140
+ return {
1141
+ ...map,
1142
+ scopes: {
1143
+ ...map.scopes,
1144
+ [scopeUrl]: { ...map.scopes?.[scopeUrl] ?? {}, ...mappings }
1145
+ }
1146
+ };
1147
+ }
1148
+ function generateImportMapScriptTag(map) {
1149
+ const json2 = JSON.stringify(map, null, 2).replace(/<\//g, "<\\/");
1150
+ return `<script type="importmap">
1151
+ ${json2}
1152
+ </script>`;
1153
+ }
1154
+ function generateImportMapScriptTagMinified(map) {
1155
+ const json2 = JSON.stringify(map).replace(/<\//g, "<\\/");
1156
+ return `<script type="importmap">${json2}</script>`;
1157
+ }
1158
+ function generateUMDShim(dependencies, options = {}) {
1159
+ const { safe = true, minify = false } = options;
1160
+ const depsWithGlobals = dependencies.filter((d) => d.global && !d.esm);
1161
+ if (depsWithGlobals.length === 0) {
1162
+ return "";
1163
+ }
1164
+ const entries = depsWithGlobals.map((dep) => {
1165
+ const global = dep.global;
1166
+ return `'${dep.packageName}': { default: window.${global}, ...window.${global} }`;
1167
+ });
1168
+ const shimObject = `{
1169
+ ${entries.join(",\n ")}
1170
+ }`;
1171
+ const code = safe ? `(function() {
1172
+ try {
1173
+ window.__esm_shim = ${shimObject};
1174
+ } catch (e) {
1175
+ console.warn('UMD shim failed:', e);
1176
+ }
1177
+ })();` : `window.__esm_shim = ${shimObject};`;
1178
+ return minify ? code.replace(/\s+/g, " ").replace(/\s*([{},:])\s*/g, "$1") : code;
1179
+ }
1180
+ function generateCDNScriptTags(dependencies) {
1181
+ return dependencies.filter((dep) => !dep.esm).map((dep) => {
1182
+ const attrs = [`src="${escapeHtmlAttr(dep.cdnUrl)}"`];
1183
+ if (dep.integrity) {
1184
+ attrs.push(`integrity="${escapeHtmlAttr(dep.integrity)}"`);
1185
+ }
1186
+ attrs.push('crossorigin="anonymous"');
1187
+ return `<script ${attrs.join(" ")}></script>`;
1188
+ });
1189
+ }
1190
+ function generateESMScriptTags(dependencies) {
1191
+ return dependencies.filter((dep) => dep.esm).map((dep) => {
1192
+ const attrs = ['type="module"', `src="${escapeHtmlAttr(dep.cdnUrl)}"`];
1193
+ if (dep.integrity) {
1194
+ attrs.push(`integrity="${escapeHtmlAttr(dep.integrity)}"`);
1195
+ }
1196
+ attrs.push('crossorigin="anonymous"');
1197
+ return `<script ${attrs.join(" ")}></script>`;
1198
+ });
1199
+ }
1200
+ function generateDependencyHTML(dependencies, options = {}) {
1201
+ const { minify = false, includeShim = true } = options;
1202
+ const parts = [];
1203
+ const importMap = createImportMap(dependencies);
1204
+ const importMapTag = minify ? generateImportMapScriptTagMinified(importMap) : generateImportMapScriptTag(importMap);
1205
+ parts.push(importMapTag);
1206
+ const umdTags = generateCDNScriptTags(dependencies);
1207
+ parts.push(...umdTags);
1208
+ if (includeShim) {
1209
+ const shim = generateUMDShim(dependencies, { minify });
1210
+ if (shim) {
1211
+ parts.push(`<script>${shim}</script>`);
1212
+ }
1213
+ }
1214
+ const esmTags = generateESMScriptTags(dependencies);
1215
+ parts.push(...esmTags);
1216
+ return parts.join(minify ? "" : "\n");
1217
+ }
1218
+ function validateImportMap(map) {
1219
+ const errors = [];
1220
+ if (typeof map !== "object" || map === null) {
1221
+ return { valid: false, errors: ["Import map must be an object"] };
1222
+ }
1223
+ const obj = map;
1224
+ if (!obj["imports"]) {
1225
+ errors.push('Import map must have an "imports" field');
1226
+ } else if (typeof obj["imports"] !== "object" || obj["imports"] === null) {
1227
+ errors.push('"imports" must be an object');
1228
+ } else {
1229
+ const imports = obj["imports"];
1230
+ for (const [key, value] of Object.entries(imports)) {
1231
+ if (typeof value !== "string") {
1232
+ errors.push(`Import "${key}" must map to a string URL`);
1233
+ } else if (!value.startsWith("https://")) {
1234
+ errors.push(`Import "${key}" URL must use HTTPS: ${value}`);
1235
+ }
1236
+ }
1237
+ }
1238
+ if (obj["integrity"] !== void 0) {
1239
+ if (typeof obj["integrity"] !== "object" || obj["integrity"] === null) {
1240
+ errors.push('"integrity" must be an object');
1241
+ } else {
1242
+ const integrity = obj["integrity"];
1243
+ for (const [url, hash] of Object.entries(integrity)) {
1244
+ if (typeof hash !== "string") {
1245
+ errors.push(`Integrity for "${url}" must be a string`);
1246
+ } else if (!hash.match(/^sha(256|384|512)-/)) {
1247
+ errors.push(`Invalid integrity hash format for "${url}": ${hash}`);
1248
+ }
1249
+ }
1250
+ }
1251
+ }
1252
+ if (obj["scopes"] !== void 0) {
1253
+ if (typeof obj["scopes"] !== "object" || obj["scopes"] === null) {
1254
+ errors.push('"scopes" must be an object');
1255
+ }
1256
+ }
1257
+ return { valid: errors.length === 0, errors };
1258
+ }
1259
+
1260
+ // libs/uipack/src/dependency/resolver.ts
1261
+ var DependencyResolutionError = class extends Error {
1262
+ constructor(packageName, reason) {
1263
+ super(`Failed to resolve dependency "${packageName}": ${reason}`);
1264
+ this.packageName = packageName;
1265
+ this.reason = reason;
1266
+ this.name = "DependencyResolutionError";
1267
+ }
1268
+ };
1269
+ var NoProviderError = class extends DependencyResolutionError {
1270
+ constructor(packageName, platform) {
1271
+ super(packageName, `No CDN provider available for platform "${platform}"`);
1272
+ this.platform = platform;
1273
+ this.name = "NoProviderError";
1274
+ }
1275
+ };
1276
+ var DependencyResolver = class {
1277
+ options;
1278
+ registry;
1279
+ constructor(options = {}) {
1280
+ this.options = {
1281
+ platform: options.platform ?? "unknown",
1282
+ preferredProviders: options.preferredProviders ?? CDN_PROVIDER_PRIORITY[options.platform ?? "unknown"],
1283
+ customRegistry: options.customRegistry ?? {},
1284
+ strictMode: options.strictMode ?? true,
1285
+ requireIntegrity: options.requireIntegrity ?? false
1286
+ };
1287
+ this.registry = mergeRegistries(this.options.customRegistry);
1288
+ }
1289
+ /**
1290
+ * Resolve a single package to its CDN dependency.
1291
+ *
1292
+ * @param packageName - NPM package name
1293
+ * @param override - Optional explicit CDN dependency override
1294
+ * @returns Resolved dependency, or null in non-strict mode if package is not found (should be bundled)
1295
+ * @throws DependencyResolutionError if package cannot be resolved in strict mode
1296
+ */
1297
+ resolve(packageName, override) {
1298
+ if (override) {
1299
+ return this.createResolvedDependency(packageName, override, "custom");
1300
+ }
1301
+ const entry = lookupPackage(packageName, this.registry);
1302
+ if (!entry) {
1303
+ if (this.options.strictMode) {
1304
+ throw new DependencyResolutionError(
1305
+ packageName,
1306
+ 'Package not found in CDN registry. Add it to "dependencies" for explicit CDN configuration.'
1307
+ );
1308
+ }
1309
+ return null;
1310
+ }
1311
+ const providerPriority = this.options.preferredProviders;
1312
+ for (const provider of providerPriority) {
1313
+ const config = entry.providers[provider];
1314
+ if (config?.url) {
1315
+ if (this.options.requireIntegrity && !config.integrity) {
1316
+ continue;
1317
+ }
1318
+ return this.createResolvedDependency(packageName, config, provider, entry.defaultVersion);
1319
+ }
1320
+ }
1321
+ throw new NoProviderError(packageName, this.options.platform);
1322
+ }
1323
+ /**
1324
+ * Resolve multiple packages.
1325
+ *
1326
+ * @param packageNames - Array of package names
1327
+ * @param overrides - Optional explicit overrides for specific packages
1328
+ * @returns Array of resolved dependencies (in dependency order)
1329
+ */
1330
+ resolveMany(packageNames, overrides) {
1331
+ const allPackages = resolveAllDependencies(packageNames, this.options.platform, this.registry);
1332
+ const resolved = [];
1333
+ for (const pkgName of allPackages) {
1334
+ try {
1335
+ const override = overrides?.[pkgName];
1336
+ const dep = this.resolve(pkgName, override);
1337
+ if (dep) {
1338
+ resolved.push(dep);
1339
+ }
1340
+ } catch (error) {
1341
+ if (this.options.strictMode) {
1342
+ throw error;
1343
+ }
1344
+ }
1345
+ }
1346
+ return resolved;
1347
+ }
1348
+ /**
1349
+ * Resolve dependencies from source code.
1350
+ *
1351
+ * Parses the source to extract imports, then resolves external packages
1352
+ * that are in the externals list.
1353
+ *
1354
+ * @param source - Source code to parse
1355
+ * @param externals - Package names to resolve from CDN (others are bundled)
1356
+ * @param overrides - Optional explicit CDN overrides
1357
+ * @returns Resolved dependencies
1358
+ */
1359
+ resolveFromSource(source, externals, overrides) {
1360
+ const parseResult = parseImports(source);
1361
+ const packagesToResolve = parseResult.externalPackages.filter((pkg) => externals.includes(pkg));
1362
+ return this.resolveMany(packagesToResolve, overrides);
1363
+ }
1364
+ /**
1365
+ * Generate an import map for resolved dependencies.
1366
+ *
1367
+ * @param dependencies - Resolved dependencies
1368
+ * @returns Browser import map
1369
+ */
1370
+ generateImportMap(dependencies) {
1371
+ return createImportMap(dependencies);
1372
+ }
1373
+ /**
1374
+ * Check if a package can be resolved for the current platform.
1375
+ *
1376
+ * @param packageName - Package name to check
1377
+ * @returns true if the package can be resolved
1378
+ */
1379
+ canResolve(packageName) {
1380
+ try {
1381
+ const result = this.resolve(packageName);
1382
+ return result !== null;
1383
+ } catch {
1384
+ return false;
1385
+ }
1386
+ }
1387
+ /**
1388
+ * Get the resolved CDN URL for a package.
1389
+ *
1390
+ * @param packageName - Package name
1391
+ * @param override - Optional explicit override
1392
+ * @returns CDN URL or undefined if cannot resolve
1393
+ */
1394
+ getUrl(packageName, override) {
1395
+ try {
1396
+ const resolved = this.resolve(packageName, override);
1397
+ return resolved?.cdnUrl;
1398
+ } catch {
1399
+ return void 0;
1400
+ }
1401
+ }
1402
+ /**
1403
+ * Get peer dependencies for a package.
1404
+ */
1405
+ getPeerDependencies(packageName) {
1406
+ return getPackagePeerDependencies(packageName, this.registry);
1407
+ }
1408
+ /**
1409
+ * Create the current registry (default + custom).
1410
+ */
1411
+ getRegistry() {
1412
+ return this.registry;
1413
+ }
1414
+ /**
1415
+ * Get the current platform.
1416
+ */
1417
+ getPlatform() {
1418
+ return this.options.platform;
1419
+ }
1420
+ /**
1421
+ * Create a resolved dependency object.
1422
+ */
1423
+ createResolvedDependency(packageName, config, provider, version) {
1424
+ return {
1425
+ packageName,
1426
+ version: version ?? this.extractVersionFromUrl(config.url) ?? "latest",
1427
+ cdnUrl: config.url,
1428
+ integrity: config.integrity,
1429
+ global: config.global,
1430
+ esm: config.esm ?? false,
1431
+ provider
1432
+ };
1433
+ }
1434
+ /**
1435
+ * Try to extract version from CDN URL.
1436
+ */
1437
+ extractVersionFromUrl(url) {
1438
+ const versionMatch = url.match(/@(\d+\.\d+\.\d+(?:-[\w.]+)?)/);
1439
+ if (versionMatch) {
1440
+ return versionMatch[1];
1441
+ }
1442
+ const versionMatch2 = url.match(/\/v?(\d+\.\d+\.\d+)\//);
1443
+ if (versionMatch2) {
1444
+ return versionMatch2[1];
1445
+ }
1446
+ return void 0;
1447
+ }
1448
+ };
1449
+ function createResolver(platform, options) {
1450
+ return new DependencyResolver({
1451
+ platform,
1452
+ ...options
1453
+ });
1454
+ }
1455
+ function createClaudeResolver(options) {
1456
+ return createResolver("claude", options);
1457
+ }
1458
+ function createOpenAIResolver(options) {
1459
+ return createResolver("openai", options);
1460
+ }
1461
+ function resolveDependencies(source, externals, options) {
1462
+ const resolver = new DependencyResolver(options);
1463
+ return resolver.resolveFromSource(source, externals);
1464
+ }
1465
+ function generateImportMapForPackages(externals, options) {
1466
+ const resolver = new DependencyResolver(options);
1467
+ const resolved = resolver.resolveMany(externals);
1468
+ return resolver.generateImportMap(resolved);
1469
+ }
1470
+
1471
+ // libs/uipack/src/dependency/template-loader.ts
1472
+ import { promises as fs } from "fs";
1473
+ import { resolve as resolvePath, isAbsolute, sep } from "path";
1474
+
1475
+ // libs/uipack/src/bundler/file-cache/hash-calculator.ts
1476
+ import { createHash } from "crypto";
1477
+ function sha256(content) {
1478
+ return createHash("sha256").update(content, "utf8").digest("hex");
1479
+ }
1480
+
1481
+ // libs/uipack/src/dependency/template-loader.ts
1482
+ var urlCache = /* @__PURE__ */ new Map();
1483
+ function getUrlCache() {
1484
+ return urlCache;
1485
+ }
1486
+ function clearUrlCache() {
1487
+ urlCache.clear();
1488
+ }
1489
+ function detectTemplateSource(template) {
1490
+ const mode = detectTemplateMode(template);
1491
+ switch (mode) {
1492
+ case "url":
1493
+ return { type: "url", url: template };
1494
+ case "file-path":
1495
+ return { type: "file", path: template };
1496
+ case "inline-string":
1497
+ case "inline-function":
1498
+ default:
1499
+ return { type: "inline", content: template };
1500
+ }
1501
+ }
1502
+ function isFileBasedTemplate(mode) {
1503
+ return mode === "file-path" || mode === "url";
1504
+ }
1505
+ function validateTemplateUrl(url) {
1506
+ const parsed = new URL(url);
1507
+ if (parsed.protocol !== "https:") {
1508
+ throw new Error(`Template URLs must use HTTPS. Got: ${parsed.protocol}`);
1509
+ }
1510
+ }
1511
+ function detectFormatFromUrl(url) {
1512
+ const parsed = new URL(url);
1513
+ return detectFormatFromPath(parsed.pathname);
1514
+ }
1515
+ async function fetchTemplateFromUrl(url, options = {}) {
1516
+ validateTemplateUrl(url);
1517
+ const { timeout = 3e4, skipCache = false, headers: customHeaders = {} } = options;
1518
+ if (!skipCache) {
1519
+ const cached = urlCache.get(url);
1520
+ if (cached?.etag) {
1521
+ const headers = {
1522
+ ...customHeaders,
1523
+ "If-None-Match": cached.etag
1524
+ };
1525
+ const controller2 = new AbortController();
1526
+ const timeoutId2 = setTimeout(() => controller2.abort(), timeout);
1527
+ try {
1528
+ const response = await fetch(url, {
1529
+ headers,
1530
+ signal: controller2.signal
1531
+ });
1532
+ clearTimeout(timeoutId2);
1533
+ if (response.status === 304) {
1534
+ return cached;
1535
+ }
1536
+ return await processFetchResponse(url, response);
1537
+ } catch (error) {
1538
+ clearTimeout(timeoutId2);
1539
+ if (error instanceof Error && error.name === "AbortError") {
1540
+ throw new Error(`Template fetch timed out after ${timeout}ms: ${url}`);
1541
+ }
1542
+ throw error;
1543
+ }
1544
+ }
1545
+ }
1546
+ const controller = new AbortController();
1547
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
1548
+ try {
1549
+ const response = await fetch(url, {
1550
+ headers: customHeaders,
1551
+ signal: controller.signal
1552
+ });
1553
+ clearTimeout(timeoutId);
1554
+ return await processFetchResponse(url, response);
1555
+ } catch (error) {
1556
+ clearTimeout(timeoutId);
1557
+ if (error instanceof Error && error.name === "AbortError") {
1558
+ throw new Error(`Template fetch timed out after ${timeout}ms: ${url}`);
1559
+ }
1560
+ throw error;
1561
+ }
1562
+ }
1563
+ async function processFetchResponse(url, response) {
1564
+ if (!response.ok) {
1565
+ throw new Error(`Failed to fetch template: ${response.status} ${response.statusText} - ${url}`);
1566
+ }
1567
+ const content = await response.text();
1568
+ const etag = response.headers.get("etag") ?? void 0;
1569
+ const contentType = response.headers.get("content-type") ?? void 0;
1570
+ const result = {
1571
+ content,
1572
+ etag,
1573
+ contentType,
1574
+ fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
1575
+ };
1576
+ urlCache.set(url, result);
1577
+ return result;
1578
+ }
1579
+ async function readTemplateFromFile(filePath, options = {}) {
1580
+ const { basePath = process.cwd(), encoding = "utf-8" } = options;
1581
+ const absolutePath = isAbsolute(filePath) ? filePath : resolvePath(basePath, filePath);
1582
+ const normalizedBase = resolvePath(basePath);
1583
+ if (!absolutePath.startsWith(normalizedBase + sep) && absolutePath !== normalizedBase) {
1584
+ throw new Error(`Template path escapes base directory: ${filePath}`);
1585
+ }
1586
+ try {
1587
+ return await fs.readFile(absolutePath, encoding);
1588
+ } catch (error) {
1589
+ const err = error;
1590
+ if (err.code === "ENOENT") {
1591
+ throw new Error(`Template file not found: ${absolutePath}`);
1592
+ }
1593
+ if (err.code === "EACCES") {
1594
+ throw new Error(`Permission denied reading template file: ${absolutePath}`);
1595
+ }
1596
+ throw new Error(`Failed to read template file: ${absolutePath} - ${err.message}`);
1597
+ }
1598
+ }
1599
+ function resolveFilePath(filePath, basePath = process.cwd()) {
1600
+ return isAbsolute(filePath) ? filePath : resolvePath(basePath, filePath);
1601
+ }
1602
+ async function resolveTemplate(template, options = {}) {
1603
+ const { basePath = process.cwd(), skipCache = false, timeout = 3e4, format: overrideFormat } = options;
1604
+ const source = detectTemplateSource(template);
1605
+ let content;
1606
+ let format;
1607
+ let metadata = {};
1608
+ switch (source.type) {
1609
+ case "inline":
1610
+ content = source.content;
1611
+ format = overrideFormat ?? "html";
1612
+ break;
1613
+ case "file": {
1614
+ const absolutePath = resolveFilePath(source.path, basePath);
1615
+ content = await readTemplateFromFile(absolutePath);
1616
+ format = overrideFormat ?? detectFormatFromPath(source.path);
1617
+ metadata.resolvedPath = absolutePath;
1618
+ break;
1619
+ }
1620
+ case "url": {
1621
+ const fetchResult = await fetchTemplateFromUrl(source.url, {
1622
+ skipCache,
1623
+ timeout
1624
+ });
1625
+ content = fetchResult.content;
1626
+ format = overrideFormat ?? detectFormatFromUrl(source.url);
1627
+ metadata = {
1628
+ fetchedAt: fetchResult.fetchedAt,
1629
+ etag: fetchResult.etag,
1630
+ contentType: fetchResult.contentType
1631
+ };
1632
+ break;
1633
+ }
1634
+ }
1635
+ const hash = sha256(content);
1636
+ return {
1637
+ source,
1638
+ format,
1639
+ content,
1640
+ hash,
1641
+ metadata: Object.keys(metadata).length > 0 ? metadata : void 0
1642
+ };
1643
+ }
1644
+ var URL_CACHE_TTL_MS = 5 * 60 * 1e3;
1645
+ function needsRefetch(resolved) {
1646
+ if (resolved.source.type !== "url") {
1647
+ return false;
1648
+ }
1649
+ const cached = urlCache.get(resolved.source.url);
1650
+ if (!cached) {
1651
+ return true;
1652
+ }
1653
+ if (cached.etag) {
1654
+ return false;
1655
+ }
1656
+ if (cached.fetchedAt) {
1657
+ const fetchedTime = new Date(cached.fetchedAt).getTime();
1658
+ const age = Date.now() - fetchedTime;
1659
+ return age > URL_CACHE_TTL_MS;
1660
+ }
1661
+ return true;
1662
+ }
1663
+ function invalidateUrlCache(url) {
1664
+ return urlCache.delete(url);
1665
+ }
1666
+
1667
+ // libs/uipack/src/handlebars/helpers.ts
1668
+ function formatDate(date, format) {
1669
+ if (date === null || date === void 0) {
1670
+ return "";
1671
+ }
1672
+ let dateObj;
1673
+ if (date instanceof Date) {
1674
+ dateObj = date;
1675
+ } else if (typeof date === "string" || typeof date === "number") {
1676
+ dateObj = new Date(date);
1677
+ } else {
1678
+ return String(date);
1679
+ }
1680
+ if (isNaN(dateObj.getTime())) {
1681
+ return String(date);
1682
+ }
1683
+ const options = {};
1684
+ switch (format) {
1685
+ case "short":
1686
+ options.dateStyle = "short";
1687
+ break;
1688
+ case "medium":
1689
+ options.dateStyle = "medium";
1690
+ break;
1691
+ case "long":
1692
+ options.dateStyle = "long";
1693
+ break;
1694
+ case "full":
1695
+ options.dateStyle = "full";
1696
+ break;
1697
+ case "time":
1698
+ options.timeStyle = "short";
1699
+ break;
1700
+ case "datetime":
1701
+ options.dateStyle = "medium";
1702
+ options.timeStyle = "short";
1703
+ break;
1704
+ case "iso":
1705
+ return dateObj.toISOString();
1706
+ case "relative":
1707
+ return formatRelativeDate(dateObj);
1708
+ default:
1709
+ options.dateStyle = "medium";
1710
+ }
1711
+ return new Intl.DateTimeFormat("en-US", options).format(dateObj);
1712
+ }
1713
+ function formatRelativeDate(date) {
1714
+ const now = /* @__PURE__ */ new Date();
1715
+ const diffMs = now.getTime() - date.getTime();
1716
+ const diffSecs = Math.floor(diffMs / 1e3);
1717
+ const diffMins = Math.floor(diffSecs / 60);
1718
+ const diffHours = Math.floor(diffMins / 60);
1719
+ const diffDays = Math.floor(diffHours / 24);
1720
+ if (diffSecs < 60) {
1721
+ return "just now";
1722
+ } else if (diffMins < 60) {
1723
+ return `${diffMins} minute${diffMins === 1 ? "" : "s"} ago`;
1724
+ } else if (diffHours < 24) {
1725
+ return `${diffHours} hour${diffHours === 1 ? "" : "s"} ago`;
1726
+ } else if (diffDays < 7) {
1727
+ return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`;
1728
+ } else {
1729
+ return formatDate(date, "medium");
1730
+ }
1731
+ }
1732
+ function formatCurrency(amount, currency) {
1733
+ if (amount === null || amount === void 0) {
1734
+ return "";
1735
+ }
1736
+ const num = typeof amount === "number" ? amount : parseFloat(String(amount));
1737
+ if (isNaN(num)) {
1738
+ return String(amount);
1739
+ }
1740
+ return new Intl.NumberFormat("en-US", {
1741
+ style: "currency",
1742
+ currency: typeof currency === "string" ? currency : "USD"
1743
+ }).format(num);
1744
+ }
1745
+ function formatNumber(value, decimals) {
1746
+ if (value === null || value === void 0) {
1747
+ return "";
1748
+ }
1749
+ const num = typeof value === "number" ? value : parseFloat(String(value));
1750
+ if (isNaN(num)) {
1751
+ return String(value);
1752
+ }
1753
+ const options = {};
1754
+ if (typeof decimals === "number") {
1755
+ options.minimumFractionDigits = decimals;
1756
+ options.maximumFractionDigits = decimals;
1757
+ }
1758
+ return new Intl.NumberFormat("en-US", options).format(num);
1759
+ }
1760
+ function jsonEmbed(data) {
1761
+ const json2 = JSON.stringify(data ?? null);
1762
+ return json2.replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
1763
+ }
1764
+ function json(data, pretty) {
1765
+ return JSON.stringify(data ?? null, null, pretty ? 2 : void 0);
1766
+ }
1767
+ function eq(a, b) {
1768
+ return a === b;
1769
+ }
1770
+ function ne(a, b) {
1771
+ return a !== b;
1772
+ }
1773
+ function gt(a, b) {
1774
+ return Number(a) > Number(b);
1775
+ }
1776
+ function gte(a, b) {
1777
+ return Number(a) >= Number(b);
1778
+ }
1779
+ function lt(a, b) {
1780
+ return Number(a) < Number(b);
1781
+ }
1782
+ function lte(a, b) {
1783
+ return Number(a) <= Number(b);
1784
+ }
1785
+ function and(a, b) {
1786
+ return Boolean(a) && Boolean(b);
1787
+ }
1788
+ function or(a, b) {
1789
+ return Boolean(a) || Boolean(b);
1790
+ }
1791
+ function not(value) {
1792
+ return !value;
1793
+ }
1794
+ function first(arr) {
1795
+ if (!Array.isArray(arr)) return void 0;
1796
+ return arr[0];
1797
+ }
1798
+ function last(arr) {
1799
+ if (!Array.isArray(arr)) return void 0;
1800
+ return arr[arr.length - 1];
1801
+ }
1802
+ function length(value) {
1803
+ if (Array.isArray(value)) return value.length;
1804
+ if (typeof value === "string") return value.length;
1805
+ return 0;
1806
+ }
1807
+ function includes(arr, value) {
1808
+ if (!Array.isArray(arr)) return false;
1809
+ return arr.includes(value);
1810
+ }
1811
+ function join(arr, separator) {
1812
+ if (!Array.isArray(arr)) return "";
1813
+ return arr.join(typeof separator === "string" ? separator : ", ");
1814
+ }
1815
+ function uppercase(str) {
1816
+ return String(str ?? "").toUpperCase();
1817
+ }
1818
+ function lowercase(str) {
1819
+ return String(str ?? "").toLowerCase();
1820
+ }
1821
+ function capitalize(str) {
1822
+ const s = String(str ?? "");
1823
+ return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
1824
+ }
1825
+ function truncate(str, maxLength, suffix) {
1826
+ const s = String(str ?? "");
1827
+ const len = typeof maxLength === "number" ? maxLength : 50;
1828
+ const suf = typeof suffix === "string" ? suffix : "...";
1829
+ if (s.length <= len) return s;
1830
+ return s.slice(0, len - suf.length) + suf;
1831
+ }
1832
+ function defaultValue(value, defaultValue2) {
1833
+ return value || defaultValue2;
1834
+ }
1835
+ var idCounter = 0;
1836
+ function uniqueId(prefix) {
1837
+ const id = ++idCounter;
1838
+ return prefix ? `${prefix}-${id}` : `id-${id}`;
1839
+ }
1840
+ function classNames(...classes) {
1841
+ return classes.filter(Boolean).map(String).join(" ");
1842
+ }
1843
+ var builtinHelpers = {
1844
+ // Escaping
1845
+ escapeHtml,
1846
+ // Formatting
1847
+ formatDate,
1848
+ formatCurrency,
1849
+ formatNumber,
1850
+ json,
1851
+ jsonEmbed,
1852
+ // Comparison
1853
+ eq,
1854
+ ne,
1855
+ gt,
1856
+ gte,
1857
+ lt,
1858
+ lte,
1859
+ // Logical
1860
+ and,
1861
+ or,
1862
+ not,
1863
+ // Array
1864
+ first,
1865
+ last,
1866
+ length,
1867
+ includes,
1868
+ join,
1869
+ // String
1870
+ uppercase,
1871
+ lowercase,
1872
+ capitalize,
1873
+ truncate,
1874
+ // Utility
1875
+ default: defaultValue,
1876
+ uniqueId,
1877
+ classNames
1878
+ };
1879
+
1880
+ // libs/uipack/src/handlebars/expression-extractor.ts
1881
+ var EXPRESSION_REGEX = /\{\{\{?(?!!)(#|\/)?([^}]+?)\}?\}\}/g;
1882
+ var PATH_REGEX = /\b(output|input|structuredContent)(\.[a-zA-Z_$][a-zA-Z0-9_$]*|\.\[[^\]]+\])+/g;
1883
+ var KEYWORDS = /* @__PURE__ */ new Set(["this", "else", "@index", "@key", "@first", "@last", "@root"]);
1884
+ function extractExpressions(template) {
1885
+ const expressions = [];
1886
+ const lines = template.split("\n");
1887
+ const positionMap = buildPositionMap(template);
1888
+ let match;
1889
+ EXPRESSION_REGEX.lastIndex = 0;
1890
+ while ((match = EXPRESSION_REGEX.exec(template)) !== null) {
1891
+ const fullExpression = match[0];
1892
+ const prefix = match[1];
1893
+ const content = match[2].trim();
1894
+ const position = positionMap.get(match.index) ?? { line: 1, column: 1 };
1895
+ let type = "variable";
1896
+ let helperName;
1897
+ if (prefix === "/") {
1898
+ type = "block-close";
1899
+ helperName = content;
1900
+ } else if (prefix === "#") {
1901
+ type = "block";
1902
+ const parts = content.split(/\s+/);
1903
+ helperName = parts[0];
1904
+ } else {
1905
+ const parts = content.split(/\s+/);
1906
+ if (parts.length > 1 && !content.startsWith("(")) {
1907
+ const firstToken = parts[0];
1908
+ if (!firstToken.includes(".") && !KEYWORDS.has(firstToken)) {
1909
+ type = "helper";
1910
+ helperName = firstToken;
1911
+ }
1912
+ }
1913
+ }
1914
+ const paths = extractPathsFromContent(content);
1915
+ for (const path of paths) {
1916
+ expressions.push({
1917
+ path,
1918
+ fullExpression,
1919
+ line: position.line,
1920
+ column: position.column,
1921
+ type,
1922
+ helperName
1923
+ });
1924
+ }
1925
+ if (paths.length === 0 && type === "variable") {
1926
+ const cleanContent = content.trim();
1927
+ if (!KEYWORDS.has(cleanContent) && !cleanContent.includes(" ") && !cleanContent.startsWith("(")) {
1928
+ }
1929
+ }
1930
+ }
1931
+ return expressions;
1932
+ }
1933
+ function extractPathsFromContent(content) {
1934
+ const paths = [];
1935
+ let match;
1936
+ const regex = new RegExp(PATH_REGEX.source, "g");
1937
+ while ((match = regex.exec(content)) !== null) {
1938
+ paths.push(match[0]);
1939
+ }
1940
+ return paths;
1941
+ }
1942
+ function buildPositionMap(template) {
1943
+ const map = /* @__PURE__ */ new Map();
1944
+ let line = 1;
1945
+ let column = 1;
1946
+ for (let i = 0; i < template.length; i++) {
1947
+ map.set(i, { line, column });
1948
+ if (template[i] === "\n") {
1949
+ line++;
1950
+ column = 1;
1951
+ } else {
1952
+ column++;
1953
+ }
1954
+ }
1955
+ return map;
1956
+ }
1957
+ function extractAll(template) {
1958
+ const expressions = extractExpressions(template);
1959
+ const paths = [...new Set(expressions.map((e) => e.path))];
1960
+ return {
1961
+ expressions,
1962
+ paths,
1963
+ outputPaths: paths.filter((p) => p.startsWith("output.")),
1964
+ inputPaths: paths.filter((p) => p.startsWith("input.")),
1965
+ structuredContentPaths: paths.filter((p) => p.startsWith("structuredContent."))
1966
+ };
1967
+ }
1968
+ function normalizePath(path) {
1969
+ return path.replace(/\.\d+\./g, ".[].").replace(/\.\d+$/g, ".[]").replace(/\[\d+\]/g, ".[]");
1970
+ }
1971
+
1972
+ // libs/uipack/src/handlebars/index.ts
1973
+ var Handlebars = null;
1974
+ async function loadHandlebars() {
1975
+ if (Handlebars !== null) {
1976
+ return Handlebars;
1977
+ }
1978
+ try {
1979
+ Handlebars = await import("handlebars");
1980
+ return Handlebars;
1981
+ } catch {
1982
+ throw new Error("Handlebars is required for template rendering. Install it: npm install handlebars");
1983
+ }
1984
+ }
1985
+ var HandlebarsRenderer = class {
1986
+ options;
1987
+ compiledTemplates = /* @__PURE__ */ new Map();
1988
+ initialized = false;
1989
+ hbs = null;
1990
+ constructor(options = {}) {
1991
+ this.options = {
1992
+ strict: false,
1993
+ autoEscape: true,
1994
+ ...options
1995
+ };
1996
+ }
1997
+ /**
1998
+ * Initialize the renderer with Handlebars.
1999
+ */
2000
+ async init() {
2001
+ if (this.initialized) return;
2002
+ this.hbs = await loadHandlebars();
2003
+ for (const [name, helper] of Object.entries(builtinHelpers)) {
2004
+ this.hbs.registerHelper(name, helper);
2005
+ }
2006
+ if (this.options.helpers) {
2007
+ for (const [name, helper] of Object.entries(this.options.helpers)) {
2008
+ this.hbs.registerHelper(name, helper);
2009
+ }
2010
+ }
2011
+ if (this.options.partials) {
2012
+ for (const [name, template] of Object.entries(this.options.partials)) {
2013
+ this.hbs.registerPartial(name, template);
2014
+ }
2015
+ }
2016
+ this.initialized = true;
2017
+ }
2018
+ /**
2019
+ * Render a Handlebars template.
2020
+ *
2021
+ * @param template - Template string
2022
+ * @param context - Render context with input/output
2023
+ * @returns Rendered HTML string
2024
+ */
2025
+ async render(template, context) {
2026
+ await this.init();
2027
+ if (!this.hbs) {
2028
+ throw new Error("Handlebars not initialized");
2029
+ }
2030
+ let compiled = this.compiledTemplates.get(template);
2031
+ if (!compiled) {
2032
+ compiled = this.hbs.compile(template, {
2033
+ strict: this.options.strict,
2034
+ noEscape: !this.options.autoEscape
2035
+ });
2036
+ this.compiledTemplates.set(template, compiled);
2037
+ }
2038
+ const data = {
2039
+ input: context.input ?? {},
2040
+ output: context.output ?? {},
2041
+ structuredContent: context.structuredContent,
2042
+ // Also expose at root level for convenience
2043
+ ...context.input,
2044
+ ...typeof context.output === "object" && context.output !== null ? context.output : {}
2045
+ };
2046
+ try {
2047
+ return compiled(data);
2048
+ } catch (error) {
2049
+ throw new Error(`Template rendering failed: ${error instanceof Error ? error.message : String(error)}`);
2050
+ }
2051
+ }
2052
+ /**
2053
+ * Render a template synchronously.
2054
+ *
2055
+ * Note: Requires Handlebars to be pre-loaded. Use `render()` for async loading.
2056
+ *
2057
+ * @param template - Template string
2058
+ * @param context - Render context
2059
+ * @returns Rendered HTML string
2060
+ */
2061
+ renderSync(template, context) {
2062
+ if (!this.initialized || !this.hbs) {
2063
+ throw new Error("HandlebarsRenderer not initialized. Call render() first or use initSync().");
2064
+ }
2065
+ let compiled = this.compiledTemplates.get(template);
2066
+ if (!compiled) {
2067
+ compiled = this.hbs.compile(template, {
2068
+ strict: this.options.strict,
2069
+ noEscape: !this.options.autoEscape
2070
+ });
2071
+ this.compiledTemplates.set(template, compiled);
2072
+ }
2073
+ const data = {
2074
+ input: context.input ?? {},
2075
+ output: context.output ?? {},
2076
+ structuredContent: context.structuredContent,
2077
+ ...context.input,
2078
+ ...typeof context.output === "object" && context.output !== null ? context.output : {}
2079
+ };
2080
+ return compiled(data);
2081
+ }
2082
+ /**
2083
+ * Initialize synchronously (for environments where Handlebars is already loaded).
2084
+ */
2085
+ initSync(handlebars) {
2086
+ this.hbs = handlebars;
2087
+ for (const [name, helper] of Object.entries(builtinHelpers)) {
2088
+ this.hbs.registerHelper(name, helper);
2089
+ }
2090
+ if (this.options.helpers) {
2091
+ for (const [name, helper] of Object.entries(this.options.helpers)) {
2092
+ this.hbs.registerHelper(name, helper);
2093
+ }
2094
+ }
2095
+ if (this.options.partials) {
2096
+ for (const [name, template] of Object.entries(this.options.partials)) {
2097
+ this.hbs.registerPartial(name, template);
2098
+ }
2099
+ }
2100
+ this.initialized = true;
2101
+ }
2102
+ /**
2103
+ * Register a custom helper.
2104
+ *
2105
+ * @param name - Helper name
2106
+ * @param fn - Helper function
2107
+ */
2108
+ registerHelper(name, fn) {
2109
+ if (this.hbs) {
2110
+ this.hbs.registerHelper(name, fn);
2111
+ }
2112
+ if (!this.options.helpers) {
2113
+ this.options.helpers = {};
2114
+ }
2115
+ this.options.helpers[name] = fn;
2116
+ }
2117
+ /**
2118
+ * Register a partial template.
2119
+ *
2120
+ * @param name - Partial name
2121
+ * @param template - Partial template string
2122
+ */
2123
+ registerPartial(name, template) {
2124
+ if (this.hbs) {
2125
+ this.hbs.registerPartial(name, template);
2126
+ }
2127
+ if (!this.options.partials) {
2128
+ this.options.partials = {};
2129
+ }
2130
+ this.options.partials[name] = template;
2131
+ }
2132
+ /**
2133
+ * Clear compiled template cache.
2134
+ */
2135
+ clearCache() {
2136
+ this.compiledTemplates.clear();
2137
+ }
2138
+ /**
2139
+ * Check if a template string contains Handlebars syntax.
2140
+ *
2141
+ * @param template - Template string to check
2142
+ * @returns true if contains {{...}} syntax
2143
+ */
2144
+ static containsHandlebars(template) {
2145
+ return /\{\{(?!!)[\s\S]*?\}\}/.test(template);
2146
+ }
2147
+ /**
2148
+ * Check if the renderer is initialized.
2149
+ */
2150
+ get isInitialized() {
2151
+ return this.initialized;
2152
+ }
2153
+ };
2154
+ function containsHandlebars(template) {
2155
+ return HandlebarsRenderer.containsHandlebars(template);
2156
+ }
2157
+
2158
+ // libs/uipack/src/renderers/utils/detect.ts
2159
+ function containsMdxSyntax(source) {
2160
+ if (/<[A-Z][a-zA-Z0-9]*/.test(source)) {
2161
+ return true;
2162
+ }
2163
+ if (/^(import|export)\s/m.test(source)) {
2164
+ return true;
2165
+ }
2166
+ if (/\s(className|onClick|onChange|onSubmit|htmlFor|dangerouslySetInnerHTML)=/.test(source)) {
2167
+ return true;
2168
+ }
2169
+ if (/\{[^}"'\n]*\}/.test(source) && !/=\s*["'][^"']*\{/.test(source)) {
2170
+ return true;
2171
+ }
2172
+ if (/^---[\s\S]*?---/m.test(source)) {
2173
+ return true;
2174
+ }
2175
+ if (/<>|<\/>/.test(source)) {
2176
+ return true;
2177
+ }
2178
+ return false;
2179
+ }
2180
+
2181
+ // libs/uipack/src/renderers/utils/hash.ts
2182
+ function hashString(source) {
2183
+ let hash = 2166136261;
2184
+ for (let i = 0; i < source.length; i++) {
2185
+ hash ^= source.charCodeAt(i);
2186
+ hash = hash * 16777619 >>> 0;
2187
+ }
2188
+ return hash.toString(36);
2189
+ }
2190
+
2191
+ // libs/uipack/src/renderers/cache.ts
2192
+ var TranspileCache = class {
2193
+ cache = /* @__PURE__ */ new Map();
2194
+ maxSize;
2195
+ ttl;
2196
+ /** Cache statistics */
2197
+ stats = {
2198
+ hits: 0,
2199
+ misses: 0,
2200
+ evictions: 0
2201
+ };
2202
+ constructor(options = {}) {
2203
+ this.maxSize = options.maxSize ?? 500;
2204
+ this.ttl = options.ttl ?? 0;
2205
+ }
2206
+ /**
2207
+ * Get a cached transpile result by source content.
2208
+ *
2209
+ * @param source - Source code to look up
2210
+ * @returns Cached result or undefined if not found/expired
2211
+ */
2212
+ get(source) {
2213
+ const key = hashString(source);
2214
+ return this.getByKey(key);
2215
+ }
2216
+ /**
2217
+ * Get a cached transpile result by hash key.
2218
+ *
2219
+ * @param key - Hash key
2220
+ * @returns Cached result or undefined if not found/expired
2221
+ */
2222
+ getByKey(key) {
2223
+ const entry = this.cache.get(key);
2224
+ if (!entry) {
2225
+ this.stats.misses++;
2226
+ return void 0;
2227
+ }
2228
+ if (this.ttl > 0 && Date.now() - entry.timestamp > this.ttl) {
2229
+ this.cache.delete(key);
2230
+ this.stats.misses++;
2231
+ return void 0;
2232
+ }
2233
+ this.cache.delete(key);
2234
+ entry.accessCount++;
2235
+ this.cache.set(key, entry);
2236
+ this.stats.hits++;
2237
+ return entry.value;
2238
+ }
2239
+ /**
2240
+ * Store a transpile result.
2241
+ *
2242
+ * @param source - Source code (used to generate key)
2243
+ * @param value - Transpile result to cache
2244
+ * @returns The hash key used for storage
2245
+ */
2246
+ set(source, value) {
2247
+ const key = hashString(source);
2248
+ this.setByKey(key, value);
2249
+ return key;
2250
+ }
2251
+ /**
2252
+ * Store a transpile result by hash key.
2253
+ *
2254
+ * @param key - Hash key
2255
+ * @param value - Transpile result to cache
2256
+ */
2257
+ setByKey(key, value) {
2258
+ if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
2259
+ const oldestKey = this.cache.keys().next().value;
2260
+ if (oldestKey) {
2261
+ this.cache.delete(oldestKey);
2262
+ this.stats.evictions++;
2263
+ }
2264
+ }
2265
+ this.cache.set(key, {
2266
+ value,
2267
+ timestamp: Date.now(),
2268
+ accessCount: 1
2269
+ });
2270
+ }
2271
+ /**
2272
+ * Check if a source is cached.
2273
+ *
2274
+ * @param source - Source code to check
2275
+ * @returns True if cached and not expired
2276
+ */
2277
+ has(source) {
2278
+ const key = hashString(source);
2279
+ return this.hasByKey(key);
2280
+ }
2281
+ /**
2282
+ * Check if a key is cached.
2283
+ *
2284
+ * @param key - Hash key to check
2285
+ * @returns True if cached and not expired
2286
+ */
2287
+ hasByKey(key) {
2288
+ const entry = this.cache.get(key);
2289
+ if (!entry) return false;
2290
+ if (this.ttl > 0 && Date.now() - entry.timestamp > this.ttl) {
2291
+ this.cache.delete(key);
2292
+ return false;
2293
+ }
2294
+ return true;
2295
+ }
2296
+ /**
2297
+ * Delete a cached entry by source.
2298
+ *
2299
+ * @param source - Source code to delete
2300
+ * @returns True if entry was deleted
2301
+ */
2302
+ delete(source) {
2303
+ const key = hashString(source);
2304
+ return this.cache.delete(key);
2305
+ }
2306
+ /**
2307
+ * Clear all cached entries.
2308
+ */
2309
+ clear() {
2310
+ this.cache.clear();
2311
+ this.stats = { hits: 0, misses: 0, evictions: 0 };
2312
+ }
2313
+ /**
2314
+ * Get current cache size.
2315
+ */
2316
+ get size() {
2317
+ return this.cache.size;
2318
+ }
2319
+ /**
2320
+ * Get cache statistics.
2321
+ */
2322
+ getStats() {
2323
+ const total = this.stats.hits + this.stats.misses;
2324
+ return {
2325
+ ...this.stats,
2326
+ size: this.cache.size,
2327
+ hitRate: total > 0 ? this.stats.hits / total : 0
2328
+ };
2329
+ }
2330
+ };
2331
+ var transpileCache = new TranspileCache({ maxSize: 500 });
2332
+ var renderCache = new TranspileCache({
2333
+ maxSize: 1e3,
2334
+ ttl: 5 * 60 * 1e3
2335
+ // 5 minutes
2336
+ });
2337
+ var ComponentCache = class {
2338
+ cache = /* @__PURE__ */ new Map();
2339
+ maxSize;
2340
+ constructor(maxSize = 200) {
2341
+ this.maxSize = maxSize;
2342
+ }
2343
+ get(key) {
2344
+ const entry = this.cache.get(key);
2345
+ if (!entry) return void 0;
2346
+ this.cache.delete(key);
2347
+ this.cache.set(key, entry);
2348
+ return entry.value;
2349
+ }
2350
+ set(key, value) {
2351
+ if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
2352
+ const oldestKey = this.cache.keys().next().value;
2353
+ if (oldestKey) {
2354
+ this.cache.delete(oldestKey);
2355
+ }
2356
+ }
2357
+ this.cache.set(key, { value, timestamp: Date.now() });
2358
+ }
2359
+ has(key) {
2360
+ return this.cache.has(key);
2361
+ }
2362
+ delete(key) {
2363
+ return this.cache.delete(key);
2364
+ }
2365
+ clear() {
2366
+ this.cache.clear();
2367
+ }
2368
+ get size() {
2369
+ return this.cache.size;
2370
+ }
2371
+ };
2372
+ var componentCache = new ComponentCache();
2373
+
2374
+ // libs/uipack/src/renderers/mdx.renderer.ts
2375
+ var REACT_CDN = {
2376
+ react: "https://unpkg.com/react@18/umd/react.production.min.js",
2377
+ reactDom: "https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"
2378
+ };
2379
+ var INLINE_MDX_PLACEHOLDER = `
2380
+ // MDX runtime not available inline yet.
2381
+ // For blocked-network platforms, use pre-rendered HTML templates.
2382
+ console.warn('[FrontMCP] MDX hydration not available on this platform.');
2383
+ `;
2384
+ var MdxRenderer = class {
2385
+ type = "mdx";
2386
+ priority = 10;
2387
+ // Between HTML (0) and React (20)
2388
+ /**
2389
+ * Lazy-loaded modules.
2390
+ */
2391
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2392
+ React = null;
2393
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2394
+ ReactDOMServer = null;
2395
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2396
+ jsxRuntime = null;
2397
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2398
+ mdxEvaluate = null;
2399
+ /**
2400
+ * Check if this renderer can handle the given template.
2401
+ *
2402
+ * Accepts strings containing MDX syntax (Markdown + JSX).
2403
+ */
2404
+ canHandle(template) {
2405
+ if (typeof template !== "string") {
2406
+ return false;
2407
+ }
2408
+ return containsMdxSyntax(template);
2409
+ }
2410
+ /**
2411
+ * Transpile MDX to executable JavaScript.
2412
+ *
2413
+ * Uses @mdx-js/mdx to compile MDX source to a module.
2414
+ * Note: For MDX, we use evaluate() which combines compile + run,
2415
+ * so this method just returns the source hash for caching purposes.
2416
+ */
2417
+ async transpile(template, _options) {
2418
+ const hash = hashString(template);
2419
+ const cached = transpileCache.getByKey(hash);
2420
+ if (cached) {
2421
+ return { ...cached, cached: true };
2422
+ }
2423
+ const transpileResult = {
2424
+ code: template,
2425
+ // Store original MDX for evaluate()
2426
+ hash,
2427
+ cached: false
2428
+ };
2429
+ transpileCache.setByKey(hash, transpileResult);
2430
+ return transpileResult;
2431
+ }
2432
+ /**
2433
+ * Render MDX template to HTML string.
2434
+ *
2435
+ * Uses @mdx-js/mdx's evaluate() for clean compilation + execution,
2436
+ * then renders the resulting React component to HTML via SSR.
2437
+ */
2438
+ async render(template, context, options) {
2439
+ await this.loadReact();
2440
+ await this.loadMdx();
2441
+ if (!this.mdxEvaluate) {
2442
+ throw new Error("MDX compilation requires @mdx-js/mdx. Install it: npm install @mdx-js/mdx");
2443
+ }
2444
+ const templateHash = hashString(template);
2445
+ const cacheKey = `mdx-component:${templateHash}`;
2446
+ let Content = componentCache.get(cacheKey);
2447
+ if (!Content) {
2448
+ const result = await this.mdxEvaluate(template, {
2449
+ ...this.jsxRuntime,
2450
+ Fragment: this.React.Fragment,
2451
+ development: false
2452
+ });
2453
+ Content = result.default;
2454
+ componentCache.set(cacheKey, Content);
2455
+ }
2456
+ const mdxComponents = {
2457
+ // User-provided components from tool config
2458
+ ...options?.mdxComponents,
2459
+ // Wrapper that provides context to the content
2460
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2461
+ wrapper: ({ children }) => {
2462
+ return this.React.createElement("div", { className: "mdx-content" }, children);
2463
+ }
2464
+ };
2465
+ const props = {
2466
+ input: context.input,
2467
+ output: context.output,
2468
+ structuredContent: context.structuredContent,
2469
+ helpers: context.helpers
2470
+ };
2471
+ const spreadProps = {
2472
+ ...props,
2473
+ ...typeof context.output === "object" && context.output !== null ? context.output : {}
2474
+ };
2475
+ const element = this.React.createElement(Content, {
2476
+ components: mdxComponents,
2477
+ ...spreadProps
2478
+ });
2479
+ const html = this.ReactDOMServer.renderToString(element);
2480
+ if (options?.hydrate) {
2481
+ const escapedProps = JSON.stringify(props).replace(/&/g, "&amp;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2482
+ return `<div data-mdx-hydrate="true" data-props='${escapedProps}'>${html}</div>`;
2483
+ }
2484
+ return html;
2485
+ }
2486
+ /**
2487
+ * Get runtime scripts for client-side functionality.
2488
+ */
2489
+ getRuntimeScripts(platform) {
2490
+ if (platform.networkMode === "blocked") {
2491
+ return {
2492
+ headScripts: "",
2493
+ inlineScripts: INLINE_MDX_PLACEHOLDER,
2494
+ isInline: true
2495
+ };
2496
+ }
2497
+ return {
2498
+ headScripts: `
2499
+ <script crossorigin src="${REACT_CDN.react}"></script>
2500
+ <script crossorigin src="${REACT_CDN.reactDom}"></script>
2501
+ `,
2502
+ isInline: false
2503
+ };
2504
+ }
2505
+ /**
2506
+ * Load React and ReactDOMServer modules.
2507
+ */
2508
+ async loadReact() {
2509
+ if (this.React && this.ReactDOMServer && this.jsxRuntime) {
2510
+ return;
2511
+ }
2512
+ try {
2513
+ const [react, reactDomServer, jsxRuntime] = await Promise.all([
2514
+ import("react"),
2515
+ import("react-dom/server"),
2516
+ import("react/jsx-runtime")
2517
+ ]);
2518
+ this.React = react;
2519
+ this.ReactDOMServer = reactDomServer;
2520
+ this.jsxRuntime = jsxRuntime;
2521
+ } catch {
2522
+ throw new Error("React is required for MdxRenderer. Install react and react-dom: npm install react react-dom");
2523
+ }
2524
+ }
2525
+ /**
2526
+ * Load @mdx-js/mdx evaluate function.
2527
+ *
2528
+ * evaluate() is the cleanest way to run MDX - it combines
2529
+ * compile and run in a single step, handling all the runtime
2530
+ * injection automatically.
2531
+ */
2532
+ async loadMdx() {
2533
+ if (this.mdxEvaluate) {
2534
+ return;
2535
+ }
2536
+ try {
2537
+ const mdx = await import("@mdx-js/mdx");
2538
+ this.mdxEvaluate = mdx.evaluate;
2539
+ } catch {
2540
+ console.warn(
2541
+ "[@frontmcp/ui] @mdx-js/mdx not available. MDX rendering disabled. Install @mdx-js/mdx to enable: npm install @mdx-js/mdx"
2542
+ );
2543
+ }
2544
+ }
2545
+ };
2546
+ var mdxRenderer = new MdxRenderer();
2547
+
2548
+ // libs/uipack/src/validation/schema-paths.ts
2549
+ import { z as z2 } from "zod";
2550
+ function extractSchemaPaths(schema, prefix = "output", options = {}) {
2551
+ const { maxDepth = 10, includeArrayItems = true } = options;
2552
+ const paths = [];
2553
+ const visited = /* @__PURE__ */ new Set();
2554
+ function recurse(currentSchema, currentPath, depth, isOptional, isNullable, isArrayItem) {
2555
+ if (depth > maxDepth) return;
2556
+ const pathKey = `${currentPath}:${depth}`;
2557
+ if (visited.has(pathKey)) return;
2558
+ visited.add(pathKey);
2559
+ const description = currentSchema.description;
2560
+ const innerType = unwrapType(currentSchema);
2561
+ paths.push({
2562
+ path: currentPath,
2563
+ zodType: currentSchema,
2564
+ optional: isOptional,
2565
+ nullable: isNullable,
2566
+ isArrayItem,
2567
+ description
2568
+ });
2569
+ if (innerType instanceof z2.ZodObject) {
2570
+ const shape = innerType.shape;
2571
+ for (const [key, value] of Object.entries(shape)) {
2572
+ const childSchema = value;
2573
+ const childOptional = isOptional || isOptionalType(childSchema);
2574
+ const childNullable = isNullable || isNullableType(childSchema);
2575
+ recurse(childSchema, `${currentPath}.${key}`, depth + 1, childOptional, childNullable, false);
2576
+ }
2577
+ } else if (innerType instanceof z2.ZodArray && includeArrayItems) {
2578
+ const itemSchema = innerType.element;
2579
+ recurse(itemSchema, `${currentPath}.[]`, depth + 1, isOptional, isNullable, true);
2580
+ } else if (innerType instanceof z2.ZodUnion || innerType instanceof z2.ZodDiscriminatedUnion) {
2581
+ const options2 = "options" in innerType ? innerType.options : [];
2582
+ for (const option of options2) {
2583
+ recurse(option, currentPath, depth, isOptional, isNullable, isArrayItem);
2584
+ }
2585
+ } else if (innerType instanceof z2.ZodIntersection) {
2586
+ recurse(innerType._def.left, currentPath, depth, isOptional, isNullable, isArrayItem);
2587
+ recurse(innerType._def.right, currentPath, depth, isOptional, isNullable, isArrayItem);
2588
+ } else if (innerType instanceof z2.ZodRecord) {
2589
+ const valueSchema = innerType._def.valueType;
2590
+ recurse(valueSchema, `${currentPath}.[]`, depth + 1, isOptional, isNullable, true);
2591
+ } else if (innerType instanceof z2.ZodTuple) {
2592
+ const items = innerType._def.items;
2593
+ items.forEach((item, index) => {
2594
+ recurse(item, `${currentPath}.${index}`, depth + 1, isOptional, isNullable, true);
2595
+ });
2596
+ }
2597
+ }
2598
+ recurse(schema, prefix, 0, false, false, false);
2599
+ const seen = /* @__PURE__ */ new Set();
2600
+ return paths.filter((p) => {
2601
+ if (seen.has(p.path)) return false;
2602
+ seen.add(p.path);
2603
+ return true;
2604
+ });
2605
+ }
2606
+ function unwrapType(schema) {
2607
+ if (schema instanceof z2.ZodOptional) {
2608
+ return unwrapType(schema.unwrap());
2609
+ }
2610
+ if (schema instanceof z2.ZodNullable) {
2611
+ return unwrapType(schema.unwrap());
2612
+ }
2613
+ if (schema instanceof z2.ZodDefault) {
2614
+ return unwrapType(schema._def.innerType);
2615
+ }
2616
+ if (schema instanceof z2.ZodCatch && "innerType" in schema._def) {
2617
+ return unwrapType(schema._def.innerType);
2618
+ }
2619
+ return schema;
2620
+ }
2621
+ function isOptionalType(schema) {
2622
+ if (schema instanceof z2.ZodOptional) return true;
2623
+ if (schema instanceof z2.ZodDefault) return true;
2624
+ if (schema instanceof z2.ZodNullable) return isOptionalType(schema.unwrap());
2625
+ return false;
2626
+ }
2627
+ function isNullableType(schema) {
2628
+ if (schema instanceof z2.ZodNullable) return true;
2629
+ if (schema instanceof z2.ZodOptional) return isNullableType(schema.unwrap());
2630
+ return false;
2631
+ }
2632
+ function getSchemaPathStrings(schema, prefix = "output") {
2633
+ const paths = extractSchemaPaths(schema, prefix);
2634
+ return new Set(paths.map((p) => p.path));
2635
+ }
2636
+
2637
+ // libs/uipack/src/validation/template-validator.ts
2638
+ function validateTemplate(template, outputSchema, options = {}) {
2639
+ const { inputSchema, warnOnOptional = true, suggestSimilar = true, maxSuggestionDistance = 3 } = options;
2640
+ const errors = [];
2641
+ const warnings = [];
2642
+ const extraction = extractAll(template);
2643
+ const expressions = extractExpressions(template);
2644
+ const outputPaths = getSchemaPathStrings(outputSchema, "output");
2645
+ const inputPaths = inputSchema ? getSchemaPathStrings(inputSchema, "input") : /* @__PURE__ */ new Set();
2646
+ const outputPathInfos = extractSchemaPaths(outputSchema, "output");
2647
+ const inputPathInfos = inputSchema ? extractSchemaPaths(inputSchema, "input") : [];
2648
+ const pathInfoMap = /* @__PURE__ */ new Map();
2649
+ for (const info of [...outputPathInfos, ...inputPathInfos]) {
2650
+ pathInfoMap.set(info.path, info);
2651
+ }
2652
+ for (const expr of expressions) {
2653
+ const { path, fullExpression, line, column } = expr;
2654
+ let validPaths;
2655
+ let allPaths;
2656
+ if (path.startsWith("output.")) {
2657
+ validPaths = outputPaths;
2658
+ allPaths = Array.from(outputPaths);
2659
+ } else if (path.startsWith("input.")) {
2660
+ if (!inputSchema) {
2661
+ continue;
2662
+ }
2663
+ validPaths = inputPaths;
2664
+ allPaths = Array.from(inputPaths);
2665
+ } else if (path.startsWith("structuredContent.")) {
2666
+ continue;
2667
+ } else {
2668
+ continue;
2669
+ }
2670
+ const normalizedPath = normalizePath(path);
2671
+ const isValid = validPaths.has(path) || validPaths.has(normalizedPath);
2672
+ if (!isValid) {
2673
+ const isArrayAccess = checkArrayAccess(path, validPaths);
2674
+ if (!isArrayAccess) {
2675
+ const suggestions = suggestSimilar ? findSimilarPaths(path, allPaths, maxSuggestionDistance) : [];
2676
+ errors.push({
2677
+ type: "missing_field",
2678
+ path,
2679
+ expression: fullExpression,
2680
+ line,
2681
+ column,
2682
+ message: `Field '${getFieldName(path)}' does not exist in ${getSchemaName(path)} schema`,
2683
+ suggestions
2684
+ });
2685
+ }
2686
+ } else {
2687
+ const pathInfo = pathInfoMap.get(path) ?? pathInfoMap.get(normalizedPath);
2688
+ if (pathInfo && warnOnOptional) {
2689
+ if (pathInfo.optional && expr.type === "variable") {
2690
+ const hasGuard = hasConditionalGuard(template, path);
2691
+ if (!hasGuard) {
2692
+ warnings.push({
2693
+ type: "optional_field",
2694
+ path,
2695
+ expression: fullExpression,
2696
+ line,
2697
+ message: `Accessing optional field '${getFieldName(path)}' without {{#if}} guard`
2698
+ });
2699
+ }
2700
+ }
2701
+ }
2702
+ }
2703
+ }
2704
+ return {
2705
+ valid: errors.length === 0,
2706
+ errors,
2707
+ warnings,
2708
+ templatePaths: extraction.paths,
2709
+ schemaPaths: [...outputPaths, ...inputPaths]
2710
+ };
2711
+ }
2712
+ function checkArrayAccess(path, validPaths) {
2713
+ const parts = path.split(".");
2714
+ for (let i = 0; i < parts.length; i++) {
2715
+ if (/^\d+$/.test(parts[i])) {
2716
+ const wildcardParts = [...parts];
2717
+ wildcardParts[i] = "[]";
2718
+ const wildcardPath = wildcardParts.join(".");
2719
+ if (validPaths.has(wildcardPath)) {
2720
+ return true;
2721
+ }
2722
+ }
2723
+ }
2724
+ return false;
2725
+ }
2726
+ function getFieldName(path) {
2727
+ const parts = path.split(".");
2728
+ return parts[parts.length - 1];
2729
+ }
2730
+ function getSchemaName(path) {
2731
+ if (path.startsWith("output.")) return "output";
2732
+ if (path.startsWith("input.")) return "input";
2733
+ if (path.startsWith("structuredContent.")) return "structuredContent";
2734
+ return "unknown";
2735
+ }
2736
+ function hasConditionalGuard(template, path) {
2737
+ const guardPattern = new RegExp(`\\{\\{#if\\s+${escapeRegex(path)}`, "i");
2738
+ return guardPattern.test(template);
2739
+ }
2740
+ function escapeRegex(str) {
2741
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2742
+ }
2743
+ function findSimilarPaths(path, validPaths, maxDistance) {
2744
+ const fieldName = getFieldName(path);
2745
+ const prefix = path.substring(0, path.lastIndexOf(".") + 1);
2746
+ const suggestions = [];
2747
+ for (const validPath of validPaths) {
2748
+ if (!validPath.startsWith(prefix)) continue;
2749
+ const validFieldName = getFieldName(validPath);
2750
+ const distance = levenshteinDistance(fieldName, validFieldName);
2751
+ if (distance <= maxDistance && distance > 0) {
2752
+ suggestions.push({ path: validPath, distance });
2753
+ }
2754
+ }
2755
+ return suggestions.sort((a, b) => a.distance - b.distance).slice(0, 3).map((s) => s.path);
2756
+ }
2757
+ function levenshteinDistance(a, b) {
2758
+ const matrix = [];
2759
+ for (let i = 0; i <= a.length; i++) {
2760
+ matrix[i] = [i];
2761
+ }
2762
+ for (let j = 0; j <= b.length; j++) {
2763
+ matrix[0][j] = j;
2764
+ }
2765
+ for (let i = 1; i <= a.length; i++) {
2766
+ for (let j = 1; j <= b.length; j++) {
2767
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
2768
+ matrix[i][j] = Math.min(
2769
+ matrix[i - 1][j] + 1,
2770
+ // deletion
2771
+ matrix[i][j - 1] + 1,
2772
+ // insertion
2773
+ matrix[i - 1][j - 1] + cost
2774
+ // substitution
2775
+ );
2776
+ }
2777
+ }
2778
+ return matrix[a.length][b.length];
2779
+ }
2780
+ function formatValidationWarnings(result, toolName) {
2781
+ if (result.valid && result.warnings.length === 0) {
2782
+ return "";
2783
+ }
2784
+ const lines = [];
2785
+ if (result.errors.length > 0) {
2786
+ lines.push(`[FrontMCP] Template validation warnings for tool "${toolName}":`);
2787
+ lines.push("");
2788
+ for (const error of result.errors) {
2789
+ lines.push(` Line ${error.line}: ${error.expression}`);
2790
+ lines.push(` ${error.message}`);
2791
+ if (error.suggestions.length > 0) {
2792
+ lines.push(` Did you mean: ${error.suggestions.join(", ")}?`);
2793
+ }
2794
+ lines.push("");
2795
+ }
2796
+ const outputFields = result.schemaPaths.filter((p) => p.startsWith("output.") && p.split(".").length === 2).map((p) => p.replace("output.", ""));
2797
+ if (outputFields.length > 0) {
2798
+ lines.push(` Available output fields: ${outputFields.join(", ")}`);
2799
+ }
2800
+ }
2801
+ if (result.warnings.length > 0) {
2802
+ if (lines.length > 0) lines.push("");
2803
+ lines.push(` Warnings:`);
2804
+ for (const warning of result.warnings) {
2805
+ lines.push(` Line ${warning.line}: ${warning.message}`);
2806
+ }
2807
+ }
2808
+ return lines.join("\n");
2809
+ }
2810
+ function logValidationWarnings(result, toolName) {
2811
+ const formatted = formatValidationWarnings(result, toolName);
2812
+ if (formatted) {
2813
+ console.warn(formatted);
2814
+ }
2815
+ }
2816
+
2817
+ // libs/uipack/src/dependency/template-processor.ts
2818
+ function safeInputToRecord(input) {
2819
+ if (input && typeof input === "object" && !Array.isArray(input)) {
2820
+ return input;
2821
+ }
2822
+ return {};
2823
+ }
2824
+ var defaultHelpers = {
2825
+ escapeHtml,
2826
+ formatDate: (date, format) => {
2827
+ const d = date instanceof Date ? date : new Date(date);
2828
+ if (format === "iso") return d.toISOString();
2829
+ if (format === "time") return d.toLocaleTimeString();
2830
+ return d.toLocaleDateString();
2831
+ },
2832
+ formatCurrency: (amount, currency = "USD") => new Intl.NumberFormat("en-US", { style: "currency", currency }).format(amount),
2833
+ uniqueId: (prefix = "id") => `${prefix}-${Math.random().toString(36).substring(2, 9)}`,
2834
+ jsonEmbed: (data) => JSON.stringify(data).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026")
2835
+ };
2836
+ function getSourceName(source) {
2837
+ switch (source.type) {
2838
+ case "file":
2839
+ return source.path;
2840
+ case "url":
2841
+ return source.url;
2842
+ case "inline":
2843
+ return "inline-template";
2844
+ }
2845
+ }
2846
+ var handlebarsRenderer = null;
2847
+ async function getHandlebarsRenderer(customHelpers) {
2848
+ if (customHelpers) {
2849
+ const freshRenderer = new HandlebarsRenderer();
2850
+ for (const [name, fn] of Object.entries(customHelpers)) {
2851
+ freshRenderer.registerHelper(name, fn);
2852
+ }
2853
+ return freshRenderer;
2854
+ }
2855
+ if (!handlebarsRenderer) {
2856
+ handlebarsRenderer = new HandlebarsRenderer();
2857
+ }
2858
+ return handlebarsRenderer;
2859
+ }
2860
+ function clearHandlebarsCache() {
2861
+ if (handlebarsRenderer) {
2862
+ handlebarsRenderer.clearCache();
2863
+ }
2864
+ }
2865
+ var markedModule = null;
2866
+ async function loadMarked() {
2867
+ if (markedModule) {
2868
+ return markedModule;
2869
+ }
2870
+ try {
2871
+ const moduleName = "marked";
2872
+ markedModule = await import(
2873
+ /* webpackIgnore: true */
2874
+ moduleName
2875
+ );
2876
+ return markedModule;
2877
+ } catch {
2878
+ throw new Error("marked is required for Markdown rendering. Install it: npm install marked");
2879
+ }
2880
+ }
2881
+ async function isMarkedAvailable() {
2882
+ try {
2883
+ await loadMarked();
2884
+ return true;
2885
+ } catch {
2886
+ return false;
2887
+ }
2888
+ }
2889
+ async function processTemplate(resolved, options) {
2890
+ const { format, content } = resolved;
2891
+ const { context, handlebarsHelpers, outputSchema, inputSchema, toolName } = options;
2892
+ if (format === "react") {
2893
+ return {
2894
+ code: content,
2895
+ format: "react",
2896
+ needsBundling: true
2897
+ };
2898
+ }
2899
+ if (outputSchema && process.env["NODE_ENV"] !== "production" && containsHandlebars(content)) {
2900
+ const sourceName = getSourceName(resolved.source);
2901
+ const validation = validateTemplate(content, outputSchema, {
2902
+ inputSchema,
2903
+ warnOnOptional: true,
2904
+ suggestSimilar: true,
2905
+ toolName: toolName ?? sourceName
2906
+ });
2907
+ if (!validation.valid || validation.warnings.length > 0) {
2908
+ logValidationWarnings(validation, toolName ?? sourceName ?? "unknown");
2909
+ }
2910
+ }
2911
+ let processedContent = content;
2912
+ if (containsHandlebars(content)) {
2913
+ const hbs = await getHandlebarsRenderer(handlebarsHelpers);
2914
+ const renderContext = {
2915
+ input: safeInputToRecord(context.input),
2916
+ output: context.output,
2917
+ structuredContent: context.structuredContent
2918
+ };
2919
+ processedContent = await hbs.render(content, renderContext);
2920
+ }
2921
+ switch (format) {
2922
+ case "html":
2923
+ return {
2924
+ html: processedContent,
2925
+ format: "html"
2926
+ };
2927
+ case "markdown": {
2928
+ const { marked } = await loadMarked();
2929
+ const html = await marked.parse(processedContent);
2930
+ return {
2931
+ html,
2932
+ format: "markdown"
2933
+ };
2934
+ }
2935
+ case "mdx": {
2936
+ const templateContext = {
2937
+ input: context.input,
2938
+ output: context.output,
2939
+ structuredContent: context.structuredContent,
2940
+ helpers: defaultHelpers
2941
+ };
2942
+ const html = await mdxRenderer.render(processedContent, templateContext);
2943
+ return {
2944
+ html,
2945
+ format: "mdx"
2946
+ };
2947
+ }
2948
+ default:
2949
+ return {
2950
+ html: processedContent,
2951
+ format: "html"
2952
+ };
2953
+ }
2954
+ }
2955
+ async function processTemplates(items) {
2956
+ return Promise.all(items.map(({ resolved, options }) => processTemplate(resolved, options)));
2957
+ }
2958
+ function supportsHandlebars(format) {
2959
+ return format === "html" || format === "markdown" || format === "mdx";
2960
+ }
2961
+ function producesHtml(format) {
2962
+ return format !== "react";
2963
+ }
2964
+ function requiresBundling(format) {
2965
+ return format === "react";
2966
+ }
2967
+ async function processHtmlTemplate(content, context, helpers) {
2968
+ if (!containsHandlebars(content)) {
2969
+ return content;
2970
+ }
2971
+ const hbs = await getHandlebarsRenderer(helpers);
2972
+ const renderContext = {
2973
+ input: safeInputToRecord(context.input),
2974
+ output: context.output,
2975
+ structuredContent: context.structuredContent
2976
+ };
2977
+ return hbs.render(content, renderContext);
2978
+ }
2979
+ async function processMarkdownTemplate(content, context, helpers) {
2980
+ let processed = content;
2981
+ if (containsHandlebars(content)) {
2982
+ const hbs = await getHandlebarsRenderer(helpers);
2983
+ const renderContext = {
2984
+ input: safeInputToRecord(context.input),
2985
+ output: context.output,
2986
+ structuredContent: context.structuredContent
2987
+ };
2988
+ processed = await hbs.render(content, renderContext);
2989
+ }
2990
+ const { marked } = await loadMarked();
2991
+ return marked.parse(processed);
2992
+ }
2993
+ async function processMdxTemplate(content, context, helpers) {
2994
+ let processed = content;
2995
+ if (containsHandlebars(content)) {
2996
+ const hbs = await getHandlebarsRenderer(helpers);
2997
+ const renderContext = {
2998
+ input: safeInputToRecord(context.input),
2999
+ output: context.output,
3000
+ structuredContent: context.structuredContent
3001
+ };
3002
+ processed = await hbs.render(content, renderContext);
3003
+ }
3004
+ const templateContext = {
3005
+ input: context.input,
3006
+ output: context.output,
3007
+ structuredContent: context.structuredContent,
3008
+ helpers: defaultHelpers
3009
+ };
3010
+ return mdxRenderer.render(processed, templateContext);
3011
+ }
3012
+ export {
3013
+ CDN_PROVIDER_PRIORITY,
3014
+ DEFAULT_CDN_REGISTRY,
3015
+ DependencyResolutionError,
3016
+ DependencyResolver,
3017
+ NoProviderError,
3018
+ addScope,
3019
+ buildManifestMetadataSchema,
3020
+ buildManifestOutputsSchema,
3021
+ bundleTargetSchema,
3022
+ cacheStatsSchema,
3023
+ cdnDependencySchema,
3024
+ cdnPlatformTypeSchema,
3025
+ cdnProviderConfigSchema,
3026
+ cdnProviderSchema,
3027
+ cdnRegistryEntrySchema,
3028
+ clearHandlebarsCache,
3029
+ clearUrlCache,
3030
+ componentBuildManifestSchema,
3031
+ createClaudeResolver,
3032
+ createImportMap,
3033
+ createImportMapFromOverrides,
3034
+ createOpenAIResolver,
3035
+ createResolver,
3036
+ dependencyResolverOptionsSchema,
3037
+ detectFormatFromPath,
3038
+ detectFormatFromUrl,
3039
+ detectTemplateMode,
3040
+ detectTemplateSource,
3041
+ extractExternalPackages,
3042
+ fetchTemplateFromUrl,
3043
+ fileBundleOptionsSchema,
3044
+ fileTemplateConfigSchema,
3045
+ filterImportsByPackages,
3046
+ generateCDNScriptTags,
3047
+ generateDependencyHTML,
3048
+ generateESMScriptTags,
3049
+ generateImportMapForPackages,
3050
+ generateImportMapScriptTag,
3051
+ generateImportMapScriptTagMinified,
3052
+ generateUMDShim,
3053
+ getImportStats,
3054
+ getPackageCDNDependency,
3055
+ getPackageCDNUrl,
3056
+ getPackageName,
3057
+ getPackagePeerDependencies,
3058
+ getRegisteredPackages,
3059
+ getUrlCache,
3060
+ importMapSchema,
3061
+ importTypeSchema,
3062
+ invalidateUrlCache,
3063
+ isFileBasedTemplate,
3064
+ isMarkedAvailable,
3065
+ isPackageRegistered,
3066
+ lookupPackage,
3067
+ mergeImportMaps,
3068
+ mergeRegistries,
3069
+ needsRefetch,
3070
+ packageMetadataSchema,
3071
+ parseImports,
3072
+ parsedImportResultSchema,
3073
+ parsedImportSchema,
3074
+ processHtmlTemplate,
3075
+ processMarkdownTemplate,
3076
+ processMdxTemplate,
3077
+ processTemplate,
3078
+ processTemplates,
3079
+ producesHtml,
3080
+ readTemplateFromFile,
3081
+ requiresBundling,
3082
+ resolveAllDependencies,
3083
+ resolveDependencies,
3084
+ resolveFilePath,
3085
+ resolveTemplate,
3086
+ resolvedDependencySchema,
3087
+ safeParseBuildManifest,
3088
+ safeParseCDNDependency,
3089
+ safeParseFileTemplateConfig,
3090
+ supportsHandlebars,
3091
+ validateBuildManifest,
3092
+ validateCDNDependency,
3093
+ validateFileTemplateConfig,
3094
+ validateImportMap,
3095
+ validateTemplateUrl
3096
+ };