@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.
@@ -1,115 +1,4 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // libs/uipack/src/bridge-runtime/index.ts
21
- var bridge_runtime_exports = {};
22
- __export(bridge_runtime_exports, {
23
- BRIDGE_SCRIPT_TAGS: () => BRIDGE_SCRIPT_TAGS,
24
- MCP_APPS_DISPLAY_MODES: () => MCP_APPS_DISPLAY_MODES,
25
- UNIVERSAL_BRIDGE_SCRIPT: () => UNIVERSAL_BRIDGE_SCRIPT,
26
- WIDGET_CALL_META_KEY: () => WIDGET_CALL_META_KEY,
27
- generateBridgeIIFE: () => generateBridgeIIFE,
28
- generatePlatformBundle: () => generatePlatformBundle
29
- });
30
- module.exports = __toCommonJS(bridge_runtime_exports);
31
-
32
- // libs/uipack/src/bridge-runtime/iife-generator.ts
33
- var WIDGET_CALL_META_KEY = "frontmcp/widgetCall";
34
- var MCP_APPS_DISPLAY_MODES = ["inline", "fullscreen", "pip"];
35
- function generateBridgeIIFE(options = {}) {
36
- const { debug = false, trustedOrigins = [], minify = false } = options;
37
- const adapters = options.adapters || ["openai", "ext-apps", "claude", "gemini", "generic"];
38
- const parts = [];
39
- parts.push("(function() {");
40
- parts.push('"use strict";');
41
- parts.push("");
42
- if (debug) {
43
- parts.push('function log(msg) { console.log("[FrontMcpBridge] " + msg); }');
44
- } else {
45
- parts.push("function log() {}");
46
- }
47
- parts.push("");
48
- parts.push("var DEFAULT_SAFE_AREA = { top: 0, bottom: 0, left: 0, right: 0 };");
49
- parts.push("");
50
- parts.push(generateContextDetection());
51
- parts.push("");
52
- parts.push(generateBaseCapabilities());
53
- parts.push("");
54
- if (adapters.includes("openai")) {
55
- parts.push(generateOpenAIAdapter());
56
- parts.push("");
57
- }
58
- if (adapters.includes("ext-apps")) {
59
- parts.push(generateExtAppsAdapter(trustedOrigins));
60
- parts.push("");
61
- }
62
- if (adapters.includes("claude")) {
63
- parts.push(generateClaudeAdapter());
64
- parts.push("");
65
- }
66
- if (adapters.includes("gemini")) {
67
- parts.push(generateGeminiAdapter());
68
- parts.push("");
69
- }
70
- if (adapters.includes("generic")) {
71
- parts.push(generateGenericAdapter());
72
- parts.push("");
73
- }
74
- parts.push(generatePlatformDetection(adapters));
75
- parts.push("");
76
- parts.push(generateBridgeClass());
77
- parts.push("");
78
- parts.push("var bridge = new FrontMcpBridge();");
79
- parts.push("bridge.initialize().then(function() {");
80
- parts.push(' log("Bridge initialized with adapter: " + bridge.adapterId);');
81
- parts.push(' window.dispatchEvent(new CustomEvent("bridge:ready", { detail: { adapter: bridge.adapterId } }));');
82
- parts.push(" if (window.__mcpDisplayMode) bridge.requestDisplayMode(window.__mcpDisplayMode).catch(function() {});");
83
- parts.push("}).catch(function(err) {");
84
- parts.push(' console.error("[FrontMcpBridge] Init failed:", err);');
85
- parts.push(' window.dispatchEvent(new CustomEvent("bridge:error", { detail: { error: err } }));');
86
- parts.push("});");
87
- parts.push("");
88
- parts.push("window.FrontMcpBridge = bridge;");
89
- parts.push("");
90
- parts.push(generateAutoResize());
91
- parts.push("function __showLoading() {");
92
- parts.push(' var root = document.getElementById("root");');
93
- parts.push(" if (root && !root.hasChildNodes()) {");
94
- parts.push(
95
- ` 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>';`
96
- );
97
- parts.push(" }");
98
- parts.push("}");
99
- parts.push('if (document.readyState === "loading") {');
100
- parts.push(' document.addEventListener("DOMContentLoaded", __showLoading);');
101
- parts.push("} else {");
102
- parts.push(" __showLoading();");
103
- parts.push("}");
104
- parts.push("})();");
105
- const code = parts.join("\n");
106
- if (minify) {
107
- return minifyJS(code);
108
- }
109
- return code;
110
- }
111
- function generateAutoResize() {
112
- return `
1
+ "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var bridge_runtime_exports={};__export(bridge_runtime_exports,{BRIDGE_SCRIPT_TAGS:()=>BRIDGE_SCRIPT_TAGS,MCP_APPS_DISPLAY_MODES:()=>MCP_APPS_DISPLAY_MODES,UNIVERSAL_BRIDGE_SCRIPT:()=>UNIVERSAL_BRIDGE_SCRIPT,WIDGET_CALL_META_KEY:()=>WIDGET_CALL_META_KEY,generateBridgeIIFE:()=>generateBridgeIIFE,generatePlatformBundle:()=>generatePlatformBundle});module.exports=__toCommonJS(bridge_runtime_exports);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`
113
2
  function __applySizingCss(sizing) {
114
3
  if (typeof document === 'undefined' || !document.documentElement) return;
115
4
  function toLen(v) { return typeof v === 'number' ? v + 'px' : v; }
@@ -244,10 +133,7 @@ function __initAutoResize() {
244
133
  }
245
134
  }
246
135
  __initAutoResize();
247
- `.trim();
248
- }
249
- function generateContextDetection() {
250
- return `
136
+ `.trim()}function generateContextDetection(){return`
251
137
  function detectTheme() {
252
138
  if (typeof window !== 'undefined' && window.matchMedia) {
253
139
  return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
@@ -334,10 +220,7 @@ function readInjectedData() {
334
220
  }
335
221
  return data;
336
222
  }
337
- `.trim();
338
- }
339
- function generateBaseCapabilities() {
340
- return `
223
+ `.trim()}function generateBaseCapabilities(){return`
341
224
  var DEFAULT_CAPABILITIES = {
342
225
  canCallTools: false,
343
226
  canSendMessages: false,
@@ -347,10 +230,7 @@ var DEFAULT_CAPABILITIES = {
347
230
  supportsDisplayModes: false,
348
231
  supportsTheme: true
349
232
  };
350
- `.trim();
351
- }
352
- function generateOpenAIAdapter() {
353
- return `
233
+ `.trim()}function generateOpenAIAdapter(){return`
354
234
  var OpenAIAdapter = {
355
235
  id: 'openai',
356
236
  name: 'OpenAI ChatGPT',
@@ -435,11 +315,7 @@ var OpenAIAdapter = {
435
315
  return Promise.resolve();
436
316
  }
437
317
  };
438
- `.trim();
439
- }
440
- function generateExtAppsAdapter(trustedOrigins) {
441
- const originsArray = trustedOrigins.length > 0 ? JSON.stringify(trustedOrigins) : "[]";
442
- return `
318
+ `.trim()}function generateExtAppsAdapter(trustedOrigins){const originsArray=trustedOrigins.length>0?JSON.stringify(trustedOrigins):"[]";return`
443
319
  var ExtAppsAdapter = {
444
320
  id: 'ext-apps',
445
321
  name: 'ext-apps (SEP-1865)',
@@ -782,10 +658,7 @@ var ExtAppsAdapter = {
782
658
  return this.sendRequest('ui/unregisterTool', { name: name });
783
659
  }
784
660
  };
785
- `.trim();
786
- }
787
- function generateClaudeAdapter() {
788
- return `
661
+ `.trim()}function generateClaudeAdapter(){return`
789
662
  var ClaudeAdapter = {
790
663
  id: 'claude',
791
664
  name: 'Claude (Anthropic)',
@@ -846,10 +719,7 @@ var ClaudeAdapter = {
846
719
  return Promise.resolve();
847
720
  }
848
721
  };
849
- `.trim();
850
- }
851
- function generateGeminiAdapter() {
852
- return `
722
+ `.trim()}function generateGeminiAdapter(){return`
853
723
  var GeminiAdapter = {
854
724
  id: 'gemini',
855
725
  name: 'Google Gemini',
@@ -900,10 +770,7 @@ var GeminiAdapter = {
900
770
  return Promise.resolve();
901
771
  }
902
772
  };
903
- `.trim();
904
- }
905
- function generateGenericAdapter() {
906
- return `
773
+ `.trim()}function generateGenericAdapter(){return`
907
774
  var GenericAdapter = {
908
775
  id: 'generic',
909
776
  name: 'Generic Web',
@@ -938,26 +805,7 @@ var GenericAdapter = {
938
805
  return Promise.resolve();
939
806
  }
940
807
  };
941
- `.trim();
942
- }
943
- function generatePlatformDetection(adapters) {
944
- const adapterVars = adapters.map((a) => {
945
- switch (a) {
946
- case "openai":
947
- return "OpenAIAdapter";
948
- case "ext-apps":
949
- return "ExtAppsAdapter";
950
- case "claude":
951
- return "ClaudeAdapter";
952
- case "gemini":
953
- return "GeminiAdapter";
954
- case "generic":
955
- return "GenericAdapter";
956
- default:
957
- return "";
958
- }
959
- }).filter(Boolean);
960
- 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`
961
809
  var ADAPTERS = [${adapterVars.join(", ")}].sort(function(a, b) { return b.priority - a.priority; });
962
810
 
963
811
  function detectPlatform() {
@@ -970,10 +818,7 @@ function detectPlatform() {
970
818
  log('No platform detected, using generic');
971
819
  return GenericAdapter;
972
820
  }
973
- `.trim();
974
- }
975
- function generateBridgeClass() {
976
- return `
821
+ `.trim()}function generateBridgeClass(){return`
977
822
  function FrontMcpBridge() {
978
823
  this._adapter = null;
979
824
  this._initialized = false;
@@ -1349,55 +1194,4 @@ FrontMcpBridge.prototype._setupDataToolCallHandler = function() {
1349
1194
  }
1350
1195
  }, true); // Use capture phase to handle before React handlers
1351
1196
  };
1352
- `.trim();
1353
- }
1354
- var MAX_MINIFY_CODE_LENGTH = 5e5;
1355
- function minifyJS(code) {
1356
- if (code.length > MAX_MINIFY_CODE_LENGTH) {
1357
- return code;
1358
- }
1359
- const out = [];
1360
- let inBlockComment = false;
1361
- for (const raw of code.split("\n")) {
1362
- const line = raw.trim();
1363
- if (inBlockComment) {
1364
- if (line.includes("*/")) inBlockComment = false;
1365
- continue;
1366
- }
1367
- if (line === "" || line.startsWith("//")) continue;
1368
- if (line.startsWith("/*")) {
1369
- if (!line.includes("*/")) inBlockComment = true;
1370
- continue;
1371
- }
1372
- out.push(line);
1373
- }
1374
- return out.join("\n");
1375
- }
1376
- function generatePlatformBundle(platform, options = {}) {
1377
- const platformAdapters = {
1378
- chatgpt: ["openai", "generic"],
1379
- claude: ["claude", "generic"],
1380
- gemini: ["gemini", "generic"],
1381
- universal: ["openai", "ext-apps", "claude", "gemini", "generic"]
1382
- };
1383
- return generateBridgeIIFE({
1384
- ...options,
1385
- adapters: platformAdapters[platform]
1386
- });
1387
- }
1388
- var UNIVERSAL_BRIDGE_SCRIPT = generateBridgeIIFE();
1389
- var BRIDGE_SCRIPT_TAGS = {
1390
- universal: `<script>${UNIVERSAL_BRIDGE_SCRIPT}</script>`,
1391
- chatgpt: `<script>${generatePlatformBundle("chatgpt")}</script>`,
1392
- claude: `<script>${generatePlatformBundle("claude")}</script>`,
1393
- gemini: `<script>${generatePlatformBundle("gemini")}</script>`
1394
- };
1395
- // Annotate the CommonJS export names for ESM import in node:
1396
- 0 && (module.exports = {
1397
- BRIDGE_SCRIPT_TAGS,
1398
- MCP_APPS_DISPLAY_MODES,
1399
- UNIVERSAL_BRIDGE_SCRIPT,
1400
- WIDGET_CALL_META_KEY,
1401
- generateBridgeIIFE,
1402
- generatePlatformBundle
1403
- });
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>`};0&&(module.exports={BRIDGE_SCRIPT_TAGS,MCP_APPS_DISPLAY_MODES,UNIVERSAL_BRIDGE_SCRIPT,WIDGET_CALL_META_KEY,generateBridgeIIFE,generatePlatformBundle});