@pickaxeproject/react 6.23.0 → 6.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/responseArtifactSnapshot.js +1 -1
- package/dist/cjs/common/responseArtifactWordImages.js +1 -1
- package/dist/cjs/common/responseDownloadDocx.js +1 -1
- package/dist/cjs/common/responseDownloadHtml.js +1 -1
- package/dist/cjs/common/responseDownloadImages.js +1 -0
- package/dist/cjs/components/Pickaxe/common/PickaxeDownloadButton.js +1 -1
- package/dist/cjs/src/common/responseDownloadDocx.d.ts +2 -2
- package/dist/cjs/src/common/responseDownloadImages.d.ts +3 -0
- package/dist/esm/common/responseArtifactSnapshot.js +1 -1
- package/dist/esm/common/responseArtifactWordImages.js +1 -1
- package/dist/esm/common/responseDownloadDocx.js +1 -1
- package/dist/esm/common/responseDownloadHtml.js +1 -1
- package/dist/esm/common/responseDownloadImages.js +1 -0
- package/dist/esm/components/Pickaxe/common/PickaxeDownloadButton.js +1 -1
- package/dist/esm/src/common/responseDownloadDocx.d.ts +2 -2
- package/dist/esm/src/common/responseDownloadImages.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("uuid"),t=require("./responseArtifactStyles.js"),n=require("./responseArtifactSvg.js");const r="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co",o=(e,r)=>`<script>\n(() => {\n const token = ${JSON.stringify(e)};\n const send = parent.postMessage.bind(parent);\n send({ type: 'PXE_RESPONSE_SNAPSHOT_STARTED', token }, '*');\n let failed = false;\n let captureStarted = false;\n let timer;\n let deadline;\n let observer;\n let paintReady = false;\n const captureSvg = ${n.artifactSvgSnapshotScript};\n const finish = async () => {\n // The quiet timer and deadline can become ready together. Capture once,\n // including while asynchronous SVG/image conversion is still in progress.\n if (captureStarted) return;\n captureStarted = true;\n clearTimeout(timer);\n clearTimeout(deadline);\n observer?.disconnect();\n if (failed || document.querySelector('${r?"iframe, object, embed":"canvas, iframe, object, embed"}')) {\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n return;\n }\n try {\n const copy = document.createElement('div');\n copy.innerHTML = document.body.innerHTML;\n const sources = [document.body, ...document.body.querySelectorAll('*')];\n const targets = [copy, ...copy.querySelectorAll('*')];\n const properties = ${JSON.stringify(t.artifactStyleProperties)};\n sources.forEach((source, index) => {\n const target = targets[index];\n if (!target || !target.style) return;\n const computed = getComputedStyle(source);\n target.removeAttribute('style');\n properties.forEach(property => target.style.setProperty(property, computed.getPropertyValue(property)));\n // Static snapshots cannot retain clipped gradient text safely without\n // its full CSS. Keep the heading readable instead of copying transparency.\n if (computed.backgroundClip === 'text' || computed.webkitBackgroundClip === 'text') {\n target.style.setProperty('background-image', 'none');\n let ancestor = source.parentElement;\n let color = 'rgb(32, 32, 32)';\n while (ancestor) {\n const candidate = getComputedStyle(ancestor).color;\n if (candidate !== 'transparent' && candidate !== 'rgba(0, 0, 0, 0)') { color = candidate; break; }\n ancestor = ancestor.parentElement;\n }\n target.style.setProperty('color', color);\n }\n // A screen-reader-only caption must not become a new visible table cell\n // when its absolute positioning and clipping are deliberately discarded.\n if (computed.position === 'absolute' && computed.clip !== 'auto' && source.getBoundingClientRect().width <= 1) {\n target.hidden = true;\n target.style.setProperty('display', 'none');\n }\n });\n // Canvas pixels are not included in innerHTML. Freeze them as inert images.\n sources.forEach((source, index) => {\n if (!(source instanceof HTMLCanvasElement)) return;\n const target = targets[index];\n if (!source.width || !source.height) { target.remove(); return; }\n if (source.width * source.height > 16000000) throw new Error('Canvas too large');\n const pixels = document.createElement('canvas');\n pixels.width = source.width;\n pixels.height = source.height;\n const context = pixels.getContext('2d');\n if (!context) throw new Error('Canvas capture unavailable');\n context.drawImage(source, 0, 0);\n // Do not turn an empty decorative overlay into a large blank PDF section.\n if (source.getAttribute('aria-hidden') === 'true') {\n const data = context.getImageData(0, 0, pixels.width, pixels.height).data;\n let visible = false;\n for (let i = 3; i < data.length; i += 4) {\n if (data[i]) { visible = true; break; }\n }\n if (!visible) { target.remove(); return; }\n }\n const image = document.createElement('img');\n image.src = pixels.toDataURL('image/png');\n image.alt = source.getAttribute('aria-label') || source.textContent || '';\n image.style.cssText = target.style.cssText;\n const bounds = source.getBoundingClientRect();\n image.width = Math.max(1, Math.round(bounds.width || source.width));\n image.height = Math.max(1, Math.round(bounds.height || source.height));\n target.replaceWith(image);\n });\n // Preserve SVG charts as inert PNGs before the export's HTML-only sanitizer.\n // Capture outer SVGs once; their nested SVGs/defs are part of the same image.\n for (let index = 0; index < sources.length; index++) {\n const source = sources[index];\n if (!(source instanceof SVGSVGElement) || source.parentElement?.closest('svg')) continue;\n const picture = await captureSvg(source);\n if (picture) {\n picture.style.cssText = targets[index].style.cssText;\n targets[index].replaceWith(picture);\n } else targets[index].remove();\n }\n copy.querySelectorAll('script, style, link, meta, noscript').forEach(node => node.remove());\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, html: copy.outerHTML }, '*');\n } catch {\n // A tainted/unreadable canvas must fail, not produce an incomplete export.\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n }\n };\n window.addEventListener('error',
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("uuid"),t=require("./responseArtifactStyles.js"),n=require("./responseArtifactSvg.js");const r="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co",o=(e,r)=>`<script>\n(() => {\n const token = ${JSON.stringify(e)};\n const send = parent.postMessage.bind(parent);\n send({ type: 'PXE_RESPONSE_SNAPSHOT_STARTED', token }, '*');\n let failed = false;\n let captureStarted = false;\n let timer;\n let deadline;\n let observer;\n let paintReady = false;\n const captureSvg = ${n.artifactSvgSnapshotScript};\n const finish = async () => {\n // The quiet timer and deadline can become ready together. Capture once,\n // including while asynchronous SVG/image conversion is still in progress.\n if (captureStarted) return;\n captureStarted = true;\n clearTimeout(timer);\n clearTimeout(deadline);\n observer?.disconnect();\n if (failed || document.querySelector('${r?"iframe, object, embed":"canvas, iframe, object, embed"}')) {\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n return;\n }\n try {\n const copy = document.createElement('div');\n copy.innerHTML = document.body.innerHTML;\n const sources = [document.body, ...document.body.querySelectorAll('*')];\n const targets = [copy, ...copy.querySelectorAll('*')];\n const properties = ${JSON.stringify(t.artifactStyleProperties)};\n sources.forEach((source, index) => {\n const target = targets[index];\n if (!target || !target.style) return;\n const computed = getComputedStyle(source);\n target.removeAttribute('style');\n properties.forEach(property => target.style.setProperty(property, computed.getPropertyValue(property)));\n // Static snapshots cannot retain clipped gradient text safely without\n // its full CSS. Keep the heading readable instead of copying transparency.\n if (computed.backgroundClip === 'text' || computed.webkitBackgroundClip === 'text') {\n target.style.setProperty('background-image', 'none');\n let ancestor = source.parentElement;\n let color = 'rgb(32, 32, 32)';\n while (ancestor) {\n const candidate = getComputedStyle(ancestor).color;\n if (candidate !== 'transparent' && candidate !== 'rgba(0, 0, 0, 0)') { color = candidate; break; }\n ancestor = ancestor.parentElement;\n }\n target.style.setProperty('color', color);\n }\n // A screen-reader-only caption must not become a new visible table cell\n // when its absolute positioning and clipping are deliberately discarded.\n if (computed.position === 'absolute' && computed.clip !== 'auto' && source.getBoundingClientRect().width <= 1) {\n target.hidden = true;\n target.style.setProperty('display', 'none');\n }\n });\n // Canvas pixels are not included in innerHTML. Freeze them as inert images.\n sources.forEach((source, index) => {\n if (!(source instanceof HTMLCanvasElement)) return;\n const target = targets[index];\n if (!source.width || !source.height) { target.remove(); return; }\n if (source.width * source.height > 16000000) throw new Error('Canvas too large');\n const pixels = document.createElement('canvas');\n pixels.width = source.width;\n pixels.height = source.height;\n const context = pixels.getContext('2d');\n if (!context) throw new Error('Canvas capture unavailable');\n context.drawImage(source, 0, 0);\n // Do not turn an empty decorative overlay into a large blank PDF section.\n if (source.getAttribute('aria-hidden') === 'true') {\n const data = context.getImageData(0, 0, pixels.width, pixels.height).data;\n let visible = false;\n for (let i = 3; i < data.length; i += 4) {\n if (data[i]) { visible = true; break; }\n }\n if (!visible) { target.remove(); return; }\n }\n const image = document.createElement('img');\n image.src = pixels.toDataURL('image/png');\n image.alt = source.getAttribute('aria-label') || source.textContent || '';\n image.style.cssText = target.style.cssText;\n const bounds = source.getBoundingClientRect();\n image.width = Math.max(1, Math.round(bounds.width || source.width));\n image.height = Math.max(1, Math.round(bounds.height || source.height));\n target.replaceWith(image);\n });\n // Preserve SVG charts as inert PNGs before the export's HTML-only sanitizer.\n // Capture outer SVGs once; their nested SVGs/defs are part of the same image.\n for (let index = 0; index < sources.length; index++) {\n const source = sources[index];\n if (!(source instanceof SVGSVGElement) || source.parentElement?.closest('svg')) continue;\n const picture = await captureSvg(source);\n if (picture) {\n picture.style.cssText = targets[index].style.cssText;\n targets[index].replaceWith(picture);\n } else targets[index].remove();\n }\n copy.querySelectorAll('script, style, link, meta, noscript').forEach(node => node.remove());\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, html: copy.outerHTML }, '*');\n } catch {\n // A tainted/unreadable canvas must fail, not produce an incomplete export.\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n }\n };\n window.addEventListener('error', event => {\n // Missing images use the export's image fallback, not a fatal capture error.\n // Script errors (including errors thrown by image handlers) still fail.\n if (event.target instanceof HTMLImageElement) return;\n failed = true;\n }, true);\n window.addEventListener('unhandledrejection', () => { failed = true; });\n observer = new MutationObserver(() => {\n if (!paintReady) return;\n clearTimeout(timer);\n timer = setTimeout(finish, 1000);\n });\n observer.observe(document.documentElement, { subtree: true, childList: true, characterData: true, attributes: true });\n // Start the capture window only after the artifact has had a chance to paint.\n // If frames are suspended (for example in a background tab), the parent's\n // timeout rejects instead of silently exporting an uninitialized chart.\n requestAnimationFrame(() => requestAnimationFrame(() => {\n paintReady = true;\n timer = setTimeout(finish, 1000);\n // Live counters/animations may never settle. Capture their rendered state\n // after a bounded wait, rather than requiring permanent DOM inactivity.\n deadline = setTimeout(finish, 3000);\n }));\n})();\n<\/script>`;exports.renderResponseArtifactHtml=(t,n=!1,i)=>t.trimStart().startsWith("%PDF")?Promise.reject(new Error("Binary PDF artifacts cannot be rendered as HTML.")):window.location.origin===r?Promise.reject(new Error("Artifact rendering requires a separate origin.")):(null==i?void 0:i.closed)?Promise.reject(new Error("The response print window was closed.")):new Promise(((a,s)=>{const c=e.v4();let d,l,u,p=!1;const m=(i?[window,i]:[window]).map((e=>({target:e,document:e.document}))),g=()=>{void 0!==u&&(null==l||l.clearInterval(u)),u=void 0},h=()=>{p=!0,window.clearTimeout(w),window.clearInterval(b),g(),m.forEach((({target:e,document:t})=>{e.removeEventListener("message",v),e.removeEventListener("focus",y),t.removeEventListener("visibilitychange",y)})),null==d||d.remove()},f=e=>{p||(h(),s(new Error(e)))},v=e=>{var t;!p&&d&&e.source===d.contentWindow&&e.origin===r&&(null===(t=e.data)||void 0===t?void 0:t.token)===c&&("PXE_RESPONSE_SNAPSHOT_STARTED"!==e.data.type?"PXE_RESPONSE_SNAPSHOT"===e.data.type&&(h(),e.data.error||"string"!=typeof e.data.html||e.data.html.length>1e7?s(new Error("Unable to capture the complete artifact.")):a(e.data.html)):g())},y=()=>{var e;if(p)return;if(null==i?void 0:i.closed)return void f("The response print window was closed.");const a=!document.hidden&&document.hasFocus()?window:i&&!i.document.hidden?i:document.hidden&&null!==(e=null!=l?l:i)&&void 0!==e?e:window;if(a===l)return;g(),null==d||d.remove(),l=a;const s=a.document.createElement("iframe");d=s,s.src=`${r}/html`,s.setAttribute("sandbox","allow-scripts allow-same-origin"),s.setAttribute("aria-hidden","true"),s.tabIndex=-1,s.style.cssText="position:fixed;left:0;top:0;width:900px;height:600px;border:0;opacity:0;pointer-events:none;",s.onload=()=>{p||d!==s||(g(),u=a.setInterval((()=>{var e;return null===(e=s.contentWindow)||void 0===e?void 0:e.postMessage({type:"HTML_CODE",content:o(c,n)+t},r)}),250))},s.onerror=()=>{d===s&&f("Unable to load the artifact renderer.")},a.document.body.appendChild(s)},w=window.setTimeout((()=>f("Artifact rendering timed out.")),15e3),b=i?window.setInterval((()=>{i.closed&&f("The response print window was closed.")}),250):void 0;m.forEach((({target:e,document:t})=>{e.addEventListener("message",v),e.addEventListener("focus",y),t.addEventListener("visibilitychange",y)})),y()}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("./responseDownloadHtml.js");exports.createResponseArtifactWordImages=(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("./responseDownloadHtml.js"),o=require("./responseDownloadImages.js");exports.createResponseArtifactWordImages=(r,n)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;let i=t.createResponseDownloadDocument(`<div class="pxe-export-artifact">${r}</div>`,!0);const a=document.createElement("template");a.innerHTML=i;const l=yield o.embedResponseDownloadImages(a.content,"docx");for(const t of a.content.querySelectorAll("img")){if(l.has(t))continue;const o=document.createElement("span");o.textContent=`⚠ ${(null===(e=t.getAttribute("alt"))||void 0===e?void 0:e.trim())||"[…]"}`,t.replaceWith(o)}i=`<!doctype html>\n${a.innerHTML}`;const c=document.createElement("iframe");c.setAttribute("sandbox","allow-same-origin"),c.setAttribute("aria-hidden","true"),c.tabIndex=-1,c.style.cssText="position:fixed;left:-10000px;top:0;width:720px;height:600px;border:0;pointer-events:none";try{yield new Promise(((e,t)=>{const o=setTimeout((()=>t(new Error("Word snapshot timed out."))),5e3);c.onload=()=>{clearTimeout(o),e()},c.onerror=()=>{clearTimeout(o),t(new Error("Word snapshot failed."))},c.srcdoc=i,document.body.appendChild(c)}));const e=c.contentDocument,t=c.contentWindow,o=null==e?void 0:e.querySelector("main");if(!e||!t||!o)throw new Error("Word snapshot unavailable.");const r=e.createElement("style");r.textContent="main{display:flow-root;width:720px;max-width:none;padding:0;margin:0}\n.pxe-export-artifact{overflow:visible}\n.pxe-export-artifact:has(tr > :nth-child(6)) > div{min-width:0}\ntable{width:100%;table-layout:fixed} pre{white-space:pre-wrap;overflow-wrap:anywhere}\n*{animation:none!important;transition:none!important}",e.head.appendChild(r),e.querySelectorAll("details").forEach((e=>{e.open=!0}));const a=Math.ceil(Math.max(o.scrollWidth,o.getBoundingClientRect().width)),l=Math.ceil(o.getBoundingClientRect().height);if(a>1440||!l||l>16e3)throw new Error("Artifact is too large for a readable Word picture.");const s=o.cloneNode(!0),d=[o,...o.querySelectorAll("*")],h=[s,...s.querySelectorAll("*")];d.forEach(((e,o)=>{const r=h[o],n=t.getComputedStyle(e);r.removeAttribute("style");for(const e of Array.from(n))r.style.setProperty(e,n.getPropertyValue(e))})),s.setAttribute("xmlns","http://www.w3.org/1999/xhtml");const p=(new XMLSerializer).serializeToString(s);if(p.length>1e7)throw new Error("Word snapshot is too large.");const m=o.getBoundingClientRect().top,u=[],w=e.createTreeWalker(o,NodeFilter.SHOW_TEXT);for(;w.nextNode();){const t=e.createRange();t.selectNodeContents(w.currentNode);for(const e of Array.from(t.getClientRects()))e.height&&u.push({top:e.top-m,bottom:e.bottom-m})}o.querySelectorAll("tr,img").forEach((e=>{const t=e.getBoundingClientRect();t.height<=800&&u.push({top:t.top-m,bottom:t.bottom-m})}));const g=[];let f=0;for(let t=0;t<l;){let o=Math.min(l,t+800);if(o<l)for(let e=0;e<u.length;e++){const e=u.find((e=>e.top+1<o&&e.bottom-1>o));if(!e||e.top<=t)break;o=Math.ceil(e.top)}if(o<=t)throw new Error("Unable to paginate artifact picture.");const r=`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${o-t}" viewBox="0 ${t} ${a} ${o-t}"><foreignObject x="0" y="0" width="${a}" height="${l}">${p}</foreignObject></svg>`,i=new Image;yield new Promise(((e,t)=>{const o=setTimeout((()=>n(!1)),5e3),n=r=>{clearTimeout(o),i.onload=i.onerror=null,r?e():t(new Error("Unable to draw Word artifact picture."))};i.onload=()=>n(!0),i.onerror=()=>n(!1),i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`}));const c=document.createElement("canvas");c.width=2*a,c.height=2*(o-t);const s=c.getContext("2d");if(!s)throw new Error("Word image capture unavailable.");s.fillStyle="white",s.fillRect(0,0,c.width,c.height),s.drawImage(i,0,0,c.width,c.height);const d=c.toDataURL("image/png");if(f+=d.length,f>1e7)throw new Error("Word artifact pictures are too large.");const h=e.createElement("img");h.src=d,h.width=a,h.height=o-t,h.alt=n;const m=e.createElement("p");m.appendChild(h),g.push(m.outerHTML),c.width=c.height=0,i.removeAttribute("src"),t=o}return g.join("")}finally{c.remove()}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("docx"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("docx"),n=require("./responseDownloadHtml.js"),r=require("./responseDownloadImages.js");const a=720,i=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DD","DETAILS","DIV","DL","DT","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SUMMARY","TABLE","UL"]),s=e=>{if(e&&/^(https?:|mailto:|tel:)/i.test(e.trim()))try{return new URL(e.trim()).href}catch(e){return}},o=(e,n)=>{const r=Object.assign({},n);switch(e.tagName){case"STRONG":case"B":r.bold=!0;break;case"EM":case"I":r.italics=!0;break;case"DEL":case"S":case"STRIKE":r.strike=!0;break;case"U":r.underline={type:t.UnderlineType.SINGLE};break;case"CODE":case"KBD":case"SAMP":r.font="Courier New";break;case"SUP":r.superScript=!0;break;case"SUB":r.subScript=!0}return r};exports.createResponseDownloadDocx=(l,c)=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=document.createElement("template");e.innerHTML=null!=c?c:n.createResponseDownloadHtml(l);const d=e.content.querySelector("main");if(!d)throw new Error("Unable to prepare the response document.");const u=yield r.embedResponseDownloadImages(d,"docx"),g=new Map;for(const e of u){const t=e.getAttribute("src")||"";if(t.length>1e7)throw new Error("Artifact image too large.");const n=Uint8Array.from(atob(t.slice(22)),(e=>e.charCodeAt(0))),r=new DataView(n.buffer);if(n.length<24||2303741511!==r.getUint32(0)||218765834!==r.getUint32(4)||1229472850!==r.getUint32(12))throw new Error("Invalid artifact image.");const a=r.getUint32(16),i=r.getUint32(20);if(!a||!i||a*i>16e6)throw new Error("Artifact image dimensions are unsupported.");yield new Promise(((e,n)=>{const r=new Image,s=t=>{clearTimeout(o),r.onload=r.onerror=null,r.removeAttribute("src"),t?e():n(new Error("Unable to read artifact image."))},o=setTimeout((()=>s(!1)),5e3);r.onload=()=>s(r.naturalWidth===a&&r.naturalHeight===i),r.onerror=()=>s(!1),r.src=t}));const s=Number(e.getAttribute("width")),o=s>0?Math.min(1,s/a):1;g.set(e,{data:n,width:a*o,height:i*o})}const h=[],m=(e,n,r)=>Array.from(e).flatMap((e=>{var a;if(3===e.nodeType){const r=e.textContent||"";return[new t.TextRun(Object.assign(Object.assign({},n),{text:(null===(a=e.parentElement)||void 0===a?void 0:a.closest("code"))?r:r.replace(/[\t\n\r ]+/g," ")}))]}if(1!==e.nodeType)return[];const i=e,l=o(i,n);if("BR"===i.tagName)return[new t.TextRun(Object.assign(Object.assign({},n),{break:1}))];if("IMG"===i.tagName){const e=g.get(i);if(e){const n=Math.min(1,Math.max(1,r/15)/e.width,900/e.height);return[new t.ImageRun(Object.assign(Object.assign({type:"png",data:e.data},i.getAttribute("alt")?{altText:{name:i.getAttribute("alt")||""}}:{}),{transformation:{width:e.width*n,height:e.height*n}}))]}const a=s(i.getAttribute("src")),o=i.getAttribute("alt")||a||"[…]",l=[new t.TextRun(Object.assign(Object.assign({},n),{text:o}))];return a&&!i.closest("a")?[new t.ExternalHyperlink({link:a,children:l})]:l}const c="A"===i.tagName?s(i.getAttribute("href")):void 0,d=m(i.childNodes,c?Object.assign(Object.assign({},l),{color:"174EA6",underline:{type:t.UnderlineType.SINGLE}}):l,r);return c?[new t.ExternalHyperlink({link:c,children:d})]:d})),p=(e,n,r={})=>{const a=n.marker&&!n.marker.used?n.marker:void 0;return a&&(a.used=!0),new t.Paragraph(Object.assign(Object.assign(Object.assign({children:e,spacing:{after:160},widowControl:!0},n.indent?{indent:Object.assign({left:n.indent},a?{hanging:360}:{})}:{}),null==a?void 0:a.properties),r))},b=(e,n)=>{var r;const a="OL"===e.tagName;let i="",s=!1;const o=e=>{i=`response-list-${h.length}`,s=0===e,h.push({reference:i,levels:[{level:0,format:t.LevelFormat.DECIMAL,text:s?"0.":"%1.",start:s?1:e,alignment:t.AlignmentType.LEFT}]})},l=e.hasAttribute("reversed"),c=Array.from(e.children).filter((e=>"LI"===e.tagName)),d=Number.parseInt(e.getAttribute("start")||"",10);let u=Number.isFinite(d)?d:l?c.length:1;a&&o(u);const g=[];for(const t of Array.from(e.children)){if("LI"!==t.tagName){g.push(...w([t],n));continue}const e=Number.parseInt(t.getAttribute("value")||"",10);a&&Number.isFinite(e)&&(u=e),a&&(l||s||0===u||Number.isFinite(e))&&o(u),u+=l?-1:1;const c=Object.assign(Object.assign({},n),{indent:Math.min(n.indent+720,5760),marker:{used:!1,properties:a?{numbering:{reference:i,level:0}}:{bullet:{level:0}}}}),d=w(t.childNodes,c);(null===(r=c.marker)||void 0===r?void 0:r.used)||d.unshift(p([],c)),g.push(...d)}return g},f=(e,n)=>{const r=[];let a=0;const i=Array.from(e.querySelectorAll("tr")).filter((t=>t.closest("table")===e)).map(((e,t)=>{let n=0;return{row:e,cells:Array.from(e.children).filter((e=>"TD"===e.tagName||"TH"===e.tagName)).map((e=>{for(;r[n]>t;)n++;const i=t=>Math.min(100,Math.max(1,parseInt(e.getAttribute(t)||"1",10)||1)),s=i("colspan"),o=i("rowspan"),l=n;for(let e=0;e<s;e++)r[n++]=t+o;return a=Math.max(a,n),{cell:e,start:l,columnSpan:s,rowSpan:o}}))}})),s=e=>Math.floor(e*n/a),o=Array.from({length:a},((e,t)=>s(t+1)-s(t))),l=i.flatMap((({row:e,cells:n})=>{var r;return n.length?[new t.TableRow({tableHeader:"THEAD"===(null===(r=e.parentElement)||void 0===r?void 0:r.tagName)||n.every((({cell:e})=>"TH"===e.tagName)),children:n.map((({cell:e,start:n,columnSpan:r,rowSpan:a})=>{const i=s(n+r)-s(n),o=w(e.childNodes,{indent:0,width:Math.max(1,i-200),run:{bold:"TH"===e.tagName}});return o[o.length-1]instanceof t.Paragraph||o.push(new t.Paragraph("")),new t.TableCell(Object.assign({children:o,columnSpan:r,rowSpan:a,width:{size:i,type:t.WidthType.DXA},margins:{top:80,bottom:80,left:100,right:100}},"TH"===e.tagName?{shading:{fill:"F0F0F0"}}:{}))}))})]:[]})),c=Array.from(e.children).filter((e=>"CAPTION"===e.tagName));return l.length?[...w(c,{indent:0,width:n,run:{}}),new t.Table({rows:l,width:{size:n,type:t.WidthType.DXA},columnWidths:o})]:w(e.childNodes,{indent:0,width:n,run:{}})},w=(e,n)=>{const r=[];let a=[];const s=()=>{a.some((e=>{var t;return(null===(t=e.textContent)||void 0===t?void 0:t.trim())||1===e.nodeType&&/^(BR|IMG)$/.test(e.tagName)||1===e.nodeType&&e.querySelector("br,img")}))&&r.push(p(m(a,n.run,n.width-n.indent),n)),a=[]};for(const l of Array.from(e)){if(1!==l.nodeType||!i.has(l.tagName)){1===l.nodeType&&Array.from(l.children).some((e=>i.has(e.tagName)))?(s(),r.push(...w(l.childNodes,Object.assign(Object.assign({},n),{run:o(l,n.run)})))):a.push(l);continue}s();const e=l,c=e.tagName;if("UL"===c||"OL"===c)n.marker&&!n.marker.used&&r.push(p([],n)),r.push(...b(e,n));else if("TABLE"===c)n.marker&&!n.marker.used&&r.push(p([],n)),r.push(...f(e,n.width));else if("PRE"===c){const a=(e.textContent||"").replace(/\r\n?/g,"\n").split("\n");r.push(p(a.map(((e,r)=>new t.TextRun(Object.assign(Object.assign(Object.assign({},n.run),{children:e.split("\t").flatMap(((e,n)=>n?[new t.Tab,e]:[e])),font:"Courier New",size:20}),r?{break:1}:{})))),n,{shading:{fill:"F4F4F4"},spacing:{before:120,after:160}}))}else if(/^H[1-6]$/.test(c)){const a=[t.HeadingLevel.HEADING_1,t.HeadingLevel.HEADING_2,t.HeadingLevel.HEADING_3,t.HeadingLevel.HEADING_4,t.HeadingLevel.HEADING_5,t.HeadingLevel.HEADING_6];r.push(p(m(e.childNodes,Object.assign(Object.assign({},n.run),{bold:!0,color:"202020"}),n.width-n.indent),n,{heading:a[Number(c[1])-1],keepNext:!0}))}else if("HR"===c)r.push(p([],n,{border:{bottom:{style:t.BorderStyle.SINGLE,color:"CCCCCC",size:4}}}));else{const t="BLOCKQUOTE"===c?Object.assign(Object.assign({},n),{indent:n.indent+360}):n,a=w(e.childNodes,t);r.push(...a),a.length||"P"!==c||r.push(p([],t))}}return s(),r},A=w(d.childNodes,{indent:0,width:10800,run:{}}),N=new t.Document({title:"Pickaxe",creator:"Pickaxe",styles:{default:{document:{run:{font:"Arial",size:22,color:"202020"}}}},numbering:{config:h},sections:[{properties:{page:{size:{width:12240,height:15840},margin:{top:a,bottom:a,left:a,right:a}}},children:A.length?A:[new t.Paragraph("")]}]});return t.Packer.toBlob(N)}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("react"),r=require("react-dom/server"),n=require("react-markdown"),o=require("remark-gfm"),a=require("rehype-raw"),i=require("isomorphic-dompurify"),l=require("./responseArtifactStyles.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("react"),r=require("react-dom/server"),n=require("react-markdown"),o=require("remark-gfm"),a=require("rehype-raw"),i=require("isomorphic-dompurify"),l=require("./responseArtifactStyles.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=d(n),p=d(o),s=d(a),h=d(i);const w=e=>{const n=r.renderToStaticMarkup(t.createElement(c.default,{remarkPlugins:[p.default],rehypePlugins:[s.default],components:{input:({type:e,checked:r})=>"checkbox"===(null==e?void 0:e.toLowerCase())?t.createElement("span",null,r?"☑":"☐"):null}},e));return m(n)},m=(e,t=!1)=>{let r=h.default.sanitize(e,{USE_PROFILES:{html:!0},FORBID_TAGS:["script","style","iframe","form","input","button","select","textarea","object","embed","link","meta","base","audio","video","source","track"],FORBID_ATTR:["srcset","ping","background",...t?[]:["style"]],ALLOW_DATA_ATTR:!1});if(t){const e=document.createElement("template");e.innerHTML=r,l.filterArtifactStyles(e.content),e.content.querySelectorAll("label").forEach((e=>{var t;(null===(t=e.textContent)||void 0===t?void 0:t.trim())||e.children.length||e.remove()})),r=e.innerHTML}return`<!doctype html>\n<html>\n<head>\n<meta charset="utf-8">\n<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src https: data:; base-uri 'none'; form-action 'none'">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n<title>Pickaxe</title>\n<style>\nbody { margin: 0; background: white; color: #202020; font: 16px/1.6 system-ui, sans-serif; }\nmain { max-width: 900px; margin: 0 auto; padding: 24px; overflow-wrap: anywhere; }\nh1, h2, h3, h4, h5, h6 { line-height: 1.25; }\na { color: #174ea6; }\npre, code { font-family: ui-monospace, monospace; }\npre { padding: 16px; background: #f4f4f4; overflow-x: auto; white-space: pre; }\nblockquote { margin-left: 0; padding-left: 16px; border-left: 3px solid #ccc; }\ntable { border-collapse: collapse; max-width: 100%; }\nth, td { border: 1px solid #ccc; padding: 8px; text-align: start; }\nimg { max-width: 100%; height: auto; }\nsummary { cursor: pointer; }\n${t?"\n.pxe-export-artifact { max-width: 100%; overflow-x: auto; }\n.pxe-export-artifact:has(tr > :nth-child(6)) > div { min-width: 720px; }\n.pxe-export-artifact table { width: 100%; max-width: 100%; }\n.pxe-export-artifact th, .pxe-export-artifact td { overflow-wrap: anywhere; }\n@media print {\n .pxe-export-artifact { overflow: visible; }\n .pxe-export-artifact:has(tr > :nth-child(6)) > div { min-width: 0; }\n .pxe-export-artifact table { width: 100%; min-width: 0; max-width: 100%; table-layout: fixed; }\n .pxe-export-artifact th, .pxe-export-artifact td { padding: 5px !important; font-size: 10px !important; overflow-wrap: anywhere; }\n .pxe-export-artifact, .pxe-export-artifact * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }\n}\n":""}</style>\n</head>\n<body><main dir="auto">${r}</main></body>\n</html>`},u=(t,r)=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=null!=r?r:window.open("","_blank");if(!e||e.closed)throw new Error("Unable to open the response print window.");try{e.opener=null;const r=e.document;r.open(),r.write(t);const n=r.createElement("style");if(n.media="print",n.textContent="\n@page { margin: 12mm; }\nmain { max-width: none; padding: 0; }\npre { overflow: visible; }\npre, pre code { white-space: pre-wrap; overflow-wrap: anywhere; }\ntable { width: 100%; table-layout: fixed; }\nth, td { white-space: normal; overflow-wrap: anywhere; }\nthead { display: table-header-group; }\ntr, img { break-inside: avoid; }\nh1, h2, h3, h4, h5, h6 { break-after: avoid; }\np, li { orphans: 3; widows: 3; }\n",r.head.appendChild(n),r.querySelectorAll("details").forEach((e=>{e.open=!0})),r.querySelectorAll("img").forEach((e=>{e.loading="eager"})),r.close(),e.focus(),yield f(e,r),e.closed)throw new Error("The response print window was closed.");r.body.offsetHeight,e.focus(),e.print()}catch(t){throw e.close(),t}})),f=(t,r)=>new Promise(((n,o)=>{const a=new Set(Array.from(r.images)),i=e=>{if(c)return;a.delete(e);const t=r.createElement("span");t.textContent=`⚠ ${e.alt.trim()||"[…]"}`,t.style.cssText="display:inline-block;border:1px solid #999;padding:4px;white-space:normal;overflow-wrap:anywhere;",e.removeAttribute("src"),e.removeAttribute("srcset"),e.replaceWith(t)},l=window.setTimeout((()=>{a.forEach(i),p()}),15e3),d=window.setInterval((()=>{t.closed&&p(new Error("The response print window was closed."))}),100);let c=!1;function p(e){c||(c=!0,window.clearTimeout(l),window.clearInterval(d),e?o(e):n())}Promise.all([...Array.from(a,(t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(yield t.decode(),!t.complete||!t.naturalWidth||!t.naturalHeight)throw new Error("Unable to load a response print image.");a.delete(t)}catch(e){i(t)}})))),r.fonts.ready]).then((()=>p()),(()=>p(new Error("Unable to load the response print resources."))))}));exports.createResponseDownloadDocument=m,exports.createResponseDownloadHtml=w,exports.printResponseDownloadDocument=u,exports.printResponseDownloadHtml=e=>u(w(e));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js");const t=75e5,r=25e6,o=e=>{if(/^data:image\/(png|jpeg|gif|webp);base64,/i.test(e))return e.length<=105e5?e:void 0;try{const t=new URL(e);if(!t.username&&!t.password&&("https:"===t.protocol||"http:"===t.protocol&&t.origin===location.origin))return t.href}catch(e){}},n=(e,t)=>new Promise(((r,o)=>{const n=new Image,i=e=>{n.onload=n.onerror=null,t.removeEventListener("abort",a),e&&n.naturalWidth&&n.naturalHeight?r(n):(n.removeAttribute("src"),o(new Error("Image unavailable.")))},a=()=>i(!1);if(t.aborted)return a();t.addEventListener("abort",a,{once:!0}),n.referrerPolicy="no-referrer",n.onload=()=>i(!0),n.onerror=()=>i(!1),n.src=e})),i=(i,a)=>e.__awaiter(void 0,void 0,void 0,(function*(){const l=Array.from(i.querySelectorAll("img")),s=new Set,c=new AbortController,d=setTimeout((()=>c.abort()),15e3),u=new Map;let m=0,g=0;const h=o=>e.__awaiter(void 0,void 0,void 0,(function*(){let i,l;try{if(c.signal.aborted)return;const s=yield((r,o)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;const n=yield fetch(r,{signal:o,credentials:"omit",referrerPolicy:"no-referrer"});if(!n.ok||!n.body)throw new Error("Image unavailable.");const i=null===(e=n.headers.get("content-type"))||void 0===e?void 0:e.split(";")[0].trim();if(!i||!/^image\/(png|jpeg|gif|webp|svg\+xml)$/i.test(i)||Number(n.headers.get("content-length"))>t)throw yield n.body.cancel(),new Error("Unsupported image.");const a=n.body.getReader(),l=[];let s=0;try{for(;;){const{done:e,value:r}=yield a.read();if(e)break;if(s+=r.byteLength,s>t)throw new Error("Image too large.");l.push(r)}}finally{yield a.cancel()}return new Blob(l,{type:i})})))(o,c.signal);if(m+=s.size,m>r)return;if(i=URL.createObjectURL(s),l=yield n(i,c.signal),l.naturalWidth*l.naturalHeight>16e6)return;if("docx"===a||"image/svg+xml"===s.type){const e=document.createElement("canvas");try{e.width=l.naturalWidth,e.height=l.naturalHeight;const t=e.getContext("2d");if(!t)return;t.drawImage(l,0,0);const o=e.toDataURL("image/png");if(m+=o.length,o.length>1e7||m>r)return;return o}finally{e.width=e.height=0}}const d=new Uint8Array(yield s.arrayBuffer());let u="";for(let e=0;e<d.length;e+=8192)u+=String.fromCharCode(...d.subarray(e,e+8192));return`data:${s.type};base64,${btoa(u)}`}catch(e){return}finally{null==l||l.removeAttribute("src"),i&&URL.revokeObjectURL(i)}}));try{yield Promise.all(Array.from({length:Math.min(4,l.length)},(()=>e.__awaiter(void 0,void 0,void 0,(function*(){for(var e,t;g<l.length;){const r=l[g++],i=o(r.getAttribute("src")||"");let d;if(i&&(u.has(i)||u.size<50)&&(u.has(i)||u.set(i,h(i)),d=yield u.get(i)),d)s.add(r),r.setAttribute("src",d),r.removeAttribute("srcset");else if("html"===a&&(null==i?void 0:i.startsWith("https:")))try{(yield n(i,c.signal)).removeAttribute("src");continue}catch(t){const o=document.createElement("span");o.textContent=`⚠ ${(null===(e=r.getAttribute("alt"))||void 0===e?void 0:e.trim())||"[…]"}`,r.replaceWith(o)}else if("html"===a){const e=document.createElement("span");e.textContent=`⚠ ${(null===(t=r.getAttribute("alt"))||void 0===t?void 0:t.trim())||"[…]"}`,r.replaceWith(e)}}})))))}finally{clearTimeout(d),c.abort()}return s}));exports.embedResponseDownloadHtmlImages=t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=(new DOMParser).parseFromString(t,"text/html");yield i(e,"html");for(const t of e.querySelectorAll("iframe[srcdoc]")){const e=t.getAttribute("srcdoc");if(e){const r=(new DOMParser).parseFromString(e,"text/html");yield i(r,"html"),t.setAttribute("srcdoc",`<!doctype html>\n${r.documentElement.outerHTML}`)}}return`<!doctype html>\n${e.documentElement.outerHTML}`})),exports.embedResponseDownloadImages=i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),n=require("react-dom"),r=require("uuid"),s=require("file-saver"),i=require("../../../common/responseDownloadDocx.js"),l=require("../../../common/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),n=require("react-dom"),r=require("uuid"),s=require("file-saver"),i=require("../../../common/responseDownloadDocx.js"),l=require("../../../common/responseDownloadImages.js"),a=require("../../../common/responseDownloadHtml.js"),u=require("../../../common/responseDownloadArtifacts.js"),d=require("../../../common/responseArtifactSnapshot.js"),c=require("../Addons/Artifact/hooks/useArtifactContext.js"),f=require("../Addons/Artifact/hooks/useArtifactData.js"),p=require("../Addons/Auth/hooks/useAuthContext.js"),m=require("../../../hooks/pickaxe/usePickaxeContext.js"),x=require("../../../hooks/core/useOutsideAlerter.js"),v=require("../../Icons/download.svg.js"),w=require("../../Core/Menu/index.js"),y=require("../../Core/Menu/List.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var b=h(s);const g=[{extension:"txt",label:"TXT",mimeType:"text/plain;charset=utf-8"},{extension:"md",label:"Markdown (.md)",mimeType:"text/markdown;charset=utf-8"},{extension:"html",label:"HTML (.html)",mimeType:"text/html;charset=utf-8"},{extension:"pdf",label:"PDF"},{extension:"docx",label:"DOCX"}];exports.default=({color:s,text:h,disabled:j=!1})=>{const{translations:k,colors:A,styles:D,isRtl:q,sender:C,senderType:O,pickaxe:R}=m.usePickaxeContext(),{artifacts:T=[]}=c.useArtifactContext(),{token:S}=p.useAuthContext(),P=f.useArtifactData(),[_,E]=o.useState(""),[H,I]=o.useState(!1),[M,N]=o.useState(),[$,B]=o.useState(!1),F=o.useRef(!1),L=o.useRef(null),K=o.useRef(null),U=o.useRef([]),X=o.useRef(0),W=(null==k?void 0:k.download)||"Download",z=j||$||!h.trim();o.useEffect((()=>{E(`response-download-${r.v4()}`)}),[]),o.useEffect((()=>{z&&I(!1)}),[z]),o.useEffect((()=>{H&&L.current&&N(getComputedStyle(L.current).fontFamily)}),[H,D.font]),x.useOutsideAlerter({ref:[L,K],callback:()=>I(!1)});const G=()=>{var e;I(!1),null===(e=L.current)||void 0===e||e.focus({preventScroll:!0})},J=e=>{var t;if(!z)if("Escape"===e.key&&H)e.preventDefault(),e.stopPropagation(),G();else if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e.stopPropagation();const o=U.current.indexOf(e.currentTarget),n="ArrowDown"===e.key?1:-1,r=g.length,s=-1===o?1===n?0:r-1:(o+n+r)%r;X.current=s,I(!0),null===(t=U.current[s])||void 0===t||t.focus({preventScroll:!0})}else"Tab"===e.key&&I(!1)},Q=e=>{e.relatedTarget===L.current||U.current.some((t=>t===e.relatedTarget))||I(!1)};return t.jsxs(w.default,Object.assign({id:_,className:"h-4 w-4 shrink-0",isOpen:H&&!z,onChange:I,closeOnSelect:!1,closeOnClickOutside:!1},{children:[t.jsx("button",Object.assign({ref:L,id:_||void 0,type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-30",style:{color:s},title:W,"aria-label":W,"aria-haspopup":"menu","aria-busy":$,"aria-expanded":H&&!z,"aria-controls":H&&!z?`${_}-menu`:void 0,disabled:z,onClick:e=>{e.stopPropagation(),X.current=0,I((e=>!e))},onKeyDown:J,onBlur:Q},{children:t.jsx(v.default,{className:"h-4 w-4 shrink-0","aria-hidden":"true"})})),_&&!z&&n.createPortal(t.jsx("div",Object.assign({ref:K,style:{fontFamily:M},dir:q?"rtl":"ltr"},{children:t.jsx(y.default,Object.assign({id:`${_}-menu`,role:"menu",align:"right",width:"auto",className:"p-1 text-sm",style:{backgroundColor:A.primary,color:A.text,maxWidth:"calc(100vw - 32px)"},imperativeModeOnly:!0,afterShow:()=>{var e;return null===(e=U.current[X.current])||void 0===e?void 0:e.focus({preventScroll:!0})}},{children:g.map(((o,n)=>t.jsx("button",Object.assign({ref:e=>{U.current[n]=e},type:"button",role:"menuitem",tabIndex:-1,className:"rounded-sm px-3 py-2 text-left hover:bg-black/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px]",onClick:t=>{((t,o)=>{e.__awaiter(void 0,void 0,void 0,(function*(){var n;if(t.stopPropagation(),z||F.current)return;let r;G();try{const t=u.findResponseArtifacts(h);let s;if(t.length){if(F.current=!0,B(!0),"pdf"===o.extension){if(r=null!==(n=window.open("","_blank"))&&void 0!==n?n:void 0,!r)throw new Error("Unable to open the print window.");r.opener=null;const e=r.document.createElement("p");e.textContent=(null==k?void 0:k.loading)||"Loading...",e.setAttribute("role","status"),e.style.cssText="margin:32px;font:16px system-ui,sans-serif",r.document.body.appendChild(e)}s=yield u.prepareResponseArtifactDownload(h,t,(t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=T.find((e=>e.id===t.id&&e.version===t.version));return null!=e?e:P.mutateAsync({artifactId:t.id,version:t.version,studioId:null==R?void 0:R.studioid,senderType:O,sender:C||void 0,studioSessionToken:S||void 0})}))),o.extension,(e=>d.renderResponseArtifactHtml(e,"pdf"===o.extension||"docx"===o.extension,r)))}if("docx"===o.extension){F.current=!0,B(!0);const e=yield i.createResponseDownloadDocx(h,s);return void b.default(e,"response.docx")}if("pdf"===o.extension)return F.current=!0,B(!0),void(s?yield a.printResponseDownloadDocument(s,r):yield a.printResponseDownloadHtml(h));let c=null!=s?s:"html"===o.extension?a.createResponseDownloadHtml(h):h;"html"===o.extension&&(F.current=!0,B(!0),c=yield l.embedResponseDownloadHtmlImages(c));const f=new Blob([c],{type:o.mimeType});b.default(f,`response.${o.extension}`)}catch(e){console.error("Response download failed",{format:o.extension,error:e}),null==r||r.close(),window.alert((null==k?void 0:k["something-went-wrong"])||"Something went wrong.")}finally{F.current=!1,B(!1)}}))})(t,o)},onKeyDown:J,onBlur:Q},{children:o.label}),o.extension)))}))})),document.body)]}))};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Exports the same sanitized response used by HTML/PDF as editable Word content.
|
|
3
|
-
* Parsing stays in an inert template.
|
|
4
|
-
*
|
|
3
|
+
* Parsing stays in an inert template. Images are copied with bounded anonymous
|
|
4
|
+
* requests; response scripts and the live chat DOM are never used.
|
|
5
5
|
*/
|
|
6
6
|
export declare const createResponseDownloadDocx: (text: string, preparedHtml?: string) => Promise<Blob>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Only modifies an inert export copy. Never reads or changes live chat images. */
|
|
2
|
+
export declare const embedResponseDownloadImages: (root: ParentNode, format: "docx" | "html") => Promise<Set<Element>>;
|
|
3
|
+
export declare const embedResponseDownloadHtmlImages: (html: string) => Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v4 as e}from"uuid";import{artifactStyleProperties as t}from"./responseArtifactStyles.js";import{artifactSvgSnapshotScript as n}from"./responseArtifactSvg.js";const r="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co",o=(e,r)=>`<script>\n(() => {\n const token = ${JSON.stringify(e)};\n const send = parent.postMessage.bind(parent);\n send({ type: 'PXE_RESPONSE_SNAPSHOT_STARTED', token }, '*');\n let failed = false;\n let captureStarted = false;\n let timer;\n let deadline;\n let observer;\n let paintReady = false;\n const captureSvg = ${n};\n const finish = async () => {\n // The quiet timer and deadline can become ready together. Capture once,\n // including while asynchronous SVG/image conversion is still in progress.\n if (captureStarted) return;\n captureStarted = true;\n clearTimeout(timer);\n clearTimeout(deadline);\n observer?.disconnect();\n if (failed || document.querySelector('${r?"iframe, object, embed":"canvas, iframe, object, embed"}')) {\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n return;\n }\n try {\n const copy = document.createElement('div');\n copy.innerHTML = document.body.innerHTML;\n const sources = [document.body, ...document.body.querySelectorAll('*')];\n const targets = [copy, ...copy.querySelectorAll('*')];\n const properties = ${JSON.stringify(t)};\n sources.forEach((source, index) => {\n const target = targets[index];\n if (!target || !target.style) return;\n const computed = getComputedStyle(source);\n target.removeAttribute('style');\n properties.forEach(property => target.style.setProperty(property, computed.getPropertyValue(property)));\n // Static snapshots cannot retain clipped gradient text safely without\n // its full CSS. Keep the heading readable instead of copying transparency.\n if (computed.backgroundClip === 'text' || computed.webkitBackgroundClip === 'text') {\n target.style.setProperty('background-image', 'none');\n let ancestor = source.parentElement;\n let color = 'rgb(32, 32, 32)';\n while (ancestor) {\n const candidate = getComputedStyle(ancestor).color;\n if (candidate !== 'transparent' && candidate !== 'rgba(0, 0, 0, 0)') { color = candidate; break; }\n ancestor = ancestor.parentElement;\n }\n target.style.setProperty('color', color);\n }\n // A screen-reader-only caption must not become a new visible table cell\n // when its absolute positioning and clipping are deliberately discarded.\n if (computed.position === 'absolute' && computed.clip !== 'auto' && source.getBoundingClientRect().width <= 1) {\n target.hidden = true;\n target.style.setProperty('display', 'none');\n }\n });\n // Canvas pixels are not included in innerHTML. Freeze them as inert images.\n sources.forEach((source, index) => {\n if (!(source instanceof HTMLCanvasElement)) return;\n const target = targets[index];\n if (!source.width || !source.height) { target.remove(); return; }\n if (source.width * source.height > 16000000) throw new Error('Canvas too large');\n const pixels = document.createElement('canvas');\n pixels.width = source.width;\n pixels.height = source.height;\n const context = pixels.getContext('2d');\n if (!context) throw new Error('Canvas capture unavailable');\n context.drawImage(source, 0, 0);\n // Do not turn an empty decorative overlay into a large blank PDF section.\n if (source.getAttribute('aria-hidden') === 'true') {\n const data = context.getImageData(0, 0, pixels.width, pixels.height).data;\n let visible = false;\n for (let i = 3; i < data.length; i += 4) {\n if (data[i]) { visible = true; break; }\n }\n if (!visible) { target.remove(); return; }\n }\n const image = document.createElement('img');\n image.src = pixels.toDataURL('image/png');\n image.alt = source.getAttribute('aria-label') || source.textContent || '';\n image.style.cssText = target.style.cssText;\n const bounds = source.getBoundingClientRect();\n image.width = Math.max(1, Math.round(bounds.width || source.width));\n image.height = Math.max(1, Math.round(bounds.height || source.height));\n target.replaceWith(image);\n });\n // Preserve SVG charts as inert PNGs before the export's HTML-only sanitizer.\n // Capture outer SVGs once; their nested SVGs/defs are part of the same image.\n for (let index = 0; index < sources.length; index++) {\n const source = sources[index];\n if (!(source instanceof SVGSVGElement) || source.parentElement?.closest('svg')) continue;\n const picture = await captureSvg(source);\n if (picture) {\n picture.style.cssText = targets[index].style.cssText;\n targets[index].replaceWith(picture);\n } else targets[index].remove();\n }\n copy.querySelectorAll('script, style, link, meta, noscript').forEach(node => node.remove());\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, html: copy.outerHTML }, '*');\n } catch {\n // A tainted/unreadable canvas must fail, not produce an incomplete export.\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n }\n };\n window.addEventListener('error',
|
|
1
|
+
import{v4 as e}from"uuid";import{artifactStyleProperties as t}from"./responseArtifactStyles.js";import{artifactSvgSnapshotScript as n}from"./responseArtifactSvg.js";const r="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co",o=(e,r)=>`<script>\n(() => {\n const token = ${JSON.stringify(e)};\n const send = parent.postMessage.bind(parent);\n send({ type: 'PXE_RESPONSE_SNAPSHOT_STARTED', token }, '*');\n let failed = false;\n let captureStarted = false;\n let timer;\n let deadline;\n let observer;\n let paintReady = false;\n const captureSvg = ${n};\n const finish = async () => {\n // The quiet timer and deadline can become ready together. Capture once,\n // including while asynchronous SVG/image conversion is still in progress.\n if (captureStarted) return;\n captureStarted = true;\n clearTimeout(timer);\n clearTimeout(deadline);\n observer?.disconnect();\n if (failed || document.querySelector('${r?"iframe, object, embed":"canvas, iframe, object, embed"}')) {\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n return;\n }\n try {\n const copy = document.createElement('div');\n copy.innerHTML = document.body.innerHTML;\n const sources = [document.body, ...document.body.querySelectorAll('*')];\n const targets = [copy, ...copy.querySelectorAll('*')];\n const properties = ${JSON.stringify(t)};\n sources.forEach((source, index) => {\n const target = targets[index];\n if (!target || !target.style) return;\n const computed = getComputedStyle(source);\n target.removeAttribute('style');\n properties.forEach(property => target.style.setProperty(property, computed.getPropertyValue(property)));\n // Static snapshots cannot retain clipped gradient text safely without\n // its full CSS. Keep the heading readable instead of copying transparency.\n if (computed.backgroundClip === 'text' || computed.webkitBackgroundClip === 'text') {\n target.style.setProperty('background-image', 'none');\n let ancestor = source.parentElement;\n let color = 'rgb(32, 32, 32)';\n while (ancestor) {\n const candidate = getComputedStyle(ancestor).color;\n if (candidate !== 'transparent' && candidate !== 'rgba(0, 0, 0, 0)') { color = candidate; break; }\n ancestor = ancestor.parentElement;\n }\n target.style.setProperty('color', color);\n }\n // A screen-reader-only caption must not become a new visible table cell\n // when its absolute positioning and clipping are deliberately discarded.\n if (computed.position === 'absolute' && computed.clip !== 'auto' && source.getBoundingClientRect().width <= 1) {\n target.hidden = true;\n target.style.setProperty('display', 'none');\n }\n });\n // Canvas pixels are not included in innerHTML. Freeze them as inert images.\n sources.forEach((source, index) => {\n if (!(source instanceof HTMLCanvasElement)) return;\n const target = targets[index];\n if (!source.width || !source.height) { target.remove(); return; }\n if (source.width * source.height > 16000000) throw new Error('Canvas too large');\n const pixels = document.createElement('canvas');\n pixels.width = source.width;\n pixels.height = source.height;\n const context = pixels.getContext('2d');\n if (!context) throw new Error('Canvas capture unavailable');\n context.drawImage(source, 0, 0);\n // Do not turn an empty decorative overlay into a large blank PDF section.\n if (source.getAttribute('aria-hidden') === 'true') {\n const data = context.getImageData(0, 0, pixels.width, pixels.height).data;\n let visible = false;\n for (let i = 3; i < data.length; i += 4) {\n if (data[i]) { visible = true; break; }\n }\n if (!visible) { target.remove(); return; }\n }\n const image = document.createElement('img');\n image.src = pixels.toDataURL('image/png');\n image.alt = source.getAttribute('aria-label') || source.textContent || '';\n image.style.cssText = target.style.cssText;\n const bounds = source.getBoundingClientRect();\n image.width = Math.max(1, Math.round(bounds.width || source.width));\n image.height = Math.max(1, Math.round(bounds.height || source.height));\n target.replaceWith(image);\n });\n // Preserve SVG charts as inert PNGs before the export's HTML-only sanitizer.\n // Capture outer SVGs once; their nested SVGs/defs are part of the same image.\n for (let index = 0; index < sources.length; index++) {\n const source = sources[index];\n if (!(source instanceof SVGSVGElement) || source.parentElement?.closest('svg')) continue;\n const picture = await captureSvg(source);\n if (picture) {\n picture.style.cssText = targets[index].style.cssText;\n targets[index].replaceWith(picture);\n } else targets[index].remove();\n }\n copy.querySelectorAll('script, style, link, meta, noscript').forEach(node => node.remove());\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, html: copy.outerHTML }, '*');\n } catch {\n // A tainted/unreadable canvas must fail, not produce an incomplete export.\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n }\n };\n window.addEventListener('error', event => {\n // Missing images use the export's image fallback, not a fatal capture error.\n // Script errors (including errors thrown by image handlers) still fail.\n if (event.target instanceof HTMLImageElement) return;\n failed = true;\n }, true);\n window.addEventListener('unhandledrejection', () => { failed = true; });\n observer = new MutationObserver(() => {\n if (!paintReady) return;\n clearTimeout(timer);\n timer = setTimeout(finish, 1000);\n });\n observer.observe(document.documentElement, { subtree: true, childList: true, characterData: true, attributes: true });\n // Start the capture window only after the artifact has had a chance to paint.\n // If frames are suspended (for example in a background tab), the parent's\n // timeout rejects instead of silently exporting an uninitialized chart.\n requestAnimationFrame(() => requestAnimationFrame(() => {\n paintReady = true;\n timer = setTimeout(finish, 1000);\n // Live counters/animations may never settle. Capture their rendered state\n // after a bounded wait, rather than requiring permanent DOM inactivity.\n deadline = setTimeout(finish, 3000);\n }));\n})();\n<\/script>`,i=(t,n=!1,i)=>t.trimStart().startsWith("%PDF")?Promise.reject(new Error("Binary PDF artifacts cannot be rendered as HTML.")):window.location.origin===r?Promise.reject(new Error("Artifact rendering requires a separate origin.")):(null==i?void 0:i.closed)?Promise.reject(new Error("The response print window was closed.")):new Promise(((a,s)=>{const c=e();let d,l,u,p=!1;const m=(i?[window,i]:[window]).map((e=>({target:e,document:e.document}))),g=()=>{void 0!==u&&(null==l||l.clearInterval(u)),u=void 0},h=()=>{p=!0,window.clearTimeout(w),window.clearInterval(b),g(),m.forEach((({target:e,document:t})=>{e.removeEventListener("message",v),e.removeEventListener("focus",y),t.removeEventListener("visibilitychange",y)})),null==d||d.remove()},f=e=>{p||(h(),s(new Error(e)))},v=e=>{var t;!p&&d&&e.source===d.contentWindow&&e.origin===r&&(null===(t=e.data)||void 0===t?void 0:t.token)===c&&("PXE_RESPONSE_SNAPSHOT_STARTED"!==e.data.type?"PXE_RESPONSE_SNAPSHOT"===e.data.type&&(h(),e.data.error||"string"!=typeof e.data.html||e.data.html.length>1e7?s(new Error("Unable to capture the complete artifact.")):a(e.data.html)):g())},y=()=>{var e;if(p)return;if(null==i?void 0:i.closed)return void f("The response print window was closed.");const a=!document.hidden&&document.hasFocus()?window:i&&!i.document.hidden?i:document.hidden&&null!==(e=null!=l?l:i)&&void 0!==e?e:window;if(a===l)return;g(),null==d||d.remove(),l=a;const s=a.document.createElement("iframe");d=s,s.src=`${r}/html`,s.setAttribute("sandbox","allow-scripts allow-same-origin"),s.setAttribute("aria-hidden","true"),s.tabIndex=-1,s.style.cssText="position:fixed;left:0;top:0;width:900px;height:600px;border:0;opacity:0;pointer-events:none;",s.onload=()=>{p||d!==s||(g(),u=a.setInterval((()=>{var e;return null===(e=s.contentWindow)||void 0===e?void 0:e.postMessage({type:"HTML_CODE",content:o(c,n)+t},r)}),250))},s.onerror=()=>{d===s&&f("Unable to load the artifact renderer.")},a.document.body.appendChild(s)},w=window.setTimeout((()=>f("Artifact rendering timed out.")),15e3),b=i?window.setInterval((()=>{i.closed&&f("The response print window was closed.")}),250):void 0;m.forEach((({target:e,document:t})=>{e.addEventListener("message",v),e.addEventListener("focus",y),t.addEventListener("visibilitychange",y)})),y()}));export{i as renderResponseArtifactHtml};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t}from"../_virtual/_tslib.js";import{createResponseDownloadDocument as e}from"./responseDownloadHtml.js";const
|
|
1
|
+
import{__awaiter as t}from"../_virtual/_tslib.js";import{createResponseDownloadDocument as e}from"./responseDownloadHtml.js";import{embedResponseDownloadImages as o}from"./responseDownloadImages.js";const r=(r,n)=>t(void 0,void 0,void 0,(function*(){var t;let i=e(`<div class="pxe-export-artifact">${r}</div>`,!0);const a=document.createElement("template");a.innerHTML=i;const l=yield o(a.content,"docx");for(const e of a.content.querySelectorAll("img")){if(l.has(e))continue;const o=document.createElement("span");o.textContent=`⚠ ${(null===(t=e.getAttribute("alt"))||void 0===t?void 0:t.trim())||"[…]"}`,e.replaceWith(o)}i=`<!doctype html>\n${a.innerHTML}`;const c=document.createElement("iframe");c.setAttribute("sandbox","allow-same-origin"),c.setAttribute("aria-hidden","true"),c.tabIndex=-1,c.style.cssText="position:fixed;left:-10000px;top:0;width:720px;height:600px;border:0;pointer-events:none";try{yield new Promise(((t,e)=>{const o=setTimeout((()=>e(new Error("Word snapshot timed out."))),5e3);c.onload=()=>{clearTimeout(o),t()},c.onerror=()=>{clearTimeout(o),e(new Error("Word snapshot failed."))},c.srcdoc=i,document.body.appendChild(c)}));const t=c.contentDocument,e=c.contentWindow,o=null==t?void 0:t.querySelector("main");if(!t||!e||!o)throw new Error("Word snapshot unavailable.");const r=t.createElement("style");r.textContent="main{display:flow-root;width:720px;max-width:none;padding:0;margin:0}\n.pxe-export-artifact{overflow:visible}\n.pxe-export-artifact:has(tr > :nth-child(6)) > div{min-width:0}\ntable{width:100%;table-layout:fixed} pre{white-space:pre-wrap;overflow-wrap:anywhere}\n*{animation:none!important;transition:none!important}",t.head.appendChild(r),t.querySelectorAll("details").forEach((t=>{t.open=!0}));const a=Math.ceil(Math.max(o.scrollWidth,o.getBoundingClientRect().width)),l=Math.ceil(o.getBoundingClientRect().height);if(a>1440||!l||l>16e3)throw new Error("Artifact is too large for a readable Word picture.");const s=o.cloneNode(!0),d=[o,...o.querySelectorAll("*")],h=[s,...s.querySelectorAll("*")];d.forEach(((t,o)=>{const r=h[o],n=e.getComputedStyle(t);r.removeAttribute("style");for(const t of Array.from(n))r.style.setProperty(t,n.getPropertyValue(t))})),s.setAttribute("xmlns","http://www.w3.org/1999/xhtml");const m=(new XMLSerializer).serializeToString(s);if(m.length>1e7)throw new Error("Word snapshot is too large.");const p=o.getBoundingClientRect().top,w=[],g=t.createTreeWalker(o,NodeFilter.SHOW_TEXT);for(;g.nextNode();){const e=t.createRange();e.selectNodeContents(g.currentNode);for(const t of Array.from(e.getClientRects()))t.height&&w.push({top:t.top-p,bottom:t.bottom-p})}o.querySelectorAll("tr,img").forEach((t=>{const e=t.getBoundingClientRect();e.height<=800&&w.push({top:e.top-p,bottom:e.bottom-p})}));const u=[];let f=0;for(let e=0;e<l;){let o=Math.min(l,e+800);if(o<l)for(let t=0;t<w.length;t++){const t=w.find((t=>t.top+1<o&&t.bottom-1>o));if(!t||t.top<=e)break;o=Math.ceil(t.top)}if(o<=e)throw new Error("Unable to paginate artifact picture.");const r=`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${o-e}" viewBox="0 ${e} ${a} ${o-e}"><foreignObject x="0" y="0" width="${a}" height="${l}">${m}</foreignObject></svg>`,i=new Image;yield new Promise(((t,e)=>{const o=setTimeout((()=>n(!1)),5e3),n=r=>{clearTimeout(o),i.onload=i.onerror=null,r?t():e(new Error("Unable to draw Word artifact picture."))};i.onload=()=>n(!0),i.onerror=()=>n(!1),i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`}));const c=document.createElement("canvas");c.width=2*a,c.height=2*(o-e);const s=c.getContext("2d");if(!s)throw new Error("Word image capture unavailable.");s.fillStyle="white",s.fillRect(0,0,c.width,c.height),s.drawImage(i,0,0,c.width,c.height);const d=c.toDataURL("image/png");if(f+=d.length,f>1e7)throw new Error("Word artifact pictures are too large.");const h=t.createElement("img");h.src=d,h.width=a,h.height=o-e,h.alt=n;const p=t.createElement("p");p.appendChild(h),u.push(p.outerHTML),c.width=c.height=0,i.removeAttribute("src"),e=o}return u.join("")}finally{c.remove()}}));export{r as createResponseArtifactWordImages};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../_virtual/_tslib.js";import{Document as t,Paragraph as r,Packer as n,TextRun as i,Tab as a,HeadingLevel as s,BorderStyle as o,UnderlineType as l,ImageRun as c,ExternalHyperlink as d,TableRow as u,TableCell as
|
|
1
|
+
import{__awaiter as e}from"../_virtual/_tslib.js";import{Document as t,Paragraph as r,Packer as n,TextRun as i,Tab as a,HeadingLevel as s,BorderStyle as o,UnderlineType as l,ImageRun as c,ExternalHyperlink as d,TableRow as u,TableCell as m,WidthType as g,Table as h,LevelFormat as p,AlignmentType as b}from"docx";import{createResponseDownloadHtml as f}from"./responseDownloadHtml.js";import{embedResponseDownloadImages as w}from"./responseDownloadImages.js";const A=720,N=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DD","DETAILS","DIV","DL","DT","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SUMMARY","TABLE","UL"]),O=e=>{if(e&&/^(https?:|mailto:|tel:)/i.test(e.trim()))try{return new URL(e.trim()).href}catch(e){return}},E=(e,t)=>{const r=Object.assign({},t);switch(e.tagName){case"STRONG":case"B":r.bold=!0;break;case"EM":case"I":r.italics=!0;break;case"DEL":case"S":case"STRIKE":r.strike=!0;break;case"U":r.underline={type:l.SINGLE};break;case"CODE":case"KBD":case"SAMP":r.font="Courier New";break;case"SUP":r.superScript=!0;break;case"SUB":r.subScript=!0}return r},I=(I,j)=>e(void 0,void 0,void 0,(function*(){const e=document.createElement("template");e.innerHTML=null!=j?j:f(I);const y=e.content.querySelector("main");if(!y)throw new Error("Unable to prepare the response document.");const T=yield w(y,"docx"),v=new Map;for(const e of T){const t=e.getAttribute("src")||"";if(t.length>1e7)throw new Error("Artifact image too large.");const r=Uint8Array.from(atob(t.slice(22)),(e=>e.charCodeAt(0))),n=new DataView(r.buffer);if(r.length<24||2303741511!==n.getUint32(0)||218765834!==n.getUint32(4)||1229472850!==n.getUint32(12))throw new Error("Invalid artifact image.");const i=n.getUint32(16),a=n.getUint32(20);if(!i||!a||i*a>16e6)throw new Error("Artifact image dimensions are unsupported.");yield new Promise(((e,r)=>{const n=new Image,s=t=>{clearTimeout(o),n.onload=n.onerror=null,n.removeAttribute("src"),t?e():r(new Error("Unable to read artifact image."))},o=setTimeout((()=>s(!1)),5e3);n.onload=()=>s(n.naturalWidth===i&&n.naturalHeight===a),n.onerror=()=>s(!1),n.src=t}));const s=Number(e.getAttribute("width")),o=s>0?Math.min(1,s/i):1;v.set(e,{data:r,width:i*o,height:a*o})}const D=[],S=(e,t,r)=>Array.from(e).flatMap((e=>{var n;if(3===e.nodeType){const r=e.textContent||"";return[new i(Object.assign(Object.assign({},t),{text:(null===(n=e.parentElement)||void 0===n?void 0:n.closest("code"))?r:r.replace(/[\t\n\r ]+/g," ")}))]}if(1!==e.nodeType)return[];const a=e,s=E(a,t);if("BR"===a.tagName)return[new i(Object.assign(Object.assign({},t),{break:1}))];if("IMG"===a.tagName){const e=v.get(a);if(e){const t=Math.min(1,Math.max(1,r/15)/e.width,900/e.height);return[new c(Object.assign(Object.assign({type:"png",data:e.data},a.getAttribute("alt")?{altText:{name:a.getAttribute("alt")||""}}:{}),{transformation:{width:e.width*t,height:e.height*t}}))]}const n=O(a.getAttribute("src")),s=a.getAttribute("alt")||n||"[…]",o=[new i(Object.assign(Object.assign({},t),{text:s}))];return n&&!a.closest("a")?[new d({link:n,children:o})]:o}const o="A"===a.tagName?O(a.getAttribute("href")):void 0,u=S(a.childNodes,o?Object.assign(Object.assign({},s),{color:"174EA6",underline:{type:l.SINGLE}}):s,r);return o?[new d({link:o,children:u})]:u})),H=(e,t,n={})=>{const i=t.marker&&!t.marker.used?t.marker:void 0;return i&&(i.used=!0),new r(Object.assign(Object.assign(Object.assign({children:e,spacing:{after:160},widowControl:!0},t.indent?{indent:Object.assign({left:t.indent},i?{hanging:360}:{})}:{}),null==i?void 0:i.properties),n))},k=(e,t)=>{var r;const n="OL"===e.tagName;let i="",a=!1;const s=e=>{i=`response-list-${D.length}`,a=0===e,D.push({reference:i,levels:[{level:0,format:p.DECIMAL,text:a?"0.":"%1.",start:a?1:e,alignment:b.LEFT}]})},o=e.hasAttribute("reversed"),l=Array.from(e.children).filter((e=>"LI"===e.tagName)),c=Number.parseInt(e.getAttribute("start")||"",10);let d=Number.isFinite(c)?c:o?l.length:1;n&&s(d);const u=[];for(const l of Array.from(e.children)){if("LI"!==l.tagName){u.push(...M([l],t));continue}const e=Number.parseInt(l.getAttribute("value")||"",10);n&&Number.isFinite(e)&&(d=e),n&&(o||a||0===d||Number.isFinite(e))&&s(d),d+=o?-1:1;const c=Object.assign(Object.assign({},t),{indent:Math.min(t.indent+720,5760),marker:{used:!1,properties:n?{numbering:{reference:i,level:0}}:{bullet:{level:0}}}}),m=M(l.childNodes,c);(null===(r=c.marker)||void 0===r?void 0:r.used)||m.unshift(H([],c)),u.push(...m)}return u},L=(e,t)=>{const n=[];let i=0;const a=Array.from(e.querySelectorAll("tr")).filter((t=>t.closest("table")===e)).map(((e,t)=>{let r=0;return{row:e,cells:Array.from(e.children).filter((e=>"TD"===e.tagName||"TH"===e.tagName)).map((e=>{for(;n[r]>t;)r++;const a=t=>Math.min(100,Math.max(1,parseInt(e.getAttribute(t)||"1",10)||1)),s=a("colspan"),o=a("rowspan"),l=r;for(let e=0;e<s;e++)n[r++]=t+o;return i=Math.max(i,r),{cell:e,start:l,columnSpan:s,rowSpan:o}}))}})),s=e=>Math.floor(e*t/i),o=Array.from({length:i},((e,t)=>s(t+1)-s(t))),l=a.flatMap((({row:e,cells:t})=>{var n;return t.length?[new u({tableHeader:"THEAD"===(null===(n=e.parentElement)||void 0===n?void 0:n.tagName)||t.every((({cell:e})=>"TH"===e.tagName)),children:t.map((({cell:e,start:t,columnSpan:n,rowSpan:i})=>{const a=s(t+n)-s(t),o=M(e.childNodes,{indent:0,width:Math.max(1,a-200),run:{bold:"TH"===e.tagName}});return o[o.length-1]instanceof r||o.push(new r("")),new m(Object.assign({children:o,columnSpan:n,rowSpan:i,width:{size:a,type:g.DXA},margins:{top:80,bottom:80,left:100,right:100}},"TH"===e.tagName?{shading:{fill:"F0F0F0"}}:{}))}))})]:[]})),c=Array.from(e.children).filter((e=>"CAPTION"===e.tagName));return l.length?[...M(c,{indent:0,width:t,run:{}}),new h({rows:l,width:{size:t,type:g.DXA},columnWidths:o})]:M(e.childNodes,{indent:0,width:t,run:{}})},M=(e,t)=>{const r=[];let n=[];const l=()=>{n.some((e=>{var t;return(null===(t=e.textContent)||void 0===t?void 0:t.trim())||1===e.nodeType&&/^(BR|IMG)$/.test(e.tagName)||1===e.nodeType&&e.querySelector("br,img")}))&&r.push(H(S(n,t.run,t.width-t.indent),t)),n=[]};for(const c of Array.from(e)){if(1!==c.nodeType||!N.has(c.tagName)){1===c.nodeType&&Array.from(c.children).some((e=>N.has(e.tagName)))?(l(),r.push(...M(c.childNodes,Object.assign(Object.assign({},t),{run:E(c,t.run)})))):n.push(c);continue}l();const e=c,d=e.tagName;if("UL"===d||"OL"===d)t.marker&&!t.marker.used&&r.push(H([],t)),r.push(...k(e,t));else if("TABLE"===d)t.marker&&!t.marker.used&&r.push(H([],t)),r.push(...L(e,t.width));else if("PRE"===d){const n=(e.textContent||"").replace(/\r\n?/g,"\n").split("\n");r.push(H(n.map(((e,r)=>new i(Object.assign(Object.assign(Object.assign({},t.run),{children:e.split("\t").flatMap(((e,t)=>t?[new a,e]:[e])),font:"Courier New",size:20}),r?{break:1}:{})))),t,{shading:{fill:"F4F4F4"},spacing:{before:120,after:160}}))}else if(/^H[1-6]$/.test(d)){const n=[s.HEADING_1,s.HEADING_2,s.HEADING_3,s.HEADING_4,s.HEADING_5,s.HEADING_6];r.push(H(S(e.childNodes,Object.assign(Object.assign({},t.run),{bold:!0,color:"202020"}),t.width-t.indent),t,{heading:n[Number(d[1])-1],keepNext:!0}))}else if("HR"===d)r.push(H([],t,{border:{bottom:{style:o.SINGLE,color:"CCCCCC",size:4}}}));else{const n="BLOCKQUOTE"===d?Object.assign(Object.assign({},t),{indent:t.indent+360}):t,i=M(e.childNodes,n);r.push(...i),i.length||"P"!==d||r.push(H([],n))}}return l(),r},C=M(y.childNodes,{indent:0,width:10800,run:{}}),U=new t({title:"Pickaxe",creator:"Pickaxe",styles:{default:{document:{run:{font:"Arial",size:22,color:"202020"}}}},numbering:{config:D},sections:[{properties:{page:{size:{width:12240,height:15840},margin:{top:A,bottom:A,left:A,right:A}}},children:C.length?C:[new r("")]}]});return n.toBlob(U)}));export{I as createResponseDownloadDocx};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../_virtual/_tslib.js";import{createElement as t}from"react";import{renderToStaticMarkup as r}from"react-dom/server";import o from"react-markdown";import n from"remark-gfm";import i from"rehype-raw";import a from"isomorphic-dompurify";import{filterArtifactStyles as l}from"./responseArtifactStyles.js";const p=e=>{const a=r(t(o,{remarkPlugins:[n],rehypePlugins:[i],components:{input:({type:e,checked:r})=>"checkbox"===(null==e?void 0:e.toLowerCase())?t("span",null,r?"☑":"☐"):null}},e));return
|
|
1
|
+
import{__awaiter as e}from"../_virtual/_tslib.js";import{createElement as t}from"react";import{renderToStaticMarkup as r}from"react-dom/server";import o from"react-markdown";import n from"remark-gfm";import i from"rehype-raw";import a from"isomorphic-dompurify";import{filterArtifactStyles as l}from"./responseArtifactStyles.js";const p=e=>{const a=r(t(o,{remarkPlugins:[n],rehypePlugins:[i],components:{input:({type:e,checked:r})=>"checkbox"===(null==e?void 0:e.toLowerCase())?t("span",null,r?"☑":"☐"):null}},e));return c(a)},c=(e,t=!1)=>{let r=a.sanitize(e,{USE_PROFILES:{html:!0},FORBID_TAGS:["script","style","iframe","form","input","button","select","textarea","object","embed","link","meta","base","audio","video","source","track"],FORBID_ATTR:["srcset","ping","background",...t?[]:["style"]],ALLOW_DATA_ATTR:!1});if(t){const e=document.createElement("template");e.innerHTML=r,l(e.content),e.content.querySelectorAll("label").forEach((e=>{var t;(null===(t=e.textContent)||void 0===t?void 0:t.trim())||e.children.length||e.remove()})),r=e.innerHTML}return`<!doctype html>\n<html>\n<head>\n<meta charset="utf-8">\n<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src https: data:; base-uri 'none'; form-action 'none'">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n<title>Pickaxe</title>\n<style>\nbody { margin: 0; background: white; color: #202020; font: 16px/1.6 system-ui, sans-serif; }\nmain { max-width: 900px; margin: 0 auto; padding: 24px; overflow-wrap: anywhere; }\nh1, h2, h3, h4, h5, h6 { line-height: 1.25; }\na { color: #174ea6; }\npre, code { font-family: ui-monospace, monospace; }\npre { padding: 16px; background: #f4f4f4; overflow-x: auto; white-space: pre; }\nblockquote { margin-left: 0; padding-left: 16px; border-left: 3px solid #ccc; }\ntable { border-collapse: collapse; max-width: 100%; }\nth, td { border: 1px solid #ccc; padding: 8px; text-align: start; }\nimg { max-width: 100%; height: auto; }\nsummary { cursor: pointer; }\n${t?"\n.pxe-export-artifact { max-width: 100%; overflow-x: auto; }\n.pxe-export-artifact:has(tr > :nth-child(6)) > div { min-width: 720px; }\n.pxe-export-artifact table { width: 100%; max-width: 100%; }\n.pxe-export-artifact th, .pxe-export-artifact td { overflow-wrap: anywhere; }\n@media print {\n .pxe-export-artifact { overflow: visible; }\n .pxe-export-artifact:has(tr > :nth-child(6)) > div { min-width: 0; }\n .pxe-export-artifact table { width: 100%; min-width: 0; max-width: 100%; table-layout: fixed; }\n .pxe-export-artifact th, .pxe-export-artifact td { padding: 5px !important; font-size: 10px !important; overflow-wrap: anywhere; }\n .pxe-export-artifact, .pxe-export-artifact * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }\n}\n":""}</style>\n</head>\n<body><main dir="auto">${r}</main></body>\n</html>`},d=e=>s(p(e)),s=(t,r)=>e(void 0,void 0,void 0,(function*(){const e=null!=r?r:window.open("","_blank");if(!e||e.closed)throw new Error("Unable to open the response print window.");try{e.opener=null;const r=e.document;r.open(),r.write(t);const o=r.createElement("style");if(o.media="print",o.textContent="\n@page { margin: 12mm; }\nmain { max-width: none; padding: 0; }\npre { overflow: visible; }\npre, pre code { white-space: pre-wrap; overflow-wrap: anywhere; }\ntable { width: 100%; table-layout: fixed; }\nth, td { white-space: normal; overflow-wrap: anywhere; }\nthead { display: table-header-group; }\ntr, img { break-inside: avoid; }\nh1, h2, h3, h4, h5, h6 { break-after: avoid; }\np, li { orphans: 3; widows: 3; }\n",r.head.appendChild(o),r.querySelectorAll("details").forEach((e=>{e.open=!0})),r.querySelectorAll("img").forEach((e=>{e.loading="eager"})),r.close(),e.focus(),yield m(e,r),e.closed)throw new Error("The response print window was closed.");r.body.offsetHeight,e.focus(),e.print()}catch(t){throw e.close(),t}})),m=(t,r)=>new Promise(((o,n)=>{const i=new Set(Array.from(r.images)),a=e=>{if(c)return;i.delete(e);const t=r.createElement("span");t.textContent=`⚠ ${e.alt.trim()||"[…]"}`,t.style.cssText="display:inline-block;border:1px solid #999;padding:4px;white-space:normal;overflow-wrap:anywhere;",e.removeAttribute("src"),e.removeAttribute("srcset"),e.replaceWith(t)},l=window.setTimeout((()=>{i.forEach(a),d()}),15e3),p=window.setInterval((()=>{t.closed&&d(new Error("The response print window was closed."))}),100);let c=!1;function d(e){c||(c=!0,window.clearTimeout(l),window.clearInterval(p),e?n(e):o())}Promise.all([...Array.from(i,(t=>e(void 0,void 0,void 0,(function*(){try{if(yield t.decode(),!t.complete||!t.naturalWidth||!t.naturalHeight)throw new Error("Unable to load a response print image.");i.delete(t)}catch(e){a(t)}})))),r.fonts.ready]).then((()=>d()),(()=>d(new Error("Unable to load the response print resources."))))}));export{c as createResponseDownloadDocument,p as createResponseDownloadHtml,s as printResponseDownloadDocument,d as printResponseDownloadHtml};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as e}from"../_virtual/_tslib.js";const t=75e5,r=25e6,n=e=>{if(/^data:image\/(png|jpeg|gif|webp);base64,/i.test(e))return e.length<=105e5?e:void 0;try{const t=new URL(e);if(!t.username&&!t.password&&("https:"===t.protocol||"http:"===t.protocol&&t.origin===location.origin))return t.href}catch(e){}},o=(e,t)=>new Promise(((r,n)=>{const o=new Image,i=e=>{o.onload=o.onerror=null,t.removeEventListener("abort",l),e&&o.naturalWidth&&o.naturalHeight?r(o):(o.removeAttribute("src"),n(new Error("Image unavailable.")))},l=()=>i(!1);if(t.aborted)return l();t.addEventListener("abort",l,{once:!0}),o.referrerPolicy="no-referrer",o.onload=()=>i(!0),o.onerror=()=>i(!1),o.src=e})),i=(i,l)=>e(void 0,void 0,void 0,(function*(){const a=Array.from(i.querySelectorAll("img")),c=new Set,s=new AbortController,d=setTimeout((()=>s.abort()),15e3),u=new Map;let m=0,g=0;const h=n=>e(void 0,void 0,void 0,(function*(){let i,a;try{if(s.signal.aborted)return;const c=yield((r,n)=>e(void 0,void 0,void 0,(function*(){var e;const o=yield fetch(r,{signal:n,credentials:"omit",referrerPolicy:"no-referrer"});if(!o.ok||!o.body)throw new Error("Image unavailable.");const i=null===(e=o.headers.get("content-type"))||void 0===e?void 0:e.split(";")[0].trim();if(!i||!/^image\/(png|jpeg|gif|webp|svg\+xml)$/i.test(i)||Number(o.headers.get("content-length"))>t)throw yield o.body.cancel(),new Error("Unsupported image.");const l=o.body.getReader(),a=[];let c=0;try{for(;;){const{done:e,value:r}=yield l.read();if(e)break;if(c+=r.byteLength,c>t)throw new Error("Image too large.");a.push(r)}}finally{yield l.cancel()}return new Blob(a,{type:i})})))(n,s.signal);if(m+=c.size,m>r)return;if(i=URL.createObjectURL(c),a=yield o(i,s.signal),a.naturalWidth*a.naturalHeight>16e6)return;if("docx"===l||"image/svg+xml"===c.type){const e=document.createElement("canvas");try{e.width=a.naturalWidth,e.height=a.naturalHeight;const t=e.getContext("2d");if(!t)return;t.drawImage(a,0,0);const n=e.toDataURL("image/png");if(m+=n.length,n.length>1e7||m>r)return;return n}finally{e.width=e.height=0}}const d=new Uint8Array(yield c.arrayBuffer());let u="";for(let e=0;e<d.length;e+=8192)u+=String.fromCharCode(...d.subarray(e,e+8192));return`data:${c.type};base64,${btoa(u)}`}catch(e){return}finally{null==a||a.removeAttribute("src"),i&&URL.revokeObjectURL(i)}}));try{yield Promise.all(Array.from({length:Math.min(4,a.length)},(()=>e(void 0,void 0,void 0,(function*(){for(var e,t;g<a.length;){const r=a[g++],i=n(r.getAttribute("src")||"");let d;if(i&&(u.has(i)||u.size<50)&&(u.has(i)||u.set(i,h(i)),d=yield u.get(i)),d)c.add(r),r.setAttribute("src",d),r.removeAttribute("srcset");else if("html"===l&&(null==i?void 0:i.startsWith("https:")))try{(yield o(i,s.signal)).removeAttribute("src");continue}catch(t){const n=document.createElement("span");n.textContent=`⚠ ${(null===(e=r.getAttribute("alt"))||void 0===e?void 0:e.trim())||"[…]"}`,r.replaceWith(n)}else if("html"===l){const e=document.createElement("span");e.textContent=`⚠ ${(null===(t=r.getAttribute("alt"))||void 0===t?void 0:t.trim())||"[…]"}`,r.replaceWith(e)}}})))))}finally{clearTimeout(d),s.abort()}return c})),l=t=>e(void 0,void 0,void 0,(function*(){const e=(new DOMParser).parseFromString(t,"text/html");yield i(e,"html");for(const t of e.querySelectorAll("iframe[srcdoc]")){const e=t.getAttribute("srcdoc");if(e){const r=(new DOMParser).parseFromString(e,"text/html");yield i(r,"html"),t.setAttribute("srcdoc",`<!doctype html>\n${r.documentElement.outerHTML}`)}}return`<!doctype html>\n${e.documentElement.outerHTML}`}));export{l as embedResponseDownloadHtmlImages,i as embedResponseDownloadImages};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as r,useEffect as i}from"react";import{createPortal as s}from"react-dom";import{v4 as l}from"uuid";import a from"file-saver";import{createResponseDownloadDocx as d}from"../../../common/responseDownloadDocx.js";import{printResponseDownloadDocument as
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as r,useEffect as i}from"react";import{createPortal as s}from"react-dom";import{v4 as l}from"uuid";import a from"file-saver";import{createResponseDownloadDocx as d}from"../../../common/responseDownloadDocx.js";import{embedResponseDownloadHtmlImages as c}from"../../../common/responseDownloadImages.js";import{printResponseDownloadDocument as u,printResponseDownloadHtml as m,createResponseDownloadHtml as p}from"../../../common/responseDownloadHtml.js";import{findResponseArtifacts as f,prepareResponseArtifactDownload as x}from"../../../common/responseDownloadArtifacts.js";import{renderResponseArtifactHtml as v}from"../../../common/responseArtifactSnapshot.js";import{useArtifactContext as h}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useArtifactData as y}from"../Addons/Artifact/hooks/useArtifactData.js";import{useAuthContext as b}from"../Addons/Auth/hooks/useAuthContext.js";import{usePickaxeContext as w}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useOutsideAlerter as g}from"../../../hooks/core/useOutsideAlerter.js";import k from"../../Icons/download.svg.js";import j from"../../Core/Menu/index.js";import A from"../../Core/Menu/List.js";const D=[{extension:"txt",label:"TXT",mimeType:"text/plain;charset=utf-8"},{extension:"md",label:"Markdown (.md)",mimeType:"text/markdown;charset=utf-8"},{extension:"html",label:"HTML (.html)",mimeType:"text/html;charset=utf-8"},{extension:"pdf",label:"PDF"},{extension:"docx",label:"DOCX"}],T=({color:T,text:C,disabled:O=!1})=>{const{translations:S,colors:P,styles:I,isRtl:M,sender:N,senderType:$,pickaxe:B}=w(),{artifacts:E=[]}=h(),{token:F}=b(),L=y(),[_,H]=n(""),[K,R]=n(!1),[U,X]=n(),[W,q]=n(!1),z=r(!1),G=r(null),J=r(null),Q=r([]),V=r(0),Y=(null==S?void 0:S.download)||"Download",Z=O||W||!C.trim();i((()=>{H(`response-download-${l()}`)}),[]),i((()=>{Z&&R(!1)}),[Z]),i((()=>{K&&G.current&&X(getComputedStyle(G.current).fontFamily)}),[K,I.font]),g({ref:[G,J],callback:()=>R(!1)});const ee=()=>{var e;R(!1),null===(e=G.current)||void 0===e||e.focus({preventScroll:!0})},oe=e=>{var o;if(!Z)if("Escape"===e.key&&K)e.preventDefault(),e.stopPropagation(),ee();else if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e.stopPropagation();const t=Q.current.indexOf(e.currentTarget),n="ArrowDown"===e.key?1:-1,r=D.length,i=-1===t?1===n?0:r-1:(t+n+r)%r;V.current=i,R(!0),null===(o=Q.current[i])||void 0===o||o.focus({preventScroll:!0})}else"Tab"===e.key&&R(!1)},te=e=>{e.relatedTarget===G.current||Q.current.some((o=>o===e.relatedTarget))||R(!1)};return o(j,Object.assign({id:_,className:"h-4 w-4 shrink-0",isOpen:K&&!Z,onChange:R,closeOnSelect:!1,closeOnClickOutside:!1},{children:[t("button",Object.assign({ref:G,id:_||void 0,type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-30",style:{color:T},title:Y,"aria-label":Y,"aria-haspopup":"menu","aria-busy":W,"aria-expanded":K&&!Z,"aria-controls":K&&!Z?`${_}-menu`:void 0,disabled:Z,onClick:e=>{e.stopPropagation(),V.current=0,R((e=>!e))},onKeyDown:oe,onBlur:te},{children:t(k,{className:"h-4 w-4 shrink-0","aria-hidden":"true"})})),_&&!Z&&s(t("div",Object.assign({ref:J,style:{fontFamily:U},dir:M?"rtl":"ltr"},{children:t(A,Object.assign({id:`${_}-menu`,role:"menu",align:"right",width:"auto",className:"p-1 text-sm",style:{backgroundColor:P.primary,color:P.text,maxWidth:"calc(100vw - 32px)"},imperativeModeOnly:!0,afterShow:()=>{var e;return null===(e=Q.current[V.current])||void 0===e?void 0:e.focus({preventScroll:!0})}},{children:D.map(((o,n)=>t("button",Object.assign({ref:e=>{Q.current[n]=e},type:"button",role:"menuitem",tabIndex:-1,className:"rounded-sm px-3 py-2 text-left hover:bg-black/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px]",onClick:t=>{((o,t)=>{e(void 0,void 0,void 0,(function*(){var n;if(o.stopPropagation(),Z||z.current)return;let r;ee();try{const o=f(C);let i;if(o.length){if(z.current=!0,q(!0),"pdf"===t.extension){if(r=null!==(n=window.open("","_blank"))&&void 0!==n?n:void 0,!r)throw new Error("Unable to open the print window.");r.opener=null;const e=r.document.createElement("p");e.textContent=(null==S?void 0:S.loading)||"Loading...",e.setAttribute("role","status"),e.style.cssText="margin:32px;font:16px system-ui,sans-serif",r.document.body.appendChild(e)}i=yield x(C,o,(o=>e(void 0,void 0,void 0,(function*(){const e=E.find((e=>e.id===o.id&&e.version===o.version));return null!=e?e:L.mutateAsync({artifactId:o.id,version:o.version,studioId:null==B?void 0:B.studioid,senderType:$,sender:N||void 0,studioSessionToken:F||void 0})}))),t.extension,(e=>v(e,"pdf"===t.extension||"docx"===t.extension,r)))}if("docx"===t.extension){z.current=!0,q(!0);const e=yield d(C,i);return void a(e,"response.docx")}if("pdf"===t.extension)return z.current=!0,q(!0),void(i?yield u(i,r):yield m(C));let s=null!=i?i:"html"===t.extension?p(C):C;"html"===t.extension&&(z.current=!0,q(!0),s=yield c(s));const l=new Blob([s],{type:t.mimeType});a(l,`response.${t.extension}`)}catch(e){console.error("Response download failed",{format:t.extension,error:e}),null==r||r.close(),window.alert((null==S?void 0:S["something-went-wrong"])||"Something went wrong.")}finally{z.current=!1,q(!1)}}))})(t,o)},onKeyDown:oe,onBlur:te},{children:o.label}),o.extension)))}))})),document.body)]}))};export{T as default};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Exports the same sanitized response used by HTML/PDF as editable Word content.
|
|
3
|
-
* Parsing stays in an inert template.
|
|
4
|
-
*
|
|
3
|
+
* Parsing stays in an inert template. Images are copied with bounded anonymous
|
|
4
|
+
* requests; response scripts and the live chat DOM are never used.
|
|
5
5
|
*/
|
|
6
6
|
export declare const createResponseDownloadDocx: (text: string, preparedHtml?: string) => Promise<Blob>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Only modifies an inert export copy. Never reads or changes live chat images. */
|
|
2
|
+
export declare const embedResponseDownloadImages: (root: ParentNode, format: "docx" | "html") => Promise<Set<Element>>;
|
|
3
|
+
export declare const embedResponseDownloadHtmlImages: (html: string) => Promise<string>;
|