@frontmcp/uipack 0.12.2 → 1.0.0-beta.2

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 (298) hide show
  1. package/CLAUDE.md +56 -154
  2. package/README.md +367 -62
  3. package/adapters/base-template.d.ts +30 -0
  4. package/adapters/base-template.d.ts.map +1 -0
  5. package/adapters/cdn-info.d.ts +34 -0
  6. package/adapters/cdn-info.d.ts.map +1 -0
  7. package/adapters/constants.d.ts +18 -0
  8. package/adapters/constants.d.ts.map +1 -0
  9. package/adapters/content-detector.d.ts +19 -0
  10. package/adapters/content-detector.d.ts.map +1 -0
  11. package/adapters/content-renderers.d.ts +27 -0
  12. package/adapters/content-renderers.d.ts.map +1 -0
  13. package/adapters/index.d.ts +14 -7
  14. package/adapters/index.d.ts.map +1 -1
  15. package/adapters/index.js +2343 -426
  16. package/adapters/render-failure.d.ts +18 -0
  17. package/adapters/render-failure.d.ts.map +1 -0
  18. package/adapters/response-builder.d.ts +34 -104
  19. package/adapters/response-builder.d.ts.map +1 -1
  20. package/adapters/serving-mode.d.ts +28 -91
  21. package/adapters/serving-mode.d.ts.map +1 -1
  22. package/adapters/template-renderer.d.ts +50 -0
  23. package/adapters/template-renderer.d.ts.map +1 -0
  24. package/adapters/type-detector.d.ts +18 -0
  25. package/adapters/type-detector.d.ts.map +1 -0
  26. package/bridge-runtime/index.js +1 -1
  27. package/component/index.d.ts +14 -0
  28. package/component/index.d.ts.map +1 -0
  29. package/component/index.js +2043 -0
  30. package/component/loader.d.ts +36 -0
  31. package/component/loader.d.ts.map +1 -0
  32. package/component/renderer.d.ts +30 -0
  33. package/component/renderer.d.ts.map +1 -0
  34. package/component/transpiler.d.ts +49 -0
  35. package/component/transpiler.d.ts.map +1 -0
  36. package/component/types.d.ts +82 -0
  37. package/component/types.d.ts.map +1 -0
  38. package/esm/adapters/index.mjs +2337 -422
  39. package/esm/bridge-runtime/index.mjs +1 -1
  40. package/esm/component/index.mjs +2013 -0
  41. package/esm/index.mjs +3446 -13935
  42. package/esm/package.json +3 -12
  43. package/esm/resolver/index.mjs +661 -0
  44. package/esm/shell/index.mjs +1406 -0
  45. package/esm/types/index.mjs +11 -11
  46. package/esm/utils/index.mjs +53 -8
  47. package/index.d.ts +12 -40
  48. package/index.d.ts.map +1 -1
  49. package/index.js +3579 -14218
  50. package/package.json +3 -12
  51. package/resolver/cdn-registry.d.ts +39 -0
  52. package/resolver/cdn-registry.d.ts.map +1 -0
  53. package/resolver/esm-sh.resolver.d.ts +54 -0
  54. package/resolver/esm-sh.resolver.d.ts.map +1 -0
  55. package/resolver/import-map.d.ts +47 -0
  56. package/resolver/import-map.d.ts.map +1 -0
  57. package/resolver/import-parser.d.ts +28 -0
  58. package/resolver/import-parser.d.ts.map +1 -0
  59. package/resolver/import-rewriter.d.ts +29 -0
  60. package/resolver/import-rewriter.d.ts.map +1 -0
  61. package/resolver/index.d.ts +15 -0
  62. package/resolver/index.d.ts.map +1 -0
  63. package/resolver/index.js +708 -0
  64. package/resolver/types.d.ts +191 -0
  65. package/resolver/types.d.ts.map +1 -0
  66. package/shell/builder.d.ts +31 -0
  67. package/shell/builder.d.ts.map +1 -0
  68. package/shell/csp.d.ts +37 -0
  69. package/shell/csp.d.ts.map +1 -0
  70. package/shell/custom-shell-applier.d.ts +33 -0
  71. package/shell/custom-shell-applier.d.ts.map +1 -0
  72. package/shell/custom-shell-resolver.d.ts +47 -0
  73. package/shell/custom-shell-resolver.d.ts.map +1 -0
  74. package/shell/custom-shell-types.d.ts +75 -0
  75. package/shell/custom-shell-types.d.ts.map +1 -0
  76. package/shell/custom-shell-validator.d.ts +26 -0
  77. package/shell/custom-shell-validator.d.ts.map +1 -0
  78. package/shell/data-injector.d.ts +40 -0
  79. package/shell/data-injector.d.ts.map +1 -0
  80. package/shell/index.d.ts +19 -0
  81. package/shell/index.d.ts.map +1 -0
  82. package/shell/index.js +1453 -0
  83. package/shell/types.d.ts +54 -0
  84. package/shell/types.d.ts.map +1 -0
  85. package/types/index.d.ts +1 -3
  86. package/types/index.d.ts.map +1 -1
  87. package/types/index.js +11 -11
  88. package/types/ui-config.d.ts +50 -11
  89. package/types/ui-config.d.ts.map +1 -1
  90. package/types/ui-runtime.d.ts +8 -82
  91. package/types/ui-runtime.d.ts.map +1 -1
  92. package/utils/index.d.ts +9 -3
  93. package/utils/index.d.ts.map +1 -1
  94. package/utils/index.js +59 -7
  95. package/adapters/platform-meta.constants.d.ts +0 -26
  96. package/adapters/platform-meta.constants.d.ts.map +0 -1
  97. package/adapters/platform-meta.d.ts +0 -234
  98. package/adapters/platform-meta.d.ts.map +0 -1
  99. package/base-template/bridge.d.ts +0 -90
  100. package/base-template/bridge.d.ts.map +0 -1
  101. package/base-template/default-base-template.d.ts +0 -91
  102. package/base-template/default-base-template.d.ts.map +0 -1
  103. package/base-template/index.d.ts +0 -15
  104. package/base-template/index.d.ts.map +0 -1
  105. package/base-template/index.js +0 -1393
  106. package/base-template/polyfills.d.ts +0 -31
  107. package/base-template/polyfills.d.ts.map +0 -1
  108. package/base-template/theme-styles.d.ts +0 -74
  109. package/base-template/theme-styles.d.ts.map +0 -1
  110. package/build/builders/base-builder.d.ts +0 -124
  111. package/build/builders/base-builder.d.ts.map +0 -1
  112. package/build/builders/esbuild-config.d.ts +0 -94
  113. package/build/builders/esbuild-config.d.ts.map +0 -1
  114. package/build/builders/hybrid-builder.d.ts +0 -93
  115. package/build/builders/hybrid-builder.d.ts.map +0 -1
  116. package/build/builders/index.d.ts +0 -17
  117. package/build/builders/index.d.ts.map +0 -1
  118. package/build/builders/inline-builder.d.ts +0 -83
  119. package/build/builders/inline-builder.d.ts.map +0 -1
  120. package/build/builders/static-builder.d.ts +0 -78
  121. package/build/builders/static-builder.d.ts.map +0 -1
  122. package/build/builders/types.d.ts +0 -341
  123. package/build/builders/types.d.ts.map +0 -1
  124. package/build/cdn-resources.d.ts +0 -244
  125. package/build/cdn-resources.d.ts.map +0 -1
  126. package/build/hybrid-data.d.ts +0 -127
  127. package/build/hybrid-data.d.ts.map +0 -1
  128. package/build/index.d.ts +0 -299
  129. package/build/index.d.ts.map +0 -1
  130. package/build/index.js +0 -8699
  131. package/build/ui-components-browser.d.ts +0 -64
  132. package/build/ui-components-browser.d.ts.map +0 -1
  133. package/build/widget-manifest.d.ts +0 -362
  134. package/build/widget-manifest.d.ts.map +0 -1
  135. package/bundler/cache.d.ts +0 -173
  136. package/bundler/cache.d.ts.map +0 -1
  137. package/bundler/file-cache/component-builder.d.ts +0 -167
  138. package/bundler/file-cache/component-builder.d.ts.map +0 -1
  139. package/bundler/file-cache/hash-calculator.d.ts +0 -155
  140. package/bundler/file-cache/hash-calculator.d.ts.map +0 -1
  141. package/bundler/file-cache/index.d.ts +0 -12
  142. package/bundler/file-cache/index.d.ts.map +0 -1
  143. package/bundler/file-cache/storage/filesystem.d.ts +0 -149
  144. package/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
  145. package/bundler/file-cache/storage/index.d.ts +0 -11
  146. package/bundler/file-cache/storage/index.d.ts.map +0 -1
  147. package/bundler/file-cache/storage/interface.d.ts +0 -152
  148. package/bundler/file-cache/storage/interface.d.ts.map +0 -1
  149. package/bundler/file-cache/storage/redis.d.ts +0 -139
  150. package/bundler/file-cache/storage/redis.d.ts.map +0 -1
  151. package/bundler/index.d.ts +0 -35
  152. package/bundler/index.d.ts.map +0 -1
  153. package/bundler/index.js +0 -2953
  154. package/bundler/sandbox/enclave-adapter.d.ts +0 -121
  155. package/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
  156. package/bundler/sandbox/executor.d.ts +0 -14
  157. package/bundler/sandbox/executor.d.ts.map +0 -1
  158. package/bundler/sandbox/policy.d.ts +0 -62
  159. package/bundler/sandbox/policy.d.ts.map +0 -1
  160. package/bundler/types.d.ts +0 -702
  161. package/bundler/types.d.ts.map +0 -1
  162. package/dependency/cdn-registry.d.ts +0 -98
  163. package/dependency/cdn-registry.d.ts.map +0 -1
  164. package/dependency/import-map.d.ts +0 -186
  165. package/dependency/import-map.d.ts.map +0 -1
  166. package/dependency/import-parser.d.ts +0 -82
  167. package/dependency/import-parser.d.ts.map +0 -1
  168. package/dependency/index.d.ts +0 -17
  169. package/dependency/index.d.ts.map +0 -1
  170. package/dependency/index.js +0 -3180
  171. package/dependency/resolver.d.ts +0 -164
  172. package/dependency/resolver.d.ts.map +0 -1
  173. package/dependency/schemas.d.ts +0 -486
  174. package/dependency/schemas.d.ts.map +0 -1
  175. package/dependency/template-loader.d.ts +0 -204
  176. package/dependency/template-loader.d.ts.map +0 -1
  177. package/dependency/template-processor.d.ts +0 -118
  178. package/dependency/template-processor.d.ts.map +0 -1
  179. package/dependency/types.d.ts +0 -739
  180. package/dependency/types.d.ts.map +0 -1
  181. package/esm/base-template/index.mjs +0 -1359
  182. package/esm/build/index.mjs +0 -8601
  183. package/esm/bundler/index.mjs +0 -2895
  184. package/esm/dependency/index.mjs +0 -3068
  185. package/esm/handlebars/index.mjs +0 -587
  186. package/esm/registry/index.mjs +0 -6305
  187. package/esm/renderers/index.mjs +0 -1557
  188. package/esm/runtime/index.mjs +0 -5361
  189. package/esm/styles/index.mjs +0 -171
  190. package/esm/theme/index.mjs +0 -756
  191. package/esm/tool-template/index.mjs +0 -3652
  192. package/esm/validation/index.mjs +0 -542
  193. package/handlebars/expression-extractor.d.ts +0 -147
  194. package/handlebars/expression-extractor.d.ts.map +0 -1
  195. package/handlebars/helpers.d.ts +0 -339
  196. package/handlebars/helpers.d.ts.map +0 -1
  197. package/handlebars/index.d.ts +0 -195
  198. package/handlebars/index.d.ts.map +0 -1
  199. package/handlebars/index.js +0 -659
  200. package/preview/claude-preview.d.ts +0 -67
  201. package/preview/claude-preview.d.ts.map +0 -1
  202. package/preview/generic-preview.d.ts +0 -66
  203. package/preview/generic-preview.d.ts.map +0 -1
  204. package/preview/index.d.ts +0 -36
  205. package/preview/index.d.ts.map +0 -1
  206. package/preview/openai-preview.d.ts +0 -70
  207. package/preview/openai-preview.d.ts.map +0 -1
  208. package/preview/types.d.ts +0 -199
  209. package/preview/types.d.ts.map +0 -1
  210. package/registry/index.d.ts +0 -46
  211. package/registry/index.d.ts.map +0 -1
  212. package/registry/index.js +0 -6342
  213. package/registry/render-template.d.ts +0 -91
  214. package/registry/render-template.d.ts.map +0 -1
  215. package/registry/tool-ui.registry.d.ts +0 -294
  216. package/registry/tool-ui.registry.d.ts.map +0 -1
  217. package/registry/uri-utils.d.ts +0 -56
  218. package/registry/uri-utils.d.ts.map +0 -1
  219. package/renderers/cache.d.ts +0 -145
  220. package/renderers/cache.d.ts.map +0 -1
  221. package/renderers/html.renderer.d.ts +0 -123
  222. package/renderers/html.renderer.d.ts.map +0 -1
  223. package/renderers/index.d.ts +0 -36
  224. package/renderers/index.d.ts.map +0 -1
  225. package/renderers/index.js +0 -1603
  226. package/renderers/mdx-client.renderer.d.ts +0 -124
  227. package/renderers/mdx-client.renderer.d.ts.map +0 -1
  228. package/renderers/registry.d.ts +0 -133
  229. package/renderers/registry.d.ts.map +0 -1
  230. package/renderers/types.d.ts +0 -343
  231. package/renderers/types.d.ts.map +0 -1
  232. package/renderers/utils/detect.d.ts +0 -107
  233. package/renderers/utils/detect.d.ts.map +0 -1
  234. package/renderers/utils/hash.d.ts +0 -40
  235. package/renderers/utils/hash.d.ts.map +0 -1
  236. package/renderers/utils/index.d.ts +0 -9
  237. package/renderers/utils/index.d.ts.map +0 -1
  238. package/renderers/utils/transpiler.d.ts +0 -70
  239. package/renderers/utils/transpiler.d.ts.map +0 -1
  240. package/runtime/adapters/html.adapter.d.ts +0 -59
  241. package/runtime/adapters/html.adapter.d.ts.map +0 -1
  242. package/runtime/adapters/index.d.ts +0 -26
  243. package/runtime/adapters/index.d.ts.map +0 -1
  244. package/runtime/adapters/mdx.adapter.d.ts +0 -73
  245. package/runtime/adapters/mdx.adapter.d.ts.map +0 -1
  246. package/runtime/adapters/types.d.ts +0 -95
  247. package/runtime/adapters/types.d.ts.map +0 -1
  248. package/runtime/csp.d.ts +0 -48
  249. package/runtime/csp.d.ts.map +0 -1
  250. package/runtime/index.d.ts +0 -17
  251. package/runtime/index.d.ts.map +0 -1
  252. package/runtime/index.js +0 -5432
  253. package/runtime/mcp-bridge.d.ts +0 -101
  254. package/runtime/mcp-bridge.d.ts.map +0 -1
  255. package/runtime/renderer-runtime.d.ts +0 -133
  256. package/runtime/renderer-runtime.d.ts.map +0 -1
  257. package/runtime/sanitizer.d.ts +0 -180
  258. package/runtime/sanitizer.d.ts.map +0 -1
  259. package/runtime/types.d.ts +0 -415
  260. package/runtime/types.d.ts.map +0 -1
  261. package/runtime/wrapper.d.ts +0 -421
  262. package/runtime/wrapper.d.ts.map +0 -1
  263. package/styles/index.d.ts +0 -8
  264. package/styles/index.d.ts.map +0 -1
  265. package/styles/index.js +0 -222
  266. package/styles/variants.d.ts +0 -51
  267. package/styles/variants.d.ts.map +0 -1
  268. package/theme/cdn.d.ts +0 -195
  269. package/theme/cdn.d.ts.map +0 -1
  270. package/theme/css-to-theme.d.ts +0 -64
  271. package/theme/css-to-theme.d.ts.map +0 -1
  272. package/theme/index.d.ts +0 -19
  273. package/theme/index.d.ts.map +0 -1
  274. package/theme/index.js +0 -814
  275. package/theme/platforms.d.ts +0 -102
  276. package/theme/platforms.d.ts.map +0 -1
  277. package/theme/presets/github-openai.d.ts +0 -50
  278. package/theme/presets/github-openai.d.ts.map +0 -1
  279. package/theme/presets/index.d.ts +0 -11
  280. package/theme/presets/index.d.ts.map +0 -1
  281. package/theme/theme.d.ts +0 -396
  282. package/theme/theme.d.ts.map +0 -1
  283. package/tool-template/builder.d.ts +0 -213
  284. package/tool-template/builder.d.ts.map +0 -1
  285. package/tool-template/index.d.ts +0 -16
  286. package/tool-template/index.d.ts.map +0 -1
  287. package/tool-template/index.js +0 -3690
  288. package/validation/error-box.d.ts +0 -56
  289. package/validation/error-box.d.ts.map +0 -1
  290. package/validation/index.d.ts +0 -13
  291. package/validation/index.d.ts.map +0 -1
  292. package/validation/index.js +0 -576
  293. package/validation/schema-paths.d.ts +0 -118
  294. package/validation/schema-paths.d.ts.map +0 -1
  295. package/validation/template-validator.d.ts +0 -143
  296. package/validation/template-validator.d.ts.map +0 -1
  297. package/validation/wrapper.d.ts +0 -97
  298. package/validation/wrapper.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,15 +1,9 @@
