@frontmcp/ui 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (393) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +438 -0
  3. package/package.json +147 -0
  4. package/src/adapters/index.d.ts +10 -0
  5. package/src/adapters/index.js +18 -0
  6. package/src/adapters/index.js.map +1 -0
  7. package/src/adapters/platform-meta.d.ts +165 -0
  8. package/src/adapters/platform-meta.js +310 -0
  9. package/src/adapters/platform-meta.js.map +1 -0
  10. package/src/base-template/bridge.d.ts +89 -0
  11. package/src/base-template/bridge.js +452 -0
  12. package/src/base-template/bridge.js.map +1 -0
  13. package/src/base-template/default-base-template.d.ts +91 -0
  14. package/src/base-template/default-base-template.js +435 -0
  15. package/src/base-template/default-base-template.js.map +1 -0
  16. package/src/base-template/index.d.ts +14 -0
  17. package/src/base-template/index.js +30 -0
  18. package/src/base-template/index.js.map +1 -0
  19. package/src/base-template/polyfills.d.ts +30 -0
  20. package/src/base-template/polyfills.js +190 -0
  21. package/src/base-template/polyfills.js.map +1 -0
  22. package/src/base-template/theme-styles.d.ts +73 -0
  23. package/src/base-template/theme-styles.js +95 -0
  24. package/src/base-template/theme-styles.js.map +1 -0
  25. package/src/bridge/adapters/base-adapter.d.ts +103 -0
  26. package/src/bridge/adapters/base-adapter.js +314 -0
  27. package/src/bridge/adapters/base-adapter.js.map +1 -0
  28. package/src/bridge/adapters/claude.adapter.d.ts +66 -0
  29. package/src/bridge/adapters/claude.adapter.js +145 -0
  30. package/src/bridge/adapters/claude.adapter.js.map +1 -0
  31. package/src/bridge/adapters/ext-apps.adapter.d.ts +142 -0
  32. package/src/bridge/adapters/ext-apps.adapter.js +416 -0
  33. package/src/bridge/adapters/ext-apps.adapter.js.map +1 -0
  34. package/src/bridge/adapters/gemini.adapter.d.ts +63 -0
  35. package/src/bridge/adapters/gemini.adapter.js +160 -0
  36. package/src/bridge/adapters/gemini.adapter.js.map +1 -0
  37. package/src/bridge/adapters/generic.adapter.d.ts +55 -0
  38. package/src/bridge/adapters/generic.adapter.js +108 -0
  39. package/src/bridge/adapters/generic.adapter.js.map +1 -0
  40. package/src/bridge/adapters/index.d.ts +25 -0
  41. package/src/bridge/adapters/index.js +65 -0
  42. package/src/bridge/adapters/index.js.map +1 -0
  43. package/src/bridge/adapters/openai.adapter.d.ts +64 -0
  44. package/src/bridge/adapters/openai.adapter.js +194 -0
  45. package/src/bridge/adapters/openai.adapter.js.map +1 -0
  46. package/src/bridge/core/adapter-registry.d.ts +121 -0
  47. package/src/bridge/core/adapter-registry.js +271 -0
  48. package/src/bridge/core/adapter-registry.js.map +1 -0
  49. package/src/bridge/core/bridge-factory.d.ts +198 -0
  50. package/src/bridge/core/bridge-factory.js +428 -0
  51. package/src/bridge/core/bridge-factory.js.map +1 -0
  52. package/src/bridge/core/index.d.ts +9 -0
  53. package/src/bridge/core/index.js +22 -0
  54. package/src/bridge/core/index.js.map +1 -0
  55. package/src/bridge/index.d.ts +61 -0
  56. package/src/bridge/index.js +94 -0
  57. package/src/bridge/index.js.map +1 -0
  58. package/src/bridge/runtime/iife-generator.d.ts +61 -0
  59. package/src/bridge/runtime/iife-generator.js +940 -0
  60. package/src/bridge/runtime/iife-generator.js.map +1 -0
  61. package/src/bridge/runtime/index.d.ts +8 -0
  62. package/src/bridge/runtime/index.js +16 -0
  63. package/src/bridge/runtime/index.js.map +1 -0
  64. package/src/bridge/types.d.ts +385 -0
  65. package/src/bridge/types.js +11 -0
  66. package/src/bridge/types.js.map +1 -0
  67. package/src/build/cdn-resources.d.ts +140 -0
  68. package/src/build/cdn-resources.js +314 -0
  69. package/src/build/cdn-resources.js.map +1 -0
  70. package/src/build/index.d.ts +294 -0
  71. package/src/build/index.js +325 -0
  72. package/src/build/index.js.map +1 -0
  73. package/src/build/widget-manifest.d.ts +212 -0
  74. package/src/build/widget-manifest.js +652 -0
  75. package/src/build/widget-manifest.js.map +1 -0
  76. package/src/bundler/bundler.d.ts +110 -0
  77. package/src/bundler/bundler.js +432 -0
  78. package/src/bundler/bundler.js.map +1 -0
  79. package/src/bundler/cache.d.ts +172 -0
  80. package/src/bundler/cache.js +250 -0
  81. package/src/bundler/cache.js.map +1 -0
  82. package/src/bundler/index.d.ts +41 -0
  83. package/src/bundler/index.js +73 -0
  84. package/src/bundler/index.js.map +1 -0
  85. package/src/bundler/sandbox/enclave-adapter.d.ts +120 -0
  86. package/src/bundler/sandbox/enclave-adapter.js +339 -0
  87. package/src/bundler/sandbox/enclave-adapter.js.map +1 -0
  88. package/src/bundler/sandbox/executor.d.ts +13 -0
  89. package/src/bundler/sandbox/executor.js +22 -0
  90. package/src/bundler/sandbox/executor.js.map +1 -0
  91. package/src/bundler/sandbox/policy.d.ts +61 -0
  92. package/src/bundler/sandbox/policy.js +238 -0
  93. package/src/bundler/sandbox/policy.js.map +1 -0
  94. package/src/bundler/types.d.ts +347 -0
  95. package/src/bundler/types.js +132 -0
  96. package/src/bundler/types.js.map +1 -0
  97. package/src/components/alert.d.ts +71 -0
  98. package/src/components/alert.js +189 -0
  99. package/src/components/alert.js.map +1 -0
  100. package/src/components/alert.schema.d.ts +114 -0
  101. package/src/components/alert.schema.js +105 -0
  102. package/src/components/alert.schema.js.map +1 -0
  103. package/src/components/avatar.d.ts +76 -0
  104. package/src/components/avatar.js +176 -0
  105. package/src/components/avatar.js.map +1 -0
  106. package/src/components/avatar.schema.d.ts +169 -0
  107. package/src/components/avatar.schema.js +103 -0
  108. package/src/components/avatar.schema.js.map +1 -0
  109. package/src/components/badge.d.ts +70 -0
  110. package/src/components/badge.js +149 -0
  111. package/src/components/badge.js.map +1 -0
  112. package/src/components/badge.schema.d.ts +109 -0
  113. package/src/components/badge.schema.js +96 -0
  114. package/src/components/badge.schema.js.map +1 -0
  115. package/src/components/button.d.ts +111 -0
  116. package/src/components/button.js +336 -0
  117. package/src/components/button.js.map +1 -0
  118. package/src/components/button.schema.d.ts +148 -0
  119. package/src/components/button.schema.js +121 -0
  120. package/src/components/button.schema.js.map +1 -0
  121. package/src/components/card.d.ts +60 -0
  122. package/src/components/card.js +117 -0
  123. package/src/components/card.js.map +1 -0
  124. package/src/components/card.schema.d.ts +113 -0
  125. package/src/components/card.schema.js +98 -0
  126. package/src/components/card.schema.js.map +1 -0
  127. package/src/components/form.d.ts +239 -0
  128. package/src/components/form.js +420 -0
  129. package/src/components/form.js.map +1 -0
  130. package/src/components/form.schema.d.ts +441 -0
  131. package/src/components/form.schema.js +406 -0
  132. package/src/components/form.schema.js.map +1 -0
  133. package/src/components/index.d.ts +29 -0
  134. package/src/components/index.js +98 -0
  135. package/src/components/index.js.map +1 -0
  136. package/src/components/list.d.ts +127 -0
  137. package/src/components/list.js +279 -0
  138. package/src/components/list.js.map +1 -0
  139. package/src/components/list.schema.d.ts +134 -0
  140. package/src/components/list.schema.js +168 -0
  141. package/src/components/list.schema.js.map +1 -0
  142. package/src/components/modal.d.ts +111 -0
  143. package/src/components/modal.js +260 -0
  144. package/src/components/modal.js.map +1 -0
  145. package/src/components/modal.schema.d.ts +186 -0
  146. package/src/components/modal.schema.js +167 -0
  147. package/src/components/modal.schema.js.map +1 -0
  148. package/src/components/table.d.ts +105 -0
  149. package/src/components/table.js +283 -0
  150. package/src/components/table.js.map +1 -0
  151. package/src/components/table.schema.d.ts +159 -0
  152. package/src/components/table.schema.js +173 -0
  153. package/src/components/table.schema.js.map +1 -0
  154. package/src/handlebars/helpers.d.ts +348 -0
  155. package/src/handlebars/helpers.js +605 -0
  156. package/src/handlebars/helpers.js.map +1 -0
  157. package/src/handlebars/index.d.ts +193 -0
  158. package/src/handlebars/index.js +350 -0
  159. package/src/handlebars/index.js.map +1 -0
  160. package/src/index.d.ts +50 -0
  161. package/src/index.js +192 -0
  162. package/src/index.js.map +1 -0
  163. package/src/layouts/base.d.ts +88 -0
  164. package/src/layouts/base.js +227 -0
  165. package/src/layouts/base.js.map +1 -0
  166. package/src/layouts/index.d.ts +7 -0
  167. package/src/layouts/index.js +25 -0
  168. package/src/layouts/index.js.map +1 -0
  169. package/src/layouts/presets.d.ts +133 -0
  170. package/src/layouts/presets.js +277 -0
  171. package/src/layouts/presets.js.map +1 -0
  172. package/src/pages/consent.d.ts +116 -0
  173. package/src/pages/consent.js +218 -0
  174. package/src/pages/consent.js.map +1 -0
  175. package/src/pages/error.d.ts +100 -0
  176. package/src/pages/error.js +263 -0
  177. package/src/pages/error.js.map +1 -0
  178. package/src/pages/index.d.ts +8 -0
  179. package/src/pages/index.js +27 -0
  180. package/src/pages/index.js.map +1 -0
  181. package/src/react/Alert.d.ts +101 -0
  182. package/src/react/Alert.js +51 -0
  183. package/src/react/Alert.js.map +1 -0
  184. package/src/react/Badge.d.ts +100 -0
  185. package/src/react/Badge.js +55 -0
  186. package/src/react/Badge.js.map +1 -0
  187. package/src/react/Button.d.ts +108 -0
  188. package/src/react/Button.js +52 -0
  189. package/src/react/Button.js.map +1 -0
  190. package/src/react/Card.d.ts +103 -0
  191. package/src/react/Card.js +55 -0
  192. package/src/react/Card.js.map +1 -0
  193. package/src/react/hooks/context.d.ts +178 -0
  194. package/src/react/hooks/context.js +287 -0
  195. package/src/react/hooks/context.js.map +1 -0
  196. package/src/react/hooks/index.d.ts +41 -0
  197. package/src/react/hooks/index.js +61 -0
  198. package/src/react/hooks/index.js.map +1 -0
  199. package/src/react/hooks/tools.d.ts +283 -0
  200. package/src/react/hooks/tools.js +465 -0
  201. package/src/react/hooks/tools.js.map +1 -0
  202. package/src/react/index.d.ts +80 -0
  203. package/src/react/index.js +113 -0
  204. package/src/react/index.js.map +1 -0
  205. package/src/react/types.d.ts +105 -0
  206. package/src/react/types.js +12 -0
  207. package/src/react/types.js.map +1 -0
  208. package/src/react/utils.d.ts +42 -0
  209. package/src/react/utils.js +99 -0
  210. package/src/react/utils.js.map +1 -0
  211. package/src/registry/index.d.ts +45 -0
  212. package/src/registry/index.js +67 -0
  213. package/src/registry/index.js.map +1 -0
  214. package/src/registry/render-template.d.ts +86 -0
  215. package/src/registry/render-template.js +239 -0
  216. package/src/registry/render-template.js.map +1 -0
  217. package/src/registry/tool-ui.registry.d.ts +260 -0
  218. package/src/registry/tool-ui.registry.js +438 -0
  219. package/src/registry/tool-ui.registry.js.map +1 -0
  220. package/src/registry/uri-utils.d.ts +55 -0
  221. package/src/registry/uri-utils.js +97 -0
  222. package/src/registry/uri-utils.js.map +1 -0
  223. package/src/render/index.d.ts +7 -0
  224. package/src/render/index.js +14 -0
  225. package/src/render/index.js.map +1 -0
  226. package/src/render/prerender.d.ts +56 -0
  227. package/src/render/prerender.js +98 -0
  228. package/src/render/prerender.js.map +1 -0
  229. package/src/renderers/cache.d.ts +144 -0
  230. package/src/renderers/cache.js +240 -0
  231. package/src/renderers/cache.js.map +1 -0
  232. package/src/renderers/html.renderer.d.ts +122 -0
  233. package/src/renderers/html.renderer.js +204 -0
  234. package/src/renderers/html.renderer.js.map +1 -0
  235. package/src/renderers/index.d.ts +35 -0
  236. package/src/renderers/index.js +70 -0
  237. package/src/renderers/index.js.map +1 -0
  238. package/src/renderers/mdx.renderer.d.ts +119 -0
  239. package/src/renderers/mdx.renderer.js +305 -0
  240. package/src/renderers/mdx.renderer.js.map +1 -0
  241. package/src/renderers/react.renderer.d.ts +95 -0
  242. package/src/renderers/react.renderer.js +260 -0
  243. package/src/renderers/react.renderer.js.map +1 -0
  244. package/src/renderers/registry.d.ts +133 -0
  245. package/src/renderers/registry.js +232 -0
  246. package/src/renderers/registry.js.map +1 -0
  247. package/src/renderers/types.d.ts +341 -0
  248. package/src/renderers/types.js +9 -0
  249. package/src/renderers/types.js.map +1 -0
  250. package/src/renderers/utils/detect.d.ts +106 -0
  251. package/src/renderers/utils/detect.js +267 -0
  252. package/src/renderers/utils/detect.js.map +1 -0
  253. package/src/renderers/utils/hash.d.ts +39 -0
  254. package/src/renderers/utils/hash.js +75 -0
  255. package/src/renderers/utils/hash.js.map +1 -0
  256. package/src/renderers/utils/index.d.ts +8 -0
  257. package/src/renderers/utils/index.js +28 -0
  258. package/src/renderers/utils/index.js.map +1 -0
  259. package/src/renderers/utils/transpiler.d.ts +88 -0
  260. package/src/renderers/utils/transpiler.js +215 -0
  261. package/src/renderers/utils/transpiler.js.map +1 -0
  262. package/src/runtime/adapters/html.adapter.d.ts +58 -0
  263. package/src/runtime/adapters/html.adapter.js +131 -0
  264. package/src/runtime/adapters/html.adapter.js.map +1 -0
  265. package/src/runtime/adapters/index.d.ts +25 -0
  266. package/src/runtime/adapters/index.js +54 -0
  267. package/src/runtime/adapters/index.js.map +1 -0
  268. package/src/runtime/adapters/mdx.adapter.d.ts +72 -0
  269. package/src/runtime/adapters/mdx.adapter.js +241 -0
  270. package/src/runtime/adapters/mdx.adapter.js.map +1 -0
  271. package/src/runtime/adapters/react.adapter.d.ts +69 -0
  272. package/src/runtime/adapters/react.adapter.js +245 -0
  273. package/src/runtime/adapters/react.adapter.js.map +1 -0
  274. package/src/runtime/adapters/types.d.ts +94 -0
  275. package/src/runtime/adapters/types.js +11 -0
  276. package/src/runtime/adapters/types.js.map +1 -0
  277. package/src/runtime/csp.d.ts +37 -0
  278. package/src/runtime/csp.js +140 -0
  279. package/src/runtime/csp.js.map +1 -0
  280. package/src/runtime/index.d.ts +16 -0
  281. package/src/runtime/index.js +72 -0
  282. package/src/runtime/index.js.map +1 -0
  283. package/src/runtime/mcp-bridge.d.ts +100 -0
  284. package/src/runtime/mcp-bridge.js +581 -0
  285. package/src/runtime/mcp-bridge.js.map +1 -0
  286. package/src/runtime/renderer-runtime.d.ts +132 -0
  287. package/src/runtime/renderer-runtime.js +389 -0
  288. package/src/runtime/renderer-runtime.js.map +1 -0
  289. package/src/runtime/sanitizer.d.ts +171 -0
  290. package/src/runtime/sanitizer.js +318 -0
  291. package/src/runtime/sanitizer.js.map +1 -0
  292. package/src/runtime/types.d.ts +414 -0
  293. package/src/runtime/types.js +12 -0
  294. package/src/runtime/types.js.map +1 -0
  295. package/src/runtime/wrapper.d.ts +375 -0
  296. package/src/runtime/wrapper.js +1793 -0
  297. package/src/runtime/wrapper.js.map +1 -0
  298. package/src/styles/index.d.ts +7 -0
  299. package/src/styles/index.js +11 -0
  300. package/src/styles/index.js.map +1 -0
  301. package/src/styles/variants.d.ts +50 -0
  302. package/src/styles/variants.js +175 -0
  303. package/src/styles/variants.js.map +1 -0
  304. package/src/theme/cdn.d.ts +194 -0
  305. package/src/theme/cdn.js +375 -0
  306. package/src/theme/cdn.js.map +1 -0
  307. package/src/theme/index.d.ts +17 -0
  308. package/src/theme/index.js +57 -0
  309. package/src/theme/index.js.map +1 -0
  310. package/src/theme/platforms.d.ts +106 -0
  311. package/src/theme/platforms.js +161 -0
  312. package/src/theme/platforms.js.map +1 -0
  313. package/src/theme/presets/github-openai.d.ts +49 -0
  314. package/src/theme/presets/github-openai.js +189 -0
  315. package/src/theme/presets/github-openai.js.map +1 -0
  316. package/src/theme/presets/index.d.ts +10 -0
  317. package/src/theme/presets/index.js +17 -0
  318. package/src/theme/presets/index.js.map +1 -0
  319. package/src/theme/theme.d.ts +395 -0
  320. package/src/theme/theme.js +332 -0
  321. package/src/theme/theme.js.map +1 -0
  322. package/src/tool-template/builder.d.ts +212 -0
  323. package/src/tool-template/builder.js +397 -0
  324. package/src/tool-template/builder.js.map +1 -0
  325. package/src/tool-template/index.d.ts +15 -0
  326. package/src/tool-template/index.js +38 -0
  327. package/src/tool-template/index.js.map +1 -0
  328. package/src/types/index.d.ts +13 -0
  329. package/src/types/index.js +26 -0
  330. package/src/types/index.js.map +1 -0
  331. package/src/types/ui-config.d.ts +357 -0
  332. package/src/types/ui-config.js +12 -0
  333. package/src/types/ui-config.js.map +1 -0
  334. package/src/types/ui-runtime.d.ts +965 -0
  335. package/src/types/ui-runtime.js +117 -0
  336. package/src/types/ui-runtime.js.map +1 -0
  337. package/src/validation/error-box.d.ts +55 -0
  338. package/src/validation/error-box.js +75 -0
  339. package/src/validation/error-box.js.map +1 -0
  340. package/src/validation/index.d.ts +12 -0
  341. package/src/validation/index.js +21 -0
  342. package/src/validation/index.js.map +1 -0
  343. package/src/validation/wrapper.d.ts +96 -0
  344. package/src/validation/wrapper.js +117 -0
  345. package/src/validation/wrapper.js.map +1 -0
  346. package/src/web-components/core/attribute-parser.d.ts +85 -0
  347. package/src/web-components/core/attribute-parser.js +189 -0
  348. package/src/web-components/core/attribute-parser.js.map +1 -0
  349. package/src/web-components/core/base-element.d.ts +197 -0
  350. package/src/web-components/core/base-element.js +289 -0
  351. package/src/web-components/core/base-element.js.map +1 -0
  352. package/src/web-components/core/index.d.ts +8 -0
  353. package/src/web-components/core/index.js +18 -0
  354. package/src/web-components/core/index.js.map +1 -0
  355. package/src/web-components/elements/fmcp-alert.d.ts +45 -0
  356. package/src/web-components/elements/fmcp-alert.js +93 -0
  357. package/src/web-components/elements/fmcp-alert.js.map +1 -0
  358. package/src/web-components/elements/fmcp-badge.d.ts +46 -0
  359. package/src/web-components/elements/fmcp-badge.js +99 -0
  360. package/src/web-components/elements/fmcp-badge.js.map +1 -0
  361. package/src/web-components/elements/fmcp-button.d.ts +124 -0
  362. package/src/web-components/elements/fmcp-button.js +233 -0
  363. package/src/web-components/elements/fmcp-button.js.map +1 -0
  364. package/src/web-components/elements/fmcp-card.d.ts +52 -0
  365. package/src/web-components/elements/fmcp-card.js +115 -0
  366. package/src/web-components/elements/fmcp-card.js.map +1 -0
  367. package/src/web-components/elements/fmcp-input.d.ts +95 -0
  368. package/src/web-components/elements/fmcp-input.js +248 -0
  369. package/src/web-components/elements/fmcp-input.js.map +1 -0
  370. package/src/web-components/elements/fmcp-select.d.ts +99 -0
  371. package/src/web-components/elements/fmcp-select.js +243 -0
  372. package/src/web-components/elements/fmcp-select.js.map +1 -0
  373. package/src/web-components/elements/index.d.ts +12 -0
  374. package/src/web-components/elements/index.js +34 -0
  375. package/src/web-components/elements/index.js.map +1 -0
  376. package/src/web-components/index.d.ts +49 -0
  377. package/src/web-components/index.js +75 -0
  378. package/src/web-components/index.js.map +1 -0
  379. package/src/web-components/register.d.ts +56 -0
  380. package/src/web-components/register.js +80 -0
  381. package/src/web-components/register.js.map +1 -0
  382. package/src/web-components/types.d.ts +121 -0
  383. package/src/web-components/types.js +25 -0
  384. package/src/web-components/types.js.map +1 -0
  385. package/src/widgets/index.d.ts +7 -0
  386. package/src/widgets/index.js +24 -0
  387. package/src/widgets/index.js.map +1 -0
  388. package/src/widgets/progress.d.ts +132 -0
  389. package/src/widgets/progress.js +303 -0
  390. package/src/widgets/progress.js.map +1 -0
  391. package/src/widgets/resource.d.ts +162 -0
  392. package/src/widgets/resource.js +340 -0
  393. package/src/widgets/resource.js.map +1 -0
