@frontmcp/uipack 0.12.2 → 1.0.0-beta.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 (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/CLAUDE.md CHANGED
@@ -2,214 +2,116 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- `@frontmcp/uipack` provides **bundling, build tools, platform adapters, and theming** for MCP UI development - all without requiring React.
5
+ `@frontmcp/uipack` provides **HTML shell builder, pluggable import resolver, and NPM component loader** for MCP UI development - all without requiring React.
6
6
 
7
7
  This is the React-free core package. For React components and hooks, use `@frontmcp/ui`.
8
8
 
9
9
  **Key Principles:**
10
10
 
11
11
  - Zero React dependency
12
- - Platform-aware theming and CDN configuration
13
- - Build tools for Tool UI generation
14
- - esbuild/SWC bundling utilities
15
- - Zod schema validation
12
+ - HTML shell generation with CSP, data injection, bridge runtime
13
+ - Pluggable import resolution (esm.sh default, custom resolvers)
14
+ - NPM component loading (npm, file, URL, or inline function)
15
+ - TypeScript type fetching from esm.sh
16
16
 
17
17
  ## Architecture
18
18
 
19
19
  ```text
20
20
  libs/uipack/src/
21
- ├── adapters/ # Platform adapters (OpenAI, Claude, etc.)
22
- ├── base-template/ # Default HTML wrappers with polyfills
23
- ├── bridge-runtime/ # MCP bridge runtime generation
24
- ├── build/ # Build-time API (buildToolUI, etc.)
25
- ├── bundler/ # esbuild/SWC bundling, caching, sandbox
26
- ├── dependency/ # CDN resolution and import maps
27
- ├── handlebars/ # Handlebars template engine
28
- ├── preview/ # Preview server utilities
29
- ├── registry/ # Tool UI registry
30
- ├── renderers/ # HTML/MDX client renderers
31
- ├── runtime/ # Runtime utilities (wrapper, sanitizer, CSP)
32
- ├── styles/ # Style variant definitions
33
- ├── theme/ # Theme system and CDN config
34
- ├── tool-template/ # Tool template utilities
35
- ├── types/ # TypeScript type definitions
36
- ├── typings/ # .d.ts type fetching
37
- ├── utils/ # Utilities (escapeHtml, safeStringify)
38
- ├── validation/ # Zod validation utilities
39
- └── index.ts # Main barrel exports
21
+ ├── bridge-runtime/ # Platform-aware IIFE generator
22
+ ├── component/ # NPM component loader (4 source modes)
23
+ ├── resolver/ # Pluggable import resolution (esm.sh default)
24
+ ├── shell/ # HTML shell builder with CSP, data injection, bridge
25
+ ├── types/ # Standalone UI config types
26
+ ├── typings/ # TypeScript type fetching engine
27
+ ├── utils/ # XSS-safe escaping functions
28
+ └── index.ts # Main barrel exports
40
29
  ```
41
30
 
42
31
  ## Package Split
43
32
 
44
- | Package | Purpose | React Required |
45
- | ------------------ | ------------------------------------------------------- | -------------- |
46
- | `@frontmcp/uipack` | Bundling, build tools, platform adapters, theme | No |
47
- | `@frontmcp/ui` | React components, hooks, SSR rendering, HTML components | Yes |
33
+ | Package | Purpose | React Required |
34
+ | ------------------ | --------------------------------------------------------- | -------------- |
35
+ | `@frontmcp/uipack` | HTML shell builder, import resolver, NPM component loader | No |
36
+ | `@frontmcp/ui` | React components, hooks, SSR rendering | Yes |
48
37
 
49
38
  ## Entry Points
50
39
 
51
- | Path | Purpose |
52
- | -------------------------------- | ------------------------------------- |
53
- | `@frontmcp/uipack` | Main exports |
54
- | `@frontmcp/uipack/adapters` | Platform adapters and meta builders |
55
- | `@frontmcp/uipack/base-template` | Default HTML templates with polyfills |
56
- | `@frontmcp/uipack/build` | Build-time API (buildToolUI) |
57
- | `@frontmcp/uipack/bundler` | esbuild/SWC bundling, cache, sandbox |
58
- | `@frontmcp/uipack/dependency` | CDN resolution and import maps |
59
- | `@frontmcp/uipack/handlebars` | Handlebars integration |
60
- | `@frontmcp/uipack/preview` | Preview server utilities |
61
- | `@frontmcp/uipack/registry` | Tool UI registry |
62
- | `@frontmcp/uipack/renderers` | HTML/MDX client renderers |
63
- | `@frontmcp/uipack/runtime` | Runtime utilities (wrapper, CSP) |
64
- | `@frontmcp/uipack/styles` | Style variants |
65
- | `@frontmcp/uipack/theme` | Theme system and platform config |
66
- | `@frontmcp/uipack/types` | Type definitions |
67
- | `@frontmcp/uipack/typings` | TypeScript definition fetching |
68
- | `@frontmcp/uipack/utils` | Utilities |
69
- | `@frontmcp/uipack/validation` | Zod validation |
70
-
71
- ## Build API
40
+ | Path | Purpose |
41
+ | --------------------------------- | -------------------------------- |
42
+ | `@frontmcp/uipack` | Main exports |
43
+ | `@frontmcp/uipack/types` | Standalone UI config types |
44
+ | `@frontmcp/uipack/utils` | XSS-safe escaping functions |
45
+ | `@frontmcp/uipack/bridge-runtime` | Platform bridge IIFE generator |
46
+ | `@frontmcp/uipack/typings` | TypeScript .d.ts fetching engine |
47
+ | `@frontmcp/uipack/resolver` | Pluggable import resolution |
48
+ | `@frontmcp/uipack/shell` | HTML shell builder |
49
+ | `@frontmcp/uipack/component` | Polymorphic component loader |
72
50
 
73
- ```typescript
74
- import { buildToolUI, getOutputModeForClient } from '@frontmcp/uipack/build';
75
-
76
- // Build tool UI HTML
77
- const html = await buildToolUI({
78
- template: '<div>{{output.data}}</div>',
79
- context: { input: {}, output: { data: 'Hello' } },
80
- platform: 'openai',
81
- });
82
-
83
- // Get output mode for client
84
- const mode = getOutputModeForClient('openai');
85
- ```
86
-
87
- ## Theme System
88
-
89
- ### Default Theme (GitHub/OpenAI)
51
+ ## Shell Builder
90
52
 
91
53
  ```typescript
92
- import { DEFAULT_THEME, createTheme } from '@frontmcp/uipack/theme';
93
-
94
- // Colors
95
- DEFAULT_THEME.colors.semantic.primary; // '#24292f' (near-black)
96
- DEFAULT_THEME.colors.semantic.secondary; // '#57606a' (medium gray)
97
- DEFAULT_THEME.colors.semantic.accent; // '#0969da' (blue accent)
98
- ```
99
-
100
- ### Custom Themes
101
-
102
- ```typescript
103
- const customTheme = createTheme({
104
- name: 'my-theme',
105
- colors: {
106
- semantic: { primary: '#0969da' },
107
- },
108
- cdn: {
109
- fonts: {
110
- preconnect: ['https://fonts.googleapis.com'],
111
- stylesheets: ['https://fonts.googleapis.com/css2?family=Roboto&display=swap'],
112
- },
113
- },
54
+ import { buildShell, buildCSPMetaTag } from '@frontmcp/uipack/shell';
55
+
56
+ // Build an HTML shell with CSP, data injection, and bridge
57
+ const result = buildShell({
58
+ body: '<div id="app"></div>',
59
+ scripts: ['https://esm.sh/react'],
60
+ csp: { scriptSrc: ["'self'"], styleSrc: ["'unsafe-inline'"] },
61
+ data: { output: { temperature: 18 } },
114
62
  });
115
63
  ```
116
64
 
117
- ## Platform Support
118
-
119
- ### Available Platforms
120
-
121
- ```typescript
122
- import { getPlatform, OPENAI_PLATFORM, CLAUDE_PLATFORM } from '@frontmcp/uipack/theme';
123
-
124
- OPENAI_PLATFORM.network; // 'open' - can fetch external resources
125
- CLAUDE_PLATFORM.network; // 'blocked' - needs inline scripts
126
- ```
127
-
128
- ### Building Platform-Aware HTML
65
+ ## Import Resolver
129
66
 
130
67
  ```typescript
131
- import { buildCdnScriptsFromTheme, DEFAULT_THEME } from '@frontmcp/uipack/theme';
132
-
133
- // For platforms with network access
134
- const scripts = buildCdnScriptsFromTheme(DEFAULT_THEME, { inline: false });
68
+ import { resolveImports, createEsmShResolver } from '@frontmcp/uipack/resolver';
135
69
 
136
- // For blocked-network platforms (Claude)
137
- const inlineScripts = buildCdnScriptsFromTheme(DEFAULT_THEME, { inline: true });
70
+ // Resolve NPM imports to CDN URLs
71
+ const resolver = createEsmShResolver();
72
+ const resolved = await resolver.resolve('react', '18.3.0');
138
73
  ```
139
74
 
140
- ## Renderers
141
-
142
- ### HTML Renderer
75
+ ## Component Loader
143
76
 
144
77
  ```typescript
145
- import { htmlRenderer, HtmlRenderer } from '@frontmcp/uipack/renderers';
146
-
147
- // Render HTML template
148
- const html = await htmlRenderer.render(template, context);
149
- ```
78
+ import { loadComponent } from '@frontmcp/uipack/component';
150
79
 
151
- ### MDX Client Renderer (CDN-based)
80
+ // Load component from npm
81
+ const component = await loadComponent({ source: 'npm', package: '@my-org/widget' });
152
82
 
153
- ```typescript
154
- import { mdxClientRenderer, MdxClientRenderer } from '@frontmcp/uipack/renderers';
155
-
156
- // Render MDX using CDN-based React (no bundled React)
157
- const html = await mdxClientRenderer.render(mdxContent, context);
83
+ // Load from URL
84
+ const component = await loadComponent({ source: 'url', href: 'https://cdn.example.com/widget.js' });
158
85
  ```
159
86
 
160
- > **Note:** For server-side MDX rendering with bundled React, use `@frontmcp/ui/renderers`.
161
-
162
- ## Bundler Utilities
87
+ ## Custom Shell Templates
163
88
 
164
89
  ```typescript
165
- import { BundlerCache, hashContent, createCacheKey, validateSource, executeCode } from '@frontmcp/uipack/bundler';
166
-
167
- // Create cache for bundled results
168
- const cache = new BundlerCache({ maxSize: 100, ttl: 60000 });
169
-
170
- // Hash content for cache keys
171
- const hash = hashContent(sourceCode);
172
-
173
- // Validate source code security
174
- const violations = validateSource(code, policy);
175
- ```
176
-
177
- ## Validation
178
-
179
- ```typescript
180
- import { validateOptions, createErrorBox } from '@frontmcp/uipack/validation';
181
-
182
- const result = validateOptions(options, {
183
- schema: MySchema,
184
- componentName: 'MyComponent',
185
- });
90
+ import { resolveShellTemplate, applyShellTemplate } from '@frontmcp/uipack/shell';
186
91
 
187
- if (!result.success) {
188
- return result.error; // HTML error box
189
- }
92
+ // Resolve a custom shell from npm, URL, or inline source
93
+ const template = await resolveShellTemplate({ source: 'npm', package: '@my-org/shell' });
94
+ const html = applyShellTemplate(template, { body: '<div>Content</div>' });
190
95
  ```
191
96
 
192
97
  ## Testing Requirements
193
98
 
194
99
  - **Coverage**: 95%+ across statements, branches, functions, lines
195
- - **Validation Tests**: Every component must test invalid inputs
196
100
  - **XSS Tests**: Test HTML escaping for user-provided content
197
- - **Platform Tests**: Test behavior across platform configurations
101
+ - **CSP Tests**: Test Content Security Policy generation
198
102
 
199
103
  Note: No React dependency!
200
104
 
201
105
  ## Anti-Patterns to Avoid
202
106
 
203
107
  - Using `any` type without justification
204
- - Missing `.strict()` on Zod schemas
205
- - Not validating component options
206
- - Exposing internal error details
207
108
  - Skipping XSS escaping
208
- - Hard-coding CDN URLs (use theme.cdn)
109
+ - Hard-coding CDN URLs (use resolver)
209
110
  - Adding React dependencies (use @frontmcp/ui for React)
111
+ - Importing from deleted modules (renderers, bundler, build, theme, validation, etc.)
210
112
 
211
113
  ## Related Packages
212
114
 
213
- - **@frontmcp/ui** - React components, hooks, SSR rendering, HTML components
115
+ - **@frontmcp/ui** - React components, hooks, SSR rendering
214
116
  - **@frontmcp/sdk** - Core FrontMCP SDK
215
117
  - **@frontmcp/testing** - E2E testing utilities