@frontmcp/ui 0.6.1 → 0.6.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 (292) hide show
  1. package/bridge/core/bridge-factory.d.ts +1 -0
  2. package/bridge/core/bridge-factory.d.ts.map +1 -1
  3. package/bridge/index.d.ts +1 -1
  4. package/bridge/index.d.ts.map +1 -1
  5. package/bridge/index.js +39 -881
  6. package/bundler/browser-components.d.ts +42 -0
  7. package/bundler/browser-components.d.ts.map +1 -0
  8. package/bundler/bundler.d.ts +78 -4
  9. package/bundler/bundler.d.ts.map +1 -1
  10. package/bundler/index.d.ts +8 -8
  11. package/bundler/index.d.ts.map +1 -1
  12. package/bundler/index.js +1315 -1854
  13. package/bundler/types.d.ts +188 -7
  14. package/bundler/types.d.ts.map +1 -1
  15. package/esm/bridge/{index.js → index.mjs} +40 -877
  16. package/esm/bundler/{index.js → index.mjs} +1391 -1895
  17. package/esm/{index.js → index.mjs} +215 -3091
  18. package/esm/layouts/{index.js → index.mjs} +3 -3
  19. package/esm/package.json +9 -8
  20. package/esm/react/index.mjs +1183 -0
  21. package/esm/renderers/index.mjs +611 -0
  22. package/esm/universal/{index.js → index.mjs} +266 -70
  23. package/index.d.ts +1 -4
  24. package/index.d.ts.map +1 -1
  25. package/index.js +208 -3113
  26. package/layouts/base.d.ts.map +1 -1
  27. package/layouts/index.js +3 -3
  28. package/layouts/presets.d.ts.map +1 -1
  29. package/package.json +9 -8
  30. package/react/Badge.d.ts.map +1 -1
  31. package/react/hooks/context.d.ts.map +1 -1
  32. package/react/index.d.ts +0 -1
  33. package/react/index.d.ts.map +1 -1
  34. package/react/index.js +57 -2001
  35. package/react/types.d.ts.map +1 -1
  36. package/renderers/index.d.ts +9 -4
  37. package/renderers/index.d.ts.map +1 -1
  38. package/renderers/index.js +328 -88
  39. package/renderers/mdx.renderer.d.ts +99 -0
  40. package/renderers/mdx.renderer.d.ts.map +1 -0
  41. package/renderers/react.renderer.d.ts +22 -13
  42. package/renderers/react.renderer.d.ts.map +1 -1
  43. package/renderers/transpiler.d.ts +49 -0
  44. package/renderers/transpiler.d.ts.map +1 -0
  45. package/universal/cached-runtime.d.ts +25 -1
  46. package/universal/cached-runtime.d.ts.map +1 -1
  47. package/universal/index.js +266 -70
  48. package/universal/runtime-builder.d.ts.map +1 -1
  49. package/universal/types.d.ts.map +1 -1
  50. package/web-components/elements/fmcp-input.d.ts.map +1 -1
  51. package/web-components/elements/fmcp-select.d.ts.map +1 -1
  52. package/web-components/index.d.ts +0 -1
  53. package/web-components/index.d.ts.map +1 -1
  54. package/bundler/cache.d.ts +0 -173
  55. package/bundler/cache.d.ts.map +0 -1
  56. package/bundler/file-cache/component-builder.d.ts +0 -167
  57. package/bundler/file-cache/component-builder.d.ts.map +0 -1
  58. package/bundler/file-cache/hash-calculator.d.ts +0 -155
  59. package/bundler/file-cache/hash-calculator.d.ts.map +0 -1
  60. package/bundler/file-cache/index.d.ts +0 -12
  61. package/bundler/file-cache/index.d.ts.map +0 -1
  62. package/bundler/file-cache/storage/filesystem.d.ts +0 -149
  63. package/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
  64. package/bundler/file-cache/storage/index.d.ts +0 -11
  65. package/bundler/file-cache/storage/index.d.ts.map +0 -1
  66. package/bundler/file-cache/storage/interface.d.ts +0 -152
  67. package/bundler/file-cache/storage/interface.d.ts.map +0 -1
  68. package/bundler/file-cache/storage/redis.d.ts +0 -139
  69. package/bundler/file-cache/storage/redis.d.ts.map +0 -1
  70. package/bundler/sandbox/enclave-adapter.d.ts +0 -121
  71. package/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
  72. package/bundler/sandbox/executor.d.ts +0 -14
  73. package/bundler/sandbox/executor.d.ts.map +0 -1
  74. package/bundler/sandbox/policy.d.ts +0 -62
  75. package/bundler/sandbox/policy.d.ts.map +0 -1
  76. package/esm/bridge/adapters/base-adapter.d.ts +0 -104
  77. package/esm/bridge/adapters/base-adapter.d.ts.map +0 -1
  78. package/esm/bridge/adapters/claude.adapter.d.ts +0 -67
  79. package/esm/bridge/adapters/claude.adapter.d.ts.map +0 -1
  80. package/esm/bridge/adapters/ext-apps.adapter.d.ts +0 -143
  81. package/esm/bridge/adapters/ext-apps.adapter.d.ts.map +0 -1
  82. package/esm/bridge/adapters/gemini.adapter.d.ts +0 -64
  83. package/esm/bridge/adapters/gemini.adapter.d.ts.map +0 -1
  84. package/esm/bridge/adapters/generic.adapter.d.ts +0 -56
  85. package/esm/bridge/adapters/generic.adapter.d.ts.map +0 -1
  86. package/esm/bridge/adapters/index.d.ts +0 -26
  87. package/esm/bridge/adapters/index.d.ts.map +0 -1
  88. package/esm/bridge/adapters/openai.adapter.d.ts +0 -65
  89. package/esm/bridge/adapters/openai.adapter.d.ts.map +0 -1
  90. package/esm/bridge/core/adapter-registry.d.ts +0 -122
  91. package/esm/bridge/core/adapter-registry.d.ts.map +0 -1
  92. package/esm/bridge/core/bridge-factory.d.ts +0 -199
  93. package/esm/bridge/core/bridge-factory.d.ts.map +0 -1
  94. package/esm/bridge/core/index.d.ts +0 -10
  95. package/esm/bridge/core/index.d.ts.map +0 -1
  96. package/esm/bridge/index.d.ts +0 -62
  97. package/esm/bridge/index.d.ts.map +0 -1
  98. package/esm/bridge/runtime/iife-generator.d.ts +0 -62
  99. package/esm/bridge/runtime/iife-generator.d.ts.map +0 -1
  100. package/esm/bridge/runtime/index.d.ts +0 -10
  101. package/esm/bridge/runtime/index.d.ts.map +0 -1
  102. package/esm/bridge/types.d.ts +0 -386
  103. package/esm/bridge/types.d.ts.map +0 -1
  104. package/esm/bundler/bundler.d.ts +0 -208
  105. package/esm/bundler/bundler.d.ts.map +0 -1
  106. package/esm/bundler/cache.d.ts +0 -173
  107. package/esm/bundler/cache.d.ts.map +0 -1
  108. package/esm/bundler/file-cache/component-builder.d.ts +0 -167
  109. package/esm/bundler/file-cache/component-builder.d.ts.map +0 -1
  110. package/esm/bundler/file-cache/hash-calculator.d.ts +0 -155
  111. package/esm/bundler/file-cache/hash-calculator.d.ts.map +0 -1
  112. package/esm/bundler/file-cache/index.d.ts +0 -12
  113. package/esm/bundler/file-cache/index.d.ts.map +0 -1
  114. package/esm/bundler/file-cache/storage/filesystem.d.ts +0 -149
  115. package/esm/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
  116. package/esm/bundler/file-cache/storage/index.d.ts +0 -11
  117. package/esm/bundler/file-cache/storage/index.d.ts.map +0 -1
  118. package/esm/bundler/file-cache/storage/interface.d.ts +0 -152
  119. package/esm/bundler/file-cache/storage/interface.d.ts.map +0 -1
  120. package/esm/bundler/file-cache/storage/redis.d.ts +0 -139
  121. package/esm/bundler/file-cache/storage/redis.d.ts.map +0 -1
  122. package/esm/bundler/index.d.ts +0 -43
  123. package/esm/bundler/index.d.ts.map +0 -1
  124. package/esm/bundler/sandbox/enclave-adapter.d.ts +0 -121
  125. package/esm/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
  126. package/esm/bundler/sandbox/executor.d.ts +0 -14
  127. package/esm/bundler/sandbox/executor.d.ts.map +0 -1
  128. package/esm/bundler/sandbox/policy.d.ts +0 -62
  129. package/esm/bundler/sandbox/policy.d.ts.map +0 -1
  130. package/esm/bundler/types.d.ts +0 -702
  131. package/esm/bundler/types.d.ts.map +0 -1
  132. package/esm/components/alert.d.ts +0 -66
  133. package/esm/components/alert.d.ts.map +0 -1
  134. package/esm/components/alert.schema.d.ts +0 -98
  135. package/esm/components/alert.schema.d.ts.map +0 -1
  136. package/esm/components/avatar.d.ts +0 -77
  137. package/esm/components/avatar.d.ts.map +0 -1
  138. package/esm/components/avatar.schema.d.ts +0 -170
  139. package/esm/components/avatar.schema.d.ts.map +0 -1
  140. package/esm/components/badge.d.ts +0 -64
  141. package/esm/components/badge.d.ts.map +0 -1
  142. package/esm/components/badge.schema.d.ts +0 -91
  143. package/esm/components/badge.schema.d.ts.map +0 -1
  144. package/esm/components/button.d.ts +0 -100
  145. package/esm/components/button.d.ts.map +0 -1
  146. package/esm/components/button.schema.d.ts +0 -120
  147. package/esm/components/button.schema.d.ts.map +0 -1
  148. package/esm/components/card.d.ts +0 -53
  149. package/esm/components/card.d.ts.map +0 -1
  150. package/esm/components/card.schema.d.ts +0 -93
  151. package/esm/components/card.schema.d.ts.map +0 -1
  152. package/esm/components/form.d.ts +0 -212
  153. package/esm/components/form.d.ts.map +0 -1
  154. package/esm/components/form.schema.d.ts +0 -365
  155. package/esm/components/form.schema.d.ts.map +0 -1
  156. package/esm/components/index.d.ts +0 -29
  157. package/esm/components/index.d.ts.map +0 -1
  158. package/esm/components/list.d.ts +0 -121
  159. package/esm/components/list.d.ts.map +0 -1
  160. package/esm/components/list.schema.d.ts +0 -129
  161. package/esm/components/list.schema.d.ts.map +0 -1
  162. package/esm/components/modal.d.ts +0 -100
  163. package/esm/components/modal.d.ts.map +0 -1
  164. package/esm/components/modal.schema.d.ts +0 -151
  165. package/esm/components/modal.schema.d.ts.map +0 -1
  166. package/esm/components/table.d.ts +0 -91
  167. package/esm/components/table.d.ts.map +0 -1
  168. package/esm/components/table.schema.d.ts +0 -123
  169. package/esm/components/table.schema.d.ts.map +0 -1
  170. package/esm/index.d.ts +0 -40
  171. package/esm/index.d.ts.map +0 -1
  172. package/esm/layouts/base.d.ts +0 -86
  173. package/esm/layouts/base.d.ts.map +0 -1
  174. package/esm/layouts/index.d.ts +0 -8
  175. package/esm/layouts/index.d.ts.map +0 -1
  176. package/esm/layouts/presets.d.ts +0 -134
  177. package/esm/layouts/presets.d.ts.map +0 -1
  178. package/esm/pages/consent.d.ts +0 -117
  179. package/esm/pages/consent.d.ts.map +0 -1
  180. package/esm/pages/error.d.ts +0 -101
  181. package/esm/pages/error.d.ts.map +0 -1
  182. package/esm/pages/index.d.ts +0 -9
  183. package/esm/pages/index.d.ts.map +0 -1
  184. package/esm/pages/index.js +0 -1036
  185. package/esm/react/Alert.d.ts +0 -101
  186. package/esm/react/Alert.d.ts.map +0 -1
  187. package/esm/react/Badge.d.ts +0 -100
  188. package/esm/react/Badge.d.ts.map +0 -1
  189. package/esm/react/Button.d.ts +0 -108
  190. package/esm/react/Button.d.ts.map +0 -1
  191. package/esm/react/Card.d.ts +0 -103
  192. package/esm/react/Card.d.ts.map +0 -1
  193. package/esm/react/hooks/context.d.ts +0 -179
  194. package/esm/react/hooks/context.d.ts.map +0 -1
  195. package/esm/react/hooks/index.d.ts +0 -42
  196. package/esm/react/hooks/index.d.ts.map +0 -1
  197. package/esm/react/hooks/tools.d.ts +0 -284
  198. package/esm/react/hooks/tools.d.ts.map +0 -1
  199. package/esm/react/index.d.ts +0 -80
  200. package/esm/react/index.d.ts.map +0 -1
  201. package/esm/react/index.js +0 -3124
  202. package/esm/react/types.d.ts +0 -105
  203. package/esm/react/types.d.ts.map +0 -1
  204. package/esm/react/utils.d.ts +0 -43
  205. package/esm/react/utils.d.ts.map +0 -1
  206. package/esm/render/index.d.ts +0 -8
  207. package/esm/render/index.d.ts.map +0 -1
  208. package/esm/render/prerender.d.ts +0 -57
  209. package/esm/render/prerender.d.ts.map +0 -1
  210. package/esm/renderers/index.d.ts +0 -21
  211. package/esm/renderers/index.d.ts.map +0 -1
  212. package/esm/renderers/index.js +0 -381
  213. package/esm/renderers/react.adapter.d.ts +0 -70
  214. package/esm/renderers/react.adapter.d.ts.map +0 -1
  215. package/esm/renderers/react.renderer.d.ts +0 -96
  216. package/esm/renderers/react.renderer.d.ts.map +0 -1
  217. package/esm/universal/UniversalApp.d.ts +0 -108
  218. package/esm/universal/UniversalApp.d.ts.map +0 -1
  219. package/esm/universal/cached-runtime.d.ts +0 -115
  220. package/esm/universal/cached-runtime.d.ts.map +0 -1
  221. package/esm/universal/context.d.ts +0 -122
  222. package/esm/universal/context.d.ts.map +0 -1
  223. package/esm/universal/index.d.ts +0 -57
  224. package/esm/universal/index.d.ts.map +0 -1
  225. package/esm/universal/renderers/html.renderer.d.ts +0 -37
  226. package/esm/universal/renderers/html.renderer.d.ts.map +0 -1
  227. package/esm/universal/renderers/index.d.ts +0 -112
  228. package/esm/universal/renderers/index.d.ts.map +0 -1
  229. package/esm/universal/renderers/markdown.renderer.d.ts +0 -33
  230. package/esm/universal/renderers/markdown.renderer.d.ts.map +0 -1
  231. package/esm/universal/renderers/mdx.renderer.d.ts +0 -38
  232. package/esm/universal/renderers/mdx.renderer.d.ts.map +0 -1
  233. package/esm/universal/renderers/react.renderer.d.ts +0 -46
  234. package/esm/universal/renderers/react.renderer.d.ts.map +0 -1
  235. package/esm/universal/runtime-builder.d.ts +0 -33
  236. package/esm/universal/runtime-builder.d.ts.map +0 -1
  237. package/esm/universal/store.d.ts +0 -135
  238. package/esm/universal/store.d.ts.map +0 -1
  239. package/esm/universal/types.d.ts +0 -199
  240. package/esm/universal/types.d.ts.map +0 -1
  241. package/esm/web-components/core/attribute-parser.d.ts +0 -82
  242. package/esm/web-components/core/attribute-parser.d.ts.map +0 -1
  243. package/esm/web-components/core/base-element.d.ts +0 -197
  244. package/esm/web-components/core/base-element.d.ts.map +0 -1
  245. package/esm/web-components/core/index.d.ts +0 -9
  246. package/esm/web-components/core/index.d.ts.map +0 -1
  247. package/esm/web-components/elements/fmcp-alert.d.ts +0 -46
  248. package/esm/web-components/elements/fmcp-alert.d.ts.map +0 -1
  249. package/esm/web-components/elements/fmcp-badge.d.ts +0 -47
  250. package/esm/web-components/elements/fmcp-badge.d.ts.map +0 -1
  251. package/esm/web-components/elements/fmcp-button.d.ts +0 -117
  252. package/esm/web-components/elements/fmcp-button.d.ts.map +0 -1
  253. package/esm/web-components/elements/fmcp-card.d.ts +0 -53
  254. package/esm/web-components/elements/fmcp-card.d.ts.map +0 -1
  255. package/esm/web-components/elements/fmcp-input.d.ts +0 -96
  256. package/esm/web-components/elements/fmcp-input.d.ts.map +0 -1
  257. package/esm/web-components/elements/fmcp-select.d.ts +0 -100
  258. package/esm/web-components/elements/fmcp-select.d.ts.map +0 -1
  259. package/esm/web-components/elements/index.d.ts +0 -13
  260. package/esm/web-components/elements/index.d.ts.map +0 -1
  261. package/esm/web-components/index.d.ts +0 -50
  262. package/esm/web-components/index.d.ts.map +0 -1
  263. package/esm/web-components/register.d.ts +0 -57
  264. package/esm/web-components/register.d.ts.map +0 -1
  265. package/esm/web-components/types.d.ts +0 -122
  266. package/esm/web-components/types.d.ts.map +0 -1
  267. package/esm/widgets/index.d.ts +0 -8
  268. package/esm/widgets/index.d.ts.map +0 -1
  269. package/esm/widgets/index.js +0 -883
  270. package/esm/widgets/progress.d.ts +0 -133
  271. package/esm/widgets/progress.d.ts.map +0 -1
  272. package/esm/widgets/resource.d.ts +0 -163
  273. package/esm/widgets/resource.d.ts.map +0 -1
  274. package/pages/consent.d.ts +0 -117
  275. package/pages/consent.d.ts.map +0 -1
  276. package/pages/error.d.ts +0 -101
  277. package/pages/error.d.ts.map +0 -1
  278. package/pages/index.d.ts +0 -9
  279. package/pages/index.d.ts.map +0 -1
  280. package/pages/index.js +0 -1065
  281. package/react/utils.d.ts +0 -43
  282. package/react/utils.d.ts.map +0 -1
  283. package/widgets/index.d.ts +0 -8
  284. package/widgets/index.d.ts.map +0 -1
  285. package/widgets/index.js +0 -910
  286. package/widgets/progress.d.ts +0 -133
  287. package/widgets/progress.d.ts.map +0 -1
  288. package/widgets/resource.d.ts +0 -163
  289. package/widgets/resource.d.ts.map +0 -1
  290. /package/esm/components/{index.js → index.mjs} +0 -0
  291. /package/esm/render/{index.js → index.mjs} +0 -0
  292. /package/esm/web-components/{index.js → index.mjs} +0 -0