@@ -0,0 +1,140 @@
1
+ /**
2
+ * CDN Resource URLs
3
+ *
4
+ * Default CDN URLs for runtime dependencies (React, MDX, Handlebars, etc).
5
+ * These URLs are used when resourceMode is 'cdn' (default).
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { CDNResource, UIType, RendererAssets, ResourceMode } from '../types';
10
+ /**
11
+ * React 19 from esm.sh (ES module).
12
+ *
13
+ * React 19 removed UMD builds, so we use esm.sh which provides
14
+ * ES module builds that work in modern browsers.
15
+ */
16
+ export declare const REACT_CDN: CDNResource;
17
+ /**
18
+ * ReactDOM 19 client from esm.sh (ES module).
19
+ *
20
+ * React 19 removed UMD builds, so we use esm.sh which provides
21
+ * ES module builds that work in modern browsers.
22
+ */
23
+ export declare const REACT_DOM_CDN: CDNResource;
24
+ /**
25
+ * Marked markdown parser from unpkg.
26
+ */
27
+ export declare const MARKED_CDN: CDNResource;
28
+ /**
29
+ * Handlebars runtime from unpkg.
30
+ */
31
+ export declare const HANDLEBARS_CDN: CDNResource;
32
+ /**
33
+ * MDX runtime from esm.sh (for browser use).
34
+ * Note: MDX compilation typically happens server-side.
35
+ */
36
+ export declare const MDX_RUNTIME_CDN: CDNResource;
37
+ /**
38
+ * Tailwind CSS Browser CDN (play.tailwindcss.com CDN).
39
+ */
40
+ export declare const TAILWIND_CDN: CDNResource;
41
+ /**
42
+ * Get default CDN resources for a UI type.
43
+ *
44
+ * @param uiType - The UI renderer type
45
+ * @param mode - Resource loading mode (cdn or inline)
46
+ * @returns RendererAssets with appropriate CDN URLs
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * // Get CDN assets for React
51
+ * const assets = getDefaultAssets('react', 'cdn');
52
+ * console.log(assets.react.url);
53
+ * // "https://unpkg.com/react@18/umd/react.production.min.js"
54
+ * ```
55
+ */
56
+ export declare function getDefaultAssets(uiType: UIType, mode?: ResourceMode): RendererAssets;
57
+ /**
58
+ * Build a script tag for a CDN resource.
59
+ *
60
+ * @param resource - CDN resource configuration
61
+ * @param options - Additional script tag options
62
+ * @returns HTML script tag string
63
+ */
64
+ export declare function buildCDNScriptTag(resource: CDNResource, options?: {
65
+ async?: boolean;
66
+ defer?: boolean;
67
+ type?: string;
68
+ }): string;
69
+ /**
70
+ * Build all required script tags for a UI type.
71
+ *
72
+ * @param uiType - The UI renderer type
73
+ * @param mode - Resource mode (cdn or inline)
74
+ * @returns Array of script tag strings
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const scripts = buildScriptsForUIType('react', 'cdn');
79
+ * // Returns:
80
+ * // [
81
+ * // '<script src="https://unpkg.com/react@18/..." crossorigin="anonymous"></script>',
82
+ * // '<script src="https://unpkg.com/react-dom@18/..." crossorigin="anonymous"></script>',
83
+ * // ]
84
+ * ```
85
+ */
86
+ export declare function buildScriptsForUIType(uiType: UIType, mode?: ResourceMode): string[];
87
+ /**
88
+ * Build a Tailwind script tag.
89
+ *
90
+ * @param config - Optional Tailwind config to inline
91
+ * @returns Tailwind script tag(s)
92
+ */
93
+ export declare function buildTailwindScriptTag(config?: string): string;
94
+ /**
95
+ * Check if inline scripts are available in cache.
96
+ *
97
+ * Inline scripts need to be pre-fetched and cached before use.
98
+ * This is typically done at build time or server startup.
99
+ */
100
+ export declare function hasInlineScripts(): boolean;
101
+ /**
102
+ * Get all CDN URLs that need to be pre-fetched for inline mode.
103
+ *
104
+ * @param uiType - The UI renderer type
105
+ * @returns Array of URLs to fetch
106
+ */
107
+ export declare function getURLsToPreFetch(uiType: UIType): string[];
108
+ /**
109
+ * CDN info structure for tools/list _meta['ui/cdn'].
110
+ *
111
+ * Contains CDN URLs for runtime dependencies needed to render the widget.
112
+ */
113
+ export interface CDNInfo {
114
+ react?: string;
115
+ reactDom?: string;
116
+ handlebars?: string;
117
+ marked?: string;
118
+ mdxRuntime?: string;
119
+ tailwind?: string;
120
+ }
121
+ /**
122
+ * Build CDN info object for a UI type.
123
+ *
124
+ * This is used in tools/list response _meta to inform clients
125
+ * which CDN resources are needed to render the widget.
126
+ *
127
+ * @param uiType - The UI renderer type
128
+ * @returns CDN info object with URLs
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * // In tools/list response
133
+ * item._meta = {
134
+ * 'openai/outputTemplate': 'ui://widget/get_weather.html',
135
+ * 'ui/cdn': buildCDNInfoForUIType('react'),
136
+ * // { react: 'https://...', reactDom: 'https://...' }
137
+ * };
138
+ * ```
139
+ */
140
+ export declare function buildCDNInfoForUIType(uiType: UIType): CDNInfo;
@@ -0,0 +1,314 @@
1
+ "use strict";
2
+ /**
3
+ * CDN Resource URLs
4
+ *
5
+ * Default CDN URLs for runtime dependencies (React, MDX, Handlebars, etc).
6
+ * These URLs are used when resourceMode is 'cdn' (default).
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.TAILWIND_CDN = exports.MDX_RUNTIME_CDN = exports.HANDLEBARS_CDN = exports.MARKED_CDN = exports.REACT_DOM_CDN = exports.REACT_CDN = void 0;
12
+ exports.getDefaultAssets = getDefaultAssets;
13
+ exports.buildCDNScriptTag = buildCDNScriptTag;
14
+ exports.buildScriptsForUIType = buildScriptsForUIType;
15
+ exports.buildTailwindScriptTag = buildTailwindScriptTag;
16
+ exports.hasInlineScripts = hasInlineScripts;
17
+ exports.getURLsToPreFetch = getURLsToPreFetch;
18
+ exports.buildCDNInfoForUIType = buildCDNInfoForUIType;
19
+ // ============================================
20
+ // CDN URL Constants
21
+ // ============================================
22
+ /**
23
+ * React 19 from esm.sh (ES module).
24
+ *
25
+ * React 19 removed UMD builds, so we use esm.sh which provides
26
+ * ES module builds that work in modern browsers.
27
+ */
28
+ exports.REACT_CDN = {
29
+ url: 'https://esm.sh/react@19',
30
+ crossorigin: 'anonymous',
31
+ };
32
+ /**
33
+ * ReactDOM 19 client from esm.sh (ES module).
34
+ *
35
+ * React 19 removed UMD builds, so we use esm.sh which provides
36
+ * ES module builds that work in modern browsers.
37
+ */
38
+ exports.REACT_DOM_CDN = {
39
+ url: 'https://esm.sh/react-dom@19/client',
40
+ crossorigin: 'anonymous',
41
+ };
42
+ /**
43
+ * Marked markdown parser from unpkg.
44
+ */
45
+ exports.MARKED_CDN = {
46
+ url: 'https://unpkg.com/marked@latest/marked.min.js',
47
+ crossorigin: 'anonymous',
48
+ };
49
+ /**
50
+ * Handlebars runtime from unpkg.
51
+ */
52
+ exports.HANDLEBARS_CDN = {
53
+ url: 'https://unpkg.com/handlebars@latest/dist/handlebars.min.js',
54
+ crossorigin: 'anonymous',
55
+ };
56
+ /**
57
+ * MDX runtime from esm.sh (for browser use).
58
+ * Note: MDX compilation typically happens server-side.
59
+ */
60
+ exports.MDX_RUNTIME_CDN = {
61
+ url: 'https://esm.sh/@mdx-js/mdx@3?bundle',
62
+ crossorigin: 'anonymous',
63
+ };
64
+ /**
65
+ * Tailwind CSS Browser CDN (play.tailwindcss.com CDN).
66
+ */
67
+ exports.TAILWIND_CDN = {
68
+ url: 'https://cdn.tailwindcss.com',
69
+ crossorigin: 'anonymous',
70
+ };
71
+ // ============================================
72
+ // Default Assets by UI Type
73
+ // ============================================
74
+ /**
75
+ * Get default CDN resources for a UI type.
76
+ *
77
+ * @param uiType - The UI renderer type
78
+ * @param mode - Resource loading mode (cdn or inline)
79
+ * @returns RendererAssets with appropriate CDN URLs
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * // Get CDN assets for React
84
+ * const assets = getDefaultAssets('react', 'cdn');
85
+ * console.log(assets.react.url);
86
+ * // "https://unpkg.com/react@18/umd/react.production.min.js"
87
+ * ```
88
+ */
89
+ function getDefaultAssets(uiType, mode = 'cdn') {
90
+ const baseAssets = {
91
+ mode,
92
+ tailwind: exports.TAILWIND_CDN,
93
+ };
94
+ switch (uiType) {
95
+ case 'react':
96
+ return {
97
+ ...baseAssets,
98
+ react: exports.REACT_CDN,
99
+ reactDom: exports.REACT_DOM_CDN,
100
+ };
101
+ case 'mdx':
102
+ return {
103
+ ...baseAssets,
104
+ react: exports.REACT_CDN,
105
+ reactDom: exports.REACT_DOM_CDN,
106
+ mdxRuntime: exports.MDX_RUNTIME_CDN,
107
+ markdown: exports.MARKED_CDN,
108
+ };
109
+ case 'markdown':
110
+ return {
111
+ ...baseAssets,
112
+ markdown: exports.MARKED_CDN,
113
+ };
114
+ case 'html':
115
+ // HTML can optionally use Handlebars for {{}} syntax
116
+ return {
117
+ ...baseAssets,
118
+ handlebars: exports.HANDLEBARS_CDN,
119
+ };
120
+ case 'auto':
121
+ // Auto mode includes all renderers (lazy-loaded at runtime)
122
+ return {
123
+ ...baseAssets,
124
+ react: exports.REACT_CDN,
125
+ reactDom: exports.REACT_DOM_CDN,
126
+ markdown: exports.MARKED_CDN,
127
+ handlebars: exports.HANDLEBARS_CDN,
128
+ };
129
+ default:
130
+ return baseAssets;
131
+ }
132
+ }
133
+ // ============================================
134
+ // Script Tag Builders
135
+ // ============================================
136
+ /**
137
+ * Build a script tag for a CDN resource.
138
+ *
139
+ * @param resource - CDN resource configuration
140
+ * @param options - Additional script tag options
141
+ * @returns HTML script tag string
142
+ */
143
+ function buildCDNScriptTag(resource, options) {
144
+ const attrs = [`src="${resource.url}"`];
145
+ if (resource.integrity) {
146
+ attrs.push(`integrity="${resource.integrity}"`);
147
+ }
148
+ if (resource.crossorigin) {
149
+ attrs.push(`crossorigin="${resource.crossorigin}"`);
150
+ }
151
+ if (options?.async) {
152
+ attrs.push('async');
153
+ }
154
+ if (options?.defer) {
155
+ attrs.push('defer');
156
+ }
157
+ if (options?.type) {
158
+ attrs.push(`type="${options.type}"`);
159
+ }
160
+ return `<script ${attrs.join(' ')}></script>`;
161
+ }
162
+ /**
163
+ * Build all required script tags for a UI type.
164
+ *
165
+ * @param uiType - The UI renderer type
166
+ * @param mode - Resource mode (cdn or inline)
167
+ * @returns Array of script tag strings
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const scripts = buildScriptsForUIType('react', 'cdn');
172
+ * // Returns:
173
+ * // [
174
+ * // '<script src="https://unpkg.com/react@18/..." crossorigin="anonymous"></script>',
175
+ * // '<script src="https://unpkg.com/react-dom@18/..." crossorigin="anonymous"></script>',
176
+ * // ]
177
+ * ```
178
+ */
179
+ function buildScriptsForUIType(uiType, mode = 'cdn') {
180
+ if (mode !== 'cdn') {
181
+ // Inline mode doesn't use CDN script tags
182
+ return [];
183
+ }
184
+ const assets = getDefaultAssets(uiType, mode);
185
+ const scripts = [];
186
+ // React (must load before ReactDOM)
187
+ if (assets.react) {
188
+ scripts.push(buildCDNScriptTag(assets.react));
189
+ }
190
+ if (assets.reactDom) {
191
+ scripts.push(buildCDNScriptTag(assets.reactDom));
192
+ }
193
+ // Markdown
194
+ if (assets.markdown) {
195
+ scripts.push(buildCDNScriptTag(assets.markdown));
196
+ }
197
+ // MDX Runtime
198
+ if (assets.mdxRuntime) {
199
+ scripts.push(buildCDNScriptTag(assets.mdxRuntime, { type: 'module' }));
200
+ }
201
+ // Handlebars
202
+ if (assets.handlebars) {
203
+ scripts.push(buildCDNScriptTag(assets.handlebars));
204
+ }
205
+ return scripts;
206
+ }
207
+ /**
208
+ * Build a Tailwind script tag.
209
+ *
210
+ * @param config - Optional Tailwind config to inline
211
+ * @returns Tailwind script tag(s)
212
+ */
213
+ function buildTailwindScriptTag(config) {
214
+ const baseTag = buildCDNScriptTag(exports.TAILWIND_CDN);
215
+ if (config) {
216
+ return `${baseTag}
217
+ <script>
218
+ tailwind.config = ${config};
219
+ </script>`;
220
+ }
221
+ return baseTag;
222
+ }
223
+ // ============================================
224
+ // Inline Mode Helpers
225
+ // ============================================
226
+ /**
227
+ * Check if inline scripts are available in cache.
228
+ *
229
+ * Inline scripts need to be pre-fetched and cached before use.
230
+ * This is typically done at build time or server startup.
231
+ */
232
+ function hasInlineScripts() {
233
+ // This would check a cache - implementation depends on runtime
234
+ return false;
235
+ }
236
+ /**
237
+ * Get all CDN URLs that need to be pre-fetched for inline mode.
238
+ *
239
+ * @param uiType - The UI renderer type
240
+ * @returns Array of URLs to fetch
241
+ */
242
+ function getURLsToPreFetch(uiType) {
243
+ const assets = getDefaultAssets(uiType, 'cdn');
244
+ const urls = [];
245
+ if (assets.react)
246
+ urls.push(assets.react.url);
247
+ if (assets.reactDom)
248
+ urls.push(assets.reactDom.url);
249
+ if (assets.markdown)
250
+ urls.push(assets.markdown.url);
251
+ if (assets.handlebars)
252
+ urls.push(assets.handlebars.url);
253
+ if (assets.tailwind)
254
+ urls.push(assets.tailwind.url);
255
+ return urls;
256
+ }
257
+ /**
258
+ * Build CDN info object for a UI type.
259
+ *
260
+ * This is used in tools/list response _meta to inform clients
261
+ * which CDN resources are needed to render the widget.
262
+ *
263
+ * @param uiType - The UI renderer type
264
+ * @returns CDN info object with URLs
265
+ *
266
+ * @example
267
+ * ```typescript
268
+ * // In tools/list response
269
+ * item._meta = {
270
+ * 'openai/outputTemplate': 'ui://widget/get_weather.html',
271
+ * 'ui/cdn': buildCDNInfoForUIType('react'),
272
+ * // { react: 'https://...', reactDom: 'https://...' }
273
+ * };
274
+ * ```
275
+ */
276
+ function buildCDNInfoForUIType(uiType) {
277
+ switch (uiType) {
278
+ case 'react':
279
+ return {
280
+ react: exports.REACT_CDN.url,
281
+ reactDom: exports.REACT_DOM_CDN.url,
282
+ tailwind: exports.TAILWIND_CDN.url,
283
+ };
284
+ case 'mdx':
285
+ return {
286
+ react: exports.REACT_CDN.url,
287
+ reactDom: exports.REACT_DOM_CDN.url,
288
+ mdxRuntime: exports.MDX_RUNTIME_CDN.url,
289
+ marked: exports.MARKED_CDN.url,
290
+ tailwind: exports.TAILWIND_CDN.url,
291
+ };
292
+ case 'markdown':
293
+ return {
294
+ marked: exports.MARKED_CDN.url,
295
+ tailwind: exports.TAILWIND_CDN.url,
296
+ };
297
+ case 'html':
298
+ return {
299
+ handlebars: exports.HANDLEBARS_CDN.url,
300
+ tailwind: exports.TAILWIND_CDN.url,
301
+ };
302
+ case 'auto':
303
+ default:
304
+ // Auto mode includes all renderers
305
+ return {
306
+ react: exports.REACT_CDN.url,
307
+ reactDom: exports.REACT_DOM_CDN.url,
308
+ handlebars: exports.HANDLEBARS_CDN.url,
309
+ marked: exports.MARKED_CDN.url,
310
+ tailwind: exports.TAILWIND_CDN.url,
311
+ };
312
+ }
313
+ }
314
+ //# sourceMappingURL=cdn-resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cdn-resources.js","sourceRoot":"","sources":["../../../src/build/cdn-resources.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAkFH,4CAoDC;AAaD,8CA+BC;AAmBD,sDAqCC;AAQD,wDAWC;AAYD,4CAGC;AAQD,8CAWC;AAuCD,sDAyCC;AA3WD,+CAA+C;AAC/C,oBAAoB;AACpB,+CAA+C;AAE/C;;;;;GAKG;AACU,QAAA,SAAS,GAAgB;IACpC,GAAG,EAAE,yBAAyB;IAC9B,WAAW,EAAE,WAAW;CACzB,CAAC;AAEF;;;;;GAKG;AACU,QAAA,aAAa,GAAgB;IACxC,GAAG,EAAE,oCAAoC;IACzC,WAAW,EAAE,WAAW;CACzB,CAAC;AAEF;;GAEG;AACU,QAAA,UAAU,GAAgB;IACrC,GAAG,EAAE,+CAA+C;IACpD,WAAW,EAAE,WAAW;CACzB,CAAC;AAEF;;GAEG;AACU,QAAA,cAAc,GAAgB;IACzC,GAAG,EAAE,4DAA4D;IACjE,WAAW,EAAE,WAAW;CACzB,CAAC;AAEF;;;GAGG;AACU,QAAA,eAAe,GAAgB;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GAAG;gBACpB,QAAQ,EAAE,qBAAa,CAAC,GAAG;gBAC3B,UAAU,EAAE,sBAAc,CAAC,GAAG;gBAC9B,MAAM,EAAE,kBAAU,CAAC,GAAG;gBACtB,QAAQ,EAAE,oBAAY,CAAC,GAAG;aAC3B,CAAC;IACN,CAAC;AACH,CAAC","sourcesContent":["/**\n * CDN Resource URLs\n *\n * Default CDN URLs for runtime dependencies (React, MDX, Handlebars, etc).\n * These URLs are used when resourceMode is 'cdn' (default).\n *\n * @packageDocumentation\n */\n\nimport type { CDNResource, UIType, RendererAssets, ResourceMode } from '../types';\n\n// ============================================\n// CDN URL Constants\n// ============================================\n\n/**\n * React 19 from esm.sh (ES module).\n *\n * React 19 removed UMD builds, so we use esm.sh which provides\n * ES module builds that work in modern browsers.\n */\nexport const REACT_CDN: CDNResource = {\n url: 'https://esm.sh/react@19',\n crossorigin: 'anonymous',\n};\n\n/**\n * ReactDOM 19 client from esm.sh (ES module).\n *\n * React 19 removed UMD builds, so we use esm.sh which provides\n * ES module builds that work in modern browsers.\n */\nexport const REACT_DOM_CDN: CDNResource = {\n url: 'https://esm.sh/react-dom@19/client',\n crossorigin: 'anonymous',\n};\n\n/**\n * Marked markdown parser from unpkg.\n */\nexport const MARKED_CDN: CDNResource = {\n url: 'https://unpkg.com/marked@latest/marked.min.js',\n crossorigin: 'anonymous',\n};\n\n/**\n * Handlebars runtime from unpkg.\n */\nexport const HANDLEBARS_CDN: CDNResource = {\n url: 'https://unpkg.com/handlebars@latest/dist/handlebars.min.js',\n crossorigin: 'anonymous',\n};\n\n/**\n * MDX runtime from esm.sh (for browser use).\n * Note: MDX compilation typically happens server-side.\n */\nexport const MDX_RUNTIME_CDN: CDNResource = {\n url: 'https://esm.sh/@mdx-js/mdx@3?bundle',\n crossorigin: 'anonymous',\n};\n\n/**\n * Tailwind CSS Browser CDN (play.tailwindcss.com CDN).\n */\nexport const TAILWIND_CDN: CDNResource = {\n url: 'https://cdn.tailwindcss.com',\n crossorigin: 'anonymous',\n};\n\n// ============================================\n// Default Assets by UI Type\n// ============================================\n\n/**\n * Get default CDN resources for a UI type.\n *\n * @param uiType - The UI renderer type\n * @param mode - Resource loading mode (cdn or inline)\n * @returns RendererAssets with appropriate CDN URLs\n *\n * @example\n * ```typescript\n * // Get CDN assets for React\n * const assets = getDefaultAssets('react', 'cdn');\n * console.log(assets.react.url);\n * // \"https://unpkg.com/react@18/umd/react.production.min.js\"\n * ```\n */\nexport function getDefaultAssets(\n uiType: UIType,\n mode: ResourceMode = 'cdn'\n): RendererAssets {\n const baseAssets: RendererAssets = {\n mode,\n tailwind: TAILWIND_CDN,\n };\n\n switch (uiType) {\n case 'react':\n return {\n ...baseAssets,\n react: REACT_CDN,\n reactDom: REACT_DOM_CDN,\n };\n\n case 'mdx':\n return {\n ...baseAssets,\n react: REACT_CDN,\n reactDom: REACT_DOM_CDN,\n mdxRuntime: MDX_RUNTIME_CDN,\n markdown: MARKED_CDN,\n };\n\n case 'markdown':\n return {\n ...baseAssets,\n markdown: MARKED_CDN,\n };\n\n case 'html':\n // HTML can optionally use Handlebars for {{}} syntax\n return {\n ...baseAssets,\n handlebars: HANDLEBARS_CDN,\n };\n\n case 'auto':\n // Auto mode includes all renderers (lazy-loaded at runtime)\n return {\n ...baseAssets,\n react: REACT_CDN,\n reactDom: REACT_DOM_CDN,\n markdown: MARKED_CDN,\n handlebars: HANDLEBARS_CDN,\n };\n\n default:\n return baseAssets;\n }\n}\n\n// ============================================\n// Script Tag Builders\n// ============================================\n\n/**\n * Build a script tag for a CDN resource.\n *\n * @param resource - CDN resource configuration\n * @param options - Additional script tag options\n * @returns HTML script tag string\n */\nexport function buildCDNScriptTag(\n resource: CDNResource,\n options?: {\n async?: boolean;\n defer?: boolean;\n type?: string;\n }\n): string {\n const attrs: string[] = [`src=\"${resource.url}\"`];\n\n if (resource.integrity) {\n attrs.push(`integrity=\"${resource.integrity}\"`);\n }\n\n if (resource.crossorigin) {\n attrs.push(`crossorigin=\"${resource.crossorigin}\"`);\n }\n\n if (options?.async) {\n attrs.push('async');\n }\n\n if (options?.defer) {\n attrs.push('defer');\n }\n\n if (options?.type) {\n attrs.push(`type=\"${options.type}\"`);\n }\n\n return `<script ${attrs.join(' ')}></script>`;\n}\n\n/**\n * Build all required script tags for a UI type.\n *\n * @param uiType - The UI renderer type\n * @param mode - Resource mode (cdn or inline)\n * @returns Array of script tag strings\n *\n * @example\n * ```typescript\n * const scripts = buildScriptsForUIType('react', 'cdn');\n * // Returns:\n * // [\n * // '<script src=\"https://unpkg.com/react@18/...\" crossorigin=\"anonymous\"></script>',\n * // '<script src=\"https://unpkg.com/react-dom@18/...\" crossorigin=\"anonymous\"></script>',\n * // ]\n * ```\n */\nexport function buildScriptsForUIType(\n uiType: UIType,\n mode: ResourceMode = 'cdn'\n): string[] {\n if (mode !== 'cdn') {\n // Inline mode doesn't use CDN script tags\n return [];\n }\n\n const assets = getDefaultAssets(uiType, mode);\n const scripts: string[] = [];\n\n // React (must load before ReactDOM)\n if (assets.react) {\n scripts.push(buildCDNScriptTag(assets.react));\n }\n\n if (assets.reactDom) {\n scripts.push(buildCDNScriptTag(assets.reactDom));\n }\n\n // Markdown\n if (assets.markdown) {\n scripts.push(buildCDNScriptTag(assets.markdown));\n }\n\n // MDX Runtime\n if (assets.mdxRuntime) {\n scripts.push(buildCDNScriptTag(assets.mdxRuntime, { type: 'module' }));\n }\n\n // Handlebars\n if (assets.handlebars) {\n scripts.push(buildCDNScriptTag(assets.handlebars));\n }\n\n return scripts;\n}\n\n/**\n * Build a Tailwind script tag.\n *\n * @param config - Optional Tailwind config to inline\n * @returns Tailwind script tag(s)\n */\nexport function buildTailwindScriptTag(config?: string): string {\n const baseTag = buildCDNScriptTag(TAILWIND_CDN);\n\n if (config) {\n return `${baseTag}\n<script>\n tailwind.config = ${config};\n</script>`;\n }\n\n return baseTag;\n}\n\n// ============================================\n// Inline Mode Helpers\n// ============================================\n\n/**\n * Check if inline scripts are available in cache.\n *\n * Inline scripts need to be pre-fetched and cached before use.\n * This is typically done at build time or server startup.\n */\nexport function hasInlineScripts(): boolean {\n // This would check a cache - implementation depends on runtime\n return false;\n}\n\n/**\n * Get all CDN URLs that need to be pre-fetched for inline mode.\n *\n * @param uiType - The UI renderer type\n * @returns Array of URLs to fetch\n */\nexport function getURLsToPreFetch(uiType: UIType): string[] {\n const assets = getDefaultAssets(uiType, 'cdn');\n const urls: string[] = [];\n\n if (assets.react) urls.push(assets.react.url);\n if (assets.reactDom) urls.push(assets.reactDom.url);\n if (assets.markdown) urls.push(assets.markdown.url);\n if (assets.handlebars) urls.push(assets.handlebars.url);\n if (assets.tailwind) urls.push(assets.tailwind.url);\n\n return urls;\n}\n\n// ============================================\n// CDN Info for tools/list _meta\n// ============================================\n\n/**\n * CDN info structure for tools/list _meta['ui/cdn'].\n *\n * Contains CDN URLs for runtime dependencies needed to render the widget.\n */\nexport interface CDNInfo {\n react?: string;\n reactDom?: string;\n handlebars?: string;\n marked?: string;\n mdxRuntime?: string;\n tailwind?: string;\n}\n\n/**\n * Build CDN info object for a UI type.\n *\n * This is used in tools/list response _meta to inform clients\n * which CDN resources are needed to render the widget.\n *\n * @param uiType - The UI renderer type\n * @returns CDN info object with URLs\n *\n * @example\n * ```typescript\n * // In tools/list response\n * item._meta = {\n * 'openai/outputTemplate': 'ui://widget/get_weather.html',\n * 'ui/cdn': buildCDNInfoForUIType('react'),\n * // { react: 'https://...', reactDom: 'https://...' }\n * };\n * ```\n */\nexport function buildCDNInfoForUIType(uiType: UIType): CDNInfo {\n switch (uiType) {\n case 'react':\n return {\n react: REACT_CDN.url,\n reactDom: REACT_DOM_CDN.url,\n tailwind: TAILWIND_CDN.url,\n };\n\n case 'mdx':\n return {\n react: REACT_CDN.url,\n reactDom: REACT_DOM_CDN.url,\n mdxRuntime: MDX_RUNTIME_CDN.url,\n marked: MARKED_CDN.url,\n tailwind: TAILWIND_CDN.url,\n };\n\n case 'markdown':\n return {\n marked: MARKED_CDN.url,\n tailwind: TAILWIND_CDN.url,\n };\n\n case 'html':\n return {\n handlebars: HANDLEBARS_CDN.url,\n tailwind: TAILWIND_CDN.url,\n };\n\n case 'auto':\n default:\n // Auto mode includes all renderers\n return {\n react: REACT_CDN.url,\n reactDom: REACT_DOM_CDN.url,\n handlebars: HANDLEBARS_CDN.url,\n marked: MARKED_CDN.url,\n tailwind: TAILWIND_CDN.url,\n };\n }\n}\n"]}