@data-fair/frame 0.18.7 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/d-frame-content.min.js +1 -1
- package/dist/d-frame-content.min.js.map +1 -1
- package/dist/d-frame.min.js +2 -2
- package/dist/d-frame.min.js.map +1 -1
- package/dist/v-iframe-compat/d-frame-content.min.js +1 -1
- package/dist/v-iframe-compat/d-frame-content.min.js.map +1 -1
- package/lib/DFrameContent.d.ts +2 -1
- package/lib/DFrameContent.js +29 -23
- package/lib/DFrameElement.js +44 -18
- package/lib/messages.js +7 -4
- package/lib/utils/sync-params.js +10 -8
- package/lib/utils/url.d.ts +1 -0
- package/lib/utils/url.js +11 -0
- package/lib/v-iframe-compat/ui-notif.js +1 -1
- package/lib/vue/use-parent-urls.js +1 -1
- package/lib/vue-reactive/util.js +4 -5
- package/lib/vue-router/state-change-adapter.js +13 -3
- package/lib/vue-router/use-parent-url.js +9 -4
- package/package.json +9 -6
- package/lib/vue-router/router-type.d.ts +0 -17
- package/lib/vue-router/router-type.js +0 -7
- package/lib/vue-router/util.d.ts +0 -17
- package/lib/vue-router/util.js +0 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var DFrameContent=function(){"use strict";
|
|
1
|
+
var DFrameContent=function(){"use strict";function a(n,e){if(typeof n!="string")return!1;try{return["http:","https:"].includes(new URL(n,e).protocol)}catch{return!1}}function d(n){return n[0]==="df-global"&&n[1]==="mouse"&&typeof n[2]=="string"}function c(n){return n[0]==="df-parent"&&n[1]==="init"}function l(n){return n[0]==="df-parent"&&n[1]==="updateSrc"}function f(n){return n[0]==="df-parent"&&n[1]==="parentUrl"}const u=(()=>{try{return window.top!==window.self}catch{return!0}})(),p=["animationstart","animationiteration","animationend","input","mouseup","mousedown","orientationchange","afterprint","beforeprint","touchstart","touchend","touchcancel","transitionstart","transitionend","resize"];class g{initialized=!1;options;pendingCheckHeight=!1;debug=!1;id;throttledCheckHeight;lastHeight=0;parentUrlListeners={};parentUrlResults={};constructor(e){if(this.options=e??{},typeof window>"u")return;if(window.__d_frame__content)throw new Error("DFrameContent was already initialized");window.__d_frame__content=this;const t=()=>{this.checkHeight(),this.pendingCheckHeight=!1};this.throttledCheckHeight=()=>{this.pendingCheckHeight||(this.pendingCheckHeight=!0,requestAnimationFrame(t))},window.addEventListener("message",i=>this.onMessage(i)),this.postMessageToParent(["df-child","init"])}log(e,...t){e==="debug"&&!this.debug||(e==="debug"&&console.timeLog(`d-frame:${this.id}:content`,...t),e==="info"&&console.info(`d-frame:${this.id}:content`,...t),e==="error"&&console.error(`d-frame:${this.id}:content`,...t))}onMessage(e){if(e.source===window.parent&&Array.isArray(e.data)){const t=e.data;if(c(t)&&(this.id=t[2].id,this.debug=!!t[2].debug,this.debug&&console.time(`d-frame:${this.id}:content`),this.log("debug","init handshake is ok",t,this.options),t[2].src&&t[2].src!==window.location.href&&this.log("error",`src mismatch at init, maybe the frame navigated before the initialization handshake: ${window.location.href} !== ${t[2].src}`),t[2].resize!=="no"&&this.initResize(),(t[2].syncParams||t[2].syncPath||t[2].stateChangeEvents)&&this.initStateChangeWatcher(),t[2].mouseEvents&&this.initMouseEvents(t[2].mouseEvents),this.initialized=!0),l(t)){if(!a(t[2],window.location.href)){this.log("error","refused to navigate to a src that is not a http(s) URL",t[2]);return}const i=new URL(t[2],window.location.href).href;if(i===window.location.href)return;this.log("debug",`update src ${window.location.href} -> ${i}`),this.options.updateSrc?this.options.updateSrc(i,this):(this.log("debug","no updateSrc method available, falling back to updating window.location.href",i),window.location.href=i)}if(d(t)&&this.mouseEventTypes.includes(t[2])&&this.applySyncedMouseEvent(t),f(t))if(!a(t[3]))this.log("error","refused a parent URL that is not a http(s) URL",t[3]);else if(!this.parentUrlListeners[t[2]])this.log("error",`received getParentUrlResponse message but no matching callback is registered: ${t[2]}`);else{this.parentUrlResults[t[2]]=t[3];for(const i of this.parentUrlListeners[t[2]])i(t[3])}}}postMessageToParent(e){window.parent.postMessage(e,"*")}sendNotif(e){this.postMessageToParent(["df-child","notif",e])}sendMessage(e){this.postMessageToParent(["df-child","custom",e])}ready(){this.postMessageToParent(["df-child","ready"])}reinitHeight(){this.lastHeight=0,this.postMessageToParent(["df-child","reinit-height"])}addParentUrlListener(e,t){const i=new URL(e,window.location.href).href;if(!u){t(i);return}if(this.parentUrlListeners[i]){this.parentUrlListeners[i].push(t),i in this.parentUrlResults&&t(this.parentUrlResults[i]);return}this.parentUrlListeners[i]=[t],this.postMessageToParent(["df-child","addParentUrlListener",i])}removeParentUrlListener(e,t){const i=new URL(e,window.location.href).href;this.parentUrlListeners[i]&&(this.parentUrlListeners[i]=this.parentUrlListeners[i].filter(s=>s!==t),this.parentUrlListeners[i].length||(delete this.parentUrlListeners[i],delete this.parentUrlResults[i],this.postMessageToParent(["df-child","removeParentUrlListener",i])))}currentSyncedMouseEvents=new Set;mouseEventTypes=[];initMouseEvents(e){this.log("debug","initMouseEvents"),this.mouseEventTypes=e;for(const t of e)document.addEventListener(t,i=>{i instanceof MouseEvent&&this.transmitSyncedMouseEvent(["df-global","mouse",t,{altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}])},!0)}transmitSyncedMouseEvent(e){this.currentSyncedMouseEvents.has(e[2])?this.currentSyncedMouseEvents.delete(e[2]):this.postMessageToParent(e)}applySyncedMouseEvent(e){this.currentSyncedMouseEvents.add(e[2]);const t=new MouseEvent(e[2],{bubbles:!0,cancelable:!0,view:window,...e[3]});document.body.dispatchEvent(t)}initResize(){this.log("debug","initResize"),this.checkHeight(),this.createMutationObserver(),this.createWindowEventListeners()}initStateChangeWatcher(){this.log("debug","initStateChangeWatcher");const e=window.history.replaceState,t=(...s)=>{const r=window.location.href,o=e.apply(window.history,s);return window.location.href!==r&&this.postMessageToParent(["df-child","stateChange","push",window.location.href]),o};window.history.pushState=t;const i=(...s)=>{const r=window.location.href,o=e.apply(window.history,s);return window.location.href!==r&&this.postMessageToParent(["df-child","stateChange","replace",window.location.href]),o};window.history.replaceState=i}createMutationObserver(){const e=document.querySelector("body");if(!e)throw new Error("DFrameContentManager was initialized before the HTML body");if(!this.throttledCheckHeight)throw new Error("throttledCheckHeight is not defined");new window.MutationObserver(this.throttledCheckHeight).observe(e,{attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0})}createWindowEventListeners(){if(!this.throttledCheckHeight)throw new Error("throttledCheckHeight is not defined");for(const e of p)window.addEventListener(e,this.throttledCheckHeight,{passive:!0})}checkHeight(){const e=document.querySelectorAll("[data-iframe-height]");let t=0,i=0;for(const s of e){const r=s.getAttribute("data-iframe-height");if(r==="false"||r==="no")continue;const o=s.getBoundingClientRect().bottom+parseFloat(getComputedStyle(s).getPropertyValue("margin-bottom")),h=r?o+parseFloat(r):o;o>t&&(t=o),h>i&&(i=h)}i=Math.ceil(i),t>0&&i!==this.lastHeight&&(this.postMessageToParent(["df-child","height",i]),this.lastHeight=i)}}return new g}();
|
|
2
2
|
//# sourceMappingURL=d-frame-content.min.js.map
|
|
@@ -1 +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,aAAeA,EAAQ,CAAC,IAAM,MACxD,CACO,SAASE,EAAmBF,EAAS,CACxC,OAAOA,EAAQ,CAAC,IAAM,aAAeA,EAAQ,CAAC,IAAM,WACxD,CACO,SAASG,EAAmBH,EAAS,CACxC,OAAOA,EAAQ,CAAC,IAAM,aAAeA,EAAQ,CAAC,IAAM,WACxD,CCtCA,MAAMI,GAAY,IAAM,CACpB,GAAI,CACA,OAAO,OAAO,MAAQ,OAAO,IACrC,MACc,CACN,MAAO,EACf,CACA,GAAI,ECLEC,EAAmB,CACrB,iBACA,uBACA,qBACA,2BACA,eACA,qBACA,QACA,UACA,YACA,oBACA,aACA,cACA,mBACA,aACA,WACA,cACA,kBACA,wBACA,oBACA,mBACA,mBAAoB,sBACpB,4BACA,wBACA,uBACA,uBAAwB,gBACxB,sBACA,kBACA,iBACA,iBAAkB,QACtB,EACe,MAAMC,CAAc,CAU/B,YAAYC,EAAS,CATrBC,EAAA,mBAAc,IACdA,EAAA,gBACAA,EAAA,0BAAqB,IACrBA,EAAA,aAAQ,IACRA,EAAA,WACAA,EAAA,6BACA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AAS,CACT,CACI,4BAA6B,CACzB,GAAI,CAAC,KAAK,qBACN,MAAM,IAAI,MAAM,qCAAqC,EACzD,UAAWP,KAAahB,EACpB,OAAO,iBAAiBgB,EAAW,KAAK,qBAAsB,CAAE,QAAS,GAAM,CAE3F,CACI,aAAc,CACV,MAAMQ,EAAW,SAAS,iBAAiB,sBAAsB,EACjE,IAAIC,EAAmB,EACnBC,EAAM,EACV,UAAWC,KAAWH,EAAU,CAC5B,MAAMI,EAAgBD,EAAQ,aAAa,oBAAoB,EAC/D,GAAIC,IAAkB,SAAWA,IAAkB,KAC/C,SACJ,MAAMC,EAAsBF,EAAQ,sBAAqB,EAAG,OACxD,WAAW,iBAAiBA,CAAO,EAAE,iBAAiB,eAAe,CAAC,EACpEG,EAASF,EAAiBC,EAAsB,WAAWD,CAAa,EAAKC,EAC/EA,EAAsBJ,IACtBA,EAAmBI,GACnBC,EAASJ,IACTA,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
|
+
{"version":3,"file":"d-frame-content.min.js","sources":["../lib/utils/url.js","../lib/messages.js","../lib/utils/in-iframe.js","../lib/DFrameContent.js","../lib/d-frame-content.ts"],"sourcesContent":["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// a URL that can be navigated to or used as a link without running code (no javascript:, data:...)\nexport function isHttpUrl(value, base) {\n if (typeof value !== 'string')\n return false;\n try {\n return ['http:', 'https:'].includes(new URL(value, base).protocol);\n }\n catch {\n return false;\n }\n}\n","import { isHttpUrl } from './utils/url.js';\nexport function isMouseEventMessage(message) {\n return message[0] === 'df-global' && message[1] === 'mouse' && typeof message[2] === 'string';\n}\nexport function isInitChildMessage(message) {\n return message[0] === 'df-child' && message[1] === 'init';\n}\nexport function isHeightMessage(message) {\n // the height is written in the style of the wrapper, anything else than a number would inject css\n return message[0] === 'df-child' && message[1] === 'height' && typeof message[2] === 'number' && Number.isFinite(message[2]) && message[2] >= 0;\n}\nexport function isReinitHeightMessage(message) {\n return message[0] === 'df-child' && message[1] === 'reinit-height';\n}\n// the URL of the child becomes the src of the iframe when it is reloaded: a javascript: URL would run in the parent\nexport function isStateChangeMessage(message) {\n return message[0] === 'df-child' && message[1] === 'stateChange' && (message[2] === 'push' || message[2] === 'replace') && isHttpUrl(message[3]);\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' && isHttpUrl(message[2]);\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';\nimport { isHttpUrl } from './utils/url.js';\n// prefixed variants are not listed: browsers do not fire them when there is an unprefixed listener\nconst windowEventTypes = [\n 'animationstart',\n 'animationiteration',\n 'animationend',\n 'input',\n 'mouseup',\n 'mousedown',\n 'orientationchange',\n 'afterprint',\n 'beforeprint',\n 'touchstart',\n 'touchend',\n 'touchcancel',\n 'transitionstart',\n 'transitionend',\n '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 // the parent can be any page, it must not be able to run code in this window (javascript: URL)\n if (!isHttpUrl(message[2], window.location.href)) {\n this.log('error', 'refused to navigate to a src that is not a http(s) URL', message[2]);\n return;\n }\n const newSrc = new URL(message[2], window.location.href).href;\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) && this.mouseEventTypes.includes(message[2])) {\n this.applySyncedMouseEvent(message);\n }\n if (isParentUrlMessage(message)) {\n if (!isHttpUrl(message[3])) {\n // the result is used as a link, it must not be able to run code\n this.log('error', 'refused a parent URL that is not a http(s) URL', message[3]);\n }\n else if (!this.parentUrlListeners[message[2]]) {\n this.log('error', `received getParentUrlResponse message but no matching callback is registered: ${message[2]}`);\n }\n else {\n this.parentUrlResults[message[2]] = message[3];\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 // the parent forgets the height, the next one must be sent even if it did not change\n this.lastHeight = 0;\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.parentUrlListeners[childHref]) {\n // the parent already sends the updates of this URL, the result is known or on its way\n this.parentUrlListeners[childHref].push(listener);\n if (childHref in this.parentUrlResults)\n listener(this.parentUrlResults[childHref]);\n return;\n }\n this.parentUrlListeners[childHref] = [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 delete this.parentUrlResults[childHref];\n this.postMessageToParent(['df-child', 'removeParentUrlListener', childHref]);\n }\n }\n }\n currentSyncedMouseEvents = new Set();\n mouseEventTypes = [];\n initMouseEvents(types) {\n this.log('debug', 'initMouseEvents');\n this.mouseEventTypes = types;\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'\n\nexport default new DFrameContent()\n"],"names":["isHttpUrl","value","base","isMouseEventMessage","message","isInitParentMessage","isUpdateSrcMessage","isParentUrlMessage","inIframe","windowEventTypes","DFrameContent","options","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":"0CAuBO,SAASA,EAAUC,EAAOC,EAAM,CACnC,GAAI,OAAOD,GAAU,SACjB,MAAO,GACX,GAAI,CACA,MAAO,CAAC,QAAS,QAAQ,EAAE,SAAS,IAAI,IAAIA,EAAOC,CAAI,EAAE,QAAQ,CACzE,MACU,CACF,MAAO,EACf,CACA,CC/BO,SAASC,EAAoBC,EAAS,CACzC,OAAOA,EAAQ,CAAC,IAAM,aAAeA,EAAQ,CAAC,IAAM,SAAW,OAAOA,EAAQ,CAAC,GAAM,QACzF,CA8BO,SAASC,EAAoBD,EAAS,CACzC,OAAOA,EAAQ,CAAC,IAAM,aAAeA,EAAQ,CAAC,IAAM,MACxD,CACO,SAASE,EAAmBF,EAAS,CACxC,OAAOA,EAAQ,CAAC,IAAM,aAAeA,EAAQ,CAAC,IAAM,WACxD,CACO,SAASG,EAAmBH,EAAS,CACxC,OAAOA,EAAQ,CAAC,IAAM,aAAeA,EAAQ,CAAC,IAAM,WACxD,CCzCA,MAAMI,GAAY,IAAM,CACpB,GAAI,CACA,OAAO,OAAO,MAAQ,OAAO,IACrC,MACc,CACN,MAAO,EACf,CACA,GAAI,ECHEC,EAAmB,CACrB,iBACA,qBACA,eACA,QACA,UACA,YACA,oBACA,aACA,cACA,aACA,WACA,cACA,kBACA,gBACA,QACJ,EACe,MAAMC,CAAc,CAC/B,YAAc,GACd,QACA,mBAAqB,GACrB,MAAQ,GACR,GACA,qBACA,WAAa,EACb,mBAAqB,CAAE,EACvB,iBAAmB,CAAE,EACrB,YAAYC,EAAS,CAEjB,GADA,KAAK,QAAUA,GAAW,CAAE,EACxB,OAAO,O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C,CACtC,CACI,wBAAyB,CACrB,MAAMC,EAAO,SAAS,cAAc,MAAM,EAC1C,GAAI,CAACA,EACD,MAAM,IAAI,MAAM,2DAA2D,EAC/E,GAAI,CAAC,KAAK,qBACN,MAAM,IAAI,MAAM,qCAAqC,EACxC,IAAI,OAAO,iBAAiB,KAAK,oBAAoB,EAC7D,QAAQA,EAAM,CACnB,WAAY,GACZ,kBAAmB,GACnB,cAAe,GACf,sBAAuB,GACvB,UAAW,GACX,QAAS,EACrB,CAAS,CACT,CACI,4BAA6B,CACzB,GAAI,CAAC,KAAK,qBACN,MAAM,IAAI,MAAM,qCAAqC,EACzD,UAAWP,KAAaf,EACpB,OAAO,iBAAiBe,EAAW,KAAK,qBAAsB,CAAE,QAAS,GAAM,CAE3F,CACI,aAAc,CACV,MAAMQ,EAAW,SAAS,iBAAiB,sBAAsB,EACjE,IAAIC,EAAmB,EACnBC,EAAM,EACV,UAAWC,KAAWH,EAAU,CAC5B,MAAMI,EAAgBD,EAAQ,aAAa,oBAAoB,EAC/D,GAAIC,IAAkB,SAAWA,IAAkB,KAC/C,SACJ,MAAMC,EAAsBF,EAAQ,sBAAqB,EAAG,OACxD,WAAW,iBAAiBA,CAAO,EAAE,iBAAiB,eAAe,CAAC,EACpEG,EAASF,EAAiBC,EAAsB,WAAWD,CAAa,EAAKC,EAC/EA,EAAsBJ,IACtBA,EAAmBI,GACnBC,EAASJ,IACTA,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,QC1Qe,IAAIxB"}
|
package/dist/d-frame.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
(function(){"use strict";function w(e){return e.endsWith("/")?e:e===""?"/":e.slice(0,e.lastIndexOf("/")+1)}function u(e){return e.endsWith("/")?e:e+"/"}function f(e,t){if(t.origin!==e.origin)return t.href;if(u(t.pathname)===u(e.pathname))return"";const i=w(e.pathname);return t.pathname.startsWith(i)?t.pathname.replace(i,""):t.pathname}function g(e,t){if(typeof e!="string")return!1;try{return["http:","https:"].includes(new URL(e,t).protocol)}catch{return!1}}function E(e){return e[0]==="df-global"&&e[1]==="mouse"&&typeof e[2]=="string"}function v(e){return e[0]==="df-child"&&e[1]==="init"}function A(e){return e[0]==="df-child"&&e[1]==="height"&&typeof e[2]=="number"&&Number.isFinite(e[2])&&e[2]>=0}function S(e){return e[0]==="df-child"&&e[1]==="reinit-height"}function C(e){return e[0]==="df-child"&&e[1]==="stateChange"&&(e[2]==="push"||e[2]==="replace")&&g(e[3])}function M(e){return e[0]==="df-child"&&e[1]==="custom"}function R(e){return e[0]==="df-child"&&e[1]==="notif"}function L(e){return e[0]==="df-child"&&e[1]==="addParentUrlListener"&&g(e[2])}function P(e){return e[0]==="df-child"&&e[1]==="removeParentUrlListener"}function z(e){return e[0]==="df-child"&&e[1]==="ready"}const U=e=>e.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&");function H(e){const t=[];for(const i of e.split(",")){const[s="*",r]=i.trim().split(":"),h="^"+U(s).replace(/\\\*/g,"(.*)")+"$";t.push({regexp:new RegExp(h),append:r})}return t}function x(e,t,i,s){if(!i&&!s)return e;const r=new URL(e),h=new URL(t);if(i&&h.searchParams.forEach((a,d)=>{for(const n of i){if(n.append&&!d.startsWith(n.append)||d===s)continue;const o=n.append?d.replace(n.append,""):d;if(o.match(n.regexp)){r.searchParams.set(o,a);break}}}),s!==null){let a;if(s==="#")a=h.hash.slice(1);else if(s.startsWith("/"))if(h.pathname.startsWith(s)||h.pathname+"/"===s)a=f(new URL(s,t),h);else return null;else a=h.searchParams.get(s);a&&(r.pathname=new URL(a,e).pathname)}return r.href}function c(e,t,i,s,r){const h=new URL(e),a=new URL(i),d=new URL(t);if(s){for(const n of Array.from(a.searchParams.keys()))for(const o of s){if(o.append&&!n.startsWith(o.append))continue;const l=o.append?n.replace(o.append,""):n;if(l.match(o.regexp)){d.searchParams.get(l)===null&&a.searchParams.delete(n);break}}d.searchParams.forEach((n,o)=>{for(const l of s){if(!o.match(l.regexp))continue;const y=l.append?l.append+o:o;h.searchParams.get(o)===n?a.searchParams.delete(y):a.searchParams.set(y,n);break}})}if(r!==null&&h){const n=f(h,d);if(r==="#")a.hash=n;else if(r.startsWith("/")){if(n.startsWith("/")||d.origin!==h.origin)return null;n===""?a.pathname=r:a.pathname=new URL(n,new URL(r,i)).pathname}else n?a.searchParams.set(r,n):a.searchParams.delete(r)}return a}function I(e){return e?.vIframe===!0&&e.uiNotification!==void 0&&e.uiNotification!==null}function O(e){if(typeof e=="string")return{type:"default",title:e};if(e.error&&!e.errorMsg){const t=e.error.response&&(e.error.response.data||e.error.response.status)||e.error.message||e.error;return e.msg?{type:"error",title:e.msg,detail:t}:{type:"error",title:t}}return e.type==="error"?{type:e.clientError?"warning":"error",title:e.msg,detail:e.errorMsg}:{type:e.type??"default",title:e.msg}}class N{stateChange(t,i,s){s.log("debug","apply state change on window.history",t,i.href),t==="replace"&&window.history.replaceState(window.history.state,"",i),t==="push"&&window.history.pushState(window.history.state,"",i)}onStateChange(t){return window.addEventListener("popstate",t),()=>{window.removeEventListener("popstate",t)}}}const p=document.head?.querySelector("meta[property=csp-nonce]")??document.head?.querySelector("meta[name=csp-nonce]"),m=p?.nonce??p?.content,b=document.createElement("template");b.innerHTML=`<style${m?` nonce="${m}"`:""}>
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
}
|
|
@@ -15,5 +15,5 @@ var $=Object.defineProperty;var k=(u,l,f)=>l in u?$(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,"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)})();
|
|
18
|
+
</style><div class="d-frame-wrapper"><slot name="loading"><div class="loading-placeholder"></div></slot><iframe class="d-frame-iframe"></iframe></div>`;class T extends HTMLElement{get id(){return this.getAttribute("id")??this.randomId}set id(t){this.setAttribute("id",t)}get debug(){return this.hasAttribute("debug")}set debug(t){t?this.setAttribute("debug",""):this.removeAttribute("debug")}get src(){return this.getAttribute("src")}set src(t){this.setAttribute("src",t)}get fullSrc(){return new URL(this.src,window.location.href).href}get scrolling(){return this.getAttribute("scrolling")}set scrolling(t){this.setAttribute("scrolling",t)}get aspectRatio(){const t=this.getAttribute("aspect-ratio");return t===""?"auto":t}set aspectRatio(t){t!==null?this.setAttribute("aspect-ratio",t):this.removeAttribute("aspect-ratio")}get height(){return this.getAttribute("height")}set height(t){t?this.setAttribute("height",t):this.removeAttribute("height")}set resize(t){this.setAttribute("resize",t)}get resize(){const t=this.getAttribute("resize");return t===null?"auto":t===""?"yes":t}set reinitHeight(t){this.setAttribute("reinit-height",t)}get reinitHeight(){const t=this.getAttribute("reinit-height");return t===null||t===""?"on-message":t}get syncParams(){return this.getAttribute("sync-params")}set syncParams(t){t!==null?this.setAttribute("sync-params",t):this.removeAttribute("sync-params")}get syncPath(){const t=this.getAttribute("sync-path");return t===null?null:t||"p"}set syncPath(t){t!==null?this.setAttribute("sync-path",t):this.removeAttribute("sync-path")}get stateChangeEvents(){return this.hasAttribute("state-change-events")}set stateChangeEvents(t){t?this.setAttribute("state-change-events",""):this.removeAttribute("state-change-events")}get readyMessage(){return this.hasAttribute("ready-message")}set readyMessage(t){t?this.setAttribute("ready-message",""):this.removeAttribute("ready-message")}get mouseEvents(){const t=this.getAttribute("mouse-events");return t===null?null:t===""?["click","dblclick","mousedown","mouseup"]:t.split(",")}set mouseEvents(t){t===null?this.removeAttribute("mouse-events"):this.setAttribute("mouse-events",t.join(","))}get reload(){return this.getAttribute("reload")}set reload(t){this.setAttribute("reload",t)}get emitIFrameMessages(){return this.hasAttribute("emit-iframe-messages")}set emitIFrameMessages(t){t?this.setAttribute("emit-iframe-messages",""):this.removeAttribute("emit-iframe-messages")}adapter;windowAdapter;connected=!1;childInitialized=!1;currentChildSrc=null;parsedSyncParams;wrapperElement;slotElement;iframeElement;width;aspectRatioHeight;resizedHeight;randomId;iframeLoaded=!1;ready=!1;iframeExtraAttrs={};resizeObserver;boundOnMessage=t=>this.onMessage(t);mouseEventListeners={};stopOnStateChange;parentUrlListeners={};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}constructor(){super(),this.randomId=Math.random().toString(36).slice(-6);const t=b.content.cloneNode(!0);this.wrapperElement=t.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(t),this.resizeObserver=new ResizeObserver(s=>{(this.width===void 0||Math.abs(this.width-s[0].contentRect.width)>2)&&(this.width=s[0].contentRect.width,this.updateAspectRatioHeight())}),this.adapter=this.windowAdapter=new N}onMessage(t){if(this.emitIFrameMessages&&this.dispatchEvent(new CustomEvent("iframe-message",{detail:t.data})),t.source===this.iframeElement?.contentWindow){const i=t.data;if(this.log("debug","received message from child",i),Array.isArray(t.data)){if(v(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,this.parentUrlListeners={}),A(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.updateAspectRatioHeight(),this.updateStyle()),C(i)){if(this.currentChildSrc=i[3],this.parsedSyncParams||this.syncPath){const s=c(this.fullSrc,i[3],window.location.href,this.parsedSyncParams,this.syncPath);if(s===null)this.log("debug","failed to process newParentUrl, ignore state change");else if(s.href!==window.location.href){this.log("debug","apply state change to parent",i[2],s.href);try{this.adapter.stateChange(i[2],s,this)}catch(r){this.log("error","failed to apply state change to parent using custom adapter",r),this.windowAdapter.stateChange(i[2],s,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]})),R(i)&&this.dispatchEvent(new CustomEvent("notif",{detail:i[2]})),z(i)&&(this.ready=!0,this.dispatchEvent(new CustomEvent("ready")),this.updateStyle()),E(i)&&this.mouseEvents?.includes(i[2])&&this.applySyncedMouseEvent(i),L(i)){const s=c(this.fullSrc,i[2],window.location.href,this.parsedSyncParams,this.syncPath);s&&(this.parentUrlListeners[i[2]]=s.href,this.postMessageToChild(["df-parent","parentUrl",i[2],s.href]))}P(i)&&delete this.parentUrlListeners[i[2]]}else I(i)&&this.dispatchEvent(new CustomEvent("notif",{detail:O(i.uiNotification)}))}}postMessageToChild(t){this.log("debug","send message to child",t),this.iframeElement?.contentWindow?.postMessage(t,"*")}updateParsedSyncParams(){this.parsedSyncParams=this.syncParams!==null?H(this.syncParams||"*"):void 0}updateSrc(){if(!this.connected||!this.src)return;for(const[i,s]of Object.entries(this.parentUrlListeners)){const r=c(this.fullSrc,i,window.location.href,this.parsedSyncParams,this.syncPath);r&&r.href!==s&&(this.parentUrlListeners[i]=r.href,this.postMessageToChild(["df-parent","parentUrl",i,r.href]))}const t=x(this.fullSrc,window.location.href,this.parsedSyncParams,this.syncPath);t&&t!==this.currentChildSrc&&(this.currentChildSrc=t,this.childInitialized?this.postMessageToChild(["df-parent","updateSrc",t]):(this.log("debug","set src attribute of iframe: "+t),this.iframeElement.setAttribute("src",t)))}updateStyle(){if(!this.connected)return;let t;this.resizedHeight?(this.log("debug","height of iframe based on resize message: "+this.resizedHeight),t=this.resizedHeight+"px"):this.height?(this.log("debug","height of iframe based on direct attribute: "+this.height),t=this.height):this.aspectRatio!==null&&this.aspectRatioHeight&&(this.log("debug","height of iframe based on aspect ratio: "+this.aspectRatioHeight),t=this.aspectRatioHeight+"px"),t!==void 0?(this.log("debug","set height iframe wrapper: "+t),this.wrapperElement.style.cssText=`height:${t};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 t=this.iframeExtraAttrs,i={};for(const s of this.getAttributeNames())if(s.startsWith("iframe-")){const r=this.getAttribute(s);if(r!==null){const h=s.slice(7);i[h]=r}}this.log("debug","update iframe extra attributes",t,i);for(const s of Object.keys(t))s in i||this.iframeElement.removeAttribute(s);for(const s of Object.keys(i))i[s]!==t[s]&&this.iframeElement.setAttribute(s,i[s])}currentSyncedMouseEvents=new Set;initMouseEvents(t){this.log("debug","initMouseEvents");for(const i of t)if(!this.mouseEventListeners[i]){const s=r=>{r instanceof MouseEvent&&this.transmitSyncedMouseEvent(["df-global","mouse",i,{altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}])};this.mouseEventListeners[i]=s,document.addEventListener(i,s,!0)}}transmitSyncedMouseEvent(t){this.currentSyncedMouseEvents.has(t[2])?this.currentSyncedMouseEvents.delete(t[2]):this.postMessageToChild(t)}applySyncedMouseEvent(t){this.currentSyncedMouseEvents.add(t[2]);const i=new MouseEvent(t[2],{bubbles:!0,cancelable:!0,view:window,...t[3]});this.dispatchEvent(i)}log(t,...i){t==="debug"&&!this.debug||(t==="debug"&&console.timeLog(`d-frame:${this.id}`,...i),t==="info"&&console.info(`d-frame:${this.id}`,...i),t==="error"&&console.error(`d-frame:${this.id}`,...i))}connectedCallback(){if(!this.debug){let t=null;try{t=window.localStorage.getItem("debug")}catch{}if(t){const i=t.split(",");(i.includes("d-frame")||i.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.aspectRatio!==null&&!this.height&&(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(){this.log("debug","disconnected"),this.connected=!1,this.childInitialized=!1,this.currentChildSrc&&this.iframeElement.setAttribute("src",this.currentChildSrc),this.resizeObserver.disconnect(),window.removeEventListener("message",this.boundOnMessage),this.stopOnStateChange?.(),this.stopOnStateChange=void 0;for(const[t,i]of Object.entries(this.mouseEventListeners))document.removeEventListener(t,i,!0),delete this.mouseEventListeners[t]}static get observedAttributes(){return["src","aspect-ratio","height","sync-params","sync-path","reload"]}attributeChangedCallback(t,i,s){if(t==="aspect-ratio"&&(this.updateAspectRatioHeight(),this.updateStyle()),!!this.connected&&(this.log("debug","attribute change",t,i,s),t==="src"&&this.updateSrc(),t==="height"&&(this.updateAspectRatioHeight(),this.updateStyle()),t==="sync-params"&&(this.updateParsedSyncParams(),this.updateSrc()),t==="sync-path"&&this.updateSrc(),t==="reload")){if(!this.currentChildSrc){this.log("error","reload attribute changed but the iframe has no current src");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);try{this.iframeElement.contentWindow?.location.reload()}catch{}}}}customElements.get("d-frame")||customElements.define("d-frame",T)})();
|
|
19
19
|
//# sourceMappingURL=d-frame.min.js.map
|
package/dist/d-frame.min.js.map
CHANGED
|
@@ -1 +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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UACT,KAAK,YAAa,EAClBA,IAAS,gBACT,KAAK,uBAAwB,EAC7B,KAAK,UAAW,GAEhBA,IAAS,aACT,KAAK,UAAW,EAChBA,IAAS,UAAU,CACnB,GAAI,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"}
|
|
1
|
+
{"version":3,"file":"d-frame.min.js","sources":["../lib/utils/url.js","../lib/messages.js","../lib/utils/sync-params.js","../lib/v-iframe-compat/ui-notif.js","../lib/DFrameElement.js","../lib/d-frame.ts"],"sourcesContent":["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// a URL that can be navigated to or used as a link without running code (no javascript:, data:...)\nexport function isHttpUrl(value, base) {\n if (typeof value !== 'string')\n return false;\n try {\n return ['http:', 'https:'].includes(new URL(value, base).protocol);\n }\n catch {\n return false;\n }\n}\n","import { isHttpUrl } from './utils/url.js';\nexport function isMouseEventMessage(message) {\n return message[0] === 'df-global' && message[1] === 'mouse' && typeof message[2] === 'string';\n}\nexport function isInitChildMessage(message) {\n return message[0] === 'df-child' && message[1] === 'init';\n}\nexport function isHeightMessage(message) {\n // the height is written in the style of the wrapper, anything else than a number would inject css\n return message[0] === 'df-child' && message[1] === 'height' && typeof message[2] === 'number' && Number.isFinite(message[2]) && message[2] >= 0;\n}\nexport function isReinitHeightMessage(message) {\n return message[0] === 'df-child' && message[1] === 'reinit-height';\n}\n// the URL of the child becomes the src of the iframe when it is reloaded: a javascript: URL would run in the parent\nexport function isStateChangeMessage(message) {\n return message[0] === 'df-child' && message[1] === 'stateChange' && (message[2] === 'push' || message[2] === 'replace') && isHttpUrl(message[3]);\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' && isHttpUrl(message[2]);\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","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.trim().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 // copy the keys as we mutate parentUrl in the loop (not with Iterator.toArray(), missing in Safari < 18.4)\n for (const key of Array.from(parentUrl.searchParams.keys())) {\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 const parentKey = syncParam.append ? (syncParam.append + key) : key;\n // the value of src is the default one: no need to keep it in the parent, but a previous value must go\n if (srcUrl.searchParams.get(key) === value)\n parentUrl.searchParams.delete(parentKey);\n else\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 or another origin is not accepted, only a path child of the base\n if (path.startsWith('/') || childUrl.origin !== srcUrl.origin)\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 && message.uiNotification !== null;\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 new URL(this.src, window.location.href).href; }\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-path', value);\n else\n this.removeAttribute('sync-path');\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 // a new document starts in the iframe, it registers its own parent URL listeners\n this.parentUrlListeners = {};\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 // not maintained while the height came from the child\n this.updateAspectRatioHeight();\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) && this.mouseEvents?.includes(message[2])) {\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 // an empty src is not known yet (<d-frame :src=\"url\">), resolved against the page it would load the parent itself\n if (!this.connected || !this.src)\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 && this.aspectRatioHeight) {\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 let globalDebug = null;\n try {\n globalDebug = window.localStorage.getItem('debug');\n }\n catch {\n // storage is blocked in some contexts (sandboxed parent, blocked cookies)\n }\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 if (this.aspectRatio !== null && !this.height) {\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 }\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.connected = false;\n // the iframe is reloaded from its src attribute when the element is connected again:\n // it must be the state reached by the child, then the child does the handshake again\n this.childInitialized = false;\n if (this.currentChildSrc)\n this.iframeElement.setAttribute('src', this.currentChildSrc);\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 // also when the attribute is removed\n this.updateStyle();\n }\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 // the aspect ratio height is not maintained while a height is set\n this.updateAspectRatioHeight();\n this.updateStyle();\n }\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.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 try {\n this.iframeElement.contentWindow?.location.reload();\n }\n catch {\n // cross-origin child: reload() is forbidden, the src attribute set above already navigates the frame\n }\n }\n }\n}\nexport default DFrameElement;\n","import DFrameElement from './DFrameElement.js'\n\nif (!customElements.get('d-frame')) {\n customElements.define('d-frame', DFrameElement)\n}\n"],"names":["getPathDirectory","path","getPathWithTrailingSlash","getUrlRelativePath","srcUrl","currentUrl","srcDirectory","isHttpUrl","value","base","isMouseEventMessage","message","isInitChildMessage","isHeightMessage","isReinitHeightMessage","isStateChangeMessage","isCustomMessage","isNotifMessage","isAddParentUrlListenerMessage","isRemoveParentUrlListenerMessage","isReadyMessage","escapeRegExp","str","parseSyncParams","syncParamsStr","syncParams","syncParam","pattern","append","regexpStr","getChildSrc","fullSrc","parentHref","syncPath","childUrl","parentUrl","key","childKey","getParentUrl","childHref","currentParentHref","parentKey","isVIframeUiNotif","convertVIframeUiNotif","notif","errorMsg","WindowStateChangeAdapter","action","newUrl","element","callback","cspNonceMeta","cspNonce","template","DFrameElement","attr","e","root","entries","newParentUrl","err","existingParentUrl","iframeSrc","wrapperHeight","previousAttrs","newAttrs","name","attrName","types","eventType","listener","event","level","args","globalDebug","debugParts","oldValue","newValue"],"mappings":"yBAAO,SAASA,EAAiBC,EAAM,CACnC,OAAIA,EAAK,SAAS,GAAG,EACVA,EACPA,IAAS,GACF,IACJA,EAAK,MAAM,EAAGA,EAAK,YAAY,GAAG,EAAI,CAAC,CAClD,CACO,SAASC,EAAyBD,EAAM,CAC3C,OAAIA,EAAK,SAAS,GAAG,EACVA,EACJA,EAAO,GAClB,CACO,SAASE,EAAmBC,E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A4D,EAC9E,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,GAAI,CACA,KAAK,cAAc,eAAe,SAAS,OAAQ,CACnE,MACkB,CAElB,CACA,CACA,CACA,CCzjBK,eAAe,IAAI,SAAS,GAChB,eAAA,OAAO,UAAWZ,CAAa"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var VIframeCompatDFrameContent=function(){"use strict";
|
|
1
|
+
var VIframeCompatDFrameContent=function(){"use strict";function h(n,e){if(typeof n!="string")return!1;try{return["http:","https:"].includes(new URL(n,e).protocol)}catch{return!1}}function c(n){return n[0]==="df-global"&&n[1]==="mouse"&&typeof n[2]=="string"}function l(n){return n[0]==="df-parent"&&n[1]==="init"}function f(n){return n[0]==="df-parent"&&n[1]==="updateSrc"}function u(n){return n[0]==="df-parent"&&n[1]==="parentUrl"}const p=(()=>{try{return window.top!==window.self}catch{return!0}})(),w=["animationstart","animationiteration","animationend","input","mouseup","mousedown","orientationchange","afterprint","beforeprint","touchstart","touchend","touchcancel","transitionstart","transitionend","resize"];class g{initialized=!1;options;pendingCheckHeight=!1;debug=!1;id;throttledCheckHeight;lastHeight=0;parentUrlListeners={};parentUrlResults={};constructor(e){if(this.options=e??{},typeof window>"u")return;if(window.__d_frame__content)throw new Error("DFrameContent was already initialized");window.__d_frame__content=this;const t=()=>{this.checkHeight(),this.pendingCheckHeight=!1};this.throttledCheckHeight=()=>{this.pendingCheckHeight||(this.pendingCheckHeight=!0,requestAnimationFrame(t))},window.addEventListener("message",i=>this.onMessage(i)),this.postMessageToParent(["df-child","init"])}log(e,...t){e==="debug"&&!this.debug||(e==="debug"&&console.timeLog(`d-frame:${this.id}:content`,...t),e==="info"&&console.info(`d-frame:${this.id}:content`,...t),e==="error"&&console.error(`d-frame:${this.id}:content`,...t))}onMessage(e){if(e.source===window.parent&&Array.isArray(e.data)){const t=e.data;if(l(t)&&(this.id=t[2].id,this.debug=!!t[2].debug,this.debug&&console.time(`d-frame:${this.id}:content`),this.log("debug","init handshake is ok",t,this.options),t[2].src&&t[2].src!==window.location.href&&this.log("error",`src mismatch at init, maybe the frame navigated before the initialization handshake: ${window.location.href} !== ${t[2].src}`),t[2].resize!=="no"&&this.initResize(),(t[2].syncParams||t[2].syncPath||t[2].stateChangeEvents)&&this.initStateChangeWatcher(),t[2].mouseEvents&&this.initMouseEvents(t[2].mouseEvents),this.initialized=!0),f(t)){if(!h(t[2],window.location.href)){this.log("error","refused to navigate to a src that is not a http(s) URL",t[2]);return}const i=new URL(t[2],window.location.href).href;if(i===window.location.href)return;this.log("debug",`update src ${window.location.href} -> ${i}`),this.options.updateSrc?this.options.updateSrc(i,this):(this.log("debug","no updateSrc method available, falling back to updating window.location.href",i),window.location.href=i)}if(c(t)&&this.mouseEventTypes.includes(t[2])&&this.applySyncedMouseEvent(t),u(t))if(!h(t[3]))this.log("error","refused a parent URL that is not a http(s) URL",t[3]);else if(!this.parentUrlListeners[t[2]])this.log("error",`received getParentUrlResponse message but no matching callback is registered: ${t[2]}`);else{this.parentUrlResults[t[2]]=t[3];for(const i of this.parentUrlListeners[t[2]])i(t[3])}}}postMessageToParent(e){window.parent.postMessage(e,"*")}sendNotif(e){this.postMessageToParent(["df-child","notif",e])}sendMessage(e){this.postMessageToParent(["df-child","custom",e])}ready(){this.postMessageToParent(["df-child","ready"])}reinitHeight(){this.lastHeight=0,this.postMessageToParent(["df-child","reinit-height"])}addParentUrlListener(e,t){const i=new URL(e,window.location.href).href;if(!p){t(i);return}if(this.parentUrlListeners[i]){this.parentUrlListeners[i].push(t),i in this.parentUrlResults&&t(this.parentUrlResults[i]);return}this.parentUrlListeners[i]=[t],this.postMessageToParent(["df-child","addParentUrlListener",i])}removeParentUrlListener(e,t){const i=new URL(e,window.location.href).href;this.parentUrlListeners[i]&&(this.parentUrlListeners[i]=this.parentUrlListeners[i].filter(r=>r!==t),this.parentUrlListeners[i].length||(delete this.parentUrlListeners[i],delete this.parentUrlResults[i],this.postMessageToParent(["df-child","removeParentUrlListener",i])))}currentSyncedMouseEvents=new Set;mouseEventTypes=[];initMouseEvents(e){this.log("debug","initMouseEvents"),this.mouseEventTypes=e;for(const t of e)document.addEventListener(t,i=>{i instanceof MouseEvent&&this.transmitSyncedMouseEvent(["df-global","mouse",t,{altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}])},!0)}transmitSyncedMouseEvent(e){this.currentSyncedMouseEvents.has(e[2])?this.currentSyncedMouseEvents.delete(e[2]):this.postMessageToParent(e)}applySyncedMouseEvent(e){this.currentSyncedMouseEvents.add(e[2]);const t=new MouseEvent(e[2],{bubbles:!0,cancelable:!0,view:window,...e[3]});document.body.dispatchEvent(t)}initResize(){this.log("debug","initResize"),this.checkHeight(),this.createMutationObserver(),this.createWindowEventListeners()}initStateChangeWatcher(){this.log("debug","initStateChangeWatcher");const e=window.history.replaceState,t=(...r)=>{const o=window.location.href,s=e.apply(window.history,r);return window.location.href!==o&&this.postMessageToParent(["df-child","stateChange","push",window.location.href]),s};window.history.pushState=t;const i=(...r)=>{const o=window.location.href,s=e.apply(window.history,r);return window.location.href!==o&&this.postMessageToParent(["df-child","stateChange","replace",window.location.href]),s};window.history.replaceState=i}createMutationObserver(){const e=document.querySelector("body");if(!e)throw new Error("DFrameContentManager was initialized before the HTML body");if(!this.throttledCheckHeight)throw new Error("throttledCheckHeight is not defined");new window.MutationObserver(this.throttledCheckHeight).observe(e,{attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0})}createWindowEventListeners(){if(!this.throttledCheckHeight)throw new Error("throttledCheckHeight is not defined");for(const e of w)window.addEventListener(e,this.throttledCheckHeight,{passive:!0})}checkHeight(){const e=document.querySelectorAll("[data-iframe-height]");let t=0,i=0;for(const r of e){const o=r.getAttribute("data-iframe-height");if(o==="false"||o==="no")continue;const s=r.getBoundingClientRect().bottom+parseFloat(getComputedStyle(r).getPropertyValue("margin-bottom")),a=o?s+parseFloat(o):s;s>t&&(t=s),a>i&&(i=a)}i=Math.ceil(i),t>0&&i!==this.lastHeight&&(this.postMessageToParent(["df-child","height",i]),this.lastHeight=i)}}const m=(n,e)=>{e.forEach((t,i)=>{n[i]=t});for(const t of Object.keys(n))e.has(t)||delete n[t]},d=new g({updateSrc(n,e){const t=window.vIframeOptions,i=t?.reactiveParams;if(i&&typeof i=="object"){const o=new URL(n);if(o.origin===window.location.origin&&o.pathname===window.location.pathname){e.log("debug","applying reactive params",o.searchParams),m(i,o.searchParams);return}}const r=t?.router;if(r){const o=r.options?.base??r.options.history?.base;if(o==null)e.log("error","failed to access base path in router (no router.options.base nor router.options.history.base)",r);else{const s=window.location.origin+o;if(!n.startsWith(s))e.log("info","src does not start with base path",n,s);else{let a=n.replace(s,"");a.startsWith("/")||(a="/"+a),e.log("debug","applying router.replace",a),r.replace(a);return}}}e.log("info","falling back to updating window.location.href",n),window.location.href=n}});return window.dFrameContent=d,d}();
|
|
2
2
|
//# sourceMappingURL=d-frame-content.min.js.map
|