issue-sticker 0.1.0 → 0.2.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/CHANGELOG.md +44 -0
- package/README.md +82 -415
- package/dist/NetworkCollector-BlY2qUKF.js +12278 -0
- package/dist/createLucideIcon-B457EluY.js +27415 -0
- package/dist/{index-DD-r5zA8.js → index-D6SaRFm4.js} +100 -3
- package/dist/issue-sticker-headless-react.js +764 -0
- package/dist/issue-sticker-headless.js +1914 -0
- package/dist/issue-sticker-react.js +12049 -24846
- package/dist/tooltip-BkQcdrki.js +512 -0
- package/headless-react.d.ts +12 -0
- package/headless.d.ts +172 -0
- package/package.json +32 -30
- package/react.d.ts +29 -2
- package/dist/index.d.ts +0 -25
- package/dist/issue-sticker-demo-react.js +0 -51761
- package/dist/issue-sticker-runtime.js +0 -37
- package/dist/issue-sticker.js +0 -2105
- package/dist/issue-sticker.umd.js +0 -1
- package/dist/sdkEventListeners-CtYEkXOR.js +0 -498
- package/runtime.d.ts +0 -11
|
@@ -1 +0,0 @@
|
|
|
1
|
-
if(function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).IssueSticker={})}(this,function(e){"use strict";var t;const n="data-issue-sticker-capture-exclude-node-id",r="data-issue-sticker-modern-sticky-node-id",o="data-issue-sticker-modern-scroll-ancestor-id";function i(){return Math.min(Math.max(window.devicePixelRatio||1,2),3)}function s(e,t){e instanceof Element&&(t(e),e.shadowRoot&&s(e.shadowRoot,t)),Array.from(e.children).forEach(e=>{s(e,t)})}function l(e,t){const n=getComputedStyle(e),r="y"===t?n.overflowY||n.overflow:n.overflowX||n.overflow,o="y"===t?e.scrollHeight-e.clientHeight:e.scrollWidth-e.clientWidth;return/(auto|scroll|overlay)/.test(r)&&o>1}function a(e){if(!e||"auto"===e)return null;const t=Number.parseFloat(e);return Number.isFinite(t)?t:null}function c(e){const t=new Map,n=[],i=[];let c=0,u=0;return s(e,s=>{if(!(s instanceof HTMLElement))return;const d=getComputedStyle(s);if("sticky"!==d.position)return;const f=function(e,t){let n=e.parentElement;for(;n&&n!==t;){if(l(n,"y")||l(n,"x"))return n;n=n.parentElement}return l(t,"y")||l(t,"x")?t:null}(s,e);if(!f)return;const h=s.getBoundingClientRect(),g=f.getBoundingClientRect(),m=h.top-g.top-f.clientTop,p=h.left-g.left-f.clientLeft,w=a(d.top),y=a(d.left),v=null!==w&&f.scrollTop>0&&m<=w+.5;if(!(null!==y&&f.scrollLeft>0&&p<=y+.5)&&!v)return;const b=String(++c),S=s.getAttribute(r),E=function(e){const t=e.getAttribute(o);if(t)return t;const n="scroll-"+ ++u,r=e.getAttribute(o);return e.setAttribute(o,n),i.push({element:e,previousValue:r}),n}(f);t.set(b,{ancestorId:E,top:m,left:p,width:h.width,height:h.height}),s.setAttribute(r,b),n.push({element:s,previousValue:S})}),{applyToClone(e){const n=new Map,i=new Map;s(e,e=>{if(!(e instanceof HTMLElement))return;const t=e.getAttribute(r);t&&n.set(t,e);const s=e.getAttribute(o);s&&i.set(s,e)}),t.forEach(({ancestorId:e,top:t,left:s,width:l,height:a},c)=>{const u=n.get(c),d=i.get(e);if(!u||!d)return;const f=u.cloneNode(!0);f instanceof HTMLElement&&(f.removeAttribute(r),f.removeAttribute(o),f.style.position="absolute",f.style.top=`${t}px`,f.style.left=`${s}px`,f.style.width=`${l}px`,f.style.height=`${a}px`,f.style.margin="0",f.style.transform="none",f.style.pointerEvents="none",f.style.right="auto",f.style.bottom="auto",f.style.zIndex&&"auto"!==f.style.zIndex||(f.style.zIndex="1"),d.style.position&&"static"!==d.style.position||(d.style.position="relative"),u.style.visibility="hidden",u.style.pointerEvents="none",u.style.transform="none",d.appendChild(f))}),s(e,e=>{e instanceof HTMLElement&&(e.removeAttribute(r),e.removeAttribute(o))})},cleanup(){n.forEach(({element:e,previousValue:t})=>{null!==t?e.setAttribute(r,t):e.removeAttribute(r)}),i.forEach(({element:e,previousValue:t})=>{null!==t?e.setAttribute(o,t):e.removeAttribute(o)})}}}async function u(e){const{domToWebp:t}=await Promise.resolve().then(()=>ze),{element:r,excludeSelectors:o=[],width:l,height:a,scale:u=i()}=e;await async function(){const e=document.fonts;e&&await e.ready}();const d=c(r),f=function(e,t){if(0===t.length)return{applyToClone:()=>{},cleanup:()=>{}};const r=[];let o=0;return s(e,e=>{if(!t.some(t=>e.matches(t)))return;const i=String(++o),s=e.getAttribute(n);e.setAttribute(n,i),r.push({element:e,previousValue:s})}),{applyToClone(e){s(e,e=>{if(!e.hasAttribute(n))return;const t=e;t.style&&(t.style.setProperty("opacity","0","important"),t.style.setProperty("visibility","hidden","important"),t.style.setProperty("pointer-events","none","important")),e.removeAttribute(n)})},cleanup(){r.forEach(({element:e,previousValue:t})=>{null!==t?e.setAttribute(n,t):e.removeAttribute(n)})}}}(r,o);try{const e={scale:u,quality:.95,features:{restoreScrollPosition:!0},onCloneNode:e=>{e instanceof Element&&(d.applyToClone(e),f.applyToClone(e))}};return l&&(e.width=l),a&&(e.height=a),await t(r,e)}finally{f.cleanup(),d.cleanup()}}const d="is_sdk_";class f{constructor(e){this.memoryStorage=new Map,this.storageListeners=new Map,this.storage={get:async e=>{try{const t=localStorage.getItem(`${d}${e}`);return t?JSON.parse(t):null}catch{return this.memoryStorage.get(e)??null}},set:async(e,t)=>{var n;try{localStorage.setItem(`${d}${e}`,JSON.stringify(t))}catch{this.memoryStorage.set(e,t)}null==(n=this.storageListeners.get(e))||n.forEach(e=>e(t))},remove:async e=>{var t;try{localStorage.removeItem(`${d}${e}`)}catch{this.memoryStorage.delete(e)}null==(t=this.storageListeners.get(e))||t.forEach(e=>e(null))},onChange:(e,t)=>(this.storageListeners.has(e)||this.storageListeners.set(e,new Set),this.storageListeners.get(e).add(t),()=>{var n;null==(n=this.storageListeners.get(e))||n.delete(t)})},this.messaging={send:async(e,t)=>{this.eventBus.emit(e,t)},onMessage:e=>this.eventBus.on("*",e),broadcast:(e,t)=>{this.eventBus.emit(e,t)}},this.screenshot={capture:async e=>{const t=(null==e?void 0:e.excludeSelectors)??[];if(null==e?void 0:e.element)return u({element:e.element,excludeSelectors:t});const n={width:window.innerWidth,height:window.innerHeight};return u({element:document.documentElement,excludeSelectors:t,width:n.width,height:n.height})}},this.capabilities={screenRecording:"undefined"!=typeof MediaRecorder,detailedNetworkLogs:!0,consoleLogCapture:!0,screenshotCapture:!0},this.eventBus=e}}class h{constructor(){this.listeners=new Map}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>this.off(e,t)}off(e,t){var n;null==(n=this.listeners.get(e))||n.delete(t)}emit(e,...t){var n,r;null==(n=this.listeners.get(e))||n.forEach(e=>e(...t)),null==(r=this.listeners.get("*"))||r.forEach(n=>n(e,...t))}once(e,t){const n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}removeAllListeners(){this.listeners.clear()}}const g={networkLogs:!0,consoleLogs:!0,screenshot:!0,screenRecording:!0,stickers:!0,keyboardShortcuts:!0,jiraIntegration:!1,fab:!0};class m{constructor(e){this.flags={...g,...e}}get(e){return this.flags[e]}set(e,t){this.flags[e]=t}getAll(){return{...this.flags}}}const p=class e{constructor(){this._config=null,this._platform=null,this._eventBus=null,this._featureFlags=null,this._initialized=!1}static getInstance(){return e.instance||(e.instance=new e),e.instance}init(e){this._initialized?this.updateConfig(e):(this._config=e,this._eventBus=new h,this._platform=new f(this._eventBus),this._featureFlags=new m({}),this._initialized=!0)}updateConfig(e){this._initialized?this._config=e:this.init(e)}destroy(){var e;null==(e=this._eventBus)||e.removeAllListeners(),this._config=null,this._platform=null,this._eventBus=null,this._featureFlags=null,this._initialized=!1}isInitialized(){return this._initialized}get config(){if(!this._config)throw new Error("SDK not initialized");return this._config}get platform(){if(!this._platform)throw new Error("SDK not initialized");return this._platform}get eventBus(){if(!this._eventBus)throw new Error("SDK not initialized");return this._eventBus}get featureFlags(){if(!this._featureFlags)throw new Error("SDK not initialized");return this._featureFlags}static resetInstance(){e.instance&&(e.instance.destroy(),e.instance=null)}};p.instance=null;let w=p;const y=new Map;function v(e){y.forEach((t,n)=>{t.forEach(t=>e.on(n,t))}),y.clear()}const b={init(e){const t=w.getInstance();if(t.isInitialized())return t.updateConfig(e),v(t.eventBus),void t.eventBus.emit("ready");t.init(e),v(t.eventBus),t.eventBus.emit("ready")},destroy(){w.resetInstance()},on(e,t){const n=w.getInstance();n.isInitialized()?n.eventBus.on(e,t):function(e,t){y.has(e)||y.set(e,new Set),y.get(e).add(t)}(e,t)},off(e,t){!function(e,t){var n,r;null==(n=y.get(e))||n.delete(t),0===(null==(r=y.get(e))?void 0:r.size)&&y.delete(e)}(e,t);const n=w.getInstance();n.isInitialized()&&n.eventBus.off(e,t)}};const S="p".charCodeAt(0),E="H".charCodeAt(0),A="Y".charCodeAt(0),x="s".charCodeAt(0);let C;function N(e){let t=-1;C||(C=function(){const e=new Int32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=1&n?3988292384^n>>>1:n>>>1;e[t]=n}return e}());for(let n=0;n<e.length;n++)t=C[255&(t^e[n])]^t>>>8;return-1^t}function T(e,t,n=!1){const r=new Uint8Array(13);t*=39.3701,r[0]=S,r[1]=E,r[2]=A,r[3]=x,r[4]=t>>>24,r[5]=t>>>16,r[6]=t>>>8,r[7]=255&t,r[8]=r[4],r[9]=r[5],r[10]=r[6],r[11]=r[7],r[12]=1;const o=N(r),i=new Uint8Array(4);if(i[0]=o>>>24,i[1]=o>>>16,i[2]=o>>>8,i[3]=255&o,n){const t=function(e){for(let t=e.length-1;t>=4;t--)if(9===e[t-4]&&e[t-3]===S&&e[t-2]===E&&e[t-1]===A&&e[t]===x)return t-3;return 0}(e);return e.set(r,t),e.set(i,t+13),e}{const t=new Uint8Array(4);t[0]=0,t[1]=0,t[2]=0,t[3]=9;const n=new Uint8Array(54);return n.set(e,0),n.set(t,33),n.set(r,37),n.set(i,50),n}}const k="undefined"!=typeof window,_=k&&"Worker"in window,I=k&&"atob"in window,D=k&&"btoa"in window,F=k?null==(t=window.navigator)?void 0:t.userAgent:"",$=F.includes("Chrome"),L=F.includes("AppleWebKit")&&!$,R=F.includes("Firefox"),M=e=>"CSSLayerBlockRule"===e.constructor.name,P=e=>1===e.nodeType,B=e=>"object"==typeof e.className,z=e=>"image"===e.tagName,U=e=>P(e)&&void 0!==e.style&&!B(e),W=e=>8===e.nodeType,j=e=>"IMG"===e.tagName,O=e=>"VIDEO"===e.tagName,V=e=>"SLOT"===e.tagName;function q(e){var t;const n=null==(t=null==e?void 0:e.createElement)?void 0:t.call(e,"canvas");return n&&(n.height=n.width=1),Boolean(n)&&"toDataURL"in n&&Boolean(n.toDataURL("image/webp").includes("image/webp"))}const H=e=>e.startsWith("data:");function X(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(k&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;if(!k)return e;const n=K().implementation.createHTMLDocument(),r=n.createElement("base"),o=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(o),t&&(r.href=t),o.href=e,o.href}function K(e){return(e&&P(e)?null==e?void 0:e.ownerDocument:e)??window.document}const Y="http://www.w3.org/2000/svg";const J=e=>function(e,t){return new Promise((n,r)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=()=>r(o.error),o.onabort=()=>r(new Error(`Failed read blob to ${t}`)),o.readAsDataURL(e)})}(e,"dataUrl");function G(e,t){const n=K(t).createElement("img");return n.decoding="sync",n.loading="eager",n.src=e,n}function Q(e,t){return new Promise(n=>{const{timeout:r,ownerDocument:o,onError:i,onWarn:s}=t??{},l="string"==typeof e?G(e,K(o)):e;let a=null,c=null;function u(){n(l),a&&clearTimeout(a),null==c||c()}if(r&&(a=setTimeout(u,r)),O(l)){const e=l.currentSrc||l.src;if(!e)return l.poster?Q(l.poster,t).then(n):u();if(l.readyState>=2)return u();const r=u,o=t=>{null==s||s("Failed video load",e,t),null==i||i(t),u()};c=()=>{l.removeEventListener("loadeddata",r),l.removeEventListener("error",o)},l.addEventListener("loadeddata",r,{once:!0}),l.addEventListener("error",o,{once:!0})}else{const e=z(l)?l.href.baseVal:l.currentSrc||l.src;if(!e)return u();const t=async()=>{if(j(l)&&"decode"in l)try{await l.decode()}catch(t){null==s||s("Failed to decode image, trying to render anyway",l.dataset.originalSrc||e,t)}u()},n=t=>{null==s||s("Failed image load",l.dataset.originalSrc||e,t),u()};if(j(l)&&l.complete)return t();c=()=>{l.removeEventListener("load",t),l.removeEventListener("error",n)},l.addEventListener("load",t,{once:!0}),l.addEventListener("error",n,{once:!0})}})}async function Z(e,t){U(e)&&(j(e)||O(e)?await Q(e,t):await Promise.all(["img","video"].flatMap(n=>Array.from(e.querySelectorAll(n)).map(e=>Q(e,t)))))}const ee=function(){let e=0;return()=>(e+=1,`u${`0000${(Math.random()*36**4|0).toString(36)}`.slice(-4)}${e}`)}();function te(e){return null==e?void 0:e.split(",").map(e=>e.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}function ne(e){return{time:t=>e&&void 0,timeEnd:t=>e&&void 0,warn:(...t)=>e&&void 0}}async function re(e,t){return(n=e)&&"__CONTEXT__"in n?e:oe(e,{...t,autoDestruct:!0});var n}async function oe(e,t){var n,r;const{scale:o=1,workerUrl:i,workerNumber:s=1}=t||{},l=Boolean(null==t?void 0:t.debug),a=(null==t?void 0:t.features)??!0,c=e.ownerDocument??(k?window.document:void 0),u=(null==(n=e.ownerDocument)?void 0:n.defaultView)??(k?window:void 0),d=new Map,f={width:0,height:0,quality:1,type:"image/png",scale:o,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:l,fetch:{requestInit:(h=null==(r=null==t?void 0:t.fetch)?void 0:r.bypassingCache,{cache:h?"no-cache":"force-cache"}),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:!1,...null==t?void 0:t.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:s,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1,...t,__CONTEXT__:!0,log:ne(l),node:e,ownerDocument:c,ownerWindow:u,dpi:1===o?null:96*o,svgStyleElement:ie(c),svgDefsElement:null==c?void 0:c.createElementNS(Y,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:_&&i&&s?s:0})].map(()=>{try{const e=new Worker(i);return e.onmessage=async e=>{var t,n,r,o;const{url:i,result:s}=e.data;s?null==(n=null==(t=d.get(i))?void 0:t.resolve)||n.call(t,s):null==(o=null==(r=d.get(i))?void 0:r.reject)||o.call(r,new Error(`Error receiving message from worker: ${i}`))},e.onmessageerror=e=>{var t,n;const{url:r}=e.data;null==(n=null==(t=d.get(r))?void 0:t.reject)||n.call(t,new Error(`Error receiving message from worker: ${r}`))},e}catch(e){return f.log.warn("Failed to new Worker",e),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[q(c)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:d,drawImageCount:0,tasks:[],features:a,isEnable:e=>"restoreScrollPosition"===e?"boolean"!=typeof a&&(a[e]??!1):"boolean"==typeof a?a:a[e]??!0,shadowRoots:[]};var h;f.log.time("wait until load"),await Z(e,{timeout:f.timeout,onWarn:f.log.warn}),f.log.timeEnd("wait until load");const{width:g,height:m}=function(e,t){let{width:n,height:r}=t;if(P(e)&&(!n||!r)){const t=e.getBoundingClientRect();n=n||t.width||Number(e.getAttribute("width"))||0,r=r||t.height||Number(e.getAttribute("height"))||0}return{width:n,height:r}}(e,f);return f.width=g,f.height=m,f}function ie(e){if(!e)return;const t=e.createElement("style"),n=t.ownerDocument.createTextNode("\n.______background-clip--text {\n background-clip: text;\n -webkit-background-clip: text;\n}\n");return t.appendChild(n),t}async function se(e,t){const{log:n,timeout:r,drawImageCount:o,drawImageInterval:i}=t;n.time("image to canvas");const s=await Q(e,{timeout:r,onWarn:t.log.warn}),{canvas:l,context2d:a}=function(e,t){const{width:n,height:r,scale:o,backgroundColor:i,maximumCanvasSize:s}=t,l=e.createElement("canvas");l.width=Math.floor(n*o),l.height=Math.floor(r*o),l.style.width=`${n}px`,l.style.height=`${r}px`,s&&(l.width>s||l.height>s)&&(l.width>s&&l.height>s?l.width>l.height?(l.height*=s/l.width,l.width=s):(l.width*=s/l.height,l.height=s):l.width>s?(l.height*=s/l.width,l.width=s):(l.width*=s/l.height,l.height=s));const a=l.getContext("2d");a&&i&&(a.fillStyle=i,a.fillRect(0,0,l.width,l.height));return{canvas:l,context2d:a}}(e.ownerDocument,t),c=()=>{try{null==a||a.drawImage(s,0,0,l.width,l.height)}catch(e){t.log.warn("Failed to drawImage",e)}};if(c(),t.isEnable("fixSvgXmlDecode"))for(let u=0;u<o;u++)await new Promise(e=>{setTimeout(()=>{null==a||a.clearRect(0,0,l.width,l.height),c(),e()},u+i)});return t.drawImageCount=0,n.timeEnd("image to canvas"),l}function le(e,t){if(e.ownerDocument)try{const t=e.toDataURL();if("data:,"!==t)return G(t,e.ownerDocument)}catch(i){t.log.warn("Failed to clone canvas",i)}const n=e.cloneNode(!1),r=e.getContext("2d"),o=n.getContext("2d");try{return r&&o&&o.putImageData(r.getImageData(0,0,e.width,e.height),0,0),n}catch(i){t.log.warn("Failed to clone canvas",i)}return n}function ae(e,t){return(e=>"CANVAS"===e.tagName)(e)?le(e,t):(e=>"IFRAME"===e.tagName)(e)?function(e,t){var n;try{if(null==(n=null==e?void 0:e.contentDocument)?void 0:n.documentElement)return ve(e.contentDocument.documentElement,t)}catch(r){t.log.warn("Failed to clone iframe",r)}return e.cloneNode(!1)}(e,t):j(e)?function(e){const t=e.cloneNode(!1);return e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager"),t}(e):O(e)?async function(e,t){if(e.ownerDocument&&!e.currentSrc&&e.poster)return G(e.poster,e.ownerDocument);const n=e.cloneNode(!1);n.crossOrigin="anonymous",e.currentSrc&&e.currentSrc!==e.src&&(n.src=e.currentSrc);const r=n.ownerDocument;if(r){let i=!0;if(await Q(n,{onError:()=>i=!1,onWarn:t.log.warn}),!i)return e.poster?G(e.poster,e.ownerDocument):n;n.currentTime=e.currentTime,await new Promise(e=>{n.addEventListener("seeked",e,{once:!0})});const s=r.createElement("canvas");s.width=e.offsetWidth,s.height=e.offsetHeight;try{const e=s.getContext("2d");e&&e.drawImage(n,0,0,s.width,s.height)}catch(o){return t.log.warn("Failed to clone video",o),e.poster?G(e.poster,e.ownerDocument):n}return le(s,t)}return n}(e,t):e.cloneNode(!1)}const ce=["width","height","-webkit-text-fill-color"],ue=["stroke","fill"];function de(e,t,n){const{defaultComputedStyles:r}=n,o=e.nodeName.toLowerCase(),i=B(e)&&"svg"!==o,s=i?ue.map(t=>[t,e.getAttribute(t)]).filter(([,e])=>null!==e):[],l=[i&&"svg",o,s.map((e,t)=>`${e}=${t}`).join(","),t].filter(Boolean).join(":");if(r.has(l))return r.get(l);const a=function(e){let t=e.sandbox;if(!t){const{ownerDocument:r}=e;try{r&&(t=r.createElement("iframe"),t.id=`__SANDBOX__${ee()}`,t.width="0",t.height="0",t.style.visibility="hidden",t.style.position="fixed",r.body.appendChild(t),t.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',e.sandbox=t)}catch(n){e.log.warn("Failed to getSandBox",n)}}return t}(n),c=null==a?void 0:a.contentWindow;if(!c)return new Map;const u=null==c?void 0:c.document;let d,f;i?(d=u.createElementNS(Y,"svg"),f=d.ownerDocument.createElementNS(d.namespaceURI,o),s.forEach(([e,t])=>{f.setAttributeNS(null,e,t)}),d.appendChild(f)):d=f=u.createElement(o),f.textContent=" ",u.body.appendChild(d);const h=c.getComputedStyle(f,t),g=new Map;for(let m=h.length,p=0;p<m;p++){const e=h.item(p);ce.includes(e)||g.set(e,h.getPropertyValue(e))}return u.body.removeChild(d),r.set(l,g),g}function fe(e,t,n){var r;const o=new Map,i=[],s=new Map;if(n)for(const a of n)l(a);else for(let a=e.length,c=0;c<a;c++){l(e.item(c))}for(let a=i.length,c=0;c<a;c++)null==(r=s.get(i[c]))||r.forEach((e,t)=>o.set(t,e));function l(n){const r=e.getPropertyValue(n),l=e.getPropertyPriority(n),a=n.lastIndexOf("-"),c=a>-1?n.substring(0,a):void 0;if(c){let e=s.get(c);e||(e=new Map,s.set(c,e)),e.set(n,[r,l])}(t.get(n)!==r||l)&&(c?i.push(c):o.set(n,[r,l]))}return o}const he=["::before","::after"],ge=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"];const me=new Set(["symbol"]);async function pe(e,t,n,r,o){if(P(n)&&((e=>"STYLE"===e.tagName)(n)||(e=>"SCRIPT"===e.tagName)(n)))return;if(r.filter&&!r.filter(n))return;me.has(t.nodeName)||me.has(n.nodeName)?r.currentParentNodeStyle=void 0:r.currentParentNodeStyle=r.currentNodeStyle;const i=await ve(n,r,!1,o);r.isEnable("restoreScrollPosition")&&function(e,t){if(!U(e)||!U(t))return;const{scrollTop:n,scrollLeft:r}=e;if(!n&&!r)return;const{transform:o}=t.style,i=new DOMMatrix(o),{a:s,b:l,c:a,d:c}=i;i.a=1,i.b=0,i.c=0,i.d=1,i.translateSelf(-r,-n),i.a=s,i.b=l,i.c=a,i.d=c,t.style.transform=i.toString()}(e,i),t.appendChild(i)}async function we(e,t,n,r){var o;let i=e.firstChild;P(e)&&e.shadowRoot&&(i=null==(o=e.shadowRoot)?void 0:o.firstChild,n.shadowRoots.push(e.shadowRoot));for(let s=i;s;s=s.nextSibling)if(!W(s))if(P(s)&&V(s)&&"function"==typeof s.assignedNodes){const o=s.assignedNodes();for(let i=0;i<o.length;i++)await pe(e,t,o[i],n,r)}else await pe(e,t,s,n,r)}const ye=/^[\w-:]+$/;async function ve(e,t,n=!1,r){var o,i,s,l;const{ownerDocument:a,ownerWindow:c,fontFamilies:u,onCloneEachNode:d}=t;if(a&&(e=>3===e.nodeType)(e))return r&&/\S/.test(e.data)&&r(e.data),a.createTextNode(e.data);if(a&&c&&P(e)&&(U(e)||B(e))){const r=await ae(e,t);if(t.isEnable("removeAbnormalAttributes")){const e=r.getAttributeNames();for(let t=e.length,n=0;n<t;n++){const t=e[n];ye.test(t)||r.removeAttribute(t)}}const a=t.currentNodeStyle=function(e,t,n,r){var o,i,s,l;const{ownerWindow:a,includeStyleProperties:c,currentParentNodeStyle:u}=r,d=t.style,f=a.getComputedStyle(e),h=de(e,null,r);null==u||u.forEach((e,t)=>{h.delete(t)});const g=fe(f,h,c);g.delete("transition-property"),g.delete("all"),g.delete("d"),g.delete("content"),n&&(g.delete("position"),g.delete("margin-top"),g.delete("margin-right"),g.delete("margin-bottom"),g.delete("margin-left"),g.delete("margin-block-start"),g.delete("margin-block-end"),g.delete("margin-inline-start"),g.delete("margin-inline-end"),g.set("box-sizing",["border-box",""])),"text"===(null==(o=g.get("background-clip"))?void 0:o[0])&&t.classList.add("______background-clip--text"),$&&(g.has("font-kerning")||g.set("font-kerning",["normal",""]),"hidden"!==(null==(i=g.get("overflow-x"))?void 0:i[0])&&"hidden"!==(null==(s=g.get("overflow-y"))?void 0:s[0])||"ellipsis"!==(null==(l=g.get("text-overflow"))?void 0:l[0])||e.scrollWidth!==e.clientWidth||g.set("text-overflow",["clip",""]));for(let m=d.length,p=0;p<m;p++)d.removeProperty(d.item(p));return g.forEach(([e,t],n)=>{d.setProperty(n,e,t)}),g}(e,r,n,t);n&&function(e,t){const{backgroundColor:n,width:r,height:o,style:i}=t,s=e.style;if(n&&s.setProperty("background-color",n,"important"),r&&s.setProperty("width",`${r}px`,"important"),o&&s.setProperty("height",`${o}px`,"important"),i)for(const l in i)s[l]=i[l]}(r,t);let c=!1;if(t.isEnable("copyScrollbar")){const t=[null==(o=a.get("overflow-x"))?void 0:o[0],null==(i=a.get("overflow-y"))?void 0:i[0]];c=t.includes("scroll")||(t.includes("auto")||t.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)}const f=null==(s=a.get("text-transform"))?void 0:s[0],h=te(null==(l=a.get("font-family"))?void 0:l[0]),g=h?e=>{"uppercase"===f?e=e.toUpperCase():"lowercase"===f?e=e.toLowerCase():"capitalize"===f&&(e=e[0].toUpperCase()+e.substring(1)),h.forEach(t=>{let n=u.get(t);n||u.set(t,n=new Set),e.split("").forEach(e=>n.add(e))})}:void 0;return function(e,t,n,r,o){const{ownerWindow:i,svgStyleElement:s,svgStyles:l,currentNodeStyle:a}=r;function c(n){var s;const c=i.getComputedStyle(e,n);let u=c.getPropertyValue("content");if(!u||"none"===u)return;null==o||o(u),u=u.replace(/(')|(")|(counter\(.+\))/g,"");const d=[ee()],f=de(e,n,r);null==a||a.forEach((e,t)=>{f.delete(t)});const h=fe(c,f,r.includeStyleProperties);h.delete("content"),h.delete("-webkit-locale"),"text"===(null==(s=h.get("background-clip"))?void 0:s[0])&&t.classList.add("______background-clip--text");const g=[`content: '${u}';`];if(h.forEach(([e,t],n)=>{g.push(`${n}: ${e}${t?" !important":""};`)}),1===g.length)return;try{t.className=[t.className,...d].join(" ")}catch(w){return void r.log.warn("Failed to copyPseudoClass",w)}const m=g.join("\n ");let p=l.get(m);p||(p=[],l.set(m,p)),p.push(`.${d[0]}${n}`)}s&&i&&(he.forEach(c),n&&ge.forEach(c))}(e,r,c,t,g),function(e,t){((e=>"TEXTAREA"===e.tagName)(e)||(e=>"INPUT"===e.tagName)(e)||(e=>"SELECT"===e.tagName)(e))&&t.setAttribute("value",e.value)}(e,r),O(e)||await we(e,r,t,g),await(null==d?void 0:d(r)),r}const f=e.cloneNode(!1);return await we(e,f,t),await(null==d?void 0:d(f)),f}function be(e){if(e.ownerDocument=void 0,e.ownerWindow=void 0,e.svgStyleElement=void 0,e.svgDefsElement=void 0,e.svgStyles.clear(),e.defaultComputedStyles.clear(),e.sandbox){try{e.sandbox.remove()}catch(t){e.log.warn("Failed to destroyContext",t)}e.sandbox=void 0}e.workers=[],e.fontFamilies.clear(),e.fontCssTexts.clear(),e.requests.clear(),e.tasks=[],e.shadowRoots=[]}function Se(e,t){const{url:n,requestType:r="text",responseType:o="text",imageDom:i}=t;let s=n;const{timeout:l,acceptOfImage:a,requests:c,fetchFn:u,fetch:{requestInit:d,bypassingCache:f,placeholderImage:h},font:g,workers:m,fontFamilies:p}=e;"image"===r&&(L||R)&&e.drawImageCount++;let w=c.get(n);if(!w){f&&f instanceof RegExp&&f.test(s)&&(s+=(/\?/.test(s)?"&":"?")+(new Date).getTime());const t=r.startsWith("font")&&g&&g.minify,y=new Set;if(t){r.split(";")[1].split(",").forEach(e=>{p.has(e)&&p.get(e).forEach(e=>y.add(e))})}const v=t&&y.size,b={url:s,timeout:l,responseType:v?"arrayBuffer":o,headers:"image"===r?{accept:a}:void 0,...d};w={type:r,resolve:void 0,reject:void 0,response:null},w.response=(async()=>{if(u&&"image"===r){const e=await u(n);if(e)return e}return!L&&n.startsWith("http")&&m.length?new Promise((e,t)=>{m[c.size&m.length-1].postMessage({rawUrl:n,...b}),w.resolve=e,w.reject=t}):function(e){const{url:t,timeout:n,responseType:r,...o}=e,i=new AbortController,s=n?setTimeout(()=>i.abort(),n):void 0;return fetch(t,{signal:i.signal,...o}).then(e=>{if(!e.ok)throw new Error("Failed fetch, not 2xx response",{cause:e});switch(r){case"arrayBuffer":return e.arrayBuffer();case"dataUrl":return e.blob().then(J);default:return e.text()}}).finally(()=>clearTimeout(s))}(b)})().catch(t=>{if(c.delete(n),"image"===r&&h)return e.log.warn("Failed to fetch image base64, trying to use placeholder image",s),"string"==typeof h?h:h(i);throw t}),c.set(n,w)}return w.response}async function Ee(e,t,n,r){if(!Ae(e))return e;for(const[i,s]of function(e,t){const n=[];return e.replace(xe,(e,r,o)=>(n.push([o,X(o,t)]),e)),n.filter(([e])=>!H(e))}(e,t))try{const t=await Se(n,{url:s,requestType:r?"image":"text",responseType:"dataUrl"});e=e.replace(Ce(i),`$1${t}$3`)}catch(o){n.log.warn("Failed to fetch css data url",i,o)}return e}function Ae(e){return/url\((['"]?)([^'"]+?)\1\)/.test(e)}const xe=/url\((['"]?)([^'"]+?)\1\)/g;function Ce(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}const Ne=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function Te(e,t){const{tasks:n}=t;P(e)&&((j(e)||z(e))&&n.push(...function(e,t){if(j(e)){const n=e.currentSrc||e.src;if(!H(n))return[Se(t,{url:n,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(t=>{t&&(e.srcset="",e.dataset.originalSrc=n,e.src=t||"")})];(L||R)&&t.drawImageCount++}else if(B(e)&&!H(e.href.baseVal)){const n=e.href.baseVal;return[Se(t,{url:n,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(t=>{t&&(e.dataset.originalSrc=n,e.href.baseVal=t||"")})]}return[]}(e,t)),"use"===e.tagName&&n.push(...function(e,t){const{ownerDocument:n,svgDefsElement:r}=t,o=e.getAttribute("href")??e.getAttribute("xlink:href");if(!o)return[];const[i,s]=o.split("#");if(s){const o=`#${s}`,l=t.shadowRoots.reduce((e,t)=>e??t.querySelector(`svg ${o}`),null==n?void 0:n.querySelector(`svg ${o}`));if(i&&e.setAttribute("href",o),null==r?void 0:r.querySelector(o))return[];if(l)return null==r||r.appendChild(l.cloneNode(!0)),[];if(i)return[Se(t,{url:i,responseType:"text"}).then(e=>{null==r||r.insertAdjacentHTML("beforeend",e)})]}return[]}(e,t))),U(e)&&n.push(...function(e,t){return Ne.map(n=>{const r=e.getPropertyValue(n);return r&&"none"!==r?((L||R)&&t.drawImageCount++,Ee(r,null,t,!0).then(t=>{t&&r!==t&&e.setProperty(n,t,e.getPropertyPriority(n))})):null}).filter(Boolean)}(e.style,t)),e.childNodes.forEach(e=>{Te(e,t)})}async function ke(e,t){const{ownerDocument:n,svgStyleElement:r,fontFamilies:o,fontCssTexts:i,tasks:s,font:l}=t;if(n&&r&&o.size)if(l&&l.cssText){const e=$e(l.cssText,t);r.appendChild(n.createTextNode(`${e}\n`))}else{const e=Array.from(n.styleSheets).filter(e=>{try{return"cssRules"in e&&Boolean(e.cssRules.length)}catch(n){return t.log.warn(`Error while reading CSS rules from ${e.href}`,n),!1}}),l=n.implementation.createHTMLDocument(""),a=l.createElement("style");l.head.appendChild(a);const c=a.sheet;await Promise.all(e.flatMap(e=>Array.from(e.cssRules).map(async e=>{if("CSSImportRule"===e.constructor.name){const r=e.href;let o="";try{o=await Se(t,{url:r,requestType:"text",responseType:"text"})}catch(n){t.log.warn(`Error fetch remote css import from ${r}`,n)}const i=o.replace(xe,(e,t,n)=>e.replace(n,X(n,r)));for(const e of function(e){if(null==e)return[];const t=[];let n=e.replace(_e,"");for(;;){const e=Ie.exec(n);if(!e)break;t.push(e[0])}n=n.replace(Ie,"");const r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let e=r.exec(n);if(e)o.lastIndex=r.lastIndex;else{if(e=o.exec(n),!e)break;r.lastIndex=o.lastIndex}t.push(e[0])}return t}(i))try{c.insertRule(e,c.cssRules.length)}catch(n){t.log.warn("Error inserting rule from remote css import",{rule:e,error:n})}}}))),c.cssRules.length&&e.push(c);const u=[];e.forEach(e=>{Le(e.cssRules,u)}),u.filter(e=>{var t;return"CSSFontFaceRule"===e.constructor.name&&Ae(e.style.getPropertyValue("src"))&&(null==(t=te(e.style.getPropertyValue("font-family")))?void 0:t.some(e=>o.has(e)))}).forEach(e=>{const o=e,l=i.get(o.cssText);l?r.appendChild(n.createTextNode(`${l}\n`)):s.push(Ee(o.cssText,o.parentStyleSheet?o.parentStyleSheet.href:null,t).then(e=>{e=$e(e,t),i.set(o.cssText,e),r.appendChild(n.createTextNode(`${e}\n`))}))})}}const _e=/(\/\*[\s\S]*?\*\/)/g,Ie=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;const De=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Fe=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function $e(e,t){const{font:n}=t,r=n?null==n?void 0:n.preferredFormat:void 0;return r?e.replace(Fe,e=>{for(;;){const[t,,n]=De.exec(e)||[];if(!n)return"";if(n===r)return`src: ${t};`}}):e}function Le(e,t=[]){for(const n of Array.from(e))M(n)?t.push(...Le(n.cssRules)):"cssRules"in n?Le(n.cssRules,t):t.push(n);return t}const Re=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;async function Me(e,t){const n=await re(e,t);if(P(n.node)&&B(n.node)&&!function(e){return Re.test(e.innerHTML)}(n.node))return n.node;const{ownerDocument:r,log:o,tasks:i,svgStyleElement:s,svgDefsElement:l,svgStyles:a,font:c,progress:u,autoDestruct:d,onCloneNode:f,onEmbedNode:h,onCreateForeignObjectSvg:g}=n;o.time("clone node");const m=await ve(n.node,n,!0);if(s&&r){let e="";a.forEach((t,n)=>{e+=`${t.join(",\n")} {\n ${n}\n}\n`}),s.appendChild(r.createTextNode(e))}o.timeEnd("clone node"),await(null==f?void 0:f(m)),!1!==c&&P(m)&&(o.time("embed web font"),await ke(0,n),o.timeEnd("embed web font")),o.time("embed node"),Te(m,n);const p=i.length;let w=0;null==u||u(w,p),await Promise.all([...Array.from({length:4})].map(async()=>{for(;;){const t=i.pop();if(!t)break;try{await t}catch(e){n.log.warn("Failed to run task",e)}null==u||u(++w,p)}})),o.timeEnd("embed node"),await(null==h?void 0:h(m));const y=function(e,t){const{width:n,height:r}=t,o=function(e,t,n){const r=K(n).createElementNS(Y,"svg");return r.setAttributeNS(null,"width",e.toString()),r.setAttributeNS(null,"height",t.toString()),r.setAttributeNS(null,"viewBox",`0 0 ${e} ${t}`),r}(n,r,e.ownerDocument),i=o.ownerDocument.createElementNS(o.namespaceURI,"foreignObject");return i.setAttributeNS(null,"x","0%"),i.setAttributeNS(null,"y","0%"),i.setAttributeNS(null,"width","100%"),i.setAttributeNS(null,"height","100%"),i.append(e),o.appendChild(i),o}(m,n);return l&&y.insertBefore(l,y.children[0]),s&&y.insertBefore(s,y.children[0]),d&&be(n),await(null==g?void 0:g(y)),y}async function Pe(e,t){var n;const r=await re(e,t),o=await Me(r),i=function(e,t){let n=(new XMLSerializer).serializeToString(e);return t&&(n=n.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}(o,r.isEnable("removeControlCharacter"));r.autoDestruct||(r.svgStyleElement=ie(r.ownerDocument),r.svgDefsElement=null==(n=r.ownerDocument)?void 0:n.createElementNS(Y,"defs"),r.svgStyles.clear());const s=G(i,o.ownerDocument);return await se(s,r)}async function Be(e,t){const n=await re(e,t),{log:r,quality:o,type:i,dpi:s}=n,l=await Pe(n);r.time("canvas to data url");let a=l.toDataURL(i,o);if(["image/png","image/jpeg"].includes(i)&&s&&I&&D){const[e,t]=a.split(",");let n=0,r=!1;if("image/png"===i){const e=function(e){let t=e.indexOf("AAlwSFlz");return-1===t&&(t=e.indexOf("AAAJcEhZ")),-1===t&&(t=e.indexOf("AAAACXBI")),t}(t);e>=0?(n=4*Math.ceil((e+28)/3),r=!0):n=44}else"image/jpeg"===i&&(n=24);const o=t.substring(0,n),l=t.substring(n),c=window.atob(o),u=new Uint8Array(c.length);for(let i=0;i<u.length;i++)u[i]=c.charCodeAt(i);const d="image/png"===i?T(u,s,r):function(e,t){return e[13]=1,e[14]=t>>8,e[15]=255&t,e[16]=t>>8,e[17]=255&t,e}(u,s);a=[e,",",window.btoa(String.fromCharCode(...d)),l].join("")}return r.timeEnd("canvas to data url"),a}const ze=Object.freeze(Object.defineProperty({__proto__:null,createContext:oe,destroyContext:be,domToCanvas:Pe,domToDataUrl:Be,domToForeignObjectSvg:Me,domToWebp:async function(e,t){return Be(await re(e,{...t,type:"image/webp"}))},loadMedia:Q,waitUntilLoad:Z},Symbol.toStringTag,{value:"Module"}));e.IssueSticker=b,e.default=b,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}),typeof window<"u"&&window.IssueSticker){var _ns=window.IssueSticker;window.IssueSticker=_ns.IssueSticker||_ns.default||_ns}
|
|
@@ -1,498 +0,0 @@
|
|
|
1
|
-
const SCREENSHOT_DATA_URL_QUALITY = 0.95;
|
|
2
|
-
const CAPTURE_EXCLUDE_NODE_ID_ATTRIBUTE = "data-issue-sticker-capture-exclude-node-id";
|
|
3
|
-
const MODERN_STICKY_NODE_ID_ATTRIBUTE = "data-issue-sticker-modern-sticky-node-id";
|
|
4
|
-
const MODERN_SCROLL_ANCESTOR_ID_ATTRIBUTE = "data-issue-sticker-modern-scroll-ancestor-id";
|
|
5
|
-
function getCaptureScale() {
|
|
6
|
-
return Math.min(Math.max(window.devicePixelRatio || 1, 2), 3);
|
|
7
|
-
}
|
|
8
|
-
async function waitForDocumentFonts() {
|
|
9
|
-
const fontFaceSet = document.fonts;
|
|
10
|
-
if (!fontFaceSet) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
await fontFaceSet.ready;
|
|
14
|
-
}
|
|
15
|
-
function forEachElementDeep(root, callback) {
|
|
16
|
-
if (root instanceof Element) {
|
|
17
|
-
callback(root);
|
|
18
|
-
if (root.shadowRoot) {
|
|
19
|
-
forEachElementDeep(root.shadowRoot, callback);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
Array.from(root.children).forEach((child) => {
|
|
23
|
-
forEachElementDeep(child, callback);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
function isScrollableOnAxis(element, axis) {
|
|
27
|
-
const style = getComputedStyle(element);
|
|
28
|
-
const overflowValue = axis === "y" ? style.overflowY || style.overflow : style.overflowX || style.overflow;
|
|
29
|
-
const scrollSize = axis === "y" ? element.scrollHeight - element.clientHeight : element.scrollWidth - element.clientWidth;
|
|
30
|
-
return /(auto|scroll|overlay)/.test(overflowValue) && scrollSize > 1;
|
|
31
|
-
}
|
|
32
|
-
function findNearestScrollableAncestor(element, root) {
|
|
33
|
-
let current = element.parentElement;
|
|
34
|
-
while (current && current !== root) {
|
|
35
|
-
if (isScrollableOnAxis(current, "y") || isScrollableOnAxis(current, "x")) {
|
|
36
|
-
return current;
|
|
37
|
-
}
|
|
38
|
-
current = current.parentElement;
|
|
39
|
-
}
|
|
40
|
-
return isScrollableOnAxis(root, "y") || isScrollableOnAxis(root, "x") ? root : null;
|
|
41
|
-
}
|
|
42
|
-
function parseStickyInset(value) {
|
|
43
|
-
if (!value || value === "auto") {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
const parsed = Number.parseFloat(value);
|
|
47
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
48
|
-
}
|
|
49
|
-
function createExcludeElementSnapshot(root, excludeSelectors) {
|
|
50
|
-
if (excludeSelectors.length === 0) {
|
|
51
|
-
return {
|
|
52
|
-
applyToClone: () => void 0,
|
|
53
|
-
cleanup: () => void 0
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
const markedElements = [];
|
|
57
|
-
let nextCaptureId = 0;
|
|
58
|
-
forEachElementDeep(root, (element) => {
|
|
59
|
-
if (!excludeSelectors.some((selector) => element.matches(selector))) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const captureId = String(++nextCaptureId);
|
|
63
|
-
const previousValue = element.getAttribute(CAPTURE_EXCLUDE_NODE_ID_ATTRIBUTE);
|
|
64
|
-
element.setAttribute(CAPTURE_EXCLUDE_NODE_ID_ATTRIBUTE, captureId);
|
|
65
|
-
markedElements.push({ element, previousValue });
|
|
66
|
-
});
|
|
67
|
-
return {
|
|
68
|
-
applyToClone(clonedRoot) {
|
|
69
|
-
forEachElementDeep(clonedRoot, (element) => {
|
|
70
|
-
if (!element.hasAttribute(CAPTURE_EXCLUDE_NODE_ID_ATTRIBUTE)) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const styledElement = element;
|
|
74
|
-
if (styledElement.style) {
|
|
75
|
-
styledElement.style.setProperty("opacity", "0", "important");
|
|
76
|
-
styledElement.style.setProperty("visibility", "hidden", "important");
|
|
77
|
-
styledElement.style.setProperty("pointer-events", "none", "important");
|
|
78
|
-
}
|
|
79
|
-
element.removeAttribute(CAPTURE_EXCLUDE_NODE_ID_ATTRIBUTE);
|
|
80
|
-
});
|
|
81
|
-
},
|
|
82
|
-
cleanup() {
|
|
83
|
-
markedElements.forEach(({ element, previousValue }) => {
|
|
84
|
-
if (previousValue === null) {
|
|
85
|
-
element.removeAttribute(CAPTURE_EXCLUDE_NODE_ID_ATTRIBUTE);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
element.setAttribute(CAPTURE_EXCLUDE_NODE_ID_ATTRIBUTE, previousValue);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function createModernStickySnapshot(root) {
|
|
94
|
-
const stickyOverlays = /* @__PURE__ */ new Map();
|
|
95
|
-
const markedStickyElements = [];
|
|
96
|
-
const markedScrollAncestors = [];
|
|
97
|
-
let nextStickyId = 0;
|
|
98
|
-
let nextScrollAncestorId = 0;
|
|
99
|
-
function ensureScrollAncestorId(element) {
|
|
100
|
-
const existingId = element.getAttribute(MODERN_SCROLL_ANCESTOR_ID_ATTRIBUTE);
|
|
101
|
-
if (existingId) {
|
|
102
|
-
return existingId;
|
|
103
|
-
}
|
|
104
|
-
const ancestorId = `scroll-${++nextScrollAncestorId}`;
|
|
105
|
-
const previousValue = element.getAttribute(MODERN_SCROLL_ANCESTOR_ID_ATTRIBUTE);
|
|
106
|
-
element.setAttribute(MODERN_SCROLL_ANCESTOR_ID_ATTRIBUTE, ancestorId);
|
|
107
|
-
markedScrollAncestors.push({ element, previousValue });
|
|
108
|
-
return ancestorId;
|
|
109
|
-
}
|
|
110
|
-
forEachElementDeep(root, (node) => {
|
|
111
|
-
if (!(node instanceof HTMLElement)) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const style = getComputedStyle(node);
|
|
115
|
-
if (style.position !== "sticky") {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const scrollAncestor = findNearestScrollableAncestor(node, root);
|
|
119
|
-
if (!scrollAncestor) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const nodeRect = node.getBoundingClientRect();
|
|
123
|
-
const ancestorRect = scrollAncestor.getBoundingClientRect();
|
|
124
|
-
const currentTop = nodeRect.top - ancestorRect.top - scrollAncestor.clientTop;
|
|
125
|
-
const currentLeft = nodeRect.left - ancestorRect.left - scrollAncestor.clientLeft;
|
|
126
|
-
const topInset = parseStickyInset(style.top);
|
|
127
|
-
const leftInset = parseStickyInset(style.left);
|
|
128
|
-
const isStuckY = topInset !== null && scrollAncestor.scrollTop > 0 && currentTop <= topInset + 0.5;
|
|
129
|
-
const isStuckX = leftInset !== null && scrollAncestor.scrollLeft > 0 && currentLeft <= leftInset + 0.5;
|
|
130
|
-
if (!isStuckX && !isStuckY) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const captureId = String(++nextStickyId);
|
|
134
|
-
const previousValue = node.getAttribute(MODERN_STICKY_NODE_ID_ATTRIBUTE);
|
|
135
|
-
const ancestorId = ensureScrollAncestorId(scrollAncestor);
|
|
136
|
-
stickyOverlays.set(captureId, {
|
|
137
|
-
ancestorId,
|
|
138
|
-
top: currentTop,
|
|
139
|
-
left: currentLeft,
|
|
140
|
-
width: nodeRect.width,
|
|
141
|
-
height: nodeRect.height
|
|
142
|
-
});
|
|
143
|
-
node.setAttribute(MODERN_STICKY_NODE_ID_ATTRIBUTE, captureId);
|
|
144
|
-
markedStickyElements.push({ element: node, previousValue });
|
|
145
|
-
});
|
|
146
|
-
return {
|
|
147
|
-
applyToClone(clonedRoot) {
|
|
148
|
-
const stickyById = /* @__PURE__ */ new Map();
|
|
149
|
-
const scrollAncestorById = /* @__PURE__ */ new Map();
|
|
150
|
-
forEachElementDeep(clonedRoot, (node) => {
|
|
151
|
-
if (!(node instanceof HTMLElement)) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
const captureId = node.getAttribute(MODERN_STICKY_NODE_ID_ATTRIBUTE);
|
|
155
|
-
if (captureId) {
|
|
156
|
-
stickyById.set(captureId, node);
|
|
157
|
-
}
|
|
158
|
-
const scrollAncestorId = node.getAttribute(MODERN_SCROLL_ANCESTOR_ID_ATTRIBUTE);
|
|
159
|
-
if (scrollAncestorId) {
|
|
160
|
-
scrollAncestorById.set(scrollAncestorId, node);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
stickyOverlays.forEach(({ ancestorId, top, left, width, height }, captureId) => {
|
|
164
|
-
const stickyNode = stickyById.get(captureId);
|
|
165
|
-
const scrollAncestor = scrollAncestorById.get(ancestorId);
|
|
166
|
-
if (!stickyNode || !scrollAncestor) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
const overlay = stickyNode.cloneNode(true);
|
|
170
|
-
if (!(overlay instanceof HTMLElement)) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
overlay.removeAttribute(MODERN_STICKY_NODE_ID_ATTRIBUTE);
|
|
174
|
-
overlay.removeAttribute(MODERN_SCROLL_ANCESTOR_ID_ATTRIBUTE);
|
|
175
|
-
overlay.style.position = "absolute";
|
|
176
|
-
overlay.style.top = `${top}px`;
|
|
177
|
-
overlay.style.left = `${left}px`;
|
|
178
|
-
overlay.style.width = `${width}px`;
|
|
179
|
-
overlay.style.height = `${height}px`;
|
|
180
|
-
overlay.style.margin = "0";
|
|
181
|
-
overlay.style.transform = "none";
|
|
182
|
-
overlay.style.pointerEvents = "none";
|
|
183
|
-
overlay.style.right = "auto";
|
|
184
|
-
overlay.style.bottom = "auto";
|
|
185
|
-
if (!overlay.style.zIndex || overlay.style.zIndex === "auto") {
|
|
186
|
-
overlay.style.zIndex = "1";
|
|
187
|
-
}
|
|
188
|
-
if (!scrollAncestor.style.position || scrollAncestor.style.position === "static") {
|
|
189
|
-
scrollAncestor.style.position = "relative";
|
|
190
|
-
}
|
|
191
|
-
stickyNode.style.visibility = "hidden";
|
|
192
|
-
stickyNode.style.pointerEvents = "none";
|
|
193
|
-
stickyNode.style.transform = "none";
|
|
194
|
-
scrollAncestor.appendChild(overlay);
|
|
195
|
-
});
|
|
196
|
-
forEachElementDeep(clonedRoot, (node) => {
|
|
197
|
-
if (!(node instanceof HTMLElement)) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
node.removeAttribute(MODERN_STICKY_NODE_ID_ATTRIBUTE);
|
|
201
|
-
node.removeAttribute(MODERN_SCROLL_ANCESTOR_ID_ATTRIBUTE);
|
|
202
|
-
});
|
|
203
|
-
},
|
|
204
|
-
cleanup() {
|
|
205
|
-
markedStickyElements.forEach(({ element, previousValue }) => {
|
|
206
|
-
if (previousValue === null) {
|
|
207
|
-
element.removeAttribute(MODERN_STICKY_NODE_ID_ATTRIBUTE);
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
element.setAttribute(MODERN_STICKY_NODE_ID_ATTRIBUTE, previousValue);
|
|
211
|
-
});
|
|
212
|
-
markedScrollAncestors.forEach(({ element, previousValue }) => {
|
|
213
|
-
if (previousValue === null) {
|
|
214
|
-
element.removeAttribute(MODERN_SCROLL_ANCESTOR_ID_ATTRIBUTE);
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
element.setAttribute(MODERN_SCROLL_ANCESTOR_ID_ATTRIBUTE, previousValue);
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
async function captureWithModernScreenshot(options) {
|
|
223
|
-
const { domToWebp } = await import("./index-DD-r5zA8.js");
|
|
224
|
-
const {
|
|
225
|
-
element,
|
|
226
|
-
excludeSelectors = [],
|
|
227
|
-
width,
|
|
228
|
-
height,
|
|
229
|
-
scale = getCaptureScale()
|
|
230
|
-
} = options;
|
|
231
|
-
await waitForDocumentFonts();
|
|
232
|
-
const stickySnapshot = createModernStickySnapshot(element);
|
|
233
|
-
const excludeSnapshot = createExcludeElementSnapshot(element, excludeSelectors);
|
|
234
|
-
try {
|
|
235
|
-
const captureOptions = {
|
|
236
|
-
scale,
|
|
237
|
-
quality: SCREENSHOT_DATA_URL_QUALITY,
|
|
238
|
-
features: {
|
|
239
|
-
restoreScrollPosition: true
|
|
240
|
-
},
|
|
241
|
-
onCloneNode: (cloned) => {
|
|
242
|
-
if (!(cloned instanceof Element)) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
stickySnapshot.applyToClone(cloned);
|
|
246
|
-
excludeSnapshot.applyToClone(cloned);
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
if (width) {
|
|
250
|
-
captureOptions.width = width;
|
|
251
|
-
}
|
|
252
|
-
if (height) {
|
|
253
|
-
captureOptions.height = height;
|
|
254
|
-
}
|
|
255
|
-
return await domToWebp(element, captureOptions);
|
|
256
|
-
} finally {
|
|
257
|
-
excludeSnapshot.cleanup();
|
|
258
|
-
stickySnapshot.cleanup();
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
function createViewportBounds() {
|
|
262
|
-
return {
|
|
263
|
-
width: window.innerWidth,
|
|
264
|
-
height: window.innerHeight
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
const STORAGE_PREFIX = "is_sdk_";
|
|
268
|
-
class WebPlatform {
|
|
269
|
-
constructor(eventBus) {
|
|
270
|
-
this.memoryStorage = /* @__PURE__ */ new Map();
|
|
271
|
-
this.storageListeners = /* @__PURE__ */ new Map();
|
|
272
|
-
this.storage = {
|
|
273
|
-
get: async (key) => {
|
|
274
|
-
try {
|
|
275
|
-
const raw = localStorage.getItem(`${STORAGE_PREFIX}${key}`);
|
|
276
|
-
return raw ? JSON.parse(raw) : null;
|
|
277
|
-
} catch {
|
|
278
|
-
return this.memoryStorage.get(key) ?? null;
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
set: async (key, value) => {
|
|
282
|
-
var _a;
|
|
283
|
-
try {
|
|
284
|
-
localStorage.setItem(`${STORAGE_PREFIX}${key}`, JSON.stringify(value));
|
|
285
|
-
} catch {
|
|
286
|
-
this.memoryStorage.set(key, value);
|
|
287
|
-
}
|
|
288
|
-
(_a = this.storageListeners.get(key)) == null ? void 0 : _a.forEach((cb) => cb(value));
|
|
289
|
-
},
|
|
290
|
-
remove: async (key) => {
|
|
291
|
-
var _a;
|
|
292
|
-
try {
|
|
293
|
-
localStorage.removeItem(`${STORAGE_PREFIX}${key}`);
|
|
294
|
-
} catch {
|
|
295
|
-
this.memoryStorage.delete(key);
|
|
296
|
-
}
|
|
297
|
-
(_a = this.storageListeners.get(key)) == null ? void 0 : _a.forEach((cb) => cb(null));
|
|
298
|
-
},
|
|
299
|
-
onChange: (key, callback) => {
|
|
300
|
-
if (!this.storageListeners.has(key)) {
|
|
301
|
-
this.storageListeners.set(key, /* @__PURE__ */ new Set());
|
|
302
|
-
}
|
|
303
|
-
this.storageListeners.get(key).add(callback);
|
|
304
|
-
return () => {
|
|
305
|
-
var _a;
|
|
306
|
-
(_a = this.storageListeners.get(key)) == null ? void 0 : _a.delete(callback);
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
this.messaging = {
|
|
311
|
-
send: async (action, payload) => {
|
|
312
|
-
this.eventBus.emit(action, payload);
|
|
313
|
-
return void 0;
|
|
314
|
-
},
|
|
315
|
-
onMessage: (callback) => {
|
|
316
|
-
return this.eventBus.on("*", callback);
|
|
317
|
-
},
|
|
318
|
-
broadcast: (action, payload) => {
|
|
319
|
-
this.eventBus.emit(action, payload);
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
this.screenshot = {
|
|
323
|
-
capture: async (options) => {
|
|
324
|
-
const excludeSelectors = (options == null ? void 0 : options.excludeSelectors) ?? [];
|
|
325
|
-
if (options == null ? void 0 : options.element) {
|
|
326
|
-
return captureWithModernScreenshot({
|
|
327
|
-
element: options.element,
|
|
328
|
-
excludeSelectors
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
const viewportBounds = createViewportBounds();
|
|
332
|
-
return captureWithModernScreenshot({
|
|
333
|
-
element: document.documentElement,
|
|
334
|
-
excludeSelectors,
|
|
335
|
-
width: viewportBounds.width,
|
|
336
|
-
height: viewportBounds.height
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
this.capabilities = {
|
|
341
|
-
screenRecording: typeof MediaRecorder !== "undefined",
|
|
342
|
-
detailedNetworkLogs: true,
|
|
343
|
-
consoleLogCapture: true,
|
|
344
|
-
screenshotCapture: true
|
|
345
|
-
};
|
|
346
|
-
this.eventBus = eventBus;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
class EventBus {
|
|
350
|
-
constructor() {
|
|
351
|
-
this.listeners = /* @__PURE__ */ new Map();
|
|
352
|
-
}
|
|
353
|
-
on(event, callback) {
|
|
354
|
-
if (!this.listeners.has(event)) {
|
|
355
|
-
this.listeners.set(event, /* @__PURE__ */ new Set());
|
|
356
|
-
}
|
|
357
|
-
this.listeners.get(event).add(callback);
|
|
358
|
-
return () => this.off(event, callback);
|
|
359
|
-
}
|
|
360
|
-
off(event, callback) {
|
|
361
|
-
var _a;
|
|
362
|
-
(_a = this.listeners.get(event)) == null ? void 0 : _a.delete(callback);
|
|
363
|
-
}
|
|
364
|
-
emit(event, ...args) {
|
|
365
|
-
var _a, _b;
|
|
366
|
-
(_a = this.listeners.get(event)) == null ? void 0 : _a.forEach((cb) => cb(...args));
|
|
367
|
-
(_b = this.listeners.get("*")) == null ? void 0 : _b.forEach((cb) => cb(event, ...args));
|
|
368
|
-
}
|
|
369
|
-
once(event, callback) {
|
|
370
|
-
const wrapper = (...args) => {
|
|
371
|
-
this.off(event, wrapper);
|
|
372
|
-
callback(...args);
|
|
373
|
-
};
|
|
374
|
-
return this.on(event, wrapper);
|
|
375
|
-
}
|
|
376
|
-
removeAllListeners() {
|
|
377
|
-
this.listeners.clear();
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
const DEFAULT_FLAGS = {
|
|
381
|
-
networkLogs: true,
|
|
382
|
-
consoleLogs: true,
|
|
383
|
-
screenshot: true,
|
|
384
|
-
screenRecording: true,
|
|
385
|
-
stickers: true,
|
|
386
|
-
keyboardShortcuts: true,
|
|
387
|
-
jiraIntegration: false,
|
|
388
|
-
fab: true
|
|
389
|
-
};
|
|
390
|
-
class FeatureFlags {
|
|
391
|
-
constructor(overrides) {
|
|
392
|
-
this.flags = { ...DEFAULT_FLAGS, ...overrides };
|
|
393
|
-
}
|
|
394
|
-
get(name) {
|
|
395
|
-
return this.flags[name];
|
|
396
|
-
}
|
|
397
|
-
set(name, enabled) {
|
|
398
|
-
this.flags[name] = enabled;
|
|
399
|
-
}
|
|
400
|
-
getAll() {
|
|
401
|
-
return { ...this.flags };
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
const _SDKManager = class _SDKManager {
|
|
405
|
-
constructor() {
|
|
406
|
-
this._config = null;
|
|
407
|
-
this._platform = null;
|
|
408
|
-
this._eventBus = null;
|
|
409
|
-
this._featureFlags = null;
|
|
410
|
-
this._initialized = false;
|
|
411
|
-
}
|
|
412
|
-
static getInstance() {
|
|
413
|
-
if (!_SDKManager.instance) {
|
|
414
|
-
_SDKManager.instance = new _SDKManager();
|
|
415
|
-
}
|
|
416
|
-
return _SDKManager.instance;
|
|
417
|
-
}
|
|
418
|
-
init(config) {
|
|
419
|
-
if (this._initialized) {
|
|
420
|
-
this.updateConfig(config);
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
this._config = config;
|
|
424
|
-
this._eventBus = new EventBus();
|
|
425
|
-
this._platform = new WebPlatform(this._eventBus);
|
|
426
|
-
this._featureFlags = new FeatureFlags({});
|
|
427
|
-
this._initialized = true;
|
|
428
|
-
}
|
|
429
|
-
updateConfig(config) {
|
|
430
|
-
if (!this._initialized) {
|
|
431
|
-
this.init(config);
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
this._config = config;
|
|
435
|
-
}
|
|
436
|
-
destroy() {
|
|
437
|
-
var _a;
|
|
438
|
-
(_a = this._eventBus) == null ? void 0 : _a.removeAllListeners();
|
|
439
|
-
this._config = null;
|
|
440
|
-
this._platform = null;
|
|
441
|
-
this._eventBus = null;
|
|
442
|
-
this._featureFlags = null;
|
|
443
|
-
this._initialized = false;
|
|
444
|
-
}
|
|
445
|
-
isInitialized() {
|
|
446
|
-
return this._initialized;
|
|
447
|
-
}
|
|
448
|
-
get config() {
|
|
449
|
-
if (!this._config) throw new Error("SDK not initialized");
|
|
450
|
-
return this._config;
|
|
451
|
-
}
|
|
452
|
-
get platform() {
|
|
453
|
-
if (!this._platform) throw new Error("SDK not initialized");
|
|
454
|
-
return this._platform;
|
|
455
|
-
}
|
|
456
|
-
get eventBus() {
|
|
457
|
-
if (!this._eventBus) throw new Error("SDK not initialized");
|
|
458
|
-
return this._eventBus;
|
|
459
|
-
}
|
|
460
|
-
get featureFlags() {
|
|
461
|
-
if (!this._featureFlags) throw new Error("SDK not initialized");
|
|
462
|
-
return this._featureFlags;
|
|
463
|
-
}
|
|
464
|
-
static resetInstance() {
|
|
465
|
-
if (_SDKManager.instance) {
|
|
466
|
-
_SDKManager.instance.destroy();
|
|
467
|
-
_SDKManager.instance = null;
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
_SDKManager.instance = null;
|
|
472
|
-
let SDKManager = _SDKManager;
|
|
473
|
-
const pendingListeners = /* @__PURE__ */ new Map();
|
|
474
|
-
function addPendingSdkEventListener(event, callback) {
|
|
475
|
-
if (!pendingListeners.has(event)) {
|
|
476
|
-
pendingListeners.set(event, /* @__PURE__ */ new Set());
|
|
477
|
-
}
|
|
478
|
-
pendingListeners.get(event).add(callback);
|
|
479
|
-
}
|
|
480
|
-
function removePendingSdkEventListener(event, callback) {
|
|
481
|
-
var _a, _b;
|
|
482
|
-
(_a = pendingListeners.get(event)) == null ? void 0 : _a.delete(callback);
|
|
483
|
-
if (((_b = pendingListeners.get(event)) == null ? void 0 : _b.size) === 0) {
|
|
484
|
-
pendingListeners.delete(event);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
function flushPendingSdkEventListeners(eventBus) {
|
|
488
|
-
pendingListeners.forEach((listeners, event) => {
|
|
489
|
-
listeners.forEach((callback) => eventBus.on(event, callback));
|
|
490
|
-
});
|
|
491
|
-
pendingListeners.clear();
|
|
492
|
-
}
|
|
493
|
-
export {
|
|
494
|
-
SDKManager as S,
|
|
495
|
-
addPendingSdkEventListener as a,
|
|
496
|
-
flushPendingSdkEventListeners as f,
|
|
497
|
-
removePendingSdkEventListener as r
|
|
498
|
-
};
|
package/runtime.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { SDKConfig, SDKEvent, SDKUser } from './dist/index';
|
|
2
|
-
|
|
3
|
-
export declare const IssueSticker: {
|
|
4
|
-
init(config: SDKConfig): void;
|
|
5
|
-
destroy(): void;
|
|
6
|
-
on(event: SDKEvent, callback: (...args: unknown[]) => void): void;
|
|
7
|
-
off(event: SDKEvent, callback: (...args: unknown[]) => void): void;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type { SDKConfig, SDKEvent, SDKUser };
|
|
11
|
-
export default IssueSticker;
|