@frontmcp/uipack 0.6.1 → 0.6.3
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 +88 -105
- package/README.md +1 -0
- package/adapters/index.d.ts +1 -1
- package/adapters/index.d.ts.map +1 -1
- package/adapters/index.js +35 -2
- package/adapters/platform-meta.d.ts +29 -0
- package/adapters/platform-meta.d.ts.map +1 -1
- package/base-template/default-base-template.d.ts +0 -1
- package/base-template/default-base-template.d.ts.map +1 -1
- package/base-template/index.js +32 -37
- package/build/builders/base-builder.d.ts +124 -0
- package/build/builders/base-builder.d.ts.map +1 -0
- package/build/builders/esbuild-config.d.ts +94 -0
- package/build/builders/esbuild-config.d.ts.map +1 -0
- package/build/builders/hybrid-builder.d.ts +93 -0
- package/build/builders/hybrid-builder.d.ts.map +1 -0
- package/build/builders/index.d.ts +17 -0
- package/build/builders/index.d.ts.map +1 -0
- package/build/builders/inline-builder.d.ts +83 -0
- package/build/builders/inline-builder.d.ts.map +1 -0
- package/build/builders/static-builder.d.ts +78 -0
- package/build/builders/static-builder.d.ts.map +1 -0
- package/build/builders/types.d.ts +341 -0
- package/build/builders/types.d.ts.map +1 -0
- package/build/cdn-resources.d.ts +3 -2
- package/build/cdn-resources.d.ts.map +1 -1
- package/build/hybrid-data.d.ts +127 -0
- package/build/hybrid-data.d.ts.map +1 -0
- package/build/index.d.ts +4 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1901 -173
- package/build/ui-components-browser.d.ts +64 -0
- package/build/ui-components-browser.d.ts.map +1 -0
- package/build/widget-manifest.d.ts.map +1 -1
- package/bundler/file-cache/component-builder.d.ts.map +1 -1
- package/bundler/file-cache/storage/redis.d.ts.map +1 -1
- package/bundler/index.js +11 -6
- package/dependency/cdn-registry.d.ts +1 -1
- package/dependency/cdn-registry.d.ts.map +1 -1
- package/dependency/import-map.d.ts.map +1 -1
- package/dependency/index.js +93 -121
- package/dependency/resolver.d.ts.map +1 -1
- package/esm/adapters/{index.js → index.mjs} +34 -2
- package/esm/base-template/{index.js → index.mjs} +32 -37
- package/esm/build/{index.js → index.mjs} +1872 -173
- package/esm/bundler/{index.js → index.mjs} +12 -7
- package/esm/dependency/{index.js → index.mjs} +93 -121
- package/esm/handlebars/{index.js → index.mjs} +0 -1
- package/esm/{index.js → index.mjs} +2532 -827
- package/esm/package.json +15 -16
- package/esm/registry/{index.js → index.mjs} +200 -265
- package/esm/renderers/{index.js → index.mjs} +110 -201
- package/esm/runtime/{index.js → index.mjs} +44 -35
- package/esm/styles/{index.js → index.mjs} +6 -6
- package/esm/theme/{index.js → index.mjs} +90 -42
- package/esm/tool-template/{index.js → index.mjs} +35 -28
- package/esm/typings/{index.js → index.mjs} +157 -1
- package/esm/utils/{index.js → index.mjs} +24 -0
- package/esm/validation/{index.js → index.mjs} +0 -1
- package/handlebars/expression-extractor.d.ts.map +1 -1
- package/handlebars/index.d.ts.map +1 -1
- package/handlebars/index.js +0 -1
- package/index.d.ts +2 -1
- package/index.d.ts.map +1 -1
- package/index.js +2560 -831
- package/package.json +7 -6
- package/preview/claude-preview.d.ts +67 -0
- package/preview/claude-preview.d.ts.map +1 -0
- package/preview/generic-preview.d.ts +67 -0
- package/preview/generic-preview.d.ts.map +1 -0
- package/preview/index.d.ts +36 -0
- package/preview/index.d.ts.map +1 -0
- package/preview/openai-preview.d.ts +70 -0
- package/preview/openai-preview.d.ts.map +1 -0
- package/preview/types.d.ts +185 -0
- package/preview/types.d.ts.map +1 -0
- package/registry/index.js +200 -265
- package/registry/render-template.d.ts.map +1 -1
- package/renderers/index.d.ts +2 -2
- package/renderers/index.d.ts.map +1 -1
- package/renderers/index.js +114 -205
- package/renderers/mdx-client.renderer.d.ts +124 -0
- package/renderers/mdx-client.renderer.d.ts.map +1 -0
- package/renderers/registry.d.ts +2 -2
- package/renderers/registry.d.ts.map +1 -1
- package/renderers/types.d.ts +3 -2
- package/renderers/types.d.ts.map +1 -1
- package/renderers/utils/transpiler.d.ts +8 -27
- package/renderers/utils/transpiler.d.ts.map +1 -1
- package/runtime/index.js +44 -35
- package/runtime/mcp-bridge.d.ts.map +1 -1
- package/runtime/renderer-runtime.d.ts.map +1 -1
- package/runtime/wrapper.d.ts.map +1 -1
- package/styles/index.js +6 -6
- package/styles/variants.d.ts +1 -1
- package/styles/variants.d.ts.map +1 -1
- package/theme/cdn.d.ts.map +1 -1
- package/theme/css-to-theme.d.ts +91 -0
- package/theme/css-to-theme.d.ts.map +1 -0
- package/theme/index.d.ts +2 -1
- package/theme/index.d.ts.map +1 -1
- package/theme/index.js +92 -43
- package/theme/platforms.d.ts +1 -6
- package/theme/platforms.d.ts.map +1 -1
- package/theme/theme.d.ts.map +1 -1
- package/tool-template/builder.d.ts.map +1 -1
- package/tool-template/index.js +35 -28
- package/typings/index.d.ts +4 -4
- package/typings/index.d.ts.map +1 -1
- package/typings/index.js +162 -1
- package/typings/schemas.d.ts +30 -0
- package/typings/schemas.d.ts.map +1 -1
- package/typings/type-fetcher.d.ts +74 -1
- package/typings/type-fetcher.d.ts.map +1 -1
- package/typings/types.d.ts +72 -1
- package/typings/types.d.ts.map +1 -1
- package/utils/escape-html.d.ts +44 -0
- package/utils/escape-html.d.ts.map +1 -1
- package/utils/index.d.ts +1 -1
- package/utils/index.d.ts.map +1 -1
- package/utils/index.js +26 -0
- package/validation/index.js +0 -1
- package/validation/template-validator.d.ts.map +1 -1
- package/esm/adapters/index.d.ts +0 -13
- package/esm/adapters/index.d.ts.map +0 -1
- package/esm/adapters/platform-meta.d.ts +0 -166
- package/esm/adapters/platform-meta.d.ts.map +0 -1
- package/esm/adapters/response-builder.d.ts +0 -108
- package/esm/adapters/response-builder.d.ts.map +0 -1
- package/esm/adapters/serving-mode.d.ts +0 -107
- package/esm/adapters/serving-mode.d.ts.map +0 -1
- package/esm/base-template/bridge.d.ts +0 -90
- package/esm/base-template/bridge.d.ts.map +0 -1
- package/esm/base-template/default-base-template.d.ts +0 -92
- package/esm/base-template/default-base-template.d.ts.map +0 -1
- package/esm/base-template/index.d.ts +0 -15
- package/esm/base-template/index.d.ts.map +0 -1
- package/esm/base-template/polyfills.d.ts +0 -31
- package/esm/base-template/polyfills.d.ts.map +0 -1
- package/esm/base-template/theme-styles.d.ts +0 -74
- package/esm/base-template/theme-styles.d.ts.map +0 -1
- package/esm/bridge-runtime/iife-generator.d.ts +0 -62
- package/esm/bridge-runtime/iife-generator.d.ts.map +0 -1
- package/esm/bridge-runtime/index.d.ts +0 -10
- package/esm/bridge-runtime/index.d.ts.map +0 -1
- package/esm/build/cdn-resources.d.ts +0 -243
- package/esm/build/cdn-resources.d.ts.map +0 -1
- package/esm/build/index.d.ts +0 -295
- package/esm/build/index.d.ts.map +0 -1
- package/esm/build/widget-manifest.d.ts +0 -362
- package/esm/build/widget-manifest.d.ts.map +0 -1
- package/esm/bundler/cache.d.ts +0 -173
- package/esm/bundler/cache.d.ts.map +0 -1
- package/esm/bundler/file-cache/component-builder.d.ts +0 -167
- package/esm/bundler/file-cache/component-builder.d.ts.map +0 -1
- package/esm/bundler/file-cache/hash-calculator.d.ts +0 -155
- package/esm/bundler/file-cache/hash-calculator.d.ts.map +0 -1
- package/esm/bundler/file-cache/index.d.ts +0 -12
- package/esm/bundler/file-cache/index.d.ts.map +0 -1
- package/esm/bundler/file-cache/storage/filesystem.d.ts +0 -149
- package/esm/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
- package/esm/bundler/file-cache/storage/index.d.ts +0 -11
- package/esm/bundler/file-cache/storage/index.d.ts.map +0 -1
- package/esm/bundler/file-cache/storage/interface.d.ts +0 -152
- package/esm/bundler/file-cache/storage/interface.d.ts.map +0 -1
- package/esm/bundler/file-cache/storage/redis.d.ts +0 -139
- package/esm/bundler/file-cache/storage/redis.d.ts.map +0 -1
- package/esm/bundler/index.d.ts +0 -35
- package/esm/bundler/index.d.ts.map +0 -1
- package/esm/bundler/sandbox/enclave-adapter.d.ts +0 -121
- package/esm/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
- package/esm/bundler/sandbox/executor.d.ts +0 -14
- package/esm/bundler/sandbox/executor.d.ts.map +0 -1
- package/esm/bundler/sandbox/policy.d.ts +0 -62
- package/esm/bundler/sandbox/policy.d.ts.map +0 -1
- package/esm/bundler/types.d.ts +0 -702
- package/esm/bundler/types.d.ts.map +0 -1
- package/esm/dependency/cdn-registry.d.ts +0 -98
- package/esm/dependency/cdn-registry.d.ts.map +0 -1
- package/esm/dependency/import-map.d.ts +0 -186
- package/esm/dependency/import-map.d.ts.map +0 -1
- package/esm/dependency/import-parser.d.ts +0 -82
- package/esm/dependency/import-parser.d.ts.map +0 -1
- package/esm/dependency/index.d.ts +0 -17
- package/esm/dependency/index.d.ts.map +0 -1
- package/esm/dependency/resolver.d.ts +0 -164
- package/esm/dependency/resolver.d.ts.map +0 -1
- package/esm/dependency/schemas.d.ts +0 -486
- package/esm/dependency/schemas.d.ts.map +0 -1
- package/esm/dependency/template-loader.d.ts +0 -204
- package/esm/dependency/template-loader.d.ts.map +0 -1
- package/esm/dependency/template-processor.d.ts +0 -118
- package/esm/dependency/template-processor.d.ts.map +0 -1
- package/esm/dependency/types.d.ts +0 -739
- package/esm/dependency/types.d.ts.map +0 -1
- package/esm/handlebars/expression-extractor.d.ts +0 -147
- package/esm/handlebars/expression-extractor.d.ts.map +0 -1
- package/esm/handlebars/helpers.d.ts +0 -339
- package/esm/handlebars/helpers.d.ts.map +0 -1
- package/esm/handlebars/index.d.ts +0 -195
- package/esm/handlebars/index.d.ts.map +0 -1
- package/esm/index.d.ts +0 -50
- package/esm/index.d.ts.map +0 -1
- package/esm/registry/index.d.ts +0 -46
- package/esm/registry/index.d.ts.map +0 -1
- package/esm/registry/render-template.d.ts +0 -91
- package/esm/registry/render-template.d.ts.map +0 -1
- package/esm/registry/tool-ui.registry.d.ts +0 -294
- package/esm/registry/tool-ui.registry.d.ts.map +0 -1
- package/esm/registry/uri-utils.d.ts +0 -56
- package/esm/registry/uri-utils.d.ts.map +0 -1
- package/esm/renderers/cache.d.ts +0 -145
- package/esm/renderers/cache.d.ts.map +0 -1
- package/esm/renderers/html.renderer.d.ts +0 -123
- package/esm/renderers/html.renderer.d.ts.map +0 -1
- package/esm/renderers/index.d.ts +0 -36
- package/esm/renderers/index.d.ts.map +0 -1
- package/esm/renderers/mdx.renderer.d.ts +0 -120
- package/esm/renderers/mdx.renderer.d.ts.map +0 -1
- package/esm/renderers/registry.d.ts +0 -133
- package/esm/renderers/registry.d.ts.map +0 -1
- package/esm/renderers/types.d.ts +0 -342
- package/esm/renderers/types.d.ts.map +0 -1
- package/esm/renderers/utils/detect.d.ts +0 -107
- package/esm/renderers/utils/detect.d.ts.map +0 -1
- package/esm/renderers/utils/hash.d.ts +0 -40
- package/esm/renderers/utils/hash.d.ts.map +0 -1
- package/esm/renderers/utils/index.d.ts +0 -9
- package/esm/renderers/utils/index.d.ts.map +0 -1
- package/esm/renderers/utils/transpiler.d.ts +0 -89
- package/esm/renderers/utils/transpiler.d.ts.map +0 -1
- package/esm/runtime/adapters/html.adapter.d.ts +0 -59
- package/esm/runtime/adapters/html.adapter.d.ts.map +0 -1
- package/esm/runtime/adapters/index.d.ts +0 -26
- package/esm/runtime/adapters/index.d.ts.map +0 -1
- package/esm/runtime/adapters/mdx.adapter.d.ts +0 -73
- package/esm/runtime/adapters/mdx.adapter.d.ts.map +0 -1
- package/esm/runtime/adapters/types.d.ts +0 -95
- package/esm/runtime/adapters/types.d.ts.map +0 -1
- package/esm/runtime/csp.d.ts +0 -48
- package/esm/runtime/csp.d.ts.map +0 -1
- package/esm/runtime/index.d.ts +0 -17
- package/esm/runtime/index.d.ts.map +0 -1
- package/esm/runtime/mcp-bridge.d.ts +0 -101
- package/esm/runtime/mcp-bridge.d.ts.map +0 -1
- package/esm/runtime/renderer-runtime.d.ts +0 -133
- package/esm/runtime/renderer-runtime.d.ts.map +0 -1
- package/esm/runtime/sanitizer.d.ts +0 -172
- package/esm/runtime/sanitizer.d.ts.map +0 -1
- package/esm/runtime/types.d.ts +0 -415
- package/esm/runtime/types.d.ts.map +0 -1
- package/esm/runtime/wrapper.d.ts +0 -421
- package/esm/runtime/wrapper.d.ts.map +0 -1
- package/esm/styles/index.d.ts +0 -8
- package/esm/styles/index.d.ts.map +0 -1
- package/esm/styles/variants.d.ts +0 -51
- package/esm/styles/variants.d.ts.map +0 -1
- package/esm/theme/cdn.d.ts +0 -195
- package/esm/theme/cdn.d.ts.map +0 -1
- package/esm/theme/index.d.ts +0 -18
- package/esm/theme/index.d.ts.map +0 -1
- package/esm/theme/platforms.d.ts +0 -107
- package/esm/theme/platforms.d.ts.map +0 -1
- package/esm/theme/presets/github-openai.d.ts +0 -50
- package/esm/theme/presets/github-openai.d.ts.map +0 -1
- package/esm/theme/presets/index.d.ts +0 -11
- package/esm/theme/presets/index.d.ts.map +0 -1
- package/esm/theme/theme.d.ts +0 -396
- package/esm/theme/theme.d.ts.map +0 -1
- package/esm/tool-template/builder.d.ts +0 -213
- package/esm/tool-template/builder.d.ts.map +0 -1
- package/esm/tool-template/index.d.ts +0 -16
- package/esm/tool-template/index.d.ts.map +0 -1
- package/esm/types/index.d.ts +0 -14
- package/esm/types/index.d.ts.map +0 -1
- package/esm/types/ui-config.d.ts +0 -641
- package/esm/types/ui-config.d.ts.map +0 -1
- package/esm/types/ui-runtime.d.ts +0 -1008
- package/esm/types/ui-runtime.d.ts.map +0 -1
- package/esm/typings/cache/cache-adapter.d.ts +0 -125
- package/esm/typings/cache/cache-adapter.d.ts.map +0 -1
- package/esm/typings/cache/index.d.ts +0 -10
- package/esm/typings/cache/index.d.ts.map +0 -1
- package/esm/typings/cache/memory-cache.d.ts +0 -92
- package/esm/typings/cache/memory-cache.d.ts.map +0 -1
- package/esm/typings/dts-parser.d.ts +0 -90
- package/esm/typings/dts-parser.d.ts.map +0 -1
- package/esm/typings/index.d.ts +0 -48
- package/esm/typings/index.d.ts.map +0 -1
- package/esm/typings/schemas.d.ts +0 -232
- package/esm/typings/schemas.d.ts.map +0 -1
- package/esm/typings/type-fetcher.d.ts +0 -89
- package/esm/typings/type-fetcher.d.ts.map +0 -1
- package/esm/typings/types.d.ts +0 -320
- package/esm/typings/types.d.ts.map +0 -1
- package/esm/utils/escape-html.d.ts +0 -58
- package/esm/utils/escape-html.d.ts.map +0 -1
- package/esm/utils/index.d.ts +0 -10
- package/esm/utils/index.d.ts.map +0 -1
- package/esm/utils/safe-stringify.d.ts +0 -30
- package/esm/utils/safe-stringify.d.ts.map +0 -1
- package/esm/validation/error-box.d.ts +0 -56
- package/esm/validation/error-box.d.ts.map +0 -1
- package/esm/validation/index.d.ts +0 -13
- package/esm/validation/index.d.ts.map +0 -1
- package/esm/validation/schema-paths.d.ts +0 -118
- package/esm/validation/schema-paths.d.ts.map +0 -1
- package/esm/validation/template-validator.d.ts +0 -143
- package/esm/validation/template-validator.d.ts.map +0 -1
- package/esm/validation/wrapper.d.ts +0 -97
- package/esm/validation/wrapper.d.ts.map +0 -1
- package/renderers/mdx.renderer.d.ts +0 -120
- package/renderers/mdx.renderer.d.ts.map +0 -1
- /package/esm/bridge-runtime/{index.js → index.mjs} +0 -0
- /package/esm/types/{index.js → index.mjs} +0 -0
package/CLAUDE.md
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
|
-
`@frontmcp/uipack` provides **bundling, build tools,
|
|
5
|
+
`@frontmcp/uipack` provides **bundling, build tools, platform adapters, and theming** 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
|
-
- Pure HTML string generation
|
|
13
|
-
- Zod schema validation for all component inputs
|
|
14
12
|
- Platform-aware theming and CDN configuration
|
|
15
|
-
-
|
|
13
|
+
- Build tools for Tool UI generation
|
|
14
|
+
- esbuild/SWC bundling utilities
|
|
15
|
+
- Zod schema validation
|
|
16
16
|
|
|
17
17
|
## Architecture
|
|
18
18
|
|
|
@@ -20,17 +20,15 @@ This is the React-free core package. For React components and hooks, use `@front
|
|
|
20
20
|
libs/uipack/src/
|
|
21
21
|
├── adapters/ # Platform adapters (OpenAI, Claude, etc.)
|
|
22
22
|
├── base-template/ # Default HTML wrappers with polyfills
|
|
23
|
-
├── bridge/
|
|
23
|
+
├── bridge-runtime/ # MCP bridge runtime generation
|
|
24
24
|
├── build/ # Build-time API (buildToolUI, etc.)
|
|
25
|
-
├── bundler/ # esbuild/SWC bundling
|
|
26
|
-
├── components/ # HTML string components (button, card, etc.)
|
|
25
|
+
├── bundler/ # esbuild/SWC bundling, caching, sandbox
|
|
27
26
|
├── dependency/ # CDN resolution and import maps
|
|
28
27
|
├── handlebars/ # Handlebars template engine
|
|
29
|
-
├──
|
|
30
|
-
├── pages/ # Pre-built pages (consent, error)
|
|
28
|
+
├── preview/ # Preview server utilities
|
|
31
29
|
├── registry/ # Tool UI registry
|
|
32
|
-
├── renderers/ # HTML/MDX renderers
|
|
33
|
-
├── runtime/ # Runtime utilities (
|
|
30
|
+
├── renderers/ # HTML/MDX client renderers
|
|
31
|
+
├── runtime/ # Runtime utilities (wrapper, sanitizer, CSP)
|
|
34
32
|
├── styles/ # Style variant definitions
|
|
35
33
|
├── theme/ # Theme system and CDN config
|
|
36
34
|
├── tool-template/ # Tool template utilities
|
|
@@ -38,103 +36,52 @@ libs/uipack/src/
|
|
|
38
36
|
├── typings/ # .d.ts type fetching
|
|
39
37
|
├── utils/ # Utilities (escapeHtml, safeStringify)
|
|
40
38
|
├── validation/ # Zod validation utilities
|
|
41
|
-
├── web-components/ # Custom HTML elements
|
|
42
|
-
├── widgets/ # OpenAI widget utilities
|
|
43
39
|
└── index.ts # Main barrel exports
|
|
44
40
|
```
|
|
45
41
|
|
|
46
42
|
## Package Split
|
|
47
43
|
|
|
48
|
-
| Package | Purpose
|
|
49
|
-
| ------------------ |
|
|
50
|
-
| `@frontmcp/uipack` | Bundling, build tools,
|
|
51
|
-
| `@frontmcp/ui` | React components, hooks, SSR rendering
|
|
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 |
|
|
52
48
|
|
|
53
49
|
## Entry Points
|
|
54
50
|
|
|
55
|
-
| Path
|
|
56
|
-
|
|
|
57
|
-
| `@frontmcp/uipack`
|
|
58
|
-
| `@frontmcp/uipack/adapters`
|
|
59
|
-
| `@frontmcp/uipack/base-template`
|
|
60
|
-
| `@frontmcp/uipack/
|
|
61
|
-
| `@frontmcp/uipack/
|
|
62
|
-
| `@frontmcp/uipack/
|
|
63
|
-
| `@frontmcp/uipack/
|
|
64
|
-
| `@frontmcp/uipack/
|
|
65
|
-
| `@frontmcp/uipack/
|
|
66
|
-
| `@frontmcp/uipack/
|
|
67
|
-
| `@frontmcp/uipack/
|
|
68
|
-
| `@frontmcp/uipack/
|
|
69
|
-
| `@frontmcp/uipack/
|
|
70
|
-
| `@frontmcp/uipack/
|
|
71
|
-
| `@frontmcp/uipack/
|
|
72
|
-
| `@frontmcp/uipack/
|
|
73
|
-
| `@frontmcp/uipack/
|
|
74
|
-
| `@frontmcp/uipack/utils` | Utilities |
|
|
75
|
-
| `@frontmcp/uipack/validation` | Zod validation |
|
|
76
|
-
| `@frontmcp/uipack/web-components` | Custom elements |
|
|
77
|
-
| `@frontmcp/uipack/widgets` | OpenAI widgets |
|
|
78
|
-
|
|
79
|
-
## Component Development
|
|
80
|
-
|
|
81
|
-
### 1. Create Schema First
|
|
82
|
-
|
|
83
|
-
Every component must have a Zod schema with `.strict()` mode:
|
|
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 |
|
|
84
70
|
|
|
85
|
-
|
|
86
|
-
// component.schema.ts
|
|
87
|
-
import { z } from 'zod';
|
|
88
|
-
|
|
89
|
-
export const ComponentOptionsSchema = z
|
|
90
|
-
.object({
|
|
91
|
-
variant: z.enum(['primary', 'secondary']).optional(),
|
|
92
|
-
size: z.enum(['sm', 'md', 'lg']).optional(),
|
|
93
|
-
disabled: z.boolean().optional(),
|
|
94
|
-
className: z.string().optional(),
|
|
95
|
-
htmx: z
|
|
96
|
-
.object({
|
|
97
|
-
get: z.string().optional(),
|
|
98
|
-
post: z.string().optional(),
|
|
99
|
-
target: z.string().optional(),
|
|
100
|
-
swap: z.string().optional(),
|
|
101
|
-
})
|
|
102
|
-
.strict()
|
|
103
|
-
.optional(),
|
|
104
|
-
})
|
|
105
|
-
.strict(); // IMPORTANT: Reject unknown properties
|
|
106
|
-
|
|
107
|
-
export type ComponentOptions = z.infer<typeof ComponentOptionsSchema>;
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### 2. Validate Inputs in Component
|
|
71
|
+
## Build API
|
|
111
72
|
|
|
112
73
|
```typescript
|
|
113
|
-
|
|
114
|
-
import { validateOptions } from '../validation';
|
|
115
|
-
import { ComponentOptionsSchema, type ComponentOptions } from './component.schema';
|
|
116
|
-
|
|
117
|
-
export function component(content: string, options: ComponentOptions = {}): string {
|
|
118
|
-
const validation = validateOptions<ComponentOptions>(options, {
|
|
119
|
-
schema: ComponentOptionsSchema,
|
|
120
|
-
componentName: 'component',
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
if (!validation.success) {
|
|
124
|
-
return validation.error; // Returns styled error box HTML
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const { variant = 'primary', size = 'md' } = validation.data;
|
|
128
|
-
return `<div class="...">${escapeHtml(content)}</div>`;
|
|
129
|
-
}
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### 3. Always Escape User Content
|
|
74
|
+
import { buildToolUI, getOutputModeForClient } from '@frontmcp/uipack/build';
|
|
133
75
|
|
|
134
|
-
|
|
135
|
-
|
|
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
|
+
});
|
|
136
82
|
|
|
137
|
-
|
|
83
|
+
// Get output mode for client
|
|
84
|
+
const mode = getOutputModeForClient('openai');
|
|
138
85
|
```
|
|
139
86
|
|
|
140
87
|
## Theme System
|
|
@@ -190,20 +137,56 @@ const scripts = buildCdnScriptsFromTheme(DEFAULT_THEME, { inline: false });
|
|
|
190
137
|
const inlineScripts = buildCdnScriptsFromTheme(DEFAULT_THEME, { inline: true });
|
|
191
138
|
```
|
|
192
139
|
|
|
193
|
-
##
|
|
140
|
+
## Renderers
|
|
141
|
+
|
|
142
|
+
### HTML Renderer
|
|
194
143
|
|
|
195
144
|
```typescript
|
|
196
|
-
import {
|
|
145
|
+
import { htmlRenderer, HtmlRenderer } from '@frontmcp/uipack/renderers';
|
|
197
146
|
|
|
198
|
-
//
|
|
199
|
-
const html = await
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
147
|
+
// Render HTML template
|
|
148
|
+
const html = await htmlRenderer.render(template, context);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### MDX Client Renderer (CDN-based)
|
|
152
|
+
|
|
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);
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
> **Note:** For server-side MDX rendering with bundled React, use `@frontmcp/ui/renderers`.
|
|
161
|
+
|
|
162
|
+
## Bundler Utilities
|
|
163
|
+
|
|
164
|
+
```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',
|
|
203
185
|
});
|
|
204
186
|
|
|
205
|
-
|
|
206
|
-
|
|
187
|
+
if (!result.success) {
|
|
188
|
+
return result.error; // HTML error box
|
|
189
|
+
}
|
|
207
190
|
```
|
|
208
191
|
|
|
209
192
|
## Testing Requirements
|
|
@@ -241,6 +224,6 @@ Note: No React dependency!
|
|
|
241
224
|
|
|
242
225
|
## Related Packages
|
|
243
226
|
|
|
244
|
-
- **@frontmcp/ui** - React components, hooks, SSR rendering
|
|
227
|
+
- **@frontmcp/ui** - React components, hooks, SSR rendering, HTML components
|
|
245
228
|
- **@frontmcp/sdk** - Core FrontMCP SDK
|
|
246
229
|
- **@frontmcp/testing** - E2E testing utilities
|
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@ yarn add @frontmcp/uipack
|
|
|
23
23
|
|
|
24
24
|
- **Theme system** – Configure Tailwind-style palettes, fonts, and CDN assets, then inline or externalize scripts per platform.
|
|
25
25
|
- **Build API** – Compile tool templates with esbuild/SWC, emit static widgets, and ship cached manifests for serverless environments.
|
|
26
|
+
- **Build modes** – Choose static, dynamic, or hybrid rendering plus multi-platform bundler helpers so the same widget rehydrates on OpenAI, Claude, and Gemini.
|
|
26
27
|
- **Runtime helpers** – Wrap HTML/React/MDX templates with CSP, sanitize user content, and expose MCP Bridge metadata.
|
|
27
28
|
- **Platform adapters** – Generate OpenAI/Claude/Gemini discovery metadata, resolve serving modes, and understand host capabilities.
|
|
28
29
|
- **Validation** – Extract schema paths, validate Handlebars templates, and render error boxes before code hits production.
|
package/adapters/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
|
-
export { type AIPlatformType, type UIMetadata, type BuildUIMetaOptions, type BuildToolDiscoveryMetaOptions, buildUIMeta, buildToolDiscoveryMeta, buildOpenAICSP, } from './platform-meta';
|
|
10
|
+
export { type AIPlatformType, type UIMetadata, type BuildUIMetaOptions, type BuildToolDiscoveryMetaOptions, buildUIMeta, buildToolDiscoveryMeta, buildOpenAICSP, buildFrontMCPCSP, } from './platform-meta';
|
|
11
11
|
export { type ResolvedServingMode, type ResolveServingModeOptions, resolveServingMode, isPlatformModeSupported, getDefaultServingMode, platformUsesStructuredContent, platformSupportsWidgets, } from './serving-mode';
|
|
12
12
|
export { type TextContentBlock, type BuildToolResponseOptions, type ToolResponseContent, buildToolResponseContent, } from './response-builder';
|
|
13
13
|
//# 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;AAEH,OAAO,EAEL,KAAK,cAAc,EAEnB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,EAElC,WAAW,EACX,sBAAsB,EACtB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAEL,KAAK,cAAc,EAEnB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,EAElC,WAAW,EACX,sBAAsB,EACtB,cAAc,EACd,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAE9B,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EAExB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC"}
|
package/adapters/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// libs/uipack/src/adapters/index.ts
|
|
21
21
|
var adapters_exports = {};
|
|
22
22
|
__export(adapters_exports, {
|
|
23
|
+
buildFrontMCPCSP: () => buildFrontMCPCSP,
|
|
23
24
|
buildOpenAICSP: () => buildOpenAICSP,
|
|
24
25
|
buildToolDiscoveryMeta: () => buildToolDiscoveryMeta,
|
|
25
26
|
buildToolResponseContent: () => buildToolResponseContent,
|
|
@@ -107,6 +108,15 @@ function buildClaudeMeta(meta, uiConfig) {
|
|
|
107
108
|
if (uiConfig.widgetDescription) {
|
|
108
109
|
meta["claude/widgetDescription"] = uiConfig.widgetDescription;
|
|
109
110
|
}
|
|
111
|
+
if (uiConfig.displayMode) {
|
|
112
|
+
meta["claude/displayMode"] = uiConfig.displayMode;
|
|
113
|
+
}
|
|
114
|
+
if (uiConfig.widgetAccessible) {
|
|
115
|
+
meta["claude/widgetAccessible"] = true;
|
|
116
|
+
}
|
|
117
|
+
if (uiConfig.prefersBorder !== void 0) {
|
|
118
|
+
meta["claude/prefersBorder"] = uiConfig.prefersBorder;
|
|
119
|
+
}
|
|
110
120
|
return meta;
|
|
111
121
|
}
|
|
112
122
|
function buildGeminiMeta(meta, uiConfig) {
|
|
@@ -121,12 +131,34 @@ function buildIDEMeta(meta, uiConfig) {
|
|
|
121
131
|
}
|
|
122
132
|
return meta;
|
|
123
133
|
}
|
|
134
|
+
function buildFrontMCPCSP(csp) {
|
|
135
|
+
const result = {};
|
|
136
|
+
if (csp.connectDomains?.length) {
|
|
137
|
+
result.connectDomains = csp.connectDomains;
|
|
138
|
+
}
|
|
139
|
+
if (csp.resourceDomains?.length) {
|
|
140
|
+
result.resourceDomains = csp.resourceDomains;
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
124
144
|
function buildGenericMeta(meta, uiConfig) {
|
|
125
145
|
if (uiConfig.widgetAccessible) {
|
|
126
|
-
meta["
|
|
146
|
+
meta["frontmcp/widgetAccessible"] = true;
|
|
127
147
|
}
|
|
128
148
|
if (uiConfig.csp) {
|
|
129
|
-
meta["
|
|
149
|
+
meta["frontmcp/widgetCSP"] = buildFrontMCPCSP(uiConfig.csp);
|
|
150
|
+
}
|
|
151
|
+
if (uiConfig.displayMode) {
|
|
152
|
+
meta["frontmcp/displayMode"] = uiConfig.displayMode;
|
|
153
|
+
}
|
|
154
|
+
if (uiConfig.widgetDescription) {
|
|
155
|
+
meta["frontmcp/widgetDescription"] = uiConfig.widgetDescription;
|
|
156
|
+
}
|
|
157
|
+
if (uiConfig.prefersBorder !== void 0) {
|
|
158
|
+
meta["frontmcp/prefersBorder"] = uiConfig.prefersBorder;
|
|
159
|
+
}
|
|
160
|
+
if (uiConfig.sandboxDomain) {
|
|
161
|
+
meta["frontmcp/domain"] = uiConfig.sandboxDomain;
|
|
130
162
|
}
|
|
131
163
|
return meta;
|
|
132
164
|
}
|
|
@@ -450,6 +482,7 @@ ${htmlContent}
|
|
|
450
482
|
}
|
|
451
483
|
// Annotate the CommonJS export names for ESM import in node:
|
|
452
484
|
0 && (module.exports = {
|
|
485
|
+
buildFrontMCPCSP,
|
|
453
486
|
buildOpenAICSP,
|
|
454
487
|
buildToolDiscoveryMeta,
|
|
455
488
|
buildToolResponseContent,
|
|
@@ -58,6 +58,27 @@ export interface UIMetadata {
|
|
|
58
58
|
'openai/toolInvocation/invoked'?: string;
|
|
59
59
|
/** Claude: Widget description */
|
|
60
60
|
'claude/widgetDescription'?: string;
|
|
61
|
+
/** Claude: Display mode preference */
|
|
62
|
+
'claude/displayMode'?: string;
|
|
63
|
+
/** Claude: Whether widget can invoke tools (informational) */
|
|
64
|
+
'claude/widgetAccessible'?: boolean;
|
|
65
|
+
/** Claude: Whether to show border around UI */
|
|
66
|
+
'claude/prefersBorder'?: boolean;
|
|
67
|
+
/** FrontMCP: Whether widget can invoke tools */
|
|
68
|
+
'frontmcp/widgetAccessible'?: boolean;
|
|
69
|
+
/** FrontMCP: CSP configuration */
|
|
70
|
+
'frontmcp/widgetCSP'?: {
|
|
71
|
+
connectDomains?: string[];
|
|
72
|
+
resourceDomains?: string[];
|
|
73
|
+
};
|
|
74
|
+
/** FrontMCP: Display mode preference */
|
|
75
|
+
'frontmcp/displayMode'?: string;
|
|
76
|
+
/** FrontMCP: Widget description */
|
|
77
|
+
'frontmcp/widgetDescription'?: string;
|
|
78
|
+
/** FrontMCP: Whether to show border around UI */
|
|
79
|
+
'frontmcp/prefersBorder'?: boolean;
|
|
80
|
+
/** FrontMCP: Dedicated sandbox domain */
|
|
81
|
+
'frontmcp/domain'?: string;
|
|
61
82
|
/** Gemini: Widget description */
|
|
62
83
|
'gemini/widgetDescription'?: string;
|
|
63
84
|
/** IDE: Resource URI for widget template */
|
|
@@ -127,6 +148,14 @@ export declare function buildOpenAICSP(csp: UIContentSecurityPolicy): {
|
|
|
127
148
|
connect_domains?: string[];
|
|
128
149
|
resource_domains?: string[];
|
|
129
150
|
};
|
|
151
|
+
/**
|
|
152
|
+
* Build FrontMCP CSP format (camelCase like MCP Apps spec).
|
|
153
|
+
* Used for generic-mcp platform metadata.
|
|
154
|
+
*/
|
|
155
|
+
export declare function buildFrontMCPCSP(csp: UIContentSecurityPolicy): {
|
|
156
|
+
connectDomains?: string[];
|
|
157
|
+
resourceDomains?: string[];
|
|
158
|
+
};
|
|
130
159
|
/**
|
|
131
160
|
* Build metadata for tool discovery (tools/list response).
|
|
132
161
|
* This includes fields that should be present at discovery time,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-meta.d.ts","sourceRoot":"","sources":["../../src/adapters/platform-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAM1E;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,MAAM,GACN,aAAa,GACb,UAAU,GACV,SAAS,CAAC;AAMd;;;GAGG;AACH,MAAM,WAAW,UAAU;IAEzB,uCAAuC;IACvC,SAAS,CAAC,EA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AAE,6BAA6B,CAAC,EAAE,EAAE,GAAG,CAAC,GAC9C,UAAU,CAwFZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-base-template.d.ts","sourceRoot":"","sources":["../../src/base-template/default-base-template.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"default-base-template.d.ts","sourceRoot":"","sources":["../../src/base-template/default-base-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE3D,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAGxE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,sDAAsD;IACtD,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,oCAAoC;IACpC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAyW9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,MAAM,CAQ3F"}
|
package/base-template/index.js
CHANGED
|
@@ -78,9 +78,6 @@ var scriptCache = /* @__PURE__ */ new Map();
|
|
|
78
78
|
function getCachedScript(url) {
|
|
79
79
|
return scriptCache.get(url);
|
|
80
80
|
}
|
|
81
|
-
function isScriptCached(url) {
|
|
82
|
-
return scriptCache.has(url);
|
|
83
|
-
}
|
|
84
81
|
function buildScriptTag(url, integrity, options = {}) {
|
|
85
82
|
const attrs = [`src="${url}"`];
|
|
86
83
|
if (integrity) {
|
|
@@ -111,8 +108,9 @@ function buildCdnScriptsFromTheme(theme, options = {}) {
|
|
|
111
108
|
const iconsConfig = theme.cdn?.icons?.script ?? CDN.icons;
|
|
112
109
|
if (inline) {
|
|
113
110
|
if (tailwind) {
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
const cached = getCachedScript(tailwindUrl);
|
|
112
|
+
if (cached) {
|
|
113
|
+
scripts.push(buildInlineScriptTag(cached));
|
|
116
114
|
} else {
|
|
117
115
|
console.warn(
|
|
118
116
|
"[frontmcp/ui] Inline mode requested but Tailwind script not cached. Call fetchAndCacheScriptsFromTheme() first."
|
|
@@ -120,8 +118,9 @@ function buildCdnScriptsFromTheme(theme, options = {}) {
|
|
|
120
118
|
}
|
|
121
119
|
}
|
|
122
120
|
if (htmx) {
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
const cached = getCachedScript(htmxConfig.url);
|
|
122
|
+
if (cached) {
|
|
123
|
+
scripts.push(buildInlineScriptTag(cached));
|
|
125
124
|
} else {
|
|
126
125
|
console.warn(
|
|
127
126
|
"[frontmcp/ui] Inline mode requested but HTMX script not cached. Call fetchAndCacheScriptsFromTheme() first."
|
|
@@ -129,8 +128,9 @@ function buildCdnScriptsFromTheme(theme, options = {}) {
|
|
|
129
128
|
}
|
|
130
129
|
}
|
|
131
130
|
if (alpine) {
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
const cached = getCachedScript(alpineConfig.url);
|
|
132
|
+
if (cached) {
|
|
133
|
+
scripts.push(buildInlineScriptTag(cached));
|
|
134
134
|
} else {
|
|
135
135
|
console.warn(
|
|
136
136
|
"[frontmcp/ui] Inline mode requested but Alpine.js script not cached. Call fetchAndCacheScriptsFromTheme() first."
|
|
@@ -138,8 +138,9 @@ function buildCdnScriptsFromTheme(theme, options = {}) {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
if (icons) {
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
const cached = getCachedScript(iconsConfig.url);
|
|
142
|
+
if (cached) {
|
|
143
|
+
scripts.push(buildInlineScriptTag(cached));
|
|
143
144
|
} else {
|
|
144
145
|
console.warn(
|
|
145
146
|
"[frontmcp/ui] Inline mode requested but icons script not cached. Call fetchAndCacheScriptsFromTheme() first."
|
|
@@ -163,26 +164,6 @@ function buildCdnScriptsFromTheme(theme, options = {}) {
|
|
|
163
164
|
return scripts.join("\n ");
|
|
164
165
|
}
|
|
165
166
|
|
|
166
|
-
// libs/uipack/src/theme/platforms.ts
|
|
167
|
-
var CLAUDE_PLATFORM = {
|
|
168
|
-
id: "claude",
|
|
169
|
-
name: "Claude (Artifacts)",
|
|
170
|
-
supportsWidgets: true,
|
|
171
|
-
supportsTailwind: true,
|
|
172
|
-
supportsHtmx: false,
|
|
173
|
-
// Network blocked, HTMX won't work for API calls
|
|
174
|
-
networkMode: "blocked",
|
|
175
|
-
scriptStrategy: "inline",
|
|
176
|
-
maxInlineSize: 100 * 1024,
|
|
177
|
-
// 100KB limit for artifacts
|
|
178
|
-
cspRestrictions: ["script-src 'unsafe-inline'", "connect-src 'none'"],
|
|
179
|
-
options: {
|
|
180
|
-
mode: "artifacts",
|
|
181
|
-
framework: "react"
|
|
182
|
-
// Claude artifacts prefer React
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
|
|
186
167
|
// libs/uipack/src/theme/presets/github-openai.ts
|
|
187
168
|
var GITHUB_OPENAI_THEME = {
|
|
188
169
|
name: "github-openai",
|
|
@@ -343,17 +324,31 @@ function emitColorScale(lines, name, scale) {
|
|
|
343
324
|
if (value) lines.push(`--color-${name}-${shade}: ${value};`);
|
|
344
325
|
}
|
|
345
326
|
}
|
|
327
|
+
var OPACITY_VARIANTS = [10, 20, 30, 50, 70, 90];
|
|
328
|
+
function emitColorWithOpacityVariants(lines, name, value) {
|
|
329
|
+
lines.push(`--color-${name}: ${value};`);
|
|
330
|
+
for (const opacity of OPACITY_VARIANTS) {
|
|
331
|
+
lines.push(`--color-${name}-${opacity}: color-mix(in oklch, ${value} ${opacity}%, transparent);`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function emitBrandColorWithVariants(lines, name, value) {
|
|
335
|
+
lines.push(`--color-${name}: ${value};`);
|
|
336
|
+
lines.push(`--color-${name}-hover: color-mix(in oklch, ${value} 85%, black);`);
|
|
337
|
+
for (const opacity of OPACITY_VARIANTS) {
|
|
338
|
+
lines.push(`--color-${name}-${opacity}: color-mix(in oklch, ${value} ${opacity}%, transparent);`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
346
341
|
function buildThemeCss(theme) {
|
|
347
342
|
const lines = [];
|
|
348
343
|
const semantic = theme.colors.semantic;
|
|
349
344
|
if (typeof semantic.primary === "string") {
|
|
350
|
-
lines
|
|
345
|
+
emitBrandColorWithVariants(lines, "primary", semantic.primary);
|
|
351
346
|
} else if (semantic.primary) {
|
|
352
347
|
emitColorScale(lines, "primary", semantic.primary);
|
|
353
348
|
}
|
|
354
349
|
if (semantic.secondary) {
|
|
355
350
|
if (typeof semantic.secondary === "string") {
|
|
356
|
-
lines
|
|
351
|
+
emitBrandColorWithVariants(lines, "secondary", semantic.secondary);
|
|
357
352
|
} else {
|
|
358
353
|
emitColorScale(lines, "secondary", semantic.secondary);
|
|
359
354
|
}
|
|
@@ -372,10 +367,10 @@ function buildThemeCss(theme) {
|
|
|
372
367
|
emitColorScale(lines, "neutral", semantic.neutral);
|
|
373
368
|
}
|
|
374
369
|
}
|
|
375
|
-
if (semantic.success) lines
|
|
376
|
-
if (semantic.warning) lines
|
|
377
|
-
if (semantic.danger) lines
|
|
378
|
-
if (semantic.info) lines
|
|
370
|
+
if (semantic.success) emitColorWithOpacityVariants(lines, "success", semantic.success);
|
|
371
|
+
if (semantic.warning) emitColorWithOpacityVariants(lines, "warning", semantic.warning);
|
|
372
|
+
if (semantic.danger) emitColorWithOpacityVariants(lines, "danger", semantic.danger);
|
|
373
|
+
if (semantic.info) emitColorWithOpacityVariants(lines, "info", semantic.info);
|
|
379
374
|
const surface = theme.colors.surface;
|
|
380
375
|
if (surface?.background) lines.push(`--color-background: ${surface.background};`);
|
|
381
376
|
if (surface?.surface) lines.push(`--color-surface: ${surface.surface};`);
|