1
1
  # @frontmcp/uipack
2
2
 
3
- React-free build utilities, theming, runtime helpers, and platform adapters for FrontMCP UI development.
3
+ HTML shell builder, pluggable import resolver, and NPM component loader for MCP UI development. React-free core.
4
4
 
5
5
  [![NPM](https://img.shields.io/npm/v/@frontmcp/uipack.svg)](https://www.npmjs.com/package/@frontmcp/uipack)
6
-
7
- ## Package Split
8
-
9
- | Package | Purpose | React Required |
10
- | ------------------ | --------------------------------------------------------------------- | -------------- |
11
- | `@frontmcp/uipack` | Themes, runtime helpers, build/render pipelines, validation, adapters | No |
12
- | `@frontmcp/ui` | HTML/React components, layouts, widgets, web components | Yes (peer dep) |
6
+ [![License](https://img.shields.io/npm/l/@frontmcp/uipack.svg)](../../LICENSE)
13
7
 
14
8
  ## Install
15
9
 
@@ -17,75 +11,386 @@ React-free build utilities, theming, runtime helpers, and platform adapters for
17
11
  npm install @frontmcp/uipack
18
12
  ```
19
13
 
20
- ## Features
14
+ No React required. The only runtime dependency is `zod`.
15
+
16
+ ## Quick Start
17
+
18
+ ### Build an HTML Shell
19
+
20
+ ```ts
21
+ import { buildShell } from '@frontmcp/uipack/shell';
22
+
23
+ const result = buildShell('<div id="root"></div>', {
24
+ toolName: 'get_weather',
25
+ input: { city: 'London' },
26
+ output: { temp: 18 },
27
+ includeBridge: true,
28
+ csp: { connectDomains: ['https://api.weather.com'] },
29
+ });
30
+
31
+ // result.html -> full HTML document with CSP, data injection, bridge IIFE
32
+ // result.hash -> fast 32-bit content hash
33
+ // result.size -> byte length
34
+ ```
35
+
36
+ ### Render an NPM Component
37
+
38
+ ```ts
39
+ import { renderComponent } from '@frontmcp/uipack/component';
40
+
41
+ const result = await renderComponent(
42
+ { source: { npm: 'my-weather-widget', exportName: 'WeatherCard' } },
43
+ { toolName: 'get_weather', output: { temp: 18 }, includeBridge: true },
44
+ );
45
+ ```
46
+
47
+ ### Resolve Imports to CDN URLs
48
+
49
+ ```ts
50
+ import { createEsmShResolver, createImportMap } from '@frontmcp/uipack/resolver';
51
+
52
+ const resolver = createEsmShResolver({ providerOrder: ['cloudflare', 'jsdelivr'] });
53
+ const result = resolver.resolve('chart.js');
54
+ // -> { value: 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.5.1/chart.umd.min.js', type: 'url' }
55
+ ```
56
+
57
+ ### Generate Bridge IIFE
58
+
59
+ ```ts
60
+ import { generateBridgeIIFE, UNIVERSAL_BRIDGE_SCRIPT } from '@frontmcp/uipack/bridge-runtime';
61
+
62
+ // Use pre-generated universal script
63
+ const script = `<script>${UNIVERSAL_BRIDGE_SCRIPT}</script>`;
21
64
 
22
- - **Theme system** Tailwind-style palettes, fonts, CDN assets, platform-aware inlining ([docs][docs-theme])
23
- - **Build API** compile tool templates with esbuild/SWC, emit static widgets, cached manifests ([docs][docs-build])
24
- - **Build modes** — static, dynamic, or hybrid rendering; multi-platform bundler helpers ([docs][docs-build-modes])
25
- - **Runtime helpers** — wrap HTML/React/MDX with CSP, sanitize content, expose MCP Bridge metadata ([docs][docs-runtime])
26
- - **Platform adapters** — OpenAI/Claude/Gemini discovery metadata, serving modes, host capabilities ([docs][docs-adapters])
27
- - **Validation** — schema path extraction, Handlebars template validation, error boxes ([docs][docs-validation])
28
- - **Bundler/cache** — filesystem and Redis caches, transpile/render caches, hashing utilities ([docs][docs-bundler])
65
+ // Or generate with custom options
66
+ const iife = generateBridgeIIFE({ debug: true, minify: false });
67
+ ```
29
68
 
30
- ## Quick Example
69
+ ### Fetch TypeScript Definitions
31
70
 
32
71
  ```ts
33
- import { buildToolUI } from '@frontmcp/uipack/build';
72
+ import { createTypeFetcher } from '@frontmcp/uipack/typings';
34
73
 
35
- const result = await buildToolUI({
36
- template: '<div>{{output.temperature}} C</div>',
37
- context: { input: { location: 'London' }, output: { temperature: 18 } },
38
- platform: 'openai',
74
+ const fetcher = createTypeFetcher({
75
+ allowedPackages: ['react', 'zod', '@frontmcp/*'],
76
+ maxDepth: 3,
39
77
  });
78
+
79
+ const result = await fetcher.fetchBatch({
80
+ imports: ["import { z } from 'zod'"],
81
+ });
82
+ // result.results[0].files -> TypeFile[] with virtual node_modules/ paths
40
83
  ```
41
84
 
42
- > Full guide: [UI Overview][docs-overview]
85
+ ## Features
86
+
87
+ - **Shell builder** — Full HTML documents with CSP, data injection, and bridge runtime
88
+ - **Import resolver** — Pluggable CDN resolution (esm.sh, Cloudflare, jsDelivr, unpkg)
89
+ - **Component loader** — 4 source modes: npm, file, URL, inline function
90
+ - **Bridge IIFE** — Platform-aware vanilla JS bridge (OpenAI, ExtApps, Claude, Gemini, Generic)
91
+ - **Type fetching** — Download `.d.ts` from esm.sh with recursive dependency resolution
92
+ - **XSS utilities** — `escapeHtml`, `safeJsonForScript`, `escapeScriptClose`, and more
93
+ - **Custom shells** — Load shell templates from npm, URL, or inline HTML
94
+ - **Standalone types** — SDK-independent type definitions for widget configuration
43
95
 
44
96
  ## Entry Points
45
97
 
46
- | Path | Purpose |
47
- | ----------------------------- | -------------------------------------------------------- |
48
- | `@frontmcp/uipack/theme` | Theme system, platform definitions, CDN helpers |
49
- | `@frontmcp/uipack/runtime` | MCP Bridge runtime, CSP utilities, sanitizers |
50
- | `@frontmcp/uipack/build` | Build API, static widget compiler, serving-mode resolver |
51
- | `@frontmcp/uipack/adapters` | Discovery metadata + platform adapters |
52
- | `@frontmcp/uipack/pages` | Prebuilt page templates (consent/error/success) |
53
- | `@frontmcp/uipack/validation` | Component + template validation helpers |
54
- | `@frontmcp/uipack/bundler` | esbuild/SWC bundler and cache utilities |
55
- | `@frontmcp/uipack/registry` | Tool UI registry, URI helpers, render functions |
56
- | `@frontmcp/uipack/types` | Shared template/context types |
57
- | `@frontmcp/uipack/utils` | Escaping, safe stringify, helper utilities |
58
-
59
- ## Docs
60
-
61
- | Topic | Link |
62
- | ----------------- | ------------------------------- |
63
- | Overview | [UI Overview][docs-overview] |
64
- | Theme system | [Theming][docs-theme] |
65
- | Build API | [Build Tools][docs-build] |
66
- | Build modes | [Build Modes][docs-build-modes] |
67
- | Runtime helpers | [Runtime][docs-runtime] |
68
- | Platform adapters | [Adapters][docs-adapters] |
69
- | Validation | [Validation][docs-validation] |
70
- | Bundler | [Bundler][docs-bundler] |
98
+ | Path | Purpose |
99
+ | --------------------------------- | ------------------------------------ |
100
+ | `@frontmcp/uipack` | Main barrel (re-exports all modules) |
101
+ | `@frontmcp/uipack/resolver` | Pluggable import resolution |
102
+ | `@frontmcp/uipack/shell` | HTML shell builder |
103
+ | `@frontmcp/uipack/component` | Polymorphic component loader |
104
+ | `@frontmcp/uipack/bridge-runtime` | Platform bridge IIFE generator |
105
+ | `@frontmcp/uipack/typings` | TypeScript .d.ts fetching engine |
106
+ | `@frontmcp/uipack/types` | Standalone type definitions |
107
+ | `@frontmcp/uipack/utils` | XSS-safe escaping utilities |
108
+
109
+ ## Module Exports
110
+
111
+ ### Resolver
112
+
113
+ | Export | Type | Purpose |
114
+ | ---------------------------------------------- | -------- | ----------------------------------------------------------------- |
115
+ | `createEsmShResolver(opts?)` | function | Default resolver using esm.sh with CDN registry fallback |
116
+ | `DEFAULT_CDN_REGISTRY` | constant | Pre-configured entries for react, react-dom, chart.js, d3, lodash |
117
+ | `parseImports(source)` | function | Parse source code for named, default, namespace, dynamic imports |
118
+ | `rewriteImports(source, resolver, overrides?)` | function | Rewrite bare specifiers to CDN URLs |
119
+ | `createImportMap(overrides?)` | function | Generate browser-standard import map |
120
+ | `mergeImportMaps(...maps)` | function | Deep-merge multiple import maps |
121
+ | `generateImportMapScriptTag(map)` | function | `<script type="importmap">` generation |
122
+ | `lookupPackage(name)` | function | Query the CDN registry for a package |
123
+ | `getPackageCDNUrl(name, provider?)` | function | Resolve package to best CDN URL |
124
+ | `extractExternalPackages(code)` | function | Extract external package names from source |
125
+
126
+ ### Shell
127
+
128
+ | Export | Type | Purpose |
129
+ | ----------------------------------------------------- | -------- | --------------------------------------------------------------------- |
130
+ | `buildShell(content, config)` | function | Main entry point -> `ShellResult` |
131
+ | `buildCSPMetaTag(config?)` | function | Generate `<meta>` CSP tag |
132
+ | `buildCSPDirectives(config?)` | function | Merge custom domains with defaults |
133
+ | `buildDataInjectionScript(toolName, input?, output?)` | function | `<script>` setting `window.__mcp*` globals |
134
+ | `createTemplateHelpers(toolName)` | function | `escapeHtml`, `formatDate`, `formatCurrency`, `uniqueId`, `jsonEmbed` |
135
+ | `resolveShellTemplate(opts)` | function | Resolve custom shell from npm/URL/inline |
136
+ | `applyShellTemplate(template, values)` | function | Apply values to resolved template |
137
+ | `validateShellTemplate(template)` | function | Validate a custom shell template |
138
+ | `DEFAULT_CDN_DOMAINS` | constant | jsDelivr, Cloudflare, Google Fonts |
139
+
140
+ ### Component
141
+
142
+ | Export | Type | Purpose |
143
+ | ------------------------------------------------------------------- | -------- | -------------------------------------------------- |
144
+ | `renderComponent(config, shell)` | function | Top-level compositor -> `ShellResult` |
145
+ | `resolveUISource(source, opts)` | function | Resolve any source to `ResolvedComponent` |
146
+ | `generateMountScript(resolved, data)` | function | ES module mount script for React/module components |
147
+ | `isNpmSource`, `isFileSource`, `isImportSource`, `isFunctionSource` | guards | Type narrowing helpers |
148
+
149
+ ### Bridge Runtime
150
+
151
+ | Export | Type | Purpose |
152
+ | ---------------------------------- | -------- | ---------------------------------------------------------------------- |
153
+ | `generateBridgeIIFE(opts?)` | function | Generate the bridge IIFE string |
154
+ | `generatePlatformBundle(platform)` | function | Platform-specific bundles (`chatgpt`, `claude`, `gemini`, `universal`) |
155
+ | `UNIVERSAL_BRIDGE_SCRIPT` | constant | Pre-generated script with all adapters |
156
+ | `BRIDGE_SCRIPT_TAGS` | constant | `{ universal, chatgpt, claude, gemini }` pre-wrapped `<script>` tags |
157
+
158
+ ### Typings
159
+
160
+ | Export | Type | Purpose |
161
+ | ----------------------------- | -------- | ------------------------------------------------------------- |
162
+ | `createTypeFetcher(opts?)` | function | Factory creating a `TypeFetcher` instance |
163
+ | `TypeFetcher` | class | Main fetcher with caching and recursive dependency resolution |
164
+ | `MemoryTypeCache` | class | LRU cache with TTL support |
165
+ | `globalTypeCache` | constant | Module-level singleton cache (500 entries, 1h TTL) |
166
+ | `parseDtsImports(content)` | function | Parse `.d.ts` files for imports/references |
167
+ | `combineDtsContents(results)` | function | Combine multiple `.d.ts` files into one |
168
+
169
+ ### Utils
170
+
171
+ | Export | Type | Purpose |
172
+ | ------------------------------ | -------- | ---------------------------------------------------------------------------- |
173
+ | `escapeHtml(str)` | function | Escape `&`, `<`, `>`, `"`, `'`, U+2028/2029 |
174
+ | `escapeHtmlAttr(str)` | function | Lighter escape for attributes |
175
+ | `escapeJsString(str)` | function | Escape for JS string literals |
176
+ | `escapeScriptClose(str)` | function | Replace `</` with `<\/` to prevent `</script>` breakout |
177
+ | `safeJsonForScript(value)` | function | JSON serialize safe for `<script>` embedding (handles BigInt, circular refs) |
178
+ | `safeStringify(value, space?)` | function | `JSON.stringify` with circular reference detection |
179
+
180
+ ## Shell HTML Structure
181
+
182
+ Annotated output of `buildShell` with `withShell: true` and `includeBridge: true`:
183
+
184
+ ```html
185
+ <!DOCTYPE html>
186
+ <html lang="en">
187
+ <head>
188
+ <meta charset="UTF-8" />
189
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
190
+ <title>get_weather</title>
191
+
192
+ <!-- CSP: default CDN domains + custom connectDomains/resourceDomains -->
193
+ <meta
194
+ http-equiv="Content-Security-Policy"
195
+ content="default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net ..."
196
+ />
197
+
198
+ <!-- Data injection: tool context as window globals -->
199
+ <script>
200
+ window.__mcpToolName = 'get_weather';
201
+ window.__mcpToolInput = { city: 'London' };
202
+ window.__mcpToolOutput = { temp: 18 };
203
+ window.__mcpStructuredContent = null;
204
+ </script>
205
+
206
+ <!-- Bridge IIFE: auto-detects platform, exposes window.FrontMcpBridge -->
207
+ <script>
208
+ (function () {
209
+ /* ... adapters, FrontMcpBridge class ... */
210
+ })();
211
+ </script>
212
+ </head>
213
+ <body>
214
+ <!-- Content from resolver + component -->
215
+ <script type="importmap">
216
+ { "imports": { "react": "https://esm.sh/react@19" } }
217
+ </script>
218
+ <div id="root"></div>
219
+ <script type="module">
220
+ import { WeatherCard } from 'https://esm.sh/my-weather-widget';
221
+ /* mount logic */
222
+ </script>
223
+ </body>
224
+ </html>
225
+ ```
226
+
227
+ ## Component Source Modes
228
+
229
+ | Mode | Config Shape | Description |
230
+ | ---------- | ------------------------------------------------- | ---------------------------------- |
231
+ | **npm** | `{ npm: 'my-chart', exportName?, version? }` | Resolved via CDN registry / esm.sh |
232
+ | **file** | `{ file: './widget.html', inline? }` | Local file path |
233
+ | **import** | `{ import: 'https://cdn.example.com/widget.js' }` | Direct URL passthrough |
234
+ | **inline** | `(input, output) => '<div>...</div>'` | Function returning HTML string |
235
+
236
+ ## Bridge API
237
+
238
+ The bridge IIFE exposes `window.FrontMcpBridge` with the following API:
239
+
240
+ | Method | Description |
241
+ | --------------------------- | ------------------------------------ |
242
+ | `callTool(name, args)` | Invoke an MCP tool from the widget |
243
+ | `getToolOutput()` | Read injected tool output data |
244
+ | `getToolInput()` | Read injected tool input data |
245
+ | `sendMessage(content)` | Send message to host |
246
+ | `openLink(url)` | Open a URL via platform adapter |
247
+ | `requestDisplayMode(mode)` | Switch inline / fullscreen / pip |
248
+ | `setWidgetState(state)` | Persist widget state to localStorage |
249
+ | `onContextChange(callback)` | Subscribe to host context changes |
250
+ | `onToolResult(callback)` | Subscribe to tool result events |
251
+ | `hasCapability(cap)` | Check adapter capabilities |
252
+ | `getTheme()` | Get current theme from host |
253
+ | `getDisplayMode()` | Get current display mode |
254
+ | `getHostContext()` | Get host context metadata |
255
+
256
+ ## Contributing
257
+
258
+ ### Architecture
259
+
260
+ ```mermaid
261
+ graph TD
262
+ subgraph "@frontmcp/uipack"
263
+ IDX["index.ts<br/><i>Main barrel exports</i>"]
264
+
265
+ subgraph bridge-runtime["bridge-runtime/"]
266
+ BR_IIFE["iife-generator.ts<br/>5 platform adapters:<br/>OpenAI, ExtApps, Claude,<br/>Gemini, Generic"]
267
+ end
268
+
269
+ subgraph component["component/"]
270
+ CO_TYPES["types.ts<br/>NpmSource, FileSource,<br/>ImportSource, FunctionSource"]
271
+ CO_LOAD["loader.ts<br/>resolveUISource(),<br/>generateMountScript()"]
272
+ CO_REND["renderer.ts<br/>renderComponent()"]
273
+ end
274
+
275
+ subgraph resolver["resolver/"]
276
+ RE_CDN["cdn-registry.ts<br/>DEFAULT_CDN_REGISTRY,<br/>lookupPackage()"]
277
+ RE_ESM["esm-sh.resolver.ts<br/>createEsmShResolver()"]
278
+ RE_PARSE["import-parser.ts<br/>parseImports()"]
279
+ RE_REWRITE["import-rewriter.ts<br/>rewriteImports()"]
280
+ RE_MAP["import-map.ts<br/>createImportMap(),<br/>mergeImportMaps()"]
281
+ end
282
+
283
+ subgraph shell["shell/"]
284
+ SH_BUILD["builder.ts<br/>buildShell()"]
285
+ SH_CSP["csp.ts<br/>CSP directives + meta tag"]
286
+ SH_DATA["data-injector.ts<br/>window.__mcp* globals"]
287
+ SH_CUSTOM["custom-shell-*.ts<br/>Resolve, validate, apply<br/>custom shell templates"]
288
+ end
289
+
290
+ subgraph types["types/"]
291
+ TY_CFG["ui-config.ts<br/>UITemplateConfig,<br/>WidgetServingMode"]
292
+ TY_RT["ui-runtime.ts<br/>UIType, WidgetManifest,<br/>WidgetConfig"]
293
+ end
294
+
295
+ subgraph typings["typings/"]
296
+ TP_FETCH["type-fetcher.ts<br/>TypeFetcher class"]
297
+ TP_DTS["dts-parser.ts<br/>parseDtsImports()"]
298
+ TP_SCHEMA["schemas.ts<br/>Zod validation"]
299
+ TP_CACHE["cache/<br/>MemoryTypeCache (LRU + TTL)"]
300
+ end
301
+
302
+ subgraph utils["utils/"]
303
+ UT["escapeHtml, safeJsonForScript,<br/>escapeScriptClose, safeStringify"]
304
+ end
305
+ end
306
+ ```
307
+
308
+ ### Module Dependency Graph
309
+
310
+ ```mermaid
311
+ graph BT
312
+ utils["utils<br/><i>foundation, zero deps</i>"]
313
+ resolver["resolver<br/><i>import resolution</i>"]
314
+ shell["shell<br/><i>HTML shell builder</i>"]
315
+ bridge["bridge-runtime<br/><i>IIFE generator, standalone</i>"]
316
+ component["component<br/><i>polymorphic loader</i>"]
317
+ types["types<br/><i>standalone, no internal deps</i>"]
318
+ typings["typings<br/><i>standalone, uses zod</i>"]
319
+
320
+ resolver --> utils
321
+ shell --> utils
322
+ shell --> resolver
323
+ shell --> bridge
324
+ component --> utils
325
+ component --> resolver
326
+ component --> shell
327
+ ```
328
+
329
+ ### How @frontmcp/uipack works with @frontmcp/ui
330
+
331
+ `@frontmcp/uipack` runs **server-side** (Node.js) and produces complete HTML documents. `@frontmcp/ui` runs **browser-side** and provides React components and hooks that mount inside those documents.
332
+
333
+ **Bridge contract:** uipack generates a vanilla JS IIFE that creates `window.FrontMcpBridge`. The `@frontmcp/ui` bridge module wraps this same API in a React-friendly class and hooks (`useCallTool`, etc.). The ui package re-exports bridge IIFE generators from uipack via `@frontmcp/ui/bridge/runtime`.
334
+
335
+ **Dependency direction:** `@frontmcp/ui` optionally depends on `@frontmcp/uipack` (optional dependency). They can be used independently — uipack alone for vanilla JS widgets, or together for React-based widgets.
336
+
337
+ **End-to-end data flow:**
338
+
339
+ ```mermaid
340
+ sequenceDiagram
341
+ participant Dev as Developer
342
+ participant SDK as @frontmcp/sdk
343
+ participant UP as @frontmcp/uipack
344
+ participant Browser
345
+ participant UI as @frontmcp/ui
346
+
347
+ Dev->>SDK: @Tool({ ui: { npm: '...' } })
348
+ SDK->>UP: renderComponent(config, shellConfig)
349
+ UP->>UP: resolve deps (esm.sh)
350
+ UP->>UP: build shell (CSP + data injection)
351
+ UP->>UP: inject bridge IIFE
352
+ UP-->>SDK: ShellResult { html, hash, size }
353
+
354
+ Browser->>SDK: readResource("ui://widget/tool.html")
355
+ SDK-->>Browser: cached HTML
356
+
357
+ Browser->>Browser: Load @frontmcp/ui via esm.sh
358
+ Browser->>UI: Mount React components
359
+ UI->>UI: Bridge hooks read window.__mcp* globals
360
+ UI->>Browser: Interactive widget rendered
361
+ ```
362
+
363
+ ### Development
364
+
365
+ ```bash
366
+ # Build
367
+ nx build uipack
368
+
369
+ # Test
370
+ nx test uipack
371
+
372
+ # Lint
373
+ nx lint uipack
374
+ ```
375
+
376
+ ### Testing
377
+
378
+ - 95%+ coverage required across statements, branches, functions, lines
379
+ - **XSS tests** are critical — test all escaping functions with malicious input
380
+ - **CSP tests** — verify generated Content-Security-Policy headers are correct
381
+ - Test all 4 component source modes (npm, file, import, inline)
382
+ - Test bridge IIFE generation for each platform
383
+
384
+ ## Requirements
385
+
386
+ - Node.js >= 22.0.0
71
387
 
72
388
  ## Related Packages
73
389
 
74
- - [`@frontmcp/ui`](../ui) — React components that consume these helpers
75
- - [`@frontmcp/sdk`](../sdk) — core framework and decorators
76
- - [`@frontmcp/testing`](../testing) — UI assertions for automated testing
390
+ - [`@frontmcp/ui`](../ui) — React components, hooks, and renderers that consume uipack output
391
+ - [`@frontmcp/sdk`](../sdk) — Core FrontMCP SDK with `ToolUIRegistry`
392
+ - [`@frontmcp/testing`](../testing) — UI test assertions
77
393
 
78
394
  ## License
79
395
 
80
396
  Apache-2.0 — see [LICENSE](../../LICENSE).
81
-
82
- <!-- links -->
83
-
84
- [docs-overview]: https://docs.agentfront.dev/frontmcp/ui/overview
85
- [docs-theme]: https://docs.agentfront.dev/frontmcp/ui/theming
86
- [docs-build]: https://docs.agentfront.dev/frontmcp/ui/build-tools
87
- [docs-build-modes]: https://docs.agentfront.dev/frontmcp/ui/build-modes
88
- [docs-runtime]: https://docs.agentfront.dev/frontmcp/ui/runtime
89
- [docs-adapters]: https://docs.agentfront.dev/frontmcp/ui/adapters
90
- [docs-validation]: https://docs.agentfront.dev/frontmcp/ui/validation
91
- [docs-bundler]: https://docs.agentfront.dev/frontmcp/ui/bundler
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Base Template
3
+ *
4
+ * Creates default base template for resources/read responses.
5
+ * Uses buildShell() from uipack/shell with bridge IIFE.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /**
10
+ * Options for creating a default base template.
11
+ */
12
+ export interface DefaultBaseTemplateOptions {
13
+ /** Tool name for data injection */
14
+ toolName: string;
15
+ }
16
+ /**
17
+ * Create a default base template for `resources/read` responses.
18
+ *
19
+ * Returns a full HTML document with:
20
+ * - CSP meta tag
21
+ * - Data injection placeholders (window globals)
22
+ * - Bridge runtime IIFE for `ui/initialize` handshake
23
+ * - A root element for widget rendering
24
+ *
25
+ * The bridge handles:
26
+ * - `ui/initialize` handshake with the host
27
+ * - `ui/notifications/tool-result` data injection from host
28
+ */
29
+ export declare function createDefaultBaseTemplate(options: DefaultBaseTemplateOptions): string;
30
+ //# sourceMappingURL=base-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-template.d.ts","sourceRoot":"","sources":["../../src/adapters/base-template.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,GAAG,MAAM,CAoCrF"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * CDN Info Builder
3
+ *
4
+ * Returns CDN dependency info for a given UI type.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ import type { UIType } from '../types/ui-runtime';
9
+ /**
10
+ * CDN info for a UI type, describing base CDN and required dependencies.
11
+ */
12
+ export interface CDNInfo {
13
+ /** Base CDN URL */
14
+ base: string;
15
+ /** Dependencies required for this UI type */
16
+ dependencies: CDNDependencyInfo[];
17
+ }
18
+ /**
19
+ * Individual CDN dependency.
20
+ */
21
+ export interface CDNDependencyInfo {
22
+ /** Package name */
23
+ name: string;
24
+ /** CDN URL */
25
+ url: string;
26
+ }
27
+ /**
28
+ * Build CDN info for a given UI type.
29
+ *
30
+ * @param uiType - The UI type to get CDN info for
31
+ * @returns CDN info object with base URL and dependencies
32
+ */
33
+ export declare function buildCDNInfoForUIType(uiType: UIType | string): CDNInfo;
34
+ //# sourceMappingURL=cdn-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cdn-info.d.ts","sourceRoot":"","sources":["../../src/adapters/cdn-info.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,YAAY,EAAE,iBAAiB,EAAE,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AASD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CA4BtE"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * MCP Apps Protocol Constants
3
+ *
4
+ * Aligned with the MCP Apps specification:
5
+ * https://modelcontextprotocol.io/extensions/apps/overview
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /**
10
+ * MIME type for MCP Apps HTML content.
11
+ * Per the MCP Apps spec: `text/html;profile=mcp-app`
12
+ */
13
+ export declare const MCP_APPS_MIME_TYPE: "text/html;profile=mcp-app";
14
+ /**
15
+ * Extension ID for MCP Apps in capabilities.experimental.
16
+ */
17
+ export declare const MCP_APPS_EXTENSION_ID: "io.modelcontextprotocol/ui";
18
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/adapters/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAG,2BAAoC,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAG,4BAAqC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Content Type Detector
3
+ *
4
+ * Auto-detects the content type from a template result value.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ /**
9
+ * Detected content types from template output.
10
+ */
11
+ export type DetectedContentType = 'chart' | 'mermaid' | 'pdf' | 'html' | 'text' | 'json';
12
+ /**
13
+ * Detect content type from a template result value.
14
+ *
15
+ * @param value - The raw template output
16
+ * @returns The detected content type
17
+ */
18
+ export declare function detectContentType(value: unknown): DetectedContentType;
19
+ //# sourceMappingURL=content-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-detector.d.ts","sourceRoot":"","sources":["../../src/adapters/content-detector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAyBzF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,CAsCrE"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Content Renderers
3
+ *
4
+ * Content-type-specific HTML generators using CDN imports.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ /**
9
+ * Build HTML for a Chart.js chart.
10
+ */
11
+ export declare function buildChartHtml(chartJson: Record<string, unknown>): string;
12
+ /**
13
+ * Build HTML for a Mermaid diagram.
14
+ */
15
+ export declare function buildMermaidHtml(mermaidCode: string): string;
16
+ /**
17
+ * Build HTML for a PDF rendered via PDF.js canvas (sandbox-safe).
18
+ */
19
+ export declare function buildPdfHtml(base64: string): string;
20
+ /**
21
+ * Auto-detect content type and wrap in appropriate HTML.
22
+ *
23
+ * @param value - The raw template output
24
+ * @returns HTML string or undefined if value is plain text/json (no wrapping needed)
25
+ */
26
+ export declare function wrapDetectedContent(value: unknown): string | undefined;
27
+ //# sourceMappingURL=content-renderers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-renderers.d.ts","sourceRoot":"","sources":["../../src/adapters/content-renderers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAqBzE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAoB5D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAoCnD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAiBtE"}
@@ -1,13 +1,20 @@
1
1
  /**
2
- * @frontmcp/ui Adapters
2
+ * @frontmcp/uipack/adapters
3
3
  *
4
- * Platform-specific adapters for building UI metadata.
5
- * These adapters are SDK-independent and can be used by external systems
6
- * like AgentLink without requiring @frontmcp/sdk.
4
+ * SDK integration layer for the UI pipeline.
5
+ * Provides rendering, serving mode resolution, and response formatting
6
+ * aligned with the MCP Apps protocol specification.
7
7
  *
8
8
  * @packageDocumentation
9
9
  */
10
- export { type AIPlatformType, type ExtAppsMimeTypeVariant, type UIMetadata, type BuildUIMetaOptions, type BuildToolDiscoveryMetaOptions, buildUIMeta, buildToolDiscoveryMeta, buildOpenAICSP, buildFrontMCPCSP, getExtAppsMimeType, isExtAppsMimeType, } from './platform-meta';
11
- export { type ResolvedServingMode, type ResolveServingModeOptions, resolveServingMode, isPlatformModeSupported, getDefaultServingMode, platformUsesStructuredContent, platformSupportsWidgets, } from './serving-mode';
12
- export { type TextContentBlock, type BuildToolResponseOptions, type ToolResponseContent, buildToolResponseContent, } from './response-builder';
10
+ export { MCP_APPS_MIME_TYPE, MCP_APPS_EXTENSION_ID } from './constants';
11
+ export { resolveServingMode, type ResolveServingModeOptions, type ServingModeResult, type AdapterPlatformType, } from './serving-mode';
12
+ export { buildToolResponseContent, type ToolResponseContent, type BuildToolResponseContentOptions, } from './response-builder';
13
+ export { isUIRenderFailure, type UIRenderFailure } from './render-failure';
14
+ export { renderToolTemplate, type RenderToolTemplateOptions, type RenderToolTemplateResult } from './template-renderer';
15
+ export { detectContentType, type DetectedContentType } from './content-detector';
16
+ export { buildChartHtml, buildMermaidHtml, buildPdfHtml, wrapDetectedContent } from './content-renderers';
17
+ export { createDefaultBaseTemplate, type DefaultBaseTemplateOptions } from './base-template';
18
+ export { buildCDNInfoForUIType, type CDNInfo, type CDNDependencyInfo } from './cdn-info';
19
+ export { detectUIType } from './type-detector';
13
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAE3B,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,EAElC,WAAW,EACX,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAEhB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAE9B,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EAExB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAKxE,OAAO,EACL,kBAAkB,EAClB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EACL,wBAAwB,EACxB,KAAK,mBAAmB,EACxB,KAAK,+BAA+B,GACrC,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EAAE,iBAAiB,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAK3E,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,KAAK,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAKxH,OAAO,EAAE,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAK1G,OAAO,EAAE,yBAAyB,EAAE,KAAK,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAK7F,OAAO,EAAE,qBAAqB,EAAE,KAAK,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAKzF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}