@frontmcp/uipack 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +122 -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 +1885 -171
- 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 +6 -4
- 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} +1855 -170
- package/esm/bundler/{index.js → index.mjs} +6 -4
- package/esm/dependency/{index.js → index.mjs} +93 -121
- package/esm/handlebars/{index.js → index.mjs} +0 -1
- package/esm/{index.js → index.mjs} +2516 -830
- package/esm/package.json +7 -6
- package/esm/registry/{index.js → index.mjs} +196 -264
- package/esm/renderers/{index.js → index.mjs} +106 -200
- 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 +2545 -835
- 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 +196 -264
- 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 +110 -204
- 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/registry/index.js
CHANGED
|
@@ -34,9 +34,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
34
34
|
function getCachedScript(url) {
|
|
35
35
|
return scriptCache.get(url);
|
|
36
36
|
}
|
|
37
|
-
function isScriptCached(url) {
|
|
38
|
-
return scriptCache.has(url);
|
|
39
|
-
}
|
|
40
37
|
function buildFontPreconnect() {
|
|
41
38
|
return CDN.fonts.preconnect.map((url, i) => `<link rel="preconnect" href="${url}"${i > 0 ? " crossorigin" : ""}>`).join("\n ");
|
|
42
39
|
}
|
|
@@ -69,8 +66,9 @@ function buildCdnScripts(options = {}) {
|
|
|
69
66
|
const scripts = [];
|
|
70
67
|
if (inline) {
|
|
71
68
|
if (tailwind) {
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
const cached = getCachedScript(CDN.tailwind);
|
|
70
|
+
if (cached) {
|
|
71
|
+
scripts.push(buildInlineScriptTag(cached));
|
|
74
72
|
} else {
|
|
75
73
|
console.warn(
|
|
76
74
|
"[frontmcp/ui] Inline mode requested but Tailwind script not cached. Call fetchAndCacheScripts() first."
|
|
@@ -78,8 +76,9 @@ function buildCdnScripts(options = {}) {
|
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
78
|
if (htmx) {
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
const cached = getCachedScript(CDN.htmx.url);
|
|
80
|
+
if (cached) {
|
|
81
|
+
scripts.push(buildInlineScriptTag(cached));
|
|
83
82
|
} else {
|
|
84
83
|
console.warn(
|
|
85
84
|
"[frontmcp/ui] Inline mode requested but HTMX script not cached. Call fetchAndCacheScripts() first."
|
|
@@ -87,8 +86,9 @@ function buildCdnScripts(options = {}) {
|
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
if (alpine) {
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
const cached = getCachedScript(CDN.alpine.url);
|
|
90
|
+
if (cached) {
|
|
91
|
+
scripts.push(buildInlineScriptTag(cached));
|
|
92
92
|
} else {
|
|
93
93
|
console.warn(
|
|
94
94
|
"[frontmcp/ui] Inline mode requested but Alpine.js script not cached. Call fetchAndCacheScripts() first."
|
|
@@ -96,8 +96,9 @@ function buildCdnScripts(options = {}) {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
if (icons) {
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
const cached = getCachedScript(CDN.icons.url);
|
|
100
|
+
if (cached) {
|
|
101
|
+
scripts.push(buildInlineScriptTag(cached));
|
|
101
102
|
} else {
|
|
102
103
|
console.warn(
|
|
103
104
|
"[frontmcp/ui] Inline mode requested but Lucide icons script not cached. Call fetchAndCacheScripts() first."
|
|
@@ -192,11 +193,12 @@ var init_platforms = __esm({
|
|
|
192
193
|
id: "claude",
|
|
193
194
|
name: "Claude (Artifacts)",
|
|
194
195
|
supportsWidgets: true,
|
|
196
|
+
// Claude Artifacts support interactive widgets
|
|
195
197
|
supportsTailwind: true,
|
|
196
198
|
supportsHtmx: false,
|
|
197
199
|
// Network blocked, HTMX won't work for API calls
|
|
198
|
-
networkMode: "
|
|
199
|
-
scriptStrategy: "
|
|
200
|
+
networkMode: "limited",
|
|
201
|
+
scriptStrategy: "cdn",
|
|
200
202
|
maxInlineSize: 100 * 1024,
|
|
201
203
|
// 100KB limit for artifacts
|
|
202
204
|
cspRestrictions: ["script-src 'unsafe-inline'", "connect-src 'none'"],
|
|
@@ -462,17 +464,30 @@ function emitColorScale(lines, name, scale) {
|
|
|
462
464
|
if (value) lines.push(`--color-${name}-${shade}: ${value};`);
|
|
463
465
|
}
|
|
464
466
|
}
|
|
467
|
+
function emitColorWithOpacityVariants(lines, name, value) {
|
|
468
|
+
lines.push(`--color-${name}: ${value};`);
|
|
469
|
+
for (const opacity of OPACITY_VARIANTS) {
|
|
470
|
+
lines.push(`--color-${name}-${opacity}: color-mix(in oklch, ${value} ${opacity}%, transparent);`);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
function emitBrandColorWithVariants(lines, name, value) {
|
|
474
|
+
lines.push(`--color-${name}: ${value};`);
|
|
475
|
+
lines.push(`--color-${name}-hover: color-mix(in oklch, ${value} 85%, black);`);
|
|
476
|
+
for (const opacity of OPACITY_VARIANTS) {
|
|
477
|
+
lines.push(`--color-${name}-${opacity}: color-mix(in oklch, ${value} ${opacity}%, transparent);`);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
465
480
|
function buildThemeCss(theme) {
|
|
466
481
|
const lines = [];
|
|
467
482
|
const semantic = theme.colors.semantic;
|
|
468
483
|
if (typeof semantic.primary === "string") {
|
|
469
|
-
lines
|
|
484
|
+
emitBrandColorWithVariants(lines, "primary", semantic.primary);
|
|
470
485
|
} else if (semantic.primary) {
|
|
471
486
|
emitColorScale(lines, "primary", semantic.primary);
|
|
472
487
|
}
|
|
473
488
|
if (semantic.secondary) {
|
|
474
489
|
if (typeof semantic.secondary === "string") {
|
|
475
|
-
lines
|
|
490
|
+
emitBrandColorWithVariants(lines, "secondary", semantic.secondary);
|
|
476
491
|
} else {
|
|
477
492
|
emitColorScale(lines, "secondary", semantic.secondary);
|
|
478
493
|
}
|
|
@@ -491,10 +506,10 @@ function buildThemeCss(theme) {
|
|
|
491
506
|
emitColorScale(lines, "neutral", semantic.neutral);
|
|
492
507
|
}
|
|
493
508
|
}
|
|
494
|
-
if (semantic.success) lines
|
|
495
|
-
if (semantic.warning) lines
|
|
496
|
-
if (semantic.danger) lines
|
|
497
|
-
if (semantic.info) lines
|
|
509
|
+
if (semantic.success) emitColorWithOpacityVariants(lines, "success", semantic.success);
|
|
510
|
+
if (semantic.warning) emitColorWithOpacityVariants(lines, "warning", semantic.warning);
|
|
511
|
+
if (semantic.danger) emitColorWithOpacityVariants(lines, "danger", semantic.danger);
|
|
512
|
+
if (semantic.info) emitColorWithOpacityVariants(lines, "info", semantic.info);
|
|
498
513
|
const surface = theme.colors.surface;
|
|
499
514
|
if (surface?.background) lines.push(`--color-background: ${surface.background};`);
|
|
500
515
|
if (surface?.surface) lines.push(`--color-surface: ${surface.surface};`);
|
|
@@ -536,10 +551,11 @@ function buildThemeCss(theme) {
|
|
|
536
551
|
}
|
|
537
552
|
return lines.join("\n ");
|
|
538
553
|
}
|
|
554
|
+
var OPACITY_VARIANTS;
|
|
539
555
|
var init_theme = __esm({
|
|
540
556
|
"libs/uipack/src/theme/theme.ts"() {
|
|
541
557
|
"use strict";
|
|
542
|
-
|
|
558
|
+
OPACITY_VARIANTS = [10, 20, 30, 50, 70, 90];
|
|
543
559
|
}
|
|
544
560
|
});
|
|
545
561
|
|
|
@@ -554,13 +570,6 @@ var init_theme2 = __esm({
|
|
|
554
570
|
}
|
|
555
571
|
});
|
|
556
572
|
|
|
557
|
-
// libs/uipack/src/utils/safe-stringify.ts
|
|
558
|
-
var init_safe_stringify = __esm({
|
|
559
|
-
"libs/uipack/src/utils/safe-stringify.ts"() {
|
|
560
|
-
"use strict";
|
|
561
|
-
}
|
|
562
|
-
});
|
|
563
|
-
|
|
564
573
|
// libs/uipack/src/utils/escape-html.ts
|
|
565
574
|
function escapeHtml(str) {
|
|
566
575
|
if (str === null || str === void 0) {
|
|
@@ -569,6 +578,12 @@ function escapeHtml(str) {
|
|
|
569
578
|
const s = String(str);
|
|
570
579
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
571
580
|
}
|
|
581
|
+
function escapeJsString(str) {
|
|
582
|
+
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");
|
|
583
|
+
}
|
|
584
|
+
function escapeScriptClose(jsonString) {
|
|
585
|
+
return jsonString.replace(/<\//g, "<\\/");
|
|
586
|
+
}
|
|
572
587
|
var init_escape_html = __esm({
|
|
573
588
|
"libs/uipack/src/utils/escape-html.ts"() {
|
|
574
589
|
"use strict";
|
|
@@ -579,7 +594,6 @@ var init_escape_html = __esm({
|
|
|
579
594
|
var init_utils = __esm({
|
|
580
595
|
"libs/uipack/src/utils/index.ts"() {
|
|
581
596
|
"use strict";
|
|
582
|
-
init_safe_stringify();
|
|
583
597
|
init_escape_html();
|
|
584
598
|
}
|
|
585
599
|
});
|
|
@@ -1163,7 +1177,6 @@ var init_helpers = __esm({
|
|
|
1163
1177
|
// libs/uipack/src/handlebars/expression-extractor.ts
|
|
1164
1178
|
function extractExpressions(template) {
|
|
1165
1179
|
const expressions = [];
|
|
1166
|
-
const lines = template.split("\n");
|
|
1167
1180
|
const positionMap = buildPositionMap(template);
|
|
1168
1181
|
let match;
|
|
1169
1182
|
EXPRESSION_REGEX.lastIndex = 0;
|
|
@@ -1861,74 +1874,32 @@ var init_registry = __esm({
|
|
|
1861
1874
|
}
|
|
1862
1875
|
});
|
|
1863
1876
|
|
|
1864
|
-
// libs/uipack/src/renderers/mdx.renderer.ts
|
|
1865
|
-
function
|
|
1866
|
-
return
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
console.warn('[FrontMCP] React not available for MDX hydration');
|
|
1872
|
-
return;
|
|
1873
|
-
}
|
|
1874
|
-
|
|
1875
|
-
// Find all elements marked for MDX hydration
|
|
1876
|
-
document.querySelectorAll('[data-mdx-hydrate]').forEach(function(root) {
|
|
1877
|
-
var propsJson = root.getAttribute('data-props');
|
|
1878
|
-
var props = propsJson ? JSON.parse(propsJson) : {};
|
|
1879
|
-
|
|
1880
|
-
// MDX content is pre-rendered, hydration mainly attaches event handlers
|
|
1881
|
-
// For full interactivity, components need to be available client-side
|
|
1882
|
-
if (window.__frontmcp_mdx_content) {
|
|
1883
|
-
try {
|
|
1884
|
-
ReactDOM.hydrateRoot(root, React.createElement(
|
|
1885
|
-
window.__frontmcp_mdx_content,
|
|
1886
|
-
props
|
|
1887
|
-
));
|
|
1888
|
-
} catch (e) {
|
|
1889
|
-
console.error('[FrontMCP] MDX hydration failed', e);
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
});
|
|
1893
|
-
})();
|
|
1894
|
-
</script>
|
|
1895
|
-
`;
|
|
1877
|
+
// libs/uipack/src/renderers/mdx-client.renderer.ts
|
|
1878
|
+
function buildReactCdnUrls(version = "19") {
|
|
1879
|
+
return {
|
|
1880
|
+
react: `https://esm.sh/react@${version}`,
|
|
1881
|
+
reactDom: `https://esm.sh/react-dom@${version}/client`,
|
|
1882
|
+
jsxRuntime: `https://esm.sh/react@${version}/jsx-runtime`
|
|
1883
|
+
};
|
|
1896
1884
|
}
|
|
1897
|
-
var
|
|
1898
|
-
var
|
|
1899
|
-
"libs/uipack/src/renderers/mdx.renderer.ts"() {
|
|
1885
|
+
var DEFAULT_CDN, MdxClientRenderer, mdxClientRenderer;
|
|
1886
|
+
var init_mdx_client_renderer = __esm({
|
|
1887
|
+
"libs/uipack/src/renderers/mdx-client.renderer.ts"() {
|
|
1900
1888
|
"use strict";
|
|
1901
1889
|
init_detect();
|
|
1902
1890
|
init_hash();
|
|
1903
1891
|
init_cache();
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1892
|
+
init_utils();
|
|
1893
|
+
DEFAULT_CDN = {
|
|
1894
|
+
mdx: "https://esm.sh/@mdx-js/mdx@3",
|
|
1895
|
+
...buildReactCdnUrls("19")
|
|
1907
1896
|
};
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
`;
|
|
1913
|
-
MdxRenderer = class {
|
|
1914
|
-
type = "mdx";
|
|
1915
|
-
priority = 10;
|
|
1916
|
-
// Between HTML (0) and React (20)
|
|
1917
|
-
/**
|
|
1918
|
-
* Lazy-loaded modules.
|
|
1919
|
-
*/
|
|
1920
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1921
|
-
React = null;
|
|
1922
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1923
|
-
ReactDOMServer = null;
|
|
1924
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1925
|
-
jsxRuntime = null;
|
|
1926
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1927
|
-
mdxEvaluate = null;
|
|
1897
|
+
MdxClientRenderer = class {
|
|
1898
|
+
type = "mdx-client";
|
|
1899
|
+
priority = 8;
|
|
1900
|
+
// Lower than server-side MDX (10)
|
|
1928
1901
|
/**
|
|
1929
1902
|
* Check if this renderer can handle the given template.
|
|
1930
|
-
*
|
|
1931
|
-
* Accepts strings containing MDX syntax (Markdown + JSX).
|
|
1932
1903
|
*/
|
|
1933
1904
|
canHandle(template) {
|
|
1934
1905
|
if (typeof template !== "string") {
|
|
@@ -1937,11 +1908,9 @@ console.warn('[FrontMCP] MDX hydration not available on this platform.');
|
|
|
1937
1908
|
return containsMdxSyntax(template);
|
|
1938
1909
|
}
|
|
1939
1910
|
/**
|
|
1940
|
-
*
|
|
1941
|
-
*
|
|
1942
|
-
*
|
|
1943
|
-
* Note: For MDX, we use evaluate() which combines compile + run,
|
|
1944
|
-
* so this method just returns the source hash for caching purposes.
|
|
1911
|
+
* Prepare MDX template for rendering.
|
|
1912
|
+
* Caches the template hash for deduplication. Actual MDX compilation
|
|
1913
|
+
* happens client-side via CDN-loaded @mdx-js/mdx in the browser.
|
|
1945
1914
|
*/
|
|
1946
1915
|
async transpile(template, _options) {
|
|
1947
1916
|
const hash = hashString(template);
|
|
@@ -1951,7 +1920,6 @@ console.warn('[FrontMCP] MDX hydration not available on this platform.');
|
|
|
1951
1920
|
}
|
|
1952
1921
|
const transpileResult = {
|
|
1953
1922
|
code: template,
|
|
1954
|
-
// Store original MDX for evaluate()
|
|
1955
1923
|
hash,
|
|
1956
1924
|
cached: false
|
|
1957
1925
|
};
|
|
@@ -1959,37 +1927,20 @@ console.warn('[FrontMCP] MDX hydration not available on this platform.');
|
|
|
1959
1927
|
return transpileResult;
|
|
1960
1928
|
}
|
|
1961
1929
|
/**
|
|
1962
|
-
* Render MDX template to HTML
|
|
1930
|
+
* Render MDX template to HTML with CDN scripts.
|
|
1963
1931
|
*
|
|
1964
|
-
*
|
|
1965
|
-
*
|
|
1932
|
+
* The returned HTML includes:
|
|
1933
|
+
* - A container div for the rendered content
|
|
1934
|
+
* - Script tags that load React and MDX from CDN
|
|
1935
|
+
* - Inline script that compiles and renders the MDX
|
|
1966
1936
|
*/
|
|
1967
1937
|
async render(template, context, options) {
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
const cacheKey = `mdx-component:${templateHash}`;
|
|
1975
|
-
let Content = componentCache.get(cacheKey);
|
|
1976
|
-
if (!Content) {
|
|
1977
|
-
const result = await this.mdxEvaluate(template, {
|
|
1978
|
-
...this.jsxRuntime,
|
|
1979
|
-
Fragment: this.React.Fragment,
|
|
1980
|
-
development: false
|
|
1981
|
-
});
|
|
1982
|
-
Content = result.default;
|
|
1983
|
-
componentCache.set(cacheKey, Content);
|
|
1984
|
-
}
|
|
1985
|
-
const mdxComponents = {
|
|
1986
|
-
// User-provided components from tool config
|
|
1987
|
-
...options?.mdxComponents,
|
|
1988
|
-
// Wrapper that provides context to the content
|
|
1989
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1990
|
-
wrapper: ({ children }) => {
|
|
1991
|
-
return this.React.createElement("div", { className: "mdx-content" }, children);
|
|
1992
|
-
}
|
|
1938
|
+
const containerId = options?.containerId || "mdx-content";
|
|
1939
|
+
const showLoading = options?.showLoading !== false;
|
|
1940
|
+
const loadingMessage = options?.loadingMessage || "Loading...";
|
|
1941
|
+
const cdn = {
|
|
1942
|
+
...DEFAULT_CDN,
|
|
1943
|
+
...options?.cdn
|
|
1993
1944
|
};
|
|
1994
1945
|
const props = {
|
|
1995
1946
|
input: context.input,
|
|
@@ -1997,82 +1948,80 @@ console.warn('[FrontMCP] MDX hydration not available on this platform.');
|
|
|
1997
1948
|
structuredContent: context.structuredContent,
|
|
1998
1949
|
helpers: context.helpers
|
|
1999
1950
|
};
|
|
1951
|
+
const reservedProps = /* @__PURE__ */ new Set(["input", "output", "structuredContent", "helpers", "components"]);
|
|
1952
|
+
const outputProps = typeof context.output === "object" && context.output !== null ? Object.fromEntries(Object.entries(context.output).filter(([key]) => !reservedProps.has(key))) : {};
|
|
2000
1953
|
const spreadProps = {
|
|
2001
|
-
...
|
|
2002
|
-
...
|
|
1954
|
+
...outputProps,
|
|
1955
|
+
...props
|
|
2003
1956
|
};
|
|
2004
|
-
const
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
1957
|
+
const escapedMdx = escapeScriptClose(JSON.stringify(template));
|
|
1958
|
+
const escapedProps = escapeScriptClose(JSON.stringify(spreadProps));
|
|
1959
|
+
const safeContainerId = escapeJsString(containerId);
|
|
1960
|
+
const loadingHtml = showLoading ? `<div class="mdx-loading">${escapeHtml(loadingMessage)}</div>` : "";
|
|
1961
|
+
return `
|
|
1962
|
+
<div id="${escapeHtml(containerId)}">${loadingHtml}</div>
|
|
1963
|
+
<script type="module">
|
|
1964
|
+
(async function() {
|
|
1965
|
+
try {
|
|
1966
|
+
// Load dependencies from CDN
|
|
1967
|
+
const [
|
|
1968
|
+
{ evaluate },
|
|
1969
|
+
runtime,
|
|
1970
|
+
React,
|
|
1971
|
+
{ createRoot }
|
|
1972
|
+
] = await Promise.all([
|
|
1973
|
+
import('${cdn.mdx}'),
|
|
1974
|
+
import('${cdn.jsxRuntime}'),
|
|
1975
|
+
import('${cdn.react}'),
|
|
1976
|
+
import('${cdn.reactDom}')
|
|
1977
|
+
]);
|
|
1978
|
+
|
|
1979
|
+
// MDX content and props
|
|
1980
|
+
const mdxSource = ${escapedMdx};
|
|
1981
|
+
const props = ${escapedProps};
|
|
1982
|
+
|
|
1983
|
+
// Compile and evaluate MDX
|
|
1984
|
+
const { default: Content } = await evaluate(mdxSource, {
|
|
1985
|
+
...runtime,
|
|
1986
|
+
Fragment: React.Fragment,
|
|
1987
|
+
development: false
|
|
1988
|
+
});
|
|
1989
|
+
|
|
1990
|
+
// Render to DOM
|
|
1991
|
+
const container = document.getElementById('${safeContainerId}');
|
|
1992
|
+
if (container) {
|
|
1993
|
+
const root = createRoot(container);
|
|
1994
|
+
root.render(React.createElement(Content, props));
|
|
1995
|
+
}
|
|
1996
|
+
} catch (error) {
|
|
1997
|
+
console.error('[FrontMCP] MDX client rendering failed:', error);
|
|
1998
|
+
const container = document.getElementById('${safeContainerId}');
|
|
1999
|
+
if (container) {
|
|
2000
|
+
container.innerHTML = '<div class="mdx-error">Failed to render MDX content</div>';
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
})();
|
|
2004
|
+
</script>
|
|
2005
|
+
`;
|
|
2014
2006
|
}
|
|
2015
2007
|
/**
|
|
2016
|
-
* Get runtime scripts for client
|
|
2008
|
+
* Get runtime scripts - not needed for client renderer since scripts are inline.
|
|
2017
2009
|
*/
|
|
2018
2010
|
getRuntimeScripts(platform) {
|
|
2019
2011
|
if (platform.networkMode === "blocked") {
|
|
2020
2012
|
return {
|
|
2021
2013
|
headScripts: "",
|
|
2022
|
-
inlineScripts:
|
|
2014
|
+
inlineScripts: `console.warn('[FrontMCP] Client-side MDX rendering requires network access. Use @frontmcp/ui for SSR.');`,
|
|
2023
2015
|
isInline: true
|
|
2024
2016
|
};
|
|
2025
2017
|
}
|
|
2026
2018
|
return {
|
|
2027
|
-
headScripts:
|
|
2028
|
-
<script crossorigin src="${REACT_CDN.react}"></script>
|
|
2029
|
-
<script crossorigin src="${REACT_CDN.reactDom}"></script>
|
|
2030
|
-
`,
|
|
2019
|
+
headScripts: "",
|
|
2031
2020
|
isInline: false
|
|
2032
2021
|
};
|
|
2033
2022
|
}
|
|
2034
|
-
/**
|
|
2035
|
-
* Load React and ReactDOMServer modules.
|
|
2036
|
-
*/
|
|
2037
|
-
async loadReact() {
|
|
2038
|
-
if (this.React && this.ReactDOMServer && this.jsxRuntime) {
|
|
2039
|
-
return;
|
|
2040
|
-
}
|
|
2041
|
-
try {
|
|
2042
|
-
const [react, reactDomServer, jsxRuntime] = await Promise.all([
|
|
2043
|
-
import("react"),
|
|
2044
|
-
import("react-dom/server"),
|
|
2045
|
-
import("react/jsx-runtime")
|
|
2046
|
-
]);
|
|
2047
|
-
this.React = react;
|
|
2048
|
-
this.ReactDOMServer = reactDomServer;
|
|
2049
|
-
this.jsxRuntime = jsxRuntime;
|
|
2050
|
-
} catch {
|
|
2051
|
-
throw new Error("React is required for MdxRenderer. Install react and react-dom: npm install react react-dom");
|
|
2052
|
-
}
|
|
2053
|
-
}
|
|
2054
|
-
/**
|
|
2055
|
-
* Load @mdx-js/mdx evaluate function.
|
|
2056
|
-
*
|
|
2057
|
-
* evaluate() is the cleanest way to run MDX - it combines
|
|
2058
|
-
* compile and run in a single step, handling all the runtime
|
|
2059
|
-
* injection automatically.
|
|
2060
|
-
*/
|
|
2061
|
-
async loadMdx() {
|
|
2062
|
-
if (this.mdxEvaluate) {
|
|
2063
|
-
return;
|
|
2064
|
-
}
|
|
2065
|
-
try {
|
|
2066
|
-
const mdx = await import("@mdx-js/mdx");
|
|
2067
|
-
this.mdxEvaluate = mdx.evaluate;
|
|
2068
|
-
} catch {
|
|
2069
|
-
console.warn(
|
|
2070
|
-
"[@frontmcp/ui] @mdx-js/mdx not available. MDX rendering disabled. Install @mdx-js/mdx to enable: npm install @mdx-js/mdx"
|
|
2071
|
-
);
|
|
2072
|
-
}
|
|
2073
|
-
}
|
|
2074
2023
|
};
|
|
2075
|
-
|
|
2024
|
+
mdxClientRenderer = new MdxClientRenderer();
|
|
2076
2025
|
}
|
|
2077
2026
|
});
|
|
2078
2027
|
|
|
@@ -2137,43 +2086,15 @@ async function isSwcAvailable() {
|
|
|
2137
2086
|
const transform = await loadSwcTransform();
|
|
2138
2087
|
return transform !== null;
|
|
2139
2088
|
}
|
|
2140
|
-
async function executeTranspiledCode(
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
React = await import("react");
|
|
2145
|
-
jsxRuntime = await import("react/jsx-runtime");
|
|
2146
|
-
} catch {
|
|
2147
|
-
throw new Error("React is required for JSX templates. Install react: npm install react react-dom");
|
|
2148
|
-
}
|
|
2149
|
-
const exports2 = {};
|
|
2150
|
-
const module2 = { exports: exports2 };
|
|
2151
|
-
const require2 = (id) => {
|
|
2152
|
-
switch (id) {
|
|
2153
|
-
case "react":
|
|
2154
|
-
return React;
|
|
2155
|
-
case "react/jsx-runtime":
|
|
2156
|
-
return jsxRuntime;
|
|
2157
|
-
case "react/jsx-dev-runtime":
|
|
2158
|
-
return jsxRuntime;
|
|
2159
|
-
default:
|
|
2160
|
-
if (context[id]) {
|
|
2161
|
-
return context[id];
|
|
2162
|
-
}
|
|
2163
|
-
throw new Error(`Module '${id}' not available in JSX template context`);
|
|
2164
|
-
}
|
|
2165
|
-
};
|
|
2166
|
-
try {
|
|
2167
|
-
const fn = new Function("exports", "require", "module", "__filename", "__dirname", "React", "context", code);
|
|
2168
|
-
fn(exports2, require2, module2, "template.js", "/", React, context);
|
|
2169
|
-
return module2.exports["default"] || module2.exports[Object.keys(module2.exports)[0]] || module2.exports;
|
|
2170
|
-
} catch (error) {
|
|
2171
|
-
throw new Error(`Failed to execute transpiled JSX: ${error instanceof Error ? error.message : String(error)}`);
|
|
2172
|
-
}
|
|
2089
|
+
async function executeTranspiledCode(_code, _context = {}) {
|
|
2090
|
+
throw new Error(
|
|
2091
|
+
'executeTranspiledCode has been moved to @frontmcp/ui/renderers. Install @frontmcp/ui and import from there: import { executeTranspiledCode } from "@frontmcp/ui/renderers"'
|
|
2092
|
+
);
|
|
2173
2093
|
}
|
|
2174
|
-
async function transpileAndExecute(
|
|
2175
|
-
|
|
2176
|
-
|
|
2094
|
+
async function transpileAndExecute(_source, _context = {}) {
|
|
2095
|
+
throw new Error(
|
|
2096
|
+
'transpileAndExecute has been moved to @frontmcp/ui/renderers. Install @frontmcp/ui and import from there: import { transpileAndExecute } from "@frontmcp/ui/renderers"'
|
|
2097
|
+
);
|
|
2177
2098
|
}
|
|
2178
2099
|
var DEFAULT_SWC_OPTIONS, swcTransform;
|
|
2179
2100
|
var init_transpiler = __esm({
|
|
@@ -2205,10 +2126,11 @@ var init_utils2 = __esm({
|
|
|
2205
2126
|
var renderers_exports = {};
|
|
2206
2127
|
__export(renderers_exports, {
|
|
2207
2128
|
HtmlRenderer: () => HtmlRenderer,
|
|
2208
|
-
|
|
2129
|
+
MdxClientRenderer: () => MdxClientRenderer,
|
|
2209
2130
|
RendererRegistry: () => RendererRegistry,
|
|
2210
2131
|
TranspileCache: () => TranspileCache,
|
|
2211
|
-
|
|
2132
|
+
buildReactCdnUrls: () => buildReactCdnUrls,
|
|
2133
|
+
componentCache: () => componentCache,
|
|
2212
2134
|
containsJsx: () => containsJsx,
|
|
2213
2135
|
containsMdxSyntax: () => containsMdxSyntax,
|
|
2214
2136
|
detectTemplateType: () => detectTemplateType,
|
|
@@ -2221,8 +2143,7 @@ __export(renderers_exports, {
|
|
|
2221
2143
|
isReactComponent: () => isReactComponent,
|
|
2222
2144
|
isSwcAvailable: () => isSwcAvailable,
|
|
2223
2145
|
isTemplateBuilderFunction: () => isTemplateBuilderFunction,
|
|
2224
|
-
|
|
2225
|
-
renderCache: () => renderCache,
|
|
2146
|
+
mdxClientRenderer: () => mdxClientRenderer,
|
|
2226
2147
|
rendererRegistry: () => rendererRegistry,
|
|
2227
2148
|
transpileAndExecute: () => transpileAndExecute,
|
|
2228
2149
|
transpileCache: () => transpileCache,
|
|
@@ -2234,7 +2155,7 @@ var init_renderers = __esm({
|
|
|
2234
2155
|
init_cache();
|
|
2235
2156
|
init_registry();
|
|
2236
2157
|
init_html_renderer();
|
|
2237
|
-
|
|
2158
|
+
init_mdx_client_renderer();
|
|
2238
2159
|
init_utils2();
|
|
2239
2160
|
}
|
|
2240
2161
|
});
|
|
@@ -3121,9 +3042,6 @@ var BRIDGE_SCRIPT_TAGS = {
|
|
|
3121
3042
|
gemini: `<script>${generatePlatformBundle("gemini")}</script>`
|
|
3122
3043
|
};
|
|
3123
3044
|
|
|
3124
|
-
// libs/uipack/src/runtime/mcp-bridge.ts
|
|
3125
|
-
var FRONTMCP_BRIDGE_RUNTIME = BRIDGE_SCRIPT_TAGS.universal;
|
|
3126
|
-
|
|
3127
3045
|
// libs/uipack/src/runtime/csp.ts
|
|
3128
3046
|
var DEFAULT_CDN_DOMAINS = [
|
|
3129
3047
|
"https://cdn.jsdelivr.net",
|
|
@@ -4569,12 +4487,12 @@ function containsMdxSyntax2(source) {
|
|
|
4569
4487
|
}
|
|
4570
4488
|
async function renderMdxContent(mdxContent, context, mdxComponents) {
|
|
4571
4489
|
try {
|
|
4572
|
-
const {
|
|
4573
|
-
const html = await
|
|
4490
|
+
const { mdxClientRenderer: mdxClientRenderer2 } = await Promise.resolve().then(() => (init_renderers(), renderers_exports));
|
|
4491
|
+
const html = await mdxClientRenderer2.render(mdxContent, context, { mdxComponents });
|
|
4574
4492
|
return html;
|
|
4575
4493
|
} catch (error) {
|
|
4576
4494
|
console.error(
|
|
4577
|
-
"[@frontmcp/
|
|
4495
|
+
"[@frontmcp/uipack] MDX rendering failed:",
|
|
4578
4496
|
error instanceof Error ? error.stack || error.message : String(error)
|
|
4579
4497
|
);
|
|
4580
4498
|
const escaped = mdxContent.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
@@ -4628,13 +4546,17 @@ async function renderToolTemplateAsync(options) {
|
|
|
4628
4546
|
if (isReactComponent2(template)) {
|
|
4629
4547
|
const componentName = template.displayName || template.name || "UnknownComponent";
|
|
4630
4548
|
try {
|
|
4549
|
+
const reactPkg = "react";
|
|
4550
|
+
const reactDomServerPkg = "react-dom/server";
|
|
4631
4551
|
const [React, ReactDOMServer] = await Promise.all([
|
|
4632
|
-
import(
|
|
4633
|
-
throw new Error(
|
|
4552
|
+
import(reactPkg).catch(() => {
|
|
4553
|
+
throw new Error(
|
|
4554
|
+
"React is required for React component templates. Either install react as a dependency, or use @frontmcp/ui for React component support."
|
|
4555
|
+
);
|
|
4634
4556
|
}),
|
|
4635
|
-
import(
|
|
4557
|
+
import(reactDomServerPkg).catch(() => {
|
|
4636
4558
|
throw new Error(
|
|
4637
|
-
"react-dom/server is required for React component templates.
|
|
4559
|
+
"react-dom/server is required for React component templates. Either install react-dom as a dependency, or use @frontmcp/ui for React component support."
|
|
4638
4560
|
);
|
|
4639
4561
|
})
|
|
4640
4562
|
]);
|
|
@@ -4738,20 +4660,19 @@ function buildOpenAIMeta(meta, uiConfig) {
|
|
|
4738
4660
|
}
|
|
4739
4661
|
return meta;
|
|
4740
4662
|
}
|
|
4741
|
-
function buildOpenAICSP(csp) {
|
|
4742
|
-
const result = {};
|
|
4743
|
-
if (csp.connectDomains?.length) {
|
|
4744
|
-
result.connect_domains = csp.connectDomains;
|
|
4745
|
-
}
|
|
4746
|
-
if (csp.resourceDomains?.length) {
|
|
4747
|
-
result.resource_domains = csp.resourceDomains;
|
|
4748
|
-
}
|
|
4749
|
-
return result;
|
|
4750
|
-
}
|
|
4751
4663
|
function buildClaudeMeta(meta, uiConfig) {
|
|
4752
4664
|
if (uiConfig.widgetDescription) {
|
|
4753
4665
|
meta["claude/widgetDescription"] = uiConfig.widgetDescription;
|
|
4754
4666
|
}
|
|
4667
|
+
if (uiConfig.displayMode) {
|
|
4668
|
+
meta["claude/displayMode"] = uiConfig.displayMode;
|
|
4669
|
+
}
|
|
4670
|
+
if (uiConfig.widgetAccessible) {
|
|
4671
|
+
meta["claude/widgetAccessible"] = true;
|
|
4672
|
+
}
|
|
4673
|
+
if (uiConfig.prefersBorder !== void 0) {
|
|
4674
|
+
meta["claude/prefersBorder"] = uiConfig.prefersBorder;
|
|
4675
|
+
}
|
|
4755
4676
|
return meta;
|
|
4756
4677
|
}
|
|
4757
4678
|
function buildGeminiMeta(meta, uiConfig) {
|
|
@@ -4766,12 +4687,34 @@ function buildIDEMeta(meta, uiConfig) {
|
|
|
4766
4687
|
}
|
|
4767
4688
|
return meta;
|
|
4768
4689
|
}
|
|
4690
|
+
function buildFrontMCPCSP(csp) {
|
|
4691
|
+
const result = {};
|
|
4692
|
+
if (csp.connectDomains?.length) {
|
|
4693
|
+
result.connectDomains = csp.connectDomains;
|
|
4694
|
+
}
|
|
4695
|
+
if (csp.resourceDomains?.length) {
|
|
4696
|
+
result.resourceDomains = csp.resourceDomains;
|
|
4697
|
+
}
|
|
4698
|
+
return result;
|
|
4699
|
+
}
|
|
4769
4700
|
function buildGenericMeta(meta, uiConfig) {
|
|
4770
4701
|
if (uiConfig.widgetAccessible) {
|
|
4771
|
-
meta["
|
|
4702
|
+
meta["frontmcp/widgetAccessible"] = true;
|
|
4772
4703
|
}
|
|
4773
4704
|
if (uiConfig.csp) {
|
|
4774
|
-
meta["
|
|
4705
|
+
meta["frontmcp/widgetCSP"] = buildFrontMCPCSP(uiConfig.csp);
|
|
4706
|
+
}
|
|
4707
|
+
if (uiConfig.displayMode) {
|
|
4708
|
+
meta["frontmcp/displayMode"] = uiConfig.displayMode;
|
|
4709
|
+
}
|
|
4710
|
+
if (uiConfig.widgetDescription) {
|
|
4711
|
+
meta["frontmcp/widgetDescription"] = uiConfig.widgetDescription;
|
|
4712
|
+
}
|
|
4713
|
+
if (uiConfig.prefersBorder !== void 0) {
|
|
4714
|
+
meta["frontmcp/prefersBorder"] = uiConfig.prefersBorder;
|
|
4715
|
+
}
|
|
4716
|
+
if (uiConfig.sandboxDomain) {
|
|
4717
|
+
meta["frontmcp/domain"] = uiConfig.sandboxDomain;
|
|
4775
4718
|
}
|
|
4776
4719
|
return meta;
|
|
4777
4720
|
}
|
|
@@ -4812,14 +4755,6 @@ function buildExtAppsMeta(meta, uiConfig) {
|
|
|
4812
4755
|
return meta;
|
|
4813
4756
|
}
|
|
4814
4757
|
|
|
4815
|
-
// libs/uipack/src/adapters/response-builder.ts
|
|
4816
|
-
init_utils();
|
|
4817
|
-
|
|
4818
|
-
// libs/uipack/src/build/index.ts
|
|
4819
|
-
init_registry();
|
|
4820
|
-
init_renderers();
|
|
4821
|
-
init_theme2();
|
|
4822
|
-
|
|
4823
4758
|
// libs/uipack/src/types/ui-runtime.ts
|
|
4824
4759
|
function isUIType(value) {
|
|
4825
4760
|
return typeof value === "string" && ["html", "react", "mdx", "markdown", "auto"].includes(value);
|
|
@@ -4856,7 +4791,7 @@ var DEFAULT_CSP_BY_TYPE = {
|
|
|
4856
4791
|
};
|
|
4857
4792
|
|
|
4858
4793
|
// libs/uipack/src/build/cdn-resources.ts
|
|
4859
|
-
var
|
|
4794
|
+
var REACT_CDN = {
|
|
4860
4795
|
url: "https://esm.sh/react@19",
|
|
4861
4796
|
crossorigin: "anonymous"
|
|
4862
4797
|
};
|
|
@@ -4889,13 +4824,13 @@ function getDefaultAssets(uiType, mode = "cdn") {
|
|
|
4889
4824
|
case "react":
|
|
4890
4825
|
return {
|
|
4891
4826
|
...baseAssets,
|
|
4892
|
-
react:
|
|
4827
|
+
react: REACT_CDN,
|
|
4893
4828
|
reactDom: REACT_DOM_CDN
|
|
4894
4829
|
};
|
|
4895
4830
|
case "mdx":
|
|
4896
4831
|
return {
|
|
4897
4832
|
...baseAssets,
|
|
4898
|
-
react:
|
|
4833
|
+
react: REACT_CDN,
|
|
4899
4834
|
reactDom: REACT_DOM_CDN,
|
|
4900
4835
|
mdxRuntime: MDX_RUNTIME_CDN,
|
|
4901
4836
|
markdown: MARKED_CDN
|
|
@@ -4913,7 +4848,7 @@ function getDefaultAssets(uiType, mode = "cdn") {
|
|
|
4913
4848
|
case "auto":
|
|
4914
4849
|
return {
|
|
4915
4850
|
...baseAssets,
|
|
4916
|
-
react:
|
|
4851
|
+
react: REACT_CDN,
|
|
4917
4852
|
reactDom: REACT_DOM_CDN,
|
|
4918
4853
|
markdown: MARKED_CDN,
|
|
4919
4854
|
handlebars: HANDLEBARS_CDN
|
|
@@ -4963,9 +4898,6 @@ function detectFormatFromPath(pathOrUrl) {
|
|
|
4963
4898
|
return "html";
|
|
4964
4899
|
}
|
|
4965
4900
|
|
|
4966
|
-
// libs/uipack/src/validation/error-box.ts
|
|
4967
|
-
init_utils();
|
|
4968
|
-
|
|
4969
4901
|
// libs/uipack/src/validation/schema-paths.ts
|
|
4970
4902
|
var import_zod = require("zod");
|
|
4971
4903
|
function extractSchemaPaths(schema, prefix = "output", options = {}) {
|
|
@@ -5397,7 +5329,7 @@ var URL_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
|
5397
5329
|
|
|
5398
5330
|
// libs/uipack/src/dependency/template-processor.ts
|
|
5399
5331
|
init_handlebars();
|
|
5400
|
-
|
|
5332
|
+
init_mdx_client_renderer();
|
|
5401
5333
|
init_utils();
|
|
5402
5334
|
function safeInputToRecord(input) {
|
|
5403
5335
|
if (input && typeof input === "object" && !Array.isArray(input)) {
|
|
@@ -5510,7 +5442,7 @@ async function processTemplate(resolved, options) {
|
|
|
5510
5442
|
structuredContent: context.structuredContent,
|
|
5511
5443
|
helpers: defaultHelpers
|
|
5512
5444
|
};
|
|
5513
|
-
const html = await
|
|
5445
|
+
const html = await mdxClientRenderer.render(processedContent, templateContext);
|
|
5514
5446
|
return {
|
|
5515
5447
|
html,
|
|
5516
5448
|
format: "mdx"
|
|
@@ -5605,7 +5537,7 @@ async function generateHash(content) {
|
|
|
5605
5537
|
return Math.abs(hash).toString(16).padStart(8, "0");
|
|
5606
5538
|
}
|
|
5607
5539
|
async function buildToolWidgetManifest(options) {
|
|
5608
|
-
const { toolName, uiConfig, schema, theme, sampleInput, sampleOutput, outputSchema, inputSchema } = options;
|
|
5540
|
+
const { toolName, uiConfig, schema, theme: _theme, sampleInput, sampleOutput, outputSchema, inputSchema } = options;
|
|
5609
5541
|
const uiType = isUIType(uiConfig.uiType) ? uiConfig.uiType : detectUIType(uiConfig.template);
|
|
5610
5542
|
const displayMode = uiConfig.displayMode ?? "inline";
|
|
5611
5543
|
const bundlingMode = uiConfig.bundlingMode ?? "static";
|
|
@@ -5743,7 +5675,7 @@ function ensureRenderersRegistered() {
|
|
|
5743
5675
|
return;
|
|
5744
5676
|
}
|
|
5745
5677
|
if (!rendererRegistry.has("mdx")) {
|
|
5746
|
-
rendererRegistry.register(
|
|
5678
|
+
rendererRegistry.register(mdxClientRenderer);
|
|
5747
5679
|
}
|
|
5748
5680
|
renderersInitialized = true;
|
|
5749
5681
|
}
|