1
0
Files
malta-slides/node_modules/@marp-team/marpit-svg-polyfill/lib/polyfill.mjs

2 lines
2.8 KiB
JavaScript

let t;const e="marpitSVGPolyfill:setZoomFactor,",n=Symbol(),o=Symbol();function r(t=document){if(t[n])return t[n];let e=!0;const o=()=>{e=!1,delete t[n]};Object.defineProperty(t,n,{configurable:!0,value:o});let r=[],a=!1;(async()=>{try{r=await i()}finally{a=!0}})();const l=()=>{for(const e of r)e({target:t});a&&0===r.length||e&&window.requestAnimationFrame(l)};return l(),o}const i=()=>{const e="Apple Computer, Inc."===navigator.vendor,n=e?[s]:[],o={then:n=>(e?(async()=>{if(void 0===t){const e=document.createElement("canvas");e.width=10,e.height=10;const n=e.getContext("2d"),o=new Image(10,10),r=new Promise((t=>{o.addEventListener("load",(()=>t()))}));o.crossOrigin="anonymous",o.src="data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2210%22%20height%3D%2210%22%20viewBox%3D%220%200%201%201%22%3E%3CforeignObject%20width%3D%221%22%20height%3D%221%22%20requiredExtensions%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%22%3E%3Cdiv%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%22%20style%3D%22width%3A%201px%3B%20height%3A%201px%3B%20background%3A%20red%3B%20position%3A%20relative%22%3E%3C%2Fdiv%3E%3C%2FforeignObject%3E%3C%2Fsvg%3E",await r,n.drawImage(o,0,0),t=n.getImageData(5,5,1,1).data[3]<128}return t})().then((t=>{null==n||n(t?[s]:[])})):null==n||n([]),o)};return Object.assign(n,o)};let a,l;function s(t){const n="object"==typeof t&&t.target||document,r="object"==typeof t?t.zoom:t;window[o]||(Object.defineProperty(window,o,{configurable:!0,value:!0}),document.body.style.zoom=1.0001,document.body.offsetHeight,document.body.style.zoom=1,window.addEventListener("message",(({data:t,origin:n})=>{if(n===window.origin)try{if(t&&"string"==typeof t&&t.startsWith(e)){const[,e]=t.split(","),n=Number.parseFloat(e);Number.isNaN(n)||(l=n)}}catch(t){console.error(t)}})));let i=!1;Array.from(n.querySelectorAll("svg[data-marpit-svg]"),(t=>{var e,n,o,s;t.style.transform||(t.style.transform="translateZ(0)");const c=r||l||t.currentScale||1;a!==c&&(a=c,i=c);const d=t.getBoundingClientRect(),{length:g}=t.children;for(let r=0;r<g;r+=1){const i=t.children[r];if(i.getScreenCTM){const t=i.getScreenCTM();if(t){const r=null!==(n=null===(e=i.x)||void 0===e?void 0:e.baseVal.value)&&void 0!==n?n:0,a=null!==(s=null===(o=i.y)||void 0===o?void 0:o.baseVal.value)&&void 0!==s?s:0,l=i.children.length;for(let e=0;e<l;e+=1){const n=i.children[e];if("SECTION"===n.tagName){const{style:e}=n;e.transformOrigin||(e.transformOrigin=`${-r}px ${-a}px`),e.transform=`scale(${c}) matrix(${t.a}, ${t.b}, ${t.c}, ${t.d}, ${t.e-d.left}, ${t.f-d.top}) translateZ(0.0001px)`;break}}}}}})),!1!==i&&Array.from(n.querySelectorAll("iframe"),(({contentWindow:t})=>{null==t||t.postMessage(`${e}${i}`,"null"===window.origin?"*":window.origin)}))}a=1,l=void 0;export{r as default,r as observe,i as polyfills,s as webkit};