@frontmcp/uipack 1.10.8 → 1.10.9-rc.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/adapters/index.js +29 -2040
- package/bridge-runtime/index.js +11 -217
- package/component/index.js +24 -1469
- package/esm/adapters/index.mjs +29 -2006
- package/esm/bridge-runtime/index.mjs +11 -185
- package/esm/component/index.mjs +24 -1439
- package/esm/index.mjs +150 -3483
- package/esm/package.json +2 -2
- package/esm/resolver/index.mjs +2 -660
- package/esm/shell/index.mjs +16 -750
- package/esm/types/index.mjs +1 -75
- package/esm/typings/index.mjs +3 -971
- package/esm/utils/index.mjs +1 -66
- package/index.js +150 -3605
- package/package.json +2 -2
- package/resolver/index.js +2 -707
- package/shell/index.js +16 -803
- package/types/index.js +1 -108
- package/typings/index.js +3 -1032
- package/utils/index.js +1 -96
|
@@ -1,84 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var WIDGET_CALL_META_KEY = "frontmcp/widgetCall";
|
|
3
|
-
var MCP_APPS_DISPLAY_MODES = ["inline", "fullscreen", "pip"];
|
|
4
|
-
function generateBridgeIIFE(options = {}) {
|
|
5
|
-
const { debug = false, trustedOrigins = [], minify = false } = options;
|
|
6
|
-
const adapters = options.adapters || ["openai", "ext-apps", "claude", "gemini", "generic"];
|
|
7
|
-
const parts = [];
|
|
8
|
-
parts.push("(function() {");
|
|
9
|
-
parts.push('"use strict";');
|
|
10
|
-
parts.push("");
|
|
11
|
-
if (debug) {
|
|
12
|
-
parts.push('function log(msg) { console.log("[FrontMcpBridge] " + msg); }');
|
|
13
|
-
} else {
|
|
14
|
-
parts.push("function log() {}");
|
|
15
|
-
}
|
|
16
|
-
parts.push("");
|
|
17
|
-
parts.push("var DEFAULT_SAFE_AREA = { top: 0, bottom: 0, left: 0, right: 0 };");
|
|
18
|
-
parts.push("");
|
|
19
|
-
parts.push(generateContextDetection());
|
|
20
|
-
parts.push("");
|
|
21
|
-
parts.push(generateBaseCapabilities());
|
|
22
|
-
parts.push("");
|
|
23
|
-
if (adapters.includes("openai")) {
|
|
24
|
-
parts.push(generateOpenAIAdapter());
|
|
25
|
-
parts.push("");
|
|
26
|
-
}
|
|
27
|
-
if (adapters.includes("ext-apps")) {
|
|
28
|
-
parts.push(generateExtAppsAdapter(trustedOrigins));
|
|
29
|
-
parts.push("");
|
|
30
|
-
}
|
|
31
|
-
if (adapters.includes("claude")) {
|
|
32
|
-
parts.push(generateClaudeAdapter());
|
|
33
|
-
parts.push("");
|
|
34
|
-
}
|
|
35
|
-
if (adapters.includes("gemini")) {
|
|
36
|
-
parts.push(generateGeminiAdapter());
|
|
37
|
-
parts.push("");
|
|
38
|
-
}
|
|
39
|
-
if (adapters.includes("generic")) {
|
|
40
|
-
parts.push(generateGenericAdapter());
|
|
41
|
-
parts.push("");
|
|
42
|
-
}
|
|
43
|
-
parts.push(generatePlatformDetection(adapters));
|
|
44
|
-
parts.push("");
|
|
45
|
-
parts.push(generateBridgeClass());
|
|
46
|
-
parts.push("");
|
|
47
|
-
parts.push("var bridge = new FrontMcpBridge();");
|
|
48
|
-
parts.push("bridge.initialize().then(function() {");
|
|
49
|
-
parts.push(' log("Bridge initialized with adapter: " + bridge.adapterId);');
|
|
50
|
-
parts.push(' window.dispatchEvent(new CustomEvent("bridge:ready", { detail: { adapter: bridge.adapterId } }));');
|
|
51
|
-
parts.push(" if (window.__mcpDisplayMode) bridge.requestDisplayMode(window.__mcpDisplayMode).catch(function() {});");
|
|
52
|
-
parts.push("}).catch(function(err) {");
|
|
53
|
-
parts.push(' console.error("[FrontMcpBridge] Init failed:", err);');
|
|
54
|
-
parts.push(' window.dispatchEvent(new CustomEvent("bridge:error", { detail: { error: err } }));');
|
|
55
|
-
parts.push("});");
|
|
56
|
-
parts.push("");
|
|
57
|
-
parts.push("window.FrontMcpBridge = bridge;");
|
|
58
|
-
parts.push("");
|
|
59
|
-
parts.push(generateAutoResize());
|
|
60
|
-
parts.push("function __showLoading() {");
|
|
61
|
-
parts.push(' var root = document.getElementById("root");');
|
|
62
|
-
parts.push(" if (root && !root.hasChildNodes()) {");
|
|
63
|
-
parts.push(
|
|
64
|
-
` root.innerHTML = '<div style="display:flex;align-items:center;justify-content:center;padding:2rem;color:#6b7280;font-family:system-ui,sans-serif"><div style="text-align:center"><div style="width:24px;height:24px;border:2px solid #e5e7eb;border-top-color:#3b82f6;border-radius:50%;animation:__spin 0.6s linear infinite;margin:0 auto 12px"></div><div style="font-size:0.875rem">Loading widget...</div></div></div><style>@keyframes __spin{to{transform:rotate(360deg)}}</style>';`
|
|
65
|
-
);
|
|
66
|
-
parts.push(" }");
|
|
67
|
-
parts.push("}");
|
|
68
|
-
parts.push('if (document.readyState === "loading") {');
|
|
69
|
-
parts.push(' document.addEventListener("DOMContentLoaded", __showLoading);');
|
|
70
|
-
parts.push("} else {");
|
|
71
|
-
parts.push(" __showLoading();");
|
|
72
|
-
parts.push("}");
|
|
73
|
-
parts.push("})();");
|
|
74
|
-
const code = parts.join("\n");
|
|
75
|
-
if (minify) {
|
|
76
|
-
return minifyJS(code);
|
|
77
|
-
}
|
|
78
|
-
return code;
|
|
79
|
-
}
|
|
80
|
-
function generateAutoResize() {
|
|
81
|
-
return `
|
|
1
|
+
var WIDGET_CALL_META_KEY="frontmcp/widgetCall";var MCP_APPS_DISPLAY_MODES=["inline","fullscreen","pip"];function generateBridgeIIFE(options={}){const{debug=false,trustedOrigins=[],minify=false}=options;const adapters=options.adapters||["openai","ext-apps","claude","gemini","generic"];const parts=[];parts.push("(function() {");parts.push('"use strict";');parts.push("");if(debug){parts.push('function log(msg) { console.log("[FrontMcpBridge] " + msg); }')}else{parts.push("function log() {}")}parts.push("");parts.push("var DEFAULT_SAFE_AREA = { top: 0, bottom: 0, left: 0, right: 0 };");parts.push("");parts.push(generateContextDetection());parts.push("");parts.push(generateBaseCapabilities());parts.push("");if(adapters.includes("openai")){parts.push(generateOpenAIAdapter());parts.push("")}if(adapters.includes("ext-apps")){parts.push(generateExtAppsAdapter(trustedOrigins));parts.push("")}if(adapters.includes("claude")){parts.push(generateClaudeAdapter());parts.push("")}if(adapters.includes("gemini")){parts.push(generateGeminiAdapter());parts.push("")}if(adapters.includes("generic")){parts.push(generateGenericAdapter());parts.push("")}parts.push(generatePlatformDetection(adapters));parts.push("");parts.push(generateBridgeClass());parts.push("");parts.push("var bridge = new FrontMcpBridge();");parts.push("bridge.initialize().then(function() {");parts.push(' log("Bridge initialized with adapter: " + bridge.adapterId);');parts.push(' window.dispatchEvent(new CustomEvent("bridge:ready", { detail: { adapter: bridge.adapterId } }));');parts.push(" if (window.__mcpDisplayMode) bridge.requestDisplayMode(window.__mcpDisplayMode).catch(function() {});");parts.push("}).catch(function(err) {");parts.push(' console.error("[FrontMcpBridge] Init failed:", err);');parts.push(' window.dispatchEvent(new CustomEvent("bridge:error", { detail: { error: err } }));');parts.push("});");parts.push("");parts.push("window.FrontMcpBridge = bridge;");parts.push("");parts.push(generateAutoResize());parts.push("function __showLoading() {");parts.push(' var root = document.getElementById("root");');parts.push(" if (root && !root.hasChildNodes()) {");parts.push(` root.innerHTML = '<div style="display:flex;align-items:center;justify-content:center;padding:2rem;color:#6b7280;font-family:system-ui,sans-serif"><div style="text-align:center"><div style="width:24px;height:24px;border:2px solid #e5e7eb;border-top-color:#3b82f6;border-radius:50%;animation:__spin 0.6s linear infinite;margin:0 auto 12px"></div><div style="font-size:0.875rem">Loading widget...</div></div></div><style>@keyframes __spin{to{transform:rotate(360deg)}}</style>';`);parts.push(" }");parts.push("}");parts.push('if (document.readyState === "loading") {');parts.push(' document.addEventListener("DOMContentLoaded", __showLoading);');parts.push("} else {");parts.push(" __showLoading();");parts.push("}");parts.push("})();");const code=parts.join("\n");if(minify){return minifyJS(code)}return code}function generateAutoResize(){return`
|
|
82
2
|
function __applySizingCss(sizing) {
|
|
83
3
|
if (typeof document === 'undefined' || !document.documentElement) return;
|
|
84
4
|
function toLen(v) { return typeof v === 'number' ? v + 'px' : v; }
|
|
@@ -213,10 +133,7 @@ function __initAutoResize() {
|
|
|
213
133
|
}
|
|
214
134
|
}
|
|
215
135
|
__initAutoResize();
|
|
216
|
-
`.trim()
|
|
217
|
-
}
|
|
218
|
-
function generateContextDetection() {
|
|
219
|
-
return `
|
|
136
|
+
`.trim()}function generateContextDetection(){return`
|
|
220
137
|
function detectTheme() {
|
|
221
138
|
if (typeof window !== 'undefined' && window.matchMedia) {
|
|
222
139
|
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
@@ -303,10 +220,7 @@ function readInjectedData() {
|
|
|
303
220
|
}
|
|
304
221
|
return data;
|
|
305
222
|
}
|
|
306
|
-
`.trim()
|
|
307
|
-
}
|
|
308
|
-
function generateBaseCapabilities() {
|
|
309
|
-
return `
|
|
223
|
+
`.trim()}function generateBaseCapabilities(){return`
|
|
310
224
|
var DEFAULT_CAPABILITIES = {
|
|
311
225
|
canCallTools: false,
|
|
312
226
|
canSendMessages: false,
|
|
@@ -316,10 +230,7 @@ var DEFAULT_CAPABILITIES = {
|
|
|
316
230
|
supportsDisplayModes: false,
|
|
317
231
|
supportsTheme: true
|
|
318
232
|
};
|
|
319
|
-
`.trim()
|
|
320
|
-
}
|
|
321
|
-
function generateOpenAIAdapter() {
|
|
322
|
-
return `
|
|
233
|
+
`.trim()}function generateOpenAIAdapter(){return`
|
|
323
234
|
var OpenAIAdapter = {
|
|
324
235
|
id: 'openai',
|
|
325
236
|
name: 'OpenAI ChatGPT',
|
|
@@ -404,11 +315,7 @@ var OpenAIAdapter = {
|
|
|
404
315
|
return Promise.resolve();
|
|
405
316
|
}
|
|
406
317
|
};
|
|
407
|
-
`.trim();
|
|
408
|
-
}
|
|
409
|
-
function generateExtAppsAdapter(trustedOrigins) {
|
|
410
|
-
const originsArray = trustedOrigins.length > 0 ? JSON.stringify(trustedOrigins) : "[]";
|
|
411
|
-
return `
|
|
318
|
+
`.trim()}function generateExtAppsAdapter(trustedOrigins){const originsArray=trustedOrigins.length>0?JSON.stringify(trustedOrigins):"[]";return`
|
|
412
319
|
var ExtAppsAdapter = {
|
|
413
320
|
id: 'ext-apps',
|
|
414
321
|
name: 'ext-apps (SEP-1865)',
|
|
@@ -751,10 +658,7 @@ var ExtAppsAdapter = {
|
|
|
751
658
|
return this.sendRequest('ui/unregisterTool', { name: name });
|
|
752
659
|
}
|
|
753
660
|
};
|
|
754
|
-
`.trim()
|
|
755
|
-
}
|
|
756
|
-
function generateClaudeAdapter() {
|
|
757
|
-
return `
|
|
661
|
+
`.trim()}function generateClaudeAdapter(){return`
|
|
758
662
|
var ClaudeAdapter = {
|
|
759
663
|
id: 'claude',
|
|
760
664
|
name: 'Claude (Anthropic)',
|
|
@@ -815,10 +719,7 @@ var ClaudeAdapter = {
|
|
|
815
719
|
return Promise.resolve();
|
|
816
720
|
}
|
|
817
721
|
};
|
|
818
|
-
`.trim()
|
|
819
|
-
}
|
|
820
|
-
function generateGeminiAdapter() {
|
|
821
|
-
return `
|
|
722
|
+
`.trim()}function generateGeminiAdapter(){return`
|
|
822
723
|
var GeminiAdapter = {
|
|
823
724
|
id: 'gemini',
|
|
824
725
|
name: 'Google Gemini',
|
|
@@ -869,10 +770,7 @@ var GeminiAdapter = {
|
|
|
869
770
|
return Promise.resolve();
|
|
870
771
|
}
|
|
871
772
|
};
|
|
872
|
-
`.trim()
|
|
873
|
-
}
|
|
874
|
-
function generateGenericAdapter() {
|
|
875
|
-
return `
|
|
773
|
+
`.trim()}function generateGenericAdapter(){return`
|
|
876
774
|
var GenericAdapter = {
|
|
877
775
|
id: 'generic',
|
|
878
776
|
name: 'Generic Web',
|
|
@@ -907,26 +805,7 @@ var GenericAdapter = {
|
|
|
907
805
|
return Promise.resolve();
|
|
908
806
|
}
|
|
909
807
|
};
|
|
910
|
-
`.trim();
|
|
911
|
-
}
|
|
912
|
-
function generatePlatformDetection(adapters) {
|
|
913
|
-
const adapterVars = adapters.map((a) => {
|
|
914
|
-
switch (a) {
|
|
915
|
-
case "openai":
|
|
916
|
-
return "OpenAIAdapter";
|
|
917
|
-
case "ext-apps":
|
|
918
|
-
return "ExtAppsAdapter";
|
|
919
|
-
case "claude":
|
|
920
|
-
return "ClaudeAdapter";
|
|
921
|
-
case "gemini":
|
|
922
|
-
return "GeminiAdapter";
|
|
923
|
-
case "generic":
|
|
924
|
-
return "GenericAdapter";
|
|
925
|
-
default:
|
|
926
|
-
return "";
|
|
927
|
-
}
|
|
928
|
-
}).filter(Boolean);
|
|
929
|
-
return `
|
|
808
|
+
`.trim()}function generatePlatformDetection(adapters){const adapterVars=adapters.map(a=>{switch(a){case"openai":return"OpenAIAdapter";case"ext-apps":return"ExtAppsAdapter";case"claude":return"ClaudeAdapter";case"gemini":return"GeminiAdapter";case"generic":return"GenericAdapter";default:return""}}).filter(Boolean);return`
|
|
930
809
|
var ADAPTERS = [${adapterVars.join(", ")}].sort(function(a, b) { return b.priority - a.priority; });
|
|
931
810
|
|
|
932
811
|
function detectPlatform() {
|
|
@@ -939,10 +818,7 @@ function detectPlatform() {
|
|
|
939
818
|
log('No platform detected, using generic');
|
|
940
819
|
return GenericAdapter;
|
|
941
820
|
}
|
|
942
|
-
`.trim()
|
|
943
|
-
}
|
|
944
|
-
function generateBridgeClass() {
|
|
945
|
-
return `
|
|
821
|
+
`.trim()}function generateBridgeClass(){return`
|
|
946
822
|
function FrontMcpBridge() {
|
|
947
823
|
this._adapter = null;
|
|
948
824
|
this._initialized = false;
|
|
@@ -1318,54 +1194,4 @@ FrontMcpBridge.prototype._setupDataToolCallHandler = function() {
|
|
|
1318
1194
|
}
|
|
1319
1195
|
}, true); // Use capture phase to handle before React handlers
|
|
1320
1196
|
};
|
|
1321
|
-
`.trim();
|
|
1322
|
-
}
|
|
1323
|
-
var MAX_MINIFY_CODE_LENGTH = 5e5;
|
|
1324
|
-
function minifyJS(code) {
|
|
1325
|
-
if (code.length > MAX_MINIFY_CODE_LENGTH) {
|
|
1326
|
-
return code;
|
|
1327
|
-
}
|
|
1328
|
-
const out = [];
|
|
1329
|
-
let inBlockComment = false;
|
|
1330
|
-
for (const raw of code.split("\n")) {
|
|
1331
|
-
const line = raw.trim();
|
|
1332
|
-
if (inBlockComment) {
|
|
1333
|
-
if (line.includes("*/")) inBlockComment = false;
|
|
1334
|
-
continue;
|
|
1335
|
-
}
|
|
1336
|
-
if (line === "" || line.startsWith("//")) continue;
|
|
1337
|
-
if (line.startsWith("/*")) {
|
|
1338
|
-
if (!line.includes("*/")) inBlockComment = true;
|
|
1339
|
-
continue;
|
|
1340
|
-
}
|
|
1341
|
-
out.push(line);
|
|
1342
|
-
}
|
|
1343
|
-
return out.join("\n");
|
|
1344
|
-
}
|
|
1345
|
-
function generatePlatformBundle(platform, options = {}) {
|
|
1346
|
-
const platformAdapters = {
|
|
1347
|
-
chatgpt: ["openai", "generic"],
|
|
1348
|
-
claude: ["claude", "generic"],
|
|
1349
|
-
gemini: ["gemini", "generic"],
|
|
1350
|
-
universal: ["openai", "ext-apps", "claude", "gemini", "generic"]
|
|
1351
|
-
};
|
|
1352
|
-
return generateBridgeIIFE({
|
|
1353
|
-
...options,
|
|
1354
|
-
adapters: platformAdapters[platform]
|
|
1355
|
-
});
|
|
1356
|
-
}
|
|
1357
|
-
var UNIVERSAL_BRIDGE_SCRIPT = generateBridgeIIFE();
|
|
1358
|
-
var BRIDGE_SCRIPT_TAGS = {
|
|
1359
|
-
universal: `<script>${UNIVERSAL_BRIDGE_SCRIPT}</script>`,
|
|
1360
|
-
chatgpt: `<script>${generatePlatformBundle("chatgpt")}</script>`,
|
|
1361
|
-
claude: `<script>${generatePlatformBundle("claude")}</script>`,
|
|
1362
|
-
gemini: `<script>${generatePlatformBundle("gemini")}</script>`
|
|
1363
|
-
};
|
|
1364
|
-
export {
|
|
1365
|
-
BRIDGE_SCRIPT_TAGS,
|
|
1366
|
-
MCP_APPS_DISPLAY_MODES,
|
|
1367
|
-
UNIVERSAL_BRIDGE_SCRIPT,
|
|
1368
|
-
WIDGET_CALL_META_KEY,
|
|
1369
|
-
generateBridgeIIFE,
|
|
1370
|
-
generatePlatformBundle
|
|
1371
|
-
};
|
|
1197
|
+
`.trim()}var MAX_MINIFY_CODE_LENGTH=5e5;function minifyJS(code){if(code.length>MAX_MINIFY_CODE_LENGTH){return code}const out=[];let inBlockComment=false;for(const raw of code.split("\n")){const line=raw.trim();if(inBlockComment){if(line.includes("*/"))inBlockComment=false;continue}if(line===""||line.startsWith("//"))continue;if(line.startsWith("/*")){if(!line.includes("*/"))inBlockComment=true;continue}out.push(line)}return out.join("\n")}function generatePlatformBundle(platform,options={}){const platformAdapters={chatgpt:["openai","generic"],claude:["claude","generic"],gemini:["gemini","generic"],universal:["openai","ext-apps","claude","gemini","generic"]};return generateBridgeIIFE({...options,adapters:platformAdapters[platform]})}var UNIVERSAL_BRIDGE_SCRIPT=generateBridgeIIFE();var BRIDGE_SCRIPT_TAGS={universal:`<script>${UNIVERSAL_BRIDGE_SCRIPT}</script>`,chatgpt:`<script>${generatePlatformBundle("chatgpt")}</script>`,claude:`<script>${generatePlatformBundle("claude")}</script>`,gemini:`<script>${generatePlatformBundle("gemini")}</script>`};export{BRIDGE_SCRIPT_TAGS,MCP_APPS_DISPLAY_MODES,UNIVERSAL_BRIDGE_SCRIPT,WIDGET_CALL_META_KEY,generateBridgeIIFE,generatePlatformBundle};
|