@elliemae/ssf-host 2.0.0-next.39 → 2.0.0-next.40
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/public/autoFill.js.map +1 -1
- package/dist/public/index.html +1 -1
- package/dist/public/init.js +1 -1
- package/dist/public/init.js.br +0 -0
- package/dist/public/init.js.gz +0 -0
- package/dist/public/init.js.map +1 -1
- package/dist/public/js/emuiSsfHost.0b1ad0a8334074f4ae55.js +3 -0
- package/dist/public/js/emuiSsfHost.0b1ad0a8334074f4ae55.js.br +0 -0
- package/dist/public/js/emuiSsfHost.0b1ad0a8334074f4ae55.js.gz +0 -0
- package/dist/public/js/emuiSsfHost.0b1ad0a8334074f4ae55.js.map +1 -0
- package/dist/public/loan-object.js +1 -1
- package/dist/public/loan-object.js.br +0 -0
- package/dist/public/loan-object.js.gz +0 -0
- package/dist/public/loan-object.js.map +1 -1
- package/dist/public/utils.js +1 -1
- package/dist/public/utils.js.br +0 -0
- package/dist/public/utils.js.gz +0 -0
- package/dist/public/utils.js.map +1 -1
- package/dist/umd/autoFill.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.br +0 -0
- package/dist/umd/index.js.gz +0 -0
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/init.js +1 -1
- package/dist/umd/init.js.br +0 -0
- package/dist/umd/init.js.gz +0 -0
- package/dist/umd/init.js.map +1 -1
- package/dist/umd/loan-object.js +1 -1
- package/dist/umd/loan-object.js.br +0 -0
- package/dist/umd/loan-object.js.gz +0 -0
- package/dist/umd/loan-object.js.map +1 -1
- package/dist/umd/utils.js +1 -1
- package/dist/umd/utils.js.br +0 -0
- package/dist/umd/utils.js.gz +0 -0
- package/dist/umd/utils.js.map +1 -1
- package/package.json +3 -3
- package/dist/public/js/emuiSsfHost.442f50c42583d524d78b.js +0 -3
- package/dist/public/js/emuiSsfHost.442f50c42583d524d78b.js.br +0 -0
- package/dist/public/js/emuiSsfHost.442f50c42583d524d78b.js.gz +0 -0
- package/dist/public/js/emuiSsfHost.442f50c42583d524d78b.js.map +0 -1
package/dist/umd/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(D,P){typeof exports=="object"&&typeof module=="object"?module.exports=P():typeof define=="function"&&define.amd?define([],P):typeof exports=="object"?exports.ice=P():D.ice=P()})(globalThis,()=>(()=>{"use strict";var j={};j.d=(e,i)=>{for(var o in i)j.o(i,o)&&!j.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:i[o]})},j.o=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),j.r=e=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var D={};j.r(D),j.d(D,{Event:()=>P,Guest:()=>Ue,IFrameSandboxValues:()=>G,OpenMode:()=>S,SSFHost:()=>gt,ScriptingObject:()=>Ce});class P{scriptingObject;name;objectId;requiresFeedback;id;constructor(i){const{name:o,requiresFeedback:t=!1,so:s}=i;if(!o)throw new Error("Event name is required");if(!s)throw new Error("Scripting object is required");this.scriptingObject=s,this.objectId=s.id,this.name=o,this.id=`${this.objectId}.${this.name}`.toLowerCase(),this.requiresFeedback=t}}const Xe=e=>e instanceof P,ft=(e,i)=>`${e.toLowerCase()}.${i.toLowerCase()}`;var Ye=Object.defineProperty,Ke=(e,i,o)=>i in e?Ye(e,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[i]=o,le=(e,i,o)=>(Ke(e,typeof i!="symbol"?i+"":i,o),o),Ge=(e,i,o)=>{if(!i.has(e))throw TypeError("Cannot "+o)},F=(e,i,o)=>(Ge(e,i,"read from private field"),o?o.call(e):i.get(e)),Ae=(e,i,o)=>{if(i.has(e))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(e):i.set(e,o)},Te=(e,i,o,t)=>(Ge(e,i,"write to private field"),t?t.call(e,o):i.set(e,o),o),B,R;const Qe="function",Ze=(e,i)=>typeof e===Qe&&!!i&&!i.startsWith("_");class Ce{constructor(i,o){Ae(this,B,void 0),Ae(this,R,"Object"),le(this,"_toJSON",()=>{const t=[],s=[];return Object.keys(this).forEach(r=>{const c=this[r];Xe(c)?s.push(r):Ze(c,r)&&t.push(r)}),{objectId:F(this,B),objectType:F(this,R),functions:t,events:s}}),le(this,"_dispose",()=>{}),le(this,"dispose",()=>{}),Te(this,B,i),Te(this,R,o||F(this,R))}get id(){return F(this,B)}get objectType(){return F(this,R)}}B=new WeakMap,R=new WeakMap;var O=(e=>(e.GuestReady="guest:ready",e.GuestClose="guest:close",e.GuestReadyComplete="guest:readyComplete",e.GuestResize="guest:resize",e.GuestFocus="guest:focus",e.HandShake="handshake",e.HandShakeAck="handshake:ack",e.ObjectInvoke="object:invoke",e.ObjectGet="object:get",e.ObjectEvent="object:event",e.HostConfig="host:config",e))(O||{}),S=(e=>(e.Popup="popup",e.Embed="embed",e))(S||{}),G=(e=>(e.AllowDownloadsWithoutUserActivation="allow-downloads-without-user-activation",e.AllowDownloads="allow-downloads",e.AllowForms="allow-forms",e.AllowModals="allow-modals",e.AllowOrientationLock="allow-orientation-lock",e.AllowPointerLock="allow-pointer-lock",e.AllowPopups="allow-popups",e.AllowPopupsToEscapeSandbox="allow-popups-to-escape-sandbox",e.AllowPresentation="allow-presentation",e.AllowSameOrigin="allow-same-origin",e.AllowScripts="allow-scripts",e.AllowStorageAccessByUserActivation="allow-storage-access-by-user-activation",e.AllowTopNavigation="allow-top-navigation",e.AllowTopNavigationByUserActivation="allow-top-navigation-by-user-activation",e))(G||{});const Ve=e=>{if(e==="about:blank")return"*";const{origin:i}=new URL(e);return i==="null"||!i?e:i},qe=(e,i=[])=>{const o=i||[];return e&&e.forEach?e.forEach(t=>{qe(t,o)}):typeof e<"u"&&o.push(e),o},vt=e=>typeof e?._toJSON=="function";function Re(e){return typeof e=="function"}const et=e=>e?.constructor?.name==="Proxy",mt=e=>e?.id??e;var tt=Object.defineProperty,it=(e,i,o)=>i in e?tt(e,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[i]=o,_=(e,i,o)=>(it(e,typeof i!="symbol"?i+"":i,o),o),xe=(e,i,o)=>{if(!i.has(e))throw TypeError("Cannot "+o)},x=(e,i,o)=>(xe(e,i,"read from private field"),o?o.call(e):i.get(e)),st=(e,i,o)=>{if(i.has(e))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(e):i.set(e,o)},nt=(e,i,o,t)=>(xe(e,i,"write to private field"),t?t.call(e,o):i.set(e,o),o),$;class Ue{constructor(i){_(this,"id"),_(this,"title"),_(this,"url"),_(this,"searchParams"),_(this,"domElement"),_(this,"window"),_(this,"openMode"),_(this,"origin"),_(this,"initialized",!1),_(this,"ready",!1),_(this,"capabilities"),st(this,$,void 0),_(this,"dispose",()=>{x(this,$).removeSender({origin:this.origin,window:this.window}),this.openMode===S.Popup?this.window.close():this.domElement?.remove?.()}),_(this,"getInfo",()=>({guestId:this.id,guestTitle:this.title,guestUrl:this.url})),_(this,"init",()=>{if(x(this,$).addSender({origin:this.origin,window:this.window}),this.openMode===S.Popup){const p=setInterval(()=>{x(this,$).send({targetWin:this.window,targetOrigin:this.origin,messageType:O.HandShake,messageBody:{}})},1e3);x(this,$).listen({messageType:O.HandShakeAck,callback:()=>{clearInterval(p)}})}}),_(this,"dispatchEvent",(p,m)=>x(this,$).invoke({targetWin:this.window,targetOrigin:this.origin,messageType:O.ObjectEvent,messageBody:p,responseTimeoutMs:m})),_(this,"send",p=>{x(this,$).send({targetWin:this.window,targetOrigin:this.origin,...p})});const{guestId:o,domElement:t=null,title:s,url:r,window:c,searchParams:a={},openMode:h=S.Embed,remoting:g}=i;this.id=o,this.title=s,this.url=r,this.origin=Ve(r),this.searchParams=a,this.domElement=t,this.window=c,this.openMode=h,this.capabilities={},nt(this,$,g)}}$=new WeakMap;const Le={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let Q;const ot=new Uint8Array(16);function rt(){if(!Q&&(Q=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Q))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Q(ot)}const b=[];for(let e=0;e<256;++e)b.push((e+256).toString(16).slice(1));function ze(e,i=0){return(b[e[i+0]]+b[e[i+1]]+b[e[i+2]]+b[e[i+3]]+"-"+b[e[i+4]]+b[e[i+5]]+"-"+b[e[i+6]]+b[e[i+7]]+"-"+b[e[i+8]]+b[e[i+9]]+"-"+b[e[i+10]]+b[e[i+11]]+b[e[i+12]]+b[e[i+13]]+b[e[i+14]]+b[e[i+15]]).toLowerCase()}function yt(e,i=0){const o=ze(e,i);if(!validate(o))throw TypeError("Stringified UUID is invalid");return o}const _t=null;function at(e,i,o){if(Le.randomUUID&&!i&&!e)return Le.randomUUID();e=e||{};const t=e.random||(e.rng||rt)();if(t[6]=t[6]&15|64,t[8]=t[8]&63|128,i){o=o||0;for(let s=0;s<16;++s)i[o+s]=t[s];return i}return ze(t)}const Ne=at;var ct=Object.defineProperty,lt=(e,i,o)=>i in e?ct(e,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[i]=o,W=(e,i,o)=>(lt(e,typeof i!="symbol"?i+"":i,o),o),De=(e,i,o)=>{if(!i.has(e))throw TypeError("Cannot "+o)},l=(e,i,o)=>(De(e,i,"read from private field"),o?o.call(e):i.get(e)),k=(e,i,o)=>{if(i.has(e))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(e):i.set(e,o)},Z=(e,i,o,t)=>(De(e,i,"write to private field"),t?t.call(e,o):i.set(e,o),o),H,w,J,A,T,U,he,de,ue,V,pe,ge,we,X;const Fe="elli:remoting",Be="elli:remoting:response",He="elli:remoting:exception",Y=({messageType:e,messageBody:i,onewayMsg:o=!1})=>({requestId:o?null:Ne(),source:Fe,type:e,body:i}),Et=e=>{const{targetWin:i,targetOrigin:o,messageType:t,messageBody:s}=e,r=Y({messageType:t,messageBody:s});i.postMessage(r,o)};class ht{constructor(i,o){if(k(this,H,void 0),k(this,w,void 0),k(this,J,new Map),k(this,A,new Map),k(this,T,null),k(this,U,new Map),k(this,he,()=>{const t=Date.now(),s=[];l(this,A).forEach((r,c)=>{const{requestId:a,cancelTime:h}=r;l(this,w).debug(`Checking response timeout for requestId: ${a}) @ ${h??""}`),r.cancelTime&&r.cancelTime<t&&(l(this,w).debug(`Detected response timeout for requestId: ${a}...`),s.push(c),r.resolve(),l(this,w).debug(`Aborted waiting for response to requestid: ${a})`))}),s.forEach(r=>{l(this,w).debug(`removing invocations with requestId ${r} from cache since response time has expired`),l(this,A).delete(r)}),l(this,A).size===0&&(l(this,w).debug("stopping response monitor"),l(this,ue).call(this))}),k(this,de,()=>{l(this,T)===null&&(l(this,w).debug("Staring response timeout evaluator"),Z(this,T,window.setInterval(l(this,he),200)))}),k(this,ue,()=>{l(this,T)!==null&&(window.clearInterval(l(this,T)),Z(this,T,null),l(this,w).debug("Stopped response timeout evaluator"))}),k(this,V,t=>{const s=l(this,A).get(t);return l(this,w).debug(`serving requestId: ${t}`),l(this,A).delete(t),s}),k(this,pe,t=>{const{requestId:s}=t;l(this,w).debug(`Response received for invocation requestId: ${s}`);const r=l(this,V).call(this,s);return r?(r.resolve(t.body),!0):(l(this,w).warn(`Received response to stale/invalid request with requestId: ${s}`),!1)}),k(this,ge,t=>{l(this,w).debug(`Exception received for invocation (requestId = ${t.requestId})`);const s=l(this,V).call(this,t.requestId);return s?(s.reject(new Error(t.body)),!0):(l(this,w).warn(`Received exception for stale/invalid request (requestId = ${t.requestId})`),!1)}),k(this,we,({sourceWin:t,sourceOrigin:s,message:r})=>{l(this,w).debug(`Received message of type "${r.type}"`);const c=l(this,J).get(r.type);return c?(c.forEach(a=>{l(this,w).debug(`Invoking message handler ${a.name}`),a({sourceWin:t,sourceOrigin:s,requestId:r.requestId,type:r.type,body:r.body})}),!0):!1}),k(this,X,t=>{if(l(this,w).debug(`Remoting: Received message ${JSON.stringify(t.data)}`),l(this,U).size===0||!t.source)return!1;const s=l(this,U).get(t.source);return!s||t?.data?.source!==Fe?!1:(t.data.type===Be?l(this,pe).call(this,t.data):t.data.type===He?l(this,ge).call(this,t.data):l(this,we).call(this,{sourceWin:t.source,sourceOrigin:s,message:t.data}),!0)}),W(this,"addSender",t=>{const{origin:s,window:r}=t;if(!s)throw new Error("origin is required");if(!r)throw new Error("window is required");l(this,U).set(r,s)}),W(this,"initialize",t=>{t.removeEventListener("message",l(this,X)),t.addEventListener("message",l(this,X)),l(this,w).debug(`initialized remoting id: ${l(this,H)}`)}),W(this,"close",()=>{window.removeEventListener("message",l(this,X)),l(this,w).debug(`closed remoting id: ${l(this,H)}`)}),W(this,"invoke",t=>{const{targetWin:s,targetOrigin:r,messageType:c,messageBody:a,responseTimeoutMs:h}=t;return new Promise((g,p)=>{const m=Y({messageType:c,messageBody:a});l(this,A).set(m.requestId,{requestId:m.requestId,resolve:g,reject:p,cancelTime:h?Date.now()+Number.parseInt(h,10):null}),s.postMessage(m,r);const{requestId:E}=m;l(this,w).debug(`Posted invocation message of type ${c} requestId: ${E||""}`),h&&(l(this,w).debug(`starting response monitor for requestId: ${E||""} for ${h} ms`),l(this,de).call(this))})}),W(this,"listen",t=>{const{messageType:s,callback:r}=t,c=l(this,J).get(s)||[];c.push(r),l(this,J).set(s,c)}),W(this,"send",t=>{const{targetWin:s,targetOrigin:r,messageType:c,messageBody:a}=t,h=Y({messageType:c,messageBody:a,onewayMsg:!0});s.postMessage(h,r),l(this,w).debug(`Posted one-way message of type "${c}"`)}),W(this,"removeSender",t=>{const{window:s}=t;s&&l(this,U).delete(s)}),W(this,"respond",t=>{const{targetWin:s,targetOrigin:r,requestId:c,response:a}=t,h=Y({messageType:Be,messageBody:a});h.requestId=c,s.postMessage(h,r),l(this,w).debug(`Response sent to caller for invocation requestId: ${c}`)}),W(this,"raiseException",t=>{const{targetWin:s,targetOrigin:r,requestId:c,ex:a}=t,h=Y({messageType:He,messageBody:a});h.requestId=c,s.postMessage(h,r),l(this,w).debug(`Exception sent to caller for invocation. requestId: ${c}`)}),!i)throw new Error("logger is required");if(!o)throw new Error("correlationId is required");Z(this,H,o),Z(this,w,i)}}H=new WeakMap,w=new WeakMap,J=new WeakMap,A=new WeakMap,T=new WeakMap,U=new WeakMap,he=new WeakMap,de=new WeakMap,ue=new WeakMap,V=new WeakMap,pe=new WeakMap,ge=new WeakMap,we=new WeakMap,X=new WeakMap;var dt=Object.defineProperty,ut=(e,i,o)=>i in e?dt(e,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[i]=o,M=(e,i,o)=>(ut(e,typeof i!="symbol"?i+"":i,o),o),Je=(e,i,o)=>{if(!i.has(e))throw TypeError("Cannot "+o)},n=(e,i,o)=>(Je(e,i,"read from private field"),o?o.call(e):i.get(e)),u=(e,i,o)=>{if(i.has(e))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(e):i.set(e,o)},L=(e,i,o,t)=>(Je(e,i,"write to private field"),t?t.call(e,o):i.set(e,o),o),v,z,d,K,I,C,ee,te,ie,q,fe,ve,se,me,ne,be,oe,ye,_e,Ee,ke,Oe,Me,Ie,Se,re,$e,We,je,Pe;const pt=[G.AllowScripts,G.AllowPopups,G.AllowModals,G.AllowForms,G.AllowDownloads,G.AllowSameOrigin].join(" ");class gt{constructor(i,o){if(M(this,"hostId"),u(this,v,void 0),u(this,z,void 0),u(this,d,void 0),u(this,K,1),u(this,I,new Map),u(this,C,new Map),u(this,ee,null),u(this,te,null),u(this,ie,()=>{for(const t of n(this,I).values())t.openMode===S.Popup&&this.unloadGuest(t.id)}),u(this,q,t=>{for(const s of n(this,I).values())if(s.window===t)return s;return null}),u(this,fe,t=>{for(const s of n(this,I).values())if(s.url===t)return s;return null}),u(this,ve,t=>typeof t?._toJSON=="function"),u(this,se,t=>n(this,ve).call(this,t)?(this.addScriptingObject(t),{type:"object",object:t._toJSON()}):{type:"value",value:t}),u(this,me,t=>typeof t=="string"?t:t instanceof Error?t.message:"An unexpected error occurred in the host application"),u(this,ne,t=>{t.ready&&n(this,v).send({targetWin:t.window,targetOrigin:t.origin,messageType:O.HostConfig,messageBody:{logLevel:n(this,d).getLogLevel(),...t.getInfo()}})}),u(this,be,({guest:t,obj:s,functionName:r,functionParams:c})=>{const a=s[r];return Re(a)?(n(this,d).debug(`Invoking host implementation of ${s.id}.${String(r)}()`),new Promise(h=>{Object.prototype.hasOwnProperty.call(a,"callContext")||Object.defineProperty(a,"callContext",{value:{guest:t},enumerable:!0}),h(a(...c))})):(n(this,d).warn(`Attempt to call invalid function on object type ${s.objectType}: ${String(r)}`),Promise.reject(new Error(`Method '${r}' not found in Scripting Object '${s.id}'`)))}),u(this,oe,({sourceWin:t,sourceOrigin:s,requestId:r})=>{var c;const a=n(this,q).call(this,t);if(!a){n(this,d).warn(`Received ready event for unknown guest. requestId: ${r}`);return}if(!a.initialized){n(this,d).warn("Guest must be initialized before it is marked as ready"),n(this,v).raiseException({targetWin:t,targetOrigin:s,requestId:r,ex:"Guest must be initialized before it is marked as ready"});return}a.ready||(a.ready=!0,n(this,ne).call(this,a),(c=n(this,ee))==null||c.call(this,a),n(this,d).audit({message:"Guest is ready",...a.getInfo()}))}),u(this,ye,({sourceWin:t,sourceOrigin:s,requestId:r,body:c})=>{const a=n(this,q).call(this,t);if(!a){n(this,d).warn(`Received ready event for unknown guest. requestid = ${r}`);return}a.initialized||(a.initialized=!0,a.capabilities=c||{},n(this,d).audit({message:"Guest is initialized",...a.getInfo()})),(!c||!c.onReady)&&n(this,oe).call(this,{sourceWin:t,sourceOrigin:s,requestId:r,type:"",body:null})}),u(this,_e,({sourceWin:t})=>{t?.window&&this.unloadGuest(t)}),u(this,Ee,({sourceWin:t,sourceOrigin:s,requestId:r,body:c})=>{const{objectId:a}=c;n(this,d).debug(`Processing getObject request for object ${a}. requestId = ${r}`);const h=n(this,q).call(this,t);if(!h)return n(this,d).warn("Rejected object request from unknown guest window"),n(this,v).raiseException({targetWin:t,targetOrigin:s,requestId:r,ex:"Specified window is not a known guest"}),!1;const g=this.getScriptingObject(a);return g?(n(this,v).respond({targetWin:t,targetOrigin:s,requestId:r,response:n(this,se).call(this,g)}),n(this,d).audit({message:"Scripting Object returned",requestId:r,scriptingObject:a,...h.getInfo()}),!0):(n(this,d).warn(`unknown or unauthorized object ${a} from guest ${h.id}`),n(this,v).raiseException({targetWin:t,targetOrigin:s,requestId:r,ex:`The requested object (${a}) is not available`}),!1)}),u(this,ke,({sourceWin:t,requestId:s,body:r})=>{const c=n(this,q).call(this,t);if(!c){n(this,d).warn(`Received resize event from unknown guest. requestid = ${s}`);return}c.domElement&&(c.domElement.style.height=`${r.height}px`),n(this,d).debug(`Guest ${c.id} resized to ${r.width}x${r.height}`)}),u(this,Oe,({sourceWin:t,sourceOrigin:s,requestId:r,body:c})=>{const{objectId:a}=c,h=n(this,q).call(this,t);if(!h)return n(this,d).warn("Rejected method invocation request from unknown guest window"),n(this,v).raiseException({targetWin:t,targetOrigin:s,requestId:r,ex:"Specified window is not a known guest"}),!1;n(this,d).debug(`Function ${a}.${String(c.functionName)}() called from guest "${h.id}" (requestId = ${r})`);const g=this.getScriptingObject(a);return g?(n(this,be).call(this,{guest:h,obj:g,functionName:c.functionName,functionParams:c.functionParams}).then(p=>{n(this,v).respond({targetWin:t,targetOrigin:s,requestId:r,response:n(this,se).call(this,p)}),n(this,d).audit({message:"Value returned for Scripting Object method call",requestId:r,scriptingObject:a,scriptingMethod:c.functionName,...h.getInfo()})}).catch(p=>{n(this,v).raiseException({targetWin:t,targetOrigin:h.origin,requestId:r,ex:n(this,me).call(this,p)}),n(this,d).audit({message:"Exception thrown for Scripting Object method call",requestId:r,scriptingObject:a,scriptingMethod:c.functionName,...h.getInfo()})}),!0):(n(this,d).warn(`Invocation of unknown or unauthorized object ${a} from guest ${h.id}`),n(this,v).raiseException({targetWin:t,targetOrigin:s,requestId:r,ex:`The requested object (${a}) is not available`}),!1)}),u(this,Me,()=>{n(this,v).listen({messageType:O.GuestResize,callback:n(this,ke)})}),u(this,Ie,()=>{n(this,v).listen({messageType:O.GuestReady,callback:n(this,ye)}),n(this,v).listen({messageType:O.GuestReadyComplete,callback:n(this,oe)}),n(this,v).listen({messageType:O.GuestClose,callback:n(this,_e)}),n(this,v).listen({messageType:O.ObjectGet,callback:n(this,Ee)}),n(this,v).listen({messageType:O.ObjectInvoke,callback:n(this,Oe)}),window.addEventListener("visibilitychange",n(this,ie))}),u(this,Se,t=>t?.constructor?.name==="ProxyEvent"),u(this,re,t=>{const s=new Ue({...t,remoting:n(this,v)});return s.init(),n(this,I).set(t.guestId,s),s}),u(this,$e,()=>{L(this,te,setInterval(()=>{const t=[];n(this,I).forEach(s=>{s.openMode===S.Popup&&s.window.closed&&t.push(s)}),t.forEach(s=>{this.unloadGuest(s.id)})},1e3))}),u(this,We,t=>{const{url:s,title:r,popupWindowFeatures:c={},searchParams:a,guestId:h}=t,{width:g=800,height:p=600,top:m=100,left:E=100}=c;let y=n(this,fe).call(this,s);if(y)y.window.closed||y.send({messageType:O.GuestFocus,messageBody:{}});else{const ae=[{key:"width",value:g},{key:"height",value:p},{key:"top",value:m},{key:"left",value:E}].reduce((N,ce,wt)=>(wt>0&&ce.value&&(N+=","),ce.value?`${N}${ce.key}=${ce.value}`:N),""),f=window.open(s,r,`popup, ${ae}`);if(!f)throw new Error("Failed to open guest application in popup window");f.opener=null,y=n(this,re).call(this,{guestId:h,window:f,title:r,url:s,searchParams:a,openMode:S.Popup})}return y}),u(this,je,t=>{const{url:s,title:r,targetElement:c,searchParams:a,guestId:h,options:g={}}=t,p=c.ownerDocument??document,{fitToContent:m=!1,disableSandbox:E=!1,sandboxValues:y=[],style:ae=""}=g;if(!r)throw new Error("title is required");m&&n(this,Me).call(this);const f=p.createElement("iframe");f.setAttribute("id",h),f.addEventListener("load",()=>{n(this,d).debug(`frame loaded for guest with id '${h}'`)}),f.setAttribute("style",`min-width: 100%; height: 100%; border: 0px; ${ae}`),E||f.setAttribute("sandbox",`${pt} ${y.join(" ")}`),f.setAttribute("title",r),f.setAttribute("src",s),c.appendChild(f);const N=p.getElementById(h);return n(this,re).call(this,{guestId:h,domElement:N,window:N.contentWindow,title:r,url:s,searchParams:a,openMode:S.Embed})}),u(this,Pe,(t,s)=>{let r="";return Object.keys(s).forEach(c=>{r+=`${(r.length?"&":"")+encodeURIComponent(c)}=${encodeURIComponent(s[c])}`}),t+(r?(t.indexOf("?")>=0?"&":"?")+r:"")}),M(this,"addScriptingObject",t=>{if(!t?.id||!t?._toJSON)throw new Error("Object is not derived from ScriptingObject");if(t.id.toLowerCase()==="module")throw new Error("Do not publish the module object. Create a concrete object derived from it.");n(this,C).set(t.id,t)}),M(this,"cloneScriptingObject",(t,s)=>{if(!t)throw new Error("proxy is required");if(!s)throw new Error("guest is required");const r=new Ce(t.id,t.objectType);let c=[];return Object.keys(t).forEach(a=>{const h=t[a];if(n(this,Se).call(this,h)){const g=new P({name:h.name,requiresFeedback:!1,so:r});Object.defineProperty(r,a,{value:g,enumerable:!0});const p=({eventParams:E,eventOptions:y})=>this.dispatchEvent({event:g,eventParams:E,eventOptions:y}),m=s.subscribe({eventId:h.id,callback:p});c.push(()=>{s.unsubscribe({eventId:h.id,token:m})})}else if(Re(h)&&(Object.defineProperty(r,a,{value:async(...g)=>{const p=await h(...g);return et(p)?this.cloneScriptingObject(p,s):p},enumerable:!0}),a==="dispose")){const g=r.dispose;Object.defineProperty(r,a,{value:()=>(r._dispose(),g.apply(r)),enumerable:!0})}}),r._dispose=()=>{c.forEach(a=>{a?.()}),c=[]},r}),M(this,"close",()=>{clearInterval(n(this,te)),n(this,v).close(),window.removeEventListener("visibilitychange",n(this,ie)),n(this,d).debug(`host is closed. hostId: ${this.hostId}, correlationId: ${n(this,z)}`)}),M(this,"dispatchEvent",async t=>{const{event:{id:s,name:r,scriptingObject:c},eventParams:a,eventOptions:h={}}=t,{eventHandler:g=null,timeout:p=null,window:m=null}=h,E={object:c._toJSON(),eventName:r,eventParams:a,eventHandler:g,eventOptions:{allowsFeedback:!1}};p&&!Number.isNaN(p)&&(E.eventOptions={allowsFeedback:!0,timeout:Number(p)});const y=[];return n(this,I).forEach(f=>{(!m||m===f.window)&&(p&&f?.capabilities?.eventFeedback?(y.push(f.dispatchEvent(E,p)),n(this,d).audit({message:"Event dispatched and awaiting feedback",scriptingEventId:s,...f.getInfo()})):(f.send({messageType:O.ObjectEvent,messageBody:E}),n(this,d).audit({message:"Event dispatched",scriptingEventId:s,...f.getInfo()})))}),await Promise.all(y).then(f=>(n(this,d).audit({message:"Event feedback received",scriptingEventId:s}),qe(f))).catch(f=>{throw n(this,d).error({message:"Error processing event",eventId:s,exception:f}),f})}),M(this,"getGuests",()=>{const t=[];return n(this,I).forEach(s=>{t.push(s)}),t}),M(this,"getScriptingObject",t=>n(this,C).has(t)?n(this,C).get(t):null),M(this,"loadGuest",t=>{const{url:s,targetElement:r,title:c,searchParams:a={},options:h={}}=t,{openMode:g=S.Embed,popupWindowFeatures:p={}}=h,m=`guest-${this.hostId}-sandbox-${n(this,K)}`;L(this,K,n(this,K)+1);const E=n(this,Pe).call(this,s,a);let y=null;if(g===S.Popup)y=n(this,We).call(this,{guestId:m,url:E,title:c,searchParams:a,popupWindowFeatures:p});else if(g===S.Embed)y=n(this,je).call(this,{guestId:m,url:E,title:c,targetElement:r,searchParams:a,options:h});else throw new Error(`Invalid openMode: ${g}`);return n(this,d).audit({message:"Guest loaded",...y.getInfo()}),y}),M(this,"loadGuests",t=>{const{url:s,targetElement:r,title:c,searchParamsList:a=[],options:h={}}=t;a.forEach(g=>{this.loadGuest({url:s,title:c,targetElement:r,searchParams:g,options:h})},this)}),M(this,"removeAllScriptingObjects",()=>{Array.from(n(this,C).keys()).forEach(s=>{this.removeScriptingObject(s)})}),M(this,"removeScriptingObject",t=>{const s=this.getScriptingObject(t);s&&(s._dispose&&typeof s._dispose=="function"&&s._dispose(),n(this,C).delete(t))}),M(this,"setLogLevel",t=>{n(this,d).setLogLevel(t),n(this,I).forEach(n(this,ne)),n(this,d).debug("Dispatched config events to all guests")}),M(this,"unloadGuest",t=>{let s=typeof t=="string"?n(this,I).get(t):null;if(!s&&(s=Array.from(n(this,I).values()).find(r=>r.window===t||r.domElement===t),!s))throw new Error("Invalid guestId or guestWindow reference");s.dispose(),n(this,I).delete(s.id),n(this,d).audit({message:"Guest is removed from host",...s.getInfo()})}),this.hostId=i,!o?.logger)throw new Error("Logger is required");if(L(this,d,o.logger),L(this,z,Ne()),L(this,v,new ht(n(this,d),n(this,z))),o?.readyStateCallback&&typeof o?.readyStateCallback!="function")throw new Error("readyStateCallback must be a function");L(this,ee,o?.readyStateCallback||null),n(this,v).initialize(window),n(this,Ie).call(this),n(this,$e).call(this),n(this,d).debug(`host is initialized. hostId: ${this.hostId}, correlationId: ${n(this,z)}`)}}return v=new WeakMap,z=new WeakMap,d=new WeakMap,K=new WeakMap,I=new WeakMap,C=new WeakMap,ee=new WeakMap,te=new WeakMap,ie=new WeakMap,q=new WeakMap,fe=new WeakMap,ve=new WeakMap,se=new WeakMap,me=new WeakMap,ne=new WeakMap,be=new WeakMap,oe=new WeakMap,ye=new WeakMap,_e=new WeakMap,Ee=new WeakMap,ke=new WeakMap,Oe=new WeakMap,Me=new WeakMap,Ie=new WeakMap,Se=new WeakMap,re=new WeakMap,$e=new WeakMap,We=new WeakMap,je=new WeakMap,Pe=new WeakMap,D})());
|
|
1
|
+
(function(T,P){typeof exports=="object"&&typeof module=="object"?module.exports=P():typeof define=="function"&&define.amd?define([],P):typeof exports=="object"?exports.ice=P():(T.ice=T.ice||{},T.ice.host=P())})(globalThis,()=>(()=>{"use strict";var j={};j.d=(e,i)=>{for(var o in i)j.o(i,o)&&!j.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:i[o]})},j.o=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),j.r=e=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var T={};j.r(T),j.d(T,{Event:()=>P,Guest:()=>Ue,IFrameSandboxValues:()=>G,OpenMode:()=>S,SSFHost:()=>gt,ScriptingObject:()=>Ce});class P{scriptingObject;name;objectId;requiresFeedback;id;constructor(i){const{name:o,requiresFeedback:t=!1,so:s}=i;if(!o)throw new Error("Event name is required");if(!s)throw new Error("Scripting object is required");this.scriptingObject=s,this.objectId=s.id,this.name=o,this.id=`${this.objectId}.${this.name}`.toLowerCase(),this.requiresFeedback=t}}const Xe=e=>e instanceof P,ft=(e,i)=>`${e.toLowerCase()}.${i.toLowerCase()}`;var Ye=Object.defineProperty,Ke=(e,i,o)=>i in e?Ye(e,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[i]=o,le=(e,i,o)=>(Ke(e,typeof i!="symbol"?i+"":i,o),o),Ge=(e,i,o)=>{if(!i.has(e))throw TypeError("Cannot "+o)},F=(e,i,o)=>(Ge(e,i,"read from private field"),o?o.call(e):i.get(e)),Ae=(e,i,o)=>{if(i.has(e))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(e):i.set(e,o)},Te=(e,i,o,t)=>(Ge(e,i,"write to private field"),t?t.call(e,o):i.set(e,o),o),B,x;const Qe="function",Ze=(e,i)=>typeof e===Qe&&!!i&&!i.startsWith("_");class Ce{constructor(i,o){Ae(this,B,void 0),Ae(this,x,"Object"),le(this,"_toJSON",()=>{const t=[],s=[];return Object.keys(this).forEach(r=>{const c=this[r];Xe(c)?s.push(r):Ze(c,r)&&t.push(r)}),{objectId:F(this,B),objectType:F(this,x),functions:t,events:s}}),le(this,"_dispose",()=>{}),le(this,"dispose",()=>{}),Te(this,B,i),Te(this,x,o||F(this,x))}get id(){return F(this,B)}get objectType(){return F(this,x)}}B=new WeakMap,x=new WeakMap;var O=(e=>(e.GuestReady="guest:ready",e.GuestClose="guest:close",e.GuestReadyComplete="guest:readyComplete",e.GuestResize="guest:resize",e.GuestFocus="guest:focus",e.HandShake="handshake",e.HandShakeAck="handshake:ack",e.ObjectInvoke="object:invoke",e.ObjectGet="object:get",e.ObjectEvent="object:event",e.HostConfig="host:config",e))(O||{}),S=(e=>(e.Popup="popup",e.Embed="embed",e))(S||{}),G=(e=>(e.AllowDownloadsWithoutUserActivation="allow-downloads-without-user-activation",e.AllowDownloads="allow-downloads",e.AllowForms="allow-forms",e.AllowModals="allow-modals",e.AllowOrientationLock="allow-orientation-lock",e.AllowPointerLock="allow-pointer-lock",e.AllowPopups="allow-popups",e.AllowPopupsToEscapeSandbox="allow-popups-to-escape-sandbox",e.AllowPresentation="allow-presentation",e.AllowSameOrigin="allow-same-origin",e.AllowScripts="allow-scripts",e.AllowStorageAccessByUserActivation="allow-storage-access-by-user-activation",e.AllowTopNavigation="allow-top-navigation",e.AllowTopNavigationByUserActivation="allow-top-navigation-by-user-activation",e))(G||{});const Ve=e=>{if(e==="about:blank")return"*";const{origin:i}=new URL(e);return i==="null"||!i?e:i},qe=(e,i=[])=>{const o=i||[];return e&&e.forEach?e.forEach(t=>{qe(t,o)}):typeof e<"u"&&o.push(e),o},vt=e=>typeof e?._toJSON=="function";function Re(e){return typeof e=="function"}const et=e=>e?.constructor?.name==="Proxy",mt=e=>e?.id??e;var tt=Object.defineProperty,it=(e,i,o)=>i in e?tt(e,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[i]=o,_=(e,i,o)=>(it(e,typeof i!="symbol"?i+"":i,o),o),xe=(e,i,o)=>{if(!i.has(e))throw TypeError("Cannot "+o)},U=(e,i,o)=>(xe(e,i,"read from private field"),o?o.call(e):i.get(e)),st=(e,i,o)=>{if(i.has(e))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(e):i.set(e,o)},nt=(e,i,o,t)=>(xe(e,i,"write to private field"),t?t.call(e,o):i.set(e,o),o),$;class Ue{constructor(i){_(this,"id"),_(this,"title"),_(this,"url"),_(this,"searchParams"),_(this,"domElement"),_(this,"window"),_(this,"openMode"),_(this,"origin"),_(this,"initialized",!1),_(this,"ready",!1),_(this,"capabilities"),st(this,$,void 0),_(this,"dispose",()=>{U(this,$).removeSender({origin:this.origin,window:this.window}),this.openMode===S.Popup?this.window.close():this.domElement?.remove?.()}),_(this,"getInfo",()=>({guestId:this.id,guestTitle:this.title,guestUrl:this.url})),_(this,"init",()=>{if(U(this,$).addSender({origin:this.origin,window:this.window}),this.openMode===S.Popup){const p=setInterval(()=>{U(this,$).send({targetWin:this.window,targetOrigin:this.origin,messageType:O.HandShake,messageBody:{}})},1e3);U(this,$).listen({messageType:O.HandShakeAck,callback:()=>{clearInterval(p)}})}}),_(this,"dispatchEvent",(p,m)=>U(this,$).invoke({targetWin:this.window,targetOrigin:this.origin,messageType:O.ObjectEvent,messageBody:p,responseTimeoutMs:m})),_(this,"send",p=>{U(this,$).send({targetWin:this.window,targetOrigin:this.origin,...p})});const{guestId:o,domElement:t=null,title:s,url:r,window:c,searchParams:a={},openMode:h=S.Embed,remoting:g}=i;this.id=o,this.title=s,this.url=r,this.origin=Ve(r),this.searchParams=a,this.domElement=t,this.window=c,this.openMode=h,this.capabilities={},nt(this,$,g)}}$=new WeakMap;const Le={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let Q;const ot=new Uint8Array(16);function rt(){if(!Q&&(Q=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Q))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Q(ot)}const b=[];for(let e=0;e<256;++e)b.push((e+256).toString(16).slice(1));function ze(e,i=0){return(b[e[i+0]]+b[e[i+1]]+b[e[i+2]]+b[e[i+3]]+"-"+b[e[i+4]]+b[e[i+5]]+"-"+b[e[i+6]]+b[e[i+7]]+"-"+b[e[i+8]]+b[e[i+9]]+"-"+b[e[i+10]]+b[e[i+11]]+b[e[i+12]]+b[e[i+13]]+b[e[i+14]]+b[e[i+15]]).toLowerCase()}function yt(e,i=0){const o=ze(e,i);if(!validate(o))throw TypeError("Stringified UUID is invalid");return o}const _t=null;function at(e,i,o){if(Le.randomUUID&&!i&&!e)return Le.randomUUID();e=e||{};const t=e.random||(e.rng||rt)();if(t[6]=t[6]&15|64,t[8]=t[8]&63|128,i){o=o||0;for(let s=0;s<16;++s)i[o+s]=t[s];return i}return ze(t)}const Ne=at;var ct=Object.defineProperty,lt=(e,i,o)=>i in e?ct(e,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[i]=o,W=(e,i,o)=>(lt(e,typeof i!="symbol"?i+"":i,o),o),De=(e,i,o)=>{if(!i.has(e))throw TypeError("Cannot "+o)},l=(e,i,o)=>(De(e,i,"read from private field"),o?o.call(e):i.get(e)),k=(e,i,o)=>{if(i.has(e))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(e):i.set(e,o)},Z=(e,i,o,t)=>(De(e,i,"write to private field"),t?t.call(e,o):i.set(e,o),o),H,w,J,A,C,L,he,de,ue,V,pe,ge,we,X;const Fe="elli:remoting",Be="elli:remoting:response",He="elli:remoting:exception",Y=({messageType:e,messageBody:i,onewayMsg:o=!1})=>({requestId:o?null:Ne(),source:Fe,type:e,body:i}),Et=e=>{const{targetWin:i,targetOrigin:o,messageType:t,messageBody:s}=e,r=Y({messageType:t,messageBody:s});i.postMessage(r,o)};class ht{constructor(i,o){if(k(this,H,void 0),k(this,w,void 0),k(this,J,new Map),k(this,A,new Map),k(this,C,null),k(this,L,new Map),k(this,he,()=>{const t=Date.now(),s=[];l(this,A).forEach((r,c)=>{const{requestId:a,cancelTime:h}=r;l(this,w).debug(`Checking response timeout for requestId: ${a}) @ ${h??""}`),r.cancelTime&&r.cancelTime<t&&(l(this,w).debug(`Detected response timeout for requestId: ${a}...`),s.push(c),r.resolve(),l(this,w).debug(`Aborted waiting for response to requestid: ${a})`))}),s.forEach(r=>{l(this,w).debug(`removing invocations with requestId ${r} from cache since response time has expired`),l(this,A).delete(r)}),l(this,A).size===0&&(l(this,w).debug("stopping response monitor"),l(this,ue).call(this))}),k(this,de,()=>{l(this,C)===null&&(l(this,w).debug("Staring response timeout evaluator"),Z(this,C,window.setInterval(l(this,he),200)))}),k(this,ue,()=>{l(this,C)!==null&&(window.clearInterval(l(this,C)),Z(this,C,null),l(this,w).debug("Stopped response timeout evaluator"))}),k(this,V,t=>{const s=l(this,A).get(t);return l(this,w).debug(`serving requestId: ${t}`),l(this,A).delete(t),s}),k(this,pe,t=>{const{requestId:s}=t;l(this,w).debug(`Response received for invocation requestId: ${s}`);const r=l(this,V).call(this,s);return r?(r.resolve(t.body),!0):(l(this,w).warn(`Received response to stale/invalid request with requestId: ${s}`),!1)}),k(this,ge,t=>{l(this,w).debug(`Exception received for invocation (requestId = ${t.requestId})`);const s=l(this,V).call(this,t.requestId);return s?(s.reject(new Error(t.body)),!0):(l(this,w).warn(`Received exception for stale/invalid request (requestId = ${t.requestId})`),!1)}),k(this,we,({sourceWin:t,sourceOrigin:s,message:r})=>{l(this,w).debug(`Received message of type "${r.type}"`);const c=l(this,J).get(r.type);return c?(c.forEach(a=>{l(this,w).debug(`Invoking message handler ${a.name}`),a({sourceWin:t,sourceOrigin:s,requestId:r.requestId,type:r.type,body:r.body})}),!0):!1}),k(this,X,t=>{if(l(this,w).debug(`Remoting: Received message ${JSON.stringify(t.data)}`),l(this,L).size===0||!t.source)return!1;const s=l(this,L).get(t.source);return!s||t?.data?.source!==Fe?!1:(t.data.type===Be?l(this,pe).call(this,t.data):t.data.type===He?l(this,ge).call(this,t.data):l(this,we).call(this,{sourceWin:t.source,sourceOrigin:s,message:t.data}),!0)}),W(this,"addSender",t=>{const{origin:s,window:r}=t;if(!s)throw new Error("origin is required");if(!r)throw new Error("window is required");l(this,L).set(r,s)}),W(this,"initialize",t=>{t.removeEventListener("message",l(this,X)),t.addEventListener("message",l(this,X)),l(this,w).debug(`initialized remoting id: ${l(this,H)}`)}),W(this,"close",()=>{window.removeEventListener("message",l(this,X)),l(this,w).debug(`closed remoting id: ${l(this,H)}`)}),W(this,"invoke",t=>{const{targetWin:s,targetOrigin:r,messageType:c,messageBody:a,responseTimeoutMs:h}=t;return new Promise((g,p)=>{const m=Y({messageType:c,messageBody:a});l(this,A).set(m.requestId,{requestId:m.requestId,resolve:g,reject:p,cancelTime:h?Date.now()+Number.parseInt(h,10):null}),s.postMessage(m,r);const{requestId:E}=m;l(this,w).debug(`Posted invocation message of type ${c} requestId: ${E||""}`),h&&(l(this,w).debug(`starting response monitor for requestId: ${E||""} for ${h} ms`),l(this,de).call(this))})}),W(this,"listen",t=>{const{messageType:s,callback:r}=t,c=l(this,J).get(s)||[];c.push(r),l(this,J).set(s,c)}),W(this,"send",t=>{const{targetWin:s,targetOrigin:r,messageType:c,messageBody:a}=t,h=Y({messageType:c,messageBody:a,onewayMsg:!0});s.postMessage(h,r),l(this,w).debug(`Posted one-way message of type "${c}"`)}),W(this,"removeSender",t=>{const{window:s}=t;s&&l(this,L).delete(s)}),W(this,"respond",t=>{const{targetWin:s,targetOrigin:r,requestId:c,response:a}=t,h=Y({messageType:Be,messageBody:a});h.requestId=c,s.postMessage(h,r),l(this,w).debug(`Response sent to caller for invocation requestId: ${c}`)}),W(this,"raiseException",t=>{const{targetWin:s,targetOrigin:r,requestId:c,ex:a}=t,h=Y({messageType:He,messageBody:a});h.requestId=c,s.postMessage(h,r),l(this,w).debug(`Exception sent to caller for invocation. requestId: ${c}`)}),!i)throw new Error("logger is required");if(!o)throw new Error("correlationId is required");Z(this,H,o),Z(this,w,i)}}H=new WeakMap,w=new WeakMap,J=new WeakMap,A=new WeakMap,C=new WeakMap,L=new WeakMap,he=new WeakMap,de=new WeakMap,ue=new WeakMap,V=new WeakMap,pe=new WeakMap,ge=new WeakMap,we=new WeakMap,X=new WeakMap;var dt=Object.defineProperty,ut=(e,i,o)=>i in e?dt(e,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[i]=o,M=(e,i,o)=>(ut(e,typeof i!="symbol"?i+"":i,o),o),Je=(e,i,o)=>{if(!i.has(e))throw TypeError("Cannot "+o)},n=(e,i,o)=>(Je(e,i,"read from private field"),o?o.call(e):i.get(e)),u=(e,i,o)=>{if(i.has(e))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(e):i.set(e,o)},z=(e,i,o,t)=>(Je(e,i,"write to private field"),t?t.call(e,o):i.set(e,o),o),v,N,d,K,I,q,ee,te,ie,R,fe,ve,se,me,ne,be,oe,ye,_e,Ee,ke,Oe,Me,Ie,Se,re,$e,We,je,Pe;const pt=[G.AllowScripts,G.AllowPopups,G.AllowModals,G.AllowForms,G.AllowDownloads,G.AllowSameOrigin].join(" ");class gt{constructor(i,o){if(M(this,"hostId"),u(this,v,void 0),u(this,N,void 0),u(this,d,void 0),u(this,K,1),u(this,I,new Map),u(this,q,new Map),u(this,ee,null),u(this,te,null),u(this,ie,()=>{for(const t of n(this,I).values())t.openMode===S.Popup&&this.unloadGuest(t.id)}),u(this,R,t=>{for(const s of n(this,I).values())if(s.window===t)return s;return null}),u(this,fe,t=>{for(const s of n(this,I).values())if(s.url===t)return s;return null}),u(this,ve,t=>typeof t?._toJSON=="function"),u(this,se,t=>n(this,ve).call(this,t)?(this.addScriptingObject(t),{type:"object",object:t._toJSON()}):{type:"value",value:t}),u(this,me,t=>typeof t=="string"?t:t instanceof Error?t.message:"An unexpected error occurred in the host application"),u(this,ne,t=>{t.ready&&n(this,v).send({targetWin:t.window,targetOrigin:t.origin,messageType:O.HostConfig,messageBody:{logLevel:n(this,d).getLogLevel(),...t.getInfo()}})}),u(this,be,({guest:t,obj:s,functionName:r,functionParams:c})=>{const a=s[r];return Re(a)?(n(this,d).debug(`Invoking host implementation of ${s.id}.${String(r)}()`),new Promise(h=>{Object.prototype.hasOwnProperty.call(a,"callContext")||Object.defineProperty(a,"callContext",{value:{guest:t},enumerable:!0}),h(a(...c))})):(n(this,d).warn(`Attempt to call invalid function on object type ${s.objectType}: ${String(r)}`),Promise.reject(new Error(`Method '${r}' not found in Scripting Object '${s.id}'`)))}),u(this,oe,({sourceWin:t,sourceOrigin:s,requestId:r})=>{var c;const a=n(this,R).call(this,t);if(!a){n(this,d).warn(`Received ready event for unknown guest. requestId: ${r}`);return}if(!a.initialized){n(this,d).warn("Guest must be initialized before it is marked as ready"),n(this,v).raiseException({targetWin:t,targetOrigin:s,requestId:r,ex:"Guest must be initialized before it is marked as ready"});return}a.ready||(a.ready=!0,n(this,ne).call(this,a),(c=n(this,ee))==null||c.call(this,a),n(this,d).audit({message:"Guest is ready",...a.getInfo()}))}),u(this,ye,({sourceWin:t,sourceOrigin:s,requestId:r,body:c})=>{const a=n(this,R).call(this,t);if(!a){n(this,d).warn(`Received ready event for unknown guest. requestid = ${r}`);return}a.initialized||(a.initialized=!0,a.capabilities=c||{},n(this,d).audit({message:"Guest is initialized",...a.getInfo()})),(!c||!c.onReady)&&n(this,oe).call(this,{sourceWin:t,sourceOrigin:s,requestId:r,type:"",body:null})}),u(this,_e,({sourceWin:t})=>{t?.window&&this.unloadGuest(t)}),u(this,Ee,({sourceWin:t,sourceOrigin:s,requestId:r,body:c})=>{const{objectId:a}=c;n(this,d).debug(`Processing getObject request for object ${a}. requestId = ${r}`);const h=n(this,R).call(this,t);if(!h)return n(this,d).warn("Rejected object request from unknown guest window"),n(this,v).raiseException({targetWin:t,targetOrigin:s,requestId:r,ex:"Specified window is not a known guest"}),!1;const g=this.getScriptingObject(a);return g?(n(this,v).respond({targetWin:t,targetOrigin:s,requestId:r,response:n(this,se).call(this,g)}),n(this,d).audit({message:"Scripting Object returned",requestId:r,scriptingObject:a,...h.getInfo()}),!0):(n(this,d).warn(`unknown or unauthorized object ${a} from guest ${h.id}`),n(this,v).raiseException({targetWin:t,targetOrigin:s,requestId:r,ex:`The requested object (${a}) is not available`}),!1)}),u(this,ke,({sourceWin:t,requestId:s,body:r})=>{const c=n(this,R).call(this,t);if(!c){n(this,d).warn(`Received resize event from unknown guest. requestid = ${s}`);return}c.domElement&&(c.domElement.style.height=`${r.height}px`),n(this,d).debug(`Guest ${c.id} resized to ${r.width}x${r.height}`)}),u(this,Oe,({sourceWin:t,sourceOrigin:s,requestId:r,body:c})=>{const{objectId:a}=c,h=n(this,R).call(this,t);if(!h)return n(this,d).warn("Rejected method invocation request from unknown guest window"),n(this,v).raiseException({targetWin:t,targetOrigin:s,requestId:r,ex:"Specified window is not a known guest"}),!1;n(this,d).debug(`Function ${a}.${String(c.functionName)}() called from guest "${h.id}" (requestId = ${r})`);const g=this.getScriptingObject(a);return g?(n(this,be).call(this,{guest:h,obj:g,functionName:c.functionName,functionParams:c.functionParams}).then(p=>{n(this,v).respond({targetWin:t,targetOrigin:s,requestId:r,response:n(this,se).call(this,p)}),n(this,d).audit({message:"Value returned for Scripting Object method call",requestId:r,scriptingObject:a,scriptingMethod:c.functionName,...h.getInfo()})}).catch(p=>{n(this,v).raiseException({targetWin:t,targetOrigin:h.origin,requestId:r,ex:n(this,me).call(this,p)}),n(this,d).audit({message:"Exception thrown for Scripting Object method call",requestId:r,scriptingObject:a,scriptingMethod:c.functionName,...h.getInfo()})}),!0):(n(this,d).warn(`Invocation of unknown or unauthorized object ${a} from guest ${h.id}`),n(this,v).raiseException({targetWin:t,targetOrigin:s,requestId:r,ex:`The requested object (${a}) is not available`}),!1)}),u(this,Me,()=>{n(this,v).listen({messageType:O.GuestResize,callback:n(this,ke)})}),u(this,Ie,()=>{n(this,v).listen({messageType:O.GuestReady,callback:n(this,ye)}),n(this,v).listen({messageType:O.GuestReadyComplete,callback:n(this,oe)}),n(this,v).listen({messageType:O.GuestClose,callback:n(this,_e)}),n(this,v).listen({messageType:O.ObjectGet,callback:n(this,Ee)}),n(this,v).listen({messageType:O.ObjectInvoke,callback:n(this,Oe)}),window.addEventListener("visibilitychange",n(this,ie))}),u(this,Se,t=>t?.constructor?.name==="ProxyEvent"),u(this,re,t=>{const s=new Ue({...t,remoting:n(this,v)});return s.init(),n(this,I).set(t.guestId,s),s}),u(this,$e,()=>{z(this,te,setInterval(()=>{const t=[];n(this,I).forEach(s=>{s.openMode===S.Popup&&s.window.closed&&t.push(s)}),t.forEach(s=>{this.unloadGuest(s.id)})},1e3))}),u(this,We,t=>{const{url:s,title:r,popupWindowFeatures:c={},searchParams:a,guestId:h}=t,{width:g=800,height:p=600,top:m=100,left:E=100}=c;let y=n(this,fe).call(this,s);if(y)y.window.closed||y.send({messageType:O.GuestFocus,messageBody:{}});else{const ae=[{key:"width",value:g},{key:"height",value:p},{key:"top",value:m},{key:"left",value:E}].reduce((D,ce,wt)=>(wt>0&&ce.value&&(D+=","),ce.value?`${D}${ce.key}=${ce.value}`:D),""),f=window.open(s,r,`popup, ${ae}`);if(!f)throw new Error("Failed to open guest application in popup window");f.opener=null,y=n(this,re).call(this,{guestId:h,window:f,title:r,url:s,searchParams:a,openMode:S.Popup})}return y}),u(this,je,t=>{const{url:s,title:r,targetElement:c,searchParams:a,guestId:h,options:g={}}=t,p=c.ownerDocument??document,{fitToContent:m=!1,disableSandbox:E=!1,sandboxValues:y=[],style:ae=""}=g;if(!r)throw new Error("title is required");m&&n(this,Me).call(this);const f=p.createElement("iframe");f.setAttribute("id",h),f.addEventListener("load",()=>{n(this,d).debug(`frame loaded for guest with id '${h}'`)}),f.setAttribute("style",`min-width: 100%; height: 100%; border: 0px; ${ae}`),E||f.setAttribute("sandbox",`${pt} ${y.join(" ")}`),f.setAttribute("title",r),f.setAttribute("src",s),c.appendChild(f);const D=p.getElementById(h);return n(this,re).call(this,{guestId:h,domElement:D,window:D.contentWindow,title:r,url:s,searchParams:a,openMode:S.Embed})}),u(this,Pe,(t,s)=>{let r="";return Object.keys(s).forEach(c=>{r+=`${(r.length?"&":"")+encodeURIComponent(c)}=${encodeURIComponent(s[c])}`}),t+(r?(t.indexOf("?")>=0?"&":"?")+r:"")}),M(this,"addScriptingObject",t=>{if(!t?.id||!t?._toJSON)throw new Error("Object is not derived from ScriptingObject");if(t.id.toLowerCase()==="module")throw new Error("Do not publish the module object. Create a concrete object derived from it.");n(this,q).set(t.id,t)}),M(this,"cloneScriptingObject",(t,s)=>{if(!t)throw new Error("proxy is required");if(!s)throw new Error("guest is required");const r=new Ce(t.id,t.objectType);let c=[];return Object.keys(t).forEach(a=>{const h=t[a];if(n(this,Se).call(this,h)){const g=new P({name:h.name,requiresFeedback:!1,so:r});Object.defineProperty(r,a,{value:g,enumerable:!0});const p=({eventParams:E,eventOptions:y})=>this.dispatchEvent({event:g,eventParams:E,eventOptions:y}),m=s.subscribe({eventId:h.id,callback:p});c.push(()=>{s.unsubscribe({eventId:h.id,token:m})})}else if(Re(h)&&(Object.defineProperty(r,a,{value:async(...g)=>{const p=await h(...g);return et(p)?this.cloneScriptingObject(p,s):p},enumerable:!0}),a==="dispose")){const g=r.dispose;Object.defineProperty(r,a,{value:()=>(r._dispose(),g.apply(r)),enumerable:!0})}}),r._dispose=()=>{c.forEach(a=>{a?.()}),c=[]},r}),M(this,"close",()=>{clearInterval(n(this,te)),n(this,v).close(),window.removeEventListener("visibilitychange",n(this,ie)),n(this,d).debug(`host is closed. hostId: ${this.hostId}, correlationId: ${n(this,N)}`)}),M(this,"dispatchEvent",async t=>{const{event:{id:s,name:r,scriptingObject:c},eventParams:a,eventOptions:h={}}=t,{eventHandler:g=null,timeout:p=null,window:m=null}=h,E={object:c._toJSON(),eventName:r,eventParams:a,eventHandler:g,eventOptions:{allowsFeedback:!1}};p&&!Number.isNaN(p)&&(E.eventOptions={allowsFeedback:!0,timeout:Number(p)});const y=[];return n(this,I).forEach(f=>{(!m||m===f.window)&&(p&&f?.capabilities?.eventFeedback?(y.push(f.dispatchEvent(E,p)),n(this,d).audit({message:"Event dispatched and awaiting feedback",scriptingEventId:s,...f.getInfo()})):(f.send({messageType:O.ObjectEvent,messageBody:E}),n(this,d).audit({message:"Event dispatched",scriptingEventId:s,...f.getInfo()})))}),await Promise.all(y).then(f=>(n(this,d).audit({message:"Event feedback received",scriptingEventId:s}),qe(f))).catch(f=>{throw n(this,d).error({message:"Error processing event",eventId:s,exception:f}),f})}),M(this,"getGuests",()=>{const t=[];return n(this,I).forEach(s=>{t.push(s)}),t}),M(this,"getScriptingObject",t=>n(this,q).has(t)?n(this,q).get(t):null),M(this,"loadGuest",t=>{const{url:s,targetElement:r,title:c,searchParams:a={},options:h={}}=t,{openMode:g=S.Embed,popupWindowFeatures:p={}}=h,m=`guest-${this.hostId}-sandbox-${n(this,K)}`;z(this,K,n(this,K)+1);const E=n(this,Pe).call(this,s,a);let y=null;if(g===S.Popup)y=n(this,We).call(this,{guestId:m,url:E,title:c,searchParams:a,popupWindowFeatures:p});else if(g===S.Embed)y=n(this,je).call(this,{guestId:m,url:E,title:c,targetElement:r,searchParams:a,options:h});else throw new Error(`Invalid openMode: ${g}`);return n(this,d).audit({message:"Guest loaded",...y.getInfo()}),y}),M(this,"loadGuests",t=>{const{url:s,targetElement:r,title:c,searchParamsList:a=[],options:h={}}=t;a.forEach(g=>{this.loadGuest({url:s,title:c,targetElement:r,searchParams:g,options:h})},this)}),M(this,"removeAllScriptingObjects",()=>{Array.from(n(this,q).keys()).forEach(s=>{this.removeScriptingObject(s)})}),M(this,"removeScriptingObject",t=>{const s=this.getScriptingObject(t);s&&(s._dispose&&typeof s._dispose=="function"&&s._dispose(),n(this,q).delete(t))}),M(this,"setLogLevel",t=>{n(this,d).setLogLevel(t),n(this,I).forEach(n(this,ne)),n(this,d).debug("Dispatched config events to all guests")}),M(this,"unloadGuest",t=>{let s=typeof t=="string"?n(this,I).get(t):null;if(!s&&(s=Array.from(n(this,I).values()).find(r=>r.window===t||r.domElement===t),!s))throw new Error("Invalid guestId or guestWindow reference");s.dispose(),n(this,I).delete(s.id),n(this,d).audit({message:"Guest is removed from host",...s.getInfo()})}),this.hostId=i,!o?.logger)throw new Error("Logger is required");if(z(this,d,o.logger),z(this,N,Ne()),z(this,v,new ht(n(this,d),n(this,N))),o?.readyStateCallback&&typeof o?.readyStateCallback!="function")throw new Error("readyStateCallback must be a function");z(this,ee,o?.readyStateCallback||null),n(this,v).initialize(window),n(this,Ie).call(this),n(this,$e).call(this),n(this,d).debug(`host is initialized. hostId: ${this.hostId}, correlationId: ${n(this,N)}`)}}return v=new WeakMap,N=new WeakMap,d=new WeakMap,K=new WeakMap,I=new WeakMap,q=new WeakMap,ee=new WeakMap,te=new WeakMap,ie=new WeakMap,R=new WeakMap,fe=new WeakMap,ve=new WeakMap,se=new WeakMap,me=new WeakMap,ne=new WeakMap,be=new WeakMap,oe=new WeakMap,ye=new WeakMap,_e=new WeakMap,Ee=new WeakMap,ke=new WeakMap,Oe=new WeakMap,Me=new WeakMap,Ie=new WeakMap,Se=new WeakMap,re=new WeakMap,$e=new WeakMap,We=new WeakMap,je=new WeakMap,Pe=new WeakMap,T})());
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/umd/index.js.br
CHANGED
|
Binary file
|
package/dist/umd/index.js.gz
CHANGED
|
Binary file
|