@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
|
@@ -12,9 +12,6 @@ var __export = (target, all) => {
|
|
|
12
12
|
function getCachedScript(url) {
|
|
13
13
|
return scriptCache.get(url);
|
|
14
14
|
}
|
|
15
|
-
function isScriptCached(url) {
|
|
16
|
-
return scriptCache.has(url);
|
|
17
|
-
}
|
|
18
15
|
function buildFontPreconnect() {
|
|
19
16
|
return CDN.fonts.preconnect.map((url, i) => `<link rel="preconnect" href="${url}"${i > 0 ? " crossorigin" : ""}>`).join("\n ");
|
|
20
17
|
}
|
|
@@ -47,8 +44,9 @@ function buildCdnScripts(options = {}) {
|
|
|
47
44
|
const scripts = [];
|
|
48
45
|
if (inline) {
|
|
49
46
|
if (tailwind) {
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
const cached = getCachedScript(CDN.tailwind);
|
|
48
|
+
if (cached) {
|
|
49
|
+
scripts.push(buildInlineScriptTag(cached));
|
|
52
50
|
} else {
|
|
53
51
|
console.warn(
|
|
54
52
|
"[frontmcp/ui] Inline mode requested but Tailwind script not cached. Call fetchAndCacheScripts() first."
|
|
@@ -56,8 +54,9 @@ function buildCdnScripts(options = {}) {
|
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
if (htmx) {
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const cached = getCachedScript(CDN.htmx.url);
|
|
58
|
+
if (cached) {
|
|
59
|
+
scripts.push(buildInlineScriptTag(cached));
|
|
61
60
|
} else {
|
|
62
61
|
console.warn(
|
|
63
62
|
"[frontmcp/ui] Inline mode requested but HTMX script not cached. Call fetchAndCacheScripts() first."
|
|
@@ -65,8 +64,9 @@ function buildCdnScripts(options = {}) {
|
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
if (alpine) {
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const cached = getCachedScript(CDN.alpine.url);
|
|
68
|
+
if (cached) {
|
|
69
|
+
scripts.push(buildInlineScriptTag(cached));
|
|
70
70
|
} else {
|
|
71
71
|
console.warn(
|
|
72
72
|
"[frontmcp/ui] Inline mode requested but Alpine.js script not cached. Call fetchAndCacheScripts() first."
|
|
@@ -74,8 +74,9 @@ function buildCdnScripts(options = {}) {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
if (icons) {
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
const cached = getCachedScript(CDN.icons.url);
|
|
78
|
+
if (cached) {
|
|
79
|
+
scripts.push(buildInlineScriptTag(cached));
|
|
79
80
|
} else {
|
|
80
81
|
console.warn(
|
|
81
82
|
"[frontmcp/ui] Inline mode requested but Lucide icons script not cached. Call fetchAndCacheScripts() first."
|
|
@@ -170,11 +171,12 @@ var init_platforms = __esm({
|
|
|
170
171
|
id: "claude",
|
|
171
172
|
name: "Claude (Artifacts)",
|
|
172
173
|
supportsWidgets: true,
|
|
174
|
+
// Claude Artifacts support interactive widgets
|
|
173
175
|
supportsTailwind: true,
|
|
174
176
|
supportsHtmx: false,
|
|
175
177
|
// Network blocked, HTMX won't work for API calls
|
|
176
|
-
networkMode: "
|
|
177
|
-
scriptStrategy: "
|
|
178
|
+
networkMode: "limited",
|
|
179
|
+
scriptStrategy: "cdn",
|
|
178
180
|
maxInlineSize: 100 * 1024,
|
|
179
181
|
// 100KB limit for artifacts
|
|
180
182
|
cspRestrictions: ["script-src 'unsafe-inline'", "connect-src 'none'"],
|
|
@@ -440,17 +442,30 @@ function emitColorScale(lines, name, scale) {
|
|
|
440
442
|
if (value) lines.push(`--color-${name}-${shade}: ${value};`);
|
|
441
443
|
}
|
|
442
444
|
}
|
|
445
|
+
function emitColorWithOpacityVariants(lines, name, value) {
|
|
446
|
+
lines.push(`--color-${name}: ${value};`);
|
|
447
|
+
for (const opacity of OPACITY_VARIANTS) {
|
|
448
|
+
lines.push(`--color-${name}-${opacity}: color-mix(in oklch, ${value} ${opacity}%, transparent);`);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
function emitBrandColorWithVariants(lines, name, value) {
|
|
452
|
+
lines.push(`--color-${name}: ${value};`);
|
|
453
|
+
lines.push(`--color-${name}-hover: color-mix(in oklch, ${value} 85%, black);`);
|
|
454
|
+
for (const opacity of OPACITY_VARIANTS) {
|
|
455
|
+
lines.push(`--color-${name}-${opacity}: color-mix(in oklch, ${value} ${opacity}%, transparent);`);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
443
458
|
function buildThemeCss(theme) {
|
|
444
459
|
const lines = [];
|
|
445
460
|
const semantic = theme.colors.semantic;
|
|
446
461
|
if (typeof semantic.primary === "string") {
|
|
447
|
-
lines
|
|
462
|
+
emitBrandColorWithVariants(lines, "primary", semantic.primary);
|
|
448
463
|
} else if (semantic.primary) {
|
|
449
464
|
emitColorScale(lines, "primary", semantic.primary);
|
|
450
465
|
}
|
|
451
466
|
if (semantic.secondary) {
|
|
452
467
|
if (typeof semantic.secondary === "string") {
|
|
453
|
-
lines
|
|
468
|
+
emitBrandColorWithVariants(lines, "secondary", semantic.secondary);
|
|
454
469
|
} else {
|
|
455
470
|
emitColorScale(lines, "secondary", semantic.secondary);
|
|
456
471
|
}
|
|
@@ -469,10 +484,10 @@ function buildThemeCss(theme) {
|
|
|
469
484
|
emitColorScale(lines, "neutral", semantic.neutral);
|
|
470
485
|
}
|
|
471
486
|
}
|
|
472
|
-
if (semantic.success) lines
|
|
473
|
-
if (semantic.warning) lines
|
|
474
|
-
if (semantic.danger) lines
|
|
475
|
-
if (semantic.info) lines
|
|
487
|
+
if (semantic.success) emitColorWithOpacityVariants(lines, "success", semantic.success);
|
|
488
|
+
if (semantic.warning) emitColorWithOpacityVariants(lines, "warning", semantic.warning);
|
|
489
|
+
if (semantic.danger) emitColorWithOpacityVariants(lines, "danger", semantic.danger);
|
|
490
|
+
if (semantic.info) emitColorWithOpacityVariants(lines, "info", semantic.info);
|
|
476
491
|
const surface = theme.colors.surface;
|
|
477
492
|
if (surface?.background) lines.push(`--color-background: ${surface.background};`);
|
|
478
493
|
if (surface?.surface) lines.push(`--color-surface: ${surface.surface};`);
|
|
@@ -514,10 +529,11 @@ function buildThemeCss(theme) {
|
|
|
514
529
|
}
|
|
515
530
|
return lines.join("\n ");
|
|
516
531
|
}
|
|
532
|
+
var OPACITY_VARIANTS;
|
|
517
533
|
var init_theme = __esm({
|
|
518
534
|
"libs/uipack/src/theme/theme.ts"() {
|
|
519
535
|
"use strict";
|
|
520
|
-
|
|
536
|
+
OPACITY_VARIANTS = [10, 20, 30, 50, 70, 90];
|
|
521
537
|
}
|
|
522
538
|
});
|
|
523
539
|
|
|
@@ -532,13 +548,6 @@ var init_theme2 = __esm({
|
|
|
532
548
|
}
|
|
533
549
|
});
|
|
534
550
|
|
|
535
|
-
// libs/uipack/src/utils/safe-stringify.ts
|
|
536
|
-
var init_safe_stringify = __esm({
|
|
537
|
-
"libs/uipack/src/utils/safe-stringify.ts"() {
|
|
538
|
-
"use strict";
|
|
539
|
-
}
|
|
540
|
-
});
|
|
541
|
-
|
|
542
551
|
// libs/uipack/src/utils/escape-html.ts
|
|
543
552
|
function escapeHtml(str) {
|
|
544
553
|
if (str === null || str === void 0) {
|
|
@@ -547,6 +556,12 @@ function escapeHtml(str) {
|
|
|
547
556
|
const s = String(str);
|
|
548
557
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
549
558
|
}
|
|
559
|
+
function escapeJsString(str) {
|
|
560
|
+
return str.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
561
|
+
}
|
|
562
|
+
function escapeScriptClose(jsonString) {
|
|
563
|
+
return jsonString.replace(/<\//g, "<\\/");
|
|
564
|
+
}
|
|
550
565
|
var init_escape_html = __esm({
|
|
551
566
|
"libs/uipack/src/utils/escape-html.ts"() {
|
|
552
567
|
"use strict";
|
|
@@ -557,7 +572,6 @@ var init_escape_html = __esm({
|
|
|
557
572
|
var init_utils = __esm({
|
|
558
573
|
"libs/uipack/src/utils/index.ts"() {
|
|
559
574
|
"use strict";
|
|
560
|
-
init_safe_stringify();
|
|
561
575
|
init_escape_html();
|
|
562
576
|
}
|
|
563
577
|
});
|
|
@@ -1141,7 +1155,6 @@ var init_helpers = __esm({
|
|
|
1141
1155
|
// libs/uipack/src/handlebars/expression-extractor.ts
|
|
1142
1156
|
function extractExpressions(template) {
|
|
1143
1157
|
const expressions = [];
|
|
1144
|
-
const lines = template.split("\n");
|
|
1145
1158
|
const positionMap = buildPositionMap(template);
|
|
1146
1159
|
let match;
|
|
1147
1160
|
EXPRESSION_REGEX.lastIndex = 0;
|
|
@@ -1839,74 +1852,32 @@ var init_registry = __esm({
|
|
|
1839
1852
|
}
|
|
1840
1853
|
});
|
|
1841
1854
|
|
|
1842
|
-
// libs/uipack/src/renderers/mdx.renderer.ts
|
|
1843
|
-
function
|
|
1844
|
-
return
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
console.warn('[FrontMCP] React not available for MDX hydration');
|
|
1850
|
-
return;
|
|
1851
|
-
}
|
|
1852
|
-
|
|
1853
|
-
// Find all elements marked for MDX hydration
|
|
1854
|
-
document.querySelectorAll('[data-mdx-hydrate]').forEach(function(root) {
|
|
1855
|
-
var propsJson = root.getAttribute('data-props');
|
|
1856
|
-
var props = propsJson ? JSON.parse(propsJson) : {};
|
|
1857
|
-
|
|
1858
|
-
// MDX content is pre-rendered, hydration mainly attaches event handlers
|
|
1859
|
-
// For full interactivity, components need to be available client-side
|
|
1860
|
-
if (window.__frontmcp_mdx_content) {
|
|
1861
|
-
try {
|
|
1862
|
-
ReactDOM.hydrateRoot(root, React.createElement(
|
|
1863
|
-
window.__frontmcp_mdx_content,
|
|
1864
|
-
props
|
|
1865
|
-
));
|
|
1866
|
-
} catch (e) {
|
|
1867
|
-
console.error('[FrontMCP] MDX hydration failed', e);
|
|
1868
|
-
}
|
|
1869
|
-
}
|
|
1870
|
-
});
|
|
1871
|
-
})();
|
|
1872
|
-
</script>
|
|
1873
|
-
`;
|
|
1855
|
+
// libs/uipack/src/renderers/mdx-client.renderer.ts
|
|
1856
|
+
function buildReactCdnUrls(version = "19") {
|
|
1857
|
+
return {
|
|
1858
|
+
react: `https://esm.sh/react@${version}`,
|
|
1859
|
+
reactDom: `https://esm.sh/react-dom@${version}/client`,
|
|
1860
|
+
jsxRuntime: `https://esm.sh/react@${version}/jsx-runtime`
|
|
1861
|
+
};
|
|
1874
1862
|
}
|
|
1875
|
-
var
|
|
1876
|
-
var
|
|
1877
|
-
"libs/uipack/src/renderers/mdx.renderer.ts"() {
|
|
1863
|
+
var DEFAULT_CDN, MdxClientRenderer, mdxClientRenderer;
|
|
1864
|
+
var init_mdx_client_renderer = __esm({
|
|
1865
|
+
"libs/uipack/src/renderers/mdx-client.renderer.ts"() {
|
|
1878
1866
|
"use strict";
|
|
1879
1867
|
init_detect();
|
|
1880
1868
|
init_hash();
|
|
1881
1869
|
init_cache();
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1870
|
+
init_utils();
|
|
1871
|
+
DEFAULT_CDN = {
|
|
1872
|
+
mdx: "https://esm.sh/@mdx-js/mdx@3",
|
|
1873
|
+
...buildReactCdnUrls("19")
|
|
1885
1874
|
};
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
`;
|
|
1891
|
-
MdxRenderer = class {
|
|
1892
|
-
type = "mdx";
|
|
1893
|
-
priority = 10;
|
|
1894
|
-
// Between HTML (0) and React (20)
|
|
1895
|
-
/**
|
|
1896
|
-
* Lazy-loaded modules.
|
|
1897
|
-
*/
|
|
1898
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1899
|
-
React = null;
|
|
1900
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1901
|
-
ReactDOMServer = null;
|
|
1902
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1903
|
-
jsxRuntime = null;
|
|
1904
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1905
|
-
mdxEvaluate = null;
|
|
1875
|
+
MdxClientRenderer = class {
|
|
1876
|
+
type = "mdx-client";
|
|
1877
|
+
priority = 8;
|
|
1878
|
+
// Lower than server-side MDX (10)
|
|
1906
1879
|
/**
|
|
1907
1880
|
* Check if this renderer can handle the given template.
|
|
1908
|
-
*
|
|
1909
|
-
* Accepts strings containing MDX syntax (Markdown + JSX).
|
|
1910
1881
|
*/
|
|
1911
1882
|
canHandle(template) {
|
|
1912
1883
|
if (typeof template !== "string") {
|
|
@@ -1915,11 +1886,9 @@ console.warn('[FrontMCP] MDX hydration not available on this platform.');
|
|
|
1915
1886
|
return containsMdxSyntax(template);
|
|
1916
1887
|
}
|
|
1917
1888
|
/**
|
|
1918
|
-
*
|
|
1919
|
-
*
|
|
1920
|
-
*
|
|
1921
|
-
* Note: For MDX, we use evaluate() which combines compile + run,
|
|
1922
|
-
* so this method just returns the source hash for caching purposes.
|
|
1889
|
+
* Prepare MDX template for rendering.
|
|
1890
|
+
* Caches the template hash for deduplication. Actual MDX compilation
|
|
1891
|
+
* happens client-side via CDN-loaded @mdx-js/mdx in the browser.
|
|
1923
1892
|
*/
|
|
1924
1893
|
async transpile(template, _options) {
|
|
1925
1894
|
const hash = hashString(template);
|
|
@@ -1929,7 +1898,6 @@ console.warn('[FrontMCP] MDX hydration not available on this platform.');
|
|
|
1929
1898
|
}
|
|
1930
1899
|
const transpileResult = {
|
|
1931
1900
|
code: template,
|
|
1932
|
-
// Store original MDX for evaluate()
|
|
1933
1901
|
hash,
|
|
1934
1902
|
cached: false
|
|
1935
1903
|
};
|
|
@@ -1937,37 +1905,20 @@ console.warn('[FrontMCP] MDX hydration not available on this platform.');
|
|
|
1937
1905
|
return transpileResult;
|
|
1938
1906
|
}
|
|
1939
1907
|
/**
|
|
1940
|
-
* Render MDX template to HTML
|
|
1908
|
+
* Render MDX template to HTML with CDN scripts.
|
|
1941
1909
|
*
|
|
1942
|
-
*
|
|
1943
|
-
*
|
|
1910
|
+
* The returned HTML includes:
|
|
1911
|
+
* - A container div for the rendered content
|
|
1912
|
+
* - Script tags that load React and MDX from CDN
|
|
1913
|
+
* - Inline script that compiles and renders the MDX
|
|
1944
1914
|
*/
|
|
1945
1915
|
async render(template, context, options) {
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
const cacheKey = `mdx-component:${templateHash}`;
|
|
1953
|
-
let Content = componentCache.get(cacheKey);
|
|
1954
|
-
if (!Content) {
|
|
1955
|
-
const result = await this.mdxEvaluate(template, {
|
|
1956
|
-
...this.jsxRuntime,
|
|
1957
|
-
Fragment: this.React.Fragment,
|
|
1958
|
-
development: false
|
|
1959
|
-
});
|
|
1960
|
-
Content = result.default;
|
|
1961
|
-
componentCache.set(cacheKey, Content);
|
|
1962
|
-
}
|
|
1963
|
-
const mdxComponents = {
|
|
1964
|
-
// User-provided components from tool config
|
|
1965
|
-
...options?.mdxComponents,
|
|
1966
|
-
// Wrapper that provides context to the content
|
|
1967
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1968
|
-
wrapper: ({ children }) => {
|
|
1969
|
-
return this.React.createElement("div", { className: "mdx-content" }, children);
|
|
1970
|
-
}
|
|
1916
|
+
const containerId = options?.containerId || "mdx-content";
|
|
1917
|
+
const showLoading = options?.showLoading !== false;
|
|
1918
|
+
const loadingMessage = options?.loadingMessage || "Loading...";
|
|
1919
|
+
const cdn = {
|
|
1920
|
+
...DEFAULT_CDN,
|
|
1921
|
+
...options?.cdn
|
|
1971
1922
|
};
|
|
1972
1923
|
const props = {
|
|
1973
1924
|
input: context.input,
|
|
@@ -1975,82 +1926,80 @@ console.warn('[FrontMCP] MDX hydration not available on this platform.');
|
|
|
1975
1926
|
structuredContent: context.structuredContent,
|
|
1976
1927
|
helpers: context.helpers
|
|
1977
1928
|
};
|
|
1929
|
+
const reservedProps = /* @__PURE__ */ new Set(["input", "output", "structuredContent", "helpers", "components"]);
|
|
1930
|
+
const outputProps = typeof context.output === "object" && context.output !== null ? Object.fromEntries(Object.entries(context.output).filter(([key]) => !reservedProps.has(key))) : {};
|
|
1978
1931
|
const spreadProps = {
|
|
1979
|
-
...
|
|
1980
|
-
...
|
|
1932
|
+
...outputProps,
|
|
1933
|
+
...props
|
|
1981
1934
|
};
|
|
1982
|
-
const
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
}
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1935
|
+
const escapedMdx = escapeScriptClose(JSON.stringify(template));
|
|
1936
|
+
const escapedProps = escapeScriptClose(JSON.stringify(spreadProps));
|
|
1937
|
+
const safeContainerId = escapeJsString(containerId);
|
|
1938
|
+
const loadingHtml = showLoading ? `<div class="mdx-loading">${escapeHtml(loadingMessage)}</div>` : "";
|
|
1939
|
+
return `
|
|
1940
|
+
<div id="${escapeHtml(containerId)}">${loadingHtml}</div>
|
|
1941
|
+
<script type="module">
|
|
1942
|
+
(async function() {
|
|
1943
|
+
try {
|
|
1944
|
+
// Load dependencies from CDN
|
|
1945
|
+
const [
|
|
1946
|
+
{ evaluate },
|
|
1947
|
+
runtime,
|
|
1948
|
+
React,
|
|
1949
|
+
{ createRoot }
|
|
1950
|
+
] = await Promise.all([
|
|
1951
|
+
import('${cdn.mdx}'),
|
|
1952
|
+
import('${cdn.jsxRuntime}'),
|
|
1953
|
+
import('${cdn.react}'),
|
|
1954
|
+
import('${cdn.reactDom}')
|
|
1955
|
+
]);
|
|
1956
|
+
|
|
1957
|
+
// MDX content and props
|
|
1958
|
+
const mdxSource = ${escapedMdx};
|
|
1959
|
+
const props = ${escapedProps};
|
|
1960
|
+
|
|
1961
|
+
// Compile and evaluate MDX
|
|
1962
|
+
const { default: Content } = await evaluate(mdxSource, {
|
|
1963
|
+
...runtime,
|
|
1964
|
+
Fragment: React.Fragment,
|
|
1965
|
+
development: false
|
|
1966
|
+
});
|
|
1967
|
+
|
|
1968
|
+
// Render to DOM
|
|
1969
|
+
const container = document.getElementById('${safeContainerId}');
|
|
1970
|
+
if (container) {
|
|
1971
|
+
const root = createRoot(container);
|
|
1972
|
+
root.render(React.createElement(Content, props));
|
|
1973
|
+
}
|
|
1974
|
+
} catch (error) {
|
|
1975
|
+
console.error('[FrontMCP] MDX client rendering failed:', error);
|
|
1976
|
+
const container = document.getElementById('${safeContainerId}');
|
|
1977
|
+
if (container) {
|
|
1978
|
+
container.innerHTML = '<div class="mdx-error">Failed to render MDX content</div>';
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
})();
|
|
1982
|
+
</script>
|
|
1983
|
+
`;
|
|
1992
1984
|
}
|
|
1993
1985
|
/**
|
|
1994
|
-
* Get runtime scripts for client
|
|
1986
|
+
* Get runtime scripts - not needed for client renderer since scripts are inline.
|
|
1995
1987
|
*/
|
|
1996
1988
|
getRuntimeScripts(platform) {
|
|
1997
1989
|
if (platform.networkMode === "blocked") {
|
|
1998
1990
|
return {
|
|
1999
1991
|
headScripts: "",
|
|
2000
|
-
inlineScripts:
|
|
1992
|
+
inlineScripts: `console.warn('[FrontMCP] Client-side MDX rendering requires network access. Use @frontmcp/ui for SSR.');`,
|
|
2001
1993
|
isInline: true
|
|
2002
1994
|
};
|
|
2003
1995
|
}
|
|
2004
1996
|
return {
|
|
2005
|
-
headScripts:
|
|
2006
|
-
<script crossorigin src="${REACT_CDN.react}"></script>
|
|
2007
|
-
<script crossorigin src="${REACT_CDN.reactDom}"></script>
|
|
2008
|
-
`,
|
|
1997
|
+
headScripts: "",
|
|
2009
1998
|
isInline: false
|
|
2010
1999
|
};
|
|
2011
2000
|
}
|
|
2012
|
-
/**
|
|
2013
|
-
* Load React and ReactDOMServer modules.
|
|
2014
|
-
*/
|
|
2015
|
-
async loadReact() {
|
|
2016
|
-
if (this.React && this.ReactDOMServer && this.jsxRuntime) {
|
|
2017
|
-
return;
|
|
2018
|
-
}
|
|
2019
|
-
try {
|
|
2020
|
-
const [react, reactDomServer, jsxRuntime] = await Promise.all([
|
|
2021
|
-
import("react"),
|
|
2022
|
-
import("react-dom/server"),
|
|
2023
|
-
import("react/jsx-runtime")
|
|
2024
|
-
]);
|
|
2025
|
-
this.React = react;
|
|
2026
|
-
this.ReactDOMServer = reactDomServer;
|
|
2027
|
-
this.jsxRuntime = jsxRuntime;
|
|
2028
|
-
} catch {
|
|
2029
|
-
throw new Error("React is required for MdxRenderer. Install react and react-dom: npm install react react-dom");
|
|
2030
|
-
}
|
|
2031
|
-
}
|
|
2032
|
-
/**
|
|
2033
|
-
* Load @mdx-js/mdx evaluate function.
|
|
2034
|
-
*
|
|
2035
|
-
* evaluate() is the cleanest way to run MDX - it combines
|
|
2036
|
-
* compile and run in a single step, handling all the runtime
|
|
2037
|
-
* injection automatically.
|
|
2038
|
-
*/
|
|
2039
|
-
async loadMdx() {
|
|
2040
|
-
if (this.mdxEvaluate) {
|
|
2041
|
-
return;
|
|
2042
|
-
}
|
|
2043
|
-
try {
|
|
2044
|
-
const mdx = await import("@mdx-js/mdx");
|
|
2045
|
-
this.mdxEvaluate = mdx.evaluate;
|
|
2046
|
-
} catch {
|
|
2047
|
-
console.warn(
|
|
2048
|
-
"[@frontmcp/ui] @mdx-js/mdx not available. MDX rendering disabled. Install @mdx-js/mdx to enable: npm install @mdx-js/mdx"
|
|
2049
|
-
);
|
|
2050
|
-
}
|
|
2051
|
-
}
|
|
2052
2001
|
};
|
|
2053
|
-
|
|
2002
|
+
mdxClientRenderer = new MdxClientRenderer();
|
|
2054
2003
|
}
|
|
2055
2004
|
});
|
|
2056
2005
|
|
|
@@ -2060,7 +2009,10 @@ async function loadSwcTransform() {
|
|
|
2060
2009
|
return swcTransform;
|
|
2061
2010
|
}
|
|
2062
2011
|
try {
|
|
2063
|
-
const swc = await import(
|
|
2012
|
+
const swc = await import(
|
|
2013
|
+
/* webpackIgnore: true */
|
|
2014
|
+
"@swc/core"
|
|
2015
|
+
);
|
|
2064
2016
|
swcTransform = swc.transform;
|
|
2065
2017
|
return swcTransform;
|
|
2066
2018
|
} catch {
|
|
@@ -2115,43 +2067,15 @@ async function isSwcAvailable() {
|
|
|
2115
2067
|
const transform = await loadSwcTransform();
|
|
2116
2068
|
return transform !== null;
|
|
2117
2069
|
}
|
|
2118
|
-
async function executeTranspiledCode(
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
React = await import("react");
|
|
2123
|
-
jsxRuntime = await import("react/jsx-runtime");
|
|
2124
|
-
} catch {
|
|
2125
|
-
throw new Error("React is required for JSX templates. Install react: npm install react react-dom");
|
|
2126
|
-
}
|
|
2127
|
-
const exports = {};
|
|
2128
|
-
const module = { exports };
|
|
2129
|
-
const require2 = (id) => {
|
|
2130
|
-
switch (id) {
|
|
2131
|
-
case "react":
|
|
2132
|
-
return React;
|
|
2133
|
-
case "react/jsx-runtime":
|
|
2134
|
-
return jsxRuntime;
|
|
2135
|
-
case "react/jsx-dev-runtime":
|
|
2136
|
-
return jsxRuntime;
|
|
2137
|
-
default:
|
|
2138
|
-
if (context[id]) {
|
|
2139
|
-
return context[id];
|
|
2140
|
-
}
|
|
2141
|
-
throw new Error(`Module '${id}' not available in JSX template context`);
|
|
2142
|
-
}
|
|
2143
|
-
};
|
|
2144
|
-
try {
|
|
2145
|
-
const fn = new Function("exports", "require", "module", "__filename", "__dirname", "React", "context", code);
|
|
2146
|
-
fn(exports, require2, module, "template.js", "/", React, context);
|
|
2147
|
-
return module.exports["default"] || module.exports[Object.keys(module.exports)[0]] || module.exports;
|
|
2148
|
-
} catch (error) {
|
|
2149
|
-
throw new Error(`Failed to execute transpiled JSX: ${error instanceof Error ? error.message : String(error)}`);
|
|
2150
|
-
}
|
|
2070
|
+
async function executeTranspiledCode(_code, _context = {}) {
|
|
2071
|
+
throw new Error(
|
|
2072
|
+
'executeTranspiledCode has been moved to @frontmcp/ui/renderers. Install @frontmcp/ui and import from there: import { executeTranspiledCode } from "@frontmcp/ui/renderers"'
|
|
2073
|
+
);
|
|
2151
2074
|
}
|
|
2152
|
-
async function transpileAndExecute(
|
|
2153
|
-
|
|
2154
|
-
|
|
2075
|
+
async function transpileAndExecute(_source, _context = {}) {
|
|
2076
|
+
throw new Error(
|
|
2077
|
+
'transpileAndExecute has been moved to @frontmcp/ui/renderers. Install @frontmcp/ui and import from there: import { transpileAndExecute } from "@frontmcp/ui/renderers"'
|
|
2078
|
+
);
|
|
2155
2079
|
}
|
|
2156
2080
|
var DEFAULT_SWC_OPTIONS, swcTransform;
|
|
2157
2081
|
var init_transpiler = __esm({
|
|
@@ -2183,10 +2107,11 @@ var init_utils2 = __esm({
|
|
|
2183
2107
|
var renderers_exports = {};
|
|
2184
2108
|
__export(renderers_exports, {
|
|
2185
2109
|
HtmlRenderer: () => HtmlRenderer,
|
|
2186
|
-
|
|
2110
|
+
MdxClientRenderer: () => MdxClientRenderer,
|
|
2187
2111
|
RendererRegistry: () => RendererRegistry,
|
|
2188
2112
|
TranspileCache: () => TranspileCache,
|
|
2189
|
-
|
|
2113
|
+
buildReactCdnUrls: () => buildReactCdnUrls,
|
|
2114
|
+
componentCache: () => componentCache,
|
|
2190
2115
|
containsJsx: () => containsJsx,
|
|
2191
2116
|
containsMdxSyntax: () => containsMdxSyntax,
|
|
2192
2117
|
detectTemplateType: () => detectTemplateType,
|
|
@@ -2199,8 +2124,7 @@ __export(renderers_exports, {
|
|
|
2199
2124
|
isReactComponent: () => isReactComponent,
|
|
2200
2125
|
isSwcAvailable: () => isSwcAvailable,
|
|
2201
2126
|
isTemplateBuilderFunction: () => isTemplateBuilderFunction,
|
|
2202
|
-
|
|
2203
|
-
renderCache: () => renderCache,
|
|
2127
|
+
mdxClientRenderer: () => mdxClientRenderer,
|
|
2204
2128
|
rendererRegistry: () => rendererRegistry,
|
|
2205
2129
|
transpileAndExecute: () => transpileAndExecute,
|
|
2206
2130
|
transpileCache: () => transpileCache,
|
|
@@ -2212,7 +2136,7 @@ var init_renderers = __esm({
|
|
|
2212
2136
|
init_cache();
|
|
2213
2137
|
init_registry();
|
|
2214
2138
|
init_html_renderer();
|
|
2215
|
-
|
|
2139
|
+
init_mdx_client_renderer();
|
|
2216
2140
|
init_utils2();
|
|
2217
2141
|
}
|
|
2218
2142
|
});
|
|
@@ -3079,9 +3003,6 @@ var BRIDGE_SCRIPT_TAGS = {
|
|
|
3079
3003
|
gemini: `<script>${generatePlatformBundle("gemini")}</script>`
|
|
3080
3004
|
};
|
|
3081
3005
|
|
|
3082
|
-
// libs/uipack/src/runtime/mcp-bridge.ts
|
|
3083
|
-
var FRONTMCP_BRIDGE_RUNTIME = BRIDGE_SCRIPT_TAGS.universal;
|
|
3084
|
-
|
|
3085
3006
|
// libs/uipack/src/runtime/csp.ts
|
|
3086
3007
|
var DEFAULT_CDN_DOMAINS = [
|
|
3087
3008
|
"https://cdn.jsdelivr.net",
|
|
@@ -4527,12 +4448,12 @@ function containsMdxSyntax2(source) {
|
|
|
4527
4448
|
}
|
|
4528
4449
|
async function renderMdxContent(mdxContent, context, mdxComponents) {
|
|
4529
4450
|
try {
|
|
4530
|
-
const {
|
|
4531
|
-
const html = await
|
|
4451
|
+
const { mdxClientRenderer: mdxClientRenderer2 } = await Promise.resolve().then(() => (init_renderers(), renderers_exports));
|
|
4452
|
+
const html = await mdxClientRenderer2.render(mdxContent, context, { mdxComponents });
|
|
4532
4453
|
return html;
|
|
4533
4454
|
} catch (error) {
|
|
4534
4455
|
console.error(
|
|
4535
|
-
"[@frontmcp/
|
|
4456
|
+
"[@frontmcp/uipack] MDX rendering failed:",
|
|
4536
4457
|
error instanceof Error ? error.stack || error.message : String(error)
|
|
4537
4458
|
);
|
|
4538
4459
|
const escaped = mdxContent.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
@@ -4586,13 +4507,17 @@ async function renderToolTemplateAsync(options) {
|
|
|
4586
4507
|
if (isReactComponent2(template)) {
|
|
4587
4508
|
const componentName = template.displayName || template.name || "UnknownComponent";
|
|
4588
4509
|
try {
|
|
4510
|
+
const reactPkg = "react";
|
|
4511
|
+
const reactDomServerPkg = "react-dom/server";
|
|
4589
4512
|
const [React, ReactDOMServer] = await Promise.all([
|
|
4590
|
-
import(
|
|
4591
|
-
throw new Error(
|
|
4513
|
+
import(reactPkg).catch(() => {
|
|
4514
|
+
throw new Error(
|
|
4515
|
+
"React is required for React component templates. Either install react as a dependency, or use @frontmcp/ui for React component support."
|
|
4516
|
+
);
|
|
4592
4517
|
}),
|
|
4593
|
-
import(
|
|
4518
|
+
import(reactDomServerPkg).catch(() => {
|
|
4594
4519
|
throw new Error(
|
|
4595
|
-
"react-dom/server is required for React component templates.
|
|
4520
|
+
"react-dom/server is required for React component templates. Either install react-dom as a dependency, or use @frontmcp/ui for React component support."
|
|
4596
4521
|
);
|
|
4597
4522
|
})
|
|
4598
4523
|
]);
|
|
@@ -4696,20 +4621,19 @@ function buildOpenAIMeta(meta, uiConfig) {
|
|
|
4696
4621
|
}
|
|
4697
4622
|
return meta;
|
|
4698
4623
|
}
|
|
4699
|
-
function buildOpenAICSP(csp) {
|
|
4700
|
-
const result = {};
|
|
4701
|
-
if (csp.connectDomains?.length) {
|
|
4702
|
-
result.connect_domains = csp.connectDomains;
|
|
4703
|
-
}
|
|
4704
|
-
if (csp.resourceDomains?.length) {
|
|
4705
|
-
result.resource_domains = csp.resourceDomains;
|
|
4706
|
-
}
|
|
4707
|
-
return result;
|
|
4708
|
-
}
|
|
4709
4624
|
function buildClaudeMeta(meta, uiConfig) {
|
|
4710
4625
|
if (uiConfig.widgetDescription) {
|
|
4711
4626
|
meta["claude/widgetDescription"] = uiConfig.widgetDescription;
|
|
4712
4627
|
}
|
|
4628
|
+
if (uiConfig.displayMode) {
|
|
4629
|
+
meta["claude/displayMode"] = uiConfig.displayMode;
|
|
4630
|
+
}
|
|
4631
|
+
if (uiConfig.widgetAccessible) {
|
|
4632
|
+
meta["claude/widgetAccessible"] = true;
|
|
4633
|
+
}
|
|
4634
|
+
if (uiConfig.prefersBorder !== void 0) {
|
|
4635
|
+
meta["claude/prefersBorder"] = uiConfig.prefersBorder;
|
|
4636
|
+
}
|
|
4713
4637
|
return meta;
|
|
4714
4638
|
}
|
|
4715
4639
|
function buildGeminiMeta(meta, uiConfig) {
|
|
@@ -4724,12 +4648,34 @@ function buildIDEMeta(meta, uiConfig) {
|
|
|
4724
4648
|
}
|
|
4725
4649
|
return meta;
|
|
4726
4650
|
}
|
|
4651
|
+
function buildFrontMCPCSP(csp) {
|
|
4652
|
+
const result = {};
|
|
4653
|
+
if (csp.connectDomains?.length) {
|
|
4654
|
+
result.connectDomains = csp.connectDomains;
|
|
4655
|
+
}
|
|
4656
|
+
if (csp.resourceDomains?.length) {
|
|
4657
|
+
result.resourceDomains = csp.resourceDomains;
|
|
4658
|
+
}
|
|
4659
|
+
return result;
|
|
4660
|
+
}
|
|
4727
4661
|
function buildGenericMeta(meta, uiConfig) {
|
|
4728
4662
|
if (uiConfig.widgetAccessible) {
|
|
4729
|
-
meta["
|
|
4663
|
+
meta["frontmcp/widgetAccessible"] = true;
|
|
4730
4664
|
}
|
|
4731
4665
|
if (uiConfig.csp) {
|
|
4732
|
-
meta["
|
|
4666
|
+
meta["frontmcp/widgetCSP"] = buildFrontMCPCSP(uiConfig.csp);
|
|
4667
|
+
}
|
|
4668
|
+
if (uiConfig.displayMode) {
|
|
4669
|
+
meta["frontmcp/displayMode"] = uiConfig.displayMode;
|
|
4670
|
+
}
|
|
4671
|
+
if (uiConfig.widgetDescription) {
|
|
4672
|
+
meta["frontmcp/widgetDescription"] = uiConfig.widgetDescription;
|
|
4673
|
+
}
|
|
4674
|
+
if (uiConfig.prefersBorder !== void 0) {
|
|
4675
|
+
meta["frontmcp/prefersBorder"] = uiConfig.prefersBorder;
|
|
4676
|
+
}
|
|
4677
|
+
if (uiConfig.sandboxDomain) {
|
|
4678
|
+
meta["frontmcp/domain"] = uiConfig.sandboxDomain;
|
|
4733
4679
|
}
|
|
4734
4680
|
return meta;
|
|
4735
4681
|
}
|
|
@@ -4770,14 +4716,6 @@ function buildExtAppsMeta(meta, uiConfig) {
|
|
|
4770
4716
|
return meta;
|
|
4771
4717
|
}
|
|
4772
4718
|
|
|
4773
|
-
// libs/uipack/src/adapters/response-builder.ts
|
|
4774
|
-
init_utils();
|
|
4775
|
-
|
|
4776
|
-
// libs/uipack/src/build/index.ts
|
|
4777
|
-
init_registry();
|
|
4778
|
-
init_renderers();
|
|
4779
|
-
init_theme2();
|
|
4780
|
-
|
|
4781
4719
|
// libs/uipack/src/types/ui-runtime.ts
|
|
4782
4720
|
function isUIType(value) {
|
|
4783
4721
|
return typeof value === "string" && ["html", "react", "mdx", "markdown", "auto"].includes(value);
|
|
@@ -4814,7 +4752,7 @@ var DEFAULT_CSP_BY_TYPE = {
|
|
|
4814
4752
|
};
|
|
4815
4753
|
|
|
4816
4754
|
// libs/uipack/src/build/cdn-resources.ts
|
|
4817
|
-
var
|
|
4755
|
+
var REACT_CDN = {
|
|
4818
4756
|
url: "https://esm.sh/react@19",
|
|
4819
4757
|
crossorigin: "anonymous"
|
|
4820
4758
|
};
|
|
@@ -4847,13 +4785,13 @@ function getDefaultAssets(uiType, mode = "cdn") {
|
|
|
4847
4785
|
case "react":
|
|
4848
4786
|
return {
|
|
4849
4787
|
...baseAssets,
|
|
4850
|
-
react:
|
|
4788
|
+
react: REACT_CDN,
|
|
4851
4789
|
reactDom: REACT_DOM_CDN
|
|
4852
4790
|
};
|
|
4853
4791
|
case "mdx":
|
|
4854
4792
|
return {
|
|
4855
4793
|
...baseAssets,
|
|
4856
|
-
react:
|
|
4794
|
+
react: REACT_CDN,
|
|
4857
4795
|
reactDom: REACT_DOM_CDN,
|
|
4858
4796
|
mdxRuntime: MDX_RUNTIME_CDN,
|
|
4859
4797
|
markdown: MARKED_CDN
|
|
@@ -4871,7 +4809,7 @@ function getDefaultAssets(uiType, mode = "cdn") {
|
|
|
4871
4809
|
case "auto":
|
|
4872
4810
|
return {
|
|
4873
4811
|
...baseAssets,
|
|
4874
|
-
react:
|
|
4812
|
+
react: REACT_CDN,
|
|
4875
4813
|
reactDom: REACT_DOM_CDN,
|
|
4876
4814
|
markdown: MARKED_CDN,
|
|
4877
4815
|
handlebars: HANDLEBARS_CDN
|
|
@@ -4921,9 +4859,6 @@ function detectFormatFromPath(pathOrUrl) {
|
|
|
4921
4859
|
return "html";
|
|
4922
4860
|
}
|
|
4923
4861
|
|
|
4924
|
-
// libs/uipack/src/validation/error-box.ts
|
|
4925
|
-
init_utils();
|
|
4926
|
-
|
|
4927
4862
|
// libs/uipack/src/validation/schema-paths.ts
|
|
4928
4863
|
import { z } from "zod";
|
|
4929
4864
|
function extractSchemaPaths(schema, prefix = "output", options = {}) {
|
|
@@ -5355,7 +5290,7 @@ var URL_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
|
5355
5290
|
|
|
5356
5291
|
// libs/uipack/src/dependency/template-processor.ts
|
|
5357
5292
|
init_handlebars();
|
|
5358
|
-
|
|
5293
|
+
init_mdx_client_renderer();
|
|
5359
5294
|
init_utils();
|
|
5360
5295
|
function safeInputToRecord(input) {
|
|
5361
5296
|
if (input && typeof input === "object" && !Array.isArray(input)) {
|
|
@@ -5468,7 +5403,7 @@ async function processTemplate(resolved, options) {
|
|
|
5468
5403
|
structuredContent: context.structuredContent,
|
|
5469
5404
|
helpers: defaultHelpers
|
|
5470
5405
|
};
|
|
5471
|
-
const html = await
|
|
5406
|
+
const html = await mdxClientRenderer.render(processedContent, templateContext);
|
|
5472
5407
|
return {
|
|
5473
5408
|
html,
|
|
5474
5409
|
format: "mdx"
|
|
@@ -5563,7 +5498,7 @@ async function generateHash(content) {
|
|
|
5563
5498
|
return Math.abs(hash).toString(16).padStart(8, "0");
|
|
5564
5499
|
}
|
|
5565
5500
|
async function buildToolWidgetManifest(options) {
|
|
5566
|
-
const { toolName, uiConfig, schema, theme, sampleInput, sampleOutput, outputSchema, inputSchema } = options;
|
|
5501
|
+
const { toolName, uiConfig, schema, theme: _theme, sampleInput, sampleOutput, outputSchema, inputSchema } = options;
|
|
5567
5502
|
const uiType = isUIType(uiConfig.uiType) ? uiConfig.uiType : detectUIType(uiConfig.template);
|
|
5568
5503
|
const displayMode = uiConfig.displayMode ?? "inline";
|
|
5569
5504
|
const bundlingMode = uiConfig.bundlingMode ?? "static";
|
|
@@ -5701,7 +5636,7 @@ function ensureRenderersRegistered() {
|
|
|
5701
5636
|
return;
|
|
5702
5637
|
}
|
|
5703
5638
|
if (!rendererRegistry.has("mdx")) {
|
|
5704
|
-
rendererRegistry.register(
|
|
5639
|
+
rendererRegistry.register(mdxClientRenderer);
|
|
5705
5640
|
}
|
|
5706
5641
|
renderersInitialized = true;
|
|
5707
5642
|
}
|