@pixerate/editor 0.80.0 → 0.82.0
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/README.md +13 -3
- package/dist/agent/index.cjs +138 -13
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +9 -5
- package/dist/agent/index.d.ts +9 -5
- package/dist/agent/index.js +144 -19
- package/dist/agent/index.js.map +1 -1
- package/dist/animation-editor/index.d.cts +1 -1
- package/dist/animation-editor/index.d.ts +1 -1
- package/dist/bridge/index.d.cts +3 -3
- package/dist/bridge/index.d.ts +3 -3
- package/dist/{bridge-client-C5dRjrz5.d.ts → bridge-client-CMGfnjTl.d.ts} +1 -1
- package/dist/{bridge-client-C5OziCRK.d.cts → bridge-client-VpnICVxP.d.cts} +1 -1
- package/dist/{builtins-BKYlHH1s.d.ts → builtins-CV1fDj64.d.ts} +5 -1
- package/dist/{builtins-1kqwLUnb.d.cts → builtins-c4w0eAYl.d.cts} +5 -1
- package/dist/canvas/index.cjs +235 -104
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +59 -1
- package/dist/canvas/index.d.ts +59 -1
- package/dist/canvas/index.js +234 -103
- package/dist/canvas/index.js.map +1 -1
- package/dist/capture-DFEMFmVt.d.cts +133 -0
- package/dist/capture-wwNGaW05.d.ts +133 -0
- package/dist/chart/index.d.cts +1 -1
- package/dist/chart/index.d.ts +1 -1
- package/dist/{chunk-2CJ3LPYQ.js → chunk-424H3P4I.js} +13 -295
- package/dist/chunk-424H3P4I.js.map +1 -0
- package/dist/{chunk-K73CKYUM.cjs → chunk-EI2MOVQ3.cjs} +198 -3
- package/dist/chunk-EI2MOVQ3.cjs.map +1 -0
- package/dist/chunk-FURT6ZFZ.cjs +1 -0
- package/dist/chunk-FURT6ZFZ.cjs.map +1 -0
- package/dist/{chunk-GPWNYQ7R.js → chunk-O2W2SP3C.js} +197 -2
- package/dist/chunk-O2W2SP3C.js.map +1 -0
- package/dist/{chunk-UN33YOXW.cjs → chunk-PA5S7KPC.cjs} +293 -2
- package/dist/chunk-PA5S7KPC.cjs.map +1 -0
- package/dist/{chunk-IB3ZHQAX.js → chunk-PTYWCFFW.js} +29 -4
- package/dist/chunk-PTYWCFFW.js.map +1 -0
- package/dist/{chunk-JQ3BB3E6.js → chunk-PXDEFEG2.js} +293 -2
- package/dist/chunk-PXDEFEG2.js.map +1 -0
- package/dist/chunk-REOJJIY3.js +201 -0
- package/dist/chunk-REOJJIY3.js.map +1 -0
- package/dist/chunk-RJ2BFKEN.js +1 -0
- package/dist/chunk-RJ2BFKEN.js.map +1 -0
- package/dist/{chunk-YU4WQE5M.cjs → chunk-TAPXWP2B.cjs} +95 -377
- package/dist/chunk-TAPXWP2B.cjs.map +1 -0
- package/dist/{chunk-HXDMZQTD.cjs → chunk-TPOT575P.cjs} +29 -4
- package/dist/{chunk-IB3ZHQAX.js.map → chunk-TPOT575P.cjs.map} +1 -1
- package/dist/chunk-VJUVNERT.cjs +201 -0
- package/dist/chunk-VJUVNERT.cjs.map +1 -0
- package/dist/commands/index.cjs +2 -2
- package/dist/commands/index.d.cts +2 -2
- package/dist/commands/index.d.ts +2 -2
- package/dist/commands/index.js +1 -1
- package/dist/diagram/index.d.cts +1 -1
- package/dist/diagram/index.d.ts +1 -1
- package/dist/dom-capture-7Wvf6Tyg.d.ts +59 -0
- package/dist/dom-capture-GyYuE-zq.d.cts +59 -0
- package/dist/generation/index.cjs +932 -791
- package/dist/generation/index.cjs.map +1 -1
- package/dist/generation/index.d.cts +268 -242
- package/dist/generation/index.d.ts +268 -242
- package/dist/generation/index.js +926 -785
- package/dist/generation/index.js.map +1 -1
- package/dist/image-editor/index.cjs +362 -2
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +35 -2
- package/dist/image-editor/index.d.ts +35 -2
- package/dist/image-editor/index.js +361 -1
- package/dist/image-editor/index.js.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -16
- package/dist/{registry-DIpIaCkH.d.cts → registry-BqA1AZt0.d.cts} +1 -1
- package/dist/{registry-7AZFuand.d.ts → registry-D-4fit9C.d.ts} +1 -1
- package/dist/spreadsheet/index.cjs +3 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.js +16 -16
- package/dist/tools/index.cjs +33 -4
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.cts +4 -2
- package/dist/tools/index.d.ts +4 -2
- package/dist/tools/index.js +43 -14
- package/dist/video-editor/index.d.cts +1 -1
- package/dist/video-editor/index.d.ts +1 -1
- package/package.json +2 -1
- package/skills/README.md +55 -0
- package/skills/pixerate-agent-tools/SKILL.md +75 -0
- package/skills/pixerate-animation-editor/SKILL.md +155 -0
- package/skills/pixerate-animation-editor/references/commands.md +123 -0
- package/skills/pixerate-canvas/SKILL.md +231 -0
- package/skills/pixerate-chart/SKILL.md +190 -0
- package/skills/pixerate-diagram/SKILL.md +134 -0
- package/skills/pixerate-generation/SKILL.md +109 -0
- package/skills/pixerate-image-editor/SKILL.md +140 -0
- package/skills/pixerate-parameters/SKILL.md +83 -0
- package/skills/pixerate-rich-text/SKILL.md +160 -0
- package/skills/pixerate-spreadsheet/SKILL.md +146 -0
- package/skills/pixerate-vector/SKILL.md +191 -0
- package/skills/pixerate-vector/references/commands.md +138 -0
- package/skills/pixerate-video-editor/SKILL.md +173 -0
- package/dist/chunk-2CJ3LPYQ.js.map +0 -1
- package/dist/chunk-GPWNYQ7R.js.map +0 -1
- package/dist/chunk-HXDMZQTD.cjs.map +0 -1
- package/dist/chunk-JQ3BB3E6.js.map +0 -1
- package/dist/chunk-K73CKYUM.cjs.map +0 -1
- package/dist/chunk-UN33YOXW.cjs.map +0 -1
- package/dist/chunk-YU4WQE5M.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/tools/definitions.ts
|
|
2
2
|
var MCP_TOOL_GET_EDITOR_STATE = {
|
|
3
3
|
name: "get_editor_state",
|
|
4
4
|
title: "Get editor state",
|
|
@@ -433,6 +433,201 @@ var EDITOR_MCP_TOOLS = [
|
|
|
433
433
|
MCP_TOOL_VIEW_EDITOR
|
|
434
434
|
];
|
|
435
435
|
|
|
436
|
+
// src/tools/dom-capture.ts
|
|
437
|
+
var NO_DOM = "Capturing needs a browser DOM (document, Image, XMLSerializer and a 2D canvas); it is not available in this environment.";
|
|
438
|
+
var SKIPPED_TAGS = /* @__PURE__ */ new Set(["SCRIPT", "NOSCRIPT", "TEMPLATE", "LINK", "META", "STYLE"]);
|
|
439
|
+
function styleText(style) {
|
|
440
|
+
let text = "";
|
|
441
|
+
for (let i = 0; i < style.length; i++) {
|
|
442
|
+
const name = style[i];
|
|
443
|
+
const priority = style.getPropertyPriority(name);
|
|
444
|
+
text += `${name}:${style.getPropertyValue(name)}${priority ? ` !${priority}` : ""};`;
|
|
445
|
+
}
|
|
446
|
+
return text;
|
|
447
|
+
}
|
|
448
|
+
function imageSnapshot(source, doc) {
|
|
449
|
+
try {
|
|
450
|
+
if (source.tagName === "CANVAS") return source.toDataURL("image/png");
|
|
451
|
+
const img = source;
|
|
452
|
+
if (!img.complete || !img.naturalWidth || img.src.startsWith("data:")) return null;
|
|
453
|
+
const canvas = doc.createElement("canvas");
|
|
454
|
+
canvas.width = img.naturalWidth;
|
|
455
|
+
canvas.height = img.naturalHeight;
|
|
456
|
+
const context = canvas.getContext("2d");
|
|
457
|
+
if (!context) return null;
|
|
458
|
+
context.drawImage(img, 0, 0);
|
|
459
|
+
return canvas.toDataURL("image/png");
|
|
460
|
+
} catch (e) {
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function cloneElementWithStyles(element, exclude = []) {
|
|
465
|
+
const doc = element.ownerDocument;
|
|
466
|
+
const view = doc.defaultView;
|
|
467
|
+
if (!view) throw new Error(NO_DOM);
|
|
468
|
+
const selector = exclude.join(",");
|
|
469
|
+
const copy = (source) => {
|
|
470
|
+
if (source.nodeType === 3) return source.cloneNode(false);
|
|
471
|
+
if (source.nodeType !== 1) return null;
|
|
472
|
+
const el = source;
|
|
473
|
+
if (SKIPPED_TAGS.has(el.tagName.toUpperCase()) || selector && el.matches(selector)) return null;
|
|
474
|
+
let clone;
|
|
475
|
+
if (el.tagName === "CANVAS") {
|
|
476
|
+
clone = doc.createElement("img");
|
|
477
|
+
const url = imageSnapshot(el, doc);
|
|
478
|
+
if (url) clone.setAttribute("src", url);
|
|
479
|
+
} else {
|
|
480
|
+
clone = el.cloneNode(false);
|
|
481
|
+
if (el.tagName === "IMG") {
|
|
482
|
+
const url = imageSnapshot(el, doc);
|
|
483
|
+
if (url) clone.setAttribute("src", url);
|
|
484
|
+
clone.removeAttribute("srcset");
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
clone.setAttribute("style", styleText(view.getComputedStyle(el)));
|
|
488
|
+
if (el.tagName === "INPUT") {
|
|
489
|
+
const input = el;
|
|
490
|
+
clone.setAttribute("value", input.value);
|
|
491
|
+
if (input.checked) clone.setAttribute("checked", "");
|
|
492
|
+
else clone.removeAttribute("checked");
|
|
493
|
+
} else if (el.tagName === "TEXTAREA") {
|
|
494
|
+
clone.textContent = el.value;
|
|
495
|
+
return clone;
|
|
496
|
+
} else if (el.tagName === "SELECT") {
|
|
497
|
+
const value = el.value;
|
|
498
|
+
for (const child of Array.from(el.childNodes)) {
|
|
499
|
+
const option = copy(child);
|
|
500
|
+
if (option && option.tagName === "OPTION" && option.value === value) {
|
|
501
|
+
option.setAttribute("selected", "");
|
|
502
|
+
}
|
|
503
|
+
if (option) clone.appendChild(option);
|
|
504
|
+
}
|
|
505
|
+
return clone;
|
|
506
|
+
}
|
|
507
|
+
for (const child of Array.from(el.childNodes)) {
|
|
508
|
+
const next = copy(child);
|
|
509
|
+
if (next) clone.appendChild(next);
|
|
510
|
+
}
|
|
511
|
+
return clone;
|
|
512
|
+
};
|
|
513
|
+
const root = copy(element);
|
|
514
|
+
if (!root) throw new Error("The element to capture is excluded by the exclude selectors.");
|
|
515
|
+
return root;
|
|
516
|
+
}
|
|
517
|
+
function elementToSvg(clone, width, height) {
|
|
518
|
+
const doc = clone.ownerDocument;
|
|
519
|
+
const Serializer = _nullishCoalesce(_optionalChain([doc, 'access', _ => _.defaultView, 'optionalAccess', _2 => _2.XMLSerializer]), () => ( globalThis.XMLSerializer));
|
|
520
|
+
if (!Serializer) throw new Error(NO_DOM);
|
|
521
|
+
clone.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
|
|
522
|
+
const xml = new Serializer().serializeToString(clone);
|
|
523
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}"><foreignObject x="0" y="0" width="100%" height="100%">${xml}</foreignObject></svg>`;
|
|
524
|
+
}
|
|
525
|
+
async function rasterizeElement(element, options = {}) {
|
|
526
|
+
const doc = element.ownerDocument;
|
|
527
|
+
const view = _optionalChain([doc, 'optionalAccess', _3 => _3.defaultView]);
|
|
528
|
+
if (!_optionalChain([view, 'optionalAccess', _4 => _4.Image])) throw new Error(NO_DOM);
|
|
529
|
+
const width = Math.max(1, Math.round(_nullishCoalesce(options.width, () => ( element.clientWidth))));
|
|
530
|
+
const height = Math.max(1, Math.round(_nullishCoalesce(options.height, () => ( element.clientHeight))));
|
|
531
|
+
const pixelWidth = Math.max(1, Math.round(_nullishCoalesce(options.pixelWidth, () => ( width))));
|
|
532
|
+
const pixelHeight = Math.max(1, Math.round(_nullishCoalesce(options.pixelHeight, () => ( height))));
|
|
533
|
+
const format = _nullishCoalesce(options.format, () => ( "png"));
|
|
534
|
+
const clone = cloneElementWithStyles(element, options.exclude);
|
|
535
|
+
const background = _nullishCoalesce(options.background, () => ( view.getComputedStyle(element).backgroundColor));
|
|
536
|
+
clone.style.width = `${width}px`;
|
|
537
|
+
clone.style.height = `${height}px`;
|
|
538
|
+
clone.style.margin = "0";
|
|
539
|
+
clone.style.position = "relative";
|
|
540
|
+
clone.style.left = "0";
|
|
541
|
+
clone.style.top = "0";
|
|
542
|
+
clone.style.transform = "none";
|
|
543
|
+
clone.style.overflow = "hidden";
|
|
544
|
+
_optionalChain([options, 'access', _5 => _5.prepare, 'optionalCall', _6 => _6(clone)]);
|
|
545
|
+
const svg = elementToSvg(clone, width, height);
|
|
546
|
+
const canvas = doc.createElement("canvas");
|
|
547
|
+
canvas.width = pixelWidth;
|
|
548
|
+
canvas.height = pixelHeight;
|
|
549
|
+
let context = null;
|
|
550
|
+
try {
|
|
551
|
+
context = canvas.getContext("2d");
|
|
552
|
+
} catch (e2) {
|
|
553
|
+
context = null;
|
|
554
|
+
}
|
|
555
|
+
if (!context) throw new Error(NO_DOM);
|
|
556
|
+
const image = new view.Image();
|
|
557
|
+
await new Promise((resolve, reject) => {
|
|
558
|
+
image.onload = () => resolve();
|
|
559
|
+
image.onerror = () => reject(new Error("The captured view could not be drawn as an image."));
|
|
560
|
+
image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
|
|
561
|
+
});
|
|
562
|
+
const transparent = !background || background === "transparent" || /rgba\([^)]*,\s*0\)$/.test(background);
|
|
563
|
+
if (!transparent || format === "jpeg") {
|
|
564
|
+
context.fillStyle = transparent ? "#ffffff" : background;
|
|
565
|
+
context.fillRect(0, 0, pixelWidth, pixelHeight);
|
|
566
|
+
}
|
|
567
|
+
context.drawImage(image, 0, 0, pixelWidth, pixelHeight);
|
|
568
|
+
try {
|
|
569
|
+
return canvas.toDataURL(format === "jpeg" ? "image/jpeg" : "image/png", _nullishCoalesce(options.quality, () => ( 0.85)));
|
|
570
|
+
} catch (e3) {
|
|
571
|
+
throw new Error("The browser refused to export the captured view (the canvas is tainted by cross-origin content).");
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
var CAPTURE_OVERLAY_SELECTORS = [...EXPORT_EXCLUDED_SELECTORS, '[data-capture="overlay"]'];
|
|
575
|
+
var CAPTURE_EXCLUDE_SELECTOR = '[data-capture="exclude"]';
|
|
576
|
+
function createElementCaptureSurface(options) {
|
|
577
|
+
const getElement = () => _nullishCoalesce((typeof options.element === "function" ? options.element() : options.element), () => ( null));
|
|
578
|
+
const require2 = () => {
|
|
579
|
+
const el = getElement();
|
|
580
|
+
if (!el || !el.isConnected) throw new Error("The view is not mounted, so there is nothing to capture.");
|
|
581
|
+
return el;
|
|
582
|
+
};
|
|
583
|
+
const visible = () => {
|
|
584
|
+
const el = getElement();
|
|
585
|
+
if (!el || !el.clientWidth || !el.clientHeight) return null;
|
|
586
|
+
return { x: el.scrollLeft, y: el.scrollTop, width: el.clientWidth, height: el.clientHeight };
|
|
587
|
+
};
|
|
588
|
+
const overlays = _nullishCoalesce(options.overlaySelectors, () => ( CAPTURE_OVERLAY_SELECTORS));
|
|
589
|
+
return {
|
|
590
|
+
units: "CSS pixels",
|
|
591
|
+
viewport: visible,
|
|
592
|
+
content: () => {
|
|
593
|
+
const el = getElement();
|
|
594
|
+
if (!el || !el.scrollWidth || !el.scrollHeight) return null;
|
|
595
|
+
return { x: 0, y: 0, width: el.scrollWidth, height: el.scrollHeight };
|
|
596
|
+
},
|
|
597
|
+
overlays: "agent cursors and presence tags",
|
|
598
|
+
maxScale: 2,
|
|
599
|
+
render: (request) => {
|
|
600
|
+
const el = require2();
|
|
601
|
+
const exclude = [CAPTURE_EXCLUDE_SELECTOR, ..._nullishCoalesce(options.exclude, () => ( [])), ...request.includeOverlays ? [] : overlays];
|
|
602
|
+
const rasterize = _nullishCoalesce(options.rasterize, () => ( rasterizeElement));
|
|
603
|
+
return rasterize(el, {
|
|
604
|
+
width: request.rect.width,
|
|
605
|
+
height: request.rect.height,
|
|
606
|
+
pixelWidth: request.width,
|
|
607
|
+
pixelHeight: request.height,
|
|
608
|
+
format: request.format,
|
|
609
|
+
quality: request.quality,
|
|
610
|
+
background: options.background,
|
|
611
|
+
exclude,
|
|
612
|
+
// Scrolling does not survive cloning: shift the content so the rect's corner is at the top left.
|
|
613
|
+
prepare: (clone) => {
|
|
614
|
+
const shift = `translate(${-request.rect.x}px, ${-request.rect.y}px)`;
|
|
615
|
+
const inner = clone.ownerDocument.createElement("div");
|
|
616
|
+
inner.setAttribute("style", `transform:${shift};transform-origin:0 0;width:${el.scrollWidth}px;height:${el.scrollHeight}px`);
|
|
617
|
+
while (clone.firstChild) inner.appendChild(clone.firstChild);
|
|
618
|
+
clone.appendChild(inner);
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
436
631
|
|
|
437
632
|
|
|
438
633
|
|
|
@@ -454,5 +649,5 @@ var EDITOR_MCP_TOOLS = [
|
|
|
454
649
|
|
|
455
650
|
|
|
456
651
|
|
|
457
|
-
exports.MCP_TOOL_GET_EDITOR_STATE = MCP_TOOL_GET_EDITOR_STATE; exports.MCP_TOOL_EDIT_CANVAS = MCP_TOOL_EDIT_CANVAS; exports.MCP_TOOL_EDIT_PROMPT = MCP_TOOL_EDIT_PROMPT; exports.MCP_TOOL_VIEW_EDITOR = MCP_TOOL_VIEW_EDITOR; exports.MCP_TOOL_CANVAS_ADD_NODE = MCP_TOOL_CANVAS_ADD_NODE; exports.MCP_TOOL_CANVAS_REMOVE_NODES = MCP_TOOL_CANVAS_REMOVE_NODES; exports.MCP_TOOL_CANVAS_CONNECT = MCP_TOOL_CANVAS_CONNECT; exports.MCP_TOOL_CANVAS_UPDATE_NODE = MCP_TOOL_CANVAS_UPDATE_NODE; exports.MCP_TOOL_CANVAS_LAYOUT = MCP_TOOL_CANVAS_LAYOUT; exports.MCP_TOOL_CANVAS_SELECT = MCP_TOOL_CANVAS_SELECT; exports.MCP_TOOL_CANVAS_HIGHLIGHT = MCP_TOOL_CANVAS_HIGHLIGHT; exports.MCP_TOOL_PROMPT_INSERT_TEXT = MCP_TOOL_PROMPT_INSERT_TEXT; exports.MCP_TOOL_PROMPT_REPLACE_RANGE = MCP_TOOL_PROMPT_REPLACE_RANGE; exports.MCP_TOOL_PROMPT_SET_VARIABLE = MCP_TOOL_PROMPT_SET_VARIABLE; exports.MCP_TOOL_PROMPT_SELECT = MCP_TOOL_PROMPT_SELECT; exports.EDITOR_CANVAS_TOOLS = EDITOR_CANVAS_TOOLS; exports.EDITOR_PROMPT_TOOLS = EDITOR_PROMPT_TOOLS; exports.EDIT_OPERATION_REQUIRED_ARGUMENTS = EDIT_OPERATION_REQUIRED_ARGUMENTS; exports.EXPORT_EXCLUDED_SELECTORS = EXPORT_EXCLUDED_SELECTORS; exports.EDITOR_MCP_TOOLS = EDITOR_MCP_TOOLS;
|
|
458
|
-
//# sourceMappingURL=chunk-
|
|
652
|
+
exports.MCP_TOOL_GET_EDITOR_STATE = MCP_TOOL_GET_EDITOR_STATE; exports.MCP_TOOL_EDIT_CANVAS = MCP_TOOL_EDIT_CANVAS; exports.MCP_TOOL_EDIT_PROMPT = MCP_TOOL_EDIT_PROMPT; exports.MCP_TOOL_VIEW_EDITOR = MCP_TOOL_VIEW_EDITOR; exports.MCP_TOOL_CANVAS_ADD_NODE = MCP_TOOL_CANVAS_ADD_NODE; exports.MCP_TOOL_CANVAS_REMOVE_NODES = MCP_TOOL_CANVAS_REMOVE_NODES; exports.MCP_TOOL_CANVAS_CONNECT = MCP_TOOL_CANVAS_CONNECT; exports.MCP_TOOL_CANVAS_UPDATE_NODE = MCP_TOOL_CANVAS_UPDATE_NODE; exports.MCP_TOOL_CANVAS_LAYOUT = MCP_TOOL_CANVAS_LAYOUT; exports.MCP_TOOL_CANVAS_SELECT = MCP_TOOL_CANVAS_SELECT; exports.MCP_TOOL_CANVAS_HIGHLIGHT = MCP_TOOL_CANVAS_HIGHLIGHT; exports.MCP_TOOL_PROMPT_INSERT_TEXT = MCP_TOOL_PROMPT_INSERT_TEXT; exports.MCP_TOOL_PROMPT_REPLACE_RANGE = MCP_TOOL_PROMPT_REPLACE_RANGE; exports.MCP_TOOL_PROMPT_SET_VARIABLE = MCP_TOOL_PROMPT_SET_VARIABLE; exports.MCP_TOOL_PROMPT_SELECT = MCP_TOOL_PROMPT_SELECT; exports.EDITOR_CANVAS_TOOLS = EDITOR_CANVAS_TOOLS; exports.EDITOR_PROMPT_TOOLS = EDITOR_PROMPT_TOOLS; exports.EDIT_OPERATION_REQUIRED_ARGUMENTS = EDIT_OPERATION_REQUIRED_ARGUMENTS; exports.EXPORT_EXCLUDED_SELECTORS = EXPORT_EXCLUDED_SELECTORS; exports.EDITOR_MCP_TOOLS = EDITOR_MCP_TOOLS; exports.cloneElementWithStyles = cloneElementWithStyles; exports.elementToSvg = elementToSvg; exports.rasterizeElement = rasterizeElement; exports.CAPTURE_OVERLAY_SELECTORS = CAPTURE_OVERLAY_SELECTORS; exports.CAPTURE_EXCLUDE_SELECTOR = CAPTURE_EXCLUDE_SELECTOR; exports.createElementCaptureSurface = createElementCaptureSurface;
|
|
653
|
+
//# sourceMappingURL=chunk-EI2MOVQ3.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/chunk-EI2MOVQ3.cjs","../src/tools/definitions.ts","../src/tools/dom-capture.ts"],"names":["require"],"mappings":"AAAA;ACKO,IAAM,0BAAA,EA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AACF,IAAA;AACD,EAAA;AACD;AF8Wa;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/editor/editor/packages/core/dist/chunk-EI2MOVQ3.cjs","sourcesContent":[null,"/**\n * Standard MCP Tool Definitions for @pixerate/editor.\n * Compatible with the Model Context Protocol (MCP) tool specification schema.\n */\n\nexport const MCP_TOOL_GET_EDITOR_STATE = {\n\tname: 'get_editor_state',\n\ttitle: 'Get editor state',\n\tannotations: {\n\t\ttitle: 'Get editor state',\n\t\treadOnlyHint: true,\n\t\tdestructiveHint: false,\n\t\tidempotentHint: true,\n\t\topenWorldHint: false\n\t},\n\tdescription:\n\t\t'Retrieves the current state of the document, variables, selection, and canvas graph (nodes and edges).',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tincludeDocument: {\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdescription: 'Whether to include the prompt document text and variables (default: true).'\n\t\t\t},\n\t\t\tincludeCanvas: {\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdescription: 'Whether to include the canvas nodes and edges (default: true).'\n\t\t\t}\n\t\t}\n\t}\n} as const;\n\nexport const MCP_TOOL_EDIT_CANVAS = {\n\tname: 'edit_canvas',\n\ttitle: 'Edit the canvas',\n\tannotations: {\n\t\ttitle: 'Edit the canvas',\n\t\treadOnlyHint: false,\n\t\tdestructiveHint: true,\n\t\tidempotentHint: false,\n\t\topenWorldHint: false\n\t},\n\tdescription:\n\t\t'Applies high-level structural operations to the visual canvas (adding nodes, connecting edges, organizing layout, or moving elements). ' +\n\t\t'Prefer the per-operation canvas_* tools when the host exposes them. Returns the ids of created nodes and edges.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\toperation: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: [\n\t\t\t\t\t'add_node',\n\t\t\t\t\t'remove_nodes',\n\t\t\t\t\t'connect',\n\t\t\t\t\t'update_node',\n\t\t\t\t\t'layout',\n\t\t\t\t\t'select',\n\t\t\t\t\t'highlight'\n\t\t\t\t],\n\t\t\t\tdescription: 'The canvas operation to execute.'\n\t\t\t},\n\t\t\tnode: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdescription: 'Node definition when operation is add_node. Can omit position to auto-place.'\n\t\t\t},\n\t\t\tnearNodeId: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Anchor node ID to position beside using collision-aware placement.'\n\t\t\t},\n\t\t\tside: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: ['top', 'right', 'bottom', 'left'],\n\t\t\t\tdescription: 'Side of the anchor node to place the new node beside.'\n\t\t\t},\n\t\t\tnodeIds: {\n\t\t\t\ttype: 'array',\n\t\t\t\titems: { type: 'string' },\n\t\t\t\tdescription: 'Array of node IDs for remove_nodes, select, or highlight.'\n\t\t\t},\n\t\t\tid: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Node ID for update_node (or pass `node: { id, data }`).'\n\t\t\t},\n\t\t\tdata: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdescription: 'Data fields to merge into the node for update_node.'\n\t\t\t},\n\t\t\tcolor: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'CSS color for highlight (default #3b82f6).'\n\t\t\t},\n\t\t\tdurationMs: {\n\t\t\t\ttype: 'integer',\n\t\t\t\tminimum: 0,\n\t\t\t\tdescription: 'How long the highlight lasts in ms (default 2000).'\n\t\t\t},\n\t\t\tsource: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Source node ID for connect operation.'\n\t\t\t},\n\t\t\ttarget: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Target node ID for connect operation.'\n\t\t\t},\n\t\t\tlabel: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Optional edge label for connect operation.'\n\t\t\t},\n\t\t\tdirection: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: ['LR', 'TB', 'RL', 'BT'],\n\t\t\t\tdescription: 'Layout direction (default LR).'\n\t\t\t},\n\t\t\tincremental: {\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdescription: 'Preserve existing node coordinates and blend layout (default true).'\n\t\t\t}\n\t\t},\n\t\trequired: ['operation']\n\t}\n} as const;\n\nexport const MCP_TOOL_EDIT_PROMPT = {\n\tname: 'edit_prompt',\n\ttitle: 'Edit the prompt',\n\tannotations: {\n\t\ttitle: 'Edit the prompt',\n\t\treadOnlyHint: false,\n\t\tdestructiveHint: true,\n\t\tidempotentHint: false,\n\t\topenWorldHint: false\n\t},\n\tdescription:\n\t\t'Applies edits to the prompt template document, including inserting text, replacing ranges, and setting variables.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\toperation: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: ['insert_text', 'replace_range', 'set_variable', 'select'],\n\t\t\t\tdescription: 'The prompt operation to execute.'\n\t\t\t},\n\t\t\ttext: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Text to insert or replace.'\n\t\t\t},\n\t\t\tat: {\n\t\t\t\ttype: 'integer',\n\t\t\t\tminimum: 0,\n\t\t\t\tdescription: 'Position to insert text at.'\n\t\t\t},\n\t\t\tfrom: {\n\t\t\t\ttype: 'integer',\n\t\t\t\tminimum: 0,\n\t\t\t\tdescription: 'Start offset for replace_range or select.'\n\t\t\t},\n\t\t\tto: {\n\t\t\t\ttype: 'integer',\n\t\t\t\tminimum: 0,\n\t\t\t\tdescription: 'End offset for replace_range or select.'\n\t\t\t},\n\t\t\tname: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Variable name for set_variable.'\n\t\t\t},\n\t\t\tvalue: {\n\t\t\t\tdescription: 'Variable value for set_variable.'\n\t\t\t}\n\t\t},\n\t\trequired: ['operation']\n\t}\n} as const;\n\nexport const MCP_TOOL_VIEW_EDITOR = {\n\tname: 'view_editor',\n\ttitle: 'View the editor',\n\tannotations: {\n\t\ttitle: 'View the editor',\n\t\treadOnlyHint: true,\n\t\tdestructiveHint: false,\n\t\tidempotentHint: true,\n\t\topenWorldHint: false\n\t},\n\tdescription:\n\t\t'Captures a visual image snapshot (JPEG or PNG) of the editor canvas or viewport for multimodal evaluation. Active agent cursor indicators are automatically excluded from the snapshot.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tscope: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: ['viewport', 'canvas'],\n\t\t\t\tdescription: 'Whether to capture only the visible viewport or the full canvas bounding box (default: viewport).'\n\t\t\t},\n\t\t\tformat: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: ['jpeg', 'png'],\n\t\t\t\tdescription: 'Image format of the base64 snapshot (default: jpeg).'\n\t\t\t},\n\t\t\tmaxEdge: {\n\t\t\t\ttype: 'integer',\n\t\t\t\tdescription: 'Maximum width or height dimension in pixels (default: 1024).'\n\t\t\t}\n\t\t}\n\t}\n} as const;\n\n// ---------------------------------------------------------------------------\n// Per-operation tools: one strict schema per canvas / prompt operation.\n// ---------------------------------------------------------------------------\n\nconst WRITE_ANNOTATIONS = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false } as const;\nconst DESTRUCTIVE_ANNOTATIONS = { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false } as const;\nconst IDEMPOTENT_ANNOTATIONS = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false } as const;\n\nconst NODE_IDS = {\n\ttype: 'array',\n\titems: { type: 'string', minLength: 1 },\n\tminItems: 1,\n\tuniqueItems: true,\n\tdescription: 'Node ids (from get_editor_state).'\n} as const;\n\nconst POSITION = {\n\ttype: 'object',\n\tproperties: { x: { type: 'number' }, y: { type: 'number' } },\n\trequired: ['x', 'y'],\n\tadditionalProperties: false\n} as const;\n\nconst DOC_POSITION = { type: 'integer', minimum: 0 } as const;\n\nexport const MCP_TOOL_CANVAS_ADD_NODE = {\n\tname: 'canvas_add_node',\n\ttitle: 'Add a canvas node',\n\tannotations: { title: 'Add a canvas node', ...WRITE_ANNOTATIONS },\n\tdescription:\n\t\t'Adds a node to the canvas. Without `position` it is placed without overlaps beside `nearNodeId` (and connected from it) ' +\n\t\t'or beside the last node. Returns the new node id (generated unless you pass `node.id`) and the id of the connecting edge.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tnode: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdescription: 'The node. Extra host-specific fields are kept.',\n\t\t\t\tproperties: {\n\t\t\t\t\tid: { type: 'string', minLength: 1, description: 'Node id (default: generated). Must be unused.' },\n\t\t\t\t\ttype: { type: 'string', description: 'Node type registered by the host.' },\n\t\t\t\t\tdata: { type: 'object', description: 'Node data (e.g. { \"label\": \"...\" }).' },\n\t\t\t\t\tposition: { ...POSITION, description: 'Canvas coordinates (default: auto-placed).' },\n\t\t\t\t\twidth: { type: 'number', exclusiveMinimum: 0 },\n\t\t\t\t\theight: { type: 'number', exclusiveMinimum: 0 },\n\t\t\t\t\tparentId: { type: 'string', description: 'Parent (group/frame) node id.' }\n\t\t\t\t}\n\t\t\t},\n\t\t\tnearNodeId: { type: 'string', description: 'Existing node to place the new node beside and connect from.' },\n\t\t\tside: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: ['top', 'right', 'bottom', 'left'],\n\t\t\t\tdescription: 'Side of `nearNodeId` to place the node on (default right).'\n\t\t\t}\n\t\t},\n\t\trequired: ['node'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_CANVAS_REMOVE_NODES = {\n\tname: 'canvas_remove_nodes',\n\ttitle: 'Remove canvas nodes',\n\tannotations: { title: 'Remove canvas nodes', ...DESTRUCTIVE_ANNOTATIONS },\n\tdescription: 'Removes nodes (and their edges) from the canvas. Every id must exist.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: { nodeIds: NODE_IDS },\n\t\trequired: ['nodeIds'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_CANVAS_CONNECT = {\n\tname: 'canvas_connect',\n\ttitle: 'Connect canvas nodes',\n\tannotations: { title: 'Connect canvas nodes', ...WRITE_ANNOTATIONS },\n\tdescription: 'Adds an edge from one existing node to another. Returns the new edge id.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tsource: { type: 'string', minLength: 1, description: 'Source node id.' },\n\t\t\ttarget: { type: 'string', minLength: 1, description: 'Target node id.' },\n\t\t\tlabel: { type: 'string', description: 'Edge label.' }\n\t\t},\n\t\trequired: ['source', 'target'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_CANVAS_UPDATE_NODE = {\n\tname: 'canvas_update_node',\n\ttitle: 'Update a canvas node',\n\tannotations: { title: 'Update a canvas node', ...DESTRUCTIVE_ANNOTATIONS, idempotentHint: true },\n\tdescription: \"Merges fields into an existing node's data.\",\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tid: { type: 'string', minLength: 1, description: 'Node id.' },\n\t\t\tdata: { type: 'object', description: 'Data fields to merge (e.g. { \"label\": \"New\" }).' }\n\t\t},\n\t\trequired: ['id', 'data'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_CANVAS_LAYOUT = {\n\tname: 'canvas_layout',\n\ttitle: 'Lay out the canvas',\n\tannotations: { title: 'Lay out the canvas', ...IDEMPOTENT_ANNOTATIONS },\n\tdescription: 'Arranges the canvas graph automatically.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tdirection: { type: 'string', enum: ['LR', 'TB', 'RL', 'BT'], description: 'Layout direction (default LR).' },\n\t\t\tincremental: {\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdescription: 'Keep nodes that already have a position where they are (default true).'\n\t\t\t}\n\t\t},\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_CANVAS_SELECT = {\n\tname: 'canvas_select',\n\ttitle: 'Select canvas nodes',\n\tannotations: { title: 'Select canvas nodes', ...IDEMPOTENT_ANNOTATIONS },\n\tdescription: 'Replaces the canvas selection with these nodes (an empty list clears it).',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: { nodeIds: { ...NODE_IDS, minItems: 0 } },\n\t\trequired: ['nodeIds'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_CANVAS_HIGHLIGHT = {\n\tname: 'canvas_highlight',\n\ttitle: 'Highlight canvas nodes',\n\tannotations: { title: 'Highlight canvas nodes', ...IDEMPOTENT_ANNOTATIONS },\n\tdescription: 'Briefly highlights nodes to draw the user\\'s attention to them.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tnodeIds: NODE_IDS,\n\t\t\tcolor: { type: 'string', description: 'CSS color (default #3b82f6).' },\n\t\t\tdurationMs: { type: 'integer', minimum: 0, maximum: 60000, description: 'Duration in ms (default 2000).' }\n\t\t},\n\t\trequired: ['nodeIds'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_PROMPT_INSERT_TEXT = {\n\tname: 'prompt_insert_text',\n\ttitle: 'Insert prompt text',\n\tannotations: { title: 'Insert prompt text', ...WRITE_ANNOTATIONS },\n\tdescription: 'Inserts text into the prompt at a position, or at the cursor when `at` is omitted.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\ttext: { type: 'string', description: 'Text to insert.' },\n\t\t\tat: { ...DOC_POSITION, description: 'Position (as in get_editor_state `document.selection`).' }\n\t\t},\n\t\trequired: ['text'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_PROMPT_REPLACE_RANGE = {\n\tname: 'prompt_replace_range',\n\ttitle: 'Replace prompt text',\n\tannotations: { title: 'Replace prompt text', ...DESTRUCTIVE_ANNOTATIONS },\n\tdescription: 'Replaces the prompt text between two positions (an empty text deletes it).',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tfrom: { ...DOC_POSITION, description: 'Start position.' },\n\t\t\tto: { ...DOC_POSITION, description: 'End position (>= from).' },\n\t\t\ttext: { type: 'string', description: 'Replacement text.' }\n\t\t},\n\t\trequired: ['from', 'to', 'text'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_PROMPT_SET_VARIABLE = {\n\tname: 'prompt_set_variable',\n\ttitle: 'Set a prompt variable',\n\tannotations: { title: 'Set a prompt variable', ...DESTRUCTIVE_ANNOTATIONS, idempotentHint: true },\n\tdescription: 'Sets the value of a template variable used by the prompt.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tname: { type: 'string', minLength: 1, description: 'Variable name.' },\n\t\t\tvalue: { description: 'Variable value (any JSON value).' }\n\t\t},\n\t\trequired: ['name', 'value'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_PROMPT_SELECT = {\n\tname: 'prompt_select',\n\ttitle: 'Select prompt text',\n\tannotations: { title: 'Select prompt text', ...IDEMPOTENT_ANNOTATIONS },\n\tdescription: 'Selects the prompt text between two positions (from === to places the cursor).',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tfrom: { ...DOC_POSITION, description: 'Start position.' },\n\t\t\tto: { ...DOC_POSITION, description: 'End position (>= from).' }\n\t\t},\n\t\trequired: ['from', 'to'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\n/** Per-operation canvas tools, the strict alternative to `edit_canvas`. */\nexport const EDITOR_CANVAS_TOOLS = [\n\tMCP_TOOL_CANVAS_ADD_NODE,\n\tMCP_TOOL_CANVAS_REMOVE_NODES,\n\tMCP_TOOL_CANVAS_CONNECT,\n\tMCP_TOOL_CANVAS_UPDATE_NODE,\n\tMCP_TOOL_CANVAS_LAYOUT,\n\tMCP_TOOL_CANVAS_SELECT,\n\tMCP_TOOL_CANVAS_HIGHLIGHT\n] as const;\n\n/** Per-operation prompt tools, the strict alternative to `edit_prompt`. */\nexport const EDITOR_PROMPT_TOOLS = [\n\tMCP_TOOL_PROMPT_INSERT_TEXT,\n\tMCP_TOOL_PROMPT_REPLACE_RANGE,\n\tMCP_TOOL_PROMPT_SET_VARIABLE,\n\tMCP_TOOL_PROMPT_SELECT\n] as const;\n\n/**\n * Arguments each `edit_canvas` / `edit_prompt` operation needs, used to tell\n * an agent exactly what is missing (the combined schemas cannot express it).\n */\nexport const EDIT_OPERATION_REQUIRED_ARGUMENTS: Readonly<Record<'edit_canvas' | 'edit_prompt', Readonly<Record<string, readonly string[]>>>> = {\n\tedit_canvas: {\n\t\tadd_node: ['node'],\n\t\tremove_nodes: ['nodeIds'],\n\t\tconnect: ['source', 'target'],\n\t\tupdate_node: ['id'],\n\t\tlayout: [],\n\t\tselect: ['nodeIds'],\n\t\thighlight: ['nodeIds']\n\t},\n\tedit_prompt: {\n\t\tinsert_text: ['text'],\n\t\treplace_range: ['from', 'to', 'text'],\n\t\tset_variable: ['name'],\n\t\tselect: ['from', 'to']\n\t}\n};\n\n/**\n * CSS selectors for ephemeral UI overlays (such as agent cursors, presence tags, and transient bubbles)\n * that should be excluded during canvas image export and visual snapshot generation.\n */\nexport const EXPORT_EXCLUDED_SELECTORS = [\n\t'.pixerate-presence',\n\t'.agent-presence',\n\t'.ursula-presence'\n] as const;\n\nexport const EDITOR_MCP_TOOLS = [\n\tMCP_TOOL_GET_EDITOR_STATE,\n\tMCP_TOOL_EDIT_CANVAS,\n\tMCP_TOOL_EDIT_PROMPT,\n\tMCP_TOOL_VIEW_EDITOR\n] as const;\n\n","import type { CaptureFormat, CaptureRect, CaptureSurface, CapturedImage } from './capture.js';\nimport { EXPORT_EXCLUDED_SELECTORS } from './definitions.js';\n\nexport interface RasterizeElementOptions {\n\t/** CSS size of the drawn box (default: the element's client size). */\n\twidth?: number;\n\theight?: number;\n\t/** Output size in pixels (default: the CSS size). */\n\tpixelWidth?: number;\n\tpixelHeight?: number;\n\tformat?: CaptureFormat;\n\t/** JPEG quality, 0-1 (default 0.85). */\n\tquality?: number;\n\t/** Fill behind the element (default: its computed background, else white for JPEG and transparent for PNG). */\n\tbackground?: string;\n\t/** Selectors of elements (and their subtrees) to leave out. */\n\texclude?: readonly string[];\n\t/** Adjusts the styled clone before it is drawn (e.g. moves a viewport transform). */\n\tprepare?: (clone: HTMLElement) => void;\n}\n\nconst NO_DOM =\n\t'Capturing needs a browser DOM (document, Image, XMLSerializer and a 2D canvas); it is not available in this environment.';\n\nconst SKIPPED_TAGS = new Set(['SCRIPT', 'NOSCRIPT', 'TEMPLATE', 'LINK', 'META', 'STYLE']);\n\nfunction styleText(style: CSSStyleDeclaration): string {\n\tlet text = '';\n\tfor (let i = 0; i < style.length; i++) {\n\t\tconst name = style[i];\n\t\tconst priority = style.getPropertyPriority(name);\n\t\ttext += `${name}:${style.getPropertyValue(name)}${priority ? ` !${priority}` : ''};`;\n\t}\n\treturn text;\n}\n\nfunction imageSnapshot(source: HTMLCanvasElement | HTMLImageElement, doc: Document): string | null {\n\ttry {\n\t\tif (source.tagName === 'CANVAS') return (source as HTMLCanvasElement).toDataURL('image/png');\n\t\tconst img = source as HTMLImageElement;\n\t\tif (!img.complete || !img.naturalWidth || img.src.startsWith('data:')) return null;\n\t\tconst canvas = doc.createElement('canvas');\n\t\tcanvas.width = img.naturalWidth;\n\t\tcanvas.height = img.naturalHeight;\n\t\tconst context = canvas.getContext('2d');\n\t\tif (!context) return null;\n\t\tcontext.drawImage(img, 0, 0);\n\t\treturn canvas.toDataURL('image/png');\n\t} catch {\n\t\t// Cross-origin pixels taint the canvas; the image is drawn blank instead.\n\t\treturn null;\n\t}\n}\n\n/**\n * Deep-clones `element` with every computed style inlined, so the copy looks\n * the same outside the page's stylesheets (inside an SVG `<foreignObject>`).\n * Elements matching `exclude` are left out, canvases become images, and\n * same-origin images and form values are copied in.\n */\nexport function cloneElementWithStyles(element: Element, exclude: readonly string[] = []): HTMLElement {\n\tconst doc = element.ownerDocument;\n\tconst view = doc.defaultView;\n\tif (!view) throw new Error(NO_DOM);\n\tconst selector = exclude.join(',');\n\tconst copy = (source: Node): Node | null => {\n\t\tif (source.nodeType === 3) return source.cloneNode(false);\n\t\tif (source.nodeType !== 1) return null;\n\t\tconst el = source as Element;\n\t\tif (SKIPPED_TAGS.has(el.tagName.toUpperCase()) || (selector && el.matches(selector))) return null;\n\t\tlet clone: Element;\n\t\tif (el.tagName === 'CANVAS') {\n\t\t\tclone = doc.createElement('img');\n\t\t\tconst url = imageSnapshot(el as HTMLCanvasElement, doc);\n\t\t\tif (url) clone.setAttribute('src', url);\n\t\t} else {\n\t\t\tclone = el.cloneNode(false) as Element;\n\t\t\tif (el.tagName === 'IMG') {\n\t\t\t\tconst url = imageSnapshot(el as HTMLImageElement, doc);\n\t\t\t\tif (url) clone.setAttribute('src', url);\n\t\t\t\tclone.removeAttribute('srcset');\n\t\t\t}\n\t\t}\n\t\tclone.setAttribute('style', styleText(view.getComputedStyle(el)));\n\t\tif (el.tagName === 'INPUT') {\n\t\t\tconst input = el as HTMLInputElement;\n\t\t\tclone.setAttribute('value', input.value);\n\t\t\tif (input.checked) clone.setAttribute('checked', '');\n\t\t\telse clone.removeAttribute('checked');\n\t\t} else if (el.tagName === 'TEXTAREA') {\n\t\t\tclone.textContent = (el as HTMLTextAreaElement).value;\n\t\t\treturn clone;\n\t\t} else if (el.tagName === 'SELECT') {\n\t\t\t// Options are copied below; mark the chosen one.\n\t\t\tconst value = (el as HTMLSelectElement).value;\n\t\t\tfor (const child of Array.from(el.childNodes)) {\n\t\t\t\tconst option = copy(child);\n\t\t\t\tif (option && (option as Element).tagName === 'OPTION' && (option as HTMLOptionElement).value === value) {\n\t\t\t\t\t(option as Element).setAttribute('selected', '');\n\t\t\t\t}\n\t\t\t\tif (option) clone.appendChild(option);\n\t\t\t}\n\t\t\treturn clone;\n\t\t}\n\t\tfor (const child of Array.from(el.childNodes)) {\n\t\t\tconst next = copy(child);\n\t\t\tif (next) clone.appendChild(next);\n\t\t}\n\t\treturn clone;\n\t};\n\tconst root = copy(element);\n\tif (!root) throw new Error('The element to capture is excluded by the exclude selectors.');\n\treturn root as HTMLElement;\n}\n\n/** Wraps a styled clone in a standalone SVG of `width` × `height` CSS pixels. */\nexport function elementToSvg(clone: Element, width: number, height: number): string {\n\tconst doc = clone.ownerDocument;\n\tconst Serializer = (doc.defaultView as (Window & typeof globalThis) | null)?.XMLSerializer ?? (globalThis as { XMLSerializer?: typeof XMLSerializer }).XMLSerializer;\n\tif (!Serializer) throw new Error(NO_DOM);\n\tclone.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');\n\tconst xml = new Serializer().serializeToString(clone);\n\treturn (\n\t\t`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${width}\" height=\"${height}\" viewBox=\"0 0 ${width} ${height}\">` +\n\t\t`<foreignObject x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">${xml}</foreignObject></svg>`\n\t);\n}\n\n/**\n * Draws a DOM element into an image in the browser: its styled clone goes\n * into an SVG `<foreignObject>`, which is drawn onto a canvas. Web fonts that\n * are not installed locally fall back, pseudo-elements (`::before`) are not\n * drawn, and cross-origin images come out blank. Returns a `data:` URL.\n */\nexport async function rasterizeElement(element: HTMLElement, options: RasterizeElementOptions = {}): Promise<string> {\n\tconst doc = element.ownerDocument;\n\tconst view = doc?.defaultView as (Window & typeof globalThis) | null;\n\tif (!view?.Image) throw new Error(NO_DOM);\n\tconst width = Math.max(1, Math.round(options.width ?? element.clientWidth));\n\tconst height = Math.max(1, Math.round(options.height ?? element.clientHeight));\n\tconst pixelWidth = Math.max(1, Math.round(options.pixelWidth ?? width));\n\tconst pixelHeight = Math.max(1, Math.round(options.pixelHeight ?? height));\n\tconst format = options.format ?? 'png';\n\n\tconst clone = cloneElementWithStyles(element, options.exclude);\n\tconst background = options.background ?? view.getComputedStyle(element).backgroundColor;\n\tclone.style.width = `${width}px`;\n\tclone.style.height = `${height}px`;\n\tclone.style.margin = '0';\n\tclone.style.position = 'relative';\n\tclone.style.left = '0';\n\tclone.style.top = '0';\n\tclone.style.transform = 'none';\n\tclone.style.overflow = 'hidden';\n\toptions.prepare?.(clone);\n\tconst svg = elementToSvg(clone, width, height);\n\n\tconst canvas = doc.createElement('canvas');\n\tcanvas.width = pixelWidth;\n\tcanvas.height = pixelHeight;\n\tlet context: CanvasRenderingContext2D | null = null;\n\ttry {\n\t\tcontext = canvas.getContext('2d');\n\t} catch {\n\t\tcontext = null;\n\t}\n\tif (!context) throw new Error(NO_DOM);\n\tconst image = new view.Image();\n\tawait new Promise<void>((resolve, reject) => {\n\t\timage.onload = () => resolve();\n\t\timage.onerror = () => reject(new Error('The captured view could not be drawn as an image.'));\n\t\timage.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;\n\t});\n\tconst transparent = !background || background === 'transparent' || /rgba\\([^)]*,\\s*0\\)$/.test(background);\n\tif (!transparent || format === 'jpeg') {\n\t\tcontext.fillStyle = transparent ? '#ffffff' : background;\n\t\tcontext.fillRect(0, 0, pixelWidth, pixelHeight);\n\t}\n\tcontext.drawImage(image, 0, 0, pixelWidth, pixelHeight);\n\ttry {\n\t\treturn canvas.toDataURL(format === 'jpeg' ? 'image/jpeg' : 'image/png', options.quality ?? 0.85);\n\t} catch {\n\t\tthrow new Error('The browser refused to export the captured view (the canvas is tainted by cross-origin content).');\n\t}\n}\n\nexport interface ElementCaptureSurfaceOptions {\n\t/** The element to capture, or a getter (re-read on every call). */\n\telement: HTMLElement | null | undefined | (() => HTMLElement | null | undefined);\n\t/** Selectors left out of every capture (default none). */\n\texclude?: readonly string[];\n\t/** Selectors of transient overlays, left out unless `includeOverlays` (default `CAPTURE_OVERLAY_SELECTORS`). */\n\toverlaySelectors?: readonly string[];\n\t/** Fill behind the element (default its computed background). */\n\tbackground?: string;\n\t/** Swaps the drawing step (tests, or a library such as html-to-image). */\n\trasterize?: (element: HTMLElement, options: RasterizeElementOptions) => Promise<CapturedImage>;\n}\n\n/** Overlays left out of captures by default: agent cursors and presence tags. */\nexport const CAPTURE_OVERLAY_SELECTORS: readonly string[] = [...EXPORT_EXCLUDED_SELECTORS, '[data-capture=\"overlay\"]'];\n\n/** Elements marked `data-capture=\"exclude\"` are never captured. */\nexport const CAPTURE_EXCLUDE_SELECTOR = '[data-capture=\"exclude\"]';\n\n/**\n * A capture surface for any DOM element (a rich-text editor, a spreadsheet, a\n * panel): units are CSS pixels from the element's top-left corner; `viewport`\n * is its visible box and `content` its full scrollable area.\n */\nexport function createElementCaptureSurface(options: ElementCaptureSurfaceOptions): CaptureSurface {\n\tconst getElement = () => (typeof options.element === 'function' ? options.element() : options.element) ?? null;\n\tconst require = () => {\n\t\tconst el = getElement();\n\t\tif (!el || !el.isConnected) throw new Error('The view is not mounted, so there is nothing to capture.');\n\t\treturn el;\n\t};\n\tconst visible = (): CaptureRect | null => {\n\t\tconst el = getElement();\n\t\tif (!el || !el.clientWidth || !el.clientHeight) return null;\n\t\treturn { x: el.scrollLeft, y: el.scrollTop, width: el.clientWidth, height: el.clientHeight };\n\t};\n\tconst overlays = options.overlaySelectors ?? CAPTURE_OVERLAY_SELECTORS;\n\treturn {\n\t\tunits: 'CSS pixels',\n\t\tviewport: visible,\n\t\tcontent: () => {\n\t\t\tconst el = getElement();\n\t\t\tif (!el || !el.scrollWidth || !el.scrollHeight) return null;\n\t\t\treturn { x: 0, y: 0, width: el.scrollWidth, height: el.scrollHeight };\n\t\t},\n\t\toverlays: 'agent cursors and presence tags',\n\t\tmaxScale: 2,\n\t\trender: (request) => {\n\t\t\tconst el = require();\n\t\t\tconst exclude = [CAPTURE_EXCLUDE_SELECTOR, ...(options.exclude ?? []), ...(request.includeOverlays ? [] : overlays)];\n\t\t\tconst rasterize = options.rasterize ?? rasterizeElement;\n\t\t\treturn rasterize(el, {\n\t\t\t\twidth: request.rect.width,\n\t\t\t\theight: request.rect.height,\n\t\t\t\tpixelWidth: request.width,\n\t\t\t\tpixelHeight: request.height,\n\t\t\t\tformat: request.format,\n\t\t\t\tquality: request.quality,\n\t\t\t\tbackground: options.background,\n\t\t\t\texclude,\n\t\t\t\t// Scrolling does not survive cloning: shift the content so the rect's corner is at the top left.\n\t\t\t\tprepare: (clone) => {\n\t\t\t\t\tconst shift = `translate(${-request.rect.x}px, ${-request.rect.y}px)`;\n\t\t\t\t\tconst inner = clone.ownerDocument.createElement('div');\n\t\t\t\t\tinner.setAttribute('style', `transform:${shift};transform-origin:0 0;width:${el.scrollWidth}px;height:${el.scrollHeight}px`);\n\t\t\t\t\twhile (clone.firstChild) inner.appendChild(clone.firstChild);\n\t\t\t\t\tclone.appendChild(inner);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=chunk-FURT6ZFZ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/chunk-FURT6ZFZ.cjs"],"names":[],"mappings":"AAAA","file":"/home/runner/work/editor/editor/packages/core/dist/chunk-FURT6ZFZ.cjs"}
|
|
@@ -433,6 +433,195 @@ var EDITOR_MCP_TOOLS = [
|
|
|
433
433
|
MCP_TOOL_VIEW_EDITOR
|
|
434
434
|
];
|
|
435
435
|
|
|
436
|
+
// src/tools/dom-capture.ts
|
|
437
|
+
var NO_DOM = "Capturing needs a browser DOM (document, Image, XMLSerializer and a 2D canvas); it is not available in this environment.";
|
|
438
|
+
var SKIPPED_TAGS = /* @__PURE__ */ new Set(["SCRIPT", "NOSCRIPT", "TEMPLATE", "LINK", "META", "STYLE"]);
|
|
439
|
+
function styleText(style) {
|
|
440
|
+
let text = "";
|
|
441
|
+
for (let i = 0; i < style.length; i++) {
|
|
442
|
+
const name = style[i];
|
|
443
|
+
const priority = style.getPropertyPriority(name);
|
|
444
|
+
text += `${name}:${style.getPropertyValue(name)}${priority ? ` !${priority}` : ""};`;
|
|
445
|
+
}
|
|
446
|
+
return text;
|
|
447
|
+
}
|
|
448
|
+
function imageSnapshot(source, doc) {
|
|
449
|
+
try {
|
|
450
|
+
if (source.tagName === "CANVAS") return source.toDataURL("image/png");
|
|
451
|
+
const img = source;
|
|
452
|
+
if (!img.complete || !img.naturalWidth || img.src.startsWith("data:")) return null;
|
|
453
|
+
const canvas = doc.createElement("canvas");
|
|
454
|
+
canvas.width = img.naturalWidth;
|
|
455
|
+
canvas.height = img.naturalHeight;
|
|
456
|
+
const context = canvas.getContext("2d");
|
|
457
|
+
if (!context) return null;
|
|
458
|
+
context.drawImage(img, 0, 0);
|
|
459
|
+
return canvas.toDataURL("image/png");
|
|
460
|
+
} catch {
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function cloneElementWithStyles(element, exclude = []) {
|
|
465
|
+
const doc = element.ownerDocument;
|
|
466
|
+
const view = doc.defaultView;
|
|
467
|
+
if (!view) throw new Error(NO_DOM);
|
|
468
|
+
const selector = exclude.join(",");
|
|
469
|
+
const copy = (source) => {
|
|
470
|
+
if (source.nodeType === 3) return source.cloneNode(false);
|
|
471
|
+
if (source.nodeType !== 1) return null;
|
|
472
|
+
const el = source;
|
|
473
|
+
if (SKIPPED_TAGS.has(el.tagName.toUpperCase()) || selector && el.matches(selector)) return null;
|
|
474
|
+
let clone;
|
|
475
|
+
if (el.tagName === "CANVAS") {
|
|
476
|
+
clone = doc.createElement("img");
|
|
477
|
+
const url = imageSnapshot(el, doc);
|
|
478
|
+
if (url) clone.setAttribute("src", url);
|
|
479
|
+
} else {
|
|
480
|
+
clone = el.cloneNode(false);
|
|
481
|
+
if (el.tagName === "IMG") {
|
|
482
|
+
const url = imageSnapshot(el, doc);
|
|
483
|
+
if (url) clone.setAttribute("src", url);
|
|
484
|
+
clone.removeAttribute("srcset");
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
clone.setAttribute("style", styleText(view.getComputedStyle(el)));
|
|
488
|
+
if (el.tagName === "INPUT") {
|
|
489
|
+
const input = el;
|
|
490
|
+
clone.setAttribute("value", input.value);
|
|
491
|
+
if (input.checked) clone.setAttribute("checked", "");
|
|
492
|
+
else clone.removeAttribute("checked");
|
|
493
|
+
} else if (el.tagName === "TEXTAREA") {
|
|
494
|
+
clone.textContent = el.value;
|
|
495
|
+
return clone;
|
|
496
|
+
} else if (el.tagName === "SELECT") {
|
|
497
|
+
const value = el.value;
|
|
498
|
+
for (const child of Array.from(el.childNodes)) {
|
|
499
|
+
const option = copy(child);
|
|
500
|
+
if (option && option.tagName === "OPTION" && option.value === value) {
|
|
501
|
+
option.setAttribute("selected", "");
|
|
502
|
+
}
|
|
503
|
+
if (option) clone.appendChild(option);
|
|
504
|
+
}
|
|
505
|
+
return clone;
|
|
506
|
+
}
|
|
507
|
+
for (const child of Array.from(el.childNodes)) {
|
|
508
|
+
const next = copy(child);
|
|
509
|
+
if (next) clone.appendChild(next);
|
|
510
|
+
}
|
|
511
|
+
return clone;
|
|
512
|
+
};
|
|
513
|
+
const root = copy(element);
|
|
514
|
+
if (!root) throw new Error("The element to capture is excluded by the exclude selectors.");
|
|
515
|
+
return root;
|
|
516
|
+
}
|
|
517
|
+
function elementToSvg(clone, width, height) {
|
|
518
|
+
const doc = clone.ownerDocument;
|
|
519
|
+
const Serializer = doc.defaultView?.XMLSerializer ?? globalThis.XMLSerializer;
|
|
520
|
+
if (!Serializer) throw new Error(NO_DOM);
|
|
521
|
+
clone.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
|
|
522
|
+
const xml = new Serializer().serializeToString(clone);
|
|
523
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}"><foreignObject x="0" y="0" width="100%" height="100%">${xml}</foreignObject></svg>`;
|
|
524
|
+
}
|
|
525
|
+
async function rasterizeElement(element, options = {}) {
|
|
526
|
+
const doc = element.ownerDocument;
|
|
527
|
+
const view = doc?.defaultView;
|
|
528
|
+
if (!view?.Image) throw new Error(NO_DOM);
|
|
529
|
+
const width = Math.max(1, Math.round(options.width ?? element.clientWidth));
|
|
530
|
+
const height = Math.max(1, Math.round(options.height ?? element.clientHeight));
|
|
531
|
+
const pixelWidth = Math.max(1, Math.round(options.pixelWidth ?? width));
|
|
532
|
+
const pixelHeight = Math.max(1, Math.round(options.pixelHeight ?? height));
|
|
533
|
+
const format = options.format ?? "png";
|
|
534
|
+
const clone = cloneElementWithStyles(element, options.exclude);
|
|
535
|
+
const background = options.background ?? view.getComputedStyle(element).backgroundColor;
|
|
536
|
+
clone.style.width = `${width}px`;
|
|
537
|
+
clone.style.height = `${height}px`;
|
|
538
|
+
clone.style.margin = "0";
|
|
539
|
+
clone.style.position = "relative";
|
|
540
|
+
clone.style.left = "0";
|
|
541
|
+
clone.style.top = "0";
|
|
542
|
+
clone.style.transform = "none";
|
|
543
|
+
clone.style.overflow = "hidden";
|
|
544
|
+
options.prepare?.(clone);
|
|
545
|
+
const svg = elementToSvg(clone, width, height);
|
|
546
|
+
const canvas = doc.createElement("canvas");
|
|
547
|
+
canvas.width = pixelWidth;
|
|
548
|
+
canvas.height = pixelHeight;
|
|
549
|
+
let context = null;
|
|
550
|
+
try {
|
|
551
|
+
context = canvas.getContext("2d");
|
|
552
|
+
} catch {
|
|
553
|
+
context = null;
|
|
554
|
+
}
|
|
555
|
+
if (!context) throw new Error(NO_DOM);
|
|
556
|
+
const image = new view.Image();
|
|
557
|
+
await new Promise((resolve, reject) => {
|
|
558
|
+
image.onload = () => resolve();
|
|
559
|
+
image.onerror = () => reject(new Error("The captured view could not be drawn as an image."));
|
|
560
|
+
image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
|
|
561
|
+
});
|
|
562
|
+
const transparent = !background || background === "transparent" || /rgba\([^)]*,\s*0\)$/.test(background);
|
|
563
|
+
if (!transparent || format === "jpeg") {
|
|
564
|
+
context.fillStyle = transparent ? "#ffffff" : background;
|
|
565
|
+
context.fillRect(0, 0, pixelWidth, pixelHeight);
|
|
566
|
+
}
|
|
567
|
+
context.drawImage(image, 0, 0, pixelWidth, pixelHeight);
|
|
568
|
+
try {
|
|
569
|
+
return canvas.toDataURL(format === "jpeg" ? "image/jpeg" : "image/png", options.quality ?? 0.85);
|
|
570
|
+
} catch {
|
|
571
|
+
throw new Error("The browser refused to export the captured view (the canvas is tainted by cross-origin content).");
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
var CAPTURE_OVERLAY_SELECTORS = [...EXPORT_EXCLUDED_SELECTORS, '[data-capture="overlay"]'];
|
|
575
|
+
var CAPTURE_EXCLUDE_SELECTOR = '[data-capture="exclude"]';
|
|
576
|
+
function createElementCaptureSurface(options) {
|
|
577
|
+
const getElement = () => (typeof options.element === "function" ? options.element() : options.element) ?? null;
|
|
578
|
+
const require2 = () => {
|
|
579
|
+
const el = getElement();
|
|
580
|
+
if (!el || !el.isConnected) throw new Error("The view is not mounted, so there is nothing to capture.");
|
|
581
|
+
return el;
|
|
582
|
+
};
|
|
583
|
+
const visible = () => {
|
|
584
|
+
const el = getElement();
|
|
585
|
+
if (!el || !el.clientWidth || !el.clientHeight) return null;
|
|
586
|
+
return { x: el.scrollLeft, y: el.scrollTop, width: el.clientWidth, height: el.clientHeight };
|
|
587
|
+
};
|
|
588
|
+
const overlays = options.overlaySelectors ?? CAPTURE_OVERLAY_SELECTORS;
|
|
589
|
+
return {
|
|
590
|
+
units: "CSS pixels",
|
|
591
|
+
viewport: visible,
|
|
592
|
+
content: () => {
|
|
593
|
+
const el = getElement();
|
|
594
|
+
if (!el || !el.scrollWidth || !el.scrollHeight) return null;
|
|
595
|
+
return { x: 0, y: 0, width: el.scrollWidth, height: el.scrollHeight };
|
|
596
|
+
},
|
|
597
|
+
overlays: "agent cursors and presence tags",
|
|
598
|
+
maxScale: 2,
|
|
599
|
+
render: (request) => {
|
|
600
|
+
const el = require2();
|
|
601
|
+
const exclude = [CAPTURE_EXCLUDE_SELECTOR, ...options.exclude ?? [], ...request.includeOverlays ? [] : overlays];
|
|
602
|
+
const rasterize = options.rasterize ?? rasterizeElement;
|
|
603
|
+
return rasterize(el, {
|
|
604
|
+
width: request.rect.width,
|
|
605
|
+
height: request.rect.height,
|
|
606
|
+
pixelWidth: request.width,
|
|
607
|
+
pixelHeight: request.height,
|
|
608
|
+
format: request.format,
|
|
609
|
+
quality: request.quality,
|
|
610
|
+
background: options.background,
|
|
611
|
+
exclude,
|
|
612
|
+
// Scrolling does not survive cloning: shift the content so the rect's corner is at the top left.
|
|
613
|
+
prepare: (clone) => {
|
|
614
|
+
const shift = `translate(${-request.rect.x}px, ${-request.rect.y}px)`;
|
|
615
|
+
const inner = clone.ownerDocument.createElement("div");
|
|
616
|
+
inner.setAttribute("style", `transform:${shift};transform-origin:0 0;width:${el.scrollWidth}px;height:${el.scrollHeight}px`);
|
|
617
|
+
while (clone.firstChild) inner.appendChild(clone.firstChild);
|
|
618
|
+
clone.appendChild(inner);
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
|
|
436
625
|
export {
|
|
437
626
|
MCP_TOOL_GET_EDITOR_STATE,
|
|
438
627
|
MCP_TOOL_EDIT_CANVAS,
|
|
@@ -453,6 +642,12 @@ export {
|
|
|
453
642
|
EDITOR_PROMPT_TOOLS,
|
|
454
643
|
EDIT_OPERATION_REQUIRED_ARGUMENTS,
|
|
455
644
|
EXPORT_EXCLUDED_SELECTORS,
|
|
456
|
-
EDITOR_MCP_TOOLS
|
|
645
|
+
EDITOR_MCP_TOOLS,
|
|
646
|
+
cloneElementWithStyles,
|
|
647
|
+
elementToSvg,
|
|
648
|
+
rasterizeElement,
|
|
649
|
+
CAPTURE_OVERLAY_SELECTORS,
|
|
650
|
+
CAPTURE_EXCLUDE_SELECTOR,
|
|
651
|
+
createElementCaptureSurface
|
|
457
652
|
};
|
|
458
|
-
//# sourceMappingURL=chunk-
|
|
653
|
+
//# sourceMappingURL=chunk-O2W2SP3C.js.map
|