@@ -1,386 +0,0 @@
1
- /**
2
- * FrontMcpBridge Core Types
3
- *
4
- * Type definitions for the unified multi-platform adapter system.
5
- * Supports OpenAI, Claude, ext-apps (SEP-1865), Gemini, and custom adapters.
6
- *
7
- * @packageDocumentation
8
- */
9
- /**
10
- * Widget display mode preference.
11
- */
12
- export type DisplayMode = 'inline' | 'fullscreen' | 'pip' | 'carousel';
13
- /**
14
- * User agent information for device capability detection.
15
- */
16
- export interface UserAgentInfo {
17
- /** Device type */
18
- type: 'web' | 'mobile' | 'desktop';
19
- /** Has hover capability (mouse/trackpad) */
20
- hover: boolean;
21
- /** Has touch capability */
22
- touch: boolean;
23
- }
24
- /**
25
- * Safe area insets for mobile devices (notch, home indicator, etc.)
26
- */
27
- export interface SafeAreaInsets {
28
- top: number;
29
- bottom: number;
30
- left: number;
31
- right: number;
32
- }
33
- /**
34
- * Viewport information for responsive widgets.
35
- */
36
- export interface ViewportInfo {
37
- width?: number;
38
- height?: number;
39
- maxWidth?: number;
40
- maxHeight?: number;
41
- }
42
- /**
43
- * Host context provided by the AI platform.
44
- */
45
- export interface HostContext {
46
- /** Current theme */
47
- theme: 'light' | 'dark';
48
- /** Current display mode */
49
- displayMode: DisplayMode;
50
- /** BCP 47 locale */
51
- locale: string;
52
- /** IANA timezone */
53
- timezone?: string;
54
- /** User agent capabilities */
55
- userAgent: UserAgentInfo;
56
- /** Safe area insets */
57
- safeArea: SafeAreaInsets;
58
- /** Viewport dimensions */
59
- viewport?: ViewportInfo;
60
- /** Platform identifier */
61
- platform?: 'web' | 'desktop' | 'ios' | 'android';
62
- }
63
- /**
64
- * Capability flags for platform adapters.
65
- * Used for feature detection before calling unavailable features.
66
- */
67
- export interface AdapterCapabilities {
68
- /** Can invoke server-side MCP tools */
69
- canCallTools: boolean;
70
- /** Can send follow-up messages to the conversation */
71
- canSendMessages: boolean;
72
- /** Can open external links */
73
- canOpenLinks: boolean;
74
- /** Can persist widget state across sessions */
75
- canPersistState: boolean;
76
- /** Has network access for fetch/XHR */
77
- hasNetworkAccess: boolean;
78
- /** Supports display mode changes (fullscreen, pip) */
79
- supportsDisplayModes: boolean;
80
- /** Supports theme detection */
81
- supportsTheme: boolean;
82
- /** Custom capability extensions */
83
- extensions?: Record<string, boolean>;
84
- }
85
- /**
86
- * Platform adapter interface - implemented by each platform.
87
- * Provides a consistent API across OpenAI, Claude, ext-apps, Gemini, etc.
88
- */
89
- export interface PlatformAdapter {
90
- /** Unique adapter identifier (e.g., 'openai', 'claude', 'ext-apps') */
91
- readonly id: string;
92
- /** Human-readable adapter name */
93
- readonly name: string;
94
- /** Adapter priority for auto-detection (higher = checked first) */
95
- readonly priority: number;
96
- /** Static capability flags */
97
- readonly capabilities: AdapterCapabilities;
98
- /**
99
- * Check if this adapter can handle the current environment.
100
- * Called during auto-detection to find the best adapter.
101
- */
102
- canHandle(): boolean;
103
- /**
104
- * Initialize the adapter.
105
- * For ext-apps, this performs the ui/initialize handshake.
106
- * @returns Promise that resolves when the adapter is ready
107
- */
108
- initialize(): Promise<void>;
109
- /**
110
- * Clean up adapter resources.
111
- * Called when switching adapters or disposing the bridge.
112
- */
113
- dispose(): void;
114
- /** Get current theme */
115
- getTheme(): 'light' | 'dark';
116
- /** Get current display mode */
117
- getDisplayMode(): DisplayMode;
118
- /** Get user agent info */
119
- getUserAgent(): UserAgentInfo;
120
- /** Get BCP 47 locale */
121
- getLocale(): string;
122
- /** Get tool input arguments */
123
- getToolInput(): Record<string, unknown>;
124
- /** Get tool output/result */
125
- getToolOutput(): unknown;
126
- /** Get structured content (parsed output) */
127
- getStructuredContent(): unknown;
128
- /** Get persisted widget state */
129
- getWidgetState(): Record<string, unknown>;
130
- /** Get safe area insets */
131
- getSafeArea(): SafeAreaInsets;
132
- /** Get viewport info */
133
- getViewport(): ViewportInfo | undefined;
134
- /** Get full host context */
135
- getHostContext(): HostContext;
136
- /**
137
- * Call a tool on the MCP server.
138
- * @param name - Tool name
139
- * @param args - Tool arguments
140
- * @returns Promise resolving to tool result
141
- */
142
- callTool(name: string, args: Record<string, unknown>): Promise<unknown>;
143
- /**
144
- * Send a follow-up message to the conversation.
145
- * @param content - Message content
146
- */
147
- sendMessage(content: string): Promise<void>;
148
- /**
149
- * Open an external link.
150
- * @param url - URL to open
151
- */
152
- openLink(url: string): Promise<void>;
153
- /**
154
- * Request a display mode change.
155
- * @param mode - Desired display mode
156
- */
157
- requestDisplayMode(mode: DisplayMode): Promise<void>;
158
- /**
159
- * Request widget close.
160
- */
161
- requestClose(): Promise<void>;
162
- /**
163
- * Set widget state (persisted across sessions).
164
- * @param state - State object to persist
165
- */
166
- setWidgetState(state: Record<string, unknown>): void;
167
- /**
168
- * Subscribe to host context changes.
169
- * @param callback - Called when context changes (theme, displayMode, etc.)
170
- * @returns Unsubscribe function
171
- */
172
- onContextChange(callback: (changes: Partial<HostContext>) => void): () => void;
173
- /**
174
- * Subscribe to tool result updates.
175
- * @param callback - Called when tool result is received
176
- * @returns Unsubscribe function
177
- */
178
- onToolResult(callback: (result: unknown) => void): () => void;
179
- }
180
- /**
181
- * Per-adapter configuration options.
182
- */
183
- export interface AdapterConfig {
184
- /** Enable/disable this adapter */
185
- enabled?: boolean;
186
- /** Priority override */
187
- priority?: number;
188
- /** Adapter-specific options */
189
- options?: Record<string, unknown>;
190
- }
191
- /**
192
- * FrontMcpBridge configuration.
193
- */
194
- export interface BridgeConfig {
195
- /** Force a specific adapter (skip auto-detection) */
196
- forceAdapter?: string;
197
- /** Explicitly disable certain adapters */
198
- disabledAdapters?: string[];
199
- /** Debug mode (verbose logging) */
200
- debug?: boolean;
201
- /** Timeout for adapter initialization (ms) */
202
- initTimeout?: number;
203
- /** Trusted origins for postMessage (ext-apps security) */
204
- trustedOrigins?: string[];
205
- /** Per-adapter configurations */
206
- adapterConfigs?: Record<string, AdapterConfig>;
207
- }
208
- /**
209
- * JSON-RPC 2.0 message base.
210
- */
211
- export interface JsonRpcMessage {
212
- jsonrpc: '2.0';
213
- }
214
- /**
215
- * JSON-RPC request message.
216
- */
217
- export interface JsonRpcRequest extends JsonRpcMessage {
218
- id: string | number;
219
- method: string;
220
- params?: unknown;
221
- }
222
- /**
223
- * JSON-RPC response message.
224
- */
225
- export interface JsonRpcResponse extends JsonRpcMessage {
226
- id: string | number;
227
- result?: unknown;
228
- error?: JsonRpcError;
229
- }
230
- /**
231
- * JSON-RPC notification message (no id, no response expected).
232
- */
233
- export interface JsonRpcNotification extends JsonRpcMessage {
234
- method: string;
235
- params?: unknown;
236
- }
237
- /**
238
- * JSON-RPC error object.
239
- */
240
- export interface JsonRpcError {
241
- code: number;
242
- message: string;
243
- data?: unknown;
244
- }
245
- /**
246
- * SEP-1865 ui/initialize request params.
247
- */
248
- export interface ExtAppsInitializeParams {
249
- appInfo: {
250
- name: string;
251
- version: string;
252
- };
253
- appCapabilities: {
254
- tools?: {
255
- listChanged: boolean;
256
- };
257
- };
258
- protocolVersion: string;
259
- }
260
- /**
261
- * SEP-1865 ui/initialize response result.
262
- */
263
- export interface ExtAppsInitializeResult {
264
- protocolVersion: string;
265
- hostInfo: {
266
- name: string;
267
- version: string;
268
- };
269
- hostCapabilities: {
270
- openLink?: boolean;
271
- serverToolProxy?: boolean;
272
- resourceRead?: boolean;
273
- logging?: boolean;
274
- };
275
- hostContext: HostContext;
276
- }
277
- /**
278
- * SEP-1865 tool input notification params.
279
- */
280
- export interface ExtAppsToolInputParams {
281
- arguments: Record<string, unknown>;
282
- }
283
- /**
284
- * SEP-1865 tool result notification params.
285
- */
286
- export interface ExtAppsToolResultParams {
287
- content: unknown;
288
- structuredContent?: unknown;
289
- isError?: boolean;
290
- }
291
- /**
292
- * SEP-1865 host context change notification params.
293
- */
294
- export interface ExtAppsHostContextChangeParams {
295
- theme?: 'light' | 'dark';
296
- displayMode?: DisplayMode;
297
- viewport?: ViewportInfo;
298
- locale?: string;
299
- timezone?: string;
300
- }
301
- /**
302
- * Bridge event types for CustomEvent dispatch.
303
- */
304
- export type BridgeEventType = 'bridge:ready' | 'bridge:error' | 'bridge:adapter-changed' | 'context:change' | 'tool:input' | 'tool:input-partial' | 'tool:result' | 'tool:cancelled';
305
- /**
306
- * Bridge event payload map.
307
- */
308
- export interface BridgeEventPayloads {
309
- 'bridge:ready': {
310
- adapter: string;
311
- };
312
- 'bridge:error': {
313
- error: Error;
314
- adapter?: string;
315
- };
316
- 'bridge:adapter-changed': {
317
- from?: string;
318
- to: string;
319
- };
320
- 'context:change': Partial<HostContext>;
321
- 'tool:input': {
322
- arguments: Record<string, unknown>;
323
- };
324
- 'tool:input-partial': {
325
- arguments: Record<string, unknown>;
326
- };
327
- 'tool:result': {
328
- content: unknown;
329
- structuredContent?: unknown;
330
- };
331
- 'tool:cancelled': {
332
- reason?: string;
333
- };
334
- }
335
- /**
336
- * Adapter factory function type.
337
- */
338
- export type AdapterFactory = (config?: AdapterConfig) => PlatformAdapter;
339
- /**
340
- * Adapter registration entry.
341
- */
342
- export interface AdapterRegistration {
343
- id: string;
344
- factory: AdapterFactory;
345
- defaultConfig?: AdapterConfig;
346
- }
347
- /**
348
- * FrontMcpBridge public interface.
349
- * Unified entry point for all platform interactions.
350
- */
351
- export interface FrontMcpBridgeInterface {
352
- /** Whether the bridge is initialized */
353
- readonly initialized: boolean;
354
- /** Current adapter ID */
355
- readonly adapterId: string | undefined;
356
- /** Current adapter capabilities */
357
- readonly capabilities: AdapterCapabilities | undefined;
358
- /**
359
- * Initialize the bridge (auto-detects platform).
360
- */
361
- initialize(): Promise<void>;
362
- /**
363
- * Get the active adapter.
364
- */
365
- getAdapter(): PlatformAdapter | undefined;
366
- /**
367
- * Check if a specific capability is available.
368
- */
369
- hasCapability(cap: keyof AdapterCapabilities): boolean;
370
- /**
371
- * Dispose the bridge and release resources.
372
- */
373
- dispose(): void;
374
- getTheme(): 'light' | 'dark';
375
- getDisplayMode(): DisplayMode;
376
- getToolInput(): Record<string, unknown>;
377
- getToolOutput(): unknown;
378
- callTool(name: string, args: Record<string, unknown>): Promise<unknown>;
379
- sendMessage(content: string): Promise<void>;
380
- openLink(url: string): Promise<void>;
381
- requestDisplayMode(mode: DisplayMode): Promise<void>;
382
- setWidgetState(state: Record<string, unknown>): void;
383
- onContextChange(callback: (changes: Partial<HostContext>) => void): () => void;
384
- onToolResult(callback: (result: unknown) => void): () => void;
385
- }
386
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/bridge/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;GAEG;AACH,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IAAI,WAAW,CAAC;IAC9B,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,aAAa,IAAI,OAAO,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACxE,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,kBAAkB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACrD,eAAe,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC/E,YAAY,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC/D"}
@@ -1,208 +0,0 @@
1
- /**
2
- * In-Memory Bundler
3
- *
4
- * Fast, secure bundler for JSX/TSX/MDX sources using esbuild.
5
- * Provides caching, security validation, and SSR support.
6
- *
7
- * @packageDocumentation
8
- */
9
- import type { BundleOptions, BundleResult, SSRBundleOptions, SSRResult, BundlerOptions, StaticHTMLOptions, StaticHTMLResult } from './types';
10
- /**
11
- * In-memory bundler for JSX/TSX/MDX sources.
12
- *
13
- * Features:
14
- * - Fast transformation using esbuild (fallback to SWC)
15
- * - Content-addressable caching
16
- * - Security validation (blocked imports, eval, etc.)
17
- * - SSR support for React components
18
- *
19
- * @example
20
- * ```typescript
21
- * const bundler = new InMemoryBundler();
22
- *
23
- * // Bundle JSX source
24
- * const result = await bundler.bundle({
25
- * source: 'const App = () => <div>Hello</div>; export default App;',
26
- * sourceType: 'jsx',
27
- * });
28
- *
29
- * console.log(result.code); // Bundled JavaScript
30
- * console.log(result.cached); // Whether from cache
31
- *
32
- * // SSR rendering
33
- * const ssrResult = await bundler.bundleSSR({
34
- * source: 'export default ({ data }) => <div>{data.message}</div>',
35
- * sourceType: 'jsx',
36
- * context: { data: { message: 'Hello' } },
37
- * });
38
- *
39
- * console.log(ssrResult.html); // Rendered HTML
40
- * ```
41
- */
42
- export declare class InMemoryBundler {
43
- private readonly cache;
44
- private readonly options;
45
- private readonly defaultSecurity;
46
- constructor(options?: BundlerOptions);
47
- /**
48
- * Bundle source code.
49
- *
50
- * @param options - Bundle options
51
- * @returns Bundle result
52
- */
53
- bundle(options: BundleOptions): Promise<BundleResult>;
54
- /**
55
- * Bundle and execute for SSR.
56
- *
57
- * @param options - SSR bundle options
58
- * @returns SSR result with rendered HTML
59
- */
60
- bundleSSR(options: SSRBundleOptions): Promise<SSRResult>;
61
- /**
62
- * Bundle and execute code, returning the exports.
63
- *
64
- * @param options - Bundle options
65
- * @param context - Execution context
66
- * @returns Exported value
67
- */
68
- bundleAndExecute<T = unknown>(options: BundleOptions, context?: Record<string, unknown>): Promise<T>;
69
- /**
70
- * Bundle a component to a self-contained static HTML document.
71
- *
72
- * Creates a complete HTML page with:
73
- * - React runtime (CDN or inline based on platform)
74
- * - FrontMCP UI hooks and components (always inline)
75
- * - Tool data injection (input/output)
76
- * - Transpiled component code
77
- * - Client-side rendering via createRoot
78
- *
79
- * @param options - Static HTML options
80
- * @returns Static HTML result with complete document
81
- *
82
- * @example
83
- * ```typescript
84
- * const result = await bundler.bundleToStaticHTML({
85
- * source: `
86
- * import { Card, useToolOutput } from '@frontmcp/ui/react';
87
- * export default function Weather() {
88
- * const output = useToolOutput();
89
- * return <Card title="Weather">{output?.temperature}°F</Card>;
90
- * }
91
- * `,
92
- * toolName: 'get_weather',
93
- * output: { temperature: 72 },
94
- * });
95
- *
96
- * // result.html contains the complete HTML document
97
- * ```
98
- */
99
- bundleToStaticHTML(options: StaticHTMLOptions): Promise<StaticHTMLResult>;
100
- /**
101
- * Bundle to static HTML with universal rendering mode.
102
- * Uses the universal renderer that can handle multiple content types.
103
- *
104
- * Optimization: Uses cached runtime (vendor chunk) to avoid rebuilding
105
- * static code on every request. Only the user's component is transpiled.
106
- */
107
- private bundleToStaticHTMLUniversal;
108
- /**
109
- * Assemble the complete universal static HTML document using cached runtime.
110
- *
111
- * For ESM mode (OpenAI), scripts must wait for React to load asynchronously.
112
- * For UMD mode (Claude), scripts can execute synchronously.
113
- */
114
- private assembleUniversalStaticHTMLCached;
115
- /**
116
- * Build the component script for transpiled React/MDX content.
117
- * Wraps CommonJS code with module/exports shim to capture the component.
118
- */
119
- private buildUniversalComponentScript;
120
- /**
121
- * Build the universal runtime script section.
122
- */
123
- private buildUniversalRuntimeScript;
124
- /**
125
- * Build data injection script for universal mode.
126
- */
127
- private buildUniversalDataScript;
128
- /**
129
- * Build the universal render script.
130
- */
131
- private buildUniversalRenderScript;
132
- /**
133
- * Assemble the complete universal static HTML document.
134
- */
135
- private assembleUniversalStaticHTML;
136
- /**
137
- * Get cache statistics.
138
- */
139
- getCacheStats(): import("./cache").CacheStats;
140
- /**
141
- * Clear the cache.
142
- */
143
- clearCache(): void;
144
- /**
145
- * Clean up expired cache entries.
146
- */
147
- cleanupCache(): number;
148
- /**
149
- * Transform source code using esbuild/SWC.
150
- */
151
- private transform;
152
- /**
153
- * Get esbuild loader for source type.
154
- */
155
- private getLoader;
156
- /**
157
- * Detect source type from content.
158
- */
159
- private detectSourceType;
160
- /**
161
- * Merge bundle options with defaults.
162
- */
163
- private mergeOptions;
164
- /**
165
- * Build hydration script for client-side React.
166
- */
167
- private buildHydrationScript;
168
- /**
169
- * Merge static HTML options with defaults.
170
- */
171
- private mergeStaticHTMLOptions;
172
- /**
173
- * Build the <head> section for static HTML.
174
- */
175
- private buildStaticHTMLHead;
176
- /**
177
- * Build React runtime scripts for static HTML.
178
- */
179
- private buildReactRuntimeScripts;
180
- /**
181
- * Build FrontMCP runtime (hooks and UI components).
182
- * Always inlined for reliability across platforms.
183
- */
184
- private buildFrontMCPRuntime;
185
- /**
186
- * Build data injection script for tool input/output.
187
- */
188
- private buildDataInjectionScript;
189
- /**
190
- * Build component render script.
191
- * Wraps CommonJS code with module/exports shim to capture the component.
192
- */
193
- private buildComponentRenderScript;
194
- /**
195
- * Assemble the complete static HTML document.
196
- */
197
- private assembleStaticHTML;
198
- }
199
- /**
200
- * Create a bundler instance with default options.
201
- *
202
- * @param options - Bundler configuration
203
- * @returns New bundler instance
204
- */
205
- export declare function createBundler(options?: BundlerOptions): InMemoryBundler;
206
- export { SecurityError } from './sandbox/policy';
207
- export { ExecutionError } from './sandbox/executor';
208
- //# sourceMappingURL=bundler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../../src/bundler/bundler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,cAAc,EAId,iBAAiB,EACjB,gBAAgB,EAIjB,MAAM,SAAS,CAAC;AAkGjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IACnD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;gBAErC,OAAO,GAAE,cAAmB;IAkBxC;;;;;OAKG;IACG,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAmE3D;;;;;OAKG;IACG,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IA6D9D;;;;;;OAMG;IACG,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,aAA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