@openartifactsai/cli 0.23.0 → 0.25.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/SKILL.md +23 -6
- package/package.json +1 -1
- package/vendor/CHANGELOG.md +1116 -0
- package/vendor/artifact-types/docs/SKILL.md +7 -5
- package/vendor/artifact-types/page/SKILL.md +3 -1
- package/vendor/artifact-types/page/artifact-type/reference/capabilities.d.ts +0 -1
- package/vendor/artifact-types/page/artifact-type/reference/capabilities.md +1 -1
- package/vendor/frame-host/client/comments.js +20 -25
- package/vendor/frame-host/client/page.js +1363 -0
- package/vendor/frame-host/client/review.js +279 -0
- package/vendor/frame-host/client/runtime.js +8 -6
- package/vendor/frame-host/client/sample.js +1 -1
- package/vendor/frame-host/client/shell.css +1 -0
- package/vendor/frame-host/client/shell.js +207 -6
- package/vendor/frame-host/client/translate.js +375 -0
- package/vendor/frame-host/frame-host.mjs +193 -32
- package/vendor/home/assets/{browser-models-DWkPVHmp.js → browser-models-CNChpEzB.js} +4 -4
- package/vendor/home/assets/library-DAVNFZ4g.js +1 -0
- package/vendor/home/assets/main-C7DAdnKi.js +32 -0
- package/vendor/home/assets/main-Cduee5v6.css +1 -0
- package/vendor/home/assets/node.browser-BX90gLvV.js +1 -0
- package/vendor/home/assets/node.browser-BltE9Vxw.js +1 -0
- package/vendor/home/assets/tokens-B6Dchhk5.js +572 -0
- package/vendor/home/index.html +3 -3
- package/vendor/home/library/index.html +2 -2
- package/vendor/open-artifacts.mjs +11128 -3829
- package/vendor/runtime.json +1 -1
- package/vendor/shell/assets/{browser-models-BzwWAVuE.js → browser-models-DEdnh4xg.js} +4 -4
- package/vendor/shell/assets/index-BbQPECay.js +47 -0
- package/vendor/shell/assets/index-Cduee5v6.css +1 -0
- package/vendor/shell/assets/{node.browser-BvryIsl7.js → node.browser-CzAEKnJQ.js} +1 -1
- package/vendor/shell/assets/{node.browser-BgqLTfql.js → node.browser-Dt1frvjW.js} +1 -1
- package/vendor/shell/index.html +2 -2
- package/vendor/type-server/cli.mjs +217 -34
- package/vendor/type-server/editors/data/assets/{index-CX_sn7ZZ.js → index-M7l6GYrQ.js} +6 -11
- package/vendor/type-server/editors/data/index.html +1 -1
- package/vendor/type-server/editors/design/assets/{index-BpNUmTVD.js → index-D3IExhNM.js} +79 -84
- package/vendor/type-server/editors/design/index.html +1 -1
- package/vendor/type-server/editors/design-system/assets/{index-CP6AEO1P.js → index-DdgIQkBN.js} +8 -13
- package/vendor/type-server/editors/design-system/index.html +1 -1
- package/vendor/type-server/editors/docs/assets/{abnfDiagram-WEYOIA3C-Do25i7oS.js → abnfDiagram-WEYOIA3C-DYZ28wZy.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{architectureDiagram-ZHVYKT53-BLlpboc2.js → architectureDiagram-ZHVYKT53-BlNOisCb.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{blockDiagram-RJAE7QA3-D0rO5p7M.js → blockDiagram-RJAE7QA3-CQVhlYNw.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{c4Diagram-XDPPPE54-OoTiysJI.js → c4Diagram-XDPPPE54-CGbpwSFn.js} +1 -1
- package/vendor/type-server/editors/docs/assets/channel-7ZHbNf0E.js +1 -0
- package/vendor/type-server/editors/docs/assets/{chunk-2E7WHVMD-yBl5BEaI.js → chunk-2E7WHVMD-CeCe17xo.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-2Q5K7J3B-DHKM5gd6.js → chunk-2Q5K7J3B-CzZ2Xznn.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-4EMNKR2T-B-f8WPM6.js → chunk-4EMNKR2T-CNzxjPBJ.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-55XCU76K-n8RDJr36.js → chunk-55XCU76K-CfB8c3Md.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-5VM5RSS4-DzLzcqXE.js → chunk-5VM5RSS4-DzQqctZp.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-JWPE2WC7-BLXkUVcK.js → chunk-JWPE2WC7-BOlMn2TP.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-VQ5W62QI-DAGNVD29.js → chunk-VQ5W62QI-DeIWF9s3.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-XXDRQBXY-fgVyAbWV.js → chunk-XXDRQBXY-DafVeBuV.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-ZCHMQSOR-D90xHR9n.js → chunk-ZCHMQSOR-Ck41oHN3.js} +2 -2
- package/vendor/type-server/editors/docs/assets/{classDiagram-v2-4MYWR3UA-uk1mPogR.js → classDiagram-v2-4MYWR3UA-Cplz4GWc.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{core-BMv5rGOd.js → core-BjihJIUD.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{cose-bilkent-JH36ORCC-BJdqW8l3.js → cose-bilkent-JH36ORCC-DWdy6m2J.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{cynefin-EF2NZ3EQ-BCce_ZhK.js → cynefin-EF2NZ3EQ-Dj_QahA-.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{cynefinDiagram-WF24UDRP-DxD-4yjR.js → cynefinDiagram-WF24UDRP-CsxxQbyD.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{dagre-NK4GIZVX-B3VAS51Y.js → dagre-NK4GIZVX-NEPrnyXL.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{diagram-CBK3MWTC-B0kHeUdr.js → diagram-CBK3MWTC-Pg1cO5IF.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{diagram-I5XIIV2D-BCRvsLAu.js → diagram-I5XIIV2D-CPc4fLeT.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{diagram-ODIL2UCW-DFOTsSuA.js → diagram-ODIL2UCW-BFAo5sAk.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{diagram-PFBEJUXE-_DT3jk0i.js → diagram-PFBEJUXE-ueA4BuBI.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{diagram-RJA3I4VV-UFrdnTgs.js → diagram-RJA3I4VV-B8Qh64n3.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{diagram-TYUNFSNR-DrbWyZOX.js → diagram-TYUNFSNR-udgAkDbB.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{ebnfDiagram-V4P3TTPT-M-DCWgZM.js → ebnfDiagram-V4P3TTPT-DNNGufNH.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{elk-QONTBCTQ-l6XmbRQj.js → elk-QONTBCTQ-fAnGl2cK.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{erDiagram-KYQIGQAA-CHqbnmEE.js → erDiagram-KYQIGQAA-C2mbNrl5.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{flowDiagram-IUGLLWBU-BzkFyGCL.js → flowDiagram-IUGLLWBU-D7L47nKm.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{ganttDiagram-R7GPNTJY-BcNaSXNv.js → ganttDiagram-R7GPNTJY-CovbGSkl.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{gitGraphDiagram-PDYL7XHY-JaNdSZbv.js → gitGraphDiagram-PDYL7XHY-C6EQlzk2.js} +1 -1
- package/vendor/type-server/editors/docs/assets/index-BvPuZVZu.js +87 -0
- package/vendor/type-server/editors/docs/assets/index-QPklhVMX.css +1 -0
- package/vendor/type-server/editors/docs/assets/{infoDiagram-MVDRKAX5-Cl2Q_Ylf.js → infoDiagram-MVDRKAX5-Bs-D7mTo.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{ishikawaDiagram-HPEHV2GE-umirqIpN.js → ishikawaDiagram-HPEHV2GE-D__AsXXu.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{journeyDiagram-BOSHW7O7-HMtvkXvq.js → journeyDiagram-BOSHW7O7-C_6yyXoB.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{kanban-definition-FNSA4HC5-CYouTBUM.js → kanban-definition-FNSA4HC5-BYfemxGS.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{mermaid.core-BEcbgpI8.js → mermaid.core-DFabEkrU.js} +4 -4
- package/vendor/type-server/editors/docs/assets/{mindmap-definition-6OY57UG3-BnwugHtV.js → mindmap-definition-6OY57UG3-BnLoWczF.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{pegDiagram-ECIUJNBX-DqT6jxo7.js → pegDiagram-ECIUJNBX-eT3tDxZi.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{pieDiagram-GNMPY74T-CBKjnr1W.js → pieDiagram-GNMPY74T-DpwWxanm.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{quadrantDiagram-D57K4MC3-CdTG11Ff.js → quadrantDiagram-D57K4MC3-CASaoK3Z.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{railroadDiagram-Y72NRBL7-BZgG8r2y.js → railroadDiagram-Y72NRBL7-CgI3O5bH.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{requirementDiagram-EQYSW5RA-CutdnAmY.js → requirementDiagram-EQYSW5RA-Bxj0Eaeh.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{sankeyDiagram-SY24JHO5-DBaoPDhR.js → sankeyDiagram-SY24JHO5-BxSCdedw.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{sequenceDiagram-BLEHNHQU-B6YZp-Wu.js → sequenceDiagram-BLEHNHQU-DkF2KRDu.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{sizeCapture-INFHLROL-xATlK6Zl.js → sizeCapture-INFHLROL-cEjHrAFu.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{stateDiagram-v2-A6IESKWZ-C7BND5vv.js → stateDiagram-v2-A6IESKWZ-mbWVZCn4.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{swimlanes-B3ENRKFQ-WYLzM6hb.js → swimlanes-B3ENRKFQ-oOsIo2dg.js} +1 -1
- package/vendor/type-server/editors/docs/assets/swimlanesDiagram-AYQRV4AK-CzluHeRp.js +8 -0
- package/vendor/type-server/editors/docs/assets/{timeline-definition-JXYKGLGB-BXC0F4xE.js → timeline-definition-JXYKGLGB-CiHqWceA.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{usecaseDiagram-WPOLBNNX-Cx58jkEj.js → usecaseDiagram-WPOLBNNX-BJmiiDPK.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{vennDiagram-Q3Y3IDCW-DhdwpApW.js → vennDiagram-Q3Y3IDCW-VoyQedKk.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{wardleyDiagram-IVAIDKWA-CBdbPWVr.js → wardleyDiagram-IVAIDKWA-CZ-NZ6bq.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{xychartDiagram-4URNHDU4-Cb0tcPqs.js → xychartDiagram-4URNHDU4-0-P15J94.js} +1 -1
- package/vendor/type-server/editors/docs/index.html +2 -2
- package/vendor/type-server/editors/motion/assets/{gif-jobs-Bq4rwLBV.js → gif-jobs-BJFbhQfZ.js} +1 -1
- package/vendor/type-server/editors/motion/assets/{index-BDOqtmcc.js → index-bQ-JgltP.js} +20 -25
- package/vendor/type-server/editors/motion/assets/{src-8SKXU1IY.js → src-BJ9yQZbU.js} +1 -1
- package/vendor/type-server/editors/motion/index.html +1 -1
- package/vendor/type-server/editors/sheets/assets/{index-BY38EAff.js → index-BOzYyyQN.js} +10 -15
- package/vendor/type-server/editors/sheets/assets/{workbook-worker-CRtLrZhP.js → workbook-worker-7n7WEEgt.js} +4 -9
- package/vendor/type-server/editors/sheets/index.html +1 -1
- package/vendor/type-server/editors/slides/assets/{index-B51oMclO.js → index-ClAq-wit.js} +10 -15
- package/vendor/type-server/editors/slides/assets/{src-CdsEFSuC.js → src-BizehBWa.js} +1 -1
- package/vendor/type-server/editors/slides/index.html +1 -1
- package/vendor/type-server/editors/whiteboard/assets/{drawing-look-worker-Dd2iYbXC.js → drawing-look-worker-DY5ZQpAe.js} +5 -10
- package/vendor/type-server/editors/whiteboard/assets/{gif-jobs-DmIqT6gk.js → gif-jobs-DM6GuLRR.js} +1 -1
- package/vendor/type-server/editors/whiteboard/assets/{index-CTf9pd4S.js → index-BJfZV8fQ.js} +9 -14
- package/vendor/type-server/editors/whiteboard/assets/{index-B3oRKavi.js → index-DXRE64I0.js} +2 -2
- package/vendor/type-server/editors/whiteboard/index.html +1 -1
- package/vendor/type-server/shell/assets/{browser-models-BzwWAVuE.js → browser-models-DEdnh4xg.js} +4 -4
- package/vendor/type-server/shell/assets/index-BbQPECay.js +47 -0
- package/vendor/type-server/shell/assets/index-Cduee5v6.css +1 -0
- package/vendor/type-server/shell/assets/{node.browser-BvryIsl7.js → node.browser-CzAEKnJQ.js} +1 -1
- package/vendor/type-server/shell/assets/{node.browser-BgqLTfql.js → node.browser-Dt1frvjW.js} +1 -1
- package/vendor/type-server/shell/index.html +2 -2
- package/vendor/home/assets/RuntimeUpdate-BwvJ9sYp.js +0 -43
- package/vendor/home/assets/library-CyeaNaQo.js +0 -226
- package/vendor/home/assets/main-DUyobyFI.js +0 -5
- package/vendor/home/assets/main-DXpv3z2x.css +0 -1
- package/vendor/home/assets/node.browser-Cy4GM7Yl.js +0 -1
- package/vendor/home/assets/node.browser-nUfHL25Z.js +0 -1
- package/vendor/shell/assets/index-BIHLxOO6.js +0 -52
- package/vendor/shell/assets/index-DXpv3z2x.css +0 -1
- package/vendor/type-server/editors/docs/assets/channel-Cgat34ii.js +0 -1
- package/vendor/type-server/editors/docs/assets/index-BMNUnwXE.js +0 -92
- package/vendor/type-server/editors/docs/assets/index-DHqOb_n-.css +0 -1
- package/vendor/type-server/editors/docs/assets/swimlanesDiagram-AYQRV4AK-Bwh1tnzE.js +0 -8
- package/vendor/type-server/shell/assets/index-BIHLxOO6.js +0 -52
- package/vendor/type-server/shell/assets/index-DXpv3z2x.css +0 -1
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
// packages/server-sdk/src/frame/client/review.ts
|
|
4
|
+
(() => {
|
|
5
|
+
"use strict";
|
|
6
|
+
const w = window;
|
|
7
|
+
const MAX_EVENTS = 50;
|
|
8
|
+
const MAX_ERRORS = 10;
|
|
9
|
+
const MAX_OUTLINE_CHARS = 9e3;
|
|
10
|
+
const VIEW_LINES = 16;
|
|
11
|
+
const PART_LINES = 45;
|
|
12
|
+
const MAX_CLIPPED_ELEMENTS = 6;
|
|
13
|
+
const MEASURE_MS = 150;
|
|
14
|
+
const MAX_CUTS = 40;
|
|
15
|
+
const CUT_OFF = "text is cut off in ";
|
|
16
|
+
const INTO_MARGIN = "text runs into the bottom margin of ";
|
|
17
|
+
const LANDMARKS = "header,nav,main,section,article,aside,footer,h1,h2,h3,table,form,canvas,svg,img,button";
|
|
18
|
+
const TEXT_HOLDERS = "h1,h2,h3,h4,p,a,button,li,td,th,label";
|
|
19
|
+
const EDITABLE = "textarea,[contenteditable]";
|
|
20
|
+
const NOT_MEASURED = "svg,script,style,textarea,select,[role=img],[aria-hidden=true],[inert],[contenteditable]:not([contenteditable=false])";
|
|
21
|
+
const MOVES = /transform|translate|rotate|scale|height|width|top|left|right|bottom|margin|inset|grid|font/i;
|
|
22
|
+
const squash = (text) => (text ?? "").replace(/\s+/g, " ").trim();
|
|
23
|
+
const clip = (text, max) => {
|
|
24
|
+
const flat = squash(text);
|
|
25
|
+
return flat.length > max ? `${flat.slice(0, max - 1)}…` : flat;
|
|
26
|
+
};
|
|
27
|
+
const shown = (el) => el.getClientRects().length > 0;
|
|
28
|
+
const px = (value) => parseFloat(value) || 0;
|
|
29
|
+
const isSet = (value) => !!value && value !== "none";
|
|
30
|
+
const hides = (overflow) => overflow === "hidden" || overflow === "clip";
|
|
31
|
+
const scrolls = (overflow) => overflow === "auto" || overflow === "scroll";
|
|
32
|
+
function pathOf(start) {
|
|
33
|
+
const steps = [];
|
|
34
|
+
for (let el = start; el && el !== document.documentElement && steps.length < 12; el = el.parentElement) {
|
|
35
|
+
if (el.id && /^[A-Za-z][\w-]*$/.test(el.id)) {
|
|
36
|
+
steps.unshift(`#${el.id}`);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
let nth = 1;
|
|
40
|
+
for (let sib = el.previousElementSibling; sib; sib = sib.previousElementSibling) if (sib.tagName === el.tagName) nth++;
|
|
41
|
+
steps.unshift(`${el.tagName.toLowerCase()}:nth-of-type(${nth})`);
|
|
42
|
+
}
|
|
43
|
+
return steps.join(" > ") || "html";
|
|
44
|
+
}
|
|
45
|
+
function wordsOf(el) {
|
|
46
|
+
if (el.ownerDocument.designMode === "on" || el.closest(EDITABLE) || el.querySelector(EDITABLE)) return "";
|
|
47
|
+
return el instanceof HTMLElement ? el.innerText : el.textContent ?? "";
|
|
48
|
+
}
|
|
49
|
+
const labelOf = (el) => clip(el.getAttribute("aria-label") || el.getAttribute("alt") || wordsOf(el), 48) || el.tagName.toLowerCase();
|
|
50
|
+
function first(selector) {
|
|
51
|
+
if (typeof selector !== "string" || !selector) return null;
|
|
52
|
+
try {
|
|
53
|
+
return [...document.querySelectorAll(selector)].find(shown) ?? null;
|
|
54
|
+
} catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function overflowsHidden(el) {
|
|
59
|
+
const style = getComputedStyle(el);
|
|
60
|
+
if (el.clientWidth <= 4 || style.textOverflow === "ellipsis" || !squash(el.textContent)) return false;
|
|
61
|
+
return hides(style.overflowX) && el.scrollWidth > el.clientWidth + 2 || hides(style.overflowY) && el.scrollHeight > el.clientHeight + 2;
|
|
62
|
+
}
|
|
63
|
+
function describe(el) {
|
|
64
|
+
const box = el.getBoundingClientRect();
|
|
65
|
+
const style = getComputedStyle(el);
|
|
66
|
+
const classes = el.classList.length ? ` .${clip(el.classList.value, 40)}` : "";
|
|
67
|
+
const at = `@${Math.round(box.left)},${Math.round(box.top + scrollY)} ${Math.round(box.width)}x${Math.round(box.height)}`;
|
|
68
|
+
const type = `${style.display} ${style.fontWeight} ${style.fontSize} ${style.color} on ${style.backgroundColor}`;
|
|
69
|
+
return `${pathOf(el)}${classes} ${at} ${type}${overflowsHidden(el) ? " CLIPPED" : ""} "${labelOf(el)}"`;
|
|
70
|
+
}
|
|
71
|
+
function outline(part) {
|
|
72
|
+
const inView = (el) => {
|
|
73
|
+
const box = el.getBoundingClientRect();
|
|
74
|
+
return box.bottom > 0 && box.top < innerHeight;
|
|
75
|
+
};
|
|
76
|
+
const els = part ? [part, ...part.querySelectorAll(":not(svg *)")].filter(shown).slice(0, PART_LINES) : [...document.querySelectorAll(LANDMARKS)].filter((el) => shown(el) && inView(el)).slice(0, VIEW_LINES);
|
|
77
|
+
const head = `Scrolled to ${Math.round(scrollY)} of ${document.documentElement.scrollHeight}`;
|
|
78
|
+
return [head, ...els.map(describe)].join("\n").slice(0, MAX_OUTLINE_CHARS);
|
|
79
|
+
}
|
|
80
|
+
function clippersOf(el, moving, known) {
|
|
81
|
+
if (known.has(el)) return known.get(el);
|
|
82
|
+
const root = document.documentElement;
|
|
83
|
+
const rootStyle = getComputedStyle(root);
|
|
84
|
+
const bodyIsViewport = rootStyle.overflowX === "visible" && rootStyle.overflowY === "visible";
|
|
85
|
+
const out = [];
|
|
86
|
+
let opacity = 1;
|
|
87
|
+
let freeX = true;
|
|
88
|
+
let freeY = true;
|
|
89
|
+
let placed = false;
|
|
90
|
+
let result = out;
|
|
91
|
+
for (let at = el; at; at = at.parentElement) {
|
|
92
|
+
const style = getComputedStyle(at);
|
|
93
|
+
opacity *= Number(style.opacity || 1);
|
|
94
|
+
if (moving.has(at) || style.display === "none" || opacity < 0.35) {
|
|
95
|
+
result = null;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
const transformed = isSet(style.transform) || isSet(style.translate) || isSet(style.rotate);
|
|
99
|
+
const containing = style.position !== "static" || transformed;
|
|
100
|
+
if (at === root) {
|
|
101
|
+
const x = freeX && hides(bodyIsViewport && document.body ? getComputedStyle(document.body).overflowX : rootStyle.overflowX);
|
|
102
|
+
if (x) out.push({ el: at, box: new DOMRect(-scrollX, -scrollY, root.clientWidth, innerHeight), room: innerHeight, padBottom: 0, x, y: false, trims: scrollX !== 0, capped: true });
|
|
103
|
+
} else if (!(placed && !containing) && !(at === document.body && bodyIsViewport)) {
|
|
104
|
+
const box = at.getBoundingClientRect();
|
|
105
|
+
const scale = box.height / (at.offsetHeight || box.height || 1) || 1;
|
|
106
|
+
const padBottom = px(style.paddingBottom) * scale;
|
|
107
|
+
const x = freeX && hides(style.overflowX);
|
|
108
|
+
const y = freeY && hides(style.overflowY);
|
|
109
|
+
if (x || y) {
|
|
110
|
+
const masked = isSet(style.maskImage) || isSet(style.scrollSnapType);
|
|
111
|
+
out.push({
|
|
112
|
+
el: at,
|
|
113
|
+
box,
|
|
114
|
+
room: box.height - px(style.paddingTop) * scale - padBottom,
|
|
115
|
+
padBottom,
|
|
116
|
+
x,
|
|
117
|
+
y,
|
|
118
|
+
trims: masked || at.scrollLeft !== 0 || style.textOverflow === "ellipsis",
|
|
119
|
+
capped: masked || at.scrollTop > 0 || isSet(style.maxHeight) || isSet(style.webkitLineClamp)
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (scrolls(style.overflowX) && at.scrollWidth > at.clientWidth) freeX = false;
|
|
123
|
+
if (scrolls(style.overflowY) && at.scrollHeight > at.clientHeight) freeY = false;
|
|
124
|
+
}
|
|
125
|
+
if (containing) placed = false;
|
|
126
|
+
if (style.position === "absolute") placed = true;
|
|
127
|
+
if (style.position === "fixed" || transformed) break;
|
|
128
|
+
}
|
|
129
|
+
known.set(el, result);
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
function cutBy(line, clippers) {
|
|
133
|
+
const slack = line.height * 0.3;
|
|
134
|
+
for (const c of clippers) {
|
|
135
|
+
const { box } = c;
|
|
136
|
+
const pastX = c.x && (line.right - slack > box.right || line.left + slack < box.left);
|
|
137
|
+
const pastY = c.y && (line.bottom - slack > box.bottom || line.top + slack < box.top);
|
|
138
|
+
const besideX = box.width < line.height || line.right <= box.left + slack || line.left >= box.right - slack;
|
|
139
|
+
const besideY = line.top >= box.bottom - slack || line.bottom <= box.top + slack;
|
|
140
|
+
const roomy = c.room > line.height * 3;
|
|
141
|
+
if (pastY && !c.capped && !besideX && (besideY ? roomy : c.room > line.height / 2)) return [c.el, CUT_OFF];
|
|
142
|
+
if (pastX && !besideX && !besideY && !c.trims) return [c.el, CUT_OFF];
|
|
143
|
+
if (pastX || pastY) return null;
|
|
144
|
+
if (c.y && !c.capped && roomy && c.padBottom >= 24 && line.bottom > box.bottom - c.padBottom * 0.6) return [c.el, INTO_MARGIN];
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
function cutText() {
|
|
149
|
+
const until = performance.now() + MEASURE_MS;
|
|
150
|
+
const moving = /* @__PURE__ */ new Set();
|
|
151
|
+
for (const animation of document.getAnimations()) {
|
|
152
|
+
const effect = animation.effect;
|
|
153
|
+
if (!(effect instanceof KeyframeEffect) || effect.pseudoElement || animation.playState === "finished") continue;
|
|
154
|
+
if (MOVES.test(Object.keys(effect.getKeyframes()[0] ?? {}).join())) moving.add(effect.target);
|
|
155
|
+
}
|
|
156
|
+
const found = /* @__PURE__ */ new Map();
|
|
157
|
+
const known = /* @__PURE__ */ new Map();
|
|
158
|
+
const range = document.createRange();
|
|
159
|
+
const texts = document.createTreeWalker(document.body ?? document.documentElement, NodeFilter.SHOW_TEXT);
|
|
160
|
+
for (let node = texts.nextNode(); node && found.size < MAX_CUTS; node = texts.nextNode()) {
|
|
161
|
+
if (performance.now() > until) return null;
|
|
162
|
+
const text = node.nodeValue ?? "";
|
|
163
|
+
const holder = node.parentElement;
|
|
164
|
+
if (!holder || text.length > 2e4 || !/[\p{L}\p{N}]/u.test(text) || holder.closest(NOT_MEASURED)) continue;
|
|
165
|
+
if (holder.checkVisibility?.({ visibilityProperty: true, contentVisibilityAuto: true }) === false) continue;
|
|
166
|
+
const clippers = clippersOf(holder, moving, known);
|
|
167
|
+
if (!clippers?.length) continue;
|
|
168
|
+
range.setStart(node, 0);
|
|
169
|
+
range.setEnd(node, text.trimEnd().length);
|
|
170
|
+
for (const line of range.getClientRects()) {
|
|
171
|
+
const cut = line.width > 0 ? cutBy(line, clippers) : null;
|
|
172
|
+
if (cut && found.get(cut[0]) !== CUT_OFF) found.set(cut[0], cut[1]);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (found.size >= MAX_CUTS || document.fonts?.status === "loading") return null;
|
|
176
|
+
return [...found].map(([el, what]) => what + pathOf(el));
|
|
177
|
+
}
|
|
178
|
+
w.__openArtifactsReview?.(({ send, errors: early }) => {
|
|
179
|
+
const errors = early.map((e) => clip(e, 200)).slice(-MAX_ERRORS);
|
|
180
|
+
const events = [];
|
|
181
|
+
const noteError = (error) => {
|
|
182
|
+
errors.push(clip(error instanceof Error ? error.message : String(error), 200));
|
|
183
|
+
errors.splice(0, errors.length - MAX_ERRORS);
|
|
184
|
+
};
|
|
185
|
+
const note = (kind, what) => {
|
|
186
|
+
const last = events[events.length - 1];
|
|
187
|
+
if (last?.kind === kind && (kind === "scroll" || last.what === what)) events.pop();
|
|
188
|
+
events.push({ at: Date.now(), kind, what });
|
|
189
|
+
events.splice(0, events.length - MAX_EVENTS);
|
|
190
|
+
};
|
|
191
|
+
addEventListener("error", (ev) => noteError(ev.message));
|
|
192
|
+
addEventListener("unhandledrejection", (ev) => noteError(ev.reason));
|
|
193
|
+
addEventListener("scrollend", () => note("scroll", `to ${Math.round(scrollY)}px`), { passive: true });
|
|
194
|
+
addEventListener(
|
|
195
|
+
"click",
|
|
196
|
+
(ev) => {
|
|
197
|
+
const at = ev.composedPath()[0];
|
|
198
|
+
if (ev.isTrusted && at instanceof Element) note("click", `${pathOf(at)} "${labelOf(at)}"`);
|
|
199
|
+
},
|
|
200
|
+
true
|
|
201
|
+
);
|
|
202
|
+
addEventListener(
|
|
203
|
+
"change",
|
|
204
|
+
(ev) => {
|
|
205
|
+
const t = ev.target;
|
|
206
|
+
if (!ev.isTrusted || !(t instanceof Element)) return;
|
|
207
|
+
let value;
|
|
208
|
+
if (t instanceof HTMLSelectElement) value = t.selectedOptions[0]?.text;
|
|
209
|
+
else if (t instanceof HTMLInputElement) value = /^(checkbox|radio)$/.test(t.type) ? String(t.checked) : t.type === "range" ? t.value : void 0;
|
|
210
|
+
note("change", `${pathOf(t)}${value === void 0 ? "" : ` to ${clip(value, 60)}`}`);
|
|
211
|
+
},
|
|
212
|
+
true
|
|
213
|
+
);
|
|
214
|
+
function problems(measure) {
|
|
215
|
+
const out = [];
|
|
216
|
+
const width = document.documentElement.clientWidth;
|
|
217
|
+
if (document.documentElement.scrollWidth > width + 1) {
|
|
218
|
+
const wide = [...document.body?.querySelectorAll(":not(svg *)") ?? []].find((el) => el.getBoundingClientRect().right > width + 1);
|
|
219
|
+
out.push(`the page scrolls sideways at ${width}px wide${wide ? `, because of ${pathOf(wide)}` : ""}`);
|
|
220
|
+
}
|
|
221
|
+
let clipped = 0;
|
|
222
|
+
for (const el of document.body?.querySelectorAll(TEXT_HOLDERS) ?? []) {
|
|
223
|
+
if (clipped >= MAX_CLIPPED_ELEMENTS) break;
|
|
224
|
+
if (overflowsHidden(el)) {
|
|
225
|
+
clipped++;
|
|
226
|
+
out.push(CUT_OFF + pathOf(el));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (measure) out.push(...cutText() ?? []);
|
|
230
|
+
return [...new Set(out)];
|
|
231
|
+
}
|
|
232
|
+
let before = null;
|
|
233
|
+
return (command) => {
|
|
234
|
+
const answer = (value) => send({ __fr: { op: "answer", n: command.n, value } });
|
|
235
|
+
const baseline = before ??= problems(false);
|
|
236
|
+
switch (command.op) {
|
|
237
|
+
case "on":
|
|
238
|
+
send({ __fr: { op: "ready" } });
|
|
239
|
+
break;
|
|
240
|
+
case "stale":
|
|
241
|
+
if (command.leaving !== true) send({ __fr: { op: "ready" } });
|
|
242
|
+
break;
|
|
243
|
+
case "view": {
|
|
244
|
+
const theme = document.documentElement.dataset.theme ?? (matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "");
|
|
245
|
+
const now = Date.now();
|
|
246
|
+
answer({
|
|
247
|
+
w: innerWidth,
|
|
248
|
+
h: innerHeight,
|
|
249
|
+
dark: theme === "dark",
|
|
250
|
+
outline: outline(null),
|
|
251
|
+
events: events.splice(0).map((e) => ({ t: Math.round((now - e.at) / 1e3), kind: e.kind, what: e.what })),
|
|
252
|
+
errors: [...errors]
|
|
253
|
+
});
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
case "look": {
|
|
257
|
+
const part = first(command.path);
|
|
258
|
+
answer({
|
|
259
|
+
outline: command.path && !part ? "Nothing visible matches." : outline(part),
|
|
260
|
+
overflow: problems(true),
|
|
261
|
+
errors: [...errors]
|
|
262
|
+
});
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
case "check": {
|
|
266
|
+
const known = Array.isArray(command.known) ? command.known.map(String) : baseline;
|
|
267
|
+
answer({ problems: [...errors.splice(0).map((e) => `script error: ${e}`), ...problems(true).filter((p) => !known.includes(p))] });
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
case "problems":
|
|
271
|
+
answer([...errors.map((e) => `script error: ${e}`), ...problems(true)]);
|
|
272
|
+
break;
|
|
273
|
+
default:
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
});
|
|
278
|
+
})();
|
|
279
|
+
})();
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
const parentWin = window.parent;
|
|
14
14
|
const framed = !!SHELL && !!parentWin && parentWin !== window;
|
|
15
15
|
const INIT_TIMEOUT_MS = 1e4;
|
|
16
|
+
const INIT_PARSING_LIMIT_MS = 35e3;
|
|
16
17
|
const WANT_TIMEOUT_MS = 1e4;
|
|
17
18
|
const ACKED_MS = 9e5;
|
|
18
19
|
const BUDGET_MAX_MS = 6e5;
|
|
@@ -74,6 +75,7 @@
|
|
|
74
75
|
initDone = true;
|
|
75
76
|
if (packet) {
|
|
76
77
|
if (typeof packet.brokerGen === "number") brokerGen = packet.brokerGen;
|
|
78
|
+
w.__openArtifactsShellInit = { hostKeys: packet.hostKeys, hostVisible: packet.hostVisible };
|
|
77
79
|
const grants2 = /* @__PURE__ */ new Set();
|
|
78
80
|
if (isRecord(packet.capabilities)) {
|
|
79
81
|
for (const [name, grant] of Object.entries(packet.capabilities)) {
|
|
@@ -137,9 +139,10 @@
|
|
|
137
139
|
if (cap === "assets") msg.holds = true;
|
|
138
140
|
const activation = cap === "comments" || ACTIVATED[`${cap}.${method}`] === true;
|
|
139
141
|
try {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
const options = { targetOrigin: SHELL };
|
|
143
|
+
if (transfer && transfer.length) options.transfer = transfer;
|
|
144
|
+
if (activation) options.includeUserActivation = true;
|
|
145
|
+
parentWin.postMessage(msg, options);
|
|
143
146
|
} catch (e) {
|
|
144
147
|
pending.delete(id);
|
|
145
148
|
p.reject({ code: "invalid_argument", message: String(e?.message || e) });
|
|
@@ -229,6 +232,7 @@
|
|
|
229
232
|
const tick = () => {
|
|
230
233
|
if (initDone) return;
|
|
231
234
|
post({ __frame_connect: true, contract: boot.contract, key: boot.key });
|
|
235
|
+
if (document.readyState === "loading" && !initWaiters.length && performance.now() < INIT_PARSING_LIMIT_MS) tries = 0;
|
|
232
236
|
if (++tries * 400 < INIT_TIMEOUT_MS) setTimeout(tick, 400);
|
|
233
237
|
else finishInit(null);
|
|
234
238
|
};
|
|
@@ -790,7 +794,6 @@
|
|
|
790
794
|
}
|
|
791
795
|
async function answerCommentSend(ticket, payload) {
|
|
792
796
|
let reply;
|
|
793
|
-
let handoffNote;
|
|
794
797
|
for (const listener of [...sendListeners]) {
|
|
795
798
|
if (!sendListeners.has(listener)) continue;
|
|
796
799
|
try {
|
|
@@ -800,11 +803,10 @@
|
|
|
800
803
|
return;
|
|
801
804
|
}
|
|
802
805
|
reply ??= commentResponseText(result?.reply, 500);
|
|
803
|
-
handoffNote ??= commentResponseText(result?.handoffNote, 2e3);
|
|
804
806
|
} catch {
|
|
805
807
|
}
|
|
806
808
|
}
|
|
807
|
-
post({ __open_artifacts_comments_sent: true, ticket, handled: false, reply
|
|
809
|
+
post({ __open_artifacts_comments_sent: true, ticket, handled: false, reply });
|
|
808
810
|
}
|
|
809
811
|
let fallbackOn = false;
|
|
810
812
|
const COMMENT_CURSOR = 'url("data:image/svg+xml,%3Csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20width=%2728%27%20height=%2728%27%20viewBox=%270%200%2028%2028%27%3E%3Cpath%20d=%27M%202%2026%20L%202%2014%20A%2012%2012%200%201%201%2014%2026%20Z%27%20fill=%27%23000%27%20stroke=%27%23fff%27%20stroke-width=%272%27/%3E%3C/svg%3E") 2 26, crosshair';
|
|
@@ -535,7 +535,7 @@
|
|
|
535
535
|
return bytes > SAMPLE_MAX_TOOL_RESULT_BYTES ? tooLarge(bytes) : { content: text };
|
|
536
536
|
}
|
|
537
537
|
function thrownResult(name, error) {
|
|
538
|
-
console.warn(`openArtifacts
|
|
538
|
+
console.warn(`openArtifacts: page tool ${name} threw:`, error);
|
|
539
539
|
const message = isRecord2(error) && typeof error.message === "string" ? error.message : String(error);
|
|
540
540
|
let content = `Error: ${message}`;
|
|
541
541
|
while (bytesOf(content) > SAMPLE_MAX_TOOL_RESULT_BYTES) content = content.slice(0, Math.floor(content.length * 0.9));
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); }
|
|
24
24
|
#stage { position: fixed; inset: 0; }
|
|
25
25
|
#stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: transparent; }
|
|
26
|
+
#stage iframe[data-page-ring] { outline: 2px solid var(--accent); outline-offset: -2px; }
|
|
26
27
|
.problem-card .row { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
|
|
27
28
|
.problem-card button {
|
|
28
29
|
font: inherit; color: inherit; background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px;
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
const ACKED = /* @__PURE__ */ new Set(["assets.upload", "comments.sendToAgent", "room.sendToAgentSession", "artifact.publish"]);
|
|
30
30
|
const SNAPSHOT_READY_S = 8;
|
|
31
31
|
const SNAPSHOT_HOLD_MS = 5e3;
|
|
32
|
+
const RELOAD_CAPTURE_MS = 250;
|
|
33
|
+
const BLOCKED_NOTICE_MS = 5e3;
|
|
34
|
+
const COMMENT_SHORTCUT = { id: "toggle_comment_mode", key: "KeyC", alt: true, skipInEditable: true };
|
|
32
35
|
let session = null;
|
|
33
36
|
let frame = null;
|
|
34
37
|
let pageWin = null;
|
|
@@ -44,6 +47,18 @@
|
|
|
44
47
|
const subs = /* @__PURE__ */ new Map();
|
|
45
48
|
const rerun = /* @__PURE__ */ new Set();
|
|
46
49
|
let rerunTimer = null;
|
|
50
|
+
const pageTab = (() => {
|
|
51
|
+
const key = "open-artifacts:tab";
|
|
52
|
+
try {
|
|
53
|
+
const have = sessionStorage.getItem(key);
|
|
54
|
+
if (have && /^[0-9a-z]{1,32}$/.test(have)) return have;
|
|
55
|
+
const made = randomId(10).toLowerCase();
|
|
56
|
+
sessionStorage.setItem(key, made);
|
|
57
|
+
return made;
|
|
58
|
+
} catch {
|
|
59
|
+
return randomId(10).toLowerCase();
|
|
60
|
+
}
|
|
61
|
+
})();
|
|
47
62
|
function randomId(n) {
|
|
48
63
|
const a = new Uint8Array(n);
|
|
49
64
|
crypto.getRandomValues(a);
|
|
@@ -182,9 +197,10 @@
|
|
|
182
197
|
const f = document.createElement("iframe");
|
|
183
198
|
frame = f;
|
|
184
199
|
f.title = session?.title || "Artifact";
|
|
185
|
-
f.allow = "clipboard-read *; clipboard-write *; fullscreen *; autoplay *";
|
|
200
|
+
f.allow = "clipboard-read *; clipboard-write *; fullscreen *; autoplay *; translator *; language-detector *";
|
|
186
201
|
f.referrerPolicy = "origin";
|
|
187
202
|
if (session?.sandbox) f.setAttribute("sandbox", session.sandbox);
|
|
203
|
+
f.name = JSON.stringify({ tab: pageTab });
|
|
188
204
|
f.src = pageUrl(ver);
|
|
189
205
|
f.addEventListener("load", () => {
|
|
190
206
|
dropSamples();
|
|
@@ -192,13 +208,32 @@
|
|
|
192
208
|
chrome.answered = 0;
|
|
193
209
|
chrome.sent = 0;
|
|
194
210
|
if (activity.known) toPage({ __frame_agent_activity: true, working: activity.working });
|
|
211
|
+
toOuter({ openArtifacts: "translate_status", status: { state: "idle", lang: null, usable: false }, fresh: true });
|
|
195
212
|
});
|
|
196
213
|
$("stage").append(f);
|
|
197
214
|
armReadyTimer();
|
|
198
215
|
}
|
|
216
|
+
let reloads = 0;
|
|
217
|
+
const captures = /* @__PURE__ */ new Map();
|
|
199
218
|
function reloadPage(nextVer) {
|
|
200
219
|
if (!frame) return;
|
|
201
220
|
ver = nextVer;
|
|
221
|
+
const n = ++reloads;
|
|
222
|
+
if (!ready || !pageWin) return loadPageAgain(n);
|
|
223
|
+
let went = false;
|
|
224
|
+
const go = () => {
|
|
225
|
+
if (went) return;
|
|
226
|
+
went = true;
|
|
227
|
+
captures.delete(n);
|
|
228
|
+
loadPageAgain(n);
|
|
229
|
+
};
|
|
230
|
+
captures.set(n, go);
|
|
231
|
+
toPage({ __frame_hot_capture: true, gen: n });
|
|
232
|
+
setTimeout(go, RELOAD_CAPTURE_MS);
|
|
233
|
+
}
|
|
234
|
+
function loadPageAgain(n) {
|
|
235
|
+
if (!frame || n !== reloads) return;
|
|
236
|
+
const nextVer = ver;
|
|
202
237
|
ready = false;
|
|
203
238
|
revealed = false;
|
|
204
239
|
revealHeld = false;
|
|
@@ -214,6 +249,7 @@
|
|
|
214
249
|
views?.setMovable(false);
|
|
215
250
|
chrome.snapshot = null;
|
|
216
251
|
lastSnapshotText = "";
|
|
252
|
+
endPrint(false, "failed");
|
|
217
253
|
chrome.pendingExport = null;
|
|
218
254
|
frame.src = pageUrl(nextVer);
|
|
219
255
|
armReadyTimer();
|
|
@@ -254,8 +290,8 @@
|
|
|
254
290
|
hostVisible: hostVisible(),
|
|
255
291
|
hostOverlays: [],
|
|
256
292
|
hostSides: {},
|
|
257
|
-
//
|
|
258
|
-
hostKeys: [],
|
|
293
|
+
// Alt+C for comment mode, also while the page has focus.
|
|
294
|
+
hostKeys: s.comments?.available ? [COMMENT_SHORTCUT] : [],
|
|
259
295
|
hot: { gen: 0, phase: "final", from: null },
|
|
260
296
|
capBudgets: DEFAULT_CAP_BUDGETS,
|
|
261
297
|
capWants: true,
|
|
@@ -297,6 +333,10 @@
|
|
|
297
333
|
}
|
|
298
334
|
if (m.__frame_cap === true && typeof m.id === "string") return answerCap(m);
|
|
299
335
|
if (m.__frame_cap_want === true) return answerWant(m);
|
|
336
|
+
if (m.__frame_hot_state === true) {
|
|
337
|
+
if (typeof m.gen === "number") captures.get(m.gen)?.();
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
300
340
|
if (m.__frame_ready === true) {
|
|
301
341
|
if (!ready) {
|
|
302
342
|
ready = true;
|
|
@@ -327,7 +367,15 @@
|
|
|
327
367
|
}
|
|
328
368
|
if (m.__frame_chrome_hello === true) return chromeHello();
|
|
329
369
|
if (m.__frame_chrome_report === true) return chromeReport(m.snapshot);
|
|
330
|
-
if (m.__frame_chrome_decline === true) return exportEnded(m.request, "declined");
|
|
370
|
+
if (m.__frame_chrome_decline === true) return printing?.request === m.request ? endPrint(false, "declined") : exportEnded(m.request, "declined");
|
|
371
|
+
if (m.__frame_print_ready === true) return printReady(m);
|
|
372
|
+
if (isObj(m.__fr)) return reviewHeard(m.__fr);
|
|
373
|
+
if (isObj(m.__ft_status)) return toOuter({ openArtifacts: "translate_status", status: m.__ft_status });
|
|
374
|
+
if (isObj(m.__ft_xl)) {
|
|
375
|
+
const { id, texts } = m.__ft_xl;
|
|
376
|
+
if (typeof id === "number" && Array.isArray(texts)) toOuter({ openArtifacts: "translate_text", id, texts });
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
331
379
|
if (m.__open_artifacts_export_done === true) return exportEnded(m.request, "done");
|
|
332
380
|
if (m.__frame_title_from_content === true && typeof m.title === "string") {
|
|
333
381
|
const out = await post("title", { title: m.title, ifUnnamed: m.ifUnnamed !== false }).catch(() => null);
|
|
@@ -361,6 +409,78 @@
|
|
|
361
409
|
return;
|
|
362
410
|
}
|
|
363
411
|
if (m.__open_artifacts_comments_moved === true) return void onMoved(m);
|
|
412
|
+
if (m.__frame_nav === true && typeof m.url === "string") return openFromPage(m);
|
|
413
|
+
if (m.__frame_blocked === true) return tellBlocked(m.kind);
|
|
414
|
+
if (m.__frame_host_key === true) return hostKey(m.id);
|
|
415
|
+
if (typeof m.__frame_page_ring === "boolean") {
|
|
416
|
+
frame?.toggleAttribute("data-page-ring", m.__frame_page_ring);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
const BLOCKED_TEXT = {
|
|
421
|
+
link: "This link can’t be opened here.",
|
|
422
|
+
form: "This form can’t be sent from here.",
|
|
423
|
+
file: "This file can’t be opened here."
|
|
424
|
+
};
|
|
425
|
+
let lastBlockedNotice = 0;
|
|
426
|
+
function tellBlocked(kind) {
|
|
427
|
+
const text = typeof kind === "string" ? BLOCKED_TEXT[kind] : void 0;
|
|
428
|
+
const now = Date.now();
|
|
429
|
+
if (!text || now - lastBlockedNotice < BLOCKED_NOTICE_MS) return;
|
|
430
|
+
lastBlockedNotice = now;
|
|
431
|
+
toast(text);
|
|
432
|
+
}
|
|
433
|
+
let lastHostKey = 0;
|
|
434
|
+
function hostKey(id) {
|
|
435
|
+
if (id !== COMMENT_SHORTCUT.id || !frame || document.activeElement !== frame || !document.hasFocus() || document.fullscreenElement) return;
|
|
436
|
+
const now = performance.now();
|
|
437
|
+
if (now - lastHostKey < 50) return;
|
|
438
|
+
lastHostKey = now;
|
|
439
|
+
toggleCommentsByKey(true);
|
|
440
|
+
}
|
|
441
|
+
function toggleCommentsByKey(fromPage2) {
|
|
442
|
+
if (!session?.comments?.available) return;
|
|
443
|
+
const on = !comments.on;
|
|
444
|
+
setMode(on);
|
|
445
|
+
if (on && fromPage2) toPage({ __frame_leave_field: true });
|
|
446
|
+
}
|
|
447
|
+
function isCommentShortcut(ev) {
|
|
448
|
+
if (!ev.altKey || ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.isComposing || ev.keyCode === 229) return false;
|
|
449
|
+
const letter = /^[ -~]$/.test(ev.key) ? ev.key.toUpperCase() : ev.keyCode >= 65 && ev.keyCode <= 90 ? String.fromCharCode(ev.keyCode) : ev.code.slice(3);
|
|
450
|
+
if (letter !== "C") return false;
|
|
451
|
+
const at = ev.target instanceof Element ? ev.target : null;
|
|
452
|
+
return !at?.closest("input,textarea,select,[contenteditable]:not([contenteditable=false]),[role=dialog],[role=alertdialog],[role=menu],[role=listbox],[role=combobox]");
|
|
453
|
+
}
|
|
454
|
+
let lastOpened = 0;
|
|
455
|
+
function openFromPage(m) {
|
|
456
|
+
const activation = navigator.userActivation;
|
|
457
|
+
if (comments.on || activation?.isActive === false) return;
|
|
458
|
+
let url;
|
|
459
|
+
try {
|
|
460
|
+
url = new URL(m.url);
|
|
461
|
+
} catch {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
const inApp = /^(mailto|tel|sms):$/.test(url.protocol);
|
|
465
|
+
if (!inApp && url.protocol !== "http:" && url.protocol !== "https:") return;
|
|
466
|
+
if (typeof m.rawHref === "string" && m.rawHref[0] === "#" && url.origin === contentOrigin) {
|
|
467
|
+
if (m.newTab === true) followLink(`${location.origin}${location.pathname}${location.search}${url.hash}`, true);
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
if (session?.outsideLinks === false) return tellBlocked("link");
|
|
471
|
+
const now = performance.now();
|
|
472
|
+
if (now - lastOpened < 50) return;
|
|
473
|
+
lastOpened = now;
|
|
474
|
+
url.username = "";
|
|
475
|
+
url.password = "";
|
|
476
|
+
followLink(url.href, !inApp);
|
|
477
|
+
}
|
|
478
|
+
function followLink(href, newTab) {
|
|
479
|
+
const a = document.createElement("a");
|
|
480
|
+
a.href = href;
|
|
481
|
+
if (newTab) a.target = "_blank";
|
|
482
|
+
a.rel = "noopener noreferrer";
|
|
483
|
+
a.click();
|
|
364
484
|
}
|
|
365
485
|
async function answerCap(m) {
|
|
366
486
|
const reply = (body) => toPage({ __frame_cap_r: true, id: m.id, ...body });
|
|
@@ -944,6 +1064,7 @@
|
|
|
944
1064
|
}
|
|
945
1065
|
const REQUEST = /^[A-Za-z0-9_-]{16,64}$/;
|
|
946
1066
|
function startExport(format, variant, request, fromOuter2) {
|
|
1067
|
+
if (format === SHELL_PRINT && variant === void 0 && shellPrints()) return startPrint(request, fromOuter2);
|
|
947
1068
|
const x = chrome.snapshot?.exports?.find((e) => e.format === format);
|
|
948
1069
|
if (!x || x.disabled) return "unsupported";
|
|
949
1070
|
if (variant !== void 0 && !(x.variants ?? []).some((v) => v.id === variant && !v.disabled)) return "unsupported";
|
|
@@ -972,6 +1093,80 @@
|
|
|
972
1093
|
chrome.pendingExport = null;
|
|
973
1094
|
if (pending.outer) toOuter({ openArtifacts: "chrome_export", request: pending.request, state });
|
|
974
1095
|
}
|
|
1096
|
+
const SHELL_PRINT = "print";
|
|
1097
|
+
const PRINT_READY_MS = 6e4;
|
|
1098
|
+
const PRINT_MAX_HEIGHT = 5e5;
|
|
1099
|
+
const shellPrints = () => !!frame && !chrome.snapshot?.exports?.length;
|
|
1100
|
+
let printing = null;
|
|
1101
|
+
function startPrint(request, fromOuter2) {
|
|
1102
|
+
const now = Date.now();
|
|
1103
|
+
if (now - chrome.lastExportAt < 250) return "busy";
|
|
1104
|
+
if (printing?.sheet) endPrint(false, "done");
|
|
1105
|
+
if (printing || chrome.pendingExport && now - chrome.pendingExport.at < 5e3) return "busy";
|
|
1106
|
+
chrome.lastExportAt = now;
|
|
1107
|
+
chrome.pendingExport = { request, at: now, outer: fromOuter2 };
|
|
1108
|
+
printing = { request, timer: setTimeout(() => endPrint(false, "failed"), PRINT_READY_MS), sheet: null };
|
|
1109
|
+
toPageCmd({ cmd: "export", format: SHELL_PRINT, request, sender: "viewer" });
|
|
1110
|
+
return "started";
|
|
1111
|
+
}
|
|
1112
|
+
const printNumber = (v) => typeof v === "number" && Number.isFinite(v) ? v : 0;
|
|
1113
|
+
function printReady(m) {
|
|
1114
|
+
const job = printing;
|
|
1115
|
+
if (!job || job.sheet || m.request !== job.request || !frame) return;
|
|
1116
|
+
if (job.timer) clearTimeout(job.timer);
|
|
1117
|
+
job.timer = null;
|
|
1118
|
+
const height = Math.min(Math.ceil(printNumber(m.h)), PRINT_MAX_HEIGHT);
|
|
1119
|
+
const sheet = Math.min(Math.max(printNumber(m.page), height / 500), height);
|
|
1120
|
+
const width = Math.ceil(frame.getBoundingClientRect().width);
|
|
1121
|
+
if (!(width > 0) || !(sheet > 0)) return endPrint(false, "failed");
|
|
1122
|
+
frame.dataset.printing = "";
|
|
1123
|
+
const style = document.createElement("style");
|
|
1124
|
+
style.textContent = `@page{size:${width + 64}px ${Math.ceil(sheet) + 64}px;margin:32px}@media print{html,body{height:auto;overflow:visible;background:none}body>:not(#stage){display:none!important}#stage{position:static}#stage iframe:not([data-printing]){display:none}#stage iframe[data-printing]{position:static;display:block;outline:none;height:${height - 1}px!important}}`;
|
|
1125
|
+
document.head.append(style);
|
|
1126
|
+
job.sheet = style;
|
|
1127
|
+
addEventListener("afterprint", () => endPrint(true, "done"), { once: true });
|
|
1128
|
+
window.print();
|
|
1129
|
+
}
|
|
1130
|
+
function endPrint(printed, state) {
|
|
1131
|
+
const job = printing;
|
|
1132
|
+
if (!job) return;
|
|
1133
|
+
printing = null;
|
|
1134
|
+
if (job.timer) clearTimeout(job.timer);
|
|
1135
|
+
job.sheet?.remove();
|
|
1136
|
+
if (frame) delete frame.dataset.printing;
|
|
1137
|
+
toPage({ __frame_print_done: true, printed });
|
|
1138
|
+
exportEnded(job.request, state);
|
|
1139
|
+
}
|
|
1140
|
+
const REVIEW_ANSWER_MS = 5e3;
|
|
1141
|
+
let reviewSeq = 0;
|
|
1142
|
+
const reviewWaiting = /* @__PURE__ */ new Map();
|
|
1143
|
+
function askPage(op, fields = {}) {
|
|
1144
|
+
const n = ++reviewSeq;
|
|
1145
|
+
return new Promise((resolve) => {
|
|
1146
|
+
const timer = setTimeout(() => {
|
|
1147
|
+
reviewWaiting.delete(n);
|
|
1148
|
+
resolve(void 0);
|
|
1149
|
+
}, REVIEW_ANSWER_MS);
|
|
1150
|
+
reviewWaiting.set(n, (value) => {
|
|
1151
|
+
clearTimeout(timer);
|
|
1152
|
+
reviewWaiting.delete(n);
|
|
1153
|
+
resolve(value);
|
|
1154
|
+
});
|
|
1155
|
+
toPage({ __fr_cmd: { ...fields, op, n } });
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
function reviewHeard(m) {
|
|
1159
|
+
if (m.op === "answer" && typeof m.n === "number") reviewWaiting.get(m.n)?.(m.value);
|
|
1160
|
+
}
|
|
1161
|
+
async function lookAtPage() {
|
|
1162
|
+
const [view, problems] = await Promise.all([askPage("view"), askPage("problems")]);
|
|
1163
|
+
if (!isObj(view)) return null;
|
|
1164
|
+
return {
|
|
1165
|
+
outline: typeof view.outline === "string" ? view.outline : "",
|
|
1166
|
+
problems: Array.isArray(problems) ? problems.filter((p) => typeof p === "string").slice(0, 40) : []
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
Object.defineProperty(window, "__openArtifactsLook", { value: () => session?.snapshot ? lookAtPage() : Promise.resolve(null) });
|
|
975
1170
|
function runAction(id) {
|
|
976
1171
|
if (typeof id !== "string") return;
|
|
977
1172
|
const action = chrome.snapshot?.actions?.find((a) => a.id === id);
|
|
@@ -1025,6 +1220,7 @@
|
|
|
1025
1220
|
exports: exportItems().length > 0,
|
|
1026
1221
|
...snapshotChrome(snap)
|
|
1027
1222
|
};
|
|
1223
|
+
if (shellPrints()) report.formats = [{ format: SHELL_PRINT }];
|
|
1028
1224
|
toOuter({ openArtifacts: "chrome_report", protocol: CHROME_PROTOCOL, report });
|
|
1029
1225
|
}
|
|
1030
1226
|
function fromOuter(m) {
|
|
@@ -1044,6 +1240,8 @@
|
|
|
1044
1240
|
return permissionAsks.get(String(m.id))?.(state);
|
|
1045
1241
|
}
|
|
1046
1242
|
if (m.openArtifacts === "sample_ev") return shellAnswers.get(String(m.id))?.(m.ev);
|
|
1243
|
+
if (m.openArtifacts === "translate") return toPage({ __ft_cmd: { action: m.action, target: m.target, engineHost: m.engineHost === true } });
|
|
1244
|
+
if (m.openArtifacts === "translate_text_r") return toPage({ __ft_xlr: { id: m.id, texts: m.texts, error: m.error } });
|
|
1047
1245
|
if (m.openArtifacts !== "chrome_cmd") return;
|
|
1048
1246
|
const c = m;
|
|
1049
1247
|
if (c.cmd === "comments_mode") setMode(c.on ?? !comments.on);
|
|
@@ -1312,8 +1510,7 @@
|
|
|
1312
1510
|
const r = await asked;
|
|
1313
1511
|
const reply = boundedCommentText(r?.reply, 500);
|
|
1314
1512
|
if (r?.handled === true) return { status: "handled", ...reply && { reply } };
|
|
1315
|
-
const
|
|
1316
|
-
const out = await cap("comments", "sendToAgent", { ...a, handoffNote }, own);
|
|
1513
|
+
const out = await cap("comments", "sendToAgent", a, own);
|
|
1317
1514
|
void refreshThreads();
|
|
1318
1515
|
return reply ? { ...out, reply } : out;
|
|
1319
1516
|
}
|
|
@@ -1375,6 +1572,10 @@
|
|
|
1375
1572
|
};
|
|
1376
1573
|
document.addEventListener("keydown", (ev) => {
|
|
1377
1574
|
if (ev.key === "Escape") onEscape();
|
|
1575
|
+
else if (session?.comments?.available && !document.fullscreenElement && isCommentShortcut(ev)) {
|
|
1576
|
+
ev.preventDefault();
|
|
1577
|
+
if (!ev.repeat) toggleCommentsByKey(false);
|
|
1578
|
+
}
|
|
1378
1579
|
});
|
|
1379
1580
|
document.addEventListener("visibilitychange", () => toPage({ __frame_host_visible: { visible: hostVisible() } }));
|
|
1380
1581
|
matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => toPage({ __frame_theme: { theme: theme() } }));
|