@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.
- package/CLAUDE.md +56 -154
- package/README.md +367 -62
- package/adapters/base-template.d.ts +30 -0
- package/adapters/base-template.d.ts.map +1 -0
- package/adapters/cdn-info.d.ts +34 -0
- package/adapters/cdn-info.d.ts.map +1 -0
- package/adapters/constants.d.ts +18 -0
- package/adapters/constants.d.ts.map +1 -0
- package/adapters/content-detector.d.ts +19 -0
- package/adapters/content-detector.d.ts.map +1 -0
- package/adapters/content-renderers.d.ts +27 -0
- package/adapters/content-renderers.d.ts.map +1 -0
- package/adapters/index.d.ts +14 -7
- package/adapters/index.d.ts.map +1 -1
- package/adapters/index.js +2343 -426
- package/adapters/render-failure.d.ts +18 -0
- package/adapters/render-failure.d.ts.map +1 -0
- package/adapters/response-builder.d.ts +34 -104
- package/adapters/response-builder.d.ts.map +1 -1
- package/adapters/serving-mode.d.ts +28 -91
- package/adapters/serving-mode.d.ts.map +1 -1
- package/adapters/template-renderer.d.ts +50 -0
- package/adapters/template-renderer.d.ts.map +1 -0
- package/adapters/type-detector.d.ts +18 -0
- package/adapters/type-detector.d.ts.map +1 -0
- package/bridge-runtime/index.js +1 -1
- package/component/index.d.ts +14 -0
- package/component/index.d.ts.map +1 -0
- package/component/index.js +2043 -0
- package/component/loader.d.ts +36 -0
- package/component/loader.d.ts.map +1 -0
- package/component/renderer.d.ts +30 -0
- package/component/renderer.d.ts.map +1 -0
- package/component/transpiler.d.ts +49 -0
- package/component/transpiler.d.ts.map +1 -0
- package/component/types.d.ts +82 -0
- package/component/types.d.ts.map +1 -0
- package/esm/adapters/index.mjs +2337 -422
- package/esm/bridge-runtime/index.mjs +1 -1
- package/esm/component/index.mjs +2013 -0
- package/esm/index.mjs +3446 -13935
- package/esm/package.json +3 -12
- package/esm/resolver/index.mjs +661 -0
- package/esm/shell/index.mjs +1406 -0
- package/esm/types/index.mjs +11 -11
- package/esm/utils/index.mjs +53 -8
- package/index.d.ts +12 -40
- package/index.d.ts.map +1 -1
- package/index.js +3579 -14218
- package/package.json +3 -12
- package/resolver/cdn-registry.d.ts +39 -0
- package/resolver/cdn-registry.d.ts.map +1 -0
- package/resolver/esm-sh.resolver.d.ts +54 -0
- package/resolver/esm-sh.resolver.d.ts.map +1 -0
- package/resolver/import-map.d.ts +47 -0
- package/resolver/import-map.d.ts.map +1 -0
- package/resolver/import-parser.d.ts +28 -0
- package/resolver/import-parser.d.ts.map +1 -0
- package/resolver/import-rewriter.d.ts +29 -0
- package/resolver/import-rewriter.d.ts.map +1 -0
- package/resolver/index.d.ts +15 -0
- package/resolver/index.d.ts.map +1 -0
- package/resolver/index.js +708 -0
- package/resolver/types.d.ts +191 -0
- package/resolver/types.d.ts.map +1 -0
- package/shell/builder.d.ts +31 -0
- package/shell/builder.d.ts.map +1 -0
- package/shell/csp.d.ts +37 -0
- package/shell/csp.d.ts.map +1 -0
- package/shell/custom-shell-applier.d.ts +33 -0
- package/shell/custom-shell-applier.d.ts.map +1 -0
- package/shell/custom-shell-resolver.d.ts +47 -0
- package/shell/custom-shell-resolver.d.ts.map +1 -0
- package/shell/custom-shell-types.d.ts +75 -0
- package/shell/custom-shell-types.d.ts.map +1 -0
- package/shell/custom-shell-validator.d.ts +26 -0
- package/shell/custom-shell-validator.d.ts.map +1 -0
- package/shell/data-injector.d.ts +40 -0
- package/shell/data-injector.d.ts.map +1 -0
- package/shell/index.d.ts +19 -0
- package/shell/index.d.ts.map +1 -0
- package/shell/index.js +1453 -0
- package/shell/types.d.ts +54 -0
- package/shell/types.d.ts.map +1 -0
- package/types/index.d.ts +1 -3
- package/types/index.d.ts.map +1 -1
- package/types/index.js +11 -11
- package/types/ui-config.d.ts +50 -11
- package/types/ui-config.d.ts.map +1 -1
- package/types/ui-runtime.d.ts +8 -82
- package/types/ui-runtime.d.ts.map +1 -1
- package/utils/index.d.ts +9 -3
- package/utils/index.d.ts.map +1 -1
- package/utils/index.js +59 -7
- package/adapters/platform-meta.constants.d.ts +0 -26
- package/adapters/platform-meta.constants.d.ts.map +0 -1
- package/adapters/platform-meta.d.ts +0 -234
- package/adapters/platform-meta.d.ts.map +0 -1
- package/base-template/bridge.d.ts +0 -90
- package/base-template/bridge.d.ts.map +0 -1
- package/base-template/default-base-template.d.ts +0 -91
- package/base-template/default-base-template.d.ts.map +0 -1
- package/base-template/index.d.ts +0 -15
- package/base-template/index.d.ts.map +0 -1
- package/base-template/index.js +0 -1393
- package/base-template/polyfills.d.ts +0 -31
- package/base-template/polyfills.d.ts.map +0 -1
- package/base-template/theme-styles.d.ts +0 -74
- package/base-template/theme-styles.d.ts.map +0 -1
- package/build/builders/base-builder.d.ts +0 -124
- package/build/builders/base-builder.d.ts.map +0 -1
- package/build/builders/esbuild-config.d.ts +0 -94
- package/build/builders/esbuild-config.d.ts.map +0 -1
- package/build/builders/hybrid-builder.d.ts +0 -93
- package/build/builders/hybrid-builder.d.ts.map +0 -1
- package/build/builders/index.d.ts +0 -17
- package/build/builders/index.d.ts.map +0 -1
- package/build/builders/inline-builder.d.ts +0 -83
- package/build/builders/inline-builder.d.ts.map +0 -1
- package/build/builders/static-builder.d.ts +0 -78
- package/build/builders/static-builder.d.ts.map +0 -1
- package/build/builders/types.d.ts +0 -341
- package/build/builders/types.d.ts.map +0 -1
- package/build/cdn-resources.d.ts +0 -244
- package/build/cdn-resources.d.ts.map +0 -1
- package/build/hybrid-data.d.ts +0 -127
- package/build/hybrid-data.d.ts.map +0 -1
- package/build/index.d.ts +0 -299
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -8699
- package/build/ui-components-browser.d.ts +0 -64
- package/build/ui-components-browser.d.ts.map +0 -1
- package/build/widget-manifest.d.ts +0 -362
- package/build/widget-manifest.d.ts.map +0 -1
- package/bundler/cache.d.ts +0 -173
- package/bundler/cache.d.ts.map +0 -1
- package/bundler/file-cache/component-builder.d.ts +0 -167
- package/bundler/file-cache/component-builder.d.ts.map +0 -1
- package/bundler/file-cache/hash-calculator.d.ts +0 -155
- package/bundler/file-cache/hash-calculator.d.ts.map +0 -1
- package/bundler/file-cache/index.d.ts +0 -12
- package/bundler/file-cache/index.d.ts.map +0 -1
- package/bundler/file-cache/storage/filesystem.d.ts +0 -149
- package/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
- package/bundler/file-cache/storage/index.d.ts +0 -11
- package/bundler/file-cache/storage/index.d.ts.map +0 -1
- package/bundler/file-cache/storage/interface.d.ts +0 -152
- package/bundler/file-cache/storage/interface.d.ts.map +0 -1
- package/bundler/file-cache/storage/redis.d.ts +0 -139
- package/bundler/file-cache/storage/redis.d.ts.map +0 -1
- package/bundler/index.d.ts +0 -35
- package/bundler/index.d.ts.map +0 -1
- package/bundler/index.js +0 -2953
- package/bundler/sandbox/enclave-adapter.d.ts +0 -121
- package/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
- package/bundler/sandbox/executor.d.ts +0 -14
- package/bundler/sandbox/executor.d.ts.map +0 -1
- package/bundler/sandbox/policy.d.ts +0 -62
- package/bundler/sandbox/policy.d.ts.map +0 -1
- package/bundler/types.d.ts +0 -702
- package/bundler/types.d.ts.map +0 -1
- package/dependency/cdn-registry.d.ts +0 -98
- package/dependency/cdn-registry.d.ts.map +0 -1
- package/dependency/import-map.d.ts +0 -186
- package/dependency/import-map.d.ts.map +0 -1
- package/dependency/import-parser.d.ts +0 -82
- package/dependency/import-parser.d.ts.map +0 -1
- package/dependency/index.d.ts +0 -17
- package/dependency/index.d.ts.map +0 -1
- package/dependency/index.js +0 -3180
- package/dependency/resolver.d.ts +0 -164
- package/dependency/resolver.d.ts.map +0 -1
- package/dependency/schemas.d.ts +0 -486
- package/dependency/schemas.d.ts.map +0 -1
- package/dependency/template-loader.d.ts +0 -204
- package/dependency/template-loader.d.ts.map +0 -1
- package/dependency/template-processor.d.ts +0 -118
- package/dependency/template-processor.d.ts.map +0 -1
- package/dependency/types.d.ts +0 -739
- package/dependency/types.d.ts.map +0 -1
- package/esm/base-template/index.mjs +0 -1359
- package/esm/build/index.mjs +0 -8601
- package/esm/bundler/index.mjs +0 -2895
- package/esm/dependency/index.mjs +0 -3068
- package/esm/handlebars/index.mjs +0 -587
- package/esm/registry/index.mjs +0 -6305
- package/esm/renderers/index.mjs +0 -1557
- package/esm/runtime/index.mjs +0 -5361
- package/esm/styles/index.mjs +0 -171
- package/esm/theme/index.mjs +0 -756
- package/esm/tool-template/index.mjs +0 -3652
- package/esm/validation/index.mjs +0 -542
- package/handlebars/expression-extractor.d.ts +0 -147
- package/handlebars/expression-extractor.d.ts.map +0 -1
- package/handlebars/helpers.d.ts +0 -339
- package/handlebars/helpers.d.ts.map +0 -1
- package/handlebars/index.d.ts +0 -195
- package/handlebars/index.d.ts.map +0 -1
- package/handlebars/index.js +0 -659
- package/preview/claude-preview.d.ts +0 -67
- package/preview/claude-preview.d.ts.map +0 -1
- package/preview/generic-preview.d.ts +0 -66
- package/preview/generic-preview.d.ts.map +0 -1
- package/preview/index.d.ts +0 -36
- package/preview/index.d.ts.map +0 -1
- package/preview/openai-preview.d.ts +0 -70
- package/preview/openai-preview.d.ts.map +0 -1
- package/preview/types.d.ts +0 -199
- package/preview/types.d.ts.map +0 -1
- package/registry/index.d.ts +0 -46
- package/registry/index.d.ts.map +0 -1
- package/registry/index.js +0 -6342
- package/registry/render-template.d.ts +0 -91
- package/registry/render-template.d.ts.map +0 -1
- package/registry/tool-ui.registry.d.ts +0 -294
- package/registry/tool-ui.registry.d.ts.map +0 -1
- package/registry/uri-utils.d.ts +0 -56
- package/registry/uri-utils.d.ts.map +0 -1
- package/renderers/cache.d.ts +0 -145
- package/renderers/cache.d.ts.map +0 -1
- package/renderers/html.renderer.d.ts +0 -123
- package/renderers/html.renderer.d.ts.map +0 -1
- package/renderers/index.d.ts +0 -36
- package/renderers/index.d.ts.map +0 -1
- package/renderers/index.js +0 -1603
- package/renderers/mdx-client.renderer.d.ts +0 -124
- package/renderers/mdx-client.renderer.d.ts.map +0 -1
- package/renderers/registry.d.ts +0 -133
- package/renderers/registry.d.ts.map +0 -1
- package/renderers/types.d.ts +0 -343
- package/renderers/types.d.ts.map +0 -1
- package/renderers/utils/detect.d.ts +0 -107
- package/renderers/utils/detect.d.ts.map +0 -1
- package/renderers/utils/hash.d.ts +0 -40
- package/renderers/utils/hash.d.ts.map +0 -1
- package/renderers/utils/index.d.ts +0 -9
- package/renderers/utils/index.d.ts.map +0 -1
- package/renderers/utils/transpiler.d.ts +0 -70
- package/renderers/utils/transpiler.d.ts.map +0 -1
- package/runtime/adapters/html.adapter.d.ts +0 -59
- package/runtime/adapters/html.adapter.d.ts.map +0 -1
- package/runtime/adapters/index.d.ts +0 -26
- package/runtime/adapters/index.d.ts.map +0 -1
- package/runtime/adapters/mdx.adapter.d.ts +0 -73
- package/runtime/adapters/mdx.adapter.d.ts.map +0 -1
- package/runtime/adapters/types.d.ts +0 -95
- package/runtime/adapters/types.d.ts.map +0 -1
- package/runtime/csp.d.ts +0 -48
- package/runtime/csp.d.ts.map +0 -1
- package/runtime/index.d.ts +0 -17
- package/runtime/index.d.ts.map +0 -1
- package/runtime/index.js +0 -5432
- package/runtime/mcp-bridge.d.ts +0 -101
- package/runtime/mcp-bridge.d.ts.map +0 -1
- package/runtime/renderer-runtime.d.ts +0 -133
- package/runtime/renderer-runtime.d.ts.map +0 -1
- package/runtime/sanitizer.d.ts +0 -180
- package/runtime/sanitizer.d.ts.map +0 -1
- package/runtime/types.d.ts +0 -415
- package/runtime/types.d.ts.map +0 -1
- package/runtime/wrapper.d.ts +0 -421
- package/runtime/wrapper.d.ts.map +0 -1
- package/styles/index.d.ts +0 -8
- package/styles/index.d.ts.map +0 -1
- package/styles/index.js +0 -222
- package/styles/variants.d.ts +0 -51
- package/styles/variants.d.ts.map +0 -1
- package/theme/cdn.d.ts +0 -195
- package/theme/cdn.d.ts.map +0 -1
- package/theme/css-to-theme.d.ts +0 -64
- package/theme/css-to-theme.d.ts.map +0 -1
- package/theme/index.d.ts +0 -19
- package/theme/index.d.ts.map +0 -1
- package/theme/index.js +0 -814
- package/theme/platforms.d.ts +0 -102
- package/theme/platforms.d.ts.map +0 -1
- package/theme/presets/github-openai.d.ts +0 -50
- package/theme/presets/github-openai.d.ts.map +0 -1
- package/theme/presets/index.d.ts +0 -11
- package/theme/presets/index.d.ts.map +0 -1
- package/theme/theme.d.ts +0 -396
- package/theme/theme.d.ts.map +0 -1
- package/tool-template/builder.d.ts +0 -213
- package/tool-template/builder.d.ts.map +0 -1
- package/tool-template/index.d.ts +0 -16
- package/tool-template/index.d.ts.map +0 -1
- package/tool-template/index.js +0 -3690
- package/validation/error-box.d.ts +0 -56
- package/validation/error-box.d.ts.map +0 -1
- package/validation/index.d.ts +0 -13
- package/validation/index.d.ts.map +0 -1
- package/validation/index.js +0 -576
- package/validation/schema-paths.d.ts +0 -118
- package/validation/schema-paths.d.ts.map +0 -1
- package/validation/template-validator.d.ts +0 -143
- package/validation/template-validator.d.ts.map +0 -1
- package/validation/wrapper.d.ts +0 -97
- package/validation/wrapper.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
# @frontmcp/uipack
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
HTML shell builder, pluggable import resolver, and NPM component loader for MCP UI development. React-free core.
|
|
4
4
|
|
|
5
5
|
[](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)
|
|
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
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
69
|
+
### Fetch TypeScript Definitions
|
|
31
70
|
|
|
32
71
|
```ts
|
|
33
|
-
import {
|
|
72
|
+
import { createTypeFetcher } from '@frontmcp/uipack/typings';
|
|
34
73
|
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
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
|
|
47
|
-
|
|
|
48
|
-
| `@frontmcp/uipack
|
|
49
|
-
| `@frontmcp/uipack/
|
|
50
|
-
| `@frontmcp/uipack/
|
|
51
|
-
| `@frontmcp/uipack/
|
|
52
|
-
| `@frontmcp/uipack/
|
|
53
|
-
| `@frontmcp/uipack/
|
|
54
|
-
| `@frontmcp/uipack/
|
|
55
|
-
| `@frontmcp/uipack/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
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
|
|
75
|
-
- [`@frontmcp/sdk`](../sdk) —
|
|
76
|
-
- [`@frontmcp/testing`](../testing) — UI assertions
|
|
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"}
|
package/adapters/index.d.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @frontmcp/
|
|
2
|
+
* @frontmcp/uipack/adapters
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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 {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
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
|
package/adapters/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
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"}
|