@majkapp/plugin-kit 1.3.7 → 1.3.8
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/dist/mcp-dom-agent.js +60 -0
- package/dist/plugin-kit.d.ts.map +1 -1
- package/dist/plugin-kit.js +20 -1
- package/package.json +1 -1
package/dist/mcp-dom-agent.js
CHANGED
|
@@ -74,17 +74,34 @@
|
|
|
74
74
|
|
|
75
75
|
async function captureScreenshot(options = {}) {
|
|
76
76
|
try {
|
|
77
|
+
// Debug: Check if html2canvas is available
|
|
78
|
+
console.log('[MCP DOM Agent] Screenshot capture started');
|
|
79
|
+
console.log('[MCP DOM Agent] html2canvas available:', typeof html2canvas !== 'undefined');
|
|
80
|
+
console.log('[MCP DOM Agent] window.html2canvas:', window.html2canvas);
|
|
81
|
+
|
|
77
82
|
// Use html2canvas if available, otherwise use basic canvas approach
|
|
78
83
|
if (typeof html2canvas !== 'undefined') {
|
|
84
|
+
console.log('[MCP DOM Agent] Using html2canvas for real screenshot');
|
|
79
85
|
const canvas = await html2canvas(document.body, {
|
|
80
86
|
allowTaint: true,
|
|
81
87
|
useCORS: true,
|
|
82
88
|
logging: false,
|
|
83
89
|
...options
|
|
84
90
|
});
|
|
91
|
+
console.log('[MCP DOM Agent] html2canvas capture successful');
|
|
85
92
|
return canvas.toDataURL('image/png');
|
|
86
93
|
} else {
|
|
87
94
|
// Fallback: Use basic canvas API to capture visible viewport
|
|
95
|
+
console.warn('[MCP DOM Agent] html2canvas not available, using fallback');
|
|
96
|
+
console.log('[MCP DOM Agent] Checking document scripts:');
|
|
97
|
+
const scripts = document.querySelectorAll('script');
|
|
98
|
+
scripts.forEach((script, idx) => {
|
|
99
|
+
console.log(` Script ${idx}:`, {
|
|
100
|
+
src: script.src || 'inline',
|
|
101
|
+
hasContent: script.textContent?.length || 0,
|
|
102
|
+
contains_html2canvas: script.textContent?.includes('html2canvas') || false
|
|
103
|
+
});
|
|
104
|
+
});
|
|
88
105
|
return captureViewportScreenshot(options);
|
|
89
106
|
}
|
|
90
107
|
} catch (error) {
|
|
@@ -259,6 +276,22 @@
|
|
|
259
276
|
// Listen for file picker results from parent window
|
|
260
277
|
window.addEventListener('message', function (ev) {
|
|
261
278
|
const msg = ev.data;
|
|
279
|
+
|
|
280
|
+
// Log ALL incoming messages for debugging
|
|
281
|
+
if (msg && msg.type && msg.type.startsWith('majk:file-picker:')) {
|
|
282
|
+
console.log('[MCP DOM Agent] Received postMessage:', {
|
|
283
|
+
type: msg.type,
|
|
284
|
+
requestId: msg.requestId,
|
|
285
|
+
success: msg.success,
|
|
286
|
+
hasResult: !!msg.result,
|
|
287
|
+
hasResults: !!msg.results,
|
|
288
|
+
hasError: !!msg.error,
|
|
289
|
+
errorName: msg.error?.name,
|
|
290
|
+
errorMessage: msg.error?.message,
|
|
291
|
+
fullMessage: msg
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
262
295
|
if (!msg) return;
|
|
263
296
|
|
|
264
297
|
// Handle directory picker result
|
|
@@ -267,10 +300,23 @@
|
|
|
267
300
|
if (pending) {
|
|
268
301
|
pendingFilePickerRequests.delete(msg.requestId);
|
|
269
302
|
if (msg.success) {
|
|
303
|
+
console.log('[MCP DOM Agent] Directory picker SUCCESS - resolving promise', {
|
|
304
|
+
requestId: msg.requestId,
|
|
305
|
+
result: msg.result
|
|
306
|
+
});
|
|
270
307
|
pending.resolve(msg.result);
|
|
271
308
|
} else {
|
|
309
|
+
console.log('[MCP DOM Agent] Directory picker FAILED - rejecting promise', {
|
|
310
|
+
requestId: msg.requestId,
|
|
311
|
+
error: msg.error
|
|
312
|
+
});
|
|
272
313
|
pending.reject(new Error(msg.error?.message || 'Directory picker failed'));
|
|
273
314
|
}
|
|
315
|
+
} else {
|
|
316
|
+
console.warn('[MCP DOM Agent] Received directory picker result but no pending request found', {
|
|
317
|
+
requestId: msg.requestId,
|
|
318
|
+
pendingRequestIds: Array.from(pendingFilePickerRequests.keys())
|
|
319
|
+
});
|
|
274
320
|
}
|
|
275
321
|
}
|
|
276
322
|
|
|
@@ -305,6 +351,12 @@
|
|
|
305
351
|
async function showDirectoryPickerBridge(options) {
|
|
306
352
|
const requestId = 'file-picker-' + (filePickerRequestId++);
|
|
307
353
|
|
|
354
|
+
console.log('[MCP DOM Agent] Sending directory picker request:', {
|
|
355
|
+
requestId,
|
|
356
|
+
options,
|
|
357
|
+
pendingRequests: pendingFilePickerRequests.size
|
|
358
|
+
});
|
|
359
|
+
|
|
308
360
|
return new Promise((resolve, reject) => {
|
|
309
361
|
pendingFilePickerRequests.set(requestId, { resolve, reject });
|
|
310
362
|
|
|
@@ -401,4 +453,12 @@
|
|
|
401
453
|
}
|
|
402
454
|
|
|
403
455
|
console.log('[MCP DOM Agent] Initialized v1.1.0 with File Picker Bridge');
|
|
456
|
+
console.log('[MCP DOM Agent] Initialized v1.0.0');
|
|
457
|
+
console.log('[MCP DOM Agent] html2canvas detected:', typeof html2canvas !== 'undefined');
|
|
458
|
+
console.log('[MCP DOM Agent] Screenshot support:', typeof html2canvas !== 'undefined' ? 'FULL' : 'FALLBACK');
|
|
459
|
+
|
|
460
|
+
// Debug: Log all inline scripts to help debug injection
|
|
461
|
+
const inlineScripts = Array.from(document.querySelectorAll('script:not([src])')).length;
|
|
462
|
+
const externalScripts = Array.from(document.querySelectorAll('script[src]')).length;
|
|
463
|
+
console.log('[MCP DOM Agent] Scripts in document:', { inline: inlineScripts, external: externalScripts });
|
|
404
464
|
})();
|
package/dist/plugin-kit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-kit.d.ts","sourceRoot":"","sources":["../src/plugin-kit.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAGb,eAAe,EACf,QAAQ,EACR,WAAW,EACX,WAAW,EACX,UAAU,EACV,QAAQ,EACR,WAAW,EACX,UAAU,EACV,eAAe,EACf,WAAW,EACX,KAAK,EACL,UAAU,EACV,SAAS,EAC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AAe,EAAE,GAAG,IAAI,CAAC;IAEnE,0EAA0E;IAC1E,sBAAsB,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,gBAAgB,EAAE,GAAG,IAAI,CAAC;IAE3E,0BAA0B;IAC1B,cAAc,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAE7C,wBAAwB;IACxB,YAAY,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI,CAAC;IAEzC,0BAA0B;IAC1B,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC;IAEjC,sCAAsC;IACtC,OAAO,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAElG,0BAA0B;IAC1B,MAAM,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI,CAAC;IAEhC;;;;;;;;;;OAUG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B,uBAAuB;IACvB,KAAK,IAAI,eAAe,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAClD,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,aAAa,CAAC,EAAE,CAAC,CA0xBnB"}
|
package/dist/plugin-kit.js
CHANGED
|
@@ -406,6 +406,16 @@ function serveSpa(ui, req, res, ctx) {
|
|
|
406
406
|
const mcpScript = BuiltPlugin.mcpDomAgentScript
|
|
407
407
|
? `<script>${BuiltPlugin.mcpDomAgentScript}</script>`
|
|
408
408
|
: '';
|
|
409
|
+
// Debug logging
|
|
410
|
+
if (html2canvasScript) {
|
|
411
|
+
ctx.logger.debug(`[React SPA] Injecting html2canvas (${(BuiltPlugin.html2canvasScript?.length || 0) / 1024} KB)`);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
ctx.logger.warn('[React SPA] html2canvas NOT injected - script not loaded');
|
|
415
|
+
}
|
|
416
|
+
if (mcpScript) {
|
|
417
|
+
ctx.logger.debug('[React SPA] Injecting MCP DOM Agent');
|
|
418
|
+
}
|
|
409
419
|
const allInjections = configInject + html2canvasScript + mcpScript;
|
|
410
420
|
const injected = html.replace('</head>', `${allInjections}</head>`);
|
|
411
421
|
content = Buffer.from(injected, 'utf-8');
|
|
@@ -620,7 +630,8 @@ class BuiltPlugin {
|
|
|
620
630
|
if (!BuiltPlugin.html2canvasScript) {
|
|
621
631
|
BuiltPlugin.html2canvasScript = loadHtml2CanvasScript();
|
|
622
632
|
if (BuiltPlugin.html2canvasScript) {
|
|
623
|
-
|
|
633
|
+
const sizeKB = (BuiltPlugin.html2canvasScript.length / 1024).toFixed(2);
|
|
634
|
+
context.logger.info(`✅ html2canvas library loaded (${sizeKB} KB) - screenshot support enabled`);
|
|
624
635
|
}
|
|
625
636
|
else {
|
|
626
637
|
context.logger.warn('⚠️ html2canvas not found - screenshots will use fallback mode');
|
|
@@ -997,6 +1008,14 @@ class BuiltPlugin {
|
|
|
997
1008
|
: '';
|
|
998
1009
|
const mcpScript = `<script>${BuiltPlugin.mcpDomAgentScript}</script>`;
|
|
999
1010
|
const allScripts = html2canvasScript + mcpScript;
|
|
1011
|
+
// Debug logging
|
|
1012
|
+
if (html2canvasScript) {
|
|
1013
|
+
this.context.logger.debug(`[HTML Screen] Injecting html2canvas (${(BuiltPlugin.html2canvasScript?.length || 0) / 1024} KB)`);
|
|
1014
|
+
}
|
|
1015
|
+
else {
|
|
1016
|
+
this.context.logger.warn('[HTML Screen] html2canvas NOT injected - script not loaded');
|
|
1017
|
+
}
|
|
1018
|
+
this.context.logger.debug('[HTML Screen] Injecting MCP DOM Agent');
|
|
1000
1019
|
// Try to inject before </body>, fallback to </head>, fallback to end of HTML
|
|
1001
1020
|
if (htmlContent.includes('</body>')) {
|
|
1002
1021
|
htmlContent = htmlContent.replace('</body>', `${allScripts}</body>`);
|