@data-fair/frame 0.18.5 → 0.18.7

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d-frame-content.min.js","sources":["../lib/messages.js","../lib/utils/in-iframe.js","../lib/DFrameContent.js","../lib/d-frame-content.js"],"sourcesContent":["export function isMouseEventMessage(message) {\n return message[0] === 'df-global' && message[1] === 'mouse';\n}\nexport function isInitChildMessage(message) {\n return message[0] === 'df-child' && message[1] === 'init';\n}\nexport function isHeightMessage(message) {\n return message[0] === 'df-child' && message[1] === 'height';\n}\nexport function isReinitHeightMessage(message) {\n return message[0] === 'df-child' && message[1] === 'reinit-height';\n}\nexport function isStateChangeMessage(message) {\n return message[0] === 'df-child' && message[1] === 'stateChange';\n}\nexport function isCustomMessage(message) {\n return message[0] === 'df-child' && message[1] === 'custom';\n}\nexport function isNotifMessage(message) {\n return message[0] === 'df-child' && message[1] === 'notif';\n}\nexport function isAddParentUrlListenerMessage(message) {\n return message[0] === 'df-child' && message[1] === 'addParentUrlListener';\n}\nexport function isRemoveParentUrlListenerMessage(message) {\n return message[0] === 'df-child' && message[1] === 'removeParentUrlListener';\n}\nexport function isReadyMessage(message) {\n return message[0] === 'df-child' && message[1] === 'ready';\n}\nexport function isInitParentMessage(message) {\n return message[0] === 'df-parent' && message[1] === 'init';\n}\nexport function isUpdateSrcMessage(message) {\n return message[0] === 'df-parent' && message[1] === 'updateSrc';\n}\nexport function isParentUrlMessage(message) {\n return message[0] === 'df-parent' && message[1] === 'parentUrl';\n}\n","const inIframe = (() => {\n try {\n return window.top !== window.self;\n }\n catch (e) {\n return true;\n }\n})();\nexport default inIframe;\n","import { isInitParentMessage, isMouseEventMessage, isUpdateSrcMessage, isParentUrlMessage } from './messages.js';\nimport inIframe from './utils/in-iframe.js';\nconst windowEventTypes = [\n 'animationstart',\n 'webkitAnimationStart',\n 'animationiteration',\n 'webkitAnimationIteration',\n 'animationend',\n 'webkitAnimationEnd',\n 'input',\n 'mouseup',\n 'mousedown',\n 'orientationchange',\n 'afterprint',\n 'beforeprint',\n 'readystatechange',\n 'touchstart',\n 'touchend',\n 'touchcancel',\n 'transitionstart',\n 'webkitTransitionStart',\n 'MSTransitionStart',\n 'oTransitionStart',\n 'otransitionstart', 'transitioniteration',\n 'webkitTransitionIteration',\n 'MSTransitionIteration',\n 'oTransitionIteration',\n 'otransitioniteration', 'transitionend',\n 'webkitTransitionEnd',\n 'MSTransitionEnd',\n 'oTransitionEnd',\n 'otransitionend', 'resize'\n];\nexport default class DFrameContent {\n initialized = false;\n options;\n pendingCheckHeight = false;\n debug = false;\n id;\n throttledCheckHeight;\n lastHeight = 0;\n parentUrlListeners = {};\n parentUrlResults = {};\n constructor(options) {\n this.options = options ?? {};\n if (typeof window === 'undefined')\n return;\n if (window.__d_frame__content) {\n throw new Error('DFrameContent was already initialized');\n }\n window.__d_frame__content = this;\n const afCallback = () => {\n this.checkHeight();\n this.pendingCheckHeight = false;\n };\n this.throttledCheckHeight = () => {\n if (this.pendingCheckHeight)\n return;\n this.pendingCheckHeight = true;\n requestAnimationFrame(afCallback);\n };\n window.addEventListener('message', (e) => this.onMessage(e));\n // simple handshake for initialization\n this.postMessageToParent(['df-child', 'init']);\n }\n log(level, ...args) {\n if (level === 'debug' && !this.debug)\n return;\n if (level === 'debug')\n console.timeLog(`d-frame:${this.id}:content`, ...args);\n if (level === 'info')\n console.info(`d-frame:${this.id}:content`, ...args);\n if (level === 'error')\n console.error(`d-frame:${this.id}:content`, ...args);\n }\n onMessage(e) {\n if (e.source === window.parent && Array.isArray(e.data)) {\n const message = e.data;\n if (isInitParentMessage(message)) {\n this.id = message[2].id;\n this.debug = !!message[2].debug;\n if (this.debug)\n console.time(`d-frame:${this.id}:content`);\n this.log('debug', 'init handshake is ok', message, this.options);\n if (message[2].src && message[2].src !== window.location.href) {\n this.log('error', `src mismatch at init, maybe the frame navigated before the initialization handshake: ${window.location.href} !== ${message[2].src}`);\n }\n if (message[2].resize !== 'no')\n this.initResize();\n if (message[2].syncParams || message[2].syncPath || message[2].stateChangeEvents)\n this.initStateChangeWatcher();\n if (message[2].mouseEvents)\n this.initMouseEvents(message[2].mouseEvents);\n this.initialized = true;\n }\n if (isUpdateSrcMessage(message)) {\n const newSrc = message[2].startsWith('/') ? window.location.origin + message[2] : message[2];\n if (newSrc === window.location.href)\n return;\n this.log('debug', `update src ${window.location.href} -> ${newSrc}`);\n if (this.options.updateSrc) {\n this.options.updateSrc(newSrc, this);\n }\n else {\n this.log('debug', 'no updateSrc method available, falling back to updating window.location.href', newSrc);\n window.location.href = newSrc;\n }\n }\n if (isMouseEventMessage(message)) {\n this.applySyncedMouseEvent(message);\n }\n if (isParentUrlMessage(message)) {\n if (!this.parentUrlListeners[message[2]]) {\n this.log('error', `received getParentUrlResponse message but no matching callback is registered: ${message[2]}`);\n }\n else {\n for (const listener of this.parentUrlListeners[message[2]]) {\n listener(message[3]);\n }\n }\n }\n }\n }\n postMessageToParent(message) {\n window.parent.postMessage(message, '*');\n }\n sendNotif(notif) {\n this.postMessageToParent(['df-child', 'notif', notif]);\n }\n sendMessage(msg) {\n this.postMessageToParent(['df-child', 'custom', msg]);\n }\n ready() {\n this.postMessageToParent(['df-child', 'ready']);\n }\n reinitHeight() {\n this.postMessageToParent(['df-child', 'reinit-height']);\n }\n // this is not a single-time callback, it can be called multiple times when parent url changes\n addParentUrlListener(partialChildHref, listener) {\n const childHref = new URL(partialChildHref, window.location.href).href;\n if (!inIframe) {\n listener(childHref);\n return;\n }\n if (this.parentUrlResults[childHref]) {\n listener(this.parentUrlResults[childHref]);\n }\n this.parentUrlListeners[childHref] = this.parentUrlListeners[childHref] ?? [];\n this.parentUrlListeners[childHref].push(listener);\n this.postMessageToParent(['df-child', 'addParentUrlListener', childHref]);\n }\n removeParentUrlListener(partialChildHref, listener) {\n const childHref = new URL(partialChildHref, window.location.href).href;\n if (this.parentUrlListeners[childHref]) {\n this.parentUrlListeners[childHref] = this.parentUrlListeners[childHref].filter(cb => cb !== listener);\n if (!this.parentUrlListeners[childHref].length) {\n delete this.parentUrlListeners[childHref];\n this.postMessageToParent(['df-child', 'removeParentUrlListener', childHref]);\n }\n }\n }\n currentSyncedMouseEvents = new Set();\n initMouseEvents(types) {\n this.log('debug', 'initMouseEvents');\n for (const eventType of types) {\n document.addEventListener(eventType, (e) => {\n if (!(e instanceof MouseEvent))\n return;\n this.transmitSyncedMouseEvent(['df-global', 'mouse', eventType, { altKey: e.altKey, ctrlKey: e.ctrlKey, shiftKey: e.shiftKey, metaKey: e.metaKey }]);\n }, true);\n }\n }\n transmitSyncedMouseEvent(message) {\n if (this.currentSyncedMouseEvents.has(message[2])) {\n this.currentSyncedMouseEvents.delete(message[2]);\n }\n else {\n this.postMessageToParent(message);\n }\n }\n applySyncedMouseEvent(message) {\n this.currentSyncedMouseEvents.add(message[2]);\n const event = new MouseEvent(message[2], { bubbles: true, cancelable: true, view: window, ...message[3] });\n document.body.dispatchEvent(event);\n }\n initResize() {\n this.log('debug', 'initResize');\n this.checkHeight();\n this.createMutationObserver();\n this.createWindowEventListeners();\n }\n initStateChangeWatcher() {\n this.log('debug', 'initStateChangeWatcher');\n // monkey patch pushState and replaceState to send all state change info to the parent window\n // this is to compensate the lack of event emission by window.history\n const oldReplaceState = window.history.replaceState;\n const newPushState = (...args) => {\n const before = window.location.href;\n // do a replace instead of a push, the push will be done in the parent window if sync-state is activated\n const ret = oldReplaceState.apply(window.history, args);\n if (window.location.href !== before) {\n this.postMessageToParent(['df-child', 'stateChange', 'push', window.location.href]);\n }\n return ret;\n };\n window.history.pushState = newPushState;\n const newReplaceState = (...args) => {\n const before = window.location.href;\n const ret = oldReplaceState.apply(window.history, args);\n if (window.location.href !== before) {\n this.postMessageToParent(['df-child', 'stateChange', 'replace', window.location.href]);\n }\n return ret;\n };\n window.history.replaceState = newReplaceState;\n }\n createMutationObserver() {\n const body = document.querySelector('body');\n if (!body)\n throw new Error('DFrameContentManager was initialized before the HTML body');\n if (!this.throttledCheckHeight)\n throw new Error('throttledCheckHeight is not defined');\n const observer = new window.MutationObserver(this.throttledCheckHeight);\n observer.observe(body, {\n attributes: false,\n attributeOldValue: false,\n characterData: false,\n characterDataOldValue: false,\n childList: true,\n subtree: true,\n });\n }\n createWindowEventListeners() {\n if (!this.throttledCheckHeight)\n throw new Error('throttledCheckHeight is not defined');\n for (const eventType of windowEventTypes) {\n window.addEventListener(eventType, this.throttledCheckHeight, { passive: true });\n }\n }\n checkHeight() {\n const elements = document.querySelectorAll('[data-iframe-height]');\n let maxWithoutOffset = 0;\n let max = 0;\n for (const element of elements) {\n const dataAttribute = element.getAttribute('data-iframe-height');\n if (dataAttribute === 'false' || dataAttribute === 'no')\n continue;\n const bottomWithoutOffset = element.getBoundingClientRect().bottom +\n parseFloat(getComputedStyle(element).getPropertyValue('margin-bottom'));\n const bottom = dataAttribute ? (bottomWithoutOffset + parseFloat(dataAttribute)) : bottomWithoutOffset;\n if (bottomWithoutOffset > maxWithoutOffset)\n maxWithoutOffset = bottomWithoutOffset;\n if (bottom > max)\n max = bottom;\n }\n max = Math.ceil(max);\n if (maxWithoutOffset > 0 && max !== this.lastHeight) {\n this.postMessageToParent(['df-child', 'height', max]);\n this.lastHeight = max;\n }\n }\n}\n","import DFrameContent from './DFrameContent.js';\nexport default new DFrameContent();\n"],"names":["isMouseEventMessage","message","isInitParentMessage","isUpdateSrcMessage","isParentUrlMessage","inIframe","windowEventTypes","DFrameContent","options","__publicField","afCallback","e","level","args","newSrc","listener","notif","msg","partialChildHref","childHref","cb","types","eventType","event","oldReplaceState","newPushState","before","ret","newReplaceState","body","elements","maxWithoutOffset","max","element","dataAttribute","bottomWithoutOffset","bottom"],"mappings":"8MAAO,SAASA,EAAoBC,EAAS,CACzC,OAAOA,EAAQ,CAAC,IAAM,aAAeA,EAAQ,CAAC,IAAM,OACxD,CA4BO,SAASC,EAAoBD,EAAS,CACzC,OAAOA,EAAQ,CAAC,IAAM,aAAe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ACTA,EAAMI,EACtB,CACQJ,EAAM,KAAK,KAAKA,CAAG,EACfD,EAAmB,GAAKC,IAAQ,KAAK,aACrC,KAAK,oBAAoB,CAAC,WAAY,SAAUA,CAAG,CAAC,EACpD,KAAK,WAAaA,EAE9B,CACA,QCrQe,IAAIzB"}
@@ -1,4 +1,4 @@
1
- var N=Object.defineProperty;var $=(u,l,f)=>l in u?N(u,l,{enumerable:!0,configurable:!0,writable:!0,value:f}):u[l]=f;var a=(u,l,f)=>$(u,typeof l!="symbol"?l+"":l,f);(function(){"use strict";var v,A;function u(t){return t[0]==="df-global"&&t[1]==="mouse"}function l(t){return t[0]==="df-child"&&t[1]==="init"}function f(t){return t[0]==="df-child"&&t[1]==="height"}function S(t){return t[0]==="df-child"&&t[1]==="reinit-height"}function M(t){return t[0]==="df-child"&&t[1]==="stateChange"}function C(t){return t[0]==="df-child"&&t[1]==="custom"}function P(t){return t[0]==="df-child"&&t[1]==="notif"}function L(t){return t[0]==="df-child"&&t[1]==="addParentUrlListener"}function R(t){return t[0]==="df-child"&&t[1]==="removeParentUrlListener"}function z(t){return t[0]==="df-child"&&t[1]==="ready"}function x(t){return t.endsWith("/")?t:t===""?"/":t.slice(0,t.lastIndexOf("/")+1)}function b(t){return t.endsWith("/")?t:t+"/"}function y(t,n){if(n.origin!==t.origin)return n.href;if(b(n.pathname)===b(t.pathname))return"";const e=x(t.pathname);return n.pathname.startsWith(e)?n.pathname.replace(e,""):n.pathname}const U=t=>t.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&");function H(t){const n=[];for(const e of t.split(",")){const[s="*",i]=e.split(":"),r="^"+U(s).replace(/\\\*/g,"(.*)")+"$";n.push({regexp:new RegExp(r),append:i})}return n}function I(t,n,e,s){if(!e&&!s)return t;const i=new URL(t),r=new URL(n);if(e&&r.searchParams.forEach((h,c)=>{for(const o of e){if(o.append&&!c.startsWith(o.append)||c===s)continue;const d=o.append?c.replace(o.append,""):c;if(d.match(o.regexp)){i.searchParams.set(d,h);break}}}),s!==null){let h;if(s==="#")h=r.hash.slice(1);else if(s.startsWith("/"))if(r.pathname.startsWith(s)||r.pathname+"/"===s)h=y(new URL(s,n),r);else return null;else h=r.searchParams.get(s);h&&(i.pathname=new URL(h,t).pathname)}return i.href}function p(t,n,e,s,i){const r=new URL(t),h=new URL(e),c=new URL(n);if(s){for(const o of h.searchParams.keys().toArray())for(const d of s){if(d.append&&!o.startsWith(d.append))continue;const m=d.append?o.replace(d.append,""):o;if(m.match(d.regexp)){c.searchParams.get(m)===null&&h.searchParams.delete(o);break}}c.searchParams.forEach((o,d)=>{for(const m of s){if(!d.match(m.regexp)||(r==null?void 0:r.searchParams.get(d))===o)continue;const k=m.append?m.append+d:d;h.searchParams.set(k,o);break}})}if(i!==null&&r){const o=y(r,c);if(i==="#")h.hash=o;else if(i.startsWith("/")){if(o.startsWith("/"))return null;o===""?h.pathname=i:h.pathname=new URL(o,new URL(i,e)).pathname}else o?h.searchParams.set(i,o):h.searchParams.delete(i)}return h}function W(t){return t.vIframe===!0&&t.uiNotification!==void 0}function T(t){if(typeof t=="string")return{type:"default",title:t};if(t.error&&!t.errorMsg){const n=t.error.response&&(t.error.response.data||t.error.response.status)||t.error.message||t.error;return t.msg?{type:"error",title:t.msg,detail:n}:{type:"error",title:n}}return t.type==="error"?{type:t.clientError?"warning":"error",title:t.msg,detail:t.errorMsg}:{type:t.type??"default",title:t.msg}}class O{stateChange(n,e,s){s.log("debug","apply state change on window.history",n,e.href),n==="replace"&&window.history.replaceState(window.history.state,"",e),n==="push"&&window.history.pushState(window.history.state,"",e)}onStateChange(n){window.addEventListener("popstate",n)}}const g=((v=document.head)==null?void 0:v.querySelector("meta[property=csp-nonce]"))??((A=document.head)==null?void 0:A.querySelector("meta[name=csp-nonce]")),w=(g==null?void 0:g.nonce)??(g==null?void 0:g.content),E=document.createElement("template");E.innerHTML=`<style${w?` nonce="${w}"`:""}>
1
+ var $=Object.defineProperty;var k=(u,l,f)=>l in u?$(u,l,{enumerable:!0,configurable:!0,writable:!0,value:f}):u[l]=f;var a=(u,l,f)=>k(u,typeof l!="symbol"?l+"":l,f);(function(){"use strict";var v,A;function u(t){return t[0]==="df-global"&&t[1]==="mouse"}function l(t){return t[0]==="df-child"&&t[1]==="init"}function f(t){return t[0]==="df-child"&&t[1]==="height"}function S(t){return t[0]==="df-child"&&t[1]==="reinit-height"}function C(t){return t[0]==="df-child"&&t[1]==="stateChange"}function M(t){return t[0]==="df-child"&&t[1]==="custom"}function P(t){return t[0]==="df-child"&&t[1]==="notif"}function R(t){return t[0]==="df-child"&&t[1]==="addParentUrlListener"}function L(t){return t[0]==="df-child"&&t[1]==="removeParentUrlListener"}function z(t){return t[0]==="df-child"&&t[1]==="ready"}function x(t){return t.endsWith("/")?t:t===""?"/":t.slice(0,t.lastIndexOf("/")+1)}function b(t){return t.endsWith("/")?t:t+"/"}function y(t,n){if(n.origin!==t.origin)return n.href;if(b(n.pathname)===b(t.pathname))return"";const e=x(t.pathname);return n.pathname.startsWith(e)?n.pathname.replace(e,""):n.pathname}const H=t=>t.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&");function U(t){const n=[];for(const e of t.split(",")){const[s="*",i]=e.split(":"),r="^"+H(s).replace(/\\\*/g,"(.*)")+"$";n.push({regexp:new RegExp(r),append:i})}return n}function I(t,n,e,s){if(!e&&!s)return t;const i=new URL(t),r=new URL(n);if(e&&r.searchParams.forEach((h,c)=>{for(const o of e){if(o.append&&!c.startsWith(o.append)||c===s)continue;const d=o.append?c.replace(o.append,""):c;if(d.match(o.regexp)){i.searchParams.set(d,h);break}}}),s!==null){let h;if(s==="#")h=r.hash.slice(1);else if(s.startsWith("/"))if(r.pathname.startsWith(s)||r.pathname+"/"===s)h=y(new URL(s,n),r);else return null;else h=r.searchParams.get(s);h&&(i.pathname=new URL(h,t).pathname)}return i.href}function p(t,n,e,s,i){const r=new URL(t),h=new URL(e),c=new URL(n);if(s){for(const o of h.searchParams.keys().toArray())for(const d of s){if(d.append&&!o.startsWith(d.append))continue;const m=d.append?o.replace(d.append,""):o;if(m.match(d.regexp)){c.searchParams.get(m)===null&&h.searchParams.delete(o);break}}c.searchParams.forEach((o,d)=>{for(const m of s){if(!d.match(m.regexp)||(r==null?void 0:r.searchParams.get(d))===o)continue;const N=m.append?m.append+d:d;h.searchParams.set(N,o);break}})}if(i!==null&&r){const o=y(r,c);if(i==="#")h.hash=o;else if(i.startsWith("/")){if(o.startsWith("/"))return null;o===""?h.pathname=i:h.pathname=new URL(o,new URL(i,e)).pathname}else o?h.searchParams.set(i,o):h.searchParams.delete(i)}return h}function W(t){return t.vIframe===!0&&t.uiNotification!==void 0}function O(t){if(typeof t=="string")return{type:"default",title:t};if(t.error&&!t.errorMsg){const n=t.error.response&&(t.error.response.data||t.error.response.status)||t.error.message||t.error;return t.msg?{type:"error",title:t.msg,detail:n}:{type:"error",title:n}}return t.type==="error"?{type:t.clientError?"warning":"error",title:t.msg,detail:t.errorMsg}:{type:t.type??"default",title:t.msg}}class T{stateChange(n,e,s){s.log("debug","apply state change on window.history",n,e.href),n==="replace"&&window.history.replaceState(window.history.state,"",e),n==="push"&&window.history.pushState(window.history.state,"",e)}onStateChange(n){return window.addEventListener("popstate",n),()=>{window.removeEventListener("popstate",n)}}}const g=((v=document.head)==null?void 0:v.querySelector("meta[property=csp-nonce]"))??((A=document.head)==null?void 0:A.querySelector("meta[name=csp-nonce]")),w=(g==null?void 0:g.nonce)??(g==null?void 0:g.content),E=document.createElement("template");E.innerHTML=`<style${w?` nonce="${w}"`:""}>
2
2
  :host {
3
3
  display: block;
4
4
  }
@@ -15,5 +15,5 @@ var N=Object.defineProperty;var $=(u,l,f)=>l in u?N(u,l,{enumerable:!0,configura
15
15
  border: none;
16
16
  user-select: none;
17
17
  }
18
- </style><div class="d-frame-wrapper"><slot name="loading"><div class="loading-placeholder"></div></slot><iframe class="d-frame-iframe"></iframe></div>`;class K extends HTMLElement{constructor(){super();a(this,"adapter");a(this,"windowAdapter");a(this,"connected",!1);a(this,"childInitialized",!1);a(this,"currentChildSrc",null);a(this,"parsedSyncParams");a(this,"wrapperElement");a(this,"slotElement");a(this,"iframeElement");a(this,"width");a(this,"aspectRatioHeight");a(this,"resizedHeight");a(this,"randomId");a(this,"iframeLoaded",!1);a(this,"ready",!1);a(this,"iframeExtraAttrs",{});a(this,"resizeObserver");a(this,"boundOnMessage",e=>this.onMessage(e));a(this,"mouseEventListeners",{});a(this,"parentUrlListeners",{});a(this,"currentSyncedMouseEvents",new Set);this.randomId=Math.random().toString(36).slice(-6);const e=E.content.cloneNode(!0);this.wrapperElement=e.childNodes[1],this.slotElement=this.wrapperElement.childNodes[0],this.iframeElement=this.wrapperElement.childNodes[1],this.iframeElement.style.cssText="visibility:hidden;position:absolute;height:0px;",this.iframeElement.addEventListener("load",()=>{this.iframeElement.getAttribute("src")&&(this.log("debug","iframe loaded"),this.iframeLoaded=!0,this.dispatchEvent(new CustomEvent("iframe-load")),this.resize!=="yes"&&!this.readyMessage&&(this.ready=!0,this.dispatchEvent(new CustomEvent("ready")),this.updateStyle()))}),this.attachShadow({mode:"open"}).appendChild(e),this.resizeObserver=new ResizeObserver(i=>{(this.width===void 0||Math.abs(this.width-i[0].contentRect.width)>2)&&(this.width=i[0].contentRect.width,this.updateAspectRatioHeight())}),this.adapter=this.windowAdapter=new O}get id(){return this.getAttribute("id")??this.randomId}set id(e){this.setAttribute("id",e)}get debug(){return this.hasAttribute("debug")}set debug(e){e?this.setAttribute("debug",""):this.removeAttribute("debug")}get src(){return this.getAttribute("src")}set src(e){this.setAttribute("src",e)}get fullSrc(){return this.src.startsWith("/")?window.location.origin+this.src:this.src}get scrolling(){return this.getAttribute("scrolling")}set scrolling(e){this.setAttribute("scrolling",e)}get aspectRatio(){const e=this.getAttribute("aspect-ratio");return e===""?"auto":e}set aspectRatio(e){e!==null?this.setAttribute("aspect-ratio",e):this.removeAttribute("aspect-ratio")}get height(){return this.getAttribute("height")}set height(e){e?this.setAttribute("height",e):this.removeAttribute("height")}set resize(e){this.setAttribute("resize",e)}get resize(){const e=this.getAttribute("resize");return e===null?"auto":e===""?"yes":e}set reinitHeight(e){this.setAttribute("reinit-height",e)}get reinitHeight(){const e=this.getAttribute("reinit-height");return e===null||e===""?"on-message":e}get syncParams(){return this.getAttribute("sync-params")}set syncParams(e){e!==null?this.setAttribute("sync-params",e):this.removeAttribute("sync-params")}get syncPath(){const e=this.getAttribute("sync-path");return e===null?null:e||"p"}set syncPath(e){e!==null?this.setAttribute("sync-params",e):this.removeAttribute("sync-params")}get stateChangeEvents(){return this.hasAttribute("state-change-events")}set stateChangeEvents(e){e?this.setAttribute("state-change-events",""):this.removeAttribute("state-change-events")}get readyMessage(){return this.hasAttribute("ready-message")}set readyMessage(e){e?this.setAttribute("ready-message",""):this.removeAttribute("ready-message")}get mouseEvents(){const e=this.getAttribute("mouse-events");return e===null?null:e===""?["click","dblclick","mousedown","mouseup"]:e.split(",")}set mouseEvents(e){e===null?this.removeAttribute("mouse-events"):this.setAttribute("mouse-events",e.join(","))}get reload(){return this.getAttribute("reload")}set reload(e){this.setAttribute("reload",e)}get emitIFrameMessages(){return this.hasAttribute("emit-iframe-messages")}set emitIFrameMessages(e){e?this.setAttribute("emit-iframe-messages",""):this.removeAttribute("emit-iframe-messages")}get actualAspectRatio(){return this.aspectRatio!=="auto"?Number(this.aspectRatio):!this.width||this.width<500?1:this.width<800?4/3:this.width<1200?16/9:21/9}onMessage(e){var s;if(this.emitIFrameMessages&&this.dispatchEvent(new CustomEvent("iframe-message",{detail:e.data})),e.source===((s=this.iframeElement)==null?void 0:s.contentWindow)){const i=e.data;if(this.log("debug","received message from child",i),Array.isArray(e.data)){if(l(i)&&(this.postMessageToChild(["df-parent","init",{id:this.id,debug:this.debug,resize:this.resize,syncParams:this.syncParams!==null,syncPath:this.syncPath!==null,stateChangeEvents:this.stateChangeEvents,mouseEvents:this.mouseEvents,src:this.currentChildSrc}]),this.childInitialized=!0),f(i)&&(this.resizedHeight=i[2],this.resize==="yes"&&!this.ready&&!this.readyMessage&&(this.ready=!0,this.dispatchEvent(new CustomEvent("ready"))),this.updateStyle()),S(i)&&this.reinitHeight==="on-message"&&(this.resizedHeight=void 0,this.updateStyle()),M(i)){if(this.currentChildSrc=i[3],this.parsedSyncParams||this.syncPath){const r=p(this.fullSrc,i[3],window.location.href,this.parsedSyncParams,this.syncPath);if(r===null)this.log("debug","failed to process newParentUrl, ignore state change");else if(r.href!==window.location.href){this.log("debug","apply state change to parent",i[2],r.href);try{this.adapter.stateChange(i[2],r,this)}catch(h){this.log("error","failed to apply state change to parent using custom adapter",h),this.windowAdapter.stateChange(i[2],r,this)}}}this.stateChangeEvents&&this.dispatchEvent(new CustomEvent("state-change",{detail:[i[2],i[3]]}))}if(C(i)&&this.dispatchEvent(new CustomEvent("message",{detail:i[2]})),P(i)&&this.dispatchEvent(new CustomEvent("notif",{detail:i[2]})),z(i)&&(this.ready=!0,this.dispatchEvent(new CustomEvent("ready")),this.updateStyle()),u(i)&&this.applySyncedMouseEvent(i),L(i)){const r=p(this.fullSrc,i[2],window.location.href,this.parsedSyncParams,this.syncPath);r&&(this.parentUrlListeners[i[2]]=r.href,this.postMessageToChild(["df-parent","parentUrl",i[2],r.href]))}R(i)&&delete this.parentUrlListeners[i[2]]}else W(i)&&this.dispatchEvent(new CustomEvent("notif",{detail:T(i.uiNotification)}))}}postMessageToChild(e){var s,i;this.log("debug","send message to child",e),(i=(s=this.iframeElement)==null?void 0:s.contentWindow)==null||i.postMessage(e,"*")}updateParsedSyncParams(){this.parsedSyncParams=this.syncParams!==null?H(this.syncParams||"*"):void 0}updateSrc(){if(!this.connected)return;for(const[s,i]of Object.entries(this.parentUrlListeners)){const r=p(this.fullSrc,s,window.location.href,this.parsedSyncParams,this.syncPath);r&&r.href!==i&&(this.parentUrlListeners[s]=r.href,this.postMessageToChild(["df-parent","parentUrl",s,r.href]))}const e=I(this.fullSrc,window.location.href,this.parsedSyncParams,this.syncPath);e&&e!==this.currentChildSrc&&(this.currentChildSrc=e,this.childInitialized?this.postMessageToChild(["df-parent","updateSrc",e]):(this.log("debug","set src attribute of iframe: "+e),this.iframeElement.setAttribute("src",e)))}updateStyle(){if(!this.connected)return;let e;this.resizedHeight?(this.log("debug","height of iframe based on resize message: "+this.resizedHeight),e=this.resizedHeight+"px"):this.height?(this.log("debug","height of iframe based on direct attribute: "+this.height),e=this.height):this.aspectRatio!==null&&(this.log("debug","height of iframe based on aspect ratio: "+this.aspectRatioHeight),e=this.aspectRatioHeight+"px"),e!==void 0?(this.log("debug","set height iframe wrapper: "+e),this.wrapperElement.style.cssText=`height:${e};min-height:0;`):this.wrapperElement.style.cssText="",this.scrolling?(this.log("debug","explicitly set of scrolling attribute of iframe: "+this.scrolling),this.iframeElement.setAttribute("scrolling",this.scrolling)):this.resize==="yes"||this.resize==="auto"&&this.resizedHeight?this.iframeElement.getAttribute("scrolling")!=="no"&&(this.log("debug","implicitly set scrolling attribute of iframe: no"),this.iframeElement.setAttribute("scrolling","no")):this.iframeElement.getAttribute("scrolling")!=="auto"&&(this.log("debug","implicitly set scrolling attribute of iframe: auto"),this.iframeElement.setAttribute("scrolling","auto")),this.ready&&this.iframeElement.getAttribute("style")!==""&&(this.log("debug","toggle loading slot and iframe visibility"),this.iframeElement.style.cssText="",this.slotElement.style.cssText="display:none;")}updateAspectRatioHeight(){this.width&&this.aspectRatio!==null&&(this.resizedHeight||this.height||(this.aspectRatioHeight=Math.ceil(this.width/this.actualAspectRatio),this.updateStyle()))}updateIframeExtraAttrs(){const e=this.iframeExtraAttrs,s={};for(const i of this.getAttributeNames())if(i.startsWith("iframe-")){const r=this.getAttribute(i);if(r!==null){const h=i.slice(7);s[h]=r}}this.log("debug","update iframe extra attributes",e,s);for(const i of Object.keys(e))i in s||this.iframeElement.removeAttribute(i);for(const i of Object.keys(s))s[i]!==e[i]&&this.iframeElement.setAttribute(i,s[i])}initMouseEvents(e){this.log("debug","initMouseEvents");for(const s of e)if(!this.mouseEventListeners[s]){const i=r=>{r instanceof MouseEvent&&this.transmitSyncedMouseEvent(["df-global","mouse",s,{altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}])};this.mouseEventListeners[s]=i,document.addEventListener(s,i,!0)}}transmitSyncedMouseEvent(e){this.currentSyncedMouseEvents.has(e[2])?this.currentSyncedMouseEvents.delete(e[2]):this.postMessageToChild(e)}applySyncedMouseEvent(e){this.currentSyncedMouseEvents.add(e[2]);const s=new MouseEvent(e[2],{bubbles:!0,cancelable:!0,view:window,...e[3]});this.dispatchEvent(s)}log(e,...s){e==="debug"&&!this.debug||(e==="debug"&&console.timeLog(`d-frame:${this.id}`,...s),e==="info"&&console.info(`d-frame:${this.id}`,...s),e==="error"&&console.error(`d-frame:${this.id}`,...s))}connectedCallback(){if(!this.debug){const e=window.localStorage.getItem("debug");if(e){const s=e.split(",");(s.includes("d-frame")||s.includes("d-frame:"+this.id))&&(this.debug=!0)}}if(this.debug&&console.time(`d-frame:${this.id}`),!this.hasAttribute("src"))throw new Error("src is a required attribute");this.log("debug","connected"),this.connected=!0,this.adapter.onStateChange&&this.adapter.onStateChange(()=>{this.updateSrc()}),this.resizeObserver.observe(this),window.addEventListener("message",this.boundOnMessage),this.updateParsedSyncParams(),this.updateStyle(),this.updateIframeExtraAttrs(),this.updateSrc(),this.mouseEvents&&this.initMouseEvents(this.mouseEvents)}disconnectedCallback(){this.log("debug","disconnected"),this.resizeObserver.disconnect(),window.removeEventListener("message",this.boundOnMessage);for(const[e,s]of Object.entries(this.mouseEventListeners))document.removeEventListener(e,s,!0),delete this.mouseEventListeners[e]}static get observedAttributes(){return["src","aspect-ratio","height","sync-params","sync-path","reload"]}attributeChangedCallback(e,s,i){var r;if(e==="aspect-ratio"&&this.updateAspectRatioHeight(),!!this.connected&&(this.log("debug","attribute change",e,s,i),e==="src"&&this.updateSrc(),e==="height"&&this.updateStyle(),e==="sync-params"&&(this.updateParsedSyncParams(),this.updateSrc()),e==="sync-path"&&this.updateSrc(),e==="reload")){if(!this.currentChildSrc){this.log("error","reload attribute changed but the iframe has no current src");return}if(!((r=this.iframeElement.contentWindow)!=null&&r.location)){this.log("debug","reload attribute changed but no iframe contentWindow, is this a cross domain iframe ?");return}if(!this.iframeLoaded){this.log("debug","reload attribute changed before initial loading was complete, ignore it");return}this.log("debug","reload iframe with current src",this.currentChildSrc),this.childInitialized=!1,this.iframeElement.setAttribute("src",this.currentChildSrc),this.iframeElement.contentWindow.location.reload()}}}customElements.get("d-frame")||customElements.define("d-frame",K)})();
18
+ </style><div class="d-frame-wrapper"><slot name="loading"><div class="loading-placeholder"></div></slot><iframe class="d-frame-iframe"></iframe></div>`;class K extends HTMLElement{constructor(){super();a(this,"adapter");a(this,"windowAdapter");a(this,"connected",!1);a(this,"childInitialized",!1);a(this,"currentChildSrc",null);a(this,"parsedSyncParams");a(this,"wrapperElement");a(this,"slotElement");a(this,"iframeElement");a(this,"width");a(this,"aspectRatioHeight");a(this,"resizedHeight");a(this,"randomId");a(this,"iframeLoaded",!1);a(this,"ready",!1);a(this,"iframeExtraAttrs",{});a(this,"resizeObserver");a(this,"boundOnMessage",e=>this.onMessage(e));a(this,"mouseEventListeners",{});a(this,"stopOnStateChange");a(this,"parentUrlListeners",{});a(this,"currentSyncedMouseEvents",new Set);this.randomId=Math.random().toString(36).slice(-6);const e=E.content.cloneNode(!0);this.wrapperElement=e.childNodes[1],this.slotElement=this.wrapperElement.childNodes[0],this.iframeElement=this.wrapperElement.childNodes[1],this.iframeElement.style.cssText="visibility:hidden;position:absolute;height:0px;",this.iframeElement.addEventListener("load",()=>{this.iframeElement.getAttribute("src")&&(this.log("debug","iframe loaded"),this.iframeLoaded=!0,this.dispatchEvent(new CustomEvent("iframe-load")),this.resize!=="yes"&&!this.readyMessage&&(this.ready=!0,this.dispatchEvent(new CustomEvent("ready")),this.updateStyle()))}),this.attachShadow({mode:"open"}).appendChild(e),this.resizeObserver=new ResizeObserver(i=>{(this.width===void 0||Math.abs(this.width-i[0].contentRect.width)>2)&&(this.width=i[0].contentRect.width,this.updateAspectRatioHeight())}),this.adapter=this.windowAdapter=new T}get id(){return this.getAttribute("id")??this.randomId}set id(e){this.setAttribute("id",e)}get debug(){return this.hasAttribute("debug")}set debug(e){e?this.setAttribute("debug",""):this.removeAttribute("debug")}get src(){return this.getAttribute("src")}set src(e){this.setAttribute("src",e)}get fullSrc(){return this.src.startsWith("/")?window.location.origin+this.src:this.src}get scrolling(){return this.getAttribute("scrolling")}set scrolling(e){this.setAttribute("scrolling",e)}get aspectRatio(){const e=this.getAttribute("aspect-ratio");return e===""?"auto":e}set aspectRatio(e){e!==null?this.setAttribute("aspect-ratio",e):this.removeAttribute("aspect-ratio")}get height(){return this.getAttribute("height")}set height(e){e?this.setAttribute("height",e):this.removeAttribute("height")}set resize(e){this.setAttribute("resize",e)}get resize(){const e=this.getAttribute("resize");return e===null?"auto":e===""?"yes":e}set reinitHeight(e){this.setAttribute("reinit-height",e)}get reinitHeight(){const e=this.getAttribute("reinit-height");return e===null||e===""?"on-message":e}get syncParams(){return this.getAttribute("sync-params")}set syncParams(e){e!==null?this.setAttribute("sync-params",e):this.removeAttribute("sync-params")}get syncPath(){const e=this.getAttribute("sync-path");return e===null?null:e||"p"}set syncPath(e){e!==null?this.setAttribute("sync-params",e):this.removeAttribute("sync-params")}get stateChangeEvents(){return this.hasAttribute("state-change-events")}set stateChangeEvents(e){e?this.setAttribute("state-change-events",""):this.removeAttribute("state-change-events")}get readyMessage(){return this.hasAttribute("ready-message")}set readyMessage(e){e?this.setAttribute("ready-message",""):this.removeAttribute("ready-message")}get mouseEvents(){const e=this.getAttribute("mouse-events");return e===null?null:e===""?["click","dblclick","mousedown","mouseup"]:e.split(",")}set mouseEvents(e){e===null?this.removeAttribute("mouse-events"):this.setAttribute("mouse-events",e.join(","))}get reload(){return this.getAttribute("reload")}set reload(e){this.setAttribute("reload",e)}get emitIFrameMessages(){return this.hasAttribute("emit-iframe-messages")}set emitIFrameMessages(e){e?this.setAttribute("emit-iframe-messages",""):this.removeAttribute("emit-iframe-messages")}get actualAspectRatio(){return this.aspectRatio!=="auto"?Number(this.aspectRatio):!this.width||this.width<500?1:this.width<800?4/3:this.width<1200?16/9:21/9}onMessage(e){var s;if(this.emitIFrameMessages&&this.dispatchEvent(new CustomEvent("iframe-message",{detail:e.data})),e.source===((s=this.iframeElement)==null?void 0:s.contentWindow)){const i=e.data;if(this.log("debug","received message from child",i),Array.isArray(e.data)){if(l(i)&&(this.postMessageToChild(["df-parent","init",{id:this.id,debug:this.debug,resize:this.resize,syncParams:this.syncParams!==null,syncPath:this.syncPath!==null,stateChangeEvents:this.stateChangeEvents,mouseEvents:this.mouseEvents,src:this.currentChildSrc}]),this.childInitialized=!0),f(i)&&(this.resizedHeight=i[2],this.resize==="yes"&&!this.ready&&!this.readyMessage&&(this.ready=!0,this.dispatchEvent(new CustomEvent("ready"))),this.updateStyle()),S(i)&&this.reinitHeight==="on-message"&&(this.resizedHeight=void 0,this.updateStyle()),C(i)){if(this.currentChildSrc=i[3],this.parsedSyncParams||this.syncPath){const r=p(this.fullSrc,i[3],window.location.href,this.parsedSyncParams,this.syncPath);if(r===null)this.log("debug","failed to process newParentUrl, ignore state change");else if(r.href!==window.location.href){this.log("debug","apply state change to parent",i[2],r.href);try{this.adapter.stateChange(i[2],r,this)}catch(h){this.log("error","failed to apply state change to parent using custom adapter",h),this.windowAdapter.stateChange(i[2],r,this)}}}this.stateChangeEvents&&this.dispatchEvent(new CustomEvent("state-change",{detail:[i[2],i[3]]}))}if(M(i)&&this.dispatchEvent(new CustomEvent("message",{detail:i[2]})),P(i)&&this.dispatchEvent(new CustomEvent("notif",{detail:i[2]})),z(i)&&(this.ready=!0,this.dispatchEvent(new CustomEvent("ready")),this.updateStyle()),u(i)&&this.applySyncedMouseEvent(i),R(i)){const r=p(this.fullSrc,i[2],window.location.href,this.parsedSyncParams,this.syncPath);r&&(this.parentUrlListeners[i[2]]=r.href,this.postMessageToChild(["df-parent","parentUrl",i[2],r.href]))}L(i)&&delete this.parentUrlListeners[i[2]]}else W(i)&&this.dispatchEvent(new CustomEvent("notif",{detail:O(i.uiNotification)}))}}postMessageToChild(e){var s,i;this.log("debug","send message to child",e),(i=(s=this.iframeElement)==null?void 0:s.contentWindow)==null||i.postMessage(e,"*")}updateParsedSyncParams(){this.parsedSyncParams=this.syncParams!==null?U(this.syncParams||"*"):void 0}updateSrc(){if(!this.connected)return;for(const[s,i]of Object.entries(this.parentUrlListeners)){const r=p(this.fullSrc,s,window.location.href,this.parsedSyncParams,this.syncPath);r&&r.href!==i&&(this.parentUrlListeners[s]=r.href,this.postMessageToChild(["df-parent","parentUrl",s,r.href]))}const e=I(this.fullSrc,window.location.href,this.parsedSyncParams,this.syncPath);e&&e!==this.currentChildSrc&&(this.currentChildSrc=e,this.childInitialized?this.postMessageToChild(["df-parent","updateSrc",e]):(this.log("debug","set src attribute of iframe: "+e),this.iframeElement.setAttribute("src",e)))}updateStyle(){if(!this.connected)return;let e;this.resizedHeight?(this.log("debug","height of iframe based on resize message: "+this.resizedHeight),e=this.resizedHeight+"px"):this.height?(this.log("debug","height of iframe based on direct attribute: "+this.height),e=this.height):this.aspectRatio!==null&&(this.log("debug","height of iframe based on aspect ratio: "+this.aspectRatioHeight),e=this.aspectRatioHeight+"px"),e!==void 0?(this.log("debug","set height iframe wrapper: "+e),this.wrapperElement.style.cssText=`height:${e};min-height:0;`):this.wrapperElement.style.cssText="",this.scrolling?(this.log("debug","explicitly set of scrolling attribute of iframe: "+this.scrolling),this.iframeElement.setAttribute("scrolling",this.scrolling)):this.resize==="yes"||this.resize==="auto"&&this.resizedHeight?this.iframeElement.getAttribute("scrolling")!=="no"&&(this.log("debug","implicitly set scrolling attribute of iframe: no"),this.iframeElement.setAttribute("scrolling","no")):this.iframeElement.getAttribute("scrolling")!=="auto"&&(this.log("debug","implicitly set scrolling attribute of iframe: auto"),this.iframeElement.setAttribute("scrolling","auto")),this.ready&&this.iframeElement.getAttribute("style")!==""&&(this.log("debug","toggle loading slot and iframe visibility"),this.iframeElement.style.cssText="",this.slotElement.style.cssText="display:none;")}updateAspectRatioHeight(){this.width&&this.aspectRatio!==null&&(this.resizedHeight||this.height||(this.aspectRatioHeight=Math.ceil(this.width/this.actualAspectRatio),this.updateStyle()))}updateIframeExtraAttrs(){const e=this.iframeExtraAttrs,s={};for(const i of this.getAttributeNames())if(i.startsWith("iframe-")){const r=this.getAttribute(i);if(r!==null){const h=i.slice(7);s[h]=r}}this.log("debug","update iframe extra attributes",e,s);for(const i of Object.keys(e))i in s||this.iframeElement.removeAttribute(i);for(const i of Object.keys(s))s[i]!==e[i]&&this.iframeElement.setAttribute(i,s[i])}initMouseEvents(e){this.log("debug","initMouseEvents");for(const s of e)if(!this.mouseEventListeners[s]){const i=r=>{r instanceof MouseEvent&&this.transmitSyncedMouseEvent(["df-global","mouse",s,{altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}])};this.mouseEventListeners[s]=i,document.addEventListener(s,i,!0)}}transmitSyncedMouseEvent(e){this.currentSyncedMouseEvents.has(e[2])?this.currentSyncedMouseEvents.delete(e[2]):this.postMessageToChild(e)}applySyncedMouseEvent(e){this.currentSyncedMouseEvents.add(e[2]);const s=new MouseEvent(e[2],{bubbles:!0,cancelable:!0,view:window,...e[3]});this.dispatchEvent(s)}log(e,...s){e==="debug"&&!this.debug||(e==="debug"&&console.timeLog(`d-frame:${this.id}`,...s),e==="info"&&console.info(`d-frame:${this.id}`,...s),e==="error"&&console.error(`d-frame:${this.id}`,...s))}connectedCallback(){if(!this.debug){const e=window.localStorage.getItem("debug");if(e){const s=e.split(",");(s.includes("d-frame")||s.includes("d-frame:"+this.id))&&(this.debug=!0)}}if(this.debug&&console.time(`d-frame:${this.id}`),!this.hasAttribute("src"))throw new Error("src is a required attribute");this.log("debug","connected"),this.connected=!0,this.adapter.onStateChange&&(this.stopOnStateChange=this.adapter.onStateChange(()=>{this.updateSrc()})),this.width=this.getBoundingClientRect().width,this.updateAspectRatioHeight(),this.resizeObserver.observe(this),window.addEventListener("message",this.boundOnMessage),this.updateParsedSyncParams(),this.updateStyle(),this.updateIframeExtraAttrs(),this.updateSrc(),this.mouseEvents&&this.initMouseEvents(this.mouseEvents)}disconnectedCallback(){var e;this.log("debug","disconnected"),this.resizeObserver.disconnect(),window.removeEventListener("message",this.boundOnMessage),(e=this.stopOnStateChange)==null||e.call(this),this.stopOnStateChange=void 0;for(const[s,i]of Object.entries(this.mouseEventListeners))document.removeEventListener(s,i,!0),delete this.mouseEventListeners[s]}static get observedAttributes(){return["src","aspect-ratio","height","sync-params","sync-path","reload"]}attributeChangedCallback(e,s,i){var r;if(e==="aspect-ratio"&&this.updateAspectRatioHeight(),!!this.connected&&(this.log("debug","attribute change",e,s,i),e==="src"&&this.updateSrc(),e==="height"&&this.updateStyle(),e==="sync-params"&&(this.updateParsedSyncParams(),this.updateSrc()),e==="sync-path"&&this.updateSrc(),e==="reload")){if(!this.currentChildSrc){this.log("error","reload attribute changed but the iframe has no current src");return}if(!((r=this.iframeElement.contentWindow)!=null&&r.location)){this.log("debug","reload attribute changed but no iframe contentWindow, is this a cross domain iframe ?");return}if(!this.iframeLoaded){this.log("debug","reload attribute changed before initial loading was complete, ignore it");return}this.log("debug","reload iframe with current src",this.currentChildSrc),this.childInitialized=!1,this.iframeElement.setAttribute("src",this.currentChildSrc),this.iframeElement.contentWindow.location.reload()}}}customElements.get("d-frame")||customElements.define("d-frame",K)})();
19
19
  //# sourceMappingURL=d-frame.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d-frame.min.js","sources":["../lib/messages.js","../lib/utils/url.js","../lib/utils/sync-params.js","../lib/v-iframe-compat/ui-notif.js","../lib/DFrameElement.js","../lib/d-frame.js"],"sourcesContent":["export function isMouseEventMessage(message) {\n return message[0] === 'df-global' && message[1] === 'mouse';\n}\nexport function isInitChildMessage(message) {\n return message[0] === 'df-child' && message[1] === 'init';\n}\nexport function isHeightMessage(message) {\n return message[0] === 'df-child' && message[1] === 'height';\n}\nexport function isReinitHeightMessage(message) {\n return message[0] === 'df-child' && message[1] === 'reinit-height';\n}\nexport function isStateChangeMessage(message) {\n return message[0] === 'df-child' && message[1] === 'stateChange';\n}\nexport function isCustomMessage(message) {\n return message[0] === 'df-child' && message[1] === 'custom';\n}\nexport function isNotifMessage(message) {\n return message[0] === 'df-child' && message[1] === 'notif';\n}\nexport function isAddParentUrlListenerMessage(message) {\n return message[0] === 'df-child' && message[1] === 'addParentUrlListener';\n}\nexport function isRemoveParentUrlListenerMessage(message) {\n return message[0] === 'df-child' && message[1] === 'removeParentUrlListener';\n}\nexport function isReadyMessage(message) {\n return message[0] === 'df-child' && message[1] === 'ready';\n}\nexport function isInitParentMessage(message) {\n return message[0] === 'df-parent' && message[1] === 'init';\n}\nexport function isUpdateSrcMessage(message) {\n return message[0] === 'df-parent' && message[1] === 'updateSrc';\n}\nexport function isParentUrlMessage(message) {\n return message[0] === 'df-parent' && message[1] === 'parentUrl';\n}\n","export function getPathDirectory(path) {\n if (path.endsWith('/'))\n return path;\n if (path === '')\n return '/';\n return path.slice(0, path.lastIndexOf('/') + 1);\n}\nexport function getPathWithTrailingSlash(path) {\n if (path.endsWith('/'))\n return path;\n return path + '/';\n}\nexport function getUrlRelativePath(srcUrl, currentUrl) {\n if (currentUrl.origin !== srcUrl.origin)\n return currentUrl.href;\n if (getPathWithTrailingSlash(currentUrl.pathname) === getPathWithTrailingSlash(srcUrl.pathname))\n return '';\n const srcDirectory = getPathDirectory(srcUrl.pathname);\n if (!currentUrl.pathname.startsWith(srcDirectory))\n return currentUrl.pathname;\n return currentUrl.pathname.replace(srcDirectory, '');\n}\n","import { getUrlRelativePath } from './url.js';\nconst escapeRegExp = (str) => str.replace(/[-[\\]/{}()*+?.\\\\^$|]/g, '\\\\$&');\nexport function parseSyncParams(syncParamsStr) {\n const syncParams = [];\n for (const syncParam of syncParamsStr.split(',')) {\n const [pattern = '*', append] = syncParam.split(':');\n const regexpStr = '^' + escapeRegExp(pattern).replace(/\\\\\\*/g, '(.*)') + '$';\n syncParams.push({\n regexp: new RegExp(regexpStr),\n append\n });\n }\n return syncParams;\n}\nexport function getChildSrc(fullSrc, parentHref, syncParams, syncPath) {\n if (!syncParams && !syncPath)\n return fullSrc;\n const childUrl = new URL(fullSrc);\n const parentUrl = new URL(parentHref);\n if (syncParams) {\n parentUrl.searchParams.forEach((value, key) => {\n for (const syncParam of syncParams) {\n if (syncParam.append && !key.startsWith(syncParam.append))\n continue;\n if (key === syncPath)\n continue;\n const childKey = syncParam.append ? key.replace(syncParam.append, '') : key;\n if (!childKey.match(syncParam.regexp))\n continue;\n childUrl.searchParams.set(childKey, value);\n break;\n }\n });\n }\n if (syncPath !== null) {\n let path;\n if (syncPath === '#') {\n path = parentUrl.hash.slice(1);\n }\n else if (syncPath.startsWith('/')) {\n if (parentUrl.pathname.startsWith(syncPath) || (parentUrl.pathname + '/') === syncPath) {\n path = getUrlRelativePath(new URL(syncPath, parentHref), parentUrl);\n }\n else {\n return null;\n }\n }\n else {\n path = parentUrl.searchParams.get(syncPath);\n }\n if (path) {\n childUrl.pathname = new URL(path, fullSrc).pathname;\n }\n }\n return childUrl.href;\n}\nexport function getParentUrl(fullSrc, childHref, currentParentHref, syncParams, syncPath) {\n const srcUrl = new URL(fullSrc);\n const parentUrl = new URL(currentParentHref);\n const childUrl = new URL(childHref);\n if (syncParams) {\n // remove existing keys that were deleted from the child\n // use toArray instead of iterator as we mutate parentUrl in the loop\n for (const key of parentUrl.searchParams.keys().toArray()) {\n for (const syncParam of syncParams) {\n if (syncParam.append && !key.startsWith(syncParam.append))\n continue;\n const childKey = syncParam.append ? key.replace(syncParam.append, '') : key;\n if (!childKey.match(syncParam.regexp))\n continue;\n if (childUrl.searchParams.get(childKey) === null)\n parentUrl.searchParams.delete(key);\n break;\n }\n }\n // apply params from child to parent\n childUrl.searchParams.forEach((value, key) => {\n for (const syncParam of syncParams) {\n if (!key.match(syncParam.regexp))\n continue;\n if (srcUrl?.searchParams.get(key) === value)\n continue;\n const parentKey = syncParam.append ? (syncParam.append + key) : key;\n parentUrl.searchParams.set(parentKey, value);\n break;\n }\n });\n }\n if (syncPath !== null && srcUrl) {\n const path = getUrlRelativePath(srcUrl, childUrl);\n if (syncPath === '#') {\n parentUrl.hash = path;\n }\n else if (syncPath.startsWith('/')) {\n // a full path is not accepted, only a path child of the base\n if (path.startsWith('/'))\n return null;\n if (path === '')\n parentUrl.pathname = syncPath;\n else\n parentUrl.pathname = new URL(path, new URL(syncPath, currentParentHref)).pathname;\n }\n else {\n if (path)\n parentUrl.searchParams.set(syncPath, path);\n else\n parentUrl.searchParams.delete(syncPath);\n }\n }\n return parentUrl;\n}\n","export function isVIframeUiNotif(message) {\n return message.vIframe === true && message.uiNotification !== undefined;\n}\nexport function convertVIframeUiNotif(notif) {\n if (typeof notif === 'string')\n return { type: 'default', title: notif };\n if (notif.error && !notif.errorMsg) {\n const errorMsg = (notif.error.response && (notif.error.response.data || notif.error.response.status)) || notif.error.message || notif.error;\n if (notif.msg) {\n return {\n type: 'error',\n title: notif.msg,\n detail: errorMsg\n };\n }\n else {\n return {\n type: 'error',\n title: errorMsg\n };\n }\n }\n if (notif.type === 'error') {\n return {\n type: notif.clientError ? 'warning' : 'error',\n title: notif.msg,\n detail: notif.errorMsg\n };\n }\n return {\n type: notif.type ?? 'default',\n title: notif.msg\n };\n}\n","// this is a good doc about writing web components https://web.dev/articles/custom-elements-best-practices\nimport { isCustomMessage, isAddParentUrlListenerMessage, isRemoveParentUrlListenerMessage, isHeightMessage, isInitChildMessage, isMouseEventMessage, isNotifMessage, isReadyMessage, isStateChangeMessage, isReinitHeightMessage } from './messages.js';\nimport { parseSyncParams, getChildSrc, getParentUrl } from './utils/sync-params.js';\nimport { isVIframeUiNotif, convertVIframeUiNotif } from './v-iframe-compat/ui-notif.js';\nclass WindowStateChangeAdapter {\n stateChange(action, newUrl, element) {\n element.log('debug', 'apply state change on window.history', action, newUrl.href);\n if (action === 'replace')\n window.history.replaceState(window.history.state, '', newUrl);\n if (action === 'push')\n window.history.pushState(window.history.state, '', newUrl);\n }\n onStateChange(callback) {\n // this is only partial, for a full implementation we would have to monkeypatch window.history\n // I chose to do it in the child but not here\n // therefore support of dynamic changes performed through the history api requires an adapter\n // the idea being that the child makes itself wholly compatible with d-frame and changes its navigation logic to fit it\n // but the parent should be left as untouched as possible and uses d-frame as a black box (custom element)\n window.addEventListener('popstate', callback);\n return () => { window.removeEventListener('popstate', callback); };\n }\n}\n// we try to adapt to some of the conventions found out there\nconst cspNonceMeta = document.head?.querySelector('meta[property=csp-nonce]') ?? document.head?.querySelector('meta[name=csp-nonce]');\nconst cspNonce = cspNonceMeta?.nonce ?? cspNonceMeta?.content;\nconst template = document.createElement('template');\ntemplate.innerHTML = `<style${cspNonce ? ` nonce=\"${cspNonce}\"` : ''}>\n :host {\n display: block;\n }\n .d-frame-wrapper {\n height: 100%;\n }\n .d-frame-wrapper .loading-placeholder {\n min-height:150px;\n }\n iframe.d-frame-iframe {\n display: block;\n width: 100%;\n height: 100%;\n border: none;\n user-select: none;\n }\n</style><div class=\"d-frame-wrapper\"><slot name=\"loading\"><div class=\"loading-placeholder\"></div></slot><iframe class=\"d-frame-iframe\"></iframe></div>`;\nexport class DFrameElement extends HTMLElement {\n get id() { return this.getAttribute('id') ?? this.randomId; }\n set id(value) {\n this.setAttribute('id', value);\n }\n get debug() { return this.hasAttribute('debug'); }\n set debug(value) {\n if (value)\n this.setAttribute('debug', '');\n else\n this.removeAttribute('debug');\n }\n get src() { return this.getAttribute('src'); }\n set src(value) { this.setAttribute('src', value); }\n get fullSrc() { return this.src.startsWith('/') ? (window.location.origin + this.src) : this.src; }\n get scrolling() { return this.getAttribute('scrolling'); }\n set scrolling(value) { this.setAttribute('scrolling', value); }\n get aspectRatio() {\n const value = this.getAttribute('aspect-ratio');\n if (value === '')\n return 'auto';\n return value;\n }\n set aspectRatio(value) {\n if (value !== null)\n this.setAttribute('aspect-ratio', value);\n else\n this.removeAttribute('aspect-ratio');\n }\n get height() { return this.getAttribute('height'); }\n set height(value) {\n if (value)\n this.setAttribute('height', value);\n else\n this.removeAttribute('height');\n }\n set resize(value) { this.setAttribute('resize', value); }\n get resize() {\n const value = this.getAttribute('resize');\n if (value === null)\n return 'auto';\n if (value === '')\n return 'yes';\n return value;\n }\n set reinitHeight(value) { this.setAttribute('reinit-height', value); }\n get reinitHeight() {\n const value = this.getAttribute('reinit-height');\n if (value === null || value === '')\n return 'on-message';\n return value;\n }\n get syncParams() { return this.getAttribute('sync-params'); }\n set syncParams(value) {\n if (value !== null)\n this.setAttribute('sync-params', value);\n else\n this.removeAttribute('sync-params');\n }\n get syncPath() {\n const value = this.getAttribute('sync-path');\n if (value === null)\n return null;\n return value || 'p';\n }\n set syncPath(value) {\n if (value !== null)\n this.setAttribute('sync-params', value);\n else\n this.removeAttribute('sync-params');\n }\n get stateChangeEvents() { return this.hasAttribute('state-change-events'); }\n set stateChangeEvents(value) {\n if (value)\n this.setAttribute('state-change-events', '');\n else\n this.removeAttribute('state-change-events');\n }\n get readyMessage() { return this.hasAttribute('ready-message'); }\n set readyMessage(value) {\n if (value)\n this.setAttribute('ready-message', '');\n else\n this.removeAttribute('ready-message');\n }\n get mouseEvents() {\n const attr = this.getAttribute('mouse-events');\n if (attr === null)\n return null;\n if (attr === '')\n return ['click', 'dblclick', 'mousedown', 'mouseup'];\n return attr.split(',');\n }\n set mouseEvents(value) {\n if (value === null)\n this.removeAttribute('mouse-events');\n else\n this.setAttribute('mouse-events', value.join(','));\n }\n get reload() { return this.getAttribute('reload'); }\n set reload(value) { this.setAttribute('reload', value); }\n get emitIFrameMessages() { return this.hasAttribute('emit-iframe-messages'); }\n set emitIFrameMessages(value) {\n if (value)\n this.setAttribute('emit-iframe-messages', '');\n else\n this.removeAttribute('emit-iframe-messages');\n }\n adapter;\n windowAdapter;\n /* internal state */\n connected = false;\n childInitialized = false;\n currentChildSrc = null;\n parsedSyncParams;\n wrapperElement;\n slotElement;\n iframeElement;\n width;\n aspectRatioHeight;\n resizedHeight;\n randomId;\n iframeLoaded = false;\n ready = false;\n iframeExtraAttrs = {};\n resizeObserver;\n boundOnMessage = (e) => this.onMessage(e);\n mouseEventListeners = {};\n stopOnStateChange;\n parentUrlListeners = {};\n get actualAspectRatio() {\n if (this.aspectRatio !== 'auto')\n return Number(this.aspectRatio);\n if (!this.width || this.width < 500)\n return 1;\n if (this.width < 800)\n return 4 / 3;\n if (this.width < 1200)\n return 16 / 9;\n return 21 / 9;\n }\n constructor() {\n super();\n this.randomId = Math.random().toString(36).slice(-6);\n const root = template.content.cloneNode(true);\n this.wrapperElement = root.childNodes[1];\n this.slotElement = this.wrapperElement.childNodes[0];\n this.iframeElement = this.wrapperElement.childNodes[1];\n this.iframeElement.style.cssText = 'visibility:hidden;position:absolute;height:0px;';\n this.iframeElement.addEventListener('load', () => {\n if (this.iframeElement.getAttribute('src')) {\n this.log('debug', 'iframe loaded');\n this.iframeLoaded = true;\n this.dispatchEvent(new CustomEvent('iframe-load'));\n if (this.resize !== 'yes' && !this.readyMessage) {\n this.ready = true;\n this.dispatchEvent(new CustomEvent('ready'));\n this.updateStyle();\n }\n }\n });\n const shadowRoot = this.attachShadow({ mode: 'open' });\n shadowRoot.appendChild(root);\n this.resizeObserver = new ResizeObserver((entries) => {\n // make this callback insensitive to micro changes\n if (this.width === undefined || Math.abs(this.width - entries[0].contentRect.width) > 2) {\n this.width = entries[0].contentRect.width;\n this.updateAspectRatioHeight();\n }\n });\n this.adapter = this.windowAdapter = new WindowStateChangeAdapter();\n }\n onMessage(e) {\n if (this.emitIFrameMessages) {\n this.dispatchEvent(new CustomEvent('iframe-message', { detail: e.data }));\n }\n if (e.source === this.iframeElement?.contentWindow) {\n const message = e.data;\n this.log('debug', 'received message from child', message);\n if (Array.isArray(e.data)) {\n if (isInitChildMessage(message)) {\n // simple handshake for initialization\n this.postMessageToChild(['df-parent', 'init', {\n id: this.id,\n debug: this.debug,\n resize: this.resize,\n syncParams: this.syncParams !== null,\n syncPath: this.syncPath !== null,\n stateChangeEvents: this.stateChangeEvents,\n mouseEvents: this.mouseEvents,\n src: this.currentChildSrc\n }]);\n this.childInitialized = true;\n }\n if (isHeightMessage(message)) {\n this.resizedHeight = message[2];\n if (this.resize === 'yes' && !this.ready && !this.readyMessage) {\n this.ready = true;\n this.dispatchEvent(new CustomEvent('ready'));\n }\n this.updateStyle();\n }\n if (isReinitHeightMessage(message) && this.reinitHeight === 'on-message') {\n this.resizedHeight = undefined;\n this.updateStyle();\n }\n if (isStateChangeMessage(message)) {\n this.currentChildSrc = message[3];\n if ((this.parsedSyncParams || this.syncPath)) {\n const newParentUrl = getParentUrl(this.fullSrc, message[3], window.location.href, this.parsedSyncParams, this.syncPath);\n if (newParentUrl === null) {\n this.log('debug', 'failed to process newParentUrl, ignore state change');\n }\n else {\n if (newParentUrl.href !== window.location.href) {\n this.log('debug', 'apply state change to parent', message[2], newParentUrl.href);\n try {\n this.adapter.stateChange(message[2], newParentUrl, this);\n }\n catch (err) {\n this.log('error', 'failed to apply state change to parent using custom adapter', err);\n this.windowAdapter.stateChange(message[2], newParentUrl, this);\n }\n }\n }\n }\n if (this.stateChangeEvents) {\n this.dispatchEvent(new CustomEvent('state-change', { detail: [message[2], message[3]] }));\n }\n }\n if (isCustomMessage(message)) {\n this.dispatchEvent(new CustomEvent('message', { detail: message[2] }));\n }\n if (isNotifMessage(message)) {\n this.dispatchEvent(new CustomEvent('notif', { detail: message[2] }));\n }\n if (isReadyMessage(message)) {\n this.ready = true;\n this.dispatchEvent(new CustomEvent('ready'));\n this.updateStyle();\n }\n if (isMouseEventMessage(message)) {\n this.applySyncedMouseEvent(message);\n }\n if (isAddParentUrlListenerMessage(message)) {\n const parentUrl = getParentUrl(this.fullSrc, message[2], window.location.href, this.parsedSyncParams, this.syncPath);\n if (parentUrl) {\n this.parentUrlListeners[message[2]] = parentUrl.href;\n this.postMessageToChild(['df-parent', 'parentUrl', message[2], parentUrl.href]);\n }\n }\n if (isRemoveParentUrlListenerMessage(message)) {\n delete this.parentUrlListeners[message[2]];\n }\n }\n else if (isVIframeUiNotif(message)) {\n // maintain compatibility with v-iframe notifications sent through postMessage\n this.dispatchEvent(new CustomEvent('notif', { detail: convertVIframeUiNotif(message.uiNotification) }));\n }\n }\n }\n postMessageToChild(message) {\n this.log('debug', 'send message to child', message);\n this.iframeElement?.contentWindow?.postMessage(message, '*');\n }\n updateParsedSyncParams() {\n this.parsedSyncParams = this.syncParams !== null ? parseSyncParams(this.syncParams || '*') : undefined;\n }\n updateSrc() {\n if (!this.connected)\n return;\n for (const [childHref, existingParentUrl] of Object.entries(this.parentUrlListeners)) {\n const parentUrl = getParentUrl(this.fullSrc, childHref, window.location.href, this.parsedSyncParams, this.syncPath);\n if (parentUrl) {\n if (parentUrl.href !== existingParentUrl) {\n this.parentUrlListeners[childHref] = parentUrl.href;\n this.postMessageToChild(['df-parent', 'parentUrl', childHref, parentUrl.href]);\n }\n }\n }\n const iframeSrc = getChildSrc(this.fullSrc, window.location.href, this.parsedSyncParams, this.syncPath);\n if (!iframeSrc)\n return;\n if (iframeSrc === this.currentChildSrc)\n return;\n this.currentChildSrc = iframeSrc;\n if (this.childInitialized) {\n this.postMessageToChild(['df-parent', 'updateSrc', iframeSrc]);\n }\n else {\n this.log('debug', 'set src attribute of iframe: ' + iframeSrc);\n this.iframeElement.setAttribute('src', iframeSrc);\n }\n }\n updateStyle() {\n if (!this.connected)\n return;\n // manage height of iframe wrapper\n let wrapperHeight;\n if (this.resizedHeight) {\n this.log('debug', 'height of iframe based on resize message: ' + this.resizedHeight);\n wrapperHeight = this.resizedHeight + 'px';\n }\n else {\n if (this.height) {\n this.log('debug', 'height of iframe based on direct attribute: ' + this.height);\n wrapperHeight = this.height;\n }\n else if (this.aspectRatio !== null) {\n this.log('debug', 'height of iframe based on aspect ratio: ' + this.aspectRatioHeight);\n wrapperHeight = this.aspectRatioHeight + 'px';\n }\n }\n if (wrapperHeight !== undefined) {\n this.log('debug', 'set height iframe wrapper: ' + wrapperHeight);\n this.wrapperElement.style.cssText = `height:${wrapperHeight};min-height:0;`;\n }\n else {\n this.wrapperElement.style.cssText = '';\n }\n // set scrolling attribute of iframe\n if (this.scrolling) {\n this.log('debug', 'explicitly set of scrolling attribute of iframe: ' + this.scrolling);\n this.iframeElement.setAttribute('scrolling', this.scrolling);\n }\n else {\n if (this.resize === 'yes' || (this.resize === 'auto' && this.resizedHeight)) {\n if (this.iframeElement.getAttribute('scrolling') !== 'no') {\n this.log('debug', 'implicitly set scrolling attribute of iframe: no');\n this.iframeElement.setAttribute('scrolling', 'no');\n }\n }\n else {\n if (this.iframeElement.getAttribute('scrolling') !== 'auto') {\n this.log('debug', 'implicitly set scrolling attribute of iframe: auto');\n this.iframeElement.setAttribute('scrolling', 'auto');\n }\n }\n }\n // toggle loading slot vs iframe visibility\n if (this.ready && this.iframeElement.getAttribute('style') !== '') {\n this.log('debug', 'toggle loading slot and iframe visibility');\n this.iframeElement.style.cssText = '';\n this.slotElement.style.cssText = 'display:none;';\n }\n }\n updateAspectRatioHeight() {\n if (!this.width)\n return;\n if (this.aspectRatio === null)\n return;\n if (this.resizedHeight)\n return;\n if (this.height)\n return;\n this.aspectRatioHeight = Math.ceil(this.width / this.actualAspectRatio);\n this.updateStyle();\n }\n updateIframeExtraAttrs() {\n const previousAttrs = this.iframeExtraAttrs;\n const newAttrs = {};\n for (const name of this.getAttributeNames()) {\n if (name.startsWith('iframe-')) {\n const value = this.getAttribute(name);\n if (value !== null) {\n const attrName = name.slice(7);\n newAttrs[attrName] = value;\n }\n }\n }\n this.log('debug', 'update iframe extra attributes', previousAttrs, newAttrs);\n for (const key of Object.keys(previousAttrs)) {\n if (!(key in newAttrs)) {\n this.iframeElement.removeAttribute(key);\n }\n }\n for (const key of Object.keys(newAttrs)) {\n if (newAttrs[key] !== previousAttrs[key]) {\n this.iframeElement.setAttribute(key, newAttrs[key]);\n }\n }\n }\n currentSyncedMouseEvents = new Set();\n initMouseEvents(types) {\n this.log('debug', 'initMouseEvents');\n for (const eventType of types) {\n if (!this.mouseEventListeners[eventType]) {\n const listener = (e) => {\n if (!(e instanceof MouseEvent))\n return;\n this.transmitSyncedMouseEvent(['df-global', 'mouse', eventType, { altKey: e.altKey, ctrlKey: e.ctrlKey, shiftKey: e.shiftKey, metaKey: e.metaKey }]);\n };\n this.mouseEventListeners[eventType] = listener;\n document.addEventListener(eventType, listener, true);\n }\n }\n }\n transmitSyncedMouseEvent(message) {\n if (this.currentSyncedMouseEvents.has(message[2])) {\n this.currentSyncedMouseEvents.delete(message[2]);\n }\n else {\n this.postMessageToChild(message);\n }\n }\n applySyncedMouseEvent(message) {\n this.currentSyncedMouseEvents.add(message[2]);\n const event = new MouseEvent(message[2], { bubbles: true, cancelable: true, view: window, ...message[3] });\n this.dispatchEvent(event);\n }\n log(level, ...args) {\n if (level === 'debug' && !this.debug)\n return;\n if (level === 'debug')\n console.timeLog(`d-frame:${this.id}`, ...args);\n if (level === 'info')\n console.info(`d-frame:${this.id}`, ...args);\n if (level === 'error')\n console.error(`d-frame:${this.id}`, ...args);\n }\n /* standard custom element callbacks */\n connectedCallback() {\n if (!this.debug) {\n const globalDebug = window.localStorage.getItem('debug');\n if (globalDebug) {\n const debugParts = globalDebug.split(',');\n if (debugParts.includes('d-frame') || debugParts.includes('d-frame:' + this.id))\n this.debug = true;\n }\n }\n if (this.debug)\n console.time(`d-frame:${this.id}`);\n if (!this.hasAttribute('src'))\n throw new Error('src is a required attribute');\n this.log('debug', 'connected');\n this.connected = true;\n if (this.adapter.onStateChange) {\n this.stopOnStateChange = this.adapter.onStateChange(() => { this.updateSrc(); });\n }\n // measure synchronously: the observer only fires after the next layout, and the frame\n // would be painted at the height of its loading slot in between\n this.width = this.getBoundingClientRect().width;\n this.updateAspectRatioHeight();\n this.resizeObserver.observe(this);\n window.addEventListener('message', this.boundOnMessage);\n this.updateParsedSyncParams();\n this.updateStyle();\n this.updateIframeExtraAttrs();\n this.updateSrc();\n if (this.mouseEvents)\n this.initMouseEvents(this.mouseEvents);\n }\n disconnectedCallback() {\n this.log('debug', 'disconnected');\n this.resizeObserver.disconnect();\n window.removeEventListener('message', this.boundOnMessage);\n this.stopOnStateChange?.();\n this.stopOnStateChange = undefined;\n for (const [eventType, listener] of Object.entries(this.mouseEventListeners)) {\n document.removeEventListener(eventType, listener, true);\n delete this.mouseEventListeners[eventType];\n }\n }\n /* reflected attributes */\n static get observedAttributes() { return ['src', 'aspect-ratio', 'height', 'sync-params', 'sync-path', 'reload']; }\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === 'aspect-ratio')\n this.updateAspectRatioHeight();\n // if (name.startsWith('iframe-')) this.updateIframeExtraAttrs()\n if (!this.connected)\n return;\n this.log('debug', 'attribute change', name, oldValue, newValue);\n if (name === 'src')\n this.updateSrc();\n if (name === 'height')\n this.updateStyle();\n if (name === 'sync-params') {\n this.updateParsedSyncParams();\n this.updateSrc();\n }\n if (name === 'sync-path')\n this.updateSrc();\n if (name === 'reload') {\n if (!this.currentChildSrc) {\n this.log('error', 'reload attribute changed but the iframe has no current src');\n return;\n }\n if (!this.iframeElement.contentWindow?.location) {\n this.log('debug', 'reload attribute changed but no iframe contentWindow, is this a cross domain iframe ?');\n return;\n }\n if (!this.iframeLoaded) {\n this.log('debug', 'reload attribute changed before initial loading was complete, ignore it');\n return;\n }\n this.log('debug', 'reload iframe with current src', this.currentChildSrc);\n this.childInitialized = false;\n this.iframeElement.setAttribute('src', this.currentChildSrc);\n this.iframeElement.contentWindow.location.reload();\n }\n }\n}\nexport default DFrameElement;\n","import DFrameElement from './DFrameElement.js';\nif (!customElements.get('d-frame')) {\n customElements.define('d-frame', DFrameElement);\n}\n"],"names":["isMouseEventMessage","message","isInitChildMessage","isHeightMessage","isReinitHeightMessage","isStateChangeMessage","isCustomMessage","isNotifMessage","isAddParentUrlListenerMessage","isRemoveParentUrlListenerMessage","isReadyMessage","getPathDirectory","path","getPathWithTrailingSlash","getUrlRelativePath","srcUrl","currentUrl","srcDirectory","escapeRegExp","str","parseSyncParams","syncParamsStr","syncParams","syncParam","pattern","append","regexpStr","getChildSrc","fullSrc","parentHref","syncPath","childUrl","parentUrl","value","key","childKey","getParentUrl","childHref","currentParentHref","parentKey","isVIframeUiNotif","convertVIframeUiNotif","notif","errorMsg","WindowStateChangeAdapter","action","newUrl","element","callback","cspNonceMeta","_a","_b","cspNonce","template","DFrameElement","__publicField","root","entries","attr","newParentUrl","err","existingParentUrl","iframeSrc","wrapperHeight","previousAttrs","newAttrs","name","attrName","types","eventType","listener","e","event","level","args","globalDebug","debugParts","oldValue","newValue"],"mappings":"qMAAO,SAASA,EAAoBC,EAAS,CACzC,OAAOA,EAAQ,CAAC,IAAM,aAAeA,EAAQ,CAAC,IAAM,OACxD,CACO,SAASC,EAAmBD,EAAS,CACxC,OAAOA,EAAQ,CAAC,IAAM,YAAcA,EAAQ,CAAC,IAAM,MACvD,CACO,SAASE,EAAgBF,EAAS,CACrC,OAAOA,EAAQ,CAAC,IAAM,YAAcA,EAAQ,CAAC,IAAM,QACvD,CACO,SAASG,EAAsBH,EAAS,CAC3C,OAAOA,EAAQ,CAAC,IAAM,YAAcA,EAAQ,CAAC,IAAM,eACvD,CACO,SAASI,EAAqBJ,EAAS,CAC1C,OAAOA,EAAQ,CAAC,IAAM,YAAcA,EAAQ,CAAC,IAAM,aACvD,CACO,SAASK,EAAgBL,EAAS,CACrC,OAAOA,EAAQ,CAAC,IAAM,YAAcA,EAAQ,CAAC,IAAM,QACvD,CACO,SAASM,EAAeN,EAAS,CACpC,OAAOA,EAAQ,CAAC,IAAM,YAAcA,EAAQ,CAAC,IAAM,OACvD,CACO,SAASO,EAA8BP,EAAS,CACnD,OAAOA,EAAQ,CAAC,IAAM,YAAcA,EAAQ,CAAC,IAAM,sBACvD,CACO,SAASQ,EAAiCR,EAAS,CACtD,OAAOA,EAAQ,CAAC,IAAM,YAAcA,EAAQ,CAAC,IAAM,yBACvD,CACO,SAASS,EAAeT,EAAS,C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CAAC,KAAK,gBAAiB,CACvB,KAAK,IAAI,QAAS,4DAA4D,EAC9E,MAChB,CACY,GAAI,GAAChB,EAAA,KAAK,cAAc,gBAAnB,MAAAA,EAAkC,UAAU,CAC7C,KAAK,IAAI,QAAS,uFAAuF,EACzG,MAChB,CACY,GAAI,CAAC,KAAK,aAAc,CACpB,KAAK,IAAI,QAAS,yEAAyE,EAC3F,MAChB,CACY,KAAK,IAAI,QAAS,iCAAkC,KAAK,eAAe,EACxE,KAAK,iBAAmB,GACxB,KAAK,cAAc,aAAa,MAAO,KAAK,eAAe,EAC3D,KAAK,cAAc,cAAc,SAAS,OAAQ,CAC9D,CACA,CACA,CChiBK,eAAe,IAAI,SAAS,GAC7B,eAAe,OAAO,UAAWI,CAAa"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d-frame-content.min.js","sources":["../../lib/messages.js","../../lib/utils/in-iframe.js","../../lib/DFrameContent.js","../../lib/vue-reactive/util.js","../../lib/v-iframe-compat/d-frame-content.js"],"sourcesContent":["export function isMouseEventMessage(message) {\n return message[0] === 'df-global' && message[1] === 'mouse';\n}\nexport function isInitChildMessage(message) {\n return message[0] === 'df-child' && message[1] === 'init';\n}\nexport function isHeightMessage(message) {\n return message[0] === 'df-child' && message[1] === 'height';\n}\nexport function isReinitHeightMessage(message) {\n return message[0] === 'df-child' && message[1] === 'reinit-height';\n}\nexport function isStateChangeMessage(message) {\n return message[0] === 'df-child' && message[1] === 'stateChange';\n}\nexport function isCustomMessage(message) {\n return message[0] === 'df-child' && message[1] === 'custom';\n}\nexport function isNotifMessage(message) {\n return message[0] === 'df-child' && message[1] === 'notif';\n}\nexport function isAddParentUrlListenerMessage(message) {\n return message[0] === 'df-child' && message[1] === 'addParentUrlListener';\n}\nexport function isRemoveParentUrlListenerMessage(message) {\n return message[0] === 'df-child' && message[1] === 'removeParentUrlListener';\n}\nexport function isReadyMessage(message) {\n return message[0] === 'df-child' && message[1] === 'ready';\n}\nexport function isInitParentMessage(message) {\n return message[0] === 'df-parent' && message[1] === 'init';\n}\nexport function isUpdateSrcMessage(message) {\n return message[0] === 'df-parent' && message[1] === 'updateSrc';\n}\nexport function isParentUrlMessage(message) {\n return message[0] === 'df-parent' && message[1] === 'parentUrl';\n}\n","const inIframe = (() => {\n try {\n return window.top !== window.self;\n }\n catch (e) {\n return true;\n }\n})();\nexport default inIframe;\n","import { isInitParentMessage, isMouseEventMessage, isUpdateSrcMessage, isParentUrlMessage } from './messages.js';\nimport inIframe from './utils/in-iframe.js';\nconst windowEventTypes = [\n 'animationstart',\n 'webkitAnimationStart',\n 'animationiteration',\n 'webkitAnimationIteration',\n 'animationend',\n 'webkitAnimationEnd',\n 'input',\n 'mouseup',\n 'mousedown',\n 'orientationchange',\n 'afterprint',\n 'beforeprint',\n 'readystatechange',\n 'touchstart',\n 'touchend',\n 'touchcancel',\n 'transitionstart',\n 'webkitTransitionStart',\n 'MSTransitionStart',\n 'oTransitionStart',\n 'otransitionstart', 'transitioniteration',\n 'webkitTransitionIteration',\n 'MSTransitionIteration',\n 'oTransitionIteration',\n 'otransitioniteration', 'transitionend',\n 'webkitTransitionEnd',\n 'MSTransitionEnd',\n 'oTransitionEnd',\n 'otransitionend', 'resize'\n];\nexport default class DFrameContent {\n initialized = false;\n options;\n pendingCheckHeight = false;\n debug = false;\n id;\n throttledCheckHeight;\n lastHeight = 0;\n parentUrlListeners = {};\n parentUrlResults = {};\n constructor(options) {\n this.options = options ?? {};\n if (typeof window === 'undefined')\n return;\n if (window.__d_frame__content) {\n throw new Error('DFrameContent was already initialized');\n }\n window.__d_frame__content = this;\n const afCallback = () => {\n this.checkHeight();\n this.pendingCheckHeight = false;\n };\n this.throttledCheckHeight = () => {\n if (this.pendingCheckHeight)\n return;\n this.pendingCheckHeight = true;\n requestAnimationFrame(afCallback);\n };\n window.addEventListener('message', (e) => this.onMessage(e));\n // simple handshake for initialization\n this.postMessageToParent(['df-child', 'init']);\n }\n log(level, ...args) {\n if (level === 'debug' && !this.debug)\n return;\n if (level === 'debug')\n console.timeLog(`d-frame:${this.id}:content`, ...args);\n if (level === 'info')\n console.info(`d-frame:${this.id}:content`, ...args);\n if (level === 'error')\n console.error(`d-frame:${this.id}:content`, ...args);\n }\n onMessage(e) {\n if (e.source === window.parent && Array.isArray(e.data)) {\n const message = e.data;\n if (isInitParentMessage(message)) {\n this.id = message[2].id;\n this.debug = !!message[2].debug;\n if (this.debug)\n console.time(`d-frame:${this.id}:content`);\n this.log('debug', 'init handshake is ok', message, this.options);\n if (message[2].src && message[2].src !== window.location.href) {\n this.log('error', `src mismatch at init, maybe the frame navigated before the initialization handshake: ${window.location.href} !== ${message[2].src}`);\n }\n if (message[2].resize !== 'no')\n this.initResize();\n if (message[2].syncParams || message[2].syncPath || message[2].stateChangeEvents)\n this.initStateChangeWatcher();\n if (message[2].mouseEvents)\n this.initMouseEvents(message[2].mouseEvents);\n this.initialized = true;\n }\n if (isUpdateSrcMessage(message)) {\n const newSrc = message[2].startsWith('/') ? window.location.origin + message[2] : message[2];\n if (newSrc === window.location.href)\n return;\n this.log('debug', `update src ${window.location.href} -> ${newSrc}`);\n if (this.options.updateSrc) {\n this.options.updateSrc(newSrc, this);\n }\n else {\n this.log('debug', 'no updateSrc method available, falling back to updating window.location.href', newSrc);\n window.location.href = newSrc;\n }\n }\n if (isMouseEventMessage(message)) {\n this.applySyncedMouseEvent(message);\n }\n if (isParentUrlMessage(message)) {\n if (!this.parentUrlListeners[message[2]]) {\n this.log('error', `received getParentUrlResponse message but no matching callback is registered: ${message[2]}`);\n }\n else {\n for (const listener of this.parentUrlListeners[message[2]]) {\n listener(message[3]);\n }\n }\n }\n }\n }\n postMessageToParent(message) {\n window.parent.postMessage(message, '*');\n }\n sendNotif(notif) {\n this.postMessageToParent(['df-child', 'notif', notif]);\n }\n sendMessage(msg) {\n this.postMessageToParent(['df-child', 'custom', msg]);\n }\n ready() {\n this.postMessageToParent(['df-child', 'ready']);\n }\n reinitHeight() {\n this.postMessageToParent(['df-child', 'reinit-height']);\n }\n // this is not a single-time callback, it can be called multiple times when parent url changes\n addParentUrlListener(partialChildHref, listener) {\n const childHref = new URL(partialChildHref, window.location.href).href;\n if (!inIframe) {\n listener(childHref);\n return;\n }\n if (this.parentUrlResults[childHref]) {\n listener(this.parentUrlResults[childHref]);\n }\n this.parentUrlListeners[childHref] = this.parentUrlListeners[childHref] ?? [];\n this.parentUrlListeners[childHref].push(listener);\n this.postMessageToParent(['df-child', 'addParentUrlListener', childHref]);\n }\n removeParentUrlListener(partialChildHref, listener) {\n const childHref = new URL(partialChildHref, window.location.href).href;\n if (this.parentUrlListeners[childHref]) {\n this.parentUrlListeners[childHref] = this.parentUrlListeners[childHref].filter(cb => cb !== listener);\n if (!this.parentUrlListeners[childHref].length) {\n delete this.parentUrlListeners[childHref];\n this.postMessageToParent(['df-child', 'removeParentUrlListener', childHref]);\n }\n }\n }\n currentSyncedMouseEvents = new Set();\n initMouseEvents(types) {\n this.log('debug', 'initMouseEvents');\n for (const eventType of types) {\n document.addEventListener(eventType, (e) => {\n if (!(e instanceof MouseEvent))\n return;\n this.transmitSyncedMouseEvent(['df-global', 'mouse', eventType, { altKey: e.altKey, ctrlKey: e.ctrlKey, shiftKey: e.shiftKey, metaKey: e.metaKey }]);\n }, true);\n }\n }\n transmitSyncedMouseEvent(message) {\n if (this.currentSyncedMouseEvents.has(message[2])) {\n this.currentSyncedMouseEvents.delete(message[2]);\n }\n else {\n this.postMessageToParent(message);\n }\n }\n applySyncedMouseEvent(message) {\n this.currentSyncedMouseEvents.add(message[2]);\n const event = new MouseEvent(message[2], { bubbles: true, cancelable: true, view: window, ...message[3] });\n document.body.dispatchEvent(event);\n }\n initResize() {\n this.log('debug', 'initResize');\n this.checkHeight();\n this.createMutationObserver();\n this.createWindowEventListeners();\n }\n initStateChangeWatcher() {\n this.log('debug', 'initStateChangeWatcher');\n // monkey patch pushState and replaceState to send all state change info to the parent window\n // this is to compensate the lack of event emission by window.history\n const oldReplaceState = window.history.replaceState;\n const newPushState = (...args) => {\n const before = window.location.href;\n // do a replace instead of a push, the push will be done in the parent window if sync-state is activated\n const ret = oldReplaceState.apply(window.history, args);\n if (window.location.href !== before) {\n this.postMessageToParent(['df-child', 'stateChange', 'push', window.location.href]);\n }\n return ret;\n };\n window.history.pushState = newPushState;\n const newReplaceState = (...args) => {\n const before = window.location.href;\n const ret = oldReplaceState.apply(window.history, args);\n if (window.location.href !== before) {\n this.postMessageToParent(['df-child', 'stateChange', 'replace', window.location.href]);\n }\n return ret;\n };\n window.history.replaceState = newReplaceState;\n }\n createMutationObserver() {\n const body = document.querySelector('body');\n if (!body)\n throw new Error('DFrameContentManager was initialized before the HTML body');\n if (!this.throttledCheckHeight)\n throw new Error('throttledCheckHeight is not defined');\n const observer = new window.MutationObserver(this.throttledCheckHeight);\n observer.observe(body, {\n attributes: false,\n attributeOldValue: false,\n characterData: false,\n characterDataOldValue: false,\n childList: true,\n subtree: true,\n });\n }\n createWindowEventListeners() {\n if (!this.throttledCheckHeight)\n throw new Error('throttledCheckHeight is not defined');\n for (const eventType of windowEventTypes) {\n window.addEventListener(eventType, this.throttledCheckHeight, { passive: true });\n }\n }\n checkHeight() {\n const elements = document.querySelectorAll('[data-iframe-height]');\n let maxWithoutOffset = 0;\n let max = 0;\n for (const element of elements) {\n const dataAttribute = element.getAttribute('data-iframe-height');\n if (dataAttribute === 'false' || dataAttribute === 'no')\n continue;\n const bottomWithoutOffset = element.getBoundingClientRect().bottom +\n parseFloat(getComputedStyle(element).getPropertyValue('margin-bottom'));\n const bottom = dataAttribute ? (bottomWithoutOffset + parseFloat(dataAttribute)) : bottomWithoutOffset;\n if (bottomWithoutOffset > maxWithoutOffset)\n maxWithoutOffset = bottomWithoutOffset;\n if (bottom > max)\n max = bottom;\n }\n max = Math.ceil(max);\n if (maxWithoutOffset > 0 && max !== this.lastHeight) {\n this.postMessageToParent(['df-child', 'height', max]);\n this.lastHeight = max;\n }\n }\n}\n","export const applySearchParams = (reactiveParams, searchParams) => {\n const existingKeys = Object.keys(reactiveParams);\n searchParams.forEach((value, key) => {\n reactiveParams[key] = value;\n existingKeys.splice(existingKeys.indexOf(key), 1);\n });\n existingKeys.forEach(key => {\n delete reactiveParams[key];\n });\n};\n","import DFrameContent from '../DFrameContent.js';\nimport { applySearchParams } from '../vue-reactive/util.js';\nconst dFrameContent = new DFrameContent({\n updateSrc(src, instance) {\n const vIframeOptions = window.vIframeOptions;\n const reactiveParams = vIframeOptions?.reactiveParams;\n if (reactiveParams && typeof reactiveParams === 'object') {\n const srcUrl = new URL(src);\n if (srcUrl.origin === window.location.origin && srcUrl.pathname === window.location.pathname) {\n instance.log('debug', 'applying reactive params', srcUrl.searchParams);\n applySearchParams(reactiveParams, srcUrl.searchParams);\n return;\n }\n }\n const router = vIframeOptions?.router;\n if (router) {\n // @ts-ignore vue-router v2\n const base = router.options?.base ?? router.options.history?.base;\n if (base === null || base === undefined) {\n instance.log('error', 'failed to access base path in router (no router.options.base nor router.options.history.base)', router);\n }\n else {\n const urlPrefix = window.location.origin + base;\n if (!src.startsWith(urlPrefix)) {\n instance.log('info', 'src does not start with base path', src, urlPrefix);\n }\n else {\n let newRoute = src.replace(urlPrefix, '');\n if (!newRoute.startsWith('/'))\n newRoute = '/' + newRoute;\n instance.log('debug', 'applying router.replace', newRoute);\n router.replace(newRoute);\n return;\n }\n }\n }\n instance.log('info', 'falling back to updating window.location.href', src);\n window.location.href = src;\n }\n});\nwindow.dFrameContent = dFrameContent;\nexport default dFrameContent;\n"],"names":["isMouseEventMessage","message","isInitParentMessage","isUpdateSrcMessage","isParentUrlMessage","inIframe","windowEventTypes","DFrameContent","options","__publicField","afCallback","e","level","args","newSrc","listener","notif","msg","partialChildHref","childHref","cb","types","eventType","event","oldReplaceState","newPushState","before","ret","newReplaceState","body","elements","maxWithoutOffset","max","element","dataAttribute","bottomWithoutOffset","bottom","applySearchParams","reactiveParams","searchParams","existingKeys","value","key","dFrameContent","src","instance","vIframeOptions","srcUrl","router","base","_a","_b","urlPrefix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H,CACD,MAAMI,EAAY,OAAO,SAAS,OAASH,EAC3C,GAAI,CAACL,EAAI,WAAWQ,CAAS,EACzBP,EAAS,IAAI,OAAQ,oCAAqCD,EAAKQ,CAAS,MAEvE,CACD,IAAIC,EAAWT,EAAI,QAAQQ,EAAW,EAAE,EACnCC,EAAS,WAAW,GAAG,IACxBA,EAAW,IAAMA,GACrBR,EAAS,IAAI,QAAS,0BAA2BQ,CAAQ,EACzDL,EAAO,QAAQK,CAAQ,EACvB,MACpB,CACA,CACA,CACQR,EAAS,IAAI,OAAQ,gDAAiDD,CAAG,EACzE,OAAO,SAAS,KAAOA,CAC/B,CACA,CAAC,EACD,cAAO,cAAgBD"}
@@ -1,7 +1,7 @@
1
1
  import { type ParentMessage } from './messages.js';
2
2
  export interface StateChangeAdapter {
3
3
  stateChange(action: 'push' | 'replace', newUrl: URL, element: DFrameElement): void;
4
- onStateChange(callback: () => void): void;
4
+ onStateChange(callback: () => void): () => void;
5
5
  }
6
6
  export declare class DFrameElement extends HTMLElement {
7
7
  get id(): string;
@@ -54,6 +54,7 @@ export declare class DFrameElement extends HTMLElement {
54
54
  private resizeObserver;
55
55
  private boundOnMessage;
56
56
  private mouseEventListeners;
57
+ private stopOnStateChange;
57
58
  private parentUrlListeners;
58
59
  get actualAspectRatio(): number;
59
60
  constructor();
@@ -17,6 +17,7 @@ class WindowStateChangeAdapter {
17
17
  // the idea being that the child makes itself wholly compatible with d-frame and changes its navigation logic to fit it
18
18
  // but the parent should be left as untouched as possible and uses d-frame as a black box (custom element)
19
19
  window.addEventListener('popstate', callback);
20
+ return () => { window.removeEventListener('popstate', callback); };
20
21
  }
21
22
  }
22
23
  // we try to adapt to some of the conventions found out there
@@ -169,6 +170,7 @@ export class DFrameElement extends HTMLElement {
169
170
  resizeObserver;
170
171
  boundOnMessage = (e) => this.onMessage(e);
171
172
  mouseEventListeners = {};
173
+ stopOnStateChange;
172
174
  parentUrlListeners = {};
173
175
  get actualAspectRatio() {
174
176
  if (this.aspectRatio !== 'auto')
@@ -477,8 +479,12 @@ export class DFrameElement extends HTMLElement {
477
479
  this.log('debug', 'connected');
478
480
  this.connected = true;
479
481
  if (this.adapter.onStateChange) {
480
- this.adapter.onStateChange(() => { this.updateSrc(); });
482
+ this.stopOnStateChange = this.adapter.onStateChange(() => { this.updateSrc(); });
481
483
  }
484
+ // measure synchronously: the observer only fires after the next layout, and the frame
485
+ // would be painted at the height of its loading slot in between
486
+ this.width = this.getBoundingClientRect().width;
487
+ this.updateAspectRatioHeight();
482
488
  this.resizeObserver.observe(this);
483
489
  window.addEventListener('message', this.boundOnMessage);
484
490
  this.updateParsedSyncParams();
@@ -492,6 +498,8 @@ export class DFrameElement extends HTMLElement {
492
498
  this.log('debug', 'disconnected');
493
499
  this.resizeObserver.disconnect();
494
500
  window.removeEventListener('message', this.boundOnMessage);
501
+ this.stopOnStateChange?.();
502
+ this.stopOnStateChange = undefined;
495
503
  for (const [eventType, listener] of Object.entries(this.mouseEventListeners)) {
496
504
  document.removeEventListener(eventType, listener, true);
497
505
  delete this.mouseEventListeners[eventType];
@@ -4,7 +4,7 @@ declare class VueReactiveDFrameStateChangeAdapter implements StateChangeAdapter
4
4
  reactiveParams: Reactive<Record<string, string>>;
5
5
  constructor(reactiveParams: Reactive<Record<string, string>>);
6
6
  stateChange(action: 'push' | 'replace', newUrl: URL): void;
7
- onStateChange(callback: () => void): void;
7
+ onStateChange(callback: () => void): () => void;
8
8
  }
9
9
  declare const _default: (reactiveParams: Reactive<Record<string, string>>) => VueReactiveDFrameStateChangeAdapter;
10
10
  export default _default;
@@ -9,7 +9,7 @@ class VueReactiveDFrameStateChangeAdapter {
9
9
  applySearchParams(this.reactiveParams, newUrl.searchParams);
10
10
  }
11
11
  onStateChange(callback) {
12
- watch(this.reactiveParams, callback);
12
+ return watch(this.reactiveParams, callback);
13
13
  }
14
14
  }
15
15
  export default (reactiveParams) => new VueReactiveDFrameStateChangeAdapter(reactiveParams);
@@ -4,7 +4,7 @@ declare class VueRouterDFrameStateChangeAdapter implements StateChangeAdapter {
4
4
  router: Router;
5
5
  constructor(router: Router);
6
6
  stateChange(action: 'push' | 'replace', newUrl: URL, element: DFrameElement): void;
7
- onStateChange(callback: () => void): void;
7
+ onStateChange(callback: () => void): () => void;
8
8
  }
9
9
  declare const _default: (router: Router) => VueRouterDFrameStateChangeAdapter;
10
10
  export default _default;
@@ -23,7 +23,7 @@ class VueRouterDFrameStateChangeAdapter {
23
23
  this.router.replace(newRoute);
24
24
  }
25
25
  onStateChange(callback) {
26
- this.router.afterEach(callback);
26
+ return this.router.afterEach(callback);
27
27
  }
28
28
  }
29
29
  export default (router) => new VueRouterDFrameStateChangeAdapter(router);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-fair/frame",
3
- "version": "0.18.5",
3
+ "version": "0.18.7",
4
4
  "description": "An iframe wrapper for powerful web app integrations.",
5
5
  "main": "dist/frame.min.js",
6
6
  "directories": {
@@ -42,6 +42,7 @@
42
42
  "files": [
43
43
  "lib/**/*.js",
44
44
  "lib/**/*.d.ts",
45
- "dist/**/*.js"
45
+ "dist/**/*.js",
46
+ "dist/**/*.js.map"
46
47
  ]
47
48
  }